Re: [virtualcommons-svn] SF.net SVN: virtualcommons:[188] mentalmodels/trunk
Status: Beta
Brought to you by:
alllee
From: seema t. <see...@gm...> - 2009-07-20 01:41:28
|
forgot to mention one more change and that is- Before enetring or updating the database, sequence number is checked, if sequence number exists, then error message is thrown. On Sun, Jul 19, 2009 at 6:13 PM, <see...@us...> wrote: > Revision: 188 > http://virtualcommons.svn.sourceforge.net/virtualcommons/?rev=188&view=revAuthor: seematalele Date: 2009-07-20 01:13:36 +0000 (Mon, 20 Jul 2009) Log > Message: ----------- Created HibernateCategoricalQuestionDao.java and > HibernatePsychometricQuestionDao.java. Changed the code of > InitialiseDatabase.mxml - Adding Module,Block,QuestionGroup and Question is > working fine. - Updating Module,Block,QuestionGroup is working fine. Need to > test updating Questions in InitialiseDatabase.mxml. (But I am not going to > test it until it really needs because it is taking some time) The init-mme > file contains the database which initialized till Module 2A - Block 2-4 > Commented the createQuestions in QuestionCreatorService.java and > StartupService.java Modified Paths: -------------- > mentalmodels/trunk/flex/src/InitialiseDatabase.mxml > mentalmodels/trunk/flex/src/actionscript/Block.as > mentalmodels/trunk/flex/src/actionscript/Module.as > mentalmodels/trunk/flex/src/actionscript/QuestionGroup.as > mentalmodels/trunk/flex/src/actionscript/questions/Question.as > mentalmodels/trunk/flex/src/custom/db/Block.mxml > mentalmodels/trunk/flex/src/custom/db/Module.mxml > mentalmodels/trunk/flex/src/custom/db/Question.mxml > mentalmodels/trunk/flex/src/custom/db/QuestionGroup.mxml > mentalmodels/trunk/flex/src/custom/db/questions/Categorical.mxml > mentalmodels/trunk/flex/src/custom/db/questions/CategoricalRelative.mxml > mentalmodels/trunk/flex/src/custom/db/questions/CategoricalSimple.mxml > mentalmodels/trunk/flex/src/custom/db/questions/Psychometric.mxml > mentalmodels/trunk/src/main/db/init-mme.sql > mentalmodels/trunk/src/main/java/edu/asu/commons/mme/entity/QuestionGroup.java > mentalmodels/trunk/src/main/java/edu/asu/commons/mme/entity/RoundConfig.java > mentalmodels/trunk/src/main/java/edu/asu/commons/mme/service/QuestionCreatorService.java > mentalmodels/trunk/src/main/java/edu/asu/commons/mme/service/StartupService.java > mentalmodels/trunk/src/main/webapp/WEB-INF/applicationContext.xml Added > Paths: ----------- > mentalmodels/trunk/src/main/java/edu/asu/commons/mme/dao/HibernateCategoricalQuestionDao.java > mentalmodels/trunk/src/main/java/edu/asu/commons/mme/dao/HibernatePsychometricQuestionDao.java > Modified: mentalmodels/trunk/flex/src/InitialiseDatabase.mxml > =================================================================== --- > mentalmodels/trunk/flex/src/InitialiseDatabase.mxml 2009-07-17 23:21:35 UTC > (rev 187) +++ mentalmodels/trunk/flex/src/InitialiseDatabase.mxml 2009-07-20 > 01:13:36 UTC (rev 188) @@ -5,11 +5,7 @@ - + /**** + * Sample exmaple of > Survey Questions structure + * - + - + - - - + @@ -60,56 +49,53 @@ - ; - > /*[Bindable] + + * + */ + +/* id field of module, block and questiongroup > and questions should come from database, +so when module info is transfered > to the server, it should return the id for that module */ + + + [Bindable] > private var survey:XML = - - ;*/ + + + ; - - /*[Bindable] - private var > questions:XML = - - - - - + /** + * Sample example of categorical question > structure + * + * + + - - - - + + + + + - - - - - ; */ - - - [Bindable] + * > + * ***/ + + [Bindable] private var categoricalQuestions:XML = - - - - - - - > - ; + /** + * Sample example of psychometric question structure + * + **/ + > [Bindable] private var psychometricQuestions:XML = - - - - + ; @@ -122,6 > +108,8 @@ public var tempQuestion:ArrayCollection = new ArrayCollection(); + > + private function init():void { roQuestionCreator.initializeData(); @@ > -148,7 +136,7 @@ survey.appendChild(newModuleNode); //if any blocks, add > into the module - if(module.blocks != null) + if(module.blocks != null) { > for(var blockCounter:int = 0; blockCounter < module.blocks.length; > blockCounter++) { @@ -181,9 +169,9 @@ } } - } + } + } } - } } } @@ -230,7 > +218,10 @@ newNode.@header = questionGroup.header; newNode.@description = > questionGroup.description; newNode.@sequenceNo = questionGroup.sequenceNo; > - newNode.@id = questionGroup.id; + newNode.@hours = > questionGroup.getHours(); + newNode.@min = questionGroup.getMinutes(); + > newNode.@sec = questionGroup.getSeconds(); + newNode.@id = > questionGroup.id; return newNode; @@ -240,33 +231,40 @@ { var newQNode:XML = > ; newQNode.setLocalName("question"); + var choices:String=""; > if(question.type.toLowerCase() == "psychometric") { var > psychometricResult:actionscript.questions.Psychometric = > actionscript.questions.Psychometric(question); - Alert.show("Id is: " + > psychometricResult.id); + /*Alert.show("Id is: " + psychometricResult.id); > Alert.show("Question is: " + psychometricResult.question); Alert.show("Type > is: " + psychometricResult.type); - Alert.show("SeQNo is: " + > psychometricResult.sequenceNo); + Alert.show("SeQNo is: " + > psychometricResult.sequenceNo);*/ var newPNode:XML = ; > newPNode.setLocalName("psychometric"); newPNode.@id = > psychometricResult.id; newPNode.@scale = psychometricResult.scale; - > newPNode.@noOfInterval = psychometricResult.maxSliderValue; + > newPNode.@maxSliderValue = psychometricResult.maxSliderValue; > newQNode.@sequenceNo = psychometricResult.sequenceNo; newQNode.@title = > psychometricResult.question; newQNode.@type = psychometricResult.type; > newQNode.@id = psychometricResult.id; - - for(var j:int = 0; j < > psychometricResult.choices.length; j++) - { - var str:String = "choice"; - > str = str + j; - newPNode.@str = psychometricResult.choices[j]; - } - + > choices = ""; + if(psychometricResult.choices != null) + { + + for(var k:int > = 0; k < psychometricResult.choices.length; k++) + { + choices = choices + > psychometricResult.choices[k]; + choices = choices + "," + + } + > //Alert.show("choices are: " + choices); + + newPNode.@choices = choices; > + } psychometricQuestions.appendChild(newPNode); } @@ -286,44 +284,60 @@ > currentState = "none"; btnsaveQuestion.enabled = false; }*/ + //false means > it is simple type, otherwise it is relative type + var flagType:Boolean = > false; var newCNode:XML = ; newCNode.setLocalName("categorical"); > newCNode.@id = categoricalResult.id; > categoricalQuestions.appendChild(newCNode); - - for(var i:int = 0; i < > categoricalResult.categoricalOptions.length ; i++) - { - var > options:actionscript.questions.CategoricalOption = new > actionscript.questions.CategoricalOption(); - options = > actionscript.questions.CategoricalOption(categoricalResult.categoricalOptions.getItemAt(i)); > - var newOptionNode:XML = ; - newOptionNode.setLocalName("option"); - > newOptionNode.@name = options.optionKey; - if(options.choices.length <= 0) > - { - newCNode.@type = "simple"; - - } - else - { - newCNode.@type = > "relative"; - for(var k:int = 0; k < options.choices.length; k++) + + > if(categoricalResult.categoricalOptions != null) + { + + for(var i:int = 0; > i < categoricalResult.categoricalOptions.length ; i++) + { + var > options:actionscript.questions.CategoricalOption = new > actionscript.questions.CategoricalOption(); + options = > actionscript.questions.CategoricalOption(categoricalResult.categoricalOptions.getItemAt(i)); > + var newOptionNode:XML = ; + newOptionNode.setLocalName("option"); + > newOptionNode.@name = options.optionKey; + if(options.choices.length == 0) > { - var choice:String = "choice"; - choice = choice + k; - > newOptionNode.@choice = options.choices[k]; + flagType = false } - } - - > /*var module:XMLList = survey.module.(@id == tempmodule.id); - if( > module.length() > 0 ) - { - module[0].appendChild(newBlockNode); - }*/ - > newCNode.appendChild(newOptionNode); - } - - + else + { + flagType = true; + > choices=""; + + for(k = 0; k < options.choices.length; k++) + { + choices = > choices + options.choices[k]; + choices = choices + "," + + } + > //Alert.show("choices are: " + choices); + + newOptionNode.@choices = > choices; + } + if(flagType) + newCNode.@type = "relative"; + else + > newCNode.@type = "simple"; + newCNode.appendChild(newOptionNode); + } + } > + + } + //if question type is strategy, day by day decision, forecasting > fish, forecasting fishermen + else + { + newQNode.@sequenceNo = > question.sequenceNo; + newQNode.@title = question.question; + > newQNode.@type = question.type; + newQNode.@id = question.id; + } return > newQNode; @@ -348,7 +362,7 @@ return node.@header; else if( > node.localName() == "question" ) - return node.@title; + return node.@type; > else return null; @@ -419,16 +433,43 @@ { var title:String = > moduleInfo.getName(); var seqNo:int = int(moduleInfo.getSequenceNo()); - > if(moduleInfo.getId() == 0) - { - roQuestionCreator.saveModule(seqNo, title, > getDuration(moduleInfo.getHours(),moduleInfo.getMinutes(),moduleInfo.getSeconds())); > + + /* check first Id if the module exists, + if no, then check if sequence > number already exists for other module, + if no then create module otherwise > throw error */ + + var checkSeqNoModule:XMLList = survey.module.(@sequenceNo > == moduleInfo.getSequenceNo()); + + /* check if new module needs to be > created, if yes, check if the sequence number is already exists + if "No" > then only save into the database */ + + if(moduleInfo.getId() == 0) + { + > if(checkSeqNoModule.length() > 0) + { + Alert.show("Sequence number : " + > seqNo + " already exists!"); + } + else + > roQuestionCreator.saveModule(seqNo, title, > getDuration(moduleInfo.getHours(),moduleInfo.getMinutes(),moduleInfo.getSeconds())); > + } + + else + { + //Alert.show("length : " + > checkSeqNoModule.length().toString()); + //check if the sequence number > exists, do not update the module + + if(checkSeqNoModule.length() > 1) + { + > Alert.show("Sequence number : " + seqNo + " already exists!"); + } + else + > roQuestionCreator.updateModule(moduleInfo.getId(),seqNo, title, > getDuration(moduleInfo.getHours(),moduleInfo.getMinutes(),moduleInfo.getSeconds())); > + } - else - roQuestionCreator.updateModule(moduleInfo.getId(),seqNo, title, > getDuration(moduleInfo.getHours(),moduleInfo.getMinutes(),moduleInfo.getSeconds())); > - currentState = "none"; + + currentState = "none"; btnsaveModule.enabled = > false; - //pnlComponent.removeChildAt(1); - } + } } else @@ -447,35 +488,35 > @@ public function resultSaveModuleHandler(event:ResultEvent):void { var > module:actionscript.Module = actionscript.Module(event.result as Object); - > Alert.show("Id is: " + module.id); - var newModuleNode:XML = ; - > newModuleNode.setLocalName("module"); - newModuleNode.@title= > module.description; - newModuleNode.@sequenceNo = module.sequenceNo; - > newModuleNode.@hours = module.getHours(); - newModuleNode.@min = > module.getMinutes(); - newModuleNode.@sec = module.getSeconds(); - > newModuleNode.@id = module.id; - survey.appendChild(newModuleNode); - > if(surveyData == null) + + if(module == null) { - surveyData= new > XMLListCollection(survey.module); + Alert.show("Error in creating module!"); > } + else + { + //Alert.show("Id is: " + module.id); + var > newModuleNode:XML = createModuleNode(module); + > survey.appendChild(newModuleNode); + } - - } //when module is updated, the > result will come to resultUpdateModuleHandler public function > resultUpdateModuleHandler(event:ResultEvent):void { var > module:actionscript.Module = actionscript.Module(event.result as Object); - > var moduleXML:XMLList = survey.module.(@id == module.id); - > moduleXML.@title = module.description; - moduleXML.@sequenceNo = > module.sequenceNo; - moduleXML.@hours = module.getHours(); - > moduleXML.@min = module.getMinutes(); - moduleXML.@sec = > module.getSeconds(); + if(module != null) + { + var moduleXML:XMLList = > survey.module.(@id == module.id); + moduleXML.@title = module.description; > + moduleXML.@sequenceNo = module.sequenceNo; + moduleXML.@hours = > module.getHours(); + moduleXML.@min = module.getMinutes(); + > moduleXML.@sec = module.getSeconds(); + } + else + Alert.show("Error in > updating module!"); } @@ -535,25 +576,42 @@ var parentNode:XML = > tree.getParentItem(tree.selectedItem) as XML; node = parentNode; } - var > module:XMLList = survey.module.(@title == node.@title); - > //Alert.show("Module length is : " + module.length()); + var module:XMLList > = survey.module.(@id == node.@id); + if( module.length() > 0 ) { - // > Alert.show("Block id is : " + blockInfo.getId()); - if(blockInfo.getId() == > 0) - { - > roQuestionCreator.saveBlock(int(blockInfo.getSequenceNo()),blockInfo.getName(),getDuration(blockInfo.getHours(),blockInfo.getMinutes(),blockInfo.getSeconds()),int(module[0].@id)); > - } - else - { - roQuestionCreator.updateBlock(blockInfo.getId(), > int(blockInfo.getSequenceNo()),blockInfo.getName(),getDuration(blockInfo.getHours(),blockInfo.getMinutes(),blockInfo.getSeconds()),int(module[0].@id)); > + + //check the sequence number first, if sequence number already exists > throw an error, otherwise create block + var checkSeqNoBlock:XMLList = > module.block.(@sequenceNo == blockInfo.getSequenceNo()); + > if(blockInfo.getId() == 0) + { + if(checkSeqNoBlock.length() > 0) + { + > Alert.show("Sequence number " + blockInfo.getSequenceNo() + " already > exists!"); + } + else + { + > roQuestionCreator.saveBlock(int(blockInfo.getSequenceNo()),blockInfo.getName(),getDuration(blockInfo.getHours(),blockInfo.getMinutes(),blockInfo.getSeconds()),int(module[0].@id)); > + } + } + else + { + //Alert.show("length : " + > checkSeqNoBlock.length().toString()); + //check if the sequence number > exists, do not update the module + if(checkSeqNoBlock.length() > 1) + { + > Alert.show("Sequence number : " + blockInfo.getSequenceNo() + " already > exists!"); + } + else + roQuestionCreator.updateBlock(blockInfo.getId(), > int(blockInfo.getSequenceNo()),blockInfo.getName(),getDuration(blockInfo.getHours(),blockInfo.getMinutes(),blockInfo.getSeconds()),int(module[0].@id)); > + } + + currentState = "none"; + btnsaveBlock.enabled = false; } - > currentState = "none"; - btnsaveBlock.enabled = false; - // > pnlComponent.removeChildAt(1); - } + } } - } + else { Alert.show("Please > fill the form correctly"); @@ -570,14 +628,7 @@ if(block != null) { - var > newBlockNode:XML = ; - newBlockNode.setLocalName("block"); - > newBlockNode.@name = block.description; - newBlockNode.@sequenceNo = > block.sequenceNo; - newBlockNode.@hours = block.getHours(); - > newBlockNode.@min = block.getMinutes(); - newBlockNode.@sec = > block.getSeconds(); - newBlockNode.@id = block.id; + var newBlockNode:XML > = createBlockNode(block); var tempmodule:actionscript.Module = block.module; > var module:XMLList = survey.module.(@id == tempmodule.id); @@ -585,7 > +636,9 @@ { module[0].appendChild(newBlockNode); } - } + } + else + > Alert.show("Error in creating Block!"); } @@ -593,19 +646,24 @@ public > function resultUpdateBlockHandler(event:ResultEvent):void { var > block:actionscript.Block = actionscript.Block(event.result as Object); - - > var tempmodule:actionscript.Module = block.module; - - var blockXML:XMLList > = survey.module.block.(@id == block.id); - - blockXML.@name = > block.description; - blockXML.@sequenceNo = block.sequenceNo; - > blockXML.@hours = block.getHours(); - blockXML.@min = block.getMinutes(); > - blockXML.@sec = block.getSeconds(); + if(block != null) + { + var > tempmodule:actionscript.Module = block.module; + var blockXML:XMLList = > survey.module.block.(@id == block.id); + if(blockXML.length() > 0) + { + > blockXML[0].@name = block.description; + blockXML[0].@sequenceNo = > block.sequenceNo; + blockXML[0].@hours = block.getHours(); + > blockXML[0].@min = block.getMinutes(); + blockXML[0].@sec = > block.getSeconds(); + } + } + else + Alert.show("Error in creating Block!"); > } - //Block functioanlity Stop + //Block functioanlity End //QuestionGroup > functionality Start @@ -629,7 +687,7 @@ var selectedNode:XML = > tree.selectedItem as XML; var obj:DisplayObject = > pnlComponent.getChildAt(1); var questionGroupInfo:custom.db.QuestionGroup = > custom.db.QuestionGroup(obj); - Alert.show("Question Group Id is: " + > questionGroupInfo.getId()); + if(tree.selectedItem == null) { > Alert.show("Please select the block from tree to which Question Group should > be added."); @@ -656,12 +714,18 @@ { //find out the parent module var > parentModule:XML = tree.getParentItem(tree.selectedItem) as XML; - - + var > isQuestionGroupFormValid:Boolean = questionGroupInfo.validateForm(event); > if(isQuestionGroupFormValid) { + var durationflag:Boolean = > this.isDurationValid(questionGroupInfo.getHours(),questionGroupInfo.getMinutes(),questionGroupInfo.getSeconds()); > + if(durationflag) + { + Alert.show("Please enter the valid duration for the > given module."); + } + else + { var node:XML; /** * Check if the selected > node is block, if it is new Question Group needs to be created. @@ -677,22 > +741,46 @@ node = parentNode; } var block:XMLList = survey.module.block.(@id > == node.@id); - //Alert.show("block id is : " + block[0].@id + "length is: > " + block.length()); + //Alert.show("block id is : " + block.@id + "length > is: " + block.length().toString()); if( block.length() > 0 ) { - > if(questionGroupInfo.getId() == 0) - { - > roQuestionCreator.saveQuestionGroup(int(questionGroupInfo.getSequenceNo()),questionGroupInfo.getHeader(),questionGroupInfo.getDescription(),int(block[0].@id)); > - } - else - { - > roQuestionCreator.updateQuestionGroup(int(questionGroupInfo.getSequenceNo()),questionGroupInfo.getHeader(),questionGroupInfo.getDescription(),int(block[0].@id),questionGroup.getId()); > + //check the sequence number first, if sequence number already exists throw > an error, otherwise create module + var checkSeqNoQuestionGroup:XMLList = > block.questiongroup.(@sequenceNo == questionGroupInfo.getSequenceNo()); + > //Alert.show("length : " + checkSeqNoQuestionGroup.length().toString()); + > if(questionGroupInfo.getId() == 0) + { + if(checkSeqNoQuestionGroup.length() > > 0) + { + Alert.show("Sequence number " + questionGroupInfo.getSequenceNo() > + " already exists!"); + } + else + { + > roQuestionCreator.saveQuestionGroup(int(questionGroupInfo.getSequenceNo()),questionGroupInfo.getHeader(),questionGroupInfo.getDescription(),getDuration(questionGroupInfo.getHours(),questionGroupInfo.getMinutes(),questionGroupInfo.getSeconds()),int(block[0].@id)); > + } + } + else + { + //Alert.show("length : " + > checkSeqNoQuestionGroup.length().toString()); + //check if the sequence > number exists, do not update the module + > if(checkSeqNoQuestionGroup.length() > 1) + { + Alert.show("Sequence number : > " + questionGroupInfo.getSequenceNo() + " already exists!"); + } + else + > roQuestionCreator.updateQuestionGroup(int(questionGroupInfo.getSequenceNo()),questionGroupInfo.getHeader(),questionGroupInfo.getDescription(),getDuration(questionGroupInfo.getHours(),questionGroupInfo.getMinutes(),questionGroupInfo.getSeconds()),int(block[0].@id),questionGroup.getId()); > + } - currentState = "none"; - btnsaveQuestionGroup.enabled = false; - > //pnlComponent.removeChildAt(1); - } - } + currentState = "none"; + > btnsaveQuestionGroup.enabled = false; + } + + } + } + else + { + > Alert.show("Please fill the form correctly"); + return; + } } } } @@ -702,23 > +790,23 @@ public function > resultSaveQuestionGroupHandler(event:ResultEvent):void { var > questionGroup:actionscript.QuestionGroup = > actionscript.QuestionGroup(event.result as Object); - Alert.show("Id is: " + > questionGroup.id); - var newNode:XML = ; - > newNode.setLocalName("questiongroup"); - newNode.@header = > questionGroup.header; - newNode.@description = questionGroup.description; > - newNode.@sequenceNo = questionGroup.sequenceNo; - newNode.@id = > questionGroup.id; - - var block:actionscript.Block = questionGroup.block; + > + if(questionGroup != null) + { + var newQuestionGroupNode:XML = > createQuestionGroupNode(questionGroup); + + var block:actionscript.Block = > questionGroup.block; - var blockXML:XMLList =survey.module.block.(@id == > block.id); + var blockXML:XMLList =survey.module.block.(@id == block.id); > - if( blockXML.length() > 0 ) - { - blockXML[0].appendChild(newNode); + if( > blockXML.length() > 0 ) + { + blockXML[0].appendChild(newQuestionGroupNode); > - } + } + } + else + Alert.show("Error in creating QuestionGroup!"); } @@ > -726,17 +814,34 @@ public function > resultUpdateQuestionGroupHandler(event:ResultEvent):void { var > questionGroup:actionscript.QuestionGroup = > actionscript.QuestionGroup(event.result as Object); - Alert.show("Id is: " + > questionGroup.id); - var newNode:XML = ; - > newNode.setLocalName("questiongroup"); - newNode.@header = > questionGroup.header; - newNode.@description = questionGroup.description; > - newNode.@sequenceNo = questionGroup.sequenceNo; - var > block:actionscript.Block = questionGroup.block; - - } + + //Alert.show("Id > is: " + questionGroup.id); + if(questionGroup != null) + { + var newNode:XML > = ; + newNode.setLocalName("questiongroup"); + var questionGroupXML:XMLList > = survey.module.block.questiongroup.(@id == questionGroup.id); + > //Alert.show("Length is: " + questionGroupXML.length()); + > if(questionGroupXML.length() > 0) + { + // Alert.show("header is :" + > questionGroup.header); + // Alert.show("questionGroup description is :" + > questionGroup.description); + //Alert.show("questionGroup.sequenceNo is :" + > questionGroup.sequenceNo); + + questionGroupXML[0].@header = > questionGroup.header; + questionGroupXML[0].@description = > questionGroup.description; + questionGroupXML[0].@sequenceNo = > questionGroup.sequenceNo; + questionGroupXML[0].@hours = > questionGroup.getHours(); + questionGroupXML[0].@min = > questionGroup.getMinutes(); + questionGroupXML[0].@sec = > questionGroup.getSeconds(); + + } + } + else + Alert.show("Error in updating > QuestionGroup!"); + } - //QuestionGroup functionality Stop + //QuestionGroup > functionality End //Question functionality Start @@ -755,26 +860,43 @@ > private function QuestionHandler(event:Event):void { - > if(question.cmbType.selectedItem.toString().toLowerCase() == "psychometric") > + if(question.cmbType.selectedItem.data.toString().toLowerCase() == > "psychometric") + { currentState = "psychometric"; - else > if(question.cmbType.selectedItem.toString().toLowerCase() == "categorical") > + psychometric.reset(); + } + else > if(question.cmbType.selectedItem.data.toString().toLowerCase() == > "categorical") + { currentState = "categorical"; + categorical.reset(); + } > + else + { + currentState = "question"; + + } } private function > CategoricalTypeHandler(event:Event):void { > if(categorical.cmbType.selectedItem.toString().toLowerCase() == "relative") > + { currentState = "relative"; + categoricalRelative.reset(); + } else > if(categorical.cmbType.selectedItem.toString().toLowerCase() == "simple") + > { currentState = "simple"; + categoricalSimple.reset(); + } + } - - private > function saveQuestion(event:Event):void { - var node:XML = tree.selectedItem > as XML; + var selectedNode:XML = tree.selectedItem as XML; + var node:XML; > if(tree.selectedItem == null) { @@ -783,109 +905,207 @@ } else { - - > //if(tree.getParentItem(tree.selectedItem) == null) - if(node.localName() != > "questiongroup") + if(selectedNode.localName().toString().toLowerCase() == > "module" || selectedNode.localName().toString().toLowerCase() == "block") { > - Alert.show("You can add Question to QuestionGroup only."); + > Alert.show("You can not add Question to Module or Block."); return; } else { > - //find out the parent module - var parentModule:XML = > tree.getParentItem(tree.selectedItem) as XML; + > if(selectedNode.localName().toString().toLowerCase() == "questiongroup") + { > + node = selectedNode; + } + else > if(selectedNode.localName().toString().toLowerCase() == "question") + { + > var parentNode:XML = tree.getParentItem(tree.selectedItem) as XML; + node = > parentNode; + } + + var obj:DisplayObject = pnlComponent.getChildAt(1); var > questionInfo:custom.db.Question = custom.db.Question(obj); - var > isQuestionGroupFormValid:Boolean = questionInfo.validateForm(event); + var > isQuestionFormValid:Boolean = questionInfo.validateForm(event); - > if(isQuestionGroupFormValid) + if(isQuestionFormValid) { - - if(currentState > == "psychometric") - { - var psychobj:DisplayObject = > pnlComponent.getChildAt(2); - - var > compPsychometric:custom.db.questions.Psychometric = > custom.db.questions.Psychometric(psychobj); - - var > asPsychometric:actionscript.questions.Psychometric = new > actionscript.questions.Psychometric(); - asPsychometric.scale = > compPsychometric.getScale(); - asPsychometric.maxSliderValue = > int(compPsychometric.getNumberofIntervals()); - asPsychometric.choices = > compPsychometric.getChoices(); - asPsychometric.question = > questionInfo.getQuestion(); - asPsychometric.sequenceNo = > int(questionInfo.getSequenceNo()); - asPsychometric.type = > questionInfo.getType(); - - Alert.show("Psychometric Object :"); - > Alert.show("Question: " + asPsychometric.question); - Alert.show("SeQ No: " > + asPsychometric.sequenceNo); - Alert.show("Type : " + asPsychometric.type); > - roQuestionCreator.saveQuestion(asPsychometric,1); - } - else > if(currentState == "relative") - { - var catobj:DisplayObject = > pnlComponent.getChildAt(3); - var compCategorical:CategoricalRelative = > CategoricalRelative(catobj); - var > categoricalQuestion:actionscript.questions.Categorical = new > actionscript.questions.Categorical(); - - var dict:Dictionary = new > Dictionary(); - dict = compCategorical.getDictionary(); - for (var > key:Object in dict) - { - var > Options:actionscript.questions.CategoricalOption = new > actionscript.questions.CategoricalOption(); - Options.optionKey = > key.toString(); - Options.choices = dict[key]; - > categoricalQuestion.categoricalOptions.addItem(Options); - } - > categoricalQuestion.type = questionInfo.getType(); - > categoricalQuestion.question = questionInfo.getQuestion(); - > categoricalQuestion.sequenceNo = int(questionInfo.getSequenceNo()); - > for(var i:int = 0; i < categoricalQuestion.categoricalOptions.length ; i++) > - { - var testoption:actionscript.questions.CategoricalOption = new > actionscript.questions.CategoricalOption(); - testoption = > actionscript.questions.CategoricalOption(categoricalQuestion.categoricalOptions.getItemAt(i)); > - trace(testoption.optionKey); - trace(testoption.choices); - } - > roQuestionCreator.saveQuestion(categoricalQuestion,1); - - } - else > if(currentState == "simple") - { - Alert.show("simple state"); - var > catSimpleobj:DisplayObject = pnlComponent.getChildAt(3); - var > compCategoricalSimple:custom.db.questions.CategoricalSimple = > custom.db.questions.CategoricalSimple(catSimpleobj); - var > categoricalSimpleQuestion:actionscript.questions.Categorical = new > actionscript.questions.Categorical(); - + Alert.show("Parent id: " + > node.@id); + //check the sequence number first, if sequence number already > exists throw an error, otherwise create Question + + var > questionGroup:XMLList = survey.module.block.questiongroup.(@id == node.@id); > + Alert.show("Parent children length: " + > questionGroup.children().length()); + if(questionGroup.length() > 0 ) + { + > var checkSeqNoQuestion:XMLList = questionGroup.question.(@sequenceNo == > questionInfo.getSequenceNo()); + Alert.show("checkSeqNoQuestion length: " + > checkSeqNoQuestion.length()); + if(currentState == "psychometric") + { + var > psychobj:DisplayObject = pnlComponent.getChildAt(2); + + var > compPsychometric:custom.db.questions.Psychometric = > custom.db.questions.Psychometric(psychobj); + + var > asPsychometric:actionscript.questions.Psychometric = new > actionscript.questions.Psychometric(); + asPsychometric.scale = > compPsychometric.getScale(); + asPsychometric.maxSliderValue = > int(compPsychometric.getNumberofIntervals()); + asPsychometric.choices = > compPsychometric.getChoices(); + asPsychometric.question = > questionInfo.getQuestion(); + asPsychometric.sequenceNo = > int(questionInfo.getSequenceNo()); + asPsychometric.type = > questionInfo.getType(); + + //Alert.show("Psychometric Object :"); + > //Alert.show("Question: " + asPsychometric.question); + //Alert.show("SeQ > No: " + asPsychometric.sequenceNo); + //Alert.show("Type : " + > asPsychometric.type); + + if(questionInfo.getId() == 0) + { + > if(checkSeqNoQuestion.length() > 0) + { + Alert.show("Sequence number " + > questionInfo.getSequenceNo() + " already exists!"); + } + else + > roQuestionCreator.saveQuestion(asPsychometric,int(node.@id)); + } + else + > { + if(checkSeqNoQuestion.length() > 1) + { + Alert.show("Sequence number " > + questionInfo.getSequenceNo() + " already exists!"); + } + else + > roQuestionCreator.updateQuestion(asPsychometric,int(node.@id), > questionInfo.getId()); + } + + } + + else if(currentState == "relative") + { > + var catobj:DisplayObject = pnlComponent.getChildAt(3); + var > compCategorical:CategoricalRelative = CategoricalRelative(catobj); + var > categoricalQuestion:actionscript.questions.Categorical = new > actionscript.questions.Categorical(); + + var dict:Dictionary = new > Dictionary(); + dict = compCategorical.getDictionary(); + for (var > key:Object in dict) + { + var > Options:actionscript.questions.CategoricalOption = new > actionscript.questions.CategoricalOption(); + Options.optionKey = > key.toString(); + Options.choices = dict[key]; + > categoricalQuestion.categoricalOptions.addItem(Options); + } + > categoricalQuestion.type = questionInfo.getType(); + > categoricalQuestion.question = questionInfo.getQuestion(); + > categoricalQuestion.sequenceNo = int(questionInfo.getSequenceNo()); + > /*for(var i:int = 0; i < categoricalQuestion.categoricalOptions.length ; > i++) + { + var testoption:actionscript.questions.CategoricalOption = new > actionscript.questions.CategoricalOption(); + testoption = > actionscript.questions.CategoricalOption(categoricalQuestion.categoricalOptions.getItemAt(i)); > + trace(testoption.optionKey); + trace(testoption.choices); + }*/ + > if(questionInfo.getId() == 0) + { + if(checkSeqNoQuestion.length() > 0) + { > + Alert.show("Sequence number " + questionInfo.getSequenceNo() + " already > exists!"); + } + else + > roQuestionCreator.saveQuestion(categoricalQuestion,int(node.@id)); + } + > else + { + if(checkSeqNoQuestion.length() > 1) + { + Alert.show("Sequence > number " + questionInfo.getSequenceNo() + " already exists!"); + } + else + > roQuestionCreator.updateQuestion(categoricalQuestion,int(node.@id), > questionInfo.getId()); + } + + } + else if(currentState == "simple") + { + > //Alert.show("simple state"); + var catSimpleobj:DisplayObject = > pnlComponent.getChildAt(3); + var > compCategoricalSimple:custom.db.questions.CategoricalSimple = > custom.db.questions.CategoricalSimple(catSimpleobj); + var > categoricalSimpleQuestion:actionscript.questions.Categorical = new > actionscript.questions.Categorical(); - var Simpledict:Dictionary = new > Dictionary(); - Simpledict = compCategoricalSimple.getDictionary(); - for > (var option:Object in Simpledict) - { - var > OptionsSimple:actionscript.questions.CategoricalOption = new > actionscript.questions.CategoricalOption(); - OptionsSimple.optionKey = > option.toString(); - Alert.show("Key : " + option.toString()); - > OptionsSimple.choices = Simpledict[key]; - > categoricalSimpleQuestion.categoricalOptions.addItem(OptionsSimple); - } - > categoricalSimpleQuestion.type = questionInfo.getType(); - > categoricalSimpleQuestion.question = questionInfo.getQuestion(); - > categoricalSimpleQuestion.sequenceNo = int(questionInfo.getSequenceNo()); - > /*for(var j:int = 0; j < categoricalSimpleQuestion.categoricalOptions.length > ; j++) - { - var testoption:ASCategoricalOption = new ASCategoricalOption(); > - testoption = > ASCategoricalOption(categoricalSimpleQuestion.categoricalOptions.getItemAt(i)); > - trace(testoption.optionKey); - trace(testoption.choices); - }*/ - > Alert.show("Question: " + categoricalSimpleQuestion.question); - > Alert.show("SeQ No: " + categoricalSimpleQuestion.sequenceNo); - > Alert.show("Type : " + categoricalSimpleQuestion.type); - - > roQuestionCreator.saveQuestion(categoricalSimpleQuestion,1); - - } - > //roQuestionCreator.saveQuestion(int(questionInfo.getSequenceNo()),questionInfo.getQuestion(),questionInfo.getType(),int(parentModule.@id)); > + var Simpledict:Dictionary = new Dictionary(); + Simpledict = > compCategoricalSimple.getDictionary(); + for (var option:Object in > Simpledict) + { + var OptionsSimple:actionscript.questions.CategoricalOption > = new actionscript.questions.CategoricalOption(); + OptionsSimple.optionKey > = option.toString(); + //Alert.show("Key : " + option.toString()); + > OptionsSimple.choices = Simpledict[key]; + > categoricalSimpleQuestion.categoricalOptions.addItem(OptionsSimple); + } + > categoricalSimpleQuestion.type = questionInfo.getType(); + > categoricalSimpleQuestion.question = questionInfo.getQuestion(); + > categoricalSimpleQuestion.sequenceNo = int(questionInfo.getSequenceNo()); + > /*for(var j:int = 0; j < categoricalSimpleQuestion.categoricalOptions.length > ; j++) + { + var testoption:ASCategoricalOption = new ASCategoricalOption(); > + testoption = > ASCategoricalOption(categoricalSimpleQuestion.categoricalOptions.getItemAt(i)); > + trace(testoption.optionKey); + trace(testoption.choices); + }*/ + > /*Alert.show("Question: " + categoricalSimpleQuestion.question); + > Alert.show("SeQ No: " + categoricalSimpleQuestion.sequenceNo); + > Alert.show("Type : " + categoricalSimpleQuestion.type);*/ + + + > if(questionInfo.getId() == 0) + { + if(checkSeqNoQuestion.length() > 0) + { > + Alert.show("Sequence number " + questionInfo.getSequenceNo() + " already > exists!"); + } + else + > roQuestionCreator.saveQuestion(categoricalSimpleQuestion,int(node.@id)); + > } + else + { + if(checkSeqNoQuestion.length() > 1) + { + > Alert.show("Sequence number " + questionInfo.getSequenceNo() + " already > exists!"); + } + else + > roQuestionCreator.updateQuestion(categoricalSimpleQuestion,int(node.@id), > questionInfo.getId()); + } + + } + else if(currentState == "question") + { + > + var question:actionscript.questions.Question = new > actionscript.questions.Question(); + + question.question = > questionInfo.getQuestion(); + question.sequenceNo = > int(questionInfo.getSequenceNo()); + question.type = questionInfo.getType(); > + //Alert.show("Type : " + question.type); + if(questionInfo.getId() == 0) + > { + if(checkSeqNoQuestion.length() > 0) + { + Alert.show("Sequence number " > + questionInfo.getSequenceNo() + " already exists!"); + } + else + > roQuestionCreator.saveQuestion(question,int(node.@id)); + } + else + { + > if(checkSeqNoQuestion.length() > 1) + { + Alert.show("Sequence number " + > questionInfo.getSequenceNo() + " already exists!"); + } + else + > roQuestionCreator.updateQuestion(question,int(node.@id), > questionInfo.getId()); + } + + } + } } @@ -896,96 +1116,142 @@ public > function resultSaveQuestionHandler(event:ResultEvent):void { - var > test_object:Object = event.result as Object; - Alert.show("Type came from > server is: " + test_object.type); - if(test_object.type == "psychometric") + > var question_Object:actionscript.questions.Question = > actionscript.questions.Question(event.result as Object); + > if(question_Object != null) { - var > questionResult:actionscript.questions.Psychometric = > actionscript.questions.Psychometric(event.result as Object); - > Alert.show("Id is: " + questionResult.id); - Alert.show("Question is: " + > questionResult.question); - Alert.show("Type is: " + questionResult.type); - > Alert.show("SeQNo is: " + questionResult.sequenceNo); + var > newQuestionNode:XML = createQuestionNode(question_Object); + Alert.show(" > question_Object.questionGroup.id " + question_Object.questionGroup.id); + > var questionGroup:XMLList = survey.module.block.questiongroup.(@id == > question_Object.questionGroup.id); + > Alert.show("question_Object.questionGroup.length " + > questionGroup.length()); + if( questionGroup.length() > 0 ) + { + > questionGroup[0].appendChild(newQuestionNode); + currentState = "none"; + > btnsaveQuestion.enabled = false; + } + } + else + Alert.show("Error in > creating Question!"); + + + } + + public function > resultUpdateQuestionHandler(event:ResultEvent):void + { + var > question:actionscript.questions.Question = > actionscript.questions.Question(event.result as Object); + if(question == > null) + { + Alert.show("Error in creating Question!"); + } + else + { + var > newNode:XML = ; + newNode.setLocalName("question"); + var newQNode:XML = ; + > newQNode.setLocalName("question"); + var choices:String=""; + > if(question.type.toLowerCase() == "psychometric") + { + var > psychometricResult:actionscript.questions.Psychometric = > actionscript.questions.Psychometric(question); + /*Alert.show("Id is: " + > psychometricResult.id); + Alert.show("Question is: " + > psychometricResult.question); + Alert.show("Type is: " + > psychometricResult.type); + Alert.show("SeQNo is: " + > psychometricResult.sequenceNo);*/ + var newPNode:XML = ; > newPNode.setLocalName("psychometric"); - newPNode.@id = questionResult.id; > - newPNode.@scale = questionResult.scale; - newPNode.@noOfInterval = > questionResult.maxSliderValue; - for(var j:int = 0; j < > questionResult.choices.length; j++) + var psychometricList:XMLList = > psychometricQuestions.psychometric.(@id == psychometricResult.id); + + if( > psychometricList.length() > 0 ) { - var str:String = "choice"; - str = str + > j; - newPNode.@str = questionResult.choices[j]; + newPNode.@scale = > psychometricResult.scale; + newPNode.@maxSliderValue = > psychometricResult.maxSliderValue; + + newQNode.@sequenceNo = > psychometricResult.sequenceNo; + newQNode.@title = > psychometricResult.question; + newQNode.@type = psychometricResult.type; + > choices = ""; + if(psychometricResult.choices != null) + { + + for(var k:int > = 0; k < psychometricResult.choices.length; k++) + { + choices = choices + > psychometricResult.choices[k]; + choices = choices + "," + + } + + > newPNode.@choices = choices; + } + } - - > psychometricQuestions.appendChild(newPNode); - + } - else > if(test_object.type.toLowerCase() == "categorical") + else > if(question.type.toLowerCase() == "categorical") { - var > categoricalResult:actionscript.questions.Categorical = > actionscript.questions.Categorical(test_object); - var newQNode:XML = ; - > newQNode.setLocalName("question"); + var > categoricalResult:actionscript.questions.Categorical = > actionscript.questions.Categorical(question); + newQNode.@sequenceNo = > categoricalResult.sequenceNo; newQNode.@title = > categoricalResult.question; newQNode.@type = categoricalResult.type; > newQNode.@id = categoricalResult.id; - var questionGroup:XMLList > =survey.module.block.questiongroup.(@header == node.@header); - - if( > questionGroup.length() > 0 ) - { - questionGroup[0].appendChild(newQNode); - > currentState = "none"; - btnsaveQuestion.enabled = false; - } + + //flagType > false means it is simple type, otherwise it is relative type + var > flagType:Boolean = false; var newCNode:XML = ; > newCNode.setLocalName("categorical"); - newCNode.@id = > categoricalResult.id; - categoricalQuestions.appendChild(newCNode); - - > for(var i:int = 0; i < categoricalResult.categoricalOptions.length ; i++) - > { - var options:actionscript.questions.CategoricalOption = new > actionscript.questions.CategoricalOption(); - options = > actionscript.questions.CategoricalOption(categoricalResult.categoricalOptions.getItemAt(i)); > - var newOptionNode:XML = ; - newOptionNode.setLocalName("option"); - > newOptionNode.@name = options.optionKey; - if(options.choices.length <= 0) > - { - newCNode.@type = "simple"; - - } - else - { - newCNode.@type = > "relative"; - for(var k:int = 0; k < options.choices.length; k++) - { - var > choice:String = "choice"; - choice = choice + k; - newOptionNode.@choice = > options.choices[k]; - } - } - - /*var module:XMLList = survey.module.(@id == > tempmodule.id); - if( module.length() > 0 ) - { - > module[0].appendChild(newBlockNode); - }*/ - > newCNode.appendChild(newOptionNode); - } + var categoricalList:XMLList = > categoricalQuestions.categorical.(@id == categoricalResult.id); - } - - > currentState = "none"; - btnsaveQuestion.enabled = false; - - - } - - public > function resultUpdateQuestionHandler(event:Event):void - { + if( > categoricalList.length() > 0 ) + { + //remove all the tags and then add > those rather than modifying those. It is simple. + var children:XMLList = > categoricalList.children(); + + for(var l:Number=0; l < children.length(); > l++) + { + delete children[i]; + } + + + > if(categoricalResult.categoricalOptions != null) + { + + for(var i:int = 0; > i < categoricalResult.categoricalOptions.length ; i++) + { + var > options:actionscript.questions.CategoricalOption = new > actionscript.questions.CategoricalOption(); + options = > actionscript.questions.CategoricalOption(categoricalResult.categoricalOptions.getItemAt(i)); > + var newOptionNode:XML = ; + newOptionNode.setLocalName("option"); + > newOptionNode.@name = options.optionKey; + if(options.choices.length == 0) > + { + flagType = false + } + else + { + flagType = true; + choices=""; + + > for(k = 0; k < options.choices.length; k++) + { + choices = choices + > options.choices[k]; + choices = choices + "," + } + newOptionNode.@choices= choices; + } + if(flagType) + newCNode.@type= "relative"; + else + newCNode.@type= "simple"; + newCNode.appendChild(newOptionNode); + } + } + } + } + } } > //Question functionality Stop @@ -1024,6 +1290,7 @@ var selectedNode:int; > var node:XML = XML(tree.selectedItem); + lbltest.text = node.@id; > if(node.localName() == "module") { currentState = "module"; @@ -1076,10 > +1343,15 @@ btnsaveQuestion.enabled = false; //set all fields + > questionGroupInfo.setHeader(node.@header); > questionGroupInfo.setDescription(node.@description); > questionGroupInfo.setSequenceNo(node.@sequenceNo); > questionGroupInfo.setId(node.@id); + > questionGroupInfo.setHours(node.@hours); + > questionGroupInfo.setMinutes(node.@min); + > questionGroupInfo.setSeconds(node.@sec); + //Alert.show("Question group id > assigned is: " + node.@id); } @@ -1100,9 +1372,12 @@ > questionInfo.setQuestion(node.@title); > questionInfo.setSequenceNo(node.@sequenceNo); questionInfo.setId(node.@id); > + var str:String = node.@type; + /*Alert.show("q type is: " + node.@type); > + questionInfo.cmbType.selectedItem = str.toLowerCase();*/ + > questionInfo.setQuestionType(node.@type); - if(node.@type == > "categorical") { currentState = "categorical"; @@ -1110,9 +1385,9 @@ var > compCategorical:custom.db.questions.Categorical = > custom.db.questions.Categorical(catobj); compCategorical.reset(); - > questionInfo.cmbType.selectedItem = "Categorical"; + > //questionInfo.cmbType.selectedItem = "Categorical"; var > categoricalQ:XMLList = categoricalQuestions.categorical.(@id == node.@id); > - + //Alert.show("categoricalQ type: " + categoricalQ[0].@type); > if(categoricalQ.length() > 0) { if(categoricalQ[0].@type == "relative") @@ > -1123,30 +1398,37 @@ var cat1obj:DisplayObject = pnlComponent.getChildAt(3); > var compRelative:CategoricalRelative = CategoricalRelative(cat1obj); - + > compRelative.reset(); var dict:Dictionary = new Dictionary(); + var > optionList:XMLList = categoricalQ[0].option.@name; - //Alert.show("option > key: " + optionList.length()); - for(var j:int = 0; j< optionList.length(); > j++) { - var str:String = optionList[j]; + str = optionList[j]; > compRelative.header1List.addItem(str); dict[str] = new ArrayCollection(); - > var attributeList:XMLList = categoricalQ[0].option[j].attributes(); - - > for(var i:int = 0; i < attributeList.length(); i++) + choiceStr=""; + > choiceStr = categoricalQ[0].option[j].@choices; + + + outputchoices = null; > + outputchoices = choiceStr.split(","); + + + for(var i:int = 0; i < > outputchoices.length; i++) { - if(attributeList[i] != optionList[j]) - { - > dict[str].addItem(attributeList[i]); - } + + > dict[str].addItem(outputchoices[i]); } - } + + } + > compRelative.setDictionary(dict); - compRelative.setDictionary(dict); - } > else if(categoricalQ[0].@type == "simple") { @@ -1154,7 +1436,7 @@ > currentState = "simple"; var cat2obj:DisplayObject = > pnlComponent.getChildAt(3); var > compSimple:custom.db.questions.CategoricalSimple = > custom.db.questions.CategoricalSimple(cat2obj); - + compSimple.reset(); var > dictionary:Dictionary = new Dictionary(); var attributeSimpleList:XMLList = > categoricalQ[0].option.attributes(); @@ -1167,9 +1449,9 @@ dictionary[str1] > = new ArrayCollection(); dictionary[str1].addItem(null); } - + > compSimple.setDictionary(dictionary); } - > compSimple.setDictionary(dictionary); + } } @@ -1180,27 +1462,34 @@ var > psychobj:DisplayObject = pnlComponent.getChildAt(2); var > compPsychometric:custom.db.questions.Psychometric = > custom.db.questions.Psychometric(psychobj); compPsychometric.reset(); - > questionInfo.cmbType.selectedItem = "Psychometric"; + > //questionInfo.cmbType.selectedItem = "Psychometric"; var > psychometricQ:XMLList = psychometricQuestions.psychometric.(@id == node.@id); > if(psychometricQ.length() > 0) { - > compPsychometric.setScale(psychometricQ[0].@scale); - > compPsychometric.setNumberofIntervals(psychometricQ[0].@interval); - var > psychometricAttributes:XMLList = psychometricQ[0].attributes(); - + var > scale:String = psychometricQ[0].@scale; + compPsychometric.setScale(scale); > + compPsychometric.setNumberofIntervals(psychometricQ[0].@maxSliderValue); > compPsychometric.vboxChoices.visible = true; - for(var l:int =0; l < > psychometricAttributes.length(); l++) - { - Alert.show("Attribute is : " > +psychometricAttributes[l]); - if((psychometricAttributes[l] != > psychometricQ[0].@id) && (psychometricAttributes[l] != > psychometricQ[0].@scale) && (psychometricAttributes[l] != > psychometricQ[0].@interval)) - { - > compPsychometric.choice.addItem(psychometricAttributes[l]); - } - } + + > choiceStr = ""; + outputchoices = null; + choiceStr = > psychometricQ[0].@choices; + outputchoices = choiceStr.split(","); + + for(i > = 0; i < outputchoices.length; i++) + { + > compPsychometric.choice.addItem(outputchoices[i]); + + } + } } else - > currentState = "none"; + { + currentState = "question"; + + } + } } @@ > -1232,7 +1521,9 @@ - + + + @@ -1245,6 +1536,7 @@ + @@ -1303,7 +1595,7 @@ - + > @@ -1313,14 +1605,12 @@ + showRoot="true" height="50%" width="80%" > textAlign="center"/> + showRoot="true" height="50%" width="80%" > textAlign="center"/> Modified: > mentalmodels/trunk/flex/src/actionscript/Block.as > =================================================================== --- > mentalmodels/trunk/flex/src/actionscript/Block.as 2009-07-17 23:21:35 UTC > (rev 187) +++ mentalmodels/trunk/flex/src/actionscript/Block.as 2009-07-20 > 01:13:36 UTC (rev 188) @@ -13,6 +13,7 @@ public var duration:int; public var > module:Module; public var questionGroups:ArrayCollection; + public var > informationWindows:ArrayCollection; public function getHours():int @@ -29,7 > +30,7 @@ public function getSeconds():int { - return (duration - > (getMinutes() * 60)); + return (duration - (getHours() * 3600) - > (getMinutes() * 60)); } } } \ No newline at end of file Modified: > mentalmodels/trunk/flex/src/actionscript/Module.as > =================================================================== --- > mentalmodels/trunk/flex/src/actionscript/Module.as 2009-07-17 23:21:35 UTC > (rev 187) +++ mentalmodels/trunk/flex/src/actionscript/Module.as 2009-07-20 > 01:13:36 UTC (rev 188) @@ -33,7 +33,7 @@ public function getSeconds():int { > - return (duration - (getMinutes() * 60)); + return (duration - (getHours() > * 3600) - (getMinutes() * 60)); } } } \ No newline at end of file Modified: > mentalmodels/trunk/flex/src/actionscript/QuestionGroup.as > =================================================================== --- > mentalmodels/trunk/flex/src/actionscript/QuestionGroup.as 2009-07-17 > 23:21:35 UTC (rev 187) +++ > mentalmodels/trunk/flex/src/actionscript/QuestionGroup.as 2009-07-20 > 01:13:36 UTC (rev 188) @@ -12,5 +12,24 @@ public var header:String; public > var description:String; public var block:Block; + public var duration:int; + > + public function getHours():int + { + return > int(Math.floor(duration/3600)); + } + + public function getMinutes():int + { > + var tempDuration:int; + tempDuration = duration - (getHours() * 3600); + > return int(Math.floor(tempDuration/60)); + } + + public function > getSeconds():int + { + return (duration - (getHours() * 3600) - > (getMinutes() * 60)); + } + } } \ No newline at end of file Modified: > mentalmodels/trunk/flex/src/actionscript/questions/Question.as > =================================================================== --- > mentalmodels/trunk/flex/src/actionscript/questions/Question.as 2009-07-17 > 23:21:35 UTC (rev 187) +++ > mentalmodels/trunk/flex/src/actionscript/questions/Question.as 2009-07-20 > 01:13:36 UTC (rev 188) @@ -1,6 +1,8 @@ package actionscript.questions { + > import actionscript.QuestionGroup; + [Bindable] > [RemoteClass(alias="edu.asu.commons.mme.entity.Question")] public class > Question @@ -9,5 +11,7 @@ public var question:String; public var > type:String; public var sequenceNo:int; + public var > questionGroup:QuestionGroup; + } } \ No newline at end of file Modified: > mentalmodels/trunk/flex/src/custom/db/Block.mxml > =================================================================== --- > mentalmodels/trunk/flex/src/custom/db/Block.mxml 2009-07-17 23:21:35 UTC > (rev 187) +++ mentalmodels/trunk/flex/src/custom/db/Block.mxml 2009-07-20 > 01:13:36 UTC (rev 188) @@ -34,7 +34,7 @@ } public function getName():String > { - return txtName.text; + return rchtxtDescription.text; } /*public > function getDuration():String { @@ -63,7 +63,7 @@ } public function > setName(name:String):void { - txtName.text = name; + rchtxtDescription.text > = name; } @@ -97,7 +97,7 @@ formIsValid = true; // Check if form is empty - > formIsEmpty = (txtSeqNo.text == "" && txtName.text == ""); + formIsEmpty = > (txtSeqNo.text == "" && rchtxtDescription.text == ""); // Run each validator > in turn, using the isValid() // helper method and update the value of > formIsValid @@ -136,12 +136,12 @@ public function reset():void { > txtSeqNo.text =""; - txtName.text = ""; + rchtxtDescription.text = ""; > hours.value =0; minutes.value =0; seconds.value =0; txtSeqNo.errorString > =""; - txtName.errorString =""; + rchtxtDescription.errorString =""; Id = 0; > } @@ -154,10 +154,12 @@ + - + + - + Modified: > mentalmodels/trunk/flex/src/custom/db/Module.mxml > =================================================================== --- > mentalmodels/trunk/flex/src/custom/db/Module.mxml 2009-07-17 23:21:35 UTC > (rev 187) +++ mentalmodels/trunk/flex/src/custom/db/Module.mxml 2009-07-20 > 01:13:36 UTC (rev 188) @@ -45,6 +45,14 @@ { //return txtMajor.text; }*/ + > public function setSequenceNo(seqNo:String):void + { + txtSeqNo.text = > seqNo; + } + public function setName(name:String):void + { + txtName.text = > name; + } public function getHours():Number { @@ -62,16 +70,6 @@ } - public > function setSequenceNo(seqNo:String):void - { - txtSeqNo.text = seqNo; - } - > public function setName(name:String):void - { - txtName.text = name; - } - - > public function setHours(hour:Number):void { hours.value = hour; @@ -148,16 > +146,7 @@ txtName.errorString =""; Id = 0; } - - public function > saveModule():void - { - - - - } - - ]]> @@ -177,10 +166,7 @@ - - - Modified: > mentalmodels/trunk/flex/src/custom/db/Question.mxml > =================================================================== --- > mentalmodels/trunk/flex/src/custom/db/Question.mxml 2009-07-17 23:21:35 UTC > (rev 187) +++ mentalmodels/trunk/flex/src/custom/db/Question.mxml 2009-07-20 > 01:13:36 UTC (rev 188) @@ -36,12 +36,12 @@ } public function > getQuestion():String { - return txtQuestion.text; + return > rchtxtQuestion.text; } public function getType():String { - return > String(cmbType.selectedItem); + return cmbType.selectedItem.data; } public > function setSequenceNo(seqNo:String):void @@ -50,7 +50,7 @@ } public > function setQuestion(question:String):void { - txtQuestion.text = question; > + rchtxtQuestion.text = question; } @@ -62,31 +62,17 @@ - public function > setQuestionInfo(type:String):void + public function > setQuestionType(type:String):void { - cmbType.selectedItem = type; - > if(cmbType.selectedItem == "Categorical") - { - currentState = > "categorical"; - var catobj:DisplayObject = > canvasQuestionType.getChildAt(0); - questionInfo = Categorical(catobj); - > questionInfo.reset(); - - } - if(cmbType.selectedItem == "Psychometric") - { > - currentState = "psychometric"; - var psychobj:DisplayObject = > canvasQuestionType.getChildAt(0); - questionInfo = Psychometric(psychobj); - > questionInfo.reset(); - - } - /*if(cmbType.selectedItem == "Text") - { - > currentState = "none"; - } */ - - + for (var i: int = 0; i < > cmbType.dataProvider.length; i++) + { + if ( type == > cmbType.dataProvider[i].data) + { + cmbType.selectedIndex = i; + break; + } > + } + } @@ -103,7 +89,7 @@ formIsValid = true; // Check if form is empty - > formIsEmpty = (txtSeqNo.text == "" && txtQuestion.text == "" && > cmbType.selectedItem == "-Select-"); + formIsEmpty = (txtSeqNo.text == "" && > rchtxtQuestion.text == "" && cmbType.selectedItem == "-Select-"); // Run > each validator in turn, using the isValid() // helper method and update the > value of formIsValid @@ -117,7 +103,7 @@ private function > showQuestionType():void { - if(cmbType.selectedItem == "Categorical") + > if(cmbType.selectedItem.toString().toLowerCase() == "categorical") { > currentState = "categorical"; var catobj:DisplayObject = > canvasQuestionType.getChildAt(0); @@ -125,7 +111,7 @@ questionInfo.reset(); > } - if(cmbType.selectedItem == "Psychometric") + > if(cmbType.selectedItem.toString().toLowerCase() == "psychometric") { > currentState = "psychometric12"; var psychobj:DisplayObject = > canvasQuestionType.getChildAt(0); @@ -133,7 +119,7 @@ questionInfo.reset(); > } - if(cmbType.selectedItem == "Text") + > if(cmbType.selectedItem.toString().toLowerCase() == "Text") { currentState = > "text"; } @@ -171,11 +157,11 @@ { currentState = "text"; txtSeqNo.text =""; > - txtQuestion.text = ""; - + rchtxtQuestion.text = ""; + this.Id = 0; > txtSeqNo.errorString =""; - txtQuestion.errorString =""; - > cmbType.selectedIndex = 0; + rchtxtQuestion.errorString =""; + > cmbType.selectedIndex = -1; } @@ -204,17 +190,23 @@ + - + + + - + - -Select- > - Categorical - Psychometric - Text - + + + + + + + + Modified: > mentalmodels/trunk/flex/src/custom/db/QuestionGroup.mxml > =================================================================== --- > mentalmodels/trunk/flex/src/custom/db/QuestionGroup.mxml 2009-07-17 23:21:35 > UTC (rev 187) +++ mentalmodels/trunk/flex/src/custom/db/QuestionGroup.mxml > 2009-07-20 01:13:36 UTC (rev 188) @@ -35,11 +35,11 @@ } public function > getHeader():String { - return txtHeader.text; + return rchtxtHeader.text; } > public function getDescription():String { - return txtDescription.text; + > return rchtxtDescription.text; } public function > setSequenceNo(seqNo:String):void @@ -48,18 +48,50 @@ } public function > setHeader(header:String):void { - txtHeader.text = header; + > rchtxtHeader.text = header; } public function > setDescription(description:String):void { - txtDescription.text = > description; + rchtxtDescription.text = description; } + public function > getHours():Number + { + return hours.value; + + } + public function > getMinutes():Number + { + return minutes.value; + + } + public function > getSeconds():Number + { + return seconds.value; + + } - public function > validateForm(event:Event):Boolean + public function > setHours(hour:Number):void + { + hours.value = hour; + + } + public function > setMinutes(min:Number):void + { + minutes.value = min; + + } + public > function setSeconds(sec:Number):void + { + seconds.value = sec; + + } + + + > public function validateForm(event:Event):Boolean { // Save a reference to > the currently focussed form control // so that the isValid() helper method > can notify only @@ -71,7 +103,7 @@ formIsValid = true; // Check if form is > empty - formIsEmpty = (txtSeqNo.text == "" && txtHeader.text == "" && > txtDescription.text == ""); + formIsEmpty = (txtSeqNo.text == "" && > rchtxtHeader.text == "" && rchtxtDescription.text == ""); // Run each > validator in turn, using the isValid() // helper method and update the value > of formIsValid @@ -110,12 +142,15 @@ public function reset():void { > txtSeqNo.text =""; - txtHeader.text = ""; - txtDescription.text =""; + > rchtxtHeader.text = ""; + rchtxtDescription.text =""; txtSeqNo.errorString > =""; - txtHeader.errorString =""; - txtDescription.errorString =""; + > rchtxtHeader.errorString =""; + rchtxtDescription.errorString =""; setId(0); > + hours.value =0; + minutes.value =0; + seconds.value =0; } @@ -126,14 > +161,35 @@ + + + + + + + + + + + + + - + + + + + - + + + + Modified: > mentalmodels/trunk/flex/src/custom/db/questions/Categorical.mxml > =================================================================== --- > mentalmodels/trunk/flex/src/custom/db/questions/Categorical.mxml 2009-07-17 > 23:21:35 UTC (rev 187) +++ > mentalmodels/trunk/flex/src/custom/db/questions/Categorical.mxml 2009-07-20 > 01:13:36 UTC (rev 188) @@ -79,17 +79,17 @@ // currentState = "none"; - > cmbType.selectedIndex = 0; + cmbType.selectedItem = "-Select-"; } public > function setType(qType:String):void { - if(qType == "relative") + > if(qType.toLowerCase() == "relative") { cmbType.selectedItem = "Relative"; } > - else if(qType == "simple") + else if(qType.toLowerCase() == "simple") { > cmbType.selectedItem = "Simple"; Modified: > mentalmodels/trunk/flex/src/custom/db/questions/CategoricalRelative.mxml > =================================================================== --- > mentalmodels/trunk/flex/src/custom/db/questions/CategoricalRelative.mxml > 2009-07-17 23:21:35 UTC (rev 187) +++ > mentalmodels/trunk/flex/src/custom/db/questions/CategoricalRelative.mxml > 2009-07-20 01:13:36 UTC (rev 188) @@ -123,11 +123,11 @@ { for(var key:Object > in dict) { - // dict[key].removeAll(); - // delete dict[key]; + > dict[key].removeAll(); + delete dict[key]; } } - vboxSecondHeader.visible = > false; + vboxSecondHeader.visible = true; } Modified: > mentalmodels/trunk/flex/src/custom/db/questions/CategoricalSimple.mxml > =================================================================== --- > mentalmodels/trunk/flex/src/custom/db/questions/CategoricalSimple.mxml > 2009-07-17 23:21:35 UTC (rev 187) +++ > mentalmodels/trunk/flex/src/custom/db/questions/CategoricalSimple.mxml > 2009-07-20 01:13:36 UTC (rev 188) @@ -94,8 +94,15 @@ txtChoice.text = ""; > lblHeader.text = ""; header.removeAll(); - frmitmAddChoice.label="Choice for > " + lblHeader.text + ":"; + if(dict != null) + { + for(var key:Object in > dict) + { + dict[key].removeAll(); + delete dict[key]; + } + } } public > function setSimpleForm():void Modified: > mentalmodels/trunk/flex/src/custom/db/questions/Psychometric.mxml > =================================================================== --- > mentalmodels/trunk/flex/src/custom/db/questions/Psychometric.mxml 2009-07-17 > 23:21:35 UTC (rev 187) +++ > mentalmodels/trunk/flex/src/custom/db/questions/Psychometric.mxml 2009-07-20 > 01:13:36 UTC (rev 188) @@ -31,12 +31,13 @@ public function > setScale(scale:String):void { this.scale = scale; - if(scale == "bipolar") + > //Alert.show("Scale is :" +scale); + if(scale.toLowerCase() == "bipolar") { > cmbType.selectedItem = "Bipolar"; } - else if(scale == "unipolar") + else > if(scale.toLowerCase() == "unipolar") { cmbType.selectedItem = "Unipolar"; > @@ -225,11 +226,11 @@ --> - + -Select- Bipolar - Scalar + Unipolar Modified: > mentalmodels/trunk/src/main/db/init-mme.sql > =================================================================== --- > mentalmodels/trunk/src/main/db/init-mme.sql 2009-07-17 23:21:35 UTC (rev > 187) +++ mentalmodels/trunk/src/main/db/init-mme.sql 2009-07-20 01:13:36 UTC > (rev 188) @@ -1,260 +1,730 @@ -insert into game > (description,image_location,max_days,max_fish_harvest,money,no_of_locations,no_of_rounds,timestamp,title) > -values("First game","island.jpg",30,5,0.0,4,3,NOW(),"Mental Model > Experiment"); - -insert into round_config > (communication_flag,round_no,game_i... [truncated message content] |