virtualcommons-svn Mailing List for Virtual Commons Experiment Software (Page 71)
Status: Beta
Brought to you by:
alllee
You can subscribe to this list here.
2008 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
(1) |
Jul
(21) |
Aug
(31) |
Sep
(6) |
Oct
(15) |
Nov
(2) |
Dec
(9) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2009 |
Jan
(4) |
Feb
(6) |
Mar
(12) |
Apr
(52) |
May
(14) |
Jun
(19) |
Jul
(81) |
Aug
(115) |
Sep
(36) |
Oct
(88) |
Nov
(46) |
Dec
(58) |
2010 |
Jan
(52) |
Feb
(55) |
Mar
(48) |
Apr
(15) |
May
(5) |
Jun
(38) |
Jul
(27) |
Aug
(24) |
Sep
(28) |
Oct
(1) |
Nov
(2) |
Dec
(29) |
2011 |
Jan
(87) |
Feb
(39) |
Mar
(63) |
Apr
(42) |
May
(26) |
Jun
(53) |
Jul
(23) |
Aug
(43) |
Sep
(37) |
Oct
(25) |
Nov
(4) |
Dec
(7) |
2012 |
Jan
(73) |
Feb
(79) |
Mar
(62) |
Apr
(28) |
May
(12) |
Jun
(2) |
Jul
(9) |
Aug
(1) |
Sep
(8) |
Oct
|
Nov
(3) |
Dec
(3) |
2013 |
Jan
(8) |
Feb
(16) |
Mar
(38) |
Apr
(74) |
May
(62) |
Jun
(15) |
Jul
(49) |
Aug
(19) |
Sep
(9) |
Oct
|
Nov
|
Dec
|
2014 |
Jan
|
Feb
|
Mar
|
Apr
(2) |
May
(25) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: <kj...@us...> - 2009-07-21 06:37:28
|
Revision: 192 http://virtualcommons.svn.sourceforge.net/virtualcommons/?rev=192&view=rev Author: kjonas Date: 2009-07-21 06:37:26 +0000 (Tue, 21 Jul 2009) Log Message: ----------- Including compiled .swf Client Added Paths: ----------- mentalmodels/trunk/src/main/webapp/FisheryExperimentShell.html mentalmodels/trunk/src/main/webapp/FisheryExperimentShell.swf Property Changed: ---------------- mentalmodels/trunk/src/main/webapp/WEB-INF/ Added: mentalmodels/trunk/src/main/webapp/FisheryExperimentShell.html =================================================================== --- mentalmodels/trunk/src/main/webapp/FisheryExperimentShell.html (rev 0) +++ mentalmodels/trunk/src/main/webapp/FisheryExperimentShell.html 2009-07-21 06:37:26 UTC (rev 192) @@ -0,0 +1,121 @@ +<!-- saved from url=(0014)about:internet --> +<html lang="en"> + +<!-- +Smart developers always View Source. + +This application was built using Adobe Flex, an open source framework +for building rich Internet applications that get delivered via the +Flash Player or to desktops via Adobe AIR. + +Learn more about Flex at http://flex.org +// --> + +<head> +<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> + +<!-- BEGIN Browser History required section --> +<link rel="stylesheet" type="text/css" href="history/history.css" /> +<!-- END Browser History required section --> + +<title></title> +<script src="AC_OETags.js" language="javascript"></script> + +<!-- BEGIN Browser History required section --> +<script src="history/history.js" language="javascript"></script> +<!-- END Browser History required section --> + +<style> +body { margin: 0px; overflow:hidden } +</style> +<script language="JavaScript" type="text/javascript"> +<!-- +// ----------------------------------------------------------------------------- +// Globals +// Major version of Flash required +var requiredMajorVersion = 9; +// Minor version of Flash required +var requiredMinorVersion = 0; +// Minor version of Flash required +var requiredRevision = 124; +// ----------------------------------------------------------------------------- +// --> +</script> +</head> + +<body scroll="no"> +<script language="JavaScript" type="text/javascript"> +<!-- +// Version check for the Flash Player that has the ability to start Player Product Install (6.0r65) +var hasProductInstall = DetectFlashVer(6, 0, 65); + +// Version check based upon the values defined in globals +var hasRequestedVersion = DetectFlashVer(requiredMajorVersion, requiredMinorVersion, requiredRevision); + +if ( hasProductInstall && !hasRequestedVersion ) { + // DO NOT MODIFY THE FOLLOWING FOUR LINES + // Location visited after installation is complete if installation is required + var MMPlayerType = (isIE == true) ? "ActiveX" : "PlugIn"; + var MMredirectURL = window.location; + document.title = document.title.slice(0, 47) + " - Flash Player Installation"; + var MMdoctitle = document.title; + + AC_FL_RunContent( + "src", "playerProductInstall", + "FlashVars", "MMredirectURL="+MMredirectURL+'&MMplayerType='+MMPlayerType+'&MMdoctitle='+MMdoctitle+"", + "width", "100%", + "height", "100%", + "align", "middle", + "id", "FisheryExperimentShell", + "quality", "high", + "bgcolor", "#869ca7", + "name", "FisheryExperimentShell", + "allowScriptAccess","sameDomain", + "type", "application/x-shockwave-flash", + "pluginspage", "http://www.adobe.com/go/getflashplayer" + ); +} else if (hasRequestedVersion) { + // if we've detected an acceptable version + // embed the Flash Content SWF when all tests are passed + AC_FL_RunContent( + "src", "FisheryExperimentShell", + "width", "100%", + "height", "100%", + "align", "middle", + "id", "FisheryExperimentShell", + "quality", "high", + "bgcolor", "#869ca7", + "name", "FisheryExperimentShell", + "allowScriptAccess","sameDomain", + "type", "application/x-shockwave-flash", + "pluginspage", "http://www.adobe.com/go/getflashplayer" + ); + } else { // flash is too old or we can't detect the plugin + var alternateContent = 'Alternate HTML content should be placed here. ' + + 'This content requires the Adobe Flash Player. ' + + '<a href=http://www.adobe.com/go/getflash/>Get Flash</a>'; + document.write(alternateContent); // insert non-flash content + } +// --> +</script> +<noscript> + <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" + id="FisheryExperimentShell" width="100%" height="100%" + codebase="http://fpdownload.macromedia.com/get/flashplayer/current/swflash.cab"> + <param name="movie" value="FisheryExperimentShell.swf" /> + <param name="quality" value="high" /> + <param name="bgcolor" value="#869ca7" /> + <param name="allowScriptAccess" value="sameDomain" /> + <embed src="FisheryExperimentShell.swf" quality="high" bgcolor="#869ca7" + width="100%" height="100%" name="FisheryExperimentShell" align="middle" + play="true" + loop="false" + quality="high" + allowScriptAccess="sameDomain" + type="application/x-shockwave-flash" + pluginspage="http://www.adobe.com/go/getflashplayer"> + </embed> + </object> +</noscript> +</body> +</html> Added: mentalmodels/trunk/src/main/webapp/FisheryExperimentShell.swf =================================================================== (Binary files differ) Property changes on: mentalmodels/trunk/src/main/webapp/FisheryExperimentShell.swf ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Property changes on: mentalmodels/trunk/src/main/webapp/WEB-INF ___________________________________________________________________ Added: svn:ignore + hibernate.properties 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-21 00:47:56
|
Revision: 190 http://virtualcommons.svn.sourceforge.net/virtualcommons/?rev=190&view=rev Author: seematalele Date: 2009-07-21 00:47:53 +0000 (Tue, 21 Jul 2009) Log Message: ----------- Changed StartupService.java - This service will create student, send first module to the client. Created AnsweringService.java which will store the student response Created RoundService.java which will retrieve the next module using Module Service and send it to the client Above services need to test using Flex GUI. Created HibernateRoundConfigDao.java and HibernateStudentResponseDao.java Modified Paths: -------------- mentalmodels/trunk/src/main/java/edu/asu/commons/mme/service/StartupService.java mentalmodels/trunk/src/main/java/edu/asu/commons/mme/service/StudentService.java mentalmodels/trunk/src/main/webapp/WEB-INF/applicationContext.xml Added Paths: ----------- mentalmodels/trunk/src/main/java/edu/asu/commons/mme/dao/HibernateRoundConfigDao.java mentalmodels/trunk/src/main/java/edu/asu/commons/mme/dao/HibernateStudentResponseDao.java mentalmodels/trunk/src/main/java/edu/asu/commons/mme/service/AnsweringService.java mentalmodels/trunk/src/main/java/edu/asu/commons/mme/service/RoundService.java Added: mentalmodels/trunk/src/main/java/edu/asu/commons/mme/dao/HibernateRoundConfigDao.java =================================================================== --- mentalmodels/trunk/src/main/java/edu/asu/commons/mme/dao/HibernateRoundConfigDao.java (rev 0) +++ mentalmodels/trunk/src/main/java/edu/asu/commons/mme/dao/HibernateRoundConfigDao.java 2009-07-21 00:47:53 UTC (rev 190) @@ -0,0 +1,13 @@ +package edu.asu.commons.mme.dao; + +import edu.asu.commons.mme.entity.RoundConfig; + + +public class HibernateRoundConfigDao extends HibernateDao<RoundConfig> { + + public HibernateRoundConfigDao() + { + super(RoundConfig.class); + } + +} Added: mentalmodels/trunk/src/main/java/edu/asu/commons/mme/dao/HibernateStudentResponseDao.java =================================================================== --- mentalmodels/trunk/src/main/java/edu/asu/commons/mme/dao/HibernateStudentResponseDao.java (rev 0) +++ mentalmodels/trunk/src/main/java/edu/asu/commons/mme/dao/HibernateStudentResponseDao.java 2009-07-21 00:47:53 UTC (rev 190) @@ -0,0 +1,11 @@ +package edu.asu.commons.mme.dao; + +import edu.asu.commons.mme.entity.StudentResponse; + +public class HibernateStudentResponseDao extends HibernateDao<StudentResponse> { + public HibernateStudentResponseDao() + { + super(StudentResponse.class); + } + +} Added: mentalmodels/trunk/src/main/java/edu/asu/commons/mme/service/AnsweringService.java =================================================================== --- mentalmodels/trunk/src/main/java/edu/asu/commons/mme/service/AnsweringService.java (rev 0) +++ mentalmodels/trunk/src/main/java/edu/asu/commons/mme/service/AnsweringService.java 2009-07-21 00:47:53 UTC (rev 190) @@ -0,0 +1,38 @@ +package edu.asu.commons.mme.service; + +import java.util.List; + +import edu.asu.commons.mme.dao.HibernateStudentDao; +import edu.asu.commons.mme.dao.HibernateStudentResponseDao; +import edu.asu.commons.mme.entity.Student; +import edu.asu.commons.mme.entity.StudentResponse; + +public class AnsweringService extends Service.Base<StudentResponse, HibernateStudentResponseDao> { + + private HibernateStudentResponseDao studentResponseDao; + private HibernateStudentDao studentDao; + + + StudentResponse studentResponse; + Student student; + + public void saveQuestion(List<StudentResponse> studentResponses) + { + for(int i = 0; i < studentResponses.size(); i++ ) + { + StudentResponse clientStudentResponse = new StudentResponse(); + clientStudentResponse = (StudentResponse) studentResponses.get(i); + + studentResponse = new StudentResponse(); + studentResponse.setQuestion(clientStudentResponse.getQuestion()); + studentResponse.setResponse(clientStudentResponse.getResponse()); + studentResponse.setStudent(clientStudentResponse.getStudent()); + save(studentResponse); + } + } + + public void setStudentDao(HibernateStudentDao studentDao) { + this.studentDao = studentDao; + } + +} Added: mentalmodels/trunk/src/main/java/edu/asu/commons/mme/service/RoundService.java =================================================================== --- mentalmodels/trunk/src/main/java/edu/asu/commons/mme/service/RoundService.java (rev 0) +++ mentalmodels/trunk/src/main/java/edu/asu/commons/mme/service/RoundService.java 2009-07-21 00:47:53 UTC (rev 190) @@ -0,0 +1,20 @@ +package edu.asu.commons.mme.service; + +import edu.asu.commons.mme.dao.HibernateRoundConfigDao; +import edu.asu.commons.mme.entity.Module; +import edu.asu.commons.mme.entity.RoundConfig; + +public class RoundService extends Service.Base<RoundConfig, HibernateRoundConfigDao> { + + private ModuleService moduleService; + + public void setModuleService(ModuleService moduleService) { + this.moduleService = moduleService; + } + + public Module getNextModule(int sequenceNo) + { + return moduleService.getModule(sequenceNo); + } + +} Modified: mentalmodels/trunk/src/main/java/edu/asu/commons/mme/service/StartupService.java =================================================================== --- mentalmodels/trunk/src/main/java/edu/asu/commons/mme/service/StartupService.java 2009-07-20 19:34:32 UTC (rev 189) +++ mentalmodels/trunk/src/main/java/edu/asu/commons/mme/service/StartupService.java 2009-07-21 00:47:53 UTC (rev 190) @@ -4,9 +4,13 @@ import org.springframework.context.ApplicationListener; import org.springframework.context.event.ContextRefreshedEvent; +import edu.asu.commons.mme.entity.Module; + public class StartupService implements ApplicationListener { private QuestionCreatorService questionCreatorService; + private StudentService studentService; + private ModuleService moduleService; private volatile boolean alreadyInitialized; @@ -14,6 +18,7 @@ public void onApplicationEvent(ApplicationEvent event) { if (event instanceof ContextRefreshedEvent && ! alreadyInitialized) { //questionCreatorService.createQuestions(); + alreadyInitialized = true; } @@ -22,7 +27,24 @@ public void setQuestionCreatorService(QuestionCreatorService questionCreatorService) { this.questionCreatorService = questionCreatorService; } + + public void setStudentService(StudentService studentService) { + this.studentService = studentService; + } + + public Long createStudent(Integer birthYear, String semester,String gender,String major) { + + return studentService.createStudent(birthYear, semester, gender, major); + } - + public Module getFirstModule() + { + studentService.formGroups(); + return moduleService.getModule(1); + } + public void setModuleService(ModuleService moduleService) { + this.moduleService = moduleService; + } + } Modified: mentalmodels/trunk/src/main/java/edu/asu/commons/mme/service/StudentService.java =================================================================== --- mentalmodels/trunk/src/main/java/edu/asu/commons/mme/service/StudentService.java 2009-07-20 19:34:32 UTC (rev 189) +++ mentalmodels/trunk/src/main/java/edu/asu/commons/mme/service/StudentService.java 2009-07-21 00:47:53 UTC (rev 190) @@ -28,16 +28,39 @@ // System.out.println("Ethnicity " + semester); // System.out.println("Gender " + gender); // System.out.println("Major " + major); + Student student = new Student(); - student.setBirthYear(birthYear); student.setSemester(semester); student.setGender(Gender.valueOf(gender)); student.setMajor(major); save(student); getLogger().debug("Student id is: " + student.getId()); - students.add(student); + if(!checkStudentAlreadyExists(student)) + { + students.add(student); + } + else + return 0L; + return student.getId(); } + public boolean checkStudentAlreadyExists(Student student) + { + for(int i = 0; i < students.size(); i++) + { + if(students.get(i).equals(student)){ + return true; + } + } + return false; + } + + + public void formGroups() + { + //write an algorithm to form groups + } + } Modified: mentalmodels/trunk/src/main/webapp/WEB-INF/applicationContext.xml =================================================================== --- mentalmodels/trunk/src/main/webapp/WEB-INF/applicationContext.xml 2009-07-20 19:34:32 UTC (rev 189) +++ mentalmodels/trunk/src/main/webapp/WEB-INF/applicationContext.xml 2009-07-21 00:47:53 UTC (rev 190) @@ -34,6 +34,10 @@ <property name='sessionFactory' ref='sessionFactory'/> </bean> + <bean id='roundConfigDao' class='edu.asu.commons.mme.dao.HibernateRoundConfigDao'> + <property name='sessionFactory' ref='sessionFactory'/> + </bean> + <bean id='moduleDao' class="edu.asu.commons.mme.dao.HibernateModuleDao"> <property name='sessionFactory' ref='sessionFactory'/> </bean> @@ -60,9 +64,25 @@ <property name='sessionFactory' ref='sessionFactory'/> </bean> + <bean id='studentResponseDao' class='edu.asu.commons.mme.dao.HibernateStudentResponseDao'> + <property name='sessionFactory' ref='sessionFactory'/> + </bean> <!-- spring managed service layer --> +<bean id='roundService' class='edu.asu.commons.mme.service.RoundService'> + <property name='dao' ref='roundConfigDao'/> + <property name='moduleService' ref='moduleService'/> + + </bean> + + + <bean id='answeringService' class='edu.asu.commons.mme.service.AnsweringService'> + <property name='dao' ref='studentResponseDao'/> + <property name='studentDao' ref='studentDao'/> + + </bean> + <bean id='questionCreatorService' class='edu.asu.commons.mme.service.QuestionCreatorService'> <property name='dao' ref='questionDao'/> <property name='blockDao' ref='blockDao'/> @@ -74,6 +94,7 @@ <bean id='startupService' class='edu.asu.commons.mme.service.StartupService'> <property name='questionCreatorService' ref='questionCreatorService'/> + <property name='studentService' ref='studentService'/> </bean> <bean id='studentService' class='edu.asu.commons.mme.service.StudentService'> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: Kalin J. <kj...@as...> - 2009-07-20 20:31:32
|
I leave work today at 13:30pm (1.5hr) I have adjusted the psychometric questions to be wider, allowing for the labels to display without being split across lines. The program additionally forces the DayByDayDecisions and Strategy Design component to be completed, and will not let the user skip a block that has an incomplete DayByDayDecisions, or a StrategyDesign component that has not at least had one row added. On Mon, Jul 20, 2009 at 12:19 PM, Kalin Jonas <kj...@as...> wrote: > I return to work at 12:00 noon. > I realize that it is necessary to stop students from going on until the > day-by-bay section is finished, and will now implement this. I will force > the program to finish all 30 days before going on to the next Block, if > there are any DayByDayDecisions Questions in the block. > After this, I will begin working on the services to submit answers > > > On Mon, Jul 20, 2009 at 11:01 AM, Kalin Jonas <kj...@as...> wrote: > >> At 11:00am (1.75hr) I am leaving for lunch. >> I am still testing and editing code to better display the modules. much of >> it is working, but I need to check the display of Forecasting questions >> >> >> On Mon, Jul 20, 2009 at 9:42 AM, Kalin Jonas <kj...@as...> wrote: >> >>> Today I arrive at 9:15 to work. >>> Today I will be testing the updated code that Seema has written, and >>> checking to see if all the data is displaying appropriately. >>> I find it wise to include a component that tells the user what >>> module/block they are in, if only for testing purposes, as I'm not sure if I >>> am travelling between blocks or modules >>> Any remaining time that I am at work today will be spent interfacing with >>> the services to submit answers. >>> >> >> > |
From: <see...@us...> - 2009-07-20 19:34:35
|
Revision: 189 http://virtualcommons.svn.sourceforge.net/virtualcommons/?rev=189&view=rev Author: seematalele Date: 2009-07-20 19:34:32 +0000 (Mon, 20 Jul 2009) Log Message: ----------- Made following changes * Strategy design has no "Edit" button, should say "Design your strategy by clicking on 'New' and 'Delete'." * Strategy: delete the paragraph "When you are done, click on 'Next'. Your strategy will then be checked for some common or logical errors.", the design used should not allow the user to create errors in the first place. * "Explain the strategy in your own words" I'm not sure what html you are using, but it is very spaced out. if you are doing an unordered list, the code is <ul><li>item</li><li>item</li></ul> (do not use any additional tags like <p> unless you are trying to add paragraph separation within a single item of the list.) * A psychometric question on page "What else influenced your strategy design?" is missing the option "not at all" which causes it to have no labels. Modified Paths: -------------- mentalmodels/trunk/flex/src/InitialiseDatabase.mxml mentalmodels/trunk/src/main/db/init-mme.sql Modified: mentalmodels/trunk/flex/src/InitialiseDatabase.mxml =================================================================== --- mentalmodels/trunk/flex/src/InitialiseDatabase.mxml 2009-07-20 01:13:36 UTC (rev 188) +++ mentalmodels/trunk/flex/src/InitialiseDatabase.mxml 2009-07-20 19:34:32 UTC (rev 189) @@ -257,9 +257,16 @@ for(var k:int = 0; k < psychometricResult.choices.length; k++) { - choices = choices + psychometricResult.choices[k]; - choices = choices + "," - + if(choices == "") + { + Alert.show("choices is eqaul to : " + choices); + choices = psychometricResult.choices[k]; + } + else + { + choices = choices + psychometricResult.choices[k]; + } + choices = choices + "," } //Alert.show("choices are: " + choices); @@ -313,9 +320,17 @@ for(k = 0; k < options.choices.length; k++) { - choices = choices + options.choices[k]; - choices = choices + "," - + + if(choices == "") + { + choices = options.choices[k]; + } + else + { + choices = choices + options.choices[k]; + } + choices = choices + "," + } //Alert.show("choices are: " + choices); @@ -1177,8 +1192,13 @@ for(var k:int = 0; k < psychometricResult.choices.length; k++) { - choices = choices + psychometricResult.choices[k]; - choices = choices + "," + if(choices == "") + choices = psychometricResult.choices[k]; + + else + choices = choices + psychometricResult.choices[k]; + + choices = choices + "," } @@ -1237,8 +1257,13 @@ for(k = 0; k < options.choices.length; k++) { - choices = choices + options.choices[k]; - choices = choices + "," + if(choices == "") + choices = options.choices[k]; + + else + choices = choices + options.choices[k]; + + choices = choices + "," } newOptionNode.@choices = choices; } Modified: mentalmodels/trunk/src/main/db/init-mme.sql =================================================================== --- mentalmodels/trunk/src/main/db/init-mme.sql 2009-07-20 01:13:36 UTC (rev 188) +++ mentalmodels/trunk/src/main/db/init-mme.sql 2009-07-20 19:34:32 UTC (rev 189) @@ -161,8 +161,8 @@ PRIMARY KEY (`id`), KEY `FKC24ACFD63A5846C1` (`roundConfig_id`), KEY `FKC24ACFD6992B5A41` (`student_id`), - CONSTRAINT `FKC24ACFD6992B5A41` FOREIGN KEY (`student_id`) REFERENCES `student` (`id`), - CONSTRAINT `FKC24ACFD63A5846C1` FOREIGN KEY (`roundConfig_id`) REFERENCES `round_config` (`id`) + CONSTRAINT `FKC24ACFD63A5846C1` FOREIGN KEY (`roundConfig_id`) REFERENCES `round_config` (`id`), + CONSTRAINT `FKC24ACFD6992B5A41` FOREIGN KEY (`student_id`) REFERENCES `student` (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1; /*!40101 SET character_set_client = @saved_cs_client */; @@ -387,7 +387,7 @@ LOCK TABLES `psychometric_question_choices` WRITE; /*!40000 ALTER TABLE `psychometric_question_choices` DISABLE KEYS */; -INSERT INTO `psychometric_question_choices` VALUES (4,'nearly as important'),(4,'not important at all'),(7,'very important'),(7,'not important at all'),(9,'nearly as important'),(9,'not important at all'),(12,'nearly as important'),(12,'not important at all'),(14,'nearly as important'),(14,'not important at all'),(15,'I like my group very much'),(15,'neutral'),(15,'I do not like my group at all'),(16,'very important'),(16,'not important at all'),(17,'very important'),(17,'not important at all'),(18,'very important'),(18,'not important at all'),(19,'completely as a team'),(19,'neutral'),(19,'completely as competing players'),(20,'very much'),(20,'not at all'),(21,'very important'),(21,'not important at all'),(22,'very much'),(22,'not at all'),(23,'very much'),(23,'not at all'),(24,'very much'),(24,'not at all'),(25,'very much'),(25,'not at all'),(26,'very much'),(27,'very much'),(27,'not at all'),(28,'very much'),(28,'not at all'),(29,'very much'),(29,'not at all'),(30,'perfectly'),(30,'not at all'),(31,'much better'),(31,'same as me'),(31,'much worse'),(32,'very confident'),(32,'not at all confident'),(33,'totally'),(33,'not at all'),(34,'completely \x91safe\x92'),(34,'balancing risk and outcomes'),(34,'completely \x91risky\x92'); +INSERT INTO `psychometric_question_choices` VALUES (4,'nearly as important'),(4,'not important at all'),(7,'very important'),(7,'not important at all'),(9,'nearly as important'),(9,'not important at all'),(12,'nearly as important'),(12,'not important at all'),(14,'nearly as important'),(14,'not important at all'),(15,'I like my group very much'),(15,'neutral'),(15,'I do not like my group at all'),(16,'very important'),(16,'not important at all'),(17,'very important'),(17,'not important at all'),(18,'very important'),(18,'not important at all'),(19,'completely as a team'),(19,'neutral'),(19,'completely as competing players'),(20,'very much'),(20,'not at all'),(21,'very important'),(21,'not important at all'),(22,'very much'),(22,'not at all'),(23,'very much'),(23,'not at all'),(24,'very much'),(24,'not at all'),(25,'very much'),(25,'not at all'),(26,'very much'),(27,'very much'),(27,'not at all'),(28,'very much'),(28,'not at all'),(29,'very much'),(29,'not at all'),(30,'perfectly'),(30,'not at all'),(31,'much better'),(31,'same as me'),(31,'much worse'),(32,'very confident'),(32,'not at all confident'),(33,'totally'),(33,'not at all'),(34,'completely ‘safe’'),(34,'balancing risk and outcomes'),(34,'completely ‘risky’'),(26,'not at all'); /*!40000 ALTER TABLE `psychometric_question_choices` ENABLE KEYS */; UNLOCK TABLES; @@ -416,7 +416,7 @@ LOCK TABLES `question` WRITE; /*!40000 ALTER TABLE `question` DISABLE KEYS */; -INSERT INTO `question` VALUES (1,'Most important goal:',1,'categorical',10),(2,'Second most important goal:',2,'categorical',10),(3,'Third most important goal:',4,'categorical',10),(4,'Compared to the most important goal, this goal is',3,'psychometric',10),(6,'',1,'daybydaydecisions',6),(7,'An example of a scale would be',1,'psychometric',11),(8,'<p>\r<ul>\r<li>Why did you design the strategy the way you did? What did you consider and why do you think your strategy is an adequate solution?</li>\r<li>What actions do you expect from the other fishermen in your group? Why do you think, they might act this way?</li>\r<li>How do you think your strategy will work? Will the fish population grow or shrink in the different bays? What earnings do you expect?</li>\r</ul>\r</p>',1,'text',12),(9,'Compared to the most important goal, this goal is',5,'psychometric',10),(10,'<b>Most important goal:</b>',1,'categorical',13),(11,'<b>Second most important goal:</b>',2,'categorical',13),(12,'Compared to the most important goal, this goal is',3,'psychometric',13),(13,'<b>Third most important goal:</b>',4,'categorical',13),(14,'Compared to the most important goal, this goal is',5,'psychometric',13),(15,'Over all, how much do like your group (i.e. the other players)?',1,'psychometric',14),(16,'How important is it for you what the others think about you and your behavior (i.e. your reputation in the group)?',2,'psychometric',14),(17,'How important is it for you that the others can reach their goals (i.e. the outcomes are fair)?',3,'psychometric',14),(18,'What do you think, how important is it for the others that you can reach your goals (i.e. the outcomes are fair)?',4,'psychometric',14),(19,'Do you perceive the group as a team or as competing players?',5,'psychometric',14),(20,'How much do you trust the others in your group?',1,'psychometric',15),(21,'How important is it for you that the others in your group can and do trust you?',2,'psychometric',15),(22,'How much do you think your group trying to coordinate their actions to reach better outcomes for all?',3,'psychometric',15),(23,'How much are you trying to follow rules or agreements that emerged from the communication?',4,'psychometric',15),(24,'How much do you think the others are trying to follow rules or agreements that emerged from the communica-tion?',5,'psychometric',15),(25,'Do you feel a sense of \x91commitment\x92 to act in the way you specified in your strategy?',1,'psychometric',16),(26,'Would you feel any discomfort or tension if you would act differently than you specified in your strategy?',2,'psychometric',16),(27,'Do you feel any sort of \x91social pressure\x92 to act in the way you specified in your strategy?',3,'psychometric',16),(28,'Would you feel guilt or shame if you had acted differently than you specified in your strategy?',4,'psychometric',16),(29,'Are you afraid of some sort of \x91punishment\x92 if you had acted differently as specified in your strategy?',5,'psychometric',16),(30,'How well did you understand the dynamics of the fish population?',1,'psychometric',17),(31,'Did the others in your group understand the dynamics better or worse than you?',2,'psychometric',17),(32,'How confident are you in having developed a strategy that leads to \x91good\x92 outcomes regarding your goals?',3,'psychometric',17),(33,'How much does your strategy depend on how the others in the group will act to reach the desired outcomes?',4,'psychometric',17),(34,'Would you classify your strategy as \x91safe\x92 in the sense of having acceptable but suboptimal results for sure, or rather as \x91risky\x92 in the sense of having the optimal results if everything runs like expected or very poor results otherwise?',5,'psychometric',17),(35,'',1,'forecastingfishermen',18),(36,'',1,'forecastingfish',19),(37,'',1,'strategydesign',9),(38,'',1,'strategydesign',22),(39,'',1,'daybydaydecisions',24); +INSERT INTO `question` VALUES (1,'Most important goal:',1,'categorical',10),(2,'Second most important goal:',2,'categorical',10),(3,'Third most important goal:',4,'categorical',10),(4,'Compared to the most important goal, this goal is',3,'psychometric',10),(6,'',1,'daybydaydecisions',6),(7,'An example of a scale would be',1,'psychometric',11),(8,'<ul>\r<li>Why did you design the strategy the way you did? What did you consider and why do you think your strategy is an adequate solution?</li>\r<li>What actions do you expect from the other fishermen in your group? Why do you think, they might act this way?</li>\r<li>How do you think your strategy will work? Will the fish population grow or shrink in the different bays? What earnings do you expect?</li>\r</ul>\r',1,'text',12),(9,'Compared to the most important goal, this goal is',5,'psychometric',10),(10,'<b>Most important goal:</b>',1,'categorical',13),(11,'<b>Second most important goal:</b>',2,'categorical',13),(12,'Compared to the most important goal, this goal is',3,'psychometric',13),(13,'<b>Third most important goal:</b>',4,'categorical',13),(14,'Compared to the most important goal, this goal is',5,'psychometric',13),(15,'Over all, how much do like your group (i.e. the other players)?',1,'psychometric',14),(16,'How important is it for you what the others think about you and your behavior (i.e. your reputation in the group)?',2,'psychometric',14),(17,'How important is it for you that the others can reach their goals (i.e. the outcomes are fair)?',3,'psychometric',14),(18,'What do you think, how important is it for the others that you can reach your goals (i.e. the outcomes are fair)?',4,'psychometric',14),(19,'Do you perceive the group as a team or as competing players?',5,'psychometric',14),(20,'How much do you trust the others in your group?',1,'psychometric',15),(21,'How important is it for you that the others in your group can and do trust you?',2,'psychometric',15),(22,'How much do you think your group trying to coordinate their actions to reach better outcomes for all?',3,'psychometric',15),(23,'How much are you trying to follow rules or agreements that emerged from the communication?',4,'psychometric',15),(24,'How much do you think the others are trying to follow rules or agreements that emerged from the communica-tion?',5,'psychometric',15),(25,'Do you feel a sense of ‘commitment’ to act in the way you specified in your strategy?',1,'psychometric',16),(26,'Would you feel any discomfort or tension if you would act differently than you specified in your strategy?',2,'psychometric',16),(27,'Do you feel any sort of ‘social pressure’ to act in the way you specified in your strategy?',3,'psychometric',16),(28,'Would you feel guilt or shame if you had acted differently than you specified in your strategy?',4,'psychometric',16),(29,'Are you afraid of some sort of ‘punishment’ if you had acted differently as specified in your strategy?',5,'psychometric',16),(30,'How well did you understand the dynamics of the fish population?',1,'psychometric',17),(31,'Did the others in your group understand the dynamics better or worse than you?',2,'psychometric',17),(32,'How confident are you in having developed a strategy that leads to ‘good’ outcomes regarding your goals?',3,'psychometric',17),(33,'How much does your strategy depend on how the others in the group will act to reach the desired outcomes?',4,'psychometric',17),(34,'Would you classify your strategy as ‘safe’ in the sense of having acceptable but suboptimal results for sure, or rather as ‘risky’ in the sense of having the optimal results if everything runs like expected or very poor results otherwise?',5,'psychometric',17),(35,'',1,'forecastingfishermen',18),(36,'',1,'forecastingfish',19),(37,'',1,'strategydesign',9),(38,'',1,'strategydesign',22),(39,'',1,'daybydaydecisions',24); /*!40000 ALTER TABLE `question` ENABLE KEYS */; UNLOCK TABLES; @@ -446,7 +446,7 @@ LOCK TABLES `question_group` WRITE; /*!40000 ALTER TABLE `question_group` DISABLE KEYS */; -INSERT INTO `question_group` VALUES (1,'In this experiment you will design a strategy to fish in an abstract fishing ground together with three other persons. As we are mainly interested in the reasons <i>why</i> you choose a certain strategy, we will ask you a number of questions. For the same reason, there are no correct or wrong strategies and no correct or wrong answers. However, since for each pound of fish you get during the experiment you will receive $1.00 US, you might be interested in finding a strategy that fits your goals well. For this, you will need to understand the dynamics of the (simulated) fish population and anticipate well the behavior of the other persons of your group.',30,'<b>Welcome to the E-Fishery Experiment</b>',1,1),(2,'<p>The experiment will run as follows:</p> <ul> <li><b>Introduction</b>: We will explain the interface and how the dynamics of the fish population are modeled. We will also ask you some questions about you and you will have the opportunity to make your decisions on how to fish on a (simulated) day-by-day basis to get a feeling for the dynamics of the fish population. </li> <li><b>Strategy design 1</b>: You will design a fishing strategy that will be simulated together with the strategies of the other persons in your group, and we ask you a larger amount of questions to understand your decisions and to help you reflect on those decisions. </li> <li><b>Fishing and evaluation 1</b>: Besides simulating the strategies you will decide on how to fish on a (simulated) day-by-day basis. Then, we will ask you some questions on your evaluation of the results. </li> <li><b>Communication</b>:You will have the opportunity to chat with the other persons in your group. After the chat we will ask some questions to asses your evaluation of the communication. </li> <li><b>Strategy design, fishing and evaluation 2</b>: The strategy design, fishing and evaluation are repeated as described above. </li> <li><b>Finishing the experiment</b>: The experiment closes with some final questions and more information on the experiment, and you will have the opportunity to give a feedback if you wish to do so. </li> </ul> <p> In the <b>information bar above the main window</b> you can see which part of the experiment you are in, your progress and how you are doing with the time. </p>',30,'<b>Experimental procedure</b>',2,1),(3,'<p>The <b>information window "Fishing Ground"</b> gives you an overview that will be explained here.</p> <p> Imagine you are living on an island and your only income is from a species of fish that only survives in the shallow bays formed by the island. The fish can leave crowed bays and move to less crowded bays, but they cannot survive in the ocean. Nor can new fish arrive from the ocean. </p> <p> The fish population grows at a constant rate. Thus, the more fish are in a bay the faster the population grows. However, the population a bay can sustain is limited and fish leave crowed bays to find less crowded bays. The more crowded a bay, the more fish leave and the less fish enter the bay (the movement is directly proportional to the percentage to which a bay is filled up). The number of fish leaving the bay is proportional to the rate of growth, and the number of fish entering the bay is also proportional to the amount of fish leaving the three bays (i.e. fish in the ocean). </p> <p> The equations of these dynamics are given in the information windows. It is, however, not necessary to know them for designing a strategy. For this, you only have to <b>understand the following five principles</b>: </p> <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 is <b>no fish</b> in any of the bays, there will be never any fish again.</li> <li>If there are both <b>crowded and empty</b> bays, a lot of fish move from the crowded to the empty bays.</li> </ul> ',120,'<b>How the dynamics of the fish population are modeled</b>',3,1),(4,'<p>The three bays are different in size and characteristics leading to different growth rates and capacities (i.e. the maximal amount of fish the bay can sustain). At the start of the simulation each bay is half filled.</p> <table> <thead> <th></th><th>Bay 1</th><th>Bay 2</th><th>Bay 3</th> </thead> <tbody> <tr> <td>Capacity:</td><td>10 lb</td><td>20 lb</td><td>30 lb</td> </tr> <tr> <td>Starts with:</td><td>5 lb</td><td>10 lb</td><td>15 lb</td> </tr> <tr> <td>Growth rate:</td><td>50% per day</td><td>15% per day</td><td>5% per day</td> </tr> </tbody> </table> <p> <b>How much fish</b> you take out in a day is <b>directly proportional with the extent that the bay is filled up with fish</b>. Your fishing gear allows you to harvest a maximum of 5 lbs. Thus, if the bay is completely filled up you get 5 lb of fish. If the bay is half filled, you get 2.5 lb of fish. If the bay is filled up only to 20 % you will get 1 lb, etc. The fish population is diminished by the same amount. If several persons fish the same bay and together would get more fish than the bay holds, then all the fish in the bay are distributed equally among these fishermen. </p> <p>However, you can <b>stay in the harbor</b> instead of fishing. This way, you do not get anything and the fish population is not diminished. </p> <p> Your task is to design a strategy of how to fish this fishing ground for 30 days together with three other persons (thus, with you the group compromises 4 persons). You will define the number of days that you stay in each bay or in the harbor. Please note that this is not an exam! We do not expect you to find the mathematically optimal solution to this problem. We want to know how you come up with a solution that sufficiently fulfills your goals. As long as we can understand why you choose a certain strategy you can come up with whatever you like. </p> ',120,'<b>Differences of bays and effects of fishing</b>',4,1),(5,'<p>Before designing the strategy, you have the opportunity to make your decisions on a day-by-day basis for the simulation. You will interact with the actual model of the fishing ground together with the other persons of your group. Thus, the problems and possibilities you will experience in this warm-up are relevant for the design of your strategy. </p> <p> The <b>interface</b> you will encounter on the next page has the following elements: <ul> <li>Information on the day of the simulation</li> <li>Buttons for your decision. If you want to fish in Bay 1, for example, click on Button "Bay 1". </li> <li>Time remaining. You have 10 seconds for each decision. If you do not press any button within these 10 seconds then you will stay in the harbor for this day. However, you can change your decision within these 10 seconds (i.e. if you clicked on "Bay 1" after 4 seconds and after another 4 seconds on "Bay 3", you will go to Bay 3). </li> <li>Table of past results. Your previous locations from past days are highlighted. The table shows you how much you fished and who else was in the same location as you. You do not have any information of locations where you not have been. </li> ',60,'<b>A warm-up</b>',5,1),(6,'',345,'<b>Day-by-day-decisions</b>',6,1),(7,'<p>In what we refer to as a \'strategy\' you predefine your decisions of where to go each day of the simulation.\r Al-though only 30 days will be simulated, your strategy should represent your decisions for an indefinite period. Therefore you define a <b>set of decisions that will be repeated</b> until the end of the simulation. The set can contain as many decisions as you want but try to use as few as possible. Remember: Often simple strategies are more effective!</p> <p>It might be that you want to base your set of repeated decisions on another state of the fish population. In this case you can define a set of not repeated decisions that are applied at the beginning of the simulation. For example, you might first stay in the harbor to let the fish population increase or first fish all the bays to reduce the fish population before you start the repeated sequence of decisions.</p> <p>In this strategy you define how many days you stay at a certain location and to which other location you will move on.\r If, for example, you define to repeat the sequence \"2 days in harbor - 3 days in Bay 1 - 2 days in Bay 2\" you will not fish for two days, then fish in Bay 1 for three days, then fish in Bay 2 for two days, then not fish for two days, then fish in Bay 1 for three days, etc.</p> ',480,'<b>Designing your Strategy</b>',1,2),(8,'<p>Your strategy is mainly based on the number of days you stay at a certain location. However, things might run differently than you expected and you might wish to leave a bay earlier than the days you specified because you get too few fish out of that bay. For doing so you can specify a threshold of income. If you fish less then this threshold, the next day you will not fish this bay anymore but move on to the next location specified in your strategy.</p> <p>Note: Thresholds refer to the quantity of fish you get during one day fishing in a bay and not, for example, to the quantity of fish in the bay, fish fished by others, sum of fish already fished, etc.</p> <p>The final option you have is to stop repeating your strategy and stay in the harbor for some days. This op-tion can be used to prevent the total destruction of the fish population. For this you define a threshold and a number of days. If during one repetition of your decision set you never fished the amount defined by the threshold, then you stay in the harbor for the specified number of days before you start the next repetition.</p> <p>Note: Intentionally we do not allow designing \'intelligent\' strategies that search for solutions during the game. You have to think about what would be the best solution for you and express it with the options explained above.</p> ',90,'<b>Some special features of the strategy design</b>',2,2),(9,'<p>Design your strategy by clicking on <b>\'New\'</b>, <b>\'Edit\'</b>, and <b>\'Delete\'</b>. You have to specify at least one repeated decision! If you are not sure about the meaning of the concepts used, refer to the information window \'Help for strategy design\'.</p>\r<p>When you are done, click on <b>\'Next\'</b>. Your strategy will then be checked for some common or logical errors. </p>',480,'<b>Design your strategy</b>',3,2),(10,'<p>Please specify three goals that most influenced the design of your strategy. You can select from 18 different goals grouped in three categories (foci). </p><p>First select the focus of the goal (earnings, fish population or the other fishermen). Based on this selection, the list on the right hand sight will be filled and you can select one of these goals. For the second and third most important goal, also state, how much less important they are in relation to the most important goal.</p><p> The information you write into these fields will be available the next time you edit your strategy.</p>',30,'<b>What goals did you follow when designing your strategy?</b>',3,3),(11,'<p>We will ask you a number of questions on the strategy you just designed. This will help us to better understand how you came up with your strategy and it might help you reflect on certain aspects to improve your strategy.</p>\r<p>Besides <b>large fields</b> to write text and <b>small fields</b> to write numbers, you will encounter drop-down lists for selecting predefined values and scales. </p>\r<p>To give an answer on a scale, click on the location between the labels that comes closest to your opinion. By clicking on the scale, a slider appears that marks the value you selected. You can change the value by clicking on another position on the scale. By clicking on the reset button, the sliders of all scales on a page are removed and you can start selecting values again.</p>\r<p>Please try to answer all questions even if you are not sure. We are not testing your abilities but rather want to understand how you came up with your strategy.</p>\r',30,'<b>Introduction to questionnaire</b>',1,3),(12,'<p>Please explain your strategy with a few sentences. Particularly consider the following aspects:</p>',300,'<b>Explain the strategy in your own words</b>',2,3),(13,'<p>Specify the three goals that you think most influenced the design of the strategy of the other fishermen in your group. You can select from 18 different goals grouped in three categories (foci).</p>\r<p>First select the focus of the goal (earnings, fish population or the other fishermen). Based on this selection, the list on the right hand sight will be filled and you can select one of these goals. For the second and third most important goal, also state, how much less important they are in relation to the most important goal</p>\r',30,'<b>What goals do you think the others follow?</b>',4,3),(14,'',30,'<b>How do you perceive your group?</b>',5,3),(15,'',30,'<b>How much do you count on others and how much can they count on you?</b>',6,3),(16,'',30,'<b>What else influenced your strategy design?</b>',7,3),(17,'',60,'<b>How confident are you in reaching the outcomes you are expecting?</b>',8,3),(18,'<p>Fill in the following table your expectations of the others\x92 actions (i.e. the number of fishermen in each bay) for the first 15 days. Please note that we ask only for the expectations of where the others will go. </p>',180,'<b>What are you expecting the others will do?</b>',9,3),(19,'<p>Please enter in the table below your expectations of how the fish population develops within the first six days. Note that by clicking on \x93Update\x94 the earnings and fish remaining in the bays is calculated, using your expecta-tions of the other\x92s actions and your strategy. Thus, you only have to think about how the fish population changes from one day to the next due to growth and movement of the fish. These estimations can be really rough. We do not expect you do perform detailed calculations.</p>\r<b>Note: You can only change the entries of one day at a time. To calculate the values and activate the next day for entries click on \x93Update\x94. You cannot return to previous days!</b>\r',180,'<b>What are you expecting how the fish population will develop?</b>',10,3),(20,'By clicking on \x93Accept\x94 you will leave this part of the questionnaire and return to the strategy design. <b>You can-not return to this or previous pages!</b> However, important information for the design of your strategy will be available in information windows.',30,'<b>Leaving questionnaire on your strategy</b>',11,3),(21,'<p>The previous questions may have lead to some reflections on your strategy and you may wish to change some elements of it. Among the information windows you will find your previous strategy, your goals and your fore-cast.</p>\r<p>The time for editing your strategy depends on how fast you finished the questionnaire. For the next simulation we have to synchronize the group again. If you have been rather fast, you can think now more deeply about your strategy. If you are rather behind the time suggestion, you have to make your changes quickly.</p>\r<p>The interface for designing your strategy will not be explained again. If you are not sure about some elements, please refer to the information window \x93Help on strategy design\x94.</p>\r',30,'<b>Edit your strategy</b>',1,4),(22,'<p>Design your strategy by clicking on <b>\'New\'</b>, <b>\'Edit\'</b>, and <b>\'Delete\'</b>. You have to specify at least one repeated decision! If you are not sure about the meaning of the concepts used, refer to the information window \'Help for strategy design\'.</p>\r<p>When you are done, click on <b>\'Next\'</b>. Your strategy will then be checked for some common or logical errors. </p>',240,'<b>Design your strategy</b>',2,4),(23,'<p>Before we present the results of your strategy, we would like to see again how you make your decisions day-by-day. On the next page you will find the same interface as you already used to decide on how to fish the modeled fishing grounds.</p>',15,'<b>Applying your strategy in day-by-day decisions</b>',1,5),(24,'',345,'<b>Day-by-day-decisions</b>',2,5),(25,'<p>We will now present you the results of your strategy. By clicking on \x93Accept\x94 you cannot return to this or any previous page, but the results of your day-by-day decisions (and also of your strategy) will be available in an information window.</p>',15,'<b>Leaving day-bay-day decisions</b>',3,5); +INSERT INTO `question_group` VALUES (1,'In this experiment you will design a strategy to fish in an abstract fishing ground together with three other persons. As we are mainly interested in the reasons <i>why</i> you choose a certain strategy, we will ask you a number of questions. For the same reason, there are no correct or wrong strategies and no correct or wrong answers. However, since for each pound of fish you get during the experiment you will receive $1.00 US, you might be interested in finding a strategy that fits your goals well. For this, you will need to understand the dynamics of the (simulated) fish population and anticipate well the behavior of the other persons of your group.',30,'<b>Welcome to the E-Fishery Experiment</b>',1,1),(2,'<p>The experiment will run as follows:</p> <ul> <li><b>Introduction</b>: We will explain the interface and how the dynamics of the fish population are modeled. We will also ask you some questions about you and you will have the opportunity to make your decisions on how to fish on a (simulated) day-by-day basis to get a feeling for the dynamics of the fish population. </li> <li><b>Strategy design 1</b>: You will design a fishing strategy that will be simulated together with the strategies of the other persons in your group, and we ask you a larger amount of questions to understand your decisions and to help you reflect on those decisions. </li> <li><b>Fishing and evaluation 1</b>: Besides simulating the strategies you will decide on how to fish on a (simulated) day-by-day basis. Then, we will ask you some questions on your evaluation of the results. </li> <li><b>Communication</b>:You will have the opportunity to chat with the other persons in your group. After the chat we will ask some questions to asses your evaluation of the communication. </li> <li><b>Strategy design, fishing and evaluation 2</b>: The strategy design, fishing and evaluation are repeated as described above. </li> <li><b>Finishing the experiment</b>: The experiment closes with some final questions and more information on the experiment, and you will have the opportunity to give a feedback if you wish to do so. </li> </ul> <p> In the <b>information bar above the main window</b> you can see which part of the experiment you are in, your progress and how you are doing with the time. </p>',30,'<b>Experimental procedure</b>',2,1),(3,'<p>The <b>information window "Fishing Ground"</b> gives you an overview that will be explained here.</p> <p> Imagine you are living on an island and your only income is from a species of fish that only survives in the shallow bays formed by the island. The fish can leave crowed bays and move to less crowded bays, but they cannot survive in the ocean. Nor can new fish arrive from the ocean. </p> <p> The fish population grows at a constant rate. Thus, the more fish are in a bay the faster the population grows. However, the population a bay can sustain is limited and fish leave crowed bays to find less crowded bays. The more crowded a bay, the more fish leave and the less fish enter the bay (the movement is directly proportional to the percentage to which a bay is filled up). The number of fish leaving the bay is proportional to the rate of growth, and the number of fish entering the bay is also proportional to the amount of fish leaving the three bays (i.e. fish in the ocean). </p> <p> The equations of these dynamics are given in the information windows. It is, however, not necessary to know them for designing a strategy. For this, you only have to <b>understand the following five principles</b>: </p> <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 is <b>no fish</b> in any of the bays, there will be never any fish again.</li> <li>If there are both <b>crowded and empty</b> bays, a lot of fish move from the crowded to the empty bays.</li> </ul> ',120,'<b>How the dynamics of the fish population are modeled</b>',3,1),(4,'<p>The three bays are different in size and characteristics leading to different growth rates and capacities (i.e. the maximal amount of fish the bay can sustain). At the start of the simulation each bay is half filled.</p> <table> <thead> <th></th><th>Bay 1</th><th>Bay 2</th><th>Bay 3</th> </thead> <tbody> <tr> <td>Capacity:</td><td>10 lb</td><td>20 lb</td><td>30 lb</td> </tr> <tr> <td>Starts with:</td><td>5 lb</td><td>10 lb</td><td>15 lb</td> </tr> <tr> <td>Growth rate:</td><td>50% per day</td><td>15% per day</td><td>5% per day</td> </tr> </tbody> </table> <p> <b>How much fish</b> you take out in a day is <b>directly proportional with the extent that the bay is filled up with fish</b>. Your fishing gear allows you to harvest a maximum of 5 lbs. Thus, if the bay is completely filled up you get 5 lb of fish. If the bay is half filled, you get 2.5 lb of fish. If the bay is filled up only to 20 % you will get 1 lb, etc. The fish population is diminished by the same amount. If several persons fish the same bay and together would get more fish than the bay holds, then all the fish in the bay are distributed equally among these fishermen. </p> <p>However, you can <b>stay in the harbor</b> instead of fishing. This way, you do not get anything and the fish population is not diminished. </p> <p> Your task is to design a strategy of how to fish this fishing ground for 30 days together with three other persons (thus, with you the group compromises 4 persons). You will define the number of days that you stay in each bay or in the harbor. Please note that this is not an exam! We do not expect you to find the mathematically optimal solution to this problem. We want to know how you come up with a solution that sufficiently fulfills your goals. As long as we can understand why you choose a certain strategy you can come up with whatever you like. </p> ',120,'<b>Differences of bays and effects of fishing</b>',4,1),(5,'<p>Before designing the strategy, you have the opportunity to make your decisions on a day-by-day basis for the simulation. You will interact with the actual model of the fishing ground together with the other persons of your group. Thus, the problems and possibilities you will experience in this warm-up are relevant for the design of your strategy. </p> <p> The <b>interface</b> you will encounter on the next page has the following elements: <ul> <li>Information on the day of the simulation</li> <li>Buttons for your decision. If you want to fish in Bay 1, for example, click on Button "Bay 1". </li> <li>Time remaining. You have 10 seconds for each decision. If you do not press any button within these 10 seconds then you will stay in the harbor for this day. However, you can change your decision within these 10 seconds (i.e. if you clicked on "Bay 1" after 4 seconds and after another 4 seconds on "Bay 3", you will go to Bay 3). </li> <li>Table of past results. Your previous locations from past days are highlighted. The table shows you how much you fished and who else was in the same location as you. You do not have any information of locations where you not have been. </li> ',60,'<b>A warm-up</b>',5,1),(6,'',345,'<b>Day-by-day-decisions</b>',6,1),(7,'<p>In what we refer to as a \'strategy\' you predefine your decisions of where to go each day of the simulation.\r Al-though only 30 days will be simulated, your strategy should represent your decisions for an indefinite period. Therefore you define a <b>set of decisions that will be repeated</b> until the end of the simulation. The set can contain as many decisions as you want but try to use as few as possible. Remember: Often simple strategies are more effective!</p> <p>It might be that you want to base your set of repeated decisions on another state of the fish population. In this case you can define a set of not repeated decisions that are applied at the beginning of the simulation. For example, you might first stay in the harbor to let the fish population increase or first fish all the bays to reduce the fish population before you start the repeated sequence of decisions.</p> <p>In this strategy you define how many days you stay at a certain location and to which other location you will move on.\r If, for example, you define to repeat the sequence \"2 days in harbor - 3 days in Bay 1 - 2 days in Bay 2\" you will not fish for two days, then fish in Bay 1 for three days, then fish in Bay 2 for two days, then not fish for two days, then fish in Bay 1 for three days, etc.</p> ',480,'<b>Designing your Strategy</b>',1,2),(8,'<p>Your strategy is mainly based on the number of days you stay at a certain location. However, things might run differently than you expected and you might wish to leave a bay earlier than the days you specified because you get too few fish out of that bay. For doing so you can specify a threshold of income. If you fish less then this threshold, the next day you will not fish this bay anymore but move on to the next location specified in your strategy.</p> <p>Note: Thresholds refer to the quantity of fish you get during one day fishing in a bay and not, for example, to the quantity of fish in the bay, fish fished by others, sum of fish already fished, etc.</p> <p>The final option you have is to stop repeating your strategy and stay in the harbor for some days. This op-tion can be used to prevent the total destruction of the fish population. For this you define a threshold and a number of days. If during one repetition of your decision set you never fished the amount defined by the threshold, then you stay in the harbor for the specified number of days before you start the next repetition.</p> <p>Note: Intentionally we do not allow designing \'intelligent\' strategies that search for solutions during the game. You have to think about what would be the best solution for you and express it with the options explained above.</p> ',90,'<b>Some special features of the strategy design</b>',2,2),(9,'<p>Design your strategy by clicking on <b>\'New\'</b> and <b>\'Delete\'</b>. You have to specify at least one repeated decision! If you are not sure about the meaning of the concepts used, refer to the information window \'Help for strategy design\'. </br>\rWhen you are done, click on <b>\'Next\'</b> </p>',480,'<b>Design your strategy</b>',3,2),(10,'<p>Please specify three goals that most influenced the design of your strategy. You can select from 18 different goals grouped in three categories (foci). </p><p>First select the focus of the goal (earnings, fish population or the other fishermen). Based on this selection, the list on the right hand sight will be filled and you can select one of these goals. For the second and third most important goal, also state, how much less important they are in relation to the most important goal.</p><p> The information you write into these fields will be available the next time you edit your strategy.</p>',30,'<b>What goals did you follow when designing your strategy?</b>',3,3),(11,'<p>We will ask you a number of questions on the strategy you just designed. This will help us to better understand how you came up with your strategy and it might help you reflect on certain aspects to improve your strategy.</p>\r<p>Besides <b>large fields</b> to write text and <b>small fields</b> to write numbers, you will encounter drop-down lists for selecting predefined values and scales. </p>\r<p>To give an answer on a scale, click on the location between the labels that comes closest to your opinion. By clicking on the scale, a slider appears that marks the value you selected. You can change the value by clicking on another position on the scale. By clicking on the reset button, the sliders of all scales on a page are removed and you can start selecting values again.</p>\r<p>Please try to answer all questions even if you are not sure. We are not testing your abilities but rather want to understand how you came up with your strategy.</p>\r',30,'<b>Introduction to questionnaire</b>',1,3),(12,'<p>Please explain your strategy with a few sentences. Particularly consider the following aspects:</p>',300,'<b>Explain the strategy in your own words</b>',2,3),(13,'<p>Specify the three goals that you think most influenced the design of the strategy of the other fishermen in your group. You can select from 18 different goals grouped in three categories (foci).</p>\r<p>First select the focus of the goal (earnings, fish population or the other fishermen). Based on this selection, the list on the right hand sight will be filled and you can select one of these goals. For the second and third most important goal, also state, how much less important they are in relation to the most important goal</p>\r',30,'<b>What goals do you think the others follow?</b>',4,3),(14,'',30,'<b>How do you perceive your group?</b>',5,3),(15,'',30,'<b>How much do you count on others and how much can they count on you?</b>',6,3),(16,'',30,'<b>What else influenced your strategy design?</b>',7,3),(17,'',60,'<b>How confident are you in reaching the outcomes you are expecting?</b>',8,3),(18,'<p>Fill in the following table your expectations of the others’ actions (i.e. the number of fishermen in each bay) for the first 15 days. Please note that we ask only for the expectations of where the others will go. </p>',180,'<b>What are you expecting the others will do?</b>',9,3),(19,'<p>Please enter in the table below your expectations of how the fish population develops within the first six days. Note that by clicking on “Update” the earnings and fish remaining in the bays is calculated, using your expecta-tions of the other’s actions and your strategy. Thus, you only have to think about how the fish population changes from one day to the next due to growth and movement of the fish. These estimations can be really rough. We do not expect you do perform detailed calculations.</p>\r<b>Note: You can only change the entries of one day at a time. To calculate the values and activate the next day for entries click on “Update”. You cannot return to previous days!</b>\r',180,'<b>What are you expecting how the fish population will develop?</b>',10,3),(20,'By clicking on “Accept” you will leave this part of the questionnaire and return to the strategy design. <b>You can-not return to this or previous pages!</b> However, important information for the design of your strategy will be available in information windows.',30,'<b>Leaving questionnaire on your strategy</b>',11,3),(21,'<p>The previous questions may have lead to some reflections on your strategy and you may wish to change some elements of it. Among the information windows you will find your previous strategy, your goals and your fore-cast.</p>\r<p>The time for editing your strategy depends on how fast you finished the questionnaire. For the next simulation we have to synchronize the group again. If you have been rather fast, you can think now more deeply about your strategy. If you are rather behind the time suggestion, you have to make your changes quickly.</p>\r<p>The interface for designing your strategy will not be explained again. If you are not sure about some elements, please refer to the information window “Help on strategy design”.</p>\r',30,'<b>Edit your strategy</b>',1,4),(22,'<p>Design your strategy by clicking on <b>\'New\'</b> and <b>\'Delete\'</b>. You have to specify at least one repeated decision! If you are not sure about the meaning of the concepts used, refer to the information window \'Help for strategy design\'. </br>\rWhen you are done, click on <b>\'Next\'</b> </p>',240,'<b>Design your strategy</b>',2,4),(23,'<p>Before we present the results of your strategy, we would like to see again how you make your decisions day-by-day. On the next page you will find the same interface as you already used to decide on how to fish the modeled fishing grounds.</p>',15,'<b>Applying your strategy in day-by-day decisions</b>',1,5),(24,'',345,'<b>Day-by-day-decisions</b>',2,5),(25,'<p>We will now present you the results of your strategy. By clicking on “Accept” you cannot return to this or any previous page, but the results of your day-by-day decisions (and also of your strategy) will be available in an information window.</p>',15,'<b>Leaving day-bay-day decisions</b>',3,5); /*!40000 ALTER TABLE `question_group` ENABLE KEYS */; UNLOCK TABLES; @@ -522,8 +522,8 @@ PRIMARY KEY (`round_config_id`,`questionGroups_id`), KEY `FKAC0583924E7815A0` (`questionGroups_id`), KEY `FKAC058392634CAB1E` (`round_config_id`), - CONSTRAINT `FKAC058392634CAB1E` FOREIGN KEY (`round_config_id`) REFERENCES `round_config` (`id`), - CONSTRAINT `FKAC0583924E7815A0` FOREIGN KEY (`questionGroups_id`) REFERENCES `question_group` (`id`) + CONSTRAINT `FKAC0583924E7815A0` FOREIGN KEY (`questionGroups_id`) REFERENCES `question_group` (`id`), + CONSTRAINT `FKAC058392634CAB1E` FOREIGN KEY (`round_config_id`) REFERENCES `round_config` (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1; /*!40101 SET character_set_client = @saved_cs_client */; @@ -583,8 +583,8 @@ PRIMARY KEY (`id`), KEY `FK7B993B8846861732` (`dayOutput_id`), KEY `FK7B993B888374539C` (`strategy_id`), - CONSTRAINT `FK7B993B888374539C` FOREIGN KEY (`strategy_id`) REFERENCES `student_strategy` (`id`), - CONSTRAINT `FK7B993B8846861732` FOREIGN KEY (`dayOutput_id`) REFERENCES `student_strategy` (`id`) + CONSTRAINT `FK7B993B8846861732` FOREIGN KEY (`dayOutput_id`) REFERENCES `student_strategy` (`id`), + CONSTRAINT `FK7B993B888374539C` FOREIGN KEY (`strategy_id`) REFERENCES `student_strategy` (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1; /*!40101 SET character_set_client = @saved_cs_client */; @@ -642,8 +642,8 @@ PRIMARY KEY (`id`), KEY `FK49C432973A5846C1` (`roundconfig_id`), KEY `FK49C43297992B5A41` (`student_id`), - CONSTRAINT `FK49C43297992B5A41` FOREIGN KEY (`student_id`) REFERENCES `student` (`id`), - CONSTRAINT `FK49C432973A5846C1` FOREIGN KEY (`roundconfig_id`) REFERENCES `round_config` (`id`) + CONSTRAINT `FK49C432973A5846C1` FOREIGN KEY (`roundconfig_id`) REFERENCES `round_config` (`id`), + CONSTRAINT `FK49C43297992B5A41` FOREIGN KEY (`student_id`) REFERENCES `student` (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1; /*!40101 SET character_set_client = @saved_cs_client */; @@ -704,8 +704,8 @@ PRIMARY KEY (`id`), KEY `FKFBDC4543A5846C1` (`roundConfig_id`), KEY `FKFBDC454992B5A41` (`student_id`), - CONSTRAINT `FKFBDC454992B5A41` FOREIGN KEY (`student_id`) REFERENCES `student` (`id`), - CONSTRAINT `FKFBDC4543A5846C1` FOREIGN KEY (`roundConfig_id`) REFERENCES `round_config` (`id`) + CONSTRAINT `FKFBDC4543A5846C1` FOREIGN KEY (`roundConfig_id`) REFERENCES `round_config` (`id`), + CONSTRAINT `FKFBDC454992B5A41` FOREIGN KEY (`student_id`) REFERENCES `student` (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1; /*!40101 SET character_set_client = @saved_cs_client */; @@ -727,4 +727,4 @@ /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2009-07-20 0:55:33 +-- Dump completed on 2009-07-20 19:31:38 This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: Kalin J. <kj...@as...> - 2009-07-20 19:19:07
|
I return to work at 12:00 noon. I realize that it is necessary to stop students from going on until the day-by-bay section is finished, and will now implement this. I will force the program to finish all 30 days before going on to the next Block, if there are any DayByDayDecisions Questions in the block. After this, I will begin working on the services to submit answers On Mon, Jul 20, 2009 at 11:01 AM, Kalin Jonas <kj...@as...> wrote: > At 11:00am (1.75hr) I am leaving for lunch. > I am still testing and editing code to better display the modules. much of > it is working, but I need to check the display of Forecasting questions > > > On Mon, Jul 20, 2009 at 9:42 AM, Kalin Jonas <kj...@as...> wrote: > >> Today I arrive at 9:15 to work. >> Today I will be testing the updated code that Seema has written, and >> checking to see if all the data is displaying appropriately. >> I find it wise to include a component that tells the user what >> module/block they are in, if only for testing purposes, as I'm not sure if I >> am travelling between blocks or modules >> Any remaining time that I am at work today will be spent interfacing with >> the services to submit answers. >> > > |
From: Kalin J. <kj...@as...> - 2009-07-20 18:01:09
|
At 11:00am (1.75hr) I am leaving for lunch. I am still testing and editing code to better display the modules. much of it is working, but I need to check the display of Forecasting questions On Mon, Jul 20, 2009 at 9:42 AM, Kalin Jonas <kj...@as...> wrote: > Today I arrive at 9:15 to work. > Today I will be testing the updated code that Seema has written, and > checking to see if all the data is displaying appropriately. > I find it wise to include a component that tells the user what module/block > they are in, if only for testing purposes, as I'm not sure if I am > travelling between blocks or modules > Any remaining time that I am at work today will be spent interfacing with > the services to submit answers. > |
From: Kalin J. <kj...@as...> - 2009-07-20 16:42:24
|
Today I arrive at 9:15 to work. Today I will be testing the updated code that Seema has written, and checking to see if all the data is displaying appropriately. I find it wise to include a component that tells the user what module/block they are in, if only for testing purposes, as I'm not sure if I am travelling between blocks or modules Any remaining time that I am at work today will be spent interfacing with the services to submit answers. |
From: seema t. <see...@gm...> - 2009-07-20 01:41:28
|
forgot to mention one more change and that is- Before enetring or updating the database, sequence number is checked, if sequence number exists, then error message is thrown. On Sun, Jul 19, 2009 at 6:13 PM, <see...@us...> wrote: > Revision: 188 > http://virtualcommons.svn.sourceforge.net/virtualcommons/?rev=188&view=revAuthor: seematalele Date: 2009-07-20 01:13:36 +0000 (Mon, 20 Jul 2009) Log > Message: ----------- Created HibernateCategoricalQuestionDao.java and > HibernatePsychometricQuestionDao.java. Changed the code of > InitialiseDatabase.mxml - Adding Module,Block,QuestionGroup and Question is > working fine. - Updating Module,Block,QuestionGroup is working fine. Need to > test updating Questions in InitialiseDatabase.mxml. (But I am not going to > test it until it really needs because it is taking some time) The init-mme > file contains the database which initialized till Module 2A - Block 2-4 > Commented the createQuestions in QuestionCreatorService.java and > StartupService.java Modified Paths: -------------- > mentalmodels/trunk/flex/src/InitialiseDatabase.mxml > mentalmodels/trunk/flex/src/actionscript/Block.as > mentalmodels/trunk/flex/src/actionscript/Module.as > mentalmodels/trunk/flex/src/actionscript/QuestionGroup.as > mentalmodels/trunk/flex/src/actionscript/questions/Question.as > mentalmodels/trunk/flex/src/custom/db/Block.mxml > mentalmodels/trunk/flex/src/custom/db/Module.mxml > mentalmodels/trunk/flex/src/custom/db/Question.mxml > mentalmodels/trunk/flex/src/custom/db/QuestionGroup.mxml > mentalmodels/trunk/flex/src/custom/db/questions/Categorical.mxml > mentalmodels/trunk/flex/src/custom/db/questions/CategoricalRelative.mxml > mentalmodels/trunk/flex/src/custom/db/questions/CategoricalSimple.mxml > mentalmodels/trunk/flex/src/custom/db/questions/Psychometric.mxml > mentalmodels/trunk/src/main/db/init-mme.sql > mentalmodels/trunk/src/main/java/edu/asu/commons/mme/entity/QuestionGroup.java > mentalmodels/trunk/src/main/java/edu/asu/commons/mme/entity/RoundConfig.java > mentalmodels/trunk/src/main/java/edu/asu/commons/mme/service/QuestionCreatorService.java > mentalmodels/trunk/src/main/java/edu/asu/commons/mme/service/StartupService.java > mentalmodels/trunk/src/main/webapp/WEB-INF/applicationContext.xml Added > Paths: ----------- > mentalmodels/trunk/src/main/java/edu/asu/commons/mme/dao/HibernateCategoricalQuestionDao.java > mentalmodels/trunk/src/main/java/edu/asu/commons/mme/dao/HibernatePsychometricQuestionDao.java > Modified: mentalmodels/trunk/flex/src/InitialiseDatabase.mxml > =================================================================== --- > mentalmodels/trunk/flex/src/InitialiseDatabase.mxml 2009-07-17 23:21:35 UTC > (rev 187) +++ mentalmodels/trunk/flex/src/InitialiseDatabase.mxml 2009-07-20 > 01:13:36 UTC (rev 188) @@ -5,11 +5,7 @@ - + /**** + * Sample exmaple of > Survey Questions structure + * - + - + - - - + @@ -60,56 +49,53 @@ - ; - > /*[Bindable] + + * + */ + +/* id field of module, block and questiongroup > and questions should come from database, +so when module info is transfered > to the server, it should return the id for that module */ + + + [Bindable] > private var survey:XML = - - ;*/ + + + ; - - /*[Bindable] - private var > questions:XML = - - - - - + /** + * Sample example of categorical question > structure + * + * + + - - - - + + + + + - - - - - ; */ - - - [Bindable] + * > + * ***/ + + [Bindable] private var categoricalQuestions:XML = - - - - - - - > - ; + /** + * Sample example of psychometric question structure + * + **/ + > [Bindable] private var psychometricQuestions:XML = - - - - + ; @@ -122,6 > +108,8 @@ public var tempQuestion:ArrayCollection = new ArrayCollection(); + > + private function init():void { roQuestionCreator.initializeData(); @@ > -148,7 +136,7 @@ survey.appendChild(newModuleNode); //if any blocks, add > into the module - if(module.blocks != null) + if(module.blocks != null) { > for(var blockCounter:int = 0; blockCounter < module.blocks.length; > blockCounter++) { @@ -181,9 +169,9 @@ } } - } + } + } } - } } } @@ -230,7 > +218,10 @@ newNode.@header = questionGroup.header; newNode.@description = > questionGroup.description; newNode.@sequenceNo = questionGroup.sequenceNo; > - newNode.@id = questionGroup.id; + newNode.@hours = > questionGroup.getHours(); + newNode.@min = questionGroup.getMinutes(); + > newNode.@sec = questionGroup.getSeconds(); + newNode.@id = > questionGroup.id; return newNode; @@ -240,33 +231,40 @@ { var newQNode:XML = > ; newQNode.setLocalName("question"); + var choices:String=""; > if(question.type.toLowerCase() == "psychometric") { var > psychometricResult:actionscript.questions.Psychometric = > actionscript.questions.Psychometric(question); - Alert.show("Id is: " + > psychometricResult.id); + /*Alert.show("Id is: " + psychometricResult.id); > Alert.show("Question is: " + psychometricResult.question); Alert.show("Type > is: " + psychometricResult.type); - Alert.show("SeQNo is: " + > psychometricResult.sequenceNo); + Alert.show("SeQNo is: " + > psychometricResult.sequenceNo);*/ var newPNode:XML = ; > newPNode.setLocalName("psychometric"); newPNode.@id = > psychometricResult.id; newPNode.@scale = psychometricResult.scale; - > newPNode.@noOfInterval = psychometricResult.maxSliderValue; + > newPNode.@maxSliderValue = psychometricResult.maxSliderValue; > newQNode.@sequenceNo = psychometricResult.sequenceNo; newQNode.@title = > psychometricResult.question; newQNode.@type = psychometricResult.type; > newQNode.@id = psychometricResult.id; - - for(var j:int = 0; j < > psychometricResult.choices.length; j++) - { - var str:String = "choice"; - > str = str + j; - newPNode.@str = psychometricResult.choices[j]; - } - + > choices = ""; + if(psychometricResult.choices != null) + { + + for(var k:int > = 0; k < psychometricResult.choices.length; k++) + { + choices = choices + > psychometricResult.choices[k]; + choices = choices + "," + + } + > //Alert.show("choices are: " + choices); + + newPNode.@choices = choices; > + } psychometricQuestions.appendChild(newPNode); } @@ -286,44 +284,60 @@ > currentState = "none"; btnsaveQuestion.enabled = false; }*/ + //false means > it is simple type, otherwise it is relative type + var flagType:Boolean = > false; var newCNode:XML = ; newCNode.setLocalName("categorical"); > newCNode.@id = categoricalResult.id; > categoricalQuestions.appendChild(newCNode); - - for(var i:int = 0; i < > categoricalResult.categoricalOptions.length ; i++) - { - var > options:actionscript.questions.CategoricalOption = new > actionscript.questions.CategoricalOption(); - options = > actionscript.questions.CategoricalOption(categoricalResult.categoricalOptions.getItemAt(i)); > - var newOptionNode:XML = ; - newOptionNode.setLocalName("option"); - > newOptionNode.@name = options.optionKey; - if(options.choices.length <= 0) > - { - newCNode.@type = "simple"; - - } - else - { - newCNode.@type = > "relative"; - for(var k:int = 0; k < options.choices.length; k++) + + > if(categoricalResult.categoricalOptions != null) + { + + for(var i:int = 0; > i < categoricalResult.categoricalOptions.length ; i++) + { + var > options:actionscript.questions.CategoricalOption = new > actionscript.questions.CategoricalOption(); + options = > actionscript.questions.CategoricalOption(categoricalResult.categoricalOptions.getItemAt(i)); > + var newOptionNode:XML = ; + newOptionNode.setLocalName("option"); + > newOptionNode.@name = options.optionKey; + if(options.choices.length == 0) > { - var choice:String = "choice"; - choice = choice + k; - > newOptionNode.@choice = options.choices[k]; + flagType = false } - } - - > /*var module:XMLList = survey.module.(@id == tempmodule.id); - if( > module.length() > 0 ) - { - module[0].appendChild(newBlockNode); - }*/ - > newCNode.appendChild(newOptionNode); - } - - + else + { + flagType = true; + > choices=""; + + for(k = 0; k < options.choices.length; k++) + { + choices = > choices + options.choices[k]; + choices = choices + "," + + } + > //Alert.show("choices are: " + choices); + + newOptionNode.@choices = > choices; + } + if(flagType) + newCNode.@type = "relative"; + else + > newCNode.@type = "simple"; + newCNode.appendChild(newOptionNode); + } + } > + + } + //if question type is strategy, day by day decision, forecasting > fish, forecasting fishermen + else + { + newQNode.@sequenceNo = > question.sequenceNo; + newQNode.@title = question.question; + > newQNode.@type = question.type; + newQNode.@id = question.id; + } return > newQNode; @@ -348,7 +362,7 @@ return node.@header; else if( > node.localName() == "question" ) - return node.@title; + return node.@type; > else return null; @@ -419,16 +433,43 @@ { var title:String = > moduleInfo.getName(); var seqNo:int = int(moduleInfo.getSequenceNo()); - > if(moduleInfo.getId() == 0) - { - roQuestionCreator.saveModule(seqNo, title, > getDuration(moduleInfo.getHours(),moduleInfo.getMinutes(),moduleInfo.getSeconds())); > + + /* check first Id if the module exists, + if no, then check if sequence > number already exists for other module, + if no then create module otherwise > throw error */ + + var checkSeqNoModule:XMLList = survey.module.(@sequenceNo > == moduleInfo.getSequenceNo()); + + /* check if new module needs to be > created, if yes, check if the sequence number is already exists + if "No" > then only save into the database */ + + if(moduleInfo.getId() == 0) + { + > if(checkSeqNoModule.length() > 0) + { + Alert.show("Sequence number : " + > seqNo + " already exists!"); + } + else + > roQuestionCreator.saveModule(seqNo, title, > getDuration(moduleInfo.getHours(),moduleInfo.getMinutes(),moduleInfo.getSeconds())); > + } + + else + { + //Alert.show("length : " + > checkSeqNoModule.length().toString()); + //check if the sequence number > exists, do not update the module + + if(checkSeqNoModule.length() > 1) + { + > Alert.show("Sequence number : " + seqNo + " already exists!"); + } + else + > roQuestionCreator.updateModule(moduleInfo.getId(),seqNo, title, > getDuration(moduleInfo.getHours(),moduleInfo.getMinutes(),moduleInfo.getSeconds())); > + } - else - roQuestionCreator.updateModule(moduleInfo.getId(),seqNo, title, > getDuration(moduleInfo.getHours(),moduleInfo.getMinutes(),moduleInfo.getSeconds())); > - currentState = "none"; + + currentState = "none"; btnsaveModule.enabled = > false; - //pnlComponent.removeChildAt(1); - } + } } else @@ -447,35 +488,35 > @@ public function resultSaveModuleHandler(event:ResultEvent):void { var > module:actionscript.Module = actionscript.Module(event.result as Object); - > Alert.show("Id is: " + module.id); - var newModuleNode:XML = ; - > newModuleNode.setLocalName("module"); - newModuleNode.@title= > module.description; - newModuleNode.@sequenceNo = module.sequenceNo; - > newModuleNode.@hours = module.getHours(); - newModuleNode.@min = > module.getMinutes(); - newModuleNode.@sec = module.getSeconds(); - > newModuleNode.@id = module.id; - survey.appendChild(newModuleNode); - > if(surveyData == null) + + if(module == null) { - surveyData= new > XMLListCollection(survey.module); + Alert.show("Error in creating module!"); > } + else + { + //Alert.show("Id is: " + module.id); + var > newModuleNode:XML = createModuleNode(module); + > survey.appendChild(newModuleNode); + } - - } //when module is updated, the > result will come to resultUpdateModuleHandler public function > resultUpdateModuleHandler(event:ResultEvent):void { var > module:actionscript.Module = actionscript.Module(event.result as Object); - > var moduleXML:XMLList = survey.module.(@id == module.id); - > moduleXML.@title = module.description; - moduleXML.@sequenceNo = > module.sequenceNo; - moduleXML.@hours = module.getHours(); - > moduleXML.@min = module.getMinutes(); - moduleXML.@sec = > module.getSeconds(); + if(module != null) + { + var moduleXML:XMLList = > survey.module.(@id == module.id); + moduleXML.@title = module.description; > + moduleXML.@sequenceNo = module.sequenceNo; + moduleXML.@hours = > module.getHours(); + moduleXML.@min = module.getMinutes(); + > moduleXML.@sec = module.getSeconds(); + } + else + Alert.show("Error in > updating module!"); } @@ -535,25 +576,42 @@ var parentNode:XML = > tree.getParentItem(tree.selectedItem) as XML; node = parentNode; } - var > module:XMLList = survey.module.(@title == node.@title); - > //Alert.show("Module length is : " + module.length()); + var module:XMLList > = survey.module.(@id == node.@id); + if( module.length() > 0 ) { - // > Alert.show("Block id is : " + blockInfo.getId()); - if(blockInfo.getId() == > 0) - { - > roQuestionCreator.saveBlock(int(blockInfo.getSequenceNo()),blockInfo.getName(),getDuration(blockInfo.getHours(),blockInfo.getMinutes(),blockInfo.getSeconds()),int(module[0].@id)); > - } - else - { - roQuestionCreator.updateBlock(blockInfo.getId(), > int(blockInfo.getSequenceNo()),blockInfo.getName(),getDuration(blockInfo.getHours(),blockInfo.getMinutes(),blockInfo.getSeconds()),int(module[0].@id)); > + + //check the sequence number first, if sequence number already exists > throw an error, otherwise create block + var checkSeqNoBlock:XMLList = > module.block.(@sequenceNo == blockInfo.getSequenceNo()); + > if(blockInfo.getId() == 0) + { + if(checkSeqNoBlock.length() > 0) + { + > Alert.show("Sequence number " + blockInfo.getSequenceNo() + " already > exists!"); + } + else + { + > roQuestionCreator.saveBlock(int(blockInfo.getSequenceNo()),blockInfo.getName(),getDuration(blockInfo.getHours(),blockInfo.getMinutes(),blockInfo.getSeconds()),int(module[0].@id)); > + } + } + else + { + //Alert.show("length : " + > checkSeqNoBlock.length().toString()); + //check if the sequence number > exists, do not update the module + if(checkSeqNoBlock.length() > 1) + { + > Alert.show("Sequence number : " + blockInfo.getSequenceNo() + " already > exists!"); + } + else + roQuestionCreator.updateBlock(blockInfo.getId(), > int(blockInfo.getSequenceNo()),blockInfo.getName(),getDuration(blockInfo.getHours(),blockInfo.getMinutes(),blockInfo.getSeconds()),int(module[0].@id)); > + } + + currentState = "none"; + btnsaveBlock.enabled = false; } - > currentState = "none"; - btnsaveBlock.enabled = false; - // > pnlComponent.removeChildAt(1); - } + } } - } + else { Alert.show("Please > fill the form correctly"); @@ -570,14 +628,7 @@ if(block != null) { - var > newBlockNode:XML = ; - newBlockNode.setLocalName("block"); - > newBlockNode.@name = block.description; - newBlockNode.@sequenceNo = > block.sequenceNo; - newBlockNode.@hours = block.getHours(); - > newBlockNode.@min = block.getMinutes(); - newBlockNode.@sec = > block.getSeconds(); - newBlockNode.@id = block.id; + var newBlockNode:XML > = createBlockNode(block); var tempmodule:actionscript.Module = block.module; > var module:XMLList = survey.module.(@id == tempmodule.id); @@ -585,7 > +636,9 @@ { module[0].appendChild(newBlockNode); } - } + } + else + > Alert.show("Error in creating Block!"); } @@ -593,19 +646,24 @@ public > function resultUpdateBlockHandler(event:ResultEvent):void { var > block:actionscript.Block = actionscript.Block(event.result as Object); - - > var tempmodule:actionscript.Module = block.module; - - var blockXML:XMLList > = survey.module.block.(@id == block.id); - - blockXML.@name = > block.description; - blockXML.@sequenceNo = block.sequenceNo; - > blockXML.@hours = block.getHours(); - blockXML.@min = block.getMinutes(); > - blockXML.@sec = block.getSeconds(); + if(block != null) + { + var > tempmodule:actionscript.Module = block.module; + var blockXML:XMLList = > survey.module.block.(@id == block.id); + if(blockXML.length() > 0) + { + > blockXML[0].@name = block.description; + blockXML[0].@sequenceNo = > block.sequenceNo; + blockXML[0].@hours = block.getHours(); + > blockXML[0].@min = block.getMinutes(); + blockXML[0].@sec = > block.getSeconds(); + } + } + else + Alert.show("Error in creating Block!"); > } - //Block functioanlity Stop + //Block functioanlity End //QuestionGroup > functionality Start @@ -629,7 +687,7 @@ var selectedNode:XML = > tree.selectedItem as XML; var obj:DisplayObject = > pnlComponent.getChildAt(1); var questionGroupInfo:custom.db.QuestionGroup = > custom.db.QuestionGroup(obj); - Alert.show("Question Group Id is: " + > questionGroupInfo.getId()); + if(tree.selectedItem == null) { > Alert.show("Please select the block from tree to which Question Group should > be added."); @@ -656,12 +714,18 @@ { //find out the parent module var > parentModule:XML = tree.getParentItem(tree.selectedItem) as XML; - - + var > isQuestionGroupFormValid:Boolean = questionGroupInfo.validateForm(event); > if(isQuestionGroupFormValid) { + var durationflag:Boolean = > this.isDurationValid(questionGroupInfo.getHours(),questionGroupInfo.getMinutes(),questionGroupInfo.getSeconds()); > + if(durationflag) + { + Alert.show("Please enter the valid duration for the > given module."); + } + else + { var node:XML; /** * Check if the selected > node is block, if it is new Question Group needs to be created. @@ -677,22 > +741,46 @@ node = parentNode; } var block:XMLList = survey.module.block.(@id > == node.@id); - //Alert.show("block id is : " + block[0].@id + "length is: > " + block.length()); + //Alert.show("block id is : " + block.@id + "length > is: " + block.length().toString()); if( block.length() > 0 ) { - > if(questionGroupInfo.getId() == 0) - { - > roQuestionCreator.saveQuestionGroup(int(questionGroupInfo.getSequenceNo()),questionGroupInfo.getHeader(),questionGroupInfo.getDescription(),int(block[0].@id)); > - } - else - { - > roQuestionCreator.updateQuestionGroup(int(questionGroupInfo.getSequenceNo()),questionGroupInfo.getHeader(),questionGroupInfo.getDescription(),int(block[0].@id),questionGroup.getId()); > + //check the sequence number first, if sequence number already exists throw > an error, otherwise create module + var checkSeqNoQuestionGroup:XMLList = > block.questiongroup.(@sequenceNo == questionGroupInfo.getSequenceNo()); + > //Alert.show("length : " + checkSeqNoQuestionGroup.length().toString()); + > if(questionGroupInfo.getId() == 0) + { + if(checkSeqNoQuestionGroup.length() > > 0) + { + Alert.show("Sequence number " + questionGroupInfo.getSequenceNo() > + " already exists!"); + } + else + { + > roQuestionCreator.saveQuestionGroup(int(questionGroupInfo.getSequenceNo()),questionGroupInfo.getHeader(),questionGroupInfo.getDescription(),getDuration(questionGroupInfo.getHours(),questionGroupInfo.getMinutes(),questionGroupInfo.getSeconds()),int(block[0].@id)); > + } + } + else + { + //Alert.show("length : " + > checkSeqNoQuestionGroup.length().toString()); + //check if the sequence > number exists, do not update the module + > if(checkSeqNoQuestionGroup.length() > 1) + { + Alert.show("Sequence number : > " + questionGroupInfo.getSequenceNo() + " already exists!"); + } + else + > roQuestionCreator.updateQuestionGroup(int(questionGroupInfo.getSequenceNo()),questionGroupInfo.getHeader(),questionGroupInfo.getDescription(),getDuration(questionGroupInfo.getHours(),questionGroupInfo.getMinutes(),questionGroupInfo.getSeconds()),int(block[0].@id),questionGroup.getId()); > + } - currentState = "none"; - btnsaveQuestionGroup.enabled = false; - > //pnlComponent.removeChildAt(1); - } - } + currentState = "none"; + > btnsaveQuestionGroup.enabled = false; + } + + } + } + else + { + > Alert.show("Please fill the form correctly"); + return; + } } } } @@ -702,23 > +790,23 @@ public function > resultSaveQuestionGroupHandler(event:ResultEvent):void { var > questionGroup:actionscript.QuestionGroup = > actionscript.QuestionGroup(event.result as Object); - Alert.show("Id is: " + > questionGroup.id); - var newNode:XML = ; - > newNode.setLocalName("questiongroup"); - newNode.@header = > questionGroup.header; - newNode.@description = questionGroup.description; > - newNode.@sequenceNo = questionGroup.sequenceNo; - newNode.@id = > questionGroup.id; - - var block:actionscript.Block = questionGroup.block; + > + if(questionGroup != null) + { + var newQuestionGroupNode:XML = > createQuestionGroupNode(questionGroup); + + var block:actionscript.Block = > questionGroup.block; - var blockXML:XMLList =survey.module.block.(@id == > block.id); + var blockXML:XMLList =survey.module.block.(@id == block.id); > - if( blockXML.length() > 0 ) - { - blockXML[0].appendChild(newNode); + if( > blockXML.length() > 0 ) + { + blockXML[0].appendChild(newQuestionGroupNode); > - } + } + } + else + Alert.show("Error in creating QuestionGroup!"); } @@ > -726,17 +814,34 @@ public function > resultUpdateQuestionGroupHandler(event:ResultEvent):void { var > questionGroup:actionscript.QuestionGroup = > actionscript.QuestionGroup(event.result as Object); - Alert.show("Id is: " + > questionGroup.id); - var newNode:XML = ; - > newNode.setLocalName("questiongroup"); - newNode.@header = > questionGroup.header; - newNode.@description = questionGroup.description; > - newNode.@sequenceNo = questionGroup.sequenceNo; - var > block:actionscript.Block = questionGroup.block; - - } + + //Alert.show("Id > is: " + questionGroup.id); + if(questionGroup != null) + { + var newNode:XML > = ; + newNode.setLocalName("questiongroup"); + var questionGroupXML:XMLList > = survey.module.block.questiongroup.(@id == questionGroup.id); + > //Alert.show("Length is: " + questionGroupXML.length()); + > if(questionGroupXML.length() > 0) + { + // Alert.show("header is :" + > questionGroup.header); + // Alert.show("questionGroup description is :" + > questionGroup.description); + //Alert.show("questionGroup.sequenceNo is :" + > questionGroup.sequenceNo); + + questionGroupXML[0].@header = > questionGroup.header; + questionGroupXML[0].@description = > questionGroup.description; + questionGroupXML[0].@sequenceNo = > questionGroup.sequenceNo; + questionGroupXML[0].@hours = > questionGroup.getHours(); + questionGroupXML[0].@min = > questionGroup.getMinutes(); + questionGroupXML[0].@sec = > questionGroup.getSeconds(); + + } + } + else + Alert.show("Error in updating > QuestionGroup!"); + } - //QuestionGroup functionality Stop + //QuestionGroup > functionality End //Question functionality Start @@ -755,26 +860,43 @@ > private function QuestionHandler(event:Event):void { - > if(question.cmbType.selectedItem.toString().toLowerCase() == "psychometric") > + if(question.cmbType.selectedItem.data.toString().toLowerCase() == > "psychometric") + { currentState = "psychometric"; - else > if(question.cmbType.selectedItem.toString().toLowerCase() == "categorical") > + psychometric.reset(); + } + else > if(question.cmbType.selectedItem.data.toString().toLowerCase() == > "categorical") + { currentState = "categorical"; + categorical.reset(); + } > + else + { + currentState = "question"; + + } } private function > CategoricalTypeHandler(event:Event):void { > if(categorical.cmbType.selectedItem.toString().toLowerCase() == "relative") > + { currentState = "relative"; + categoricalRelative.reset(); + } else > if(categorical.cmbType.selectedItem.toString().toLowerCase() == "simple") + > { currentState = "simple"; + categoricalSimple.reset(); + } + } - - private > function saveQuestion(event:Event):void { - var node:XML = tree.selectedItem > as XML; + var selectedNode:XML = tree.selectedItem as XML; + var node:XML; > if(tree.selectedItem == null) { @@ -783,109 +905,207 @@ } else { - - > //if(tree.getParentItem(tree.selectedItem) == null) - if(node.localName() != > "questiongroup") + if(selectedNode.localName().toString().toLowerCase() == > "module" || selectedNode.localName().toString().toLowerCase() == "block") { > - Alert.show("You can add Question to QuestionGroup only."); + > Alert.show("You can not add Question to Module or Block."); return; } else { > - //find out the parent module - var parentModule:XML = > tree.getParentItem(tree.selectedItem) as XML; + > if(selectedNode.localName().toString().toLowerCase() == "questiongroup") + { > + node = selectedNode; + } + else > if(selectedNode.localName().toString().toLowerCase() == "question") + { + > var parentNode:XML = tree.getParentItem(tree.selectedItem) as XML; + node = > parentNode; + } + + var obj:DisplayObject = pnlComponent.getChildAt(1); var > questionInfo:custom.db.Question = custom.db.Question(obj); - var > isQuestionGroupFormValid:Boolean = questionInfo.validateForm(event); + var > isQuestionFormValid:Boolean = questionInfo.validateForm(event); - > if(isQuestionGroupFormValid) + if(isQuestionFormValid) { - - if(currentState > == "psychometric") - { - var psychobj:DisplayObject = > pnlComponent.getChildAt(2); - - var > compPsychometric:custom.db.questions.Psychometric = > custom.db.questions.Psychometric(psychobj); - - var > asPsychometric:actionscript.questions.Psychometric = new > actionscript.questions.Psychometric(); - asPsychometric.scale = > compPsychometric.getScale(); - asPsychometric.maxSliderValue = > int(compPsychometric.getNumberofIntervals()); - asPsychometric.choices = > compPsychometric.getChoices(); - asPsychometric.question = > questionInfo.getQuestion(); - asPsychometric.sequenceNo = > int(questionInfo.getSequenceNo()); - asPsychometric.type = > questionInfo.getType(); - - Alert.show("Psychometric Object :"); - > Alert.show("Question: " + asPsychometric.question); - Alert.show("SeQ No: " > + asPsychometric.sequenceNo); - Alert.show("Type : " + asPsychometric.type); > - roQuestionCreator.saveQuestion(asPsychometric,1); - } - else > if(currentState == "relative") - { - var catobj:DisplayObject = > pnlComponent.getChildAt(3); - var compCategorical:CategoricalRelative = > CategoricalRelative(catobj); - var > categoricalQuestion:actionscript.questions.Categorical = new > actionscript.questions.Categorical(); - - var dict:Dictionary = new > Dictionary(); - dict = compCategorical.getDictionary(); - for (var > key:Object in dict) - { - var > Options:actionscript.questions.CategoricalOption = new > actionscript.questions.CategoricalOption(); - Options.optionKey = > key.toString(); - Options.choices = dict[key]; - > categoricalQuestion.categoricalOptions.addItem(Options); - } - > categoricalQuestion.type = questionInfo.getType(); - > categoricalQuestion.question = questionInfo.getQuestion(); - > categoricalQuestion.sequenceNo = int(questionInfo.getSequenceNo()); - > for(var i:int = 0; i < categoricalQuestion.categoricalOptions.length ; i++) > - { - var testoption:actionscript.questions.CategoricalOption = new > actionscript.questions.CategoricalOption(); - testoption = > actionscript.questions.CategoricalOption(categoricalQuestion.categoricalOptions.getItemAt(i)); > - trace(testoption.optionKey); - trace(testoption.choices); - } - > roQuestionCreator.saveQuestion(categoricalQuestion,1); - - } - else > if(currentState == "simple") - { - Alert.show("simple state"); - var > catSimpleobj:DisplayObject = pnlComponent.getChildAt(3); - var > compCategoricalSimple:custom.db.questions.CategoricalSimple = > custom.db.questions.CategoricalSimple(catSimpleobj); - var > categoricalSimpleQuestion:actionscript.questions.Categorical = new > actionscript.questions.Categorical(); - + Alert.show("Parent id: " + > node.@id); + //check the sequence number first, if sequence number already > exists throw an error, otherwise create Question + + var > questionGroup:XMLList = survey.module.block.questiongroup.(@id == node.@id); > + Alert.show("Parent children length: " + > questionGroup.children().length()); + if(questionGroup.length() > 0 ) + { + > var checkSeqNoQuestion:XMLList = questionGroup.question.(@sequenceNo == > questionInfo.getSequenceNo()); + Alert.show("checkSeqNoQuestion length: " + > checkSeqNoQuestion.length()); + if(currentState == "psychometric") + { + var > psychobj:DisplayObject = pnlComponent.getChildAt(2); + + var > compPsychometric:custom.db.questions.Psychometric = > custom.db.questions.Psychometric(psychobj); + + var > asPsychometric:actionscript.questions.Psychometric = new > actionscript.questions.Psychometric(); + asPsychometric.scale = > compPsychometric.getScale(); + asPsychometric.maxSliderValue = > int(compPsychometric.getNumberofIntervals()); + asPsychometric.choices = > compPsychometric.getChoices(); + asPsychometric.question = > questionInfo.getQuestion(); + asPsychometric.sequenceNo = > int(questionInfo.getSequenceNo()); + asPsychometric.type = > questionInfo.getType(); + + //Alert.show("Psychometric Object :"); + > //Alert.show("Question: " + asPsychometric.question); + //Alert.show("SeQ > No: " + asPsychometric.sequenceNo); + //Alert.show("Type : " + > asPsychometric.type); + + if(questionInfo.getId() == 0) + { + > if(checkSeqNoQuestion.length() > 0) + { + Alert.show("Sequence number " + > questionInfo.getSequenceNo() + " already exists!"); + } + else + > roQuestionCreator.saveQuestion(asPsychometric,int(node.@id)); + } + else + > { + if(checkSeqNoQuestion.length() > 1) + { + Alert.show("Sequence number " > + questionInfo.getSequenceNo() + " already exists!"); + } + else + > roQuestionCreator.updateQuestion(asPsychometric,int(node.@id), > questionInfo.getId()); + } + + } + + else if(currentState == "relative") + { > + var catobj:DisplayObject = pnlComponent.getChildAt(3); + var > compCategorical:CategoricalRelative = CategoricalRelative(catobj); + var > categoricalQuestion:actionscript.questions.Categorical = new > actionscript.questions.Categorical(); + + var dict:Dictionary = new > Dictionary(); + dict = compCategorical.getDictionary(); + for (var > key:Object in dict) + { + var > Options:actionscript.questions.CategoricalOption = new > actionscript.questions.CategoricalOption(); + Options.optionKey = > key.toString(); + Options.choices = dict[key]; + > categoricalQuestion.categoricalOptions.addItem(Options); + } + > categoricalQuestion.type = questionInfo.getType(); + > categoricalQuestion.question = questionInfo.getQuestion(); + > categoricalQuestion.sequenceNo = int(questionInfo.getSequenceNo()); + > /*for(var i:int = 0; i < categoricalQuestion.categoricalOptions.length ; > i++) + { + var testoption:actionscript.questions.CategoricalOption = new > actionscript.questions.CategoricalOption(); + testoption = > actionscript.questions.CategoricalOption(categoricalQuestion.categoricalOptions.getItemAt(i)); > + trace(testoption.optionKey); + trace(testoption.choices); + }*/ + > if(questionInfo.getId() == 0) + { + if(checkSeqNoQuestion.length() > 0) + { > + Alert.show("Sequence number " + questionInfo.getSequenceNo() + " already > exists!"); + } + else + > roQuestionCreator.saveQuestion(categoricalQuestion,int(node.@id)); + } + > else + { + if(checkSeqNoQuestion.length() > 1) + { + Alert.show("Sequence > number " + questionInfo.getSequenceNo() + " already exists!"); + } + else + > roQuestionCreator.updateQuestion(categoricalQuestion,int(node.@id), > questionInfo.getId()); + } + + } + else if(currentState == "simple") + { + > //Alert.show("simple state"); + var catSimpleobj:DisplayObject = > pnlComponent.getChildAt(3); + var > compCategoricalSimple:custom.db.questions.CategoricalSimple = > custom.db.questions.CategoricalSimple(catSimpleobj); + var > categoricalSimpleQuestion:actionscript.questions.Categorical = new > actionscript.questions.Categorical(); - var Simpledict:Dictionary = new > Dictionary(); - Simpledict = compCategoricalSimple.getDictionary(); - for > (var option:Object in Simpledict) - { - var > OptionsSimple:actionscript.questions.CategoricalOption = new > actionscript.questions.CategoricalOption(); - OptionsSimple.optionKey = > option.toString(); - Alert.show("Key : " + option.toString()); - > OptionsSimple.choices = Simpledict[key]; - > categoricalSimpleQuestion.categoricalOptions.addItem(OptionsSimple); - } - > categoricalSimpleQuestion.type = questionInfo.getType(); - > categoricalSimpleQuestion.question = questionInfo.getQuestion(); - > categoricalSimpleQuestion.sequenceNo = int(questionInfo.getSequenceNo()); - > /*for(var j:int = 0; j < categoricalSimpleQuestion.categoricalOptions.length > ; j++) - { - var testoption:ASCategoricalOption = new ASCategoricalOption(); > - testoption = > ASCategoricalOption(categoricalSimpleQuestion.categoricalOptions.getItemAt(i)); > - trace(testoption.optionKey); - trace(testoption.choices); - }*/ - > Alert.show("Question: " + categoricalSimpleQuestion.question); - > Alert.show("SeQ No: " + categoricalSimpleQuestion.sequenceNo); - > Alert.show("Type : " + categoricalSimpleQuestion.type); - - > roQuestionCreator.saveQuestion(categoricalSimpleQuestion,1); - - } - > //roQuestionCreator.saveQuestion(int(questionInfo.getSequenceNo()),questionInfo.getQuestion(),questionInfo.getType(),int(parentModule.@id)); > + var Simpledict:Dictionary = new Dictionary(); + Simpledict = > compCategoricalSimple.getDictionary(); + for (var option:Object in > Simpledict) + { + var OptionsSimple:actionscript.questions.CategoricalOption > = new actionscript.questions.CategoricalOption(); + OptionsSimple.optionKey > = option.toString(); + //Alert.show("Key : " + option.toString()); + > OptionsSimple.choices = Simpledict[key]; + > categoricalSimpleQuestion.categoricalOptions.addItem(OptionsSimple); + } + > categoricalSimpleQuestion.type = questionInfo.getType(); + > categoricalSimpleQuestion.question = questionInfo.getQuestion(); + > categoricalSimpleQuestion.sequenceNo = int(questionInfo.getSequenceNo()); + > /*for(var j:int = 0; j < categoricalSimpleQuestion.categoricalOptions.length > ; j++) + { + var testoption:ASCategoricalOption = new ASCategoricalOption(); > + testoption = > ASCategoricalOption(categoricalSimpleQuestion.categoricalOptions.getItemAt(i)); > + trace(testoption.optionKey); + trace(testoption.choices); + }*/ + > /*Alert.show("Question: " + categoricalSimpleQuestion.question); + > Alert.show("SeQ No: " + categoricalSimpleQuestion.sequenceNo); + > Alert.show("Type : " + categoricalSimpleQuestion.type);*/ + + + > if(questionInfo.getId() == 0) + { + if(checkSeqNoQuestion.length() > 0) + { > + Alert.show("Sequence number " + questionInfo.getSequenceNo() + " already > exists!"); + } + else + > roQuestionCreator.saveQuestion(categoricalSimpleQuestion,int(node.@id)); + > } + else + { + if(checkSeqNoQuestion.length() > 1) + { + > Alert.show("Sequence number " + questionInfo.getSequenceNo() + " already > exists!"); + } + else + > roQuestionCreator.updateQuestion(categoricalSimpleQuestion,int(node.@id), > questionInfo.getId()); + } + + } + else if(currentState == "question") + { + > + var question:actionscript.questions.Question = new > actionscript.questions.Question(); + + question.question = > questionInfo.getQuestion(); + question.sequenceNo = > int(questionInfo.getSequenceNo()); + question.type = questionInfo.getType(); > + //Alert.show("Type : " + question.type); + if(questionInfo.getId() == 0) + > { + if(checkSeqNoQuestion.length() > 0) + { + Alert.show("Sequence number " > + questionInfo.getSequenceNo() + " already exists!"); + } + else + > roQuestionCreator.saveQuestion(question,int(node.@id)); + } + else + { + > if(checkSeqNoQuestion.length() > 1) + { + Alert.show("Sequence number " + > questionInfo.getSequenceNo() + " already exists!"); + } + else + > roQuestionCreator.updateQuestion(question,int(node.@id), > questionInfo.getId()); + } + + } + } } @@ -896,96 +1116,142 @@ public > function resultSaveQuestionHandler(event:ResultEvent):void { - var > test_object:Object = event.result as Object; - Alert.show("Type came from > server is: " + test_object.type); - if(test_object.type == "psychometric") + > var question_Object:actionscript.questions.Question = > actionscript.questions.Question(event.result as Object); + > if(question_Object != null) { - var > questionResult:actionscript.questions.Psychometric = > actionscript.questions.Psychometric(event.result as Object); - > Alert.show("Id is: " + questionResult.id); - Alert.show("Question is: " + > questionResult.question); - Alert.show("Type is: " + questionResult.type); - > Alert.show("SeQNo is: " + questionResult.sequenceNo); + var > newQuestionNode:XML = createQuestionNode(question_Object); + Alert.show(" > question_Object.questionGroup.id " + question_Object.questionGroup.id); + > var questionGroup:XMLList = survey.module.block.questiongroup.(@id == > question_Object.questionGroup.id); + > Alert.show("question_Object.questionGroup.length " + > questionGroup.length()); + if( questionGroup.length() > 0 ) + { + > questionGroup[0].appendChild(newQuestionNode); + currentState = "none"; + > btnsaveQuestion.enabled = false; + } + } + else + Alert.show("Error in > creating Question!"); + + + } + + public function > resultUpdateQuestionHandler(event:ResultEvent):void + { + var > question:actionscript.questions.Question = > actionscript.questions.Question(event.result as Object); + if(question == > null) + { + Alert.show("Error in creating Question!"); + } + else + { + var > newNode:XML = ; + newNode.setLocalName("question"); + var newQNode:XML = ; + > newQNode.setLocalName("question"); + var choices:String=""; + > if(question.type.toLowerCase() == "psychometric") + { + var > psychometricResult:actionscript.questions.Psychometric = > actionscript.questions.Psychometric(question); + /*Alert.show("Id is: " + > psychometricResult.id); + Alert.show("Question is: " + > psychometricResult.question); + Alert.show("Type is: " + > psychometricResult.type); + Alert.show("SeQNo is: " + > psychometricResult.sequenceNo);*/ + var newPNode:XML = ; > newPNode.setLocalName("psychometric"); - newPNode.@id = questionResult.id; > - newPNode.@scale = questionResult.scale; - newPNode.@noOfInterval = > questionResult.maxSliderValue; - for(var j:int = 0; j < > questionResult.choices.length; j++) + var psychometricList:XMLList = > psychometricQuestions.psychometric.(@id == psychometricResult.id); + + if( > psychometricList.length() > 0 ) { - var str:String = "choice"; - str = str + > j; - newPNode.@str = questionResult.choices[j]; + newPNode.@scale = > psychometricResult.scale; + newPNode.@maxSliderValue = > psychometricResult.maxSliderValue; + + newQNode.@sequenceNo = > psychometricResult.sequenceNo; + newQNode.@title = > psychometricResult.question; + newQNode.@type = psychometricResult.type; + > choices = ""; + if(psychometricResult.choices != null) + { + + for(var k:int > = 0; k < psychometricResult.choices.length; k++) + { + choices = choices + > psychometricResult.choices[k]; + choices = choices + "," + + } + + > newPNode.@choices = choices; + } + } - - > psychometricQuestions.appendChild(newPNode); - + } - else > if(test_object.type.toLowerCase() == "categorical") + else > if(question.type.toLowerCase() == "categorical") { - var > categoricalResult:actionscript.questions.Categorical = > actionscript.questions.Categorical(test_object); - var newQNode:XML = ; - > newQNode.setLocalName("question"); + var > categoricalResult:actionscript.questions.Categorical = > actionscript.questions.Categorical(question); + newQNode.@sequenceNo = > categoricalResult.sequenceNo; newQNode.@title = > categoricalResult.question; newQNode.@type = categoricalResult.type; > newQNode.@id = categoricalResult.id; - var questionGroup:XMLList > =survey.module.block.questiongroup.(@header == node.@header); - - if( > questionGroup.length() > 0 ) - { - questionGroup[0].appendChild(newQNode); - > currentState = "none"; - btnsaveQuestion.enabled = false; - } + + //flagType > false means it is simple type, otherwise it is relative type + var > flagType:Boolean = false; var newCNode:XML = ; > newCNode.setLocalName("categorical"); - newCNode.@id = > categoricalResult.id; - categoricalQuestions.appendChild(newCNode); - - > for(var i:int = 0; i < categoricalResult.categoricalOptions.length ; i++) - > { - var options:actionscript.questions.CategoricalOption = new > actionscript.questions.CategoricalOption(); - options = > actionscript.questions.CategoricalOption(categoricalResult.categoricalOptions.getItemAt(i)); > - var newOptionNode:XML = ; - newOptionNode.setLocalName("option"); - > newOptionNode.@name = options.optionKey; - if(options.choices.length <= 0) > - { - newCNode.@type = "simple"; - - } - else - { - newCNode.@type = > "relative"; - for(var k:int = 0; k < options.choices.length; k++) - { - var > choice:String = "choice"; - choice = choice + k; - newOptionNode.@choice = > options.choices[k]; - } - } - - /*var module:XMLList = survey.module.(@id == > tempmodule.id); - if( module.length() > 0 ) - { - > module[0].appendChild(newBlockNode); - }*/ - > newCNode.appendChild(newOptionNode); - } + var categoricalList:XMLList = > categoricalQuestions.categorical.(@id == categoricalResult.id); - } - - > currentState = "none"; - btnsaveQuestion.enabled = false; - - - } - - public > function resultUpdateQuestionHandler(event:Event):void - { + if( > categoricalList.length() > 0 ) + { + //remove all the tags and then add > those rather than modifying those. It is simple. + var children:XMLList = > categoricalList.children(); + + for(var l:Number=0; l < children.length(); > l++) + { + delete children[i]; + } + + + > if(categoricalResult.categoricalOptions != null) + { + + for(var i:int = 0; > i < categoricalResult.categoricalOptions.length ; i++) + { + var > options:actionscript.questions.CategoricalOption = new > actionscript.questions.CategoricalOption(); + options = > actionscript.questions.CategoricalOption(categoricalResult.categoricalOptions.getItemAt(i)); > + var newOptionNode:XML = ; + newOptionNode.setLocalName("option"); + > newOptionNode.@name = options.optionKey; + if(options.choices.length == 0) > + { + flagType = false + } + else + { + flagType = true; + choices=""; + + > for(k = 0; k < options.choices.length; k++) + { + choices = choices + > options.choices[k]; + choices = choices + "," + } + newOptionNode.@choices= choices; + } + if(flagType) + newCNode.@type= "relative"; + else + newCNode.@type= "simple"; + newCNode.appendChild(newOptionNode); + } + } + } + } + } } > //Question functionality Stop @@ -1024,6 +1290,7 @@ var selectedNode:int; > var node:XML = XML(tree.selectedItem); + lbltest.text = node.@id; > if(node.localName() == "module") { currentState = "module"; @@ -1076,10 > +1343,15 @@ btnsaveQuestion.enabled = false; //set all fields + > questionGroupInfo.setHeader(node.@header); > questionGroupInfo.setDescription(node.@description); > questionGroupInfo.setSequenceNo(node.@sequenceNo); > questionGroupInfo.setId(node.@id); + > questionGroupInfo.setHours(node.@hours); + > questionGroupInfo.setMinutes(node.@min); + > questionGroupInfo.setSeconds(node.@sec); + //Alert.show("Question group id > assigned is: " + node.@id); } @@ -1100,9 +1372,12 @@ > questionInfo.setQuestion(node.@title); > questionInfo.setSequenceNo(node.@sequenceNo); questionInfo.setId(node.@id); > + var str:String = node.@type; + /*Alert.show("q type is: " + node.@type); > + questionInfo.cmbType.selectedItem = str.toLowerCase();*/ + > questionInfo.setQuestionType(node.@type); - if(node.@type == > "categorical") { currentState = "categorical"; @@ -1110,9 +1385,9 @@ var > compCategorical:custom.db.questions.Categorical = > custom.db.questions.Categorical(catobj); compCategorical.reset(); - > questionInfo.cmbType.selectedItem = "Categorical"; + > //questionInfo.cmbType.selectedItem = "Categorical"; var > categoricalQ:XMLList = categoricalQuestions.categorical.(@id == node.@id); > - + //Alert.show("categoricalQ type: " + categoricalQ[0].@type); > if(categoricalQ.length() > 0) { if(categoricalQ[0].@type == "relative") @@ > -1123,30 +1398,37 @@ var cat1obj:DisplayObject = pnlComponent.getChildAt(3); > var compRelative:CategoricalRelative = CategoricalRelative(cat1obj); - + > compRelative.reset(); var dict:Dictionary = new Dictionary(); + var > optionList:XMLList = categoricalQ[0].option.@name; - //Alert.show("option > key: " + optionList.length()); - for(var j:int = 0; j< optionList.length(); > j++) { - var str:String = optionList[j]; + str = optionList[j]; > compRelative.header1List.addItem(str); dict[str] = new ArrayCollection(); - > var attributeList:XMLList = categoricalQ[0].option[j].attributes(); - - > for(var i:int = 0; i < attributeList.length(); i++) + choiceStr=""; + > choiceStr = categoricalQ[0].option[j].@choices; + + + outputchoices = null; > + outputchoices = choiceStr.split(","); + + + for(var i:int = 0; i < > outputchoices.length; i++) { - if(attributeList[i] != optionList[j]) - { - > dict[str].addItem(attributeList[i]); - } + + > dict[str].addItem(outputchoices[i]); } - } + + } + > compRelative.setDictionary(dict); - compRelative.setDictionary(dict); - } > else if(categoricalQ[0].@type == "simple") { @@ -1154,7 +1436,7 @@ > currentState = "simple"; var cat2obj:DisplayObject = > pnlComponent.getChildAt(3); var > compSimple:custom.db.questions.CategoricalSimple = > custom.db.questions.CategoricalSimple(cat2obj); - + compSimple.reset(); var > dictionary:Dictionary = new Dictionary(); var attributeSimpleList:XMLList = > categoricalQ[0].option.attributes(); @@ -1167,9 +1449,9 @@ dictionary[str1] > = new ArrayCollection(); dictionary[str1].addItem(null); } - + > compSimple.setDictionary(dictionary); } - > compSimple.setDictionary(dictionary); + } } @@ -1180,27 +1462,34 @@ var > psychobj:DisplayObject = pnlComponent.getChildAt(2); var > compPsychometric:custom.db.questions.Psychometric = > custom.db.questions.Psychometric(psychobj); compPsychometric.reset(); - > questionInfo.cmbType.selectedItem = "Psychometric"; + > //questionInfo.cmbType.selectedItem = "Psychometric"; var > psychometricQ:XMLList = psychometricQuestions.psychometric.(@id == node.@id); > if(psychometricQ.length() > 0) { - > compPsychometric.setScale(psychometricQ[0].@scale); - > compPsychometric.setNumberofIntervals(psychometricQ[0].@interval); - var > psychometricAttributes:XMLList = psychometricQ[0].attributes(); - + var > scale:String = psychometricQ[0].@scale; + compPsychometric.setScale(scale); > + compPsychometric.setNumberofIntervals(psychometricQ[0].@maxSliderValue); > compPsychometric.vboxChoices.visible = true; - for(var l:int =0; l < > psychometricAttributes.length(); l++) - { - Alert.show("Attribute is : " > +psychometricAttributes[l]); - if((psychometricAttributes[l] != > psychometricQ[0].@id) && (psychometricAttributes[l] != > psychometricQ[0].@scale) && (psychometricAttributes[l] != > psychometricQ[0].@interval)) - { - > compPsychometric.choice.addItem(psychometricAttributes[l]); - } - } + + > choiceStr = ""; + outputchoices = null; + choiceStr = > psychometricQ[0].@choices; + outputchoices = choiceStr.split(","); + + for(i > = 0; i < outputchoices.length; i++) + { + > compPsychometric.choice.addItem(outputchoices[i]); + + } + } } else - > currentState = "none"; + { + currentState = "question"; + + } + } } @@ > -1232,7 +1521,9 @@ - + + + @@ -1245,6 +1536,7 @@ + @@ -1303,7 +1595,7 @@ - + > @@ -1313,14 +1605,12 @@ + showRoot="true" height="50%" width="80%" > textAlign="center"/> + showRoot="true" height="50%" width="80%" > textAlign="center"/> Modified: > mentalmodels/trunk/flex/src/actionscript/Block.as > =================================================================== --- > mentalmodels/trunk/flex/src/actionscript/Block.as 2009-07-17 23:21:35 UTC > (rev 187) +++ mentalmodels/trunk/flex/src/actionscript/Block.as 2009-07-20 > 01:13:36 UTC (rev 188) @@ -13,6 +13,7 @@ public var duration:int; public var > module:Module; public var questionGroups:ArrayCollection; + public var > informationWindows:ArrayCollection; public function getHours():int @@ -29,7 > +30,7 @@ public function getSeconds():int { - return (duration - > (getMinutes() * 60)); + return (duration - (getHours() * 3600) - > (getMinutes() * 60)); } } } \ No newline at end of file Modified: > mentalmodels/trunk/flex/src/actionscript/Module.as > =================================================================== --- > mentalmodels/trunk/flex/src/actionscript/Module.as 2009-07-17 23:21:35 UTC > (rev 187) +++ mentalmodels/trunk/flex/src/actionscript/Module.as 2009-07-20 > 01:13:36 UTC (rev 188) @@ -33,7 +33,7 @@ public function getSeconds():int { > - return (duration - (getMinutes() * 60)); + return (duration - (getHours() > * 3600) - (getMinutes() * 60)); } } } \ No newline at end of file Modified: > mentalmodels/trunk/flex/src/actionscript/QuestionGroup.as > =================================================================== --- > mentalmodels/trunk/flex/src/actionscript/QuestionGroup.as 2009-07-17 > 23:21:35 UTC (rev 187) +++ > mentalmodels/trunk/flex/src/actionscript/QuestionGroup.as 2009-07-20 > 01:13:36 UTC (rev 188) @@ -12,5 +12,24 @@ public var header:String; public > var description:String; public var block:Block; + public var duration:int; + > + public function getHours():int + { + return > int(Math.floor(duration/3600)); + } + + public function getMinutes():int + { > + var tempDuration:int; + tempDuration = duration - (getHours() * 3600); + > return int(Math.floor(tempDuration/60)); + } + + public function > getSeconds():int + { + return (duration - (getHours() * 3600) - > (getMinutes() * 60)); + } + } } \ No newline at end of file Modified: > mentalmodels/trunk/flex/src/actionscript/questions/Question.as > =================================================================== --- > mentalmodels/trunk/flex/src/actionscript/questions/Question.as 2009-07-17 > 23:21:35 UTC (rev 187) +++ > mentalmodels/trunk/flex/src/actionscript/questions/Question.as 2009-07-20 > 01:13:36 UTC (rev 188) @@ -1,6 +1,8 @@ package actionscript.questions { + > import actionscript.QuestionGroup; + [Bindable] > [RemoteClass(alias="edu.asu.commons.mme.entity.Question")] public class > Question @@ -9,5 +11,7 @@ public var question:String; public var > type:String; public var sequenceNo:int; + public var > questionGroup:QuestionGroup; + } } \ No newline at end of file Modified: > mentalmodels/trunk/flex/src/custom/db/Block.mxml > =================================================================== --- > mentalmodels/trunk/flex/src/custom/db/Block.mxml 2009-07-17 23:21:35 UTC > (rev 187) +++ mentalmodels/trunk/flex/src/custom/db/Block.mxml 2009-07-20 > 01:13:36 UTC (rev 188) @@ -34,7 +34,7 @@ } public function getName():String > { - return txtName.text; + return rchtxtDescription.text; } /*public > function getDuration():String { @@ -63,7 +63,7 @@ } public function > setName(name:String):void { - txtName.text = name; + rchtxtDescription.text > = name; } @@ -97,7 +97,7 @@ formIsValid = true; // Check if form is empty - > formIsEmpty = (txtSeqNo.text == "" && txtName.text == ""); + formIsEmpty = > (txtSeqNo.text == "" && rchtxtDescription.text == ""); // Run each validator > in turn, using the isValid() // helper method and update the value of > formIsValid @@ -136,12 +136,12 @@ public function reset():void { > txtSeqNo.text =""; - txtName.text = ""; + rchtxtDescription.text = ""; > hours.value =0; minutes.value =0; seconds.value =0; txtSeqNo.errorString > =""; - txtName.errorString =""; + rchtxtDescription.errorString =""; Id = 0; > } @@ -154,10 +154,12 @@ + - + + - + Modified: > mentalmodels/trunk/flex/src/custom/db/Module.mxml > =================================================================== --- > mentalmodels/trunk/flex/src/custom/db/Module.mxml 2009-07-17 23:21:35 UTC > (rev 187) +++ mentalmodels/trunk/flex/src/custom/db/Module.mxml 2009-07-20 > 01:13:36 UTC (rev 188) @@ -45,6 +45,14 @@ { //return txtMajor.text; }*/ + > public function setSequenceNo(seqNo:String):void + { + txtSeqNo.text = > seqNo; + } + public function setName(name:String):void + { + txtName.text = > name; + } public function getHours():Number { @@ -62,16 +70,6 @@ } - public > function setSequenceNo(seqNo:String):void - { - txtSeqNo.text = seqNo; - } - > public function setName(name:String):void - { - txtName.text = name; - } - - > public function setHours(hour:Number):void { hours.value = hour; @@ -148,16 > +146,7 @@ txtName.errorString =""; Id = 0; } - - public function > saveModule():void - { - - - - } - - ]]> @@ -177,10 +166,7 @@ - - - Modified: > mentalmodels/trunk/flex/src/custom/db/Question.mxml > =================================================================== --- > mentalmodels/trunk/flex/src/custom/db/Question.mxml 2009-07-17 23:21:35 UTC > (rev 187) +++ mentalmodels/trunk/flex/src/custom/db/Question.mxml 2009-07-20 > 01:13:36 UTC (rev 188) @@ -36,12 +36,12 @@ } public function > getQuestion():String { - return txtQuestion.text; + return > rchtxtQuestion.text; } public function getType():String { - return > String(cmbType.selectedItem); + return cmbType.selectedItem.data; } public > function setSequenceNo(seqNo:String):void @@ -50,7 +50,7 @@ } public > function setQuestion(question:String):void { - txtQuestion.text = question; > + rchtxtQuestion.text = question; } @@ -62,31 +62,17 @@ - public function > setQuestionInfo(type:String):void + public function > setQuestionType(type:String):void { - cmbType.selectedItem = type; - > if(cmbType.selectedItem == "Categorical") - { - currentState = > "categorical"; - var catobj:DisplayObject = > canvasQuestionType.getChildAt(0); - questionInfo = Categorical(catobj); - > questionInfo.reset(); - - } - if(cmbType.selectedItem == "Psychometric") - { > - currentState = "psychometric"; - var psychobj:DisplayObject = > canvasQuestionType.getChildAt(0); - questionInfo = Psychometric(psychobj); - > questionInfo.reset(); - - } - /*if(cmbType.selectedItem == "Text") - { - > currentState = "none"; - } */ - - + for (var i: int = 0; i < > cmbType.dataProvider.length; i++) + { + if ( type == > cmbType.dataProvider[i].data) + { + cmbType.selectedIndex = i; + break; + } > + } + } @@ -103,7 +89,7 @@ formIsValid = true; // Check if form is empty - > formIsEmpty = (txtSeqNo.text == "" && txtQuestion.text == "" && > cmbType.selectedItem == "-Select-"); + formIsEmpty = (txtSeqNo.text == "" && > rchtxtQuestion.text == "" && cmbType.selectedItem == "-Select-"); // Run > each validator in turn, using the isValid() // helper method and update the > value of formIsValid @@ -117,7 +103,7 @@ private function > showQuestionType():void { - if(cmbType.selectedItem == "Categorical") + > if(cmbType.selectedItem.toString().toLowerCase() == "categorical") { > currentState = "categorical"; var catobj:DisplayObject = > canvasQuestionType.getChildAt(0); @@ -125,7 +111,7 @@ questionInfo.reset(); > } - if(cmbType.selectedItem == "Psychometric") + > if(cmbType.selectedItem.toString().toLowerCase() == "psychometric") { > currentState = "psychometric12"; var psychobj:DisplayObject = > canvasQuestionType.getChildAt(0); @@ -133,7 +119,7 @@ questionInfo.reset(); > } - if(cmbType.selectedItem == "Text") + > if(cmbType.selectedItem.toString().toLowerCase() == "Text") { currentState = > "text"; } @@ -171,11 +157,11 @@ { currentState = "text"; txtSeqNo.text =""; > - txtQuestion.text = ""; - + rchtxtQuestion.text = ""; + this.Id = 0; > txtSeqNo.errorString =""; - txtQuestion.errorString =""; - > cmbType.selectedIndex = 0; + rchtxtQuestion.errorString =""; + > cmbType.selectedIndex = -1; } @@ -204,17 +190,23 @@ + - + + + - + - -Select- > - Categorical - Psychometric - Text - + + + + + + + + Modified: > mentalmodels/trunk/flex/src/custom/db/QuestionGroup.mxml > =================================================================== --- > mentalmodels/trunk/flex/src/custom/db/QuestionGroup.mxml 2009-07-17 23:21:35 > UTC (rev 187) +++ mentalmodels/trunk/flex/src/custom/db/QuestionGroup.mxml > 2009-07-20 01:13:36 UTC (rev 188) @@ -35,11 +35,11 @@ } public function > getHeader():String { - return txtHeader.text; + return rchtxtHeader.text; } > public function getDescription():String { - return txtDescription.text; + > return rchtxtDescription.text; } public function > setSequenceNo(seqNo:String):void @@ -48,18 +48,50 @@ } public function > setHeader(header:String):void { - txtHeader.text = header; + > rchtxtHeader.text = header; } public function > setDescription(description:String):void { - txtDescription.text = > description; + rchtxtDescription.text = description; } + public function > getHours():Number + { + return hours.value; + + } + public function > getMinutes():Number + { + return minutes.value; + + } + public function > getSeconds():Number + { + return seconds.value; + + } - public function > validateForm(event:Event):Boolean + public function > setHours(hour:Number):void + { + hours.value = hour; + + } + public function > setMinutes(min:Number):void + { + minutes.value = min; + + } + public > function setSeconds(sec:Number):void + { + seconds.value = sec; + + } + + + > public function validateForm(event:Event):Boolean { // Save a reference to > the currently focussed form control // so that the isValid() helper method > can notify only @@ -71,7 +103,7 @@ formIsValid = true; // Check if form is > empty - formIsEmpty = (txtSeqNo.text == "" && txtHeader.text == "" && > txtDescription.text == ""); + formIsEmpty = (txtSeqNo.text == "" && > rchtxtHeader.text == "" && rchtxtDescription.text == ""); // Run each > validator in turn, using the isValid() // helper method and update the value > of formIsValid @@ -110,12 +142,15 @@ public function reset():void { > txtSeqNo.text =""; - txtHeader.text = ""; - txtDescription.text =""; + > rchtxtHeader.text = ""; + rchtxtDescription.text =""; txtSeqNo.errorString > =""; - txtHeader.errorString =""; - txtDescription.errorString =""; + > rchtxtHeader.errorString =""; + rchtxtDescription.errorString =""; setId(0); > + hours.value =0; + minutes.value =0; + seconds.value =0; } @@ -126,14 > +161,35 @@ + + + + + + + + + + + + + - + + + + + - + + + + Modified: > mentalmodels/trunk/flex/src/custom/db/questions/Categorical.mxml > =================================================================== --- > mentalmodels/trunk/flex/src/custom/db/questions/Categorical.mxml 2009-07-17 > 23:21:35 UTC (rev 187) +++ > mentalmodels/trunk/flex/src/custom/db/questions/Categorical.mxml 2009-07-20 > 01:13:36 UTC (rev 188) @@ -79,17 +79,17 @@ // currentState = "none"; - > cmbType.selectedIndex = 0; + cmbType.selectedItem = "-Select-"; } public > function setType(qType:String):void { - if(qType == "relative") + > if(qType.toLowerCase() == "relative") { cmbType.selectedItem = "Relative"; } > - else if(qType == "simple") + else if(qType.toLowerCase() == "simple") { > cmbType.selectedItem = "Simple"; Modified: > mentalmodels/trunk/flex/src/custom/db/questions/CategoricalRelative.mxml > =================================================================== --- > mentalmodels/trunk/flex/src/custom/db/questions/CategoricalRelative.mxml > 2009-07-17 23:21:35 UTC (rev 187) +++ > mentalmodels/trunk/flex/src/custom/db/questions/CategoricalRelative.mxml > 2009-07-20 01:13:36 UTC (rev 188) @@ -123,11 +123,11 @@ { for(var key:Object > in dict) { - // dict[key].removeAll(); - // delete dict[key]; + > dict[key].removeAll(); + delete dict[key]; } } - vboxSecondHeader.visible = > false; + vboxSecondHeader.visible = true; } Modified: > mentalmodels/trunk/flex/src/custom/db/questions/CategoricalSimple.mxml > =================================================================== --- > mentalmodels/trunk/flex/src/custom/db/questions/CategoricalSimple.mxml > 2009-07-17 23:21:35 UTC (rev 187) +++ > mentalmodels/trunk/flex/src/custom/db/questions/CategoricalSimple.mxml > 2009-07-20 01:13:36 UTC (rev 188) @@ -94,8 +94,15 @@ txtChoice.text = ""; > lblHeader.text = ""; header.removeAll(); - frmitmAddChoice.label="Choice for > " + lblHeader.text + ":"; + if(dict != null) + { + for(var key:Object in > dict) + { + dict[key].removeAll(); + delete dict[key]; + } + } } public > function setSimpleForm():void Modified: > mentalmodels/trunk/flex/src/custom/db/questions/Psychometric.mxml > =================================================================== --- > mentalmodels/trunk/flex/src/custom/db/questions/Psychometric.mxml 2009-07-17 > 23:21:35 UTC (rev 187) +++ > mentalmodels/trunk/flex/src/custom/db/questions/Psychometric.mxml 2009-07-20 > 01:13:36 UTC (rev 188) @@ -31,12 +31,13 @@ public function > setScale(scale:String):void { this.scale = scale; - if(scale == "bipolar") + > //Alert.show("Scale is :" +scale); + if(scale.toLowerCase() == "bipolar") { > cmbType.selectedItem = "Bipolar"; } - else if(scale == "unipolar") + else > if(scale.toLowerCase() == "unipolar") { cmbType.selectedItem = "Unipolar"; > @@ -225,11 +226,11 @@ --> - + -Select- Bipolar - Scalar + Unipolar Modified: > mentalmodels/trunk/src/main/db/init-mme.sql > =================================================================== --- > mentalmodels/trunk/src/main/db/init-mme.sql 2009-07-17 23:21:35 UTC (rev > 187) +++ mentalmodels/trunk/src/main/db/init-mme.sql 2009-07-20 01:13:36 UTC > (rev 188) @@ -1,260 +1,730 @@ -insert into game > (description,image_location,max_days,max_fish_harvest,money,no_of_locations,no_of_rounds,timestamp,title) > -values("First game","island.jpg",30,5,0.0,4,3,NOW(),"Mental Model > Experiment"); - -insert into round_config > (communication_flag,round_no,game_i... [truncated message content] |
From: <see...@us...> - 2009-07-20 01:13:41
|
Revision: 188 http://virtualcommons.svn.sourceforge.net/virtualcommons/?rev=188&view=rev Author: seematalele Date: 2009-07-20 01:13:36 +0000 (Mon, 20 Jul 2009) Log Message: ----------- Created HibernateCategoricalQuestionDao.java and HibernatePsychometricQuestionDao.java. Changed the code of InitialiseDatabase.mxml - Adding Module,Block,QuestionGroup and Question is working fine. - Updating Module,Block,QuestionGroup is working fine. Need to test updating Questions in InitialiseDatabase.mxml. (But I am not going to test it until it really needs because it is taking some time) The init-mme file contains the database which initialized till Module 2A - Block 2-4 Commented the createQuestions in QuestionCreatorService.java and StartupService.java Modified Paths: -------------- mentalmodels/trunk/flex/src/InitialiseDatabase.mxml mentalmodels/trunk/flex/src/actionscript/Block.as mentalmodels/trunk/flex/src/actionscript/Module.as mentalmodels/trunk/flex/src/actionscript/QuestionGroup.as mentalmodels/trunk/flex/src/actionscript/questions/Question.as mentalmodels/trunk/flex/src/custom/db/Block.mxml mentalmodels/trunk/flex/src/custom/db/Module.mxml mentalmodels/trunk/flex/src/custom/db/Question.mxml mentalmodels/trunk/flex/src/custom/db/QuestionGroup.mxml mentalmodels/trunk/flex/src/custom/db/questions/Categorical.mxml mentalmodels/trunk/flex/src/custom/db/questions/CategoricalRelative.mxml mentalmodels/trunk/flex/src/custom/db/questions/CategoricalSimple.mxml mentalmodels/trunk/flex/src/custom/db/questions/Psychometric.mxml mentalmodels/trunk/src/main/db/init-mme.sql mentalmodels/trunk/src/main/java/edu/asu/commons/mme/entity/QuestionGroup.java mentalmodels/trunk/src/main/java/edu/asu/commons/mme/entity/RoundConfig.java mentalmodels/trunk/src/main/java/edu/asu/commons/mme/service/QuestionCreatorService.java mentalmodels/trunk/src/main/java/edu/asu/commons/mme/service/StartupService.java mentalmodels/trunk/src/main/webapp/WEB-INF/applicationContext.xml Added Paths: ----------- mentalmodels/trunk/src/main/java/edu/asu/commons/mme/dao/HibernateCategoricalQuestionDao.java mentalmodels/trunk/src/main/java/edu/asu/commons/mme/dao/HibernatePsychometricQuestionDao.java Modified: mentalmodels/trunk/flex/src/InitialiseDatabase.mxml =================================================================== --- mentalmodels/trunk/flex/src/InitialiseDatabase.mxml 2009-07-17 23:21:35 UTC (rev 187) +++ mentalmodels/trunk/flex/src/InitialiseDatabase.mxml 2009-07-20 01:13:36 UTC (rev 188) @@ -5,11 +5,7 @@ <mx:Script> <![CDATA[ import mx.binding.utils.BindingUtils; - /*import custom.db.questions.Psychometric; - import custom.db.questions.CategoricalSimple; - import custom.db.questions.CategoricalRelative; - import custom.db.questions.Categorical; - import custom.db.Block; */ + import actionscript.Block; import actionscript.Module; @@ -28,31 +24,24 @@ import mx.rpc.events.FaultEvent; import mx.rpc.events.ResultEvent; - - -/* id field of module, block and questiongroup and questions should come from database, -so when module info is transfered to the server, it should return the id for that module */ - //public static var Qid:int = 2; - - [Bindable] - private var survey:XML = - <list> - <module title="Preexperiment" sequenceNo="1" hours="0" min="3" sec="0" id="1"> + /**** + * Sample exmaple of Survey Questions structure + * <module title="Preexperiment" sequenceNo="1" hours="0" min="3" sec="0" id="1"> <block name="Introduction" sequenceNo="1" hours="0" min="3" sec="0" id="1"> - <questiongroup header="Welcome to E-Fishery Experiment" description="In this experiment you will design..." sequenceNo="1" id="1"/> + <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..." sequenceNo="1" 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> - - <question title="second important goal" type="psychometric" sequenceNo="2" id="2" > - </question> + </question> </questiongroup> @@ -60,56 +49,53 @@ </block> </module> - </list>; - /*[Bindable] + + * + */ + +/* id field of module, block and questiongroup and questions should come from database, +so when module info is transfered to the server, it should return the id for that module */ + + + [Bindable] private var survey:XML = <list> - <module title="Survey Questions" /> - </list>;*/ + <module title="Survey Questions" id="0" sequenceNo="0" hours="0" min="0" sec="0"/> + + </list>; - - /*[Bindable] - private var questions:XML = - <list> - <categorical id="1" type="relative"> - <optionKey name="fish" > - - </optionKey> + /** + * Sample example of categorical question structure + * + * <categorical type="relative" id="2"> + <option name="focus on earning" choices="less,more,most" /> + <option name="focus on fish" choices="123,more than 123,none" /> </categorical> - <categorical id="2" type="simple"> - <optionKey name="poeple" > - - </optionKey> + <categorical type="simple" id="1"> + <option name="less"/> + <option name="more"/> + <option name="most" /> + </categorical> - <psychometric id="1" scale="bipolar" numberOfIntervals="21"> - - </psychometric> - - </list>; */ - - - [Bindable] + * + * ***/ + + [Bindable] private var categoricalQuestions:XML = <list> <categorical type="Categorical Questions" id="0"/> - <categorical type="relative" id="2"> - <option name="focus on earning" choice1="less" choice2="more" choice3="most" /> - <option name="focus on fish" choice1="123" choice2="more than 123" choice3="none" /> - </categorical> - <categorical type="simple" id="1"> - <option choice1="less" choice2="more" choice3="most" /> - - </categorical> </list>; + /** + * Sample example of psychometric question structure + * <psychometric scale="bipolar" id="2" choices="good,better,best" maxSliderValue="21" /> + **/ + [Bindable] private var psychometricQuestions:XML = <list> - <psychometric scale="Psychometric Questions" id="0"/> - <psychometric scale="bipolar" id="2" choice1="good" choice2="better" choice3="best" interval="21" /> - - + <psychometric scale="Psychometric Questions" id="0" choices="none" maxSliderValue="0"/> </list>; @@ -122,6 +108,8 @@ public var tempQuestion:ArrayCollection = new ArrayCollection(); + + private function init():void { roQuestionCreator.initializeData(); @@ -148,7 +136,7 @@ survey.appendChild(newModuleNode); //if any blocks, add into the module - if(module.blocks != null) + if(module.blocks != null) { for(var blockCounter:int = 0; blockCounter < module.blocks.length; blockCounter++) { @@ -181,9 +169,9 @@ } } - } + } + } } - } } } @@ -230,7 +218,10 @@ newNode.@header = questionGroup.header; newNode.@description = questionGroup.description; newNode.@sequenceNo = questionGroup.sequenceNo; - newNode.@id = questionGroup.id; + newNode.@hours = questionGroup.getHours(); + newNode.@min = questionGroup.getMinutes(); + newNode.@sec = questionGroup.getSeconds(); + newNode.@id = questionGroup.id; return newNode; @@ -240,33 +231,40 @@ { var newQNode:XML = <question/>; newQNode.setLocalName("question"); + var choices:String=""; if(question.type.toLowerCase() == "psychometric") { var psychometricResult:actionscript.questions.Psychometric = actionscript.questions.Psychometric(question); - Alert.show("Id is: " + psychometricResult.id); + /*Alert.show("Id is: " + psychometricResult.id); Alert.show("Question is: " + psychometricResult.question); Alert.show("Type is: " + psychometricResult.type); - Alert.show("SeQNo is: " + psychometricResult.sequenceNo); + Alert.show("SeQNo is: " + psychometricResult.sequenceNo);*/ var newPNode:XML = <psychometric/>; newPNode.setLocalName("psychometric"); newPNode.@id = psychometricResult.id; newPNode.@scale = psychometricResult.scale; - newPNode.@noOfInterval = psychometricResult.maxSliderValue; + newPNode.@maxSliderValue = psychometricResult.maxSliderValue; newQNode.@sequenceNo = psychometricResult.sequenceNo; newQNode.@title = psychometricResult.question; newQNode.@type = psychometricResult.type; newQNode.@id = psychometricResult.id; - - for(var j:int = 0; j < psychometricResult.choices.length; j++) - { - var str:String = "choice"; - str = str + j; - newPNode.@str = psychometricResult.choices[j]; - } - + choices = ""; + if(psychometricResult.choices != null) + { + + for(var k:int = 0; k < psychometricResult.choices.length; k++) + { + choices = choices + psychometricResult.choices[k]; + choices = choices + "," + + } + //Alert.show("choices are: " + choices); + + newPNode.@choices = choices; + } psychometricQuestions.appendChild(newPNode); } @@ -286,44 +284,60 @@ currentState = "none"; btnsaveQuestion.enabled = false; }*/ + //false means it is simple type, otherwise it is relative type + var flagType:Boolean = false; var newCNode:XML = <categorical/>; newCNode.setLocalName("categorical"); newCNode.@id = categoricalResult.id; categoricalQuestions.appendChild(newCNode); - - for(var i:int = 0; i < categoricalResult.categoricalOptions.length ; i++) - { - var options:actionscript.questions.CategoricalOption = new actionscript.questions.CategoricalOption(); - options = actionscript.questions.CategoricalOption(categoricalResult.categoricalOptions.getItemAt(i)); - var newOptionNode:XML = <option/>; - newOptionNode.setLocalName("option"); - newOptionNode.@name = options.optionKey; - if(options.choices.length <= 0) - { - newCNode.@type = "simple"; - - } - else - { - newCNode.@type = "relative"; - for(var k:int = 0; k < options.choices.length; k++) + + if(categoricalResult.categoricalOptions != null) + { + + for(var i:int = 0; i < categoricalResult.categoricalOptions.length ; i++) + { + var options:actionscript.questions.CategoricalOption = new actionscript.questions.CategoricalOption(); + options = actionscript.questions.CategoricalOption(categoricalResult.categoricalOptions.getItemAt(i)); + var newOptionNode:XML = <option/>; + newOptionNode.setLocalName("option"); + newOptionNode.@name = options.optionKey; + if(options.choices.length == 0) { - var choice:String = "choice"; - choice = choice + k; - newOptionNode.@choice = options.choices[k]; + flagType = false } - } - - /*var module:XMLList = survey.module.(@id == tempmodule.id); - if( module.length() > 0 ) - { - module[0].appendChild(newBlockNode); - }*/ - newCNode.appendChild(newOptionNode); - } - - + else + { + flagType = true; + choices=""; + + for(k = 0; k < options.choices.length; k++) + { + choices = choices + options.choices[k]; + choices = choices + "," + + } + //Alert.show("choices are: " + choices); + + newOptionNode.@choices = choices; + } + if(flagType) + newCNode.@type = "relative"; + else + newCNode.@type = "simple"; + newCNode.appendChild(newOptionNode); + } + } + + } + //if question type is strategy, day by day decision, forecasting fish, forecasting fishermen + else + { + newQNode.@sequenceNo = question.sequenceNo; + newQNode.@title = question.question; + newQNode.@type = question.type; + newQNode.@id = question.id; + } return newQNode; @@ -348,7 +362,7 @@ return node.@header; else if( node.localName() == "question" ) - return node.@title; + return node.@type; else return null; @@ -419,16 +433,43 @@ { var title:String = moduleInfo.getName(); var seqNo:int = int(moduleInfo.getSequenceNo()); - if(moduleInfo.getId() == 0) - { - roQuestionCreator.saveModule(seqNo, title, getDuration(moduleInfo.getHours(),moduleInfo.getMinutes(),moduleInfo.getSeconds())); + + /* check first Id if the module exists, + if no, then check if sequence number already exists for other module, + if no then create module otherwise throw error */ + + var checkSeqNoModule:XMLList = survey.module.(@sequenceNo == moduleInfo.getSequenceNo()); + + /* check if new module needs to be created, if yes, check if the sequence number is already exists + if "No" then only save into the database */ + + if(moduleInfo.getId() == 0) + { + if(checkSeqNoModule.length() > 0) + { + Alert.show("Sequence number : " + seqNo + " already exists!"); + } + else + roQuestionCreator.saveModule(seqNo, title, getDuration(moduleInfo.getHours(),moduleInfo.getMinutes(),moduleInfo.getSeconds())); + } + + else + { + //Alert.show("length : " + checkSeqNoModule.length().toString()); + //check if the sequence number exists, do not update the module + + if(checkSeqNoModule.length() > 1) + { + Alert.show("Sequence number : " + seqNo + " already exists!"); + } + else + roQuestionCreator.updateModule(moduleInfo.getId(),seqNo, title, getDuration(moduleInfo.getHours(),moduleInfo.getMinutes(),moduleInfo.getSeconds())); + } - else - roQuestionCreator.updateModule(moduleInfo.getId(),seqNo, title, getDuration(moduleInfo.getHours(),moduleInfo.getMinutes(),moduleInfo.getSeconds())); - currentState = "none"; + + currentState = "none"; btnsaveModule.enabled = false; - //pnlComponent.removeChildAt(1); - } + } } else @@ -447,35 +488,35 @@ public function resultSaveModuleHandler(event:ResultEvent):void { var module:actionscript.Module = actionscript.Module(event.result as Object); - Alert.show("Id is: " + module.id); - var newModuleNode:XML = <module/>; - newModuleNode.setLocalName("module"); - newModuleNode.@title= module.description; - newModuleNode.@sequenceNo = module.sequenceNo; - newModuleNode.@hours = module.getHours(); - newModuleNode.@min = module.getMinutes(); - newModuleNode.@sec = module.getSeconds(); - newModuleNode.@id = module.id; - survey.appendChild(newModuleNode); - if(surveyData == null) + + if(module == null) { - surveyData= new XMLListCollection(survey.module); + Alert.show("Error in creating module!"); } + else + { + //Alert.show("Id is: " + module.id); + var newModuleNode:XML = createModuleNode(module); + survey.appendChild(newModuleNode); + } - - } //when module is updated, the result will come to resultUpdateModuleHandler public function resultUpdateModuleHandler(event:ResultEvent):void { var module:actionscript.Module = actionscript.Module(event.result as Object); - var moduleXML:XMLList = survey.module.(@id == module.id); - moduleXML.@title = module.description; - moduleXML.@sequenceNo = module.sequenceNo; - moduleXML.@hours = module.getHours(); - moduleXML.@min = module.getMinutes(); - moduleXML.@sec = module.getSeconds(); + if(module != null) + { + var moduleXML:XMLList = survey.module.(@id == module.id); + moduleXML.@title = module.description; + moduleXML.@sequenceNo = module.sequenceNo; + moduleXML.@hours = module.getHours(); + moduleXML.@min = module.getMinutes(); + moduleXML.@sec = module.getSeconds(); + } + else + Alert.show("Error in updating module!"); } @@ -535,25 +576,42 @@ var parentNode:XML = tree.getParentItem(tree.selectedItem) as XML; node = parentNode; } - var module:XMLList = survey.module.(@title == node.@title); - //Alert.show("Module length is : " + module.length()); + var module:XMLList = survey.module.(@id == node.@id); + if( module.length() > 0 ) { - // Alert.show("Block id is : " + blockInfo.getId()); - if(blockInfo.getId() == 0) - { - roQuestionCreator.saveBlock(int(blockInfo.getSequenceNo()),blockInfo.getName(),getDuration(blockInfo.getHours(),blockInfo.getMinutes(),blockInfo.getSeconds()),int(module[0].@id)); - } - else - { - roQuestionCreator.updateBlock(blockInfo.getId(), int(blockInfo.getSequenceNo()),blockInfo.getName(),getDuration(blockInfo.getHours(),blockInfo.getMinutes(),blockInfo.getSeconds()),int(module[0].@id)); + + //check the sequence number first, if sequence number already exists throw an error, otherwise create block + var checkSeqNoBlock:XMLList = module.block.(@sequenceNo == blockInfo.getSequenceNo()); + if(blockInfo.getId() == 0) + { + if(checkSeqNoBlock.length() > 0) + { + Alert.show("Sequence number " + blockInfo.getSequenceNo() + " already exists!"); + } + else + { + roQuestionCreator.saveBlock(int(blockInfo.getSequenceNo()),blockInfo.getName(),getDuration(blockInfo.getHours(),blockInfo.getMinutes(),blockInfo.getSeconds()),int(module[0].@id)); + } + } + else + { + //Alert.show("length : " + checkSeqNoBlock.length().toString()); + //check if the sequence number exists, do not update the module + if(checkSeqNoBlock.length() > 1) + { + Alert.show("Sequence number : " + blockInfo.getSequenceNo() + " already exists!"); + } + else + roQuestionCreator.updateBlock(blockInfo.getId(), int(blockInfo.getSequenceNo()),blockInfo.getName(),getDuration(blockInfo.getHours(),blockInfo.getMinutes(),blockInfo.getSeconds()),int(module[0].@id)); + } + + currentState = "none"; + btnsaveBlock.enabled = false; } - currentState = "none"; - btnsaveBlock.enabled = false; - // pnlComponent.removeChildAt(1); - } + } } - } + else { Alert.show("Please fill the form correctly"); @@ -570,14 +628,7 @@ if(block != null) { - var newBlockNode:XML = <block/>; - newBlockNode.setLocalName("block"); - newBlockNode.@name = block.description; - newBlockNode.@sequenceNo = block.sequenceNo; - newBlockNode.@hours = block.getHours(); - newBlockNode.@min = block.getMinutes(); - newBlockNode.@sec = block.getSeconds(); - newBlockNode.@id = block.id; + var newBlockNode:XML = createBlockNode(block); var tempmodule:actionscript.Module = block.module; var module:XMLList = survey.module.(@id == tempmodule.id); @@ -585,7 +636,9 @@ { module[0].appendChild(newBlockNode); } - } + } + else + Alert.show("Error in creating Block!"); } @@ -593,19 +646,24 @@ public function resultUpdateBlockHandler(event:ResultEvent):void { var block:actionscript.Block = actionscript.Block(event.result as Object); - - var tempmodule:actionscript.Module = block.module; - - var blockXML:XMLList = survey.module.block.(@id == block.id); - - blockXML.@name = block.description; - blockXML.@sequenceNo = block.sequenceNo; - blockXML.@hours = block.getHours(); - blockXML.@min = block.getMinutes(); - blockXML.@sec = block.getSeconds(); + if(block != null) + { + var tempmodule:actionscript.Module = block.module; + var blockXML:XMLList = survey.module.block.(@id == block.id); + if(blockXML.length() > 0) + { + blockXML[0].@name = block.description; + blockXML[0].@sequenceNo = block.sequenceNo; + blockXML[0].@hours = block.getHours(); + blockXML[0].@min = block.getMinutes(); + blockXML[0].@sec = block.getSeconds(); + } + } + else + Alert.show("Error in creating Block!"); } - //Block functioanlity Stop + //Block functioanlity End //QuestionGroup functionality Start @@ -629,7 +687,7 @@ var selectedNode:XML = tree.selectedItem as XML; var obj:DisplayObject = pnlComponent.getChildAt(1); var questionGroupInfo:custom.db.QuestionGroup = custom.db.QuestionGroup(obj); - Alert.show("Question Group Id is: " + questionGroupInfo.getId()); + if(tree.selectedItem == null) { Alert.show("Please select the block from tree to which Question Group should be added."); @@ -656,12 +714,18 @@ { //find out the parent module var parentModule:XML = tree.getParentItem(tree.selectedItem) as XML; - - + var isQuestionGroupFormValid:Boolean = questionGroupInfo.validateForm(event); if(isQuestionGroupFormValid) { + var durationflag:Boolean = this.isDurationValid(questionGroupInfo.getHours(),questionGroupInfo.getMinutes(),questionGroupInfo.getSeconds()); + if(durationflag) + { + Alert.show("Please enter the valid duration for the given module."); + } + else + { var node:XML; /** * Check if the selected node is block, if it is new Question Group needs to be created. @@ -677,22 +741,46 @@ node = parentNode; } var block:XMLList = survey.module.block.(@id == node.@id); - //Alert.show("block id is : " + block[0].@id + "length is: " + block.length()); + //Alert.show("block id is : " + block.@id + "length is: " + block.length().toString()); if( block.length() > 0 ) { - if(questionGroupInfo.getId() == 0) - { - roQuestionCreator.saveQuestionGroup(int(questionGroupInfo.getSequenceNo()),questionGroupInfo.getHeader(),questionGroupInfo.getDescription(),int(block[0].@id)); - } - else - { - roQuestionCreator.updateQuestionGroup(int(questionGroupInfo.getSequenceNo()),questionGroupInfo.getHeader(),questionGroupInfo.getDescription(),int(block[0].@id),questionGroup.getId()); + //check the sequence number first, if sequence number already exists throw an error, otherwise create module + var checkSeqNoQuestionGroup:XMLList = block.questiongroup.(@sequenceNo == questionGroupInfo.getSequenceNo()); + //Alert.show("length : " + checkSeqNoQuestionGroup.length().toString()); + if(questionGroupInfo.getId() == 0) + { + if(checkSeqNoQuestionGroup.length() > 0) + { + Alert.show("Sequence number " + questionGroupInfo.getSequenceNo() + " already exists!"); + } + else + { + roQuestionCreator.saveQuestionGroup(int(questionGroupInfo.getSequenceNo()),questionGroupInfo.getHeader(),questionGroupInfo.getDescription(),getDuration(questionGroupInfo.getHours(),questionGroupInfo.getMinutes(),questionGroupInfo.getSeconds()),int(block[0].@id)); + } + } + else + { + //Alert.show("length : " + checkSeqNoQuestionGroup.length().toString()); + //check if the sequence number exists, do not update the module + if(checkSeqNoQuestionGroup.length() > 1) + { + Alert.show("Sequence number : " + questionGroupInfo.getSequenceNo() + " already exists!"); + } + else + roQuestionCreator.updateQuestionGroup(int(questionGroupInfo.getSequenceNo()),questionGroupInfo.getHeader(),questionGroupInfo.getDescription(),getDuration(questionGroupInfo.getHours(),questionGroupInfo.getMinutes(),questionGroupInfo.getSeconds()),int(block[0].@id),questionGroup.getId()); + } - currentState = "none"; - btnsaveQuestionGroup.enabled = false; - //pnlComponent.removeChildAt(1); - } - } + currentState = "none"; + btnsaveQuestionGroup.enabled = false; + } + + } + } + else + { + Alert.show("Please fill the form correctly"); + return; + } } } } @@ -702,23 +790,23 @@ public function resultSaveQuestionGroupHandler(event:ResultEvent):void { var questionGroup:actionscript.QuestionGroup = actionscript.QuestionGroup(event.result as Object); - Alert.show("Id is: " + questionGroup.id); - var newNode:XML = <questiongroup/>; - newNode.setLocalName("questiongroup"); - newNode.@header = questionGroup.header; - newNode.@description = questionGroup.description; - newNode.@sequenceNo = questionGroup.sequenceNo; - newNode.@id = questionGroup.id; - - var block:actionscript.Block = questionGroup.block; + + if(questionGroup != null) + { + var newQuestionGroupNode:XML = createQuestionGroupNode(questionGroup); + + var block:actionscript.Block = questionGroup.block; - var blockXML:XMLList =survey.module.block.(@id == block.id); + var blockXML:XMLList =survey.module.block.(@id == block.id); - if( blockXML.length() > 0 ) - { - blockXML[0].appendChild(newNode); + if( blockXML.length() > 0 ) + { + blockXML[0].appendChild(newQuestionGroupNode); - } + } + } + else + Alert.show("Error in creating QuestionGroup!"); } @@ -726,17 +814,34 @@ public function resultUpdateQuestionGroupHandler(event:ResultEvent):void { var questionGroup:actionscript.QuestionGroup = actionscript.QuestionGroup(event.result as Object); - Alert.show("Id is: " + questionGroup.id); - var newNode:XML = <questiongroup/>; - newNode.setLocalName("questiongroup"); - newNode.@header = questionGroup.header; - newNode.@description = questionGroup.description; - newNode.@sequenceNo = questionGroup.sequenceNo; - var block:actionscript.Block = questionGroup.block; - - } + + //Alert.show("Id is: " + questionGroup.id); + if(questionGroup != null) + { + var newNode:XML = <questiongroup/>; + newNode.setLocalName("questiongroup"); + var questionGroupXML:XMLList = survey.module.block.questiongroup.(@id == questionGroup.id); + //Alert.show("Length is: " + questionGroupXML.length()); + if(questionGroupXML.length() > 0) + { + // Alert.show("header is :" + questionGroup.header); + // Alert.show("questionGroup description is :" + questionGroup.description); + //Alert.show("questionGroup.sequenceNo is :" + questionGroup.sequenceNo); + + questionGroupXML[0].@header = questionGroup.header; + questionGroupXML[0].@description = questionGroup.description; + questionGroupXML[0].@sequenceNo = questionGroup.sequenceNo; + questionGroupXML[0].@hours = questionGroup.getHours(); + questionGroupXML[0].@min = questionGroup.getMinutes(); + questionGroupXML[0].@sec = questionGroup.getSeconds(); + + } + } + else + Alert.show("Error in updating QuestionGroup!"); + } - //QuestionGroup functionality Stop + //QuestionGroup functionality End //Question functionality Start @@ -755,26 +860,43 @@ private function QuestionHandler(event:Event):void { - if(question.cmbType.selectedItem.toString().toLowerCase() == "psychometric") + if(question.cmbType.selectedItem.data.toString().toLowerCase() == "psychometric") + { currentState = "psychometric"; - else if(question.cmbType.selectedItem.toString().toLowerCase() == "categorical") + psychometric.reset(); + } + else if(question.cmbType.selectedItem.data.toString().toLowerCase() == "categorical") + { currentState = "categorical"; + categorical.reset(); + } + else + { + currentState = "question"; + + } } private function CategoricalTypeHandler(event:Event):void { if(categorical.cmbType.selectedItem.toString().toLowerCase() == "relative") + { currentState = "relative"; + categoricalRelative.reset(); + } else if(categorical.cmbType.selectedItem.toString().toLowerCase() == "simple") + { currentState = "simple"; + categoricalSimple.reset(); + } + } - - private function saveQuestion(event:Event):void { - var node:XML = tree.selectedItem as XML; + var selectedNode:XML = tree.selectedItem as XML; + var node:XML; if(tree.selectedItem == null) { @@ -783,109 +905,207 @@ } else { - - //if(tree.getParentItem(tree.selectedItem) == null) - if(node.localName() != "questiongroup") + if(selectedNode.localName().toString().toLowerCase() == "module" || selectedNode.localName().toString().toLowerCase() == "block") { - Alert.show("You can add Question to QuestionGroup only."); + Alert.show("You can not add Question to Module or Block."); return; } else { - //find out the parent module - var parentModule:XML = tree.getParentItem(tree.selectedItem) as XML; + if(selectedNode.localName().toString().toLowerCase() == "questiongroup") + { + node = selectedNode; + } + else if(selectedNode.localName().toString().toLowerCase() == "question") + { + var parentNode:XML = tree.getParentItem(tree.selectedItem) as XML; + node = parentNode; + } + + var obj:DisplayObject = pnlComponent.getChildAt(1); var questionInfo:custom.db.Question = custom.db.Question(obj); - var isQuestionGroupFormValid:Boolean = questionInfo.validateForm(event); + var isQuestionFormValid:Boolean = questionInfo.validateForm(event); - if(isQuestionGroupFormValid) + if(isQuestionFormValid) { - - if(currentState == "psychometric") - { - var psychobj:DisplayObject = pnlComponent.getChildAt(2); - - var compPsychometric:custom.db.questions.Psychometric = custom.db.questions.Psychometric(psychobj); - - var asPsychometric:actionscript.questions.Psychometric = new actionscript.questions.Psychometric(); - asPsychometric.scale = compPsychometric.getScale(); - asPsychometric.maxSliderValue = int(compPsychometric.getNumberofIntervals()); - asPsychometric.choices = compPsychometric.getChoices(); - asPsychometric.question = questionInfo.getQuestion(); - asPsychometric.sequenceNo = int(questionInfo.getSequenceNo()); - asPsychometric.type = questionInfo.getType(); - - Alert.show("Psychometric Object :"); - Alert.show("Question: " + asPsychometric.question); - Alert.show("SeQ No: " + asPsychometric.sequenceNo); - Alert.show("Type : " + asPsychometric.type); - roQuestionCreator.saveQuestion(asPsychometric,1); - } - else if(currentState == "relative") - { - var catobj:DisplayObject = pnlComponent.getChildAt(3); - var compCategorical:CategoricalRelative = CategoricalRelative(catobj); - var categoricalQuestion:actionscript.questions.Categorical = new actionscript.questions.Categorical(); - - var dict:Dictionary = new Dictionary(); - dict = compCategorical.getDictionary(); - for (var key:Object in dict) - { - var Options:actionscript.questions.CategoricalOption = new actionscript.questions.CategoricalOption(); - Options.optionKey = key.toString(); - Options.choices = dict[key]; - categoricalQuestion.categoricalOptions.addItem(Options); - } - categoricalQuestion.type = questionInfo.getType(); - categoricalQuestion.question = questionInfo.getQuestion(); - categoricalQuestion.sequenceNo = int(questionInfo.getSequenceNo()); - for(var i:int = 0; i < categoricalQuestion.categoricalOptions.length ; i++) - { - var testoption:actionscript.questions.CategoricalOption = new actionscript.questions.CategoricalOption(); - testoption = actionscript.questions.CategoricalOption(categoricalQuestion.categoricalOptions.getItemAt(i)); - trace(testoption.optionKey); - trace(testoption.choices); - } - roQuestionCreator.saveQuestion(categoricalQuestion,1); - - } - else if(currentState == "simple") - { - Alert.show("simple state"); - var catSimpleobj:DisplayObject = pnlComponent.getChildAt(3); - var compCategoricalSimple:custom.db.questions.CategoricalSimple = custom.db.questions.CategoricalSimple(catSimpleobj); - var categoricalSimpleQuestion:actionscript.questions.Categorical = new actionscript.questions.Categorical(); - + Alert.show("Parent id: " + node.@id); + //check the sequence number first, if sequence number already exists throw an error, otherwise create Question + + var questionGroup:XMLList = survey.module.block.questiongroup.(@id == node.@id); + Alert.show("Parent children length: " + questionGroup.children().length()); + if(questionGroup.length() > 0 ) + { + var checkSeqNoQuestion:XMLList = questionGroup.question.(@sequenceNo == questionInfo.getSequenceNo()); + Alert.show("checkSeqNoQuestion length: " + checkSeqNoQuestion.length()); + if(currentState == "psychometric") + { + var psychobj:DisplayObject = pnlComponent.getChildAt(2); + + var compPsychometric:custom.db.questions.Psychometric = custom.db.questions.Psychometric(psychobj); + + var asPsychometric:actionscript.questions.Psychometric = new actionscript.questions.Psychometric(); + asPsychometric.scale = compPsychometric.getScale(); + asPsychometric.maxSliderValue = int(compPsychometric.getNumberofIntervals()); + asPsychometric.choices = compPsychometric.getChoices(); + asPsychometric.question = questionInfo.getQuestion(); + asPsychometric.sequenceNo = int(questionInfo.getSequenceNo()); + asPsychometric.type = questionInfo.getType(); + + //Alert.show("Psychometric Object :"); + //Alert.show("Question: " + asPsychometric.question); + //Alert.show("SeQ No: " + asPsychometric.sequenceNo); + //Alert.show("Type : " + asPsychometric.type); + + if(questionInfo.getId() == 0) + { + if(checkSeqNoQuestion.length() > 0) + { + Alert.show("Sequence number " + questionInfo.getSequenceNo() + " already exists!"); + } + else + roQuestionCreator.saveQuestion(asPsychometric,int(node.@id)); + } + else + { + if(checkSeqNoQuestion.length() > 1) + { + Alert.show("Sequence number " + questionInfo.getSequenceNo() + " already exists!"); + } + else + roQuestionCreator.updateQuestion(asPsychometric,int(node.@id), questionInfo.getId()); + } + + } + + else if(currentState == "relative") + { + var catobj:DisplayObject = pnlComponent.getChildAt(3); + var compCategorical:CategoricalRelative = CategoricalRelative(catobj); + var categoricalQuestion:actionscript.questions.Categorical = new actionscript.questions.Categorical(); + + var dict:Dictionary = new Dictionary(); + dict = compCategorical.getDictionary(); + for (var key:Object in dict) + { + var Options:actionscript.questions.CategoricalOption = new actionscript.questions.CategoricalOption(); + Options.optionKey = key.toString(); + Options.choices = dict[key]; + categoricalQuestion.categoricalOptions.addItem(Options); + } + categoricalQuestion.type = questionInfo.getType(); + categoricalQuestion.question = questionInfo.getQuestion(); + categoricalQuestion.sequenceNo = int(questionInfo.getSequenceNo()); + /*for(var i:int = 0; i < categoricalQuestion.categoricalOptions.length ; i++) + { + var testoption:actionscript.questions.CategoricalOption = new actionscript.questions.CategoricalOption(); + testoption = actionscript.questions.CategoricalOption(categoricalQuestion.categoricalOptions.getItemAt(i)); + trace(testoption.optionKey); + trace(testoption.choices); + }*/ + if(questionInfo.getId() == 0) + { + if(checkSeqNoQuestion.length() > 0) + { + Alert.show("Sequence number " + questionInfo.getSequenceNo() + " already exists!"); + } + else + roQuestionCreator.saveQuestion(categoricalQuestion,int(node.@id)); + } + else + { + if(checkSeqNoQuestion.length() > 1) + { + Alert.show("Sequence number " + questionInfo.getSequenceNo() + " already exists!"); + } + else + roQuestionCreator.updateQuestion(categoricalQuestion,int(node.@id), questionInfo.getId()); + } + + } + else if(currentState == "simple") + { + //Alert.show("simple state"); + var catSimpleobj:DisplayObject = pnlComponent.getChildAt(3); + var compCategoricalSimple:custom.db.questions.CategoricalSimple = custom.db.questions.CategoricalSimple(catSimpleobj); + var categoricalSimpleQuestion:actionscript.questions.Categorical = new actionscript.questions.Categorical(); - var Simpledict:Dictionary = new Dictionary(); - Simpledict = compCategoricalSimple.getDictionary(); - for (var option:Object in Simpledict) - { - var OptionsSimple:actionscript.questions.CategoricalOption = new actionscript.questions.CategoricalOption(); - OptionsSimple.optionKey = option.toString(); - Alert.show("Key : " + option.toString()); - OptionsSimple.choices = Simpledict[key]; - categoricalSimpleQuestion.categoricalOptions.addItem(OptionsSimple); - } - categoricalSimpleQuestion.type = questionInfo.getType(); - categoricalSimpleQuestion.question = questionInfo.getQuestion(); - categoricalSimpleQuestion.sequenceNo = int(questionInfo.getSequenceNo()); - /*for(var j:int = 0; j < categoricalSimpleQuestion.categoricalOptions.length ; j++) - { - var testoption:ASCategoricalOption = new ASCategoricalOption(); - testoption = ASCategoricalOption(categoricalSimpleQuestion.categoricalOptions.getItemAt(i)); - trace(testoption.optionKey); - trace(testoption.choices); - }*/ - Alert.show("Question: " + categoricalSimpleQuestion.question); - Alert.show("SeQ No: " + categoricalSimpleQuestion.sequenceNo); - Alert.show("Type : " + categoricalSimpleQuestion.type); - - roQuestionCreator.saveQuestion(categoricalSimpleQuestion,1); - - } - //roQuestionCreator.saveQuestion(int(questionInfo.getSequenceNo()),questionInfo.getQuestion(),questionInfo.getType(),int(parentModule.@id)); + var Simpledict:Dictionary = new Dictionary(); + Simpledict = compCategoricalSimple.getDictionary(); + for (var option:Object in Simpledict) + { + var OptionsSimple:actionscript.questions.CategoricalOption = new actionscript.questions.CategoricalOption(); + OptionsSimple.optionKey = option.toString(); + //Alert.show("Key : " + option.toString()); + OptionsSimple.choices = Simpledict[key]; + categoricalSimpleQuestion.categoricalOptions.addItem(OptionsSimple); + } + categoricalSimpleQuestion.type = questionInfo.getType(); + categoricalSimpleQuestion.question = questionInfo.getQuestion(); + categoricalSimpleQuestion.sequenceNo = int(questionInfo.getSequenceNo()); + /*for(var j:int = 0; j < categoricalSimpleQuestion.categoricalOptions.length ; j++) + { + var testoption:ASCategoricalOption = new ASCategoricalOption(); + testoption = ASCategoricalOption(categoricalSimpleQuestion.categoricalOptions.getItemAt(i)); + trace(testoption.optionKey); + trace(testoption.choices); + }*/ + /*Alert.show("Question: " + categoricalSimpleQuestion.question); + Alert.show("SeQ No: " + categoricalSimpleQuestion.sequenceNo); + Alert.show("Type : " + categoricalSimpleQuestion.type);*/ + + + if(questionInfo.getId() == 0) + { + if(checkSeqNoQuestion.length() > 0) + { + Alert.show("Sequence number " + questionInfo.getSequenceNo() + " already exists!"); + } + else + roQuestionCreator.saveQuestion(categoricalSimpleQuestion,int(node.@id)); + } + else + { + if(checkSeqNoQuestion.length() > 1) + { + Alert.show("Sequence number " + questionInfo.getSequenceNo() + " already exists!"); + } + else + roQuestionCreator.updateQuestion(categoricalSimpleQuestion,int(node.@id), questionInfo.getId()); + } + + } + else if(currentState == "question") + { + + var question:actionscript.questions.Question = new actionscript.questions.Question(); + + question.question = questionInfo.getQuestion(); + question.sequenceNo = int(questionInfo.getSequenceNo()); + question.type = questionInfo.getType(); + //Alert.show("Type : " + question.type); + if(questionInfo.getId() == 0) + { + if(checkSeqNoQuestion.length() > 0) + { + Alert.show("Sequence number " + questionInfo.getSequenceNo() + " already exists!"); + } + else + roQuestionCreator.saveQuestion(question,int(node.@id)); + } + else + { + if(checkSeqNoQuestion.length() > 1) + { + Alert.show("Sequence number " + questionInfo.getSequenceNo() + " already exists!"); + } + else + roQuestionCreator.updateQuestion(question,int(node.@id), questionInfo.getId()); + } + + } + } } @@ -896,96 +1116,142 @@ public function resultSaveQuestionHandler(event:ResultEvent):void { - var test_object:Object = event.result as Object; - Alert.show("Type came from server is: " + test_object.type); - if(test_object.type == "psychometric") + var question_Object:actionscript.questions.Question = actionscript.questions.Question(event.result as Object); + if(question_Object != null) { - var questionResult:actionscript.questions.Psychometric = actionscript.questions.Psychometric(event.result as Object); - Alert.show("Id is: " + questionResult.id); - Alert.show("Question is: " + questionResult.question); - Alert.show("Type is: " + questionResult.type); - Alert.show("SeQNo is: " + questionResult.sequenceNo); + var newQuestionNode:XML = createQuestionNode(question_Object); + Alert.show("question_Object.questionGroup.id " + question_Object.questionGroup.id); + var questionGroup:XMLList = survey.module.block.questiongroup.(@id == question_Object.questionGroup.id); + Alert.show("question_Object.questionGroup.length " + questionGroup.length()); + if( questionGroup.length() > 0 ) + { + questionGroup[0].appendChild(newQuestionNode); + currentState = "none"; + btnsaveQuestion.enabled = false; + } + } + else + Alert.show("Error in creating Question!"); + + + } + + public function resultUpdateQuestionHandler(event:ResultEvent):void + { + var question:actionscript.questions.Question = actionscript.questions.Question(event.result as Object); + if(question == null) + { + Alert.show("Error in creating Question!"); + } + else + { + var newNode:XML = <question/>; + newNode.setLocalName("question"); + var newQNode:XML = <question/>; + newQNode.setLocalName("question"); + var choices:String=""; + if(question.type.toLowerCase() == "psychometric") + { + var psychometricResult:actionscript.questions.Psychometric = actionscript.questions.Psychometric(question); + /*Alert.show("Id is: " + psychometricResult.id); + Alert.show("Question is: " + psychometricResult.question); + Alert.show("Type is: " + psychometricResult.type); + Alert.show("SeQNo is: " + psychometricResult.sequenceNo);*/ + var newPNode:XML = <psychometric/>; newPNode.setLocalName("psychometric"); - newPNode.@id = questionResult.id; - newPNode.@scale = questionResult.scale; - newPNode.@noOfInterval = questionResult.maxSliderValue; - for(var j:int = 0; j < questionResult.choices.length; j++) + var psychometricList:XMLList = psychometricQuestions.psychometric.(@id == psychometricResult.id); + + if( psychometricList.length() > 0 ) { - var str:String = "choice"; - str = str + j; - newPNode.@str = questionResult.choices[j]; + newPNode.@scale = psychometricResult.scale; + newPNode.@maxSliderValue = psychometricResult.maxSliderValue; + + newQNode.@sequenceNo = psychometricResult.sequenceNo; + newQNode.@title = psychometricResult.question; + newQNode.@type = psychometricResult.type; + choices = ""; + if(psychometricResult.choices != null) + { + + for(var k:int = 0; k < psychometricResult.choices.length; k++) + { + choices = choices + psychometricResult.choices[k]; + choices = choices + "," + + } + + newPNode.@choices = choices; + } + } - - psychometricQuestions.appendChild(newPNode); - + } - else if(test_object.type.toLowerCase() == "categorical") + else if(question.type.toLowerCase() == "categorical") { - var categoricalResult:actionscript.questions.Categorical = actionscript.questions.Categorical(test_object); - var newQNode:XML = <question/>; - newQNode.setLocalName("question"); + var categoricalResult:actionscript.questions.Categorical = actionscript.questions.Categorical(question); + newQNode.@sequenceNo = categoricalResult.sequenceNo; newQNode.@title = categoricalResult.question; newQNode.@type = categoricalResult.type; newQNode.@id = categoricalResult.id; - var questionGroup:XMLList =survey.module.block.questiongroup.(@header == node.@header); - - if( questionGroup.length() > 0 ) - { - questionGroup[0].appendChild(newQNode); - currentState = "none"; - btnsaveQuestion.enabled = false; - } + + //flagType false means it is simple type, otherwise it is relative type + var flagType:Boolean = false; var newCNode:XML = <categorical/>; newCNode.setLocalName("categorical"); - newCNode.@id = categoricalResult.id; - categoricalQuestions.appendChild(newCNode); - - for(var i:int = 0; i < categoricalResult.categoricalOptions.length ; i++) - { - var options:actionscript.questions.CategoricalOption = new actionscript.questions.CategoricalOption(); - options = actionscript.questions.CategoricalOption(categoricalResult.categoricalOptions.getItemAt(i)); - var newOptionNode:XML = <option/>; - newOptionNode.setLocalName("option"); - newOptionNode.@name = options.optionKey; - if(options.choices.length <= 0) - { - newCNode.@type = "simple"; - - } - else - { - newCNode.@type = "relative"; - for(var k:int = 0; k < options.choices.length; k++) - { - var choice:String = "choice"; - choice = choice + k; - newOptionNode.@choice = options.choices[k]; - } - } - - /*var module:XMLList = survey.module.(@id == tempmodule.id); - if( module.length() > 0 ) - { - module[0].appendChild(newBlockNode); - }*/ - newCNode.appendChild(newOptionNode); - } + var categoricalList:XMLList = categoricalQuestions.categorical.(@id == categoricalResult.id); - } - - currentState = "none"; - btnsaveQuestion.enabled = false; - - - } - - public function resultUpdateQuestionHandler(event:Event):void - { + if( categoricalList.length() > 0 ) + { + //remove all the <option> tags and then add those rather than modifying those. It is simple. + var children:XMLList = categoricalList.children(); + + for(var l:Number=0; l < children.length(); l++) + { + delete children[i]; + } + + + if(categoricalResult.categoricalOptions != null) + { + + for(var i:int = 0; i < categoricalResult.categoricalOptions.length ; i++) + { + var options:actionscript.questions.CategoricalOption = new actionscript.questions.CategoricalOption(); + options = actionscript.questions.CategoricalOption(categoricalResult.categoricalOptions.getItemAt(i)); + var newOptionNode:XML = <option/>; + newOptionNode.setLocalName("option"); + newOptionNode.@name = options.optionKey; + if(options.choices.length == 0) + { + flagType = false + } + else + { + flagType = true; + choices=""; + + for(k = 0; k < options.choices.length; k++) + { + choices = choices + options.choices[k]; + choices = choices + "," + } + newOptionNode.@choices = choices; + } + if(flagType) + newCNode.@type = "relative"; + else + newCNode.@type = "simple"; + newCNode.appendChild(newOptionNode); + } + } + } + } + } } //Question functionality Stop @@ -1024,6 +1290,7 @@ var selectedNode:int; var node:XML = XML(tree.selectedItem); + lbltest.text = node.@id; if(node.localName() == "module") { currentState = "module"; @@ -1076,10 +1343,15 @@ btnsaveQuestion.enabled = false; //set all fields + questionGroupInfo.setHeader(node.@header); questionGroupInfo.setDescription(node.@description); questionGroupInfo.setSequenceNo(node.@sequenceNo); questionGroupInfo.setId(node.@id); + questionGroupInfo.setHours(node.@hours); + questionGroupInfo.setMinutes(node.@min); + questionGroupInfo.setSeconds(node.@sec); + //Alert.show("Question group id assigned is: " + node.@id); } @@ -1100,9 +1372,12 @@ questionInfo.setQuestion(node.@title); questionInfo.setSequenceNo(node.@sequenceNo); questionInfo.setId(node.@id); + var str:String = node.@type; + /*Alert.show("q type is: " + node.@type); + questionInfo.cmbType.selectedItem = str.toLowerCase();*/ + questionInfo.setQuestionType(node.@type); - if(node.@type == "categorical") { currentState = "categorical"; @@ -1110,9 +1385,9 @@ var compCate... [truncated message content] |
From: Kalin J. <kj...@as...> - 2009-07-19 20:37:29
|
My work today has completed the html for module 4, and about halfway through the html for module 3 (communication) I would work longer, but my computer does not seem like it will last more than a minute if unplugged. On Sun, Jul 19, 2009 at 1:36 PM, Kalin Jonas <kj...@as...> wrote: > At 13:30 pm (1.5 hr), it came to my attention that my laptop is currently > at 1% battery life. > Seeing as I do not currently have a functioning charger (mine will not > increase the %, only stop it from dropping as fast) I must discontinue work, > as the cord slips on occasion, letting the charge drop. > Tomorrow I will be in at roughly 9am or 10am to continue working, if I can > get a charger by then. > > > On Sun, Jul 19, 2009 at 12:10 PM, Kalin Jonas <kj...@as...> wrote: > >> Today I will be working starting at 12:00 >> Today I will begin formatting blocks in html for use in the database. I >> will start from the last block, and work backwards, so as not to overlap >> with Seema's work. >> > > |
From: Kalin J. <kj...@as...> - 2009-07-19 20:36:29
|
At 13:30 pm (1.5 hr), it came to my attention that my laptop is currently at 1% battery life. Seeing as I do not currently have a functioning charger (mine will not increase the %, only stop it from dropping as fast) I must discontinue work, as the cord slips on occasion, letting the charge drop. Tomorrow I will be in at roughly 9am or 10am to continue working, if I can get a charger by then. On Sun, Jul 19, 2009 at 12:10 PM, Kalin Jonas <kj...@as...> wrote: > Today I will be working starting at 12:00 > Today I will begin formatting blocks in html for use in the database. I > will start from the last block, and work backwards, so as not to overlap > with Seema's work. > |
From: Kalin J. <kj...@as...> - 2009-07-19 19:10:45
|
Today I will be working starting at 12:00 Today I will begin formatting blocks in html for use in the database. I will start from the last block, and work backwards, so as not to overlap with Seema's work. |
From: Kalin J. <kj...@as...> - 2009-07-17 23:24:50
|
I returned to work at 14:15, and worked until 16:15 (2hr) on trying to extract the information from questions into a form that we could use to send them to the server. Additionally, a bit of text has been added to the ForecastingPeople component, which tells the user right at the start what the maximum number of people is for when they are filling in information. On Fri, Jul 17, 2009 at 1:41 PM, Kalin Jonas <kj...@as...> wrote: > At 13:30 (2.5hr) I am taking a lunch break. > At this time, I have completed the "Reset" button, and it will reset the > values of all psychometric and categorical questions in the current page. > The locations should be passed before the components are initialized now, > but I have not done extensive testing. > I have also corrected an error where the descriptions of questions were not > only part of the component, but also added into the page, so they showed up > twice. Now they only appear as part of the component. > > > On Fri, Jul 17, 2009 at 11:14 AM, Kalin Jonas <kj...@as...> wrote: > >> Today I arrived at 11 am >> First I will try to get the list of locations to be passed to the child >> objects before they initialize, so that the number of bays should truly be >> dynamic. >> Then I will begin implementing a button that says "reset" on each page, >> allowing a student to reset the psychometric and categorical questions. >> For the rest of my time working today, I will begin converting the text >> from the design document into usable html code for the server. >> > > |
From: <kj...@us...> - 2009-07-17 23:21:41
|
Revision: 187 http://virtualcommons.svn.sourceforge.net/virtualcommons/?rev=187&view=rev Author: kjonas Date: 2009-07-17 23:21:35 +0000 (Fri, 17 Jul 2009) Log Message: ----------- trying to extract the information from questions into a form that we can use to send them to the server. A bit of text has been added to the ForecastingPeople component, which tells the user right at the start what the maximum number of people is for when they are filling in information. I need to have services created so that I know what I'm going to be sending back and forth with the server to give it the answers to the questions and simulate a game. 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/InformationWindowPopup.mxml mentalmodels/trunk/flex/src/custom/InstructionPage.mxml mentalmodels/trunk/flex/src/custom/questions/CategoricalQuestionC.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/StrategyDesignQuestionC.mxml Modified: mentalmodels/trunk/flex/src/FisheryExperimentShell.mxml =================================================================== --- mentalmodels/trunk/flex/src/FisheryExperimentShell.mxml 2009-07-16 21:00:46 UTC (rev 186) +++ mentalmodels/trunk/flex/src/FisheryExperimentShell.mxml 2009-07-17 23:21:35 UTC (rev 187) @@ -94,8 +94,8 @@ public function init():void { // temporarily store all 3 objects returned... - allInfoWindowsA = makeWindows() as ArrayCollection; - allInfoWindowsB = makeWindows() as ArrayCollection; + allInfoWindowsA = makeWindows(); + allInfoWindowsB = makeWindows(); // extract the updaters updateObjectA = allInfoWindowsA.getItemAt(2) as InformationWindowCreator; Modified: mentalmodels/trunk/flex/src/actionscript/PageDisplay.as =================================================================== --- mentalmodels/trunk/flex/src/actionscript/PageDisplay.as 2009-07-16 21:00:46 UTC (rev 186) +++ mentalmodels/trunk/flex/src/actionscript/PageDisplay.as 2009-07-17 23:21:35 UTC (rev 187) @@ -13,6 +13,7 @@ import mx.collections.ArrayCollection; import mx.containers.VBox; + import mx.controls.Alert; import mx.controls.Text; @@ -67,10 +68,11 @@ { var tempQuestion:Question = Question(questionGroup.questions.getItemAt(question)); - var txt:Text = new Text(); - txt.width = 300; - txt.htmlText = tempQuestion.question; - tempBox.addChild(txt); +// //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 ForecastingPeople) { @@ -175,9 +177,9 @@ { return (DisplayObject)(pages.getItemAt(currentPageNumber)); // VALID_RESULT } - return (DisplayObject)(pages.getItemAt(pages.length - 1)); // too high + return (DisplayObject)(pages.getItemAt(currentPageNumber = pages.length - 1)); // too high } - return (DisplayObject)(pages.getItemAt(0)); // too low + return (DisplayObject)(pages.getItemAt(currentPageNumber = 0)); // too low } return null; // no pages @@ -199,5 +201,108 @@ 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); + } + } + + public function getQuestionResults():ArrayCollection + { + var curr:VBox = currentPage as VBox; + var questionResults:ArrayCollection = new ArrayCollection(); + var messages:String = ""; + + if(curr != null) + { + var tempQuestion:DisplayObject; + for(var i:int=0; i < curr.numChildren; i++) + { + tempQuestion = (curr.getChildAt(i) as DisplayObject); + var tempArray:ArrayCollection; + + if(tempQuestion == null) + { + messages += "(-)"; + } + else if(tempQuestion is ForecastingPeopleQuestionC) + { + messages += "(FP)"; + (tempQuestion as ForecastingPeopleQuestionC); + } + else if(tempQuestion is ForecastingFishQuestionC) + { + messages += "(FF)"; + (tempQuestion as ForecastingFishQuestionC); + } + else if(tempQuestion is CategoricalQuestionC) + { + messages += "(C)"; + tempArray = new ArrayCollection(); + tempArray.addItem((tempQuestion as CategoricalQuestionC).comboTopic.selectedItem); + var tempStr:String = (tempQuestion as CategoricalQuestionC).comboSpecific.selectedItem as String; + if(tempStr != null) + { + tempArray.addItem(tempStr); + } + } + else if(tempQuestion is PsychometricQuestionC) + { + messages += "(P)"; + (tempQuestion as PsychometricQuestionC).slider1.getValue(); + } + else if(tempQuestion is StrategyDesignQuestionC) + { + messages += "(S)"; + (tempQuestion as StrategyDesignQuestionC); + } + else if(tempQuestion is DayByDayDecisions) + { + messages += "(D)"; + (tempQuestion as DayByDayDecisionsQuestionC); + } + else if(tempQuestion is TextQuestionC) + { + messages += "(T)"; + (tempQuestion as TextQuestionC).textAnswer.text; + } + else + { + messages += "(-)"; + } + } +// Alert.show(messages); + } + + return questionResults; + } + } } \ No newline at end of file Modified: mentalmodels/trunk/flex/src/custom/FisheryExperimentCore.mxml =================================================================== --- mentalmodels/trunk/flex/src/custom/FisheryExperimentCore.mxml 2009-07-16 21:00:46 UTC (rev 186) +++ mentalmodels/trunk/flex/src/custom/FisheryExperimentCore.mxml 2009-07-17 23:21:35 UTC (rev 187) @@ -40,6 +40,7 @@ <mx:Label id="end" text="Thank you for playing!" fontSize="30"/> </mx:AddChild> <mx:SetProperty target="{btnAccept}" name="enabled" value="false"/> + <mx:SetProperty target="{btnReset}" name="enabled" value="false"/> <mx:SetProperty target="{btnBack}" name="enabled" value="false"/> <mx:SetProperty target="{btnForward}" name="enabled" value="false"/> </mx:State> @@ -49,9 +50,10 @@ <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:HBox id="buttonBar" left="{(width-buttonBar.width)/2}" bottom="0" horizontalGap="150"> + <mx:HBox id="buttonBar" left="{(width-buttonBar.width)/2}" bottom="0" horizontalGap="100"> <mx:Button id="btnBack" label="« Back" click="back()" enabled="false"/> <mx:Button id="btnAccept" label="Accept" click="accept()" /> + <mx:Button id="btnReset" label="Reset" click="reset()" enabled="false"/> <mx:Button id="btnForward" label="Forward »" click="forward()" enabled="false"/> </mx:HBox> @@ -106,8 +108,7 @@ return newLoc; } - [Bindable] - public var randomNumbers:String; + [Bindable] public var randomNumbers:String; private function ack(event:MessageAckEvent):void { //chart.setVisible(true); @@ -117,12 +118,12 @@ public function init():void { - moduleService.setToModule(1); + } private function gotoInstructions():void { - btnForward.enabled = btnBack.enabled = true; + btnForward.enabled = btnBack.enabled = btnReset.enabled = true; instructionsLoaded = true; currentState = "instructions"; } @@ -272,7 +273,7 @@ Id=ss.createStudent(info.getYear(), info.getSemester(), info.getGender(),info.getMajor()); currentState = "wait"; - btnBack.enabled = btnForward.enabled = true; + btnBack.enabled = btnForward.enabled = btnReset.enabled = true; getNextModule(); returnValue = true; @@ -309,11 +310,19 @@ } } - btnBack.enabled = btnForward.enabled = (currentState == "instructions"); + btnBack.enabled = btnForward.enabled = btnReset.enabled = (currentState == "instructions"); return returnValue; } + public function reset():void + { + if(content.getChildAt(0) is InstructionPage) + { + (content.getChildAt(0) as InstructionPage).reset(); + } + } + public function makeBlock():Block { var block1:Block = new Block(); Modified: mentalmodels/trunk/flex/src/custom/InformationWindowPopup.mxml =================================================================== --- mentalmodels/trunk/flex/src/custom/InformationWindowPopup.mxml 2009-07-16 21:00:46 UTC (rev 186) +++ mentalmodels/trunk/flex/src/custom/InformationWindowPopup.mxml 2009-07-17 23:21:35 UTC (rev 187) @@ -1,11 +1,8 @@ <?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);" - horizontalScrollPolicy="on" verticalScrollPolicy="on" - width="720" height="550"> + width="720" height="550" layout="vertical" + title="Information Window Popup" close="titleWindow_close(event);" showCloseButton="true" + horizontalScrollPolicy="on" verticalScrollPolicy="on"> <mx:Script> <![CDATA[ Modified: mentalmodels/trunk/flex/src/custom/InstructionPage.mxml =================================================================== --- mentalmodels/trunk/flex/src/custom/InstructionPage.mxml 2009-07-16 21:00:46 UTC (rev 186) +++ mentalmodels/trunk/flex/src/custom/InstructionPage.mxml 2009-07-17 23:21:35 UTC (rev 187) @@ -179,6 +179,14 @@ return 0; } + public function reset():void + { + if(pageDisplay != null) + { + pageDisplay.reset(); + } + } + public function save():ArrayCollection { var saveArray:ArrayCollection = new ArrayCollection(); Modified: mentalmodels/trunk/flex/src/custom/questions/CategoricalQuestionC.mxml =================================================================== --- mentalmodels/trunk/flex/src/custom/questions/CategoricalQuestionC.mxml 2009-07-16 21:00:46 UTC (rev 186) +++ mentalmodels/trunk/flex/src/custom/questions/CategoricalQuestionC.mxml 2009-07-17 23:21:35 UTC (rev 187) @@ -10,7 +10,7 @@ <mx:HBox id="content"> <mx:ComboBox id="comboTopic" - dataProvider="{topics}" selectedIndex="0"/> + dataProvider="{topics}"/> <mx:ComboBox id="comboSpecific" prompt="Select" dataProvider="{specifics.getItemAt(fix(comboTopic.selectedIndex, specifics))}"/> </mx:HBox> @@ -55,6 +55,8 @@ topics.addItem((arry.getItemAt(i) as CategoricalOption).optionKey); specifics.addItem((arry.getItemAt(i) as CategoricalOption).choices); } + comboTopic.selectedIndex = 0; + comboSpecific.selectedIndex = -1; description = question.question; } Modified: mentalmodels/trunk/flex/src/custom/questions/forecasting/ForecastingFishQuestionC.mxml =================================================================== --- mentalmodels/trunk/flex/src/custom/questions/forecasting/ForecastingFishQuestionC.mxml 2009-07-16 21:00:46 UTC (rev 186) +++ mentalmodels/trunk/flex/src/custom/questions/forecasting/ForecastingFishQuestionC.mxml 2009-07-17 23:21:35 UTC (rev 187) @@ -26,6 +26,7 @@ <mx:Script> <![CDATA[ + import actionscript.Location; import mx.controls.Alert; import actionscript.questions.ForecastingFish; import mx.collections.ArrayCollection; @@ -33,11 +34,20 @@ public var loadFish:ArrayCollection = null; public var loadPeople:ArrayCollection = null; - [Bindable] public var locations:ArrayCollection = new ArrayCollection(); + [Bindable] public var locations:ArrayCollection = new ArrayCollection([newLocation(10, 0.50),newLocation(20, 0.15),newLocation(30, 0.05)]); [Bindable] public var numBays:int = locations.length; [Bindable] public var numColumns:int = 6; + 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 init():void { fishEntry.initialize(); fishEntry.init(); Modified: mentalmodels/trunk/flex/src/custom/questions/forecasting/ForecastingPeopleQuestionC.mxml =================================================================== --- mentalmodels/trunk/flex/src/custom/questions/forecasting/ForecastingPeopleQuestionC.mxml 2009-07-16 21:00:46 UTC (rev 186) +++ mentalmodels/trunk/flex/src/custom/questions/forecasting/ForecastingPeopleQuestionC.mxml 2009-07-17 23:21:35 UTC (rev 187) @@ -8,6 +8,8 @@ ]]> </mx:Script> + <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"/> @@ -21,16 +23,26 @@ <mx:Script> <![CDATA[ + import actionscript.Location; import actionscript.questions.ForecastingPeople; import mx.collections.ArrayCollection; import custom.questions.forecasting.ForecastComponent; public var loadPeople:ArrayCollection = null; - [Bindable] public var locations:ArrayCollection = new ArrayCollection(); + [Bindable] public var locations:ArrayCollection = new ArrayCollection([newLocation(10, 0.50),newLocation(20, 0.15),newLocation(30, 0.05)]); [Bindable] public var numBays:int = locations.length; [Bindable] public var numColumns:int = 15; + 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 init():void { peopleEntry.initialize(); peopleEntry.init(); Modified: mentalmodels/trunk/flex/src/custom/questions/strategyDesign/StrategyDesignQuestionC.mxml =================================================================== --- mentalmodels/trunk/flex/src/custom/questions/strategyDesign/StrategyDesignQuestionC.mxml 2009-07-16 21:00:46 UTC (rev 186) +++ mentalmodels/trunk/flex/src/custom/questions/strategyDesign/StrategyDesignQuestionC.mxml 2009-07-17 23:21:35 UTC (rev 187) @@ -11,11 +11,11 @@ <mx:HBox> <mx:VBox> <mx:Label text="Not Repeated decisions (start-up)" fontSize="18"/> - <qComp:Planner id="notRepeated" locations="{locations}"/> + <qComp:Planner id="notRepeated" preinitialize="notRepeated.locations=this.locations"/> </mx:VBox> <mx:VBox> <mx:Label text="Repeated decisions (after start-up)" fontSize="18"/> - <qComp:Planner id="repeated" valueRequired="true" locations="{locations}"/> + <qComp:Planner id="repeated" valueRequired="true" preinitialize="repeated.locations=this.locations"/> </mx:VBox> </mx:HBox> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: Kalin J. <kj...@as...> - 2009-07-17 20:41:30
|
At 13:30 (2.5hr) I am taking a lunch break. At this time, I have completed the "Reset" button, and it will reset the values of all psychometric and categorical questions in the current page. The locations should be passed before the components are initialized now, but I have not done extensive testing. I have also corrected an error where the descriptions of questions were not only part of the component, but also added into the page, so they showed up twice. Now they only appear as part of the component. On Fri, Jul 17, 2009 at 11:14 AM, Kalin Jonas <kj...@as...> wrote: > Today I arrived at 11 am > First I will try to get the list of locations to be passed to the child > objects before they initialize, so that the number of bays should truly be > dynamic. > Then I will begin implementing a button that says "reset" on each page, > allowing a student to reset the psychometric and categorical questions. > For the rest of my time working today, I will begin converting the text > from the design document into usable html code for the server. > |
From: Kalin J. <kj...@as...> - 2009-07-17 18:20:00
|
Today I arrived at 11 am First I will try to get the list of locations to be passed to the child objects before they initialize, so that the number of bays should truly be dynamic. Then I will begin implementing a button that says "reset" on each page, allowing a student to reset the psychometric and categorical questions. For the rest of my time working today, I will begin converting the text from the design document into usable html code for the server. |
From: Kalin J. <kj...@as...> - 2009-07-16 21:04:31
|
I am completing my work today at 14:00pm (3.5hrs) My work on the accept button seems to have been successful, and should clear up the odd behaviour that I worked around in the past. I have now replaced this workaround code, and replaced it with a more concise way of doing the similar functionality. I made a help page, which can be seen in the most recent commit to the repository. It illustrates different functionality, though it might be out of date. Thirdly, I added basic timers which can be set to a certain percent. they currently just scroll across at set speeds for a few seconds and stop, but this can be changed later. On Thu, Jul 16, 2009 at 11:18 AM, Kalin Jonas <kj...@as...> wrote: > Today I arrived at 10:30am and began talking to Seema about the changes to > be done today. > I plan to alter the accept() function within the PageDisplay and > InstructionPage files to return values based on whether or not the current > block has finished, and whether that means the module is finished, instead > of just whether the module is finished. > Then I will work on the help page, making an image that will have arrows > pointing to the parts of the program that someone would want to use. > If I still have time, I will begin working on the abstain or reset buttons, > which will go through and reset all Psychometric and Categorical Questions > to their "unselected" or "incomplete" values. > |
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: Kalin J. <kj...@as...> - 2009-07-16 18:18:29
|
Today I arrived at 10:30am and began talking to Seema about the changes to be done today. I plan to alter the accept() function within the PageDisplay and InstructionPage files to return values based on whether or not the current block has finished, and whether that means the module is finished, instead of just whether the module is finished. Then I will work on the help page, making an image that will have arrows pointing to the parts of the program that someone would want to use. If I still have time, I will begin working on the abstain or reset buttons, which will go through and reset all Psychometric and Categorical Questions to their "unselected" or "incomplete" values. |
From: <al...@us...> - 2009-07-16 00:53:10
|
Revision: 185 http://virtualcommons.svn.sourceforge.net/virtualcommons/?rev=185&view=rev Author: alllee Date: 2009-07-16 00:23:57 +0000 (Thu, 16 Jul 2009) Log Message: ----------- fleshing out video creation a little more. May use QTJava directly instead, but that only works on Windows and Mac and may be unsupported soon. Added Paths: ----------- foraging/trunk/src/main/java/edu/asu/commons/foraging/util/AviOutputStream.java foraging/trunk/src/main/java/edu/asu/commons/foraging/util/DataChunkOutputStream.java foraging/trunk/src/main/java/edu/asu/commons/foraging/util/VideoFormat.java Added: foraging/trunk/src/main/java/edu/asu/commons/foraging/util/AviOutputStream.java =================================================================== --- foraging/trunk/src/main/java/edu/asu/commons/foraging/util/AviOutputStream.java (rev 0) +++ foraging/trunk/src/main/java/edu/asu/commons/foraging/util/AviOutputStream.java 2009-07-16 00:23:57 UTC (rev 185) @@ -0,0 +1,1184 @@ +package edu.asu.commons.foraging.util; +/** + * @(#)AVIOutputStream.java 1.1 2008-08-27 + * + * Copyright (c) 2008 Werner Randelshofer + * Staldenmattweg 2, CH-6405 Immensee, Switzerland + * All rights reserved. + * + * The copyright of this software is owned by Werner Randelshofer. + * You may not use, copy or modify this software, except in + * accordance with the license agreement you entered into with + * Werner Randelshofer. For details see accompanying license terms. + */ + + + +import java.awt.image.BufferedImage; +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.util.Date; +import java.util.LinkedList; + +import javax.imageio.IIOImage; +import javax.imageio.ImageIO; +import javax.imageio.ImageWriteParam; +import javax.imageio.ImageWriter; +import javax.imageio.stream.FileImageOutputStream; +import javax.imageio.stream.ImageOutputStream; +import javax.imageio.stream.MemoryCacheImageOutputStream; + +/** + * This class supports writing of images as frames into the video track of + * a AVI RIFF file. + * <p> + * All frames are encoded either using the Motion JPG or the PNG video format. + * When Motion JPG is used each frame can have an individual encoding quality. + * <p> + * All frames in an AVI file have the same duration. + * <p> + * For detailed information about the AVI RIFF file format see:<br> + * <a href="http://msdn.microsoft.com/en-us/library/ms779636.aspx">msdn.microsoft.com AVI RIFF</a><br> + * <a href="http://www.saettler.com/RIFFMCI/riffmci.html">www.saettler.com RIFF</a> + * + * @author Werner Randelshofer + * @version 1.1 2008-08-27 Fixed computation of dwMicroSecPerFrame in avih + * chunk. Changed the API to reflect that AVI works with frame rates instead of + * with frame durations. + * <br>1.0.1 2008-08-13 Use FourCC "MJPG" instead of "jpg " for JPG + * encoded video. + * <br>1.0 2008-08-11 Created. + */ +public class AviOutputStream { + + /** + * Output stream of the AVIOutputStream. + */ + private ImageOutputStream out; + + /** + * Current video formats. + */ + private VideoFormat videoFormat; + /** + * Quality of JPEG encoded video frames. + */ + private float quality = 0.9f; + /** + * Creation time of the movie output stream. + */ + private Date creationTime; + /** + * Width of the video frames. All frames must have the same width. + * The value -1 is used to mark unspecified width. + */ + private int imgWidth = -1; + /** + * Height of the video frames. All frames must have the same height. + * The value -1 is used to mark unspecified height. + */ + private int imgHeight = -1; + /** + * The timeScale of the movie. + * <p> + * Used with frameRate to specify the time scale that this stream will use. + * Dividing frameRate by timeScale gives the number of samples per second. + * For video streams, this is the frame rate. For audio streams, this rate + * corresponds to the time needed to play nBlockAlign bytes of audio, which + * for PCM audio is the just the sample rate. + */ + private int timeScale = 1; + /** + * The frameRate of the movie in timeScale units. + * <p> + * @see timeScale + */ + private int frameRate = 30; + + /** + * The states of the movie output stream. + */ + private static enum States { + + STARTED, FINISHED, CLOSED; + } + /** + * The current state of the movie output stream. + */ + private States state = States.FINISHED; + + /** + * AVI stores media data in samples. + * A sample is a single element in a sequence of time-ordered data. + */ + private static class Sample { + + /** Offset of the sample relative to the start of the AVI file. + */ + long offset; + /** Data length of the sample. */ + long length; + /** + * The duration of the sample in time scale units. + */ + int duration; + + /** + * Creates a new sample. + * @param duration + * @param offset + * @param length + */ + public Sample(int duration, long offset, long length) { + this.duration = duration; + this.offset = offset; + this.length = length; + } + } + /** + * List of video frames. + */ + private LinkedList<Sample> videoFrames; + /** + * This chunk holds the whole AVI content. + */ + private CompositeChunk aviChunk; + /** + * This chunk holds the movie frames. + */ + private CompositeChunk moviChunk; + /** + * This chunk holds the AVI Main Header. + */ + FixedSizeDataChunk avihChunk; + /** + * This chunk holds the AVI Stream Header. + */ + FixedSizeDataChunk strhChunk; + /** + * This chunk holds the AVI Stream Format Header. + */ + FixedSizeDataChunk strfChunk; + + /** + * Chunk base class. + */ + private abstract class Chunk { + + /** + * The chunkType of the chunk. A String with the length of 4 characters. + */ + protected String chunkType; + /** + * The offset of the chunk relative to the start of the + * ImageOutputStream. + */ + protected long offset; + + /** + * Creates a new Chunk at the current position of the ImageOutputStream. + * @param chunkType The chunkType of the chunk. A string with a length of 4 characters. + */ + public Chunk(String chunkType) throws IOException { + this.chunkType = chunkType; + offset = out.getStreamPosition(); + } + + /** + * Writes the chunk to the ImageOutputStream and disposes it. + */ + public abstract void finish() throws IOException; + + /** + * Returns the size of the chunk including the size of the chunk header. + * @return The size of the chunk. + */ + public abstract long size(); + } + + /** + * A CompositeChunk contains an ordered list of Chunks. + */ + private class CompositeChunk extends Chunk { + + /** + * The type of the composite. A String with the length of 4 characters. + */ + protected String compositeType; + private LinkedList<Chunk> children; + private boolean finished; + + /** + * Creates a new CompositeChunk at the current position of the + * ImageOutputStream. + * @param compositeType The type of the composite. + * @param chunkType The type of the chunk. + */ + public CompositeChunk(String compositeType, String chunkType) throws IOException { + super(chunkType); + this.compositeType = compositeType; + //out.write + out.writeLong(0); // make room for the chunk header + out.writeInt(0); // make room for the chunk header + children = new LinkedList<Chunk>(); + } + + public void add(Chunk child) throws IOException { + if (children.size() > 0) { + children.getLast().finish(); + } + children.add(child); + } + + /** + * Writes the chunk and all its children to the ImageOutputStream + * and disposes of all resources held by the chunk. + * @throws java.io.IOException + */ + public void finish() throws IOException { + if (!finished) { + if (size() > 0xffffffffL) { + throw new IOException("CompositeChunk \"" + chunkType + "\" is too large: " + size()); + } + + long pointer = out.getStreamPosition(); + out.seek(offset); + + DataChunkOutputStream headerData = new DataChunkOutputStream(new FilterImageOutputStream(out)); + headerData.writeType(compositeType); + headerData.writeUInt(size() - 8); + headerData.writeType(chunkType); + for (Chunk child : children) { + child.finish(); + } + out.seek(pointer); + if (size() % 2 == 1) { + out.writeByte(0); // write pad byte + } + finished = true; + } + } + + public long size() { + long length = 12; + for (Chunk child : children) { + length += child.size() + child.size() % 2; + } + return length; + } + } + + /** + * Data Chunk. + */ + private class DataChunk extends Chunk { + + private DataChunkOutputStream data; + private boolean finished; + + /** + * Creates a new DataChunk at the current position of the + * ImageOutputStream. + * @param chunkType The chunkType of the chunk. + */ + public DataChunk(String name) throws IOException { + super(name); + out.writeLong(0); // make room for the chunk header + data = new DataChunkOutputStream(new FilterImageOutputStream(out)); + } + + public DataChunkOutputStream getOutputStream() { + if (finished) { + throw new IllegalStateException("DataChunk is finished"); + } + return data; + } + + /** + * Returns the offset of this chunk to the beginning of the random access file + * @return + */ + public long getOffset() { + return offset; + } + + @Override + public void finish() throws IOException { + if (!finished) { + long sizeBefore = size(); + + if (size() > 0xffffffffL) { + throw new IOException("DataChunk \"" + chunkType + "\" is too large: " + size()); + } + + long pointer = out.getStreamPosition(); + out.seek(offset); + + DataChunkOutputStream headerData = new DataChunkOutputStream(new FilterImageOutputStream(out)); + headerData.writeType(chunkType); + headerData.writeUInt(size() - 8); + out.seek(pointer); + if (size() % 2 == 1) { + out.writeByte(0); // write pad byte + } + finished = true; + long sizeAfter = size(); + if (sizeBefore != sizeAfter) { + System.err.println("size mismatch " + sizeBefore + ".." + sizeAfter); + } + } + } + + @Override + public long size() { + return 8 + data.size(); + } + } + + /** + * A DataChunk with a fixed size. + */ + private class FixedSizeDataChunk extends Chunk { + + private DataChunkOutputStream data; + private boolean finished; + private long fixedSize; + + /** + * Creates a new DataChunk at the current position of the + * ImageOutputStream. + * @param chunkType The chunkType of the chunk. + */ + public FixedSizeDataChunk(String chunkType, long fixedSize) throws IOException { + super(chunkType); + this.fixedSize = fixedSize; + data = new DataChunkOutputStream(new FilterImageOutputStream(out)); + data.writeType(chunkType); + data.writeUInt(fixedSize); + data.clearCount(); + + // Fill fixed size with nulls + byte[] buf = new byte[(int) Math.min(512, fixedSize)]; + long written = 0; + while (written < fixedSize) { + data.write(buf, 0, (int) Math.min(buf.length, fixedSize - written)); + written += Math.min(buf.length, fixedSize - written); + } + if (fixedSize % 2 == 1) { + out.writeByte(0); // write pad byte + } + seekToStartOfData(); + } + + public DataChunkOutputStream getOutputStream() { + /*if (finished) { + throw new IllegalStateException("DataChunk is finished"); + }*/ + return data; + } + + /** + * Returns the offset of this chunk to the beginning of the random access file + * @return + */ + public long getOffset() { + return offset; + } + + public void seekToStartOfData() throws IOException { + out.seek(offset + 8); + data.clearCount(); + } + + public void seekToEndOfChunk() throws IOException { + out.seek(offset + 8 + fixedSize + fixedSize % 2); + } + + @Override + public void finish() throws IOException { + if (!finished) { + finished = true; + } + } + + @Override + public long size() { + return 8 + fixedSize; + } + } + + /** + * Creates a new output stream with the specified image videoFormat and + * framerate. + * + * @param file the output file + * @param format Selects an encoder for the video format "JPG" or "PNG". + * @exception IllegalArgumentException if videoFormat is null or if + * framerate is <= 0 + */ + public AviOutputStream(File file, VideoFormat format) throws IOException { + if (file.exists()) { + file.delete(); + } + out = new FileImageOutputStream(file); + + if (format == null) { + throw new IllegalArgumentException("format must not be null"); + } + + this.videoFormat = format; + + this.videoFrames = new LinkedList<Sample>(); + } + + /** + * Used with frameRate to specify the time scale that this stream will use. + * Dividing frameRate by timeScale gives the number of samples per second. + * For video streams, this is the frame rate. For audio streams, this rate + * corresponds to the time needed to play nBlockAlign bytes of audio, which + * for PCM audio is the just the sample rate. + * <p> + * The default value is 1. + * + * @param newValue + */ + public void setTimeScale(int newValue) { + if (newValue <= 0) { + throw new IllegalArgumentException("timeScale must be greater 0"); + } + this.timeScale = newValue; + } + + /** + * Returns the time scale of this media. + * + * @return time scale + */ + public int getTimeScale() { + return timeScale; + } + + /** + * Sets the rate of video frames in time scale units. + * <p> + * The default value is 30. Together with the default value 1 of timeScale + * this results in 30 frames pers second. + * + * @param newValue + */ + public void setFrameRate(int newValue) { + if (newValue <= 0) { + throw new IllegalArgumentException("frameDuration must be greater 0"); + } + if (state == States.STARTED) { + throw new IllegalStateException("frameDuration must be set before the first frame is written"); + } + this.frameRate = newValue; + } + + /** + * Returns the frame rate of this media. + * + * @return frame rate + */ + public int getFrameRate() { + return frameRate; + } + + /** + * Sets the compression quality of the video track. + * A value of 0 stands for "high compression is important" a value of + * 1 for "high image quality is important". + * <p> + * Changing this value affects frames which are subsequently written + * to the AVIOutputStream. Frames which have already been written + * are not changed. + * <p> + * This value has no effect on videos encoded with the PNG format. + * <p> + * The default value is 0.9. + * + * @param newValue + */ + public void setVideoCompressionQuality(float newValue) { + this.quality = newValue; + } + + /** + * Returns the video compression quality. + * + * @return video compression quality + */ + public float getVideoCompressionQuality() { + return quality; + } + + /** + * Sets the dimension of the video track. + * <p> + * You need to explicitly set the dimension, if you add all frames from + * files or input streams. + * <p> + * If you add frames from buffered images, then AVIOutputStream + * can determine the video dimension from the image width and height. + * + * @param width + * @param height + */ + public void setVideoDimension(int width, int height) { + if (width < 1 || height < 1) { + throw new IllegalArgumentException("width and height must be greater zero."); + } + this.imgWidth = width; + this.imgHeight = height; + } + + /** + * Sets the state of the QuickTimeOutpuStream to started. + * <p> + * If the state is changed by this method, the prolog is + * written. + */ + private void ensureStarted() throws IOException { + if (state != States.STARTED) { + creationTime = new Date(); + writeProlog(); + state = States.STARTED; + } + } + + /** + * Writes a frame to the video track. + * <p> + * If the dimension of the video track has not been specified yet, it + * is derived from the first buffered image added to the AVIOutputStream. + * + * @param image The frame image. + * + * @throws IllegalArgumentException if the duration is less than 1, or + * if the dimension of the frame does not match the dimension of the video + * track. + * @throws IOException if writing the image failed. + */ + public void writeFrame(BufferedImage image) throws IOException { + ensureOpen(); + ensureStarted(); + + // Get the dimensions of the first image + if (imgWidth == -1) { + imgWidth = image.getWidth(); + imgHeight = image.getHeight(); + } else { + // The dimension of the image must match the dimension of the video track + if (imgWidth != image.getWidth() || imgHeight != image.getHeight()) { + throw new IllegalArgumentException("Dimensions of image[" + videoFrames.size() + + "] (width=" + image.getWidth() + ", height=" + image.getHeight() + + ") differs from image[0] (width=" + + imgWidth + ", height=" + imgHeight); + } + } + + DataChunk videoFrameChunk = new DataChunk("00dc"); + moviChunk.add(videoFrameChunk); + MemoryCacheImageOutputStream imgOut = new MemoryCacheImageOutputStream(videoFrameChunk.getOutputStream()); + long offset = out.getStreamPosition(); + ImageWriter iw; + ImageWriteParam iwParam; + switch (videoFormat) { + case JPG: + iw = (ImageWriter) ImageIO.getImageWritersByMIMEType("image/jpeg").next(); + iwParam = iw.getDefaultWriteParam(); + iwParam.setCompressionMode(ImageWriteParam.MODE_EXPLICIT); + iwParam.setCompressionQuality(quality); + break; + case PNG: + default: + iw = (ImageWriter) ImageIO.getImageWritersByMIMEType("image/png").next(); + iwParam = iw.getDefaultWriteParam(); + break; + } + iw.setOutput(imgOut); + IIOImage img = new IIOImage(image, null, null); + iw.write(null, img, iwParam); + iw.dispose(); + long length = out.getStreamPosition() - offset; + videoFrameChunk.finish(); + + videoFrames.add(new Sample(frameRate, offset, length)); + if (out.getStreamPosition() > 1L << 32) { + throw new IOException("AVI file is larger than 4 GB"); + } + } + + /** + * Writes a frame from a file to the video track. + * <p> + * This method does not inspect the contents of the file. + * Its your responsibility to only add JPG files if you have chosen + * the JPEG video format, and only PNG files if you have chosen the PNG + * video format. + * <p> + * If you add all frames from files or from input streams, then you + * have to explicitly set the dimension of the video track before you + * call finish() or close(). + * + * @param file The file which holds the image data. + * + * @throws IllegalStateException if the duration is less than 1. + * @throws IOException if writing the image failed. + */ + public void writeFrame(File file) throws IOException { + FileInputStream in = null; + try { + in = new FileInputStream(file); + writeFrame(in); + } finally { + if (in != null) { + in.close(); + } + } + } + + /** + * Writes a frame to the video track. + * <p> + * This method does not inspect the contents of the file. + * Its your responsibility to only add JPG files if you have chosen + * the JPEG video format, and only PNG files if you have chosen the PNG + * video format. + * <p> + * If you add all frames from files or from input streams, then you + * have to explicitly set the dimension of the video track before you + * call finish() or close(). + * + * @param in The input stream which holds the image data. + * + * @throws IllegalArgumentException if the duration is less than 1. + * @throws IOException if writing the image failed. + */ + public void writeFrame(InputStream in) throws IOException { + ensureOpen(); + ensureStarted(); + + DataChunk videoFrameChunk = new DataChunk("00dc"); + moviChunk.add(videoFrameChunk); + OutputStream mdatOut = videoFrameChunk.getOutputStream(); + long offset = out.getStreamPosition(); + byte[] buf = new byte[512]; + int len; + while ((len = in.read(buf)) != -1) { + mdatOut.write(buf, 0, len); + } + long length = out.getStreamPosition() - offset; + videoFrameChunk.finish(); + videoFrames.add(new Sample(frameRate, offset, length)); + if (out.getStreamPosition() > 1L << 32) { + throw new IOException("AVI file is larger than 4 GB"); + } + } + + /** + * Closes the movie file as well as the stream being filtered. + * + * @exception IOException if an I/O error has occurred + */ + public void close() throws IOException { + if (state == States.STARTED) { + finish(); + } + if (state != States.CLOSED) { + out.close(); + state = States.CLOSED; + } + } + + /** + * Finishes writing the contents of the AVI output stream without closing + * the underlying stream. Use this method when applying multiple filters + * in succession to the same output stream. + * + * @exception IllegalStateException if the dimension of the video track + * has not been specified or determined yet. + * @exception IOException if an I/O exception has occurred + */ + public void finish() throws IOException { + ensureOpen(); + if (state != States.FINISHED) { + if (imgWidth == -1 || imgHeight == -1) { + throw new IllegalStateException("image width and height must be specified"); + } + + moviChunk.finish(); + writeEpilog(); + state = States.FINISHED; + imgWidth = imgHeight = -1; + } + } + + /** + * Check to make sure that this stream has not been closed + */ + private void ensureOpen() throws IOException { + if (state == States.CLOSED) { + throw new IOException("Stream closed"); + } + } + + private void writeProlog() throws IOException { + // The file has the following structure: + // + // .RIFF AVI + // ..avih (AVI Header Chunk) + // ..LIST strl + // ...strh (Stream Header Chunk) + // ...strf (Stream Format Chunk) + // ..LIST movi + // ...00dc (Compressed video data chunk in Track 00, repeated for each frame) + // ..idx1 (List of video data chunks and their location in the file) + + // The RIFF AVI Chunk holds the complete movie + aviChunk = new CompositeChunk("RIFF", "AVI "); + CompositeChunk hdrlChunk = new CompositeChunk("LIST", "hdrl"); + + // Write empty AVI Main Header Chunk - we fill the data in later + aviChunk.add(hdrlChunk); + avihChunk = new FixedSizeDataChunk("avih", 56); + avihChunk.seekToEndOfChunk(); + hdrlChunk.add(avihChunk); + + CompositeChunk strlChunk = new CompositeChunk("LIST", "strl"); + hdrlChunk.add(strlChunk); + + // Write empty AVI Stream Header Chunk - we fill the data in later + strhChunk = new FixedSizeDataChunk("strh", 56); + strhChunk.seekToEndOfChunk(); + strlChunk.add(strhChunk); + strfChunk = new FixedSizeDataChunk("strf", 40); + strfChunk.seekToEndOfChunk(); + strlChunk.add(strfChunk); + + moviChunk = new CompositeChunk("LIST", "movi"); + aviChunk.add(moviChunk); + + + } + + private void writeEpilog() throws IOException { + // Compute values + int duration = 0; + for (Sample s : videoFrames) { + duration += s.duration; + } + long bufferSize = 0; + for (Sample s : videoFrames) { + if (s.length > bufferSize) { + bufferSize = s.length; + } + } + + + DataChunkOutputStream d; + + /* Create Idx1 Chunk and write data + * ------------- + typedef struct _avioldindex { + FOURCC fcc; + DWORD cb; + struct _avioldindex_entry { + DWORD dwChunkId; + DWORD dwFlags; + DWORD dwOffset; + DWORD dwSize; + } aIndex[]; + } AVIOLDINDEX; + */ + DataChunk idx1Chunk = new DataChunk("idx1"); + aviChunk.add(idx1Chunk); + d = idx1Chunk.getOutputStream(); + + for (Sample f : videoFrames) { + + d.writeType("00dc"); // dwChunkId + // Specifies a FOURCC that identifies a stream in the AVI file. The + // FOURCC must have the form 'xxyy' where xx is the stream number and yy + // is a two-character code that identifies the contents of the stream: + // + // Two-character code Description + // db Uncompressed video frame + // dc Compressed video frame + // pc Palette change + // wb Audio data + + d.writeUInt(0x10); // dwFlags + // Specifies a bitwise combination of zero or more of the following + // flags: + // + // Value Name Description + // 0x10 AVIIF_KEYFRAME The data chunk is a key frame. + // 0x1 AVIIF_LIST The data chunk is a 'rec ' list. + // 0x100 AVIIF_NO_TIME The data chunk does not affect the timing of the + // stream. For example, this flag should be set for + // palette changes. + + d.writeUInt(f.offset - moviChunk.offset - 16); // dwOffset + // Specifies the location of the data chunk in the file. The value + // should be specified as an offset, in bytes, from the start of the + // 'movi' list; however, in some AVI files it is given as an offset from + // the start of the file. + + d.writeUInt(f.length); // dwSize + // Specifies the size of the data chunk, in bytes. + } + idx1Chunk.finish(); + + /* Write Data into AVI Main Header Chunk + * ------------- + * The AVIMAINHEADER structure defines global information in an AVI file. + * see http://msdn.microsoft.com/en-us/library/ms779632(VS.85).aspx + typedef struct _avimainheader { + FOURCC fcc; + DWORD cb; + DWORD dwMicroSecPerFrame; + DWORD dwMaxBytesPerSec; + DWORD dwPaddingGranularity; + DWORD dwFlags; + DWORD dwTotalFrames; + DWORD dwInitialFrames; + DWORD dwStreams; + DWORD dwSuggestedBufferSize; + DWORD dwWidth; + DWORD dwHeight; + DWORD dwReserved[4]; + } AVIMAINHEADER; */ + avihChunk.seekToStartOfData(); + d = avihChunk.getOutputStream(); + + d.writeUInt((1000000L * (long) timeScale) / (long) frameRate); // dwMicroSecPerFrame + // Specifies the number of microseconds between frames. + // This value indicates the overall timing for the file. + + d.writeUInt(0); // dwMaxBytesPerSec + // Specifies the approximate maximum data rate of the file. + // This value indicates the number of bytes per second the system + // must handle to present an AVI sequence as specified by the other + // parameters contained in the main header and stream header chunks. + + d.writeUInt(0); // dwPaddingGranularity + // Specifies the alignment for data, in bytes. Pad the data to multiples + // of this value. + + d.writeUInt(0x10); // dwFlags (0x10 == hasIndex) + // Contains a bitwise combination of zero or more of the following + // flags: + // + // Value Name Description + // 0x10 AVIF_HASINDEX Indicates the AVI file has an index. + // 0x20 AVIF_MUSTUSEINDEX Indicates that application should use the + // index, rather than the physical ordering of the + // chunks in the file, to determine the order of + // presentation of the data. For example, this flag + // could be used to create a list of frames for + // editing. + // 0x100 AVIF_ISINTERLEAVED Indicates the AVI file is interleaved. + // 0x1000 AVIF_WASCAPTUREFILE Indicates the AVI file is a specially + // allocated file used for capturing real-time + // video. Applications should warn the user before + // writing over a file with this flag set because + // the user probably defragmented this file. + // 0x20000 AVIF_COPYRIGHTED Indicates the AVI file contains copyrighted + // data and software. When this flag is used, + // software should not permit the data to be + // duplicated. + + d.writeUInt(videoFrames.size()); // dwTotalFrames + // Specifies the total number of frames of data in the file. + + d.writeUInt(0); // dwInitialFrames + // Specifies the initial frame for interleaved files. Noninterleaved + // files should specify zero. If you are creating interleaved files, + // specify the number of frames in the file prior to the initial frame + // of the AVI sequence in this member. + // To give the audio driver enough audio to work with, the audio data in + // an interleaved file must be skewed from the video data. Typically, + // the audio data should be moved forward enough frames to allow + // approximately 0.75 seconds of audio data to be preloaded. The + // dwInitialRecords member should be set to the number of frames the + // audio is skewed. Also set the same value for the dwInitialFrames + // member of the AVISTREAMHEADER structure in the audio stream header + + d.writeUInt(1); // dwStreams + // Specifies the number of streams in the file. For example, a file with + // audio and video has two streams. + + d.writeUInt(bufferSize); // dwSuggestedBufferSize + // Specifies the suggested buffer size for reading the file. Generally, + // this size should be large enough to contain the largest chunk in the + // file. If set to zero, or if it is too small, the playback software + // will have to reallocate memory during playback, which will reduce + // performance. For an interleaved file, the buffer size should be large + // enough to read an entire record, and not just a chunk. + + + d.writeUInt(imgWidth); // dwWidth + // Specifies the width of the AVI file in pixels. + + d.writeUInt(imgHeight); // dwHeight + // Specifies the height of the AVI file in pixels. + + d.writeUInt(0); // dwReserved[0] + d.writeUInt(0); // dwReserved[1] + d.writeUInt(0); // dwReserved[2] + d.writeUInt(0); // dwReserved[3] + // Reserved. Set this array to zero. + + /* Write Data into AVI Stream Header Chunk + * ------------- + * The AVISTREAMHEADER structure contains information about one stream + * in an AVI file. + * see http://msdn.microsoft.com/en-us/library/ms779638(VS.85).aspx + typedef struct _avistreamheader { + FOURCC fcc; + DWORD cb; + FOURCC fccType; + FOURCC fccHandler; + DWORD dwFlags; + WORD wPriority; + WORD wLanguage; + DWORD dwInitialFrames; + DWORD dwScale; + DWORD dwRate; + DWORD dwStart; + DWORD dwLength; + DWORD dwSuggestedBufferSize; + DWORD dwQuality; + DWORD dwSampleSize; + struct { + short int left; + short int top; + short int right; + short int bottom; + } rcFrame; + } AVISTREAMHEADER; + */ + strhChunk.seekToStartOfData(); + d = strhChunk.getOutputStream(); + d.writeType("vids"); // fccType - vids for video stream + // Contains a FOURCC that specifies the type of the data contained in + // the stream. The following standard AVI values for video and audio are + // defined: + // + // FOURCC Description + // 'auds' Audio stream + // 'mids' MIDI stream + // 'txts' Text stream + // 'vids' Video stream + + switch (videoFormat) { + case JPG: + d.writeType("MJPG"); // fccHandler - MJPG for Motion JPEG + break; + case PNG: + default: + d.writeType("png "); // fccHandler - png for PNG + break; + } + // Optionally, contains a FOURCC that identifies a specific data + // handler. The data handler is the preferred handler for the stream. + // For audio and video streams, this specifies the codec for decoding + // the stream. + + d.writeUInt(0); // dwFlags + // Contains any flags for the data stream. The bits in the high-order + // word of these flags are specific to the type of data contained in the + // stream. The following standard flags are defined: + // + // Value Name Description + // AVISF_DISABLED Indicates this stream should not be enabled + // by default. + // AVISF_VIDEO_PALCHANGES Indicates this video stream contains + // palette changes. This flag warns the playback + // software that it will need to animate the + // palette. + + d.writeUShort(0); // wPriority + // Specifies priority of a stream type. For example, in a file with + // multiple audio streams, the one with the highest priority might be + // the default stream. + + d.writeUShort(0); // wLanguage + // Language tag. + + d.writeUInt(0); // dwInitialFrames + // Specifies how far audio data is skewed ahead of the video frames in + // interleaved files. Typically, this is about 0.75 seconds. If you are + // creating interleaved files, specify the number of frames in the file + // prior to the initial frame of the AVI sequence in this member. For + // more information, see the remarks for the dwInitialFrames member of + // the AVIMAINHEADER structure. + + d.writeUInt(timeScale); // dwScale + // Used with dwRate to specify the time scale that this stream will use. + // Dividing dwRate by dwScale gives the number of samples per second. + // For video streams, this is the frame rate. For audio streams, this + // rate corresponds to the time needed to play nBlockAlign bytes of + // audio, which for PCM audio is the just the sample rate. + + d.writeUInt(frameRate); // dwRate + // See dwScale. + + d.writeUInt(0); // dwStart + // Specifies the starting time for this stream. The units are defined by + // the dwRate and dwScale members in the main file header. Usually, this + // is zero, but it can specify a delay time for a stream that does not + // start concurrently with the file. + + d.writeUInt(videoFrames.size()); // dwLength + // Specifies the length of this stream. The units are defined by the + // dwRate and dwScale members of the stream's header. + + d.writeUInt(bufferSize); // dwSuggestedBufferSize + // Specifies how large a buffer should be used to read this stream. + // Typically, this contains a value corresponding to the largest chunk + // present in the stream. Using the correct buffer size makes playback + // more efficient. Use zero if you do not know the correct buffer size. + + d.writeInt(-1); // dwQuality + // Specifies an indicator of the quality of the data in the stream. + // Quality is represented as a number between 0 and 10,000. + // For compressed data, this typically represents the value of the + // quality parameter passed to the compression software. If set to –1, + // drivers use the default quality value. + + d.writeUInt(0); // dwSampleSize + // Specifies the size of a single sample of data. This is set to zero + // if the samples can vary in size. If this number is nonzero, then + // multiple samples of data can be grouped into a single chunk within + // the file. If it is zero, each sample of data (such as a video frame) + // must be in a separate chunk. For video streams, this number is + // typically zero, although it can be nonzero if all video frames are + // the same size. For audio streams, this number should be the same as + // the nBlockAlign member of the WAVEFORMATEX structure describing the + // audio. + + d.writeUShort(0); // rcFrame.left + d.writeUShort(0); // rcFrame.top + d.writeUShort(imgWidth); // rcFrame.right + d.writeUShort(imgHeight); // rcFrame.bottom + // Specifies the destination rectangle for a text or video stream within + // the movie rectangle specified by the dwWidth and dwHeight members of + // the AVI main header structure. The rcFrame member is typically used + // in support of multiple video streams. Set this rectangle to the + // coordinates corresponding to the movie rectangle to update the whole + // movie rectangle. Units for this member are pixels. The upper-left + // corner of the destination rectangle is relative to the upper-left + // corner of the movie rectangle. + + /* Write BITMAPINFOHEADR Data into AVI Stream Format Chunk + /* ------------- + * see http://msdn.microsoft.com/en-us/library/ms779712(VS.85).aspx + typedef struct tagBITMAPINFOHEADER { + DWORD biSize; + LONG biWidth; + LONG biHeight; + WORD biPlanes; + WORD biBitCount; + DWORD biCompression; + DWORD biSizeImage; + LONG biXPelsPerMeter; + LONG biYPelsPerMeter; + DWORD biClrUsed; + DWORD biClrImportant; + } BITMAPINFOHEADER; + */ + strfChunk.seekToStartOfData(); + d = strfChunk.getOutputStream(); + d.writeUInt(40); // biSize + // Specifies the number of bytes required by the structure. This value + // does not include the size of the color table or the size of the color + // masks, if they are appended to the end of structure. + + d.writeInt(imgWidth); // biWidth + // Specifies the width of the bitmap, in pixels. + + d.writeInt(imgHeight); // biHeight + // Specifies the height of the bitmap, in pixels. + // + // For uncompressed RGB bitmaps, if biHeight is positive, the bitmap is + // a bottom-up DIB with the origin at the lower left corner. If biHeight + // is negative, the bitmap is a top-down DIB with the origin at the + // upper left corner. + // For YUV bitmaps, the bitmap is always top-down, regardless of the + // sign of biHeight. Decoders should offer YUV formats with postive + // biHeight, but for backward compatibility they should accept YUV + // formats with either positive or negative biHeight. + // For compressed formats, biHeight must be positive, regardless of + // image orientation. + + d.writeShort(1); // biPlanes + // Specifies the number of planes for the target device. This value must + // be set to 1. + + d.writeShort(24); // biBitCount + // Specifies the number of bits per pixel (bpp). For uncompressed + // formats, this value is the average number of bits per pixel. For + // compressed formats, this value is the implied bit depth of the + // uncompressed image, after the image has been decoded. + + switch (videoFormat) { + case JPG: + d.writeType("MJPG"); // biCompression - MJPG for Motion JPEG + break; + case PNG: + default: + d.writeType("png "); // biCompression - png for PNG + break; + } + // For compressed video and YUV formats, this member is a FOURCC code, + // specified as a DWORD in little-endian order. For example, YUYV video + // has the FOURCC 'VYUY' or 0x56595559. For more information, see FOURCC + // Codes. + // + // For uncompressed RGB formats, the following values are possible: + // + // Value Description + // BI_RGB Uncompressed RGB. + // BI_BITFIELDS Uncompressed RGB with color masks. Valid for 16-bpp and + // 32-bpp bitmaps. + // + // Note that BI_JPG and BI_PNG are not valid video formats. + // + // For 16-bpp bitmaps, if biCompression equals BI_RGB, the format is + // always RGB 555. If biCompression equals BI_BITFIELDS, the format is + // either RGB 555 or RGB 565. Use the subtype GUID in the AM_MEDIA_TYPE + // structure to determine the specific RGB type. + + d.writeInt(imgWidth * imgHeight * 3); // biSizeImage + // Specifies the size, in bytes, of the image. This can be set to 0 for + // uncompressed RGB bitmaps. + + d.writeInt(0); // biXPelsPerMeter + // Specifies the horizontal resolution, in pixels per meter, of the + // target device for the bitmap. + + d.writeInt(0); // biYPelsPerMeter + // Specifies the vertical resolution, in pixels per meter, of the target + // device for the bitmap. + + d.writeInt(0); // biClrUsed + // Specifies the number of color indices in the color table that are + // actually used by the bitmap. + + d.writeInt(0); // biClrImportant + // Specifies the number of color indices that are considered important + // for displaying the bitmap. If this value is zero, all colors are + // important. + + + // ----------------- + aviChunk.finish(); + } +} + Added: foraging/trunk/src/main/java/edu/asu/commons/foraging/util/DataChunkOutputStream.java =================================================================== --- foraging/trunk/src/main/java/edu/asu/commons/foraging/util/DataChunkOutputStream.java (rev 0) +++ foraging/trunk/src/main/java/edu/asu/commons/foraging/util/DataChunkOutputStream.java 2009-07-16 00:23:57 UTC (rev 185) @@ -0,0 +1,202 @@ +package edu.asu.commons.foraging.util; +/** + * @(#)DataChunkOutputStream.java 1.0 2008-08-11 + * + * Copyright (c) 2008 Werner Randelshofer + * Staldenmattweg 2, CH-6405 Immensee, Switzerland + * All rights reserved. + * + * The copyright of this software is owned by Werner Randelshofer. + * You may not use, copy or modify this software, except in + * accordance with the license agreement you entered into with + * Werner Randelshofer. For details see accompanying license terms. + */ + +import java.io.FilterOutputStream; +import java.io.IOException; +import java.io.OutputStream; +import java.io.UnsupportedEncodingException; +import java.util.GregorianCalendar; + +/** + * This output stream filter supports common data types used inside + * of AVI RIFF Data Chunks. + * + * @author Werner Randelshofer + * @version 1.0 2008-08-11 Created. + */ +public class DataChunkOutputStream extends FilterOutputStream { + + protected static final long MAC_TIMESTAMP_EPOCH = new GregorianCalendar(1904, GregorianCalendar.JANUARY, 1).getTimeInMillis(); + /** + * The number of bytes written to the data output stream so far. + * If this counter overflows, it will be wrapped to Integer.MAX_VALUE. + */ + protected long written; + + public DataChunkOutputStream(OutputStream out) { + super(out); + } + + /** + * Writes an Atom Type identifier (4 bytes). + * @param s A string with a length of 4 characters. + */ + public void writeType(String s) throws IOException { + if (s.length() != 4) { + throw new IllegalArgumentException("type string must have 4 characters"); + } + + try { + out.write(s.getBytes("ASCII"), 0, 4); + incCount(4); + } catch (UnsupportedEncodingException e) { + throw new InternalError(e.toString()); + } + } + + /** + * Writes out a <code>byte</code> to the underlying output stream as + * a 1-byte value. If no exception is thrown, the counter + * <code>written</code> is incremented by <code>1</code>. + * + * @param v a <code>byte</code> value to be written. + * @exception IOException if an I/O error occurs. + * @see java.io.FilterOutputStream#out + */ + public final void writeByte(int v) throws IOException { + out.write(v); + incCount(1); + } + + /** + * Writes <code>len</code> bytes from the specified byte array + * starting at offset <code>off</code> to the underlying output stream. + * If no exception is thrown, the counter <code>written</code> is + * incremented by <code>len</code>. + * + * @param b the data. + * @param off the start offset in the data. + * @param len the number of bytes to write. + * @exception IOException if an I/O error occurs. + * @see java.io.FilterOutputStream#out + */ + @Override + public synchronized void write(byte b[], int off, int len) + throws IOException { + out.write(b, off, len); + incCount(len); + } + + /** + * Writes the specified byte (the low eight bits of the argument + * <code>b</code>) to the underlying output stream. If no exception + * is thrown, the counter <code>written</code> is incremented by + * <code>1</code>. + * <p> + * Implements the <code>write</code> method of <code>OutputStream</code>. + * + * @param b the <code>byte</code> to be written. + * @exception IOException if an I/O error occurs. + * @see java.io.FilterOutputStream#out + */ + @Override + public synchronized void write(int b) throws IOException { + out.write(b); + incCount(1); + } + + /** + * Writes an <code>int</code> to the underlying output stream as four + * bytes, high byte first. If no exception is thrown, the counter + * <code>written</code> is incremented by <code>4</code>. + * + * @param v an <code>int</code> to be written. + * @exception IOException if an I/O error occurs. + * @see java.io.FilterOutputStream#out + */ + public void writeInt(int v) throws IOException { + out.write((v >>> 0) & 0xff); + out.write((v >>> 8) & 0xff); + out.write((v >>> 16) & 0xff); + out.write((v >>> 24) & 0xff); + incCount(4); + } + + /** + * Writes an unsigned 32 bit integer value. + * + * @param v The value + * @throws java.io.IOException + */ + public void writeUInt(long v) throws IOException { + out.write((int) ((v >>> 0) & 0xff)); + out.write((int) ((v >>> 8) & 0xff)); + out.write((int) ((v >>> 16) & 0xff)); + out.write((int) ((v >>> 24) & 0xff)); + incCount(4); + } + + /** + * Writes a signed 16 bit integer value. + * + * @param v The value + * @throws java.io.IOException + */ + public void writeShort(int v) throws IOException { + out.write((int) ((v >>> 0) & 0xff)); + out.write((int) ((v >> 8) & 0xff)); + incCount(2); + } + + public void writeLong(long v) throws IOException { + out.write((int) (v >>> 0) & 0xff); + out.write((int) (v >>> 8) & 0xff); + out.write((int) (v >>> 16) & 0xff); + out.write((int) (v >>> 24) & 0xff); + out.write((int) (v >>> 32) & 0xff); + out.write((int) (v >>> 40) & 0xff); + out.write((int) (v >>> 48) & 0xff); + out.write((int) (v >>> 56) & 0xff); + incCount(8); + } + + public void writeUShort(int v) throws IOException { + out.write((int) ((v >>> 0) & 0xff)); + out.write((int) ((v >> 8) & 0xff)); + incCount(2); + } + + /** + * Increases the written counter by the specified value + * until it reaches Long.MAX_VALUE. + */ + protected void incCount(int value) { + long temp = written + value; + if (temp < 0) { + temp = Long.MAX_VALUE; + } + written = temp; + } + + /** + * Returns the current value of the counter <code>written</code>, + * the number of bytes written to this data output stream so far. + * If the counter overflows, it will be wrapped to Integer.MAX_VALUE. + * + * @return the value of the <code>written</code> field. + * @see java.io.DataOutputStream#written + */ + public final long size() { + return written; + } + + /** + * Sets the value of the counter <code>written</code> to 0. + */ + public void clearCount() { + written = 0; + } + + +} Added: foraging/trunk/src/main/java/edu/asu/commons/foraging/util/VideoFormat.java =================================================================== --- foraging/trunk/src/main/java/edu/asu/commons/foraging/util/VideoFormat.java (rev 0) +++ foraging/trunk/src/main/java/edu/asu/commons/foraging/util/VideoFormat.java 2009-07-16 00:23:57 UTC (rev 185) @@ -0,0 +1,8 @@ +package edu.asu.commons.foraging.util; + +/** + * Supported video encodings. + */ +public enum VideoFormat { + JPG, PNG; +} \ 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-15 22:51:20
|
Revision: 184 http://virtualcommons.svn.sourceforge.net/virtualcommons/?rev=184&view=rev Author: kjonas Date: 2009-07-15 22:51:14 +0000 (Wed, 15 Jul 2009) Log Message: ----------- Core of program now known as FisheryExperimentCore.mxml, to be less confusing. Various components that rely on the number of bays, and information about them should now store a list of the Locations and their parameters. I have yet to work on the error-checking to ensure that the number of fish is less than the maxCapacity of a bay. SocioDemographicPage.mxml now has a drop-down menu with options Freshman, Sophomore, Junior, Senior, and Graduate/Other. Modified Paths: -------------- mentalmodels/trunk/flex/src/FisheryExperimentShell.mxml mentalmodels/trunk/flex/src/_InstructionsTest.mxml mentalmodels/trunk/flex/src/actionscript/PageDisplay.as 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/questions/dayByDayDecisions/DayByDayDecisionsQuestionC.mxml mentalmodels/trunk/flex/src/custom/questions/dayByDayDecisions/OneDay.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 Added Paths: ----------- mentalmodels/trunk/flex/src/custom/FisheryExperimentCore.mxml Removed Paths: ------------- mentalmodels/trunk/flex/src/custom/FisheryExperimentKalin.mxml Modified: mentalmodels/trunk/flex/src/FisheryExperimentShell.mxml =================================================================== --- mentalmodels/trunk/flex/src/FisheryExperimentShell.mxml 2009-07-15 21:54:25 UTC (rev 183) +++ mentalmodels/trunk/flex/src/FisheryExperimentShell.mxml 2009-07-15 22:51:14 UTC (rev 184) @@ -24,11 +24,11 @@ <mx:Button id="btnPickerB" label="{btnPickerA.label}" click="popupInformationWindow(2)"/> </mx:HBox> - <mx:Button id="btnResetPopups" label="Reset Popups" click="closedFunction()"/> + <mx:Button id="btnResetPopups" label="Reset Popups" click="{closedFunction(1);closedFunction(2)}"/> </mx:VBox> <mx:VBox id="vbxContent" horizontalAlign="center" verticalAlign="middle"> - <custom:FisheryExperimentKalin id="fisheryContent" blockLoader="loadBlock"/> + <custom:FisheryExperimentCore id="fisheryContent" blockLoader="loadBlock"/> </mx:VBox> <mx:Script> @@ -87,22 +87,23 @@ cbxChanged(); } - public function popupInformationWindow(source:int):void + public function popupInformationWindow(window:int):void { var temp:DisplayObject = null; var popupNew:InformationWindowPopup = PopUpManager.createPopUp(this, InformationWindowPopup, false) as InformationWindowPopup; popupNew.closedFunction = closedFunction; + popupNew.window = window; var old:TitleWindow = null; - if(source == 1) + if(window == 1) { old = InformationWindowA; popupA = popupNew; btnPickerA.enabled = cbxPickerA.enabled = false; } - else if(source == 2) + else if(window == 2) { old = InformationWindowB; popupB = popupNew; @@ -124,10 +125,10 @@ PopUpManager.centerPopUp(popupNew); } - public function closedFunction():void + public function closedFunction(window:int):void { var temp:DisplayObject = null; - if(popupA != null) + if(popupA != null && window == 1) { while(popupA.numChildren > 0) { @@ -140,7 +141,7 @@ popupA = null; } - if(popupB != null) + if(popupB != null && window == 2) { while(popupB.numChildren > 0) { Modified: mentalmodels/trunk/flex/src/_InstructionsTest.mxml =================================================================== --- mentalmodels/trunk/flex/src/_InstructionsTest.mxml 2009-07-15 21:54:25 UTC (rev 183) +++ mentalmodels/trunk/flex/src/_InstructionsTest.mxml 2009-07-15 22:51:14 UTC (rev 184) @@ -5,28 +5,43 @@ <mx:VBox> <mx:Button id="save" click="save_click()" label="Save"/> - <mx:Button id="load" click="bak_click()" label="Load"/> - <dayByDayDecisions:DayByDayDecisionsQuestionC id="day1"/> - <dayByDayDecisions:DayByDayDecisionsQuestionC id="day2"/> + <mx:Button id="load" click="load_click()" label="Load"/> + <strategyDesign:StrategyDesignQuestionC id="strat" locations="{locations}"/> + <dayByDayDecisions:DayByDayDecisionsQuestionC id="dayby" locations="{locations}"/> </mx:VBox> <mx:Script> <![CDATA[ public var arry:ArrayCollection = new ArrayCollection(); + [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 + { + var newLoc:Location = new Location(); + newLoc.maxCapacity = maxCapacity; + newLoc.growthRate = growth; + newLoc.initialPopulation = maxCapacity / 2.0; + return newLoc; + } + public function save_click():void { - arry = day1.save(); + } - public function bak_click():void + public function load_click():void { - day2.load(arry); + dayby.loadFromStrategy(strat.save()); } ]]> </mx:Script> + + + + + <mx:Script> <![CDATA[ import mx.controls.Alert; Modified: mentalmodels/trunk/flex/src/actionscript/PageDisplay.as =================================================================== --- mentalmodels/trunk/flex/src/actionscript/PageDisplay.as 2009-07-15 21:54:25 UTC (rev 183) +++ mentalmodels/trunk/flex/src/actionscript/PageDisplay.as 2009-07-15 22:51:14 UTC (rev 184) @@ -13,7 +13,6 @@ import mx.collections.ArrayCollection; import mx.containers.VBox; - import mx.controls.Label; import mx.controls.Text; @@ -26,15 +25,17 @@ public var minPagesRead:int; public var currentPageNumber:int; public var highestPageReached:int; + public var locations:ArrayCollection = null; public var currBlock:Block; - public function PageDisplay(newBlock:Block, minimumPagesRead:int=1) + public function PageDisplay(newBlock:Block, minimumPagesRead:int=1, locations:ArrayCollection=null) { currBlock = newBlock; minPagesRead = minimumPagesRead; currentPageNumber = 0; highestPageReached = currentPageNumber; + this.locations = locations; loadPages(); } @@ -74,6 +75,7 @@ if(tempQuestion is ForecastingPeople) { var fpq:ForecastingPeopleQuestionC = new ForecastingPeopleQuestionC(); + fpq.locations = locations; fpq.loadFromQuestion(ForecastingPeople(tempQuestion)); fpq.id = "q"+question; @@ -82,6 +84,7 @@ else if(tempQuestion is ForecastingFish) { var ffq:ForecastingFishQuestionC = new ForecastingFishQuestionC(); + ffq.locations = locations; ffq.loadFromQuestion(ForecastingFish(tempQuestion)); ffq.id = "q"+question; @@ -109,6 +112,7 @@ tempQuestion.type.toLowerCase() == "strategydesign") { var sdq:StrategyDesignQuestionC = new StrategyDesignQuestionC(); + sdq.locations = locations; sdq.loadFromQuestion(Question(tempQuestion)); sdq.id = "q"+question; @@ -118,6 +122,7 @@ tempQuestion.type.toLowerCase() == "daybydaydecisions") { var ddq:DayByDayDecisionsQuestionC = new DayByDayDecisionsQuestionC(); + ddq.locations = locations; ddq.loadFromQuestion(Question(tempQuestion)); ddq.id = "q"+question; Added: mentalmodels/trunk/flex/src/custom/FisheryExperimentCore.mxml =================================================================== --- mentalmodels/trunk/flex/src/custom/FisheryExperimentCore.mxml (rev 0) +++ mentalmodels/trunk/flex/src/custom/FisheryExperimentCore.mxml 2009-07-15 22:51:14 UTC (rev 184) @@ -0,0 +1,399 @@ +<?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="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}"> + <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="instructionsLoad"> + <mx:AddChild relativeTo="{content}"> + <comp:InstructionPage id="instructions" initialize="gotoInstructions()" locations="{locations}"/> + </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"/> + </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:SetProperty target="{btnAccept}" name="enabled" value="false"/> + <mx:SetProperty target="{btnBack}" name="enabled" value="false"/> + <mx:SetProperty target="{btnForward}" name="enabled" value="false"/> + </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="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: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; + public var currModuleNumber:int = 0; + public var currBlock:Block = null; + public var currBlockNumber: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; + + public var updateObjectA:InformationWindowCreator = null; + public var updateObjectB:InformationWindowCreator = null; + + public var instructionsLoaded:Boolean = false; + + private var shared:SharedObject; + private var flushMessage:String; + [Bindable] + public var Id : uint; + + 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; + } + + [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 + { + moduleService.setToModule(1); + } + + private function gotoInstructions():void + { + btnForward.enabled = btnBack.enabled = true; + instructionsLoaded = true; + currentState = "instructions"; + } + private function sendBlockQuestions():void + { + + } + private function getNextModule():void + { + sendBlockQuestions(); + currModule = null; + currModuleNumber++; + + moduleService.getModule(currModuleNumber); + } + 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) + { + 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) + { + currentState = "none"; + } + else if(!instructionsLoaded) + { + currentState = "instructionsLoad"; + } + else + { + gotoInstructions(); + } + } + private function moduleFaultHandler(event:FaultEvent):void + { + Alert.show(event.fault.message + "\n" + event.fault.getStackTrace()); + } + + public function getLocation():void + { + + } + private function locationResultHandler(event:ResultEvent):void + { + locations = new ArrayCollection(); + locations.addItem(newLocation(10, 0.50)); + locations.addItem(newLocation(20, 0.15)); + locations.addItem(newLocation(30, 0.05)); + } + private function locationFaultHandler(event:FaultEvent):void + { + + } + + 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 messageHandler(message:IMessage):void + { + randomNumbers = message.body as String; +// Alert.show( ""+randomNumbers); + } + + 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); + + currentState = "wait"; + getNextModule(); + + + var info:SocioDemographicPage = SocioDemographicPage(obj); + Id=ss.createStudent(info.getYear(), info.getSemester(), info.getGender(),info.getMajor()); + + btnBack.enabled = btnForward.enabled = true; + + returnValue = true; + } + } + if(obj is InstructionPage) + { + try + { + if( (InstructionPage)(obj).accept() ) + { + obj.visible = false; + expiredContent.addChild(obj); + currentState = "wait"; + getNextModule(); + //consumer.subscribe(); + returnValue = true; + } + else + { + var newCurrBlock:Block = (InstructionPage)(obj).block; + if(newCurrBlock != currBlock) + { + currBlock = newCurrBlock; + currBlockNumber++; + blockLoader.call(); + } + } + } + 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.categoricalOptions = new ArrayCollection(); + + var for1:ForecastingPeople = new ForecastingPeople(); + var for2:ForecastingFish = new 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> + +</mx:Canvas> + Deleted: mentalmodels/trunk/flex/src/custom/FisheryExperimentKalin.mxml =================================================================== --- mentalmodels/trunk/flex/src/custom/FisheryExperimentKalin.mxml 2009-07-15 21:54:25 UTC (rev 183) +++ mentalmodels/trunk/flex/src/custom/FisheryExperimentKalin.mxml 2009-07-15 22:51:14 UTC (rev 184) @@ -1,406 +0,0 @@ -<?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="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}"> - <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="instructionsLoad"> - <mx:AddChild relativeTo="{content}"> - <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"/> - </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="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: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; - 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] - 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); - } - - 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.getNextModule(); - - currModule = null; - return currModule; // set to null for now (clear old) - } - 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.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 - { - Alert.show(event.fault.message + "\n" + event.fault.getStackTrace()); - } - - private function resultHandler(event:ResultEvent):void - { - Id = event.result as uint; -// Alert.show("Student id is " + Id ); - consumer.disconnect(); - } - private function faultHandler(event:FaultEvent):void - { -// Alert.show("event fault is " + event.fault.faultDetail); - } - private function handleFault(event:MessageFaultEvent):void - { -// Alert.show("Message event fault is " + event.faultString); - } - - - private function messageHandler(message:IMessage):void - { - randomNumbers = message.body as String; -// Alert.show( ""+randomNumbers); - } - - 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); - - currentState = "wait"; - getModule(); - // - // END TEMPORARY CODE - // - - - var info:SocioDemographicPage = SocioDemographicPage(obj); - Id=ss.createStudent(info.getYear(), info.getSemester(), info.getGender(),info.getMajor()); - - 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"; - getModule(); - //consumer.subscribe(); - returnValue = true; - } - else - { - var newCurrBlock:Block = (InstructionPage)(obj).block; - if(newCurrBlock != currBlock) - { - currBlock = newCurrBlock; - currBlockNumber++; - blockLoader.call(); - } - } - } - 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.categoricalOptions = new ArrayCollection(); - - var for1:ForecastingPeople = new ForecastingPeople(); - var for2:ForecastingFish = new 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> - -</mx:Canvas> - Modified: mentalmodels/trunk/flex/src/custom/InformationWindowPopup.mxml =================================================================== --- mentalmodels/trunk/flex/src/custom/InformationWindowPopup.mxml 2009-07-15 21:54:25 UTC (rev 183) +++ mentalmodels/trunk/flex/src/custom/InformationWindowPopup.mxml 2009-07-15 22:51:14 UTC (rev 184) @@ -14,10 +14,11 @@ public var closedFunction:Function = null; public var valid:Boolean = true; + public var window:int = -1; private function titleWindow_close(evt:CloseEvent):void { - closedFunction.call(); + closedFunction.call(this,window); } ]]> </mx:Script> Modified: mentalmodels/trunk/flex/src/custom/InstructionPage.mxml =================================================================== --- mentalmodels/trunk/flex/src/custom/InstructionPage.mxml 2009-07-15 21:54:25 UTC (rev 183) +++ mentalmodels/trunk/flex/src/custom/InstructionPage.mxml 2009-07-15 22:51:14 UTC (rev 184) @@ -3,6 +3,7 @@ <mx:Script> <![CDATA[ + import actionscript.Location; import actionscript.QuestionGroup; import actionscript.Module; import custom.questions.forecasting.*; @@ -18,8 +19,21 @@ [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)]); + public var savedForecastPeople:ArrayCollection = null; + public var savedForecastFish:ArrayCollection = null; + public var savedStrategyDesign:ArrayCollection = null; + public var savedDayByDayDecisions: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 initModule(newModule:actionscript.Module):void { @@ -53,33 +67,27 @@ if(block != null && block.questionGroups != null) { minPagesRead = block.questionGroups.length - pageDisplay = new PageDisplay(block, minPagesRead); + pageDisplay = new PageDisplay(block, minPagesRead,locations); } if(pageDisplay == null) { debug2.text += "pageDisplay is null\n"; - pageDisplay = new PageDisplay(makeBlock(),0); + pageDisplay = new PageDisplay(makeBlock(),0,locations); } // pageDisplay = new PageDisplay(block, block.questionGroups.length); - - }catch(errObject:Error){ debug2.text += "pageDisplay creation failure\n" + errObject.message +"\n"+ errObject.getStackTrace() +"\n"; - pageDisplay = new PageDisplay(makeBlock(),0); + pageDisplay = new PageDisplay(makeBlock(),0,locations); // Alert.show(debug2.text); } -// debug2.text += "setting currPage...\n"; currPage = pageDisplay.currentPageNumber; -// debug2.text += "setting numPages...\n"; numPages = pageDisplay.pages.length; -// debug2.text += "adding currentPage...\n"; content.removeAllChildren(); content.addChild(pageDisplay.currentPage); -// debug2.text += "currentPage added.\n"; } public function back():Boolean Modified: mentalmodels/trunk/flex/src/custom/SocioDemographicPage.mxml =================================================================== --- mentalmodels/trunk/flex/src/custom/SocioDemographicPage.mxml 2009-07-15 21:54:25 UTC (rev 183) +++ mentalmodels/trunk/flex/src/custom/SocioDemographicPage.mxml 2009-07-15 22:51:14 UTC (rev 184) @@ -21,7 +21,7 @@ } public function getSemester():String { - return txtSemester.text; + return cbxSemester.selectedItem as String; } public function accept():Boolean @@ -57,14 +57,6 @@ txtMajor.setStyle(bgcolor, white); } - if(getSemester().length == 0) - { - txtSemester.setStyle(bgcolor, red); - ready=false; - }else{ - txtSemester.setStyle(bgcolor, white); - } - enable(!ready); return ready; } @@ -74,7 +66,7 @@ boxGender.enabled = enabled; txtYear.enabled = enabled; txtMajor.enabled = enabled; - txtSemester.enabled = enabled; + cbxSemester.enabled = enabled; } public function save():ArrayCollection @@ -95,9 +87,13 @@ radioMale.selected = (gender == "M"); radioFemale.selected = (gender == "F"); } + else + { + radioMale.selected = radioFemale.selected = false; + } txtYear.text = (loadArray.getItemAt(1) as String); txtMajor.text = (loadArray.getItemAt(2) as String); - txtSemester.text = (loadArray.getItemAt(3) as String); + cbxSemester.selectedIndex = (cbxSemester.dataProvider as ArrayCollection).getItemIndex(loadArray.getItemAt(3) as String); } ]]> @@ -130,7 +126,8 @@ <mx:HBox> <mx:Label text="Semester:" fontWeight="bold" width="100" textAlign="right"/> - <mx:TextInput id="txtSemester" width="75" maxChars="6"/> + <mx:ComboBox id="cbxSemester" selectedIndex="0" dataProvider="{new ArrayCollection(['Freshman','Sophomore','Junior','Senior','Graduate/Other'])}"/> + <!--<mx:TextInput id="txtSemester" width="75" maxChars="6"/>--> </mx:HBox> </mx:VBox> Modified: mentalmodels/trunk/flex/src/custom/questions/dayByDayDecisions/DayByDayDecisionsQuestionC.mxml =================================================================== --- mentalmodels/trunk/flex/src/custom/questions/dayByDayDecisions/DayByDayDecisionsQuestionC.mxml 2009-07-15 21:54:25 UTC (rev 183) +++ mentalmodels/trunk/flex/src/custom/questions/dayByDayDecisions/DayByDayDecisionsQuestionC.mxml 2009-07-15 22:51:14 UTC (rev 184) @@ -21,6 +21,7 @@ <mx:Script> <![CDATA[ + import actionscript.Location; import mx.controls.Alert; import mx.collections.ArrayCollection; import mx.controls.Button; @@ -28,11 +29,20 @@ import actionscript.questions.*; import custom.questions.dayByDayDecisions.OneDay; - public var numBays:int = 3; + [Bindable] public var locations:ArrayCollection = new ArrayCollection([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; + 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 init():void { buttons.removeAllChildren(); @@ -55,7 +65,7 @@ txtTemp.text = "Harbor"; labels.addChild(txtTemp); - for(var i:int = 0; i < numBays; i++) + for(var i:int = 0; i < locations.length; i++) { btnTemp = new Button(); btnTemp.label = "Bay" + (i+1); @@ -115,7 +125,7 @@ } var newDay:OneDay = new OneDay(); - newDay.numBays = numBays; + newDay.locations = locations; newDay.initialize(); newDay.day = dayByDayContent.numChildren + 1; newDay.dollarPerLb = dollarPerLb; @@ -138,7 +148,7 @@ var day:OneDay = dayByDayContent.getChildAt(i) as OneDay; var newDay:OneDay = new OneDay(); - newDay.numBays = numBays; + newDay.locations = locations; newDay.initialize(); newDay.day = day.day; newDay.dollarPerLb = day.day; Modified: mentalmodels/trunk/flex/src/custom/questions/dayByDayDecisions/OneDay.mxml =================================================================== --- mentalmodels/trunk/flex/src/custom/questions/dayByDayDecisions/OneDay.mxml 2009-07-15 21:54:25 UTC (rev 183) +++ mentalmodels/trunk/flex/src/custom/questions/dayByDayDecisions/OneDay.mxml 2009-07-15 22:51:14 UTC (rev 184) @@ -3,11 +3,12 @@ <mx:Script> <![CDATA[ + import actionscript.Location; import mx.controls.Text; import mx.controls.Label; import mx.collections.ArrayCollection; - [Bindable] public var numBays:int = 3; + [Bindable] public var locations:ArrayCollection = new ArrayCollection([newLocation(10, 0.50),newLocation(20, 0.15),newLocation(30, 0.05)]); [Bindable] public var decisions:ArrayCollection; public var previousTotal:Number = 0; @@ -15,13 +16,22 @@ public var day:int = 1; public var dollarPerLb:Number = 3.99; + 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 init():void { if(decisions == null) { drawNull(); } - else if(decisions.length < numBays+1) + else if(decisions.length < locations.length+1) { drawPartial(); } @@ -47,7 +57,7 @@ public function drawPartial():void { var temp:OneDecision; - for(var i:int = decisions.length; i < numBays+1; i++) + for(var i:int = decisions.length; i < locations.length+1; i++) { temp = new OneDecision(); temp.active = false; @@ -70,7 +80,7 @@ dayText.minWidth = 50; addChild(dayText); - for(var i:int = 0; i < numBays+1 && i < decisions.length; i++) + for(var i:int = 0; i < locations.length+1 && i < decisions.length; i++) { var temp:OneDecision = (decisions.getItemAt(i) as OneDecision); presentTotal += temp.lbsFished; @@ -100,7 +110,7 @@ } else { - for(var i:int = 0; i < locationChosen && i < numBays; i++) + for(var i:int = 0; i < locationChosen && i < locations.length; i++) { var tempInactive:OneDecision = new OneDecision(); tempInactive.active = false; Modified: mentalmodels/trunk/flex/src/custom/questions/forecasting/ForecastingFishQuestionC.mxml =================================================================== --- mentalmodels/trunk/flex/src/custom/questions/forecasting/ForecastingFishQuestionC.mxml 2009-07-15 21:54:25 UTC (rev 183) +++ mentalmodels/trunk/flex/src/custom/questions/forecasting/ForecastingFishQuestionC.mxml 2009-07-15 22:51:14 UTC (rev 184) @@ -33,8 +33,9 @@ public var loadFish:ArrayCollection = null; public var loadPeople:ArrayCollection = null; + [Bindable] public var locations:ArrayCollection = new ArrayCollection(); - [Bindable] public var numBays:int = 3; + [Bindable] public var numBays:int = locations.length; [Bindable] public var numColumns:int = 6; public function init():void Modified: mentalmodels/trunk/flex/src/custom/questions/forecasting/ForecastingPeopleQuestionC.mxml =================================================================== --- mentalmodels/trunk/flex/src/custom/questions/forecasting/ForecastingPeopleQuestionC.mxml 2009-07-15 21:54:25 UTC (rev 183) +++ mentalmodels/trunk/flex/src/custom/questions/forecasting/ForecastingPeopleQuestionC.mxml 2009-07-15 22:51:14 UTC (rev 184) @@ -26,8 +26,9 @@ import custom.questions.forecasting.ForecastComponent; public var loadPeople:ArrayCollection = null; + [Bindable] public var locations:ArrayCollection = new ArrayCollection(); - [Bindable] public var numBays:int = 3; + [Bindable] public var numBays:int = locations.length; [Bindable] public var numColumns:int = 15; public function init():void Modified: mentalmodels/trunk/flex/src/custom/questions/strategyDesign/Planner.mxml =================================================================== --- mentalmodels/trunk/flex/src/custom/questions/strategyDesign/Planner.mxml 2009-07-15 21:54:25 UTC (rev 183) +++ mentalmodels/trunk/flex/src/custom/questions/strategyDesign/Planner.mxml 2009-07-15 22:51:14 UTC (rev 184) @@ -5,11 +5,22 @@ <mx:Script> <![CDATA[ + import actionscript.Location; import mx.collections.ArrayCollection; import mx.controls.Label; public var valueRequired: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 + { + var newLoc:Location = new Location(); + newLoc.maxCapacity = maxCapacity; + newLoc.growthRate = growth; + newLoc.initialPopulation = maxCapacity / 2.0; + return newLoc; + } + private function init():void { if(valueRequired) @@ -27,6 +38,8 @@ { var newRow:PlannerRow = new PlannerRow(); newRow.valueRequired = this.valueRequired; + newRow.locations = locations; + newRow.initialize(); 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-07-15 21:54:25 UTC (rev 183) +++ mentalmodels/trunk/flex/src/custom/questions/strategyDesign/PlannerRow.mxml 2009-07-15 22:51:14 UTC (rev 184) @@ -1,11 +1,39 @@ <?xml version="1.0" encoding="utf-8"?> -<mx:HBox xmlns:mx="http://www.adobe.com/2006/mxml"> +<mx:HBox xmlns:mx="http://www.adobe.com/2006/mxml" initialize="init()"> <mx:Script> <![CDATA[ + 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)]); + 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 init():void + { + locs.removeAll(); + var obj:Object = new Object(); + obj.data = "Harbor"; + obj.label = obj.data; + locs.addItem(obj); + + for(var i:int=0; i<locations.length; i++) + { + obj = new Object(); + obj.data = "Bay " + (i+1); + obj.label = obj.data; + locs.addItem(obj); + } + } + public function deleteMe():void { if(!valueRequired || parent.numChildren > 1) @@ -30,16 +58,19 @@ } public function setLocation(newValue:String):void { - if(newValue == "Harbor") location.selectedIndex = 0; - if(newValue == "Bay 1") location.selectedIndex = 1; - if(newValue == "Bay 2") location.selectedIndex = 2; - if(newValue == "Bay 3") location.selectedIndex = 3; - if(newValue == "Bay 4") location.selectedIndex = 1; - if(newValue == "Bay 5") location.selectedIndex = 2; - if(newValue == "Bay 6") location.selectedIndex = 3; - if(newValue == "Bay 7") location.selectedIndex = 1; - if(newValue == "Bay 8") location.selectedIndex = 2; - if(newValue == "Bay 9") location.selectedIndex = 3; + try{ + if(newValue.indexOf("Bay ") == 0) + { + location.selectedIndex = int(newValue.substring(4)); + } + else + { + location.selectedIndex = 0; + } + }catch(err:Error){ + location.selectedIndex = 0; + } + changedLocation(); } public function getDays():Number @@ -67,12 +98,7 @@ ]]> </mx:Script> - <mx:ArrayCollection id="locs"> - <mx:Object label="Harbor" data="Harbor"/> - <mx:Object label="Bay 1" data="Bay 1"/> - <mx:Object label="Bay 2" data="Bay 2"/> - <mx:Object label="Bay 3" data="Bay 3"/> - </mx:ArrayCollection> + <mx:ArrayCollection id="locs"/> <mx:Button id="deleteRow" label="Del" click="deleteMe()" width="60"/> Modified: mentalmodels/trunk/flex/src/custom/questions/strategyDesign/StrategyDesignQuestionC.mxml =================================================================== --- mentalmodels/trunk/flex/src/custom/questions/strategyDesign/StrategyDesignQuestionC.mxml 2009-07-15 21:54:25 UTC (rev 183) +++ mentalmodels/trunk/flex/src/custom/questions/strategyDesign/StrategyDesignQuestionC.mxml 2009-07-15 22:51:14 UTC (rev 184) @@ -11,11 +11,11 @@ <mx:HBox> <mx:VBox> <mx:Label text="Not Repeated decisions (start-up)" fontSize="18"/> - <qComp:Planner id="notRepeated"/> + <qComp:Planner id="notRepeated" locations="{locations}"/> </mx:VBox> <mx:VBox> <mx:Label text="Repeated decisions (after start-up)" fontSize="18"/> - <qComp:Planner id="repeated" valueRequired="true"/> + <qComp:Planner id="repeated" valueRequired="true" locations="{locations}"/> </mx:VBox> </mx:HBox> @@ -39,6 +39,17 @@ 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)]); + + 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 getNotRepeated():ArrayCollection { return notRepeated.save(); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: Kalin J. <kj...@as...> - 2009-07-15 22:43:44
|
at 15:15, I ended work for the day (3.5hr) The sociodemographic page now has a drop-down menu for students to choose between the following: - Freshman - Sophomore - Junior - Senior - Graduate/Other "Other" was included just to cover any other options one would want to choose. I attempted to implement the Location class today. the only problem I encountered is that almost every component we have automatically initializes itself, which happens before I can give them new arrays of locations. The result is that they all take the default array of locations, rather than the one passed to them by their parent components. Tomorrow I will fix this. I think moving assignments into the preinitialize field should help. On Wed, Jul 15, 2009 at 12:04 PM, Kalin Jonas <kj...@as...> wrote: > Today I began talking to Seema and planning what to do at 11:45 am. > Today I am planning to implement the requested feature that selects between > Freshman/Sophomore/Junior/Senior for the Socio-Demographic page. > I will also include Graduate, which should just about cover all options > they would want to put in. > after this, I will be working primarily on implementing the Location class, > and using it to input values based on which bays are there. > This should clear up the problems such as incorrect maximums and minimums > for number of fish or people in each bay. > |
From: <kj...@us...> - 2009-07-15 22:14:48
|
Revision: 183 http://virtualcommons.svn.sourceforge.net/virtualcommons/?rev=183&view=rev Author: kjonas Date: 2009-07-15 21:54:25 +0000 (Wed, 15 Jul 2009) Log Message: ----------- Modified Paths: -------------- mentalmodels/trunk/src/main/java/edu/asu/commons/mme/service/ModuleService.java Modified: mentalmodels/trunk/src/main/java/edu/asu/commons/mme/service/ModuleService.java =================================================================== --- mentalmodels/trunk/src/main/java/edu/asu/commons/mme/service/ModuleService.java 2009-07-13 23:32:20 UTC (rev 182) +++ mentalmodels/trunk/src/main/java/edu/asu/commons/mme/service/ModuleService.java 2009-07-15 21:54:25 UTC (rev 183) @@ -17,21 +17,10 @@ @Transactional public class ModuleService extends Service.Base<Module, HibernateModuleDao>{ - public Integer currentModule = new Integer(1); - - public Module setToModule(int moduleNumber) + public Module getModule(int moduleNumber) { - currentModule = new Integer(moduleNumber); - Module tempModule = new Module(); - tempModule.setDescription("result of setModule - ignore!"); - return tempModule; - } - - public Module getNextModule() - { // Enter the sequence number in new Integer(Sequence number of module u want to fetch) - Module module = getDao().findByProperty("sequenceNo", currentModule); - setToModule(1 + currentModule.intValue()); + Module module = getDao().findByProperty("sequenceNo", moduleNumber); Hibernate.initialize(module); getLogger().debug("Module object is " + module.getDescription()); @@ -66,44 +55,4 @@ return module; } - public Module get1thModule() - { - // Enter the sequence number in new Integer(Sequence number of module u want to fetch) - setToModule(1); - Module module = getDao().findByProperty("sequenceNo", currentModule); - setToModule(1 + currentModule.intValue()); - - Hibernate.initialize(module); - getLogger().debug("Module object is " + module.getDescription()); - - Iterator<Block> iterateBlock = module.getBlocks().iterator(); - while(iterateBlock.hasNext()) - { - Block block = iterateBlock.next(); - Hibernate.initialize(block); - Iterator<QuestionGroup> iteratorquestionGrp = block.getQuestionGroups().iterator(); - { - while(iteratorquestionGrp.hasNext()) - { - QuestionGroup questionGroup = iteratorquestionGrp.next(); - Hibernate.initialize(questionGroup); - List<Question> questions = questionGroup.getQuestions(); - - for(int j = 0; j < questions.size(); j++) - { - Hibernate.initialize(questions.get(j)); - if(questions.get(j).getClass().getName().equalsIgnoreCase("edu.asu.commons.mme.entity.CategoricalQuestion")) - { - CategoricalQuestion categoricalQ = (CategoricalQuestion)questions.get(j); - Iterator<CategoricalOption> categoricalOption = categoricalQ.getCategoricalOptions().iterator(); - Hibernate.initialize(categoricalOption); - } - } - } - } - - } - return module; - } - } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: Kalin J. <kj...@as...> - 2009-07-15 19:34:07
|
Today I began talking to Seema and planning what to do at 11:45 am. Today I am planning to implement the requested feature that selects between Freshman/Sophomore/Junior/Senior for the Socio-Demographic page. I will also include Graduate, which should just about cover all options they would want to put in. after this, I will be working primarily on implementing the Location class, and using it to input values based on which bays are there. This should clear up the problems such as incorrect maximums and minimums for number of fish or people in each bay. |