[virtualcommons-svn] SF.net SVN: virtualcommons:[42] vcweb/trunk/virtualcommons/experiment
Status: Beta
Brought to you by:
alllee
From: <see...@us...> - 2008-08-16 00:02:26
|
Revision: 42 http://virtualcommons.svn.sourceforge.net/virtualcommons/?rev=42&view=rev Author: seematalele Date: 2008-08-16 00:02:36 +0000 (Sat, 16 Aug 2008) Log Message: ----------- modified the experiment.inc in order to work rule 2 but have some bugs. Modified Paths: -------------- vcweb/trunk/virtualcommons/experiment/experiment.inc vcweb/trunk/virtualcommons/experiment/games/forestry_v2/forestry_v2.module vcweb/trunk/virtualcommons/experiment/teacher_dashboard/teacher_dashboard.module Modified: vcweb/trunk/virtualcommons/experiment/experiment.inc =================================================================== --- vcweb/trunk/virtualcommons/experiment/experiment.inc 2008-08-15 00:15:12 UTC (rev 41) +++ vcweb/trunk/virtualcommons/experiment/experiment.inc 2008-08-16 00:02:36 UTC (rev 42) @@ -415,42 +415,31 @@ } //update start flag - if (! $this->isLastRound()) { - $this->updateStartFlag(true); + if ($this->isLastRound()) { + drupal_get_messages(); + drupal_set_message('Student flag is updated to TRUE'); + $this->updateStartFlag(false); } - // $this->prev_round_no=$round_no; + + else + { + $this->updateStartFlag(true); + } + + + //update current round_no $round_no=$round_no+1; $this->current_round_no = $round_no; - // drupal_set_message(t('Round no which is over is :' . $this->prev_round_no . 'Current round no set to is: ' . $this->current_round_no)); - //call setRound function - /* if ($round_no > ($this->getNumberOfRounds())) { - // reset round number to 1 - $this->current_round_no = 1; - // increment stage number and try to find a stage id for that stage - - $current_stage_no = $this->getCurrentStageNumber(); - $next_stage_id = $this->getStageId( $current_stage_no + 1 ); - if ($next_stage_id) { - db_query("UPDATE {vc_game} SET vc_stage_id=%d WHERE id=%d", $next_stage_id, $this->game_id); - } - else { - // experiment is over. figure out how to signal the end of - - } - } - else { - $this->current_round_no = $round_no; - }*/ + db_query("UPDATE {vc_game} SET current_round_no=%d WHERE id=%d", $this->current_round_no, $this->game_id); if ($voting_enabled) { //initialise the rule settings for next round.If game is finished don't initialise anything if(!($this->isFinished())) $this->initRules(); } - /*if($this->isStageOver()) - $this->setRoundNo($this->getCurrentRoundNo());*/ + } public function setRoundNo($round_no) @@ -491,9 +480,11 @@ $result_resource=db_query("select max_resources,vc_group_id from vc_forestry_common_resource_pool where vc_game_id=%d",$this->game_id); - while($data=db_fetch_object($result_resource)) + if($data=db_fetch_object($result_resource)) { - db_query("update vc_forestry_common_resource_pool set common_resource_pool=%d where vc_group_id=%d and vc_game_id=%d",$data->max_resources,$data->vc_group_id,$this>game_id); + //$data->max_resources; + //db_query("update vc_forestry_common_resource_pool set common_resource_pool=%d where vc_group_id=%d and vc_game_id=%d",$data->max_resources,$data->vc_group_id,$this>game_id); + db_query("update {vc_forestry_common_resource_pool} set common_resource_pool=%d where vc_game_id=%d and vc_group_id=%d",$data->max_resources,$this->game_id,$data->vc_group_id); drupal_set_message("vc_forestry_common_resource_pool si updated for group id, max resources: " . $data->vc_group_id . ', ' . $data->max_resources . ', ' . $this->game_id ); } $this->setRoundNo($this->getCurrentRoundNo()); @@ -590,13 +581,18 @@ private function generateTurnSequence($how_many, $no_of_students) { $students = range(1,$no_of_students); drupal_set_message("no of students need to be selected for this round are :" . $how_many); + //$keys=array(); $keys = array_rand( range(1, $no_of_students), $how_many ); $turn_sequence = array(); + if(! is_array($keys)) + { + $turn_sequence[] = $students[$keys]; + } for($i=0;$i<count($keys);$i++) { - drupal_set_message($students[$i]); - $turn_sequence[] = $students[$i]; + // drupal_set_message($keys[$i]); + $turn_sequence[] = $students[$keys[$i]]; } @@ -635,13 +631,50 @@ drupal_set_message("For some reason there were $no_of_student students - should never happen!"); break; } - $turn_sequence = implode(',', $this->generateTurnSequence($how_many, $no_of_student)); + $turn_sequence_array=$this->generateTurnSequence($how_many, $no_of_student); + //if $turn_sequence is an array then only implode with ',' else directly put the value in the database + if($how_many <> 1) + { + $turn_sequence = implode(',',$turn_sequence_array); + } + else + $turn_sequence = implode($turn_sequence_array); db_query("insert into {vc_forestry_turn_sequence}(round_no,turn_sequence,vc_group_id,vc_rules_id,vc_game_id) values (%d,'%s',%d,%d,%d)",$round_no,$turn_sequence,$group_id,$selected_rule_id,$this->game_id); } else if($selected_rule_no==2) { //setting for rule 2 + // pick N students for the Rotation + switch ($no_of_student) { + case 3: + // in even numbered rounds, pick only 1 person, otherwise + // pick two. but pick students sequentially. + if(($round_no%2)==1) + { + //round is uneven, pick 2 students which are always 1,2 in this case. + $turn_sequence = "1,2"; + } + else + $turn_sequence = "3"; + + break; + case 4: + case 5: + $how_many = 2; + + + break; + default: + drupal_set_message("For some reason there were $no_of_student students - should never happen!"); + break; + } + $turn_sequence_array=$this->generateTurnSequence($how_many, $no_of_student); + //if $turn_sequence is an array then only implode with ',' else directly put the value in the database + db_query("insert into {vc_forestry_turn_sequence}(round_no,turn_sequence,vc_group_id,vc_rules_id,vc_game_id) + values (%d,'%s',%d,%d,%d)",$round_no,$turn_sequence,$group_id,$selected_rule_id,$this->game_id); + + } else if($selected_rule_no==3) { Modified: vcweb/trunk/virtualcommons/experiment/games/forestry_v2/forestry_v2.module =================================================================== --- vcweb/trunk/virtualcommons/experiment/games/forestry_v2/forestry_v2.module 2008-08-15 00:15:12 UTC (rev 41) +++ vcweb/trunk/virtualcommons/experiment/games/forestry_v2/forestry_v2.module 2008-08-16 00:02:36 UTC (rev 42) @@ -174,7 +174,7 @@ $resource_before=0; $round_no = $group->getGame()->getCurrentRoundNo(); - +drupal_set_message($round_no); if($student->getGroup()->getGame()->isVotingEnabled()) { @@ -396,7 +396,7 @@ drupal_set_message(t('The game is over. Thanks for participating.'), 'warning', FALSE); } - else if($group->getGame()->isLastRound() || $group->getGame()->isStageOver()) + else if($group->getGame()->isStageOver() || $group->getGame()->isLastRound()) { drupal_set_message(t('This stage is now over. The next stage should begin shortly.'), 'warning', FALSE); $form['submit'] = array( Modified: vcweb/trunk/virtualcommons/experiment/teacher_dashboard/teacher_dashboard.module =================================================================== --- vcweb/trunk/virtualcommons/experiment/teacher_dashboard/teacher_dashboard.module 2008-08-15 00:15:12 UTC (rev 41) +++ vcweb/trunk/virtualcommons/experiment/teacher_dashboard/teacher_dashboard.module 2008-08-16 00:02:36 UTC (rev 42) @@ -125,6 +125,7 @@ ); if($start_flag) { + drupal_get_messages(); drupal_set_message(t('This stage needs voting. Please tell students to vote.'),'warning',FALSE); $form['submit'] = array( '#type' => 'submit', This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |