[virtualcommons-svn] SF.net SVN: virtualcommons:[261] mentalmodels/trunk
Status: Beta
Brought to you by:
alllee
From: <kj...@us...> - 2009-08-18 22:43:53
|
Revision: 261 http://virtualcommons.svn.sourceforge.net/virtualcommons/?rev=261&view=rev Author: kjonas Date: 2009-08-18 22:43:42 +0000 (Tue, 18 Aug 2009) Log Message: ----------- Modified Paths: -------------- mentalmodels/trunk/flex/src/StartGame.mxml mentalmodels/trunk/flex/src/actionscript/Game.as mentalmodels/trunk/flex/src/actionscript/PageDisplay.as mentalmodels/trunk/flex/src/actionscript/StudentStrategy.as mentalmodels/trunk/flex/src/custom/FisheryExperimentCore.mxml mentalmodels/trunk/flex/src/custom/questions/strategyDesign/StrategyDesignQuestionC.mxml mentalmodels/trunk/src/main/webapp/FisheryExperimentShell.swf mentalmodels/trunk/src/main/webapp/InitialiseDatabase.swf mentalmodels/trunk/src/main/webapp/StartGame.swf Modified: mentalmodels/trunk/flex/src/StartGame.mxml =================================================================== --- mentalmodels/trunk/flex/src/StartGame.mxml 2009-08-18 22:35:46 UTC (rev 260) +++ mentalmodels/trunk/flex/src/StartGame.mxml 2009-08-18 22:43:42 UTC (rev 261) @@ -1,24 +1,54 @@ <?xml version="1.0" encoding="utf-8"?> -<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute"> - -<mx:Script> - <![CDATA[ - import actionscript.Block; +<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical"> - import mx.rpc.events.ResultEvent; - import mx.rpc.events.FaultEvent; - import mx.controls.Alert; - - - public function faultHandler(event:FaultEvent):void - { - Alert.show(event.fault.getStackTrace()); - } + <mx:VBox visible="{pageNum==0}" horizontalAlign="center"> + <mx:HBox horizontalAlign="right" width="330" id="firstBox"> + <mx:Label text="$USD per lb of fish:"/> + <mx:TextInput id="txtMoney"/> + </mx:HBox> + <mx:HBox horizontalAlign="right" width="{firstBox.width}"> + <mx:Label text="Brief description of game:"/> + <mx:TextArea id="txtDescription"/> + </mx:HBox> + <mx:Button label="Create Game" id="btnCreateGame" click="false"/> + <mx:HBox horizontalAlign="right" width="{firstBox.width}"> + <mx:Label text="Game ID:"/> + <mx:TextInput id="txtGameID" enabled="false"/> + </mx:HBox> - ]]> -</mx:Script> + <mx:Spacer height="30"/> + + <mx:Text text="Click the Start Game button only after all students have connected using the above ID." width="300"/> + <mx:Button label="Start Game" id="btnStartGame" click="feed.start()"/> + </mx:VBox> - <mx:Button label="Start Game" id="btnStartGame" horizontalCenter="-6" verticalCenter="-46" click="feed.start()"/> - <mx:RemoteObject id="feed" destination="feed" fault="{faultHandler(event)}" /> + <mx:VBox visible="{pageNum==1}"> + <mx:Button label="Get Responses" id="btnGetResponses" click="getResponses()"/> + <mx:VBox id="responsesContent"/> + </mx:VBox> + + <mx:RemoteObject id="feed" destination="feed" fault="{faultHandler(event)}" /> + + <mx:Script> + <![CDATA[ + import actionscript.Block; + import mx.rpc.events.ResultEvent; + import mx.rpc.events.FaultEvent; + import mx.controls.Alert; + + [Bindable]private var pageNum:int = 0; + + public function faultHandler(event:FaultEvent):void + { + Alert.show(event.fault.getStackTrace()); + } + + public function getResponses():void + { + + } + ]]> + </mx:Script> + </mx:Application> Modified: mentalmodels/trunk/flex/src/actionscript/Game.as =================================================================== --- mentalmodels/trunk/flex/src/actionscript/Game.as 2009-08-18 22:35:46 UTC (rev 260) +++ mentalmodels/trunk/flex/src/actionscript/Game.as 2009-08-18 22:43:42 UTC (rev 261) @@ -11,7 +11,7 @@ public var numberOfLocations:int; public var maxDays:int; public var maxFishHarvest:int; - public var timestamp:Timestamp; + public var timestamp:Date; public var title:String; public var description:String; public var money:Number; Modified: mentalmodels/trunk/flex/src/actionscript/PageDisplay.as =================================================================== --- mentalmodels/trunk/flex/src/actionscript/PageDisplay.as 2009-08-18 22:35:46 UTC (rev 260) +++ mentalmodels/trunk/flex/src/actionscript/PageDisplay.as 2009-08-18 22:43:42 UTC (rev 261) @@ -13,14 +13,12 @@ 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 msg:String = ""; public var pages:ArrayCollection; public var minPagesRead:int; Modified: mentalmodels/trunk/flex/src/actionscript/StudentStrategy.as =================================================================== --- mentalmodels/trunk/flex/src/actionscript/StudentStrategy.as 2009-08-18 22:35:46 UTC (rev 260) +++ mentalmodels/trunk/flex/src/actionscript/StudentStrategy.as 2009-08-18 22:43:42 UTC (rev 261) @@ -8,12 +8,13 @@ public class StudentStrategy { public var id:Number; + public var student:actionscript.Student; public var allocationSeqNo:int; public var days:int; public var threshold:Number; public var location:Location; public var repeatedDecisions:Boolean; public var dayOutput:ArrayCollection; - + public var roundConfig:actionscript.Round; } } \ No newline at end of file Modified: mentalmodels/trunk/flex/src/custom/FisheryExperimentCore.mxml =================================================================== --- mentalmodels/trunk/flex/src/custom/FisheryExperimentCore.mxml 2009-08-18 22:35:46 UTC (rev 260) +++ mentalmodels/trunk/flex/src/custom/FisheryExperimentCore.mxml 2009-08-18 22:43:42 UTC (rev 261) @@ -46,8 +46,7 @@ </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="720" height="475"/> + <mx:Canvas id="content" x="0" y="0" width="720" height="460"/> <mx:Canvas id="expiredContent" x="-1" y="-1" width="1" height="1" visible="false"/> <mx:HBox id="buttonBar" left="{(width-buttonBar.width)/2}" bottom="0" horizontalGap="100"> @@ -60,10 +59,10 @@ <mx:RemoteObject id="roundService" destination="roundService" fault="faultHandler(event)"> <mx:method name="getBlock" result="blockResultHandler(event)"/> + <mx:method name="getCurrentRound" result="roundResultHandler(event)"/> </mx:RemoteObject> <mx:RemoteObject id="startupService" destination="startupService" fault="faultHandler(event)"> <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:method name="saveStrategy" result="strategyResultHandler(event)"/> @@ -106,6 +105,8 @@ public var currentModuleNumber:int = 0; public var currentBlock:Block = null; public var currentBlockNumber:int = 0; + public var currentRound:Round = null; + public var currentRoundNumber:int = 0; [Bindable] public var locations:ArrayCollection = new ArrayCollection([newLocation(0, 0)]); public var blockLoader:Function = null; @@ -117,6 +118,7 @@ public var instructionsLoaded:Boolean = false; [Bindable] public var studentObject:actionscript.Student; + [Bindable] public var roundObject:actionscript.Round; private function newLocation(maxCapacity:Number,growth:Number):Location { @@ -130,9 +132,7 @@ [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); } public function init():void @@ -144,7 +144,6 @@ { btnForward.enabled = btnBack.enabled = btnReset.enabled = true; instructionsLoaded = true; -// instructions.moduleNumber = currentModuleNumber; currentState = "instructions"; } private function sendBlockQuestions():void @@ -242,10 +241,16 @@ studentResponse.question = null; var strategy:StrategyDesignQuestionC = StrategyDesignQuestionC(curr.getChildAt(j)); - answeringService.saveStrategy(strategy.toDatabaseObject()); + var tempDBObjects:ArrayCollection = strategy.toDatabaseObject(); + + for(var k:int=0;k<tempDBObjects.length;k++) + { + (tempDBObjects.getItemAt(k) as StudentStrategy).student = studentObject; + (tempDBObjects.getItemAt(k) as StudentStrategy).roundConfig = roundObject; + } + + answeringService.saveStrategy(tempDBObjects); } -// if(curr.getChildAt(j) is StrategyDesignQuestionC) -// Alert.show("strategy found"); if(studentResponse.question != null) { @@ -254,19 +259,6 @@ } } -// 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); } @@ -276,16 +268,21 @@ } private function getNextBlock():void { - if(currentBlock != null) sendBlockQuestions(); currentBlock = null; currentBlockNumber++; //server request roundService.getBlock(); -// blockResultHandler(new ResultEvent("",false,true,makeBlock())); } private function blockResultHandler(event:ResultEvent):void { + // save questions from previous Block + if(currentBlock != null) + { + sendBlockQuestions(); + } + + // update with new block currentBlock = (event.result as actionscript.Block); if(currentBlock == null @@ -303,8 +300,12 @@ gotoInstructions(); } + // start timer to alert students to hurry shell.setProgressBarTime(0,0,currentBlock.duration); shell.progressBarInit(); + + // get the present round; hopefully the strategy design has been finished by now + roundService.getCurrentRound(); } private function moduleResultHandler(event:ResultEvent):void { @@ -330,6 +331,11 @@ gotoInstructions(); } } + private function roundResultHandler(event:ResultEvent):void + { + currentRound = event.result as Round; + currentRoundNumber = currentRound.id; + } public function getLocation():void { @@ -340,7 +346,6 @@ if(event.result is ArrayCollection) { locations = event.result as ArrayCollection; -// Alert.show("locations received: "+locations.length); } } private function strategyResultHandler(event:ResultEvent):void @@ -362,7 +367,6 @@ private function messageHandler(message:IMessage):void { randomNumbers = message.body as String; -// Alert.show( ""+randomNumbers); } public function back():Boolean @@ -460,98 +464,6 @@ } } - 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.categoricalOptions = new ArrayCollection(); - - 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"; - psy1.type = "psychometric"; - psy1.maxSliderValue = 10; - psy1.choices = new ArrayCollection(); - psy1.choices.addItem("Highly Agree"); - 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"; - - 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); - qg4.questions.addItem(psy2); - 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> Modified: mentalmodels/trunk/flex/src/custom/questions/strategyDesign/StrategyDesignQuestionC.mxml =================================================================== --- mentalmodels/trunk/flex/src/custom/questions/strategyDesign/StrategyDesignQuestionC.mxml 2009-08-18 22:35:46 UTC (rev 260) +++ mentalmodels/trunk/flex/src/custom/questions/strategyDesign/StrategyDesignQuestionC.mxml 2009-08-18 22:43:42 UTC (rev 261) @@ -35,6 +35,7 @@ <mx:Script> <![CDATA[ + import actionscript.Round; import actionscript.Location; import actionscript.StudentStrategy; import actionscript.questions.Question; Modified: mentalmodels/trunk/src/main/webapp/FisheryExperimentShell.swf =================================================================== (Binary files differ) Modified: mentalmodels/trunk/src/main/webapp/InitialiseDatabase.swf =================================================================== (Binary files differ) Modified: mentalmodels/trunk/src/main/webapp/StartGame.swf =================================================================== (Binary files differ) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |