virtualcommons-svn Mailing List for Virtual Commons Experiment Software (Page 72)
Status: Beta
Brought to you by:
alllee
You can subscribe to this list here.
2008 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
(1) |
Jul
(21) |
Aug
(31) |
Sep
(6) |
Oct
(15) |
Nov
(2) |
Dec
(9) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2009 |
Jan
(4) |
Feb
(6) |
Mar
(12) |
Apr
(52) |
May
(14) |
Jun
(19) |
Jul
(81) |
Aug
(115) |
Sep
(36) |
Oct
(88) |
Nov
(46) |
Dec
(58) |
2010 |
Jan
(52) |
Feb
(55) |
Mar
(48) |
Apr
(15) |
May
(5) |
Jun
(38) |
Jul
(27) |
Aug
(24) |
Sep
(28) |
Oct
(1) |
Nov
(2) |
Dec
(29) |
2011 |
Jan
(87) |
Feb
(39) |
Mar
(63) |
Apr
(42) |
May
(26) |
Jun
(53) |
Jul
(23) |
Aug
(43) |
Sep
(37) |
Oct
(25) |
Nov
(4) |
Dec
(7) |
2012 |
Jan
(73) |
Feb
(79) |
Mar
(62) |
Apr
(28) |
May
(12) |
Jun
(2) |
Jul
(9) |
Aug
(1) |
Sep
(8) |
Oct
|
Nov
(3) |
Dec
(3) |
2013 |
Jan
(8) |
Feb
(16) |
Mar
(38) |
Apr
(74) |
May
(62) |
Jun
(15) |
Jul
(49) |
Aug
(19) |
Sep
(9) |
Oct
|
Nov
|
Dec
|
2014 |
Jan
|
Feb
|
Mar
|
Apr
(2) |
May
(25) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: <kj...@us...> - 2009-07-13 23:32:25
|
Revision: 182 http://virtualcommons.svn.sourceforge.net/virtualcommons/?rev=182&view=rev Author: kjonas Date: 2009-07-13 23:32:20 +0000 (Mon, 13 Jul 2009) Log Message: ----------- Modified DayOutput.java and StudentStrategy.java to contain public variables, for use as beans. ModuleService.java now returns sequential modules, and can be reset to the first. (this needs to be changed to get module number N) Modified Paths: -------------- mentalmodels/trunk/src/main/java/edu/asu/commons/mme/entity/DayOutput.java mentalmodels/trunk/src/main/java/edu/asu/commons/mme/entity/StudentStrategy.java mentalmodels/trunk/src/main/java/edu/asu/commons/mme/service/ModuleService.java Modified: mentalmodels/trunk/src/main/java/edu/asu/commons/mme/entity/DayOutput.java =================================================================== --- mentalmodels/trunk/src/main/java/edu/asu/commons/mme/entity/DayOutput.java 2009-07-13 23:29:02 UTC (rev 181) +++ mentalmodels/trunk/src/main/java/edu/asu/commons/mme/entity/DayOutput.java 2009-07-13 23:32:20 UTC (rev 182) @@ -19,17 +19,17 @@ @Id @GeneratedValue - private Long id; + public Long id; @ManyToOne @JoinColumn(nullable=false) - private StudentStrategy strategy; + public StudentStrategy strategy; @Column(nullable=false) - private Integer day; + public Integer day; @Column(nullable=false) - private Double earnings; + public Double earnings; public void setId(Long id) { this.id = id; Modified: mentalmodels/trunk/src/main/java/edu/asu/commons/mme/entity/StudentStrategy.java =================================================================== --- mentalmodels/trunk/src/main/java/edu/asu/commons/mme/entity/StudentStrategy.java 2009-07-13 23:29:02 UTC (rev 181) +++ mentalmodels/trunk/src/main/java/edu/asu/commons/mme/entity/StudentStrategy.java 2009-07-13 23:32:20 UTC (rev 182) @@ -24,7 +24,7 @@ @Id @GeneratedValue - private Long id; + public Long id; @ManyToOne @@ -32,25 +32,25 @@ private RoundConfig roundConfig; @Column(name = "allocation_sequence_no",nullable=false) - private Integer allocationSeqNo; + public Integer allocationSeqNo; @Column(nullable=false) - private Integer days; + public Integer days; @Column(nullable=false) - private Double threshold; + public Double threshold; @ManyToOne @JoinColumn(nullable=false) - private Location location; + public Location location; @Column (name="repeated_decisions",columnDefinition="Boolean", nullable=false) - private boolean repeatedDecisions; + public boolean repeatedDecisions; @OneToMany(mappedBy="strategy") @JoinColumn(nullable=false) - private List<DayOutput> dayOutput; + public List<DayOutput> dayOutput; public void setId(Long id) { Modified: mentalmodels/trunk/src/main/java/edu/asu/commons/mme/service/ModuleService.java =================================================================== --- mentalmodels/trunk/src/main/java/edu/asu/commons/mme/service/ModuleService.java 2009-07-13 23:29:02 UTC (rev 181) +++ mentalmodels/trunk/src/main/java/edu/asu/commons/mme/service/ModuleService.java 2009-07-13 23:32:20 UTC (rev 182) @@ -17,10 +17,21 @@ @Transactional public class ModuleService extends Service.Base<Module, HibernateModuleDao>{ - public Module getFirstPage() + public Integer currentModule = new Integer(1); + + public Module setToModule(int moduleNumber) { + currentModule = new Integer(moduleNumber); + Module tempModule = new Module(); + tempModule.setDescription("result of setModule - ignore!"); + return tempModule; + } + + public Module getNextModule() + { // Enter the sequence number in new Integer(Sequence number of module u want to fetch) - Module module = getDao().findByProperty("sequenceNo", new Integer(1)); + Module module = getDao().findByProperty("sequenceNo", currentModule); + setToModule(1 + currentModule.intValue()); Hibernate.initialize(module); getLogger().debug("Module object is " + module.getDescription()); @@ -52,8 +63,47 @@ } } - return module; - + return module; } - + + public Module get1thModule() + { + // Enter the sequence number in new Integer(Sequence number of module u want to fetch) + setToModule(1); + Module module = getDao().findByProperty("sequenceNo", currentModule); + setToModule(1 + currentModule.intValue()); + + Hibernate.initialize(module); + getLogger().debug("Module object is " + module.getDescription()); + + Iterator<Block> iterateBlock = module.getBlocks().iterator(); + while(iterateBlock.hasNext()) + { + Block block = iterateBlock.next(); + Hibernate.initialize(block); + Iterator<QuestionGroup> iteratorquestionGrp = block.getQuestionGroups().iterator(); + { + while(iteratorquestionGrp.hasNext()) + { + QuestionGroup questionGroup = iteratorquestionGrp.next(); + Hibernate.initialize(questionGroup); + List<Question> questions = questionGroup.getQuestions(); + + for(int j = 0; j < questions.size(); j++) + { + Hibernate.initialize(questions.get(j)); + if(questions.get(j).getClass().getName().equalsIgnoreCase("edu.asu.commons.mme.entity.CategoricalQuestion")) + { + CategoricalQuestion categoricalQ = (CategoricalQuestion)questions.get(j); + Iterator<CategoricalOption> categoricalOption = categoricalQ.getCategoricalOptions().iterator(); + Hibernate.initialize(categoricalOption); + } + } + } + } + + } + return module; + } + } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <kj...@us...> - 2009-07-13 23:29:08
|
Revision: 181 http://virtualcommons.svn.sourceforge.net/virtualcommons/?rev=181&view=rev Author: kjonas Date: 2009-07-13 23:29:02 +0000 (Mon, 13 Jul 2009) Log Message: ----------- Myriad changes including: Information Windows will now only display once each, regardless of how many times they are specified (just a precaution). The program can now get sequential Modules from the server. (errors occur with empty blocks or modules) DayByDayDecisionsQuestionC.mxml now automatically scrolls to the bottom when advanced. All question component descriptions now wrap when longer than 600 pixels. Modified Paths: -------------- mentalmodels/trunk/flex/src/FisheryExperimentShell.mxml mentalmodels/trunk/flex/src/actionscript/InformationWindowCreator.as mentalmodels/trunk/flex/src/actionscript/PageDisplay.as mentalmodels/trunk/flex/src/actionscript/questions/Question.as mentalmodels/trunk/flex/src/custom/FisheryExperimentKalin.mxml mentalmodels/trunk/flex/src/custom/InstructionPage.mxml mentalmodels/trunk/flex/src/custom/questions/CategoricalQuestionC.mxml mentalmodels/trunk/flex/src/custom/questions/TextQuestionC.mxml mentalmodels/trunk/flex/src/custom/questions/dayByDayDecisions/DayByDayDecisionsQuestionC.mxml mentalmodels/trunk/flex/src/custom/questions/forecasting/ForecastingFishQuestionC.mxml mentalmodels/trunk/flex/src/custom/questions/forecasting/ForecastingPeopleQuestionC.mxml mentalmodels/trunk/flex/src/custom/questions/psychometric/PsychometricQuestionC.mxml mentalmodels/trunk/flex/src/custom/questions/strategyDesign/StrategyDesignQuestionC.mxml Added Paths: ----------- mentalmodels/trunk/flex/src/actionscript/DayOutput.as mentalmodels/trunk/flex/src/actionscript/StudentStrategy.as Modified: mentalmodels/trunk/flex/src/FisheryExperimentShell.mxml =================================================================== --- mentalmodels/trunk/flex/src/FisheryExperimentShell.mxml 2009-07-12 02:32:16 UTC (rev 180) +++ mentalmodels/trunk/flex/src/FisheryExperimentShell.mxml 2009-07-13 23:29:02 UTC (rev 181) @@ -73,6 +73,8 @@ // extract the updaters updateObjectA = allInfoWindowsA.getItemAt(2) as InformationWindowCreator; updateObjectB = allInfoWindowsB.getItemAt(2) as InformationWindowCreator; + fisheryContent.updateObjectA = allInfoWindowsA.getItemAt(2) as InformationWindowCreator; + fisheryContent.updateObjectB = allInfoWindowsB.getItemAt(2) as InformationWindowCreator; // extract the information windows themselves allInfoWindowsA = allInfoWindowsA.getItemAt(0) as ArrayCollection; @@ -169,14 +171,13 @@ currInfoWindowsB = new ArrayCollection(); currInfoWindowsDescriptions = new ArrayCollection(); - for(var i:int = 0; i < selectedWindows.length; i++) + for(var i:int = 0; i < allInfoWindowsA.length; i++) { - var selectedIndex:int = selectedWindows.getItemAt(i) as int; - if(selectedIndex < allInfoWindowsA.length && selectedIndex < allInfoWindowsB.length) + if(selectedWindows.contains(i)) { - currInfoWindowsA.addItem(allInfoWindowsA.getItemAt(selectedIndex)); - currInfoWindowsB.addItem(allInfoWindowsB.getItemAt(selectedIndex)); - currInfoWindowsDescriptions.addItem(allInfoWindowsDescriptions.getItemAt(selectedIndex)); + currInfoWindowsA.addItem(allInfoWindowsA.getItemAt(i)); + currInfoWindowsB.addItem(allInfoWindowsB.getItemAt(i)); + currInfoWindowsDescriptions.addItem(allInfoWindowsDescriptions.getItemAt(i)); } } Added: mentalmodels/trunk/flex/src/actionscript/DayOutput.as =================================================================== --- mentalmodels/trunk/flex/src/actionscript/DayOutput.as (rev 0) +++ mentalmodels/trunk/flex/src/actionscript/DayOutput.as 2009-07-13 23:29:02 UTC (rev 181) @@ -0,0 +1,11 @@ +package actionscript +{ + [Bindable] + [RemoteClass(alias="edu.asu.commons.mme.entity.DayOutput")] + public class DayOutput + { + public var id:Number; + public day:int; + public earnings:Number; + } +} \ No newline at end of file Modified: mentalmodels/trunk/flex/src/actionscript/InformationWindowCreator.as =================================================================== --- mentalmodels/trunk/flex/src/actionscript/InformationWindowCreator.as 2009-07-12 02:32:16 UTC (rev 180) +++ mentalmodels/trunk/flex/src/actionscript/InformationWindowCreator.as 2009-07-13 23:29:02 UTC (rev 181) @@ -503,22 +503,7 @@ allInfoWindows.addItem(tempWindow); allInfoWindowsDescriptions.addItem("Notes - With Group"); - //// - // Window 11 - tempWindow = new ArrayCollection(); - temp = new Label(); - (temp as Label).text = "Title"; - (temp as Label).setStyle("fontSize",14); - (temp as Label).setStyle("fontWeight","bold"); - tempWindow.addItem(temp); - - allInfoWindows.addItem(tempWindow); - allInfoWindowsDescriptions.addItem("Window Description"); - - - - /* //// // Window X Modified: mentalmodels/trunk/flex/src/actionscript/PageDisplay.as =================================================================== --- mentalmodels/trunk/flex/src/actionscript/PageDisplay.as 2009-07-12 02:32:16 UTC (rev 180) +++ mentalmodels/trunk/flex/src/actionscript/PageDisplay.as 2009-07-13 23:29:02 UTC (rev 181) @@ -144,9 +144,9 @@ head.setStyle("fontSize", 12); head.width = 600; desc.width = 600; - head.text = questionGroup.header; + head.htmlText = questionGroup.header; desc.htmlText = questionGroup.description; - if(head.text.length != 0) tempBox.addChildAt(head,0); + if(head.htmlText.length != 0) tempBox.addChildAt(head,0); if(desc.htmlText.length != 0) tempBox.addChildAt(desc,1); pages.addItem(tempBox); Added: mentalmodels/trunk/flex/src/actionscript/StudentStrategy.as =================================================================== --- mentalmodels/trunk/flex/src/actionscript/StudentStrategy.as (rev 0) +++ mentalmodels/trunk/flex/src/actionscript/StudentStrategy.as 2009-07-13 23:29:02 UTC (rev 181) @@ -0,0 +1,19 @@ +package actionscript +{ + + import mx.collections.ArrayCollection; + + [Bindable] + [RemoteClass(alias="edu.asu.commons.mme.entity.StudentStrategy")] + public class StudentStrategy + { + public var id:Number; + public var allocationSeqNo:int; + public var days:int; + public var threshold:Number; + public var location:Location; + public var repeatedDecisions:Boolean; + public var dayOutput:ArrayCollection; + + } +} \ 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-12 02:32:16 UTC (rev 180) +++ mentalmodels/trunk/flex/src/actionscript/questions/Question.as 2009-07-13 23:29:02 UTC (rev 181) @@ -9,6 +9,5 @@ public var question:String; public var type:String; public var sequenceNo:int; - } } \ No newline at end of file Modified: mentalmodels/trunk/flex/src/custom/FisheryExperimentKalin.mxml =================================================================== --- mentalmodels/trunk/flex/src/custom/FisheryExperimentKalin.mxml 2009-07-12 02:32:16 UTC (rev 180) +++ mentalmodels/trunk/flex/src/custom/FisheryExperimentKalin.mxml 2009-07-13 23:29:02 UTC (rev 181) @@ -17,13 +17,18 @@ <mx:SetStyle target="{content}" name="horizontalCenter" value="0"/> </mx:State> - <mx:State name="instructions"> + <mx:State name="instructionsLoad"> <mx:AddChild relativeTo="{content}"> - <!--<comp:InstructionPage id="instructions" initialize="instructions.init(makeBlock())"/>--> - <comp:InstructionPage id="instructions" initialize="instructions.initModule(currModule)"/> + <comp:InstructionPage id="instructions" initialize="gotoInstructions()"/> </mx:AddChild> </mx:State> + <mx:State name="instructions" enterState="instructions.initModule(currModule)"> + <mx:RemoveChild target="{instructions}"/> + <mx:AddChild relativeTo="{content}" target="{instructions}"/> + <mx:SetProperty target="{instructions}" name="visible" value="true"/> + </mx:State> + <mx:State name="wait"> <mx:AddChild relativeTo="{content}"> <mx:Label id="lblWaiting" text="Waiting for next Module from server..." fontSize="16"/> @@ -48,6 +53,7 @@ <mx:RemoteObject id="ss" destination="studentService" fault="faultHandler(event)" result="resultHandler(event)"/> <mx:Producer id="producer" destination="DataPush" acknowledge="ack(event)"/> <mx:Consumer id="consumer" destination="DataPush" message="messageHandler(event.message)" /> + <mx:Script> <![CDATA[ import actionscript.*; @@ -70,8 +76,14 @@ // public var currModule:Module = null; public var currBlock:Block = null; + public var currBlockNumber:int = 0; public var blockLoader:Function = null; + public var updateObjectA:InformationWindowCreator = null; + public var updateObjectB:InformationWindowCreator = null; + + public var instructionsLoaded:Boolean = false; + private var shared:SharedObject; private var flushMessage:String; [Bindable] @@ -88,33 +100,90 @@ public function init():void { + moduleService.setToModule(1); + } + + private function gotoInstructions():void + { + instructionsLoaded = true; + currentState = "instructions"; + } + private function sendBlockQuestions():void + { + if(1==1)return; + if(currBlock == null) return; + var qgroups:ArrayCollection = currBlock.questionGroups; + for(var qgroupNum:int=0; qgroupNum<qgroups.length; qgroupNum++) + { + var questions:ArrayCollection = (qgroups.getItemAt(qgroupNum) as QuestionGroup).questions; + for(var qNum:int=0; qNum<questions.length; qNum++) + { + var question:Question = questions.getItemAt(qNum) as Question; + sendQuestion(question,currBlockNumber,qgroupNum,qNum); + } + } + } + private function sendQuestion(databaseObject:Object,blockNumber:int,questionGroupNumber:int,questionNumber:int):void + { + if(databaseObject is ArrayCollection) + { + var array:ArrayCollection = databaseObject as ArrayCollection; + if(array != null && array.length > 0) + { + if(array.getItemAt(0) is StudentStrategy) + { + var sstrat:StudentStrategy = array.getItemAt(0) as StudentStrategy; + // invoke service here + } + } + } } private function getModule():Module { + sendBlockQuestions(); // server request here - moduleService.getFirstPage(); + moduleService.getNextModule(); - Alert.show("MODULE REQUEST SENT"); - currModule = null; return currModule; // set to null for now (clear old) } private function moduleResultHandler(event:ResultEvent):void { - Alert.show("MODULE RECIEVED"); +// try{ +// Alert.show("module==null:"+(event.result==null)+ +// "\nblock==null:"+((event.result as Module).blocks == null)+ +// "\nblock.length:"+((event.result as Module).blocks.length)+ +// "\nblock1.questionGroups==null:"+(((event.result as Module).blocks.getItemAt(0) as Block).questionGroups==null)+ +// "\nblock1.questionGroups.length:"+(((event.result as Module).blocks.getItemAt(0) as Block).questionGroups.length) +// ); +// }catch(err:Error){ +// +// } - Alert.show("module==null:"+(event.result==null)+ - "\nblock==null:"+((event.result as Module).blocks == null)+ - "\nblock.length:"+((event.result as Module).blocks.length)+ - "\nblock1.questionGroups==null:"+(((event.result as Module).blocks.getItemAt(0) as Block).questionGroups==null)+ - "\nblock1.questionGroups.length"+(((event.result as Module).blocks.getItemAt(0) as Block).questionGroups.length) - ); - currModule = (event.result as actionscript.Module); - currentState = "instructions"; + if(currModule.description == "result of setModule - ignore!") + { + return; + } + else if(currModule == null || currModule.blocks == null || currModule.blocks.length < 1 || + (currModule.blocks.getItemAt(0) as Block) == null || + (currModule.blocks.getItemAt(0) as Block).questionGroups == null || + (currModule.blocks.getItemAt(0) as Block).questionGroups.length < 1) + { + currentState = "none"; + } + else if(!instructionsLoaded) + { + currentState = "instructionsLoad"; + } + else + { + gotoInstructions(); + } + btnBack.enabled = btnForward.enabled = true; } private function moduleFaultHandler(event:FaultEvent):void @@ -194,14 +263,6 @@ obj.visible = false; expiredContent.addChild(obj); - // - // TEMPORARY CODE - // comments indicate changes to be made for legitimate server communication - // -// currModule = new Module(); //delete -// currModule.blocks = new ArrayCollection(); //delete -// currModule.blocks.addItem(makeBlock()); //delete -// currModule.blocks.addItem(makeBlock()); //delete currentState = "wait"; getModule(); // @@ -210,12 +271,7 @@ var info:SocioDemographicPage = SocioDemographicPage(obj); - /* Alert.show(info.getGender()); - Alert.show(info.getMajor()); - Alert.show(info.getSemester()); - Alert.show(info.getYear());*/ Id=ss.createStudent(info.getYear(), info.getSemester(), info.getGender(),info.getMajor()); -// Alert.show("Before invoking createstudent()"); btnBack.enabled = true; btnForward.enabled = true; @@ -242,6 +298,7 @@ if(newCurrBlock != currBlock) { currBlock = newCurrBlock; + currBlockNumber++; blockLoader.call(); } } @@ -249,7 +306,7 @@ catch(err:Error){} } - btnBack.enabled = btnForward.enabled = currentState == "instructions"; + btnBack.enabled = btnForward.enabled = (currentState == "instructions"); return returnValue; } Modified: mentalmodels/trunk/flex/src/custom/InstructionPage.mxml =================================================================== --- mentalmodels/trunk/flex/src/custom/InstructionPage.mxml 2009-07-12 02:32:16 UTC (rev 180) +++ mentalmodels/trunk/flex/src/custom/InstructionPage.mxml 2009-07-13 23:29:02 UTC (rev 181) @@ -3,6 +3,7 @@ <mx:Script> <![CDATA[ + import actionscript.QuestionGroup; import actionscript.Module; import custom.questions.forecasting.*; import mx.controls.Alert; @@ -48,14 +49,16 @@ try{ // debug2.text += "creating pageDisplay...\n"; var minPagesRead:int = 0; + pageDisplay = null; if(block != null && block.questionGroups != null) { minPagesRead = block.questionGroups.length + pageDisplay = new PageDisplay(block, minPagesRead); } - pageDisplay = new PageDisplay(block, minPagesRead); if(pageDisplay == null) { debug2.text += "pageDisplay is null\n"; + pageDisplay = new PageDisplay(makeBlock(),0); } // pageDisplay = new PageDisplay(block, block.questionGroups.length); @@ -64,6 +67,7 @@ }catch(errObject:Error){ debug2.text += "pageDisplay creation failure\n" + errObject.message +"\n"+ errObject.getStackTrace() +"\n"; + pageDisplay = new PageDisplay(makeBlock(),0); // Alert.show(debug2.text); } @@ -73,6 +77,7 @@ numPages = pageDisplay.pages.length; // debug2.text += "adding currentPage...\n"; + content.removeAllChildren(); content.addChild(pageDisplay.currentPage); // debug2.text += "currentPage added.\n"; } @@ -177,6 +182,15 @@ block = (loadArray.getItemAt(0) as Block); } + public function makeBlock():Block + { + var block:Block = new Block(); + block.questionGroups = new ArrayCollection(); + block.questionGroups.addItem(new QuestionGroup()); + (block.questionGroups.getItemAt(0) as QuestionGroup).description = "Default Page."; + return block; + } + ]]> </mx:Script> Modified: mentalmodels/trunk/flex/src/custom/questions/CategoricalQuestionC.mxml =================================================================== --- mentalmodels/trunk/flex/src/custom/questions/CategoricalQuestionC.mxml 2009-07-12 02:32:16 UTC (rev 180) +++ mentalmodels/trunk/flex/src/custom/questions/CategoricalQuestionC.mxml 2009-07-13 23:29:02 UTC (rev 181) @@ -1,7 +1,12 @@ <?xml version="1.0" encoding="utf-8"?> <mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:as="actionscript.*"> - <mx:String id="description"></mx:String> + <mx:Text width="600" text="{description}"/> + <mx:Script> + <![CDATA[ + [Bindable] public var description:String = ""; + ]]> + </mx:Script> <mx:HBox id="content"> <mx:ComboBox id="comboTopic" Modified: mentalmodels/trunk/flex/src/custom/questions/TextQuestionC.mxml =================================================================== --- mentalmodels/trunk/flex/src/custom/questions/TextQuestionC.mxml 2009-07-12 02:32:16 UTC (rev 180) +++ mentalmodels/trunk/flex/src/custom/questions/TextQuestionC.mxml 2009-07-13 23:29:02 UTC (rev 181) @@ -1,7 +1,12 @@ <?xml version="1.0" encoding="utf-8"?> <mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml"> - <mx:String id="description"></mx:String> + <mx:Text width="600" text="{description}"/> + <mx:Script> + <![CDATA[ + [Bindable] public var description:String = ""; + ]]> + </mx:Script> <mx:Number id="txtWidth">400</mx:Number> <mx:Number id="txtHeight">100</mx:Number> Modified: mentalmodels/trunk/flex/src/custom/questions/dayByDayDecisions/DayByDayDecisionsQuestionC.mxml =================================================================== --- mentalmodels/trunk/flex/src/custom/questions/dayByDayDecisions/DayByDayDecisionsQuestionC.mxml 2009-07-12 02:32:16 UTC (rev 180) +++ mentalmodels/trunk/flex/src/custom/questions/dayByDayDecisions/DayByDayDecisionsQuestionC.mxml 2009-07-13 23:29:02 UTC (rev 181) @@ -1,7 +1,12 @@ <?xml version="1.0" encoding="utf-8"?> <mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml" initialize="init()"> - <mx:String id="description"></mx:String> + <mx:Text width="600" text="{description}"/> + <mx:Script> + <![CDATA[ + [Bindable] public var description:String = ""; + ]]> + </mx:Script> <mx:Label id="txtPrompt" text="It's Day 1. Where will you go to fish, or will you stay in the harbor?"/> <mx:Label id="lblChosen" text="location chosen: {deciding}"/> Modified: mentalmodels/trunk/flex/src/custom/questions/forecasting/ForecastingFishQuestionC.mxml =================================================================== --- mentalmodels/trunk/flex/src/custom/questions/forecasting/ForecastingFishQuestionC.mxml 2009-07-12 02:32:16 UTC (rev 180) +++ mentalmodels/trunk/flex/src/custom/questions/forecasting/ForecastingFishQuestionC.mxml 2009-07-13 23:29:02 UTC (rev 181) @@ -1,9 +1,14 @@ <?xml version="1.0" encoding="utf-8"?> <mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:components="custom.questions.forecasting.*"> - <mx:String id="description"></mx:String> + <mx:Text width="600" text="{description}"/> + <mx:Script> + <![CDATA[ + [Bindable] public var description:String = ""; + ]]> + </mx:Script> - <components:ForecastComponent id="fishEntry" style="1" isEntry="true" + <components:ForecastComponent id="fishEntry" style="1" isEntry="true" maxValue="30" numBays="{numBays}" numColumns="{numColumns}" initialize="false" updaterObject="{this}" updater="{recalculate}"/> <components:ForecastComponent id="peopleDisplay" style="0" isEntry="false" Modified: mentalmodels/trunk/flex/src/custom/questions/forecasting/ForecastingPeopleQuestionC.mxml =================================================================== --- mentalmodels/trunk/flex/src/custom/questions/forecasting/ForecastingPeopleQuestionC.mxml 2009-07-12 02:32:16 UTC (rev 180) +++ mentalmodels/trunk/flex/src/custom/questions/forecasting/ForecastingPeopleQuestionC.mxml 2009-07-13 23:29:02 UTC (rev 181) @@ -1,7 +1,12 @@ <?xml version="1.0" encoding="utf-8"?> <mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:components="custom.questions.forecasting.*"> - <mx:String id="description"></mx:String> + <mx:Text width="600" text="{description}"/> + <mx:Script> + <![CDATA[ + [Bindable] public var description:String = ""; + ]]> + </mx:Script> <components:ForecastComponent id="peopleEntry" style="0" isEntry="true" numBays="{numBays}" numColumns="{numColumns}" initialize="false"/> Modified: mentalmodels/trunk/flex/src/custom/questions/psychometric/PsychometricQuestionC.mxml =================================================================== --- mentalmodels/trunk/flex/src/custom/questions/psychometric/PsychometricQuestionC.mxml 2009-07-12 02:32:16 UTC (rev 180) +++ mentalmodels/trunk/flex/src/custom/questions/psychometric/PsychometricQuestionC.mxml 2009-07-13 23:29:02 UTC (rev 181) @@ -1,7 +1,12 @@ <?xml version="1.0" encoding="utf-8"?> <mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:qComp="custom.questions.psychometric.*" initialize="false"> - <mx:String id="description"></mx:String> + <mx:Text width="600" text="{description}"/> + <mx:Script> + <![CDATA[ + [Bindable] public var description:String = ""; + ]]> + </mx:Script> <mx:Canvas id="content" minHeight="30" maxHeight="90"> <!-- Used for bipolar psychometric scales --> Modified: mentalmodels/trunk/flex/src/custom/questions/strategyDesign/StrategyDesignQuestionC.mxml =================================================================== --- mentalmodels/trunk/flex/src/custom/questions/strategyDesign/StrategyDesignQuestionC.mxml 2009-07-12 02:32:16 UTC (rev 180) +++ mentalmodels/trunk/flex/src/custom/questions/strategyDesign/StrategyDesignQuestionC.mxml 2009-07-13 23:29:02 UTC (rev 181) @@ -1,7 +1,12 @@ <?xml version="1.0" encoding="utf-8"?> <mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:qComp="custom.questions.strategyDesign.*"> - <mx:String id="description"></mx:String> + <mx:Text width="600" text="{description}"/> + <mx:Script> + <![CDATA[ + [Bindable] public var description:String = ""; + ]]> + </mx:Script> <mx:HBox> <mx:VBox> @@ -29,6 +34,8 @@ <mx:Script> <![CDATA[ + import actionscript.Location; + import actionscript.StudentStrategy; import actionscript.questions.Question; import mx.collections.ArrayCollection; @@ -69,6 +76,51 @@ // init(); } + public function toDatabaseObject():ArrayCollection + { + var array:ArrayCollection = new ArrayCollection(); + var tempObject:StudentStrategy; + + var notRepeatedArray:ArrayCollection = notRepeated.save(); + var repeatedArray:ArrayCollection = repeated.save(); + var i:int; + var tempArray:ArrayCollection; + + + for(i=0;i<notRepeatedArray.length;i++) + { + tempArray = notRepeatedArray.getItemAt(i) as ArrayCollection; + tempObject = new StudentStrategy(); + tempObject.location = strToLocation(tempArray.getItemAt(0) as String); + tempObject.days = int(tempArray.getItemAt(1) as Number); + tempObject.threshold = (tempArray.getItemAt(2) as Number); + + tempObject.allocationSeqNo = i; + tempObject.repeatedDecisions = false; + + array.addItem(tempObject); + } + for(i=0;i<repeatedArray.length;i++) + { + tempArray = repeatedArray.getItemAt(i) as ArrayCollection; + tempObject = new StudentStrategy(); + tempObject.location = strToLocation(tempArray.getItemAt(0) as String); + tempObject.days = int(tempArray.getItemAt(1) as Number); + tempObject.threshold = (tempArray.getItemAt(2) as Number); + + tempObject.allocationSeqNo = i+notRepeatedArray.length; + tempObject.repeatedDecisions = true; + + array.addItem(tempObject); + } + + return array; + } + private function strToLocation(str:String):Location + { + return new Location(); + } + ]]> </mx:Script> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: Kalin J. <kj...@as...> - 2009-07-13 07:46:40
|
At approximately 11pm I terminated my activities, having attempted to create a similar function to the string tokenizer, but failing, and Seema found a similar function already implemented. I have made some progress on implementing the updating functions, but not too much: The FisheryExperiment component has references to the updating features, but I'm not sure where to trigger the updates, where the components will be in scope. On Sun, Jul 12, 2009 at 10:31 PM, Kalin Jonas <kj...@as...> wrote: > Tonight at 10:15 I began minor fixes to the Question Components, to fix a > minor glitch where the descriptions were stored as strings, which displayed > them strangely. They should no longer scroll across the page indefinitely. > > I plan to work on the Information Windows and create updating functions for > each element that needs to be updated. > If I still have time, I will be working more on the part of the Question > Components that saves their data and prepares it for sending to server. > > > On Sun, Jul 12, 2009 at 11:49 AM, Kalin Jonas <kj...@as...> wrote: > >> I worked from 9:00AM until 11:45AM (2.75 hr) talking, and coding a method >> within the display component of the strategy design that outputs an >> ArrayCollection of StudentStrategy objects. >> These can be used to fill the database with the answers that the students >> provide when they create their strategies. >> I cannot myself code the necessary services to communicate this >> information to the server, but I have created at least one method that would >> create the data. >> >> >> On Sun, Jul 12, 2009 at 9:44 AM, Kalin Jonas <kj...@as...> wrote: >> >>> This morning at 9:00am I began talking to Seema about what needs to be >>> done before the deadline today. >>> I plan on working on the code that sends data to the servers about how >>> the students have answered the questions they will hopefully be presented. >>> Since there is currently no module or block that contains questions, nor >>> code to send any module beyond the first, I am not sure if they will display >>> properly. >>> I will try to write the code, but I won't have any real way of testing >>> it. >>> >> >> > |
From: Kalin J. <kj...@as...> - 2009-07-13 05:31:34
|
Tonight at 10:15 I began minor fixes to the Question Components, to fix a minor glitch where the descriptions were stored as strings, which displayed them strangely. They should no longer scroll across the page indefinitely. I plan to work on the Information Windows and create updating functions for each element that needs to be updated. If I still have time, I will be working more on the part of the Question Components that saves their data and prepares it for sending to server. On Sun, Jul 12, 2009 at 11:49 AM, Kalin Jonas <kj...@as...> wrote: > I worked from 9:00AM until 11:45AM (2.75 hr) talking, and coding a method > within the display component of the strategy design that outputs an > ArrayCollection of StudentStrategy objects. > These can be used to fill the database with the answers that the students > provide when they create their strategies. > I cannot myself code the necessary services to communicate this information > to the server, but I have created at least one method that would create the > data. > > > On Sun, Jul 12, 2009 at 9:44 AM, Kalin Jonas <kj...@as...> wrote: > >> This morning at 9:00am I began talking to Seema about what needs to be >> done before the deadline today. >> I plan on working on the code that sends data to the servers about how the >> students have answered the questions they will hopefully be presented. >> Since there is currently no module or block that contains questions, nor >> code to send any module beyond the first, I am not sure if they will display >> properly. >> I will try to write the code, but I won't have any real way of testing it. >> > > |
From: Kalin J. <kj...@as...> - 2009-07-12 20:59:20
|
This morning at 9:00am I began talking to Seema about what needs to be done before the deadline today. I plan on working on the code that sends data to the servers about how the students have answered the questions they will hopefully be presented. Since there is currently no module or block that contains questions, nor code to send any module beyond the first, I am not sure if they will display properly. I will try to write the code, but I won't have any real way of testing it. |
From: Kalin J. <kj...@as...> - 2009-07-12 19:58:30
|
I worked from 9:00AM until 11:45AM (2.75 hr) talking, and coding a method within the display component of the strategy design that outputs an ArrayCollection of StudentStrategy objects. These can be used to fill the database with the answers that the students provide when they create their strategies. I cannot myself code the necessary services to communicate this information to the server, but I have created at least one method that would create the data. On Sun, Jul 12, 2009 at 9:44 AM, Kalin Jonas <kj...@as...> wrote: > This morning at 9:00am I began talking to Seema about what needs to be done > before the deadline today. > I plan on working on the code that sends data to the servers about how the > students have answered the questions they will hopefully be presented. > Since there is currently no module or block that contains questions, nor > code to send any module beyond the first, I am not sure if they will display > properly. > I will try to write the code, but I won't have any real way of testing it. > |
From: Kalin J. <kj...@as...> - 2009-07-12 02:42:57
|
Today I got online and began updating and installing maven, ant, and mysql at around 15:00. Seema walked me through the process of installing these programs, and I finally managed to get them to work at approximately 16:00. >From 16:00 to 19:00, I worked on fixing the parts of the Flex code that were necessary to make the connection to the server and retrieve a module. The program currently retrieves the first module, allows the user to page through the instructions, and then ceases to function. |
From: <kj...@us...> - 2009-07-12 02:32:20
|
Revision: 180 http://virtualcommons.svn.sourceforge.net/virtualcommons/?rev=180&view=rev Author: kjonas Date: 2009-07-12 02:32:16 +0000 (Sun, 12 Jul 2009) Log Message: ----------- Today I got online and began updating and installing maven, ant, and mysql at around 15:00. Seema walked me through the process of installing these programs, and I finally managed to get them to work at approximately 16:00. >From 16:00 to 19:15, I worked on fixing the parts of the Flex code that were necessary to make the connection to the server and retrieve a module. The program currently retrieves the first module, allows the user to page through the instructions, and then ceases to function. Modified Paths: -------------- mentalmodels/trunk/flex/src/FisheryExperimentShell.mxml mentalmodels/trunk/flex/src/actionscript/PageDisplay.as mentalmodels/trunk/flex/src/custom/FisheryExperimentKalin.mxml mentalmodels/trunk/flex/src/custom/InstructionPage.mxml mentalmodels/trunk/src/main/java/edu/asu/commons/mme/service/ModuleService.java Property Changed: ---------------- mentalmodels/trunk/ Property changes on: mentalmodels/trunk ___________________________________________________________________ Added: svn:ignore + target Modified: mentalmodels/trunk/flex/src/FisheryExperimentShell.mxml =================================================================== --- mentalmodels/trunk/flex/src/FisheryExperimentShell.mxml 2009-07-12 00:22:56 UTC (rev 179) +++ mentalmodels/trunk/flex/src/FisheryExperimentShell.mxml 2009-07-12 02:32:16 UTC (rev 180) @@ -5,7 +5,7 @@ width="100%" height="100%" xmlns:custom="custom.*" initialize="init()"> - <mx:Button id="btnTemp" label="Update" click="updateObjectA.updateLearned(new ArrayCollection([new ArrayCollection(['test']),new ArrayCollection(['test']),new ArrayCollection(['test'])]))"/> + <!--<mx:Button id="btnTemp" label="Update" click="updateObjectA.updateLearned(new ArrayCollection([new ArrayCollection(['test']),new ArrayCollection(['test']),new ArrayCollection(['test'])]))"/>--> <mx:VBox id="vbxInfo"> <mx:TitleWindow id="InformationWindowA" width="400" height="200" title="Information Window A" Modified: mentalmodels/trunk/flex/src/actionscript/PageDisplay.as =================================================================== --- mentalmodels/trunk/flex/src/actionscript/PageDisplay.as 2009-07-12 00:22:56 UTC (rev 179) +++ mentalmodels/trunk/flex/src/actionscript/PageDisplay.as 2009-07-12 02:32:16 UTC (rev 180) @@ -133,19 +133,21 @@ } } } - var head:Label = new Label(); - var desc:Text = new Text(); - head.text = questionGroup.header; - head.setStyle("fontSize", 12); - desc.htmlText = questionGroup.description; - if(head.text.length != 0) tempBox.addChildAt(head,0); - if(desc.htmlText.length != 0) tempBox.addChildAt(desc,1); } else { - msg += "no Questions found\n"; +// msg += "no Questions found\n"; // Alert.show(msg); } + var head:Text = new Text(); + var desc:Text = new Text(); + head.setStyle("fontSize", 12); + head.width = 600; + desc.width = 600; + head.text = questionGroup.header; + desc.htmlText = questionGroup.description; + if(head.text.length != 0) tempBox.addChildAt(head,0); + if(desc.htmlText.length != 0) tempBox.addChildAt(desc,1); pages.addItem(tempBox); // msg += "item added\n"; Modified: mentalmodels/trunk/flex/src/custom/FisheryExperimentKalin.mxml =================================================================== --- mentalmodels/trunk/flex/src/custom/FisheryExperimentKalin.mxml 2009-07-12 00:22:56 UTC (rev 179) +++ mentalmodels/trunk/flex/src/custom/FisheryExperimentKalin.mxml 2009-07-12 02:32:16 UTC (rev 180) @@ -4,6 +4,8 @@ currentState="socioDemographic" initialize="init()" width="720" height="490"> + <mx:RemoteObject id="moduleService" destination="moduleService" fault="moduleFaultHandler(event)" result="moduleResultHandler(event)"/> + <mx:states> <mx:State name="socioDemographic"> <mx:AddChild relativeTo="{content}"> @@ -83,19 +85,53 @@ randomNumbers = event.message.body as String; //Alert.show("in ack method" + randomNumbers); } + + public function init():void + { + + } + + private function getModule():Module + { + // server request here + moduleService.getFirstPage(); + + Alert.show("MODULE REQUEST SENT"); + + currModule = null; + return currModule; // set to null for now (clear old) + } + private function moduleResultHandler(event:ResultEvent):void + { + Alert.show("MODULE RECIEVED"); + + Alert.show("module==null:"+(event.result==null)+ + "\nblock==null:"+((event.result as Module).blocks == null)+ + "\nblock.length:"+((event.result as Module).blocks.length)+ + "\nblock1.questionGroups==null:"+(((event.result as Module).blocks.getItemAt(0) as Block).questionGroups==null)+ + "\nblock1.questionGroups.length"+(((event.result as Module).blocks.getItemAt(0) as Block).questionGroups.length) + ); + + currModule = (event.result as actionscript.Module); + currentState = "instructions"; + + btnBack.enabled = btnForward.enabled = true; + } + private function moduleFaultHandler(event:FaultEvent):void + { + Alert.show(event.fault.message + "\n" + event.fault.getStackTrace()); + } + private function resultHandler(event:ResultEvent):void { Id = event.result as uint; - // Alert.show("Student id is " + Id ); consumer.disconnect(); } - private function faultHandler(event:FaultEvent):void { // Alert.show("event fault is " + event.fault.faultDetail); } - private function handleFault(event:MessageFaultEvent):void { // Alert.show("Message event fault is " + event.faultString); @@ -108,19 +144,6 @@ // Alert.show( ""+randomNumbers); } - public function init():void - { - - } - - private function getModule():Module - { - // server request here - - currModule = null; - return currModule; // set to null for now (clear old) - } - public function back():Boolean { if(content.numChildren == 0) @@ -175,11 +198,12 @@ // TEMPORARY CODE // comments indicate changes to be made for legitimate server communication // - currModule = new Module(); //delete - currModule.blocks = new ArrayCollection(); //delete - currModule.blocks.addItem(makeBlock()); //delete - currModule.blocks.addItem(makeBlock()); //delete - currentState = "instructions"; //change to state "wait", which will call getModule() +// currModule = new Module(); //delete +// currModule.blocks = new ArrayCollection(); //delete +// currModule.blocks.addItem(makeBlock()); //delete +// currModule.blocks.addItem(makeBlock()); //delete + currentState = "wait"; + getModule(); // // END TEMPORARY CODE // @@ -208,6 +232,7 @@ obj.visible = false; expiredContent.addChild(obj); currentState = "wait"; + getModule(); //consumer.subscribe(); returnValue = true; } Modified: mentalmodels/trunk/flex/src/custom/InstructionPage.mxml =================================================================== --- mentalmodels/trunk/flex/src/custom/InstructionPage.mxml 2009-07-12 00:22:56 UTC (rev 179) +++ mentalmodels/trunk/flex/src/custom/InstructionPage.mxml 2009-07-12 02:32:16 UTC (rev 180) @@ -24,6 +24,21 @@ { module = newModule; currBlock = 0; + if(module == null) + { + debug2.text += "module is null\n"; + return; + } + if(module.blocks == null) + { + debug2.text += "module.blocks is null\n"; + return; + } + if(module.blocks.length < 1) + { + debug2.text += "module.blocks.length is less than 1\n"; + return; + } init(module.blocks.getItemAt(currBlock) as Block); } @@ -31,7 +46,7 @@ { block = newBlock; try{ -// debug.text += "creating pageDisplay...\n"; +// debug2.text += "creating pageDisplay...\n"; var minPagesRead:int = 0; if(block != null && block.questionGroups != null) { @@ -40,26 +55,26 @@ pageDisplay = new PageDisplay(block, minPagesRead); if(pageDisplay == null) { - debug.text += "pageDisplay is null"; + debug2.text += "pageDisplay is null\n"; } // pageDisplay = new PageDisplay(block, block.questionGroups.length); }catch(errObject:Error){ - debug.text += "pageDisplay creation failure\n" + + debug2.text += "pageDisplay creation failure\n" + errObject.message +"\n"+ errObject.getStackTrace() +"\n"; -// Alert.show(debug.text); +// Alert.show(debug2.text); } -// debug.text += "setting currPage...\n"; +// debug2.text += "setting currPage...\n"; currPage = pageDisplay.currentPageNumber; -// debug.text += "setting numPages...\n"; +// debug2.text += "setting numPages...\n"; numPages = pageDisplay.pages.length; -// debug.text += "adding currentPage...\n"; +// debug2.text += "adding currentPage...\n"; content.addChild(pageDisplay.currentPage); -// debug.text += "currentPage added.\n"; +// debug2.text += "currentPage added.\n"; } public function back():Boolean @@ -167,6 +182,7 @@ <mx:Label id="currPageLabel" text="Page {(currPage+1)} / {numPages}"/> <mx:Text id="debug" text="{pageDisplay.msg}" width="300"/> +<mx:Text id="debug2" text="" width="300"/> <mx:VBox id="content"/> Modified: mentalmodels/trunk/src/main/java/edu/asu/commons/mme/service/ModuleService.java =================================================================== --- mentalmodels/trunk/src/main/java/edu/asu/commons/mme/service/ModuleService.java 2009-07-12 00:22:56 UTC (rev 179) +++ mentalmodels/trunk/src/main/java/edu/asu/commons/mme/service/ModuleService.java 2009-07-12 02:32:16 UTC (rev 180) @@ -20,7 +20,7 @@ public Module getFirstPage() { // Enter the sequence number in new Integer(Sequence number of module u want to fetch) - Module module = getDao().findByProperty("sequenceNo", new Integer(2)); + Module module = getDao().findByProperty("sequenceNo", new Integer(1)); Hibernate.initialize(module); getLogger().debug("Module object is " + module.getDescription()); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <see...@us...> - 2009-07-12 00:23:02
|
Revision: 179 http://virtualcommons.svn.sourceforge.net/virtualcommons/?rev=179&view=rev Author: seematalele Date: 2009-07-12 00:22:56 +0000 (Sun, 12 Jul 2009) Log Message: ----------- change the getFirstPage in ModuleService.java file. Modified Paths: -------------- mentalmodels/trunk/src/main/java/edu/asu/commons/mme/service/ModuleService.java Modified: mentalmodels/trunk/src/main/java/edu/asu/commons/mme/service/ModuleService.java =================================================================== --- mentalmodels/trunk/src/main/java/edu/asu/commons/mme/service/ModuleService.java 2009-07-11 22:43:56 UTC (rev 178) +++ mentalmodels/trunk/src/main/java/edu/asu/commons/mme/service/ModuleService.java 2009-07-12 00:22:56 UTC (rev 179) @@ -8,7 +8,10 @@ import edu.asu.commons.mme.dao.HibernateModuleDao; import edu.asu.commons.mme.entity.Block; +import edu.asu.commons.mme.entity.CategoricalOption; +import edu.asu.commons.mme.entity.CategoricalQuestion; import edu.asu.commons.mme.entity.Module; +import edu.asu.commons.mme.entity.Question; import edu.asu.commons.mme.entity.QuestionGroup; @Transactional @@ -16,34 +19,41 @@ public Module getFirstPage() { - // System.out.println("test is " + test); + // Enter the sequence number in new Integer(Sequence number of module u want to fetch) Module module = getDao().findByProperty("sequenceNo", new Integer(2)); + Hibernate.initialize(module); - System.out.println("Module object is " + module.getDescription()); + getLogger().debug("Module object is " + module.getDescription()); - - List<Block> listBlock = module.getBlocks(); - Iterator<Block> iterateBlock = listBlock.iterator(); + Iterator<Block> iterateBlock = module.getBlocks().iterator(); while(iterateBlock.hasNext()) { Block block = iterateBlock.next(); Hibernate.initialize(block); - List<QuestionGroup> questionGroup = block.getQuestionGroups(); - Iterator<QuestionGroup> iteratorquestion = questionGroup.iterator(); + Iterator<QuestionGroup> iteratorquestionGrp = block.getQuestionGroups().iterator(); { - while(iteratorquestion.hasNext()) + while(iteratorquestionGrp.hasNext()) { - Hibernate.initialize(iteratorquestion.next()); + QuestionGroup questionGroup = iteratorquestionGrp.next(); + Hibernate.initialize(questionGroup); + List<Question> questions = questionGroup.getQuestions(); + + for(int j = 0; j < questions.size(); j++) + { + Hibernate.initialize(questions.get(j)); + if(questions.get(j).getClass().getName().equalsIgnoreCase("edu.asu.commons.mme.entity.CategoricalQuestion")) + { + CategoricalQuestion categoricalQ = (CategoricalQuestion)questions.get(j); + Iterator<CategoricalOption> categoricalOption = categoricalQ.getCategoricalOptions().iterator(); + Hibernate.initialize(categoricalOption); + } + } } } - + } - - - System.out.println("Module block is " + module.getBlocks().size()); + return module; - return module; - } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <see...@us...> - 2009-07-11 22:44:09
|
Revision: 178 http://virtualcommons.svn.sourceforge.net/virtualcommons/?rev=178&view=rev Author: seematalele Date: 2009-07-11 22:43:56 +0000 (Sat, 11 Jul 2009) Log Message: ----------- Fixed errors in the following files - 1)Block.java - removed informationWindow variable 2)InitialiseDatabase.mxml file - due to changes in the folder structure and class names, getting lot of errors. 3)init-mme.sql - round_config_location table was empty. I written insert statement for this table. Modified Paths: -------------- mentalmodels/trunk/flex/src/InitialiseDatabase.mxml mentalmodels/trunk/flex/src/custom/db/Question.mxml mentalmodels/trunk/flex/src/custom/db/questions/Categorical.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/Block.java Removed Paths: ------------- mentalmodels/trunk/flex/.actionScriptProperties mentalmodels/trunk/flex/.flexProperties mentalmodels/trunk/flex/.project mentalmodels/trunk/flex/src/actionscript/questions/PsychometricQuestion.as Deleted: mentalmodels/trunk/flex/.actionScriptProperties =================================================================== --- mentalmodels/trunk/flex/.actionScriptProperties 2009-07-10 22:11:37 UTC (rev 177) +++ mentalmodels/trunk/flex/.actionScriptProperties 2009-07-11 22:43:56 UTC (rev 178) @@ -1,22 +0,0 @@ -<?xml version="1.0" encoding="UTF-8" standalone="no"?> -<actionScriptProperties mainApplicationPath="FisheryExperiment.mxml" version="3"> - <compiler additionalCompilerArguments="-locale en_US" copyDependentFiles="true" enableModuleDebug="true" generateAccessible="false" htmlExpressInstall="true" htmlGenerate="true" htmlHistoryManagement="true" htmlPlayerVersion="9.0.28" htmlPlayerVersionCheck="true" outputFolderPath="bin-debug" sourceFolderPath="src" strict="true" useApolloConfig="false" verifyDigests="true" warn="true"> - <compilerSourcePath/> - <libraryPath defaultLinkType="1"> - <libraryPathEntry kind="4" path=""/> - <libraryPathEntry kind="1" linkType="1" path="libs"/> - </libraryPath> - <sourceAttachmentPath/> - </compiler> - <applications> - <application path="Socio_demographic.mxml"/> - <application path="TestApp.mxml"/> - <application path="display.mxml"/> - <application path="TableTest.mxml"/> - <application path="MME.mxml"/> - <application path="Mental.mxml"/> - <application path="FisheryExperiment.mxml"/> - </applications> - <modules/> - <buildCSSFiles/> -</actionScriptProperties> Deleted: mentalmodels/trunk/flex/.flexProperties =================================================================== --- mentalmodels/trunk/flex/.flexProperties 2009-07-10 22:11:37 UTC (rev 177) +++ mentalmodels/trunk/flex/.flexProperties 2009-07-11 22:43:56 UTC (rev 178) @@ -1,2 +0,0 @@ -<?xml version="1.0" encoding="UTF-8" standalone="no"?> -<flexProperties flexServerType="0" toolCompile="true" useServerFlexSDK="false" version="1"/> Deleted: mentalmodels/trunk/flex/.project =================================================================== --- mentalmodels/trunk/flex/.project 2009-07-10 22:11:37 UTC (rev 177) +++ mentalmodels/trunk/flex/.project 2009-07-11 22:43:56 UTC (rev 178) @@ -1,18 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<projectDescription> - <name>Fishery</name> - <comment></comment> - <projects> - </projects> - <buildSpec> - <buildCommand> - <name>com.adobe.flexbuilder.project.flexbuilder</name> - <arguments> - </arguments> - </buildCommand> - </buildSpec> - <natures> - <nature>com.adobe.flexbuilder.project.flexnature</nature> - <nature>com.adobe.flexbuilder.project.actionscriptnature</nature> - </natures> -</projectDescription> Modified: mentalmodels/trunk/flex/src/InitialiseDatabase.mxml =================================================================== --- mentalmodels/trunk/flex/src/InitialiseDatabase.mxml 2009-07-10 22:11:37 UTC (rev 177) +++ mentalmodels/trunk/flex/src/InitialiseDatabase.mxml 2009-07-11 22:43:56 UTC (rev 178) @@ -1,18 +1,19 @@ <?xml version="1.0" encoding="utf-8"?> -<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:net="flash.net.*" xmlns:comp="customComponents.db.questions.*" xmlns:basicComp="customComponents.db.*" +<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:net="flash.net.*" xmlns:comp="custom.db.questions.*" xmlns:basicComp="custom.db.*" backgroundGradientAlphas="[1.0, 1.0]" backgroundGradientColors="[#FFFFFF, #80FFAA]" width="100%" height="100%" clipContent="false" layout="absolute" currentState="none" initialize="init()"> <mx:Script> <![CDATA[ import mx.binding.utils.BindingUtils; - import customComponents.db.questions.Psychometric; - import customComponents.db.questions.CategoricalSimple; - import customComponents.db.questions.CategoricalRelative; - import customComponents.db.questions.Categorical; + /*import custom.db.questions.Psychometric; + import custom.db.questions.CategoricalSimple; + import custom.db.questions.CategoricalRelative; + import custom.db.questions.Categorical; + import custom.db.Block; */ import actionscript.Block; import actionscript.Module; - import actionscript.Question; + import actionscript.questions.Question; import actionscript.QuestionGroup; import actionscript.questions.Categorical; import actionscript.questions.CategoricalOption; @@ -137,7 +138,7 @@ { for(var i:int = 0 ; i < modulelist.length ; i++) { - var module:Module = new Module(); + var module:actionscript.Module = new actionscript.Module(); module = modulelist[i]; @@ -151,7 +152,7 @@ { for(var blockCounter:int = 0; blockCounter < module.blocks.length; blockCounter++) { - var block:Block = new Block(); + var block:actionscript.Block = new actionscript.Block(); block = module.blocks[blockCounter]; var newBlockNode:XML = createBlockNode(block); @@ -163,7 +164,7 @@ //if any question Group, add into the block for(var qgCounter:int = 0; qgCounter < block.questionGroups.length; qgCounter++) { - var qg:QuestionGroup = new QuestionGroup(); + var qg:actionscript.QuestionGroup = new actionscript.QuestionGroup(); qg = block.questionGroups[qgCounter]; var newQuestionGroupNode:XML = createQuestionGroupNode(qg); @@ -172,7 +173,7 @@ { for(var QCounter:int = 0; QCounter < qg.questions.length; QCounter++) { - var question:Question = new Question(); + var question:actionscript.questions.Question = new actionscript.questions.Question(); question = qg.questions[QCounter]; var newQuestionNode:XML = createQuestionNode(question); newQuestionGroupNode.appendChild(newQuestionNode); @@ -189,7 +190,7 @@ } - private function createModuleNode(module:Module):XML + private function createModuleNode(module:actionscript.Module):XML { @@ -207,7 +208,7 @@ } - private function createBlockNode(block:Block):XML + private function createBlockNode(block:actionscript.Block):XML { var newBlockNode:XML = <block/>; newBlockNode.setLocalName("block"); @@ -222,7 +223,7 @@ } - private function createQuestionGroupNode(questionGroup:QuestionGroup):XML + private function createQuestionGroupNode(questionGroup:actionscript.QuestionGroup):XML { var newNode:XML = <questiongroup/>; newNode.setLocalName("questiongroup"); @@ -235,13 +236,13 @@ } - private function createQuestionNode(question:Question):XML + private function createQuestionNode(question:actionscript.questions.Question):XML { var newQNode:XML = <question/>; newQNode.setLocalName("question"); if(question.type.toLowerCase() == "psychometric") { - var psychometricResult:Psychometric = Psychometric(question); + 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); @@ -271,7 +272,7 @@ } else if(question.type.toLowerCase() == "categorical") { - var categoricalResult:Categorical = Categorical(question); + var categoricalResult:actionscript.questions.Categorical = actionscript.questions.Categorical(question); newQNode.@sequenceNo = categoricalResult.sequenceNo; newQNode.@title = categoricalResult.question; @@ -293,8 +294,8 @@ for(var i:int = 0; i < categoricalResult.categoricalOptions.length ; i++) { - var options:CategoricalOption = new CategoricalOption(); - options = CategoricalOption(categoricalResult.categoricalOptions.getItemAt(i)); + var options:actionscript.questions.CategoricalOption = new actionscript.questions.CategoricalOption(); + options = actionscript.questions.CategoricalOption(categoricalResult.categoricalOptions.getItemAt(i)); var newOptionNode:XML = <option/>; newOptionNode.setLocalName("option"); newOptionNode.@name = options.optionKey; @@ -390,7 +391,7 @@ currentState = "module"; var obj:DisplayObject = pnlComponent.getChildAt(1); - var moduleInfo:Module = Module(obj); + var moduleInfo:custom.db.Module = custom.db.Module(obj); moduleInfo.reset(); btnsaveModule.enabled = true; @@ -404,7 +405,7 @@ { var obj:DisplayObject = pnlComponent.getChildAt(1); - var moduleInfo:Module = Module(obj); + var moduleInfo:custom.db.Module = custom.db.Module(obj); var isModuleFormValid:Boolean = moduleInfo.validateForm(event); if(isModuleFormValid) @@ -445,7 +446,7 @@ //when module is created, the result will come to resultSaveModuleHandler public function resultSaveModuleHandler(event:ResultEvent):void { - var module:Module = Module(event.result as Object); + var module:actionscript.Module = actionscript.Module(event.result as Object); Alert.show("Id is: " + module.id); var newModuleNode:XML = <module/>; newModuleNode.setLocalName("module"); @@ -468,7 +469,7 @@ //when module is updated, the result will come to resultUpdateModuleHandler public function resultUpdateModuleHandler(event:ResultEvent):void { - var module:Module = Module(event.result as Object); + 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; @@ -485,7 +486,7 @@ { currentState = "block"; var obj:DisplayObject = pnlComponent.getChildAt(1); - var blockInfo:Block = Block(obj); + var blockInfo:custom.db.Block = custom.db.Block(obj); blockInfo.reset(); btnsaveBlock.enabled = true; btnsaveModule.enabled = false; @@ -498,7 +499,7 @@ { var obj:DisplayObject = pnlComponent.getChildAt(1); - var blockInfo:Block = Block(obj); + var blockInfo:custom.db.Block = custom.db.Block(obj); var selectedNode:XML = tree.selectedItem as XML; //Alert.show("enter info","",Alert.OK | Alert.); @@ -565,7 +566,7 @@ //when block is created, the result will come to resultSaveBlockHandler public function resultSaveBlockHandler(event:ResultEvent):void { - var block:Block = Block(event.result as Object); + var block:actionscript.Block = actionscript.Block(event.result as Object); if(block != null) { @@ -577,7 +578,7 @@ newBlockNode.@min = block.getMinutes(); newBlockNode.@sec = block.getSeconds(); newBlockNode.@id = block.id; - var tempmodule:Module = block.module; + var tempmodule:actionscript.Module = block.module; var module:XMLList = survey.module.(@id == tempmodule.id); if( module.length() > 0 ) @@ -591,9 +592,9 @@ public function resultUpdateBlockHandler(event:ResultEvent):void { - var block:Block = Block(event.result as Object); + var block:actionscript.Block = actionscript.Block(event.result as Object); - var tempmodule:Module = block.module; + var tempmodule:actionscript.Module = block.module; var blockXML:XMLList = survey.module.block.(@id == block.id); @@ -612,7 +613,7 @@ { currentState = "questionGroup"; var obj:DisplayObject = pnlComponent.getChildAt(1); - var questionGroupInfo:QuestionGroup = QuestionGroup(obj); + var questionGroupInfo:custom.db.QuestionGroup = custom.db.QuestionGroup(obj); questionGroupInfo.reset(); btnsaveModule.enabled = false; @@ -627,7 +628,7 @@ var selectedNode:XML = tree.selectedItem as XML; var obj:DisplayObject = pnlComponent.getChildAt(1); - var questionGroupInfo:QuestionGroup = QuestionGroup(obj); + var questionGroupInfo:custom.db.QuestionGroup = custom.db.QuestionGroup(obj); Alert.show("Question Group Id is: " + questionGroupInfo.getId()); if(tree.selectedItem == null) { @@ -700,7 +701,7 @@ //when QuestionGroup is created, the result will come to resultSaveQuestionGroupHandler public function resultSaveQuestionGroupHandler(event:ResultEvent):void { - var questionGroup:QuestionGroup = QuestionGroup(event.result as Object); + var questionGroup:actionscript.QuestionGroup = actionscript.QuestionGroup(event.result as Object); Alert.show("Id is: " + questionGroup.id); var newNode:XML = <questiongroup/>; newNode.setLocalName("questiongroup"); @@ -709,7 +710,7 @@ newNode.@sequenceNo = questionGroup.sequenceNo; newNode.@id = questionGroup.id; - var block:Block = questionGroup.block; + var block:actionscript.Block = questionGroup.block; var blockXML:XMLList =survey.module.block.(@id == block.id); @@ -724,14 +725,14 @@ //when QuestionGroup is updated, the result will come to resultUpdateQuestionGroupHandler public function resultUpdateQuestionGroupHandler(event:ResultEvent):void { - var questionGroup:QuestionGroup = QuestionGroup(event.result as Object); + var questionGroup:actionscript.QuestionGroup = actionscript.QuestionGroup(event.result as Object); Alert.show("Id is: " + questionGroup.id); var newNode:XML = <questiongroup/>; newNode.setLocalName("questiongroup"); newNode.@header = questionGroup.header; newNode.@description = questionGroup.description; newNode.@sequenceNo = questionGroup.sequenceNo; - var block:Block = questionGroup.block; + var block:actionscript.Block = questionGroup.block; } @@ -743,7 +744,7 @@ { currentState = "question"; var obj:DisplayObject = pnlComponent.getChildAt(1); - var questionInfo:Question = Question(obj); + var questionInfo:custom.db.Question = custom.db.Question(obj); questionInfo.reset(); btnsaveModule.enabled = false; @@ -794,7 +795,7 @@ //find out the parent module var parentModule:XML = tree.getParentItem(tree.selectedItem) as XML; var obj:DisplayObject = pnlComponent.getChildAt(1); - var questionInfo:Question = Question(obj); + var questionInfo:custom.db.Question = custom.db.Question(obj); var isQuestionGroupFormValid:Boolean = questionInfo.validateForm(event); if(isQuestionGroupFormValid) @@ -804,9 +805,9 @@ { var psychobj:DisplayObject = pnlComponent.getChildAt(2); - var compPsychometric:Psychometric = Psychometric(psychobj); + var compPsychometric:custom.db.questions.Psychometric = custom.db.questions.Psychometric(psychobj); - var asPsychometric:Psychometric = new Psychometric(); + var asPsychometric:actionscript.questions.Psychometric = new actionscript.questions.Psychometric(); asPsychometric.scale = compPsychometric.getScale(); asPsychometric.maxSliderValue = int(compPsychometric.getNumberofIntervals()); asPsychometric.choices = compPsychometric.getChoices(); @@ -824,13 +825,13 @@ { var catobj:DisplayObject = pnlComponent.getChildAt(3); var compCategorical:CategoricalRelative = CategoricalRelative(catobj); - var categoricalQuestion:Categorical = new Categorical(); + 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:CategoricalOption = new CategoricalOption(); + var Options:actionscript.questions.CategoricalOption = new actionscript.questions.CategoricalOption(); Options.optionKey = key.toString(); Options.choices = dict[key]; categoricalQuestion.categoricalOptions.addItem(Options); @@ -840,8 +841,8 @@ categoricalQuestion.sequenceNo = int(questionInfo.getSequenceNo()); for(var i:int = 0; i < categoricalQuestion.categoricalOptions.length ; i++) { - var testoption:CategoricalOption = new CategoricalOption(); - testoption = CategoricalOption(categoricalQuestion.categoricalOptions.getItemAt(i)); + var testoption:actionscript.questions.CategoricalOption = new actionscript.questions.CategoricalOption(); + testoption = actionscript.questions.CategoricalOption(categoricalQuestion.categoricalOptions.getItemAt(i)); trace(testoption.optionKey); trace(testoption.choices); } @@ -852,15 +853,15 @@ { Alert.show("simple state"); var catSimpleobj:DisplayObject = pnlComponent.getChildAt(3); - var compCategoricalSimple:CategoricalSimple = CategoricalSimple(catSimpleobj); - var categoricalSimpleQuestion:Categorical = new Categorical(); + 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:CategoricalOption = new CategoricalOption(); + var OptionsSimple:actionscript.questions.CategoricalOption = new actionscript.questions.CategoricalOption(); OptionsSimple.optionKey = option.toString(); Alert.show("Key : " + option.toString()); OptionsSimple.choices = Simpledict[key]; @@ -899,7 +900,7 @@ Alert.show("Type came from server is: " + test_object.type); if(test_object.type == "psychometric") { - var questionResult:Psychometric = Psychometric(event.result as Object); + 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); @@ -922,7 +923,7 @@ } else if(test_object.type.toLowerCase() == "categorical") { - var categoricalResult:Categorical = Categorical(test_object); + var categoricalResult:actionscript.questions.Categorical = actionscript.questions.Categorical(test_object); var newQNode:XML = <question/>; newQNode.setLocalName("question"); newQNode.@sequenceNo = categoricalResult.sequenceNo; @@ -945,8 +946,8 @@ for(var i:int = 0; i < categoricalResult.categoricalOptions.length ; i++) { - var options:CategoricalOption = new CategoricalOption(); - options = CategoricalOption(categoricalResult.categoricalOptions.getItemAt(i)); + var options:actionscript.questions.CategoricalOption = new actionscript.questions.CategoricalOption(); + options = actionscript.questions.CategoricalOption(categoricalResult.categoricalOptions.getItemAt(i)); var newOptionNode:XML = <option/>; newOptionNode.setLocalName("option"); newOptionNode.@name = options.optionKey; @@ -1027,7 +1028,7 @@ { currentState = "module"; var module:DisplayObject = pnlComponent.getChildAt(1); - var moduleInfo:Module = Module(module); + var moduleInfo:custom.db.Module = custom.db.Module(module); btnsaveModule.enabled = true; btnsaveBlock.enabled = false; @@ -1047,7 +1048,7 @@ { currentState = "block"; var block:DisplayObject = pnlComponent.getChildAt(1); - var blockInfo:Block = Block(block); + var blockInfo:custom.db.Block = custom.db.Block(block); btnsaveBlock.enabled = true; btnsaveModule.enabled = false; btnsaveQuestionGroup.enabled = false; @@ -1066,7 +1067,7 @@ { currentState = "questionGroup"; var questionGroup:DisplayObject = pnlComponent.getChildAt(1); - var questionGroupInfo:QuestionGroup = QuestionGroup(questionGroup); + var questionGroupInfo:custom.db.QuestionGroup = custom.db.QuestionGroup(questionGroup); questionGroupInfo.reset(); btnsaveModule.enabled = false; @@ -1086,7 +1087,7 @@ { currentState = "question"; var question:DisplayObject = pnlComponent.getChildAt(1); - var questionInfo:Question = Question(question); + var questionInfo:custom.db.Question = custom.db.Question(question); btnsaveModule.enabled = false; btnsaveBlock.enabled = false; @@ -1106,7 +1107,7 @@ { currentState = "categorical"; var catobj:DisplayObject = pnlComponent.getChildAt(2); - var compCategorical:Categorical = Categorical(catobj); + var compCategorical:custom.db.questions.Categorical = custom.db.questions.Categorical(catobj); compCategorical.reset(); questionInfo.cmbType.selectedItem = "Categorical"; @@ -1152,7 +1153,7 @@ compCategorical.setType("simple"); currentState = "simple"; var cat2obj:DisplayObject = pnlComponent.getChildAt(3); - var compSimple:CategoricalSimple = CategoricalSimple(cat2obj); + var compSimple:custom.db.questions.CategoricalSimple = custom.db.questions.CategoricalSimple(cat2obj); var dictionary:Dictionary = new Dictionary(); @@ -1177,7 +1178,7 @@ { currentState = "psychometric"; var psychobj:DisplayObject = pnlComponent.getChildAt(2); - var compPsychometric:Psychometric = Psychometric(psychobj); + var compPsychometric:custom.db.questions.Psychometric = custom.db.questions.Psychometric(psychobj); compPsychometric.reset(); questionInfo.cmbType.selectedItem = "Psychometric"; var psychometricQ:XMLList = psychometricQuestions.psychometric.(@id == node.@id); Deleted: mentalmodels/trunk/flex/src/actionscript/questions/PsychometricQuestion.as =================================================================== --- mentalmodels/trunk/flex/src/actionscript/questions/PsychometricQuestion.as 2009-07-10 22:11:37 UTC (rev 177) +++ mentalmodels/trunk/flex/src/actionscript/questions/PsychometricQuestion.as 2009-07-11 22:43:56 UTC (rev 178) @@ -1,13 +0,0 @@ -package actionscript.questions -{ - import mx.collections.ArrayCollection; - - [Bindable] - [RemoteClass(alias="edu.asu.commons.mme.entity.PsychometricQuestion")] - public class PsychometricQuestion extends Question - { - public var scale:String; - public var numberOfIntervals:int; - public var choices:ArrayCollection; - } -} \ No newline at end of file Modified: mentalmodels/trunk/flex/src/custom/db/Question.mxml =================================================================== --- mentalmodels/trunk/flex/src/custom/db/Question.mxml 2009-07-10 22:11:37 UTC (rev 177) +++ mentalmodels/trunk/flex/src/custom/db/Question.mxml 2009-07-11 22:43:56 UTC (rev 178) @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="utf-8"?> -<mx:Form xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:net="flash.net.*" xmlns:comp="customComponents.db.questions.*" currentState=""> +<mx:Form xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:net="flash.net.*" xmlns:comp="custom.db.questions.*" currentState=""> <mx:Script> <![CDATA[ import mx.validators.NumberValidator; Modified: mentalmodels/trunk/flex/src/custom/db/questions/Categorical.mxml =================================================================== --- mentalmodels/trunk/flex/src/custom/db/questions/Categorical.mxml 2009-07-10 22:11:37 UTC (rev 177) +++ mentalmodels/trunk/flex/src/custom/db/questions/Categorical.mxml 2009-07-11 22:43:56 UTC (rev 178) @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="utf-8"?> -<mx:Form xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:net="flash.net.*" xmlns:comp="customComponents.db.questions.*"> +<mx:Form xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:net="flash.net.*" xmlns:comp="custom.db.questions.*"> <mx:Script> <![CDATA[ import mx.collections.ArrayCollection; Modified: mentalmodels/trunk/flex/src/custom/db/questions/Psychometric.mxml =================================================================== --- mentalmodels/trunk/flex/src/custom/db/questions/Psychometric.mxml 2009-07-10 22:11:37 UTC (rev 177) +++ mentalmodels/trunk/flex/src/custom/db/questions/Psychometric.mxml 2009-07-11 22:43:56 UTC (rev 178) @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="utf-8"?> -<mx:Form xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:net="flash.net.*" xmlns:comp="customComponents.db.questions.*"> +<mx:Form xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:net="flash.net.*" xmlns:comp="custom.db.questions.*"> <mx:Script> <![CDATA[ import mx.collections.ArrayCollection; Modified: mentalmodels/trunk/src/main/db/init-mme.sql =================================================================== --- mentalmodels/trunk/src/main/db/init-mme.sql 2009-07-10 22:11:37 UTC (rev 177) +++ mentalmodels/trunk/src/main/db/init-mme.sql 2009-07-11 22:43:56 UTC (rev 178) @@ -21,14 +21,14 @@ insert into location_round_config(roundConfigs_id,location_id) values(2,3); insert into location_round_config(roundConfigs_id,location_id) values(2,4); -insert into round_config_location(roundConfig_id,locations_id) values(1,1); -insert into round_config_location(roundConfig_id,locations_id) values(1,2); -insert into round_config_location(roundConfig_id,locations_id) values(1,3); -insert into round_config_location(roundConfig_id,locations_id) values(1,4); -insert into round_config_location(roundConfig_id,locations_id) values(2,1); -insert into round_config_location(roundConfig_id,locations_id) values(2,2); -insert into round_config_location(roundConfig_id,locations_id) values(2,3); -insert into round_config_location(roundConfig_id,locations_id) values(2,4); +insert into round_config_location(round_config_id,locations_id) values(1,1); +insert into round_config_location(round_config_id,locations_id) values(1,2); +insert into round_config_location(round_config_id,locations_id) values(1,3); +insert into round_config_location(round_config_id,locations_id) values(1,4); +insert into round_config_location(round_config_id,locations_id) values(2,1); +insert into round_config_location(round_config_id,locations_id) values(2,2); +insert into round_config_location(round_config_id,locations_id) values(2,3); +insert into round_config_location(round_config_id,locations_id) values(2,4); Modified: mentalmodels/trunk/src/main/java/edu/asu/commons/mme/entity/Block.java =================================================================== --- mentalmodels/trunk/src/main/java/edu/asu/commons/mme/entity/Block.java 2009-07-10 22:11:37 UTC (rev 177) +++ mentalmodels/trunk/src/main/java/edu/asu/commons/mme/entity/Block.java 2009-07-11 22:43:56 UTC (rev 178) @@ -100,12 +100,12 @@ return duration; } - public void setInformationWindows(List<Integer> informationWindows) { + /*public void setInformationWindows(List<Integer> informationWindows) { this.informationWindows = informationWindows; } public List<Integer> getInformationWindows() { return informationWindows; - } + }*/ } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <kj...@us...> - 2009-07-10 22:11:44
|
Revision: 177 http://virtualcommons.svn.sourceforge.net/virtualcommons/?rev=177&view=rev Author: kjonas Date: 2009-07-10 22:11:37 +0000 (Fri, 10 Jul 2009) Log Message: ----------- Removed an old file, removed duplicate Question.as, fixed errors in flex code regarding changes to Actionscript code. Updated CategoricalQuestionC.mxml to properly interpret an object of Categorical.as Updated PsychometricQuestionC.mxml and its Slider.mxml to highlight the first and last items (middle, too, if isBipolar) ( it looks like this: |.........|.........| ) Modified Paths: -------------- mentalmodels/trunk/flex/src/_InstructionsTest.mxml mentalmodels/trunk/flex/src/actionscript/Block.as mentalmodels/trunk/flex/src/actionscript/PageDisplay.as mentalmodels/trunk/flex/src/actionscript/questions/Question.as mentalmodels/trunk/flex/src/custom/FisheryExperimentKalin.mxml mentalmodels/trunk/flex/src/custom/InstructionPage.mxml mentalmodels/trunk/flex/src/custom/questions/CategoricalQuestionC.mxml mentalmodels/trunk/flex/src/custom/questions/psychometric/PsychometricQuestionC.mxml mentalmodels/trunk/flex/src/custom/questions/psychometric/Slider.mxml Removed Paths: ------------- mentalmodels/trunk/flex/src/FisheryExperiment.mxml mentalmodels/trunk/flex/src/actionscript/Question.as Deleted: mentalmodels/trunk/flex/src/FisheryExperiment.mxml =================================================================== --- mentalmodels/trunk/flex/src/FisheryExperiment.mxml 2009-07-10 21:39:00 UTC (rev 176) +++ mentalmodels/trunk/flex/src/FisheryExperiment.mxml 2009-07-10 22:11:37 UTC (rev 177) @@ -1,256 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:net="flash.net.*" xmlns:comp="customComponents.*" - backgroundGradientAlphas="[1.0, 1.0]" backgroundGradientColors="[#FFFFFF, #80FFAA]" - width="760" height="510" clipContent="false" layout="absolute" - currentState="instructions" initialize="init()"> - - <mx:states> - <mx:State name="instructions"> - <mx:AddChild relativeTo="{content}"> - <comp:InstructionPage id="instructions"/> - </mx:AddChild> - </mx:State> - - <mx:State name="socioDemographic"> - <mx:AddChild relativeTo="{content}"> - <comp:SocioDemographicPage id="socioDemographic" x="265" y="100"/> - </mx:AddChild> - </mx:State> - - <mx:State name="planner"> - <mx:AddChild relativeTo="{content}"> - <comp:StrategyDesignPage id="planner"/> - </mx:AddChild> - </mx:State> - - <mx:State name="none"/> - </mx:states> - - - - <mx:Canvas id="content" x="5" y="5" width="750" height="470"/> - <mx:Canvas id="expiredContent" x="-100" y="-100" width="1" height="1" visible="false"/> - - <mx:Button id="btnBack" label="« Back" click="back()" left="8" bottom="8"/> - <mx:Button id="btnAccept" label="Accept" click="accept()" left="375" bottom="10"/> - <mx:Button id="btnForward" label="Forward »" click="forward()" right="8" bottom="8"/> - <mx:RemoteObject id="ss" destination="studentService" fault="faultHandler(event)" result="resultHandler(event)"/> - <mx:RemoteObject id="mod" destination="moduleService" fault="faultHandler(event)" result="resultHandlerModule(event)"/> - <mx:Producer id="producer" destination="DataPush" acknowledge="ack(event)"/> - <mx:Consumer id="consumer" destination="DataPush" message="messageHandler(event.message)" /> - <mx:Script> - <![CDATA[ - import actionscript.Block; - import mx.collections.ArrayCollection; - import actionscript.Module; - import flash.sampler.getInvocationCount; - import mx.controls.Label; - import customComponents.*; - import mx.controls.Alert; - import mx.rpc.events.ResultEvent; - import mx.rpc.events.FaultEvent; - import mx.messaging.messages.IMessage; - import mx.messaging.events.MessageAckEvent; - import mx.messaging.events.MessageFaultEvent; - import mx.messaging.FlexClient; - import mx.messaging.messages.AsyncMessage; - - - private var shared:SharedObject; - private var flushMessage:String; - [Bindable] - public var Id : uint; - - [Bindable] - public var module:Module; - - [Bindable] - public var randomNumbers:String; - - - private function ack(event:MessageAckEvent):void - { - //chart.setVisible(true); - randomNumbers = event.message.body as String; - //Alert.show("in ack method" + randomNumbers); - } - private function resultHandler(event:ResultEvent):void - { - Id = event.result as uint; - - Alert.show("Student id is " + Id ); - //consumer.disconnect(); - } - private function resultHandlerModule(event:ResultEvent):void - { - module = Module(event.result); - - var block:Block = module.blocks.getItemAt(0) as Block - Alert.show("block is " + block.description); - - } - private function faultHandler(event:FaultEvent):void - { - Alert.show("event fault is " + event.fault.faultDetail); - } - - private function handleFault(event:MessageFaultEvent):void - { - Alert.show("Message event fault is " + event.faultString); - } - - - private function messageHandler(message:IMessage):void - { - randomNumbers = message.body as String; - Alert.show( ""+randomNumbers); - } - - public function init():void - { - /*var sharedObjTest:Boolean = false; - if(sharedObjTest) - { - var got:Boolean = getLocal(); - if(got) - { - getData().saved1 = "Hello, World!"; - getData().thisIsATest = 283; - - var testLabel:Label = new Label(); - testLabel.text = "This is a test"; - testLabel.x = getData().thisIsATest; - testLabel.y = getData().thisIsATest; - - testLabel.text += ", " +flushMessage+"x"+shared.toString()+"x"; - getData().testLabel = testLabel; - - if(getData().exists) testLabel.text += "SharedObject existed before initialization"; - else getData().exists = true; - - this.addChild(getData().testLabel); - - } - }*/ - - // var msg:AsyncMessage = new AsyncMessage(); - //var client:FlexClient = FlexClient.getInstance(); - //creating new msg with “New” to get current state. - //msg.body = "New"; - - //producer.send(msg); - //Alert.show("message send is " + msg.body); - - - //consumer.subscribe(); - - module = mod.getFirstPage(); - - } - public function getData():Object - { - return shared.data; - } - public function getLocal():Boolean - { - try{ - shared = SharedObject.getLocal("thisIsForWork"); - }catch(err:Error){ - return false; - } - return true; - } - public function flush():Boolean - { - try{ - flushMessage = shared.flush(10000); - }catch(err:Error){ - return false; - } - return true; - } - - public function back():Boolean - { - if(content.numChildren == 0) - { return false; } - var obj:DisplayObject = content.getChildAt(0); - - if(obj is InstructionPage) - { - (InstructionPage)(obj).back(); - } - return false; - } - - public function forward():Boolean - { - if(content.numChildren == 0) - { return false; } - var obj:DisplayObject = content.getChildAt(0); - - if(obj is InstructionPage) - { - (InstructionPage)(obj).forward(); - } - return false; - } - - public function accept():Boolean - { - if(content.numChildren == 0) - { return false; } - var obj:DisplayObject = content.getChildAt(0); - - if(obj is InstructionPage) - { - if( (InstructionPage)(obj).accept() ) - { - obj.visible = false; - expiredContent.addChild(obj); - currentState = "socioDemographic"; - //consumer.subscribe(); - return true; - } - } - if(obj is SocioDemographicPage) - { - var Id:uint = 0; - if( (SocioDemographicPage)(obj).accept() ) - { - obj.visible = false; - expiredContent.addChild(obj); - currentState = "planner"; - var info:SocioDemographicPage = SocioDemographicPage(obj); - - /* Alert.show(info.getGender()); - Alert.show(info.getMajor()); - Alert.show(info.getSemester()); - Alert.show(info.getYear());*/ - Id=ss.createStudent(info.getYear(), info.getSemester(), info.getGender(),info.getMajor()); - Alert.show("Before invoking createstudent()"); - // module = mod.getFirstPage(); - return true; - } - } - if(obj is StrategyDesignPage) - { - if( (StrategyDesignPage)(obj).accept() ) - { - obj.visible = false; - expiredContent.addChild(obj); - currentState = "none"; - - return true; - } - } - - return false; - } - - - - ]]> - </mx:Script> - -</mx:Application> Modified: mentalmodels/trunk/flex/src/_InstructionsTest.mxml =================================================================== --- mentalmodels/trunk/flex/src/_InstructionsTest.mxml 2009-07-10 21:39:00 UTC (rev 176) +++ mentalmodels/trunk/flex/src/_InstructionsTest.mxml 2009-07-10 22:11:37 UTC (rev 177) @@ -65,16 +65,15 @@ var cat1:Categorical = new Categorical(); cat1.question = "categoricalQuestion"; cat1.type = "categorical"; - cat1.topics = new ArrayCollection(); - cat1.specifics = new ArrayCollection(); + cat1.categoricalOptions = new ArrayCollection(); var for1:ForecastingPeople = new ForecastingPeople(); var for2:ForecastingFish = new ForecastingFish(); - var psy1:PsychometricQuestion = new PsychometricQuestion(); + var psy1:Psychometric = new Psychometric(); psy1.question = "psychometricQuestion"; psy1.type = "psychometric"; - psy1.numberOfIntervals = 10; + psy1.maxSliderValue = 10; psy1.choices = new ArrayCollection(); psy1.choices.addItem("Highly Agree"); psy1.choices.addItem("Highly Neutral"); Modified: mentalmodels/trunk/flex/src/actionscript/Block.as =================================================================== --- mentalmodels/trunk/flex/src/actionscript/Block.as 2009-07-10 21:39:00 UTC (rev 176) +++ mentalmodels/trunk/flex/src/actionscript/Block.as 2009-07-10 22:11:37 UTC (rev 177) @@ -2,8 +2,6 @@ { import mx.collections.ArrayCollection; - import mx.formatters.NumberFormatter; - import mx.formatters.NumberBaseRoundType; [Bindable] [RemoteClass(alias="edu.asu.commons.mme.entity.Block")] Modified: mentalmodels/trunk/flex/src/actionscript/PageDisplay.as =================================================================== --- mentalmodels/trunk/flex/src/actionscript/PageDisplay.as 2009-07-10 21:39:00 UTC (rev 176) +++ mentalmodels/trunk/flex/src/actionscript/PageDisplay.as 2009-07-10 22:11:37 UTC (rev 177) @@ -1,14 +1,14 @@ // ActionScript file package actionscript { + import actionscript.questions.*; + + import custom.questions.*; import custom.questions.dayByDayDecisions.DayByDayDecisionsQuestionC; + import custom.questions.forecasting.*; import custom.questions.psychometric.PsychometricQuestionC; import custom.questions.strategyDesign.StrategyDesignQuestionC; - import custom.questions.forecasting.*; - import custom.questions.*; - import actionscript.questions.* - import flash.display.DisplayObject; import mx.collections.ArrayCollection; @@ -95,10 +95,10 @@ tempBox.addChild(cq); } - else if(tempQuestion is PsychometricQuestion) + else if(tempQuestion is Psychometric) { var pq:PsychometricQuestionC = new PsychometricQuestionC(); - pq.loadFromQuestion(PsychometricQuestion(tempQuestion)); + pq.loadFromQuestion(Psychometric(tempQuestion)); pq.id = "q"+question; tempBox.addChild(pq); Deleted: mentalmodels/trunk/flex/src/actionscript/Question.as =================================================================== --- mentalmodels/trunk/flex/src/actionscript/Question.as 2009-07-10 21:39:00 UTC (rev 176) +++ mentalmodels/trunk/flex/src/actionscript/Question.as 2009-07-10 22:11:37 UTC (rev 177) @@ -1,14 +0,0 @@ -package actionscript -{ - - [Bindable] - [RemoteClass(alias="edu.asu.commons.mme.entity.Question")] - public class Question - { - public var id:int; - public var question:String; - public var type:String; - public var sequenceNo:int; - - } -} \ 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-10 21:39:00 UTC (rev 176) +++ mentalmodels/trunk/flex/src/actionscript/questions/Question.as 2009-07-10 22:11:37 UTC (rev 177) @@ -1,4 +1,4 @@ -package actionscript +package actionscript.questions { [Bindable] Modified: mentalmodels/trunk/flex/src/custom/FisheryExperimentKalin.mxml =================================================================== --- mentalmodels/trunk/flex/src/custom/FisheryExperimentKalin.mxml 2009-07-10 21:39:00 UTC (rev 176) +++ mentalmodels/trunk/flex/src/custom/FisheryExperimentKalin.mxml 2009-07-10 22:11:37 UTC (rev 177) @@ -258,21 +258,28 @@ var cat1:Categorical = new Categorical(); cat1.question = "categoricalQuestion"; cat1.type = "categorical"; - cat1.topics = new ArrayCollection(); - cat1.specifics = new ArrayCollection(); + cat1.categoricalOptions = new ArrayCollection(); var for1:ForecastingPeople = new ForecastingPeople(); var for2:ForecastingFish = new ForecastingFish(); - var psy1:PsychometricQuestion = new PsychometricQuestion(); - psy1.question = "psychometricQuestion"; + var psy1:Psychometric = new Psychometric(); + psy1.question = "psychometricQuestionBipolar"; psy1.type = "psychometric"; - psy1.numberOfIntervals = 10; + psy1.maxSliderValue = 10; psy1.choices = new ArrayCollection(); psy1.choices.addItem("Highly Agree"); - psy1.choices.addItem("Highly Neutral"); + psy1.choices.addItem("Neutral"); psy1.choices.addItem("Highly Disagree"); + var psy2:Psychometric = new Psychometric(); + psy2.question = "psychometricQuestionUnipolar"; + psy2.type = "psychometric"; + psy2.maxSliderValue = 10; + psy2.choices = new ArrayCollection(); + psy2.choices.addItem("Strong"); + psy2.choices.addItem("Neutral"); + var str1:Question = new Question(); str1.question = "strategyDesignQuestion"; str1.type = "strategyDesign"; @@ -287,6 +294,7 @@ qg2.questions.addItem(for1); qg3.questions.addItem(for2); qg4.questions.addItem(psy1); + qg4.questions.addItem(psy2); qg5.questions.addItem(str1); qg6.questions.addItem(txt1); Modified: mentalmodels/trunk/flex/src/custom/InstructionPage.mxml =================================================================== --- mentalmodels/trunk/flex/src/custom/InstructionPage.mxml 2009-07-10 21:39:00 UTC (rev 176) +++ mentalmodels/trunk/flex/src/custom/InstructionPage.mxml 2009-07-10 22:11:37 UTC (rev 177) @@ -127,7 +127,7 @@ currBlock = nextBlock; init(module.blocks.getItemAt(currBlock) as Block); - numPages = 1; + numPages = pageDisplay.pages.length; return false; } else Modified: mentalmodels/trunk/flex/src/custom/questions/CategoricalQuestionC.mxml =================================================================== --- mentalmodels/trunk/flex/src/custom/questions/CategoricalQuestionC.mxml 2009-07-10 21:39:00 UTC (rev 176) +++ mentalmodels/trunk/flex/src/custom/questions/CategoricalQuestionC.mxml 2009-07-10 22:11:37 UTC (rev 177) @@ -12,6 +12,7 @@ <mx:Script> <![CDATA[ + import actionscript.questions.CategoricalOption; import actionscript.questions.Categorical; private function fix(index:int, list:ArrayCollection):int @@ -37,9 +38,19 @@ public function loadFromQuestion(question:Categorical):void { - initialize(); // init(); + + topics = new ArrayCollection(); + specifics = new ArrayCollection(); + + var arry:ArrayCollection = question.categoricalOptions; + for(var i:int = 0; i < arry.length; i++) + { + topics.addItem((arry.getItemAt(i) as CategoricalOption).optionKey); + specifics.addItem((arry.getItemAt(i) as CategoricalOption).choices); + } + description = question.question; } Modified: mentalmodels/trunk/flex/src/custom/questions/psychometric/PsychometricQuestionC.mxml =================================================================== --- mentalmodels/trunk/flex/src/custom/questions/psychometric/PsychometricQuestionC.mxml 2009-07-10 21:39:00 UTC (rev 176) +++ mentalmodels/trunk/flex/src/custom/questions/psychometric/PsychometricQuestionC.mxml 2009-07-10 22:11:37 UTC (rev 177) @@ -10,13 +10,13 @@ <mx:Label id="topright" text="topright" x="300" y="0" width="100" textAlign="right" visible="false"/> <!-- Used for unipolar psychometric scales --> - <mx:Label id="farleft" text="farleft" x="0" y="0" width="100" textAlign="center" visible="false"/> - <mx:Label id="farright" text="farright" x="300" y="0" width="100" textAlign="center" visible="false"/> + <mx:Label id="farleft" text="farleft" x="0" y="0" width="100" textAlign="left" visible="false"/> + <mx:Label id="farright" text="farright" x="110" y="0" width="100" textAlign="right" visible="false"/> </mx:Canvas> <mx:Script> <![CDATA[ - import actionscript.questions.PsychometricQuestion; + import actionscript.questions.Psychometric; import mx.collections.ArrayCollection; import custom.questions.psychometric.Slider; @@ -40,8 +40,8 @@ content.removeChild(topmid); content.removeChild(topright); slider1.isBipolar = false; - slider1.x = 100; - slider1.y = 0; + slider1.x = 0; + slider1.y = 36; } else if(labels.length == 3) { @@ -87,17 +87,17 @@ slider1.sliderButton.move(loadArray.getItemAt(1) as Number, 0); } - public function loadFromQuestion(question:PsychometricQuestion):void + public function loadFromQuestion(question:Psychometric):void { description = question.question; - maxValue = question.numberOfIntervals; + maxValue = question.maxSliderValue; labels = loadChoices(question); initialize(); init(); } - private function loadChoices(question:PsychometricQuestion):ArrayCollection + private function loadChoices(question:Psychometric):ArrayCollection { var choices:ArrayCollection = new ArrayCollection(); Modified: mentalmodels/trunk/flex/src/custom/questions/psychometric/Slider.mxml =================================================================== --- mentalmodels/trunk/flex/src/custom/questions/psychometric/Slider.mxml 2009-07-10 21:39:00 UTC (rev 176) +++ mentalmodels/trunk/flex/src/custom/questions/psychometric/Slider.mxml 2009-07-10 22:11:37 UTC (rev 177) @@ -46,15 +46,23 @@ private function addTicks():void { - var numTicks:Number = maxValue - minValue + 1; + var numTicks:int = int( maxValue - minValue + 1 ); var separation:Number = (sliderBar.width - imageWidth) / (numTicks-1) var ticks:Array = new Array(numTicks); - for(var i:Number = 0; i < numTicks; i++) + for(var i:int = 0; i < numTicks; i++) { var tick:Label = new Label(); - tick.htmlText = "<b>.</b>"; + if(i == 0 || i == numTicks-1 || (i == int(numTicks / 2) && isBipolar)) + { + tick.htmlText = "<b>|</b>"; + tick.setStyle("fontSize",12); + } + else + { + tick.htmlText = "<b>.</b>"; + } tick.x = i*separation - imageWidth/2; tick.y = -10; addChild(tick); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <see...@us...> - 2009-07-10 21:39:07
|
Revision: 176 http://virtualcommons.svn.sourceforge.net/virtualcommons/?rev=176&view=rev Author: seematalele Date: 2009-07-10 21:39:00 +0000 (Fri, 10 Jul 2009) Log Message: ----------- Was Getting errors in some files. So Corrected errors like class name changed but did not reflected everywhere in flex. Modified Paths: -------------- mentalmodels/trunk/flex/src/InitialiseDatabase.mxml mentalmodels/trunk/flex/src/actionscript/Block.as mentalmodels/trunk/flex/src/actionscript/QuestionGroup.as mentalmodels/trunk/flex/src/actionscript/questions/Categorical.as mentalmodels/trunk/flex/src/actionscript/questions/Question.as mentalmodels/trunk/src/main/java/edu/asu/commons/mme/entity/Block.java Added Paths: ----------- mentalmodels/trunk/flex/src/actionscript/questions/CategoricalOption.as mentalmodels/trunk/flex/src/actionscript/questions/Psychometric.as Removed Paths: ------------- mentalmodels/trunk/flex/src/actionscript/Categorical.as mentalmodels/trunk/flex/src/actionscript/CategoricalOption.as mentalmodels/trunk/flex/src/actionscript/Psychometric.as Modified: mentalmodels/trunk/flex/src/InitialiseDatabase.mxml =================================================================== --- mentalmodels/trunk/flex/src/InitialiseDatabase.mxml 2009-07-10 21:02:20 UTC (rev 175) +++ mentalmodels/trunk/flex/src/InitialiseDatabase.mxml 2009-07-10 21:39:00 UTC (rev 176) @@ -14,8 +14,9 @@ import actionscript.Module; import actionscript.Question; import actionscript.QuestionGroup; - import actionscript.Categorical; - import actionscript.CategoricalOption; + import actionscript.questions.Categorical; + import actionscript.questions.CategoricalOption; + import actionscript.questions.Psychometric; import mx.collections.ArrayCollection; Modified: mentalmodels/trunk/flex/src/actionscript/Block.as =================================================================== --- mentalmodels/trunk/flex/src/actionscript/Block.as 2009-07-10 21:02:20 UTC (rev 175) +++ mentalmodels/trunk/flex/src/actionscript/Block.as 2009-07-10 21:39:00 UTC (rev 176) @@ -13,7 +13,7 @@ public var sequenceNo:int; public var description:String; public var duration:int; - public var module:ASModule; + public var module:Module; public var questionGroups:ArrayCollection; public var informationWindows:ArrayCollection; Deleted: mentalmodels/trunk/flex/src/actionscript/Categorical.as =================================================================== --- mentalmodels/trunk/flex/src/actionscript/Categorical.as 2009-07-10 21:02:20 UTC (rev 175) +++ mentalmodels/trunk/flex/src/actionscript/Categorical.as 2009-07-10 21:39:00 UTC (rev 176) @@ -1,12 +0,0 @@ -package actionscript -{ - import mx.collections.ArrayCollection; - - [Bindable] - [RemoteClass(alias="edu.asu.commons.mme.entity.CategoricalQuestion")] - public class Categorical extends Question - { - - public var categoricalOptions:ArrayCollection = new ArrayCollection(); - } -} \ No newline at end of file Deleted: mentalmodels/trunk/flex/src/actionscript/CategoricalOption.as =================================================================== --- mentalmodels/trunk/flex/src/actionscript/CategoricalOption.as 2009-07-10 21:02:20 UTC (rev 175) +++ mentalmodels/trunk/flex/src/actionscript/CategoricalOption.as 2009-07-10 21:39:00 UTC (rev 176) @@ -1,14 +0,0 @@ -package actionscript.initDB.ASquestions -{ - import mx.collections.ArrayCollection; - - [Bindable] - [RemoteClass(alias="edu.asu.commons.mme.entity.CategoricalOption")] - public class CategoricalOption - { - public var optionKey:String; - - public var choices:ArrayCollection = new ArrayCollection(); - - } -} \ No newline at end of file Deleted: mentalmodels/trunk/flex/src/actionscript/Psychometric.as =================================================================== --- mentalmodels/trunk/flex/src/actionscript/Psychometric.as 2009-07-10 21:02:20 UTC (rev 175) +++ mentalmodels/trunk/flex/src/actionscript/Psychometric.as 2009-07-10 21:39:00 UTC (rev 176) @@ -1,19 +0,0 @@ -package actionscript -{ - - - import mx.collections.ArrayCollection; - - [Bindable] - [RemoteClass(alias="edu.asu.commons.mme.entity.PsychometricQuestion")] - public class Psychometric extends Question - { - - public var scale:String; - - public var choices:ArrayCollection; - - public var maxSliderValue:int; - - } -} \ No newline at end of file Modified: mentalmodels/trunk/flex/src/actionscript/QuestionGroup.as =================================================================== --- mentalmodels/trunk/flex/src/actionscript/QuestionGroup.as 2009-07-10 21:02:20 UTC (rev 175) +++ mentalmodels/trunk/flex/src/actionscript/QuestionGroup.as 2009-07-10 21:39:00 UTC (rev 176) @@ -4,13 +4,13 @@ [Bindable] [RemoteClass(alias="edu.asu.commons.mme.entity.QuestionGroup")] - public class ASQuestionGroup + public class QuestionGroup { public var id:Number; public var questions:ArrayCollection; public var sequenceNo:int; public var header:String; public var description:String; - public var block:ASBlock; + public var block:Block; } } \ No newline at end of file Modified: mentalmodels/trunk/flex/src/actionscript/questions/Categorical.as =================================================================== --- mentalmodels/trunk/flex/src/actionscript/questions/Categorical.as 2009-07-10 21:02:20 UTC (rev 175) +++ mentalmodels/trunk/flex/src/actionscript/questions/Categorical.as 2009-07-10 21:39:00 UTC (rev 176) @@ -1,14 +1,12 @@ -package actionscript.questions -{ - import mx.collections.ArrayCollection; - - [Bindable] - [RemoteClass(alias="edu.asu.commons.mme.entity.CategoricalQuestion")] - public class Categorical extends Question - { - public var choices:Object; - - public var topics:ArrayCollection; - public var specifics:ArrayCollection; - } +package actionscript.questions +{ + import mx.collections.ArrayCollection; + + [Bindable] + [RemoteClass(alias="edu.asu.commons.mme.entity.CategoricalQuestion")] + public class Categorical extends Question + { + + public var categoricalOptions:ArrayCollection = new ArrayCollection(); + } } \ No newline at end of file Added: mentalmodels/trunk/flex/src/actionscript/questions/CategoricalOption.as =================================================================== --- mentalmodels/trunk/flex/src/actionscript/questions/CategoricalOption.as (rev 0) +++ mentalmodels/trunk/flex/src/actionscript/questions/CategoricalOption.as 2009-07-10 21:39:00 UTC (rev 176) @@ -0,0 +1,14 @@ +package actionscript.questions +{ + import mx.collections.ArrayCollection; + + [Bindable] + [RemoteClass(alias="edu.asu.commons.mme.entity.CategoricalOption")] + public class CategoricalOption + { + public var optionKey:String; + + public var choices:ArrayCollection = new ArrayCollection(); + + } +} \ No newline at end of file Added: mentalmodels/trunk/flex/src/actionscript/questions/Psychometric.as =================================================================== --- mentalmodels/trunk/flex/src/actionscript/questions/Psychometric.as (rev 0) +++ mentalmodels/trunk/flex/src/actionscript/questions/Psychometric.as 2009-07-10 21:39:00 UTC (rev 176) @@ -0,0 +1,19 @@ +package actionscript.questions +{ + + + import mx.collections.ArrayCollection; + + [Bindable] + [RemoteClass(alias="edu.asu.commons.mme.entity.PsychometricQuestion")] + public class Psychometric extends Question + { + + public var scale:String; + + public var choices:ArrayCollection; + + public var maxSliderValue:int; + + } +} \ 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-10 21:02:20 UTC (rev 175) +++ mentalmodels/trunk/flex/src/actionscript/questions/Question.as 2009-07-10 21:39:00 UTC (rev 176) @@ -1,17 +1,14 @@ -package actionscript.questions -{ - import mx.collections.ArrayCollection; - - [Bindable] - [RemoteClass(alias="edu.asu.commons.mme.entity.Question")] - public class Question - { - public var id:Number; - public var question:String; - public var type:String; - public var singleLocation:Boolean; - public var multiLocation:Boolean; - public var miscLocation:Boolean; - public var sequenceNo:int; - } +package actionscript +{ + + [Bindable] + [RemoteClass(alias="edu.asu.commons.mme.entity.Question")] + public class Question + { + public var id:int; + public var question:String; + public var type:String; + public var sequenceNo:int; + + } } \ No newline at end of file Modified: mentalmodels/trunk/src/main/java/edu/asu/commons/mme/entity/Block.java =================================================================== --- mentalmodels/trunk/src/main/java/edu/asu/commons/mme/entity/Block.java 2009-07-10 21:02:20 UTC (rev 175) +++ mentalmodels/trunk/src/main/java/edu/asu/commons/mme/entity/Block.java 2009-07-10 21:39:00 UTC (rev 176) @@ -49,6 +49,7 @@ @OrderBy("sequenceNo") private List<QuestionGroup> questionGroups; + public void setId(Long id) { this.id = id; } @@ -99,4 +100,12 @@ return duration; } + public void setInformationWindows(List<Integer> informationWindows) { + this.informationWindows = informationWindows; + } + + public List<Integer> getInformationWindows() { + return informationWindows; + } + } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <see...@us...> - 2009-07-10 21:02:32
|
Revision: 175 http://virtualcommons.svn.sourceforge.net/virtualcommons/?rev=175&view=rev Author: seematalele Date: 2009-07-10 21:02:20 +0000 (Fri, 10 Jul 2009) Log Message: ----------- Database initialization working fine. It loads data from database if any. Rename some files. Clean up the folder flex folder. Deleted duplicated files. 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/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/dao/HibernateModuleDao.java mentalmodels/trunk/src/main/java/edu/asu/commons/mme/entity/Block.java mentalmodels/trunk/src/main/java/edu/asu/commons/mme/entity/CategoricalOption.java mentalmodels/trunk/src/main/java/edu/asu/commons/mme/entity/Game.java mentalmodels/trunk/src/main/java/edu/asu/commons/mme/entity/Module.java mentalmodels/trunk/src/main/java/edu/asu/commons/mme/entity/PsychometricQuestion.java mentalmodels/trunk/src/main/java/edu/asu/commons/mme/entity/Question.java 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/webapp/WEB-INF/applicationContext.xml Added Paths: ----------- mentalmodels/trunk/flex/src/actionscript/Categorical.as mentalmodels/trunk/flex/src/actionscript/CategoricalOption.as mentalmodels/trunk/flex/src/actionscript/Psychometric.as mentalmodels/trunk/flex/src/actionscript/Question.as mentalmodels/trunk/src/main/java/edu/asu/commons/mme/dao/HibernateQuestionGroupDao.java Removed Paths: ------------- mentalmodels/trunk/flex/src/actionscript/ASCategorical.as mentalmodels/trunk/flex/src/actionscript/ASPsychometric.as mentalmodels/trunk/flex/src/actionscript/ASQuestion.as mentalmodels/trunk/flex/src/actionscript/ASResults.as Modified: mentalmodels/trunk/flex/src/InitialiseDatabase.mxml =================================================================== --- mentalmodels/trunk/flex/src/InitialiseDatabase.mxml 2009-07-10 07:04:06 UTC (rev 174) +++ mentalmodels/trunk/flex/src/InitialiseDatabase.mxml 2009-07-10 21:02:20 UTC (rev 175) @@ -1,28 +1,41 @@ <?xml version="1.0" encoding="utf-8"?> -<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:net="flash.net.*" xmlns:comp="customComponents.db.*" +<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:net="flash.net.*" xmlns:comp="customComponents.db.questions.*" xmlns:basicComp="customComponents.db.*" backgroundGradientAlphas="[1.0, 1.0]" backgroundGradientColors="[#FFFFFF, #80FFAA]" - width="100%" height="100%" clipContent="false" layout="absolute" currentState="none"> + width="100%" height="100%" clipContent="false" layout="absolute" currentState="none" initialize="init()"> <mx:Script> <![CDATA[ + import mx.binding.utils.BindingUtils; + import customComponents.db.questions.Psychometric; import customComponents.db.questions.CategoricalSimple; import customComponents.db.questions.CategoricalRelative; import customComponents.db.questions.Categorical; + + import actionscript.Block; + import actionscript.Module; + import actionscript.Question; + import actionscript.QuestionGroup; + import actionscript.Categorical; + import actionscript.CategoricalOption; + + import mx.collections.ArrayCollection; import mx.effects.Fade; import mx.collections.XMLListCollection; import mx.controls.Alert; + import mx.rpc.events.FaultEvent; + import mx.rpc.events.ResultEvent; - import actionscript.*; + /* 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 */ - public static var Qid:int = 2; + //public static var Qid:int = 2; + [Bindable] - private var company:XML = - <list> - - <module title="Preexperiment" sequenceNo="1" hours="0" min="3" sec="0" id="1"> + private var survey:XML = + <list> + <module title="Preexperiment" sequenceNo="1" hours="0" min="3" sec="0" id="1"> <block name="Introduction" sequenceNo="1" hours="0" min="3" sec="0" id="1"> <questiongroup header="Welcome to E-Fishery Experiment" description="In this experiment you will design..." sequenceNo="1" id="1"/> @@ -32,29 +45,295 @@ <module title ="Game Round" sequenceNo="2" hours="1" min="30" sec="0" id="2"> <block name="Characterizing Own Strategy" sequenceNo="1" hours="0" min="30" sec="0" id="2"> <questiongroup header="What goals did you follow when designing your strategy" description="Please specify three goals..." sequenceNo="1" id="2"> - <question title="Most important goal" type="psychometric" sequenceNo="1" id="1"> - + <question title="Most important goal" type="categorical" sequenceNo="1" id="1" > </question> - <question title="second important goal" type="catgorical" sequenceNo="2" id="2"> - </question> + <question title="second important goal" type="psychometric" sequenceNo="2" id="2" > + </question> + + </questiongroup> </block> - </module> - - </list>; - + </module> + </list>; + /*[Bindable] + private var survey:XML = + <list> + <module title="Survey Questions" /> + </list>;*/ + + + /*[Bindable] + private var questions:XML = + <list> + <categorical id="1" type="relative"> + <optionKey name="fish" > + + </optionKey> + </categorical> + <categorical id="2" type="simple"> + <optionKey name="poeple" > + + </optionKey> + </categorical> + <psychometric id="1" scale="bipolar" numberOfIntervals="21"> + + </psychometric> + + </list>; */ + + + [Bindable] + private var categoricalQuestions:XML = + <list> + <categorical type="Categorical Questions" id="0"/> + <categorical type="relative" id="2"> + <option name="focus on earning" choice1="less" choice2="more" choice3="most" /> + <option name="focus on fish" choice1="123" choice2="more than 123" choice3="none" /> + </categorical> + <categorical type="simple" id="1"> + <option choice1="less" choice2="more" choice3="most" /> + + </categorical> + + </list>; + + [Bindable] + private var psychometricQuestions:XML = + <list> + <psychometric scale="Psychometric Questions" id="0"/> + <psychometric scale="bipolar" id="2" choice1="good" choice2="better" choice3="best" interval="21" /> + + + </list>; + + [Bindable] - private var companyData:XMLListCollection = new XMLListCollection(company.module); + private var surveyData:XMLListCollection = new XMLListCollection(survey.module); + + private var CategoricalquestionsData:XMLListCollection = new XMLListCollection(categoricalQuestions.categorical); + + private var PsychometricquestionsData:XMLListCollection = new XMLListCollection(psychometricQuestions.psychometric); - public var tempQuestion:ArrayCollection = new ArrayCollection(); + public var tempQuestion:ArrayCollection = new ArrayCollection(); + + private function init():void + { + roQuestionCreator.initializeData(); + } + + private function resultInitializeDataHandler(event:ResultEvent):void + { + //Alert.show(event.result.toString()); + var modulelist:ArrayCollection = new ArrayCollection(); + modulelist = event.result as ArrayCollection; + + + if(modulelist != null) + { + for(var i:int = 0 ; i < modulelist.length ; i++) + { + var module:Module = new Module(); + module = modulelist[i]; + + + //create module node and add into the tree + var newModuleNode:XML = createModuleNode(module); + + survey.appendChild(newModuleNode); + + //if any blocks, add into the module + if(module.blocks != null) + { + for(var blockCounter:int = 0; blockCounter < module.blocks.length; blockCounter++) + { + var block:Block = new Block(); + block = module.blocks[blockCounter]; + + var newBlockNode:XML = createBlockNode(block); + newModuleNode.appendChild(newBlockNode); + + + if(block.questionGroups != null) + { + //if any question Group, add into the block + for(var qgCounter:int = 0; qgCounter < block.questionGroups.length; qgCounter++) + { + var qg:QuestionGroup = new QuestionGroup(); + qg = block.questionGroups[qgCounter]; + + var newQuestionGroupNode:XML = createQuestionGroupNode(qg); + newBlockNode.appendChild(newQuestionGroupNode); + if(qg.questions != null) + { + for(var QCounter:int = 0; QCounter < qg.questions.length; QCounter++) + { + var question:Question = new Question(); + question = qg.questions[QCounter]; + var newQuestionNode:XML = createQuestionNode(question); + newQuestionGroupNode.appendChild(newQuestionNode); + } + } + + } + } + } + } + } + + } + + } + + private function createModuleNode(module:Module):XML + { + + + var newModuleNode:XML = <module/>; + 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; + + + return newModuleNode; + + } + private function createBlockNode(block:Block):XML + { + var newBlockNode:XML = <block/>; + 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; + + return newBlockNode; + + } + + private function createQuestionGroupNode(questionGroup:QuestionGroup):XML + { + var newNode:XML = <questiongroup/>; + newNode.setLocalName("questiongroup"); + newNode.@header = questionGroup.header; + newNode.@description = questionGroup.description; + newNode.@sequenceNo = questionGroup.sequenceNo; + newNode.@id = questionGroup.id; + + return newNode; + + } + + private function createQuestionNode(question:Question):XML + { + var newQNode:XML = <question/>; + newQNode.setLocalName("question"); + if(question.type.toLowerCase() == "psychometric") + { + var psychometricResult:Psychometric = 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 = <psychometric/>; + newPNode.setLocalName("psychometric"); + newPNode.@id = psychometricResult.id; + newPNode.@scale = psychometricResult.scale; + newPNode.@noOfInterval = 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]; + } + + psychometricQuestions.appendChild(newPNode); + + } + else if(question.type.toLowerCase() == "categorical") + { + var categoricalResult:Categorical = 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; + }*/ + + var newCNode:XML = <categorical/>; + newCNode.setLocalName("categorical"); + newCNode.@id = categoricalResult.id; + categoricalQuestions.appendChild(newCNode); + + for(var i:int = 0; i < categoricalResult.categoricalOptions.length ; i++) + { + var options:CategoricalOption = new CategoricalOption(); + options = CategoricalOption(categoricalResult.categoricalOptions.getItemAt(i)); + var newOptionNode:XML = <option/>; + 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); + } + + + } + return newQNode; + + } + + private function faultHandler(event:FaultEvent):void + { + Alert.show("event fault is " + event.fault.getStackTrace()); + } + private function treeLabel(item:Object):String { - var node:XML = XML(item); if( node.localName() == "module" ) @@ -73,17 +352,43 @@ return null; } - + private function treeLabelPsychometricQ(item:Object):String + { + var node:XML = XML(item); + + if( node.localName() == "psychometric" ) + return node.@scale; + + else + return node.@name; + + } + + private function treeLabelCategoricalQ(item:Object):String + { + var node:XML = XML(item); + + if( node.localName() == "categorical" ) + return node.@type; + + + else + return node.@name; + + } + public function isDurationValid(hours:Number,minutes:Number,seconds:Number):Boolean { return (hours == 0 && minutes == 0 && seconds == 0); } + //Module Functionality Start private function addModule():void { currentState = "module"; var obj:DisplayObject = pnlComponent.getChildAt(1); + var moduleInfo:Module = Module(obj); moduleInfo.reset(); btnsaveModule.enabled = true; @@ -91,7 +396,7 @@ btnsaveBlock.enabled = false; btnsaveQuestionGroup.enabled = false; btnsaveQuestion.enabled = false; - + } private function saveModule(event:Event):void @@ -110,18 +415,17 @@ } else { - var newNode:XML = <module/> - newNode.setLocalName("module"); - newNode.@title=moduleInfo.getName(); - newNode.@sequenceNo =moduleInfo.getSequenceNo(); - newNode.@hours = moduleInfo.getHours(); - newNode.@min = moduleInfo.getMinutes(); - newNode.@sec = moduleInfo.getSeconds(); - company.appendChild(newNode); + 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())); + } + else + roQuestionCreator.updateModule(moduleInfo.getId(),seqNo, title, getDuration(moduleInfo.getHours(),moduleInfo.getMinutes(),moduleInfo.getSeconds())); currentState = "none"; btnsaveModule.enabled = false; - // pnlComponent.removeChildAt(1); - + //pnlComponent.removeChildAt(1); } } @@ -132,8 +436,50 @@ } + private function getDuration(hours:int,min:int,sec:int):int + { + return hours * 3600 + min * 60 + sec; + } - + //when module is created, the result will come to resultSaveModuleHandler + public function resultSaveModuleHandler(event:ResultEvent):void + { + var module:Module = Module(event.result as Object); + Alert.show("Id is: " + module.id); + var newModuleNode:XML = <module/>; + 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) + { + surveyData= new XMLListCollection(survey.module); + } + + + + } + + //when module is updated, the result will come to resultUpdateModuleHandler + public function resultUpdateModuleHandler(event:ResultEvent):void + { + var module:Module = 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(); + + } + + //Module Functionality Stop + + //Block functionality Start private function addBlock():void { currentState = "block"; @@ -144,8 +490,7 @@ btnsaveModule.enabled = false; btnsaveQuestionGroup.enabled = false; btnsaveQuestion.enabled = false; - - + } private function saveBlock(event:Event):void @@ -154,53 +499,114 @@ var obj:DisplayObject = pnlComponent.getChildAt(1); var blockInfo:Block = Block(obj); - var node:XML = tree.selectedItem as XML; - + var selectedNode:XML = tree.selectedItem as XML; + //Alert.show("enter info","",Alert.OK | Alert.); if(tree.selectedItem == null) { Alert.show("Please select the module from tree to which block should be added."); + return; } else { var isBlockFormValid:Boolean = blockInfo.validateForm(event); + //Alert.show("Local name is: " + selectedNode.localName()); + if(isBlockFormValid) { var durationflag:Boolean = this.isDurationValid(blockInfo.getHours(),blockInfo.getMinutes(),blockInfo.getSeconds()); if(durationflag) { Alert.show("Please enter the valid duration for the given block."); + return; } - else + else { - var newNode:XML = <block/> - newNode.setLocalName("block"); - newNode.@name=blockInfo.getName(); - newNode.@sequenceNo =blockInfo.getSequenceNo(); - newNode.@hours = blockInfo.getHours(); - newNode.@min = blockInfo.getMinutes(); - newNode.@sec = blockInfo.getSeconds(); - - - var module:XMLList =company.module.(@title == node.@title); + + var node:XML; + if(selectedNode.localName() == "module") + { + node = selectedNode; + } + else + { + 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()); if( module.length() > 0 ) { - module[0].appendChild(newNode); - currentState = "none"; - btnsaveBlock.enabled = false; - - } - - } + // 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)); + } + currentState = "none"; + btnsaveBlock.enabled = false; + // pnlComponent.removeChildAt(1); + } + } } else { Alert.show("Please fill the form correctly"); + return; } } } + //when block is created, the result will come to resultSaveBlockHandler + public function resultSaveBlockHandler(event:ResultEvent):void + { + var block:Block = Block(event.result as Object); + if(block != null) + { + + var newBlockNode:XML = <block/>; + 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 tempmodule:Module = block.module; + + var module:XMLList = survey.module.(@id == tempmodule.id); + if( module.length() > 0 ) + { + module[0].appendChild(newBlockNode); + } + } + + + } + + public function resultUpdateBlockHandler(event:ResultEvent):void + { + var block:Block = Block(event.result as Object); + + var tempmodule: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(); + + } + //Block functioanlity Stop + + + //QuestionGroup functionality Start private function addQuestionGroup():void { currentState = "questionGroup"; @@ -217,10 +623,11 @@ private function saveQuestionGroup(event:Event):void { - - - var node:XML = tree.selectedItem as XML; - + + var selectedNode:XML = tree.selectedItem as XML; + var obj:DisplayObject = pnlComponent.getChildAt(1); + var questionGroupInfo:QuestionGroup = 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."); @@ -230,14 +637,14 @@ { //if(tree.getParentItem(tree.selectedItem) == null) - if(node.localName() == "module") + if(selectedNode.localName() == "module") { Alert.show("You can not add QuestionGroup to Module."); return; } else { - if(node.localName() == "questiongroup" ) + if(selectedNode.localName() == "questiongroup" && questionGroupInfo.getId() == 0) { Alert.show("You can not add QuestionGroup to QuestionGroup."); return; @@ -247,33 +654,90 @@ { //find out the parent module var parentModule:XML = tree.getParentItem(tree.selectedItem) as XML; - var obj:DisplayObject = pnlComponent.getChildAt(1); - var questionGroupInfo:QuestionGroup = QuestionGroup(obj); + + var isQuestionGroupFormValid:Boolean = questionGroupInfo.validateForm(event); if(isQuestionGroupFormValid) { - - var newNode:XML = <questiongroup/>; - newNode.setLocalName("questiongroup"); - newNode.@header = questionGroupInfo.getHeader(); - newNode.@description = questionGroupInfo.getDescription(); - newNode.@sequenceNo = questionGroupInfo.getSequenceNo(); - - var block:XMLList =company.module.block.(@name == node.@name); - Alert.show(block.@name + "is name of the block"); + var node:XML; + /** + * Check if the selected node is block, if it is new Question Group needs to be created. + else if selected node is Question Group, then Question Group needs to be updated.*/ + + if(selectedNode.localName() == "block") + { + node = selectedNode; + } + else if(selectedNode.localName() == "questiongroup") + { + var parentNode:XML = tree.getParentItem(tree.selectedItem) as XML; + node = parentNode; + } + var block:XMLList = survey.module.block.(@id == node.@id); + //Alert.show("block id is : " + block[0].@id + "length is: " + block.length()); if( block.length() > 0 ) - { - block[0].appendChild(newNode); - currentState = "none"; - btnsaveQuestionGroup.enabled = false; - - } + { + 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()); + } + currentState = "none"; + btnsaveQuestionGroup.enabled = false; + //pnlComponent.removeChildAt(1); + } } } } } } + + //when QuestionGroup is created, the result will come to resultSaveQuestionGroupHandler + public function resultSaveQuestionGroupHandler(event:ResultEvent):void + { + var questionGroup:QuestionGroup = QuestionGroup(event.result as Object); + Alert.show("Id is: " + questionGroup.id); + var newNode:XML = <questiongroup/>; + newNode.setLocalName("questiongroup"); + newNode.@header = questionGroup.header; + newNode.@description = questionGroup.description; + newNode.@sequenceNo = questionGroup.sequenceNo; + newNode.@id = questionGroup.id; + + var block:Block = questionGroup.block; + + var blockXML:XMLList =survey.module.block.(@id == block.id); + + if( blockXML.length() > 0 ) + { + blockXML[0].appendChild(newNode); + + } + + } + + //when QuestionGroup is updated, the result will come to resultUpdateQuestionGroupHandler + public function resultUpdateQuestionGroupHandler(event:ResultEvent):void + { + var questionGroup:QuestionGroup = QuestionGroup(event.result as Object); + Alert.show("Id is: " + questionGroup.id); + var newNode:XML = <questiongroup/>; + newNode.setLocalName("questiongroup"); + newNode.@header = questionGroup.header; + newNode.@description = questionGroup.description; + newNode.@sequenceNo = questionGroup.sequenceNo; + var block:Block = questionGroup.block; + + } + + //QuestionGroup functionality Stop + + + //Question functionality Start private function addQuestion():void { currentState = "question"; @@ -287,6 +751,25 @@ btnsaveQuestion.enabled = true; } + private function QuestionHandler(event:Event):void + { + if(question.cmbType.selectedItem.toString().toLowerCase() == "psychometric") + currentState = "psychometric"; + else if(question.cmbType.selectedItem.toString().toLowerCase() == "categorical") + currentState = "categorical"; + + } + + private function CategoricalTypeHandler(event:Event):void + { + if(categorical.cmbType.selectedItem.toString().toLowerCase() == "relative") + currentState = "relative"; + else if(categorical.cmbType.selectedItem.toString().toLowerCase() == "simple") + currentState = "simple"; + } + + + private function saveQuestion(event:Event):void { var node:XML = tree.selectedItem as XML; @@ -315,49 +798,195 @@ if(isQuestionGroupFormValid) { - - var newNode:XML = <question/>; - newNode.setLocalName("question"); - newNode.@sequenceNo = questionInfo.getSequenceNo(); - newNode.@title = questionInfo.getQuestion(); - newNode.@type = questionInfo.getType(); - newNode.@id = ++Qid; - var questionGroup:XMLList =company.module.block.questiongroup.(@header == node.@header); - - if( questionGroup.length() > 0 ) - { - questionGroup[0].appendChild(newNode); - currentState = "none"; - btnsaveQuestion.enabled = false; - - } - var ques:ASQuestion = new ASQuestion(newNode.@id); - if(questionInfo.getType().toLowerCase() == "categorical") - { - var cat:ASCategorical = new ASCategorical(newNode.@id); - - var compCategorical:Categorical = Categorical(questionInfo.getQuestionInfo()); - if(compCategorical.getCategoricalType().toLowerCase() == "relative") - { - var relative:CategoricalRelative = CategoricalRelative(compCategorical.getCategoricalInfo()); - cat.setDictionary(relative.dict); - } - else - { - var simple:CategoricalSimple = CategoricalSimple(compCategorical.getCategoricalInfo()); - cat.setDictionary(simple.dict); - } - ques.setQtype(cat); - } - - tempQuestion.addItem(ques); + + if(currentState == "psychometric") + { + var psychobj:DisplayObject = pnlComponent.getChildAt(2); + + var compPsychometric:Psychometric = Psychometric(psychobj); + + var asPsychometric:Psychometric = new 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:Categorical = new Categorical(); + + var dict:Dictionary = new Dictionary(); + dict = compCategorical.getDictionary(); + for (var key:Object in dict) + { + var Options:CategoricalOption = new 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:CategoricalOption = new CategoricalOption(); + testoption = 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:CategoricalSimple = CategoricalSimple(catSimpleobj); + var categoricalSimpleQuestion:Categorical = new Categorical(); + + + var Simpledict:Dictionary = new Dictionary(); + Simpledict = compCategoricalSimple.getDictionary(); + for (var option:Object in Simpledict) + { + var OptionsSimple:CategoricalOption = new 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)); + } + } } - } - + } + 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 questionResult:Psychometric = 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 newPNode:XML = <psychometric/>; + 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 str:String = "choice"; + str = str + j; + newPNode.@str = questionResult.choices[j]; + } + + psychometricQuestions.appendChild(newPNode); + + } + else if(test_object.type.toLowerCase() == "categorical") + { + var categoricalResult:Categorical = Categorical(test_object); + var newQNode:XML = <question/>; + newQNode.setLocalName("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; + } + + var newCNode:XML = <categorical/>; + newCNode.setLocalName("categorical"); + newCNode.@id = categoricalResult.id; + categoricalQuestions.appendChild(newCNode); + + for(var i:int = 0; i < categoricalResult.categoricalOptions.length ; i++) + { + var options:CategoricalOption = new CategoricalOption(); + options = CategoricalOption(categoricalResult.categoricalOptions.getItemAt(i)); + var newOptionNode:XML = <option/>; + 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); + } + + + } + + currentState = "none"; + btnsaveQuestion.enabled = false; + + + } + + public function resultUpdateQuestionHandler(event:Event):void + { + + } + //Question functionality Stop public function removeItem():void { currentState = "none"; @@ -380,7 +1009,7 @@ if( children[i].@name == node.@name ) { - delete children[i]; + delete children[i].@*; } } @@ -410,6 +1039,7 @@ moduleInfo.setHours(node.@hours); moduleInfo.setMinutes(node.@min); moduleInfo.setSeconds(node.@sec); + moduleInfo.setId(node.@id); } if(node.localName() == "block") @@ -427,7 +1057,8 @@ blockInfo.setSequenceNo(node.@sequenceNo); blockInfo.setHours(node.@hours); blockInfo.setMinutes(node.@min); - blockInfo.setSeconds(node.@sec); + blockInfo.setSeconds(node.@sec); + blockInfo.setId(node.@id); } if(node.localName() == "questiongroup") @@ -446,7 +1077,8 @@ questionGroupInfo.setHeader(node.@header); questionGroupInfo.setDescription(node.@description); questionGroupInfo.setSequenceNo(node.@sequenceNo); - + questionGroupInfo.setId(node.@id); + //Alert.show("Question group id assigned is: " + node.@id); } if(node.localName() == "question") @@ -459,71 +1091,186 @@ btnsaveBlock.enabled = false; btnsaveQuestionGroup.enabled = false; btnsaveQuestion.enabled = true; - //questionInfo.reset(); + questionInfo.reset(); + //set all fields - questionInfo.setType(node.@type); + //get question infromation like sequence number , type, id and title questionInfo.setQuestion(node.@title); questionInfo.setSequenceNo(node.@sequenceNo); - var id:int = node.@id; - var Q:ASQuestion; + questionInfo.setId(node.@id); - for(var i:int = 0; i<tempQuestion.length; i++) + + + if(node.@type == "categorical") { - Q = tempQuestion[i]; - if(Q.getId() == id ) + currentState = "categorical"; + var catobj:DisplayObject = pnlComponent.getChildAt(2); + var compCategorical:Categorical = Categorical(catobj); + compCategorical.reset(); + + questionInfo.cmbType.selectedItem = "Categorical"; + var categoricalQ:XMLList = categoricalQuestions.categorical.(@id == node.@id); + + if(categoricalQ.length() > 0) { - if(Q.getType().toLowerCase() == "categorical") + if(categoricalQ[0].@type == "relative") { - var cat:ASCategorical = ASCategorical(Q.getQtype()); - Alert.show(cat.dict[0]); + compCategorical.setType("relative"); - } + currentState = "relative"; + + var cat1obj:DisplayObject = pnlComponent.getChildAt(3); + var compRelative:CategoricalRelative = CategoricalRelative(cat1obj); + + 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]; + 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++) + { + if(attributeList[i] != optionList[j]) + { + dict[str].addItem(attributeList[i]); + } + + } + } + + compRelative.setDictionary(dict); + + } + else if(categoricalQ[0].@type == "simple") + { + compCategorical.setType("simple"); + currentState = "simple"; + var cat2obj:DisplayObject = pnlComponent.getChildAt(3); + var compSimple:CategoricalSimple = CategoricalSimple(cat2obj); + + var dictionary:Dictionary = new Dictionary(); + + var attributeSimpleList:XMLList = categoricalQ[0].option.attributes(); + var str1:String; + + for(var k:int = 0; k < attributeSimpleList.length(); k++) + { + str1 = attributeSimpleList[k]; + compSimple.header.addItem(str1); + dictionary[str1] = new ArrayCollection(); + dictionary[str1].addItem(null); + } + + } + compSimple.setDictionary(dictionary); + } - } - } + } - - } + else if(node.@type == "psychometric") + { + currentState = "psychometric"; + var psychobj:DisplayObject = pnlComponent.getChildAt(2); + var compPsychometric:Psychometric = Psychometric(psychobj); + compPsychometric.reset(); + 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(); + + 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]); + } + } + } + } + else + currentState = "none"; + } } - - + ]]> </mx:Script> <mx:states> <mx:State name="module"> <mx:AddChild relativeTo="{pnlComponent}"> - <comp:Module id="module"/> + <basicComp:Module id="module"/> </mx:AddChild> </mx:State> <mx:State name="block"> <mx:AddChild relativeTo="{pnlComponent}"> - <comp:Block id="block"/> + <basicComp:Block id="block"/> </mx:AddChild> </mx:State> <mx:State name="questionGroup"> <mx:AddChild relativeTo="{pnlComponent}"> - <comp:QuestionGroup id="questionGroup"/> + <basicComp:QuestionGroup id="questionGroup"/> </mx:AddChild> </mx:State> <mx:State name="question"> <mx:AddChild relativeTo="{pnlComponent}"> - <comp:Question id="question"/> + <basicComp:Question id="question"/> </mx:AddChild> + <mx:SetEventHandler handlerFunction="QuestionHandler" target="{question.cmbType}" name="change" /> </mx:State> + <mx:State name="none"/> + <mx:State name="psychometric" basedOn="question"> + <mx:AddChild relativeTo="{pnlComponent}"> + <comp:Psychometric id="psychometric" width="335"/> + </mx:AddChild> + </mx:State> + + <mx:State name="categorical" basedOn="question" > + <mx:AddChild relativeTo="{pnlComponent}"> + <comp:Categorical id="categorical" width="335"/> + </mx:AddChild> + + <mx:SetEventHandler handlerFunction="CategoricalTypeHandler" target="{categorical.cmbType}" name="change" /> + + </mx:State> + + <mx:State name="relative" basedOn="categorical"> + <mx:AddChild relativeTo="{pnlComponent}"> + <comp:CategoricalRelative id="categoricalRelative" width="100%"/> + </mx:AddChild> + </mx:State> + + + <mx:State name="simple" basedOn="categorical"> + <mx:AddChild relativeTo="{pnlComponent}"> + <comp:CategoricalSimple id="categoricalSimple" width="100%"/> + </mx:AddChild> + <mx:SetProperty target="{categorical}" name="width" value="335"/> + </mx:State> + + <!-- <mx:State name="text" basedOn="question"/> --> - <mx:State name="none"> - </mx:State> + + </mx:states> <mx:Spacer width="40"/> <mx:HDividedBox width="100%" height="100%" id="hdMain"> <mx:Spacer width="40"/> <mx:VBox height="100%" id="vboxLeft" width ="40%"> <mx:Spacer width="40"/> - <mx:Tree id="tree" dataProvider="{companyData}" + <mx:Tree id="tree" dataProvider="{surveyData}" labelFunction="treeLabel" allowMultipleSelection="false" selectable="true" showRoot="true" change="{treeChanged(event)}" height="50%" width="80%" textAlign="center"/> @@ -554,6 +1301,7 @@ <mx:GridRow width="100%" height="100%" id="gridrow2"> <mx:GridItem width="100%" height="100%" id="griditem1"> <mx:Button label="Remove Item" id="butRemModule" click ="{removeItem()}"/> + <mx:Button id="butnTest" label="Test" click="{init()}"/> </mx:GridItem> @@ -561,6 +1309,16 @@ </mx:Grid> </mx:Canvas> + <mx:Tree id="treeCQ" dataProvider="{categoricalQuestions}" + labelFunction="treeLabelCategoricalQ" allowMultipleSelection="false" selectable="true" + showRoot="true" change="{treeChanged(event)}" + height="50%" width="80%" textAlign="center"/> + + <mx:Spacer width="20"/> + <mx:Tree id="treePQ" dataProvider="{psychometricQuestions}" + labelFunction="treeLabelPsychometricQ" allowMultipleSelection="false" selectable="true" + showRoot="true" change="{treeChanged(event)}" + height="50%" width="80%" textAlign="center"/> </mx:VBox> <mx:Panel id = "pnlComponent" height="100%" layout="vertical"> <mx:HBox width="100%"> @@ -573,10 +1331,23 @@ <mx:Spacer width="40"/> <mx:Button id = "btnsaveQuestion" enabled="false" label="Save Question" click="{saveQuestion(event)}" /> <mx:Spacer width="40"/> - + <mx:Label id="lbltest" /> </mx:HBox> </mx:Panel> + </mx:HDividedBox> + <mx:RemoteObject id="roQuestionCreator" destination="questionCreatorService" fault="faultHandler(event)" > + <mx:method name="saveModule" result="resultSaveModuleHandler(event)" /> + <mx:method name="updateModule" result="resultUpdateModuleHandler(event)" /> + <mx:method name="saveBlock" result="resultSaveBlockHandler(event)" /> + <mx:method name="updateBlock" result="resultUpdateBlockHandler(event)" /> + <mx:method name="saveQuestionGroup" result="resultSaveQuestionGroupHandler(event)" /> + <mx:method name="updateQuestionGroup" result="resultUpdateQuestionGroupHandler(event)" /> + <mx:method name="saveQuestion" result="resultSaveQuestionHandler(event)" /> + <mx:method name="updateQuestion" result="resultUpdateQuestionHandler(event)" /> + <mx:method name="initializeData" result="resultInitializeDataHandler(event)" /> + + </mx:RemoteObject> </mx:Application> Deleted: mentalmodels/trunk/flex/src/actionscript/ASCategorical.as =================================================================== --- mentalmodels/trunk/flex/src/actionscript/ASCategorical.as 2009-07-10 07:04:06 UTC (rev 174) +++ mentalmodels/trunk/flex/src/actionscript/ASCategorical.as 2009-07-10 21:02:20 UTC (rev 175) @@ -1,30 +0,0 @@ -package actionscript -{ - import flash.utils.Dictionary; - - import mx.collections.ArrayCollection; - - public class ASCategorical - { - public var id:int; - - public function ASCategorical(id:int) - { - this.id = id; - } - - public var type:String; - public var dict:Dictionary = new Dictionary(); - - public function setDictionary(dictionary:Dictionary):void - { - dict = dictionary; - } - - public function getDictionary():Dictionary - { - return dict; - } - - } -} \ No newline at end of file Deleted: mentalmodels/trunk/flex/src/actionscript/ASPsychometric.as =================================================================== --- mentalmodels/trunk/flex/src/actionscript/ASPsychometric.as 2009-07-10 07:04:06 UTC (rev 174) +++ mentalmodels/trunk/flex/src/actionscript/ASPsychometric.as 2009-07-10 21:02:20 UTC (rev 175) @@ -1,20 +0,0 @@ -package actionscript -{ - import mx.collections.ArrayCollection; - - public class ASPsychometric - { - public function ASPsychometric() - { - } - - - public var scale:String; - - public var numberOfIntervals:Number; - - public var choices:ArrayCollection; - - - } -} \ No newline at end of file Deleted: mentalmodels/trunk/flex/src/actionscript/ASQuestion.as =================================================================== --- mentalmodels/trunk/flex/src/actionscript/ASQuestion.as 2009-07-10 07:04:06 UTC (rev 174) +++ mentalmodels/trunk/flex/src/actionscript/ASQuestion.as 2009-07-10 21:02:20 UTC (rev 175) @@ -1,46 +0,0 @@ -package actionscript -{ - import mx.collections.ArrayCollection; - - public class ASQuestion - { - private var id:int; - public var question:String; - private var type:String; - private var Qtype:Object; - - public function ASQuestion(id:int) - { - this.id = id; - - } - - public function setType(type:String):void - { - this.type = type; - - } - - public function getType():String - { - return type; - } - - public function setQtype(questionInfo:Object):void - { - this.Qtype = questionInfo; - } - - public function getQtype():Object - { - return Qtype; - } - - public function getId():int - { - return id; - } - - - } -} \ No newline at end of file Deleted: mentalmodels/trunk/flex/src/actionscript/ASResults.as =================================================================== --- mentalmodels/trunk/flex/src/actionscript/ASResults.as 2009-07-10 07:04:06 UTC (rev 174) +++ mentalmodels/trunk/flex/src/actionscript/ASResults.as 2009-07-10 21:02:20 UTC (rev 175) @@ -1,18 +0,0 @@ -package actionscript -{ - import mx.messaging.channels.StreamingHTTPChannel; - - public class ASResults - { - public function ASResults() - { - } - public function calculateString():String - { - var greeting:String; - greeting="Welcome Kalin!!"; - return String(greeting); - } - - } -} \ No newline at end of file Modified: mentalmodels/trunk/flex/src/actionscript/Block.as =================================================================== --- mentalmodels/trunk/flex/src/actionscript/Block.as 2009-07-10 07:04:06 UTC (rev 174) +++ mentalmodels/trunk/flex/src/actionscript/Block.as 2009-07-10 21:02:20 UTC (rev 175) @@ -1,6 +1,9 @@ package actionscript { + import mx.collections.ArrayCollection; + import mx.formatters.NumberFormatter; + import mx.formatters.NumberBaseRoundType; [Bindable] [RemoteClass(alias="edu.asu.commons.mme.entity.Block")] @@ -10,7 +13,25 @@ public var sequenceNo:int; public var description:String; public var duration:int; + public var module:ASModule; public var questionGroups:ArrayCollection; public var informationWindows:ArrayCollection; + + 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 - (getMinutes() * 60)); + } } } \ No newline at end of file Added: mentalmodels/trunk/flex/src/actionscript/Categorical.as =================================================================== --- mentalmodels/trunk/flex/src/actionscript/Categorical.as (rev 0) +++ mentalmodels/trunk/flex/src/actionscript/Categorical.as 2009-07-10 21:02:20 UTC (rev 175) @@ -0,0 +1,12 @@ +package actionscript +{ + import mx.collections.ArrayCollection; + + [Bindable] + [RemoteClass(alias="edu.asu.commons.mme.entity.CategoricalQuestion")] + public class Categorical extends Question + { + + public var categoricalOptions:ArrayCollection = new ArrayCollection(); + } +} \ No newline at end of file Added: mentalmodels/trunk/flex/src/actionscript/CategoricalOption.as =================================================================== --- mentalmode... [truncated message content] |
From: <kj...@us...> - 2009-07-10 07:04:08
|
Revision: 174 http://virtualcommons.svn.sourceforge.net/virtualcommons/?rev=174&view=rev Author: kjonas Date: 2009-07-10 07:04:06 +0000 (Fri, 10 Jul 2009) Log Message: ----------- InformationWindowCreator.as method makeWindows() now returns a set of windows, descriptions, and an InformationWindowCreator.as object with which to update the windows. updateGoals has been tested with nested ArrayCollections of strings, and seems to work. (hence the strange "Update" button on the main page) "9 Notes - Yourself" is the information window that is updated by this button, and only on the first set of windows. It just tests the concept of updating. Modified Paths: -------------- mentalmodels/trunk/flex/src/FisheryExperimentShell.mxml mentalmodels/trunk/flex/src/_InstructionsTest.mxml mentalmodels/trunk/flex/src/actionscript/InformationWindowCreator.as mentalmodels/trunk/flex/src/custom/questions/dayByDayDecisions/DayByDayDecisionsQuestionC.mxml mentalmodels/trunk/flex/src/custom/questions/dayByDayDecisions/OneDay.mxml mentalmodels/trunk/flex/src/custom/questions/strategyDesign/PlannerRow.mxml Modified: mentalmodels/trunk/flex/src/FisheryExperimentShell.mxml =================================================================== --- mentalmodels/trunk/flex/src/FisheryExperimentShell.mxml 2009-07-09 00:39:46 UTC (rev 173) +++ mentalmodels/trunk/flex/src/FisheryExperimentShell.mxml 2009-07-10 07:04:06 UTC (rev 174) @@ -5,6 +5,8 @@ width="100%" height="100%" xmlns:custom="custom.*" initialize="init()"> + <mx:Button id="btnTemp" label="Update" click="updateObjectA.updateLearned(new ArrayCollection([new ArrayCollection(['test']),new ArrayCollection(['test']),new ArrayCollection(['test'])]))"/> + <mx:VBox id="vbxInfo"> <mx:TitleWindow id="InformationWindowA" width="400" height="200" title="Information Window A" clipContent="true" horizontalScrollPolicy="on" verticalScrollPolicy="on"> @@ -52,6 +54,8 @@ public var allInfoWindowsA:ArrayCollection = null; public var allInfoWindowsB:ArrayCollection = null; public var allInfoWindowsDescriptions:ArrayCollection = null; + public var updateObjectA:InformationWindowCreator = null; + public var updateObjectB:InformationWindowCreator = null; public var currInfoWindowsA:ArrayCollection = null; public var currInfoWindowsB:ArrayCollection = null; @@ -62,8 +66,19 @@ public function init():void { - allInfoWindowsA = makeWindows(); - allInfoWindowsB = makeWindows(); + // temporarily store all 3 objects returned... + allInfoWindowsA = makeWindows() as ArrayCollection; + allInfoWindowsB = makeWindows() as ArrayCollection; + + // extract the updaters + updateObjectA = allInfoWindowsA.getItemAt(2) as InformationWindowCreator; + updateObjectB = allInfoWindowsB.getItemAt(2) as InformationWindowCreator; + + // extract the information windows themselves + allInfoWindowsA = allInfoWindowsA.getItemAt(0) as ArrayCollection; + allInfoWindowsB = allInfoWindowsB.getItemAt(0) as ArrayCollection; + + var arry:ArrayCollection = new ArrayCollection(); // fix when communicating with server... for(var i:int=0;i<30;i++) arry.addItem(i); // fix when communicating with server... selectCurrentWindows( arry ); // fix when communicating with server... @@ -144,7 +159,8 @@ { var windowData:ArrayCollection = InformationWindowCreator.makeWindows(); allInfoWindowsDescriptions = windowData.getItemAt(1) as ArrayCollection; - return windowData.getItemAt(0) as ArrayCollection; + + return windowData; } public function selectCurrentWindows(selectedWindows:ArrayCollection):void Modified: mentalmodels/trunk/flex/src/_InstructionsTest.mxml =================================================================== --- mentalmodels/trunk/flex/src/_InstructionsTest.mxml 2009-07-09 00:39:46 UTC (rev 173) +++ mentalmodels/trunk/flex/src/_InstructionsTest.mxml 2009-07-10 07:04:06 UTC (rev 174) @@ -1,41 +1,27 @@ <?xml version="1.0" encoding="utf-8"?> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:comp="custom.*" xmlns:as="actionscript.*" layout="horizontal" - backgroundGradientColors="[#FFFFFF, #B0B0FF]"> + backgroundGradientColors="[#FFFFFF, #B0B0FF]" xmlns:strategyDesign="custom.questions.strategyDesign.*" xmlns:dayByDayDecisions="custom.questions.dayByDayDecisions.*"> - <mx:VBox id="vbxInfo"> - <mx:TitleWindow id="InformationWindowA" width="300" height="200" title="Information Window A"/> - <mx:HBox id="hbxPickerA"> - <mx:ComboBox id="cbxPickerA"/> - <mx:Button id="btnPickerA" click="popupInformationWindow(1)"/> - </mx:HBox> - - <mx:TitleWindow id="InformationWindowB" width="300" height="200" title="Information Window B"/> - <mx:HBox id="hbxPickerB"> - <mx:ComboBox id="cbxPickerB"/> - <mx:Button id="btnPickerB" click="popupInformationWindow(2)"/> - </mx:HBox> + <mx:VBox> + <mx:Button id="save" click="save_click()" label="Save"/> + <mx:Button id="load" click="bak_click()" label="Load"/> + <dayByDayDecisions:DayByDayDecisionsQuestionC id="day1"/> + <dayByDayDecisions:DayByDayDecisionsQuestionC id="day2"/> </mx:VBox> <mx:Script> <![CDATA[ - import custom.InformationWindowPopup; - import mx.managers.PopUpManager; - public function popupInformationWindow(source:int):void + public var arry:ArrayCollection = new ArrayCollection(); + + public function save_click():void { -// Alert.cancelLabel = "Close"; -// var flags:uint = Alert.NONMODAL | Alert.CANCEL; -// var alert:Alert = Alert.show("::","Information Window",flags,null,null,null,Alert.CANCEL) - - var win:InformationWindowPopup = PopUpManager.createPopUp(this, InformationWindowPopup, false) as InformationWindowPopup; - PopUpManager.centerPopUp(win); - win.closedFunction = closedFunction; + arry = day1.save(); } - - public function closedFunction():void + public function bak_click():void { - btnPickerA.label += "."; + day2.load(arry); } ]]> @@ -43,29 +29,26 @@ <mx:Script> <![CDATA[ + import mx.controls.Alert; import custom.questions.CategoricalQuestionC; import actionscript.* import actionscript.questions.*; import actionscript.Block; import mx.collections.ArrayCollection; - public var block1:Block = new Block(); - - - // - // InstructionPage Testing below here - // - - public function fillBlock():void + public function makeBlock():Block { + var block1:Block = new Block(); try{ var questionGroups1:ArrayCollection = new ArrayCollection(); + var qg0:QuestionGroup = new QuestionGroup(); var qg1:QuestionGroup = new QuestionGroup(); var qg2:QuestionGroup = new QuestionGroup(); var qg3:QuestionGroup = new QuestionGroup(); var qg4:QuestionGroup = new QuestionGroup(); var qg5:QuestionGroup = new QuestionGroup(); var qg6:QuestionGroup = new QuestionGroup(); + qg0.questions = new ArrayCollection(); qg1.questions = new ArrayCollection(); qg2.questions = new ArrayCollection(); qg3.questions = new ArrayCollection(); @@ -75,8 +58,13 @@ block1.questionGroups = new ArrayCollection(); // create questions + var ddq1:Question = new Question(); + ddq1.question = "dayByDayDecisionsQuestion"; + ddq1.type = "dayByDayDecisions"; + var cat1:Categorical = new Categorical(); cat1.question = "categoricalQuestion"; + cat1.type = "categorical"; cat1.topics = new ArrayCollection(); cat1.specifics = new ArrayCollection(); @@ -84,29 +72,35 @@ var for2:ForecastingFish = new ForecastingFish(); var psy1:PsychometricQuestion = new PsychometricQuestion(); - psy1.question = "psychQuestion"; + psy1.question = "psychometricQuestion"; + psy1.type = "psychometric"; psy1.numberOfIntervals = 10; psy1.choices = new ArrayCollection(); psy1.choices.addItem("Highly Agree"); psy1.choices.addItem("Highly Neutral"); psy1.choices.addItem("Highly Disagree"); - var str1:StrategyDesign = new StrategyDesign(); - str1.question = "stratDesQuestion"; + var str1:Question = new Question(); + str1.question = "strategyDesignQuestion"; + str1.type = "strategyDesign"; var txt1:Question = new Question(); txt1.question = "textQuestion"; + txt1.type = "text"; // insert questions into groups + qg0.questions.addItem(ddq1); qg1.questions.addItem(cat1); - qg1.description = "testDesc"; - qg1.header = "testHead"; qg2.questions.addItem(for1); qg3.questions.addItem(for2); qg4.questions.addItem(psy1); qg5.questions.addItem(str1); qg6.questions.addItem(txt1); + qg1.description = "testDesc"; + qg1.header = "testHead"; + + block1.questionGroups.addItem(qg0); block1.questionGroups.addItem(qg1); block1.questionGroups.addItem(qg2); block1.questionGroups.addItem(qg3); @@ -114,25 +108,15 @@ block1.questionGroups.addItem(qg5); block1.questionGroups.addItem(qg6); -// debg.text += "finished\n"; + }catch(errObject:Error){ - debug.text += "block creation failure\n" + - errObject.message + "\n" + errObject.getStackTrace(); + Alert.show("block creation failure\n" + + errObject.message + "\n" + errObject.getStackTrace()); } + return block1; } ]]> </mx:Script> - <mx:VBox id="vbxContent" minWidth="700" horizontalAlign="center"> - <mx:HBox> - <mx:Button id="back" click="iPage.back()" label="back"/> - <mx:Button id="forward" click="iPage.forward()" label="forward"/> - </mx:HBox> - - <mx:Text id="debug" text=""/> - - <comp:InstructionPage id="iPage" preinitialize="fillBlock()" initialize="iPage.init(block1)"/> - </mx:VBox> - </mx:Application> Modified: mentalmodels/trunk/flex/src/actionscript/InformationWindowCreator.as =================================================================== --- mentalmodels/trunk/flex/src/actionscript/InformationWindowCreator.as 2009-07-09 00:39:46 UTC (rev 173) +++ mentalmodels/trunk/flex/src/actionscript/InformationWindowCreator.as 2009-07-10 07:04:06 UTC (rev 174) @@ -17,18 +17,71 @@ public class InformationWindowCreator { - public var listeners:ArrayCollection; + public var goals:ArrayCollection; + public var learned:ArrayCollection; + public var learnedComm:ArrayCollection; + public var strategy:StrategyDesignQuestionC; + public var forecasting:ForecastingFishQuestionC; + public var dayByDayResults:DayByDayDecisionsQuestionC; + public var strategyResults:DayByDayDecisionsQuestionC; public function InformationWindowCreator() { - listeners = new ArrayCollection(); + goals = new ArrayCollection(); + learned = new ArrayCollection(); + learnedComm = new ArrayCollection(); + strategy = null; + forecasting = null; + dayByDayResults = null; + strategyResults = null; } + public function updateGoals(saved:ArrayCollection):void + { + (goals.getItemAt(0) as CategoricalQuestionC).load(saved.getItemAt(0) as ArrayCollection); + (goals.getItemAt(1) as CategoricalQuestionC).load(saved.getItemAt(1) as ArrayCollection); + (goals.getItemAt(2) as CategoricalQuestionC).load(saved.getItemAt(2) as ArrayCollection); + } + + public function updateLearned(saved:ArrayCollection):void + { + (learned.getItemAt(0) as TextQuestionC).load(saved.getItemAt(0) as ArrayCollection); + (learned.getItemAt(1) as TextQuestionC).load(saved.getItemAt(1) as ArrayCollection); + (learned.getItemAt(2) as TextQuestionC).load(saved.getItemAt(2) as ArrayCollection); + } + + public function updateLearnedWithCommunication(saved:ArrayCollection):void + { + (learnedComm.getItemAt(0) as TextQuestionC).load(saved.getItemAt(0) as ArrayCollection); + (learnedComm.getItemAt(1) as TextQuestionC).load(saved.getItemAt(1) as ArrayCollection); + (learnedComm.getItemAt(2) as TextQuestionC).load(saved.getItemAt(2) as ArrayCollection); + (learnedComm.getItemAt(3) as TextQuestionC).load(saved.getItemAt(3) as ArrayCollection); + } + + public function updateStrategyDesign(saved:ArrayCollection):void + { + strategy.load(saved); + strategyResults.loadFromStrategy(saved); + } + + public function updateForecasting(savedFish:ArrayCollection, savedPeople:ArrayCollection):void + { + forecasting.load(savedFish, savedPeople); + } + + public function updateDayByDayDecisions(saved:ArrayCollection):void + { + dayByDayResults.load(saved); + } + + //// + // Static functions for creating windows + //// public static var maxWidth:int = 460; public static function makeWindows():ArrayCollection { - var listenerObject:InformationWindowCreator = new InformationWindowCreator(); + var updateObject:InformationWindowCreator = new InformationWindowCreator(); var allInfoWindows:ArrayCollection = new ArrayCollection(); var allInfoWindowsDescriptions:ArrayCollection = new ArrayCollection(); @@ -47,7 +100,7 @@ tempWindow.addItem(temp); temp = new Text(); - (temp as Text).htmlText = "What is presented in an information window can be selected from the drop-down list below each window!<br><br>Please check the options of the drop-down list when entering a new module of the experiment (i.e. after leaving a module by clicking on “Accept”).<br><br><br>If you would like to look at the contents of an information window bigger, click the “Pop Up” button below."; + (temp as Text).htmlText = "What is presented in an information window can be selected from the drop-down list below each window!<br><br>Please check the options of the drop-down list when entering a new module of the experiment (i.e. after leaving a module by clicking on “Accept”).<br><br>If the information window looks too small or broken, click the “Pop Up” button below."; (temp as Text).width = maxWidth; tempWindow.addItem(temp); @@ -267,6 +320,7 @@ (temp as StrategyDesignQuestionC).description = "This is the strategy that you designed previously. Use it for reference."; (temp as StrategyDesignQuestionC).enabled = false; tempWindow.addItem(temp); + updateObject.strategy = temp as StrategyDesignQuestionC; allInfoWindows.addItem(tempWindow); allInfoWindowsDescriptions.addItem("Your Strategy"); @@ -292,6 +346,7 @@ temp = new CategoricalQuestionC(); (temp as CategoricalQuestionC).enabled = false; tempWindow.addItem(temp); + updateObject.goals.addItem(temp as CategoricalQuestionC); temp = new Label(); (temp as Label).text = "Your second most important goal is to"; @@ -299,6 +354,7 @@ temp = new CategoricalQuestionC(); (temp as CategoricalQuestionC).enabled = false; tempWindow.addItem(temp); + updateObject.goals.addItem(temp as CategoricalQuestionC); temp = new Label(); (temp as Label).text = "Your third most important goal is to"; @@ -306,6 +362,7 @@ temp = new CategoricalQuestionC(); (temp as CategoricalQuestionC).enabled = false; tempWindow.addItem(temp); + updateObject.goals.addItem(temp as CategoricalQuestionC); allInfoWindows.addItem(tempWindow); allInfoWindowsDescriptions.addItem("Your Goals"); @@ -323,6 +380,7 @@ temp = new ForecastingFishQuestionC(); (temp as ForecastingFishQuestionC).enabled = false; tempWindow.addItem(temp); + updateObject.forecasting = temp as ForecastingFishQuestionC; allInfoWindows.addItem(tempWindow); allInfoWindowsDescriptions.addItem("Your Forecast"); @@ -340,6 +398,7 @@ temp = new DayByDayDecisionsQuestionC(); (temp as DayByDayDecisionsQuestionC).enabled = false; tempWindow.addItem(temp); + updateObject.dayByDayResults = temp as DayByDayDecisionsQuestionC; allInfoWindows.addItem(tempWindow); allInfoWindowsDescriptions.addItem("Day-by-Day Results"); @@ -357,6 +416,7 @@ temp = new DayByDayDecisionsQuestionC(); (temp as DayByDayDecisionsQuestionC).enabled = false; tempWindow.addItem(temp); + updateObject.strategyResults = temp as DayByDayDecisionsQuestionC; allInfoWindows.addItem(tempWindow); allInfoWindowsDescriptions.addItem("Strategy Results"); @@ -377,6 +437,7 @@ temp = new TextQuestionC(); (temp as TextQuestionC).enabled = false; tempWindow.addItem(temp); + updateObject.learned.addItem(temp as TextQuestionC); temp = new Label(); (temp as Label).text = "New Expectations on How the Others of the Group Will Act"; @@ -384,6 +445,7 @@ temp = new TextQuestionC(); (temp as TextQuestionC).enabled = false; tempWindow.addItem(temp); + updateObject.learned.addItem(temp as TextQuestionC); temp = new Label(); (temp as Label).text = "Ideas for Improving Your Strategy"; @@ -391,6 +453,7 @@ temp = new TextQuestionC(); (temp as TextQuestionC).enabled = false; tempWindow.addItem(temp); + updateObject.learned.addItem(temp as TextQuestionC); allInfoWindows.addItem(tempWindow); allInfoWindowsDescriptions.addItem("Notes - Yourself"); @@ -411,6 +474,7 @@ temp = new TextQuestionC(); (temp as TextQuestionC).enabled = false; tempWindow.addItem(temp); + updateObject.learnedComm.addItem(temp as TextQuestionC); temp = new Label(); (temp as Label).text = "New Understanding of Fish Dynamics"; @@ -418,6 +482,7 @@ temp = new TextQuestionC(); (temp as TextQuestionC).enabled = false; tempWindow.addItem(temp); + updateObject.learnedComm.addItem(temp as TextQuestionC); temp = new Label(); (temp as Label).text = "New Expectations on How the Others of the Group Will Act"; @@ -425,6 +490,7 @@ temp = new TextQuestionC(); (temp as TextQuestionC).enabled = false; tempWindow.addItem(temp); + updateObject.learnedComm.addItem(temp as TextQuestionC); temp = new Label(); (temp as Label).text = "Ideas for Improving Your Strategy"; @@ -432,6 +498,7 @@ temp = new TextQuestionC(); (temp as TextQuestionC).enabled = false; tempWindow.addItem(temp); + updateObject.learnedComm.addItem(temp as TextQuestionC); allInfoWindows.addItem(tempWindow); allInfoWindowsDescriptions.addItem("Notes - With Group"); @@ -471,10 +538,11 @@ var content:ArrayCollection = new ArrayCollection(); content.addItem(allInfoWindows); content.addItem(allInfoWindowsDescriptions); + content.addItem(updateObject); for(var endLoop:int; endLoop < allInfoWindowsDescriptions.length; endLoop++) { - allInfoWindowsDescriptions.setItemAt(endLoop + (allInfoWindowsDescriptions.getItemAt(endLoop) as String), endLoop); + allInfoWindowsDescriptions.setItemAt(endLoop +" "+ (allInfoWindowsDescriptions.getItemAt(endLoop) as String), endLoop); } return content; Modified: mentalmodels/trunk/flex/src/custom/questions/dayByDayDecisions/DayByDayDecisionsQuestionC.mxml =================================================================== --- mentalmodels/trunk/flex/src/custom/questions/dayByDayDecisions/DayByDayDecisionsQuestionC.mxml 2009-07-09 00:39:46 UTC (rev 173) +++ mentalmodels/trunk/flex/src/custom/questions/dayByDayDecisions/DayByDayDecisionsQuestionC.mxml 2009-07-10 07:04:06 UTC (rev 174) @@ -3,7 +3,7 @@ <mx:String id="description"></mx:String> - <mx:Label id="txtPrompt" text="It's Day {currentDay}. Where will you go to fish, or will you stay in the harbor?"/> + <mx:Label id="txtPrompt" text="It's Day 1. Where will you go to fish, or will you stay in the harbor?"/> <mx:Label id="lblChosen" text="location chosen: {deciding}"/> <mx:HBox id="buttons"/> @@ -16,6 +16,8 @@ <mx:Script> <![CDATA[ + import mx.controls.Alert; + import mx.collections.ArrayCollection; import mx.controls.Button; import mx.controls.Text; import actionscript.questions.*; @@ -23,7 +25,6 @@ public var numBays:int = 3; [Bindable] public var deciding:int = 0; - [Bindable] public var currentDay:int = 1; [Bindable] public var cumTotal:Number = 0; [Bindable] public var dollarPerLb:Number = 3.99; @@ -71,7 +72,7 @@ txtTemp = new Text(); txtTemp = stylize(txtTemp); - txtTemp.htmlText = "Cumulative<br>Total"; + txtTemp.htmlText = "Total"; txtTemp.minWidth = 60; labels.addChild(txtTemp); } @@ -103,7 +104,7 @@ public function advance(event:MouseEvent=null):void { - if(currentDay == 30) + if(dayByDayContent.numChildren == 30) { return; } @@ -111,27 +112,65 @@ var newDay:OneDay = new OneDay(); newDay.numBays = numBays; newDay.initialize(); - newDay.day = currentDay++; + newDay.day = dayByDayContent.numChildren + 1; newDay.dollarPerLb = dollarPerLb; dayByDayContent.addChild(newDay.load(deciding)); cumTotal += newDay.presentTotal; -// try -// { -// var last:Object = dayByDayContent.getChildAt(dayByDayContent.numChildren - 1); -// if(last is OneDay) -// { -// cumTotal += (last as OneDay).presentTotal; -// } -// } -// catch(err:Error) -// { -// // silent failure -// } + txtPrompt.text = "It's Day "+(dayByDayContent.numChildren+1)+". Where will you go to fish, or will you stay in the harbor?"; + deciding = 0; - deciding = 0; + dayByDayContent.validateNow(); + dayByDayContent.verticalScrollPosition = dayByDayContent.maxVerticalScrollPosition; } + public function save():ArrayCollection + { + var saveArray:ArrayCollection = new ArrayCollection(); + + for(var i:int = 0; i < dayByDayContent.numChildren; i++) + { + var day:OneDay = dayByDayContent.getChildAt(i) as OneDay; + + var newDay:OneDay = new OneDay(); + newDay.numBays = numBays; + newDay.initialize(); + newDay.day = day.day; + newDay.dollarPerLb = day.day; + + newDay.decisions = new ArrayCollection(); + for(var j:int=0; j<day.decisions.length; j++) + { + var tempDecision:OneDecision = new OneDecision(); + tempDecision.lbsFished = (day.decisions.getItemAt(j) as OneDecision).lbsFished; + tempDecision.active = (day.decisions.getItemAt(j) as OneDecision).active; + tempDecision.peopleFishing = (day.decisions.getItemAt(j) as OneDecision).peopleFishing; + newDay.decisions.addItem(tempDecision); + } + + saveArray.addItem(newDay); + } + + return saveArray; + } + + public function load(loadArray:ArrayCollection):void + { + dayByDayContent.removeAllChildren(); + cumTotal = 0; + + for(var i:int = 0; i < loadArray.length; i++) + { + var day:OneDay = loadArray.getItemAt(i) as OneDay; + + day.drawPartial(); + dayByDayContent.addChild(day); + cumTotal += day.presentTotal; + } + + txtPrompt.text = "It's Day "+(dayByDayContent.numChildren+1)+". Where will you go to fish, or will you stay in the harbor?"; + } + public function loadFromQuestion(question:Question):void { description = question.question; @@ -166,6 +205,70 @@ return moneyString; } + public function loadFromStrategy(saved:ArrayCollection):void + { + dayByDayContent.removeAllChildren(); + cumTotal = 0; + + var notRepeated:ArrayCollection = saved.getItemAt(0) as ArrayCollection; + var repeated:ArrayCollection = saved.getItemAt(1) as ArrayCollection; + var suspendWeight:Number = saved.getItemAt(2) as Number; + var suspendDays:Number = saved.getItemAt(3) as Number; + + var dayTotal:int = 0; + var location:String; + var days:Number; + var threshold:Number; + + for(var i:int=0; notRepeated.length > 0 && i < notRepeated.length; i++) + { + var notRepeatedDay:ArrayCollection = notRepeated.getItemAt(i) as ArrayCollection; + location = (notRepeatedDay.getItemAt(0) as String); + days = (notRepeatedDay.getItemAt(1) as Number); + threshold = (notRepeatedDay.getItemAt(2) as Number); + + dayTotal = executeCommand(location,days,threshold,dayTotal); + } + for(var j:int=0; j < repeated.length; ) + { + var repeatedDay:ArrayCollection = repeated.getItemAt(j) as ArrayCollection; + location = (repeatedDay.getItemAt(0) as String); + days = (repeatedDay.getItemAt(1) as Number); + threshold = (repeatedDay.getItemAt(2) as Number); + + dayTotal = executeCommand(location,days,threshold,dayTotal); + + j++; + if(dayTotal < 30 && j == repeated.length) + { + j = 0; + } + } + +// Alert.show("done"); + } + + public function executeCommand(location:String,days:Number,threshold:Number,dayTotal:int):int + { + for(var day:int=0; day < days && dayTotal < 30; day++) + { + deciding = 0; +// Alert.show(location+","+day+","+threshold,"",Alert.NONMODAL); + if(location.indexOf("Bay ") == 0) + { + try{ + deciding = Number(location.substring(4)); + }catch(err:Error){ + deciding = 0; + } + } + advance(); + dayTotal++; + } +// Alert.show("Exited","",Alert.NONMODAL); + return dayTotal; + } + ]]> </mx:Script> Modified: mentalmodels/trunk/flex/src/custom/questions/dayByDayDecisions/OneDay.mxml =================================================================== --- mentalmodels/trunk/flex/src/custom/questions/dayByDayDecisions/OneDay.mxml 2009-07-09 00:39:46 UTC (rev 173) +++ mentalmodels/trunk/flex/src/custom/questions/dayByDayDecisions/OneDay.mxml 2009-07-10 07:04:06 UTC (rev 174) @@ -109,7 +109,7 @@ } var tempActive:OneDecision = new OneDecision(); - tempActive.lbsFished = Math.round(Math.random()*50)/10.0; + tempActive.lbsFished = getLbsFromServer(locationChosen); tempActive.initialize(); decisions.addItem(tempActive); } @@ -119,6 +119,11 @@ return this; } + public function getLbsFromServer(loc:int):Number + { + return Math.round(Math.random()*50)/10.0; + } + ]]> </mx:Script> Modified: mentalmodels/trunk/flex/src/custom/questions/strategyDesign/PlannerRow.mxml =================================================================== --- mentalmodels/trunk/flex/src/custom/questions/strategyDesign/PlannerRow.mxml 2009-07-09 00:39:46 UTC (rev 173) +++ mentalmodels/trunk/flex/src/custom/questions/strategyDesign/PlannerRow.mxml 2009-07-10 07:04:06 UTC (rev 174) @@ -34,6 +34,12 @@ if(newValue == "Bay 1") location.selectedIndex = 1; if(newValue == "Bay 2") location.selectedIndex = 2; if(newValue == "Bay 3") location.selectedIndex = 3; + if(newValue == "Bay 4") location.selectedIndex = 1; + if(newValue == "Bay 5") location.selectedIndex = 2; + if(newValue == "Bay 6") location.selectedIndex = 3; + if(newValue == "Bay 7") location.selectedIndex = 1; + if(newValue == "Bay 8") location.selectedIndex = 2; + if(newValue == "Bay 9") location.selectedIndex = 3; changedLocation(); } public function getDays():Number This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <kj...@us...> - 2009-07-09 00:40:01
|
Revision: 173 http://virtualcommons.svn.sourceforge.net/virtualcommons/?rev=173&view=rev Author: kjonas Date: 2009-07-09 00:39:46 +0000 (Thu, 09 Jul 2009) Log Message: ----------- Information windows now scale down by 75% when not popped-up, windows slightly bigger Modified Paths: -------------- mentalmodels/trunk/flex/src/FisheryExperimentShell.mxml mentalmodels/trunk/flex/src/actionscript/Block.as mentalmodels/trunk/flex/src/custom/FisheryExperimentKalin.mxml mentalmodels/trunk/flex/src/custom/InformationWindowPopup.mxml mentalmodels/trunk/flex/src/custom/SocioDemographicPage.mxml mentalmodels/trunk/flex/src/custom/questions/dayByDayDecisions/DayByDayDecisionsQuestionC.mxml Added Paths: ----------- mentalmodels/trunk/flex/src/LakeImage.png mentalmodels/trunk/flex/src/actionscript/InformationWindowCreator.as Modified: mentalmodels/trunk/flex/src/FisheryExperimentShell.mxml =================================================================== --- mentalmodels/trunk/flex/src/FisheryExperimentShell.mxml 2009-07-05 23:58:17 UTC (rev 172) +++ mentalmodels/trunk/flex/src/FisheryExperimentShell.mxml 2009-07-09 00:39:46 UTC (rev 173) @@ -1,38 +1,47 @@ <?xml version="1.0" encoding="utf-8"?> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" backgroundGradientAlphas="[1.0, 1.0]" backgroundGradientColors="[#FFFFFF, #B0B0FF]" - layout="horizontal" - width="100%" height="100%" xmlns:custom="custom.*"> + layout="horizontal" horizontalGap="30" + width="100%" height="100%" xmlns:custom="custom.*" + initialize="init()"> <mx:VBox id="vbxInfo"> - <mx:TitleWindow id="InformationWindowA" width="300" height="200" title="Information Window A" + <mx:TitleWindow id="InformationWindowA" width="400" height="200" title="Information Window A" clipContent="true" horizontalScrollPolicy="on" verticalScrollPolicy="on"> - <mx:Label text="InfoA"/> </mx:TitleWindow> <mx:HBox id="hbxPickerA"> - <mx:ComboBox id="cbxPickerA"/> + <mx:ComboBox id="cbxPickerA" maxWidth="225" change="cbxChanged()"/> <mx:Button id="btnPickerA" label="Pop Up" click="popupInformationWindow(1)"/> </mx:HBox> - <mx:TitleWindow id="InformationWindowB" width="300" height="200" title="Information Window B" + <mx:TitleWindow id="InformationWindowB" width="400" height="200" title="Information Window B" clipContent="true" horizontalScrollPolicy="on" verticalScrollPolicy="on"> - <mx:Label text="InfoB"/> </mx:TitleWindow> <mx:HBox id="hbxPickerB"> - <mx:ComboBox id="cbxPickerB"/> + <mx:ComboBox id="cbxPickerB" maxWidth="225" change="cbxChanged()"/> <mx:Button id="btnPickerB" label="{btnPickerA.label}" click="popupInformationWindow(2)"/> </mx:HBox> + <mx:Button id="btnResetPopups" label="Reset Popups" click="closedFunction()"/> </mx:VBox> - <mx:VBox id="vbxContent" horizontalAlign="center" verticalAlign="middle" - width="{this.width - 400}" - height="{this.height - 80}"> - <custom:FisheryExperimentKalin id="fisheryContent"/> + <mx:VBox id="vbxContent" horizontalAlign="center" verticalAlign="middle"> + <custom:FisheryExperimentKalin id="fisheryContent" blockLoader="loadBlock"/> </mx:VBox> <mx:Script> <![CDATA[ + import mx.controls.Alert; + import mx.controls.Spacer; + import mx.controls.Image; + import mx.controls.TextArea; + import mx.controls.Text; + import mx.controls.Label; + import mx.containers.Canvas; + import actionscript.Block; + import actionscript.Module; + import actionscript.InformationWindowCreator; + import mx.collections.ArrayCollection; import mx.skins.halo.TitleBackground; import custom.InformationWindowPopup; import mx.managers.PopUpManager; @@ -40,12 +49,33 @@ public var popupA:InformationWindowPopup = null; public var popupB:InformationWindowPopup = null; + public var allInfoWindowsA:ArrayCollection = null; + public var allInfoWindowsB:ArrayCollection = null; + public var allInfoWindowsDescriptions:ArrayCollection = null; + + public var currInfoWindowsA:ArrayCollection = null; + public var currInfoWindowsB:ArrayCollection = null; + public var currInfoWindowsDescriptions:ArrayCollection = null; + + public var currModule:Module = null; + public var currBlock:Block = null; + + public function init():void + { + allInfoWindowsA = makeWindows(); + allInfoWindowsB = makeWindows(); + var arry:ArrayCollection = new ArrayCollection(); // fix when communicating with server... + for(var i:int=0;i<30;i++) arry.addItem(i); // fix when communicating with server... + selectCurrentWindows( arry ); // fix when communicating with server... + cbxChanged(); + } + public function popupInformationWindow(source:int):void { + var temp:DisplayObject = null; + var popupNew:InformationWindowPopup = PopUpManager.createPopUp(this, InformationWindowPopup, false) as InformationWindowPopup; popupNew.closedFunction = closedFunction; - popupNew.horizontalScrollPolicy = "on"; - popupNew.verticalScrollPolicy = "on"; var old:TitleWindow = null; @@ -68,7 +98,10 @@ while(old != null && old.numChildren > 0) { - popupNew.addChild(old.removeChildAt(0)) + temp = old.removeChildAt(0); + temp.scaleX = 1; + temp.scaleY = 1; + popupNew.addChild(temp); } PopUpManager.centerPopUp(popupNew); @@ -76,11 +109,15 @@ public function closedFunction():void { + var temp:DisplayObject = null; if(popupA != null) { while(popupA.numChildren > 0) { - InformationWindowA.addChild(popupA.removeChildAt(0)) + temp = popupA.removeChildAt(0); + temp.scaleX = 0.75; + temp.scaleY = 0.75; + InformationWindowA.addChild(temp); } PopUpManager.removePopUp(popupA); popupA = null; @@ -90,7 +127,10 @@ { while(popupB.numChildren > 0) { - InformationWindowB.addChild(popupB.removeChildAt(0)) + temp = popupB.removeChildAt(0) + temp.scaleX = 0.75; + temp.scaleY = 0.75; + InformationWindowB.addChild(temp); } PopUpManager.removePopUp(popupB); popupB = null; @@ -100,6 +140,71 @@ cbxPickerA.enabled = cbxPickerB.enabled = true; } + public function makeWindows():ArrayCollection + { + var windowData:ArrayCollection = InformationWindowCreator.makeWindows(); + allInfoWindowsDescriptions = windowData.getItemAt(1) as ArrayCollection; + return windowData.getItemAt(0) as ArrayCollection; + } + + public function selectCurrentWindows(selectedWindows:ArrayCollection):void + { + currInfoWindowsA = new ArrayCollection(); + currInfoWindowsB = new ArrayCollection(); + currInfoWindowsDescriptions = new ArrayCollection(); + + for(var i:int = 0; i < selectedWindows.length; i++) + { + var selectedIndex:int = selectedWindows.getItemAt(i) as int; + if(selectedIndex < allInfoWindowsA.length && selectedIndex < allInfoWindowsB.length) + { + currInfoWindowsA.addItem(allInfoWindowsA.getItemAt(selectedIndex)); + currInfoWindowsB.addItem(allInfoWindowsB.getItemAt(selectedIndex)); + currInfoWindowsDescriptions.addItem(allInfoWindowsDescriptions.getItemAt(selectedIndex)); + } + } + + cbxPickerA.dataProvider = currInfoWindowsDescriptions; + cbxPickerB.dataProvider = currInfoWindowsDescriptions; + } + + public function cbxChanged():void + { + var temp:DisplayObject = null; + if(cbxPickerA.selectedIndex >= 0 && cbxPickerA.selectedIndex <= currInfoWindowsA.length && cbxPickerA.enabled) + { + InformationWindowA.removeAllChildren(); + + var windowA:ArrayCollection = currInfoWindowsA.getItemAt(cbxPickerA.selectedIndex) as ArrayCollection; + for(var i:int = 0; i < windowA.length; i++) + { + temp = windowA.getItemAt(i) as DisplayObject; + temp.scaleX = 0.75; + temp.scaleY = 0.75; + InformationWindowA.addChild(temp); + } + } + + if(cbxPickerB.selectedIndex >= 0 && cbxPickerB.selectedIndex <= currInfoWindowsB.length && cbxPickerB.enabled) + { + InformationWindowB.removeAllChildren(); + + var windowB:ArrayCollection = currInfoWindowsB.getItemAt(cbxPickerB.selectedIndex) as ArrayCollection; + for(var j:int = 0; j < windowB.length; j++) + { + temp = windowB.getItemAt(j) as DisplayObject; + temp.scaleX = 0.75; + temp.scaleY = 0.75; + InformationWindowB.addChild(temp); + } + } + } + + public function loadBlock(module:Module, block:Block):void + { + + } + ]]> </mx:Script> Added: mentalmodels/trunk/flex/src/LakeImage.png =================================================================== (Binary files differ) Property changes on: mentalmodels/trunk/flex/src/LakeImage.png ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Modified: mentalmodels/trunk/flex/src/actionscript/Block.as =================================================================== --- mentalmodels/trunk/flex/src/actionscript/Block.as 2009-07-05 23:58:17 UTC (rev 172) +++ mentalmodels/trunk/flex/src/actionscript/Block.as 2009-07-09 00:39:46 UTC (rev 173) @@ -11,5 +11,6 @@ public var description:String; public var duration:int; public var questionGroups:ArrayCollection; + public var informationWindows:ArrayCollection; } } \ No newline at end of file Added: mentalmodels/trunk/flex/src/actionscript/InformationWindowCreator.as =================================================================== --- mentalmodels/trunk/flex/src/actionscript/InformationWindowCreator.as (rev 0) +++ mentalmodels/trunk/flex/src/actionscript/InformationWindowCreator.as 2009-07-09 00:39:46 UTC (rev 173) @@ -0,0 +1,484 @@ +package actionscript +{ + import custom.questions.CategoricalQuestionC; + import custom.questions.TextQuestionC; + import custom.questions.dayByDayDecisions.DayByDayDecisionsQuestionC; + import custom.questions.forecasting.ForecastingFishQuestionC; + import custom.questions.strategyDesign.StrategyDesignQuestionC; + + import flash.display.DisplayObject; + + import mx.collections.ArrayCollection; + import mx.containers.HBox; + import mx.containers.VBox; + import mx.controls.Image; + import mx.controls.Label; + import mx.controls.Text; + + public class InformationWindowCreator + { + public var listeners:ArrayCollection; + + public function InformationWindowCreator() + { + listeners = new ArrayCollection(); + } + + public static var maxWidth:int = 460; + + public static function makeWindows():ArrayCollection + { + var listenerObject:InformationWindowCreator = new InformationWindowCreator(); + + var allInfoWindows:ArrayCollection = new ArrayCollection(); + var allInfoWindowsDescriptions:ArrayCollection = new ArrayCollection(); + + var tempWindow:ArrayCollection; + var temp:DisplayObject; + + //// + // Window 0 + tempWindow = new ArrayCollection(); + + temp = new Label(); + (temp as Label).text = "This is an Information Window"; + (temp as Label).setStyle("fontSize",14); + (temp as Label).setStyle("fontWeight","bold"); + tempWindow.addItem(temp); + + temp = new Text(); + (temp as Text).htmlText = "What is presented in an information window can be selected from the drop-down list below each window!<br><br>Please check the options of the drop-down list when entering a new module of the experiment (i.e. after leaving a module by clicking on “Accept”).<br><br><br>If you would like to look at the contents of an information window bigger, click the “Pop Up” button below."; + (temp as Text).width = maxWidth; + tempWindow.addItem(temp); + + allInfoWindows.addItem(tempWindow); + allInfoWindowsDescriptions.addItem("Dummy Window"); + + //// + // Window 1 + tempWindow = new ArrayCollection(); + + temp = new Label(); + (temp as Label).text = "Model of the Fishing Ground"; + (temp as Label).setStyle("fontSize",14); + (temp as Label).setStyle("fontWeight","bold"); + tempWindow.addItem(temp); + + [Embed(source="LakeImage.png")] var img:Class; + temp = new Image(); + (temp as Image).source = img; + (temp as Image).maxWidth = 600; + (temp as Image).maxHeight = 600; + tempWindow.addItem(temp); + + allInfoWindows.addItem(tempWindow); + allInfoWindowsDescriptions.addItem("Model of the Fishing Ground"); + + //// + // Window 2 + tempWindow = new ArrayCollection(); + + temp = new Label(); + (temp as Label).text = "Important Formulas"; + (temp as Label).setStyle("fontSize",14); + (temp as Label).setStyle("fontWeight","bold"); + tempWindow.addItem(temp); + + temp = new HBox(); + (temp as HBox).setStyle("verticalAlign", "middle"); + var tempLabel:Label = new Label(); + tempLabel.text = "Fishing Takes Out:"; + (temp as HBox).addChild(tempLabel); + tempLabel = new Label(); + tempLabel.text = "5 *"; + tempLabel.setStyle("fontSize",12); + (temp as HBox).addChild(tempLabel); + var tempVBox:VBox = new VBox(); + tempVBox.setStyle("verticalGap","-6"); + tempVBox.setStyle("horizontalAlign","center"); + tempLabel = new Label(); + tempLabel.text = "Amount of Fish in Bay Before Fishing"; + tempLabel.setStyle("fontSize",12); + tempLabel.setStyle("textDecoration","underline"); + tempVBox.addChild(tempLabel); + tempLabel = new Label(); + tempLabel.text = "Capacity of Bay"; + tempLabel.setStyle("fontSize",12); + tempVBox.addChild(tempLabel); + (temp as HBox).addChild(tempVBox); + tempLabel = new Label(); + tempLabel.text = "lbs of fish."; + (temp as HBox).addChild(tempLabel); + tempWindow.addItem(temp); + + temp = new Text(); + (temp as Text).htmlText = "When several fishermen fish in the same bay and they take out more fish from the bay than it contains, the amount of fish in the bay is divided equally between the fishermen.<br>Staying in the harbor gives no earnings and does not diminish the fish population."; + (temp as Text).width = maxWidth; + tempWindow.addItem(temp); + + temp = new Text(); + (temp as Text).htmlText = "<br><b>Basic principles of the dynamics of the fish population:</b><ul><li>If all bays are <b>filled up</b> with fish, then the total growth is highest, but all additional lbs of fish are lost to the ocean and the amount of fish in the bays stops growing.</li><li>If the bays are <b>half filled</b>, then the amount of fish in the bays grows fastest.</li><li>If the bays are <b>nearly empty</b>, the population grows very slowly.</li><li>If there are <b>no fish</b> in any of the bays, there will be never any fish again.</li><li>If there are <b>both crowded and empty</b> bays, a lot of fish move from the crowded to the empty bays.</li></ul>"; + (temp as Text).width = maxWidth; + tempWindow.addItem(temp); + + temp = new Text(); + (temp as Text).htmlText = "<br><b>Equations of the dynamics for each bay and each day:</b><br>(Note: The <b>current fish population</b> is the amount of fish in a bay <b>after fishing</b>.)"; + tempWindow.addItem(temp); + + temp = new Text(); + (temp as Text).htmlText = " <b>∙</b> Growth = Current Fish Population * Growth Rate"; + (temp as Text).setStyle("fontSize",12); + tempWindow.addItem(temp); + + temp = new HBox(); + (temp as HBox).setStyle("verticalAlign", "middle"); + tempLabel = new Label(); + tempLabel.htmlText = " <b>∙</b> Fish Leaving = "; + tempLabel.setStyle("fontSize",12); + (temp as HBox).addChild(tempLabel); + tempVBox = new VBox(); + tempVBox.setStyle("verticalGap","-6"); + tempVBox.setStyle("horizontalAlign","center"); + tempLabel = new Label(); + tempLabel.text = "Current Fish Population"; + tempLabel.setStyle("fontSize",12); + tempLabel.setStyle("textDecoration","underline"); + tempVBox.addChild(tempLabel); + tempLabel = new Label(); + tempLabel.text = "Capacity of Bay"; + tempLabel.setStyle("fontSize",12); + tempVBox.addChild(tempLabel); + (temp as HBox).addChild(tempVBox); + tempLabel = new Label(); + tempLabel.text = "* Growth Rate"; + tempLabel.setStyle("fontSize",12); + (temp as HBox).addChild(tempLabel); + (temp as HBox).width = maxWidth; + tempWindow.addItem(temp); + + temp = new Text(); + (temp as Text).htmlText = " <b>∙</b> Fish Returning = Emptiness * Amount of Fish in Ocean * Relative Emptiness to Other Bays"; + (temp as Text).setStyle("fontSize",12); + (temp as Text).width = maxWidth; + tempWindow.addItem(temp); + + temp = new HBox(); + (temp as HBox).setStyle("verticalAlign", "middle"); + tempLabel = new Label(); + tempLabel.htmlText = " <b>∙</b> Emptiness = 1 -"; + tempLabel.setStyle("fontSize",12); + (temp as HBox).addChild(tempLabel); + tempVBox = new VBox(); + tempVBox.setStyle("verticalGap","-6"); + tempVBox.setStyle("horizontalAlign","center"); + tempLabel = new Label(); + tempLabel.text = "Current Fish Population"; + tempLabel.setStyle("fontSize",12); + tempLabel.setStyle("textDecoration","underline"); + tempVBox.addChild(tempLabel); + tempLabel = new Label(); + tempLabel.text = "Capacity of Bay"; + tempLabel.setStyle("fontSize",12); + tempVBox.addChild(tempLabel); + (temp as HBox).addChild(tempVBox); + tempWindow.addItem(temp); + + allInfoWindows.addItem(tempWindow); + allInfoWindowsDescriptions.addItem("Important Formulas"); + + //// + // Window 3 + tempWindow = new ArrayCollection(); + + temp = new Label(); + (temp as Label).text = "Help for Strategy Design"; + (temp as Label).setStyle("fontSize",14); + (temp as Label).setStyle("fontWeight","bold"); + tempWindow.addItem(temp); + + temp = new Text(); + (temp as Text).htmlText = "<b>Note: You do not need to read the following text. The information given in the main window is sufficient to design your strategy. However, if you want to look up specific information, you will find the following:</b>"+ + "<br> <b>∙</b>Tips on how to proceed in the design of your strategy"+ + "<br> <b>∙</b>Explanations of the key concepts used in the strategy design:"+ + "<br> <b>∙</b>Start-up decisions"+ + "<br> <b>∙</b>Repeated decisions"+ + "<br> <b>∙</b>Decision element “Location”"+ + "<br> <b>∙</b>Decision element “Days”"+ + "<br> <b>∙</b>Decision element “Threshold”"+ + "<br> <b>∙</b>Suspension of the repetition (staying in the harbor if fish population is low)"+ + "<br> <b>∙</b>An example of a strategy and what this strategy would do"; + (temp as Text).setStyle("fontSize",12); + (temp as Text).width = maxWidth; + tempWindow.addItem(temp); + + tempWindow.addItem(new Label()); + tempVBox = new VBox(); + tempVBox.setStyle("borderStyle","solid"); + tempVBox.width = 300; + tempWindow.addItem(tempVBox); + + temp = new Text(); + (temp as Text).htmlText = "<br><b>Procedure:</b>"+ + "<ul><li>When designing the strategy you first might think about the state of the fish population that you would like when running your repeated sequence of decisions. Based on this you can decide on the start-up decisions. If, for example, you prefer to have a larger fish population than the half-filled bays the simulation starts with, then you might consider staying in the harbor some days. As another example, you might start with fishing all bays for a day to get the fish before the others do, even though you do not want to go on repeating this pattern later on.</li>"+ + "<li>Alternatively, you also might start with the repeated decisions assuming the system is already in the state on which these work best. You can specify a sequence which you think makes sense to repeat for an indefinite period, and then design the start-up rules in a way that this sequence works best. Note that you have to specify at least one repeated decision, which might include staying in the harbor.</li>"+ + "<li>When specifying a decision, first think of the location: Do you want to give a break and stay in the harbor or do you want to fish? If you plan to fish, which bay would be best to be fished first and which bay would be best later on?</li>"+ + "<li>The next step in specifying a decision is to set the days you plan to stay at a location. If you plan to fish longer than a day, you might also consider setting a threshold for moving on earlier if the earnings drop too low. By setting the threshold to rather low values you avoid moving too fast from bay to bay. If you plan to stay in the harbor or only for one day in a bay, then the threshold can be ignored.</li>"+ + "<li>The final step is to think about the suspension of the repeated sequence. It is not necessary to specify these conditions, but they might protect the fish population form being completely destroyed. First, think on what would be the lowest earnings for which you think it still is better to go on repeating your sequence instead of going to the harbor (i.e. set the threshold). Then, think on how many days would be necessary to stay in the harbor until starting the repeated sequence again.</li></ul>"+ + "<br><br><b>Start-up decisions:</b><ul><li>You can define a set of start-up decisions to prepare the system for the repeated decisions (e.g. stay in the harbor to let the fish population grow, harvest all bays to get the fish before the others, etc.). These decisions are not repeated and usually the complete set of start-up decisions takes up only a few days. You may create a strategy without using start-up decisions. For the elements of a decision, see the entries ‘Location’, ‘Days’, and ‘Threshold’.</li></ul>"+ + "<br><br><b>Repeated decisions:</b><ul><li>The core of your strategy is a set of decisions that is repeated after the start-up decisions for the entire simulation. You have to specify at least one repeated decision, which also might be staying in the harbor. The decisions are always processed in the same sequence. After the last decision, the first one will be applied again. For the elements of a decision, see the entries ‘Location’, ‘Days’, and ‘Threshold’.</li></ul>"+ + "<br><br><b>Location:</b><ul><li>One element of a decision is where to go. You can stay in the harbor and thus get no fish but neither the fish population is reduced. Otherwise, you can go to one of the bays. In this case you fish for an amount predefined by the percentage the bay is filled (maximum 5 lb if the bay is completely filled) and maybe the number of other fishermen in the bay. To reduce the quantity you are fishing in a bay you have to switch between fishing in that bay and staying in the harbor or fishing in another bay.</li></ul>"+ + "<br><br><b>Days:</b><ul><li>You specify how many days you plan to stay at a certain location (the harbor or one of the bays). After the specified number of days you leave the location to go to the one specified in the next decision. If you want to ignore this condition in one of your decisions, then set the number of days to 30. In this case you will change the location only due to a low earning from fishing as specified by the threshold.</li></ul>"+ + "<br><br><b>Threshold:</b><ul><li>If you fish less then the amount specified by the threshold, you move on to the location specified by the next decision. This way you avoid staying in an unproductive bay. If you want to ignore this condition as one of your decisions, then set the threshold to 0. Usually the threshold is set to rather small values. However, values up to 5 lb are possible. A threshold larger than 5 lb does not make sense because you can fish only up to 5 lb. Also in the case that you plan to stay at a location only for one day the threshold can be ignored as you will move on the next day, anyway. The threshold cannot be set for staying in the harbor as at this location one cannot fish anything.</li></ul>"+ + "<br><br><b>Suspend repetition:</b><ul><li>You can define a threshold of earnings that must be reached to go on repeating your set of repeated decisions. After the last repeated decision it is checked what the highest earning at any of the days were. If the highest earning is lower than the threshold, then you stay a number of days in the harbor before starting again the set of repeated decisions. This way you can avoid destroying the fish population if it reached a very low level. You can ignore this condition by setting the threshold for going to or the number of days of staying in the harbor to zero. The threshold for going to the harbor is usually set lower than the thresholds for moving from one location to the next. However, it is possible to set the threshold for going to the harbor higher than thresholds for moving on because the harbor threshold is only checked at the end of a repetition.</li></ul>"+ + "<br><br><b>Example:</b>"+ + "<br> <b>∙</b>Start-up decisions:"+ + "<br> <b>∙</b>Start-up decision 1: Location = Harbor, Days = 3, Threshold = n/a"+ + "<br> <b>∙</b>Start-up decision 2: Location = Bay 1, Days = 2, Threshold = 0.5 lb"+ + "<br> <b>∙</b>Repeated decisions:"+ + "<br> <b>∙</b>Repeated decision 1: Location = Bay 1, Days = 3, Threshold = 0.2 lb"+ + "<br> <b>∙</b>Repeated decision 2: Location = Bay 2, Days = 2, Threshold = 0.4 lb"+ + "<br> <b>∙</b>Repeated decision 3: Location = Bay 3, Days = 1, Threshold = 0.6 lb"+ + "<br> <b>∙</b>Repeated decision 4: Location = Harbor, Days = 3, Threshold = n/a"+ + "<br> <b>∙</b>Suspend repetition:"+ + "<br> <b>∙</b>Threshold = 0.1 lb"+ + "<br> <b>∙</b>Days = 5"+ + "<br><br><b>This example strategy would lead to the following behavior:</b>"+ + "<ul><li>You would stay three days in the harbor and then fish two days in Bay 1 unless on the first day in Bay 1 you fish less then 0.5 lb.</li>"+ + "<li>Then you fish 3 days in Bay 1 unless you fish less then 0.2 lb. After 3 days or if you earned less then 0.2 lb you fish 2 days in Bay 2 unless you fish less then 0.4 lb. After 2 days or if you earned less then 0.4 lb you fish 1 day in Bay 3. The threshold will be ignored here, as independent of your earnings, you will move on after fishing for one day in Bay 3. After staying 3 days in the harbor you fish again in Bay 1 unless in all three bays you fished less then 0.1 lb.</li>"+ + "<li>If you earned less than 0.1 lb in all three bays, instead of going to Bay 1 the next day you stay for five days in the harbor. Then, again, you fish in Bay 1.</li></ul>"; + (temp as Text).setStyle("fontSize",12); + (temp as Text).width = maxWidth; + tempWindow.addItem(temp); + + allInfoWindows.addItem(tempWindow); + allInfoWindowsDescriptions.addItem("Help for Strategy Design"); + + //// + // Window 4 + tempWindow = new ArrayCollection(); + + temp = new Label(); + (temp as Label).text = "The 30-Day Strategy you Designed"; + (temp as Label).setStyle("fontSize",14); + (temp as Label).setStyle("fontWeight","bold"); + tempWindow.addItem(temp); + + temp = new StrategyDesignQuestionC(); + (temp as StrategyDesignQuestionC).description = "This is the strategy that you designed previously. Use it for reference."; + (temp as StrategyDesignQuestionC).enabled = false; + tempWindow.addItem(temp); + + allInfoWindows.addItem(tempWindow); + allInfoWindowsDescriptions.addItem("Your Strategy"); + + //// + // Window 5 + tempWindow = new ArrayCollection(); + + temp = new Label(); + (temp as Label).text = "The Goals You Specified"; + (temp as Label).setStyle("fontSize",14); + (temp as Label).setStyle("fontWeight","bold"); + tempWindow.addItem(temp); + + temp = new Label(); + (temp as Label).text = "These are the goals that you specified previously. Use them for reference."; + (temp as Label).setStyle("fontSize",12); + tempWindow.addItem(temp); + + temp = new Label(); + (temp as Label).text = "Your most important goal is to"; + tempWindow.addItem(temp); + temp = new CategoricalQuestionC(); + (temp as CategoricalQuestionC).enabled = false; + tempWindow.addItem(temp); + + temp = new Label(); + (temp as Label).text = "Your second most important goal is to"; + tempWindow.addItem(temp); + temp = new CategoricalQuestionC(); + (temp as CategoricalQuestionC).enabled = false; + tempWindow.addItem(temp); + + temp = new Label(); + (temp as Label).text = "Your third most important goal is to"; + tempWindow.addItem(temp); + temp = new CategoricalQuestionC(); + (temp as CategoricalQuestionC).enabled = false; + tempWindow.addItem(temp); + + allInfoWindows.addItem(tempWindow); + allInfoWindowsDescriptions.addItem("Your Goals"); + + //// + // Window 6 + tempWindow = new ArrayCollection(); + + temp = new Label(); + (temp as Label).text = "Your Forecast of Developments Using the Strategy You Designed"; + (temp as Label).setStyle("fontSize",14); + (temp as Label).setStyle("fontWeight","bold"); + tempWindow.addItem(temp); + + temp = new ForecastingFishQuestionC(); + (temp as ForecastingFishQuestionC).enabled = false; + tempWindow.addItem(temp); + + allInfoWindows.addItem(tempWindow); + allInfoWindowsDescriptions.addItem("Your Forecast"); + + //// + // Window 7 + tempWindow = new ArrayCollection(); + + temp = new Label(); + (temp as Label).text = "Results of Day-by-Day Decisions"; + (temp as Label).setStyle("fontSize",14); + (temp as Label).setStyle("fontWeight","bold"); + tempWindow.addItem(temp); + + temp = new DayByDayDecisionsQuestionC(); + (temp as DayByDayDecisionsQuestionC).enabled = false; + tempWindow.addItem(temp); + + allInfoWindows.addItem(tempWindow); + allInfoWindowsDescriptions.addItem("Day-by-Day Results"); + + //// + // Window 8 + tempWindow = new ArrayCollection(); + + temp = new Label(); + (temp as Label).text = "Results of Your 30-Day Strategy"; + (temp as Label).setStyle("fontSize",14); + (temp as Label).setStyle("fontWeight","bold"); + tempWindow.addItem(temp); + + temp = new DayByDayDecisionsQuestionC(); + (temp as DayByDayDecisionsQuestionC).enabled = false; + tempWindow.addItem(temp); + + allInfoWindows.addItem(tempWindow); + allInfoWindowsDescriptions.addItem("Strategy Results"); + + //// + // Window 9 + tempWindow = new ArrayCollection(); + + temp = new Label(); + (temp as Label).text = "Your Notes on What to Change for the Next Round"; + (temp as Label).setStyle("fontSize",14); + (temp as Label).setStyle("fontWeight","bold"); + tempWindow.addItem(temp); + + temp = new Label(); + (temp as Label).text = "New Understanding of Fish Dynamics"; + tempWindow.addItem(temp); + temp = new TextQuestionC(); + (temp as TextQuestionC).enabled = false; + tempWindow.addItem(temp); + + temp = new Label(); + (temp as Label).text = "New Expectations on How the Others of the Group Will Act"; + tempWindow.addItem(temp); + temp = new TextQuestionC(); + (temp as TextQuestionC).enabled = false; + tempWindow.addItem(temp); + + temp = new Label(); + (temp as Label).text = "Ideas for Improving Your Strategy"; + tempWindow.addItem(temp); + temp = new TextQuestionC(); + (temp as TextQuestionC).enabled = false; + tempWindow.addItem(temp); + + allInfoWindows.addItem(tempWindow); + allInfoWindowsDescriptions.addItem("Notes - Yourself"); + + //// + // Window 10 + tempWindow = new ArrayCollection(); + + temp = new Label(); + (temp as Label).text = "Your Conclusions From Communication"; + (temp as Label).setStyle("fontSize",14); + (temp as Label).setStyle("fontWeight","bold"); + tempWindow.addItem(temp); + + temp = new Label(); + (temp as Label).text = "Rules or Agreements to Consider"; + tempWindow.addItem(temp); + temp = new TextQuestionC(); + (temp as TextQuestionC).enabled = false; + tempWindow.addItem(temp); + + temp = new Label(); + (temp as Label).text = "New Understanding of Fish Dynamics"; + tempWindow.addItem(temp); + temp = new TextQuestionC(); + (temp as TextQuestionC).enabled = false; + tempWindow.addItem(temp); + + temp = new Label(); + (temp as Label).text = "New Expectations on How the Others of the Group Will Act"; + tempWindow.addItem(temp); + temp = new TextQuestionC(); + (temp as TextQuestionC).enabled = false; + tempWindow.addItem(temp); + + temp = new Label(); + (temp as Label).text = "Ideas for Improving Your Strategy"; + tempWindow.addItem(temp); + temp = new TextQuestionC(); + (temp as TextQuestionC).enabled = false; + tempWindow.addItem(temp); + + allInfoWindows.addItem(tempWindow); + allInfoWindowsDescriptions.addItem("Notes - With Group"); + + //// + // Window 11 + tempWindow = new ArrayCollection(); + + temp = new Label(); + (temp as Label).text = "Title"; + (temp as Label).setStyle("fontSize",14); + (temp as Label).setStyle("fontWeight","bold"); + tempWindow.addItem(temp); + + allInfoWindows.addItem(tempWindow); + allInfoWindowsDescriptions.addItem("Window Description"); + + + + + /* + //// + // Window X + tempWindow = new ArrayCollection(); + + temp = new Label(); + (temp as Label).text = "Title"; + (temp as Label).setStyle("fontSize",14); + (temp as Label).setStyle("fontWeight","bold"); + tempWindow.addItem(temp); + + allInfoWindows.addItem(tempWindow); + allInfoWindowsDescriptions.addItem("Window Description"); + */ + + + var content:ArrayCollection = new ArrayCollection(); + content.addItem(allInfoWindows); + content.addItem(allInfoWindowsDescriptions); + +for(var endLoop:int; endLoop < allInfoWindowsDescriptions.length; endLoop++) +{ + allInfoWindowsDescriptions.setItemAt(endLoop + (allInfoWindowsDescriptions.getItemAt(endLoop) as String), endLoop); +} + + return content; + //InformationWindowA.addChild( allInfoWindows.getItemAt(0) as DisplayObject ); + } + } +} \ No newline at end of file Modified: mentalmodels/trunk/flex/src/custom/FisheryExperimentKalin.mxml =================================================================== --- mentalmodels/trunk/flex/src/custom/FisheryExperimentKalin.mxml 2009-07-05 23:58:17 UTC (rev 172) +++ mentalmodels/trunk/flex/src/custom/FisheryExperimentKalin.mxml 2009-07-09 00:39:46 UTC (rev 173) @@ -2,7 +2,7 @@ <mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:net="flash.net.*" xmlns:comp="custom.*" clipContent="false" verticalScrollPolicy="off" horizontalScrollPolicy="off" currentState="socioDemographic" initialize="init()" - width="100%" height="100%"> + width="720" height="490"> <mx:states> <mx:State name="socioDemographic"> @@ -35,15 +35,13 @@ </mx:State> </mx:states> - - <!-- <mx:Canvas id="content" x="5" y="5" width="750" height="470"/> --> - <mx:Canvas id="content" x="0" y="0" width="100%" height="100%"/> + <mx:Canvas id="content" x="0" y="0" width="720" height="475"/> <mx:Canvas id="expiredContent" x="-1" y="-1" width="1" height="1" visible="false"/> - <mx:Button id="btnBack" label="« Back" click="back()" left="8" bottom="8" enabled="false"/> - <mx:Button id="btnAccept" label="Accept" click="accept()" left="{(width-btnAccept.width)/2}" bottom="10"/> - <mx:Button id="btnForward" label="Forward »" click="forward()" right="8" bottom="8" enabled="false"/> + <mx:Button id="btnBack" label="« Back" click="back()" left="0" bottom="0" enabled="false"/> + <mx:Button id="btnAccept" label="Accept" click="accept()" left="{(width-btnAccept.width)/2}" bottom="0"/> + <mx:Button id="btnForward" label="Forward »" click="forward()" right="0" bottom="0" enabled="false"/> <mx:RemoteObject id="ss" destination="studentService" fault="faultHandler(event)" result="resultHandler(event)"/> <mx:Producer id="producer" destination="DataPush" acknowledge="ack(event)"/> @@ -65,11 +63,12 @@ import mx.messaging.FlexClient; import mx.messaging.messages.AsyncMessage; - // // Important Variables // public var currModule:Module = null; + public var currBlock:Block = null; + public var blockLoader:Function = null; private var shared:SharedObject; private var flushMessage:String; @@ -212,6 +211,15 @@ //consumer.subscribe(); returnValue = true; } + else + { + var newCurrBlock:Block = (InstructionPage)(obj).block; + if(newCurrBlock != currBlock) + { + currBlock = newCurrBlock; + blockLoader.call(); + } + } } catch(err:Error){} } Modified: mentalmodels/trunk/flex/src/custom/InformationWindowPopup.mxml =================================================================== --- mentalmodels/trunk/flex/src/custom/InformationWindowPopup.mxml 2009-07-05 23:58:17 UTC (rev 172) +++ mentalmodels/trunk/flex/src/custom/InformationWindowPopup.mxml 2009-07-09 00:39:46 UTC (rev 173) @@ -4,7 +4,8 @@ title="Information Window Popup" showCloseButton="true" close="titleWindow_close(event);" - width="700" height="500"> + horizontalScrollPolicy="on" verticalScrollPolicy="on" + width="720" height="550"> <mx:Script> <![CDATA[ Modified: mentalmodels/trunk/flex/src/custom/SocioDemographicPage.mxml =================================================================== --- mentalmodels/trunk/flex/src/custom/SocioDemographicPage.mxml 2009-07-05 23:58:17 UTC (rev 172) +++ mentalmodels/trunk/flex/src/custom/SocioDemographicPage.mxml 2009-07-09 00:39:46 UTC (rev 173) @@ -40,8 +40,8 @@ }else{ boxGender.setStyle(bgcolor, ""); } - - if(getYear().length != 4 || Number(getYear()) < 1900) + var today:Date = new Date(); + if(getYear().length != 4 || Number(getYear()) < today.fullYear - 180 || Number(getYear()) > today.fullYear) { txtYear.setStyle(bgcolor, red); ready=false; Modified: mentalmodels/trunk/flex/src/custom/questions/dayByDayDecisions/DayByDayDecisionsQuestionC.mxml =================================================================== --- mentalmodels/trunk/flex/src/custom/questions/dayByDayDecisions/DayByDayDecisionsQuestionC.mxml 2009-07-05 23:58:17 UTC (rev 172) +++ mentalmodels/trunk/flex/src/custom/questions/dayByDayDecisions/DayByDayDecisionsQuestionC.mxml 2009-07-09 00:39:46 UTC (rev 173) @@ -10,7 +10,7 @@ <mx:HBox id="labels" verticalAlign="middle"/> <mx:VBox id="dayByDayContent" borderStyle="outset" minWidth="655" verticalGap="0" - height="300" verticalScrollPolicy="on"/> + height="250" verticalScrollPolicy="on"/> <mx:Label id="lblCumulative" text="So far, you have fished {getLbs(cumTotal)}, which is worth {getMoney(cumTotal,dollarPerLb)}."/> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <kj...@us...> - 2009-07-05 23:58:24
|
Revision: 172 http://virtualcommons.svn.sourceforge.net/virtualcommons/?rev=172&view=rev Author: kjonas Date: 2009-07-05 23:58:17 +0000 (Sun, 05 Jul 2009) Log Message: ----------- trying to re-commit restructured folders Added Paths: ----------- mentalmodels/trunk/flex/src/custom/questions/dayByDayDecisions/ mentalmodels/trunk/flex/src/custom/questions/dayByDayDecisions/DayByDayDecisionsQuestionC.mxml mentalmodels/trunk/flex/src/custom/questions/dayByDayDecisions/OneDay.mxml mentalmodels/trunk/flex/src/custom/questions/dayByDayDecisions/OneDecision.mxml mentalmodels/trunk/flex/src/custom/questions/dayByDayDecisions/TotalDisplay.mxml mentalmodels/trunk/flex/src/custom/questions/forecasting/ mentalmodels/trunk/flex/src/custom/questions/forecasting/ForecastComponent.mxml mentalmodels/trunk/flex/src/custom/questions/forecasting/ForecastingFishQuestionC.mxml mentalmodels/trunk/flex/src/custom/questions/forecasting/ForecastingPeopleQuestionC.mxml mentalmodels/trunk/flex/src/custom/questions/psychometric/ mentalmodels/trunk/flex/src/custom/questions/psychometric/PsychometricQuestionC.mxml mentalmodels/trunk/flex/src/custom/questions/psychometric/Slider.mxml mentalmodels/trunk/flex/src/custom/questions/psychometric/SliderImage.png mentalmodels/trunk/flex/src/custom/questions/strategyDesign/ mentalmodels/trunk/flex/src/custom/questions/strategyDesign/Planner.mxml mentalmodels/trunk/flex/src/custom/questions/strategyDesign/PlannerRow.mxml mentalmodels/trunk/flex/src/custom/questions/strategyDesign/StrategyDesignQuestionC.mxml Added: mentalmodels/trunk/flex/src/custom/questions/dayByDayDecisions/DayByDayDecisionsQuestionC.mxml =================================================================== --- mentalmodels/trunk/flex/src/custom/questions/dayByDayDecisions/DayByDayDecisionsQuestionC.mxml (rev 0) +++ mentalmodels/trunk/flex/src/custom/questions/dayByDayDecisions/DayByDayDecisionsQuestionC.mxml 2009-07-05 23:58:17 UTC (rev 172) @@ -0,0 +1,172 @@ +<?xml version="1.0" encoding="utf-8"?> +<mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml" initialize="init()"> + + <mx:String id="description"></mx:String> + + <mx:Label id="txtPrompt" text="It's Day {currentDay}. Where will you go to fish, or will you stay in the harbor?"/> + <mx:Label id="lblChosen" text="location chosen: {deciding}"/> + + <mx:HBox id="buttons"/> + <mx:HBox id="labels" verticalAlign="middle"/> + + <mx:VBox id="dayByDayContent" borderStyle="outset" minWidth="655" verticalGap="0" + height="300" verticalScrollPolicy="on"/> + + <mx:Label id="lblCumulative" text="So far, you have fished {getLbs(cumTotal)}, which is worth {getMoney(cumTotal,dollarPerLb)}."/> + + <mx:Script> + <![CDATA[ + import mx.controls.Button; + import mx.controls.Text; + import actionscript.questions.*; + import custom.questions.dayByDayDecisions.OneDay; + + public var numBays:int = 3; + [Bindable] public var deciding:int = 0; + [Bindable] public var currentDay:int = 1; + [Bindable] public var cumTotal:Number = 0; + [Bindable] public var dollarPerLb:Number = 3.99; + + public function init():void + { + buttons.removeAllChildren(); + labels.removeAllChildren(); + + var btnTemp:Button = new Button(); + btnTemp.label = "Harbor"; + btnTemp.id = "btnHarbor"; + btnTemp.addEventListener(MouseEvent.CLICK,clicked); + buttons.addChild(btnTemp); + + var txtTemp:Text = new Text(); + txtTemp = stylize(txtTemp); + txtTemp.minWidth = 50; + txtTemp.text = "Day"; + labels.addChild(txtTemp); + + txtTemp = new Text(); + txtTemp = stylize(txtTemp); + txtTemp.text = "Harbor"; + labels.addChild(txtTemp); + + for(var i:int = 0; i < numBays; i++) + { + btnTemp = new Button(); + btnTemp.label = "Bay" + (i+1); + btnTemp.id = "btn" + btnTemp.label; + btnTemp.addEventListener(MouseEvent.CLICK,clicked); + buttons.addChild(btnTemp); + + txtTemp = new Text(); + txtTemp = stylize(txtTemp); + txtTemp.text = "Bay" + (i+1); + labels.addChild(txtTemp); + } + + btnTemp = new Button(); + btnTemp.label = "Advance"; + btnTemp.id = "btnAdvance"; + btnTemp.addEventListener(MouseEvent.CLICK,advance); + buttons.addChild(btnTemp); + + txtTemp = new Text(); + txtTemp = stylize(txtTemp); + txtTemp.htmlText = "Cumulative<br>Total"; + txtTemp.minWidth = 60; + labels.addChild(txtTemp); + } + private function stylize(txtTemp:Text):Text + { + txtTemp.setStyle("textAlign", "center"); + txtTemp.setStyle("fontWeight","bold"); + txtTemp.minWidth = 125; + return txtTemp; + } + + public function clicked(event:MouseEvent):void + { + try + { + deciding = 0; + if(event != null && (event.target as Button).label != "Harbor") + { + var obj:Button = event.target as Button; + deciding = int(obj.label.substring(3)); + } + } + catch(err:Error) + { + // silent failure + deciding = 0; + } + } + + public function advance(event:MouseEvent=null):void + { + if(currentDay == 30) + { + return; + } + + var newDay:OneDay = new OneDay(); + newDay.numBays = numBays; + newDay.initialize(); + newDay.day = currentDay++; + newDay.dollarPerLb = dollarPerLb; + dayByDayContent.addChild(newDay.load(deciding)); + cumTotal += newDay.presentTotal; + +// try +// { +// var last:Object = dayByDayContent.getChildAt(dayByDayContent.numChildren - 1); +// if(last is OneDay) +// { +// cumTotal += (last as OneDay).presentTotal; +// } +// } +// catch(err:Error) +// { +// // silent failure +// } + + deciding = 0; + } + + public function loadFromQuestion(question:Question):void + { + description = question.question; + + initialize(); + init(); + } + + public function getLbs(lbsFished:Number):String + { + lbsFished = Math.round(lbsFished * 10.0) / 10.0; + + var zeroDec:String = ""; + if(lbsFished as int == lbsFished) + { + zeroDec = ".0"; + } + var lbString:String = String(lbsFished).substr(0,5) + zeroDec + " lbs"; + return lbString; + } + public function getMoney(lbsFished:Number, dollarPerLb:Number):String + { + var moneyMade:Number = lbsFished * dollarPerLb; + moneyMade = Math.floor(moneyMade * 100.0) / 100.0; + + var zeroDec:String = ""; + if(moneyMade as int == moneyMade) + { + zeroDec = ".00"; + } + var moneyString:String = "$" + moneyMade + zeroDec; + return moneyString; + } + + ]]> + </mx:Script> + +</mx:VBox> Added: mentalmodels/trunk/flex/src/custom/questions/dayByDayDecisions/OneDay.mxml =================================================================== --- mentalmodels/trunk/flex/src/custom/questions/dayByDayDecisions/OneDay.mxml (rev 0) +++ mentalmodels/trunk/flex/src/custom/questions/dayByDayDecisions/OneDay.mxml 2009-07-05 23:58:17 UTC (rev 172) @@ -0,0 +1,125 @@ +<?xml version="1.0" encoding="utf-8"?> +<mx:HBox xmlns:mx="http://www.adobe.com/2006/mxml" initialize="init()" borderStyle="inset"> + + <mx:Script> + <![CDATA[ + import mx.controls.Text; + import mx.controls.Label; + import mx.collections.ArrayCollection; + + [Bindable] public var numBays:int = 3; + [Bindable] public var decisions:ArrayCollection; + + public var previousTotal:Number = 0; + public var presentTotal:Number = 0; + public var day:int = 1; + public var dollarPerLb:Number = 3.99; + + public function init():void + { + if(decisions == null) + { + drawNull(); + } + else if(decisions.length < numBays+1) + { + drawPartial(); + } + else + { + drawFull(); + } + } + + public function drawNull():void + { + decisions = new ArrayCollection(); + + var temp:OneDecision = new OneDecision(); + temp.lbsFished = 0.0; + temp.initialize(); + temp.redraw(); + decisions.addItem(temp); + + drawPartial(); + } + + public function drawPartial():void + { + var temp:OneDecision; + for(var i:int = decisions.length; i < numBays+1; i++) + { + temp = new OneDecision(); + temp.active = false; + temp.initialize(); + temp.redraw(); + decisions.addItem(temp); + } + + drawFull(); + } + + public function drawFull():void + { + removeAllChildren(); + presentTotal = previousTotal; + + var dayText:Text = new Text(); + dayText.text = day + ""; + dayText.setStyle("textAlign","center"); + dayText.minWidth = 50; + addChild(dayText); + + for(var i:int = 0; i < numBays+1 && i < decisions.length; i++) + { + var temp:OneDecision = (decisions.getItemAt(i) as OneDecision); + presentTotal += temp.lbsFished; + addChild(temp.redraw()); + } + + var totalObject:TotalDisplay = new TotalDisplay(); + totalObject.lbsFished = presentTotal; + totalObject.dollarPerLb = dollarPerLb; + totalObject.initialize(); + addChild(totalObject.redraw()); + } + + public function load(locationChosen:int):OneDay + { + if(decisions == null || decisions.length != 0) + { + decisions = new ArrayCollection(); + } + + if(locationChosen == 0) + { + var temp:OneDecision = new OneDecision(); + temp.lbsFished = 0; + temp.initialize(); + decisions.addItem(temp); + } + else + { + for(var i:int = 0; i < locationChosen && i < numBays; i++) + { + var tempInactive:OneDecision = new OneDecision(); + tempInactive.active = false; + tempInactive.initialize(); + decisions.addItem(tempInactive); + } + + var tempActive:OneDecision = new OneDecision(); + tempActive.lbsFished = Math.round(Math.random()*50)/10.0; + tempActive.initialize(); + decisions.addItem(tempActive); + } + + drawPartial(); + + return this; + } + + ]]> + </mx:Script> + +</mx:HBox> Added: mentalmodels/trunk/flex/src/custom/questions/dayByDayDecisions/OneDecision.mxml =================================================================== --- mentalmodels/trunk/flex/src/custom/questions/dayByDayDecisions/OneDecision.mxml (rev 0) +++ mentalmodels/trunk/flex/src/custom/questions/dayByDayDecisions/OneDecision.mxml 2009-07-05 23:58:17 UTC (rev 172) @@ -0,0 +1,63 @@ +<?xml version="1.0" encoding="utf-8"?> +<mx:Text xmlns:mx="http://www.adobe.com/2006/mxml" initialize="redraw()" textAlign="center" minWidth="125" minHeight="38"> + + <mx:Script> + <![CDATA[ + import mx.collections.ArrayCollection; + + [Bindable] public var active:Boolean = true; + [Bindable] public var lbsFished:Number = 0.0; + [Bindable] public var peopleFishing:ArrayCollection = null; + + public function getLbs():String + { + var zeroDec:String = ""; + if(lbsFished as int == lbsFished) + { + zeroDec = ".0"; + } + var lbString:String = String(lbsFished).substr(0,5) + zeroDec + " lbs"; + return lbString; + } + + public function findPeople():String + { + var listStr:String = ""; + + if(peopleFishing == null || peopleFishing.length == 0) + { + listStr = "-"; + } + else + { + for(var i:int=0; i<peopleFishing.length; i++) + { + if(listStr.length != 0) + { + listStr += ", "; + } + listStr += peopleFishing.getItemAt(i); + } + } + + return listStr; + } + + public function redraw():OneDecision + { + if(active) + { + htmlText = "Fished: "+getLbs()+"<br>People: "+findPeople(); + } + else + { + htmlText = "--"; + } + + return this; + } + + ]]> + </mx:Script> + +</mx:Text> \ No newline at end of file Added: mentalmodels/trunk/flex/src/custom/questions/dayByDayDecisions/TotalDisplay.mxml =================================================================== --- mentalmodels/trunk/flex/src/custom/questions/dayByDayDecisions/TotalDisplay.mxml (rev 0) +++ mentalmodels/trunk/flex/src/custom/questions/dayByDayDecisions/TotalDisplay.mxml 2009-07-05 23:58:17 UTC (rev 172) @@ -0,0 +1,46 @@ +<?xml version="1.0" encoding="utf-8"?> +<mx:Text xmlns:mx="http://www.adobe.com/2006/mxml" initialize="redraw()" textAlign="center" minWidth="60" minHeight="38"> + + <mx:Script> + <![CDATA[ + + [Bindable] public var lbsFished:Number = 0.0; + [Bindable] public var dollarPerLb:Number = 3.99; + + public function getLbs():String + { + lbsFished = Math.round(lbsFished * 10.0) / 10.0; + + var zeroDec:String = ""; + if(lbsFished as int == lbsFished) + { + zeroDec = ".0"; + } + var lbString:String = String(lbsFished).substr(0,5) + zeroDec + " lbs"; + return lbString; + } + + public function getMoney():String + { + var moneyMade:Number = lbsFished * dollarPerLb; + moneyMade = Math.floor(moneyMade * 100.0) / 100.0; + + var zeroDec:String = ""; + if(moneyMade as int == moneyMade) + { + zeroDec = ".00"; + } + var moneyString:String = "$" + moneyMade + zeroDec; + return moneyString; + } + + public function redraw():TotalDisplay + { + htmlText = getLbs()+"<br>"+getMoney(); + return this; + } + + ]]> + </mx:Script> + +</mx:Text> Added: mentalmodels/trunk/flex/src/custom/questions/forecasting/ForecastComponent.mxml =================================================================== --- mentalmodels/trunk/flex/src/custom/questions/forecasting/ForecastComponent.mxml (rev 0) +++ mentalmodels/trunk/flex/src/custom/questions/forecasting/ForecastComponent.mxml 2009-07-05 23:58:17 UTC (rev 172) @@ -0,0 +1,315 @@ +<?xml version="1.0" encoding="utf-8"?> +<mx:HBox xmlns:mx="http://www.adobe.com/2006/mxml" initialize="init()"> + + <mx:VBox id="labels" verticalGap="5" minWidth="{minimumWidth}" horizontalAlign="right"/> + + <mx:Script> + <![CDATA[ + import mx.controls.Alert; + import mx.events.FlexEvent; + import mx.controls.DataGrid; + import mx.collections.ArrayCollection; + import mx.controls.Label; + import mx.controls.dataGridClasses.DataGridColumn; + import mx.utils.StringUtil; + + // vital components + [Bindable] public var dataGrid:DataGrid; + [Bindable] public var dataProvider:ArrayCollection; + [Bindable] public var errorMessage:String = ""; + [Bindable] public var updaterObject:Object = null; + [Bindable] public var updater:Function = new Function(); + + [Bindable] public var currentColumn:int = 0; + + // Game Data + [Bindable] public var style:int = 0; // 0:People, 1:Fish, 2:Calculated + [Bindable] public var numBays:int = 3; + [Bindable] public var numColumns:int = -1; + [Bindable] public var numFields:int = 15; + [Bindable] public var minValue:int = 0; + [Bindable] public var maxValue:int = 5; + [Bindable] public var groupSize:int = 4; + [Bindable] public var finished:Boolean = false; + [Bindable] public var isEntry:Boolean = false; + + // for lining up grids + [Bindable] public var minimumWidth:int = 160; + + // + // public accessible functions + // + + public function init():void + { + labels.removeAllChildren(); + removeAllChildren(); + addChild(labels); + + createGrid(); + fillGridColumns(); + fillGridFields(); + setGridHeight(); + addChild(dataGrid); + } + + public function save():ArrayCollection + { + var saveArray:ArrayCollection = new ArrayCollection(); + for(var field:int = 0; field < dataProvider.length; field++) + { + saveArray.addItem(new ArrayCollection()); + for(var column:int = 0; column < dataGrid.columnCount; column++) + { + (saveArray.getItemAt(field) as ArrayCollection).addItem(getItem(field, column)); + } + } + return saveArray; + } + + public function load(loadArray:ArrayCollection):void + { + for(var field:int = 0; field < loadArray.length && field < dataProvider.length; field++) + { + var loadSubArray:ArrayCollection = loadArray.getItemAt(field) as ArrayCollection; + for(var column:int = 0; column < loadSubArray.length && column < dataGrid.columnCount; column++) + { + setItem(field, column, loadSubArray.getItemAt(column)); + } + } + redraw(); + } + + public function changed(event:Object=null):void + { + if(isEntry && style != 2) // NOT 2:Calculated + { + errorCheck(); + } + try{updater.call(updaterObject);} + catch(err:Error){/* Alert.show(err.message+"\n"+err.getStackTrace()); */} + redraw(); + } + + public function getItem(field:Number, col:Number):Object + { + return dataProvider.getItemAt(field)["day"+(col+1)]; + } + public function setItem(field:Number, col:Number, value:Object):void + { + dataProvider.getItemAt(field)["day"+(col+1)] = value; + } + + public function redraw():void + { + dataGrid.invalidateList(); + } + + // + // private Utility functions + // + + private function addLabel(text:String="", html:Boolean=false):void + { + var newLabel:Label = new Label(); + if(text != "" && !html) + { + newLabel.text = text; + } + else if(html) + { + newLabel.htmlText = text; + } + labels.addChild(newLabel); + } + + private function addField():void + { + dataProvider.addItem(new Object()); + } + + private function createGrid():void + { + dataGrid = new DataGrid(); + dataGrid.id = "dataGrid"; + dataGrid.editable = true; + dataGrid.enabled = true; + dataGrid.addEventListener("change", changed); + } + + private function fillGridColumns():void + { + var columnArray:Array = dataGrid.columns; + for(var columnNumber:int = 0; columnNumber < numColumns; columnNumber++) + { + var newDataGridColumn:DataGridColumn = new DataGridColumn("day"+(columnNumber+1)); + newDataGridColumn.headerText = ""+(columnNumber+1); // 1, 2, 3, ... + newDataGridColumn.dataField = "day"+(columnNumber+1); // day1, day2, day3, ... + + newDataGridColumn.draggable = false; + newDataGridColumn.sortable = false; + newDataGridColumn.resizable = false; + newDataGridColumn.width = 30; + + newDataGridColumn.editable = (isEntry + && ((style == 0) || (style == 1)) + && columnNumber == 0); // 0:People, 1:Fish + if(newDataGridColumn.editable) + { + newDataGridColumn.setStyle("backgroundColor", "#FFFF00"); + } + + columnArray[columnNumber] = newDataGridColumn; + } + dataGrid.columns = columnArray; + + dataGrid.editable = (isEntry && ((style == 0) || (style == 1))); // 0:People, 1:Fish + } + + private function fillGridFields():void + { + dataProvider = new ArrayCollection(); + + addLabel(" <b>Day</b>:",true); + + var bayNumber:int = 0; + if(style==0) // 0:People + { + addLabel("# People in Harbor:"); + addField(); + + for(bayNumber=0; bayNumber<numBays; bayNumber++) + { + addLabel("# People in Bay " + (bayNumber+1) + ":"); + addField(); + } + } + else if(style==1) + { + for(bayNumber=0; bayNumber<numBays; bayNumber++) + { + addLabel("# Fish in Bay " + (bayNumber+1) + "(AM):"); + addField(); + } + } + else if(style==2) + { + addLabel("You will be in location #:"); + addField(); + addLabel("You will get USD:"); + addField(); + addLabel("Others will get USD:"); + addField(); + for(bayNumber=0; bayNumber<numBays; bayNumber++) + { + addLabel("# Fish in Bay " + (bayNumber+1) + "(PM):"); + addField(); + } + } + dataGrid.dataProvider = dataProvider; + numFields = dataProvider.length; + } + + private function setGridHeight():void + { + switch(style) + { + case(0): // 0:People + dataGrid.height = (23)*(numBays+2)-1; + break; + case(1): // 2:Fish + dataGrid.height = (23)*(numBays+1); + break; + case(2): // 3:Calculated + dataGrid.height = (23)*(numBays+4)-3; + break; + } + } + + private function errorCheck():Boolean + { + if(currentColumn >= dataGrid.columnCount) + { + errorMessage = "Click 'Forward' to continue to the next page."; + return true; + } + markNoError(); + errorMessage = "Click 'Update' to continue."; + var error:Boolean = false; + + var colSum:Number = 0; + for(var field:Number=0; field < numFields && !error; field++) + { + var value:Object = getItem(field, currentColumn); + if(!validNum(value)) + { + errorMessage = "Enter a value between "+minValue+" and "+maxValue+"."; + error = true; + } + else if(!inBounds(value)) + { + errorMessage = "Value must be between "+minValue+" and "+maxValue+"."; + error = true; + } + else if(style == 0) // 0:People + { + colSum += Number(value); + } + } + + if(!error && style == 0 && colSum != groupSize-1) // 0:People + { + errorMessage = "Sum of all columns must be exactly "+(groupSize-1)+"."; + error = true; + } + + + finished = !error; + return finished; + } + + private function validNum(n:Object):Boolean + { + if(n == null) return false; + var pattern:RegExp = /^\d+$/; //the entire string must be consecutive digits + var s:String = StringUtil.trim(String(n)); + return (n is Number) || pattern.test(s); + } + private function inBounds(n:Object):Boolean + { + return Number(n) >= minValue && Number(n) <= maxValue; + } + private function markNoError():void + { +// for(var column:Number=0; column < numColumns; column++) +// { +// DataGridColumn(dataGrid.columns[column]).setStyle("backgroundColor", "#FFFFFF"); +// } + dataGrid.selectedIndex = -1; + } + + public function updateNextColumn():void + { + if(errorCheck()) + { + dataGrid.columns[currentColumn].setStyle("backgroundColor", "#FFFFFF"); + dataGrid.columns[currentColumn].editable = false; + currentColumn = fix(currentColumn+1,0,dataGrid.columnCount) as int; + if(currentColumn < dataGrid.columnCount) + { + dataGrid.columns[currentColumn].editable = true; + dataGrid.columns[currentColumn].setStyle("backgroundColor", "#FFFF00"); + } + } + } + private function fix(n:Number,min:Number,max:Number):Number + { + if(n < min) return min; + if(n > max) return max; + return n; + } + + ]]> + </mx:Script> + +</mx:HBox> Added: mentalmodels/trunk/flex/src/custom/questions/forecasting/ForecastingFishQuestionC.mxml =================================================================== --- mentalmodels/trunk/flex/src/custom/questions/forecasting/ForecastingFishQuestionC.mxml (rev 0) +++ mentalmodels/trunk/flex/src/custom/questions/forecasting/ForecastingFishQuestionC.mxml 2009-07-05 23:58:17 UTC (rev 172) @@ -0,0 +1,99 @@ +<?xml version="1.0" encoding="utf-8"?> +<mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:components="custom.questions.forecasting.*"> + + <mx:String id="description"></mx:String> + + <components:ForecastComponent id="fishEntry" style="1" isEntry="true" + numBays="{numBays}" numColumns="{numColumns}" initialize="false" + updaterObject="{this}" updater="{recalculate}"/> + <components:ForecastComponent id="peopleDisplay" style="0" isEntry="false" + numBays="{numBays}" numColumns="15" initialize="false"/> + <components:ForecastComponent id="calculated" style="2" isEntry="false" + numBays="{numBays}" numColumns="{numColumns}" initialize="false"/> + + <mx:HBox> + <mx:Spacer width="160"/> + <mx:VBox> + <mx:Button id="btnUpdate" label="Update" click="fishEntry.updateNextColumn()"/> + <mx:Label id="lblError" text="{fishEntry.errorMessage}"/> + </mx:VBox> + </mx:HBox> + + <mx:Script> + <![CDATA[ + import mx.controls.Alert; + import actionscript.questions.ForecastingFish; + import mx.collections.ArrayCollection; + import custom.questions.forecasting.ForecastComponent; + + public var loadFish:ArrayCollection = null; + public var loadPeople:ArrayCollection = null; + + [Bindable] public var numBays:int = 3; + [Bindable] public var numColumns:int = 6; + + public function init():void + { + fishEntry.initialize(); fishEntry.init(); + peopleDisplay.initialize(); peopleDisplay.init(); + calculated.initialize(); calculated.init(); + + if(loadFish != null) + { + fishEntry.load(loadFish); + } + if(loadPeople != null) + { + peopleDisplay.load(loadPeople); + } + } + + public function save():ArrayCollection + { + return fishEntry.save(); + } + public function load(newFishEntry:ArrayCollection,newPeopleDisplay:ArrayCollection):void + { + loadFish = newFishEntry; + loadPeople = newPeopleDisplay; + init(); + } + public function loadPeopleOnly(newPeopleDisplay:ArrayCollection):void + { + loadPeople = newPeopleDisplay; + peopleDisplay.load(loadPeople); + } + public function loadFromQuestion(question:ForecastingFish):void + { + description = question.question; + + initialize(); + init(); + } + + public function recalculate():void + { + var currLoc:int = 0; + + var fishCols:int = fishEntry.dataGrid.columns.length; + var pplCols:int = peopleDisplay.dataGrid.columns.length; + var calcCols:int = calculated.dataGrid.columns.length; + + for(var column:int = 0; column < fishCols && column < pplCols && column < calcCols; column++) + { + calculated.setItem(0,column,currLoc); + calculated.setItem(1,column,0); + calculated.setItem(2,column,0); + + for(var bay:int = 0; bay < numBays; bay++) + { + calculated.setItem(3+bay,column,Number(fishEntry.getItem(bay,column)) * 0.9); + } + } + calculated.redraw(); + } + + ]]> + </mx:Script> + +</mx:VBox> Added: mentalmodels/trunk/flex/src/custom/questions/forecasting/ForecastingPeopleQuestionC.mxml =================================================================== --- mentalmodels/trunk/flex/src/custom/questions/forecasting/ForecastingPeopleQuestionC.mxml (rev 0) +++ mentalmodels/trunk/flex/src/custom/questions/forecasting/ForecastingPeopleQuestionC.mxml 2009-07-05 23:58:17 UTC (rev 172) @@ -0,0 +1,58 @@ +<?xml version="1.0" encoding="utf-8"?> +<mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:components="custom.questions.forecasting.*"> + + <mx:String id="description"></mx:String> + + <components:ForecastComponent id="peopleEntry" style="0" isEntry="true" + numBays="{numBays}" numColumns="{numColumns}" initialize="false"/> + + <mx:HBox> + <mx:Spacer width="160"/> + <mx:VBox> + <mx:Button id="btnUpdate" label="Update" click="peopleEntry.updateNextColumn()"/> + <mx:Label id="lblError" text="{peopleEntry.errorMessage}"/> + </mx:VBox> + </mx:HBox> + + <mx:Script> + <![CDATA[ + import actionscript.questions.ForecastingPeople; + import mx.collections.ArrayCollection; + import custom.questions.forecasting.ForecastComponent; + + public var loadPeople:ArrayCollection = null; + + [Bindable] public var numBays:int = 3; + [Bindable] public var numColumns:int = 15; + + public function init():void + { + peopleEntry.initialize(); peopleEntry.init(); + + if(loadPeople != null) + { + peopleEntry.load(loadPeople); + } + } + + public function save():ArrayCollection + { + return peopleEntry.save(); + } + public function load(newPeopleDisplay:ArrayCollection):void + { + loadPeople = newPeopleDisplay; + init(); + } + public function loadFromQuestion(question:ForecastingPeople):void + { + description = question.question; + + initialize(); + init(); + } + + ]]> + </mx:Script> + +</mx:VBox> Added: mentalmodels/trunk/flex/src/custom/questions/psychometric/PsychometricQuestionC.mxml =================================================================== --- mentalmodels/trunk/flex/src/custom/questions/psychometric/PsychometricQuestionC.mxml (rev 0) +++ mentalmodels/trunk/flex/src/custom/questions/psychometric/PsychometricQuestionC.mxml 2009-07-05 23:58:17 UTC (rev 172) @@ -0,0 +1,118 @@ +<?xml version="1.0" encoding="utf-8"?> +<mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:qComp="custom.questions.psychometric.*" initialize="false"> + + <mx:String id="description"></mx:String> + + <mx:Canvas id="content" minHeight="30" maxHeight="90"> + <!-- Used for bipolar psychometric scales --> + <mx:Label id="topleft" text="topleft" x="0" y="0" width="100" textAlign="left" visible="false"/> + <mx:Label id="topmid" text="topmid" x="150" y="0" width="100" textAlign="center" visible="false"/> + <mx:Label id="topright" text="topright" x="300" y="0" width="100" textAlign="right" visible="false"/> + + <!-- Used for unipolar psychometric scales --> + <mx:Label id="farleft" text="farleft" x="0" y="0" width="100" textAlign="center" visible="false"/> + <mx:Label id="farright" text="farright" x="300" y="0" width="100" textAlign="center" visible="false"/> + </mx:Canvas> + + <mx:Script> + <![CDATA[ + import actionscript.questions.PsychometricQuestion; + import mx.collections.ArrayCollection; + import custom.questions.psychometric.Slider; + + public var labels:ArrayCollection = new ArrayCollection(); + [Bindable] public var maxValue:Number; + [Bindable] public var slider1:Slider; + + public function init():void + { + if(labels != null) + { + slider1 = new Slider(); + + if(labels.length == 2) + { + farleft.text = (String)(labels.getItemAt(0)); + farright.text = (String)(labels.getItemAt(1)); + farleft.visible = true; + farright.visible = true; + content.removeChild(topleft); + content.removeChild(topmid); + content.removeChild(topright); + slider1.isBipolar = false; + slider1.x = 100; + slider1.y = 0; + } + else if(labels.length == 3) + { + topleft.text = (String)(labels.getItemAt(0)); + topmid.text = (String)(labels.getItemAt(1)); + topright.text = (String)(labels.getItemAt(2)); + topleft.visible = true; + topmid.visible = true; + topright.visible = true; + content.removeChild(farleft); + content.removeChild(farright); + slider1.isBipolar = true; + slider1.x = 0; + slider1.y = 36; + } + + initializeSlider(); + } + } + + public function initializeSlider():void + { + slider1.maxValue = maxValue; + slider1.initialize(); + slider1.init(); + if(!(content.contains(slider1))) + { + content.addChild(slider1); + } + } + + public function save():ArrayCollection + { + var saveArray:ArrayCollection = new ArrayCollection(); + saveArray.addItem(slider1.sliderButton.visible); + saveArray.addItem(slider1.sliderButton.x); + return saveArray; + } + + public function load(loadArray:ArrayCollection):void + { + slider1.sliderButton.visible = loadArray.getItemAt(0) as Boolean; + slider1.sliderButton.move(loadArray.getItemAt(1) as Number, 0); + } + + public function loadFromQuestion(question:PsychometricQuestion):void + { + description = question.question; + + maxValue = question.numberOfIntervals; + labels = loadChoices(question); + + initialize(); + init(); + } + private function loadChoices(question:PsychometricQuestion):ArrayCollection + { + var choices:ArrayCollection = new ArrayCollection(); + + if(question.choices != null && question.choices.length >= 2) + { + for(var i:int = 0; i < question.choices.length; i++) + { + choices.addItem(question.choices.getItemAt(i)); + } + } + + return choices; + } + + ]]> + </mx:Script> + +</mx:VBox> Added: mentalmodels/trunk/flex/src/custom/questions/psychometric/Slider.mxml =================================================================== --- mentalmodels/trunk/flex/src/custom/questions/psychometric/Slider.mxml (rev 0) +++ mentalmodels/trunk/flex/src/custom/questions/psychometric/Slider.mxml 2009-07-05 23:58:17 UTC (rev 172) @@ -0,0 +1,117 @@ +<?xml version="1.0" encoding="utf-8"?> +<mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml"> + + <mx:Script> + <![CDATA[ + import mx.controls.Label; + import mx.controls.Text; + + [Bindable] + [Embed(source="SliderImage.png")] + private var sliderImage:Class; + + // Psychometric Variables - (Left = Positive, Right = Negative) + public var maxValue:Number = 10; // Leftmost value + public static var abstainValue:Number = -999; // Refusal to answer + private static var unipolarWidth:Number = 200; + private static var bipolarWidth:Number = 400; + private static var imageWidth:Number = 4; + + private var minValue:Number; // Rightmost value + private var value:Number; // value selected + + [Bindable] public var getVal:Number; // (for binding: same value as last getValue() method call) + public var isBipolar:Boolean; // double slider = true, single slider = false + + // prepare Slider in default (abstain) position + public function init():void + { + addEventListener(MouseEvent.MOUSE_DOWN, mouseMove); + addEventListener(MouseEvent.MOUSE_UP, mouseMove); + + if(isBipolar) + { + sliderBar.width = bipolarWidth + imageWidth; + minValue = -maxValue; + } + else + { + sliderBar.width = unipolarWidth + imageWidth; + minValue = 0; + } + + addTicks(); + reset(); + } + + private function addTicks():void + { + var numTicks:Number = maxValue - minValue + 1; + var separation:Number = (sliderBar.width - imageWidth) / (numTicks-1) + + var ticks:Array = new Array(numTicks); + + for(var i:Number = 0; i < numTicks; i++) + { + var tick:Label = new Label(); + tick.htmlText = "<b>.</b>"; + tick.x = i*separation - imageWidth/2; + tick.y = -10; + addChild(tick); + } + } + + private function mouseMove(event:MouseEvent):void + { + sliderButton.visible = true; + updateValue(); + } + + public function getValue():Number + { + if(sliderButton.visible) + { + getVal = value; + } + else + { + getVal = abstainValue; + } + return getVal; + } + + private function updateValue():void + { + var separation:Number = (sliderBar.width - imageWidth) / (maxValue - minValue) + var index:Number = Math.round((mouseX-imageWidth/2) / separation); // snap to nearest valid position + + value = maxValue - index; // flips scale so positive numbers on left + if(value > maxValue) value = maxValue; + if(value < minValue) value = minValue; + index = maxValue - value; + + getValue(); // updates the bindable "getVal" variable + + var xPos:Number = index * separation; + sliderButton.move(xPos, 0); + } + + public function reset():void + { + sliderButton.visible = false; + updateValue(); + sliderButton.move(0,0); + } + + ]]> + </mx:Script> + + <!-- change X value to 1/2 the width of the sliderButton image --> + <mx:HBox id="sliderBar" + height="3" x="0" y="15" + borderStyle="solid" borderColor="#000000" borderThickness="1" + /> + + <mx:Image id="sliderButton" x="0" y="0" source="{sliderImage}"/> + +</mx:Canvas> Added: mentalmodels/trunk/flex/src/custom/questions/psychometric/SliderImage.png =================================================================== (Binary files differ) Property changes on: mentalmodels/trunk/flex/src/custom/questions/psychometric/SliderImage.png ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: mentalmodels/trunk/flex/src/custom/questions/strategyDesign/Planner.mxml =================================================================== --- mentalmodels/trunk/flex/src/custom/questions/strategyDesign/Planner.mxml (rev 0) +++ mentalmodels/trunk/flex/src/custom/questions/strategyDesign/Planner.mxml 2009-07-05 23:58:17 UTC (rev 172) @@ -0,0 +1,116 @@ +<?xml version="1.0" encoding="utf-8"?> +<mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:comp="custom.*" initialize="init()" + width="350" height="200" + borderStyle="solid" verticalScrollPolicy="off" horizontalScrollPolicy="off"> + + <mx:Script> + <![CDATA[ + import mx.collections.ArrayCollection; + import mx.controls.Label; + + public var valueRequired:Boolean = false; + + private function init():void + { + if(valueRequired) + { + addRow(); + } + } + + public function childRemoved():void + { + numbers.removeChildAt(numbers.numChildren-1); + } + + public function addRow():PlannerRow + { + var newRow:PlannerRow = new PlannerRow(); + newRow.valueRequired = this.valueRequired; + var newNumber:Label = new Label(); + newNumber.text = "" + (numbers.numChildren+1); + newNumber.height = 22; + + grid.addChildAt(newRow, grid.numChildren); + numbers.addChild(newNumber); + + return newRow; + } + + public function getPlannerRow(index:Number):PlannerRow + { + if(index < grid.numChildren && index >= 0) + { + return (PlannerRow)(grid.getChildAt(index)); + } + return null; + } + public function getPlannerList(index:Number):ArrayCollection + { + var row:PlannerRow = getPlannerRow(index); + if(row == null) + { + return null; + } + var list:ArrayCollection = new ArrayCollection([row.getLocation(), row.getDays(), row.getThreshold()]); + return list; + } + public function setPlannerList(index:Number, newValues:ArrayCollection):void + { + var row:PlannerRow = getPlannerRow(index); + if(row == null) + { + row = addRow(); + } + row.setLocation(newValues.getItemAt(0) as String); + row.setDays(newValues.getItemAt(1) as Number); + row.setThreshold(newValues.getItemAt(2) as Number); + } + + public function save():ArrayCollection + { + var saveArray:ArrayCollection = new ArrayCollection(); + + for(var index:Number = 0; index < grid.numChildren; index++) + { + saveArray.addItem(getPlannerList(index)); + } + + return saveArray; + } + + public function load(loadArray:ArrayCollection):void + { + grid.removeAllChildren(); + numbers.removeAllChildren(); + for(var index:Number = 0; index < loadArray.length; index++) + { + setPlannerList(index, loadArray.getItemAt(index) as ArrayCollection); + } + } + + ]]> + </mx:Script> + + <mx:HBox id="newButtonBox"> + <mx:Label text="" width="12"/> + <mx:Button id="newButton" label="New" click="addRow()" width="60"/> + <!--<mx:Label text="-" width="80" textAlign="center"/> + <mx:Label text="-" width="50" textAlign="center"/> + <mx:Label text="-" width="80" textAlign="center"/>--> + </mx:HBox> + + <mx:HBox id="headerBox"> + <mx:Label text="#" fontWeight="bold" paddingBottom="-3" width="12"/> + <mx:Label text="Remove" fontWeight="bold" paddingBottom="-3" width="60" textAlign="center"/> + <mx:Label text="Location" fontWeight="bold" paddingBottom="-3" width="80" textAlign="center"/> + <mx:Label text="Days" fontWeight="bold" paddingBottom="-3" width="50" textAlign="center"/> + <mx:Label text="Threshold" fontWeight="bold" paddingBottom="-3" width="80" textAlign="center"/> + </mx:HBox> + + <mx:HBox horizontalScrollPolicy="off" height="147" width="100%"> + <mx:VBox id="numbers" width="12"/> + <mx:VBox id="grid" childRemove="childRemoved()"/> + </mx:HBox> + +</mx:VBox> Added: mentalmodels/trunk/flex/src/custom/questions/strategyDesign/PlannerRow.mxml =================================================================== --- mentalmodels/trunk/flex/src/custom/questions/strategyDesign/PlannerRow.mxml (rev 0) +++ mentalmodels/trunk/flex/src/custom/questions/strategyDesign/PlannerRow.mxml 2009-07-05 23:58:17 UTC (rev 172) @@ -0,0 +1,77 @@ +<?xml version="1.0" encoding="utf-8"?> +<mx:HBox xmlns:mx="http://www.adobe.com/2006/mxml"> + + <mx:Script> + <![CDATA[ + + public var valueRequired:Boolean = false; + + public function deleteMe():void + { + if(!valueRequired || parent.numChildren > 1) + { + parent.removeChild(this); + } + } + + public function changedLocation():void + { + threshold.visible = (location.selectedIndex != 0); + threshold.enabled = threshold.visible; + } + + public function getLocation():String + { + if(location.selectedIndex == 0) + { + return "Harbor"; + } + return "Bay " + location.selectedIndex; + } + public function setLocation(newValue:String):void + { + if(newValue == "Harbor") location.selectedIndex = 0; + if(newValue == "Bay 1") location.selectedIndex = 1; + if(newValue == "Bay 2") location.selectedIndex = 2; + if(newValue == "Bay 3") location.selectedIndex = 3; + changedLocation(); + } + public function getDays():Number + { + return days.value; + } + public function setDays(newValue:Number):void + { + days.value = newValue; + } + public function getThreshold():Number + { + if(location.selectedIndex == 0) + { + return -1; + } + return threshold.value; + } + public function setThreshold(newValue:Number):void + { + if(newValue == -1) return; + threshold.value = newValue; + } + + ]]> + </mx:Script> + + <mx:ArrayCollection id="locs"> + <mx:Object label="Harbor" data="Harbor"/> + <mx:Object label="Bay 1" data="Bay 1"/> + <mx:Object label="Bay 2" data="Bay 2"/> + <mx:Object label="Bay 3" data="Bay 3"/> + </mx:ArrayCollection> + + + <mx:Button id="deleteRow" label="Del" click="deleteMe()" width="60"/> + <mx:ComboBox id="location" dataProvider="{locs}" change="changedLocation()" width="80"/> + <mx:NumericStepper id="days" value="1" minimum="1" maximum="30" stepSize="1" width="50"/> + <mx:NumericStepper id="threshold" value="0.5" stepSize="0.1" minimum="0" maximum="100" enabled="false" visible="false" width="80"/> + +</mx:HBox> Added: mentalmodels/trunk/flex/src/custom/questions/strategyDesign/StrategyDesignQuestionC.mxml =================================================================== --- mentalmodels/trunk/flex/src/custom/questions/strategyDesign/StrategyDesignQuestionC.mxml (rev 0) +++ mentalmodels/trunk/flex/src/custom/questions/strategyDesign/StrategyDesignQuestionC.mxml 2009-07-05 23:58:17 UTC (rev 172) @@ -0,0 +1,75 @@ +<?xml version="1.0" encoding="utf-8"?> +<mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:qComp="custom.questions.strategyDesign.*"> + + <mx:String id="description"></mx:String> + + <mx:HBox> + <mx:VBox> + <mx:Label text="Not Repeated decisions (start-up)" fontSize="18"/> + <qComp:Planner id="notRepeated"/> + </mx:VBox> + <mx:VBox> + <mx:Label text="Repeated decisions (after start-up)" fontSize="18"/> + <qComp:Planner id="repeated" valueRequired="true"/> + </mx:VBox> + </mx:HBox> + + <mx:HBox> + <mx:Label text="Suspend repetition:" fontWeight="bold" width="130"/> + <mx:Label text="If during one repetition"/> + <mx:NumericStepper id="suspendWeight" value="5" minimum="0.1" maximum="100" stepSize="0.1" height="20" width="50"/> + <mx:Label text="lbs could not be fished,"/> + </mx:HBox> + <mx:HBox> + <mx:Label width="113"/> + <mx:Label text="then stay in the harbor for"/> + <mx:NumericStepper id="suspendDays" value="1" minimum="0" maximum="30" stepSize="1" height="20" width="50"/> + <mx:Label text="days before starting the next repetition."/> + </mx:HBox> + + <mx:Script> + <![CDATA[ + import actionscript.questions.Question; + import mx.collections.ArrayCollection; + + public function getNotRepeated():ArrayCollection + { return notRepeated.save(); } + + public function getRepeated():ArrayCollection + { return repeated.save(); } + + public function accept():Boolean + { + return true; + } + + public function save():ArrayCollection + { + var saveArray:ArrayCollection = new ArrayCollection(); + saveArray.addItem(notRepeated.save()); + saveArray.addItem(repeated.save()); + saveArray.addItem(suspendWeight.value); + saveArray.addItem(suspendDays.value); + return saveArray; + } + + public function load(loadArray:ArrayCollection):void + { + notRepeated.load(loadArray.getItemAt(0) as ArrayCollection); + repeated.load(loadArray.getItemAt(1) as ArrayCollection); + suspendWeight.value = loadArray.getItemAt(2) as Number; + suspendDays.value = loadArray.getItemAt(3) as Number; + } + + public function loadFromQuestion(question:Question):void + { + description = question.question; + + initialize(); +// init(); + } + + ]]> + </mx:Script> + +</mx:VBox> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <kj...@us...> - 2009-07-05 23:47:59
|
Revision: 171 http://virtualcommons.svn.sourceforge.net/virtualcommons/?rev=171&view=rev Author: kjonas Date: 2009-07-05 23:47:57 +0000 (Sun, 05 Jul 2009) Log Message: ----------- trying to re-commit restructured folders, new features with FisheryExperimentShell.mxml (InformationWindowPopup.mxml, etc) Modified Paths: -------------- mentalmodels/trunk/flex/src/_InstructionsTest.mxml Added Paths: ----------- mentalmodels/trunk/flex/src/FisheryExperimentShell.mxml mentalmodels/trunk/flex/src/custom/ mentalmodels/trunk/flex/src/custom/FisheryExperimentKalin.mxml mentalmodels/trunk/flex/src/custom/InformationWindowPopup.mxml mentalmodels/trunk/flex/src/custom/InstructionPage.mxml mentalmodels/trunk/flex/src/custom/SocioDemographicPage.mxml mentalmodels/trunk/flex/src/custom/TimeLabel.mxml mentalmodels/trunk/flex/src/custom/db/ 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/ mentalmodels/trunk/flex/src/custom/db/questions/Categorical.mxml mentalmodels/trunk/flex/src/custom/db/questions/CategoricalQuestion.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/flex/src/custom/questions/ mentalmodels/trunk/flex/src/custom/questions/CategoricalQuestionC.mxml mentalmodels/trunk/flex/src/custom/questions/TextQuestionC.mxml Removed Paths: ------------- mentalmodels/trunk/flex/src/FisheryExperimentKalin.mxml Deleted: mentalmodels/trunk/flex/src/FisheryExperimentKalin.mxml =================================================================== --- mentalmodels/trunk/flex/src/FisheryExperimentKalin.mxml 2009-07-05 19:50:39 UTC (rev 170) +++ mentalmodels/trunk/flex/src/FisheryExperimentKalin.mxml 2009-07-05 23:47:57 UTC (rev 171) @@ -1,308 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:net="flash.net.*" xmlns:comp="custom.*" - backgroundGradientAlphas="[1.0, 1.0]" backgroundGradientColors="[#FFFFFF, #B0B0FF]" - width="100%" height="100%" clipContent="false" layout="absolute" - currentState="socioDemographic" initialize="init()"> - - <mx:states> - <mx:State name="socioDemographic"> - <mx:AddChild relativeTo="{content}"> - <comp:SocioDemographicPage id="socioDemographic" - x="{(content.width-socioDemographic.width)/2}" - y="{(content.height-socioDemographic.height)/2}"/> - </mx:AddChild> - <mx:SetProperty target="{content}" name="x"/> - <mx:SetStyle target="{content}" name="horizontalCenter" value="0"/> - </mx:State> - - <mx:State name="instructions"> - <mx:AddChild relativeTo="{content}"> - <!--<comp:InstructionPage id="instructions" initialize="instructions.init(makeBlock())"/>--> - <comp:InstructionPage id="instructions" initialize="instructions.initModule(currModule)"/> - </mx:AddChild> - </mx:State> - - <mx:State name="wait"> - <mx:AddChild relativeTo="{content}"> - <mx:Label id="lblWaiting" text="Waiting for next Module from server..." fontSize="16"/> - </mx:AddChild> - </mx:State> - - <mx:State name="none"> - <mx:AddChild relativeTo="{content}"> - <mx:Label id="end" text="Thank you for playing!" fontSize="30"/> - </mx:AddChild> - </mx:State> - </mx:states> - - - - <!-- <mx:Canvas id="content" x="5" y="5" width="750" height="470"/> --> - <mx:Canvas id="content" x="0" y="0" width="100%" height="100%"/> - <mx:Canvas id="expiredContent" x="-1" y="-1" width="1" height="1" visible="false"/> - - <mx:Button id="btnBack" label="« Back" click="back()" left="8" bottom="8" enabled="false"/> - <mx:Button id="btnAccept" label="Accept" click="accept()" left="{(width-btnAccept.width)/2}" bottom="10"/> - <mx:Button id="btnForward" label="Forward »" click="forward()" right="8" bottom="8" enabled="false"/> - - <mx:RemoteObject id="ss" destination="studentService" fault="faultHandler(event)" result="resultHandler(event)"/> - <mx:Producer id="producer" destination="DataPush" acknowledge="ack(event)"/> - <mx:Consumer id="consumer" destination="DataPush" message="messageHandler(event.message)" /> - <mx:Script> - <![CDATA[ - import actionscript.*; - import actionscript.questions.*; - import custom.*; - import mx.controls.Label; - import mx.controls.Alert; - import mx.collections.ArrayCollection; - import flash.sampler.getInvocationCount; - import mx.rpc.events.ResultEvent; - import mx.rpc.events.FaultEvent; - import mx.messaging.messages.IMessage; - import mx.messaging.events.MessageAckEvent; - import mx.messaging.events.MessageFaultEvent; - import mx.messaging.FlexClient; - import mx.messaging.messages.AsyncMessage; - - - // - // Important Variables - // - public var currModule:Module = null; - - private var shared:SharedObject; - private var flushMessage:String; - [Bindable] - public var Id : uint; - - [Bindable] - public var randomNumbers:String; - private function ack(event:MessageAckEvent):void - { - //chart.setVisible(true); - randomNumbers = event.message.body as String; - //Alert.show("in ack method" + randomNumbers); - } - private function resultHandler(event:ResultEvent):void - { - Id = event.result as uint; - -// Alert.show("Student id is " + Id ); - consumer.disconnect(); - } - - private function faultHandler(event:FaultEvent):void - { -// Alert.show("event fault is " + event.fault.faultDetail); - } - - private function handleFault(event:MessageFaultEvent):void - { -// Alert.show("Message event fault is " + event.faultString); - } - - - private function messageHandler(message:IMessage):void - { - randomNumbers = message.body as String; -// Alert.show( ""+randomNumbers); - } - - public function init():void - { - - } - - private function getModule():Module - { - // server request here - - currModule = null; - return currModule; // set to null for now (clear old) - } - - public function back():Boolean - { - if(content.numChildren == 0) - { return false; } - var obj:DisplayObject = content.getChildAt(0); - - if(obj is InstructionPage) - { - try - { - return (InstructionPage)(obj).back(); - } - catch(err:Error){} - } - return false; - } - - public function forward():Boolean - { - if(content.numChildren == 0) - { return false; } - var obj:DisplayObject = content.getChildAt(0); - - if(obj is InstructionPage) - { - try - { - return (InstructionPage)(obj).forward(); - } - catch(err:Error){} - } - return false; - } - - public function accept():Boolean - { - if(content.numChildren == 0) - { return false; } - - var obj:DisplayObject = content.getChildAt(0); - var returnValue:Boolean = false; - - if(obj is SocioDemographicPage) - { - var Id:uint = 0; - if( (SocioDemographicPage)(obj).accept() ) - { - obj.visible = false; - expiredContent.addChild(obj); - - // - // TEMPORARY CODE - // comments indicate changes to be made for legitimate server communication - // - currModule = new Module(); //delete - currModule.blocks = new ArrayCollection(); //delete - currModule.blocks.addItem(makeBlock()); //delete - currModule.blocks.addItem(makeBlock()); //delete - currentState = "instructions"; //change to state "wait", which will call getModule() - // - // END TEMPORARY CODE - // - - - var info:SocioDemographicPage = SocioDemographicPage(obj); - /* Alert.show(info.getGender()); - Alert.show(info.getMajor()); - Alert.show(info.getSemester()); - Alert.show(info.getYear());*/ - Id=ss.createStudent(info.getYear(), info.getSemester(), info.getGender(),info.getMajor()); -// Alert.show("Before invoking createstudent()"); - - btnBack.enabled = true; - btnForward.enabled = true; - - returnValue = true; - } - } - if(obj is InstructionPage) - { - try - { - if( (InstructionPage)(obj).accept() ) - { - obj.visible = false; - expiredContent.addChild(obj); - currentState = "wait"; - //consumer.subscribe(); - returnValue = true; - } - } - catch(err:Error){} - } - - btnBack.enabled = btnForward.enabled = currentState == "instructions"; - - return returnValue; - } - - public function makeBlock():Block - { - var block1:Block = new Block(); - try{ - var questionGroups1:ArrayCollection = new ArrayCollection(); - var qg0:QuestionGroup = new QuestionGroup(); - var qg1:QuestionGroup = new QuestionGroup(); - var qg2:QuestionGroup = new QuestionGroup(); - var qg3:QuestionGroup = new QuestionGroup(); - var qg4:QuestionGroup = new QuestionGroup(); - var qg5:QuestionGroup = new QuestionGroup(); - var qg6:QuestionGroup = new QuestionGroup(); - qg0.questions = new ArrayCollection(); - qg1.questions = new ArrayCollection(); - qg2.questions = new ArrayCollection(); - qg3.questions = new ArrayCollection(); - qg4.questions = new ArrayCollection(); - qg5.questions = new ArrayCollection(); - qg6.questions = new ArrayCollection(); - block1.questionGroups = new ArrayCollection(); - - // create questions - var ddq1:Question = new Question(); - ddq1.question = "dayByDayDecisionsQuestion"; - ddq1.type = "dayByDayDecisions"; - - var cat1:Categorical = new Categorical(); - cat1.question = "categoricalQuestion"; - cat1.type = "categorical"; - cat1.topics = new ArrayCollection(); - cat1.specifics = new ArrayCollection(); - - var for1:ForecastingPeople = new ForecastingPeople(); - var for2:ForecastingFish = new ForecastingFish(); - - var psy1:PsychometricQuestion = new PsychometricQuestion(); - psy1.question = "psychometricQuestion"; - psy1.type = "psychometric"; - psy1.numberOfIntervals = 10; - psy1.choices = new ArrayCollection(); - psy1.choices.addItem("Highly Agree"); - psy1.choices.addItem("Highly Neutral"); - psy1.choices.addItem("Highly Disagree"); - - var str1:Question = new Question(); - str1.question = "strategyDesignQuestion"; - str1.type = "strategyDesign"; - - var txt1:Question = new Question(); - txt1.question = "textQuestion"; - txt1.type = "text"; - - // insert questions into groups - qg0.questions.addItem(ddq1); - qg1.questions.addItem(cat1); - qg2.questions.addItem(for1); - qg3.questions.addItem(for2); - qg4.questions.addItem(psy1); - qg5.questions.addItem(str1); - qg6.questions.addItem(txt1); - - qg1.description = "testDesc"; - qg1.header = "testHead"; - - block1.questionGroups.addItem(qg0); - block1.questionGroups.addItem(qg1); - block1.questionGroups.addItem(qg2); - block1.questionGroups.addItem(qg3); - block1.questionGroups.addItem(qg4); - block1.questionGroups.addItem(qg5); - block1.questionGroups.addItem(qg6); - - - }catch(errObject:Error){ - Alert.show("block creation failure\n" + - errObject.message + "\n" + errObject.getStackTrace()); - } - return block1; - } - - ]]> - </mx:Script> - -</mx:Application> - Added: mentalmodels/trunk/flex/src/FisheryExperimentShell.mxml =================================================================== --- mentalmodels/trunk/flex/src/FisheryExperimentShell.mxml (rev 0) +++ mentalmodels/trunk/flex/src/FisheryExperimentShell.mxml 2009-07-05 23:47:57 UTC (rev 171) @@ -0,0 +1,106 @@ +<?xml version="1.0" encoding="utf-8"?> +<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" + backgroundGradientAlphas="[1.0, 1.0]" backgroundGradientColors="[#FFFFFF, #B0B0FF]" + layout="horizontal" + width="100%" height="100%" xmlns:custom="custom.*"> + + <mx:VBox id="vbxInfo"> + <mx:TitleWindow id="InformationWindowA" width="300" height="200" title="Information Window A" + clipContent="true" horizontalScrollPolicy="on" verticalScrollPolicy="on"> + <mx:Label text="InfoA"/> + </mx:TitleWindow> + <mx:HBox id="hbxPickerA"> + <mx:ComboBox id="cbxPickerA"/> + <mx:Button id="btnPickerA" label="Pop Up" click="popupInformationWindow(1)"/> + </mx:HBox> + + <mx:TitleWindow id="InformationWindowB" width="300" height="200" title="Information Window B" + clipContent="true" horizontalScrollPolicy="on" verticalScrollPolicy="on"> + <mx:Label text="InfoB"/> + </mx:TitleWindow> + <mx:HBox id="hbxPickerB"> + <mx:ComboBox id="cbxPickerB"/> + <mx:Button id="btnPickerB" label="{btnPickerA.label}" click="popupInformationWindow(2)"/> + </mx:HBox> + <mx:Button id="btnResetPopups" label="Reset Popups" click="closedFunction()"/> + </mx:VBox> + + <mx:VBox id="vbxContent" horizontalAlign="center" verticalAlign="middle" + width="{this.width - 400}" + height="{this.height - 80}"> + <custom:FisheryExperimentKalin id="fisheryContent"/> + </mx:VBox> + + <mx:Script> + <![CDATA[ + import mx.skins.halo.TitleBackground; + import custom.InformationWindowPopup; + import mx.managers.PopUpManager; + + public var popupA:InformationWindowPopup = null; + public var popupB:InformationWindowPopup = null; + + public function popupInformationWindow(source:int):void + { + var popupNew:InformationWindowPopup = PopUpManager.createPopUp(this, InformationWindowPopup, false) as InformationWindowPopup; + popupNew.closedFunction = closedFunction; + popupNew.horizontalScrollPolicy = "on"; + popupNew.verticalScrollPolicy = "on"; + + var old:TitleWindow = null; + + if(source == 1) + { + old = InformationWindowA; + popupA = popupNew; + btnPickerA.enabled = cbxPickerA.enabled = false; + } + else if(source == 2) + { + old = InformationWindowB; + popupB = popupNew; + btnPickerB.enabled = cbxPickerB.enabled = false; + } + else + { + return; + } + + while(old != null && old.numChildren > 0) + { + popupNew.addChild(old.removeChildAt(0)) + } + + PopUpManager.centerPopUp(popupNew); + } + + public function closedFunction():void + { + if(popupA != null) + { + while(popupA.numChildren > 0) + { + InformationWindowA.addChild(popupA.removeChildAt(0)) + } + PopUpManager.removePopUp(popupA); + popupA = null; + } + + if(popupB != null) + { + while(popupB.numChildren > 0) + { + InformationWindowB.addChild(popupB.removeChildAt(0)) + } + PopUpManager.removePopUp(popupB); + popupB = null; + } + + btnPickerA.enabled = btnPickerB.enabled = true; + cbxPickerA.enabled = cbxPickerB.enabled = true; + } + + ]]> + </mx:Script> + +</mx:Application> Modified: mentalmodels/trunk/flex/src/_InstructionsTest.mxml =================================================================== --- mentalmodels/trunk/flex/src/_InstructionsTest.mxml 2009-07-05 19:50:39 UTC (rev 170) +++ mentalmodels/trunk/flex/src/_InstructionsTest.mxml 2009-07-05 23:47:57 UTC (rev 171) @@ -1,10 +1,48 @@ <?xml version="1.0" encoding="utf-8"?> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:comp="custom.*" xmlns:as="actionscript.*" - layout="vertical" - backgroundGradientColors="[#FFFFFF, #B0B0FF]"> - + layout="horizontal" + backgroundGradientColors="[#FFFFFF, #B0B0FF]"> + + <mx:VBox id="vbxInfo"> + <mx:TitleWindow id="InformationWindowA" width="300" height="200" title="Information Window A"/> + <mx:HBox id="hbxPickerA"> + <mx:ComboBox id="cbxPickerA"/> + <mx:Button id="btnPickerA" click="popupInformationWindow(1)"/> + </mx:HBox> + + <mx:TitleWindow id="InformationWindowB" width="300" height="200" title="Information Window B"/> + <mx:HBox id="hbxPickerB"> + <mx:ComboBox id="cbxPickerB"/> + <mx:Button id="btnPickerB" click="popupInformationWindow(2)"/> + </mx:HBox> + </mx:VBox> + <mx:Script> <![CDATA[ + import custom.InformationWindowPopup; + import mx.managers.PopUpManager; + + public function popupInformationWindow(source:int):void + { +// Alert.cancelLabel = "Close"; +// var flags:uint = Alert.NONMODAL | Alert.CANCEL; +// var alert:Alert = Alert.show("::","Information Window",flags,null,null,null,Alert.CANCEL) + + var win:InformationWindowPopup = PopUpManager.createPopUp(this, InformationWindowPopup, false) as InformationWindowPopup; + PopUpManager.centerPopUp(win); + win.closedFunction = closedFunction; + } + + public function closedFunction():void + { + btnPickerA.label += "."; + } + + ]]> + </mx:Script> + + <mx:Script> + <![CDATA[ import custom.questions.CategoricalQuestionC; import actionscript.* import actionscript.questions.*; @@ -86,13 +124,15 @@ ]]> </mx:Script> - <mx:HBox> - <mx:Button id="back" click="iPage.back()" label="back"/> - <mx:Button id="forward" click="iPage.forward()" label="forward"/> - </mx:HBox> + <mx:VBox id="vbxContent" minWidth="700" horizontalAlign="center"> + <mx:HBox> + <mx:Button id="back" click="iPage.back()" label="back"/> + <mx:Button id="forward" click="iPage.forward()" label="forward"/> + </mx:HBox> + + <mx:Text id="debug" text=""/> + + <comp:InstructionPage id="iPage" preinitialize="fillBlock()" initialize="iPage.init(block1)"/> + </mx:VBox> - <mx:Text id="debug" text=""/> - - <comp:InstructionPage id="iPage" preinitialize="fillBlock()" initialize="iPage.init(block1)"/> - </mx:Application> Added: mentalmodels/trunk/flex/src/custom/FisheryExperimentKalin.mxml =================================================================== --- mentalmodels/trunk/flex/src/custom/FisheryExperimentKalin.mxml (rev 0) +++ mentalmodels/trunk/flex/src/custom/FisheryExperimentKalin.mxml 2009-07-05 23:47:57 UTC (rev 171) @@ -0,0 +1,308 @@ +<?xml version="1.0" encoding="utf-8"?> +<mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:net="flash.net.*" xmlns:comp="custom.*" + clipContent="false" verticalScrollPolicy="off" horizontalScrollPolicy="off" + currentState="socioDemographic" initialize="init()" + width="100%" height="100%"> + + <mx:states> + <mx:State name="socioDemographic"> + <mx:AddChild relativeTo="{content}"> + <comp:SocioDemographicPage id="socioDemographic" + x="{(content.width-socioDemographic.width)/2}" + y="{(content.height-socioDemographic.height)/2}"/> + </mx:AddChild> + <mx:SetProperty target="{content}" name="x"/> + <mx:SetStyle target="{content}" name="horizontalCenter" value="0"/> + </mx:State> + + <mx:State name="instructions"> + <mx:AddChild relativeTo="{content}"> + <!--<comp:InstructionPage id="instructions" initialize="instructions.init(makeBlock())"/>--> + <comp:InstructionPage id="instructions" initialize="instructions.initModule(currModule)"/> + </mx:AddChild> + </mx:State> + + <mx:State name="wait"> + <mx:AddChild relativeTo="{content}"> + <mx:Label id="lblWaiting" text="Waiting for next Module from server..." fontSize="16"/> + </mx:AddChild> + </mx:State> + + <mx:State name="none"> + <mx:AddChild relativeTo="{content}"> + <mx:Label id="end" text="Thank you for playing!" fontSize="30"/> + </mx:AddChild> + </mx:State> + </mx:states> + + + + <!-- <mx:Canvas id="content" x="5" y="5" width="750" height="470"/> --> + <mx:Canvas id="content" x="0" y="0" width="100%" height="100%"/> + <mx:Canvas id="expiredContent" x="-1" y="-1" width="1" height="1" visible="false"/> + + <mx:Button id="btnBack" label="« Back" click="back()" left="8" bottom="8" enabled="false"/> + <mx:Button id="btnAccept" label="Accept" click="accept()" left="{(width-btnAccept.width)/2}" bottom="10"/> + <mx:Button id="btnForward" label="Forward »" click="forward()" right="8" bottom="8" enabled="false"/> + + <mx:RemoteObject id="ss" destination="studentService" fault="faultHandler(event)" result="resultHandler(event)"/> + <mx:Producer id="producer" destination="DataPush" acknowledge="ack(event)"/> + <mx:Consumer id="consumer" destination="DataPush" message="messageHandler(event.message)" /> + <mx:Script> + <![CDATA[ + import actionscript.*; + import actionscript.questions.*; + import custom.*; + import mx.controls.Label; + import mx.controls.Alert; + import mx.collections.ArrayCollection; + import flash.sampler.getInvocationCount; + import mx.rpc.events.ResultEvent; + import mx.rpc.events.FaultEvent; + import mx.messaging.messages.IMessage; + import mx.messaging.events.MessageAckEvent; + import mx.messaging.events.MessageFaultEvent; + import mx.messaging.FlexClient; + import mx.messaging.messages.AsyncMessage; + + + // + // Important Variables + // + public var currModule:Module = null; + + private var shared:SharedObject; + private var flushMessage:String; + [Bindable] + public var Id : uint; + + [Bindable] + public var randomNumbers:String; + private function ack(event:MessageAckEvent):void + { + //chart.setVisible(true); + randomNumbers = event.message.body as String; + //Alert.show("in ack method" + randomNumbers); + } + private function resultHandler(event:ResultEvent):void + { + Id = event.result as uint; + +// Alert.show("Student id is " + Id ); + consumer.disconnect(); + } + + private function faultHandler(event:FaultEvent):void + { +// Alert.show("event fault is " + event.fault.faultDetail); + } + + private function handleFault(event:MessageFaultEvent):void + { +// Alert.show("Message event fault is " + event.faultString); + } + + + private function messageHandler(message:IMessage):void + { + randomNumbers = message.body as String; +// Alert.show( ""+randomNumbers); + } + + public function init():void + { + + } + + private function getModule():Module + { + // server request here + + currModule = null; + return currModule; // set to null for now (clear old) + } + + public function back():Boolean + { + if(content.numChildren == 0) + { return false; } + var obj:DisplayObject = content.getChildAt(0); + + if(obj is InstructionPage) + { + try + { + return (InstructionPage)(obj).back(); + } + catch(err:Error){} + } + return false; + } + + public function forward():Boolean + { + if(content.numChildren == 0) + { return false; } + var obj:DisplayObject = content.getChildAt(0); + + if(obj is InstructionPage) + { + try + { + return (InstructionPage)(obj).forward(); + } + catch(err:Error){} + } + return false; + } + + public function accept():Boolean + { + if(content.numChildren == 0) + { return false; } + + var obj:DisplayObject = content.getChildAt(0); + var returnValue:Boolean = false; + + if(obj is SocioDemographicPage) + { + var Id:uint = 0; + if( (SocioDemographicPage)(obj).accept() ) + { + obj.visible = false; + expiredContent.addChild(obj); + + // + // TEMPORARY CODE + // comments indicate changes to be made for legitimate server communication + // + currModule = new Module(); //delete + currModule.blocks = new ArrayCollection(); //delete + currModule.blocks.addItem(makeBlock()); //delete + currModule.blocks.addItem(makeBlock()); //delete + currentState = "instructions"; //change to state "wait", which will call getModule() + // + // END TEMPORARY CODE + // + + + var info:SocioDemographicPage = SocioDemographicPage(obj); + /* Alert.show(info.getGender()); + Alert.show(info.getMajor()); + Alert.show(info.getSemester()); + Alert.show(info.getYear());*/ + Id=ss.createStudent(info.getYear(), info.getSemester(), info.getGender(),info.getMajor()); +// Alert.show("Before invoking createstudent()"); + + btnBack.enabled = true; + btnForward.enabled = true; + + returnValue = true; + } + } + if(obj is InstructionPage) + { + try + { + if( (InstructionPage)(obj).accept() ) + { + obj.visible = false; + expiredContent.addChild(obj); + currentState = "wait"; + //consumer.subscribe(); + returnValue = true; + } + } + catch(err:Error){} + } + + btnBack.enabled = btnForward.enabled = currentState == "instructions"; + + return returnValue; + } + + public function makeBlock():Block + { + var block1:Block = new Block(); + try{ + var questionGroups1:ArrayCollection = new ArrayCollection(); + var qg0:QuestionGroup = new QuestionGroup(); + var qg1:QuestionGroup = new QuestionGroup(); + var qg2:QuestionGroup = new QuestionGroup(); + var qg3:QuestionGroup = new QuestionGroup(); + var qg4:QuestionGroup = new QuestionGroup(); + var qg5:QuestionGroup = new QuestionGroup(); + var qg6:QuestionGroup = new QuestionGroup(); + qg0.questions = new ArrayCollection(); + qg1.questions = new ArrayCollection(); + qg2.questions = new ArrayCollection(); + qg3.questions = new ArrayCollection(); + qg4.questions = new ArrayCollection(); + qg5.questions = new ArrayCollection(); + qg6.questions = new ArrayCollection(); + block1.questionGroups = new ArrayCollection(); + + // create questions + var ddq1:Question = new Question(); + ddq1.question = "dayByDayDecisionsQuestion"; + ddq1.type = "dayByDayDecisions"; + + var cat1:Categorical = new Categorical(); + cat1.question = "categoricalQuestion"; + cat1.type = "categorical"; + cat1.topics = new ArrayCollection(); + cat1.specifics = new ArrayCollection(); + + var for1:ForecastingPeople = new ForecastingPeople(); + var for2:ForecastingFish = new ForecastingFish(); + + var psy1:PsychometricQuestion = new PsychometricQuestion(); + psy1.question = "psychometricQuestion"; + psy1.type = "psychometric"; + psy1.numberOfIntervals = 10; + psy1.choices = new ArrayCollection(); + psy1.choices.addItem("Highly Agree"); + psy1.choices.addItem("Highly Neutral"); + psy1.choices.addItem("Highly Disagree"); + + var str1:Question = new Question(); + str1.question = "strategyDesignQuestion"; + str1.type = "strategyDesign"; + + var txt1:Question = new Question(); + txt1.question = "textQuestion"; + txt1.type = "text"; + + // insert questions into groups + qg0.questions.addItem(ddq1); + qg1.questions.addItem(cat1); + qg2.questions.addItem(for1); + qg3.questions.addItem(for2); + qg4.questions.addItem(psy1); + qg5.questions.addItem(str1); + qg6.questions.addItem(txt1); + + qg1.description = "testDesc"; + qg1.header = "testHead"; + + block1.questionGroups.addItem(qg0); + block1.questionGroups.addItem(qg1); + block1.questionGroups.addItem(qg2); + block1.questionGroups.addItem(qg3); + block1.questionGroups.addItem(qg4); + block1.questionGroups.addItem(qg5); + block1.questionGroups.addItem(qg6); + + + }catch(errObject:Error){ + Alert.show("block creation failure\n" + + errObject.message + "\n" + errObject.getStackTrace()); + } + return block1; + } + + ]]> + </mx:Script> + +</mx:Canvas> + Added: mentalmodels/trunk/flex/src/custom/InformationWindowPopup.mxml =================================================================== --- mentalmodels/trunk/flex/src/custom/InformationWindowPopup.mxml (rev 0) +++ mentalmodels/trunk/flex/src/custom/InformationWindowPopup.mxml 2009-07-05 23:47:57 UTC (rev 171) @@ -0,0 +1,24 @@ +<?xml version="1.0" encoding="utf-8"?> +<mx:TitleWindow xmlns:mx="http://www.adobe.com/2006/mxml" + layout="vertical" + title="Information Window Popup" + showCloseButton="true" + close="titleWindow_close(event);" + width="700" height="500"> + + <mx:Script> + <![CDATA[ + import mx.events.CloseEvent; + import mx.managers.PopUpManager; + + public var closedFunction:Function = null; + public var valid:Boolean = true; + + private function titleWindow_close(evt:CloseEvent):void + { + closedFunction.call(); + } + ]]> + </mx:Script> + +</mx:TitleWindow> Added: mentalmodels/trunk/flex/src/custom/InstructionPage.mxml =================================================================== --- mentalmodels/trunk/flex/src/custom/InstructionPage.mxml (rev 0) +++ mentalmodels/trunk/flex/src/custom/InstructionPage.mxml 2009-07-05 23:47:57 UTC (rev 171) @@ -0,0 +1,173 @@ +<?xml version="1.0" encoding="utf-8"?> +<mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:comp="custom.*" xmlns:as="actionscript.*"> + + <mx:Script> + <![CDATA[ + import actionscript.Module; + import custom.questions.forecasting.*; + import mx.controls.Alert; + import actionscript.Block; + import actionscript.PageDisplay; + import mx.collections.ArrayCollection; + + [Bindable] public var module:Module; + [Bindable] public var currBlock:int = 0; + [Bindable] public var block:Block; + [Bindable] public var pageDisplay:PageDisplay; + [Bindable] public var numPages:int = 1; + [Bindable] public var currPage:int = 0; + + public var savedForecastPeople:ArrayCollection = null; + + + public function initModule(newModule:actionscript.Module):void + { + module = newModule; + currBlock = 0; + init(module.blocks.getItemAt(currBlock) as Block); + } + + public function init(newBlock:Block):void + { + block = newBlock; + try{ +// debug.text += "creating pageDisplay...\n"; + var minPagesRead:int = 0; + if(block != null && block.questionGroups != null) + { + minPagesRead = block.questionGroups.length + } + pageDisplay = new PageDisplay(block, minPagesRead); + if(pageDisplay == null) + { + debug.text += "pageDisplay is null"; + } +// pageDisplay = new PageDisplay(block, block.questionGroups.length); + + + + }catch(errObject:Error){ + debug.text += "pageDisplay creation failure\n" + + errObject.message +"\n"+ errObject.getStackTrace() +"\n"; +// Alert.show(debug.text); + } + +// debug.text += "setting currPage...\n"; + currPage = pageDisplay.currentPageNumber; +// debug.text += "setting numPages...\n"; + numPages = pageDisplay.pages.length; + +// debug.text += "adding currentPage...\n"; + content.addChild(pageDisplay.currentPage); +// debug.text += "currentPage added.\n"; + } + + public function back():Boolean + { + preTurn(); + var pageSuccess:Boolean = pageDisplay.prevPage(); + if(pageSuccess) + { + postTurn(); + } + return pageSuccess; + } + + public function forward():Boolean + { + preTurn(); + var pageSuccess:Boolean = pageDisplay.nextPage(); + if(pageSuccess) + { + postTurn(); + } + return pageSuccess; + } + private function preTurn():void + { + var currPageArray:Array = (pageDisplay.currentPage as VBox).getChildren(); + for(var i:int = 0; i < currPageArray.length; i++) + { + if(currPageArray[i] is ForecastingPeopleQuestionC) + { + savedForecastPeople = (currPageArray[i] as ForecastingPeopleQuestionC).save(); + } + } + } + private function postTurn():void + { + currPage = pageDisplay.currentPageNumber; + currPageLabel.text = "Page " + (currPage+1) + " / " + numPages; + + content.removeAllChildren(); + content.addChild(pageDisplay.currentPage); + + var currPageArray:Array = (pageDisplay.currentPage as VBox).getChildren(); + for(var i:int = 0; i < currPageArray.length; i++) + { + if(currPageArray[i] is ForecastingFishQuestionC) + { + (currPageArray[i] as ForecastingFishQuestionC).loadPeopleOnly(savedForecastPeople); + } + } + + } + + public function accept():Boolean // true iff completely finished with module + { + try + { + if(pageDisplay.finished()) + { + //switch blocks within module + var nextBlock:int = currBlock+1; + if(nextBlock < module.blocks.length) + { + content.removeAllChildren(); + + currBlock = nextBlock; + init(module.blocks.getItemAt(currBlock) as Block); + numPages = 1; + return false; + } + else + { + //server stuff goes here + + return true; // module finished + } + } + else + { + Alert.show("Cannot advance.\nTry looking at every page."); + } + return false; + } + catch(err:Error) + { + Alert.show("accepterror"+err.message+err.getStackTrace()); + } + return false; + } + + public function save():ArrayCollection + { + var saveArray:ArrayCollection = new ArrayCollection(); + saveArray.addItem(block); + return saveArray; + } + + public function load(loadArray:ArrayCollection):void + { + block = (loadArray.getItemAt(0) as Block); + } + + ]]> + </mx:Script> + + <mx:Label id="currPageLabel" text="Page {(currPage+1)} / {numPages}"/> +<mx:Text id="debug" text="{pageDisplay.msg}" width="300"/> + + <mx:VBox id="content"/> + +</mx:VBox> Added: mentalmodels/trunk/flex/src/custom/SocioDemographicPage.mxml =================================================================== --- mentalmodels/trunk/flex/src/custom/SocioDemographicPage.mxml (rev 0) +++ mentalmodels/trunk/flex/src/custom/SocioDemographicPage.mxml 2009-07-05 23:47:57 UTC (rev 171) @@ -0,0 +1,137 @@ +<?xml version="1.0" encoding="utf-8"?> +<mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml" verticalAlign="middle" horizontalAlign="center"> + + <mx:Script> + <![CDATA[ + import mx.collections.ArrayCollection; + + public function getGender():String + { + if(radioMale.selected) { return "M"; } + if(radioFemale.selected) { return "F"; } + return "Err"; + } + public function getYear():String + { + return txtYear.text; + } + public function getMajor():String + { + return txtMajor.text; + } + public function getSemester():String + { + return txtSemester.text; + } + + public function accept():Boolean + { + // if any field is of improper length, this section is not completed + // flag/unflag an area with red if incomplete/complete + var ready:Boolean=true; + var bgcolor:String = "backgroundColor"; + var red:String = "#FF0000"; + var white:String = "#FFFFFF"; + + if(getGender().length != 1) // "M", "F", "Err" + { + boxGender.setStyle(bgcolor, red); + ready=false; + }else{ + boxGender.setStyle(bgcolor, ""); + } + + if(getYear().length != 4 || Number(getYear()) < 1900) + { + txtYear.setStyle(bgcolor, red); + ready=false; + }else{ + txtYear.setStyle(bgcolor, white); + } + + if(getMajor().length == 0) + { + txtMajor.setStyle(bgcolor, red); + ready=false; + }else{ + txtMajor.setStyle(bgcolor, white); + } + + if(getSemester().length == 0) + { + txtSemester.setStyle(bgcolor, red); + ready=false; + }else{ + txtSemester.setStyle(bgcolor, white); + } + + enable(!ready); + return ready; + } + + public function enable(enabled:Boolean=true):void + { + boxGender.enabled = enabled; + txtYear.enabled = enabled; + txtMajor.enabled = enabled; + txtSemester.enabled = enabled; + } + + public function save():ArrayCollection + { + var saveArray:ArrayCollection = new ArrayCollection(); + saveArray.addItem(getGender()); + saveArray.addItem(getYear()); + saveArray.addItem(getMajor()); + saveArray.addItem(getSemester()); + return saveArray; + } + + public function load(loadArray:ArrayCollection):void + { + var gender:String = (loadArray.getItemAt(0) as String); + if(gender != null && gender.length == 1) + { + radioMale.selected = (gender == "M"); + radioFemale.selected = (gender == "F"); + } + txtYear.text = (loadArray.getItemAt(1) as String); + txtMajor.text = (loadArray.getItemAt(2) as String); + txtSemester.text = (loadArray.getItemAt(3) as String); + } + + ]]> + </mx:Script> + + <mx:VBox id="content"> + <mx:VBox width="220" horizontalAlign="center"> + <mx:Label text="Personal Data" fontSize="18"/> + <mx:Label text="Please fill out the following fields:"/> + </mx:VBox> + + <mx:HBox> + <mx:Label text="Gender:" fontWeight="bold" width="100" textAlign="right"/> + <mx:HBox id="boxGender"> + <mx:RadioButtonGroup id="gender"/> + <mx:RadioButton groupName="{gender}" label="M" id="radioMale"/> + <mx:RadioButton groupName="{gender}" label="F" id="radioFemale"/> + </mx:HBox> + </mx:HBox> + + <mx:HBox> + <mx:Label text="Year of Birth:" fontWeight="bold" width="100" textAlign="right"/> + <mx:TextInput id="txtYear" width="75" maxChars="4"/> + </mx:HBox> + + <mx:HBox> + <mx:Label text="Major:" fontWeight="bold" width="100" textAlign="right"/> + <mx:TextInput id="txtMajor" width="120" maxChars="100"/> + </mx:HBox> + + <mx:HBox> + <mx:Label text="Semester:" fontWeight="bold" width="100" textAlign="right"/> + <mx:TextInput id="txtSemester" width="75" maxChars="6"/> + </mx:HBox> + </mx:VBox> + +</mx:VBox> Added: mentalmodels/trunk/flex/src/custom/TimeLabel.mxml =================================================================== --- mentalmodels/trunk/flex/src/custom/TimeLabel.mxml (rev 0) +++ mentalmodels/trunk/flex/src/custom/TimeLabel.mxml 2009-07-05 23:47:57 UTC (rev 171) @@ -0,0 +1,28 @@ +<?xml version="1.0" encoding="utf-8"?> +<mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml" + creationComplete="init()"> + + <mx:Script> + <![CDATA[ + [Bindable] private var showTime:String; + + private function init():void{ + // Update every second + var tmr:Timer = new Timer(1000); + tmr.addEventListener(TimerEvent.TIMER, changeTime); + tmr.start(); + } + + private function changeTime(event:TimerEvent):void{ + // Get Server Time + var serv:Date = new Date(); // *fix this* + + // Display Server Time + showTime = serv.toLocaleTimeString(); + } + ]]> + </mx:Script> + + <mx:Label text="{showTime}"/> + +</mx:Canvas> Added: mentalmodels/trunk/flex/src/custom/db/Block.mxml =================================================================== --- mentalmodels/trunk/flex/src/custom/db/Block.mxml (rev 0) +++ mentalmodels/trunk/flex/src/custom/db/Block.mxml 2009-07-05 23:47:57 UTC (rev 171) @@ -0,0 +1,166 @@ +<?xml version="1.0" encoding="utf-8"?> +<mx:Form xmlns:mx="http://www.adobe.com/2006/mxml"> +<mx:Script> + <![CDATA[ + import mx.validators.NumberValidator; + import mx.validators.Validator; + import mx.events.ValidationResultEvent; + import mx.controls.Alert; + + [Bindable] + public var formIsEmpty:Boolean = true; + + [Bindable] + public var formIsValid:Boolean = false; + + + // Holds a reference to the currently focussed + // control on the form. + private var focussedFormControl:DisplayObject; + + public function getSequenceNo():String + { + return txtSeqNo.text; + } + public function getName():String + { + return txtName.text; + } + /*public function getDuration():String + { + //return txtMajor.text; + }*/ + + public function getHours():Number + { + return hours.value; + + } + public function getMinutes():Number + { + return minutes.value; + + } + public function getSeconds():Number + { + return seconds.value; + + } + + 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; + + } + 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 + // the currently focussed form control and not affect + // any of the other form controls. + focussedFormControl = event.target as DisplayObject; + + // Mark the form as valid to start with + formIsValid = true; + + // Check if form is empty + formIsEmpty = (txtSeqNo.text == "" && txtName.text == ""); + + // Run each validator in turn, using the isValid() + // helper method and update the value of formIsValid + // accordingly. + validate(validateSeqNo); + return formIsValid; + + } + + private function validate(validator:Validator):Boolean + { + // Get a reference to the component that is the + // source of the validator. + var validatorSource:DisplayObject = validator.source as DisplayObject; + + // Suppress events if the current control being validated is not + // the currently focussed control on the form. This stops the user + // from receiving visual validation cues on other form controls. + // var suppressEvents:Boolean = (validatorSource != focussedFormControl); + var suppressEvents:Boolean = false; + // Carry out validation. Returns a ValidationResultEvent. + // Passing null for the first parameter makes the validator + // use the property defined in the property tag of the + // <mx:Validator> tag. + var event:ValidationResultEvent = validator.validate(null, suppressEvents); + + // Check if validation passed and return a boolean value accordingly. + var currentControlIsValid:Boolean = (event.type == ValidationResultEvent.VALID); + + // Update the formIsValid flag + formIsValid = formIsValid && currentControlIsValid; + + return currentControlIsValid; + } + + public function reset():void + { + txtSeqNo.text =""; + txtName.text = ""; + hours.value =0; + minutes.value =0; + seconds.value =0; + txtSeqNo.errorString =""; + txtName.errorString =""; + + } + + + + ]]> + </mx:Script> + <mx:FormHeading label="Block Information"/> + <mx:FormItem label="Sequence Number:"> + <mx:TextInput id="txtSeqNo" maxChars="3" change="{validateForm(event)}"/> + </mx:FormItem> + <mx:FormItem label="Description:"> + <mx:TextArea id="txtName" change="{validateForm(event)}"/> + </mx:FormItem> + +<mx:FormItem label="Duration(hr:min:sec):"> + <mx:HBox> + <!--<mx:TextInput id="txtDuration" maxChars="8"/>--> + <mx:NumericStepper id="hours" minimum="0" maximum="12" stepSize="1" change="{getHours()}"/> + <mx:Label text=":" textAlign="center"/> + <mx:NumericStepper id="minutes" minimum="0" maximum="60" stepSize="1" change="{getMinutes()}"/> + <mx:Label text=":" textAlign="center"/> + <mx:NumericStepper id="seconds" minimum="0" maximum="60" stepSize="1" change="{getSeconds()}"/> + </mx:HBox> + + + + +</mx:FormItem> +<mx:NumberValidator id ="validateSeqNo" source="{txtSeqNo}" property="text" minValue="1" maxValue="1000" domain="int"/> + +</mx:Form> Added: mentalmodels/trunk/flex/src/custom/db/Module.mxml =================================================================== --- mentalmodels/trunk/flex/src/custom/db/Module.mxml (rev 0) +++ mentalmodels/trunk/flex/src/custom/db/Module.mxml 2009-07-05 23:47:57 UTC (rev 171) @@ -0,0 +1,169 @@ +<?xml version="1.0" encoding="utf-8"?> + + +<mx:Form xmlns:mx="http://www.adobe.com/2006/mxml" width="30%" height="100%" autoLayout="true"> +<mx:Script> + <![CDATA[ + import mx.validators.NumberValidator; + import mx.validators.Validator; + import mx.events.ValidationResultEvent; + import mx.controls.Alert; + + [Bindable] + public var formIsEmpty:Boolean = true; + + [Bindable] + public var formIsValid:Boolean = false; + + + // Holds a reference to the currently focussed + // control on the form. + private var focussedFormControl:DisplayObject; + + public function getSequenceNo():String + { + return txtSeqNo.text; + } + public function getName():String + { + return txtName.text; + } + /*public function getDuration():String + { + //return txtMajor.text; + }*/ + + public function getHours():Number + { + return hours.value; + + } + public function getMinutes():Number + { + return minutes.value; + + } + public function getSeconds():Number + { + return seconds.value; + + } + + 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; + + } + 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 + // the currently focussed form control and not affect + // any of the other form controls. + focussedFormControl = event.target as DisplayObject; + + // Mark the form as valid to start with + formIsValid = true; + + // Check if form is empty + formIsEmpty = (txtSeqNo.text == "" && txtName.text == ""); + + // Run each validator in turn, using the isValid() + // helper method and update the value of formIsValid + // accordingly. + validate(validateSeqNo); + return formIsValid; + + } + + private function validate(validator:Validator):Boolean + { + // Get a reference to the component that is the + // source of the validator. + var validatorSource:DisplayObject = validator.source as DisplayObject; + + // Suppress events if the current control being validated is not + // the currently focussed control on the form. This stops the user + // from receiving visual validation cues on other form controls. + // var suppressEvents:Boolean = (validatorSource != focussedFormControl); + var suppressEvents:Boolean = false; + // Carry out validation. Returns a ValidationResultEvent. + // Passing null for the first parameter makes the validator + // use the property defined in the property tag of the + // <mx:Validator> tag. + var event:ValidationResultEvent = validator.validate(null, suppressEvents); + + // Check if validation passed and return a boolean value accordingly. + var currentControlIsValid:Boolean = (event.type == ValidationResultEvent.VALID); + + // Update the formIsValid flag + formIsValid = formIsValid && currentControlIsValid; + + return currentControlIsValid; + } + + public function reset():void + { + txtSeqNo.text =""; + txtName.text = ""; + hours.value =0; + minutes.value =0; + seconds.value =0; + txtSeqNo.errorString =""; + txtName.errorString =""; + + } + + + + ]]> + </mx:Script> + <mx:FormHeading label="Module Information"/> + <mx:FormItem label="Sequence Number:"> + <mx:TextInput id="txtSeqNo" maxChars="3" change="{validateForm(event)}"/> + </mx:FormItem> + <mx:FormItem label="Name:"> + <mx:TextInput id="txtName" change="{validateForm(event)}"/> + </mx:FormItem> + +<mx:FormItem label="Duration(hr:min:sec):"> + <mx:HBox> + <!--<mx:TextInput id="txtDuration" maxChars="8"/>--> + <mx:NumericStepper id="hours" minimum="0" maximum="12" stepSize="1" change="{getHours()}"/> + <mx:Label text=":" textAlign="center"/> + <mx:NumericStepper id="minutes" minimum="0" maximum="60" stepSize="1" change="{getMinutes()}"/> + <mx:Label text=":" textAlign="center"/> + <mx:NumericStepper id="seconds" minimum="0" maximum="60" stepSize="1" change="{getSeconds()}"/> + </mx:HBox> + + + + +</mx:FormItem> +<mx:NumberValidator id ="validateSeqNo" source="{txtSeqNo}" property="text" minValue="1" maxValue="1000" domain="int"/> + + +</mx:Form> Added: mentalmodels/trunk/flex/src/custom/db/Question.mxml =================================================================== --- mentalmodels/trunk/flex/src/custom/db/Question.mxml (rev 0) +++ mentalmodels/trunk/flex/src/custom/db/Question.mxml 2009-07-05 23:47:57 UTC (rev 171) @@ -0,0 +1,213 @@ +<?xml version="1.0" encoding="utf-8"?> +<mx:Form xmlns:mx="http://www.adobe.com/2006/mxml" width="80%" height="100%" currentState="none" xmlns:net="flash.net.*" xmlns:comp="customComponents.db.questions.*"> + <mx:Script> + <![CDATA[ + import mx.validators.NumberValidator; + import mx.validators.Validator; + import mx.events.ValidationResultEvent; + import mx.controls.Alert; + + [Bindable] + public var formIsEmpty:Boolean = true; + + [Bindable] + public var formIsValid:Boolean = false; + + public var questionInfo:Object; + // Holds a reference to the currently focussed + // control on the form. + private var focussedFormControl:DisplayObject; + + public function getSequenceNo():String + { + return txtSeqNo.text; + } + public function getQuestion():String + { + return txtQuestion.text; + } + + public function getType():String + { + return String(cmbType.selectedItem); + } + + public function setSequenceNo(seqNo:String):void + { + txtSeqNo.text = seqNo; + } + public function setQuestion(question:String):void + { + txtQuestion.text = question; + } + + public function setQuestionInfo():void + { + + } + + public function getQuestionInfo():Object + { + return questionInfo; + + } + + public function setType(type:String):void + { + cmbType.selectedItem = type; + if(cmbType.selectedItem == "Categorical") + { + currentState = "categorical"; + var catobj:DisplayObject = canvasQuestionType.getChildAt(0); + var categoricalInfo:Categorical = Categorical(catobj); + categoricalInfo.reset(); + + } + if(cmbType.selectedItem == "Psychometric") + { + currentState = "psychometric"; + var psychobj:DisplayObject = canvasQuestionType.getChildAt(0); + var psychometricInfo:Psychometric = Psychometric(psychobj); + psychometricInfo.reset(); + + } + if(cmbType.selectedItem == "Text") + { + currentState = "none"; + } + } + + + + public function validateForm(event:Event):Boolean + { + // Save a reference to the currently focussed form control + // so that the isValid() helper method can notify only + // the currently focussed form control and not affect + // any of the other form controls. + focussedFormControl = event.target as DisplayObject; + + // Mark the form as valid to start with + formIsValid = true; + + // Check if form is empty + formIsEmpty = (txtSeqNo.text == "" && txtQuestion.text == "" && cmbType.selectedItem == "-Select-"); + + // Run each validator in turn, using the isValid() + // helper method and update the value of formIsValid + // accordingly. + validate(validateSeqNo); + + return formIsValid; + + } + + private function showQuestionType():void + { + + 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"; + } + + } + + + private function validate(validator:Validator):Boolean + { + // Get a reference to the component that is the + // source of the validator. + var validatorSource:DisplayObject = validator.source as DisplayObject; + + // Suppress events if the current control being validated is not + // the currently focussed control on the form. This stops the user + // from receiving visual validation cues on other form controls. + // var suppressEvents:Boolean = (validatorSource != focussedFormControl); + var suppressEvents:Boolean = false; + // Carry out validation. Returns a ValidationResultEvent. + // Passing null for the first parameter makes the validator + // use the property defined in the property tag of the + // <mx:Validator> tag. + var event:ValidationResultEvent = validator.validate(null, suppressEvents); + + // Check if validation passed and return a boolean value accordingly. + var currentControlIsValid:Boolean = (event.type == ValidationResultEvent.VALID); + + // Update the formIsValid flag + formIsValid = formIsValid && currentControlIsValid; + + return currentControlIsValid; + } + + public function reset():void + { + currentState = "none"; + txtSeqNo.text =""; + txtQuestion.text = ""; + + txtSeqNo.errorString =""; + txtQuestion.errorString =""; + cmbType.selectedIndex = 0; + + + } + + ]]> + </mx:Script> + <mx:states> + <mx:State name="categorical"> + <mx:AddChild relativeTo="{canvasQuestionType}"> + <comp:Categorical id="categorical"/> + </mx:AddChild> + </mx:State> + + <mx:State name="psychometric"> + <mx:AddChild relativeTo="{canvasQuestionType}"> + <comp:Psychometric id="psychometric"/> + </mx:AddChild> + </mx:State> + <mx:State name="none" /> + + </mx:states> + + + <mx:FormHeading label="Question"/> + <mx:FormItem label="Sequence Number:"> + <mx:TextInput id="txtSeqNo" maxChars="3" change="{validateForm(event)}"/> + </mx:FormItem> + <mx:FormItem label="Question:"> + <mx:TextArea id="txtQuestion" change="{validateForm(event)}"/> + </mx:FormItem> + <mx:FormItem label="Select Question Type:"> + <mx:ComboBox id="cmbType" change="{showQuestionType()}" width="100%"> + <mx:ArrayCollection> + <mx:String>-Select-</mx:String> + <mx:String>Categorical</mx:String> + <mx:String>Psychometric</mx:String> + <mx:String>Text</mx:String> + </mx:ArrayCollection> + </mx:ComboBox> + + </mx:FormItem> + + <mx:Canvas id="canvasQuestionType" height="100%"/> + +<mx:NumberValidator id ="validateSeqNo" source="{txtSeqNo}" property="text" minValue="1" maxValue="1000" domain="int"/> + +</mx:Form> Added: mentalmodels/trunk/flex/src/custom/db/QuestionGroup.mxml =================================================================== --- mentalmodels/trunk/flex/src/custom/db/QuestionGroup.mxml (rev 0) +++ mentalmodels/trunk/flex/src/custom/db/QuestionGroup.mxml 2009-07-05 23:47:57 UTC (rev 171) @@ -0,0 +1,127 @@ +<?xml version="1.0" encoding="utf-8"?> +<mx:Form xmlns:mx="http://www.adobe.com/2006/mxml"> + <mx:Script> + <![CDATA[ + import mx.validators.NumberValidator; + import mx.validators.Validator; + import mx.events.ValidationResultEvent; + import mx.controls.Alert; + + [Bindable] + public var formIsEmpty:Boolean = true; + + [Bindable] + public var formIsValid:Boolean = false; + + + // Holds a reference to the currently focussed + // control on the form. + private var focussedFormControl:DisplayObject; + + public function getSequenceNo():String + { + return txtSeqNo.text; + } + public function getHeader():String + { + return txtHeader.text; + } + public function getDescription():String + { + return txtDescription.text; + } + + public function setSequenceNo(seqNo:String):void + { + txtSeqNo.text = seqNo; + } + public function setHeader(header:String):void + { + txtHeader.text = header; + } + + + public function setDescription(description:String):void + { + txtDescription.text = description; + + } + + + public function validateForm(event:Event):Boolean + { + // Save a reference to the currently focussed form control + // so that the isValid() helper method can notify only + // the currently focussed form control and not affect + // any of the other form controls. + focussedFormControl = event.target as DisplayObject; + + // Mark the form as valid to start with + formIsValid = true; + +... [truncated message content] |
From: <kj...@us...> - 2009-07-05 19:50:49
|
Revision: 170 http://virtualcommons.svn.sourceforge.net/virtualcommons/?rev=170&view=rev Author: kjonas Date: 2009-07-05 19:50:39 +0000 (Sun, 05 Jul 2009) Log Message: ----------- obsolete and testing files deleted. folders restructured to contain "questions" folders in /flex/src/actionscript/ and /flex/src/custom/ ( formerly flex/src/customComponents/ ) /flex/src/customComponents/questions/ contains folders for question types that have auxiliary files associated with them. the effect of this restructuring appears to have had no negative effect on the performance of the program. Modified Paths: -------------- mentalmodels/trunk/flex/src/FisheryExperimentKalin.mxml mentalmodels/trunk/flex/src/_InstructionsTest.mxml mentalmodels/trunk/flex/src/actionscript/PageDisplay.as Added Paths: ----------- mentalmodels/trunk/flex/src/actionscript/questions/ mentalmodels/trunk/flex/src/actionscript/questions/Categorical.as mentalmodels/trunk/flex/src/actionscript/questions/DayByDayDecisions.as mentalmodels/trunk/flex/src/actionscript/questions/ForecastingFish.as mentalmodels/trunk/flex/src/actionscript/questions/ForecastingPeople.as mentalmodels/trunk/flex/src/actionscript/questions/PsychometricQuestion.as mentalmodels/trunk/flex/src/actionscript/questions/Question.as mentalmodels/trunk/flex/src/actionscript/questions/StrategyDesign.as Removed Paths: ------------- mentalmodels/trunk/flex/src/QuestionTest.mxml mentalmodels/trunk/flex/src/TableTest.mxml mentalmodels/trunk/flex/src/TestApp.mxml mentalmodels/trunk/flex/src/TestForecast.mxml mentalmodels/trunk/flex/src/actionscript/Categorical.as mentalmodels/trunk/flex/src/actionscript/CategoricalQuestion.as mentalmodels/trunk/flex/src/actionscript/DataGridHandler.as mentalmodels/trunk/flex/src/actionscript/DayByDayDecisionsQuestion.as mentalmodels/trunk/flex/src/actionscript/FishUtil.as mentalmodels/trunk/flex/src/actionscript/Forecasting.as mentalmodels/trunk/flex/src/actionscript/ForecastingFishQuestion.as mentalmodels/trunk/flex/src/actionscript/ForecastingPeopleQuestion.as mentalmodels/trunk/flex/src/actionscript/ForecastingQuestion.as mentalmodels/trunk/flex/src/actionscript/Psychometric.as mentalmodels/trunk/flex/src/actionscript/PsychometricQuestion.as mentalmodels/trunk/flex/src/actionscript/Question.as mentalmodels/trunk/flex/src/actionscript/StrategyDesignQuestion.as mentalmodels/trunk/flex/src/customComponents/ Modified: mentalmodels/trunk/flex/src/FisheryExperimentKalin.mxml =================================================================== --- mentalmodels/trunk/flex/src/FisheryExperimentKalin.mxml 2009-07-02 00:13:07 UTC (rev 169) +++ mentalmodels/trunk/flex/src/FisheryExperimentKalin.mxml 2009-07-05 19:50:39 UTC (rev 170) @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="utf-8"?> -<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:net="flash.net.*" xmlns:comp="customComponents.*" +<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:net="flash.net.*" xmlns:comp="custom.*" backgroundGradientAlphas="[1.0, 1.0]" backgroundGradientColors="[#FFFFFF, #B0B0FF]" width="100%" height="100%" clipContent="false" layout="absolute" currentState="socioDemographic" initialize="init()"> @@ -17,10 +17,17 @@ <mx:State name="instructions"> <mx:AddChild relativeTo="{content}"> - <comp:InstructionPage id="instructions" initialize="instructions.init(makeBlock())"/> + <!--<comp:InstructionPage id="instructions" initialize="instructions.init(makeBlock())"/>--> + <comp:InstructionPage id="instructions" initialize="instructions.initModule(currModule)"/> </mx:AddChild> </mx:State> + <mx:State name="wait"> + <mx:AddChild relativeTo="{content}"> + <mx:Label id="lblWaiting" text="Waiting for next Module from server..." fontSize="16"/> + </mx:AddChild> + </mx:State> + <mx:State name="none"> <mx:AddChild relativeTo="{content}"> <mx:Label id="end" text="Thank you for playing!" fontSize="30"/> @@ -44,7 +51,8 @@ <mx:Script> <![CDATA[ import actionscript.*; - import customComponents.*; + import actionscript.questions.*; + import custom.*; import mx.controls.Label; import mx.controls.Alert; import mx.collections.ArrayCollection; @@ -58,6 +66,11 @@ import mx.messaging.messages.AsyncMessage; + // + // Important Variables + // + public var currModule:Module = null; + private var shared:SharedObject; private var flushMessage:String; [Bindable] @@ -98,65 +111,16 @@ public function init():void { - /*var sharedObjTest:Boolean = false; - if(sharedObjTest) - { - var got:Boolean = getLocal(); - if(got) - { - getData().saved1 = "Hello, World!"; - getData().thisIsATest = 283; - - var testLabel:Label = new Label(); - testLabel.text = "This is a test"; - testLabel.x = getData().thisIsATest; - testLabel.y = getData().thisIsATest; - - testLabel.text += ", " +flushMessage+"x"+shared.toString()+"x"; - getData().testLabel = testLabel; - - if(getData().exists) testLabel.text += "SharedObject existed before initialization"; - else getData().exists = true; - - this.addChild(getData().testLabel); - - } - }*/ - // var msg:AsyncMessage = new AsyncMessage(); - //var client:FlexClient = FlexClient.getInstance(); - //creating new msg with "New"to get current state. - //msg.body = "New"; - - //producer.send(msg); - //Alert.show("message send is " + msg.body); - - - //consumer.subscribe(); - } - public function getData():Object + + private function getModule():Module { - return shared.data; + // server request here + + currModule = null; + return currModule; // set to null for now (clear old) } - public function getLocal():Boolean - { - try{ - shared = SharedObject.getLocal("thisIsForWork"); - }catch(err:Error){ - return false; - } - return true; - } - public function flush():Boolean - { - try{ - flushMessage = shared.flush(10000); - }catch(err:Error){ - return false; - } - return true; - } public function back():Boolean { @@ -207,8 +171,21 @@ { obj.visible = false; expiredContent.addChild(obj); - currentState = "instructions"; + // + // TEMPORARY CODE + // comments indicate changes to be made for legitimate server communication + // + currModule = new Module(); //delete + currModule.blocks = new ArrayCollection(); //delete + currModule.blocks.addItem(makeBlock()); //delete + currModule.blocks.addItem(makeBlock()); //delete + currentState = "instructions"; //change to state "wait", which will call getModule() + // + // END TEMPORARY CODE + // + + var info:SocioDemographicPage = SocioDemographicPage(obj); /* Alert.show(info.getGender()); Alert.show(info.getMajor()); @@ -231,14 +208,10 @@ { obj.visible = false; expiredContent.addChild(obj); - currentState = "none"; + currentState = "wait"; //consumer.subscribe(); returnValue = true; } - else - { - Alert.show("Cannot advance.\nTry looking at every page."); - } } catch(err:Error){} } @@ -270,30 +243,35 @@ block1.questionGroups = new ArrayCollection(); // create questions - var ddq1:DayByDayDecisionsQuestion = new DayByDayDecisionsQuestion(); - ddq1.question = "categoricalQuestion"; + var ddq1:Question = new Question(); + ddq1.question = "dayByDayDecisionsQuestion"; + ddq1.type = "dayByDayDecisions"; - var cat1:CategoricalQuestion = new CategoricalQuestion(); + var cat1:Categorical = new Categorical(); cat1.question = "categoricalQuestion"; + cat1.type = "categorical"; cat1.topics = new ArrayCollection(); cat1.specifics = new ArrayCollection(); - var for1:ForecastingPeopleQuestion = new ForecastingPeopleQuestion(); - var for2:ForecastingFishQuestion = new ForecastingFishQuestion(); + var for1:ForecastingPeople = new ForecastingPeople(); + var for2:ForecastingFish = new ForecastingFish(); var psy1:PsychometricQuestion = new PsychometricQuestion(); - psy1.question = "psychQuestion"; + psy1.question = "psychometricQuestion"; + psy1.type = "psychometric"; psy1.numberOfIntervals = 10; psy1.choices = new ArrayCollection(); psy1.choices.addItem("Highly Agree"); psy1.choices.addItem("Highly Neutral"); psy1.choices.addItem("Highly Disagree"); - var str1:StrategyDesignQuestion = new StrategyDesignQuestion(); - str1.question = "stratDesQuestion"; + var str1:Question = new Question(); + str1.question = "strategyDesignQuestion"; + str1.type = "strategyDesign"; var txt1:Question = new Question(); txt1.question = "textQuestion"; + txt1.type = "text"; // insert questions into groups qg0.questions.addItem(ddq1); Deleted: mentalmodels/trunk/flex/src/QuestionTest.mxml =================================================================== --- mentalmodels/trunk/flex/src/QuestionTest.mxml 2009-07-02 00:13:07 UTC (rev 169) +++ mentalmodels/trunk/flex/src/QuestionTest.mxml 2009-07-05 19:50:39 UTC (rev 170) @@ -1,47 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical" xmlns:comp="customComponents.*"> - - <mx:ArrayCollection id="topicList"> - <mx:String>- Select -</mx:String> - <mx:String>Your Earnings</mx:String> - <mx:String>Fish Population</mx:String> - <mx:String>Other Players</mx:String> - </mx:ArrayCollection> - - <mx:ArrayCollection id="specificList"> - <mx:ArrayCollection> - </mx:ArrayCollection> - <mx:ArrayCollection> - <mx:String>- Select -</mx:String> - <mx:String>Earn as much as possible</mx:String> - <mx:String>Earn more than the others</mx:String> - <mx:String>Earn about the same as the others</mx:String> - <mx:String>Earn less then the others</mx:String> - <mx:String>Earn a fair amount but much less then would be possible</mx:String> - <mx:String>Earn nothing</mx:String> - </mx:ArrayCollection> - <mx:ArrayCollection> - <mx:String>- Select -</mx:String> - <mx:String>Let the fish population grow as much as possible</mx:String> - <mx:String>Keep the fish population at a high stable level</mx:String> - <mx:String>Keep the fish population at a medium stable level</mx:String> - <mx:String>Keep the fish population at a low stable level</mx:String> - <mx:String>Not to completely destroy the fish population</mx:String> - <mx:String>To destroy the fish population</mx:String> - </mx:ArrayCollection> - <mx:ArrayCollection> - <mx:String>- Select -</mx:String> - <mx:String>Act similarly to the others</mx:String> - <mx:String>Act differently than the others</mx:String> - <mx:String>Allow the others to have good earnings</mx:String> - <mx:String>Avoid that the others get good earnings</mx:String> - <mx:String>Act according to rules I expect the others to know</mx:String> - <mx:String>Act against rules I expect the others to know</mx:String> - </mx:ArrayCollection> - </mx:ArrayCollection> - - <comp:TextQuestionC id="question1"/> - <comp:CategoricalQuestionC id="question2" topics="{topicList}" specifics="{specificList}"/> - <comp:ForecastingQuestionC id="question3"/> - -</mx:Application> Deleted: mentalmodels/trunk/flex/src/TableTest.mxml =================================================================== --- mentalmodels/trunk/flex/src/TableTest.mxml 2009-07-02 00:13:07 UTC (rev 169) +++ mentalmodels/trunk/flex/src/TableTest.mxml 2009-07-05 19:50:39 UTC (rev 170) @@ -1,37 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:comp="customComponents.*" layout="absolute"> - - <mx:VBox> - <mx:HBox id="cast"> - <!--<comp:Forecast id="legacy" numColumns="10"/>--> - <comp:Forecast1 id="forecastPeople" numColumns="15" minValue="0" maxValue="30" initialize="init()"/> - </mx:HBox> - <mx:Label initialize="init()"/> - <mx:Button id="next" label="Next" click="testNext()"/> - </mx:VBox> - - <mx:Script> - <![CDATA[ - import mx.messaging.channels.StreamingAMFChannel; - import customComponents.*; - import mx.collections.ArrayCollection; - - public function init():void - { - for(var x:Number=0;x<4;x++)for(var y:Number=0;y<15;y++)forecastPeople.setItem(x,y,7.5); - } - - public function testNext(evt:Event=null):void - { - if(!forecastPeople.isFinished()) return; - var f2:Forecast2 = new Forecast2(); - f2.id = "forecastFull_AS"; - f2.numColumns = 6; - f2.oldForecast1 = forecastPeople; - cast.addChild(f2); - } - - ]]> - </mx:Script> - -</mx:Application> Deleted: mentalmodels/trunk/flex/src/TestApp.mxml =================================================================== --- mentalmodels/trunk/flex/src/TestApp.mxml 2009-07-02 00:13:07 UTC (rev 169) +++ mentalmodels/trunk/flex/src/TestApp.mxml 2009-07-05 19:50:39 UTC (rev 170) @@ -1,32 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical" xmlns:comp="customComponents.*" - width="700" height="500"> - - <comp:LongHScale id="slider1" label="blah"/> - <mx:Label id="slideinfo1" text="{slider1.slider.value}"/> - - <comp:ShortHScale id="slider2"/> - <mx:Label id="slideinfo2" text="{slider2.slider.value}"/> - - <mx:Label/> - <mx:Label/> - <mx:Label/> - - <mx:ArrayCollection id="slider3Labels"> - <mx:String>label1</mx:String> - <mx:String>label2</mx:String> - <mx:String>label3</mx:String> - </mx:ArrayCollection> - - <mx:ArrayCollection id="slider4Labels"> - <mx:String>label1</mx:String> - <mx:String>label2</mx:String> - </mx:ArrayCollection> - - <comp:PsychometricQuestionC id="slider3" labels="{slider3Labels}"/> - <mx:Label id="slideinfo3" text="{slider3.slider1.getVal}"/> - - <comp:PsychometricQuestionC id="slider4" labels="{slider4Labels}"/> - <mx:Label id="slideinfo4" text="{slider4.slider1.getVal}"/> - -</mx:Application> Deleted: mentalmodels/trunk/flex/src/TestForecast.mxml =================================================================== --- mentalmodels/trunk/flex/src/TestForecast.mxml 2009-07-02 00:13:07 UTC (rev 169) +++ mentalmodels/trunk/flex/src/TestForecast.mxml 2009-07-05 19:50:39 UTC (rev 170) @@ -1,55 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:qComp="customComponents.questions.components.*" xmlns:quest="customComponents.questions.*" - initialize="init()"> - - <mx:VBox id="content" minWidth="160"> - <quest:ForecastingPeopleQuestionC id="people"/> - <mx:Button label="Save" click="save()"/> - <mx:Button label="Load" click="load()"/> - <quest:ForecastingFishQuestionC id="fish" initialize="false"/> - </mx:VBox> - - <mx:Script> - <![CDATA[ - import mx.collections.ArrayCollection; - import mx.controls.Alert; - - public var peopleSaved:ArrayCollection = null; - public var fishSaved:ArrayCollection = null; - - public function init():void - { - people.initialize(); - people.init(); - } - - public function save():void - { - try - { - peopleSaved = people.save(); - fishSaved = fish.save(); - } - catch(error:Error) - { - Alert.show(error.message + "\n" + error.getStackTrace()); - } - } - - public function load():void - { - try - { - people.load(peopleSaved); - fish.load(fishSaved,peopleSaved); - } - catch(error:Error) - { - Alert.show(error.message + "\n" + error.getStackTrace()); - } - } - - ]]> - </mx:Script> - -</mx:Application> Modified: mentalmodels/trunk/flex/src/_InstructionsTest.mxml =================================================================== --- mentalmodels/trunk/flex/src/_InstructionsTest.mxml 2009-07-02 00:13:07 UTC (rev 169) +++ mentalmodels/trunk/flex/src/_InstructionsTest.mxml 2009-07-05 19:50:39 UTC (rev 170) @@ -1,158 +1,19 @@ <?xml version="1.0" encoding="utf-8"?> -<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:comp="customComponents.*" xmlns:as="actionscript.*" - layout="vertical" xmlns:compQ="customComponents.questions.components.*" xmlns:questions="customComponents.questions.*" +<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:comp="custom.*" xmlns:as="actionscript.*" + layout="vertical" backgroundGradientColors="[#FFFFFF, #B0B0FF]"> - - <questions:DayByDayDecisionsQuestionC/> - - <!--<mx:HBox> - <compQ:OneDecision id="test1" lbsFished="12" initialize="initQ()"/> - <compQ:OneDecision id="test2" lbsFished="12" active="false"/> - <compQ:OneDecision id="test3" lbsFished="12" active="false"/> - <compQ:TotalDisplay id="testTotal" lbsFished="12" initialize="testTotal.redraw()"/> - </mx:HBox>--> - - <!--<mx:VBox id="dayByDayContent" initialize="daybydayinit()"> - - <mx:HBox id="buttons"> - <mx:Label id="lblChosen" text="location chosen: {deciding}"/> - <mx:Button id="btnHarbor" label="Harbor" click="{deciding = 0; clicked(null);}"/> - <mx:Button id="btnAdvance" label="Advance" click="advance()" fillColors="[#B0B0FF,#FFFFFF]"/> - </mx:HBox> - - <mx:HBox id="labels" verticalAlign="middle"> - <mx:Text textAlign="center" fontWeight="bold" minWidth="50" text="Day"/> - <mx:Text textAlign="center" fontWeight="bold" minWidth="125" text="Harbor"/> - <mx:Text textAlign="center" fontWeight="bold" minWidth="60" htmlText="Cumulative<br>Total"/> - </mx:HBox> - - <compQ:OneDay id="testDay" numBays="3"> - <compQ:decisions> - <mx:ArrayCollection id="decisions"> - <compQ:OneDecision active="false"/> - <compQ:OneDecision lbsFished="{Math.round(Math.random()*50)/10.0}"/> - <compQ:OneDecision active="false"/> - <compQ:OneDecision active="false"/> - </mx:ArrayCollection> - </compQ:decisions> - </compQ:OneDay> - - </mx:VBox>--> - + <mx:Script> <![CDATA[ - import customComponents.questions.components.OneDay; - import mx.controls.Alert; - -// <mx:Text textAlign="center" fontWeight="bold" minWidth="125" text="Bay1"/> -// <mx:Text textAlign="center" fontWeight="bold" minWidth="125" text="Bay2"/> -// <mx:Text textAlign="center" fontWeight="bold" minWidth="125" text="Bay3"/> - -// public var numBays:int = 3; -// [Bindable] public var deciding:int = 0; -// public var cumTotal:Number = 0; -// -// public function daybydayinit():void -// { -// for(var i:int = 0; i < numBays; i++) -// { -// var btnTemp:Button = new Button(); -// btnTemp.label = "Bay" + (i+1); -// btnTemp.id = "btn" + btnTemp.label; -// btnTemp.addEventListener(MouseEvent.CLICK,clicked); -// buttons.addChildAt(btnTemp,i+2); -// -// var txtTemp:Text = new Text(); -// txtTemp.setStyle("textAlign", "center"); -// txtTemp.setStyle("fontWeight","bold"); -// txtTemp.minWidth = 125; -// txtTemp.text = "Bay" + (i+1); -// labels.addChildAt(txtTemp,i+2); -// } -// } -// -// public function clicked(event:MouseEvent):void -// { -// try -// { -// deciding = 0; -// if(event != null) -// { -// var obj:Button = event.target as Button; -// deciding = int(obj.label.substring(3)); -// } -// } -// catch(err:Error) -// { -// // silent failure -// } -// } -// -// public function advance():void -// { -// var last:Object = dayByDayContent.getChildAt(dayByDayContent.numChildren - 1); -// if(last is OneDay) -// { -// cumTotal = (last as OneDay).presentTotal; -// } -// -// var newDay:OneDay = new OneDay(); -// newDay.numBays = numBays; -// newDay.previousTotal = cumTotal; -// newDay.initialize(); -// dayByDayContent.addChild(newDay.load(deciding)); -// -// deciding = 0; -// } - - ]]> - </mx:Script> - - - <!--<mx:DataGrid id="myGrid" - dataProvider="{initDG}" - variableRowHeight="true"> - <mx:columns> - <mx:DataGridColumn dataField="Day"/> - <mx:DataGridColumn dataField="Harbor" - itemRenderer="customComponents.questions.components.OneDecision"/> - <mx:DataGridColumn dataField="Bay1" - itemRenderer="customComponents.questions.components.OneDecision"/> - <mx:DataGridColumn dataField="Bay2" - itemRenderer="customComponents.questions.components.OneDecision"/> - <mx:DataGridColumn dataField="Bay3" - itemRenderer="customComponents.questions.components.OneDecision"/> - <mx:DataGridColumn dataField="Total" - itemRenderer="customComponents.questions.components.TotalDisplay"/> - </mx:columns> - </mx:DataGrid>--> - - <mx:Script> - <![CDATA[ - import customComponents.questions.CategoricalQuestionC; - import actionscript.StrategyDesignQuestion; - import actionscript.ForecastingFishQuestion; - import actionscript.ForecastingPeopleQuestion; - import actionscript.Question; - import actionscript.CategoricalQuestion; - import actionscript.QuestionGroup; - import actionscript.PsychometricQuestion; + import custom.questions.CategoricalQuestionC; + import actionscript.* + import actionscript.questions.*; import actionscript.Block; import mx.collections.ArrayCollection; public var block1:Block = new Block(); - /* [Bindable] - private var initDG:ArrayCollection = new ArrayCollection([ - {Day:1, Harbor:0, Bay1:1, Bay2:2, Bay3:3, Total:6}, - {Day:2, Harbor:0, Bay1:2, Bay2:3, Bay3:4, Total:9}]); */ -// public function initQ():void -// { -// test1.peopleFishing = new ArrayCollection([1,2,3,4,5]); -// test1.redraw(); -// } - // // InstructionPage Testing below here // @@ -176,13 +37,13 @@ block1.questionGroups = new ArrayCollection(); // create questions - var cat1:CategoricalQuestion = new CategoricalQuestion(); + var cat1:Categorical = new Categorical(); cat1.question = "categoricalQuestion"; cat1.topics = new ArrayCollection(); cat1.specifics = new ArrayCollection(); - var for1:ForecastingPeopleQuestion = new ForecastingPeopleQuestion(); - var for2:ForecastingFishQuestion = new ForecastingFishQuestion(); + var for1:ForecastingPeople = new ForecastingPeople(); + var for2:ForecastingFish = new ForecastingFish(); var psy1:PsychometricQuestion = new PsychometricQuestion(); psy1.question = "psychQuestion"; @@ -192,7 +53,7 @@ psy1.choices.addItem("Highly Neutral"); psy1.choices.addItem("Highly Disagree"); - var str1:StrategyDesignQuestion = new StrategyDesignQuestion(); + var str1:StrategyDesign = new StrategyDesign(); str1.question = "stratDesQuestion"; var txt1:Question = new Question(); Deleted: mentalmodels/trunk/flex/src/actionscript/Categorical.as =================================================================== --- mentalmodels/trunk/flex/src/actionscript/Categorical.as 2009-07-02 00:13:07 UTC (rev 169) +++ mentalmodels/trunk/flex/src/actionscript/Categorical.as 2009-07-05 19:50:39 UTC (rev 170) @@ -1,11 +0,0 @@ -package actionscript -{ - import mx.collections.ArrayCollection; - - [Bindable] - [RemoteClass(alias="edu.asu.commons.mme.entity.Categorical")] - public class Categorical extends Question - { - public var choices:Object; - } -} \ No newline at end of file Deleted: mentalmodels/trunk/flex/src/actionscript/CategoricalQuestion.as =================================================================== --- mentalmodels/trunk/flex/src/actionscript/CategoricalQuestion.as 2009-07-02 00:13:07 UTC (rev 169) +++ mentalmodels/trunk/flex/src/actionscript/CategoricalQuestion.as 2009-07-05 19:50:39 UTC (rev 170) @@ -1,14 +0,0 @@ -package actionscript -{ - import mx.collections.ArrayCollection; - - [Bindable] - [RemoteClass(alias="edu.asu.commons.mme.entity.CategoricalQuestion")] - public class CategoricalQuestion extends Question - { - public var choices:Object; - - public var topics:ArrayCollection; - public var specifics:ArrayCollection; - } -} \ No newline at end of file Deleted: mentalmodels/trunk/flex/src/actionscript/DataGridHandler.as =================================================================== --- mentalmodels/trunk/flex/src/actionscript/DataGridHandler.as 2009-07-02 00:13:07 UTC (rev 169) +++ mentalmodels/trunk/flex/src/actionscript/DataGridHandler.as 2009-07-05 19:50:39 UTC (rev 170) @@ -1,270 +0,0 @@ -// ActionScript file -package actionscript -{ - import mx.collections.ArrayCollection; - import mx.controls.Alert; - import mx.controls.DataGrid; - import mx.controls.dataGridClasses.DataGridColumn; - import mx.utils.StringUtil; - - - [Bindable] - public class DataGridHandler - { - public var enabled:Boolean = true; - private var _myDataGrid:DataGrid; - private var _myProvider:ArrayCollection; - - private var _errorMessage:String = ""; -public var debug:String = new String(); - private var finished:Boolean = false; - - private var _numFields:Number; - private var _numColumns:Number; - private var _minValue:Number; - private var _maxValue:Number; - private var _sumOfEachColumn:Number; - - - public function get grid():DataGrid - { return _myDataGrid; } - public function set grid(newValue:DataGrid):void - { _myDataGrid = newValue; } - public function get dataProvider():ArrayCollection - { return _myProvider; } - public function set dataProvider(newValue:ArrayCollection):void - { _myProvider = newValue; } - - public function get errorMessage():String - { return _errorMessage; } - public function set errorMessage(newValue:String):void - { _errorMessage = newValue; } - public function isFinished():Boolean - { - return finished; - } - - public function get numFields():Number - { return _numFields; } - public function set numFields(newValue:Number):void - { _numFields = newValue; } - public function get numColumns():Number - { return _numColumns; } - public function set numColumns(newValue:Number):void - { _numColumns = newValue; } - public function get minValue():Number - { return _minValue; } - public function set minValue(newValue:Number):void - { _minValue = newValue; } - public function get maxValue():Number - { return _maxValue; } - public function set maxValue(newValue:Number):void - { _maxValue = newValue; } - public function get sumOfEachColumn():Number - { return _sumOfEachColumn; } - public function set sumOfEachColumn(newValue:Number):void - { _sumOfEachColumn = newValue; } - - public function DataGridHandler(fields:Number, cols:Number, min:Number=0, max:Number=9999, colSum:Number=-1) - { - try{ - numFields = fields; - numColumns = cols; - minValue = min; - maxValue = max; - sumOfEachColumn = colSum; - - errorMessage = ""; - - createGrid(); - - grid.addEventListener("change", changed); -// dataProvider.addEventListener(CollectionEvent.COLLECTION_CHANGE, changed, false); -// dataProvider.addEventListener(CollectionEvent.COLLECTION_CHANGE, changed, true); - }catch(e:Error){ - Alert.show(e.message); - } - } - - public function getItem(field:Number, col:Number):Object - { - return dataProvider.getItemAt(field)["day"+(col+1)]; - } - public function setItem(field:Number, col:Number, value:Object):void - { - dataProvider.getItemAt(field)["day"+(col+1)] = value; - } - - private function createGrid():void - { - grid = new DataGrid(); - - dataProvider = new ArrayCollection(); - - //_myDataGrid.columns = new Array(); - var tempArray:Array = grid.columns; - var i:Number; - var temp:DataGridColumn; - - for(i=0; i<numColumns; i++) - { - temp = new DataGridColumn("day"+(i+1)); - - temp.headerText = ""+(i+1); - temp.dataField = "day"+(i+1); - temp.editable = enabled; - temp.draggable = false; - temp.sortable = false; - temp.resizable = false; - temp.width = 30; - - tempArray[i] = temp; - } - - grid.columns = tempArray; - - // add day1, day2, etc to each field - for(var j:Number=0; j<numFields; j++) - { - var field:Object = new Object(); - dataProvider.addItem(field); - } - - grid.dataProvider = dataProvider; - grid.height = (23)*(_numFields+1)+2; - grid.editable = enabled; -debug += ""; - } - - public function clone():DataGrid - { - var dgClone:DataGrid = new DataGrid(); - var myProviderClone:ArrayCollection = new ArrayCollection(); - dgClone.dataProvider = myProviderClone; - - var tempArray:Array = dgClone.columns; - var i:Number; - var temp:DataGridColumn; - - for(i=0; i<numColumns; i++) - { - temp = new DataGridColumn("day"+(i+1)); - - temp.headerText = ""+(i+1); - temp.dataField = "day"+(i+1); - temp.editable = true; - temp.draggable = false; - temp.sortable = false; - temp.resizable = false; - temp.width = 30; - - tempArray[i] = temp; - } - - dgClone.columns = tempArray; - - // fill data - for(var j:Number=0; j<_numFields; j++) - { - var field:Object = new Object(); - myProviderClone.addItem(field); - for(var k:Number=0; k<numColumns; k++) - { - myProviderClone.getItemAt(j)["day"+(k+1)] = getItem(j,k); - } - } - - dgClone.height = (23)*(_numFields+1)+2; - - return dgClone; - } - - public function changed(evt:Event=null):void - { - markNoError(); - errorMessage = ""; - - var error:Boolean = false; - var value:Object; - - // check the values of the current column - // and point out any errors (TextBox) - for(var col:Number=0; col < numColumns && !error; col++) - { - var colStr:String = "day"+(col+1); - var colSum:Number = 0; - for(var field:Number=0; field < _numFields && !error; field++) - { - value = getItem(field, col); - if(invalidNum(value)) - { - errorMessage = "Enter a value between "+minValue+" and "+maxValue+"."; - error = true; - markError(field,col); - } - else if(outOfBoundsNum(value)) - { - errorMessage = "Value must be between "+minValue+" and "+maxValue+"."; - error = true; - markError(field,col); - } - else - { - colSum += Number(value); - } - } - - // if no other errors yet, and there is a required sum for columns, - // then check actual sum against expected - if( !error && sumOfEachColumn != -1 && colSum != sumOfEachColumn ) - { - errorMessage = "Sum of all columns must be exactly "+sumOfEachColumn+"."; - error = true; - markError(-1,col); - debug += "{"+colSum+"}"; - } - else - { - debug += "["+colSum+"]"; - } - } - - finished = !error; - } - private function invalidNum(n:Object):Boolean - { - if(n == null) return true; - var pattern:RegExp = /^\d+$/; //the entire string must be consecutive digits - var s:String = StringUtil.trim(String(n)); - return !pattern.test(s) && !(n is Number); - } - private function outOfBoundsNum(n:Object):Boolean - { - return Number(n) < minValue || Number(n) > maxValue; - } - - private function markError(field:Number, col:Number):void - { - if(sumOfEachColumn == -1) return; - DataGridColumn(grid.columns[col]).setStyle("backgroundColor", "#ee82ee"); - grid.selectedIndex = field; - } - private function markNoError():void - { - for(var col:Number=0; col < numColumns; col++) - { - DataGridColumn(grid.columns[col]).setStyle("backgroundColor", "#FFFFFF"); - } - grid.selectedIndex = -1; - } - - public function deactivate():void - { - for(var col:Number=0; col < numColumns; col++) - { - DataGridColumn(grid.columns[col]).editable = false; - } - grid.selectedIndex = -1; - } - } -} \ No newline at end of file Deleted: mentalmodels/trunk/flex/src/actionscript/DayByDayDecisionsQuestion.as =================================================================== --- mentalmodels/trunk/flex/src/actionscript/DayByDayDecisionsQuestion.as 2009-07-02 00:13:07 UTC (rev 169) +++ mentalmodels/trunk/flex/src/actionscript/DayByDayDecisionsQuestion.as 2009-07-05 19:50:39 UTC (rev 170) @@ -1,11 +0,0 @@ -package actionscript -{ - import mx.collections.ArrayCollection; - - [Bindable] - [RemoteClass(alias="edu.asu.commons.mme.entity.DayByDayDecisionsQuestion")] - public class DayByDayDecisionsQuestion extends Question - { - - } -} \ No newline at end of file Deleted: mentalmodels/trunk/flex/src/actionscript/FishUtil.as =================================================================== --- mentalmodels/trunk/flex/src/actionscript/FishUtil.as 2009-07-02 00:13:07 UTC (rev 169) +++ mentalmodels/trunk/flex/src/actionscript/FishUtil.as 2009-07-05 19:50:39 UTC (rev 170) @@ -1,18 +0,0 @@ -package actionscript -{ - import mx.collections.ArrayCollection; - - [Bindable] - public class FishUtil - { - public function FishUtil() {} - - public static function fix(index:int, list:ArrayCollection):int - { - if( index < 0 ) return 0; - if( index >= list.length ) return list.length - 1; - return index; - } - } - -} \ No newline at end of file Deleted: mentalmodels/trunk/flex/src/actionscript/Forecasting.as =================================================================== --- mentalmodels/trunk/flex/src/actionscript/Forecasting.as 2009-07-02 00:13:07 UTC (rev 169) +++ mentalmodels/trunk/flex/src/actionscript/Forecasting.as 2009-07-05 19:50:39 UTC (rev 170) @@ -1,11 +0,0 @@ -package actionscript -{ - import mx.collections.ArrayCollection; - - [Bindable] - [RemoteClass(alias="edu.asu.commons.mme.entity.Forecasting")] - public class Forecasting extends Question - { - public var dayNo:int; - } -} \ No newline at end of file Deleted: mentalmodels/trunk/flex/src/actionscript/ForecastingFishQuestion.as =================================================================== --- mentalmodels/trunk/flex/src/actionscript/ForecastingFishQuestion.as 2009-07-02 00:13:07 UTC (rev 169) +++ mentalmodels/trunk/flex/src/actionscript/ForecastingFishQuestion.as 2009-07-05 19:50:39 UTC (rev 170) @@ -1,11 +0,0 @@ -package actionscript -{ - import mx.collections.ArrayCollection; - - [Bindable] - [RemoteClass(alias="edu.asu.commons.mme.entity.ForecastingFishQuestion")] - public class ForecastingFishQuestion extends Question - { - public var numDays:int; - } -} \ No newline at end of file Deleted: mentalmodels/trunk/flex/src/actionscript/ForecastingPeopleQuestion.as =================================================================== --- mentalmodels/trunk/flex/src/actionscript/ForecastingPeopleQuestion.as 2009-07-02 00:13:07 UTC (rev 169) +++ mentalmodels/trunk/flex/src/actionscript/ForecastingPeopleQuestion.as 2009-07-05 19:50:39 UTC (rev 170) @@ -1,11 +0,0 @@ -package actionscript -{ - import mx.collections.ArrayCollection; - - [Bindable] - [RemoteClass(alias="edu.asu.commons.mme.entity.ForecastingPeopleQuestion")] - public class ForecastingPeopleQuestion extends Question - { - public var numDays:int; - } -} \ No newline at end of file Deleted: mentalmodels/trunk/flex/src/actionscript/ForecastingQuestion.as =================================================================== --- mentalmodels/trunk/flex/src/actionscript/ForecastingQuestion.as 2009-07-02 00:13:07 UTC (rev 169) +++ mentalmodels/trunk/flex/src/actionscript/ForecastingQuestion.as 2009-07-05 19:50:39 UTC (rev 170) @@ -1,11 +0,0 @@ -package actionscript -{ - import mx.collections.ArrayCollection; - - [Bindable] - [RemoteClass(alias="edu.asu.commons.mme.entity.ForecastingQuestion")] - public class ForecastingQuestion extends Question - { - public var dayNo:int; - } -} \ No newline at end of file Modified: mentalmodels/trunk/flex/src/actionscript/PageDisplay.as =================================================================== --- mentalmodels/trunk/flex/src/actionscript/PageDisplay.as 2009-07-02 00:13:07 UTC (rev 169) +++ mentalmodels/trunk/flex/src/actionscript/PageDisplay.as 2009-07-05 19:50:39 UTC (rev 170) @@ -1,14 +1,14 @@ // ActionScript file package actionscript { - import customComponents.questions.CategoricalQuestionC; - import customComponents.questions.DayByDayDecisionsQuestionC; - import customComponents.questions.ForecastingFishQuestionC; - import customComponents.questions.ForecastingPeopleQuestionC; - import customComponents.questions.PsychometricQuestionC; - import customComponents.questions.StrategyDesignQuestionC; - import customComponents.questions.TextQuestionC; + import custom.questions.dayByDayDecisions.DayByDayDecisionsQuestionC; + import custom.questions.psychometric.PsychometricQuestionC; + import custom.questions.strategyDesign.StrategyDesignQuestionC; + import custom.questions.forecasting.*; + import custom.questions.*; + import actionscript.questions.* + import flash.display.DisplayObject; import mx.collections.ArrayCollection; @@ -71,34 +71,26 @@ txt.htmlText = tempQuestion.question; tempBox.addChild(txt); - if(tempQuestion is StrategyDesignQuestion) + if(tempQuestion is ForecastingPeople) { - var sdq:StrategyDesignQuestionC = new StrategyDesignQuestionC(); - sdq.loadFromQuestion(StrategyDesignQuestion(tempQuestion)); - sdq.id = "q"+question; - - tempBox.addChild(sdq); - } - else if(tempQuestion is ForecastingPeopleQuestion) - { var fpq:ForecastingPeopleQuestionC = new ForecastingPeopleQuestionC(); - fpq.loadFromQuestion(ForecastingPeopleQuestion(tempQuestion)); + fpq.loadFromQuestion(ForecastingPeople(tempQuestion)); fpq.id = "q"+question; tempBox.addChild(fpq); } - else if(tempQuestion is ForecastingFishQuestion) + else if(tempQuestion is ForecastingFish) { var ffq:ForecastingFishQuestionC = new ForecastingFishQuestionC(); - ffq.loadFromQuestion(ForecastingFishQuestion(tempQuestion)); + ffq.loadFromQuestion(ForecastingFish(tempQuestion)); ffq.id = "q"+question; tempBox.addChild(ffq); } - else if(tempQuestion is CategoricalQuestion) + else if(tempQuestion is Categorical) { var cq:CategoricalQuestionC = new CategoricalQuestionC(); - cq.loadFromQuestion(CategoricalQuestion(tempQuestion)); + cq.loadFromQuestion(Categorical(tempQuestion)); cq.id = "q"+question; tempBox.addChild(cq); @@ -111,21 +103,34 @@ tempBox.addChild(pq); } - else if(tempQuestion is DayByDayDecisionsQuestion) - { - var ddq:DayByDayDecisionsQuestionC = new DayByDayDecisionsQuestionC(); - ddq.loadFromQuestion(DayByDayDecisionsQuestion(tempQuestion)); - ddq.id = "q"+question; - - tempBox.addChild(ddq); - } else { - var tq:TextQuestionC = new TextQuestionC(); - tq.loadFromQuestion(Question(tempQuestion)); - tq.id = "q"+question; - - tempBox.addChild(tq); + if(tempQuestion != null && tempQuestion.type != null && + tempQuestion.type.toLowerCase() == "strategydesign") + { + var sdq:StrategyDesignQuestionC = new StrategyDesignQuestionC(); + sdq.loadFromQuestion(Question(tempQuestion)); + sdq.id = "q"+question; + + tempBox.addChild(sdq); + } + else if(tempQuestion != null && tempQuestion.type != null && + tempQuestion.type.toLowerCase() == "daybydaydecisions") + { + var ddq:DayByDayDecisionsQuestionC = new DayByDayDecisionsQuestionC(); + ddq.loadFromQuestion(Question(tempQuestion)); + ddq.id = "q"+question; + + tempBox.addChild(ddq); + } + else + { + var tq:TextQuestionC = new TextQuestionC(); + tq.loadFromQuestion(Question(tempQuestion)); + tq.id = "q"+question; + + tempBox.addChild(tq); + } } } var head:Label = new Label(); @@ -172,14 +177,20 @@ } public function nextPage():Boolean { - currentPageNumber = FishUtil.fix(currentPageNumber + 1, pages); + currentPageNumber = fix(currentPageNumber + 1, 0, pages.length-1); highestPageReached = Math.max(currentPageNumber, highestPageReached) return true; } public function prevPage():Boolean { - currentPageNumber = FishUtil.fix(currentPageNumber - 1, pages); + currentPageNumber = fix(currentPageNumber - 1, 0, pages.length-1); return true; } + private function fix(n:Number,min:Number,max:Number):Number + { + if(n < min) return min; + if(n > max) return max; + return n; + } } } \ No newline at end of file Deleted: mentalmodels/trunk/flex/src/actionscript/Psychometric.as =================================================================== --- mentalmodels/trunk/flex/src/actionscript/Psychometric.as 2009-07-02 00:13:07 UTC (rev 169) +++ mentalmodels/trunk/flex/src/actionscript/Psychometric.as 2009-07-05 19:50:39 UTC (rev 170) @@ -1,13 +0,0 @@ -package actionscript -{ - import mx.collections.ArrayCollection; - - [Bindable] - [RemoteClass(alias="edu.asu.commons.mme.entity.Psychometric")] - public class Psychometric extends Question - { - public var scale:String; - public var numberOfIntervals:int; - public var choices:ArrayCollection; - } -} \ No newline at end of file Deleted: mentalmodels/trunk/flex/src/actionscript/PsychometricQuestion.as =================================================================== --- mentalmodels/trunk/flex/src/actionscript/PsychometricQuestion.as 2009-07-02 00:13:07 UTC (rev 169) +++ mentalmodels/trunk/flex/src/actionscript/PsychometricQuestion.as 2009-07-05 19:50:39 UTC (rev 170) @@ -1,13 +0,0 @@ -package actionscript -{ - import mx.collections.ArrayCollection; - - [Bindable] - [RemoteClass(alias="edu.asu.commons.mme.entity.PsychometricQuestion")] - public class PsychometricQuestion extends Question - { - public var scale:String; - public var numberOfIntervals:int; - public var choices:ArrayCollection; - } -} \ No newline at end of file Deleted: mentalmodels/trunk/flex/src/actionscript/Question.as =================================================================== --- mentalmodels/trunk/flex/src/actionscript/Question.as 2009-07-02 00:13:07 UTC (rev 169) +++ mentalmodels/trunk/flex/src/actionscript/Question.as 2009-07-05 19:50:39 UTC (rev 170) @@ -1,16 +0,0 @@ -package actionscript -{ - import mx.collections.ArrayCollection; - - [Bindable] - [RemoteClass(alias="edu.asu.commons.mme.entity.Question")] - public class Question - { - public var id:Number; - public var question:String; - public var singleLocation:Boolean; - public var multiLocation:Boolean; - public var miscLocation:Boolean; - public var sequenceNo:int; - } -} \ No newline at end of file Deleted: mentalmodels/trunk/flex/src/actionscript/StrategyDesignQuestion.as =================================================================== --- mentalmodels/trunk/flex/src/actionscript/StrategyDesignQuestion.as 2009-07-02 00:13:07 UTC (rev 169) +++ mentalmodels/trunk/flex/src/actionscript/StrategyDesignQuestion.as 2009-07-05 19:50:39 UTC (rev 170) @@ -1,11 +0,0 @@ -package actionscript -{ - import mx.collections.ArrayCollection; - - [Bindable] - [RemoteClass(alias="edu.asu.commons.mme.entity.StrategyDesignQuestion")] - public class StrategyDesignQuestion extends Question - { - public var numDays:int; - } -} \ No newline at end of file Added: mentalmodels/trunk/flex/src/actionscript/questions/Categorical.as =================================================================== --- mentalmodels/trunk/flex/src/actionscript/questions/Categorical.as (rev 0) +++ mentalmodels/trunk/flex/src/actionscript/questions/Categorical.as 2009-07-05 19:50:39 UTC (rev 170) @@ -0,0 +1,14 @@ +package actionscript.questions +{ + import mx.collections.ArrayCollection; + + [Bindable] + [RemoteClass(alias="edu.asu.commons.mme.entity.CategoricalQuestion")] + public class Categorical extends Question + { + public var choices:Object; + + public var topics:ArrayCollection; + public var specifics:ArrayCollection; + } +} \ No newline at end of file Added: mentalmodels/trunk/flex/src/actionscript/questions/DayByDayDecisions.as =================================================================== --- mentalmodels/trunk/flex/src/actionscript/questions/DayByDayDecisions.as (rev 0) +++ mentalmodels/trunk/flex/src/actionscript/questions/DayByDayDecisions.as 2009-07-05 19:50:39 UTC (rev 170) @@ -0,0 +1,11 @@ +package actionscript.questions +{ + import mx.collections.ArrayCollection; + + [Bindable] + [RemoteClass(alias="edu.asu.commons.mme.entity.DayByDayDecisionsQuestion")] + public class DayByDayDecisions extends Question + { + + } +} \ No newline at end of file Added: mentalmodels/trunk/flex/src/actionscript/questions/ForecastingFish.as =================================================================== --- mentalmodels/trunk/flex/src/actionscript/questions/ForecastingFish.as (rev 0) +++ mentalmodels/trunk/flex/src/actionscript/questions/ForecastingFish.as 2009-07-05 19:50:39 UTC (rev 170) @@ -0,0 +1,11 @@ +package actionscript.questions +{ + import mx.collections.ArrayCollection; + + [Bindable] + [RemoteClass(alias="edu.asu.commons.mme.entity.ForecastingFishQuestion")] + public class ForecastingFish extends Question + { + public var numDays:int; + } +} \ No newline at end of file Added: mentalmodels/trunk/flex/src/actionscript/questions/ForecastingPeople.as =================================================================== --- mentalmodels/trunk/flex/src/actionscript/questions/ForecastingPeople.as (rev 0) +++ mentalmodels/trunk/flex/src/actionscript/questions/ForecastingPeople.as 2009-07-05 19:50:39 UTC (rev 170) @@ -0,0 +1,11 @@ +package actionscript.questions +{ + import mx.collections.ArrayCollection; + + [Bindable] + [RemoteClass(alias="edu.asu.commons.mme.entity.ForecastingPeopleQuestion")] + public class ForecastingPeople extends Question + { + public var numDays:int; + } +} \ No newline at end of file Added: mentalmodels/trunk/flex/src/actionscript/questions/PsychometricQuestion.as =================================================================== --- mentalmodels/trunk/flex/src/actionscript/questions/PsychometricQuestion.as (rev 0) +++ mentalmodels/trunk/flex/src/actionscript/questions/PsychometricQuestion.as 2009-07-05 19:50:39 UTC (rev 170) @@ -0,0 +1,13 @@ +package actionscript.questions +{ + import mx.collections.ArrayCollection; + + [Bindable] + [RemoteClass(alias="edu.asu.commons.mme.entity.PsychometricQuestion")] + public class PsychometricQuestion extends Question + { + public var scale:String; + public var numberOfIntervals:int; + public var choices:ArrayCollection; + } +} \ No newline at end of file Added: mentalmodels/trunk/flex/src/actionscript/questions/Question.as =================================================================== --- mentalmodels/trunk/flex/src/actionscript/questions/Question.as (rev 0) +++ mentalmodels/trunk/flex/src/actionscript/questions/Question.as 2009-07-05 19:50:39 UTC (rev 170) @@ -0,0 +1,17 @@ +package actionscript.questions +{ + import mx.collections.ArrayCollection; + + [Bindable] + [RemoteClass(alias="edu.asu.commons.mme.entity.Question")] + public class Question + { + public var id:Number; + public var question:String; + public var type:String; + public var singleLocation:Boolean; + public var multiLocation:Boolean; + public var miscLocation:Boolean; + public var sequenceNo:int; + } +} \ No newline at end of file Added: mentalmodels/trunk/flex/src/actionscript/questions/StrategyDesign.as =================================================================== --- mentalmodels/trunk/flex/src/actionscript/questions/StrategyDesign.as (rev 0) +++ mentalmodels/trunk/flex/src/actionscript/questions/StrategyDesign.as 2009-07-05 19:50:39 UTC (rev 170) @@ -0,0 +1,11 @@ +package actionscript.questions +{ + import mx.collections.ArrayCollection; + + [Bindable] + [RemoteClass(alias="edu.asu.commons.mme.entity.StrategyDesignQuestion")] + public class StrategyDesign extends Question + { + public var numDays:int; + } +} \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <kj...@us...> - 2009-07-02 01:22:15
|
Revision: 169 http://virtualcommons.svn.sourceforge.net/virtualcommons/?rev=169&view=rev Author: kjonas Date: 2009-07-02 00:13:07 +0000 (Thu, 02 Jul 2009) Log Message: ----------- Forecasting components now have update button, and all data must be entered day-by-day. DayByDayDecisionsQuestionC.mxml now has a component at the bottom to tally cumulative fishings and earnings for the player. Further components must be added when the program can talk to the server about other players. Modified Paths: -------------- mentalmodels/trunk/flex/src/customComponents/questions/DayByDayDecisionsQuestionC.mxml mentalmodels/trunk/flex/src/customComponents/questions/ForecastingFishQuestionC.mxml mentalmodels/trunk/flex/src/customComponents/questions/ForecastingPeopleQuestionC.mxml mentalmodels/trunk/flex/src/customComponents/questions/components/ForecastComponent.mxml mentalmodels/trunk/flex/src/customComponents/questions/components/OneDay.mxml Modified: mentalmodels/trunk/flex/src/customComponents/questions/DayByDayDecisionsQuestionC.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/questions/DayByDayDecisionsQuestionC.mxml 2009-06-30 02:02:32 UTC (rev 168) +++ mentalmodels/trunk/flex/src/customComponents/questions/DayByDayDecisionsQuestionC.mxml 2009-07-02 00:13:07 UTC (rev 169) @@ -3,13 +3,17 @@ <mx:String id="description"></mx:String> + <mx:Label id="txtPrompt" text="It's Day {currentDay}. Where will you go to fish, or will you stay in the harbor?"/> <mx:Label id="lblChosen" text="location chosen: {deciding}"/> <mx:HBox id="buttons"/> <mx:HBox id="labels" verticalAlign="middle"/> - <mx:VBox id="dayByDayContent" borderStyle="outset" minHeight="42" minWidth="655" verticalGap="0"/> + <mx:VBox id="dayByDayContent" borderStyle="outset" minWidth="655" verticalGap="0" + height="300" verticalScrollPolicy="on"/> + <mx:Label id="lblCumulative" text="So far, you have fished {getLbs(cumTotal)}, which is worth {getMoney(cumTotal,dollarPerLb)}."/> + <mx:Script> <![CDATA[ import mx.controls.Button; @@ -19,7 +23,9 @@ public var numBays:int = 3; [Bindable] public var deciding:int = 0; - public var cumTotal:Number = 0; + [Bindable] public var currentDay:int = 1; + [Bindable] public var cumTotal:Number = 0; + [Bindable] public var dollarPerLb:Number = 3.99; public function init():void { @@ -97,25 +103,32 @@ public function advance(event:MouseEvent=null):void { - try + if(currentDay == 30) { - var last:Object = dayByDayContent.getChildAt(dayByDayContent.numChildren - 1); - if(last is OneDay) - { - cumTotal = (last as OneDay).presentTotal; - } + return; } - catch(err:Error) - { - // silent failure - } var newDay:OneDay = new OneDay(); newDay.numBays = numBays; - newDay.previousTotal = cumTotal; newDay.initialize(); + newDay.day = currentDay++; + newDay.dollarPerLb = dollarPerLb; dayByDayContent.addChild(newDay.load(deciding)); + cumTotal += newDay.presentTotal; +// try +// { +// var last:Object = dayByDayContent.getChildAt(dayByDayContent.numChildren - 1); +// if(last is OneDay) +// { +// cumTotal += (last as OneDay).presentTotal; +// } +// } +// catch(err:Error) +// { +// // silent failure +// } + deciding = 0; } @@ -127,6 +140,32 @@ init(); } + public function getLbs(lbsFished:Number):String + { + lbsFished = Math.round(lbsFished * 10.0) / 10.0; + + var zeroDec:String = ""; + if(lbsFished as int == lbsFished) + { + zeroDec = ".0"; + } + var lbString:String = String(lbsFished).substr(0,5) + zeroDec + " lbs"; + return lbString; + } + public function getMoney(lbsFished:Number, dollarPerLb:Number):String + { + var moneyMade:Number = lbsFished * dollarPerLb; + moneyMade = Math.floor(moneyMade * 100.0) / 100.0; + + var zeroDec:String = ""; + if(moneyMade as int == moneyMade) + { + zeroDec = ".00"; + } + var moneyString:String = "$" + moneyMade + zeroDec; + return moneyString; + } + ]]> </mx:Script> Modified: mentalmodels/trunk/flex/src/customComponents/questions/ForecastingFishQuestionC.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/questions/ForecastingFishQuestionC.mxml 2009-06-30 02:02:32 UTC (rev 168) +++ mentalmodels/trunk/flex/src/customComponents/questions/ForecastingFishQuestionC.mxml 2009-07-02 00:13:07 UTC (rev 169) @@ -11,6 +11,14 @@ <components:ForecastComponent id="calculated" style="2" isEntry="false" numBays="{numBays}" numColumns="{numColumns}" initialize="false"/> + <mx:HBox> + <mx:Spacer width="160"/> + <mx:VBox> + <mx:Button id="btnUpdate" label="Update" click="fishEntry.updateNextColumn()"/> + <mx:Label id="lblError" text="{fishEntry.errorMessage}"/> + </mx:VBox> + </mx:HBox> + <mx:Script> <![CDATA[ import mx.controls.Alert; Modified: mentalmodels/trunk/flex/src/customComponents/questions/ForecastingPeopleQuestionC.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/questions/ForecastingPeopleQuestionC.mxml 2009-06-30 02:02:32 UTC (rev 168) +++ mentalmodels/trunk/flex/src/customComponents/questions/ForecastingPeopleQuestionC.mxml 2009-07-02 00:13:07 UTC (rev 169) @@ -6,6 +6,14 @@ <components:ForecastComponent id="peopleEntry" style="0" isEntry="true" numBays="{numBays}" numColumns="{numColumns}" initialize="false"/> + <mx:HBox> + <mx:Spacer width="160"/> + <mx:VBox> + <mx:Button id="btnUpdate" label="Update" click="peopleEntry.updateNextColumn()"/> + <mx:Label id="lblError" text="{peopleEntry.errorMessage}"/> + </mx:VBox> + </mx:HBox> + <mx:Script> <![CDATA[ import actionscript.ForecastingPeopleQuestion; Modified: mentalmodels/trunk/flex/src/customComponents/questions/components/ForecastComponent.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/questions/components/ForecastComponent.mxml 2009-06-30 02:02:32 UTC (rev 168) +++ mentalmodels/trunk/flex/src/customComponents/questions/components/ForecastComponent.mxml 2009-07-02 00:13:07 UTC (rev 169) @@ -20,6 +20,8 @@ [Bindable] public var updaterObject:Object = null; [Bindable] public var updater:Function = new Function(); + [Bindable] public var currentColumn:int = 0; + // Game Data [Bindable] public var style:int = 0; // 0:People, 1:Fish, 2:Calculated [Bindable] public var numBays:int = 3; @@ -144,12 +146,19 @@ newDataGridColumn.headerText = ""+(columnNumber+1); // 1, 2, 3, ... newDataGridColumn.dataField = "day"+(columnNumber+1); // day1, day2, day3, ... - newDataGridColumn.editable = (isEntry && ((style == 0) || (style == 1))); // 0:People, 1:Fish newDataGridColumn.draggable = false; newDataGridColumn.sortable = false; newDataGridColumn.resizable = false; newDataGridColumn.width = 30; + newDataGridColumn.editable = (isEntry + && ((style == 0) || (style == 1)) + && columnNumber == 0); // 0:People, 1:Fish + if(newDataGridColumn.editable) + { + newDataGridColumn.setStyle("backgroundColor", "#FFFF00"); + } + columnArray[columnNumber] = newDataGridColumn; } dataGrid.columns = columnArray; @@ -161,18 +170,11 @@ { dataProvider = new ArrayCollection(); + addLabel(" <b>Day</b>:",true); + var bayNumber:int = 0; if(style==0) // 0:People { - if(isEntry) - { - addLabel(" <b>Predict</b>:",true); - } - else - { - addLabel(" <b>You Predicted</b>:",true); - } - addLabel("# People in Harbor:"); addField(); @@ -184,15 +186,6 @@ } else if(style==1) { - if(isEntry) - { - addLabel(" <b>Predict</b>:",true); - } - else - { - addLabel(" <b>You Predicted</b>:",true); - } - for(bayNumber=0; bayNumber<numBays; bayNumber++) { addLabel("# Fish in Bay " + (bayNumber+1) + "(AM):"); @@ -201,8 +194,6 @@ } else if(style==2) { - addLabel(" <b>We calculate that:</b>",true); - addLabel("You will be in location #:"); addField(); addLabel("You will get USD:"); @@ -235,44 +226,46 @@ } } - private function errorCheck():void + private function errorCheck():Boolean { + if(currentColumn >= dataGrid.columnCount) + { + errorMessage = "Click 'Forward' to continue to the next page."; + return true; + } markNoError(); + errorMessage = "Click 'Update' to continue."; var error:Boolean = false; - for(var column:Number=0; column < numColumns && !error; column++) + var colSum:Number = 0; + for(var field:Number=0; field < numFields && !error; field++) { - var colSum:Number = 0; - for(var field:Number=0; field < numFields && !error; field++) + var value:Object = getItem(field, currentColumn); + if(!validNum(value)) { - var value:Object = getItem(field, column); - if(!validNum(value)) - { - errorMessage = "Enter a value between "+minValue+" and "+maxValue+"."; - error = true; - markError(field,column); - } - else if(!inBounds(value)) - { - errorMessage = "Value must be between "+minValue+" and "+maxValue+"."; - error = true; - markError(field,column); - } - else if(style == 0) // 0:People - { - colSum += Number(value); - } + errorMessage = "Enter a value between "+minValue+" and "+maxValue+"."; + error = true; } - - if(!error && style == 0 && colSum != groupSize-1) // 0:People + else if(!inBounds(value)) { - errorMessage = "Sum of all columns must be exactly "+(groupSize-1)+"."; + errorMessage = "Value must be between "+minValue+" and "+maxValue+"."; error = true; - markError(-1,column); } + else if(style == 0) // 0:People + { + colSum += Number(value); + } } + if(!error && style == 0 && colSum != groupSize-1) // 0:People + { + errorMessage = "Sum of all columns must be exactly "+(groupSize-1)+"."; + error = true; + } + + finished = !error; + return finished; } private function validNum(n:Object):Boolean @@ -286,20 +279,33 @@ { return Number(n) >= minValue && Number(n) <= maxValue; } - public function markError(field:Number, column:Number):void + private function markNoError():void { - if(! (isEntry && (style == 0 || style == 1)) ) return; // 0:People, 1:Fish - DataGridColumn(dataGrid.columns[column]).setStyle("backgroundColor", "#ee82ee"); - dataGrid.selectedIndex = field; +// for(var column:Number=0; column < numColumns; column++) +// { +// DataGridColumn(dataGrid.columns[column]).setStyle("backgroundColor", "#FFFFFF"); +// } + dataGrid.selectedIndex = -1; } - private function markNoError():void + + public function updateNextColumn():void { - for(var column:Number=0; column < numColumns; column++) + if(errorCheck()) { - DataGridColumn(dataGrid.columns[column]).setStyle("backgroundColor", "#FFFFFF"); + dataGrid.columns[currentColumn].setStyle("backgroundColor", "#FFFFFF"); + dataGrid.columns[currentColumn].editable = false; + currentColumn = fix(currentColumn+1,0,dataGrid.columnCount) as int; + if(currentColumn < dataGrid.columnCount) + { + dataGrid.columns[currentColumn].editable = true; + dataGrid.columns[currentColumn].setStyle("backgroundColor", "#FFFF00"); + } } - dataGrid.selectedIndex = -1; } + private function fix(n:Number,min:Number,max:Number):Number + { + return Math.max(Math.min(max,n),min); + } ]]> </mx:Script> Modified: mentalmodels/trunk/flex/src/customComponents/questions/components/OneDay.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/questions/components/OneDay.mxml 2009-06-30 02:02:32 UTC (rev 168) +++ mentalmodels/trunk/flex/src/customComponents/questions/components/OneDay.mxml 2009-07-02 00:13:07 UTC (rev 169) @@ -13,6 +13,7 @@ public var previousTotal:Number = 0; public var presentTotal:Number = 0; public var day:int = 1; + public var dollarPerLb:Number = 3.99; public function init():void { @@ -78,6 +79,7 @@ var totalObject:TotalDisplay = new TotalDisplay(); totalObject.lbsFished = presentTotal; + totalObject.dollarPerLb = dollarPerLb; totalObject.initialize(); addChild(totalObject.redraw()); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <kj...@us...> - 2009-06-30 03:22:14
|
Revision: 168 http://virtualcommons.svn.sourceforge.net/virtualcommons/?rev=168&view=rev Author: kjonas Date: 2009-06-30 02:02:32 +0000 (Tue, 30 Jun 2009) Log Message: ----------- DayByDayDecisionsQuestionC.mxml has been created and functions properly according to my tests. It just needs to be synchronized with the server, and it should be able to function. Random values are currently inserted; this needs to be updated when we connect to the server. Modified Paths: -------------- mentalmodels/trunk/flex/src/FisheryExperimentKalin.mxml mentalmodels/trunk/flex/src/_InstructionsTest.mxml mentalmodels/trunk/flex/src/actionscript/PageDisplay.as mentalmodels/trunk/flex/src/customComponents/questions/components/OneDecision.mxml mentalmodels/trunk/flex/src/customComponents/questions/components/TotalDisplay.mxml Added Paths: ----------- mentalmodels/trunk/flex/src/actionscript/DayByDayDecisionsQuestion.as mentalmodels/trunk/flex/src/customComponents/questions/DayByDayDecisionsQuestionC.mxml mentalmodels/trunk/flex/src/customComponents/questions/components/OneDay.mxml Modified: mentalmodels/trunk/flex/src/FisheryExperimentKalin.mxml =================================================================== --- mentalmodels/trunk/flex/src/FisheryExperimentKalin.mxml 2009-06-27 06:28:28 UTC (rev 167) +++ mentalmodels/trunk/flex/src/FisheryExperimentKalin.mxml 2009-06-30 02:02:32 UTC (rev 168) @@ -43,19 +43,12 @@ <mx:Consumer id="consumer" destination="DataPush" message="messageHandler(event.message)" /> <mx:Script> <![CDATA[ - import actionscript.Question; - import actionscript.StrategyDesignQuestion; - import actionscript.PsychometricQuestion; - import actionscript.ForecastingFishQuestion; - import actionscript.ForecastingPeopleQuestion; - import actionscript.CategoricalQuestion; - import actionscript.QuestionGroup; + import actionscript.*; + import customComponents.*; + import mx.controls.Label; + import mx.controls.Alert; import mx.collections.ArrayCollection; - import actionscript.Block; import flash.sampler.getInvocationCount; - import mx.controls.Label; - import customComponents.*; - import mx.controls.Alert; import mx.rpc.events.ResultEvent; import mx.rpc.events.FaultEvent; import mx.messaging.messages.IMessage; @@ -260,12 +253,14 @@ var block1:Block = new Block(); try{ var questionGroups1:ArrayCollection = new ArrayCollection(); + var qg0:QuestionGroup = new QuestionGroup(); var qg1:QuestionGroup = new QuestionGroup(); var qg2:QuestionGroup = new QuestionGroup(); var qg3:QuestionGroup = new QuestionGroup(); var qg4:QuestionGroup = new QuestionGroup(); var qg5:QuestionGroup = new QuestionGroup(); var qg6:QuestionGroup = new QuestionGroup(); + qg0.questions = new ArrayCollection(); qg1.questions = new ArrayCollection(); qg2.questions = new ArrayCollection(); qg3.questions = new ArrayCollection(); @@ -275,6 +270,9 @@ block1.questionGroups = new ArrayCollection(); // create questions + var ddq1:DayByDayDecisionsQuestion = new DayByDayDecisionsQuestion(); + ddq1.question = "categoricalQuestion"; + var cat1:CategoricalQuestion = new CategoricalQuestion(); cat1.question = "categoricalQuestion"; cat1.topics = new ArrayCollection(); @@ -298,15 +296,18 @@ txt1.question = "textQuestion"; // insert questions into groups + qg0.questions.addItem(ddq1); qg1.questions.addItem(cat1); - qg1.description = "testDesc"; - qg1.header = "testHead"; qg2.questions.addItem(for1); qg3.questions.addItem(for2); qg4.questions.addItem(psy1); qg5.questions.addItem(str1); qg6.questions.addItem(txt1); + qg1.description = "testDesc"; + qg1.header = "testHead"; + + block1.questionGroups.addItem(qg0); block1.questionGroups.addItem(qg1); block1.questionGroups.addItem(qg2); block1.questionGroups.addItem(qg3); Modified: mentalmodels/trunk/flex/src/_InstructionsTest.mxml =================================================================== --- mentalmodels/trunk/flex/src/_InstructionsTest.mxml 2009-06-27 06:28:28 UTC (rev 167) +++ mentalmodels/trunk/flex/src/_InstructionsTest.mxml 2009-06-30 02:02:32 UTC (rev 168) @@ -1,11 +1,115 @@ <?xml version="1.0" encoding="utf-8"?> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:comp="customComponents.*" xmlns:as="actionscript.*" - layout="vertical" xmlns:compQ="customComponents.questions.components.*"> + layout="vertical" xmlns:compQ="customComponents.questions.components.*" xmlns:questions="customComponents.questions.*" + backgroundGradientColors="[#FFFFFF, #B0B0FF]"> - <compQ:OneDecision id="test1" lbsFished="12" initialize="initQ()"/> - <compQ:TotalDisplay id="test2" lbsFished="12" initialize="test2.redraw()"/> + <questions:DayByDayDecisionsQuestionC/> - <mx:DataGrid id="myGrid" + <!--<mx:HBox> + <compQ:OneDecision id="test1" lbsFished="12" initialize="initQ()"/> + <compQ:OneDecision id="test2" lbsFished="12" active="false"/> + <compQ:OneDecision id="test3" lbsFished="12" active="false"/> + <compQ:TotalDisplay id="testTotal" lbsFished="12" initialize="testTotal.redraw()"/> + </mx:HBox>--> + + <!--<mx:VBox id="dayByDayContent" initialize="daybydayinit()"> + + <mx:HBox id="buttons"> + <mx:Label id="lblChosen" text="location chosen: {deciding}"/> + <mx:Button id="btnHarbor" label="Harbor" click="{deciding = 0; clicked(null);}"/> + <mx:Button id="btnAdvance" label="Advance" click="advance()" fillColors="[#B0B0FF,#FFFFFF]"/> + </mx:HBox> + + <mx:HBox id="labels" verticalAlign="middle"> + <mx:Text textAlign="center" fontWeight="bold" minWidth="50" text="Day"/> + <mx:Text textAlign="center" fontWeight="bold" minWidth="125" text="Harbor"/> + <mx:Text textAlign="center" fontWeight="bold" minWidth="60" htmlText="Cumulative<br>Total"/> + </mx:HBox> + + <compQ:OneDay id="testDay" numBays="3"> + <compQ:decisions> + <mx:ArrayCollection id="decisions"> + <compQ:OneDecision active="false"/> + <compQ:OneDecision lbsFished="{Math.round(Math.random()*50)/10.0}"/> + <compQ:OneDecision active="false"/> + <compQ:OneDecision active="false"/> + </mx:ArrayCollection> + </compQ:decisions> + </compQ:OneDay> + + </mx:VBox>--> + + <mx:Script> + <![CDATA[ + import customComponents.questions.components.OneDay; + import mx.controls.Alert; + +// <mx:Text textAlign="center" fontWeight="bold" minWidth="125" text="Bay1"/> +// <mx:Text textAlign="center" fontWeight="bold" minWidth="125" text="Bay2"/> +// <mx:Text textAlign="center" fontWeight="bold" minWidth="125" text="Bay3"/> + +// public var numBays:int = 3; +// [Bindable] public var deciding:int = 0; +// public var cumTotal:Number = 0; +// +// public function daybydayinit():void +// { +// for(var i:int = 0; i < numBays; i++) +// { +// var btnTemp:Button = new Button(); +// btnTemp.label = "Bay" + (i+1); +// btnTemp.id = "btn" + btnTemp.label; +// btnTemp.addEventListener(MouseEvent.CLICK,clicked); +// buttons.addChildAt(btnTemp,i+2); +// +// var txtTemp:Text = new Text(); +// txtTemp.setStyle("textAlign", "center"); +// txtTemp.setStyle("fontWeight","bold"); +// txtTemp.minWidth = 125; +// txtTemp.text = "Bay" + (i+1); +// labels.addChildAt(txtTemp,i+2); +// } +// } +// +// public function clicked(event:MouseEvent):void +// { +// try +// { +// deciding = 0; +// if(event != null) +// { +// var obj:Button = event.target as Button; +// deciding = int(obj.label.substring(3)); +// } +// } +// catch(err:Error) +// { +// // silent failure +// } +// } +// +// public function advance():void +// { +// var last:Object = dayByDayContent.getChildAt(dayByDayContent.numChildren - 1); +// if(last is OneDay) +// { +// cumTotal = (last as OneDay).presentTotal; +// } +// +// var newDay:OneDay = new OneDay(); +// newDay.numBays = numBays; +// newDay.previousTotal = cumTotal; +// newDay.initialize(); +// dayByDayContent.addChild(newDay.load(deciding)); +// +// deciding = 0; +// } + + ]]> + </mx:Script> + + + <!--<mx:DataGrid id="myGrid" dataProvider="{initDG}" variableRowHeight="true"> <mx:columns> @@ -21,7 +125,7 @@ <mx:DataGridColumn dataField="Total" itemRenderer="customComponents.questions.components.TotalDisplay"/> </mx:columns> - </mx:DataGrid> + </mx:DataGrid>--> <mx:Script> <![CDATA[ @@ -38,16 +142,21 @@ public var block1:Block = new Block(); - [Bindable] + /* [Bindable] private var initDG:ArrayCollection = new ArrayCollection([ - {1:'Pavement', 2:'Slanted and Enchanted'}, - {1:'Pavement', 2:'Brighten the Corners'}]); - public function initQ():void - { - test1.peopleFishing = new ArrayCollection([1,2,3]); - test1.redraw(); - } + {Day:1, Harbor:0, Bay1:1, Bay2:2, Bay3:3, Total:6}, + {Day:2, Harbor:0, Bay1:2, Bay2:3, Bay3:4, Total:9}]); */ +// public function initQ():void +// { +// test1.peopleFishing = new ArrayCollection([1,2,3,4,5]); +// test1.redraw(); +// } + + // + // InstructionPage Testing below here + // + public function fillBlock():void { try{ @@ -116,14 +225,6 @@ ]]> </mx:Script> - <!--<mx:ArrayCollection id="labs"> - <mx:String>testLeft</mx:String> - <mx:String>testRight</mx:String> - <mx:String>testRight</mx:String> - </mx:ArrayCollection> - <comp:PsychometricQuestionC id="psych" labels="{labs}" initialize="true"/> - <comp:CategoricalQuestionC/>--> - <mx:HBox> <mx:Button id="back" click="iPage.back()" label="back"/> <mx:Button id="forward" click="iPage.forward()" label="forward"/> Added: mentalmodels/trunk/flex/src/actionscript/DayByDayDecisionsQuestion.as =================================================================== --- mentalmodels/trunk/flex/src/actionscript/DayByDayDecisionsQuestion.as (rev 0) +++ mentalmodels/trunk/flex/src/actionscript/DayByDayDecisionsQuestion.as 2009-06-30 02:02:32 UTC (rev 168) @@ -0,0 +1,11 @@ +package actionscript +{ + import mx.collections.ArrayCollection; + + [Bindable] + [RemoteClass(alias="edu.asu.commons.mme.entity.DayByDayDecisionsQuestion")] + public class DayByDayDecisionsQuestion extends Question + { + + } +} \ No newline at end of file Modified: mentalmodels/trunk/flex/src/actionscript/PageDisplay.as =================================================================== --- mentalmodels/trunk/flex/src/actionscript/PageDisplay.as 2009-06-27 06:28:28 UTC (rev 167) +++ mentalmodels/trunk/flex/src/actionscript/PageDisplay.as 2009-06-30 02:02:32 UTC (rev 168) @@ -2,6 +2,7 @@ package actionscript { import customComponents.questions.CategoricalQuestionC; + import customComponents.questions.DayByDayDecisionsQuestionC; import customComponents.questions.ForecastingFishQuestionC; import customComponents.questions.ForecastingPeopleQuestionC; import customComponents.questions.PsychometricQuestionC; @@ -12,7 +13,6 @@ import mx.collections.ArrayCollection; import mx.containers.VBox; - import mx.controls.Alert; import mx.controls.Label; import mx.controls.Text; @@ -111,6 +111,14 @@ tempBox.addChild(pq); } + else if(tempQuestion is DayByDayDecisionsQuestion) + { + var ddq:DayByDayDecisionsQuestionC = new DayByDayDecisionsQuestionC(); + ddq.loadFromQuestion(DayByDayDecisionsQuestion(tempQuestion)); + ddq.id = "q"+question; + + tempBox.addChild(ddq); + } else { var tq:TextQuestionC = new TextQuestionC(); Added: mentalmodels/trunk/flex/src/customComponents/questions/DayByDayDecisionsQuestionC.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/questions/DayByDayDecisionsQuestionC.mxml (rev 0) +++ mentalmodels/trunk/flex/src/customComponents/questions/DayByDayDecisionsQuestionC.mxml 2009-06-30 02:02:32 UTC (rev 168) @@ -0,0 +1,133 @@ +<?xml version="1.0" encoding="utf-8"?> +<mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml" initialize="init()"> + + <mx:String id="description"></mx:String> + + <mx:Label id="lblChosen" text="location chosen: {deciding}"/> + + <mx:HBox id="buttons"/> + <mx:HBox id="labels" verticalAlign="middle"/> + + <mx:VBox id="dayByDayContent" borderStyle="outset" minHeight="42" minWidth="655" verticalGap="0"/> + + <mx:Script> + <![CDATA[ + import mx.controls.Button; + import mx.controls.Text; + import actionscript.Question; + import customComponents.questions.components.OneDay; + + public var numBays:int = 3; + [Bindable] public var deciding:int = 0; + public var cumTotal:Number = 0; + + public function init():void + { + buttons.removeAllChildren(); + labels.removeAllChildren(); + + var btnTemp:Button = new Button(); + btnTemp.label = "Harbor"; + btnTemp.id = "btnHarbor"; + btnTemp.addEventListener(MouseEvent.CLICK,clicked); + buttons.addChild(btnTemp); + + var txtTemp:Text = new Text(); + txtTemp = stylize(txtTemp); + txtTemp.minWidth = 50; + txtTemp.text = "Day"; + labels.addChild(txtTemp); + + txtTemp = new Text(); + txtTemp = stylize(txtTemp); + txtTemp.text = "Harbor"; + labels.addChild(txtTemp); + + for(var i:int = 0; i < numBays; i++) + { + btnTemp = new Button(); + btnTemp.label = "Bay" + (i+1); + btnTemp.id = "btn" + btnTemp.label; + btnTemp.addEventListener(MouseEvent.CLICK,clicked); + buttons.addChild(btnTemp); + + txtTemp = new Text(); + txtTemp = stylize(txtTemp); + txtTemp.text = "Bay" + (i+1); + labels.addChild(txtTemp); + } + + btnTemp = new Button(); + btnTemp.label = "Advance"; + btnTemp.id = "btnAdvance"; + btnTemp.addEventListener(MouseEvent.CLICK,advance); + buttons.addChild(btnTemp); + + txtTemp = new Text(); + txtTemp = stylize(txtTemp); + txtTemp.htmlText = "Cumulative<br>Total"; + txtTemp.minWidth = 60; + labels.addChild(txtTemp); + } + private function stylize(txtTemp:Text):Text + { + txtTemp.setStyle("textAlign", "center"); + txtTemp.setStyle("fontWeight","bold"); + txtTemp.minWidth = 125; + return txtTemp; + } + + public function clicked(event:MouseEvent):void + { + try + { + deciding = 0; + if(event != null && (event.target as Button).label != "Harbor") + { + var obj:Button = event.target as Button; + deciding = int(obj.label.substring(3)); + } + } + catch(err:Error) + { + // silent failure + deciding = 0; + } + } + + public function advance(event:MouseEvent=null):void + { + try + { + var last:Object = dayByDayContent.getChildAt(dayByDayContent.numChildren - 1); + if(last is OneDay) + { + cumTotal = (last as OneDay).presentTotal; + } + } + catch(err:Error) + { + // silent failure + } + + var newDay:OneDay = new OneDay(); + newDay.numBays = numBays; + newDay.previousTotal = cumTotal; + newDay.initialize(); + dayByDayContent.addChild(newDay.load(deciding)); + + deciding = 0; + } + + public function loadFromQuestion(question:Question):void + { + description = question.question; + + initialize(); + init(); + } + + ]]> + </mx:Script> + +</mx:VBox> Added: mentalmodels/trunk/flex/src/customComponents/questions/components/OneDay.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/questions/components/OneDay.mxml (rev 0) +++ mentalmodels/trunk/flex/src/customComponents/questions/components/OneDay.mxml 2009-06-30 02:02:32 UTC (rev 168) @@ -0,0 +1,123 @@ +<?xml version="1.0" encoding="utf-8"?> +<mx:HBox xmlns:mx="http://www.adobe.com/2006/mxml" initialize="init()" borderStyle="inset"> + + <mx:Script> + <![CDATA[ + import mx.controls.Text; + import mx.controls.Label; + import mx.collections.ArrayCollection; + + [Bindable] public var numBays:int = 3; + [Bindable] public var decisions:ArrayCollection; + + public var previousTotal:Number = 0; + public var presentTotal:Number = 0; + public var day:int = 1; + + public function init():void + { + if(decisions == null) + { + drawNull(); + } + else if(decisions.length < numBays+1) + { + drawPartial(); + } + else + { + drawFull(); + } + } + + public function drawNull():void + { + decisions = new ArrayCollection(); + + var temp:OneDecision = new OneDecision(); + temp.lbsFished = 0.0; + temp.initialize(); + temp.redraw(); + decisions.addItem(temp); + + drawPartial(); + } + + public function drawPartial():void + { + var temp:OneDecision; + for(var i:int = decisions.length; i < numBays+1; i++) + { + temp = new OneDecision(); + temp.active = false; + temp.initialize(); + temp.redraw(); + decisions.addItem(temp); + } + + drawFull(); + } + + public function drawFull():void + { + removeAllChildren(); + presentTotal = previousTotal; + + var dayText:Text = new Text(); + dayText.text = day + ""; + dayText.setStyle("textAlign","center"); + dayText.minWidth = 50; + addChild(dayText); + + for(var i:int = 0; i < numBays+1 && i < decisions.length; i++) + { + var temp:OneDecision = (decisions.getItemAt(i) as OneDecision); + presentTotal += temp.lbsFished; + addChild(temp.redraw()); + } + + var totalObject:TotalDisplay = new TotalDisplay(); + totalObject.lbsFished = presentTotal; + totalObject.initialize(); + addChild(totalObject.redraw()); + } + + public function load(locationChosen:int):OneDay + { + if(decisions == null || decisions.length != 0) + { + decisions = new ArrayCollection(); + } + + if(locationChosen == 0) + { + var temp:OneDecision = new OneDecision(); + temp.lbsFished = 0; + temp.initialize(); + decisions.addItem(temp); + } + else + { + for(var i:int = 0; i < locationChosen && i < numBays; i++) + { + var tempInactive:OneDecision = new OneDecision(); + tempInactive.active = false; + tempInactive.initialize(); + decisions.addItem(tempInactive); + } + + var tempActive:OneDecision = new OneDecision(); + tempActive.lbsFished = Math.round(Math.random()*50)/10.0; + tempActive.initialize(); + decisions.addItem(tempActive); + } + + drawPartial(); + + return this; + } + + ]]> + </mx:Script> + +</mx:HBox> Modified: mentalmodels/trunk/flex/src/customComponents/questions/components/OneDecision.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/questions/components/OneDecision.mxml 2009-06-27 06:28:28 UTC (rev 167) +++ mentalmodels/trunk/flex/src/customComponents/questions/components/OneDecision.mxml 2009-06-30 02:02:32 UTC (rev 168) @@ -1,10 +1,11 @@ <?xml version="1.0" encoding="utf-8"?> -<mx:Text xmlns:mx="http://www.adobe.com/2006/mxml" initialize="redraw()"> +<mx:Text xmlns:mx="http://www.adobe.com/2006/mxml" initialize="redraw()" textAlign="center" minWidth="125" minHeight="38"> <mx:Script> <![CDATA[ import mx.collections.ArrayCollection; + [Bindable] public var active:Boolean = true; [Bindable] public var lbsFished:Number = 0.0; [Bindable] public var peopleFishing:ArrayCollection = null; @@ -42,9 +43,18 @@ return listStr; } - public function redraw():void + public function redraw():OneDecision { - htmlText = "Fished: "+getLbs()+"<br>People: "+findPeople(); + if(active) + { + htmlText = "Fished: "+getLbs()+"<br>People: "+findPeople(); + } + else + { + htmlText = "--"; + } + + return this; } ]]> Modified: mentalmodels/trunk/flex/src/customComponents/questions/components/TotalDisplay.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/questions/components/TotalDisplay.mxml 2009-06-27 06:28:28 UTC (rev 167) +++ mentalmodels/trunk/flex/src/customComponents/questions/components/TotalDisplay.mxml 2009-06-30 02:02:32 UTC (rev 168) @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="utf-8"?> -<mx:Text xmlns:mx="http://www.adobe.com/2006/mxml" initialize="redraw()"> +<mx:Text xmlns:mx="http://www.adobe.com/2006/mxml" initialize="redraw()" textAlign="center" minWidth="60" minHeight="38"> <mx:Script> <![CDATA[ @@ -9,6 +9,8 @@ public function getLbs():String { + lbsFished = Math.round(lbsFished * 10.0) / 10.0; + var zeroDec:String = ""; if(lbsFished as int == lbsFished) { @@ -21,18 +23,21 @@ public function getMoney():String { var moneyMade:Number = lbsFished * dollarPerLb; + moneyMade = Math.floor(moneyMade * 100.0) / 100.0; + var zeroDec:String = ""; if(moneyMade as int == moneyMade) { - zeroDec = ".0"; + zeroDec = ".00"; } - var moneyString:String = "$" + String(moneyMade).substr(0,5) + zeroDec; + var moneyString:String = "$" + moneyMade + zeroDec; return moneyString; } - public function redraw():void + public function redraw():TotalDisplay { htmlText = getLbs()+"<br>"+getMoney(); + return this; } ]]> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <kj...@us...> - 2009-06-27 06:28:31
|
Revision: 167 http://virtualcommons.svn.sourceforge.net/virtualcommons/?rev=167&view=rev Author: kjonas Date: 2009-06-27 06:28:28 +0000 (Sat, 27 Jun 2009) Log Message: ----------- OneDecision.mxml and TotalDisplay.mxml created for use in day-by-day decision component. These could be used as an Item Renderer, but it seems that it would be rather difficult, as the renderer would appear to need customization that is not possible with a single component? Modified Paths: -------------- mentalmodels/trunk/flex/src/FisheryExperimentKalin.mxml mentalmodels/trunk/flex/src/_InstructionsTest.mxml mentalmodels/trunk/flex/src/customComponents/InstructionPage.mxml mentalmodels/trunk/flex/src/customComponents/SocioDemographicPage.mxml mentalmodels/trunk/flex/src/customComponents/questions/ForecastingFishQuestionC.mxml Added Paths: ----------- mentalmodels/trunk/flex/src/customComponents/questions/components/OneDecision.mxml mentalmodels/trunk/flex/src/customComponents/questions/components/TotalDisplay.mxml Modified: mentalmodels/trunk/flex/src/FisheryExperimentKalin.mxml =================================================================== --- mentalmodels/trunk/flex/src/FisheryExperimentKalin.mxml 2009-06-24 09:28:09 UTC (rev 166) +++ mentalmodels/trunk/flex/src/FisheryExperimentKalin.mxml 2009-06-27 06:28:28 UTC (rev 167) @@ -7,7 +7,9 @@ <mx:states> <mx:State name="socioDemographic"> <mx:AddChild relativeTo="{content}"> - <comp:SocioDemographicPage id="socioDemographic" x="265" y="100"/> + <comp:SocioDemographicPage id="socioDemographic" + x="{(content.width-socioDemographic.width)/2}" + y="{(content.height-socioDemographic.height)/2}"/> </mx:AddChild> <mx:SetProperty target="{content}" name="x"/> <mx:SetStyle target="{content}" name="horizontalCenter" value="0"/> @@ -29,12 +31,12 @@ <!-- <mx:Canvas id="content" x="5" y="5" width="750" height="470"/> --> - <mx:Canvas id="content" x="5" y="5" width="1000" height="470"/> + <mx:Canvas id="content" x="0" y="0" width="100%" height="100%"/> <mx:Canvas id="expiredContent" x="-1" y="-1" width="1" height="1" visible="false"/> - <mx:Button id="btnBack" label="« Back" click="back()" left="8" bottom="8"/> + <mx:Button id="btnBack" label="« Back" click="back()" left="8" bottom="8" enabled="false"/> <mx:Button id="btnAccept" label="Accept" click="accept()" left="{(width-btnAccept.width)/2}" bottom="10"/> - <mx:Button id="btnForward" label="Forward »" click="forward()" right="8" bottom="8"/> + <mx:Button id="btnForward" label="Forward »" click="forward()" right="8" bottom="8" enabled="false"/> <mx:RemoteObject id="ss" destination="studentService" fault="faultHandler(event)" result="resultHandler(event)"/> <mx:Producer id="producer" destination="DataPush" acknowledge="ack(event)"/> @@ -240,10 +242,16 @@ //consumer.subscribe(); returnValue = true; } + else + { + Alert.show("Cannot advance.\nTry looking at every page."); + } } catch(err:Error){} } + btnBack.enabled = btnForward.enabled = currentState == "instructions"; + return returnValue; } Modified: mentalmodels/trunk/flex/src/_InstructionsTest.mxml =================================================================== --- mentalmodels/trunk/flex/src/_InstructionsTest.mxml 2009-06-24 09:28:09 UTC (rev 166) +++ mentalmodels/trunk/flex/src/_InstructionsTest.mxml 2009-06-27 06:28:28 UTC (rev 167) @@ -1,7 +1,28 @@ <?xml version="1.0" encoding="utf-8"?> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:comp="customComponents.*" xmlns:as="actionscript.*" - layout="vertical"> - + layout="vertical" xmlns:compQ="customComponents.questions.components.*"> + + <compQ:OneDecision id="test1" lbsFished="12" initialize="initQ()"/> + <compQ:TotalDisplay id="test2" lbsFished="12" initialize="test2.redraw()"/> + + <mx:DataGrid id="myGrid" + dataProvider="{initDG}" + variableRowHeight="true"> + <mx:columns> + <mx:DataGridColumn dataField="Day"/> + <mx:DataGridColumn dataField="Harbor" + itemRenderer="customComponents.questions.components.OneDecision"/> + <mx:DataGridColumn dataField="Bay1" + itemRenderer="customComponents.questions.components.OneDecision"/> + <mx:DataGridColumn dataField="Bay2" + itemRenderer="customComponents.questions.components.OneDecision"/> + <mx:DataGridColumn dataField="Bay3" + itemRenderer="customComponents.questions.components.OneDecision"/> + <mx:DataGridColumn dataField="Total" + itemRenderer="customComponents.questions.components.TotalDisplay"/> + </mx:columns> + </mx:DataGrid> + <mx:Script> <![CDATA[ import customComponents.questions.CategoricalQuestionC; @@ -17,6 +38,16 @@ public var block1:Block = new Block(); + [Bindable] + private var initDG:ArrayCollection = new ArrayCollection([ + {1:'Pavement', 2:'Slanted and Enchanted'}, + {1:'Pavement', 2:'Brighten the Corners'}]); + public function initQ():void + { + test1.peopleFishing = new ArrayCollection([1,2,3]); + test1.redraw(); + } + public function fillBlock():void { try{ Modified: mentalmodels/trunk/flex/src/customComponents/InstructionPage.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/InstructionPage.mxml 2009-06-24 09:28:09 UTC (rev 166) +++ mentalmodels/trunk/flex/src/customComponents/InstructionPage.mxml 2009-06-27 06:28:28 UTC (rev 167) @@ -3,6 +3,8 @@ <mx:Script> <![CDATA[ + import customComponents.questions.ForecastingFishQuestionC; + import customComponents.questions.ForecastingPeopleQuestionC; import mx.controls.Alert; import actionscript.Block; import actionscript.PageDisplay; @@ -13,6 +15,8 @@ [Bindable] public var numPages:int = 1; [Bindable] public var currPage:int = 0; + public var savedForecastPeople:ArrayCollection = null; + public function init(newBlock:Block):void { block = newBlock; @@ -50,31 +54,54 @@ public function back():Boolean { + preTurn(); var pageSuccess:Boolean = pageDisplay.prevPage(); if(pageSuccess) { - currPage = pageDisplay.currentPageNumber; - currPageLabel.text = "Page " + (currPage+1) + " / " + numPages; - - content.removeAllChildren(); - content.addChild(pageDisplay.currentPage); + postTurn(); } return pageSuccess; } public function forward():Boolean { + preTurn(); var pageSuccess:Boolean = pageDisplay.nextPage(); if(pageSuccess) { - currPage = pageDisplay.currentPageNumber; - currPageLabel.text = "Page " + (currPage+1) + " / " + numPages; - - content.removeAllChildren(); - content.addChild(pageDisplay.currentPage); + postTurn(); } return pageSuccess; } + private function preTurn():void + { + var currPageArray:Array = (pageDisplay.currentPage as VBox).getChildren(); + for(var i:int = 0; i < currPageArray.length; i++) + { + if(currPageArray[i] is ForecastingPeopleQuestionC) + { + savedForecastPeople = (currPageArray[i] as ForecastingPeopleQuestionC).save(); + } + } + } + private function postTurn():void + { + currPage = pageDisplay.currentPageNumber; + currPageLabel.text = "Page " + (currPage+1) + " / " + numPages; + + content.removeAllChildren(); + content.addChild(pageDisplay.currentPage); + + var currPageArray:Array = (pageDisplay.currentPage as VBox).getChildren(); + for(var i:int = 0; i < currPageArray.length; i++) + { + if(currPageArray[i] is ForecastingFishQuestionC) + { + (currPageArray[i] as ForecastingFishQuestionC).loadPeopleOnly(savedForecastPeople); + } + } + + } public function accept():Boolean { Modified: mentalmodels/trunk/flex/src/customComponents/SocioDemographicPage.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/SocioDemographicPage.mxml 2009-06-24 09:28:09 UTC (rev 166) +++ mentalmodels/trunk/flex/src/customComponents/SocioDemographicPage.mxml 2009-06-27 06:28:28 UTC (rev 167) @@ -38,7 +38,7 @@ boxGender.setStyle(bgcolor, red); ready=false; }else{ - boxGender.setStyle(bgcolor, white); + boxGender.setStyle(bgcolor, ""); } if(getYear().length != 4 || Number(getYear()) < 1900) Modified: mentalmodels/trunk/flex/src/customComponents/questions/ForecastingFishQuestionC.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/questions/ForecastingFishQuestionC.mxml 2009-06-24 09:28:09 UTC (rev 166) +++ mentalmodels/trunk/flex/src/customComponents/questions/ForecastingFishQuestionC.mxml 2009-06-27 06:28:28 UTC (rev 167) @@ -50,6 +50,11 @@ loadPeople = newPeopleDisplay; init(); } + public function loadPeopleOnly(newPeopleDisplay:ArrayCollection):void + { + loadPeople = newPeopleDisplay; + init(); + } public function loadFromQuestion(question:ForecastingFishQuestion):void { description = question.question; Added: mentalmodels/trunk/flex/src/customComponents/questions/components/OneDecision.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/questions/components/OneDecision.mxml (rev 0) +++ mentalmodels/trunk/flex/src/customComponents/questions/components/OneDecision.mxml 2009-06-27 06:28:28 UTC (rev 167) @@ -0,0 +1,53 @@ +<?xml version="1.0" encoding="utf-8"?> +<mx:Text xmlns:mx="http://www.adobe.com/2006/mxml" initialize="redraw()"> + + <mx:Script> + <![CDATA[ + import mx.collections.ArrayCollection; + + [Bindable] public var lbsFished:Number = 0.0; + [Bindable] public var peopleFishing:ArrayCollection = null; + + public function getLbs():String + { + var zeroDec:String = ""; + if(lbsFished as int == lbsFished) + { + zeroDec = ".0"; + } + var lbString:String = String(lbsFished).substr(0,5) + zeroDec + " lbs"; + return lbString; + } + + public function findPeople():String + { + var listStr:String = ""; + + if(peopleFishing == null || peopleFishing.length == 0) + { + listStr = "-"; + } + else + { + for(var i:int=0; i<peopleFishing.length; i++) + { + if(listStr.length != 0) + { + listStr += ", "; + } + listStr += peopleFishing.getItemAt(i); + } + } + + return listStr; + } + + public function redraw():void + { + htmlText = "Fished: "+getLbs()+"<br>People: "+findPeople(); + } + + ]]> + </mx:Script> + +</mx:Text> \ No newline at end of file Added: mentalmodels/trunk/flex/src/customComponents/questions/components/TotalDisplay.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/questions/components/TotalDisplay.mxml (rev 0) +++ mentalmodels/trunk/flex/src/customComponents/questions/components/TotalDisplay.mxml 2009-06-27 06:28:28 UTC (rev 167) @@ -0,0 +1,41 @@ +<?xml version="1.0" encoding="utf-8"?> +<mx:Text xmlns:mx="http://www.adobe.com/2006/mxml" initialize="redraw()"> + + <mx:Script> + <![CDATA[ + + [Bindable] public var lbsFished:Number = 0.0; + [Bindable] public var dollarPerLb:Number = 3.99; + + public function getLbs():String + { + var zeroDec:String = ""; + if(lbsFished as int == lbsFished) + { + zeroDec = ".0"; + } + var lbString:String = String(lbsFished).substr(0,5) + zeroDec + " lbs"; + return lbString; + } + + public function getMoney():String + { + var moneyMade:Number = lbsFished * dollarPerLb; + var zeroDec:String = ""; + if(moneyMade as int == moneyMade) + { + zeroDec = ".0"; + } + var moneyString:String = "$" + String(moneyMade).substr(0,5) + zeroDec; + return moneyString; + } + + public function redraw():void + { + htmlText = getLbs()+"<br>"+getMoney(); + } + + ]]> + </mx:Script> + +</mx:Text> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <kj...@us...> - 2009-06-24 09:28:39
|
Revision: 166 http://virtualcommons.svn.sourceforge.net/virtualcommons/?rev=166&view=rev Author: kjonas Date: 2009-06-24 09:28:09 +0000 (Wed, 24 Jun 2009) Log Message: ----------- CategoricalQuestionC.mxml, ForecastingPeopleQuestionC.mxml, ForecastingFishQuestionC.mxml, PsychometricQuestionC.mxml, StrategyDesignQuestionC.mxml, and TextQuestionC.mxml all render for their corresponding *Question actionscript classes. Possible modification: interpret a ForecastingQuestion from actionscript as two components for paging through, but synchronize them. _InstructionsTest.mxml works as a test for these components. FisheryExperimentKalin.mxml now incorporates proper functionality with InstructionPage.mxml and SocioDemographicPage.mxml. More testing is required, as well as hard-coding the formulas for determining calculated vallues. All Question Components render individually. global variables will be added so that the forecasting components will automatically load information that has recently been entered by other forecasting components Modified Paths: -------------- mentalmodels/trunk/flex/src/FisheryExperimentKalin.mxml mentalmodels/trunk/flex/src/_InstructionsTest.mxml mentalmodels/trunk/flex/src/actionscript/CategoricalQuestion.as mentalmodels/trunk/flex/src/actionscript/PageDisplay.as mentalmodels/trunk/flex/src/customComponents/InstructionPage.mxml mentalmodels/trunk/flex/src/customComponents/questions/CategoricalQuestionC.mxml mentalmodels/trunk/flex/src/customComponents/questions/ForecastingFishQuestionC.mxml mentalmodels/trunk/flex/src/customComponents/questions/ForecastingPeopleQuestionC.mxml mentalmodels/trunk/flex/src/customComponents/questions/ForecastingQuestionC.mxml mentalmodels/trunk/flex/src/customComponents/questions/PsychometricQuestionC.mxml mentalmodels/trunk/flex/src/customComponents/questions/StrategyDesignQuestionC.mxml mentalmodels/trunk/flex/src/customComponents/questions/TextQuestionC.mxml Modified: mentalmodels/trunk/flex/src/FisheryExperimentKalin.mxml =================================================================== --- mentalmodels/trunk/flex/src/FisheryExperimentKalin.mxml 2009-06-17 23:29:38 UTC (rev 165) +++ mentalmodels/trunk/flex/src/FisheryExperimentKalin.mxml 2009-06-24 09:28:09 UTC (rev 166) @@ -15,11 +15,14 @@ <mx:State name="instructions"> <mx:AddChild relativeTo="{content}"> - <comp:InstructionPage_TEMP id="instructions"/> + <comp:InstructionPage id="instructions" initialize="instructions.init(makeBlock())"/> </mx:AddChild> </mx:State> <mx:State name="none"> + <mx:AddChild relativeTo="{content}"> + <mx:Label id="end" text="Thank you for playing!" fontSize="30"/> + </mx:AddChild> </mx:State> </mx:states> @@ -30,15 +33,23 @@ <mx:Canvas id="expiredContent" x="-1" y="-1" width="1" height="1" visible="false"/> <mx:Button id="btnBack" label="« Back" click="back()" left="8" bottom="8"/> - <mx:Button id="btnAccept" label="Accept" click="accept()" left="375" bottom="10"/> + <mx:Button id="btnAccept" label="Accept" click="accept()" left="{(width-btnAccept.width)/2}" bottom="10"/> <mx:Button id="btnForward" label="Forward »" click="forward()" right="8" bottom="8"/> - <mx:RemoteObject id="ss" destination="studentService" fault="faultHandler(event)" result="resultHandler(event)"/> <mx:Producer id="producer" destination="DataPush" acknowledge="ack(event)"/> <mx:Consumer id="consumer" destination="DataPush" message="messageHandler(event.message)" /> <mx:Script> <![CDATA[ + import actionscript.Question; + import actionscript.StrategyDesignQuestion; + import actionscript.PsychometricQuestion; + import actionscript.ForecastingFishQuestion; + import actionscript.ForecastingPeopleQuestion; + import actionscript.CategoricalQuestion; + import actionscript.QuestionGroup; + import mx.collections.ArrayCollection; + import actionscript.Block; import flash.sampler.getInvocationCount; import mx.controls.Label; import customComponents.*; @@ -160,7 +171,11 @@ if(obj is InstructionPage) { - (InstructionPage)(obj).back(); + try + { + return (InstructionPage)(obj).back(); + } + catch(err:Error){} } return false; } @@ -173,7 +188,11 @@ if(obj is InstructionPage) { - (InstructionPage)(obj).forward(); + try + { + return (InstructionPage)(obj).forward(); + } + catch(err:Error){} } return false; } @@ -209,21 +228,91 @@ returnValue = true; } } - if(obj is InstructionPage_TEMP) + if(obj is InstructionPage) { - if( (InstructionPage_TEMP)(obj).accept() ) + try { - obj.visible = false; - expiredContent.addChild(obj); - currentState = "none"; - //consumer.subscribe(); - returnValue = true; + if( (InstructionPage)(obj).accept() ) + { + obj.visible = false; + expiredContent.addChild(obj); + currentState = "none"; + //consumer.subscribe(); + returnValue = true; + } } + catch(err:Error){} } return returnValue; } + public function makeBlock():Block + { + var block1:Block = new Block(); + try{ + var questionGroups1:ArrayCollection = new ArrayCollection(); + var qg1:QuestionGroup = new QuestionGroup(); + var qg2:QuestionGroup = new QuestionGroup(); + var qg3:QuestionGroup = new QuestionGroup(); + var qg4:QuestionGroup = new QuestionGroup(); + var qg5:QuestionGroup = new QuestionGroup(); + var qg6:QuestionGroup = new QuestionGroup(); + qg1.questions = new ArrayCollection(); + qg2.questions = new ArrayCollection(); + qg3.questions = new ArrayCollection(); + qg4.questions = new ArrayCollection(); + qg5.questions = new ArrayCollection(); + qg6.questions = new ArrayCollection(); + block1.questionGroups = new ArrayCollection(); + + // create questions + var cat1:CategoricalQuestion = new CategoricalQuestion(); + cat1.question = "categoricalQuestion"; + cat1.topics = new ArrayCollection(); + cat1.specifics = new ArrayCollection(); + + var for1:ForecastingPeopleQuestion = new ForecastingPeopleQuestion(); + var for2:ForecastingFishQuestion = new ForecastingFishQuestion(); + + var psy1:PsychometricQuestion = new PsychometricQuestion(); + psy1.question = "psychQuestion"; + psy1.numberOfIntervals = 10; + psy1.choices = new ArrayCollection(); + psy1.choices.addItem("Highly Agree"); + psy1.choices.addItem("Highly Neutral"); + psy1.choices.addItem("Highly Disagree"); + + var str1:StrategyDesignQuestion = new StrategyDesignQuestion(); + str1.question = "stratDesQuestion"; + + var txt1:Question = new Question(); + txt1.question = "textQuestion"; + + // insert questions into groups + qg1.questions.addItem(cat1); + qg1.description = "testDesc"; + qg1.header = "testHead"; + qg2.questions.addItem(for1); + qg3.questions.addItem(for2); + qg4.questions.addItem(psy1); + qg5.questions.addItem(str1); + qg6.questions.addItem(txt1); + + block1.questionGroups.addItem(qg1); + block1.questionGroups.addItem(qg2); + block1.questionGroups.addItem(qg3); + block1.questionGroups.addItem(qg4); + block1.questionGroups.addItem(qg5); + block1.questionGroups.addItem(qg6); + + + }catch(errObject:Error){ + Alert.show("block creation failure\n" + + errObject.message + "\n" + errObject.getStackTrace()); + } + return block1; + } ]]> </mx:Script> Modified: mentalmodels/trunk/flex/src/_InstructionsTest.mxml =================================================================== --- mentalmodels/trunk/flex/src/_InstructionsTest.mxml 2009-06-17 23:29:38 UTC (rev 165) +++ mentalmodels/trunk/flex/src/_InstructionsTest.mxml 2009-06-24 09:28:09 UTC (rev 166) @@ -4,6 +4,10 @@ <mx:Script> <![CDATA[ + import customComponents.questions.CategoricalQuestionC; + import actionscript.StrategyDesignQuestion; + import actionscript.ForecastingFishQuestion; + import actionscript.ForecastingPeopleQuestion; import actionscript.Question; import actionscript.CategoricalQuestion; import actionscript.QuestionGroup; @@ -11,44 +15,65 @@ import actionscript.Block; import mx.collections.ArrayCollection; - public var choices1:ArrayCollection = new ArrayCollection(); - public var questions1:ArrayCollection = new ArrayCollection(); - public var choices2:ArrayCollection = new ArrayCollection(); - public var questions2:ArrayCollection = new ArrayCollection(); - - public var questionGroups1:ArrayCollection = new ArrayCollection(); public var block1:Block = new Block(); public function fillBlock():void { try{ + var questionGroups1:ArrayCollection = new ArrayCollection(); + var qg1:QuestionGroup = new QuestionGroup(); + var qg2:QuestionGroup = new QuestionGroup(); + var qg3:QuestionGroup = new QuestionGroup(); + var qg4:QuestionGroup = new QuestionGroup(); + var qg5:QuestionGroup = new QuestionGroup(); + var qg6:QuestionGroup = new QuestionGroup(); + qg1.questions = new ArrayCollection(); + qg2.questions = new ArrayCollection(); + qg3.questions = new ArrayCollection(); + qg4.questions = new ArrayCollection(); + qg5.questions = new ArrayCollection(); + qg6.questions = new ArrayCollection(); + block1.questionGroups = new ArrayCollection(); + // create questions + var cat1:CategoricalQuestion = new CategoricalQuestion(); + cat1.question = "categoricalQuestion"; + cat1.topics = new ArrayCollection(); + cat1.specifics = new ArrayCollection(); + + var for1:ForecastingPeopleQuestion = new ForecastingPeopleQuestion(); + var for2:ForecastingFishQuestion = new ForecastingFishQuestion(); + var psy1:PsychometricQuestion = new PsychometricQuestion(); + psy1.question = "psychQuestion"; psy1.numberOfIntervals = 10; psy1.choices = new ArrayCollection(); psy1.choices.addItem("Highly Agree"); psy1.choices.addItem("Highly Neutral"); psy1.choices.addItem("Highly Disagree"); - var psy2:PsychometricQuestion = new PsychometricQuestion(); - psy2.numberOfIntervals = 10; - psy2.choices = new ArrayCollection(); - psy2.choices.addItem("Agree"); - psy2.choices.addItem("Neutral"); + var str1:StrategyDesignQuestion = new StrategyDesignQuestion(); + str1.question = "stratDesQuestion"; + var txt1:Question = new Question(); + txt1.question = "textQuestion"; + // insert questions into groups - var qg1:QuestionGroup = new QuestionGroup(); - qg1.questions = new ArrayCollection(); - qg1.questions.addItem(psy1); + qg1.questions.addItem(cat1); + qg1.description = "testDesc"; + qg1.header = "testHead"; + qg2.questions.addItem(for1); + qg3.questions.addItem(for2); + qg4.questions.addItem(psy1); + qg5.questions.addItem(str1); + qg6.questions.addItem(txt1); - var qg2:QuestionGroup = new QuestionGroup(); - qg2.questions = new ArrayCollection(); - qg2.questions.addItem(psy2); -// throw new Error("test"); - - block1.questionGroups = new ArrayCollection(); block1.questionGroups.addItem(qg1); block1.questionGroups.addItem(qg2); + block1.questionGroups.addItem(qg3); + block1.questionGroups.addItem(qg4); + block1.questionGroups.addItem(qg5); + block1.questionGroups.addItem(qg6); // debg.text += "finished\n"; }catch(errObject:Error){ @@ -68,8 +93,10 @@ <comp:PsychometricQuestionC id="psych" labels="{labs}" initialize="true"/> <comp:CategoricalQuestionC/>--> - <mx:Button id="forward" click="iPage.forward()" label="forward"/> - <mx:Button id="back" click="iPage.back()" label="back"/> + <mx:HBox> + <mx:Button id="back" click="iPage.back()" label="back"/> + <mx:Button id="forward" click="iPage.forward()" label="forward"/> + </mx:HBox> <mx:Text id="debug" text=""/> Modified: mentalmodels/trunk/flex/src/actionscript/CategoricalQuestion.as =================================================================== --- mentalmodels/trunk/flex/src/actionscript/CategoricalQuestion.as 2009-06-17 23:29:38 UTC (rev 165) +++ mentalmodels/trunk/flex/src/actionscript/CategoricalQuestion.as 2009-06-24 09:28:09 UTC (rev 166) @@ -7,5 +7,8 @@ public class CategoricalQuestion extends Question { public var choices:Object; + + public var topics:ArrayCollection; + public var specifics:ArrayCollection; } } \ No newline at end of file Modified: mentalmodels/trunk/flex/src/actionscript/PageDisplay.as =================================================================== --- mentalmodels/trunk/flex/src/actionscript/PageDisplay.as 2009-06-17 23:29:38 UTC (rev 165) +++ mentalmodels/trunk/flex/src/actionscript/PageDisplay.as 2009-06-24 09:28:09 UTC (rev 166) @@ -12,6 +12,7 @@ import mx.collections.ArrayCollection; import mx.containers.VBox; + import mx.controls.Alert; import mx.controls.Label; import mx.controls.Text; @@ -122,13 +123,15 @@ var head:Label = new Label(); var desc:Text = new Text(); head.text = questionGroup.header; + head.setStyle("fontSize", 12); desc.htmlText = questionGroup.description; - tempBox.addChildAt(head,0); - tempBox.addChildAt(desc,1); + if(head.text.length != 0) tempBox.addChildAt(head,0); + if(desc.htmlText.length != 0) tempBox.addChildAt(desc,1); } else { msg += "no Questions found\n"; +// Alert.show(msg); } pages.addItem(tempBox); @@ -162,11 +165,7 @@ public function nextPage():Boolean { currentPageNumber = FishUtil.fix(currentPageNumber + 1, pages); - - if( currentPageNumber > highestPageReached ) - { - highestPageReached = currentPageNumber; - } + highestPageReached = Math.max(currentPageNumber, highestPageReached) return true; } public function prevPage():Boolean Modified: mentalmodels/trunk/flex/src/customComponents/InstructionPage.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/InstructionPage.mxml 2009-06-17 23:29:38 UTC (rev 165) +++ mentalmodels/trunk/flex/src/customComponents/InstructionPage.mxml 2009-06-24 09:28:09 UTC (rev 166) @@ -3,6 +3,7 @@ <mx:Script> <![CDATA[ + import mx.controls.Alert; import actionscript.Block; import actionscript.PageDisplay; import mx.collections.ArrayCollection; @@ -17,7 +18,12 @@ block = newBlock; try{ // debug.text += "creating pageDisplay...\n"; - pageDisplay = new PageDisplay(block, 3); + var minPagesRead:int = 0; + if(block != null && block.questionGroups != null) + { + minPagesRead = block.questionGroups.length + } + pageDisplay = new PageDisplay(block, minPagesRead); if(pageDisplay == null) { debug.text += "pageDisplay is null"; @@ -28,7 +34,8 @@ }catch(errObject:Error){ debug.text += "pageDisplay creation failure\n" + - errObject.message +"\n"+ errObject.name +"\n"; + errObject.message +"\n"+ errObject.getStackTrace() +"\n"; +// Alert.show(debug.text); } // debug.text += "setting currPage...\n"; @@ -44,10 +51,11 @@ public function back():Boolean { var pageSuccess:Boolean = pageDisplay.prevPage(); - currPage = pageDisplay.currentPageNumber; - currPageLabel.text = "Page " + (currPage+1) + " / " + numPages; if(pageSuccess) { + currPage = pageDisplay.currentPageNumber; + currPageLabel.text = "Page " + (currPage+1) + " / " + numPages; + content.removeAllChildren(); content.addChild(pageDisplay.currentPage); } @@ -57,10 +65,11 @@ public function forward():Boolean { var pageSuccess:Boolean = pageDisplay.nextPage(); - currPage = pageDisplay.currentPageNumber; - currPageLabel.text = "Page " + (currPage+1) + " / " + numPages; if(pageSuccess) { + currPage = pageDisplay.currentPageNumber; + currPageLabel.text = "Page " + (currPage+1) + " / " + numPages; + content.removeAllChildren(); content.addChild(pageDisplay.currentPage); } @@ -69,14 +78,18 @@ public function accept():Boolean { - if(pageDisplay.finished()) + try { - //do stuff - - - //and finish - return true; + if(pageDisplay.finished()) + { + //do stuff + + + //and finish + return true; + } } + catch(err:Error){Alert.show("accepterror"+err.message+err.getStackTrace());} return false; } Modified: mentalmodels/trunk/flex/src/customComponents/questions/CategoricalQuestionC.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/questions/CategoricalQuestionC.mxml 2009-06-17 23:29:38 UTC (rev 165) +++ mentalmodels/trunk/flex/src/customComponents/questions/CategoricalQuestionC.mxml 2009-06-24 09:28:09 UTC (rev 166) @@ -2,15 +2,11 @@ <mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:as="actionscript.*"> <mx:String id="description"></mx:String> - <mx:VBox id="headers"> - <mx:Label/> - <mx:Text htmlText="{description}"/> - </mx:VBox> <mx:HBox id="content"> <mx:ComboBox id="comboTopic" dataProvider="{topics}" selectedIndex="0"/> - <mx:ComboBox id="comboSpecific" + <mx:ComboBox id="comboSpecific" prompt="Select" dataProvider="{specifics.getItemAt(fix(comboTopic.selectedIndex, specifics))}"/> </mx:HBox> @@ -40,10 +36,10 @@ public function loadFromQuestion(question:CategoricalQuestion):void { - description = question.question; initialize(); // init(); + description = question.question; } ]]> @@ -52,7 +48,6 @@ <!-- the selected element of this array determines which of the elements of "specifics" will be used as the dataProvider --> <mx:ArrayCollection id="topics"> - <mx:String>- Select -</mx:String> <mx:String>topic1</mx:String> <mx:String>topic2</mx:String> <mx:String>topic3</mx:String> @@ -60,22 +55,17 @@ <!-- each element of this ArrayCollection will serve as a dataProvider --> <mx:ArrayCollection id="specifics"> - <mx:ArrayCollection id="topic0"> - </mx:ArrayCollection> <mx:ArrayCollection id="topic1"> - <mx:String>- Select -</mx:String> <mx:String>specific1.0</mx:String> <mx:String>specific1.1</mx:String> <mx:String>specific1.2</mx:String> </mx:ArrayCollection> <mx:ArrayCollection id="topic2"> - <mx:String>- Select -</mx:String> <mx:String>specific2.0</mx:String> <mx:String>specific2.1</mx:String> <mx:String>specific2.2</mx:String> </mx:ArrayCollection> <mx:ArrayCollection id="topic3"> - <mx:String>- Select -</mx:String> <mx:String>specific3.0</mx:String> <mx:String>specific3.1</mx:String> <mx:String>specific3.2</mx:String> Modified: mentalmodels/trunk/flex/src/customComponents/questions/ForecastingFishQuestionC.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/questions/ForecastingFishQuestionC.mxml 2009-06-17 23:29:38 UTC (rev 165) +++ mentalmodels/trunk/flex/src/customComponents/questions/ForecastingFishQuestionC.mxml 2009-06-24 09:28:09 UTC (rev 166) @@ -2,10 +2,6 @@ <mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:components="customComponents.questions.components.*"> <mx:String id="description"></mx:String> - <mx:VBox id="headers"> - <mx:Label/> - <mx:Text htmlText="{description}"/> - </mx:VBox> <components:ForecastComponent id="fishEntry" style="1" isEntry="true" numBays="{numBays}" numColumns="{numColumns}" initialize="false" Modified: mentalmodels/trunk/flex/src/customComponents/questions/ForecastingPeopleQuestionC.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/questions/ForecastingPeopleQuestionC.mxml 2009-06-17 23:29:38 UTC (rev 165) +++ mentalmodels/trunk/flex/src/customComponents/questions/ForecastingPeopleQuestionC.mxml 2009-06-24 09:28:09 UTC (rev 166) @@ -2,10 +2,6 @@ <mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:components="customComponents.questions.components.*"> <mx:String id="description"></mx:String> - <mx:VBox id="headers"> - <mx:Label/> - <mx:Text htmlText="{description}"/> - </mx:VBox> <components:ForecastComponent id="peopleEntry" style="0" isEntry="true" numBays="{numBays}" numColumns="{numColumns}" initialize="false"/> Modified: mentalmodels/trunk/flex/src/customComponents/questions/ForecastingQuestionC.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/questions/ForecastingQuestionC.mxml 2009-06-17 23:29:38 UTC (rev 165) +++ mentalmodels/trunk/flex/src/customComponents/questions/ForecastingQuestionC.mxml 2009-06-24 09:28:09 UTC (rev 166) @@ -2,10 +2,6 @@ <mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml"> <mx:String id="description"></mx:String> - <mx:VBox id="headers"> - <mx:Label/> - <mx:Text htmlText="{description}"/> - </mx:VBox> <mx:HBox id="buttons"> <mx:Button id="btnForward" label="Forecast Fish" click="forward()"/> Modified: mentalmodels/trunk/flex/src/customComponents/questions/PsychometricQuestionC.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/questions/PsychometricQuestionC.mxml 2009-06-17 23:29:38 UTC (rev 165) +++ mentalmodels/trunk/flex/src/customComponents/questions/PsychometricQuestionC.mxml 2009-06-24 09:28:09 UTC (rev 166) @@ -2,10 +2,6 @@ <mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:qComp="customComponents.questions.components.*" initialize="false"> <mx:String id="description"></mx:String> - <mx:VBox id="headers"> - <mx:Label/> - <mx:Text htmlText="{description}"/> - </mx:VBox> <mx:Canvas id="content" minHeight="30" maxHeight="90"> <!-- Used for bipolar psychometric scales --> @@ -24,7 +20,7 @@ import mx.collections.ArrayCollection; import customComponents.questions.components.Slider; - public var labels:ArrayCollection; + public var labels:ArrayCollection = new ArrayCollection(); [Bindable] public var maxValue:Number; [Bindable] public var slider1:Slider; @@ -95,9 +91,26 @@ { description = question.question; + maxValue = question.numberOfIntervals; + labels = loadChoices(question); + initialize(); init(); } + private function loadChoices(question:PsychometricQuestion):ArrayCollection + { + var choices:ArrayCollection = new ArrayCollection(); + + if(question.choices != null && question.choices.length >= 2) + { + for(var i:int = 0; i < question.choices.length; i++) + { + choices.addItem(question.choices.getItemAt(i)); + } + } + + return choices; + } ]]> </mx:Script> Modified: mentalmodels/trunk/flex/src/customComponents/questions/StrategyDesignQuestionC.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/questions/StrategyDesignQuestionC.mxml 2009-06-17 23:29:38 UTC (rev 165) +++ mentalmodels/trunk/flex/src/customComponents/questions/StrategyDesignQuestionC.mxml 2009-06-24 09:28:09 UTC (rev 166) @@ -2,10 +2,6 @@ <mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:qComp="customComponents.questions.components.*"> <mx:String id="description"></mx:String> - <mx:VBox id="headers"> - <mx:Label/> - <mx:Text htmlText="{description}"/> - </mx:VBox> <mx:HBox> <mx:VBox> Modified: mentalmodels/trunk/flex/src/customComponents/questions/TextQuestionC.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/questions/TextQuestionC.mxml 2009-06-17 23:29:38 UTC (rev 165) +++ mentalmodels/trunk/flex/src/customComponents/questions/TextQuestionC.mxml 2009-06-24 09:28:09 UTC (rev 166) @@ -2,10 +2,6 @@ <mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml"> <mx:String id="description"></mx:String> - <mx:VBox id="headers"> - <mx:Label/> - <mx:Text htmlText="{description}"/> - </mx:VBox> <mx:Number id="txtWidth">200</mx:Number> <mx:Number id="txtHeight">24</mx:Number> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <kj...@us...> - 2009-06-17 23:30:49
|
Revision: 165 http://virtualcommons.svn.sourceforge.net/virtualcommons/?rev=165&view=rev Author: kjonas Date: 2009-06-17 23:29:38 +0000 (Wed, 17 Jun 2009) Log Message: ----------- ForecastingFishQuestionC.mxml and ForecastingPeopleQuestionC.mxml are component representations of the two original forecasting components the recalculate function needs to be fixed once the ForecastingFishQuestionC.mxml has access to necessary information Changing values in the first dataGrid does, however, force updating of the calculated dataGrid through use of updater and updaterObject Modified Paths: -------------- mentalmodels/trunk/flex/src/FisheryExperimentKalin.mxml mentalmodels/trunk/flex/src/TestForecast.mxml mentalmodels/trunk/flex/src/actionscript/PageDisplay.as mentalmodels/trunk/flex/src/customComponents/InstructionPage_TEMP.mxml mentalmodels/trunk/flex/src/customComponents/questions/CategoricalQuestionC.mxml mentalmodels/trunk/flex/src/customComponents/questions/ForecastingQuestionC.mxml mentalmodels/trunk/flex/src/customComponents/questions/PsychometricQuestionC.mxml mentalmodels/trunk/flex/src/customComponents/questions/StrategyDesignQuestionC.mxml mentalmodels/trunk/flex/src/customComponents/questions/TextQuestionC.mxml mentalmodels/trunk/flex/src/customComponents/questions/components/ForecastComponent.mxml Added Paths: ----------- mentalmodels/trunk/flex/src/actionscript/ForecastingFishQuestion.as mentalmodels/trunk/flex/src/actionscript/ForecastingPeopleQuestion.as mentalmodels/trunk/flex/src/actionscript/StrategyDesignQuestion.as mentalmodels/trunk/flex/src/customComponents/questions/ForecastingFishQuestionC.mxml mentalmodels/trunk/flex/src/customComponents/questions/ForecastingPeopleQuestionC.mxml Removed Paths: ------------- mentalmodels/trunk/flex/src/actionscript/InstructionPageLoader.as Modified: mentalmodels/trunk/flex/src/FisheryExperimentKalin.mxml =================================================================== --- mentalmodels/trunk/flex/src/FisheryExperimentKalin.mxml 2009-06-17 19:19:34 UTC (rev 164) +++ mentalmodels/trunk/flex/src/FisheryExperimentKalin.mxml 2009-06-17 23:29:38 UTC (rev 165) @@ -182,7 +182,9 @@ { if(content.numChildren == 0) { return false; } + var obj:DisplayObject = content.getChildAt(0); + var returnValue:Boolean = false; if(obj is SocioDemographicPage) { @@ -200,7 +202,11 @@ Alert.show(info.getYear());*/ Id=ss.createStudent(info.getYear(), info.getSemester(), info.getGender(),info.getMajor()); // Alert.show("Before invoking createstudent()"); - return true; + + btnBack.enabled = true; + btnForward.enabled = true; + + returnValue = true; } } if(obj is InstructionPage_TEMP) @@ -211,11 +217,11 @@ expiredContent.addChild(obj); currentState = "none"; //consumer.subscribe(); - return true; + returnValue = true; } } - return false; + return returnValue; } Modified: mentalmodels/trunk/flex/src/TestForecast.mxml =================================================================== --- mentalmodels/trunk/flex/src/TestForecast.mxml 2009-06-17 19:19:34 UTC (rev 164) +++ mentalmodels/trunk/flex/src/TestForecast.mxml 2009-06-17 23:29:38 UTC (rev 165) @@ -1,19 +1,12 @@ <?xml version="1.0" encoding="utf-8"?> -<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:qComp="customComponents.questions.components.*" xmlns:quest="customComponents.questions.*" initialize="init()"> +<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:qComp="customComponents.questions.components.*" xmlns:quest="customComponents.questions.*" + initialize="init()"> <mx:VBox id="content" minWidth="160"> - - <qComp:ForecastComponent id="forecastComponent0" numColumns="15" numBays="3" style="0" minimumWidth="{content.minWidth}"/> - <qComp:ForecastComponent id="forecastComponent1" numColumns="15" numBays="3" style="1" minimumWidth="{content.minWidth}"/> - <qComp:ForecastComponent id="forecastComponent2" numColumns="6" numBays="3" style="2" minimumWidth="{content.minWidth}"/> - <qComp:ForecastComponent id="forecastComponent3" numColumns="6" numBays="3" style="3" minimumWidth="{content.minWidth}"/> - <mx:HBox> - <mx:Button label="Save" click="save()"/> - <mx:Button label="Load" click="load()"/> - </mx:HBox> - - <quest:StrategyDesignQuestionC id="planner"/> - + <quest:ForecastingPeopleQuestionC id="people"/> + <mx:Button label="Save" click="save()"/> + <mx:Button label="Load" click="load()"/> + <quest:ForecastingFishQuestionC id="fish" initialize="false"/> </mx:VBox> <mx:Script> @@ -21,30 +14,21 @@ import mx.collections.ArrayCollection; import mx.controls.Alert; - public var forecastSaved:ArrayCollection = null; - public var plannerSaved:ArrayCollection = null; + public var peopleSaved:ArrayCollection = null; + public var fishSaved:ArrayCollection = null; -// try -// { -// -// } -// catch(error:Error) -// { -// Alert.show(error.message + "\n" + error.getStackTrace()); -// } - public function init():void { - + people.initialize(); + people.init(); } public function save():void { try { - forecastSaved = forecastComponent0.save(); - - plannerSaved = planner.save(); + peopleSaved = people.save(); + fishSaved = fish.save(); } catch(error:Error) { @@ -56,12 +40,8 @@ { try { - forecastComponent0.load(forecastSaved); - forecastComponent1.load(forecastSaved); - forecastComponent2.load(forecastSaved); - forecastComponent3.load(forecastSaved); - - planner.load(plannerSaved); + people.load(peopleSaved); + fish.load(fishSaved,peopleSaved); } catch(error:Error) { Added: mentalmodels/trunk/flex/src/actionscript/ForecastingFishQuestion.as =================================================================== --- mentalmodels/trunk/flex/src/actionscript/ForecastingFishQuestion.as (rev 0) +++ mentalmodels/trunk/flex/src/actionscript/ForecastingFishQuestion.as 2009-06-17 23:29:38 UTC (rev 165) @@ -0,0 +1,11 @@ +package actionscript +{ + import mx.collections.ArrayCollection; + + [Bindable] + [RemoteClass(alias="edu.asu.commons.mme.entity.ForecastingFishQuestion")] + public class ForecastingFishQuestion extends Question + { + public var numDays:int; + } +} \ No newline at end of file Added: mentalmodels/trunk/flex/src/actionscript/ForecastingPeopleQuestion.as =================================================================== --- mentalmodels/trunk/flex/src/actionscript/ForecastingPeopleQuestion.as (rev 0) +++ mentalmodels/trunk/flex/src/actionscript/ForecastingPeopleQuestion.as 2009-06-17 23:29:38 UTC (rev 165) @@ -0,0 +1,11 @@ +package actionscript +{ + import mx.collections.ArrayCollection; + + [Bindable] + [RemoteClass(alias="edu.asu.commons.mme.entity.ForecastingPeopleQuestion")] + public class ForecastingPeopleQuestion extends Question + { + public var numDays:int; + } +} \ No newline at end of file Deleted: mentalmodels/trunk/flex/src/actionscript/InstructionPageLoader.as =================================================================== --- mentalmodels/trunk/flex/src/actionscript/InstructionPageLoader.as 2009-06-17 19:19:34 UTC (rev 164) +++ mentalmodels/trunk/flex/src/actionscript/InstructionPageLoader.as 2009-06-17 23:29:38 UTC (rev 165) @@ -1,10 +0,0 @@ -package actionscript -{ - public class InstructionPageLoader - { - public function InstructionPageLoader() - { - } - - } -} \ No newline at end of file Modified: mentalmodels/trunk/flex/src/actionscript/PageDisplay.as =================================================================== --- mentalmodels/trunk/flex/src/actionscript/PageDisplay.as 2009-06-17 19:19:34 UTC (rev 164) +++ mentalmodels/trunk/flex/src/actionscript/PageDisplay.as 2009-06-17 23:29:38 UTC (rev 165) @@ -1,16 +1,17 @@ // ActionScript file package actionscript { - import customComponents.questions.TextQuestionC; - import customComponents.questions.ForecastingQuestionC; import customComponents.questions.CategoricalQuestionC; + import customComponents.questions.ForecastingFishQuestionC; + import customComponents.questions.ForecastingPeopleQuestionC; import customComponents.questions.PsychometricQuestionC; + import customComponents.questions.StrategyDesignQuestionC; + import customComponents.questions.TextQuestionC; import flash.display.DisplayObject; import mx.collections.ArrayCollection; import mx.containers.VBox; - import mx.controls.ComboBox; import mx.controls.Label; import mx.controls.Text; @@ -69,14 +70,30 @@ txt.htmlText = tempQuestion.question; tempBox.addChild(txt); - if(tempQuestion is ForecastingQuestion) + if(tempQuestion is StrategyDesignQuestion) { - var fq:ForecastingQuestionC = new ForecastingQuestionC(); - fq.loadFromQuestion(ForecastingQuestion(tempQuestion)); - fq.id = "q"+question; + var sdq:StrategyDesignQuestionC = new StrategyDesignQuestionC(); + sdq.loadFromQuestion(StrategyDesignQuestion(tempQuestion)); + sdq.id = "q"+question; - tempBox.addChild(fq); + tempBox.addChild(sdq); } + else if(tempQuestion is ForecastingPeopleQuestion) + { + var fpq:ForecastingPeopleQuestionC = new ForecastingPeopleQuestionC(); + fpq.loadFromQuestion(ForecastingPeopleQuestion(tempQuestion)); + fpq.id = "q"+question; + + tempBox.addChild(fpq); + } + else if(tempQuestion is ForecastingFishQuestion) + { + var ffq:ForecastingFishQuestionC = new ForecastingFishQuestionC(); + ffq.loadFromQuestion(ForecastingFishQuestion(tempQuestion)); + ffq.id = "q"+question; + + tempBox.addChild(ffq); + } else if(tempQuestion is CategoricalQuestion) { var cq:CategoricalQuestionC = new CategoricalQuestionC(); Added: mentalmodels/trunk/flex/src/actionscript/StrategyDesignQuestion.as =================================================================== --- mentalmodels/trunk/flex/src/actionscript/StrategyDesignQuestion.as (rev 0) +++ mentalmodels/trunk/flex/src/actionscript/StrategyDesignQuestion.as 2009-06-17 23:29:38 UTC (rev 165) @@ -0,0 +1,11 @@ +package actionscript +{ + import mx.collections.ArrayCollection; + + [Bindable] + [RemoteClass(alias="edu.asu.commons.mme.entity.StrategyDesignQuestion")] + public class StrategyDesignQuestion extends Question + { + public var numDays:int; + } +} \ No newline at end of file Modified: mentalmodels/trunk/flex/src/customComponents/InstructionPage_TEMP.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/InstructionPage_TEMP.mxml 2009-06-17 19:19:34 UTC (rev 164) +++ mentalmodels/trunk/flex/src/customComponents/InstructionPage_TEMP.mxml 2009-06-17 23:29:38 UTC (rev 165) @@ -55,7 +55,7 @@ <mx:Text htmlText="<b><font size="16">Sample Questions</font></b>" width="300"/> <quest:PsychometricQuestionC id="psychometricQuestion" description="Overall, how much do you like your group?" labels="{psychometricLabels}" maxValue="3"/> - <quest:CategoricalQuestionC id="categoricalQuestion" title="What goals did you follow when designing your strategy?" + <quest:CategoricalQuestionC id="categoricalQuestion" description="What goals did you follow when designing your strategy?" topics="{categoricalTopics}" specifics="{categoricalSpecifics}"/> <quest:TextQuestionC id="textQuestion" description="Describe in your own words what the rule, agreement, or other coordination attempt states." defaultText="Enter your response here..." txtHeight="48"/> Modified: mentalmodels/trunk/flex/src/customComponents/questions/CategoricalQuestionC.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/questions/CategoricalQuestionC.mxml 2009-06-17 19:19:34 UTC (rev 164) +++ mentalmodels/trunk/flex/src/customComponents/questions/CategoricalQuestionC.mxml 2009-06-17 23:29:38 UTC (rev 165) @@ -1,20 +1,11 @@ <?xml version="1.0" encoding="utf-8"?> <mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:as="actionscript.*"> - <mx:String id="title"></mx:String> <mx:String id="description"></mx:String> <mx:VBox id="headers"> <mx:Label/> - <mx:Label htmlText="{htmlBold(title)}"/> <mx:Text htmlText="{description}"/> </mx:VBox> - <mx:Script> <![CDATA[ - public function htmlBold(str:String):String - { - if(str==null)return null; - return "<font size=\"12px\">" + str + "</font>"; - } - ]]> </mx:Script> <mx:HBox id="content"> <mx:ComboBox id="comboTopic" Added: mentalmodels/trunk/flex/src/customComponents/questions/ForecastingFishQuestionC.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/questions/ForecastingFishQuestionC.mxml (rev 0) +++ mentalmodels/trunk/flex/src/customComponents/questions/ForecastingFishQuestionC.mxml 2009-06-17 23:29:38 UTC (rev 165) @@ -0,0 +1,90 @@ +<?xml version="1.0" encoding="utf-8"?> +<mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:components="customComponents.questions.components.*"> + + <mx:String id="description"></mx:String> + <mx:VBox id="headers"> + <mx:Label/> + <mx:Text htmlText="{description}"/> + </mx:VBox> + + <components:ForecastComponent id="fishEntry" style="1" isEntry="true" + numBays="{numBays}" numColumns="{numColumns}" initialize="false" + updaterObject="{this}" updater="{recalculate}"/> + <components:ForecastComponent id="peopleDisplay" style="0" isEntry="false" + numBays="{numBays}" numColumns="15" initialize="false"/> + <components:ForecastComponent id="calculated" style="2" isEntry="false" + numBays="{numBays}" numColumns="{numColumns}" initialize="false"/> + + <mx:Script> + <![CDATA[ + import mx.controls.Alert; + import actionscript.ForecastingFishQuestion; + import mx.collections.ArrayCollection; + import customComponents.questions.components.ForecastComponent; + + public var loadFish:ArrayCollection = null; + public var loadPeople:ArrayCollection = null; + + [Bindable] public var numBays:int = 3; + [Bindable] public var numColumns:int = 6; + + public function init():void + { + fishEntry.initialize(); fishEntry.init(); + peopleDisplay.initialize(); peopleDisplay.init(); + calculated.initialize(); calculated.init(); + + if(loadFish != null) + { + fishEntry.load(loadFish); + } + if(loadPeople != null) + { + peopleDisplay.load(loadPeople); + } + } + + public function save():ArrayCollection + { + return fishEntry.save(); + } + public function load(newFishEntry:ArrayCollection,newPeopleDisplay:ArrayCollection):void + { + loadFish = newFishEntry; + loadPeople = newPeopleDisplay; + init(); + } + public function loadFromQuestion(question:ForecastingFishQuestion):void + { + description = question.question; + + initialize(); + init(); + } + + public function recalculate():void + { + var currLoc:int = 0; + + var fishCols:int = fishEntry.dataGrid.columns.length; + var pplCols:int = peopleDisplay.dataGrid.columns.length; + var calcCols:int = calculated.dataGrid.columns.length; + + for(var column:int = 0; column < fishCols && column < pplCols && column < calcCols; column++) + { + calculated.setItem(0,column,currLoc); + calculated.setItem(1,column,0); + calculated.setItem(2,column,0); + + for(var bay:int = 0; bay < numBays; bay++) + { + calculated.setItem(3+bay,column,Number(fishEntry.getItem(bay,column)) * 0.9); + } + } + calculated.redraw(); + } + + ]]> + </mx:Script> + +</mx:VBox> Added: mentalmodels/trunk/flex/src/customComponents/questions/ForecastingPeopleQuestionC.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/questions/ForecastingPeopleQuestionC.mxml (rev 0) +++ mentalmodels/trunk/flex/src/customComponents/questions/ForecastingPeopleQuestionC.mxml 2009-06-17 23:29:38 UTC (rev 165) @@ -0,0 +1,54 @@ +<?xml version="1.0" encoding="utf-8"?> +<mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:components="customComponents.questions.components.*"> + + <mx:String id="description"></mx:String> + <mx:VBox id="headers"> + <mx:Label/> + <mx:Text htmlText="{description}"/> + </mx:VBox> + + <components:ForecastComponent id="peopleEntry" style="0" isEntry="true" + numBays="{numBays}" numColumns="{numColumns}" initialize="false"/> + + <mx:Script> + <![CDATA[ + import actionscript.ForecastingPeopleQuestion; + import mx.collections.ArrayCollection; + import customComponents.questions.components.ForecastComponent; + + public var loadPeople:ArrayCollection = null; + + [Bindable] public var numBays:int = 3; + [Bindable] public var numColumns:int = 15; + + public function init():void + { + peopleEntry.initialize(); peopleEntry.init(); + + if(loadPeople != null) + { + peopleEntry.load(loadPeople); + } + } + + public function save():ArrayCollection + { + return peopleEntry.save(); + } + public function load(newPeopleDisplay:ArrayCollection):void + { + loadPeople = newPeopleDisplay; + init(); + } + public function loadFromQuestion(question:ForecastingPeopleQuestion):void + { + description = question.question; + + initialize(); + init(); + } + + ]]> + </mx:Script> + +</mx:VBox> Modified: mentalmodels/trunk/flex/src/customComponents/questions/ForecastingQuestionC.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/questions/ForecastingQuestionC.mxml 2009-06-17 19:19:34 UTC (rev 164) +++ mentalmodels/trunk/flex/src/customComponents/questions/ForecastingQuestionC.mxml 2009-06-17 23:29:38 UTC (rev 165) @@ -6,13 +6,6 @@ <mx:Label/> <mx:Text htmlText="{description}"/> </mx:VBox> - <mx:Script> <![CDATA[ - public function htmlBold(str:String):String - { - if(str==null)return null; - return "<font size=\"12px\">" + str + "</font>"; - } - ]]> </mx:Script> <mx:HBox id="buttons"> <mx:Button id="btnForward" label="Forecast Fish" click="forward()"/> Modified: mentalmodels/trunk/flex/src/customComponents/questions/PsychometricQuestionC.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/questions/PsychometricQuestionC.mxml 2009-06-17 19:19:34 UTC (rev 164) +++ mentalmodels/trunk/flex/src/customComponents/questions/PsychometricQuestionC.mxml 2009-06-17 23:29:38 UTC (rev 165) @@ -6,13 +6,6 @@ <mx:Label/> <mx:Text htmlText="{description}"/> </mx:VBox> - <mx:Script> <![CDATA[ - public function htmlBold(str:String):String - { - if(str==null)return null; - return "<font size=\"12px\">" + str + "</font>"; - } - ]]> </mx:Script> <mx:Canvas id="content" minHeight="30" maxHeight="90"> <!-- Used for bipolar psychometric scales --> Modified: mentalmodels/trunk/flex/src/customComponents/questions/StrategyDesignQuestionC.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/questions/StrategyDesignQuestionC.mxml 2009-06-17 19:19:34 UTC (rev 164) +++ mentalmodels/trunk/flex/src/customComponents/questions/StrategyDesignQuestionC.mxml 2009-06-17 23:29:38 UTC (rev 165) @@ -1,10 +1,11 @@ <?xml version="1.0" encoding="utf-8"?> <mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:qComp="customComponents.questions.components.*"> - <mx:Label text="Strategy Design" fontSize="24"/> - <mx:Text text="Please create a plan for the month. You will visit each of the locations listed in the left column in order. You will then do the same using the right column, but repeat until the 30 days are completed. If you do not manage to mine enough fish after one repetition, you may wait a few days until fishing again." - width="600"/> - <mx:Label/> + <mx:String id="description"></mx:String> + <mx:VBox id="headers"> + <mx:Label/> + <mx:Text htmlText="{description}"/> + </mx:VBox> <mx:HBox> <mx:VBox> @@ -32,6 +33,7 @@ <mx:Script> <![CDATA[ + import actionscript.StrategyDesignQuestion; import mx.collections.ArrayCollection; public function getNotRepeated():ArrayCollection @@ -63,6 +65,14 @@ suspendDays.value = loadArray.getItemAt(3) as Number; } + public function loadFromQuestion(question:StrategyDesignQuestion):void + { + description = question.question; + + initialize(); +// init(); + } + ]]> </mx:Script> Modified: mentalmodels/trunk/flex/src/customComponents/questions/TextQuestionC.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/questions/TextQuestionC.mxml 2009-06-17 19:19:34 UTC (rev 164) +++ mentalmodels/trunk/flex/src/customComponents/questions/TextQuestionC.mxml 2009-06-17 23:29:38 UTC (rev 165) @@ -6,13 +6,6 @@ <mx:Label/> <mx:Text htmlText="{description}"/> </mx:VBox> - <mx:Script> <![CDATA[ - public function htmlBold(str:String):String - { - if(str==null)return null; - return "<font size=\"12px\">" + str + "</font>"; - } - ]]> </mx:Script> <mx:Number id="txtWidth">200</mx:Number> <mx:Number id="txtHeight">24</mx:Number> Modified: mentalmodels/trunk/flex/src/customComponents/questions/components/ForecastComponent.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/questions/components/ForecastComponent.mxml 2009-06-17 19:19:34 UTC (rev 164) +++ mentalmodels/trunk/flex/src/customComponents/questions/components/ForecastComponent.mxml 2009-06-17 23:29:38 UTC (rev 165) @@ -17,9 +17,11 @@ [Bindable] public var dataGrid:DataGrid; [Bindable] public var dataProvider:ArrayCollection; [Bindable] public var errorMessage:String = ""; + [Bindable] public var updaterObject:Object = null; + [Bindable] public var updater:Function = new Function(); // Game Data - [Bindable] public var style:int = 0; // 0:PeopleEntry, 1:PeopleViewing, 2:FishEntry, 3:CalculatedViewing + [Bindable] public var style:int = 0; // 0:People, 1:Fish, 2:Calculated [Bindable] public var numBays:int = 3; [Bindable] public var numColumns:int = -1; [Bindable] public var numFields:int = 15; @@ -27,6 +29,7 @@ [Bindable] public var maxValue:int = 5; [Bindable] public var groupSize:int = 4; [Bindable] public var finished:Boolean = false; + [Bindable] public var isEntry:Boolean = false; // for lining up grids [Bindable] public var minimumWidth:int = 160; @@ -37,6 +40,10 @@ public function init():void { + labels.removeAllChildren(); + removeAllChildren(); + addChild(labels); + createGrid(); fillGridColumns(); fillGridFields(); @@ -73,10 +80,12 @@ public function changed(event:Object=null):void { - if((style == 0) || (style == 2)) // 0:PeopleEntry, 2:FishEntry + if(isEntry && style != 2) // NOT 2:Calculated { errorCheck(); } + try{updater.call(updaterObject);} + catch(err:Error){/* Alert.show(err.message+"\n"+err.getStackTrace()); */} redraw(); } @@ -135,7 +144,7 @@ newDataGridColumn.headerText = ""+(columnNumber+1); // 1, 2, 3, ... newDataGridColumn.dataField = "day"+(columnNumber+1); // day1, day2, day3, ... - newDataGridColumn.editable = ((style == 0) || (style == 2)); // 0:PeopleEntry, 2:FishEntry + newDataGridColumn.editable = (isEntry && ((style == 0) || (style == 1))); // 0:People, 1:Fish newDataGridColumn.draggable = false; newDataGridColumn.sortable = false; newDataGridColumn.resizable = false; @@ -145,7 +154,7 @@ } dataGrid.columns = columnArray; - dataGrid.editable = ((style == 0) || (style == 2)); // 0:PeopleEntry, 2:FishEntry + dataGrid.editable = (isEntry && ((style == 0) || (style == 1))); // 0:People, 1:Fish } private function fillGridFields():void @@ -153,9 +162,9 @@ dataProvider = new ArrayCollection(); var bayNumber:int = 0; - if(style==0 || style==1) // 0:PeopleEntry, 1:PeopleViewing + if(style==0) // 0:People { - if(style==0) + if(isEntry) { addLabel(" <b>Predict</b>:",true); } @@ -173,9 +182,16 @@ addField(); } } - else if(style==2) + else if(style==1) { - addLabel(" <b>Predict:</b>",true); + if(isEntry) + { + addLabel(" <b>Predict</b>:",true); + } + else + { + addLabel(" <b>You Predicted</b>:",true); + } for(bayNumber=0; bayNumber<numBays; bayNumber++) { @@ -183,7 +199,7 @@ addField(); } } - else if(style==3) + else if(style==2) { addLabel(" <b>We calculate that:</b>",true); @@ -207,14 +223,13 @@ { switch(style) { - case(0): - case(1): // 0:PeopleEntry, 1:PeopleViewing + case(0): // 0:People dataGrid.height = (23)*(numBays+2)-1; break; - case(2): // 2:FishEntry + case(1): // 2:Fish dataGrid.height = (23)*(numBays+1); break; - case(3): // 3:CalculatedViewing + case(2): // 3:Calculated dataGrid.height = (23)*(numBays+4)-3; break; } @@ -243,13 +258,13 @@ error = true; markError(field,column); } - else if(style == 0) // 0:PeopleEntry + else if(style == 0) // 0:People { colSum += Number(value); } } - if(!error && style == 0 && colSum != groupSize-1) // 0:PeopleEntry + if(!error && style == 0 && colSum != groupSize-1) // 0:People { errorMessage = "Sum of all columns must be exactly "+(groupSize-1)+"."; error = true; @@ -273,7 +288,7 @@ } public function markError(field:Number, column:Number):void { - if(style != 0 && style != 2) return; // 0:PeopleEntry, 2:FishEntry + if(! (isEntry && (style == 0 || style == 1)) ) return; // 0:People, 1:Fish DataGridColumn(dataGrid.columns[column]).setStyle("backgroundColor", "#ee82ee"); dataGrid.selectedIndex = field; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <kj...@us...> - 2009-06-17 19:19:37
|
Revision: 164 http://virtualcommons.svn.sourceforge.net/virtualcommons/?rev=164&view=rev Author: kjonas Date: 2009-06-17 19:19:34 +0000 (Wed, 17 Jun 2009) Log Message: ----------- Deletion of unused components, actionscript. Rehaul of structuring of /flex/src/customComponents to reflect structure of questions and their component parts. Further rename of StrategyDesignPage.mxml (originally PlannerPage.mxml) to the present StrategyDesignQuestionC.mxml Modified Paths: -------------- mentalmodels/trunk/flex/src/FisheryExperiment.mxml mentalmodels/trunk/flex/src/FisheryExperimentKalin.mxml mentalmodels/trunk/flex/src/TestForecast.mxml mentalmodels/trunk/flex/src/actionscript/PageDisplay.as mentalmodels/trunk/flex/src/customComponents/InstructionPage_TEMP.mxml Added Paths: ----------- mentalmodels/trunk/flex/src/customComponents/questions/ mentalmodels/trunk/flex/src/customComponents/questions/CategoricalQuestionC.mxml mentalmodels/trunk/flex/src/customComponents/questions/ForecastingQuestionC.mxml mentalmodels/trunk/flex/src/customComponents/questions/PsychometricQuestionC.mxml mentalmodels/trunk/flex/src/customComponents/questions/StrategyDesignQuestionC.mxml mentalmodels/trunk/flex/src/customComponents/questions/TextQuestionC.mxml mentalmodels/trunk/flex/src/customComponents/questions/components/ mentalmodels/trunk/flex/src/customComponents/questions/components/ForecastComponent.mxml mentalmodels/trunk/flex/src/customComponents/questions/components/Planner.mxml mentalmodels/trunk/flex/src/customComponents/questions/components/PlannerRow.mxml mentalmodels/trunk/flex/src/customComponents/questions/components/Slider.mxml mentalmodels/trunk/flex/src/customComponents/questions/components/SliderImage.png Removed Paths: ------------- mentalmodels/trunk/flex/src/Forecasting.mxml mentalmodels/trunk/flex/src/MME.mxml mentalmodels/trunk/flex/src/Mental.mxml mentalmodels/trunk/flex/src/Socio_Demographic_Information.mxml mentalmodels/trunk/flex/src/Socio_demographic.mxml mentalmodels/trunk/flex/src/actionscript/RoundConfig.as mentalmodels/trunk/flex/src/customComponents/CategoricalQuestionC.mxml mentalmodels/trunk/flex/src/customComponents/Forecast.mxml mentalmodels/trunk/flex/src/customComponents/Forecast1.mxml mentalmodels/trunk/flex/src/customComponents/Forecast2.mxml mentalmodels/trunk/flex/src/customComponents/ForecastComponent.mxml mentalmodels/trunk/flex/src/customComponents/ForecastPage_TEMP.mxml mentalmodels/trunk/flex/src/customComponents/ForecastingQuestionC.mxml mentalmodels/trunk/flex/src/customComponents/LongHScale.mxml mentalmodels/trunk/flex/src/customComponents/LongScale.mxml mentalmodels/trunk/flex/src/customComponents/Planner.mxml mentalmodels/trunk/flex/src/customComponents/PlannerPage.mxml mentalmodels/trunk/flex/src/customComponents/PlannerRow.mxml mentalmodels/trunk/flex/src/customComponents/PsychometricQuestionC.mxml mentalmodels/trunk/flex/src/customComponents/QuestionList.mxml mentalmodels/trunk/flex/src/customComponents/ShortHScale.mxml mentalmodels/trunk/flex/src/customComponents/Slider.mxml mentalmodels/trunk/flex/src/customComponents/TextQuestionC.mxml mentalmodels/trunk/flex/src/display.mxml mentalmodels/trunk/flex/src/images/ Modified: mentalmodels/trunk/flex/src/FisheryExperiment.mxml =================================================================== --- mentalmodels/trunk/flex/src/FisheryExperiment.mxml 2009-06-16 22:08:55 UTC (rev 163) +++ mentalmodels/trunk/flex/src/FisheryExperiment.mxml 2009-06-17 19:19:34 UTC (rev 164) @@ -19,7 +19,7 @@ <mx:State name="planner"> <mx:AddChild relativeTo="{content}"> - <comp:PlannerPage id="planner"/> + <comp:StrategyDesignPage id="planner"/> </mx:AddChild> </mx:State> @@ -233,9 +233,9 @@ return true; } } - if(obj is PlannerPage) + if(obj is StrategyDesignPage) { - if( (PlannerPage)(obj).accept() ) + if( (StrategyDesignPage)(obj).accept() ) { obj.visible = false; expiredContent.addChild(obj); Modified: mentalmodels/trunk/flex/src/FisheryExperimentKalin.mxml =================================================================== --- mentalmodels/trunk/flex/src/FisheryExperimentKalin.mxml 2009-06-16 22:08:55 UTC (rev 163) +++ mentalmodels/trunk/flex/src/FisheryExperimentKalin.mxml 2009-06-17 19:19:34 UTC (rev 164) @@ -1,7 +1,7 @@ <?xml version="1.0" encoding="utf-8"?> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:net="flash.net.*" xmlns:comp="customComponents.*" backgroundGradientAlphas="[1.0, 1.0]" backgroundGradientColors="[#FFFFFF, #B0B0FF]" - width="90%" height="70%" clipContent="false" layout="absolute" + width="100%" height="100%" clipContent="false" layout="absolute" currentState="socioDemographic" initialize="init()"> <mx:states> @@ -13,24 +13,12 @@ <mx:SetStyle target="{content}" name="horizontalCenter" value="0"/> </mx:State> - <mx:State name="planner"> - <mx:AddChild relativeTo="{content}"> - <comp:PlannerPage id="planner"/> - </mx:AddChild> - </mx:State> - <mx:State name="instructions"> <mx:AddChild relativeTo="{content}"> <comp:InstructionPage_TEMP id="instructions"/> </mx:AddChild> </mx:State> - <mx:State name="forecasting"> - <mx:AddChild relativeTo="{content}"> - <comp:ForecastPage_TEMP id="forecasting"/> - </mx:AddChild> - </mx:State> - <mx:State name="none"> </mx:State> </mx:states> @@ -39,11 +27,11 @@ <!-- <mx:Canvas id="content" x="5" y="5" width="750" height="470"/> --> <mx:Canvas id="content" x="5" y="5" width="1000" height="470"/> - <mx:Canvas id="expiredContent" x="-100" y="-100" width="1" height="1" visible="false"/> + <mx:Canvas id="expiredContent" x="-1" y="-1" width="1" height="1" visible="false"/> - <mx:Button id="btnBack" label="\xAB Back" click="back()" left="8" bottom="8"/> + <mx:Button id="btnBack" label="« Back" click="back()" left="8" bottom="8"/> <mx:Button id="btnAccept" label="Accept" click="accept()" left="375" bottom="10"/> - <mx:Button id="btnForward" label="Forward \xBB" click="forward()" right="8" bottom="8"/> + <mx:Button id="btnForward" label="Forward »" click="forward()" right="8" bottom="8"/> <mx:RemoteObject id="ss" destination="studentService" fault="faultHandler(event)" result="resultHandler(event)"/> @@ -131,7 +119,7 @@ // var msg:AsyncMessage = new AsyncMessage(); //var client:FlexClient = FlexClient.getInstance(); - //creating new msg with \x93New\x94 to get current state. + //creating new msg with "New"to get current state. //msg.body = "New"; //producer.send(msg); @@ -187,10 +175,6 @@ { (InstructionPage)(obj).forward(); } - if(obj is ForecastPage_TEMP) - { - (ForecastPage_TEMP)(obj).forward(); - } return false; } @@ -207,9 +191,9 @@ { obj.visible = false; expiredContent.addChild(obj); - currentState = "planner"; - var info:SocioDemographicPage = SocioDemographicPage(obj); + currentState = "instructions"; + var info:SocioDemographicPage = SocioDemographicPage(obj); /* Alert.show(info.getGender()); Alert.show(info.getMajor()); Alert.show(info.getSemester()); @@ -219,34 +203,12 @@ return true; } } - if(obj is PlannerPage) - { - if( (PlannerPage)(obj).accept() ) - { - obj.visible = false; - expiredContent.addChild(obj); - currentState = "instructions"; - - return true; - } - } if(obj is InstructionPage_TEMP) { if( (InstructionPage_TEMP)(obj).accept() ) { obj.visible = false; expiredContent.addChild(obj); - currentState = "forecasting"; - //consumer.subscribe(); - return true; - } - } - if(obj is ForecastPage_TEMP) - { - if( (ForecastPage_TEMP)(obj).accept() ) - { - obj.visible = false; - expiredContent.addChild(obj); currentState = "none"; //consumer.subscribe(); return true; Deleted: mentalmodels/trunk/flex/src/Forecasting.mxml =================================================================== --- mentalmodels/trunk/flex/src/Forecasting.mxml 2009-06-16 22:08:55 UTC (rev 163) +++ mentalmodels/trunk/flex/src/Forecasting.mxml 2009-06-17 19:19:34 UTC (rev 164) @@ -1,53 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml" width="100%" height="100%" xmlns:local="*" xmlns:comp="customComponents.*"> - <mx:Grid top="10" bottom="10" right="10" left="10"> - <mx:GridRow width="100%" height="100%"> - <mx:GridItem width="100%" height="100%"> - <mx:VDividedBox width="100%" height="100%" id="vdboxOuter" liveDragging="false"> - <mx:VBox width="100%" height="50%" id="vboxLeftInnerDown" verticalGap="20"> - <mx:VBox width="100%" height="50%" id="vboxLeftInnerUpper" verticalGap="20"> - <mx:Image id="imgIsland" source="../libs/island.png"/> - <mx:ComboBox width="50%" id="cmbUpper"></mx:ComboBox> - </mx:VBox> - <mx:TextArea width="50%" height="70%"/> - <mx:ComboBox width="50%"></mx:ComboBox> - </mx:VBox> - </mx:VDividedBox> - </mx:GridItem> - <mx:GridItem width="100%" height="100%"> - <mx:VBox width="100%" height="100%" id="vboxRightSideMainContainer" verticalGap="10"> - <mx:VBox width="100%" height="20%" id="vboxRightInnerUpper" verticalGap="20"> - <mx:Form width="100%" height="8%" id="frmGeneralInfoOfPlayer_Time"> - <mx:FormItem label="Clock" horizontalAlign="right" fontSize="14" fontWeight="bold"> - <!-- <mx:Text id="txtclock" text="10:50"/> --> - <comp:TimeLabel/> - </mx:FormItem> - <mx:FormItem label="Round Number:" horizontalAlign="right" fontSize="14" fontWeight="bold"> - <mx:Text id="txtroundno" text="1"/> - </mx:FormItem> - <mx:FormItem label="You Are Player Number:" fontSize="14" fontWeight="bold"> - <mx:Text id="txtplayerno" text="2"/> - </mx:FormItem> - <mx:FormItem label="You Are in Group Number:" fontSize="14" fontWeight="bold"> - <mx:Text id="txtgroupno" text="3"/> - </mx:FormItem> - - </mx:Form> - <mx:ProgressBar id="progressbarRoundInfo" label="Round" width="100%" height="10%" minimum="0" maximum="100" indeterminate="false" enabled="true"/> - </mx:VBox> - <mx:VBox width="100%" height="70%" id="vboxRightInnerDown" verticalGap="20"> - <mx:Form width="100%" height="90%" id="frmSurvey"> - <mx:FormHeading label="Survey Questions"/> - <mx:TextArea id="txtaSurvey" width="100%" height="100%" wordWrap="true"/> - </mx:Form> - <mx:HBox width="100%" height="10%" id="hboxButtons" horizontalAlign="center" horizontalGap="20" verticalAlign="middle"> - <mx:Button label="Previous" fontSize="14" id="btnPrevious"/> - <mx:Button label="Next" fontSize="14" id="btnNext"/> - </mx:HBox> - </mx:VBox> - </mx:VBox> - </mx:GridItem> - </mx:GridRow> - </mx:Grid> - -</mx:Canvas> Deleted: mentalmodels/trunk/flex/src/MME.mxml =================================================================== --- mentalmodels/trunk/flex/src/MME.mxml 2009-06-16 22:08:55 UTC (rev 163) +++ mentalmodels/trunk/flex/src/MME.mxml 2009-06-17 19:19:34 UTC (rev 164) @@ -1,104 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" - backgroundGradientAlphas="[1.0, 1.0]" - backgroundGradientColors="[#9DDBED, #BFED9D]" - xmlns:ns1="*" - pageTitle="Fishery Experiment"> - - <mx:Script> - <![CDATA[ - import mx.collections.ArrayCollection; - import actionscript.RoundConfig; - import mx.controls.Alert; - import mx.rpc.events.ResultEvent; - import mx.rpc.events.FaultEvent; - - // request config data from server - private var rndConfig:RoundConfig = getConfig(); - - public function getConfig():RoundConfig - { - // temporary fix: - return new RoundConfig( 1, - new ArrayCollection([0.5, 0.15, 0.05]), - new ArrayCollection([10, 20, 30]), - new ArrayCollection([5, 10, 15])); - } - - [Bindable] public var outputresp : Boolean; - private function resultHandler(event:ResultEvent):void - { - outputresp = event.result as Boolean; - } - - private function faultHandler(event:FaultEvent):void - { - Alert.show(event.fault.faultDetail); - } - - /*private function getData():void - { - outputresp = ss.getStudentFname(); - - }*/ - - private function save():void - { - - changeState(); - /*Alert.show("In save() function"); - Alert.show("year of birth is " + socio_demographic_information1.txtipYOB.text); - Alert.show(socio_demographic_information1.txtipMajor.text); - Alert.show(socio_demographic_information1.study.selectedValue.toString());*/ - //Alert.show(socio_demographic_information1.female.selected?'Correct Answer!':'Wrong Answer', 'Result'); - if(ss.createStudent(socio_demographic_information1.txtipYOB.text, socio_demographic_information1.txtipMajor.text,"Female",socio_demographic_information1.study.selectedValue.toString())) - { - Alert.show("Record is sucessfully added!"); - } - else - Alert.show("Record is NOT sucessfully added!"); - - } - - private function changeState():void - { - this.currentState = 'forecasting'; - } - - - ]]> - </mx:Script> - - <mx:states> - <mx:State name="forecasting"> - <mx:RemoveChild target="{socio_demographic_information1}"/> - <mx:RemoveChild target="{hbox1}"/> - <mx:AddChild relativeTo="{containerContent}" position="lastChild"> - <ns1:Forecasting top="10" bottom="10" right="10" left="10" id="forecasting1"> - </ns1:Forecasting> - </mx:AddChild> - </mx:State> - </mx:states> - <mx:Canvas left="10" right="10" bottom="10" top="10" id="containerMain" label="OutsideContainer"> - <mx:VBox right="10" top="10" bottom="10" left="10"> - <mx:HBox width="100%" horizontalAlign="center" verticalAlign="middle" id="hboxheading"> - <mx:Label text="Fishery Experiment" id="lblHeading" enabled="true" fontSize="36" textAlign="center" fontWeight="bold" color="#4D992C"/> - </mx:HBox> - <mx:Canvas width="100%" height="90%" id="containerContent"> - <ns1:Socio_Demographic_Information top="10" left="10" right="0" bottom="10" id="socio_demographic_information1"> - </ns1:Socio_Demographic_Information> - - <mx:HBox x="42" width="100%" height="10%" verticalAlign="bottom" horizontalAlign="center" bottom="5" id="hbox1"> - <mx:Button label="Submit" id="btnSubmit_Socio_Demographic_Info" click="save()" fontSize="12"/> - </mx:HBox> - </mx:Canvas> - <mx:HBox width="100%" id="hboxfooter" horizontalAlign="center" verticalAlign="bottom"> - <mx:Text text="School of Human Evolution & Social Change - Tempe, AZ 85287-2402 - T: 480-965-6213 / Fax: 480-965-7671" - id="txtFooter"/> - </mx:HBox> - </mx:VBox> - </mx:Canvas> - <mx:RemoteObject id="ss" destination="studentservice" fault="faultHandler(event)" result="resultHandler(event)"/> -</mx:Application> Deleted: mentalmodels/trunk/flex/src/Mental.mxml =================================================================== --- mentalmodels/trunk/flex/src/Mental.mxml 2009-06-16 22:08:55 UTC (rev 163) +++ mentalmodels/trunk/flex/src/Mental.mxml 2009-06-17 19:19:34 UTC (rev 164) @@ -1,69 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical" backgroundGradientAlphas="[1.0, 1.0]" backgroundGradientColors="[#ACD1EE, #D989E5]"> - <mx:Label text="Socio-demographic Information" id="lblHeading" enabled="true" fontSize="16" color="#230869" textAlign="center" fontWeight="bold"/> - - - <mx:VBox height="100%" id="vboxGatherInfo"> - <mx:HBox width="100%" id="hboxSubHeading"> - <mx:Label text="Before starting the actual experiment, we would like to ask you for some general information." id="lblSubHeading" fontFamily="Verdana" fontSize="12" height="5%" fontWeight="bold" color="#0D18A9"/> - </mx:HBox> - <mx:RadioButtonGroup id="radiogroupGender"/> - <mx:HBox width="100%" id="hboxGender" label="Gender" height="5%" verticalAlign="middle"> - <mx:Label text="Gender:" id="lblGender" fontFamily="Verdana" fontSize="12"/> - <mx:RadioButtonGroup id="radiogroup1Gender"/> - <mx:RadioButton label="Female" groupName="radiogroupGender" id="radioFemale" fontFamily="Verdana" fontSize="12"/> - <mx:RadioButton label="Male" groupName="radiogroup1Gender" id="radioMale" fontFamily="Verdana" fontSize="12"/> - </mx:HBox> - <mx:HBox width="100%" id="hboxBirthYear" height="5%" horizontalAlign="left" verticalAlign="middle"> - <mx:Label text="Year of Birth:" id="lblBirthYear" fontFamily="Verdana" fontSize="12"/> - <mx:ComboBox id="cmbBirthYear" fontSize="12"> - <mx:dataProvider> - <!-- Ask Robert for the range: make combo box as text box 4 digit --> - <mx:Array> - <mx:String>1980</mx:String> - <mx:String>1981</mx:String> - <mx:String>1982</mx:String> - <mx:String>1983</mx:String> - <mx:String>1984</mx:String> - <mx:String>1985</mx:String> - </mx:Array> - - </mx:dataProvider> - - </mx:ComboBox> - - - </mx:HBox> - <mx:HBox width="100%" id="hboxStudySubject" height="5%" verticalAlign="middle"> - <mx:Label text="What is your major?" id="lblStudySubject" fontFamily="Verdana" fontSize="12"/> - <mx:TextInput id="txtMajor" editable="true" enabled="true"/> - - - </mx:HBox> - - <mx:HBox width="100%" id="hboxethnicity" height="5%" verticalAlign="middle"> - <mx:Label text="In which year your are you in your study?" id="lblEthnicity" fontFamily="Verdana" fontSize="12"/> - <mx:ComboBox id="cmbEthnicity" fontSize="12"> - <mx:dataProvider> - <!-- Ask Robert for this one also --> - <mx:Array> - <mx:String>Freshman</mx:String> - <mx:String>Sophomore</mx:String> - <mx:String>Junior</mx:String> - <mx:String>Senior</mx:String> - - </mx:Array> - - </mx:dataProvider> - - </mx:ComboBox> - - - </mx:HBox> - <mx:HBox width="100%" height="5%" id="hboxSubmit" verticalAlign="middle" horizontalAlign="center"> - <mx:Button label="Submit" id="butSubmit"/> - </mx:HBox> - - </mx:VBox> - -</mx:Application> Deleted: mentalmodels/trunk/flex/src/Socio_Demographic_Information.mxml =================================================================== --- mentalmodels/trunk/flex/src/Socio_Demographic_Information.mxml 2009-06-16 22:08:55 UTC (rev 163) +++ mentalmodels/trunk/flex/src/Socio_Demographic_Information.mxml 2009-06-17 19:19:34 UTC (rev 164) @@ -1,48 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml" width="698" height="407" textAlign="center"> - <mx:VBox id="vboxouterBox" horizontalAlign="center" verticalAlign="middle" width="100%" height="50%" horizontalCenter="0" top="10" verticalGap="0"> - - - <mx:Form top="5" bottom="5" id="frmSocioDemographic" right="5" left="5" width="50%" height="50%" textAlign="center"> - <mx:FormHeading label="Socio DemographicInformation " id="frmheadingSocioDemographicInfo" fontSize="24" textAlign="left" themeColor="#1200FF" color="#186BE8" width="5%" height="10%"/> - <mx:FormItem id="frmitemStudy" horizontalAlign="left" fontSize="14" required="true"> - <mx:Label text="What year are you in your study?"/> - <mx:RadioButtonGroup id="study"/> - <mx:RadioButton id="freshman" groupName="{study}"> - <mx:label>Freshman</mx:label> - </mx:RadioButton> - <mx:RadioButton id="sophomore" groupName="{study}"> - <mx:label>Sophomore</mx:label> - </mx:RadioButton> - <mx:RadioButton id="junior" groupName="{study}"> - <mx:label>Junior</mx:label> - </mx:RadioButton> - <mx:RadioButton id="senior" groupName="{study}"> - <mx:label>Senior</mx:label> - </mx:RadioButton> - - - - </mx:FormItem> - <mx:FormItem label="What is your major?" id="frmitemMajor" horizontalAlign="left" fontSize="14" required="true"> - <mx:TextInput id="txtipMajor"/> - </mx:FormItem> - <mx:FormItem label="Year of Birth" id="frmitemYOB" horizontalAlign="left" fontSize="14" required="true"> - <mx:TextInput id="txtipYOB" maxChars="4"/> - </mx:FormItem> - <mx:FormItem label="Gender" id="frmitemGender" horizontalAlign="left" fontSize="14" required="true"> - <mx:RadioButtonGroup id="gender"/> - <mx:RadioButton id="male" groupName="{gender}"> - <mx:label>Male</mx:label> - </mx:RadioButton> - <mx:RadioButton id="female" groupName="{gender}"> - <mx:label>Female</mx:label> - </mx:RadioButton> - - </mx:FormItem> - - </mx:Form> - - - </mx:VBox> -</mx:Canvas> Deleted: mentalmodels/trunk/flex/src/Socio_demographic.mxml =================================================================== --- mentalmodels/trunk/flex/src/Socio_demographic.mxml 2009-06-16 22:08:55 UTC (rev 163) +++ mentalmodels/trunk/flex/src/Socio_demographic.mxml 2009-06-17 19:19:34 UTC (rev 164) @@ -1,72 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml" width="100%" height="80%"> - - <mx:VBox height="100%" id="vboxGatherInfo" width="100%"> - <mx:HBox horizontalAlign="center" verticalAlign="middle" id="hboxSocio_demographic_info"> - <mx:Label text="Socio-demographic Information" id="lblHeading" enabled="true" fontSize="16" color="#230869" textAlign="center" fontWeight="bold"/> - </mx:HBox> - <mx:HBox width="100%" id="hboxSubHeading"> - <mx:Label text="Before starting the actual experiment, we would like to ask you for some general information." id="lblSubHeading" fontFamily="Verdana" fontSize="12" height="5%" fontWeight="bold" color="#0D18A9"/> - </mx:HBox> - <mx:RadioButtonGroup id="radiogroupGender"/> - <mx:HBox width="100%" id="hboxGender" label="Gender" height="5%" verticalAlign="middle" horizontalAlign="center"> - <mx:Label text="Gender:" id="lblGender" fontFamily="Verdana" fontSize="12"/> - <mx:RadioButtonGroup id="radiogroup1Gender"/> - <mx:RadioButton label="Female" groupName="radiogroupGender" id="radioFemale" fontFamily="Verdana" fontSize="12"/> - <mx:RadioButton label="Male" groupName="radiogroup1Gender" id="radioMale" fontFamily="Verdana" fontSize="12"/> - </mx:HBox> - <mx:HBox width="100%" id="hboxBirthYear" height="5%" horizontalAlign="center" verticalAlign="middle"> - <mx:Label text="Year of Birth:" id="lblBirthYear" fontFamily="Verdana" fontSize="12"/> - <mx:ComboBox id="cmbBirthYear" fontSize="12"> - <mx:dataProvider> - <!-- Ask Robert for the range: make combo box as text box 4 digit --> - <mx:Array> - <mx:String>1980</mx:String> - <mx:String>1981</mx:String> - <mx:String>1982</mx:String> - <mx:String>1983</mx:String> - <mx:String>1984</mx:String> - <mx:String>1985</mx:String> - </mx:Array> - - </mx:dataProvider> - - </mx:ComboBox> - - - </mx:HBox> - <mx:HBox width="100%" id="hboxStudySubject" height="5%" verticalAlign="middle" horizontalAlign="center"> - <mx:Label text="What is your major?" id="lblStudySubject" fontFamily="Verdana" fontSize="12"/> - <mx:TextInput id="txtMajor" editable="true" enabled="true"/> - - - </mx:HBox> - - <mx:HBox width="100%" id="hboxethnicity" height="5%" verticalAlign="middle" horizontalAlign="center"> - <mx:Label text="In which year your are you in your study?" id="lblEthnicity" fontFamily="Verdana" fontSize="12"/> - <mx:ComboBox id="cmbEthnicity" fontSize="12"> - <mx:dataProvider> - <!-- Ask Robert for this one also --> - <mx:Array> - <mx:String>Freshman</mx:String> - <mx:String>Sophomore</mx:String> - <mx:String>Junior</mx:String> - <mx:String>Senior</mx:String> - - </mx:Array> - - </mx:dataProvider> - - </mx:ComboBox> - - - </mx:HBox> - <mx:HBox width="100%" height="5%" id="hboxSubmit" verticalAlign="middle" horizontalAlign="center"> - <mx:Button label="Submit" id="butSubmit"/> - </mx:HBox> - - </mx:VBox> - - - -</mx:Canvas> Modified: mentalmodels/trunk/flex/src/TestForecast.mxml =================================================================== --- mentalmodels/trunk/flex/src/TestForecast.mxml 2009-06-16 22:08:55 UTC (rev 163) +++ mentalmodels/trunk/flex/src/TestForecast.mxml 2009-06-17 19:19:34 UTC (rev 164) @@ -1,18 +1,18 @@ <?xml version="1.0" encoding="utf-8"?> -<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:comp="customComponents.*" initialize="init()"> +<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:qComp="customComponents.questions.components.*" xmlns:quest="customComponents.questions.*" initialize="init()"> <mx:VBox id="content" minWidth="160"> - <comp:ForecastComponent id="forecastComponent0" numColumns="15" numBays="3" style="0" minimumWidth="{content.minWidth}"/> - <comp:ForecastComponent id="forecastComponent1" numColumns="15" numBays="3" style="1" minimumWidth="{content.minWidth}"/> - <comp:ForecastComponent id="forecastComponent2" numColumns="6" numBays="3" style="2" minimumWidth="{content.minWidth}"/> - <comp:ForecastComponent id="forecastComponent3" numColumns="6" numBays="3" style="3" minimumWidth="{content.minWidth}"/> + <qComp:ForecastComponent id="forecastComponent0" numColumns="15" numBays="3" style="0" minimumWidth="{content.minWidth}"/> + <qComp:ForecastComponent id="forecastComponent1" numColumns="15" numBays="3" style="1" minimumWidth="{content.minWidth}"/> + <qComp:ForecastComponent id="forecastComponent2" numColumns="6" numBays="3" style="2" minimumWidth="{content.minWidth}"/> + <qComp:ForecastComponent id="forecastComponent3" numColumns="6" numBays="3" style="3" minimumWidth="{content.minWidth}"/> <mx:HBox> <mx:Button label="Save" click="save()"/> <mx:Button label="Load" click="load()"/> </mx:HBox> - <comp:PlannerPage id="planner"/> + <quest:StrategyDesignQuestionC id="planner"/> </mx:VBox> Modified: mentalmodels/trunk/flex/src/actionscript/PageDisplay.as =================================================================== --- mentalmodels/trunk/flex/src/actionscript/PageDisplay.as 2009-06-16 22:08:55 UTC (rev 163) +++ mentalmodels/trunk/flex/src/actionscript/PageDisplay.as 2009-06-17 19:19:34 UTC (rev 164) @@ -1,10 +1,10 @@ // ActionScript file package actionscript { - import customComponents.TextQuestionC; - import customComponents.ForecastingQuestionC; - import customComponents.CategoricalQuestionC; - import customComponents.PsychometricQuestionC; + import customComponents.questions.TextQuestionC; + import customComponents.questions.ForecastingQuestionC; + import customComponents.questions.CategoricalQuestionC; + import customComponents.questions.PsychometricQuestionC; import flash.display.DisplayObject; Deleted: mentalmodels/trunk/flex/src/actionscript/RoundConfig.as =================================================================== --- mentalmodels/trunk/flex/src/actionscript/RoundConfig.as 2009-06-16 22:08:55 UTC (rev 163) +++ mentalmodels/trunk/flex/src/actionscript/RoundConfig.as 2009-06-17 19:19:34 UTC (rev 164) @@ -1,35 +0,0 @@ -package actionscript -{ - import mx.collections.ArrayCollection; - - - public class RoundConfig - { - private var number:Number; // what round is it? - - // bay information - private var bayRegen:ArrayCollection; - private var bayMax:ArrayCollection; - private var bayStart:ArrayCollection; - - public function RoundConfig(number:Number, bayRegen:ArrayCollection, bayMax:ArrayCollection, bayStart:ArrayCollection) - { - this.number = number; - this.bayRegen = bayRegen; - this.bayMax = bayMax; - this.bayStart = bayStart; - } - - public function getRegen():ArrayCollection - { return this.bayRegen; } - - public function getMax():ArrayCollection - { return this.bayMax; } - - public function getStart():ArrayCollection - { return this.bayStart; } - - public function getNumber():Number - { return this.number; } - } -} \ No newline at end of file Deleted: mentalmodels/trunk/flex/src/customComponents/CategoricalQuestionC.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/CategoricalQuestionC.mxml 2009-06-16 22:08:55 UTC (rev 163) +++ mentalmodels/trunk/flex/src/customComponents/CategoricalQuestionC.mxml 2009-06-17 19:19:34 UTC (rev 164) @@ -1,94 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:as="actionscript.*"> - - <mx:String id="title"></mx:String> - <mx:String id="description"></mx:String> - <mx:VBox id="headers"> - <mx:Label/> - <mx:Label htmlText="{htmlBold(title)}"/> - <mx:Text htmlText="{description}"/> - </mx:VBox> - <mx:Script> <![CDATA[ - public function htmlBold(str:String):String - { - if(str==null)return null; - return "<font size=\"12px\">" + str + "</font>"; - } - ]]> </mx:Script> - - <mx:HBox id="content"> - <mx:ComboBox id="comboTopic" - dataProvider="{topics}" selectedIndex="0"/> - <mx:ComboBox id="comboSpecific" - dataProvider="{specifics.getItemAt(fix(comboTopic.selectedIndex, specifics))}"/> - </mx:HBox> - - <mx:Script> - <![CDATA[ - import actionscript.FishUtil; - import actionscript.CategoricalQuestion; - - private function fix(index:int, list:ArrayCollection):int - { - return FishUtil.fix(index, list); - } - - public function save():ArrayCollection - { - var saveArray:ArrayCollection = new ArrayCollection(); - saveArray.addItem(comboTopic.selectedIndex); - saveArray.addItem(comboSpecific.selectedIndex); - return saveArray; - } - - public function load(loadArray:ArrayCollection):void - { - comboTopic.selectedIndex = loadArray.getItemAt(0) as int; - comboSpecific.selectedIndex = loadArray.getItemAt(1) as int; - } - - public function loadFromQuestion(question:CategoricalQuestion):void - { - description = question.question; - - initialize(); -// init(); - } - - ]]> - </mx:Script> - - <!-- the selected element of this array determines which of the elements of - "specifics" will be used as the dataProvider --> - <mx:ArrayCollection id="topics"> - <mx:String>- Select -</mx:String> - <mx:String>topic1</mx:String> - <mx:String>topic2</mx:String> - <mx:String>topic3</mx:String> - </mx:ArrayCollection> - - <!-- each element of this ArrayCollection will serve as a dataProvider --> - <mx:ArrayCollection id="specifics"> - <mx:ArrayCollection id="topic0"> - </mx:ArrayCollection> - <mx:ArrayCollection id="topic1"> - <mx:String>- Select -</mx:String> - <mx:String>specific1.0</mx:String> - <mx:String>specific1.1</mx:String> - <mx:String>specific1.2</mx:String> - </mx:ArrayCollection> - <mx:ArrayCollection id="topic2"> - <mx:String>- Select -</mx:String> - <mx:String>specific2.0</mx:String> - <mx:String>specific2.1</mx:String> - <mx:String>specific2.2</mx:String> - </mx:ArrayCollection> - <mx:ArrayCollection id="topic3"> - <mx:String>- Select -</mx:String> - <mx:String>specific3.0</mx:String> - <mx:String>specific3.1</mx:String> - <mx:String>specific3.2</mx:String> - </mx:ArrayCollection> - </mx:ArrayCollection> - -</mx:VBox> Deleted: mentalmodels/trunk/flex/src/customComponents/Forecast.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/Forecast.mxml 2009-06-16 22:08:55 UTC (rev 163) +++ mentalmodels/trunk/flex/src/customComponents/Forecast.mxml 2009-06-17 19:19:34 UTC (rev 164) @@ -1,161 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml" initialize="init()"> - - <mx:ArrayCollection id="sched"/> - - <mx:HBox> - <mx:VBox id="labels"> - </mx:VBox> - - <mx:DataGrid id="dgMain" editable="true" textAlign="right" dataProvider="{sched}" - change="changed()" - horizontalScrollPolicy="on" - verticalScrollPolicy="off"/> - <mx:Button label="{dgMain.columns.length}" click="clicked()"/> - </mx:HBox> - - <mx:Script> - <![CDATA[ - import mx.utils.StringUtil; - import mx.controls.dataGridClasses.DataGridColumn; - - private var colIndex:Number=0; - [Bindable] - public var numColumns:Number = 3; - [Bindable] - public var numFields:Number = 6; - [Bindable] - public var finished:Boolean = false; - - public function init():void - { - createColumns(); - - /* dgMain.selectedIndex = 0; dgMain.selectedItem.day1 = 5; - dgMain.selectedIndex = 1; dgMain.selectedItem.day1 = 10; - dgMain.selectedIndex = 2; dgMain.selectedItem.day1 = 15; - dgMain.selectedIndex = -1; */ - - setItem(0,0,5); - setItem(1,0,10); - setItem(2,0,15); - } - private function createColumns():void - { - var tempArray:Array = dgMain.columns; - var i:Number; - var temp:DataGridColumn; - - for(i=0; i<numColumns; i++) - { - temp = new DataGridColumn("day"+(i+1)); - - temp.headerText = ""+(i+1); - temp.dataField = "day"+(i+1); - temp.editable = false; - temp.draggable = false; - temp.sortable = false; - temp.resizable = false; - temp.width = 30; - - if(0 == i) - { - temp.editable = true; - } - - tempArray[i] = temp; - - // add day1, day2, etc to each field - for(var j:Number=0; j<numFields; j++) - { - if(0 == i) - { - var field:Object = new Object(); - sched.addItem(field); - } - } - } - dgMain.columns = tempArray; - - dgMain.height = 23*(numFields+1)+17 - dgMain.width = 30*Math.min(numColumns, 6)+1 - } - - public function clicked():void - { - for(var i:Number = 0; i < numFields; i++) - { -// dgMain.selectedIndex = i; -// dgMain.selectedItem.day2 = Number(dgMain.selectedItem.day1)*0; - var num:Object = getItem(i, colIndex); - var col:DataGridColumn = dgMain.columns[colIndex]; - if(num == null || !(num is Number)) - { - col.setStyle("backgroundColor", "#FF0000"); - break; - } - else - { - col.setStyle("backgroundColor", "#FFFFFF"); - } - } - // all numbers in the current column are actually numbers - // after executing the above loop - -// dgMain.selectedItem.day3 = "success"; - if(i >= numFields) - { - changeColumn(); - dgMain.selectedIndex = -1; - } - } - - public function getItem(field:Number, col:Number):Object - { - return sched.getItemAt(field)["day"+(col+1)]; - } - public function setItem(field:Number, col:Number, value:Object):void - { - sched.getItemAt(field)["day"+(col+1)] = value; - } - - private function changeColumn():void - { - DataGridColumn(dgMain.columns[colIndex]).editable = false; - colIndex++; - if(colIndex == numColumns) - { - colIndex--; - finished = true; - } - DataGridColumn(dgMain.columns[colIndex]).editable = true; - } - - public function changed():void - { - // check the values of the current column - // and point out any errors (TextBox) - } - - private function invalidNum(n:Object):Boolean - { - if(n == null) return true; - - var pattern:RegExp = /^\d+$/; - var s:String = StringUtil.trim(String(n)); - -// debug.text = "."+n+"."+pattern.test(s)+(s is String); - - // if it does not match the pattern, it is invalid - return !pattern.test(s); - } - private function outOfBoundsNum(n:Object):Boolean - { - //return Number(n) < minValue || Number(n) > maxValue; - return false; - } - - ]]> - </mx:Script> - -</mx:VBox> Deleted: mentalmodels/trunk/flex/src/customComponents/Forecast1.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/Forecast1.mxml 2009-06-16 22:08:55 UTC (rev 163) +++ mentalmodels/trunk/flex/src/customComponents/Forecast1.mxml 2009-06-17 19:19:34 UTC (rev 164) @@ -1,71 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:comp="customComponents.*" initialize="init()"> - - <mx:HBox id="gridContainer"> - <mx:VBox id="labels"> - </mx:VBox> - - <!--<mx:DataGrid id="dgMain" editable="true" textAlign="right" dataProvider="{sched}" - change="changed()" click="changed()"/>--> - </mx:HBox> - - <mx:Label id="lbl" text="{dgh.errorMessage}"/> - <!--<mx:Label id="debug" text="{dgh.debug}"/>--> - - <mx:Script> - <![CDATA[ - import mx.controls.DataGrid; - import actionscript.DataGridHandler; - import mx.utils.StringUtil; - import mx.controls.dataGridClasses.DataGridColumn; - - [Bindable] - public var dgh:DataGridHandler; - - [Bindable] - public var numColumns:Number = 15; - [Bindable] - public var numFields:Number = 4; - [Bindable] - public var minValue:Number = 0; - [Bindable] - public var maxValue:Number = 10; - [Bindable] - public var colSum:Number = 30; - - private var errorMessage:String = null; - - public function init():void - { - dgh = new DataGridHandler(numFields,numColumns,minValue,maxValue,colSum); - gridContainer.addChildAt(dgh.grid, 1); - } - public function changed():void - { - dgh.changed(); - } - public function deactivate():void - { - dgh.deactivate(); - } - public function isFinished():Boolean - { - return dgh.isFinished(); - } - public function getItem(field:Number, col:Number):Object - { - return dgh.getItem(field, col); - } - public function setItem(field:Number, col:Number, value:Object):void - { - dgh.setItem(field, col, value); - } - public function clone():DataGrid - { - return dgh.clone(); - } - - ]]> - </mx:Script> - -</mx:VBox> Deleted: mentalmodels/trunk/flex/src/customComponents/Forecast2.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/Forecast2.mxml 2009-06-16 22:08:55 UTC (rev 163) +++ mentalmodels/trunk/flex/src/customComponents/Forecast2.mxml 2009-06-17 19:19:34 UTC (rev 164) @@ -1,290 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:comp="customComponents.*" creationComplete="init()"> - - <mx:ArrayCollection id="sched"/> - <mx:ArrayCollection id="schedPeople"/> - <mx:ArrayCollection id="calculated"/> - - <comp:Forecast1 id="newForecast1" visible="false" includeInLayout="false"/> - - <mx:HBox> - <mx:VBox id="labels"> - </mx:VBox> - - <mx:VBox id="dgRows" verticalGap="0"> - <mx:HBox id="dgRow1" horizontalGap="0"> - <mx:DataGrid id="dgMain" - editable="true" textAlign="right" dataProvider="{sched}" - change="changed()" click="changed()" - width="300" horizontalScrollPolicy="off" - verticalScrollPolicy="off"/> - </mx:HBox> - - <mx:HBox id="dgRow2"> - <!--<mx:DataGrid id="dgPeople" - editable="false" textAlign="right" dataProvider="{schedPeople}" - width="300" horizontalScrollPolicy="off" - verticalScrollPolicy="off"/>--> - </mx:HBox> - - <mx:HBox id="dgRow3"> - <!--<mx:DataGrid id="dgCalculated" headerHeight="1" - editable="false" textAlign="right" dataProvider="{calculated}" - width="300" horizontalScrollPolicy="off" - verticalScrollPolicy="off"/>--> - </mx:HBox> - </mx:VBox> - </mx:HBox> - - <mx:Label id="lbl"/> - - - <mx:Script> - <![CDATA[ - import actionscript.DataGridHandler; - import mx.controls.Button; - import mx.utils.StringUtil; - import mx.controls.dataGridClasses.DataGridColumn; - - [Bindable] public var numColumns:Number = 5; - [Bindable] public var numFields:Number = 3; - [Bindable] public var minValue:Number = 0; - [Bindable] public var maxValue:Number = 100; - [Bindable] public var oldForecast1:Forecast1 = null; - - private var dgCalculated:DataGridHandler = new DataGridHandler(numFields+3,numColumns); - - private var errorMessage:String = null; - private var colIndex:Number=0; - private var finished:Boolean = false; - - public function init():void - { - createColumns(); - getPeople(); - - setItem(0,0,5); - setItem(1,0,10); - setItem(2,0,15); - - dgCalculated.deactivate(); - dgRow3.addChild(dgCalculated.grid); - } - private function createColumns():void - { - var tempArray:Array = dgMain.columns; - var i:Number; - var temp:DataGridColumn; - - for(i=0; i<numColumns; i++) - { - temp = new DataGridColumn("day"+(i+1)); - - temp.headerText = ""+(i+1); - temp.dataField = "day"+(i+1); - temp.editable = false; - temp.draggable = false; - temp.sortable = false; - temp.resizable = false; - temp.width = 30; - - if(0 != i) - { - temp.editable = true; - } - - tempArray[i] = temp; - } - - dgMain.columns = tempArray; - - // add day1, day2, etc to each field - for(var j:Number=0; j<numFields; j++) - { - var field:Object = new Object(); - sched.addItem(field); - } - - dgMain.height = (23)*(numFields+1)+2; - } - - public function getPeople():void - { - if(oldForecast1 == null) - { - dgRow2.addChild(newForecast1.dgh.grid); - } - else - { - dgRow2.addChild(oldForecast1.clone()); - } - } - - public function getItem(field:Number, col:Number):Object - { - return this.sched.getItemAt(field)["day"+(col+1)]; - } - public function setItem(field:Number, col:Number, value:Object):void - { - this.sched.getItemAt(field)["day"+(col+1)] = value; - } - - public function changed():void - { - calculateValues(); - - markNoError(); - - var error:Boolean = false; - // check the values of the current column - // and point out any errors (TextBox) - for(var col:Number=0; col < numColumns && !error; col++) - { - var colStr:String = "day"+(col+1); - var colSum:Number = 0; - for(var field:Number=0; field < numFields && !error; field++) - { - var value:Object = getItem(field, col); - if(invalidNum(value)) - { - errorMessage = "Enter a value between "+minValue+" and "+maxValue+"."; - error = true; - markError(field,col); - } - else if(outOfBoundsNum(value)) - { - errorMessage = "Value must be between "+minValue+" and "+maxValue+"."; - error = true; - markError(field,col); - } - else - { - colSum += Number(value); - } - } - } - - if(error) - { - lbl.text = errorMessage; - } - else - { - lbl.text = "Complete."; - } - - } - private function invalidNum(n:Object):Boolean - { - if(n == null) return true; - - var pattern:RegExp = /^\d+$/; - var s:String = StringUtil.trim(String(n)); - -// debug.text = "."+n+"."+pattern.test(s)+(s is String); - - // if it does not match the pattern, it is invalid - return !pattern.test(s); - } - private function outOfBoundsNum(n:Object):Boolean - { - return Number(n) < minValue || Number(n) > maxValue; - } - - private function markError(field:Number, col:Number):void - { - DataGridColumn(dgMain.columns[col]).setStyle("backgroundColor", "#ee82ee"); - dgMain.selectedIndex = field; - } - private function markNoError():void - { - for(var col:Number=0; col < numColumns; col++) - { - DataGridColumn(dgMain.columns[col]).setStyle("backgroundColor", "#FFFFFF"); - } - dgMain.selectedIndex = -1; - } - - public function calculateValues():void - { - for(var col:Number=0; col < numColumns; col++) - { - var t_location:Number = 0; // get thru Planner, -1=harbor - - var t_capacity:Array = [10, 20, 30]; - var t_population:Array = new Array(3); - var t_people:Array = new Array(3); - - var t_fish_mined:Number = 0; - var t_fish_mined_total:Number = 0; - - //lbs in bay 1...N - for(var x:Number = 0; x < numFields; x++) - { - t_population[x] = getItem(x, col); //update fishies - t_people[x] = oldForecast1.getItem(x+1,col); //update fishers - if(x == t_location) - { - t_people[x]++; //add this player - } - - var t_fish_each:Number = 5*t_population[x]/t_capacity[x]; - var t_fish_mined_this:Number = t_people[x] * t_fish_each; - if(t_fish_mined_this > t_population[x]) - { - t_fish_each = t_population[x] / t_people[x]; - } - - if(x == t_location) - { - t_fish_mined = t_fish_each; - } - - dgCalculated.setItem(3+x,col,t_population[x]); - } - - //location - dgCalculated.setItem(0,col,t_location); - - //you get - dgCalculated.setItem(1,col, 5* t_fish_mined); // in USD$ - - //others get - dgCalculated.setItem(2,col, 5* (t_fish_mined_total - t_fish_mined)); - - } - - dgCalculated.grid.invalidateList(); - } - - public function isFinished():Boolean - { - for(var col:Number=0; col < numColumns; col++) - { - for(var x:Number = 0; x < numFields; x++) - { - if(getItem(x, col) <= 0) - { - return false; - } - } - } - return true; - } - - public function updateOld():void - { - try{ - dgRow2.removeAllChildren(); - dgRow2.addChild(oldForecast1.clone()); - } - catch(errObject:Error) - { - lbl.text = errObject.message + "\n" + errObject.getStackTrace(); - } - } - - ]]> - </mx:Script> - -</mx:VBox> Deleted: mentalmodels/trunk/flex/src/customComponents/ForecastComponent.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/ForecastComponent.mxml 2009-06-16 22:08:55 UTC (rev 163) +++ mentalmodels/trunk/flex/src/customComponents/ForecastComponent.mxml 2009-06-17 19:19:34 UTC (rev 164) @@ -1,292 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<mx:HBox xmlns:mx="http://www.adobe.com/2006/mxml" initialize="init()"> - - <mx:VBox id="labels" verticalGap="5" minWidth="{minimumWidth}" horizontalAlign="right"/> - - <mx:Script> - <![CDATA[ - import mx.controls.Alert; - import mx.events.FlexEvent; - import mx.controls.DataGrid; - import mx.collections.ArrayCollection; - import mx.controls.Label; - import mx.controls.dataGridClasses.DataGridColumn; - import mx.utils.StringUtil; - - // vital components - [Bindable] public var dataGrid:DataGrid; - [Bindable] public var dataProvider:ArrayCollection; - [Bindable] public var errorMessage:String = ""; - - // Game Data - [Bindable] public var style:int = 0; // 0:PeopleEntry, 1:PeopleViewing, 2:FishEntry, 3:CalculatedViewing - [Bindable] public var numBays:int = 3; - [Bindable] public var numColumns:int = -1; - [Bindable] public var numFields:int = 15; - [Bindable] public var minValue:int = 0; - [Bindable] public var maxValue:int = 5; - [Bindable] public var groupSize:int = 4; - [Bindable] public var finished:Boolean = false; - - // for lining up grids - [Bindable] public var minimumWidth:int = 160; - - // - // public accessible functions - // - - public function init():void - { - createGrid(); - fillGridColumns(); - fillGridFields(); - setGridHeight(); - addChild(dataGrid); - } - - public function save():ArrayCollection - { - var saveArray:ArrayCollection = new ArrayCollection(); - for(var field:int = 0; field < dataProvider.length; field++) - { - saveArray.addItem(new ArrayCollection()); - for(var column:int = 0; column < dataGrid.columnCount; column++) - { - (saveArray.getItemAt(field) as ArrayCollection).addItem(getItem(field, column)); - } - } - return saveArray; - } - - public function load(loadArray:ArrayCollection):void - { - for(var field:int = 0; field < loadArray.length && field < dataProvider.length; field++) - { - var loadSubArray:ArrayCollection = loadArray.getItemAt(field) as ArrayCollection; - for(var column:int = 0; column < loadSubArray.length && column < dataGrid.columnCount; column++) - { - setItem(field, column, loadSubArray.getItemAt(column)); - } - } - redraw(); - } - - public function changed(event:Object=null):void - { - if((style == 0) || (style == 2)) // 0:PeopleEntry, 2:FishEntry - { - errorCheck(); - } - redraw(); - } - - public function getItem(field:Number, col:Number):Object - { - return dataProvider.getItemAt(field)["day"+(col+1)]; - } - public function setItem(field:Number, col:Number, value:Object):void - { - dataProvider.getItemAt(field)["day"+(col+1)] = value; - } - - public function redraw():void - { - dataGrid.invalidateList(); - } - - // - // private Utility functions - // - - private function addLabel(text:String="", html:Boolean=false):void - { - var newLabel:Label = new Label(); - if(text != "" && !html) - { - newLabel.text = text; - } - else if(html) - { - newLabel.htmlText = text; - } - labels.addChild(newLabel); - } - - private function addField():void - { - dataProvider.addItem(new Object()); - } - - private function createGrid():void - { - dataGrid = new DataGrid(); - dataGrid.id = "dataGrid"; - dataGrid.editable = true; - dataGrid.enabled = true; - dataGrid.addEventListener("change", changed); - } - - private function fillGridColumns():void - { - var columnArray:Array = dataGrid.columns; - for(var columnNumber:int = 0; columnNumber < numColumns; columnNumber++) - { - var newDataGridColumn:DataGridColumn = new DataGridColumn("day"+(columnNumber+1)); - newDataGridColumn.headerText = ""+(columnNumber+1); // 1, 2, 3, ... - newDataGridColumn.dataField = "day"+(columnNumber+1); // day1, day2, day3, ... - - newDataGridColumn.editable = ((style == 0) || (style == 2)); // 0:PeopleEntry, 2:FishEntry - newDataGridColumn.draggable = false; - newDataGridColumn.sortable = false; - newDataGridColumn.resizable = false; - newDataGridColumn.width = 30; - - columnArray[columnNumber] = newDataGridColumn; - } - dataGrid.columns = columnArray; - - dataGrid.editable = ((style == 0) || (style == 2)); // 0:PeopleEntry, 2:FishEntry - } - - private function fillGridFields():void - { - dataProvider = new ArrayCollection(); - - var bayNumber:int = 0; - if(style==0 || style==1) // 0:PeopleEntry, 1:PeopleViewing - { - if(style==0) - { - addLabel(" <b>Predict</b>:",true); - } - else - { - addLabel(" <b>You Predicted</b>:",true); - } - - addLabel("# People in Harbor:"); - addField(); - - for(bayNumber=0; bayNumber<numBays; bayNumber++) - { - addLabel("# People in Bay " + (bayNumber+1) + ":"); - addField(); - } - } - else if(style==2) - { - addLabel(" <b>Predict:</b>",true); - - for(bayNumber=0; bayNumber<numBays; bayNumber++) - { - addLabel("# Fish in Bay " + (bayNumber+1) + "(AM):"); - addField(); - } - } - else if(style==3) - { - addLabel(" <b>We calculate that:</b>",true); - - addLabel("You will be in location #:"); - addField(); - addLabel("You will get USD:"); - addField(); - addLabel("Others will get USD:"); - addField(); - for(bayNumber=0; bayNumber<numBays; bayNumber++) - { - addLabel("# Fish in Bay " + (bayNumber+1) + "(PM):"); - addField(); - } - } - dataGrid.dataProvider = dataProvider; - numFields = dataProvider.length; - } - - private function setGridHeight():void - { - switch(style) - { - case(0): - case(1): // 0:PeopleEntry, 1:PeopleViewing - dataGrid.height = (23)*(numBays+2)-1; - break; - case(2): // 2:FishEntry - dataGrid.height = (23)*(numBays+1); - break; - case(3): // 3:CalculatedViewing - dataGrid.height = (23)*(numBays+4)-3; - break; - } - } - - private function errorCheck():void - { - markNoError(); - var error:Boolean = false; - - for(var column:Number=0; column < numColumns && !error; column++) - { - var colSum:Number = 0; - for(var field:Number=0; field < numFields && !error; field++) - { - var value:Object = getItem(field, column); - if(!validNum(value)) - { - errorMessage = "Enter a value between "+minValue+" and "+maxValue+"."; - error = true; - markError(field,column); - } - else if(!inBounds(value)) - { - errorMessage = "Value must be between "+minValue+" and "+maxValue+"."; - error = true; - markError(field,column); - } - else if(style == 0) // 0:PeopleEntry - { - colSum += Number(value); - } - } - - if(!error && style == 0 && colSum != groupSize-1) // 0:PeopleEntry - { - errorMessage = "Sum of all columns must be exactly "+(groupSize-1)+"."; - error = true; - markError(-1,column); - } - } - - finished = !error; - } - - private function validNum(n:Object):Boolean - { - if(n == null) return false; - var pattern:RegExp = /^\d+$/; //the entire string must be consecutive digits - var s:String = StringUtil.trim(String(n)); - return (n is Number) || pattern.test(s); - } - private function inBounds(n:Object):Boolean - { - return Number(n) >= minValue && Number(n) <= maxValue; - } - public function markError(field:Number, column:Number):void - { - if(style != 0 && style != 2) return; // 0:PeopleEntry, 2:FishEntry - DataGridColumn(dataGrid.columns[column]).setStyle("backgroundColor", "#ee82ee"); - dataGrid.selectedIndex = field; - } - private function markNoError():void - { - for(var column:Number=0; column < numColumns; column++) - { - DataGridColumn(dataGrid.columns[column]).setStyle("backgroundColor", "#FFFFFF"); - } - dataGrid.selectedIndex = -1; - } - - ]]> - </mx:Script> - -</mx:HBox> Deleted: mentalmodels/trunk/flex/src/customComponents/ForecastPage_TEMP.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/ForecastPage_TEMP.mxml 2009-06-16 22:08:55 UTC (rev 163) +++ mentalmodels/trunk/flex/src/customComponents/ForecastPage_TEMP.mxml 2009-06-17 19:19:34 UTC (rev 164) @@ -1,74 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:comp="customComponents.*" xmlns:as="actionscript.*" initialize="init()"> - - <mx:VBox id="content"> - <comp:Forecast1 id="forecastPeople" numColumns="15" minValue="0" maxValue="30"/> - <!--<mx:Button id="next" label="Forecast Fish Movements" click="testNext()"/>--> - </mx:VBox> - - <mx:Script> - <![CDATA[ - import customComponents.*; - import mx.collections.ArrayCollection; - import mx.controls.Alert; - - private var firstPage:Boolean = true; - private var tries:int = 0; - private var f2:Forecast2; - - public function init():void - { - f2 = new Forecast2(); - f2.id = "forecastFull_AS"; - f2.numColumns = 6; - } - - public function testNext(evt:Event=null):Boolean - { - if(! firstPage) return false; - - tries++; - if(!(forecastPeople.isFinished() || tries > 1)) - { - Alert.show("Not finished forecasting Predictions of People. Click again to disregard."); - return false; - } - Alert.show("!"); - - f2.oldForecast1 = forecastPeople; - f2.updateOld(); - content.removeAllChildren(); - content.addChild(f2); - firstPage = false; - return true; - } - - public function back():Boolean - { - //if(content.contains(forecastPeople)) return false; - - content.removeAllChildren(); - content.addChild(forecastPeople); - firstPage = true; - return true; - } - - public function forward():Boolean - { - return testNext(); - } - - public function accept():Boolean - { - if(forecastPeople.isFinished()) - { - var forecastFish:Forecast2 = content.getChildAt(1) as Forecast2; - return forecastFish.isFinished(); - } - return false; - } - - ]]> - </mx:Script> - -</mx:Canvas> Deleted: mentalmodels/trunk/flex/src/customComponents/ForecastingQuestionC.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/ForecastingQuestionC.mxml 2009-06-16 22:08:55 UTC (rev 163) +++ mentalmodels/trunk/flex/src/customComponents/ForecastingQuestionC.mxml 2009-06-17 19:19:34 UTC (rev 164) @@ -1,109 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:comp="customComponents.*"> - - <mx:String id="description"></mx:String> - <mx:VBox id="headers"> - <mx:Label/> - <mx:Text htmlText="{description}"/> - </mx:VBox> - <mx:Script> <![CDATA[ - public function htmlBold(str:String):String - { - if(str==null)return null; - return "<font size=\"12px\">" + str + "</font>"; - } - ]]> </mx:Script> - - <mx:HBox id="buttons"> - <mx:Button id="btnForward" label="Forecast Fish" click="forward()"/> - <mx:Button id="btnBack" label="Forecast People" click="back()" enabled="false"/> - </mx:HBox> - - <mx:VBox id="content"/> - - <mx:Script> - <![CDATA[ - import actionscript.ForecastingQuestion; - import mx.collections.ArrayCollection; - - public var style0:ForecastComponent; - public var style1:ForecastComponent; - public var style2:ForecastComponent; - public var style3:ForecastComponent; - - public var peopleSaved:ArrayCollection; - public var fishSaved:ArrayCollection; - - public var numBays:int = 3; - public var numColumnsMin:int = 6; - public var numColumnsMax:int = 15; - - public function init():void - { - createStyle(style0,0); - createStyle(style1,1); - createStyle(style2,2); - createStyle(style3,3); - content.addChild(style0); - } - private function createStyle(style:ForecastComponent,styleNum:int):void - { - style = new ForecastComponent(); - style.style = styleNum; - style.numBays = numBays; - if(styleNum <= 1) - { - style.numColumns = numColumnsMax; - } - else - { - style.numColumns = numColumnsMin; - } - style.initialize(); - style.init(); - } - - public function back():void - { - fishSaved = style2.save(); - content.removeAllChildren(); - content.addChild(style0); - } - public function forward():void - { - peopleSaved = style0.save(); - style1.load(peopleSaved); - content.removeAllChildren(); - content.addChild(style2); // 2:FishEntry - content.addChild(style1); // 1:PeopleView - content.addChild(style3); // 3:Calculated - } - public function accept():Boolean - { - return true; - } - - public function save():ArrayCollection - { - var saveArray:ArrayCollection = new ArrayCollection(); - saveArray.addItem(null); - return saveArray; - } - - public function load(loadArray:ArrayCollection):void - { - (loadArray.getItemAt(0) as Object); - } - - public function loadFromQuestion(question:ForecastingQuestion):void - { - description = question.question; - - initialize(); - init(); - } - - ]]> - </mx:Script> - -</mx:VBox> Modified: mentalmodels/trunk/flex/src/customComponents/InstructionPage_TEMP.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/InstructionPage_TEMP.mxml 2009-06-16 22:08:55 UTC (rev 163) +++ mentalmodels/trunk/flex/src/customComponents/InstructionPage_TEMP.mxml 2009-06-17 19:19:34 UTC (rev 164) @@ -1,10 +1,11 @@ <?xml version="1.0" encoding="utf-8"?> -<mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:comp="customComponents.*" xmlns:as="actionscript.*" initialize="init()"> +<mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:as="actionscript.*" + xmlns:comp="customComponents.*" xmlns:quest="customComponents.questions.*" initialize="init()"> <mx:ArrayCollection id="psychometricLabels"> <mx:String>Very Much</mx:String> <mx:String>Neutral</mx:String> - <!--<mx:String>Not at All... [truncated message content] |
From: <kj...@us...> - 2009-06-16 22:08:59
|
Revision: 163 http://virtualcommons.svn.sourceforge.net/virtualcommons/?rev=163&view=rev Author: kjonas Date: 2009-06-16 22:08:55 +0000 (Tue, 16 Jun 2009) Log Message: ----------- renamed ForecastQuestion.mxml to ForecastingQuestionC.mxml added loadFromQuestion() functions to all *QuestionC.mxml files these functions do not work, must fix beans for *Question.as files first Modified Paths: -------------- mentalmodels/trunk/flex/src/QuestionTest.mxml mentalmodels/trunk/flex/src/TestForecast.mxml mentalmodels/trunk/flex/src/_InstructionsTest.mxml mentalmodels/trunk/flex/src/actionscript/PageDisplay.as mentalmodels/trunk/flex/src/customComponents/CategoricalQuestionC.mxml mentalmodels/trunk/flex/src/customComponents/ForecastComponent.mxml mentalmodels/trunk/flex/src/customComponents/InstructionPage.mxml mentalmodels/trunk/flex/src/customComponents/InstructionPage_TEMP.mxml mentalmodels/trunk/flex/src/customComponents/PlannerPage.mxml mentalmodels/trunk/flex/src/customComponents/PsychometricQuestionC.mxml mentalmodels/trunk/flex/src/customComponents/SocioDemographicPage.mxml mentalmodels/trunk/flex/src/customComponents/TextQuestionC.mxml Added Paths: ----------- mentalmodels/trunk/flex/src/customComponents/ForecastingQuestionC.mxml Removed Paths: ------------- mentalmodels/trunk/flex/src/customComponents/ForecastQuestion.mxml Modified: mentalmodels/trunk/flex/src/QuestionTest.mxml =================================================================== --- mentalmodels/trunk/flex/src/QuestionTest.mxml 2009-06-16 22:08:11 UTC (rev 162) +++ mentalmodels/trunk/flex/src/QuestionTest.mxml 2009-06-16 22:08:55 UTC (rev 163) @@ -42,6 +42,6 @@ <comp:TextQuestionC id="question1"/> <comp:CategoricalQuestionC id="question2" topics="{topicList}" specifics="{specificList}"/> - <comp:ForecastQuestion id="question3"/> + <comp:ForecastingQuestionC id="question3"/> </mx:Application> Modified: mentalmodels/trunk/flex/src/TestForecast.mxml =================================================================== --- mentalmodels/trunk/flex/src/TestForecast.mxml 2009-06-16 22:08:11 UTC (rev 162) +++ mentalmodels/trunk/flex/src/TestForecast.mxml 2009-06-16 22:08:55 UTC (rev 163) @@ -56,7 +56,10 @@ { try { + forecastComponent0.load(forecastSaved); forecastComponent1.load(forecastSaved); + forecastComponent2.load(forecastSaved); + forecastComponent3.load(forecastSaved); planner.load(plannerSaved); } Modified: mentalmodels/trunk/flex/src/_InstructionsTest.mxml =================================================================== --- mentalmodels/trunk/flex/src/_InstructionsTest.mxml 2009-06-16 22:08:11 UTC (rev 162) +++ mentalmodels/trunk/flex/src/_InstructionsTest.mxml 2009-06-16 22:08:55 UTC (rev 163) @@ -1,11 +1,15 @@ <?xml version="1.0" encoding="utf-8"?> -<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:comp="customComponents.*" layout="vertical" xmlns:as="actionscript.*"> +<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:comp="customComponents.*" xmlns:as="actionscript.*" + layout="vertical"> <mx:Script> <![CDATA[ + import actionscript.Question; + import actionscript.CategoricalQuestion; import actionscript.QuestionGroup; import actionscript.PsychometricQuestion; import actionscript.Block; + import mx.collections.ArrayCollection; public var choices1:ArrayCollection = new ArrayCollection(); public var questions1:ArrayCollection = new ArrayCollection(); @@ -18,39 +22,37 @@ public function fillBlock():void { try{ -// debg.text += "creating choices\n"; - choices1.addItem("Highly Agree"); - choices1.addItem("Highly Neutral"); - choices1.addItem("Highly Disagree"); + // create questions + var psy1:PsychometricQuestion = new PsychometricQuestion(); + psy1.numberOfIntervals = 10; + psy1.choices = new ArrayCollection(); + psy1.choices.addItem("Highly Agree"); + psy1.choices.addItem("Highly Neutral"); + psy1.choices.addItem("Highly Disagree"); - choices2.addItem("Agree"); - choices2.addItem("Neutral"); -// debg.text += "choices1.length="+choices1.length+"\n"; + var psy2:PsychometricQuestion = new PsychometricQuestion(); + psy2.numberOfIntervals = 10; + psy2.choices = new ArrayCollection(); + psy2.choices.addItem("Agree"); + psy2.choices.addItem("Neutral"); -// debg.text += "creating questions\n"; - questions1.addItem(new PsychometricQuestion()); - PsychometricQuestion(questions1.getItemAt(0)).choices = choices1; - PsychometricQuestion(questions1.getItemAt(0)).numberOfIntervals = 3; + // insert questions into groups + var qg1:QuestionGroup = new QuestionGroup(); + qg1.questions = new ArrayCollection(); + qg1.questions.addItem(psy1); - questions2.addItem(new PsychometricQuestion()); - PsychometricQuestion(questions2.getItemAt(0)).choices = choices2; - PsychometricQuestion(questions2.getItemAt(0)).numberOfIntervals = 5; -// debg.text += "questions1.length="+questions1.length+"\n"; + var qg2:QuestionGroup = new QuestionGroup(); + qg2.questions = new ArrayCollection(); + qg2.questions.addItem(psy2); +// throw new Error("test"); -// debg.text += "creating questiongroups\n"; - questionGroups1.addItem(new QuestionGroup()); - questionGroups1.addItem(new QuestionGroup()); - QuestionGroup(questionGroups1.getItemAt(0)).questions = questions1; - QuestionGroup(questionGroups1.getItemAt(1)).questions = questions2; -// debg.text += "questionGroups.length="+questionGroups.length+"\n"; + block1.questionGroups = new ArrayCollection(); + block1.questionGroups.addItem(qg1); + block1.questionGroups.addItem(qg2); -// debg.text += "creating block\n"; - block1.questionGroups = questionGroups1; -// debg.text += "block1.questionGroups.length="+block1.questionGroups.length+"\n"; - // debg.text += "finished\n"; }catch(errObject:Error){ - debg.text += "block creation failure\n" + + debug.text += "block creation failure\n" + errObject.message + "\n" + errObject.getStackTrace(); } } @@ -58,18 +60,18 @@ ]]> </mx:Script> - <mx:ArrayCollection id="labs"> + <!--<mx:ArrayCollection id="labs"> <mx:String>testLeft</mx:String> <mx:String>testRight</mx:String> <mx:String>testRight</mx:String> </mx:ArrayCollection> <comp:PsychometricQuestionC id="psych" labels="{labs}" initialize="true"/> - <comp:CategoricalQuestionC/> + <comp:CategoricalQuestionC/>--> <mx:Button id="forward" click="iPage.forward()" label="forward"/> <mx:Button id="back" click="iPage.back()" label="back"/> - <mx:Text id="debg" text=""/> + <mx:Text id="debug" text=""/> <comp:InstructionPage id="iPage" preinitialize="fillBlock()" initialize="iPage.init(block1)"/> Modified: mentalmodels/trunk/flex/src/actionscript/PageDisplay.as =================================================================== --- mentalmodels/trunk/flex/src/actionscript/PageDisplay.as 2009-06-16 22:08:11 UTC (rev 162) +++ mentalmodels/trunk/flex/src/actionscript/PageDisplay.as 2009-06-16 22:08:55 UTC (rev 163) @@ -1,6 +1,9 @@ // ActionScript file package actionscript { + import customComponents.TextQuestionC; + import customComponents.ForecastingQuestionC; + import customComponents.CategoricalQuestionC; import customComponents.PsychometricQuestionC; import flash.display.DisplayObject; @@ -10,24 +13,11 @@ import mx.controls.ComboBox; import mx.controls.Label; import mx.controls.Text; - import mx.controls.TextArea; [Bindable] public class PageDisplay { - /* - pages:ArrayCollection should be a bunch of VBoxes. - The structure of an element of the pages:ArrayCollection is as follows: - (element / type / description) - - 0 / Label / this is the header - 1 / Text / description (USE THIS FOR INSTRUCTION PAGES) - - 2+2*N / Label / question description for N'th question - 3+2*N / TextArea,ComboBox,PsychometricQuestion,Forecasting / the question itself - - */ public var msg:String = ""; public var pages:ArrayCollection; @@ -79,43 +69,36 @@ txt.htmlText = tempQuestion.question; tempBox.addChild(txt); - if(tempQuestion is actionscript.ForecastingQuestion) + if(tempQuestion is ForecastingQuestion) { - // ??? how is this going to be worked in ??? - //tempBox.addChild(new mx.containers.HBox()); + var fq:ForecastingQuestionC = new ForecastingQuestionC(); + fq.loadFromQuestion(ForecastingQuestion(tempQuestion)); + fq.id = "q"+question; + + tempBox.addChild(fq); } - else if(tempQuestion is actionscript.CategoricalQuestion) + else if(tempQuestion is CategoricalQuestion) { - var tempCat:CategoricalQuestion = CategoricalQuestion(tempQuestion); - var cq:ComboBox = new ComboBox(); + var cq:CategoricalQuestionC = new CategoricalQuestionC(); + cq.loadFromQuestion(CategoricalQuestion(tempQuestion)); cq.id = "q"+question; - cq.dataProvider = tempCat.choices; - cq.initialize(); + tempBox.addChild(cq); } - else if(tempQuestion is actionscript.PsychometricQuestion) + else if(tempQuestion is PsychometricQuestion) { - var tempPsych:actionscript.PsychometricQuestion = actionscript.PsychometricQuestion(tempQuestion); - var pq:customComponents.PsychometricQuestionC = new customComponents.PsychometricQuestionC(); + var pq:PsychometricQuestionC = new PsychometricQuestionC(); + pq.loadFromQuestion(PsychometricQuestion(tempQuestion)); pq.id = "q"+question; - pq.labels = tempPsych.choices; - pq.maxValue = tempPsych.numberOfIntervals; - pq.initialize(); - pq.init(); // ERROR FOUND SOMEWHERE IN HERE - -/* var e:Error = new Error(); -e.message = "TEST"; -throw e; */ tempBox.addChild(pq); } else { - var tq:TextArea = new TextArea(); + var tq:TextQuestionC = new TextQuestionC(); + tq.loadFromQuestion(Question(tempQuestion)); tq.id = "q"+question; - tq.width = 150; - tq.height = 14; - tq.initialize(); + tempBox.addChild(tq); } } Modified: mentalmodels/trunk/flex/src/customComponents/CategoricalQuestionC.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/CategoricalQuestionC.mxml 2009-06-16 22:08:11 UTC (rev 162) +++ mentalmodels/trunk/flex/src/customComponents/CategoricalQuestionC.mxml 2009-06-16 22:08:55 UTC (rev 163) @@ -1,9 +1,32 @@ <?xml version="1.0" encoding="utf-8"?> <mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:as="actionscript.*"> + <mx:String id="title"></mx:String> + <mx:String id="description"></mx:String> + <mx:VBox id="headers"> + <mx:Label/> + <mx:Label htmlText="{htmlBold(title)}"/> + <mx:Text htmlText="{description}"/> + </mx:VBox> + <mx:Script> <![CDATA[ + public function htmlBold(str:String):String + { + if(str==null)return null; + return "<font size=\"12px\">" + str + "</font>"; + } + ]]> </mx:Script> + + <mx:HBox id="content"> + <mx:ComboBox id="comboTopic" + dataProvider="{topics}" selectedIndex="0"/> + <mx:ComboBox id="comboSpecific" + dataProvider="{specifics.getItemAt(fix(comboTopic.selectedIndex, specifics))}"/> + </mx:HBox> + <mx:Script> <![CDATA[ import actionscript.FishUtil; + import actionscript.CategoricalQuestion; private function fix(index:int, list:ArrayCollection):int { @@ -24,31 +47,17 @@ comboSpecific.selectedIndex = loadArray.getItemAt(1) as int; } + public function loadFromQuestion(question:CategoricalQuestion):void + { + description = question.question; + + initialize(); +// init(); + } + ]]> </mx:Script> - <mx:String id="title"></mx:String> - <mx:String id="description"></mx:String> - <mx:VBox id="headers"> - <mx:Label/> - <mx:Label htmlText="{htmlBold(title)}"/> - <mx:Text htmlText="{description}"/> - </mx:VBox> - <mx:Script> <![CDATA[ - public function htmlBold(str:String):String - { - if(str==null)return null; - return "<font size=\"12px\">" + str + "</font>"; - } - ]]> </mx:Script> - - <mx:HBox id="content"> - <mx:ComboBox id="comboTopic" - dataProvider="{topics}" selectedIndex="0"/> - <mx:ComboBox id="comboSpecific" - dataProvider="{specifics.getItemAt(fix(comboTopic.selectedIndex, specifics))}"/> - </mx:HBox> - <!-- the selected element of this array determines which of the elements of "specifics" will be used as the dataProvider --> <mx:ArrayCollection id="topics"> Modified: mentalmodels/trunk/flex/src/customComponents/ForecastComponent.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/ForecastComponent.mxml 2009-06-16 22:08:11 UTC (rev 162) +++ mentalmodels/trunk/flex/src/customComponents/ForecastComponent.mxml 2009-06-16 22:08:55 UTC (rev 163) @@ -29,7 +29,7 @@ [Bindable] public var finished:Boolean = false; // for lining up grids - [Bindable] public var minimumWidth:int = 30; + [Bindable] public var minimumWidth:int = 160; // // public accessible functions Deleted: mentalmodels/trunk/flex/src/customComponents/ForecastQuestion.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/ForecastQuestion.mxml 2009-06-16 22:08:11 UTC (rev 162) +++ mentalmodels/trunk/flex/src/customComponents/ForecastQuestion.mxml 2009-06-16 22:08:55 UTC (rev 163) @@ -1,31 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:comp="customComponents.*"> - - <mx:Label id="header"/> - <comp:Forecast1 id="forecastPeople" numColumns="15" minValue="0" maxValue="30" initialize="init()"/> - <mx:Button id="next" label="Next" click="testNext()"/> - - <mx:Script> - <![CDATA[ - import customComponents.*; - import mx.collections.ArrayCollection; - - public function init():void - { - for(var x:int=0;x<4;x++)for(var y:int=0;y<15;y++)forecastPeople.setItem(x,y,7.5); - } - - public function testNext(evt:Event=null):void - { - if(!forecastPeople.isFinished()) return; - var f2:Forecast2 = new Forecast2(); - f2.id = "forecastFull_AS"; - f2.numColumns = 6; - f2.oldForecast1 = forecastPeople; - this.addChild(f2); - } - - ]]> - </mx:Script> - -</mx:VBox> Added: mentalmodels/trunk/flex/src/customComponents/ForecastingQuestionC.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/ForecastingQuestionC.mxml (rev 0) +++ mentalmodels/trunk/flex/src/customComponents/ForecastingQuestionC.mxml 2009-06-16 22:08:55 UTC (rev 163) @@ -0,0 +1,109 @@ +<?xml version="1.0" encoding="utf-8"?> +<mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:comp="customComponents.*"> + + <mx:String id="description"></mx:String> + <mx:VBox id="headers"> + <mx:Label/> + <mx:Text htmlText="{description}"/> + </mx:VBox> + <mx:Script> <![CDATA[ + public function htmlBold(str:String):String + { + if(str==null)return null; + return "<font size=\"12px\">" + str + "</font>"; + } + ]]> </mx:Script> + + <mx:HBox id="buttons"> + <mx:Button id="btnForward" label="Forecast Fish" click="forward()"/> + <mx:Button id="btnBack" label="Forecast People" click="back()" enabled="false"/> + </mx:HBox> + + <mx:VBox id="content"/> + + <mx:Script> + <![CDATA[ + import actionscript.ForecastingQuestion; + import mx.collections.ArrayCollection; + + public var style0:ForecastComponent; + public var style1:ForecastComponent; + public var style2:ForecastComponent; + public var style3:ForecastComponent; + + public var peopleSaved:ArrayCollection; + public var fishSaved:ArrayCollection; + + public var numBays:int = 3; + public var numColumnsMin:int = 6; + public var numColumnsMax:int = 15; + + public function init():void + { + createStyle(style0,0); + createStyle(style1,1); + createStyle(style2,2); + createStyle(style3,3); + content.addChild(style0); + } + private function createStyle(style:ForecastComponent,styleNum:int):void + { + style = new ForecastComponent(); + style.style = styleNum; + style.numBays = numBays; + if(styleNum <= 1) + { + style.numColumns = numColumnsMax; + } + else + { + style.numColumns = numColumnsMin; + } + style.initialize(); + style.init(); + } + + public function back():void + { + fishSaved = style2.save(); + content.removeAllChildren(); + content.addChild(style0); + } + public function forward():void + { + peopleSaved = style0.save(); + style1.load(peopleSaved); + content.removeAllChildren(); + content.addChild(style2); // 2:FishEntry + content.addChild(style1); // 1:PeopleView + content.addChild(style3); // 3:Calculated + } + public function accept():Boolean + { + return true; + } + + public function save():ArrayCollection + { + var saveArray:ArrayCollection = new ArrayCollection(); + saveArray.addItem(null); + return saveArray; + } + + public function load(loadArray:ArrayCollection):void + { + (loadArray.getItemAt(0) as Object); + } + + public function loadFromQuestion(question:ForecastingQuestion):void + { + description = question.question; + + initialize(); + init(); + } + + ]]> + </mx:Script> + +</mx:VBox> Modified: mentalmodels/trunk/flex/src/customComponents/InstructionPage.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/InstructionPage.mxml 2009-06-16 22:08:11 UTC (rev 162) +++ mentalmodels/trunk/flex/src/customComponents/InstructionPage.mxml 2009-06-16 22:08:55 UTC (rev 163) @@ -80,6 +80,18 @@ return false; } + public function save():ArrayCollection + { + var saveArray:ArrayCollection = new ArrayCollection(); + saveArray.addItem(block); + return saveArray; + } + + public function load(loadArray:ArrayCollection):void + { + block = (loadArray.getItemAt(0) as Block); + } + ]]> </mx:Script> Modified: mentalmodels/trunk/flex/src/customComponents/InstructionPage_TEMP.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/InstructionPage_TEMP.mxml 2009-06-16 22:08:11 UTC (rev 162) +++ mentalmodels/trunk/flex/src/customComponents/InstructionPage_TEMP.mxml 2009-06-16 22:08:55 UTC (rev 163) @@ -52,11 +52,11 @@ </mx:VBox> <mx:VBox id="p1"> <mx:Text htmlText="<b><font size="16">Sample Questions</font></b>" width="300"/> - <comp:PsychometricQuestionC id="psychometricQuestion" title="Overall, how much do you like your group?" + <comp:PsychometricQuestionC id="psychometricQuestion" description="Overall, how much do you like your group?" labels="{psychometricLabels}" maxValue="3"/> <comp:CategoricalQuestionC id="categoricalQuestion" title="What goals did you follow when designing your strategy?" topics="{categoricalTopics}" specifics="{categoricalSpecifics}"/> - <comp:TextQuestionC id="textQuestion" title="Describe in your own words what the rule, agreement, or other coordination attempt states." + <comp:TextQuestionC id="textQuestion" description="Describe in your own words what the rule, agreement, or other coordination attempt states." defaultText="Enter your response here..." txtHeight="48"/> </mx:VBox> </mx:HBox> Modified: mentalmodels/trunk/flex/src/customComponents/PlannerPage.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/PlannerPage.mxml 2009-06-16 22:08:11 UTC (rev 162) +++ mentalmodels/trunk/flex/src/customComponents/PlannerPage.mxml 2009-06-16 22:08:55 UTC (rev 163) @@ -2,7 +2,7 @@ <mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:comp="customComponents.*"> <mx:Label text="Strategy Design" fontSize="24"/> - <mx:Text text="Please create a plan for the month. You will visit each of the locations listed in the left column in order. You will then do the same using the right column, and repeat until the 30 days are completed. If you do not manage to mine enough fish after one repetition, you may wait a few days until fishing again." + <mx:Text text="Please create a plan for the month. You will visit each of the locations listed in the left column in order. You will then do the same using the right column, but repeat until the 30 days are completed. If you do not manage to mine enough fish after one repetition, you may wait a few days until fishing again." width="600"/> <mx:Label/> Modified: mentalmodels/trunk/flex/src/customComponents/PsychometricQuestionC.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/PsychometricQuestionC.mxml 2009-06-16 22:08:11 UTC (rev 162) +++ mentalmodels/trunk/flex/src/customComponents/PsychometricQuestionC.mxml 2009-06-16 22:08:55 UTC (rev 163) @@ -1,11 +1,9 @@ <?xml version="1.0" encoding="utf-8"?> <mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:comp="customComponents.*" initialize="false"> - <mx:String id="title"></mx:String> <mx:String id="description"></mx:String> <mx:VBox id="headers"> <mx:Label/> - <mx:Label htmlText="{htmlBold(title)}"/> <mx:Text htmlText="{description}"/> </mx:VBox> <mx:Script> <![CDATA[ @@ -29,6 +27,7 @@ <mx:Script> <![CDATA[ + import actionscript.PsychometricQuestion; import mx.collections.ArrayCollection; public var labels:ArrayCollection; @@ -98,6 +97,14 @@ slider1.sliderButton.move(loadArray.getItemAt(1) as Number, 0); } + public function loadFromQuestion(question:PsychometricQuestion):void + { + description = question.question; + + initialize(); + init(); + } + ]]> </mx:Script> Modified: mentalmodels/trunk/flex/src/customComponents/SocioDemographicPage.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/SocioDemographicPage.mxml 2009-06-16 22:08:11 UTC (rev 162) +++ mentalmodels/trunk/flex/src/customComponents/SocioDemographicPage.mxml 2009-06-16 22:08:55 UTC (rev 163) @@ -1,8 +1,9 @@ <?xml version="1.0" encoding="utf-8"?> -<mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml"> +<mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml" verticalAlign="middle" horizontalAlign="center"> <mx:Script> <![CDATA[ + import mx.collections.ArrayCollection; public function getGender():String { @@ -28,77 +29,109 @@ // if any field is of improper length, this section is not completed // flag/unflag an area with red if incomplete/complete var ready:Boolean=true; + var bgcolor:String = "backgroundColor"; + var red:String = "#FF0000"; + var white:String = "#FFFFFF"; - if(getGender().length != 1) + if(getGender().length != 1) // "M", "F", "Err" { - boxGender.setStyle("backgroundColor", "#FF0000"); + boxGender.setStyle(bgcolor, red); ready=false; }else{ - boxGender.setStyle("backgroundColor", ""); + boxGender.setStyle(bgcolor, white); } if(getYear().length != 4 || Number(getYear()) < 1900) { - txtYear.setStyle("backgroundColor", "#FF0000"); + txtYear.setStyle(bgcolor, red); ready=false; }else{ - txtYear.setStyle("backgroundColor", "#FFFFFF"); + txtYear.setStyle(bgcolor, white); } if(getMajor().length == 0) { - txtMajor.setStyle("backgroundColor", "#FF0000"); + txtMajor.setStyle(bgcolor, red); ready=false; }else{ - txtMajor.setStyle("backgroundColor", "#FFFFFF"); + txtMajor.setStyle(bgcolor, white); } if(getSemester().length == 0) { - txtSemester.setStyle("backgroundColor", "#FF0000"); + txtSemester.setStyle(bgcolor, red); ready=false; }else{ - txtSemester.setStyle("backgroundColor", "#FFFFFF"); + txtSemester.setStyle(bgcolor, white); } - boxGender.enabled = !ready; - txtYear.enabled = !ready; - txtMajor.enabled = !ready; - txtSemester.enabled = !ready; - // all datamembers are the desired length + enable(!ready); return ready; } + public function enable(enabled:Boolean=true):void + { + boxGender.enabled = enabled; + txtYear.enabled = enabled; + txtMajor.enabled = enabled; + txtSemester.enabled = enabled; + } + + public function save():ArrayCollection + { + var saveArray:ArrayCollection = new ArrayCollection(); + saveArray.addItem(getGender()); + saveArray.addItem(getYear()); + saveArray.addItem(getMajor()); + saveArray.addItem(getSemester()); + return saveArray; + } + + public function load(loadArray:ArrayCollection):void + { + var gender:String = (loadArray.getItemAt(0) as String); + if(gender != null && gender.length == 1) + { + radioMale.selected = (gender == "M"); + radioFemale.selected = (gender == "F"); + } + txtYear.text = (loadArray.getItemAt(1) as String); + txtMajor.text = (loadArray.getItemAt(2) as String); + txtSemester.text = (loadArray.getItemAt(3) as String); + } + ]]> </mx:Script> - <mx:VBox width="220" horizontalAlign="center"> - <mx:Label text="Personal Data" fontSize="18"/> - <mx:Label text="Please fill out the following fields:"/> + <mx:VBox id="content"> + <mx:VBox width="220" horizontalAlign="center"> + <mx:Label text="Personal Data" fontSize="18"/> + <mx:Label text="Please fill out the following fields:"/> + </mx:VBox> + + <mx:HBox> + <mx:Label text="Gender:" fontWeight="bold" width="100" textAlign="right"/> + <mx:HBox id="boxGender"> + <mx:RadioButtonGroup id="gender"/> + <mx:RadioButton groupName="{gender}" label="M" id="radioMale"/> + <mx:RadioButton groupName="{gender}" label="F" id="radioFemale"/> + </mx:HBox> + </mx:HBox> + + <mx:HBox> + <mx:Label text="Year of Birth:" fontWeight="bold" width="100" textAlign="right"/> + <mx:TextInput id="txtYear" width="75" maxChars="4"/> + </mx:HBox> + + <mx:HBox> + <mx:Label text="Major:" fontWeight="bold" width="100" textAlign="right"/> + <mx:TextInput id="txtMajor" width="120" maxChars="100"/> + </mx:HBox> + + <mx:HBox> + <mx:Label text="Semester:" fontWeight="bold" width="100" textAlign="right"/> + <mx:TextInput id="txtSemester" width="75" maxChars="6"/> + </mx:HBox> </mx:VBox> - <mx:HBox> - <mx:Label text="Gender:" fontWeight="bold" width="100" textAlign="right"/> - <mx:HBox id="boxGender"> - <mx:RadioButtonGroup id="gender"/> - <mx:RadioButton groupName="{gender}" label="M" id="radioMale"/> - <mx:RadioButton groupName="{gender}" label="F" id="radioFemale"/> - </mx:HBox> - </mx:HBox> - - <mx:HBox> - <mx:Label text="Year of Birth:" fontWeight="bold" width="100" textAlign="right"/> - <mx:TextInput id="txtYear" width="75" maxChars="4"/> - </mx:HBox> - - <mx:HBox> - <mx:Label text="Major:" fontWeight="bold" width="100" textAlign="right"/> - <mx:TextInput id="txtMajor" width="120" maxChars="100"/> - </mx:HBox> - - <mx:HBox> - <mx:Label text="Semester:" fontWeight="bold" width="100" textAlign="right"/> - <mx:TextInput id="txtSemester" width="75" maxChars="6"/> - </mx:HBox> - </mx:VBox> Modified: mentalmodels/trunk/flex/src/customComponents/TextQuestionC.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/TextQuestionC.mxml 2009-06-16 22:08:11 UTC (rev 162) +++ mentalmodels/trunk/flex/src/customComponents/TextQuestionC.mxml 2009-06-16 22:08:55 UTC (rev 163) @@ -1,11 +1,9 @@ <?xml version="1.0" encoding="utf-8"?> <mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml"> - <mx:String id="title"></mx:String> <mx:String id="description"></mx:String> <mx:VBox id="headers"> <mx:Label/> - <mx:Label htmlText="{htmlBold(title)}"/> <mx:Text htmlText="{description}"/> </mx:VBox> <mx:Script> <![CDATA[ @@ -24,6 +22,7 @@ <mx:Script> <![CDATA[ import mx.collections.ArrayCollection; + import actionscript.Question; public function save():ArrayCollection { @@ -37,6 +36,14 @@ textAnswer.text = loadArray.getItemAt(0) as String; } + public function loadFromQuestion(question:Question):void + { + description = question.question; + + initialize(); +// init(); + } + ]]> </mx:Script> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |