Thread: [virtualcommons-svn] SF.net SVN: virtualcommons:[155] mentalmodels/trunk/flex/src (Page 2)
Status: Beta
Brought to you by:
alllee
From: <kj...@us...> - 2009-06-09 23:15:45
|
Revision: 155 http://virtualcommons.svn.sourceforge.net/virtualcommons/?rev=155&view=rev Author: kjonas Date: 2009-06-09 23:15:43 +0000 (Tue, 09 Jun 2009) Log Message: ----------- Added Paths: ----------- mentalmodels/trunk/flex/src/TestForecast.mxml mentalmodels/trunk/flex/src/customComponents/ForecastComponent.mxml Added: mentalmodels/trunk/flex/src/TestForecast.mxml =================================================================== --- mentalmodels/trunk/flex/src/TestForecast.mxml (rev 0) +++ mentalmodels/trunk/flex/src/TestForecast.mxml 2009-06-09 23:15:43 UTC (rev 155) @@ -0,0 +1,26 @@ +<?xml version="1.0" encoding="utf-8"?> +<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical" xmlns:comp="customComponents.*"> + + <comp:ForecastComponent id="forecastComponent" numColumns="15" numBays="3" style="0"/> + + <mx:Script> + <![CDATA[ +// import mx.controls.Alert; +// +// public function init():void +// { +// try +// { +// forecastComponent.initialize(); +// forecastComponent.init(); +// } +// catch(error:Error) +// { +// Alert.show(error.message + "\n" + error.getStackTrace()); +// } +// } + + ]]> + </mx:Script> + +</mx:Application> Added: mentalmodels/trunk/flex/src/customComponents/ForecastComponent.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/ForecastComponent.mxml (rev 0) +++ mentalmodels/trunk/flex/src/customComponents/ForecastComponent.mxml 2009-06-09 23:15:43 UTC (rev 155) @@ -0,0 +1,72 @@ +<?xml version="1.0" encoding="utf-8"?> +<mx:HBox xmlns:mx="http://www.adobe.com/2006/mxml" initialize="init()"> + + <mx:VBox id="labels" verticalGap="2"/> + + <mx:DataGrid id="dataGrid" editable="true" enabled="true" dataProvider="dataProvider"/> + + <mx:Script> + <![CDATA[ + import mx.collections.ArrayCollection; + import mx.controls.Label; + import mx.controls.dataGridClasses.DataGridColumn; + + [Bindable] public var dataProvider:ArrayCollection = new ArrayCollection(); + [Bindable] public var numBays:int = 3; + [Bindable] public var numColumns:int = 15; + [Bindable] public var style:int = 0; // 0:PeopleEntry, 1:PeopleViewing, 2:FishEntry, 3:Calculated + + public function init():void + { + var newColumnArray:Array = new Array(numColumns); + for(var columnNumber:int=0; columnNumber<newColumnArray.length; columnNumber++) + { + var newDataGridColumn:DataGridColumn = new DataGridColumn(); + newDataGridColumn.draggable = false; + newDataGridColumn.sortable = false; + newDataGridColumn.resizable = false; + newDataGridColumn.width = 30; + + 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 + + newColumnArray[columnNumber] = newDataGridColumn; + } + dataGrid.columns = newColumnArray; + + var bayNumber:int = 0; + if(style==0 || style==1) // 0:PeopleEntry, 1:PeopleViewing + { + addLabel(); + addLabel("# People in Harbor:"); + for(bayNumber=0; bayNumber<numBays; bayNumber++) + { + addLabel("# People in Bay " + (bayNumber+1) + ":"); + } + } + else if(style==2) + { + addLabel(); + for(bayNumber=0; bayNumber<numBays; bayNumber++) + { + addLabel("# Fish in Bay " + (bayNumber+1) + ":"); + } + } + } + + public function addLabel(text:String=""):void + { + var newLabel:Label = new Label(); + if(text != "") + { + newLabel.text = text; + } + labels.addChild(newLabel); + } + + ]]> + </mx:Script> + +</mx:HBox> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <kj...@us...> - 2009-06-12 23:08:48
|
Revision: 160 http://virtualcommons.svn.sourceforge.net/virtualcommons/?rev=160&view=rev Author: kjonas Date: 2009-06-12 23:08:38 +0000 (Fri, 12 Jun 2009) Log Message: ----------- ForecastComponent.mxml now contains methods save() and load(). These methods are common to all four "styles". ForecastComponent.mxml also contains value-checking, which only occurs on styles 0 and 2, the two styles that allow data entry. Style 0 checks for number validity, range, and sum (in columns). Style 2 checks for number validity and range only. Error messages are generated and accessible through the public variable errorMessage, but they are not displayed. Modified Paths: -------------- mentalmodels/trunk/flex/src/TestForecast.mxml mentalmodels/trunk/flex/src/customComponents/ForecastComponent.mxml Modified: mentalmodels/trunk/flex/src/TestForecast.mxml =================================================================== --- mentalmodels/trunk/flex/src/TestForecast.mxml 2009-06-12 02:39:11 UTC (rev 159) +++ mentalmodels/trunk/flex/src/TestForecast.mxml 2009-06-12 23:08:38 UTC (rev 160) @@ -1,30 +1,65 @@ <?xml version="1.0" encoding="utf-8"?> -<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical" xmlns:comp="customComponents.*"> +<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:comp="customComponents.*" 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}"/> + <mx:HBox> + <mx:Button label="Save" click="save()"/> + <!--<mx:Button label="Load" click="load()"/>--> + </mx:HBox> </mx:VBox> <mx:Script> <![CDATA[ -// import mx.controls.Alert; -// -// public function init():void -// { + import mx.collections.ArrayCollection; + import mx.controls.Alert; + + public var saved:ArrayCollection = null; + // try // { -// forecastComponent.initialize(); -// forecastComponent.init(); +// // } // catch(error:Error) // { // Alert.show(error.message + "\n" + error.getStackTrace()); // } -// } + public function init():void + { + //forecastComponent0.changed(); + } + + public function save():void + { + try + { + saved = forecastComponent0.save(); + forecastComponent1.load(saved); + forecastComponent2.load(saved); + forecastComponent3.load(saved); + } + catch(error:Error) + { + Alert.show(error.message + "\n" + error.getStackTrace()); + } + } + + public function load():void + { + try + { + forecastComponent1.load(saved); + } + catch(error:Error) + { + Alert.show(error.message + "\n" + error.getStackTrace()); + } + } + ]]> </mx:Script> Modified: mentalmodels/trunk/flex/src/customComponents/ForecastComponent.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/ForecastComponent.mxml 2009-06-12 02:39:11 UTC (rev 159) +++ mentalmodels/trunk/flex/src/customComponents/ForecastComponent.mxml 2009-06-12 23:08:38 UTC (rev 160) @@ -5,18 +5,36 @@ <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; - public var dataGrid:DataGrid; - [Bindable] public var dataProvider:ArrayCollection = new ArrayCollection(); + // 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 = 15; + [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 = 30; - [Bindable] public var style:int = 0; // 0:PeopleEntry, 1:PeopleViewing, 2:FishEntry, 3:Calculated + // + // public accessible functions + // + public function init():void { createGrid(); @@ -26,6 +44,60 @@ 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(); @@ -47,37 +119,39 @@ private function createGrid():void { - dataGrid = new DataGrid; + dataGrid = new DataGrid(); dataGrid.id = "dataGrid"; dataGrid.editable = true; dataGrid.enabled = true; + dataGrid.addEventListener("change", changed); } private function fillGridColumns():void { - var newColumnArray:Array = new Array(numColumns); + var columnArray:Array = dataGrid.columns; for(var columnNumber:int = 0; columnNumber < numColumns; columnNumber++) { - var newDataGridColumn:DataGridColumn = new DataGridColumn(); + 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; - 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 - - newColumnArray[columnNumber] = newDataGridColumn; + columnArray[columnNumber] = newDataGridColumn; } - dataGrid.columns = newColumnArray; + 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 { @@ -126,6 +200,7 @@ } } dataGrid.dataProvider = dataProvider; + numFields = dataProvider.length; } private function setGridHeight():void @@ -139,12 +214,78 @@ case(2): // 2:FishEntry dataGrid.height = (23)*(numBays+1); break; - case(3): // 3:Calculated + 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> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
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. |
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-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-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-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-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-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-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-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-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: <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: <kj...@us...> - 2009-07-16 21:00:49
|
Revision: 186 http://virtualcommons.svn.sourceforge.net/virtualcommons/?rev=186&view=rev Author: kjonas Date: 2009-07-16 21:00:46 +0000 (Thu, 16 Jul 2009) Log Message: ----------- Deleted old file. Added HelpImage.png and corresponding information window. Added timers to the main page, can be set to a percentage. (Currently setting to increasing percentages with a timer) Altered the accept() function of InstructionPage.mxml to return an int representing whether the block or module was completed, or neither. Changed functions related to accept(), allowing the program to tell the server what block they are on, as opposed to only on modules. Modified Paths: -------------- mentalmodels/trunk/flex/src/FisheryExperimentShell.mxml mentalmodels/trunk/flex/src/actionscript/InformationWindowCreator.as mentalmodels/trunk/flex/src/custom/FisheryExperimentCore.mxml mentalmodels/trunk/flex/src/custom/InstructionPage.mxml mentalmodels/trunk/flex/src/custom/questions/strategyDesign/PlannerRow.mxml Added Paths: ----------- mentalmodels/trunk/flex/src/HelpImage.png Removed Paths: ------------- mentalmodels/trunk/flex/src/custom/TimeLabel.mxml Modified: mentalmodels/trunk/flex/src/FisheryExperimentShell.mxml =================================================================== --- mentalmodels/trunk/flex/src/FisheryExperimentShell.mxml 2009-07-16 00:23:57 UTC (rev 185) +++ mentalmodels/trunk/flex/src/FisheryExperimentShell.mxml 2009-07-16 21:00:46 UTC (rev 186) @@ -1,50 +1,77 @@ <?xml version="1.0" encoding="utf-8"?> -<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" +<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:custom="custom.*" backgroundGradientAlphas="[1.0, 1.0]" backgroundGradientColors="[#FFFFFF, #B0B0FF]" - layout="horizontal" horizontalGap="30" - width="100%" height="100%" xmlns:custom="custom.*" + width="100%" height="100%" layout="vertical" horizontalAlign="center" initialize="init()"> - <!--<mx:Button id="btnTemp" label="Update" click="updateObjectA.updateLearned(new ArrayCollection([new ArrayCollection(['test']),new ArrayCollection(['test']),new ArrayCollection(['test'])]))"/>--> + <mx:Script><![CDATA[ + public var progressTimer:Timer; + [Bindable] public var progressBarWidth:Number = 600; + public function progressBarInit():void + { + progressTimer = new Timer(100, 100); // 21600 * 1000 = 6hrs + progressTimer.addEventListener(TimerEvent.TIMER, timerTick); + progressTimer.start(); + } + public function timerTick(event:TimerEvent):void + { + tick(progressTimer.currentCount/2/progressTimer.repeatCount, progressTimer.currentCount/progressTimer.repeatCount); + } + private function tick(percentModule:Number,percentBlock:Number):void + { + progressBarModule.width = progressBarWidth*percentModule; + progressBarBlock.width = progressBarWidth*percentBlock; + } + ]]></mx:Script> - <mx:VBox id="vbxInfo"> - <mx:TitleWindow id="InformationWindowA" width="400" height="200" title="Information Window A" - clipContent="true" horizontalScrollPolicy="on" verticalScrollPolicy="on"> - </mx:TitleWindow> - <mx:HBox id="hbxPickerA"> - <mx:ComboBox id="cbxPickerA" maxWidth="225" change="cbxChanged()"/> - <mx:Button id="btnPickerA" label="Pop Up" click="popupInformationWindow(1)"/> - </mx:HBox> + <mx:HBox horizontalGap="30" y="60"> + <mx:VBox id="vbxInfo"> + <mx:TitleWindow id="InformationWindowA" width="400" height="220" title="Information Window A" + clipContent="true" horizontalScrollPolicy="on" verticalScrollPolicy="on"> + </mx:TitleWindow> + <mx:HBox id="hbxPickerA"> + <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="400" height="220" title="Information Window B" + clipContent="true" horizontalScrollPolicy="on" verticalScrollPolicy="on"> + </mx:TitleWindow> + <mx:HBox id="hbxPickerB"> + <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(1);closedFunction(2)}"/> + </mx:VBox> - <mx:TitleWindow id="InformationWindowB" width="400" height="200" title="Information Window B" - clipContent="true" horizontalScrollPolicy="on" verticalScrollPolicy="on"> - </mx:TitleWindow> - <mx:HBox id="hbxPickerB"> - <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(1);closedFunction(2)}"/> - </mx:VBox> + <mx:VBox id="vbxContent" horizontalAlign="center" verticalAlign="middle"> + <mx:VBox id="progressBars" x="0" y="0" verticalGap="0" initialize="progressBarInit()"> + <mx:HBox> + <mx:Label text="Time for Module:" width="130" textAlign="right"/> + <mx:HBox width="{progressBarWidth+2}" borderStyle="solid"> + <mx:HBox id="progressBarModule" height="10" backgroundColor="#00FF00"/> + </mx:HBox> + </mx:HBox> + <mx:HBox> + <mx:Label text="Time for Block:" width="130" textAlign="right"/> + <mx:HBox width="{progressBarWidth+2}" borderStyle="solid"> + <mx:HBox id="progressBarBlock" height="10" backgroundColor="#00FF00"/> + </mx:HBox> + </mx:HBox> + </mx:VBox> + <custom:FisheryExperimentCore id="fisheryContent" blockLoader="loadBlock"/> + </mx:VBox> + </mx:HBox> - <mx:VBox id="vbxContent" horizontalAlign="center" verticalAlign="middle"> - <custom:FisheryExperimentCore 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; @@ -168,13 +195,18 @@ public function selectCurrentWindows(selectedWindows:ArrayCollection):void { + var mustHaveWindows:ArrayCollection = new ArrayCollection([0,2,3]); + + closedFunction(1); + closedFunction(2); + currInfoWindowsA = new ArrayCollection(); currInfoWindowsB = new ArrayCollection(); currInfoWindowsDescriptions = new ArrayCollection(); for(var i:int = 0; i < allInfoWindowsA.length; i++) { - if(selectedWindows.contains(i)) + if(selectedWindows.contains(i) || mustHaveWindows.contains(i)) { currInfoWindowsA.addItem(allInfoWindowsA.getItemAt(i)); currInfoWindowsB.addItem(allInfoWindowsB.getItemAt(i)); Added: mentalmodels/trunk/flex/src/HelpImage.png =================================================================== (Binary files differ) Property changes on: mentalmodels/trunk/flex/src/HelpImage.png ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Modified: mentalmodels/trunk/flex/src/actionscript/InformationWindowCreator.as =================================================================== --- mentalmodels/trunk/flex/src/actionscript/InformationWindowCreator.as 2009-07-16 00:23:57 UTC (rev 185) +++ mentalmodels/trunk/flex/src/actionscript/InformationWindowCreator.as 2009-07-16 21:00:46 UTC (rev 186) @@ -94,6 +94,24 @@ tempWindow = new ArrayCollection(); temp = new Label(); + (temp as Label).text = "How to Navigate the Program (Help)"; + (temp as Label).setStyle("fontSize",14); + (temp as Label).setStyle("fontWeight","bold"); + tempWindow.addItem(temp); + + [Embed(source="HelpImage.png")] var helpImg:Class; + temp = new Image(); + (temp as Image).source = helpImg; + tempWindow.addItem(temp); + + allInfoWindows.addItem(tempWindow); + allInfoWindowsDescriptions.addItem("Help"); + + //// + // Window 1 + 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"); @@ -108,7 +126,7 @@ allInfoWindowsDescriptions.addItem("Dummy Window"); //// - // Window 1 + // Window 2 tempWindow = new ArrayCollection(); temp = new Label(); @@ -117,9 +135,9 @@ (temp as Label).setStyle("fontWeight","bold"); tempWindow.addItem(temp); - [Embed(source="LakeImage.png")] var img:Class; + [Embed(source="LakeImage.png")] var lakeImg:Class; temp = new Image(); - (temp as Image).source = img; + (temp as Image).source = lakeImg; (temp as Image).maxWidth = 600; (temp as Image).maxHeight = 600; tempWindow.addItem(temp); @@ -128,7 +146,7 @@ allInfoWindowsDescriptions.addItem("Model of the Fishing Ground"); //// - // Window 2 + // Window 3 tempWindow = new ArrayCollection(); temp = new Label(); @@ -240,7 +258,7 @@ allInfoWindowsDescriptions.addItem("Important Formulas"); //// - // Window 3 + // Window 4 tempWindow = new ArrayCollection(); temp = new Label(); @@ -307,7 +325,7 @@ allInfoWindowsDescriptions.addItem("Help for Strategy Design"); //// - // Window 4 + // Window 5 tempWindow = new ArrayCollection(); temp = new Label(); @@ -326,7 +344,7 @@ allInfoWindowsDescriptions.addItem("Your Strategy"); //// - // Window 5 + // Window 6 tempWindow = new ArrayCollection(); temp = new Label(); @@ -368,7 +386,7 @@ allInfoWindowsDescriptions.addItem("Your Goals"); //// - // Window 6 + // Window 7 tempWindow = new ArrayCollection(); temp = new Label(); @@ -386,7 +404,7 @@ allInfoWindowsDescriptions.addItem("Your Forecast"); //// - // Window 7 + // Window 8 tempWindow = new ArrayCollection(); temp = new Label(); @@ -404,7 +422,7 @@ allInfoWindowsDescriptions.addItem("Day-by-Day Results"); //// - // Window 8 + // Window 9 tempWindow = new ArrayCollection(); temp = new Label(); @@ -422,7 +440,7 @@ allInfoWindowsDescriptions.addItem("Strategy Results"); //// - // Window 9 + // Window 10 tempWindow = new ArrayCollection(); temp = new Label(); @@ -459,7 +477,7 @@ allInfoWindowsDescriptions.addItem("Notes - Yourself"); //// - // Window 10 + // Window 11 tempWindow = new ArrayCollection(); temp = new Label(); @@ -525,10 +543,10 @@ content.addItem(allInfoWindowsDescriptions); content.addItem(updateObject); -for(var endLoop:int; endLoop < allInfoWindowsDescriptions.length; endLoop++) -{ - allInfoWindowsDescriptions.setItemAt(endLoop +" "+ (allInfoWindowsDescriptions.getItemAt(endLoop) as String), endLoop); -} +//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 ); Modified: mentalmodels/trunk/flex/src/custom/FisheryExperimentCore.mxml =================================================================== --- mentalmodels/trunk/flex/src/custom/FisheryExperimentCore.mxml 2009-07-16 00:23:57 UTC (rev 185) +++ mentalmodels/trunk/flex/src/custom/FisheryExperimentCore.mxml 2009-07-16 21:00:46 UTC (rev 186) @@ -49,9 +49,11 @@ <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="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:HBox id="buttonBar" left="{(width-buttonBar.width)/2}" bottom="0" horizontalGap="150"> + <mx:Button id="btnBack" label="« Back" click="back()" enabled="false"/> + <mx:Button id="btnAccept" label="Accept" click="accept()" /> + <mx:Button id="btnForward" label="Forward »" click="forward()" enabled="false"/> + </mx:HBox> <mx:RemoteObject id="ss" destination="studentService" fault="faultHandler(event)" result="resultHandler(event)"/> <mx:Producer id="producer" destination="DataPush" acknowledge="ack(event)"/> @@ -128,9 +130,15 @@ { } + private function reportBlockFinished():void + { + sendBlockQuestions(); + + // send something to server to indicate that someone finished a block + } private function getNextModule():void { - sendBlockQuestions(); + reportBlockFinished(); currModule = null; currModuleNumber++; @@ -260,15 +268,13 @@ obj.visible = false; expiredContent.addChild(obj); - currentState = "wait"; - getNextModule(); - - var info:SocioDemographicPage = SocioDemographicPage(obj); Id=ss.createStudent(info.getYear(), info.getSemester(), info.getGender(),info.getMajor()); + currentState = "wait"; btnBack.enabled = btnForward.enabled = true; + getNextModule(); returnValue = true; } } @@ -276,27 +282,31 @@ { try { - if( (InstructionPage)(obj).accept() ) + var instructionPageAcceptValue:int = (InstructionPage)(obj).accept(); + if( instructionPageAcceptValue == 2 ) { obj.visible = false; expiredContent.addChild(obj); currentState = "wait"; + //consumer.subscribe(); + getNextModule(); - //consumer.subscribe(); returnValue = true; } - else + else if( instructionPageAcceptValue == 1 ) { - var newCurrBlock:Block = (InstructionPage)(obj).block; - if(newCurrBlock != currBlock) - { - currBlock = newCurrBlock; - currBlockNumber++; - blockLoader.call(); - } + currBlock = (InstructionPage)(obj).block; + currBlockNumber++; + blockLoader.call(); + + reportBlockFinished(); + returnValue = true; } } - catch(err:Error){} + catch(err:Error) + { + returnValue = false; + } } btnBack.enabled = btnForward.enabled = (currentState == "instructions"); Modified: mentalmodels/trunk/flex/src/custom/InstructionPage.mxml =================================================================== --- mentalmodels/trunk/flex/src/custom/InstructionPage.mxml 2009-07-16 00:23:57 UTC (rev 185) +++ mentalmodels/trunk/flex/src/custom/InstructionPage.mxml 2009-07-16 21:00:46 UTC (rev 186) @@ -141,7 +141,7 @@ } - public function accept():Boolean // true iff completely finished with module + public function accept():int // 0: not finished, 1: finished block, 2: finished module { try { @@ -156,26 +156,27 @@ currBlock = nextBlock; init(module.blocks.getItemAt(currBlock) as Block); numPages = pageDisplay.pages.length; - return false; + + return 1; } else { - //server stuff goes here + //server stuff goes here (in FisheryExperiment,actually) - return true; // module finished + return 2; // module finished } } else { Alert.show("Cannot advance.\nTry looking at every page."); } - return false; + return 0; } catch(err:Error) { Alert.show("accepterror"+err.message+err.getStackTrace()); } - return false; + return 0; } public function save():ArrayCollection Deleted: mentalmodels/trunk/flex/src/custom/TimeLabel.mxml =================================================================== --- mentalmodels/trunk/flex/src/custom/TimeLabel.mxml 2009-07-16 00:23:57 UTC (rev 185) +++ mentalmodels/trunk/flex/src/custom/TimeLabel.mxml 2009-07-16 21:00:46 UTC (rev 186) @@ -1,28 +0,0 @@ -<?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> Modified: mentalmodels/trunk/flex/src/custom/questions/strategyDesign/PlannerRow.mxml =================================================================== --- mentalmodels/trunk/flex/src/custom/questions/strategyDesign/PlannerRow.mxml 2009-07-16 00:23:57 UTC (rev 185) +++ mentalmodels/trunk/flex/src/custom/questions/strategyDesign/PlannerRow.mxml 2009-07-16 21:00:46 UTC (rev 186) @@ -50,11 +50,12 @@ public function getLocation():String { - if(location.selectedIndex == 0) - { - return "Harbor"; - } - return "Bay " + location.selectedIndex; + return location.selectedItem as String; +// if(location.selectedIndex == 0) +// { +// return "Harbor"; +// } +// return "Bay " + location.selectedIndex; } public function setLocation(newValue:String):void { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <kj...@us...> - 2009-07-21 06:24:58
|
Revision: 191 http://virtualcommons.svn.sourceforge.net/virtualcommons/?rev=191&view=rev Author: kjonas Date: 2009-07-21 06:24:52 +0000 (Tue, 21 Jul 2009) Log Message: ----------- Modified "current page" tag to display current module, block within a module, and page within a block. all DayByDayDecisionsQuestionC.mxml and StrategyDesignQuestionC.mxml components within a block must be completed before the user can move on to a new block. (they can still page back and forth within a block) The StrategyDesignQuestionC.mxml component needs to have the "New" button clicked at least once. The user can then delete the new row, and it will still let them go on. Modified Paths: -------------- mentalmodels/trunk/flex/src/actionscript/PageDisplay.as mentalmodels/trunk/flex/src/custom/FisheryExperimentCore.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/psychometric/Slider.mxml mentalmodels/trunk/flex/src/custom/questions/strategyDesign/Planner.mxml mentalmodels/trunk/flex/src/custom/questions/strategyDesign/StrategyDesignQuestionC.mxml Modified: mentalmodels/trunk/flex/src/actionscript/PageDisplay.as =================================================================== --- mentalmodels/trunk/flex/src/actionscript/PageDisplay.as 2009-07-21 00:47:53 UTC (rev 190) +++ mentalmodels/trunk/flex/src/actionscript/PageDisplay.as 2009-07-21 06:24:52 UTC (rev 191) @@ -13,7 +13,6 @@ import mx.collections.ArrayCollection; import mx.containers.VBox; - import mx.controls.Alert; import mx.controls.Text; @@ -74,26 +73,8 @@ // txt.htmlText = tempQuestion.question; // tempBox.addChild(txt); - if(tempQuestion is ForecastingPeople) + if(tempQuestion is Categorical) { - var fpq:ForecastingPeopleQuestionC = new ForecastingPeopleQuestionC(); - fpq.locations = locations; - fpq.loadFromQuestion(ForecastingPeople(tempQuestion)); - fpq.id = "q"+question; - - tempBox.addChild(fpq); - } - else if(tempQuestion is ForecastingFish) - { - var ffq:ForecastingFishQuestionC = new ForecastingFishQuestionC(); - ffq.locations = locations; - ffq.loadFromQuestion(ForecastingFish(tempQuestion)); - ffq.id = "q"+question; - - tempBox.addChild(ffq); - } - else if(tempQuestion is Categorical) - { var cq:CategoricalQuestionC = new CategoricalQuestionC(); cq.loadFromQuestion(Categorical(tempQuestion)); cq.id = "q"+question; @@ -110,9 +91,16 @@ } else { - if(tempQuestion != null && tempQuestion.type != null && - tempQuestion.type.toLowerCase() == "strategydesign") + if(tempQuestion == null || tempQuestion.type == null) { + var tq:TextQuestionC = new TextQuestionC(); + tq.loadFromQuestion(Question(tempQuestion)); + tq.id = "q"+question; + + tempBox.addChild(tq); + } + if(tempQuestion.type.toLowerCase() == "strategydesign") + { var sdq:StrategyDesignQuestionC = new StrategyDesignQuestionC(); sdq.locations = locations; sdq.loadFromQuestion(Question(tempQuestion)); @@ -120,8 +108,7 @@ tempBox.addChild(sdq); } - else if(tempQuestion != null && tempQuestion.type != null && - tempQuestion.type.toLowerCase() == "daybydaydecisions") + else if(tempQuestion.type.toLowerCase() == "daybydaydecisions") { var ddq:DayByDayDecisionsQuestionC = new DayByDayDecisionsQuestionC(); ddq.locations = locations; @@ -130,9 +117,27 @@ tempBox.addChild(ddq); } + else if(tempQuestion.type.toLowerCase() == "forecastingfishermen") + { + var fpq:ForecastingPeopleQuestionC = new ForecastingPeopleQuestionC(); + fpq.locations = locations; + fpq.loadFromQuestion(tempQuestion); + fpq.id = "q"+question; + + tempBox.addChild(fpq); + } + else if(tempQuestion.type.toLowerCase() == "forecastingfish") + { + var ffq:ForecastingFishQuestionC = new ForecastingFishQuestionC(); + ffq.locations = locations; + ffq.loadFromQuestion(tempQuestion); + ffq.id = "q"+question; + + tempBox.addChild(ffq); + } else { - var tq:TextQuestionC = new TextQuestionC(); + tq = new TextQuestionC(); tq.loadFromQuestion(Question(tempQuestion)); tq.id = "q"+question; @@ -162,6 +167,44 @@ } + public function componentsNotFinished():Boolean + { + var returnValue:Boolean = false; + var curr:VBox = currentPage as VBox; + var messages:String = ""; + + if(curr != null) + { + var tempQuestion:DisplayObject; + for(var i:int=0; i < curr.numChildren; i++) + { + tempQuestion = (curr.getChildAt(i) as DisplayObject); + + if(tempQuestion is DayByDayDecisionsQuestionC) + { + messages += "D"; + if((tempQuestion as DayByDayDecisionsQuestionC).dayByDayContent.numChildren < 30) + { + returnValue = true; + } + } + else if(tempQuestion is StrategyDesignQuestionC) + { + messages += "S"; + if(!(tempQuestion as StrategyDesignQuestionC).accept()) + { + returnValue = true; + } + } + else + { + messages += "x"; + } + } +// Alert.show(messages + returnValue); + } + return returnValue; + } public function finished():Boolean { return highestPageReached >= minPagesRead - 1; } public function get length():int @@ -171,15 +214,9 @@ { if(pages != null && pages.length > 0) // pages? { - if(currentPageNumber >= 0) // how low? - { - if(currentPageNumber < pages.length) // how high? - { - return (DisplayObject)(pages.getItemAt(currentPageNumber)); // VALID_RESULT - } - return (DisplayObject)(pages.getItemAt(currentPageNumber = pages.length - 1)); // too high - } - return (DisplayObject)(pages.getItemAt(currentPageNumber = 0)); // too low + if(currentPageNumber < 0) currentPageNumber = 0; + if(currentPageNumber >= pages.length) currentPageNumber = pages.length - 1; + return (DisplayObject)(pages.getItemAt(currentPageNumber)); // VALID_RESULT } return null; // no pages Modified: mentalmodels/trunk/flex/src/custom/FisheryExperimentCore.mxml =================================================================== --- mentalmodels/trunk/flex/src/custom/FisheryExperimentCore.mxml 2009-07-21 00:47:53 UTC (rev 190) +++ mentalmodels/trunk/flex/src/custom/FisheryExperimentCore.mxml 2009-07-21 06:24:52 UTC (rev 191) @@ -125,6 +125,7 @@ { btnForward.enabled = btnBack.enabled = btnReset.enabled = true; instructionsLoaded = true; + instructions.moduleNumber = currModuleNumber; currentState = "instructions"; } private function sendBlockQuestions():void @@ -147,17 +148,6 @@ } private function moduleResultHandler(event:ResultEvent):void { - /* 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){ - - } */ - currModule = (event.result as actionscript.Module); if(currModule == null) Modified: mentalmodels/trunk/flex/src/custom/InstructionPage.mxml =================================================================== --- mentalmodels/trunk/flex/src/custom/InstructionPage.mxml 2009-07-21 00:47:53 UTC (rev 190) +++ mentalmodels/trunk/flex/src/custom/InstructionPage.mxml 2009-07-21 06:24:52 UTC (rev 191) @@ -12,8 +12,9 @@ import actionscript.PageDisplay; import mx.collections.ArrayCollection; + [Bindable] public var moduleNumber:int = 1; [Bindable] public var module:Module; - [Bindable] public var currBlock:int = 0; + [Bindable] public var blockNumber:int = 0; [Bindable] public var block:Block; [Bindable] public var pageDisplay:PageDisplay; [Bindable] public var numPages:int = 1; @@ -38,7 +39,7 @@ public function initModule(newModule:actionscript.Module):void { module = newModule; - currBlock = 0; + blockNumber = 0; if(module == null) { debug2.text += "module is null\n"; @@ -54,7 +55,7 @@ debug2.text += "module.blocks.length is less than 1\n"; return; } - init(module.blocks.getItemAt(currBlock) as Block); + init(module.blocks.getItemAt(blockNumber) as Block); } public function init(newBlock:Block):void @@ -125,7 +126,10 @@ private function postTurn():void { currPage = pageDisplay.currentPageNumber; - currPageLabel.text = "Page " + (currPage+1) + " / " + numPages; + currPageLabel.htmlText = + "Module: "+moduleNumber+ + "<br>Block: "+(blockNumber+1)+" / "+module.blocks.length+ + "<br>Page: "+(currPage+1)+" / "+numPages; content.removeAllChildren(); content.addChild(pageDisplay.currentPage); @@ -145,16 +149,21 @@ { try { - if(pageDisplay.finished()) + if(pageDisplay.componentsNotFinished()) { + Alert.show("Go back and complete all required sections of the Block.","Cannot Advance"); + return 0; + } + else if(pageDisplay.finished()) + { //switch blocks within module - var nextBlock:int = currBlock+1; + var nextBlock:int = blockNumber+1; if(nextBlock < module.blocks.length) { content.removeAllChildren(); - currBlock = nextBlock; - init(module.blocks.getItemAt(currBlock) as Block); + blockNumber = nextBlock; + init(module.blocks.getItemAt(blockNumber) as Block); numPages = pageDisplay.pages.length; return 1; @@ -168,7 +177,7 @@ } else { - Alert.show("Cannot advance.\nTry looking at every page."); + Alert.show("Try looking at every page.","Cannot Advance"); } return 0; } @@ -211,10 +220,10 @@ ]]> </mx:Script> - <mx:Label id="currPageLabel" text="Page {(currPage+1)} / {numPages}"/> + <mx:Text id="currPageLabel" htmlText="Module: {moduleNumber}<br>Block: {(blockNumber+1)} / {module.blocks.length}<br>Page: {(currPage+1)} / {numPages}"/> + <mx:VBox id="content"/> + <mx:Text id="debug" text="{pageDisplay.msg}" width="300"/> <mx:Text id="debug2" text="" width="300"/> - <mx:VBox id="content"/> - </mx:VBox> Modified: mentalmodels/trunk/flex/src/custom/questions/CategoricalQuestionC.mxml =================================================================== --- mentalmodels/trunk/flex/src/custom/questions/CategoricalQuestionC.mxml 2009-07-21 00:47:53 UTC (rev 190) +++ mentalmodels/trunk/flex/src/custom/questions/CategoricalQuestionC.mxml 2009-07-21 06:24:52 UTC (rev 191) @@ -1,7 +1,7 @@ <?xml version="1.0" encoding="utf-8"?> <mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:as="actionscript.*"> - <mx:Text width="600" text="{description}"/> + <mx:Text width="600" htmlText="{description}"/> <mx:Script> <![CDATA[ [Bindable] public var description:String = ""; Modified: mentalmodels/trunk/flex/src/custom/questions/TextQuestionC.mxml =================================================================== --- mentalmodels/trunk/flex/src/custom/questions/TextQuestionC.mxml 2009-07-21 00:47:53 UTC (rev 190) +++ mentalmodels/trunk/flex/src/custom/questions/TextQuestionC.mxml 2009-07-21 06:24:52 UTC (rev 191) @@ -1,7 +1,7 @@ <?xml version="1.0" encoding="utf-8"?> <mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml"> - <mx:Text width="600" text="{description}"/> + <mx:Text width="600" htmlText="{description}"/> <mx:Script> <![CDATA[ [Bindable] public var description:String = ""; Modified: mentalmodels/trunk/flex/src/custom/questions/dayByDayDecisions/DayByDayDecisionsQuestionC.mxml =================================================================== --- mentalmodels/trunk/flex/src/custom/questions/dayByDayDecisions/DayByDayDecisionsQuestionC.mxml 2009-07-21 00:47:53 UTC (rev 190) +++ mentalmodels/trunk/flex/src/custom/questions/dayByDayDecisions/DayByDayDecisionsQuestionC.mxml 2009-07-21 06:24:52 UTC (rev 191) @@ -1,7 +1,7 @@ <?xml version="1.0" encoding="utf-8"?> <mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml" initialize="init()"> - <mx:Text width="600" text="{description}"/> + <mx:Text width="600" htmlText="{description}"/> <mx:Script> <![CDATA[ [Bindable] public var description:String = ""; Modified: mentalmodels/trunk/flex/src/custom/questions/forecasting/ForecastingFishQuestionC.mxml =================================================================== --- mentalmodels/trunk/flex/src/custom/questions/forecasting/ForecastingFishQuestionC.mxml 2009-07-21 00:47:53 UTC (rev 190) +++ mentalmodels/trunk/flex/src/custom/questions/forecasting/ForecastingFishQuestionC.mxml 2009-07-21 06:24:52 UTC (rev 191) @@ -1,7 +1,7 @@ <?xml version="1.0" encoding="utf-8"?> <mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:components="custom.questions.forecasting.*"> - <mx:Text width="600" text="{description}"/> + <mx:Text width="600" htmlText="{description}"/> <mx:Script> <![CDATA[ [Bindable] public var description:String = ""; @@ -26,6 +26,7 @@ <mx:Script> <![CDATA[ + import actionscript.questions.Question; import actionscript.Location; import mx.controls.Alert; import actionscript.questions.ForecastingFish; @@ -79,7 +80,7 @@ loadPeople = newPeopleDisplay; peopleDisplay.load(loadPeople); } - public function loadFromQuestion(question:ForecastingFish):void + public function loadFromQuestion(question:Question):void { description = question.question; Modified: mentalmodels/trunk/flex/src/custom/questions/forecasting/ForecastingPeopleQuestionC.mxml =================================================================== --- mentalmodels/trunk/flex/src/custom/questions/forecasting/ForecastingPeopleQuestionC.mxml 2009-07-21 00:47:53 UTC (rev 190) +++ mentalmodels/trunk/flex/src/custom/questions/forecasting/ForecastingPeopleQuestionC.mxml 2009-07-21 06:24:52 UTC (rev 191) @@ -1,7 +1,7 @@ <?xml version="1.0" encoding="utf-8"?> <mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:components="custom.questions.forecasting.*"> - <mx:Text width="600" text="{description}"/> + <mx:Text width="600" htmlText="{description}"/> <mx:Script> <![CDATA[ [Bindable] public var description:String = ""; @@ -23,6 +23,7 @@ <mx:Script> <![CDATA[ + import actionscript.questions.Question; import actionscript.Location; import actionscript.questions.ForecastingPeople; import mx.collections.ArrayCollection; @@ -62,7 +63,7 @@ loadPeople = newPeopleDisplay; init(); } - public function loadFromQuestion(question:ForecastingPeople):void + public function loadFromQuestion(question:Question):void { description = question.question; Modified: mentalmodels/trunk/flex/src/custom/questions/psychometric/PsychometricQuestionC.mxml =================================================================== --- mentalmodels/trunk/flex/src/custom/questions/psychometric/PsychometricQuestionC.mxml 2009-07-21 00:47:53 UTC (rev 190) +++ mentalmodels/trunk/flex/src/custom/questions/psychometric/PsychometricQuestionC.mxml 2009-07-21 06:24:52 UTC (rev 191) @@ -1,7 +1,7 @@ <?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:Text width="600" text="{description}"/> + <mx:Text width="600" htmlText="{description}"/> <mx:Script> <![CDATA[ [Bindable] public var description:String = ""; @@ -10,13 +10,13 @@ <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"/> + <mx:Text id="topleft" htmlText="topleft" x="0" y="0" width="{Slider.bipolarWidth/3}" textAlign="left" visible="false"/> + <mx:Text id="topmid" htmlText="topmid" x="{Slider.bipolarWidth/3}" y="0" width="{Slider.bipolarWidth/3}" textAlign="center" visible="false"/> + <mx:Text id="topright" htmlText="topright" x="{Slider.bipolarWidth*2/3}" y="0" width="{Slider.bipolarWidth/3}" textAlign="right" visible="false"/> <!-- Used for unipolar psychometric scales --> - <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:Text id="farleft" htmlText="farleft" x="0" y="0" width="{Slider.unipolarWidth/2}" textAlign="left" visible="false"/> + <mx:Text id="farright" htmlText="farright" x="{Slider.unipolarWidth/2}" y="0" width="{Slider.unipolarWidth/2}" textAlign="right" visible="false"/> </mx:Canvas> <mx:Script> @@ -37,31 +37,29 @@ if(labels.length == 2) { - farleft.text = (String)(labels.getItemAt(0)); - farright.text = (String)(labels.getItemAt(1)); + farleft.htmlText = (String)(labels.getItemAt(0)); + farright.htmlText = (String)(labels.getItemAt(1)); farleft.visible = true; farright.visible = true; content.removeChild(topleft); content.removeChild(topmid); content.removeChild(topright); slider1.isBipolar = false; - slider1.x = 0; - slider1.y = 36; } else if(labels.length == 3) { - topleft.text = (String)(labels.getItemAt(0)); - topmid.text = (String)(labels.getItemAt(1)); - topright.text = (String)(labels.getItemAt(2)); + topleft.htmlText = (String)(labels.getItemAt(0)); + topmid.htmlText = (String)(labels.getItemAt(1)); + topright.htmlText = (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; } + slider1.x = 0; + slider1.y = 20; initializeSlider(); } Modified: mentalmodels/trunk/flex/src/custom/questions/psychometric/Slider.mxml =================================================================== --- mentalmodels/trunk/flex/src/custom/questions/psychometric/Slider.mxml 2009-07-21 00:47:53 UTC (rev 190) +++ mentalmodels/trunk/flex/src/custom/questions/psychometric/Slider.mxml 2009-07-21 06:24:52 UTC (rev 191) @@ -6,16 +6,15 @@ import mx.controls.Label; import mx.controls.Text; - [Bindable] - [Embed(source="SliderImage.png")] + [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; + [Bindable] public static var abstainValue:Number = -999; // Refusal to answer + [Bindable] public static var unipolarWidth:Number = 400; + [Bindable] public static var bipolarWidth:Number = 600; + [Bindable] private static var imageWidth:Number = 4; private var minValue:Number; // Rightmost value private var value:Number; // value selected @@ -39,6 +38,7 @@ sliderBar.width = unipolarWidth + imageWidth; minValue = 0; } + sliderButton.height = 25; addTicks(); reset(); @@ -54,17 +54,18 @@ for(var i:int = 0; i < numTicks; i++) { var tick:Label = new Label(); + tick.x = i*separation - imageWidth/2; + tick.y = 0; if(i == 0 || i == numTicks-1 || (i == int(numTicks / 2) && isBipolar)) { tick.htmlText = "<b>|</b>"; tick.setStyle("fontSize",12); + tick.x -= 2; } else { tick.htmlText = "<b>.</b>"; } - tick.x = i*separation - imageWidth/2; - tick.y = -10; addChild(tick); } } @@ -101,7 +102,7 @@ getValue(); // updates the bindable "getVal" variable var xPos:Number = index * separation; - sliderButton.move(xPos, 0); + sliderButton.move(xPos, 10); } public function reset():void @@ -116,10 +117,10 @@ <!-- change X value to 1/2 the width of the sliderButton image --> <mx:HBox id="sliderBar" - height="3" x="0" y="15" + height="3" x="0" y="25" borderStyle="solid" borderColor="#000000" borderThickness="1" /> - <mx:Image id="sliderButton" x="0" y="0" source="{sliderImage}"/> + <mx:Image id="sliderButton" x="0" y="10" source="{sliderImage}"/> </mx:Canvas> Modified: mentalmodels/trunk/flex/src/custom/questions/strategyDesign/Planner.mxml =================================================================== --- mentalmodels/trunk/flex/src/custom/questions/strategyDesign/Planner.mxml 2009-07-21 00:47:53 UTC (rev 190) +++ mentalmodels/trunk/flex/src/custom/questions/strategyDesign/Planner.mxml 2009-07-21 06:24:52 UTC (rev 191) @@ -10,6 +10,7 @@ import mx.controls.Label; public var valueRequired:Boolean = false; + public var hasBeenChanged:Boolean = false; [Bindable] public var locations:ArrayCollection = new ArrayCollection([newLocation(10, 0.50),newLocation(20, 0.15),newLocation(30, 0.05)]); private function newLocation(maxCapacity:Number,growth:Number):Location @@ -27,6 +28,7 @@ { addRow(); } + hasBeenChanged = false; } public function childRemoved():void @@ -44,6 +46,8 @@ newNumber.text = "" + (numbers.numChildren+1); newNumber.height = 22; + hasBeenChanged = true; + grid.addChildAt(newRow, grid.numChildren); numbers.addChild(newNumber); @@ -100,6 +104,10 @@ { setPlannerList(index, loadArray.getItemAt(index) as ArrayCollection); } + if(getPlannerRow(0) == null && valueRequired) + { + hasBeenChanged = false; + } } ]]> Modified: mentalmodels/trunk/flex/src/custom/questions/strategyDesign/StrategyDesignQuestionC.mxml =================================================================== --- mentalmodels/trunk/flex/src/custom/questions/strategyDesign/StrategyDesignQuestionC.mxml 2009-07-21 00:47:53 UTC (rev 190) +++ mentalmodels/trunk/flex/src/custom/questions/strategyDesign/StrategyDesignQuestionC.mxml 2009-07-21 06:24:52 UTC (rev 191) @@ -1,7 +1,7 @@ <?xml version="1.0" encoding="utf-8"?> <mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:qComp="custom.questions.strategyDesign.*"> - <mx:Text width="600" text="{description}"/> + <mx:Text width="600" htmlText="{description}"/> <mx:Script> <![CDATA[ [Bindable] public var description:String = ""; @@ -58,7 +58,7 @@ public function accept():Boolean { - return true; + return repeated.hasBeenChanged || notRepeated.hasBeenChanged; } public function save():ArrayCollection This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <see...@us...> - 2009-07-22 01:16:45
|
Revision: 195 http://virtualcommons.svn.sourceforge.net/virtualcommons/?rev=195&view=rev Author: seematalele Date: 2009-07-22 01:16:38 +0000 (Wed, 22 Jul 2009) Log Message: ----------- Added a check box in Question.mxml for communication question. Added variable in Question.as. Changed the InitialiseDatabase.mxml so that it will work properly according to changes in Question.as and Question.mxml. Modified Paths: -------------- mentalmodels/trunk/flex/src/InitialiseDatabase.mxml mentalmodels/trunk/flex/src/actionscript/questions/Question.as mentalmodels/trunk/flex/src/custom/db/Question.mxml Modified: mentalmodels/trunk/flex/src/InitialiseDatabase.mxml =================================================================== --- mentalmodels/trunk/flex/src/InitialiseDatabase.mxml 2009-07-22 01:13:40 UTC (rev 194) +++ mentalmodels/trunk/flex/src/InitialiseDatabase.mxml 2009-07-22 01:16:38 UTC (rev 195) @@ -38,14 +38,11 @@ <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..." hours="0" min="3" sec="0" sequenceNo="1" id="2"> - <question title="Most important goal" type="categorical" sequenceNo="1" id="1" > + <question title="Most important goal" type="categorical" sequenceNo="1" communication="true" id="1" > </question> - <question title="second important goal" type="psychometric" sequenceNo="2" id="2" > + <question title="second important goal" type="psychometric" sequenceNo="2" communication="false" id="2" > </question> - - </questiongroup> - </block> </module> @@ -61,7 +58,26 @@ private var survey:XML = <list> <module title="Survey Questions" id="0" sequenceNo="0" hours="0" min="0" sec="0"/> - + <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" + hours="0" min="3" sec="0" id="1" /> + + </block> + + </module> + <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..." hours="0" min="3" sec="0" sequenceNo="1" id="2"> + <question title="Most important goal" type="categorical" sequenceNo="1" communication="true" id="1" > + </question> + <question title="second important goal" type="psychometric" sequenceNo="2" communication="false" id="2" > + </question> + </questiongroup> + </block> + + </module> </list>; /** @@ -250,16 +266,18 @@ newQNode.@title = psychometricResult.question; newQNode.@type = psychometricResult.type; newQNode.@id = psychometricResult.id; + //Check if this question is for communication round. + newQNode.@communication = psychometricResult.communicationQ; choices = ""; if(psychometricResult.choices != null) { - + //Alert.show("choices is eqaul to : " + choices); for(var k:int = 0; k < psychometricResult.choices.length; k++) { if(choices == "") { - Alert.show("choices is eqaul to : " + choices); + //Alert.show("choices is eqaul to : " + choices); choices = psychometricResult.choices[k]; } else @@ -283,6 +301,7 @@ newQNode.@title = categoricalResult.question; newQNode.@type = categoricalResult.type; newQNode.@id = categoricalResult.id; + newQNode.@communication = categoricalResult.communicationQ; /*var questionGroup:XMLList =survey.module.block.questiongroup.(@header == node.@header); if( questionGroup.length() > 0 ) @@ -352,7 +371,8 @@ newQNode.@title = question.question; newQNode.@type = question.type; newQNode.@id = question.id; - + newQNode.@communication = question.communicationQ; + Alert.show("communication : " + question.communicationQ); } return newQNode; @@ -401,7 +421,6 @@ if( node.localName() == "categorical" ) return node.@type; - else return node.@name; @@ -966,9 +985,9 @@ asPsychometric.question = questionInfo.getQuestion(); asPsychometric.sequenceNo = int(questionInfo.getSequenceNo()); asPsychometric.type = questionInfo.getType(); - + asPsychometric.communicationQ = questionInfo.isCommunicationQuestion(); //Alert.show("Psychometric Object :"); - //Alert.show("Question: " + asPsychometric.question); + Alert.show("Communication: " + asPsychometric.communicationQ); //Alert.show("SeQ No: " + asPsychometric.sequenceNo); //Alert.show("Type : " + asPsychometric.type); @@ -1011,6 +1030,7 @@ categoricalQuestion.type = questionInfo.getType(); categoricalQuestion.question = questionInfo.getQuestion(); categoricalQuestion.sequenceNo = int(questionInfo.getSequenceNo()); + categoricalQuestion.communicationQ = questionInfo.isCommunicationQuestion(); /*for(var i:int = 0; i < categoricalQuestion.categoricalOptions.length ; i++) { var testoption:actionscript.questions.CategoricalOption = new actionscript.questions.CategoricalOption(); @@ -1059,6 +1079,7 @@ categoricalSimpleQuestion.type = questionInfo.getType(); categoricalSimpleQuestion.question = questionInfo.getQuestion(); categoricalSimpleQuestion.sequenceNo = int(questionInfo.getSequenceNo()); + categoricalSimpleQuestion.communicationQ = questionInfo.isCommunicationQuestion(); /*for(var j:int = 0; j < categoricalSimpleQuestion.categoricalOptions.length ; j++) { var testoption:ASCategoricalOption = new ASCategoricalOption(); @@ -1099,7 +1120,8 @@ question.question = questionInfo.getQuestion(); question.sequenceNo = int(questionInfo.getSequenceNo()); question.type = questionInfo.getType(); - //Alert.show("Type : " + question.type); + question.communicationQ = questionInfo.isCommunicationQuestion(); + Alert.show("communication : " + questionInfo.isCommunicationQuestion()); if(questionInfo.getId() == 0) { if(checkSeqNoQuestion.length() > 0) @@ -1186,6 +1208,7 @@ newQNode.@sequenceNo = psychometricResult.sequenceNo; newQNode.@title = psychometricResult.question; newQNode.@type = psychometricResult.type; + newQNode.@communication = psychometricResult.communicationQ; choices = ""; if(psychometricResult.choices != null) { @@ -1216,7 +1239,7 @@ newQNode.@title = categoricalResult.question; newQNode.@type = categoricalResult.type; newQNode.@id = categoricalResult.id; - + newQNode.@communication = categoricalResult.communicationQ; //flagType false means it is simple type, otherwise it is relative type var flagType:Boolean = false; @@ -1397,6 +1420,8 @@ questionInfo.setQuestion(node.@title); questionInfo.setSequenceNo(node.@sequenceNo); questionInfo.setId(node.@id); + Alert.show("communication: " + node.@communication); + questionInfo.setCommunicationQuestion(node.@communication); var str:String = node.@type; /*Alert.show("q type is: " + node.@type); questionInfo.cmbType.selectedItem = str.toLowerCase();*/ Modified: mentalmodels/trunk/flex/src/actionscript/questions/Question.as =================================================================== --- mentalmodels/trunk/flex/src/actionscript/questions/Question.as 2009-07-22 01:13:40 UTC (rev 194) +++ mentalmodels/trunk/flex/src/actionscript/questions/Question.as 2009-07-22 01:16:38 UTC (rev 195) @@ -12,6 +12,7 @@ public var type:String; public var sequenceNo:int; public var questionGroup:QuestionGroup; + public var communicationQ:Boolean; } } \ 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-22 01:13:40 UTC (rev 194) +++ mentalmodels/trunk/flex/src/custom/db/Question.mxml 2009-07-22 01:16:38 UTC (rev 195) @@ -59,9 +59,8 @@ return questionInfo; } + - - public function setQuestionType(type:String):void { for (var i: int = 0; i < cmbType.dataProvider.length; i++) @@ -75,7 +74,18 @@ } + public function setCommunicationQuestion(flag:String):void + { + if(flag == "true") + chkboxCommunication.selected = true; + else + chkboxCommunication.selected = false; + } + public function isCommunicationQuestion():Boolean + { + return chkboxCommunication.selected; + } public function validateForm(event:Event):Boolean { @@ -153,6 +163,7 @@ return currentControlIsValid; } + public function reset():void { currentState = "text"; @@ -162,8 +173,8 @@ txtSeqNo.errorString =""; rchtxtQuestion.errorString =""; cmbType.selectedIndex = -1; + chkboxCommunication.selected = false; - } ]]> @@ -196,6 +207,11 @@ <mx:RichTextEditor id="rchtxtQuestion" change="{validateForm(event)}" title="Question Editor" width="500" height="500" /> </mx:FormItem> <mx:Spacer height="20" /> + <mx:FormItem label= "Is this question for communication Round?"> + <mx:CheckBox id="chkboxCommunication" /> + </mx:FormItem> + + <mx:Spacer height="20" /> <mx:FormItem label="Select Question Type:"> <mx:ComboBox id="cmbType" change="{showQuestionType()}" width="100%" prompt="-Select-"> <mx:ArrayCollection> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <kj...@us...> - 2009-07-22 21:59:15
|
Revision: 202 http://virtualcommons.svn.sourceforge.net/virtualcommons/?rev=202&view=rev Author: kjonas Date: 2009-07-22 21:59:10 +0000 (Wed, 22 Jul 2009) Log Message: ----------- Added help window to InformationWindowCreator.as. Added the Question object into Question components. Increased width of PsychometricQuestionC.mxml sliders. Added code for reporting values of questions in FisheryExperimentCore.mxml. Modified Paths: -------------- mentalmodels/trunk/flex/src/actionscript/InformationWindowCreator.as mentalmodels/trunk/flex/src/custom/FisheryExperimentCore.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 Modified: mentalmodels/trunk/flex/src/actionscript/InformationWindowCreator.as =================================================================== --- mentalmodels/trunk/flex/src/actionscript/InformationWindowCreator.as 2009-07-22 21:50:39 UTC (rev 201) +++ mentalmodels/trunk/flex/src/actionscript/InformationWindowCreator.as 2009-07-22 21:59:10 UTC (rev 202) @@ -335,7 +335,7 @@ 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).question.question = "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; Modified: mentalmodels/trunk/flex/src/custom/FisheryExperimentCore.mxml =================================================================== --- mentalmodels/trunk/flex/src/custom/FisheryExperimentCore.mxml 2009-07-22 21:50:39 UTC (rev 201) +++ mentalmodels/trunk/flex/src/custom/FisheryExperimentCore.mxml 2009-07-22 21:59:10 UTC (rev 202) @@ -153,45 +153,87 @@ for(var j:int=0; j<curr.numChildren; j++) { studentResponse = new StudentResponse(); -// studentResponse.student = Id; + studentResponse.student = studentObject; + studentResponse.question = null; + var row:int, col:int; + if(curr.getChildAt(j) is TextQuestionC) { -// studentResponse.question = (curr.getChildAt(j) as TextQuestionC).description; + studentResponse.question = (curr.getChildAt(j) as TextQuestionC).question; studentResponse.response = (curr.getChildAt(j) as TextQuestionC).textAnswer.text; } else if(curr.getChildAt(j) is PsychometricQuestionC) { -// studentResponse.question = (curr.getChildAt(j) as PsychometricQuestionC).description; + studentResponse.question = (curr.getChildAt(j) as PsychometricQuestionC).question; studentResponse.response = (curr.getChildAt(j) as PsychometricQuestionC).slider1.getValue() + ""; } else if(curr.getChildAt(j) is CategoricalQuestionC) { -// studentResponse.question = (curr.getChildAt(j) as CategoricalQuestionC).description; + studentResponse.question = (curr.getChildAt(j) as CategoricalQuestionC).question; studentResponse.response = (curr.getChildAt(j) as CategoricalQuestionC).comboTopic.selectedItem as String; studentResponse.response += ", "; studentResponse.response += (curr.getChildAt(j) as CategoricalQuestionC).comboSpecific.selectedItem as String; } else if(curr.getChildAt(j) is DayByDayDecisionsQuestionC) { -// studentResponse.question = (curr.getChildAt(j) as DayByDayDecisionsQuestionC).description; + studentResponse.question = (curr.getChildAt(j) as DayByDayDecisionsQuestionC).question; studentResponse.response = null; } else if(curr.getChildAt(j) is ForecastingPeopleQuestionC) { -// studentResponse.question = (curr.getChildAt(j) as ForecastingPeopleQuestionC).description; - studentResponse.response = null; + var forecast1:ForecastingPeopleQuestionC = (curr.getChildAt(j) as ForecastingPeopleQuestionC); + for(row=0; row<locations.length; row++) + { + studentResponse = new StudentResponse(); + studentResponse.student = studentObject; + studentResponse.question = forecast1.question; + studentResponse.response = forecast1.peopleEntry.labels.getChildAt(row+1) + " "; + for(col=0; col<forecast1.peopleEntry.dataGrid.columnCount; col++) + { + studentResponse.response += (col+1) + ":" + forecast1.peopleEntry.getItem(row,col); + if(col<forecast1.peopleEntry.dataGrid.columnCount-1) + { + studentResponse.response += ", "; + } + } + // server: submit the response + } + studentResponse = new StudentResponse(); + studentResponse.question = null; } else if(curr.getChildAt(j) is ForecastingFishQuestionC) { -// studentResponse.question = (curr.getChildAt(j) as ForecastingFishQuestionC).description; - studentResponse.response = null; + var forecast2:ForecastingFishQuestionC = (curr.getChildAt(j) as ForecastingFishQuestionC); + for(row=0; row<locations.length-1; row++) + { + studentResponse = new StudentResponse(); + studentResponse.student = studentObject; + studentResponse.question = forecast2.question; + studentResponse.response = forecast2.fishEntry.labels.getChildAt(row+1) + " "; + for(col=0; col<forecast2.fishEntry.dataGrid.columnCount; col++) + { + studentResponse.response += (col+1) + ":" + forecast2.fishEntry.getItem(row,col); + if(col<forecast2.fishEntry.dataGrid.columnCount-1) + { + studentResponse.response += ", "; + } + } + // server: submit the response + } + studentResponse = new StudentResponse(); + studentResponse.question = null; } else if(curr.getChildAt(j) is StrategyDesignQuestionC) { -// studentResponse.question = (curr.getChildAt(j) as StrategyDesignQuestionC).description; + studentResponse.question = (curr.getChildAt(j) as StrategyDesignQuestionC).question; studentResponse.response = null; } + + if(studentResponse.question != null) + { + // server: submit the response + } } } } Modified: mentalmodels/trunk/flex/src/custom/questions/CategoricalQuestionC.mxml =================================================================== --- mentalmodels/trunk/flex/src/custom/questions/CategoricalQuestionC.mxml 2009-07-22 21:50:39 UTC (rev 201) +++ mentalmodels/trunk/flex/src/custom/questions/CategoricalQuestionC.mxml 2009-07-22 21:59:10 UTC (rev 202) @@ -1,10 +1,11 @@ <?xml version="1.0" encoding="utf-8"?> <mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:as="actionscript.*"> - <mx:Text width="600" htmlText="{description}"/> + <mx:Text width="600" htmlText="{question.question}"/> <mx:Script> <![CDATA[ - [Bindable] public var description:String = ""; + import actionscript.questions.Question; + [Bindable] public var question:Question = new Question(); ]]> </mx:Script> @@ -58,7 +59,7 @@ comboTopic.selectedIndex = 0; comboSpecific.selectedIndex = -1; - description = question.question; + this.question = question; } ]]> Modified: mentalmodels/trunk/flex/src/custom/questions/TextQuestionC.mxml =================================================================== --- mentalmodels/trunk/flex/src/custom/questions/TextQuestionC.mxml 2009-07-22 21:50:39 UTC (rev 201) +++ mentalmodels/trunk/flex/src/custom/questions/TextQuestionC.mxml 2009-07-22 21:59:10 UTC (rev 202) @@ -1,10 +1,11 @@ <?xml version="1.0" encoding="utf-8"?> <mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml"> - <mx:Text width="600" htmlText="{description}"/> + <mx:Text width="600" htmlText="{question.question}"/> <mx:Script> <![CDATA[ - [Bindable] public var description:String = ""; + import actionscript.questions.Question; + [Bindable] public var question:Question = new Question(); ]]> </mx:Script> @@ -32,7 +33,7 @@ public function loadFromQuestion(question:Question):void { - description = question.question; + this.question = question; initialize(); // init(); Modified: mentalmodels/trunk/flex/src/custom/questions/dayByDayDecisions/DayByDayDecisionsQuestionC.mxml =================================================================== --- mentalmodels/trunk/flex/src/custom/questions/dayByDayDecisions/DayByDayDecisionsQuestionC.mxml 2009-07-22 21:50:39 UTC (rev 201) +++ mentalmodels/trunk/flex/src/custom/questions/dayByDayDecisions/DayByDayDecisionsQuestionC.mxml 2009-07-22 21:59:10 UTC (rev 202) @@ -1,10 +1,11 @@ <?xml version="1.0" encoding="utf-8"?> <mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml" initialize="init()"> - <mx:Text width="600" htmlText="{description}"/> + <mx:Text width="600" htmlText="{question.question}"/> <mx:Script> <![CDATA[ - [Bindable] public var description:String = ""; + import actionscript.questions.Question; + [Bindable] public var question:Question = new Question(); ]]> </mx:Script> @@ -188,7 +189,7 @@ public function loadFromQuestion(question:Question):void { - description = question.question; + this.question = question; initialize(); init(); Modified: mentalmodels/trunk/flex/src/custom/questions/forecasting/ForecastingFishQuestionC.mxml =================================================================== --- mentalmodels/trunk/flex/src/custom/questions/forecasting/ForecastingFishQuestionC.mxml 2009-07-22 21:50:39 UTC (rev 201) +++ mentalmodels/trunk/flex/src/custom/questions/forecasting/ForecastingFishQuestionC.mxml 2009-07-22 21:59:10 UTC (rev 202) @@ -1,10 +1,11 @@ <?xml version="1.0" encoding="utf-8"?> <mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:components="custom.questions.forecasting.*"> - <mx:Text width="600" htmlText="{description}"/> + <mx:Text width="600" htmlText="{question.question}"/> <mx:Script> <![CDATA[ - [Bindable] public var description:String = ""; + import actionscript.questions.Question; + [Bindable] public var question:Question = new Question(); ]]> </mx:Script> @@ -82,7 +83,7 @@ } public function loadFromQuestion(question:Question):void { - description = question.question; + this.question = question; initialize(); init(); Modified: mentalmodels/trunk/flex/src/custom/questions/forecasting/ForecastingPeopleQuestionC.mxml =================================================================== --- mentalmodels/trunk/flex/src/custom/questions/forecasting/ForecastingPeopleQuestionC.mxml 2009-07-22 21:50:39 UTC (rev 201) +++ mentalmodels/trunk/flex/src/custom/questions/forecasting/ForecastingPeopleQuestionC.mxml 2009-07-22 21:59:10 UTC (rev 202) @@ -1,10 +1,11 @@ <?xml version="1.0" encoding="utf-8"?> <mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:components="custom.questions.forecasting.*"> - <mx:Text width="600" htmlText="{description}"/> + <mx:Text width="600" htmlText="{question.question}"/> <mx:Script> <![CDATA[ - [Bindable] public var description:String = ""; + import actionscript.questions.Question; + [Bindable] public var question:Question = new Question(); ]]> </mx:Script> @@ -65,7 +66,7 @@ } public function loadFromQuestion(question:Question):void { - description = question.question; + this.question = question; initialize(); init(); Modified: mentalmodels/trunk/flex/src/custom/questions/psychometric/PsychometricQuestionC.mxml =================================================================== --- mentalmodels/trunk/flex/src/custom/questions/psychometric/PsychometricQuestionC.mxml 2009-07-22 21:50:39 UTC (rev 201) +++ mentalmodels/trunk/flex/src/custom/questions/psychometric/PsychometricQuestionC.mxml 2009-07-22 21:59:10 UTC (rev 202) @@ -1,10 +1,11 @@ <?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:Text width="600" htmlText="{description}"/> + <mx:Text width="600" htmlText="{question.question}"/> <mx:Script> <![CDATA[ - [Bindable] public var description:String = ""; + import actionscript.questions.Question; + [Bindable] public var question:Question = new Question(); ]]> </mx:Script> @@ -92,7 +93,7 @@ public function loadFromQuestion(question:Psychometric):void { - description = question.question; + this.question = question; maxValue = question.maxSliderValue; labels = loadChoices(question); Modified: mentalmodels/trunk/flex/src/custom/questions/strategyDesign/StrategyDesignQuestionC.mxml =================================================================== --- mentalmodels/trunk/flex/src/custom/questions/strategyDesign/StrategyDesignQuestionC.mxml 2009-07-22 21:50:39 UTC (rev 201) +++ mentalmodels/trunk/flex/src/custom/questions/strategyDesign/StrategyDesignQuestionC.mxml 2009-07-22 21:59:10 UTC (rev 202) @@ -1,10 +1,11 @@ <?xml version="1.0" encoding="utf-8"?> <mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:qComp="custom.questions.strategyDesign.*"> - <mx:Text width="600" htmlText="{description}"/> + <mx:Text width="600" htmlText="{question.question}"/> <mx:Script> <![CDATA[ - [Bindable] public var description:String = ""; + import actionscript.questions.Question; + [Bindable] public var question:Question = new Question(); ]]> </mx:Script> @@ -81,7 +82,7 @@ public function loadFromQuestion(question:Question):void { - description = question.question; + this.question = question; initialize(); // init(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <kj...@us...> - 2009-07-24 23:11:33
|
Revision: 207 http://virtualcommons.svn.sourceforge.net/virtualcommons/?rev=207&view=rev Author: kjonas Date: 2009-07-24 23:11:25 +0000 (Fri, 24 Jul 2009) Log Message: ----------- Added Entities as .as classes for all known entities Removed modules from FisheryExperimentCore.mxml, now fetching block-by-block. Modified Paths: -------------- mentalmodels/trunk/flex/src/custom/FisheryExperimentCore.mxml mentalmodels/trunk/flex/src/custom/InstructionPage.mxml Added Paths: ----------- mentalmodels/trunk/flex/src/actionscript/CategoricalOption.as mentalmodels/trunk/flex/src/actionscript/Communication.as mentalmodels/trunk/flex/src/actionscript/Game.as mentalmodels/trunk/flex/src/actionscript/Group.as mentalmodels/trunk/flex/src/actionscript/ModuleRoundConfig.as mentalmodels/trunk/flex/src/actionscript/Persistable.as mentalmodels/trunk/flex/src/actionscript/PersistableSequence.as mentalmodels/trunk/flex/src/actionscript/Round.as mentalmodels/trunk/flex/src/actionscript/StudentRoundConfig.as mentalmodels/trunk/flex/src/actionscript/SuspendRepetition.as mentalmodels/trunk/flex/src/custom/questions/DayByDayOutput.mxml Removed Paths: ------------- mentalmodels/trunk/flex/src/actionscript/CustomNumericStepper.as Property Changed: ---------------- mentalmodels/trunk/flex/src/ Property changes on: mentalmodels/trunk/flex/src ___________________________________________________________________ Added: svn:ignore + messaging-config.xml proxy-config.xml remoting-config.xml services-config.xml Added: mentalmodels/trunk/flex/src/actionscript/CategoricalOption.as =================================================================== --- mentalmodels/trunk/flex/src/actionscript/CategoricalOption.as (rev 0) +++ mentalmodels/trunk/flex/src/actionscript/CategoricalOption.as 2009-07-24 23:11:25 UTC (rev 207) @@ -0,0 +1,14 @@ +package actionscript +{ + + 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/Communication.as =================================================================== --- mentalmodels/trunk/flex/src/actionscript/Communication.as (rev 0) +++ mentalmodels/trunk/flex/src/actionscript/Communication.as 2009-07-24 23:11:25 UTC (rev 207) @@ -0,0 +1,13 @@ +package actionscript +{ + [Bindable] + [RemoteClass(alias="edu.asu.commons.mme.entity.Communication")] + public class Communication + { + public var id:Number; + public var message:String; + public var timestamp:Timestamp; + public var student:Student; + public var round:Round; + } +} \ No newline at end of file Deleted: mentalmodels/trunk/flex/src/actionscript/CustomNumericStepper.as =================================================================== --- mentalmodels/trunk/flex/src/actionscript/CustomNumericStepper.as 2009-07-24 21:29:16 UTC (rev 206) +++ mentalmodels/trunk/flex/src/actionscript/CustomNumericStepper.as 2009-07-24 23:11:25 UTC (rev 207) @@ -1,20 +0,0 @@ -package actionscript -{ - import mx.controls.NumericStepper; - - public class CustomNumericStepper extends mx.controls.NumericStepper - { - - public function CustomNumericStepper() - { - super(); - super.stepSize = 1; - super.maximum = 3; - super.minimum = 0; - - } - - - - } -} \ No newline at end of file Added: mentalmodels/trunk/flex/src/actionscript/Game.as =================================================================== --- mentalmodels/trunk/flex/src/actionscript/Game.as (rev 0) +++ mentalmodels/trunk/flex/src/actionscript/Game.as 2009-07-24 23:11:25 UTC (rev 207) @@ -0,0 +1,21 @@ +package actionscript +{ + import mx.collections.ArrayCollection; + + [Bindable] + [RemoteClass(alias="edu.asu.commons.mme.entity.Game")] + public class Game + { + public var id:Number; + public var numberOfRounds:int; + public var numberOfLocations:int; + public var maxDays:int; + public var maxFishHarvest:int; + public var timestamp:Timestamp; + public var title:String; + public var description:String; + public var money:Number; + public var imageLocation:String; + public var rounds:ArrayCollection; + } +} \ No newline at end of file Added: mentalmodels/trunk/flex/src/actionscript/Group.as =================================================================== --- mentalmodels/trunk/flex/src/actionscript/Group.as (rev 0) +++ mentalmodels/trunk/flex/src/actionscript/Group.as 2009-07-24 23:11:25 UTC (rev 207) @@ -0,0 +1,11 @@ +package actionscript +{ + [Bindable] + [RemoteClass(alias="edu.asu.commons.mme.entity.Group")] + public class Group + { + public var id:Number; + public var number:int; + public var game:Game; + } +} \ No newline at end of file Added: mentalmodels/trunk/flex/src/actionscript/ModuleRoundConfig.as =================================================================== --- mentalmodels/trunk/flex/src/actionscript/ModuleRoundConfig.as (rev 0) +++ mentalmodels/trunk/flex/src/actionscript/ModuleRoundConfig.as 2009-07-24 23:11:25 UTC (rev 207) @@ -0,0 +1,12 @@ +package actionscript +{ + [Bindable] + [RemoteClass(alias="edu.asu.commons.mme.entity.ModuleRoundConfig")] + public class ModuleRoundConfig + { + public var id:Number; + public var sequenceNo:int; + public var module:Module; + public var round:Round; + } +} \ No newline at end of file Added: mentalmodels/trunk/flex/src/actionscript/Persistable.as =================================================================== --- mentalmodels/trunk/flex/src/actionscript/Persistable.as (rev 0) +++ mentalmodels/trunk/flex/src/actionscript/Persistable.as 2009-07-24 23:11:25 UTC (rev 207) @@ -0,0 +1,9 @@ +package actionscript +{ + + [Bindable] + [RemoteClass(alias="edu.asu.commons.mme.entity.Persistable")] + public class Persistable + { + } +} \ No newline at end of file Added: mentalmodels/trunk/flex/src/actionscript/PersistableSequence.as =================================================================== --- mentalmodels/trunk/flex/src/actionscript/PersistableSequence.as (rev 0) +++ mentalmodels/trunk/flex/src/actionscript/PersistableSequence.as 2009-07-24 23:11:25 UTC (rev 207) @@ -0,0 +1,10 @@ +package actionscript +{ + + [Bindable] + [RemoteClass(alias="edu.asu.commons.mme.entity.PersistableSequence")] + public class PersistableSequence + { + public var sequenceNumber:int; + } +} \ No newline at end of file Added: mentalmodels/trunk/flex/src/actionscript/Round.as =================================================================== --- mentalmodels/trunk/flex/src/actionscript/Round.as (rev 0) +++ mentalmodels/trunk/flex/src/actionscript/Round.as 2009-07-24 23:11:25 UTC (rev 207) @@ -0,0 +1,13 @@ +package actionscript +{ + + [Bindable] + [RemoteClass(alias="edu.asu.commons.mme.entity.Round")] + public class Round + { + public var id:Number; + public var roundNo:int; + public var game:Game; + public var communicationFlag:Boolean; + } +} \ No newline at end of file Added: mentalmodels/trunk/flex/src/actionscript/StudentRoundConfig.as =================================================================== --- mentalmodels/trunk/flex/src/actionscript/StudentRoundConfig.as (rev 0) +++ mentalmodels/trunk/flex/src/actionscript/StudentRoundConfig.as 2009-07-24 23:11:25 UTC (rev 207) @@ -0,0 +1,14 @@ +package actionscript +{ + + [Bindable] + [RemoteClass(alias="edu.asu.commons.mme.entity.StudentRoundConfig")] + public class StudentRoundConfig + { + public var id:Number; + public var student:Student; + public var roundconfig:Round; + public var currentAllocationNo:int; + public var currentDayNo:int; + } +} \ No newline at end of file Added: mentalmodels/trunk/flex/src/actionscript/SuspendRepetition.as =================================================================== --- mentalmodels/trunk/flex/src/actionscript/SuspendRepetition.as (rev 0) +++ mentalmodels/trunk/flex/src/actionscript/SuspendRepetition.as 2009-07-24 23:11:25 UTC (rev 207) @@ -0,0 +1,14 @@ +package actionscript +{ + + [Bindable] + [RemoteClass(alias="edu.asu.commons.mme.entity.SuspendRepetition")] + public class SuspendRepetition + { + public var id:Number; + public var roundConfig:Round; + public var student:Student; + public var daysInHarbor:int; + public var fishingThreshold:Number; + } +} \ No newline at end of file Modified: mentalmodels/trunk/flex/src/custom/FisheryExperimentCore.mxml =================================================================== --- mentalmodels/trunk/flex/src/custom/FisheryExperimentCore.mxml 2009-07-24 21:29:16 UTC (rev 206) +++ mentalmodels/trunk/flex/src/custom/FisheryExperimentCore.mxml 2009-07-24 23:11:25 UTC (rev 207) @@ -21,7 +21,7 @@ </mx:AddChild> </mx:State> - <mx:State name="instructions" enterState="instructions.initModule(currModule)"> + <mx:State name="instructions" enterState="instructions.init(currentBlock)"> <mx:RemoveChild target="{instructions}"/> <mx:AddChild relativeTo="{content}" target="{instructions}"/> <mx:SetProperty target="{instructions}" name="visible" value="true"/> @@ -29,7 +29,7 @@ <mx:State name="wait"> <mx:AddChild relativeTo="{content}"> - <mx:Label id="lblWaiting" text="Waiting for next Module from server..." fontSize="16"/> + <mx:Label id="lblWaiting" text="Waiting for next Block from server..." fontSize="16"/> </mx:AddChild> </mx:State> @@ -64,6 +64,8 @@ <mx:method name="createStudent" result="studentResultHandler(event)"/> <mx:method name="getFirstModule" result="moduleResultHandler(event)"/> </mx:RemoteObject> + <mx:RemoteObject id="answeringService" destination="answeringService" fault="faultHandler(event)"> + </mx:RemoteObject> <mx:Producer id="producer" destination="DataPush" acknowledge="ack(event)"/> <mx:Consumer id="consumer" destination="DataPush" message="messageHandler(event.message)" /> @@ -95,10 +97,10 @@ // // Important Variables // - public var currModule:Module = null; - public var currModuleNumber:int = 0; - public var currBlock:Block = null; - public var currBlockNumber:int = 0; + public var currentModule:Module = null; + public var currentModuleNumber:int = 0; + public var currentBlock:Block = null; + public var currentBlockNumber:int = 0; [Bindable] public var locations:ArrayCollection = new ArrayCollection([newLocation(10, 0.50),newLocation(20, 0.15),newLocation(30, 0.05)]); public var blockLoader:Function = null; @@ -108,7 +110,7 @@ public var instructionsLoaded:Boolean = false; - [Bindable] public var studentObject:Student; + [Bindable] public var studentObject:actionscript.Student; private function newLocation(maxCapacity:Number,growth:Number):Location { @@ -136,13 +138,14 @@ { btnForward.enabled = btnBack.enabled = btnReset.enabled = true; instructionsLoaded = true; - instructions.moduleNumber = currModuleNumber; + instructions.moduleNumber = currentModuleNumber; currentState = "instructions"; } private function sendBlockQuestions():void { if(instructions == null) return; + var responseList:ArrayCollection = new ArrayCollection(); var studentResponse:StudentResponse; var pages:ArrayCollection = instructions.pageDisplay.pages; @@ -197,7 +200,8 @@ studentResponse.response += ", "; } } - // server: submit the response + + responseList.addItem(studentResponse); } studentResponse = new StudentResponse(); studentResponse.question = null; @@ -219,7 +223,8 @@ studentResponse.response += ", "; } } - // server: submit the response + + responseList.addItem(studentResponse); } studentResponse = new StudentResponse(); studentResponse.question = null; @@ -232,10 +237,12 @@ if(studentResponse.question != null) { - // server: submit the response + responseList.addItem(studentResponse); } } } + + answeringService.saveQuestion(responseList); } private function reportBlockFinished():void { @@ -246,23 +253,31 @@ private function getNextModule():void { if(instructions != null) reportBlockFinished(); - currModule = null; - currModuleNumber++; + currentModule = null; + currentModuleNumber++; - roundService.getNextModule(currModuleNumber); + roundService.getNextModule(currentModuleNumber); } + private function getNextBlock():void + { + if(instructions != null) reportBlockFinished(); + currentBlock = null; + currentBlockNumber++; + + //server request + } private function moduleResultHandler(event:ResultEvent):void { - currModule = (event.result as actionscript.Module); + currentModule = (event.result as actionscript.Module); - if(currModule == null) + if(currentModule == null) { currentState = "none"; } - else if(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) + else if(currentModule.blocks == null || currentModule.blocks.length < 1 || + (currentModule.blocks.getItemAt(0) as Block) == null || + (currentModule.blocks.getItemAt(0) as Block).questionGroups == null || + (currentModule.blocks.getItemAt(0) as Block).questionGroups.length < 1) { currentState = "none"; } @@ -290,7 +305,7 @@ private function studentResultHandler(event:ResultEvent):void { - studentObject = event.result as Student; + studentObject = event.result as actionscript.Student; consumer.disconnect(); } private function faultHandler(event:FaultEvent):void @@ -369,26 +384,17 @@ { try { - var instructionPageAcceptValue:int = (InstructionPage)(obj).accept(); - if( instructionPageAcceptValue == 2 ) + var instructionPageAcceptValue:Boolean = (InstructionPage)(obj).accept(); + if( (InstructionPage)(obj).accept() ) { obj.visible = false; expiredContent.addChild(obj); currentState = "wait"; //consumer.subscribe(); - getNextModule(); + getNextBlock(); //TK returnValue = true; } - else if( instructionPageAcceptValue == 1 ) - { - currBlock = (InstructionPage)(obj).block; - currBlockNumber++; - blockLoader.call(); - - reportBlockFinished(); - returnValue = true; - } } catch(err:Error) { Modified: mentalmodels/trunk/flex/src/custom/InstructionPage.mxml =================================================================== --- mentalmodels/trunk/flex/src/custom/InstructionPage.mxml 2009-07-24 21:29:16 UTC (rev 206) +++ mentalmodels/trunk/flex/src/custom/InstructionPage.mxml 2009-07-24 23:11:25 UTC (rev 207) @@ -26,6 +26,7 @@ public var savedForecastFish:ArrayCollection = null; public var savedStrategyDesign:ArrayCollection = null; public var savedDayByDayDecisions:ArrayCollection = null; +// public var savedDayByDayDecisions:ArrayCollection = null; private function newLocation(maxCapacity:Number,growth:Number):Location { @@ -36,27 +37,27 @@ return newLoc; } - public function initModule(newModule:actionscript.Module):void - { - module = newModule; - blockNumber = 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(blockNumber) as Block); - } +// public function initModule(newModule:actionscript.Module):void +// { +// module = newModule; +// blockNumber = 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(blockNumber) as Block); +// } public function init(newBlock:Block):void { @@ -128,7 +129,7 @@ currPage = pageDisplay.currentPageNumber; currPageLabel.htmlText = "Module: "+moduleNumber+ - "<br>Block: "+(blockNumber+1)+" / "+module.blocks.length+ + "<br>Block: "+(blockNumber+1)+ "<br>Page: "+(currPage+1)+" / "+numPages; content.removeAllChildren(); @@ -145,47 +146,28 @@ } - public function accept():int // 0: not finished, 1: finished block, 2: finished module + public function accept():Boolean { try { if(pageDisplay.componentsNotFinished()) { - Alert.show("Go back and complete all required sections of the Block.","Cannot Advance"); - return 0; + Alert.show("You must complete all required sections of the Block.","Cannot Advance"); } else if(pageDisplay.finished()) { - //switch blocks within module - var nextBlock:int = blockNumber+1; - if(nextBlock < module.blocks.length) - { - content.removeAllChildren(); - - blockNumber = nextBlock; - init(module.blocks.getItemAt(blockNumber) as Block); - numPages = pageDisplay.pages.length; - - return 1; - } - else - { - //server stuff goes here (in FisheryExperiment,actually) - - return 2; // module finished - } + return true; } else { Alert.show("Try looking at every page.","Cannot Advance"); } - return 0; } catch(err:Error) { - Alert.show("accepterror"+err.message+err.getStackTrace()); + Alert.show(err.message+"\n"+err.getStackTrace(),"Accept Error"); } - return 0; + return false; } public function reset():void @@ -220,7 +202,7 @@ ]]> </mx:Script> - <mx:Text id="currPageLabel" htmlText="Module: {moduleNumber}<br>Block: {(blockNumber+1)} / {module.blocks.length}<br>Page: {(currPage+1)} / {numPages}"/> + <mx:Text id="currPageLabel" htmlText="Module: {moduleNumber}<br>Block: {(blockNumber+1)}<br>Page: {(currPage+1)} / {numPages}"/> <mx:VBox id="content"/> <mx:Text id="debug" text="{pageDisplay.msg}" width="300"/> Added: mentalmodels/trunk/flex/src/custom/questions/DayByDayOutput.mxml =================================================================== --- mentalmodels/trunk/flex/src/custom/questions/DayByDayOutput.mxml (rev 0) +++ mentalmodels/trunk/flex/src/custom/questions/DayByDayOutput.mxml 2009-07-24 23:11:25 UTC (rev 207) @@ -0,0 +1,31 @@ +<?xml version="1.0" encoding="utf-8"?> +<mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:dbd="custom.questions.dayByDayDecisions.*"> + <dbd:DayByDayDecisionsQuestionC id="dayByDay"/> + + <mx:Script> + <![CDATA[ + import mx.collections.ArrayCollection; + + public var savedStrategy:ArrayCollection = null; + public var savedDayByDay:ArrayCollection = null; + + public function init():void + { + dayByDay.removeChild(dayByDay.buttons); +// dayByDay.removeChild(dayByDay.timer); + + if(savedStrategy != null) + { + dayByDay.loadFromStrategy(savedStrategy); + } + else if(savedDayByDay != null) + { + dayByDay.load(savedDayByDay); + } + + } + + ]]> + </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-08-05 00:01:27
|
Revision: 219 http://virtualcommons.svn.sourceforge.net/virtualcommons/?rev=219&view=rev Author: kjonas Date: 2009-08-05 00:01:16 +0000 (Wed, 05 Aug 2009) Log Message: ----------- Repairing two parts of the program that are accidentally showing 4 bays (more to be fixed later) Modified Paths: -------------- mentalmodels/trunk/flex/src/FisheryExperimentShell.mxml mentalmodels/trunk/flex/src/actionscript/PageDisplay.as mentalmodels/trunk/flex/src/custom/FisheryExperimentCore.mxml 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-08-05 00:00:30 UTC (rev 218) +++ mentalmodels/trunk/flex/src/FisheryExperimentShell.mxml 2009-08-05 00:01:16 UTC (rev 219) @@ -1,7 +1,7 @@ <?xml version="1.0" encoding="utf-8"?> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:custom="custom.*" backgroundGradientAlphas="[1.0, 1.0]" backgroundGradientColors="[#FFFFFF, #B0B0FF]" - width="100%" height="100%" layout="vertical" horizontalAlign="center" + width="100%" height="100%" layout="absolute" initialize="init()"> <mx:Script><![CDATA[ @@ -24,7 +24,10 @@ } ]]></mx:Script> - <mx:HBox horizontalGap="30" y="60"> + <mx:HBox id="shell" horizontalGap="30" + y="{(height - shell.height)/2}" + x="{(width - shell.width)/2}"> + <mx:VBox id="vbxInfo"> <mx:TitleWindow id="InformationWindowA" width="400" height="220" title="Information Window A" clipContent="true" horizontalScrollPolicy="on" verticalScrollPolicy="on"> Modified: mentalmodels/trunk/flex/src/actionscript/PageDisplay.as =================================================================== --- mentalmodels/trunk/flex/src/actionscript/PageDisplay.as 2009-08-05 00:00:30 UTC (rev 218) +++ mentalmodels/trunk/flex/src/actionscript/PageDisplay.as 2009-08-05 00:01:16 UTC (rev 219) @@ -99,7 +99,7 @@ tempBox.addChild(tq); } - if(tempQuestion.type.toLowerCase() == "strategydesign") + else if(tempQuestion.type.toLowerCase() == "strategydesign") { var sdq:StrategyDesignQuestionC = new StrategyDesignQuestionC(); sdq.locations = locations; @@ -158,8 +158,8 @@ desc.width = 600; head.htmlText = questionGroup.header; desc.htmlText = questionGroup.description; + if(desc.htmlText.length != 0) tempBox.addChildAt(desc,0); if(head.htmlText.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/FisheryExperimentCore.mxml =================================================================== --- mentalmodels/trunk/flex/src/custom/FisheryExperimentCore.mxml 2009-08-05 00:00:30 UTC (rev 218) +++ mentalmodels/trunk/flex/src/custom/FisheryExperimentCore.mxml 2009-08-05 00:01:16 UTC (rev 219) @@ -17,7 +17,8 @@ <mx:State name="instructionsLoad"> <mx:AddChild relativeTo="{content}"> - <comp:InstructionPage id="instructions" initialize="gotoInstructions()" locations="{locations}"/> + <comp:InstructionPage id="instructions" initialize="gotoInstructions()" x="0" y="0" + preinitialize="instructions.locations=locations"/> </mx:AddChild> </mx:State> @@ -101,7 +102,7 @@ public var currentModuleNumber:int = 0; public var currentBlock:Block = null; public var currentBlockNumber:int = 0; - [Bindable] public var locations:ArrayCollection = new ArrayCollection([newLocation(10, 0.50),newLocation(20, 0.15),newLocation(30, 0.05)]); + [Bindable] public var locations:ArrayCollection = new ArrayCollection([newLocation(0, 0),newLocation(10, 0.50),newLocation(20, 0.15),newLocation(30, 0.05)]); public var blockLoader:Function = null; @@ -138,7 +139,7 @@ { btnForward.enabled = btnBack.enabled = btnReset.enabled = true; instructionsLoaded = true; - instructions.moduleNumber = currentModuleNumber; +// instructions.moduleNumber = currentModuleNumber; currentState = "instructions"; } private function sendBlockQuestions():void @@ -265,7 +266,27 @@ currentBlockNumber++; //server request + blockResultHandler(new ResultEvent("",false,true,makeBlock())); } + private function blockResultHandler(event:ResultEvent):void + { + currentBlock = (event.result as actionscript.Block); + + if(currentBlock == null + || currentBlock.questionGroups == null + || currentBlock.questionGroups.length < 1) + { + currentState = "none"; + } + else if(!instructionsLoaded) + { + currentState = "instructionsLoad"; + } + else + { + gotoInstructions(); + } + } private function moduleResultHandler(event:ResultEvent):void { currentModule = (event.result as actionscript.Module); @@ -298,6 +319,7 @@ private function locationResultHandler(event:ResultEvent):void { locations = new ArrayCollection(); + locations.addItem(newLocation(0, 0)); locations.addItem(newLocation(10, 0.50)); locations.addItem(newLocation(20, 0.15)); locations.addItem(newLocation(30, 0.05)); @@ -376,7 +398,7 @@ currentState = "wait"; btnBack.enabled = btnForward.enabled = btnReset.enabled = true; - getNextModule(); + getNextBlock(); returnValue = true; } } Modified: mentalmodels/trunk/flex/src/custom/questions/dayByDayDecisions/DayByDayDecisionsQuestionC.mxml =================================================================== --- mentalmodels/trunk/flex/src/custom/questions/dayByDayDecisions/DayByDayDecisionsQuestionC.mxml 2009-08-05 00:00:30 UTC (rev 218) +++ mentalmodels/trunk/flex/src/custom/questions/dayByDayDecisions/DayByDayDecisionsQuestionC.mxml 2009-08-05 00:01:16 UTC (rev 219) @@ -30,7 +30,7 @@ import actionscript.questions.*; import custom.questions.dayByDayDecisions.OneDay; - [Bindable] public var locations:ArrayCollection = new ArrayCollection([newLocation(10, 0.50),newLocation(20, 0.15),newLocation(30, 0.05)]); + [Bindable] public var locations:ArrayCollection = new ArrayCollection([newLocation(0, 0),newLocation(10, 0.50),newLocation(20, 0.15),newLocation(30, 0.05)]); [Bindable] public var deciding:int = 0; [Bindable] public var cumTotal:Number = 0; [Bindable] public var dollarPerLb:Number = 3.99; @@ -66,17 +66,17 @@ txtTemp.text = "Harbor"; labels.addChild(txtTemp); - for(var i:int = 0; i < locations.length; i++) + for(var i:int = 1; i < locations.length; i++) { btnTemp = new Button(); - btnTemp.label = "Bay" + (i+1); + btnTemp.label = "Bay" + (i); btnTemp.id = "btn" + btnTemp.label; btnTemp.addEventListener(MouseEvent.CLICK,clicked); buttons.addChild(btnTemp); txtTemp = new Text(); txtTemp = stylize(txtTemp); - txtTemp.text = "Bay" + (i+1); + txtTemp.text = "Bay" + (i); labels.addChild(txtTemp); } @@ -217,6 +217,10 @@ { zeroDec = ".00"; } + else if((moneyMade*10) as int == (moneyMade*10)) + { + zeroDec = "0"; + } var moneyString:String = "$" + moneyMade + zeroDec; return moneyString; } Modified: mentalmodels/trunk/flex/src/custom/questions/dayByDayDecisions/OneDay.mxml =================================================================== --- mentalmodels/trunk/flex/src/custom/questions/dayByDayDecisions/OneDay.mxml 2009-08-05 00:00:30 UTC (rev 218) +++ mentalmodels/trunk/flex/src/custom/questions/dayByDayDecisions/OneDay.mxml 2009-08-05 00:01:16 UTC (rev 219) @@ -8,7 +8,7 @@ import mx.controls.Label; import mx.collections.ArrayCollection; - [Bindable] public var locations:ArrayCollection = new ArrayCollection([newLocation(10, 0.50),newLocation(20, 0.15),newLocation(30, 0.05)]); + [Bindable] public var locations:ArrayCollection = new ArrayCollection([newLocation(0, 0),newLocation(10, 0.50),newLocation(20, 0.15),newLocation(30, 0.05)]); [Bindable] public var decisions:ArrayCollection; public var previousTotal:Number = 0; @@ -57,7 +57,7 @@ public function drawPartial():void { var temp:OneDecision; - for(var i:int = decisions.length; i < locations.length+1; i++) + for(var i:int = decisions.length; i < locations.length; i++) { temp = new OneDecision(); temp.active = false; @@ -80,7 +80,7 @@ dayText.minWidth = 50; addChild(dayText); - for(var i:int = 0; i < locations.length+1 && i < decisions.length; i++) + for(var i:int = 0; i < locations.length && i < decisions.length; i++) { var temp:OneDecision = (decisions.getItemAt(i) as OneDecision); presentTotal += temp.lbsFished; Modified: mentalmodels/trunk/flex/src/custom/questions/strategyDesign/PlannerRow.mxml =================================================================== --- mentalmodels/trunk/flex/src/custom/questions/strategyDesign/PlannerRow.mxml 2009-08-05 00:00:30 UTC (rev 218) +++ mentalmodels/trunk/flex/src/custom/questions/strategyDesign/PlannerRow.mxml 2009-08-05 00:01:16 UTC (rev 219) @@ -25,10 +25,10 @@ obj.label = obj.data; locs.addItem(obj); - for(var i:int=0; i<locations.length; i++) + for(var i:int=1; i<locations.length; i++) { obj = new Object(); - obj.data = "Bay " + (i+1); + obj.data = "Bay " + (i); obj.label = obj.data; locs.addItem(obj); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <kj...@us...> - 2009-08-06 01:25:58
|
Revision: 221 http://virtualcommons.svn.sourceforge.net/virtualcommons/?rev=221&view=rev Author: kjonas Date: 2009-08-06 01:25:00 +0000 (Thu, 06 Aug 2009) Log Message: ----------- Modified components so they may be able to receive the locations from server, rather than hard-coding. hard-coded the "request from server" until it is properly implemented. Modified Paths: -------------- mentalmodels/trunk/flex/src/actionscript/PageDisplay.as mentalmodels/trunk/flex/src/custom/FisheryExperimentCore.mxml mentalmodels/trunk/flex/src/custom/InstructionPage.mxml mentalmodels/trunk/flex/src/custom/questions/DayByDayOutput.mxml mentalmodels/trunk/flex/src/custom/questions/dayByDayDecisions/DayByDayDecisionsQuestionC.mxml mentalmodels/trunk/flex/src/custom/questions/dayByDayDecisions/OneDay.mxml 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/strategyDesign/Planner.mxml mentalmodels/trunk/flex/src/custom/questions/strategyDesign/PlannerRow.mxml mentalmodels/trunk/flex/src/custom/questions/strategyDesign/StrategyDesignQuestionC.mxml Modified: mentalmodels/trunk/flex/src/actionscript/PageDisplay.as =================================================================== --- mentalmodels/trunk/flex/src/actionscript/PageDisplay.as 2009-08-05 00:17:23 UTC (rev 220) +++ mentalmodels/trunk/flex/src/actionscript/PageDisplay.as 2009-08-06 01:25:00 UTC (rev 221) @@ -13,6 +13,7 @@ import mx.collections.ArrayCollection; import mx.containers.VBox; + import mx.controls.Alert; import mx.controls.Text; @@ -25,12 +26,22 @@ public var minPagesRead:int; public var currentPageNumber:int; public var highestPageReached:int; - public var locations:ArrayCollection = null; + public var locations:ArrayCollection = new ArrayCollection([newLocation(0, 0)]); + public var currBlock:Block; - public function PageDisplay(newBlock:Block, minimumPagesRead:int=1, locations:ArrayCollection=null) + private function newLocation(maxCapacity:Number,growth:Number):Location { + var newLoc:Location = new Location(); + newLoc.maxCapacity = maxCapacity; + newLoc.growthRate = growth; + newLoc.initialPopulation = maxCapacity / 2.0; + return newLoc; + } + + public function PageDisplay(newBlock:Block, minimumPagesRead:int, locations:ArrayCollection) + { currBlock = newBlock; minPagesRead = minimumPagesRead; currentPageNumber = 0; @@ -112,6 +123,7 @@ { var ddq:DayByDayDecisionsQuestionC = new DayByDayDecisionsQuestionC(); ddq.locations = locations; + Alert.show(locations.length+""); ddq.loadFromQuestion(Question(tempQuestion)); ddq.id = "q"+question; Modified: mentalmodels/trunk/flex/src/custom/FisheryExperimentCore.mxml =================================================================== --- mentalmodels/trunk/flex/src/custom/FisheryExperimentCore.mxml 2009-08-05 00:17:23 UTC (rev 220) +++ mentalmodels/trunk/flex/src/custom/FisheryExperimentCore.mxml 2009-08-06 01:25:00 UTC (rev 221) @@ -102,7 +102,7 @@ public var currentModuleNumber:int = 0; public var currentBlock:Block = null; public var currentBlockNumber:int = 0; - [Bindable] public var locations:ArrayCollection = new ArrayCollection([newLocation(0, 0),newLocation(10, 0.50),newLocation(20, 0.15),newLocation(30, 0.05)]); + [Bindable] public var locations:ArrayCollection = new ArrayCollection([newLocation(0, 0)]); public var blockLoader:Function = null; @@ -144,7 +144,7 @@ } private function sendBlockQuestions():void { - if(instructions == null) return; + if(currentBlock == null) return; var responseList:ArrayCollection = new ArrayCollection(); var studentResponse:StudentResponse; @@ -245,15 +245,14 @@ answeringService.saveQuestion(responseList); } - private function reportBlockFinished():void + + private function getLocations():void { - sendBlockQuestions(); - - // send something to server to indicate that someone finished a block + locationResultHandler(null); //TK } private function getNextModule():void { - if(instructions != null) reportBlockFinished(); + if(instructionsLoaded) sendBlockQuestions(); currentModule = null; currentModuleNumber++; @@ -261,7 +260,7 @@ } private function getNextBlock():void { - if(instructions != null) reportBlockFinished(); + if(currentBlock != null) sendBlockQuestions(); currentBlock = null; currentBlockNumber++; @@ -398,6 +397,7 @@ currentState = "wait"; btnBack.enabled = btnForward.enabled = btnReset.enabled = true; + getLocations(); getNextBlock(); returnValue = true; } @@ -468,8 +468,12 @@ cat1.type = "categorical"; cat1.categoricalOptions = new ArrayCollection(); - var for1:ForecastingPeople = new ForecastingPeople(); - var for2:ForecastingFish = new ForecastingFish(); + var for1:Question = new Question(); + for1.question = "forecastingFishQuestion"; + for1.type = "forecastingFishermen"; + var for2:Question = new Question(); + for2.question = "forecastingFishermenQuestion"; + for2.type = "forecastingFish"; var psy1:Psychometric = new Psychometric(); psy1.question = "psychometricQuestionBipolar"; Modified: mentalmodels/trunk/flex/src/custom/InstructionPage.mxml =================================================================== --- mentalmodels/trunk/flex/src/custom/InstructionPage.mxml 2009-08-05 00:17:23 UTC (rev 220) +++ mentalmodels/trunk/flex/src/custom/InstructionPage.mxml 2009-08-06 01:25:00 UTC (rev 221) @@ -20,7 +20,7 @@ [Bindable] public var numPages:int = 1; [Bindable] public var currPage:int = 0; - [Bindable] public var locations:ArrayCollection = new ArrayCollection([newLocation(10, 0.50),newLocation(20, 0.15),newLocation(30, 0.05)]); + [Bindable] public var locations:ArrayCollection = new ArrayCollection([newLocation(0, 0)]); public var savedForecastPeople:ArrayCollection = null; public var savedForecastFish:ArrayCollection = null; Modified: mentalmodels/trunk/flex/src/custom/questions/DayByDayOutput.mxml =================================================================== --- mentalmodels/trunk/flex/src/custom/questions/DayByDayOutput.mxml 2009-08-05 00:17:23 UTC (rev 220) +++ mentalmodels/trunk/flex/src/custom/questions/DayByDayOutput.mxml 2009-08-06 01:25:00 UTC (rev 221) @@ -6,12 +6,15 @@ <![CDATA[ import mx.collections.ArrayCollection; + [Bindable] public var locations:ArrayCollection = new ArrayCollection([newLocation(0, 0)]); + public var savedStrategy:ArrayCollection = null; public var savedDayByDay:ArrayCollection = null; public function init():void { dayByDay.removeChild(dayByDay.buttons); + dayByDay.locations = locations; // dayByDay.removeChild(dayByDay.timer); if(savedStrategy != null) Modified: mentalmodels/trunk/flex/src/custom/questions/dayByDayDecisions/DayByDayDecisionsQuestionC.mxml =================================================================== --- mentalmodels/trunk/flex/src/custom/questions/dayByDayDecisions/DayByDayDecisionsQuestionC.mxml 2009-08-05 00:17:23 UTC (rev 220) +++ mentalmodels/trunk/flex/src/custom/questions/dayByDayDecisions/DayByDayDecisionsQuestionC.mxml 2009-08-06 01:25:00 UTC (rev 221) @@ -30,7 +30,7 @@ import actionscript.questions.*; import custom.questions.dayByDayDecisions.OneDay; - [Bindable] public var locations:ArrayCollection = new ArrayCollection([newLocation(0, 0),newLocation(10, 0.50),newLocation(20, 0.15),newLocation(30, 0.05)]); + [Bindable] public var locations:ArrayCollection = new ArrayCollection([newLocation(0, 0)]); [Bindable] public var deciding:int = 0; [Bindable] public var cumTotal:Number = 0; [Bindable] public var dollarPerLb:Number = 3.99; Modified: mentalmodels/trunk/flex/src/custom/questions/dayByDayDecisions/OneDay.mxml =================================================================== --- mentalmodels/trunk/flex/src/custom/questions/dayByDayDecisions/OneDay.mxml 2009-08-05 00:17:23 UTC (rev 220) +++ mentalmodels/trunk/flex/src/custom/questions/dayByDayDecisions/OneDay.mxml 2009-08-06 01:25:00 UTC (rev 221) @@ -8,7 +8,7 @@ import mx.controls.Label; import mx.collections.ArrayCollection; - [Bindable] public var locations:ArrayCollection = new ArrayCollection([newLocation(0, 0),newLocation(10, 0.50),newLocation(20, 0.15),newLocation(30, 0.05)]); + [Bindable] public var locations:ArrayCollection = new ArrayCollection([newLocation(0, 0)]); [Bindable] public var decisions:ArrayCollection; public var previousTotal:Number = 0; Modified: mentalmodels/trunk/flex/src/custom/questions/forecasting/ForecastComponent.mxml =================================================================== --- mentalmodels/trunk/flex/src/custom/questions/forecasting/ForecastComponent.mxml 2009-08-05 00:17:23 UTC (rev 220) +++ mentalmodels/trunk/flex/src/custom/questions/forecasting/ForecastComponent.mxml 2009-08-06 01:25:00 UTC (rev 221) @@ -5,6 +5,7 @@ <mx:Script> <![CDATA[ + import actionscript.Location; import mx.controls.Alert; import mx.events.FlexEvent; import mx.controls.DataGrid; @@ -24,7 +25,8 @@ // Game Data [Bindable] public var style:int = 0; // 0:People, 1:Fish, 2:Calculated - [Bindable] public var numBays:int = 3; +// [Bindable] public var numBays:int = 3; + [Bindable] public var locations:ArrayCollection = new ArrayCollection([newLocation(0, 0)]); [Bindable] public var numColumns:int = -1; [Bindable] public var numFields:int = 15; [Bindable] public var minValue:int = 0; @@ -36,6 +38,15 @@ // for lining up grids [Bindable] public var minimumWidth:int = 160; + private function newLocation(maxCapacity:Number,growth:Number):Location + { + var newLoc:Location = new Location(); + newLoc.maxCapacity = maxCapacity; + newLoc.growthRate = growth; + newLoc.initialPopulation = maxCapacity / 2.0; + return newLoc; + } + // // public accessible functions // @@ -178,7 +189,7 @@ addLabel("# People in Harbor:"); addField(); - for(bayNumber=0; bayNumber<numBays; bayNumber++) + for(bayNumber=0; bayNumber<locations.length-1; bayNumber++) { addLabel("# People in Bay " + (bayNumber+1) + ":"); addField(); @@ -186,7 +197,7 @@ } else if(style==1) { - for(bayNumber=0; bayNumber<numBays; bayNumber++) + for(bayNumber=0; bayNumber<locations.length-1; bayNumber++) { addLabel("# Fish in Bay " + (bayNumber+1) + "(AM):"); addField(); @@ -200,7 +211,7 @@ addField(); addLabel("Others will get USD:"); addField(); - for(bayNumber=0; bayNumber<numBays; bayNumber++) + for(bayNumber=0; bayNumber<locations.length-1; bayNumber++) { addLabel("# Fish in Bay " + (bayNumber+1) + "(PM):"); addField(); @@ -215,13 +226,13 @@ switch(style) { case(0): // 0:People - dataGrid.height = (23)*(numBays+2)-1; + dataGrid.height = (23)*(locations.length+1)-1; break; case(1): // 2:Fish - dataGrid.height = (23)*(numBays+1); + dataGrid.height = (23)*(locations.length); break; case(2): // 3:Calculated - dataGrid.height = (23)*(numBays+4)-3; + dataGrid.height = (23)*(locations.length+3)-3; break; } } Modified: mentalmodels/trunk/flex/src/custom/questions/forecasting/ForecastingFishQuestionC.mxml =================================================================== --- mentalmodels/trunk/flex/src/custom/questions/forecasting/ForecastingFishQuestionC.mxml 2009-08-05 00:17:23 UTC (rev 220) +++ mentalmodels/trunk/flex/src/custom/questions/forecasting/ForecastingFishQuestionC.mxml 2009-08-06 01:25:00 UTC (rev 221) @@ -10,12 +10,12 @@ </mx:Script> <components:ForecastComponent id="fishEntry" style="1" isEntry="true" maxValue="30" - numBays="{numBays}" numColumns="{numColumns}" initialize="false" + preinitialize="fishEntry.locations = locations" numColumns="{numColumns}" initialize="false" updaterObject="{this}" updater="{recalculate}"/> <components:ForecastComponent id="peopleDisplay" style="0" isEntry="false" - numBays="{numBays}" numColumns="15" initialize="false"/> + preinitialize="peopleDisplay.locations = locations" numColumns="15" initialize="false"/> <components:ForecastComponent id="calculated" style="2" isEntry="false" - numBays="{numBays}" numColumns="{numColumns}" initialize="false"/> + preinitialize="calculated.locations = locations" numColumns="{numColumns}" initialize="false"/> <mx:HBox> <mx:Spacer width="160"/> @@ -36,9 +36,8 @@ public var loadFish:ArrayCollection = null; public var loadPeople:ArrayCollection = null; - [Bindable] public var locations:ArrayCollection = new ArrayCollection([newLocation(10, 0.50),newLocation(20, 0.15),newLocation(30, 0.05)]); + [Bindable] public var locations:ArrayCollection = new ArrayCollection([newLocation(0, 0)]); - [Bindable] public var numBays:int = locations.length; [Bindable] public var numColumns:int = 6; private function newLocation(maxCapacity:Number,growth:Number):Location @@ -103,9 +102,9 @@ calculated.setItem(1,column,0); calculated.setItem(2,column,0); - for(var bay:int = 0; bay < numBays; bay++) + for(var bay:int = 1; bay < locations.length; bay++) { - calculated.setItem(3+bay,column,Number(fishEntry.getItem(bay,column)) * 0.9); + calculated.setItem(3+bay,column,Number(fishEntry.getItem(bay-1,column)) * 0.9); } } calculated.redraw(); Modified: mentalmodels/trunk/flex/src/custom/questions/forecasting/ForecastingPeopleQuestionC.mxml =================================================================== --- mentalmodels/trunk/flex/src/custom/questions/forecasting/ForecastingPeopleQuestionC.mxml 2009-08-05 00:17:23 UTC (rev 220) +++ mentalmodels/trunk/flex/src/custom/questions/forecasting/ForecastingPeopleQuestionC.mxml 2009-08-06 01:25:00 UTC (rev 221) @@ -12,7 +12,7 @@ <mx:Text width="600" text="The sum of expected fishermen each day is {(peopleEntry.groupSize-1)}.\nDo not include yourself in the count."/> <components:ForecastComponent id="peopleEntry" style="0" isEntry="true" - numBays="{numBays}" numColumns="{numColumns}" initialize="false"/> + preinitialize="peopleEntry.locations = locations" numColumns="{numColumns}" initialize="false"/> <mx:HBox> <mx:Spacer width="160"/> @@ -31,9 +31,8 @@ import custom.questions.forecasting.ForecastComponent; public var loadPeople:ArrayCollection = null; - [Bindable] public var locations:ArrayCollection = new ArrayCollection([newLocation(10, 0.50),newLocation(20, 0.15),newLocation(30, 0.05)]); + [Bindable] public var locations:ArrayCollection = new ArrayCollection([newLocation(0, 0)]); - [Bindable] public var numBays:int = locations.length; [Bindable] public var numColumns:int = 15; private function newLocation(maxCapacity:Number,growth:Number):Location Modified: mentalmodels/trunk/flex/src/custom/questions/strategyDesign/Planner.mxml =================================================================== --- mentalmodels/trunk/flex/src/custom/questions/strategyDesign/Planner.mxml 2009-08-05 00:17:23 UTC (rev 220) +++ mentalmodels/trunk/flex/src/custom/questions/strategyDesign/Planner.mxml 2009-08-06 01:25:00 UTC (rev 221) @@ -11,7 +11,7 @@ public var valueRequired:Boolean = false; public var hasBeenChanged:Boolean = false; - [Bindable] public var locations:ArrayCollection = new ArrayCollection([newLocation(10, 0.50),newLocation(20, 0.15),newLocation(30, 0.05)]); + [Bindable] public var locations:ArrayCollection = new ArrayCollection([newLocation(0, 0)]); private function newLocation(maxCapacity:Number,growth:Number):Location { Modified: mentalmodels/trunk/flex/src/custom/questions/strategyDesign/PlannerRow.mxml =================================================================== --- mentalmodels/trunk/flex/src/custom/questions/strategyDesign/PlannerRow.mxml 2009-08-05 00:17:23 UTC (rev 220) +++ mentalmodels/trunk/flex/src/custom/questions/strategyDesign/PlannerRow.mxml 2009-08-06 01:25:00 UTC (rev 221) @@ -6,7 +6,7 @@ import actionscript.Location; public var valueRequired:Boolean = false; - [Bindable] public var locations:ArrayCollection = new ArrayCollection([newLocation(10, 0.50),newLocation(20, 0.15),newLocation(30, 0.05)]); + [Bindable] public var locations:ArrayCollection = new ArrayCollection([newLocation(0, 0)]); private function newLocation(maxCapacity:Number,growth:Number):Location { Modified: mentalmodels/trunk/flex/src/custom/questions/strategyDesign/StrategyDesignQuestionC.mxml =================================================================== --- mentalmodels/trunk/flex/src/custom/questions/strategyDesign/StrategyDesignQuestionC.mxml 2009-08-05 00:17:23 UTC (rev 220) +++ mentalmodels/trunk/flex/src/custom/questions/strategyDesign/StrategyDesignQuestionC.mxml 2009-08-06 01:25:00 UTC (rev 221) @@ -12,11 +12,11 @@ <mx:HBox> <mx:VBox> <mx:Label text="Not Repeated decisions (start-up)" fontSize="18"/> - <qComp:Planner id="notRepeated" preinitialize="notRepeated.locations=this.locations"/> + <qComp:Planner id="notRepeated"/> </mx:VBox> <mx:VBox> <mx:Label text="Repeated decisions (after start-up)" fontSize="18"/> - <qComp:Planner id="repeated" valueRequired="true" preinitialize="repeated.locations=this.locations"/> + <qComp:Planner id="repeated" valueRequired="true"/> </mx:VBox> </mx:HBox> @@ -40,7 +40,7 @@ import actionscript.questions.Question; import mx.collections.ArrayCollection; - [Bindable] public var locations:ArrayCollection = new ArrayCollection([newLocation(10, 0.50),newLocation(20, 0.15),newLocation(30, 0.05)]); + [Bindable] public var locations:ArrayCollection = new ArrayCollection([newLocation(0, 0)]); private function newLocation(maxCapacity:Number,growth:Number):Location { @@ -51,6 +51,12 @@ return newLoc; } + public function init():void + { + notRepeated.locations=this.locations; + repeated.locations=this.locations; + } + public function getNotRepeated():ArrayCollection { return notRepeated.save(); } @@ -85,7 +91,7 @@ this.question = question; initialize(); -// init(); + init(); } public function toDatabaseObject():ArrayCollection This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <kj...@us...> - 2009-08-10 22:14:20
|
Revision: 241 http://virtualcommons.svn.sourceforge.net/virtualcommons/?rev=241&view=rev Author: kjonas Date: 2009-08-10 22:14:12 +0000 (Mon, 10 Aug 2009) Log Message: ----------- Core receiving first two blocks with no problems. not receiving locations at all. made sure the code would work for any number of bays. Modified Paths: -------------- mentalmodels/trunk/flex/src/FisheryExperimentShell.mxml mentalmodels/trunk/flex/src/actionscript/PageDisplay.as mentalmodels/trunk/flex/src/custom/FisheryExperimentCore.mxml 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 Modified: mentalmodels/trunk/flex/src/FisheryExperimentShell.mxml =================================================================== --- mentalmodels/trunk/flex/src/FisheryExperimentShell.mxml 2009-08-10 22:12:04 UTC (rev 240) +++ mentalmodels/trunk/flex/src/FisheryExperimentShell.mxml 2009-08-10 22:14:12 UTC (rev 241) @@ -7,19 +7,27 @@ <mx:Script><![CDATA[ public var progressTimer:Timer; [Bindable] public var progressBarWidth:Number = 600; + private var repetitions:int = 100; + + public function setProgressBarTime(hours:int,minutes:int,seconds:int):void + { + repetitions = seconds * 10; + repetitions += minutes * 600; + repetitions += hours * 36000; + } public function progressBarInit():void { - progressTimer = new Timer(100, 100); // 21600 * 1000 = 6hrs + + progressTimer = new Timer(100, repetitions); // 21600 * 1000 = 6hrs progressTimer.addEventListener(TimerEvent.TIMER, timerTick); progressTimer.start(); } public function timerTick(event:TimerEvent):void { - tick(progressTimer.currentCount/2/progressTimer.repeatCount, progressTimer.currentCount/progressTimer.repeatCount); + tick(progressTimer.currentCount/progressTimer.repeatCount); } - private function tick(percentModule:Number,percentBlock:Number):void + private function tick(percentBlock:Number):void { - progressBarModule.width = progressBarWidth*percentModule; progressBarBlock.width = progressBarWidth*percentBlock; } ]]></mx:Script> @@ -49,13 +57,13 @@ </mx:VBox> <mx:VBox id="vbxContent" horizontalAlign="center" verticalAlign="middle"> - <mx:VBox id="progressBars" x="0" y="0" verticalGap="0" initialize="progressBarInit()"> - <mx:HBox> + <mx:VBox id="progressBars" x="0" y="0" verticalGap="0"> + <!--<mx:HBox> <mx:Label text="Time for Module:" width="130" textAlign="right"/> <mx:HBox width="{progressBarWidth+2}" borderStyle="solid"> <mx:HBox id="progressBarModule" height="10" backgroundColor="#00FF00"/> </mx:HBox> - </mx:HBox> + </mx:HBox>--> <mx:HBox> <mx:Label text="Time for Block:" width="130" textAlign="right"/> <mx:HBox width="{progressBarWidth+2}" borderStyle="solid"> @@ -63,7 +71,7 @@ </mx:HBox> </mx:HBox> </mx:VBox> - <custom:FisheryExperimentCore id="fisheryContent" blockLoader="loadBlock"/> + <custom:FisheryExperimentCore id="fisheryContent" blockLoader="loadBlock" shell="{this}"/> </mx:VBox> </mx:HBox> Modified: mentalmodels/trunk/flex/src/actionscript/PageDisplay.as =================================================================== --- mentalmodels/trunk/flex/src/actionscript/PageDisplay.as 2009-08-10 22:12:04 UTC (rev 240) +++ mentalmodels/trunk/flex/src/actionscript/PageDisplay.as 2009-08-10 22:14:12 UTC (rev 241) @@ -123,7 +123,6 @@ { var ddq:DayByDayDecisionsQuestionC = new DayByDayDecisionsQuestionC(); ddq.locations = locations; - Alert.show(locations.length+""); ddq.loadFromQuestion(Question(tempQuestion)); ddq.id = "q"+question; Modified: mentalmodels/trunk/flex/src/custom/FisheryExperimentCore.mxml =================================================================== --- mentalmodels/trunk/flex/src/custom/FisheryExperimentCore.mxml 2009-08-10 22:12:04 UTC (rev 240) +++ mentalmodels/trunk/flex/src/custom/FisheryExperimentCore.mxml 2009-08-10 22:14:12 UTC (rev 241) @@ -59,7 +59,7 @@ <mx:RemoteObject id="roundService" destination="roundService" fault="faultHandler(event)"> - <mx:method name="getNextModule" result="moduleResultHandler(event)"/> + <mx:method name="getBlock" result="blockResultHandler(event)"/> </mx:RemoteObject> <mx:RemoteObject id="startupService" destination="startupService" fault="faultHandler(event)"> <mx:method name="createStudent" result="studentResultHandler(event)"/> @@ -67,7 +67,12 @@ </mx:RemoteObject> <mx:RemoteObject id="answeringService" destination="answeringService" fault="faultHandler(event)"> </mx:RemoteObject> + <mx:RemoteObject id="locationService" destination="locationService" fault="faultHandler(event)"> + <mx:method name="getAllLocations" result="locationResultHandler(event)"/> + </mx:RemoteObject> + + <mx:Producer id="producer" destination="DataPush" acknowledge="ack(event)"/> <mx:Consumer id="consumer" destination="DataPush" message="messageHandler(event.message)" /> @@ -105,6 +110,7 @@ [Bindable] public var locations:ArrayCollection = new ArrayCollection([newLocation(0, 0)]); public var blockLoader:Function = null; + public var shell:FisheryExperimentShell = null; public var updateObjectA:InformationWindowCreator = null; public var updateObjectB:InformationWindowCreator = null; @@ -132,7 +138,8 @@ public function init():void { - + getLocations(); +// Alert.show("initialized"); } private function gotoInstructions():void @@ -181,8 +188,8 @@ } else if(curr.getChildAt(j) is DayByDayDecisionsQuestionC) { - studentResponse.question = (curr.getChildAt(j) as DayByDayDecisionsQuestionC).question; - studentResponse.response = null; + //SKIP IT + studentResponse.question = null; } else if(curr.getChildAt(j) is ForecastingPeopleQuestionC) { @@ -192,7 +199,7 @@ studentResponse = new StudentResponse(); studentResponse.student = studentObject; studentResponse.question = forecast1.question; - studentResponse.response = forecast1.peopleEntry.labels.getChildAt(row+1) + " "; + studentResponse.response = (forecast1.peopleEntry.labels.getChildAt(row+1) as Label).text + " "; for(col=0; col<forecast1.peopleEntry.dataGrid.columnCount; col++) { studentResponse.response += (col+1) + ":" + forecast1.peopleEntry.getItem(row,col); @@ -215,7 +222,7 @@ studentResponse = new StudentResponse(); studentResponse.student = studentObject; studentResponse.question = forecast2.question; - studentResponse.response = forecast2.fishEntry.labels.getChildAt(row+1) + " "; + studentResponse.response = (forecast2.fishEntry.labels.getChildAt(row+1) as Label).text + " "; for(col=0; col<forecast2.fishEntry.dataGrid.columnCount; col++) { studentResponse.response += (col+1) + ":" + forecast2.fishEntry.getItem(row,col); @@ -234,6 +241,9 @@ { studentResponse.question = (curr.getChildAt(j) as StrategyDesignQuestionC).question; studentResponse.response = null; + + //SKIP IT FOR NOW + studentResponse.question = null; } if(studentResponse.question != null) @@ -243,21 +253,26 @@ } } + var str:String = ""; + for(var q:int=0;q<responseList.length;q++) + { + str += "null:"; + str += (responseList.getItemAt(q) == null); + str += "\n"; + str += "response:"; + str += (responseList.getItemAt(q) as StudentResponse).response; + + str += "\n"; + str += "\n"; + } + Alert.show(str); answeringService.saveQuestion(responseList); } private function getLocations():void { - locationResultHandler(null); //TK + locationService.getAllLocations(); } - private function getNextModule():void - { - if(instructionsLoaded) sendBlockQuestions(); - currentModule = null; - currentModuleNumber++; - - roundService.getNextModule(currentModuleNumber); - } private function getNextBlock():void { if(currentBlock != null) sendBlockQuestions(); @@ -265,7 +280,8 @@ currentBlockNumber++; //server request - blockResultHandler(new ResultEvent("",false,true,makeBlock())); + roundService.getBlock(); +// blockResultHandler(new ResultEvent("",false,true,makeBlock())); } private function blockResultHandler(event:ResultEvent):void { @@ -285,6 +301,9 @@ { gotoInstructions(); } + + shell.setProgressBarTime(0,0,currentBlock.duration); + shell.progressBarInit(); } private function moduleResultHandler(event:ResultEvent):void { @@ -317,11 +336,11 @@ } private function locationResultHandler(event:ResultEvent):void { - locations = new ArrayCollection(); - locations.addItem(newLocation(0, 0)); - locations.addItem(newLocation(10, 0.50)); - locations.addItem(newLocation(20, 0.15)); - locations.addItem(newLocation(30, 0.05)); + if(event.result is ArrayCollection) + { + locations = event.result as ArrayCollection; +// Alert.show("locations received: "+locations.length); + } } private function studentResultHandler(event:ResultEvent):void @@ -331,14 +350,14 @@ } private function faultHandler(event:FaultEvent):void { - Alert.show(event.fault.message + "\n" + event.fault.getStackTrace()); + Alert.show("Fault:\n"+event.fault.message + "\n" + event.fault.getStackTrace()); } private function messageHandler(message:IMessage):void { randomNumbers = message.body as String; -// Alert.show( ""+randomNumbers); +// Alert.show( ""+randomNumbers); } public function back():Boolean @@ -397,7 +416,6 @@ currentState = "wait"; btnBack.enabled = btnForward.enabled = btnReset.enabled = true; - getLocations(); getNextBlock(); returnValue = true; } @@ -407,14 +425,14 @@ try { var instructionPageAcceptValue:Boolean = (InstructionPage)(obj).accept(); - if( (InstructionPage)(obj).accept() ) + if( instructionPageAcceptValue ) { obj.visible = false; expiredContent.addChild(obj); currentState = "wait"; //consumer.subscribe(); - getNextBlock(); //TK + getNextBlock(); returnValue = true; } } Modified: mentalmodels/trunk/flex/src/custom/questions/strategyDesign/Planner.mxml =================================================================== --- mentalmodels/trunk/flex/src/custom/questions/strategyDesign/Planner.mxml 2009-08-10 22:12:04 UTC (rev 240) +++ mentalmodels/trunk/flex/src/custom/questions/strategyDesign/Planner.mxml 2009-08-10 22:14:12 UTC (rev 241) @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="utf-8"?> -<mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:comp="custom.*" initialize="init()" +<mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:comp="custom.*" width="350" height="200" borderStyle="solid" verticalScrollPolicy="off" horizontalScrollPolicy="off"> @@ -22,9 +22,9 @@ return newLoc; } - private function init():void + public function init():void { - if(valueRequired) + if(valueRequired && grid.numChildren == 0) { addRow(); } @@ -42,6 +42,7 @@ newRow.valueRequired = this.valueRequired; newRow.locations = locations; newRow.initialize(); + newRow.init(); var newNumber:Label = new Label(); newNumber.text = "" + (numbers.numChildren+1); newNumber.height = 22; Modified: mentalmodels/trunk/flex/src/custom/questions/strategyDesign/PlannerRow.mxml =================================================================== --- mentalmodels/trunk/flex/src/custom/questions/strategyDesign/PlannerRow.mxml 2009-08-10 22:12:04 UTC (rev 240) +++ mentalmodels/trunk/flex/src/custom/questions/strategyDesign/PlannerRow.mxml 2009-08-10 22:14:12 UTC (rev 241) @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="utf-8"?> -<mx:HBox xmlns:mx="http://www.adobe.com/2006/mxml" initialize="init()"> +<mx:HBox xmlns:mx="http://www.adobe.com/2006/mxml"> <mx:Script> <![CDATA[ Modified: mentalmodels/trunk/flex/src/custom/questions/strategyDesign/StrategyDesignQuestionC.mxml =================================================================== --- mentalmodels/trunk/flex/src/custom/questions/strategyDesign/StrategyDesignQuestionC.mxml 2009-08-10 22:12:04 UTC (rev 240) +++ mentalmodels/trunk/flex/src/custom/questions/strategyDesign/StrategyDesignQuestionC.mxml 2009-08-10 22:14:12 UTC (rev 241) @@ -53,8 +53,6 @@ public function init():void { - notRepeated.locations=this.locations; - repeated.locations=this.locations; } public function getNotRepeated():ArrayCollection @@ -92,6 +90,11 @@ initialize(); init(); + + notRepeated.locations = locations; + repeated.locations = locations; + notRepeated.init(); + repeated.init(); } public function toDatabaseObject():ArrayCollection This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <kj...@us...> - 2009-09-16 21:09:54
|
Revision: 279 http://virtualcommons.svn.sourceforge.net/virtualcommons/?rev=279&view=rev Author: kjonas Date: 2009-09-16 21:09:44 +0000 (Wed, 16 Sep 2009) Log Message: ----------- Implementing BlockInformationWindow.as Modified Paths: -------------- mentalmodels/trunk/flex/src/FisheryExperimentShell.mxml mentalmodels/trunk/flex/src/custom/FisheryExperimentCore.mxml mentalmodels/trunk/flex/src/custom/questions/strategyDesign/PlannerRow.mxml mentalmodels/trunk/flex/src/custom/questions/strategyDesign/StrategyDesignQuestionC.mxml Added Paths: ----------- mentalmodels/trunk/flex/src/actionscript/BlockInformationWindow.as Modified: mentalmodels/trunk/flex/src/FisheryExperimentShell.mxml =================================================================== --- mentalmodels/trunk/flex/src/FisheryExperimentShell.mxml 2009-09-11 22:14:03 UTC (rev 278) +++ mentalmodels/trunk/flex/src/FisheryExperimentShell.mxml 2009-09-16 21:09:44 UTC (rev 279) @@ -70,6 +70,7 @@ <mx:Script> <![CDATA[ + import actionscript.BlockInformationWindow; import mx.messaging.events.MessageEvent; import mx.messaging.MessageAgent; import mx.messaging.messages.IMessage; @@ -272,23 +273,31 @@ if(block != null) { currentBlock = block; + var tempArray:ArrayCollection = new ArrayCollection(); var i:int = 0; + var temp:Object = null; var str:String = currentBlock.informationWindows.length + " of them.\n"; for(i = 0; i < currentBlock.informationWindows.length; i++) { - str += "["+(currentBlock.informationWindows.getItemAt(i) as InformationWindow).id+"]"; + temp = currentBlock.informationWindows.getItemAt(i); + + str += "<" + i + ":" + temp.toString(); + if((temp as BlockInformationWindow) == null) + { + str += "(as BIW = null)"; + } + else + { + var windowID:int = (temp as BlockInformationWindow).infoWindowID; + tempArray.addItem(windowID); + str += "(id:" + windowID + ")"; + } + str += ">\n"; } + selectCurrentWindows( tempArray ); Alert.show(str,"Information Windows:"); - - var tempArray:ArrayCollection = new ArrayCollection(); - for(i = 0; i<currentBlock.informationWindows.length; i++) - { - var temp:InformationWindow = (currentBlock.informationWindows.getItemAt(i) as InformationWindow); - tempArray.addItem(temp.id - 1); - } - selectCurrentWindows( tempArray ); } } Added: mentalmodels/trunk/flex/src/actionscript/BlockInformationWindow.as =================================================================== --- mentalmodels/trunk/flex/src/actionscript/BlockInformationWindow.as (rev 0) +++ mentalmodels/trunk/flex/src/actionscript/BlockInformationWindow.as 2009-09-16 21:09:44 UTC (rev 279) @@ -0,0 +1,15 @@ +package actionscript +{ + + [Bindable] + [RemoteClass(alias="edu.asu.commons.mme.entity.BlockInformationWindow")] + public class BlockInformationWindow + { + + public var id:Number; + public var sequenceNo:int; + public var infoWindowID:int; + public var infoWindow:InformationWindow; + + } +} \ No newline at end of file Modified: mentalmodels/trunk/flex/src/custom/FisheryExperimentCore.mxml =================================================================== --- mentalmodels/trunk/flex/src/custom/FisheryExperimentCore.mxml 2009-09-11 22:14:03 UTC (rev 278) +++ mentalmodels/trunk/flex/src/custom/FisheryExperimentCore.mxml 2009-09-16 21:09:44 UTC (rev 279) @@ -135,11 +135,10 @@ } private function setBlock(block:Block):void { - Alert.show(currentState); +// Alert.show(currentState); if(currentState == "none") { Alert.show("Block received in End of Game state.","Unexpected Block"); - return; } else if(currentState == "wait") { @@ -147,7 +146,7 @@ } else if(currentState == "instructions") { - Alert.show("FORCING"); +// Alert.show("FORCING"); accept(true); loadNextBlock(block); } @@ -337,8 +336,10 @@ || currentBlock.questionGroups.length < 1) { currentState = "none"; + return; } - else if(!instructionsLoaded) + + if(!instructionsLoaded) { currentState = "instructionsLoad"; } @@ -347,6 +348,8 @@ gotoInstructions(); } + shell.loadBlock(currentBlock); + // start timer to alert students to hurry shell.setProgressBarTime(0,0,currentBlock.duration); shell.progressBarInit(); Modified: mentalmodels/trunk/flex/src/custom/questions/strategyDesign/PlannerRow.mxml =================================================================== --- mentalmodels/trunk/flex/src/custom/questions/strategyDesign/PlannerRow.mxml 2009-09-11 22:14:03 UTC (rev 278) +++ mentalmodels/trunk/flex/src/custom/questions/strategyDesign/PlannerRow.mxml 2009-09-16 21:09:44 UTC (rev 279) @@ -86,7 +86,7 @@ { if(location.selectedIndex == 0) { - return -1; + return 0; } return threshold.value; } Modified: mentalmodels/trunk/flex/src/custom/questions/strategyDesign/StrategyDesignQuestionC.mxml =================================================================== --- mentalmodels/trunk/flex/src/custom/questions/strategyDesign/StrategyDesignQuestionC.mxml 2009-09-11 22:14:03 UTC (rev 278) +++ mentalmodels/trunk/flex/src/custom/questions/strategyDesign/StrategyDesignQuestionC.mxml 2009-09-16 21:09:44 UTC (rev 279) @@ -66,7 +66,7 @@ public function roundResultHandler(event:ResultEvent):void { repeated.round = notRepeated.round = event.result as Round; - Alert.show("Round received in StrategyDesign"); +// Alert.show("Round received in StrategyDesign"); } public function faultHandler(event:FaultEvent):void { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <kj...@us...> - 2009-11-29 18:51:41
|
Revision: 376 http://virtualcommons.svn.sourceforge.net/virtualcommons/?rev=376&view=rev Author: kjonas Date: 2009-11-29 18:51:32 +0000 (Sun, 29 Nov 2009) Log Message: ----------- FisheryExperimentCore.mxml now accepts Game objects, rather than Block only. Other files changed to pass the game object along the hierarchy wherever needed. Modified Paths: -------------- mentalmodels/trunk/flex/src/actionscript/PageDisplay.as mentalmodels/trunk/flex/src/custom/FisheryExperimentCore.mxml mentalmodels/trunk/flex/src/custom/InstructionPage.mxml mentalmodels/trunk/flex/src/custom/SocioDemographicPage.mxml mentalmodels/trunk/flex/src/custom/questions/strategyDesign/StrategyDesignQuestionC.mxml Modified: mentalmodels/trunk/flex/src/actionscript/PageDisplay.as =================================================================== --- mentalmodels/trunk/flex/src/actionscript/PageDisplay.as 2009-11-25 23:31:53 UTC (rev 375) +++ mentalmodels/trunk/flex/src/actionscript/PageDisplay.as 2009-11-29 18:51:32 UTC (rev 376) @@ -20,6 +20,7 @@ { public var msg:String = ""; + public var gameObject:actionscript.Game = null; public var pages:ArrayCollection; public var minPagesRead:int; public var currentPageNumber:int; @@ -110,7 +111,7 @@ { var sdq:StrategyDesignQuestionC = new StrategyDesignQuestionC(); sdq.locations = locations; - sdq.roundService.getCurrentRound(); + sdq.setRound(gameObject.currentRound); sdq.loadFromQuestion(Question(tempQuestion)); sdq.id = "q"+question; Modified: mentalmodels/trunk/flex/src/custom/FisheryExperimentCore.mxml =================================================================== --- mentalmodels/trunk/flex/src/custom/FisheryExperimentCore.mxml 2009-11-25 23:31:53 UTC (rev 375) +++ mentalmodels/trunk/flex/src/custom/FisheryExperimentCore.mxml 2009-11-29 18:51:32 UTC (rev 376) @@ -105,8 +105,9 @@ // // Important Variables // - public var currentModule:Module = null; - public var currentModuleNumber:int = 0; + public var gameObject:actionscript.Game = null; +// public var currentModule:Module = null; +// public var currentModuleNumber:int = 0; public var currentBlock:Block = null; public var currentBlockNumber:int = 0; [Bindable] public var locations:ArrayCollection = new ArrayCollection([newLocation(0, 0)]); @@ -134,6 +135,15 @@ { setBlock(event.message.body as actionscript.Block); } + else if(event.message.body is actionscript.Game) + { + gameObject = event.message.body as actionscript.Game; + setBlock(gameObject.currentBlock); + if(instructions != null) + { + instructions.setGameObject(this.gameObject); + } + } else if(event.message.body is ArrayCollection) { var students:ArrayCollection = new ArrayCollection(); Modified: mentalmodels/trunk/flex/src/custom/InstructionPage.mxml =================================================================== --- mentalmodels/trunk/flex/src/custom/InstructionPage.mxml 2009-11-25 23:31:53 UTC (rev 375) +++ mentalmodels/trunk/flex/src/custom/InstructionPage.mxml 2009-11-29 18:51:32 UTC (rev 376) @@ -3,6 +3,7 @@ <mx:Script> <![CDATA[ + import actionscript.Game; import custom.questions.strategyDesign.StrategyDesignQuestionC; import custom.questions.dayByDayDecisions.DayByDayDecisionsQuestionC; import actionscript.Location; @@ -14,6 +15,7 @@ import actionscript.PageDisplay; import mx.collections.ArrayCollection; + [Bindable] public var gameObject:actionscript.Game = null; [Bindable] public var moduleNumber:int = 1; [Bindable] public var module:Module; [Bindable] public var blockNumber:int = 0; @@ -36,6 +38,15 @@ return newLoc; } + public function setGameObject(newGameObject:actionscript.Game):void + { + this.gameObject = newGameObject; + if(pageDisplay != null) + { + pageDisplay.gameObject = this.gameObject; + } + } + // public function initModule(newModule:actionscript.Module):void // { // module = newModule; @@ -83,6 +94,7 @@ pageDisplay = new PageDisplay(makeBlock(),0,locations); // Alert.show(debug2.text); } + setGameObject(this.gameObject); currPage = pageDisplay.currentPageNumber; numPages = pageDisplay.pages.length; Modified: mentalmodels/trunk/flex/src/custom/SocioDemographicPage.mxml =================================================================== --- mentalmodels/trunk/flex/src/custom/SocioDemographicPage.mxml 2009-11-25 23:31:53 UTC (rev 375) +++ mentalmodels/trunk/flex/src/custom/SocioDemographicPage.mxml 2009-11-29 18:51:32 UTC (rev 376) @@ -37,7 +37,7 @@ var red:String = "#FF0000"; var white:String = "#FFFFFF"; - if(getGender().length != 1) // "M", "F", "Err" + if(getGender().length != 1) // possible genders are: "M", "F", "Err" { boxGender.setStyle(bgcolor, red); ready=false; Modified: mentalmodels/trunk/flex/src/custom/questions/strategyDesign/StrategyDesignQuestionC.mxml =================================================================== --- mentalmodels/trunk/flex/src/custom/questions/strategyDesign/StrategyDesignQuestionC.mxml 2009-11-25 23:31:53 UTC (rev 375) +++ mentalmodels/trunk/flex/src/custom/questions/strategyDesign/StrategyDesignQuestionC.mxml 2009-11-29 18:51:32 UTC (rev 376) @@ -33,8 +33,8 @@ <mx:Label text="days before starting the next repetition."/> </mx:HBox> - <mx:RemoteObject id="roundService" destination="roundService" fault="faultHandler(event)"> - <mx:method name="getCurrentRound" result="roundResultHandler(event)"/> + <mx:RemoteObject id="GameService" destination="gameService" fault="faultHandler(event)"> + <mx:method name="getCurrentRoundNo" result="roundResultHandler(event)"/> </mx:RemoteObject> <mx:Script> @@ -63,9 +63,13 @@ public function roundResultHandler(event:ResultEvent):void { - repeated.round = notRepeated.round = event.result as Round; + setRound(event.result as Round); // Alert.show("Round received in StrategyDesign"); } + public function setRound(newRound:Round):void + { + repeated.round = notRepeated.round = newRound; + } public function faultHandler(event:FaultEvent):void { Alert.show("Error finding round for Strategy Design!"); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <kj...@us...> - 2009-11-29 22:06:41
|
Revision: 379 http://virtualcommons.svn.sourceforge.net/virtualcommons/?rev=379&view=rev Author: kjonas Date: 2009-11-29 22:06:34 +0000 (Sun, 29 Nov 2009) Log Message: ----------- Changed actionscript/Communication.as to use Date instead of Timestamp Added custom/Communication.mxml class which has basic methods needed for communication-interface. - Client will create an Communication.as object and send to server, expecting server to push same object to all clients exactly once. - Client can display Communication.as objects that it receives from server. Modified Paths: -------------- mentalmodels/trunk/flex/src/actionscript/Communication.as Added Paths: ----------- mentalmodels/trunk/flex/src/custom/Communication.mxml Modified: mentalmodels/trunk/flex/src/actionscript/Communication.as =================================================================== --- mentalmodels/trunk/flex/src/actionscript/Communication.as 2009-11-29 19:23:30 UTC (rev 378) +++ mentalmodels/trunk/flex/src/actionscript/Communication.as 2009-11-29 22:06:34 UTC (rev 379) @@ -6,8 +6,8 @@ { public var id:Number; public var message:String; - public var timestamp:Timestamp; - public var student:Student; + public var date:Date; + public var student:actionscript.Student; public var round:Round; } } \ No newline at end of file Added: mentalmodels/trunk/flex/src/custom/Communication.mxml =================================================================== --- mentalmodels/trunk/flex/src/custom/Communication.mxml (rev 0) +++ mentalmodels/trunk/flex/src/custom/Communication.mxml 2009-11-29 22:06:34 UTC (rev 379) @@ -0,0 +1,55 @@ +<?xml version="1.0" encoding="utf-8"?> +<mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml" defaultButton="{btnSelfComm}"> + + <mx:Script> + <![CDATA[ + import actionscript.Communication; + import actionscript.Student; + import mx.controls.Label; + import mx.controls.Text; + + public function btnSend_click():void + { + //<service>.<method>(txtMessage.text); + } + public function btnSelfComm_click():void + { + var comm:actionscript.Communication = new actionscript.Communication(); + comm.message = txtMessage.text; + comm.date = new Date(); + comm.student = new actionscript.Student(); comm.student.id = 1; + txtMessage.text = ""; + + commReceived(comm); + } + + public function commReceived(comm:actionscript.Communication):void + { + if(comm.message == null || comm.message.length == 0) return; + vbxMessages.addChild(commToText(comm)); + } + + private function strToText(str:String):Text + { + var newText:Text = new Text(); + newText.text = str; + return newText; + } + private function commToText(comm:actionscript.Communication):Text + { + var newText:Text = new Text(); + newText.text = "["+comm.date.toLocaleTimeString()+"] "+comm.student.id+": "+comm.message; + return newText; + } + + ]]> + </mx:Script> + + <mx:VBox id="vbxMessages" width="500" height="300"/> + <mx:HBox> + <mx:TextInput id="txtMessage" width="400"/> + <mx:Button id="btnSend" label="Send" click="btnSend_click()"/> + <mx:Button id="btnSelfComm" label="SelfComm" click="btnSelfComm_click()"/> + </mx:HBox> + +</mx:VBox> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <kj...@us...> - 2009-12-08 20:42:02
|
Revision: 411 http://virtualcommons.svn.sourceforge.net/virtualcommons/?rev=411&view=rev Author: kjonas Date: 2009-12-08 20:41:37 +0000 (Tue, 08 Dec 2009) Log Message: ----------- renamed from custom/Communication.mxml to custom/CommunicationC.mxml added code into actionscript/PageDisplay.as to display custom/CommunicationC.mxml components to the client during the first question_group of a communication round. (this seems not to work, as the gameObject or its currentRound is null Modified Paths: -------------- mentalmodels/trunk/flex/src/actionscript/PageDisplay.as mentalmodels/trunk/flex/src/test.mxml Added Paths: ----------- mentalmodels/trunk/flex/src/custom/CommunicationC.mxml Removed Paths: ------------- mentalmodels/trunk/flex/src/Student.as mentalmodels/trunk/flex/src/custom/Communication.mxml Deleted: mentalmodels/trunk/flex/src/Student.as =================================================================== --- mentalmodels/trunk/flex/src/Student.as 2009-12-04 19:41:59 UTC (rev 410) +++ mentalmodels/trunk/flex/src/Student.as 2009-12-08 20:41:37 UTC (rev 411) @@ -1,11 +0,0 @@ -package -{ - [Bindable] - [RemoteClass(alias="student.Student")] - public class Student - { - public var fname:String; - public var lname:String; - - } -} \ No newline at end of file Modified: mentalmodels/trunk/flex/src/actionscript/PageDisplay.as =================================================================== --- mentalmodels/trunk/flex/src/actionscript/PageDisplay.as 2009-12-04 19:41:59 UTC (rev 410) +++ mentalmodels/trunk/flex/src/actionscript/PageDisplay.as 2009-12-08 20:41:37 UTC (rev 411) @@ -1,285 +1,303 @@ -// 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 flash.display.DisplayObject; - - import mx.collections.ArrayCollection; - import mx.containers.VBox; - import mx.controls.Text; - - [Bindable] - public class PageDisplay - { - public var msg:String = ""; - - public var gameObject:actionscript.Game = null; - public var pages:ArrayCollection; - public var minPagesRead:int; - public var currentPageNumber:int; - public var highestPageReached:int; - - public var locations:ArrayCollection = new ArrayCollection([newLocation(0, 0)]); - - public var currBlock:Block; - - private function newLocation(maxCapacity:Number,growth:Number):Location - { - var newLoc:Location = new Location(); - newLoc.growthRate = growth; - return newLoc; - } - - public function PageDisplay(newBlock:Block, minimumPagesRead:int, locations:ArrayCollection) - { - currBlock = newBlock; - minPagesRead = minimumPagesRead; - currentPageNumber = 0; - highestPageReached = currentPageNumber; - this.locations = locations; - - loadPages(); - } - - public function loadPages():void - { - pages = new ArrayCollection(); - - if(currBlock == null) - { - msg += "block is null"; - return; - } - if(currBlock.questionGroups == null || currBlock.questionGroups.length == 0) - { - msg += "no QuestionGroups found\n"; - return; - } - - for(var group:int=0; group<currBlock.questionGroups.length; group++) - { - var questionGroup:QuestionGroup = QuestionGroup(currBlock.questionGroups.getItemAt(group)); - var tempBox:VBox = new VBox(); - tempBox.visible = true; - - if(questionGroup.questions != null && questionGroup.questions.length != 0) - { - for(var question:int=0; question<questionGroup.questions.length; question++) - { - var tempQuestion:Question = Question(questionGroup.questions.getItemAt(question)); - -// //This should be handled inside the question itself. -// var txt:Text = new Text(); -// txt.width = 300; -// txt.htmlText = tempQuestion.question; -// tempBox.addChild(txt); - - if(tempQuestion is Categorical) - { - var cq:CategoricalQuestionC = new CategoricalQuestionC(); - cq.loadFromQuestion(Categorical(tempQuestion)); - cq.id = "q"+question; - - tempBox.addChild(cq); - } - else if(tempQuestion is Psychometric) - { - var pq:PsychometricQuestionC = new PsychometricQuestionC(); - pq.loadFromQuestion(Psychometric(tempQuestion)); - pq.id = "q"+question; - - tempBox.addChild(pq); - } - else - { - if(tempQuestion == null || tempQuestion.type == null) - { - var tq:TextQuestionC = new TextQuestionC(); - tq.loadFromQuestion(Question(tempQuestion)); - tq.id = "q"+question; - - tempBox.addChild(tq); - } - else if(tempQuestion.type.toLowerCase() == "strategydesign") - { - var sdq:StrategyDesignQuestionC = new StrategyDesignQuestionC(); - sdq.locations = locations; - sdq.setRound(gameObject.currentRound); - sdq.loadFromQuestion(Question(tempQuestion)); - sdq.id = "q"+question; - - tempBox.addChild(sdq); - } - else if(tempQuestion.type.toLowerCase() == "daybydaydecisions") - { - var ddq:DayByDayDecisionsQuestionC = new DayByDayDecisionsQuestionC(); - ddq.locations = locations; - ddq.loadFromQuestion(Question(tempQuestion)); - ddq.id = "q"+question; - - tempBox.addChild(ddq); - } - else if(tempQuestion.type.toLowerCase() == "forecastingfishermen") - { - var fpq:ForecastingPeopleQuestionC = new ForecastingPeopleQuestionC(); - fpq.locations = locations; - fpq.loadFromQuestion(tempQuestion); - fpq.id = "q"+question; - - tempBox.addChild(fpq); - } - else if(tempQuestion.type.toLowerCase() == "forecastingfish") - { - var ffq:ForecastingFishQuestionC = new ForecastingFishQuestionC(); - ffq.locations = locations; - ffq.loadFromQuestion(tempQuestion); - ffq.id = "q"+question; - - tempBox.addChild(ffq); - } - else - { - tq = new TextQuestionC(); - tq.loadFromQuestion(Question(tempQuestion)); - tq.id = "q"+question; - - tempBox.addChild(tq); - } - } - } - } - else - { -// 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.htmlText = questionGroup.header; - desc.htmlText = questionGroup.description; - if(desc.htmlText.length != 0) tempBox.addChildAt(desc,0); - if(head.htmlText.length != 0) tempBox.addChildAt(head,0); - - pages.addItem(tempBox); -// msg += "item added\n"; - } - - } - - public function componentsNotFinished(force:Boolean=false):Boolean - { - var returnValue:Boolean = false; - var curr:VBox; - var messages:String = ""; - - for(var pageNumber:int=0; pageNumber < pages.length; pageNumber++) - { - curr = pages.getItemAt(pageNumber) as VBox; - - var tempQuestion:DisplayObject; - for(var i:int=0; i < curr.numChildren; i++) - { - tempQuestion = (curr.getChildAt(i) as DisplayObject); - - if(tempQuestion is DayByDayDecisionsQuestionC) - { - messages += "D"; - if((tempQuestion as DayByDayDecisionsQuestionC).dayByDayContent.numChildren < 30) - { - returnValue = true; - } - } - else if(tempQuestion is StrategyDesignQuestionC) - { - messages += "S"; - if(!(tempQuestion as StrategyDesignQuestionC).accept()) - { - returnValue = true; - } - } - else - { - messages += "x"; - } - } -// Alert.show(messages + returnValue); - } - return returnValue && !force; - } - public function finished(force:Boolean=false):Boolean - { return highestPageReached >= minPagesRead - 1 || force; } - public function get length():int - { return pages.length; } - - public function get currentPage():DisplayObject - { - if(pages != null && pages.length > 0) // pages? - { - if(currentPageNumber < 0) currentPageNumber = 0; - if(currentPageNumber >= pages.length) currentPageNumber = pages.length - 1; - return (DisplayObject)(pages.getItemAt(currentPageNumber)); // VALID_RESULT - } - - return null; // no pages - } - public function nextPage():Boolean - { - currentPageNumber = fix(currentPageNumber + 1, 0, pages.length-1); - highestPageReached = Math.max(currentPageNumber, highestPageReached) - return true; - } - public function prevPage():Boolean - { - 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; - } - - public function reset():void - { - var curr:VBox = currentPage as VBox; - var messages:String = ""; - - if(curr != null) - { - var tempQuestion:DisplayObject; - for(var i:int=0; i < curr.numChildren; i++) - { - tempQuestion = (curr.getChildAt(i) as DisplayObject); - - if(tempQuestion is PsychometricQuestionC) - { - (tempQuestion as PsychometricQuestionC).slider1.reset(); - messages += "P"; - } - else if(tempQuestion is CategoricalQuestionC) - { - (tempQuestion as CategoricalQuestionC).comboTopic.selectedIndex = 0; - (tempQuestion as CategoricalQuestionC).comboSpecific.selectedIndex = -1; - messages += "C"; - } - else - { - messages += "x"; - } - } -// Alert.show(messages); - } - } - } +// ActionScript file +package actionscript +{ + import actionscript.questions.*; + + import custom.CommunicationC; + import custom.questions.*; + import custom.questions.dayByDayDecisions.DayByDayDecisionsQuestionC; + import custom.questions.forecasting.*; + import custom.questions.psychometric.PsychometricQuestionC; + import custom.questions.strategyDesign.StrategyDesignQuestionC; + + import flash.display.DisplayObject; + + import mx.collections.ArrayCollection; + import mx.containers.VBox; + import mx.controls.Alert; + import mx.controls.Text; + + [Bindable] + public class PageDisplay + { + public var msg:String = ""; + + public var gameObject:actionscript.Game = null; + public var pages:ArrayCollection; + public var minPagesRead:int; + public var currentPageNumber:int; + public var highestPageReached:int; + + public var locations:ArrayCollection = new ArrayCollection([newLocation(0, 0)]); + + public var currBlock:Block; + + private function newLocation(maxCapacity:Number,growth:Number):Location + { + var newLoc:Location = new Location(); + newLoc.growthRate = growth; + return newLoc; + } + + public function PageDisplay(newBlock:Block, minimumPagesRead:int, locations:ArrayCollection) + { + currBlock = newBlock; + minPagesRead = minimumPagesRead; + currentPageNumber = 0; + highestPageReached = currentPageNumber; + this.locations = locations; + + loadPages(); + } + + public function loadPages():void + { + pages = new ArrayCollection(); + + if(currBlock == null) + { + msg += "block is null"; + return; + } + if(currBlock.questionGroups == null || currBlock.questionGroups.length == 0) + { + msg += "no QuestionGroups found\n"; + return; + } + + for(var group:int=0; group<currBlock.questionGroups.length; group++) + { + var questionGroup:QuestionGroup = QuestionGroup(currBlock.questionGroups.getItemAt(group)); + var tempBox:VBox = new VBox(); + tempBox.visible = true; + + if(questionGroup.questions != null && questionGroup.questions.length != 0) + { + for(var question:int=0; question<questionGroup.questions.length; question++) + { + var tempQuestion:Question = Question(questionGroup.questions.getItemAt(question)); + +// //This should be handled inside the question itself. +// var txt:Text = new Text(); +// txt.width = 300; +// txt.htmlText = tempQuestion.question; +// tempBox.addChild(txt); + + if(tempQuestion is Categorical) + { + var cq:CategoricalQuestionC = new CategoricalQuestionC(); + cq.loadFromQuestion(Categorical(tempQuestion)); + cq.id = "q"+question; + + tempBox.addChild(cq); + } + else if(tempQuestion is Psychometric) + { + var pq:PsychometricQuestionC = new PsychometricQuestionC(); + pq.loadFromQuestion(Psychometric(tempQuestion)); + pq.id = "q"+question; + + tempBox.addChild(pq); + } + else + { + if(tempQuestion == null || tempQuestion.type == null) + { + var tq:TextQuestionC = new TextQuestionC(); + tq.loadFromQuestion(Question(tempQuestion)); + tq.id = "q"+question; + + tempBox.addChild(tq); + } + else if(tempQuestion.type.toLowerCase() == "strategydesign") + { + var sdq:StrategyDesignQuestionC = new StrategyDesignQuestionC(); + sdq.locations = locations; + sdq.setRound(gameObject.currentRound); + sdq.loadFromQuestion(Question(tempQuestion)); + sdq.id = "q"+question; + + tempBox.addChild(sdq); + } + else if(tempQuestion.type.toLowerCase() == "daybydaydecisions") + { + var ddq:DayByDayDecisionsQuestionC = new DayByDayDecisionsQuestionC(); + ddq.locations = locations; + ddq.loadFromQuestion(Question(tempQuestion)); + ddq.id = "q"+question; + + tempBox.addChild(ddq); + } + else if(tempQuestion.type.toLowerCase() == "forecastingfishermen") + { + var fpq:ForecastingPeopleQuestionC = new ForecastingPeopleQuestionC(); + fpq.locations = locations; + fpq.loadFromQuestion(tempQuestion); + fpq.id = "q"+question; + + tempBox.addChild(fpq); + } + else if(tempQuestion.type.toLowerCase() == "forecastingfish") + { + var ffq:ForecastingFishQuestionC = new ForecastingFishQuestionC(); + ffq.locations = locations; + ffq.loadFromQuestion(tempQuestion); + ffq.id = "q"+question; + + tempBox.addChild(ffq); + } + else + { + tq = new TextQuestionC(); + tq.loadFromQuestion(Question(tempQuestion)); + tq.id = "q"+question; + + tempBox.addChild(tq); + } + } + } + } + else + { +// 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.htmlText = questionGroup.header; + desc.htmlText = questionGroup.description; + if(desc.htmlText.length != 0) tempBox.addChildAt(desc,0); + if(head.htmlText.length != 0) tempBox.addChildAt(head,0); + + pages.addItem(tempBox); +// msg += "item added\n"; + } + + if(gameObject == null) return; + if(gameObject.currentRound != null) + { + if(gameObject.currentRound.communicationFlag) + { + var comm:CommunicationC = new custom.CommunicationC(); + comm.id = "q"+question; + comm.initialize(); + + (pages.getItemAt(0) as VBox).addChild(comm); + } + } + else + { + Alert.show("gameObject.currentRound == null"); + } + } + + public function componentsNotFinished(force:Boolean=false):Boolean + { + var returnValue:Boolean = false; + var curr:VBox; + var messages:String = ""; + + for(var pageNumber:int=0; pageNumber < pages.length; pageNumber++) + { + curr = pages.getItemAt(pageNumber) as VBox; + + var tempQuestion:DisplayObject; + for(var i:int=0; i < curr.numChildren; i++) + { + tempQuestion = (curr.getChildAt(i) as DisplayObject); + + if(tempQuestion is DayByDayDecisionsQuestionC) + { + messages += "D"; + if((tempQuestion as DayByDayDecisionsQuestionC).dayByDayContent.numChildren < 30) + { + returnValue = true; + } + } + else if(tempQuestion is StrategyDesignQuestionC) + { + messages += "S"; + if(!(tempQuestion as StrategyDesignQuestionC).accept()) + { + returnValue = true; + } + } + else + { + messages += "x"; + } + } +// Alert.show(messages + returnValue); + } + return returnValue && !force; + } + public function finished(force:Boolean=false):Boolean + { return highestPageReached >= minPagesRead - 1 || force; } + public function get length():int + { return pages.length; } + + public function get currentPage():DisplayObject + { + if(pages != null && pages.length > 0) // pages? + { + if(currentPageNumber < 0) currentPageNumber = 0; + if(currentPageNumber >= pages.length) currentPageNumber = pages.length - 1; + return (DisplayObject)(pages.getItemAt(currentPageNumber)); // VALID_RESULT + } + + return null; // no pages + } + public function nextPage():Boolean + { + currentPageNumber = fix(currentPageNumber + 1, 0, pages.length-1); + highestPageReached = Math.max(currentPageNumber, highestPageReached) + return true; + } + public function prevPage():Boolean + { + 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; + } + + public function reset():void + { + var curr:VBox = currentPage as VBox; + var messages:String = ""; + + if(curr != null) + { + var tempQuestion:DisplayObject; + for(var i:int=0; i < curr.numChildren; i++) + { + tempQuestion = (curr.getChildAt(i) as DisplayObject); + + if(tempQuestion is PsychometricQuestionC) + { + (tempQuestion as PsychometricQuestionC).slider1.reset(); + messages += "P"; + } + else if(tempQuestion is CategoricalQuestionC) + { + (tempQuestion as CategoricalQuestionC).comboTopic.selectedIndex = 0; + (tempQuestion as CategoricalQuestionC).comboSpecific.selectedIndex = -1; + messages += "C"; + } + else + { + messages += "x"; + } + } +// Alert.show(messages); + } + } + } } \ No newline at end of file Deleted: mentalmodels/trunk/flex/src/custom/Communication.mxml =================================================================== --- mentalmodels/trunk/flex/src/custom/Communication.mxml 2009-12-04 19:41:59 UTC (rev 410) +++ mentalmodels/trunk/flex/src/custom/Communication.mxml 2009-12-08 20:41:37 UTC (rev 411) @@ -1,127 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml" defaultButton="{btnSelfComm}" creationComplete="init()"> - - <mx:Consumer id="consumer" destination="mme" message="messageHandler(event.message)" fault="faultMsgHandler(event)" channelSet="{cs}" /> - <mx:ChannelSet id="cs"> - <!-- <mx:StreamingAMFChannel url="http://localhost:8080/messagebroker/streamingamf"/> --> - <mx:AMFChannel url="http://localhost:8080/mme/messagebroker/amflongpolling"/> - <mx:AMFChannel url="http://localhost:8080/mme/messagebroker/amfpolling"/> - </mx:ChannelSet> - <mx:Producer id="producer" destination="mme" channelSet="{cs}"/> - <mx:RemoteObject id="comunication" destination="communicationService" fault="faultHandler(event)"> - <mx:method name="saveCommunication"/> - </mx:RemoteObject> - - <mx:Script> - <![CDATA[ - import actionscript.Group; - import actionscript.Communication; - import actionscript.Student; - import mx.controls.Label; - import mx.controls.Text; - import mx.messaging.messages.IMessage; - import mx.messaging.events.MessageAckEvent; - import mx.messaging.events.MessageFaultEvent; - import mx.messaging.events.MessageEvent; - import mx.messaging.events.MessageFaultEvent; - import mx.messaging.events.MessageFaultEvent; - import mx.controls.Alert; - import mx.messaging.messages.AsyncMessage; - - import mx.messaging.Producer; - import mx.messaging.Consumer; - - import mx.rpc.events.FaultEvent; - - public var student:actionscript.Student; - public var testDBD:TestDayByDayDecisions = new TestDayByDayDecisions(); - public function init():void - { - /* var testDBD:TestDayByDayDecisions = new TestDayByDayDecisions(); - student = testDBD.studentObject; - var group:actionscript.Group = testDBD.getGroup(); - var subTopic:String = student.gameCode + group.id.toString() + student.id.toString();*/ - - consumer.subtopic = "test1.1"; - consumer.subscribe(); - - producer.subtopic = "test1.1"; - - } - public function faultMsgHandler(msgevent:MessageFaultEvent):void - { - Alert.show("Error in getting message: " + msgevent.faultString); - } - - private function faultHandler(event:FaultEvent):void - { - Alert.show("Fault:\n"+event.fault.message + "\n" + event.fault.getStackTrace()); - } - public function btnSend_click():void - { - var message:IMessage = new AsyncMessage(); - var comm:actionscript.Communication = new actionscript.Communication(); - comm.message = txtMessage.text; - comm.date = new Date(); - comm.student = new actionscript.Student(); - comm.student.birthYear = 1982; - comm.student.gender = "F"; - comm.student.major = "CSE" - comm.student.semester = "1"; - comm.student.gameCode = "test1" - comm.student.id = 1; - - message.body = comm; - //producer.send(message); - - txtMessage.text = ""; - //<service>.<method>(txtMessage.text); - comunication.saveCommunication(comm); - } - public function btnSelfComm_click():void - { - var comm:actionscript.Communication = new actionscript.Communication(); - comm.message = txtMessage.text; - comm.date = new Date(); - comm.student = new actionscript.Student(); comm.student.id = 1; - txtMessage.text = ""; - commReceived(comm); - } - - public function commReceived(comm:actionscript.Communication):void - { - if(comm.message == null || comm.message.length == 0) return; - vbxMessages.addChild(commToText(comm)); - vbxMessages.verticalScrollPosition = vbxMessages.maxVerticalScrollPosition; - } - - private function messageHandler(message:IMessage):void - { - commReceived(message.body as actionscript.Communication); - } - private function strToText(str:String):Text - { - var newText:Text = new Text(); - newText.text = str; - return newText; - } - private function commToText(comm:actionscript.Communication):Text - { - var newText:Text = new Text(); - newText.text = "["+comm.date.toLocaleTimeString()+"] "+comm.student.id+": "+comm.message; - return newText; - } - - ]]> - </mx:Script> - - - <mx:VBox id="vbxMessages" width="500" height="300" verticalScrollPolicy="on"/> - <mx:HBox> - <mx:TextInput id="txtMessage" width="500"/> - <mx:Button id="btnSend" label="Send" click="btnSend_click()" visible="false"/> - <mx:Button id="btnSelfComm" label="SelfComm" click="btnSelfComm_click()" visible="false"/> - </mx:HBox> - - -</mx:VBox> Added: mentalmodels/trunk/flex/src/custom/CommunicationC.mxml =================================================================== --- mentalmodels/trunk/flex/src/custom/CommunicationC.mxml (rev 0) +++ mentalmodels/trunk/flex/src/custom/CommunicationC.mxml 2009-12-08 20:41:37 UTC (rev 411) @@ -0,0 +1,82 @@ +<?xml version="1.0" encoding="utf-8"?> +<mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml" defaultButton="{btnSend}"> + + <mx:Script> + <![CDATA[ + import mx.messaging.events.MessageEvent; + import mx.rpc.events.FaultEvent; + import actionscript.Communication; + import actionscript.Student; + import mx.controls.Label; + import mx.controls.Text; + + public var student:Student = null; + + public function faultHandler(event:FaultEvent):void + { + // Silent Failure + } + public function messageHandler(event:MessageEvent):void + { + if(event.message.body is actionscript.Communication) + { + commReceived(event.message.body as actionscript.Communication); + } + } + + public function btnSend_click():void + { + var tempCommunication:actionscript.Communication = new actionscript.Communication(); + tempCommunication.date = new Date(); + tempCommunication.message = txtMessage.text; + tempCommunication.student = this.student; + txtMessage.text = ""; + + //<service>.<method>(tempCommunication); + } + public function btnSelfComm_click():void + { + var comm:actionscript.Communication = new actionscript.Communication(); + comm.message = txtMessage.text; + comm.date = new Date(); + comm.student = new actionscript.Student(); comm.student.id = 1; + txtMessage.text = ""; + + commReceived(comm); + } + + public function commReceived(comm:actionscript.Communication):void + { + if(comm.message == null || comm.message.length == 0) return; + vbxMessages.addChild(commToText(comm)); + vbxMessages.verticalScrollPosition = vbxMessages.maxVerticalScrollPosition; + } + + private function strToText(str:String):Text + { + var newText:Text = new Text(); + newText.text = str; + return newText; + } + private function commToText(comm:actionscript.Communication):Text + { + var newText:Text = new Text(); + newText.text = "["+comm.date.toLocaleTimeString()+"] "+comm.student.id+": "+comm.message; + return newText; + } + + ]]> + </mx:Script> + + <mx:RemoteObject id="communicationService" destination="communicationService" fault="faultHandler(event)"> + <mx:method name="sendCommunication" result="messageHandler(event)"/> + </mx:RemoteObject> + + <mx:VBox id="vbxMessages" width="500" height="300" verticalScrollPolicy="on"/> + <mx:HBox> + <mx:TextInput id="txtMessage" width="500"/> + <mx:Button id="btnSend" label="Send" click="btnSend_click()" visible="false"/> + <mx:Button id="btnSelfComm" label="SelfComm" click="btnSelfComm_click()" visible="false"/> + </mx:HBox> + +</mx:VBox> Modified: mentalmodels/trunk/flex/src/test.mxml =================================================================== --- mentalmodels/trunk/flex/src/test.mxml 2009-12-04 19:41:59 UTC (rev 410) +++ mentalmodels/trunk/flex/src/test.mxml 2009-12-08 20:41:37 UTC (rev 411) @@ -1,94 +1,6 @@ <?xml version="1.0" encoding="utf-8"?> -<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical" xmlns:actionscript="actionscript.*"> +<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical" xmlns:actionscript="actionscript.*" xmlns:custom="custom.*"> - <actionscript:Student id="stu" birthYear="1991" gender="M" major="cse" gameCode="{gc.text}"/> - <mx:TextInput id="gc" text="test3"/> - - <mx:ArrayCollection id="strat"> - <actionscript:StudentStrategy days="1" repeatedDecision="true" location="{locs.getItemAt(0) as Location}"/> - </mx:ArrayCollection> - - <mx:ArrayCollection id="locs"> - </mx:ArrayCollection> - - <mx:HBox> - <mx:Button label="roundService.getBlock()" click="roundService.getBlock()"/> - <mx:Button label="roundService.getCurrentRound()" click="roundService.getCurrentRound()"/> - <mx:Button label="startupService.createStudent()" click="startupService.createStudent(stu)"/> - <mx:Button label="answeringService.saveStrategy()" click="answeringService.saveStrategy(strat)"/> - <mx:Button label="locationService.getAllLocations()" click="locationService.getAllLocations()"/> - </mx:HBox> - - <mx:HBox> - <mx:VBox> - <mx:Label text="location"/> - <mx:NumericStepper stepSize="1" value="0" enabled="{locs.length != 0}"/> - </mx:VBox> - <mx:VBox> - <mx:Label text="???"/> - <mx:NumericStepper stepSize="1" value="0"/> - </mx:VBox> - </mx:HBox> - - <mx:RemoteObject id="roundService" destination="roundService" fault="faultHandler(event)"> - <mx:method name="getBlock" result="resultHandler(event)"/> - <mx:method name="getCurrentRound" result="resultHandler(event)"/> - </mx:RemoteObject> - <mx:RemoteObject id="startupService" destination="startupService" fault="faultHandler(event)"> - <mx:method name="createStudent" result="resultHandler(event)"/> - </mx:RemoteObject> - <mx:RemoteObject id="answeringService" destination="answeringService" fault="faultHandler(event)"> - <mx:method name="saveStrategy" result="resultHandler(event)"/> - </mx:RemoteObject> - <mx:RemoteObject id="locationService" destination="locationService" fault="faultHandler(event)"> - <mx:method name="getAllLocations" result="resultHandler(event)"/> - </mx:RemoteObject> - - <mx:Script> - <![CDATA[ - import actionscript.Location; - import actionscript.Round; - import mx.core.UIComponent; - import mx.controls.Alert; - import mx.rpc.events.FaultEvent; - import mx.rpc.events.ResultEvent; - - public function resultHandler(event:ResultEvent):void - { - var str:String = ""; - str += "event == null : " + (event == null) + "\n"; - str += "event.result == null : " + (event.result == null) + "\n"; - - Alert.show(str, "resultHandler()"); - - var array:ArrayCollection = (event.result as ArrayCollection); - if(array != null) - { - Alert.show("ArrayCollection"); - var first:Object = array.getItemAt(0); - if((first as Location) != null) - { - Alert.show("ArrayCollection of Locations"); - locs = array; - } - } - -// var round:actionscript.Round = event.result as actionscript.Round; -// Alert.show("round no is : " + round.roundNo + " " + round.id); - //Alert.show - - } - - public function faultHandler(event:FaultEvent):void - { - var str:String = ""; - str += "event.fault.message:\n" + (event.fault.message) + "\n\n"; - str += "event.fault.getStackTrace():\n*START*\n" + (event.fault.getStackTrace()) + "\n*END*"; - - Alert.show(str, "faultHandler()"); - } - - ]]> - </mx:Script> - + <custom:CommunicationC/> + </mx:Application> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |