[virtualcommons-svn] SF.net SVN: virtualcommons:[196] mentalmodels/trunk/flex/src
Status: Beta
Brought to you by:
alllee
From: <kj...@us...> - 2009-07-22 19:22:21
|
Revision: 196 http://virtualcommons.svn.sourceforge.net/virtualcommons/?rev=196&view=rev Author: kjonas Date: 2009-07-22 18:42:10 +0000 (Wed, 22 Jul 2009) Log Message: ----------- created structure (but not necessarily code) for submitting answers for each question created StudentResponse.as as alias for StudentResponse.java, for sending responses Modified Paths: -------------- mentalmodels/trunk/flex/src/actionscript/PageDisplay.as mentalmodels/trunk/flex/src/custom/FisheryExperimentCore.mxml Added Paths: ----------- mentalmodels/trunk/flex/src/actionscript/StudentResponse.as Modified: mentalmodels/trunk/flex/src/actionscript/PageDisplay.as =================================================================== --- mentalmodels/trunk/flex/src/actionscript/PageDisplay.as 2009-07-22 01:16:38 UTC (rev 195) +++ mentalmodels/trunk/flex/src/actionscript/PageDisplay.as 2009-07-22 18:42:10 UTC (rev 196) @@ -170,11 +170,13 @@ public function componentsNotFinished():Boolean { var returnValue:Boolean = false; - var curr:VBox = currentPage as VBox; + var curr:VBox; var messages:String = ""; - if(curr != null) + 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++) { Added: mentalmodels/trunk/flex/src/actionscript/StudentResponse.as =================================================================== --- mentalmodels/trunk/flex/src/actionscript/StudentResponse.as (rev 0) +++ mentalmodels/trunk/flex/src/actionscript/StudentResponse.as 2009-07-22 18:42:10 UTC (rev 196) @@ -0,0 +1,14 @@ +package actionscript +{ + import actionscript.questions.Question; + + [Bindable] + [RemoteClass(alias="edu.asu.commons.mme.entity.StudentResponse")] + public class StudentResponse + { + public var id:Number; + public var student:Student; + public var question:Question; + public var response:String; + } +} Modified: mentalmodels/trunk/flex/src/custom/FisheryExperimentCore.mxml =================================================================== --- mentalmodels/trunk/flex/src/custom/FisheryExperimentCore.mxml 2009-07-22 01:16:38 UTC (rev 195) +++ mentalmodels/trunk/flex/src/custom/FisheryExperimentCore.mxml 2009-07-22 18:42:10 UTC (rev 196) @@ -4,8 +4,6 @@ currentState="socioDemographic" initialize="init()" width="720" height="490"> - <mx:RemoteObject id="moduleService" destination="moduleService" fault="moduleFaultHandler(event)" result="moduleResultHandler(event)"/> - <mx:states> <mx:State name="socioDemographic"> <mx:AddChild relativeTo="{content}"> @@ -36,6 +34,7 @@ </mx:State> <mx:State name="none"> + <mx:RemoveChild target="{instructions}"/> <mx:AddChild relativeTo="{content}"> <mx:Label id="end" text="Thank you for playing!" fontSize="30"/> </mx:AddChild> @@ -57,15 +56,30 @@ <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:RemoteObject id="roundService" destination="roundService" fault="faultHandler(event)"> + <mx:method name="getNextModule" result="moduleResultHandler(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:Producer id="producer" destination="DataPush" acknowledge="ack(event)"/> <mx:Consumer id="consumer" destination="DataPush" message="messageHandler(event.message)" /> <mx:Script> <![CDATA[ + import custom.*; + import custom.questions.*; + import custom.questions.dayByDayDecisions.DayByDayDecisionsQuestionC; + import custom.questions.forecasting.ForecastingPeopleQuestionC; + import custom.questions.forecasting.ForecastingFishQuestionC; + import custom.questions.psychometric.PsychometricQuestionC; + import custom.questions.strategyDesign.StrategyDesignQuestionC; import actionscript.*; import actionscript.questions.*; - import custom.*; + import mx.containers.VBox; import mx.controls.Label; import mx.controls.Alert; import mx.collections.ArrayCollection; @@ -94,10 +108,7 @@ public var instructionsLoaded:Boolean = false; - private var shared:SharedObject; - private var flushMessage:String; - [Bindable] - public var Id : uint; + [Bindable] public var studentObject:Student; private function newLocation(maxCapacity:Number,growth:Number):Location { @@ -130,7 +141,59 @@ } private function sendBlockQuestions():void { + if(instructions == null) return; + var studentResponse:StudentResponse; + var pages:ArrayCollection = instructions.pageDisplay.pages; + + for(var i:int=0; i<pages.length; i++) + { + var curr:VBox = pages.getItemAt(i) as VBox + + for(var j:int=0; j<curr.numChildren; j++) + { + studentResponse = new StudentResponse(); +// studentResponse.student = Id; + + if(curr.getChildAt(j) is TextQuestionC) + { +// studentResponse.question = (curr.getChildAt(j) as TextQuestionC).description; + 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.response = (curr.getChildAt(j) as PsychometricQuestionC).slider1.getValue() + ""; + } + else if(curr.getChildAt(j) is CategoricalQuestionC) + { +// studentResponse.question = (curr.getChildAt(j) as CategoricalQuestionC).description; + 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.response = null; + } + else if(curr.getChildAt(j) is ForecastingPeopleQuestionC) + { +// studentResponse.question = (curr.getChildAt(j) as ForecastingPeopleQuestionC).description; + studentResponse.response = null; + } + else if(curr.getChildAt(j) is ForecastingFishQuestionC) + { +// studentResponse.question = (curr.getChildAt(j) as ForecastingFishQuestionC).description; + studentResponse.response = null; + } + else if(curr.getChildAt(j) is StrategyDesignQuestionC) + { +// studentResponse.question = (curr.getChildAt(j) as StrategyDesignQuestionC).description; + studentResponse.response = null; + } + } + } } private function reportBlockFinished():void { @@ -140,11 +203,11 @@ } private function getNextModule():void { - reportBlockFinished(); + if(instructions != null) reportBlockFinished(); currModule = null; currModuleNumber++; - moduleService.getModule(currModuleNumber); + roundService.getNextModule(currModuleNumber); } private function moduleResultHandler(event:ResultEvent):void { @@ -170,10 +233,6 @@ gotoInstructions(); } } - private function moduleFaultHandler(event:FaultEvent):void - { - Alert.show(event.fault.message + "\n" + event.fault.getStackTrace()); - } public function getLocation():void { @@ -186,20 +245,15 @@ locations.addItem(newLocation(20, 0.15)); locations.addItem(newLocation(30, 0.05)); } - private function locationFaultHandler(event:FaultEvent):void - { - - } - private function resultHandler(event:ResultEvent):void + private function studentResultHandler(event:ResultEvent):void { - Id = event.result as uint; -// Alert.show("Student id is " + Id ); + studentObject = event.result as Student; consumer.disconnect(); } private function faultHandler(event:FaultEvent):void { -// Alert.show("event fault is " + event.fault.faultDetail); + Alert.show(event.fault.message + "\n" + event.fault.getStackTrace()); } @@ -260,7 +314,7 @@ expiredContent.addChild(obj); var info:SocioDemographicPage = SocioDemographicPage(obj); - Id=ss.createStudent(info.getYear(), info.getSemester(), info.getGender(),info.getMajor()); + Id = startupService.createStudent(info.getYear(), info.getSemester(), info.getGender(),info.getMajor()); currentState = "wait"; btnBack.enabled = btnForward.enabled = btnReset.enabled = true; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |