virtualcommons-svn Mailing List for Virtual Commons Experiment Software (Page 78)
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: <al...@us...> - 2008-10-24 19:42:27
|
Revision: 55 http://virtualcommons.svn.sourceforge.net/virtualcommons/?rev=55&view=rev Author: alllee Date: 2008-10-24 19:42:20 +0000 (Fri, 24 Oct 2008) Log Message: ----------- starting to sanitize module .install files to respect the db_prefix setting properly, need to surround all table names with curly brackets (with no spaces) Modified Paths: -------------- vcweb/trunk/virtualcommons/experiment/experiment.inc vcweb/trunk/virtualcommons/experiment/experiment.install vcweb/trunk/virtualcommons/experiment/experiment.module vcweb/trunk/virtualcommons/experiment/games/forestry/forestry_game/forestry_game.install vcweb/trunk/virtualcommons/experiment/games/forestry_v2/forestry_v2.install vcweb/trunk/virtualcommons/experiment/games/forestry_v2/forestry_v2.module vcweb/trunk/virtualcommons/experiment/rules/rules.install vcweb/trunk/virtualcommons/experiment/student_login/student_login.module vcweb/trunk/virtualcommons/experiment/survey/survey.install vcweb/trunk/virtualcommons/experiment/survey/survey.module vcweb/trunk/virtualcommons/experiment/teacher_dashboard/teacher_dashboard.install vcweb/trunk/virtualcommons/experiment/teacher_dashboard/teacher_dashboard.module Modified: vcweb/trunk/virtualcommons/experiment/experiment.inc =================================================================== --- vcweb/trunk/virtualcommons/experiment/experiment.inc 2008-10-23 21:56:35 UTC (rev 54) +++ vcweb/trunk/virtualcommons/experiment/experiment.inc 2008-10-24 19:42:20 UTC (rev 55) @@ -40,6 +40,7 @@ private $no_of_students; private $experiment_name; private $prev_round_no; + public function __construct($game_id, $experiment_id=-1, $teacher_id=-1, $no_of_students=-1) { $this->game_id = $game_id; @@ -53,7 +54,14 @@ } public function getNumberOfRounds() { - return db_result(db_query("select s.no_of_rounds as number_of_rounds from vc_stage s, vc_game g where s.id=g.vc_stage_id and g.id=%d",$this->game_id)); + /*if($this->isPracticeRound()) + { + return db_result(db_query("select s.no_of_practice_rounds as no_of_practice_rounds from vc_stage s, vc_game g where s.id=g.vc_stage_id and g.id=%d",$this->game_id)); + } + else + {*/ + return db_result(db_query("select s.no_of_rounds as number_of_rounds from vc_stage s, vc_game g where s.id=g.vc_stage_id and g.id=%d",$this->game_id)); + //} } public function getNumberOfStudents() { @@ -114,6 +122,10 @@ $this->no_of_students, $this->getStageId($this->current_stage_no), $this->current_round_no); + if($this->isPracticeRoundEnabled()) + $practice_round_flag=false; + + db_query("UPDATE {vc_game} set practice_round_flag =%d where id=%d",$practice_round_flag,$this->game_id); } } @@ -224,9 +236,9 @@ public function getAllGroupRoundInfo() { $result=db_query("SELECT vc_stage_id, round_no, g.group_no as group_no, total_harvest_decision, resources_before, resources_after, vc_rules_id, dice FROM {vc_forestry_group_round_info fgr,vc_group g} - WHERE g.vc_game_id=%d and fgr.vc_group_id=g.id + WHERE g.vc_game_id=%d and fgr.vc_group_id=g.id and fgr.practice_round_flag=%d ORDER BY round_no", - $this->game_id); + $this->game_id,$this->isPracticeRound()); $stage_data = array(); while($data = db_fetch_object($result)) { $round_no=$data->round_no; @@ -288,14 +300,42 @@ } + public function isPracticeRound() + { + $practice_round_flag=db_result(db_query("select practice_round_flag from vc_game where id=%d", $this->game_id)); + if($practice_round_flag) + { + return 0; + } + else + { + return 1; + } + } + + public function isLastRound() { - return ($this->getCurrentRoundNo() == $this->getNumberOfRounds()); + //check if it is a practice round for the current stage, if yes check if it is last practice round + if($this->isPracticeRound()) + { + return ($this->getCurrentRoundNo() == $this->getNumberofPracticeRounds()); + } + else + return ($this->getCurrentRoundNo() == $this->getNumberOfRounds()); } public function isStageOver() { - return (($this->getCurrentRoundNo() > $this->getNumberOfRounds()) || ($this->IsResourceOverForAllGroup())); + if(($this->getCurrentRoundNo() > $this->getNumberOfRounds()) || ($this->IsResourceOverForAllGroup())) + { + return 1; + } + else + { + return 0; + } + } public function getTurnSequence($group_id) { @@ -373,50 +413,96 @@ //drupal_get_messages(); while ($fetch_object = db_fetch_object($result)) { $student_id = $fetch_object->id; + $practice_round_flag=$this->isPracticeRound(); $harvest_decision = db_result(db_query("SELECT harvest_decision FROM vc_forestry_student - WHERE vc_student_id='%s' AND round_no=%d AND vc_stage_id=%d", - $student_id, $round_no, $stage_id)); + WHERE vc_student_id='%s' AND round_no=%d AND vc_stage_id=%d AND practice_round_flag=%d", + $student_id, $round_no, $stage_id,$practice_round_flag)); - // drupal_set_message("harvest decision is submitted is student :" . $harvest_decision); + //drupal_set_message("harvest decision is submitted is student :" . $harvest_decision); if ($harvest_decision == '') { //drupal_set_message("if harvest decision is submitted is empty :" . $harvest_decision); - $this->insert_default_decision($student_id, $round_no,$stage_id); + $this->insert_default_decision($student_id, $round_no,$stage_id,$practice_round_flag); } } } - private function insert_default_decision($student_id, $round_no,$stage_id) { + private function insert_default_decision($student_id, $round_no,$stage_id,$practice_round_flag) { // FIXME: how will this work for IrrigationStudent or FisheryStudent $student = new ForestryStudent($student_id); - $student->save($round_no, DEFAULT_HARVEST_DECISION, $stage_id); + //drupal_set_message("in insert default decision"); + $student->save($round_no, DEFAULT_HARVEST_DECISION, $stage_id,$practice_round_flag); } - + public function getNumberofPracticeRounds() + { + $no_of_practice_rounds = db_result(db_query(" select no_of_practice_rounds from vc_stage where id=%d",$this->getCurrentStageId())); + return $no_of_practice_rounds; + } + + public function isPracticeRoundEnabled() + { + + $no_of_practice_rounds=$this->getNumberofPracticeRounds(); + + if($no_of_practice_rounds > 0) + return 1 ; + else + return 0; + + } + + public function isPracticeRoundOver() + { + //drupal_set_message("In isPracticeRoundOver() function"); + if(($this->getCurrentRoundNo() > $this->getNumberOfPracticeRounds()) || ($this->IsResourceOverForAllGroup())) + { + //db_query("UPDATE {vc_game} set practice_round_flag =1 where id=%d",$this->game_id); + //db_query("UPDATE {vc_game} SET current_round_no=%d WHERE id=%d", $this->current_round_no, $this->game_id); + + return 1; + } + else + return 0; + + + } + public function IsPracticeRoundConducted() + { + $practice_round_flag=db_result(db_query("select practice_round_flag from vc_game where id=%d", $this->game_id)); + //drupal_set_message("is conducted flag: ".$practice_round_flag); + return $practice_round_flag; + } + public function nextRound() { + $round_no=$this->getCurrentRoundNo(); $stage_id=$this->getCurrentStageId(); + $practice_round_flag=$this->isPracticeRound(); $result = db_query(" select c.vc_group_id as group_id,c.common_resource_pool as crp,c.max_resources as max_r from vc_forestry_common_resource_pool c, vc_group g where c.vc_group_id =g.id and g.vc_game_id=%d",$this->game_id); // processing each group $voting_enabled = $this->isVotingEnabled(); + //drupal_set_message("in nextround() function"); + while($data = db_fetch_object($result)) { // FIXME: preprocess the groups and insert default decisions for // all students that haven't made a harvest decision. - $group_id=$data->group_id; + //drupal_set_message("in nextround() function while loop"); + $group_id=$data->group_id; $this->generate_default_decisions($group_id, $round_no, $stage_id); $resources_before=$crp=$data->crp; $max_resources=$data->max_r; $total_harvest_decision = db_result(db_query("select sum(harvest_decision) from vc_forestry_student - where vc_student_id in (select id from vc_student where vc_group_id=%d) and vc_stage_id=%d and round_no=%d", - $group_id,$stage_id,$round_no)); + where vc_student_id in (select id from vc_student where vc_group_id=%d) and vc_stage_id=%d and round_no=%d and practice_round_flag=%d", + $group_id,$stage_id,$round_no,$practice_round_flag)); $resources_available=$crp-$total_harvest_decision; $resources_available=$resources_available+($resources_available*0.1); if($resources_available > $max_resources) { @@ -439,21 +525,22 @@ $selected_rule_id=db_result(db_query("select vc_selected_rules_id from vc_group where id=%d",$group_id)); // db_query("insert into {vc_forestry_group_round_info}(vc_rules_id,dice) values (%d,%d) where vc_game_id=%d and vc_stage_id=%d and vc_group_id=%d",$selected_rule_id,$dice,$this->game_id,$stage_id,$group_id); //$this->initRules(); - db_query("Insert into {vc_forestry_group_round_info} (round_no,vc_game_id,vc_group_id,vc_stage_id,total_harvest_decision,resources_before,resources_after,vc_rules_id,dice) - values(%d,%d,%d,%d,%d,%d,%d,%d,%d)", - $round_no,$this->game_id,$group_id,$stage_id,$total_harvest_decision,$resources_before,$resources_available,$selected_rule_id,$dice); + db_query("Insert into {vc_forestry_group_round_info} (round_no,vc_game_id,vc_group_id,vc_stage_id,total_harvest_decision,resources_before,resources_after,vc_rules_id,dice,practice_round_flag) + values(%d,%d,%d,%d,%d,%d,%d,%d,%d,%d)", + $round_no,$this->game_id,$group_id,$stage_id,$total_harvest_decision,$resources_before,$resources_available,$selected_rule_id,$dice,$practice_round_flag); } else { - db_query("Insert into {vc_forestry_group_round_info} (round_no,vc_game_id,vc_group_id,vc_stage_id,total_harvest_decision,resources_before,resources_after) - values(%d,%d,%d,%d,%d,%d,%d)", - $round_no,$this->game_id,$group_id,$stage_id,$total_harvest_decision,$resources_before,$resources_available); + db_query("Insert into {vc_forestry_group_round_info} (round_no,vc_game_id,vc_group_id,vc_stage_id,total_harvest_decision,resources_before,resources_after,practice_round_flag) + values(%d,%d,%d,%d,%d,%d,%d,%d)", + $round_no,$this->game_id,$group_id,$stage_id,$total_harvest_decision,$resources_before,$resources_available,$practice_round_flag); } //update forestry common pool db_query("update {vc_forestry_common_resource_pool} set common_resource_pool=%d where vc_game_id=%d and vc_group_id=%d",$resources_available,$this->game_id,$group_id); } - + + //update start flag if ($this->isLastRound()) { //drupal_get_messages(); @@ -479,7 +566,7 @@ } - public function setRoundNo() + public function setRoundNo($practice_round) { //drupal_set_mesage(t('Round is : ' . $round_no)); @@ -487,21 +574,25 @@ // reset round number to 1 $this->current_round_no = 1; + //check if this is a practice round, if yes then start actual stage otherwise // 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 { + //drupal_set_message(t('in set round no isPracticeRound() ' . $this->isPracticeRound())); + // drupal_set_message("practice round flag insetRoundno is:". $practice_round); + if(!$practice_round) + { + $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); @@ -514,8 +605,15 @@ public function initNextStage() { //reset the forestry common resource pool + //drupal_set_message("in initNextStage function..."); + $practice_round=0; + //drupal_set_message("1 practice round flag in initnext stage is:". $practice_round); + if($this->isPracticeRound()) + { + db_query("UPDATE {vc_game} set practice_round_flag =true where id=%d",$this->game_id); + $practice_round=1; + } - $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)) { @@ -524,7 +622,8 @@ 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(); + // drupal_set_message("2 practice round flag in initnext stage is:". $practice_round); + $this->setRoundNo($practice_round); } /* public function assign_Rules_To_Groups() @@ -668,8 +767,8 @@ $max_rule_id=$rule_id[0]; //drupal_set_message(t( 'NOT Tie' . '$max_rule_id: ' . $max_rule_id)); db_query("update vc_group set vc_selected_rules_id =%d where id=%d",$max_rule_id,$group_id); - drupal_set_message(t('Group No : '. db_result(db_query("select group_no from vc_group where id=%d",$group_id))),'warning'); - drupal_set_message(t( 'is assigned Rule No: '.db_result(db_query("select rule_no from vc_rules where id=%d",$max_rule_id)) . '<br>'),'warning'); + drupal_set_message(t('Group No : '. db_result(db_query("select group_no from vc_group where id=%d",$group_id))),'warning'); + drupal_set_message(t( 'is assigned Rule No: '.db_result(db_query("select rule_no from vc_rules where id=%d",$max_rule_id)) . '<br>'),'warning'); } else { @@ -717,7 +816,7 @@ $tie=implode(',',$tie_rules); //drupal_get_messages(); - // drupal_set_message(t( 'Tie happened in Group no: ' . $group_id .'<br> Rules are :' . $tie),'warning'); + drupal_set_message(t( 'Tie happened in Group no: ' . $group_id .'<br> Rules are :' . $tie),'warning'); //check if the group id exists in vc_tie.If it exists it means that for $group_id, tie had alredy happened previously. //So chosse one rule randomly from tie rules $prev_tie_result=db_result(db_query("select tie_rules_id from vc_tie where vc_group_id=%d",$group_id)); @@ -1153,7 +1252,7 @@ $rule_id=array(); $final_rule_no=array(); $rule_id=explode(',',$result_voting); - //drupal_set_message(t('Tie Rules are : ' . $result_voting)); + drupal_set_message(t('Tie Rules are : ' . $result_voting)); for($i=0;$i<count($rule_id);$i++) { $result=db_query("select rule_no,description from vc_rules where id =%d",$rule_id[$i]); @@ -1205,14 +1304,14 @@ $min_resource=db_result(db_query("select min(max_resource_level) from {vc_forestry_${number_of_players}player_harvest_table")); $current_resource=db_result(db_query('select common_resource_pool from vc_forestry_common_resource_pool where vc_group_id=%d and vc_game_id=%d',$this->group_id,$this->game_id)); - drupal_set_message(t('min resource level is: '.$min_resource . 'and current resource level is: '.$current_resource)); + //drupal_set_message(t('min resource level is: '.$min_resource . 'and current resource level is: '.$current_resource)); if($current_resource <= $min_resource) $flag=1; else $flag=0; - drupal_set_message(t('in resource function returning flag is: ' .$flag)); + //drupal_set_message(t('in resource function returning flag is: ' .$flag)); return $flag; } @@ -1277,7 +1376,11 @@ } public function getStageData($stage_id) { - $student_decision = db_query("select round_no,harvest_decision,fine,total_points from vc_forestry_student where vc_student_id='%s' and vc_stage_id=%d order by round_no",$this->stud_id,$stage_id); + $student_decision = db_query("select round_no,harvest_decision,fine,total_points + from vc_forestry_student + where vc_student_id='%s' and + vc_stage_id=%d and + practice_round_flag=%d order by round_no",$this->stud_id,$stage_id,$this->getGroup()->getGame()->isPracticeRound()); $decision_table = array(); $voting_enabled=db_result(db_query("select voting from vc_stage where id=%d",$stage_id)); @@ -1295,8 +1398,8 @@ //get the resource info from vc_forestry_group_round_information $fetch_object = db_fetch_object(db_query("SELECT resources_before,resources_after FROM vc_forestry_group_round_info - WHERE vc_group_id=%d and vc_game_id=%d and round_no=%d and vc_stage_id=%d", - $this->group->getId(),$this->group->getGame()->getGameId(),$round_no,$stage_id)); + WHERE vc_group_id=%d and vc_game_id=%d and round_no=%d and vc_stage_id=%d and practice_round_flag=%d", + $this->group->getId(),$this->group->getGame()->getGameId(),$round_no,$stage_id,$this->getGroup()->getGame()->isPracticeRound())); if ($fetch_object) { $resources_before=$fetch_object->resources_before; $resources_after=$fetch_object->resources_after; @@ -1356,9 +1459,11 @@ } */ - public function save($round_no, $harvest_decision,$stage_id=0) + public function save($round_no, $harvest_decision,$stage_id=0,$practice_round_flag) { //drupal_set_message($stage_id); + + if($stage_id <> 0) { // $stage_id = $this->getGroup()->getGame()->getCurrentStageId(); @@ -1371,8 +1476,8 @@ $this->stud_id, $stage_id,$round_no-1)); $total=$total+$harvest_decision; - db_query("INSERT INTO {vc_forestry_student} (round_no,vc_student_id,vc_stage_id,harvest_decision, total_points) VALUES (%d,'%s',%d,%d, %d)", - $round_no,$this->stud_id,$stage_id,$harvest_decision, $total); + db_query("INSERT INTO {vc_forestry_student} (round_no,vc_student_id,vc_stage_id,harvest_decision, total_points,practice_round_flag) VALUES (%d,'%s',%d,%d, %d,%d)", + $round_no,$this->stud_id,$stage_id,$harvest_decision, $total,$practice_round_flag); } public function updateStartFlag($flag) Modified: vcweb/trunk/virtualcommons/experiment/experiment.install =================================================================== --- vcweb/trunk/virtualcommons/experiment/experiment.install 2008-10-23 21:56:35 UTC (rev 54) +++ vcweb/trunk/virtualcommons/experiment/experiment.install 2008-10-24 19:42:20 UTC (rev 55) @@ -26,7 +26,7 @@ vc_experiment_id INT NOT NULL, PRIMARY KEY(id), - FOREIGN KEY (vc_experiment_id) REFERENCES vc_experiment(id) ON DELETE CASCADE + FOREIGN KEY (vc_experiment_id) REFERENCES {vc_experiment}(id) ON DELETE CASCADE ) ENGINE=InnoDB /*!40100 DEFAULT CHARACTER SET UTF8 */"); db_query("CREATE TABLE {vc_rules} ( @@ -37,7 +37,7 @@ name enum('Lottery', 'Rotation', 'Property Rights'), PRIMARY KEY(id), - FOREIGN KEY (vc_stage_id) REFERENCES vc_stage(id) ON DELETE CASCADE + FOREIGN KEY (vc_stage_id) REFERENCES {vc_stage}(id) ON DELETE CASCADE ) ENGINE=InnoDB /*!40100 DEFAULT CHARACTER SET UTF8 */"); db_query("CREATE TABLE {vc_game} ( @@ -47,11 +47,16 @@ no_of_students INT NOT NULL, vc_stage_id INT NOT NULL, current_round_no INT NOT NULL, + +/* if there is practice round enabled for the stage, practice_round_flag flag will be 1/0 , +if there is not practice round this flag will be null.This flag is used for manipulating the practice rounds*/ + + practice_round_flag bool, date_created TIMESTAMP NOT NULL, PRIMARY KEY(id), - FOREIGN KEY(vc_experiment_id) REFERENCES vc_experiment(id) ON DELETE CASCADE, - FOREIGN KEY(vc_stage_id) REFERENCES vc_stage(id) + FOREIGN KEY(vc_experiment_id) REFERENCES {vc_experiment}(id) ON DELETE CASCADE, + FOREIGN KEY(vc_stage_id) REFERENCES {vc_stage}(id) ) ENGINE=InnoDB /*!40100 DEFAULT CHARACTER SET UTF8 */"); db_query("CREATE TABLE {vc_group} @@ -62,8 +67,8 @@ vc_selected_rules_id INT NULL, PRIMARY KEY(id), - FOREIGN KEY(vc_game_id) REFERENCES vc_game(id), - FOREIGN KEY(vc_selected_rules_id) REFERENCES vc_rules(id) + FOREIGN KEY(vc_game_id) REFERENCES {vc_game}(id), + FOREIGN KEY(vc_selected_rules_id) REFERENCES {vc_rules}(id) ) ENGINE=InnoDB /*!40100 DEFAULT CHARACTER SET UTF8 */"); db_query("CREATE TABLE {vc_student} @@ -76,7 +81,7 @@ played_flag BOOL NOT NULL, PRIMARY KEY(id), - FOREIGN KEY(vc_group_id) REFERENCES vc_group(id) + FOREIGN KEY(vc_group_id) REFERENCES {vc_group}(id) ) ENGINE=InnoDB /*!40100 DEFAULT CHARACTER SET UTF8 */"); @@ -87,15 +92,15 @@ db_query("insert into {vc_experiment} (name) values('Forestry Game')"); db_query("insert into {vc_experiment} (name) values('Water Irrigation Game')"); -db_query("insert into { vc_stage} (stage_no,vc_experiment_id,no_of_rounds,voting,no_of_practice_rounds) values(1,1,10,false,3)"); -db_query("insert into { vc_stage} (stage_no,vc_experiment_id,no_of_rounds,voting,no_of_practice_rounds) values(2,1,10,true,0)"); -db_query("insert into { vc_stage} (stage_no,vc_experiment_id,no_of_rounds,voting,no_of_practice_rounds) values(1,2,10,false,3)"); -db_query("insert into { vc_stage} (stage_no,vc_experiment_id,no_of_rounds,voting,no_of_practice_rounds) values(2,2,10,true,0)"); -db_query("insert into { vc_stage} (stage_no,vc_experiment_id,no_of_rounds,voting,no_of_practice_rounds) values(1,3,10,false,3)"); -db_query("insert into { vc_stage} (stage_no,vc_experiment_id,no_of_rounds,voting,no_of_practice_rounds) values(2,3,10,true,0)"); +db_query("insert into {vc_stage} (stage_no,vc_experiment_id,no_of_rounds,voting,no_of_practice_rounds) values(1,1,10,false,3)"); +db_query("insert into {vc_stage} (stage_no,vc_experiment_id,no_of_rounds,voting,no_of_practice_rounds) values(2,1,10,true,0)"); +db_query("insert into {vc_stage} (stage_no,vc_experiment_id,no_of_rounds,voting,no_of_practice_rounds) values(1,2,10,false,3)"); +db_query("insert into {vc_stage} (stage_no,vc_experiment_id,no_of_rounds,voting,no_of_practice_rounds) values(2,2,10,true,0)"); +db_query("insert into {vc_stage} (stage_no,vc_experiment_id,no_of_rounds,voting,no_of_practice_rounds) values(1,3,10,false,3)"); +db_query("insert into {vc_stage} (stage_no,vc_experiment_id,no_of_rounds,voting,no_of_practice_rounds) values(2,3,10,true,0)"); -db_query("insert into { vc_rules} (vc_stage_id,rule_no,name,description) values(2,1,'Lottery','With this rule the computer draws randomly for each player a location the player is allowed to fish. We throw a virtual dice to see whether an inspector (when a 6 is thrown) come to the region and to check on your locations. When you harvest in a location which you are not allowed to, you have to pay back the harvest points. For example if the player harvests in the place A with 2 effort units when the allowed place to fish is B and the dice yield 6, the player pays back the harvest.')"); -db_query("insert into { vc_rules} (vc_stage_id,rule_no,name,description) values(2,2,'Rotation','Only one location is allowed to be fished in each round. There is a rotation +db_query("insert into {vc_rules} (vc_stage_id,rule_no,name,description) values(2,1,'Lottery','With this rule the computer draws randomly for each player a location the player is allowed to fish. We throw a virtual dice to see whether an inspector (when a 6 is thrown) come to the region and to check on your locations. When you harvest in a location which you are not allowed to, you have to pay back the harvest points. For example if the player harvests in the place A with 2 effort units when the allowed place to fish is B and the dice yield 6, the player pays back the harvest.')"); +db_query("insert into {vc_rules} (vc_stage_id,rule_no,name,description) values(2,2,'Rotation','Only one location is allowed to be fished in each round. There is a rotation AABBAABBAABBAA of a ban where you are not allowed to harvest. It means that: Round 1 ban in A Round 2 ban in A @@ -108,9 +113,9 @@ Round 9 ban in A Round 10 ban in A Thus in the forth round you are not allowed to harvest in location A. When you harvest, but are not allowed to, the throwing of a virtual dice determines whether you need to pay a penalty. If we throw a six, the penalty is to return back the harvest plus.')"); -db_query("insert into { vc_rules} (vc_stage_id,rule_no,name,description) values(2,3,'Property Rights','Each of you can put an effort of 0 or 1 per round. We throw a virtual dice every round. If we throw a six, an inspector comes to the region to check on your effort levels. If a participant writes 2 units of effort on its game card, and the inspector is present, the participant does not get the points it wrote down on its decision sheet.')"); -db_query("insert into { vc_rules} (vc_stage_id,rule_no,name,description) values(4,1,'Lottery','With this rule only two participants can harvest each round. Who is allowed to harvest is determined by drawing two cards with players numbers. The instructor writes down the player numbers who are allowed on the board. When someone harvest, but is not allowed to, this participant may get a penalty. Every round we throw a dice after the decisions are made. If we throw a six an inspector is in the forest and will catch the rule breakers, the participants who harvested in a turn it was not allowed to. In that case the participant has to payback the harvest plus an extra 3 units. If the dice shows any other number everybody keeps its earnings and we pass to the next round.')"); -db_query("insert into { vc_rules} (vc_stage_id,rule_no,name,description) values(4,2,'Rotation','With this rule each participant will have its turn to extract forest unit. Only two participants can harvest each round. In this way it will be a rotation scheme to extract forest units. Each participant will be assigned randomly a turn card to extract forest units: The extraction order is: +db_query("insert into {vc_rules} (vc_stage_id,rule_no,name,description) values(2,3,'Property Rights','Each of you can put an effort of 0 or 1 per round. We throw a virtual dice every round. If we throw a six, an inspector comes to the region to check on your effort levels. If a participant writes 2 units of effort on its game card, and the inspector is present, the participant does not get the points it wrote down on its decision sheet.')"); +db_query("insert into {vc_rules} (vc_stage_id,rule_no,name,description) values(4,1,'Lottery','With this rule only two participants can harvest each round. Who is allowed to harvest is determined by drawing two cards with players numbers. The instructor writes down the player numbers who are allowed on the board. When someone harvest, but is not allowed to, this participant may get a penalty. Every round we throw a dice after the decisions are made. If we throw a six an inspector is in the forest and will catch the rule breakers, the participants who harvested in a turn it was not allowed to. In that case the participant has to payback the harvest plus an extra 3 units. If the dice shows any other number everybody keeps its earnings and we pass to the next round.')"); +db_query("insert into {vc_rules} (vc_stage_id,rule_no,name,description) values(4,2,'Rotation','With this rule each participant will have its turn to extract forest unit. Only two participants can harvest each round. In this way it will be a rotation scheme to extract forest units. Each participant will be assigned randomly a turn card to extract forest units: The extraction order is: Round 1: extracts wood the player A, B Round 2 extracts wood the player C, D Round 3: extracts wood the player E, A @@ -126,9 +131,9 @@ When someone harvest, but is not allowed to, this participant may get a penalty. Every round we throw a dice after the decisions are made. If we throw a six an inspector is in the forest and will catch the rule breakers, the participants who harvested in a turn it was not allowed to. In that case the participant has to payback the harvest plus an extra 3 units. So, if participant whose turn is A is writing down on the decision sheet to harvest 3 units when only the player with turn C is allowed to harvest, we throw a dice, and when we throw a six, participant with turn A do not get the points on its decision sheet, and we subtract an extra 3 from the total collected points of player with turn A. If the dice shows any other number everybody keeps its earnings and we pass to the next round. ')"); -db_query("insert into { vc_rules} (vc_stage_id,rule_no,name,description) values(4,3,'Property Rights','Each of you can harvest legally 0, 1 or 2 units per round. If a participant types a higher amount than 2, he or she can be caught by the inspector and has to pay a penalty. In every round we throw a virtual dice. And when we throw a six, and the participants who harvest more than 2 units in that round, do not get the points it wrote down on its game card, and we subtract an extra 3 points from it’s total so far.')"); -db_query("insert into { vc_rules} (vc_stage_id,rule_no,name,description) values(6,1,'Lottery','In this rule we draw for each round, after you have contributed to the maintenance of the irrigation system, the order in which you can take water for irrigation will be assigned randomly.')"); -db_query("insert into { vc_rules} (vc_stage_id,rule_no,name,description) values(6,2,'Rotation','There will be a fixed rotation in which you can collect water. This order is a 5 round rotation system: +db_query("insert into {vc_rules} (vc_stage_id,rule_no,name,description) values(4,3,'Property Rights','Each of you can harvest legally 0, 1 or 2 units per round. If a participant types a higher amount than 2, he or she can be caught by the inspector and has to pay a penalty. In every round we throw a virtual dice. And when we throw a six, and the participants who harvest more than 2 units in that round, do not get the points it wrote down on its game card, and we subtract an extra 3 points from it’s total so far.')"); +db_query("insert into {vc_rules} (vc_stage_id,rule_no,name,description) values(6,1,'Lottery','In this rule we draw for each round, after you have contributed to the maintenance of the irrigation system, the order in which you can take water for irrigation will be assigned randomly.')"); +db_query("insert into {vc_rules} (vc_stage_id,rule_no,name,description) values(6,2,'Rotation','There will be a fixed rotation in which you can collect water. This order is a 5 round rotation system: Round 1: ABCDE Round 2: BCDEA Round 3: CDEAB @@ -139,7 +144,7 @@ Round 8: CDEAB Round 9: DEABC Round 10: EABCD')"); -db_query("insert into { vc_rules} (vc_stage_id,rule_no,name,description) values(6,3,'Property Rights','Each of you has a right of 20% of the water of the irrigation system. This amount is calculated after the available water is announced. The order to extract water remains the same for all the rounds: ABCDE. A virtual dice is thrown in each round. When 6 is thrown, an inspector arrives to the irrigation system and will check the water extraction. The player who takes more than the 20% share pays back the extra amount taken, and an extra amount of 6 units.')"); +db_query("insert into {vc_rules} (vc_stage_id,rule_no,name,description) values(6,3,'Property Rights','Each of you has a right of 20% of the water of the irrigation system. This amount is calculated after the available water is announced. The order to extract water remains the same for all the rounds: ABCDE. A virtual dice is thrown in each round. When 6 is thrown, an inspector arrives to the irrigation system and will check the water extraction. The player who takes more than the 20% share pays back the extra amount taken, and an extra amount of 6 units.')"); $flag=TRUE; @@ -153,7 +158,7 @@ PRIMARY KEY(id), - FOREIGN KEY(vc_game_id) REFERENCES vc_game(id) + FOREIGN KEY(vc_game_id) REFERENCES {vc_game}(id) ON DELETE CASCADE )"); $flag=TRUE; Modified: vcweb/trunk/virtualcommons/experiment/experiment.module =================================================================== --- vcweb/trunk/virtualcommons/experiment/experiment.module 2008-10-23 21:56:35 UTC (rev 54) +++ vcweb/trunk/virtualcommons/experiment/experiment.module 2008-10-24 19:42:20 UTC (rev 55) @@ -351,7 +351,7 @@ $form['submit'] = array( '#type' => 'submit', - '#value' => t('Start Game!!!') + '#value' => t('Start Practice Rounds!!!') ); return $form; Modified: vcweb/trunk/virtualcommons/experiment/games/forestry/forestry_game/forestry_game.install =================================================================== --- vcweb/trunk/virtualcommons/experiment/games/forestry/forestry_game/forestry_game.install 2008-10-23 21:56:35 UTC (rev 54) +++ vcweb/trunk/virtualcommons/experiment/games/forestry/forestry_game/forestry_game.install 2008-10-24 19:42:20 UTC (rev 55) @@ -22,13 +22,13 @@ PRIMARY KEY(id), - FOREIGN KEY(virtualcommons_student_id) REFERENCES virtualcommons_student(id) + FOREIGN KEY(virtualcommons_student_id) REFERENCES {virtualcommons_student}(id) ON DELETE CASCADE, - FOREIGN KEY(virtualcommons_stage_no) REFERENCES virtualcommons_stage(stage_no) + FOREIGN KEY(virtualcommons_stage_no) REFERENCES {virtualcommons_stage}(stage_no) ON DELETE CASCADE, - FOREIGN KEY(virtualcommons_student_group_no) REFERENCES virtualcommons_student(group_no) + FOREIGN KEY(virtualcommons_student_group_no) REFERENCES {virtualcommons_student}(group_no) ON DELETE CASCADE Modified: vcweb/trunk/virtualcommons/experiment/games/forestry_v2/forestry_v2.install =================================================================== --- vcweb/trunk/virtualcommons/experiment/games/forestry_v2/forestry_v2.install 2008-10-23 21:56:35 UTC (rev 54) +++ vcweb/trunk/virtualcommons/experiment/games/forestry_v2/forestry_v2.install 2008-10-24 19:42:20 UTC (rev 55) @@ -18,10 +18,10 @@ max_resources INT NOT NULL, PRIMARY KEY(id), - FOREIGN KEY(vc_group_id) REFERENCES vc_group(id) + FOREIGN KEY(vc_group_id) REFERENCES {vc_group}(id) ON DELETE CASCADE, - FOREIGN KEY(vc_game_id) REFERENCES vc_game(id) + FOREIGN KEY(vc_game_id) REFERENCES {vc_game}(id) ON DELETE CASCADE )ENGINE=InnoDB /*!40100 DEFAULT CHARACTER SET UTF8 */"); @@ -89,14 +89,15 @@ harvest_decision int NOT NULL, fine int default 0, total_points int default 0, + practice_round_flag bool default false, date TIMESTAMP NOT NULL, PRIMARY KEY(id), - FOREIGN KEY(vc_student_id) REFERENCES vc_student(id) + FOREIGN KEY(vc_student_id) REFERENCES {vc_student}(id) ON DELETE CASCADE, - FOREIGN KEY(vc_stage_id) REFERENCES vc_stage(id) + FOREIGN KEY(vc_stage_id) REFERENCES {vc_stage}(id) ON DELETE CASCADE @@ -112,13 +113,13 @@ PRIMARY KEY(id), - FOREIGN KEY(vc_group_id) REFERENCES vc_group(id) + FOREIGN KEY(vc_group_id) REFERENCES {vc_group}(id) ON DELETE CASCADE, - FOREIGN KEY(vc_rules_id) REFERENCES vc_rules(id) + FOREIGN KEY(vc_rules_id) REFERENCES {vc_rules}(id) ON DELETE CASCADE, - FOREIGN KEY(vc_game_id) REFERENCES vc_game(id) + FOREIGN KEY(vc_game_id) REFERENCES {vc_game}(id) ON DELETE CASCADE )ENGINE=InnoDB /*!40100 DEFAULT CHARACTER SET UTF8 */"); @@ -140,10 +141,10 @@ PRIMARY KEY(id), - FOREIGN KEY(vc_student_id) REFERENCES vc_student(id) + FOREIGN KEY(vc_student_id) REFERENCES {vc_student}(id) ON DELETE CASCADE, - FOREIGN KEY(vc_stage_id) REFERENCES vc_stage(id) + FOREIGN KEY(vc_stage_id) REFERENCES {vc_stage}(id) ON DELETE CASCADE @@ -159,13 +160,13 @@ PRIMARY KEY(id), - FOREIGN KEY(vc_group_id) REFERENCES vc_group(id) + FOREIGN KEY(vc_group_id) REFERENCES {vc_group}(id) ON DELETE CASCADE, - FOREIGN KEY(vc_rules_id) REFERENCES vc_rules(id) + FOREIGN KEY(vc_rules_id) REFERENCES {vc_rules}(id) ON DELETE CASCADE, - FOREIGN KEY(vc_game_id) REFERENCES vc_conducts(id) + FOREIGN KEY(vc_game_id) REFERENCES {vc_conducts}(id) ON DELETE CASCADE ) /*!40100 DEFAULT CHARACTER SET UTF8 */"); Modified: vcweb/trunk/virtualcommons/experiment/games/forestry_v2/forestry_v2.module =================================================================== --- vcweb/trunk/virtualcommons/experiment/games/forestry_v2/forestry_v2.module 2008-10-23 21:56:35 UTC (rev 54) +++ vcweb/trunk/virtualcommons/experiment/games/forestry_v2/forestry_v2.module 2008-10-24 19:42:20 UTC (rev 55) @@ -17,12 +17,12 @@ //$stage_no = $student->getGroup()->getGame()->getCurrentStageNumber(); $items = array(); if ($may_cache) { - $items[] = array('path' => 'forestry/info', + /* $items[] = array('path' => 'forestry/info', 'title' => t('Forestry Game Information'), 'callback' => 'forestry_info', 'type'=>MENU_CALLBACK, 'access' => TRUE//user_access('Only Teachers') - ); + );*/ $items[] = array('path' => 'forestry/decision_info', 'title' => t('Forestry Game Decision Information'), @@ -231,15 +231,19 @@ $output = '<br/><h3 align="center" style="color:#990000">The experiment is now over. Your results are listed below. Thanks for participating!</h3><br/>'; $output .= generate_all_results_table(); } + else if ($student->shouldVote()) { return drupal_get_form('voting_rules_form'); } + else { $output .= generate_harvest_table(); $output .= generate_results_table(); - drupal_set_message(t('resource over flag is: '. $student->getGroup()->isResourceOver())); + //drupal_set_message(t('resource over flag is: '. $student->getGroup()->isResourceOver())); + + if($student->canStart()) { if($student->getGroup()->isResourceOver()) @@ -248,7 +252,8 @@ } else $start=1; - drupal_set_message(t('start flag is: '. $start)); + + drupal_set_message(t('start flag is: '. $start)); $output .= (!$start) ? drupal_get_form('forestry_play_multiform') : drupal_get_form('forestry_wait_form'); } return $output; @@ -418,15 +423,15 @@ $temp_max_resource= $harvest_table[0][0]; $temp_max_resource=explode("-",$temp_max_resource); $max_resource=$temp_max_resource[1]; - drupal_set_message(t('max resource : '. $max_resource)); - + //drupal_set_message(t('max resource : '. $max_resource)); + $practice_rounds_over_flag=false; $stud_harvest_decision=(int) $form_values['indicator']['harvest_decision']; $round_no=$form_values['round_no']; - $student->save($round_no,$stud_harvest_decision,$group->getGame()->getCurrentStageId()); + $student->save($round_no,$stud_harvest_decision,$group->getGame()->getCurrentStageId(),$group->getGame()->isPracticeRound()); $student->updateStartFlag(false); return 'forestry/play'; @@ -484,6 +489,8 @@ $group = $student->getGroup(); $group_id=$group->getId(); $game_id=$group->getGameId(); + $practice_round_conducted=FALSE; + $practice_rounds_over_flag=FALSE; // FIXME: hack only in place for Drupal 5, can get rid of in Drupal 6 in // favor of the $repeat parameter in drupal_set_message drupal_get_messages(); @@ -499,11 +506,34 @@ drupal_set_message(t('The game is over. Thanks for participating.'), 'warning', FALSE); } - - else if( $group->getGame()->isLastRound() || $group->isResourceOver() || $group->getGame()->isStageOver() - ) + + else if(!$group->getGame()->IsPracticeRoundConducted()) { - drupal_set_message(t('This stage is now over. The next stage should begin shortly.'), 'warning', FALSE); + $practice_rounds_over_flag=$group->getGame()->isPracticeRoundOver(); + //drupal_set_message("Are practice rounds over?".$practice_rounds_over_flag); + Session::put('practice_round',$practice_rounds_over_flag); + + } + else + { + $practice_round_conducted=TRUE; + } + if(Session::get('practice_round') &&(!$practice_round_conducted)) + { + drupal_get_messages(); + drupal_set_message(t('<h2 align="center" style="color:#990000">Practice Rounds are Over! </h2>')); + drupal_set_message(t('Please wait till facilitator instructs you to click on Start Game button'),'warning',FALSE); + + $form['submit'] = array( + '#type' => 'submit', + '#value' => t('Start Game') + ); + } + + else if( $group->getGame()->isLastRound() || $group->isResourceOver() || $group->getGame()->isStageOver()) + { + + drupal_set_message(t('This stage is now over. The next stage should begin shortly.'), 'warning', FALSE); $form['submit'] = array( '#type' => 'submit', '#value' => t('Next Stage') @@ -524,5 +554,10 @@ function forestry_wait_form_submit($form_id,$form_values) { + if($form_values['submit']=="Start Game") + { + Session::remove('practice_round'); + } + return 'forestry/play'; } Modified: vcweb/trunk/virtualcommons/experiment/rules/rules.install =================================================================== --- vcweb/trunk/virtualcommons/experiment/rules/rules.install 2008-10-23 21:56:35 UTC (rev 54) +++ vcweb/trunk/virtualcommons/experiment/rules/rules.install 2008-10-24 19:42:20 UTC (rev 55) @@ -17,10 +17,10 @@ time_created TIMESTAMP NOT NULL, PRIMARY KEY(id), - FOREIGN KEY(vc_student_id) REFERENCES vc_student(id) + FOREIGN KEY(vc_student_id) REFERENCES {vc_student}(id) ON DELETE CASCADE, - FOREIGN KEY(vc_rules_id) REFERENCES vc_rules(id) + FOREIGN KEY(vc_rules_id) REFERENCES {vc_rules}(id) ON DELETE CASCADE )ENGINE=InnoDB /*!40100 DEFAULT CHARACTER SET UTF8 */"); @@ -35,7 +35,7 @@ time_created TIMESTAMP NOT NULL, PRIMARY KEY(id), - FOREIGN KEY(vc_group_id) REFERENCES vc_group(id) + FOREIGN KEY(vc_group_id) REFERENCES {vc_group}(id) ON DELETE CASCADE )ENGINE=InnoDB /*!40100 DEFAULT CHARACTER SET UTF8 */"); @@ -55,10 +55,10 @@ time_created TIMESTAMP NOT NULL, PRIMARY KEY(id), - FOREIGN KEY(vc_student_id) REFERENCES vc_student(id) + FOREIGN KEY(vc_student_id) REFERENCES {vc_student}(id) ON DELETE CASCADE, - FOREIGN KEY(vc_rules_id) REFERENCES vc_rules(id) + FOREIGN KEY(vc_rules_id) REFERENCES {vc_rules}(id) ON DELETE CASCADE )ENGINE=InnoDB /*!40100 DEFAULT CHARACTER SET UTF8 */"); Modified: vcweb/trunk/virtualcommons/experiment/student_login/student_login.module =================================================================== --- vcweb/trunk/virtualcommons/experiment/student_login/student_login.module 2008-10-23 21:56:35 UTC (rev 54) +++ vcweb/trunk/virtualcommons/experiment/student_login/student_login.module 2008-10-24 19:42:20 UTC (rev 55) @@ -36,7 +36,7 @@ $form['student_info'] = array( '#title' => t('Student Information'), '#type' => 'fieldset', - '#description'=>t('Please enter correct the student ID, you received from your teacher.') + '#description'=>t('Please enter correct the student ID, you received from your instructor.') ); $form['student_info']['id'] = array( Modified: vcweb/trunk/virtualcommons/experiment/survey/survey.install =================================================================== --- vcweb/trunk/virtualcommons/experiment/survey/survey.install 2008-10-23 21:56:35 UTC (rev 54) +++ vcweb/trunk/virtualcommons/experiment/survey/survey.install 2008-10-24 19:42:20 UTC (rev 55) @@ -17,7 +17,7 @@ PRIMARY KEY(id), - FOREIGN KEY(vc_experiment_id) REFERENCES vc_experiment(id) + FOREIGN KEY(vc_experiment_id) REFERENCES {vc_experiment}(id) ON DELETE CASCADE )ENGINE=InnoDB /*!40100 DEFAULT CHARACTER SET UTF8 */"); @@ -32,10 +32,10 @@ PRIMARY KEY(id), - FOREIGN KEY(vc_survey_id) REFERENCES vc_survey(id) + FOREIGN KEY(vc_survey_id) REFERENCES {vc_survey}(id) ON DELETE CASCADE, - FOREIGN KEY(vc_rules_id) REFERENCES vc_rules(id) + FOREIGN KEY(vc_rules_id) REFERENCES {vc_rules}(id) ON DELETE CASCADE )ENGINE=InnoDB /*!40100 DEFAULT CHARACTER SET UTF8 */"); @@ -50,7 +50,7 @@ PRIMARY KEY(id), - FOREIGN KEY(vc_survey_questions_id) REFERENCES vc_survey_questions(id) + FOREIGN KEY(vc_survey_questions_id) REFERENCES {vc_survey_questions}(id) ON DELETE CASCADE )ENGINE=InnoDB /*!40100 DEFAULT CHARACTER SET UTF8 */"); @@ -65,11 +65,11 @@ PRIMARY KEY(id), - FOREIGN KEY(vc_student_id) REFERENCES vc_student(id) + FOREIGN KEY(vc_student_id) REFERENCES {vc_student}(id) ON DELETE CASCADE, - FOREIGN KEY(vc_survey_questions_id) REFERENCES vc_survey_questions(id) + FOREIGN KEY(vc_survey_questions_id) REFERENCES {vc_survey_questions}(id) ON DELETE CASCADE )ENGINE=InnoDB /*!40100 DEFAULT CHARACTER SET UTF8 */"); @@ -208,7 +208,7 @@ PRIMARY KEY(id), - FOREIGN KEY(vc_experiments_id) REFERENCES vc_experiments(id) + FOREIGN KEY(vc_experiments_id) REFERENCES {vc_experiments}(id) ON DELETE CASCADE )ENGINE=InnoDB /*!40100 DEFAULT CHARACTER SET UTF8 */"); @@ -223,10 +223,10 @@ PRIMARY KEY(id), - FOREIGN KEY(vc_survey_id) REFERENCES vc_survey(id) + FOREIGN KEY(vc_survey_id) REFERENCES {vc_survey}(id) ON DELETE CASCADE, - FOREIGN KEY(vc_rules_id) REFERENCES vc_rules(id) + FOREIGN KEY(vc_rules_id) REFERENCES {vc_rules}(id) ON DELETE CASCADE )ENGINE=InnoDB /*!40100 DEFAULT CHARACTER SET UTF8 */"); @@ -242,7 +242,7 @@ PRIMARY KEY(id), - FOREIGN KEY(vc_survey_questions_id) REFERENCES vc_survey_questions(id) + FOREIGN KEY(vc_survey_questions_id) REFERENCES {vc_survey_questions}(id) ON DELETE CASCADE )ENGINE=InnoDB /*!40100 DEFAULT CHARACTER SET UTF8 */"); Modified: vcweb/trunk/virtualcommons/experiment/survey/survey.module =================================================================== --- vcweb/trunk/virtualcommons/experiment/survey/survey.module 2008-10-23 21:56:35 UTC (rev 54) +++ vcweb/trunk/virtualcommons/experiment/survey/survey.module 2008-10-24 19:42:20 UTC (rev 55) @@ -279,7 +279,7 @@ { $student=Session::get('student'); //check whether teacher processed the votings - if( $student->getGroup()->getGame()->isRuleSelected()) + if(!$student->getGroup()->getGame()->isRuleSelected()) { return 'rule_decision'; } Modified: vcweb/trunk/virtualcommons/experiment/teacher_dashboard/teacher_dashboard.install =================================================================== --- vcweb/trunk/virtualcommons/experiment/teacher_dashboard/teacher_dashboard.install 2008-10-23 21:56:35 UTC (rev 54) +++ vcweb/trunk/virtualcommons/experiment/teacher_dashboard/teacher_dashboard.install 2008-10-24 19:42:20 UTC (rev 55) @@ -6,6 +6,7 @@ */ function teacher_dashboard_install() { + global $db_prefix; switch ($GLOBALS['db_type']) { case 'mysql': @@ -22,18 +23,20 @@ resources_after int NOT NULL, vc_rules_id int default NULL, dice int default 0, + practice_round_flag bool default false, + date_created TIMESTAMP NOT NULL, PRIMARY KEY(id), - FOREIGN KEY(vc_game_id) REFERENCES vc_game(id) + FOREIGN KEY(vc_game_id) REFERENCES {vc_game}(id) ON DELETE CASCADE, - FOREIGN KEY(vc_group_id) REFERENCES vc_group(id) + FOREIGN KEY(vc_group_id) REFERENCES {vc_group}(id) ON DELETE CASCADE, - FOREIGN KEY(vc_stage_id) REFERENCES vc_stage(id) ON DELETE CASCADE, + FOREIGN KEY(vc_stage_id) REFERENCES {vc_stage}(id) ON DELETE CASCADE, - FOREIGN KEY(vc_rules_id) REFERENCES vc_rules(id) + FOREIGN KEY(vc_rules_id) REFERENCES {vc_rules}(id) ON DELETE CASCADE @@ -58,13 +61,13 @@ PRIMARY KEY(id), - FOREIGN KEY(vc_group_id) REFERENCES vc_group(group_id) + FOREIGN KEY(vc_group_id) REFERENCES {vc_group}(group_id) ON DELETE CASCADE, - FOREIGN KEY(vc_game_id) REFERENCES vc_game(id) + FOREIGN KEY(vc_game_id) REFERENCES {vc_game}(id) ON DELETE CASCADE, - FOREIGN KEY(vc_rules_id) REFERENCES vc_rules(id) + FOREIGN KEY(vc_rules_id) REFERENCES {vc_rules}(id) ON DELETE CASCADE Modified: vcweb/trunk/virtualcommons/experiment/teacher_dashboard/teacher_dashboard.module =================================================================== --- vcweb/trunk/virtualcommons/experiment/teacher_dashboard/teacher_dashboard.module 2008-10-23 21:56:35 UTC (rev 54) +++ vcweb/trunk/virtualcommons/experiment/teacher_dashboard/teacher_dashboard.module 2008-10-24 19:42:20 UTC (rev 55) @@ -71,12 +71,14 @@ $game = Session::get('game'); // $teacher_id=$GLOBALS['user']->uid; $round_no=0; - $stage_flag=FALSE; - + $stage_flag=0; + $practice_rounds_flag =0; + $practice_round_conducted=0; // display all stage data $all_stage_data = $game->getAllGroupRoundInfo(); $header_novoting=array('Round No','Group No', 'Group Harvest Decision','Resources Before','Resources After'); $header_voting=array('Round No','Group No', 'Group Harvest Decision','Resources Before','Resources After', 'Rule #', 'Dice'); +// drupal_get_messages(); foreach ($all_stage_data as $stage_id => $stage_data) { $stage_no = $game->getStageNumber($stage_id); @@ -102,40 +104,94 @@ */ } else { - if ($game->isVotingEnabled()) - { - if (!($game->isRuleSelected())) - { - $start_flag=TRUE; - } + + if($stage_flag=$game->isStageOver()) + { + + } + else + { + if($game->isPracticeRoundEnabled()) + { + //drupal_set_message(t("Practice round enabled if loop ")); + if(! $game->IsPracticeRoundConducted()) + { + $practice_rounds_over_flag=$game->isPracticeRoundOver(); + Session::put('practice_round',$practice_rounds_over_flag); + //drupal_set_message(t("Practice round flag " . $practice_rounds_over_flag)); + } + else + { + $practice_round_conducted=TRUE; + } + } + else + { + $practice_round_conducted=TRUE; + } + if($practice_round_conducted) + { + if ($game->isVotingEnabled()) + { + if (!($game->isRuleSelected())) + { + $start_flag=TRUE; + } + } + + } } - else - { - $stage_flag=$game->isStageOver(); - // if($stage_flag) - //$game->setRoundNo($game->getCurrentRoundNo()); - - - } - //drupal_set_message(t('Stage flag is:' .$stage_flag)); + + // drupal_set_message(t('Stage flag is:' .$stage_flag)); - $form['submit'] = array( + /*$form['submit'] = array( '#type' => 'submit', - '#value' => ($stage_flag) ? t('Go to Next Stage') : t('Next Round'), + '#value' => ($stage_flag)?t('Go to Next Stage'):t('Next Round'), '#attributes' => array('onClick' => 'return confirm("Go to the next round? Any participants with unsubmitted harvest decisions will receive a default harvest decision.")') + );*/ + if($stage_flag) + { + $form['submit'] = array( + '#type' => 'submit', + '#value' => t('Go to Next Stage'), + // '#attributes' => array('onClick' => 'return confirm("Go to the next round? Any participants with unsubmitted harvest decisions will receive a default harvest decision.")') ); - if($start_flag) + } + else if(Session::get('practice_round')) { //drupal_get_messages(); + //drupal_set_message(t('This stage needs voting. Please tell students to vote.'),'warning',FALSE); + //drupal_get_messages(); + drupal_set_message(t('<h2 align="center" style="color:#990000">Practice Rounds are Over!</h2>')); + + $form['submit'] = array( + '#type' => 'submit', + '#value' => t('Start Game') + + ); + } + else 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', '#value' => t('Start Stage') ); - // unset($_SESSION['next_stage']); - - } + } + else + { + $form['submit'] = array( + '#type' => 'submit', + '#value' => t('Next Round'), + '#attributes' => array('onClick' => 'return confirm("Go to the next round? Any participants with unsubmitted harvest decisions will receive a default harvest decision.")') + ); + + } + + + } @@ -169,35 +225,38 @@ //chosen while for uneven rounds 2 students will ve randomely chosen. So, I //set flag, when flag=TRUE it means round is even , when flag=FALSE it means //that round is uneven. Ja! + + + //$practice_rounds_flag=Session::get('practicerounds'); + $game=Session::get('game'); if($form_values['submit']=="Next Round") { // $no_rounds = $game->getNumberOfRounds(); // $curr_round_no = $game->getCurrentRoundNo(); + //drupal_set_message("in next round"); $game->nextRound(); } else if($form_values['submit']=="Go to Next Stage") - { //initialise the stage 2 - - - // drupal_set_message(t('Go to stage 2')); + { + //initialise the stage + // drupal_set_message(t('Go to stage 2')); // FIXME: initNextStage is actually an initialization for voting stage - // remove that assumption + //drupal_set_message("in start game"); $game->initNextStage(); - - /*if ($game->isVotingEnabled()) - { - if ($game->isVotingDone()) - { - $rule_no=$game->initRules(); - } - else - form_set_error('submit',t('Please tell students to vote. Without voting you can not proceed to Stage 2')); - - }*/ -// $_SESSION['next_stage']='pressed'; - + } + else if($form_values['submit']=="Start Game") + { + + $game->initNextStage(); + Session::remove('practice_round'); + $game->updateStartFlag(true); + drupal_get_messages(); + + } + else if($form_values['submit']=="Start Stage") { if ($game->isVotingEnabled()) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <see...@us...> - 2008-10-23 22:09:00
|
Revision: 54 http://virtualcommons.svn.sourceforge.net/virtualcommons/?rev=54&view=rev Author: seematalele Date: 2008-10-23 21:56:35 +0000 (Thu, 23 Oct 2008) Log Message: ----------- Practice rounds are working correctly. Whole experiment tested; working properly. Modified Paths: -------------- vcweb/trunk/virtualcommons/experiment/experiment.inc Modified: vcweb/trunk/virtualcommons/experiment/experiment.inc =================================================================== --- vcweb/trunk/virtualcommons/experiment/experiment.inc 2008-09-24 22:42:55 UTC (rev 53) +++ vcweb/trunk/virtualcommons/experiment/experiment.inc 2008-10-23 21:56:35 UTC (rev 54) @@ -900,6 +900,103 @@ } + + + public function initRuleSetting() + { + $result_group=db_query("select id,vc_selected_rules_id from vc_group where vc_game_id=%d",$this->game_id); + while($data=db_fetch_object($result_group)) + { + $group_id=$data->id; + $selected_rule_id=$data->vc_selected_rules_id; + $selected_rule_no=db_result(db_query("select rule_no from vc_rules where id=%d",$selected_rule_id)); + $no_of_student=db_result(db_query("SELECT count(*) FROM vc_student WHERE vc_group_id=%d",$group_id)); + + if($selected_rule_no==1) + { + //setting for rule 1 + if($no_of_student==3) + { + if(($round_no%2)==0) //even + { + $stud_seq=rand(1,$no_of_student); + drupal_set_message(t('1 insert')); + 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,$stud_seq,$group_id,$selected_rule_id,$vc_game_id); + } + else //uneven + { + $stud1=rand(1,$no_of_student); + $stud2=rand(1,$no_of_student); + + while($stud1 == $stud2) + { + $stud1=rand(1,$no_of_student); + $stud2=rand(1,$no_of_student); + } + $stud_seq=$stud1.$stud2; + drupal_set_message(t('2 insert')); + 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,$stud_seq,$group_id,$selected_rule_id,$vc_game_id); + + } + } + + + + if($no_of_student==4) + { + $stud1=rand(1,$no_of_student); + $stud2=rand(1,$no_of_student); + + while($stud1 == $stud2) + { + $stud1=rand(1,$no_of_student); + $stud2=rand(1,$no_of_student); + } + $stud=$stud1.$stud2; + drupal_set_message(t('3 insert')); + db_query("insert into {virtualcommons_forestry_turn_sequence} + (virtualcommons_stage_no,round_no,virtualcommons_student_group_no,virtualcommons_rules_no,turn_sequence,virtualcommons_conducts_id) + values (%d,%d,%d,%d,'%s',%d)",2,$round_no,$group_no,$rule_no,$stud,$virtual_conduct_id); + } + + + if($no_of_student==5) + { + $stud1=rand(1,$no_of_student); + $stud2=rand(1,$no_of_student); + + while($stud1 == $stud2) + { + $stud1=rand(1,$no_of_student); + $stud2=rand(1,$no_of_student); + } + $stud=$stud1.$stud2; + drupal_set_message(t('4 insert')); + db_query("insert into {virtualcommons_forestry_turn_sequence} + (virtualcommons_stage_no,round_no,virtualcommons_student_group_no,virtualcommons_rules_no,turn_sequence,virtualcommons_conducts_id) + values (%d,%d,%d,%d,'%s',%d)",2,$round_no,$group_no,$rule_no,$stud,$virtual_conduct_id); + + } + + + + + } + else if($selected_rule_no==2) + { + //setting for rule 2 + } + else if($selected_rule_no==3) + { + //setting for rule 3 + } + } + + + } + }//end of class Game class Group { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <al...@us...> - 2008-09-24 22:43:07
|
Revision: 53 http://virtualcommons.svn.sourceforge.net/virtualcommons/?rev=53&view=rev Author: alllee Date: 2008-09-24 22:42:55 +0000 (Wed, 24 Sep 2008) Log Message: ----------- adding deployment script for windows (will need to be customized by the user for appropriate installed locations of Java and Ant, but this could be handled by another script...) Modified Paths: -------------- foraging/trunk/build.properties.example foraging/trunk/build.xml foraging/trunk/ivy.xml foraging/trunk/ivysettings.xml foraging/trunk/pom.xml foraging/trunk/src/main/resources/configuration/asu-experiments/2d-abstract/round1.xml foraging/trunk/src/main/resources/configuration/asu-experiments/2d-abstract/round2.xml foraging/trunk/src/main/resources/configuration/asu-experiments/2d-abstract/round3.xml foraging/trunk/src/main/resources/configuration/asu-experiments/2d-abstract/round4.xml foraging/trunk/src/main/resources/configuration/asu-experiments/2d-abstract/server.xml foraging/trunk/src/main/resources/configuration/asu-experiments/2d-forestry/round1.xml foraging/trunk/src/main/resources/configuration/asu-experiments/2d-forestry/round2.xml foraging/trunk/src/main/resources/configuration/asu-experiments/2d-forestry/round3.xml foraging/trunk/src/main/resources/configuration/asu-experiments/2d-forestry/round4.xml foraging/trunk/src/main/resources/configuration/asu-experiments/2d-forestry/server.xml foraging/trunk/src/main/resources/configuration/asu-experiments/abstract-2d/round1.xml foraging/trunk/src/main/resources/configuration/asu-experiments/abstract-2d/round2.xml foraging/trunk/src/main/resources/configuration/asu-experiments/abstract-2d/round3.xml foraging/trunk/src/main/resources/configuration/asu-experiments/abstract-2d/round4.xml foraging/trunk/src/main/resources/configuration/asu-experiments/abstract-2d/server.xml foraging/trunk/src/main/resources/configuration/asu-experiments/forestry-2d/round1.xml foraging/trunk/src/main/resources/configuration/asu-experiments/forestry-2d/round2.xml foraging/trunk/src/main/resources/configuration/asu-experiments/forestry-2d/round3.xml foraging/trunk/src/main/resources/configuration/asu-experiments/forestry-2d/round4.xml foraging/trunk/src/main/resources/configuration/asu-experiments/forestry-2d/server.xml foraging/trunk/src/main/resources/configuration/indiana-experiments/chat-sanction-open-access/round0.xml foraging/trunk/src/main/resources/configuration/indiana-experiments/chat-sanction-open-access/round1.xml foraging/trunk/src/main/resources/configuration/indiana-experiments/chat-sanction-open-access/round2.xml foraging/trunk/src/main/resources/configuration/indiana-experiments/chat-sanction-open-access/round3.xml foraging/trunk/src/main/resources/configuration/indiana-experiments/chat-sanction-open-access/round4.xml foraging/trunk/src/main/resources/configuration/indiana-experiments/chat-sanction-open-access/round5.xml foraging/trunk/src/main/resources/configuration/indiana-experiments/chat-sanction-open-access/round6.xml foraging/trunk/src/main/resources/configuration/indiana-experiments/round1.xml foraging/trunk/src/main/resources/configuration/indiana-experiments/round2.xml foraging/trunk/src/main/resources/configuration/indiana-experiments/round3.xml foraging/trunk/src/main/resources/configuration/indiana-experiments/round4.xml foraging/trunk/src/main/resources/configuration/indiana-experiments/round5.xml foraging/trunk/src/main/resources/configuration/indiana-experiments/round6.xml foraging/trunk/src/main/resources/configuration/round1.xml foraging/trunk/src/main/resources/configuration/round2.xml foraging/trunk/src/main/resources/configuration/round3.xml foraging/trunk/src/main/resources/configuration/round4.xml foraging/trunk/src/main/resources/configuration/server.xml Added Paths: ----------- foraging/trunk/deploy.bat foraging/trunk/src/main/resources/configuration/indiana-experiments/open-access-chat/ foraging/trunk/src/main/resources/configuration/indiana-experiments/open-access-chat/round0.xml foraging/trunk/src/main/resources/configuration/indiana-experiments/open-access-chat/round1.xml foraging/trunk/src/main/resources/configuration/indiana-experiments/open-access-chat/round2.xml foraging/trunk/src/main/resources/configuration/indiana-experiments/open-access-chat/round3.xml foraging/trunk/src/main/resources/configuration/indiana-experiments/open-access-chat/round4.xml foraging/trunk/src/main/resources/configuration/indiana-experiments/open-access-chat/round5.xml foraging/trunk/src/main/resources/configuration/indiana-experiments/open-access-chat/round6.xml foraging/trunk/src/main/resources/configuration/indiana-experiments/open-access-chat/server.xml Modified: foraging/trunk/build.properties.example =================================================================== --- foraging/trunk/build.properties.example 2008-09-12 20:46:29 UTC (rev 52) +++ foraging/trunk/build.properties.example 2008-09-24 22:42:55 UTC (rev 53) @@ -2,12 +2,16 @@ # the build.xml file. # server name, set this to the IP address or domain name that will be running -# the experiment server. +# the experiment server +# FIXME: currently, this MUST be the same as the IP address/domain name of the +# webserver you are deploying the software on. server.address=libai.la.asu.edu # the absolute path of where you would like to deploy the experiment JNLP and # jar files # (should be accessible / mounted by the webserver) +# NOTE: for windows, use double backslashes as a path separator +# web.dir=C:\\WebServer\\foraging web.dir=/var/www/html/foraging/ # The URL that maps to the path above. If you don't mind using "foraging" as Modified: foraging/trunk/build.xml =================================================================== --- foraging/trunk/build.xml 2008-09-12 20:46:29 UTC (rev 52) +++ foraging/trunk/build.xml 2008-09-24 22:42:55 UTC (rev 53) @@ -43,7 +43,7 @@ </target> <target name='resolve' depends='init-ivy' description='--> retrieve dependencies with ivy'> - <ivy:retrieve pattern='${lib.dir}/[conf]/[artifact].[ext]'/> + <ivy:retrieve pattern='${lib.dir}/[conf]/[artifact].[ext]'/> </target> <!-- Load all properties from the build.properties file, @@ -215,6 +215,7 @@ <delete dir="${build.dir}"/> <delete dir="${test.build.dir}"/> <delete dir='${dist.dir}'/> + <delete dir='${lib.dir}'/> <delete file='server.jar'/> </target> Added: foraging/trunk/deploy.bat =================================================================== --- foraging/trunk/deploy.bat (rev 0) +++ foraging/trunk/deploy.bat 2008-09-24 22:42:55 UTC (rev 53) @@ -0,0 +1,4 @@ +set ANT_HOME=C:\tools\ant +set JAVA_HOME=C:\Program Files\Java\jdk1.6.0_10 +set PATH=%ANT_HOME%\bin;%JAVA_HOME\bin;%PATH% +ant deploy Modified: foraging/trunk/ivy.xml =================================================================== --- foraging/trunk/ivy.xml 2008-09-12 20:46:29 UTC (rev 52) +++ foraging/trunk/ivy.xml 2008-09-24 22:42:55 UTC (rev 53) @@ -3,14 +3,11 @@ vim:sts=2:sw=2: --> <ivy-module version="2.0"> - <info organisation="edu.asu.commons" module="foraging"/> - <dependencies> - <dependency org='junit' name='junit' rev='4.4'/> - <dependency org="edu.asu.commons" name="csidex" rev="latest.integration"/> - <dependency org='net.java.dev.jogl' name='jogl' rev='1.1.1'/> - <dependency org='net.java.dev.jogl' name='gluegen-rt' rev='1.1.1'/> - </dependencies> + <info organisation="edu.asu.commons" module="foraging"/> + <dependencies> + <dependency org="junit" name="junit" rev="4.4"/> + <dependency org="edu.asu.commons" name="csidex" rev="latest.integration"/> + <dependency org="net.java.dev.jogl" name="jogl" rev="1.1.1"/> + <dependency org="net.java.dev.jogl" name="gluegen-rt" rev="1.1.1"/> + </dependencies> </ivy-module> - - - Modified: foraging/trunk/ivysettings.xml =================================================================== --- foraging/trunk/ivysettings.xml 2008-09-12 20:46:29 UTC (rev 52) +++ foraging/trunk/ivysettings.xml 2008-09-24 22:42:55 UTC (rev 53) @@ -6,12 +6,9 @@ <settings defaultResolver="tdar-archiva" checkUpToDate="false"/> <resolvers> <ibiblio name='tdar-archiva' m2compatible='true' root='http://dev.tdar.org/archiva/repository/internal'/> - <filesystem name="internal"> + <filesystem name="local"> <ivy pattern="${repository.dir}/[module]/ivy-[revision].xml"/> <artifact pattern="${repository.dir}/[module]/[artifact]-[revision].[ext]"/> </filesystem> </resolvers> - <modules> - <module organisation='edu.asu.commons' name='csidex' resolver='internal'/> - </modules> </ivysettings> Modified: foraging/trunk/pom.xml =================================================================== --- foraging/trunk/pom.xml 2008-09-12 20:46:29 UTC (rev 52) +++ foraging/trunk/pom.xml 2008-09-24 22:42:55 UTC (rev 53) @@ -34,7 +34,7 @@ <dependency> <groupId>edu.asu.commons</groupId> <artifactId>csidex</artifactId> - <version>0.1.1</version> + <version>0.2</version> </dependency> <dependency> <groupId>net.java.dev.jogl</groupId> Modified: foraging/trunk/src/main/resources/configuration/asu-experiments/2d-abstract/round1.xml =================================================================== --- foraging/trunk/src/main/resources/configuration/asu-experiments/2d-abstract/round1.xml 2008-09-12 20:46:29 UTC (rev 52) +++ foraging/trunk/src/main/resources/configuration/asu-experiments/2d-abstract/round1.xml 2008-09-24 22:42:55 UTC (rev 53) @@ -1,7 +1,7 @@ <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd"> <properties> -<comment>CSAN XML-ized experiment round configuration</comment> +<comment>Foraging XML-ized experiment round configuration</comment> <entry key="display-group-tokens">true</entry> <entry key="clients-per-group">4</entry> <entry key="duration">240</entry> Modified: foraging/trunk/src/main/resources/configuration/asu-experiments/2d-abstract/round2.xml =================================================================== --- foraging/trunk/src/main/resources/configuration/asu-experiments/2d-abstract/round2.xml 2008-09-12 20:46:29 UTC (rev 52) +++ foraging/trunk/src/main/resources/configuration/asu-experiments/2d-abstract/round2.xml 2008-09-24 22:42:55 UTC (rev 53) @@ -1,7 +1,7 @@ <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd"> <properties> -<comment>CSAN XML-ized experiment round configuration</comment> +<comment>Foraging XML-ized experiment round configuration</comment> <entry key="display-group-tokens">true</entry> <entry key="clients-per-group">4</entry> <entry key="duration">240</entry> Modified: foraging/trunk/src/main/resources/configuration/asu-experiments/2d-abstract/round3.xml =================================================================== --- foraging/trunk/src/main/resources/configuration/asu-experiments/2d-abstract/round3.xml 2008-09-12 20:46:29 UTC (rev 52) +++ foraging/trunk/src/main/resources/configuration/asu-experiments/2d-abstract/round3.xml 2008-09-24 22:42:55 UTC (rev 53) @@ -1,7 +1,7 @@ <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd"> <properties> -<comment>CSAN XML-ized experiment round configuration</comment> +<comment>Foraging XML-ized experiment round configuration</comment> <entry key="practice-round">true</entry> <entry key='resource-width'>8</entry> <entry key='resource-depth'>8</entry> Modified: foraging/trunk/src/main/resources/configuration/asu-experiments/2d-abstract/round4.xml =================================================================== --- foraging/trunk/src/main/resources/configuration/asu-experiments/2d-abstract/round4.xml 2008-09-12 20:46:29 UTC (rev 52) +++ foraging/trunk/src/main/resources/configuration/asu-experiments/2d-abstract/round4.xml 2008-09-24 22:42:55 UTC (rev 53) @@ -1,7 +1,7 @@ <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd"> <properties> -<comment>CSAN XML-ized experiment round configuration</comment> +<comment>Foraging XML-ized experiment round configuration</comment> <entry key="practice-round">false</entry> <entry key='resource-width'>8</entry> <entry key='resource-depth'>8</entry> Modified: foraging/trunk/src/main/resources/configuration/asu-experiments/2d-abstract/server.xml =================================================================== --- foraging/trunk/src/main/resources/configuration/asu-experiments/2d-abstract/server.xml 2008-09-12 20:46:29 UTC (rev 52) +++ foraging/trunk/src/main/resources/configuration/asu-experiments/2d-abstract/server.xml 2008-09-24 22:42:55 UTC (rev 53) @@ -1,7 +1,7 @@ <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd"> <properties> -<comment>CSAN XML-ized experiment round configuration</comment> +<comment>Foraging XML-ized experiment round configuration</comment> <entry key="hostname">@SERVER_ADDRESS@</entry> <entry key="port">@PORT_NUMBER@</entry> <entry key="round0">round0.xml</entry> Modified: foraging/trunk/src/main/resources/configuration/asu-experiments/2d-forestry/round1.xml =================================================================== --- foraging/trunk/src/main/resources/configuration/asu-experiments/2d-forestry/round1.xml 2008-09-12 20:46:29 UTC (rev 52) +++ foraging/trunk/src/main/resources/configuration/asu-experiments/2d-forestry/round1.xml 2008-09-24 22:42:55 UTC (rev 53) @@ -1,7 +1,7 @@ <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd"> <properties> -<comment>CSAN XML-ized experiment round configuration</comment> +<comment>Foraging XML-ized experiment round configuration</comment> <entry key="display-group-tokens">true</entry> <entry key="clients-per-group">4</entry> <entry key="duration">240</entry> Modified: foraging/trunk/src/main/resources/configuration/asu-experiments/2d-forestry/round2.xml =================================================================== --- foraging/trunk/src/main/resources/configuration/asu-experiments/2d-forestry/round2.xml 2008-09-12 20:46:29 UTC (rev 52) +++ foraging/trunk/src/main/resources/configuration/asu-experiments/2d-forestry/round2.xml 2008-09-24 22:42:55 UTC (rev 53) @@ -1,7 +1,7 @@ <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd"> <properties> -<comment>CSAN XML-ized experiment round configuration</comment> +<comment>Foraging XML-ized experiment round configuration</comment> <entry key="display-group-tokens">true</entry> <entry key="clients-per-group">4</entry> <entry key="duration">240</entry> Modified: foraging/trunk/src/main/resources/configuration/asu-experiments/2d-forestry/round3.xml =================================================================== --- foraging/trunk/src/main/resources/configuration/asu-experiments/2d-forestry/round3.xml 2008-09-12 20:46:29 UTC (rev 52) +++ foraging/trunk/src/main/resources/configuration/asu-experiments/2d-forestry/round3.xml 2008-09-24 22:42:55 UTC (rev 53) @@ -1,7 +1,7 @@ <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd"> <properties> -<comment>CSAN XML-ized experiment round configuration</comment> +<comment>Foraging XML-ized experiment round configuration</comment> <entry key="practice-round">true</entry> <entry key='resource-width'>8</entry> <entry key='resource-depth'>8</entry> Modified: foraging/trunk/src/main/resources/configuration/asu-experiments/2d-forestry/round4.xml =================================================================== --- foraging/trunk/src/main/resources/configuration/asu-experiments/2d-forestry/round4.xml 2008-09-12 20:46:29 UTC (rev 52) +++ foraging/trunk/src/main/resources/configuration/asu-experiments/2d-forestry/round4.xml 2008-09-24 22:42:55 UTC (rev 53) @@ -1,7 +1,7 @@ <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd"> <properties> -<comment>CSAN XML-ized experiment round configuration</comment> +<comment>Foraging XML-ized experiment round configuration</comment> <entry key="practice-round">false</entry> <entry key='resource-width'>8</entry> <entry key='resource-depth'>8</entry> Modified: foraging/trunk/src/main/resources/configuration/asu-experiments/2d-forestry/server.xml =================================================================== --- foraging/trunk/src/main/resources/configuration/asu-experiments/2d-forestry/server.xml 2008-09-12 20:46:29 UTC (rev 52) +++ foraging/trunk/src/main/resources/configuration/asu-experiments/2d-forestry/server.xml 2008-09-24 22:42:55 UTC (rev 53) @@ -1,7 +1,7 @@ <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd"> <properties> -<comment>CSAN XML-ized experiment round configuration</comment> +<comment>Foraging XML-ized experiment round configuration</comment> <entry key="hostname">@SERVER_ADDRESS@</entry> <entry key="port">@PORT_NUMBER@</entry> <entry key="round0">round0.xml</entry> Modified: foraging/trunk/src/main/resources/configuration/asu-experiments/abstract-2d/round1.xml =================================================================== --- foraging/trunk/src/main/resources/configuration/asu-experiments/abstract-2d/round1.xml 2008-09-12 20:46:29 UTC (rev 52) +++ foraging/trunk/src/main/resources/configuration/asu-experiments/abstract-2d/round1.xml 2008-09-24 22:42:55 UTC (rev 53) @@ -1,7 +1,7 @@ <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd"> <properties> -<comment>CSAN XML-ized experiment round configuration</comment> +<comment>Foraging XML-ized experiment round configuration</comment> <entry key="practice-round">false</entry> <entry key='resource-width'>8</entry> <entry key='resource-depth'>8</entry> Modified: foraging/trunk/src/main/resources/configuration/asu-experiments/abstract-2d/round2.xml =================================================================== --- foraging/trunk/src/main/resources/configuration/asu-experiments/abstract-2d/round2.xml 2008-09-12 20:46:29 UTC (rev 52) +++ foraging/trunk/src/main/resources/configuration/asu-experiments/abstract-2d/round2.xml 2008-09-24 22:42:55 UTC (rev 53) @@ -1,7 +1,7 @@ <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd"> <properties> -<comment>CSAN XML-ized experiment round configuration</comment> +<comment>Foraging XML-ized experiment round configuration</comment> <entry key="resource-width">14</entry> <entry key="resource-depth">14</entry> Modified: foraging/trunk/src/main/resources/configuration/asu-experiments/abstract-2d/round3.xml =================================================================== --- foraging/trunk/src/main/resources/configuration/asu-experiments/abstract-2d/round3.xml 2008-09-12 20:46:29 UTC (rev 52) +++ foraging/trunk/src/main/resources/configuration/asu-experiments/abstract-2d/round3.xml 2008-09-24 22:42:55 UTC (rev 53) @@ -1,7 +1,7 @@ <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd"> <properties> -<comment>CSAN XML-ized experiment round configuration</comment> +<comment>Foraging XML-ized experiment round configuration</comment> <entry key="display-group-tokens">true</entry> <entry key="clients-per-group">4</entry> <entry key="duration">240</entry> Modified: foraging/trunk/src/main/resources/configuration/asu-experiments/abstract-2d/round4.xml =================================================================== --- foraging/trunk/src/main/resources/configuration/asu-experiments/abstract-2d/round4.xml 2008-09-12 20:46:29 UTC (rev 52) +++ foraging/trunk/src/main/resources/configuration/asu-experiments/abstract-2d/round4.xml 2008-09-24 22:42:55 UTC (rev 53) @@ -1,7 +1,7 @@ <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd"> <properties> -<comment>CSAN XML-ized experiment round configuration</comment> +<comment>Foraging XML-ized experiment round configuration</comment> <entry key="display-group-tokens">true</entry> <entry key="clients-per-group">4</entry> <entry key="duration">240</entry> Modified: foraging/trunk/src/main/resources/configuration/asu-experiments/abstract-2d/server.xml =================================================================== --- foraging/trunk/src/main/resources/configuration/asu-experiments/abstract-2d/server.xml 2008-09-12 20:46:29 UTC (rev 52) +++ foraging/trunk/src/main/resources/configuration/asu-experiments/abstract-2d/server.xml 2008-09-24 22:42:55 UTC (rev 53) @@ -1,7 +1,7 @@ <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd"> <properties> -<comment>CSAN XML-ized experiment round configuration</comment> +<comment>Foraging XML-ized experiment round configuration</comment> <entry key="hostname">@SERVER_ADDRESS@</entry> <entry key="port">@PORT_NUMBER@</entry> <entry key="round0">round0.xml</entry> Modified: foraging/trunk/src/main/resources/configuration/asu-experiments/forestry-2d/round1.xml =================================================================== --- foraging/trunk/src/main/resources/configuration/asu-experiments/forestry-2d/round1.xml 2008-09-12 20:46:29 UTC (rev 52) +++ foraging/trunk/src/main/resources/configuration/asu-experiments/forestry-2d/round1.xml 2008-09-24 22:42:55 UTC (rev 53) @@ -1,7 +1,7 @@ <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd"> <properties> -<comment>CSAN XML-ized experiment round configuration</comment> +<comment>Foraging XML-ized experiment round configuration</comment> <entry key="practice-round">false</entry> <entry key='resource-width'>8</entry> <entry key='resource-depth'>8</entry> Modified: foraging/trunk/src/main/resources/configuration/asu-experiments/forestry-2d/round2.xml =================================================================== --- foraging/trunk/src/main/resources/configuration/asu-experiments/forestry-2d/round2.xml 2008-09-12 20:46:29 UTC (rev 52) +++ foraging/trunk/src/main/resources/configuration/asu-experiments/forestry-2d/round2.xml 2008-09-24 22:42:55 UTC (rev 53) @@ -1,7 +1,7 @@ <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd"> <properties> -<comment>CSAN XML-ized experiment round configuration</comment> +<comment>Foraging XML-ized experiment round configuration</comment> <entry key="resource-width">14</entry> <entry key="resource-depth">14</entry> Modified: foraging/trunk/src/main/resources/configuration/asu-experiments/forestry-2d/round3.xml =================================================================== --- foraging/trunk/src/main/resources/configuration/asu-experiments/forestry-2d/round3.xml 2008-09-12 20:46:29 UTC (rev 52) +++ foraging/trunk/src/main/resources/configuration/asu-experiments/forestry-2d/round3.xml 2008-09-24 22:42:55 UTC (rev 53) @@ -1,7 +1,7 @@ <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd"> <properties> -<comment>CSAN XML-ized experiment round configuration</comment> +<comment>Foraging XML-ized experiment round configuration</comment> <entry key="display-group-tokens">true</entry> <entry key="clients-per-group">4</entry> <entry key="duration">240</entry> Modified: foraging/trunk/src/main/resources/configuration/asu-experiments/forestry-2d/round4.xml =================================================================== --- foraging/trunk/src/main/resources/configuration/asu-experiments/forestry-2d/round4.xml 2008-09-12 20:46:29 UTC (rev 52) +++ foraging/trunk/src/main/resources/configuration/asu-experiments/forestry-2d/round4.xml 2008-09-24 22:42:55 UTC (rev 53) @@ -1,7 +1,7 @@ <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd"> <properties> -<comment>CSAN XML-ized experiment round configuration</comment> +<comment>Foraging XML-ized experiment round configuration</comment> <entry key="display-group-tokens">true</entry> <entry key="clients-per-group">4</entry> <entry key="duration">240</entry> Modified: foraging/trunk/src/main/resources/configuration/asu-experiments/forestry-2d/server.xml =================================================================== --- foraging/trunk/src/main/resources/configuration/asu-experiments/forestry-2d/server.xml 2008-09-12 20:46:29 UTC (rev 52) +++ foraging/trunk/src/main/resources/configuration/asu-experiments/forestry-2d/server.xml 2008-09-24 22:42:55 UTC (rev 53) @@ -1,7 +1,7 @@ <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd"> <properties> -<comment>CSAN XML-ized experiment round configuration</comment> +<comment>Foraging XML-ized experiment round configuration</comment> <entry key="hostname">@SERVER_ADDRESS@</entry> <entry key="port">@PORT_NUMBER@</entry> <entry key="round0">round0.xml</entry> Modified: foraging/trunk/src/main/resources/configuration/indiana-experiments/chat-sanction-open-access/round0.xml =================================================================== --- foraging/trunk/src/main/resources/configuration/indiana-experiments/chat-sanction-open-access/round0.xml 2008-09-12 20:46:29 UTC (rev 52) +++ foraging/trunk/src/main/resources/configuration/indiana-experiments/chat-sanction-open-access/round0.xml 2008-09-24 22:42:55 UTC (rev 53) @@ -1,7 +1,7 @@ <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd"> <properties> -<comment>CSAN XML-ized experiment round configuration</comment> +<comment>Foraging XML-ized experiment round configuration</comment> <entry key="resource-width">13</entry> <entry key="resource-depth">13</entry> <entry key="practice-round">true</entry> Modified: foraging/trunk/src/main/resources/configuration/indiana-experiments/chat-sanction-open-access/round1.xml =================================================================== --- foraging/trunk/src/main/resources/configuration/indiana-experiments/chat-sanction-open-access/round1.xml 2008-09-12 20:46:29 UTC (rev 52) +++ foraging/trunk/src/main/resources/configuration/indiana-experiments/chat-sanction-open-access/round1.xml 2008-09-24 22:42:55 UTC (rev 53) @@ -1,7 +1,7 @@ <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd"> <properties> -<comment>CSAN XML-ized experiment round configuration</comment> +<comment>Foraging XML-ized experiment round configuration</comment> <entry key="display-group-tokens">true</entry> <entry key="clients-per-group">5</entry> <entry key="resource-depth">29</entry> Modified: foraging/trunk/src/main/resources/configuration/indiana-experiments/chat-sanction-open-access/round2.xml =================================================================== --- foraging/trunk/src/main/resources/configuration/indiana-experiments/chat-sanction-open-access/round2.xml 2008-09-12 20:46:29 UTC (rev 52) +++ foraging/trunk/src/main/resources/configuration/indiana-experiments/chat-sanction-open-access/round2.xml 2008-09-24 22:42:55 UTC (rev 53) @@ -1,7 +1,7 @@ <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd"> <properties> -<comment>CSAN XML-ized experiment round configuration</comment> +<comment>Foraging XML-ized experiment round configuration</comment> <entry key="display-group-tokens">true</entry> <entry key="clients-per-group">5</entry> <entry key="resource-depth">29</entry> Modified: foraging/trunk/src/main/resources/configuration/indiana-experiments/chat-sanction-open-access/round3.xml =================================================================== --- foraging/trunk/src/main/resources/configuration/indiana-experiments/chat-sanction-open-access/round3.xml 2008-09-12 20:46:29 UTC (rev 52) +++ foraging/trunk/src/main/resources/configuration/indiana-experiments/chat-sanction-open-access/round3.xml 2008-09-24 22:42:55 UTC (rev 53) @@ -1,7 +1,7 @@ <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd"> <properties> -<comment>CSAN XML-ized experiment round configuration</comment> +<comment>Foraging XML-ized experiment round configuration</comment> <entry key="display-group-tokens">true</entry> <entry key="clients-per-group">5</entry> <entry key="resource-depth">29</entry> Modified: foraging/trunk/src/main/resources/configuration/indiana-experiments/chat-sanction-open-access/round4.xml =================================================================== --- foraging/trunk/src/main/resources/configuration/indiana-experiments/chat-sanction-open-access/round4.xml 2008-09-12 20:46:29 UTC (rev 52) +++ foraging/trunk/src/main/resources/configuration/indiana-experiments/chat-sanction-open-access/round4.xml 2008-09-24 22:42:55 UTC (rev 53) @@ -1,7 +1,7 @@ <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd"> <properties> -<comment>CSAN XML-ized experiment round configuration</comment> +<comment>Foraging XML-ized experiment round configuration</comment> <entry key="display-group-tokens">true</entry> <entry key="clients-per-group">5</entry> <entry key="duration">240</entry> Modified: foraging/trunk/src/main/resources/configuration/indiana-experiments/chat-sanction-open-access/round5.xml =================================================================== --- foraging/trunk/src/main/resources/configuration/indiana-experiments/chat-sanction-open-access/round5.xml 2008-09-12 20:46:29 UTC (rev 52) +++ foraging/trunk/src/main/resources/configuration/indiana-experiments/chat-sanction-open-access/round5.xml 2008-09-24 22:42:55 UTC (rev 53) @@ -1,7 +1,7 @@ <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd"> <properties> -<comment>CSAN XML-ized experiment round configuration</comment> +<comment>Foraging XML-ized experiment round configuration</comment> <entry key="display-group-tokens">true</entry> <entry key="clients-per-group">5</entry> <entry key="duration">240</entry> Modified: foraging/trunk/src/main/resources/configuration/indiana-experiments/chat-sanction-open-access/round6.xml =================================================================== --- foraging/trunk/src/main/resources/configuration/indiana-experiments/chat-sanction-open-access/round6.xml 2008-09-12 20:46:29 UTC (rev 52) +++ foraging/trunk/src/main/resources/configuration/indiana-experiments/chat-sanction-open-access/round6.xml 2008-09-24 22:42:55 UTC (rev 53) @@ -1,7 +1,7 @@ <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd"> <properties> -<comment>CSAN XML-ized experiment round configuration</comment> +<comment>Foraging XML-ized experiment round configuration</comment> <entry key="display-group-tokens">true</entry> <entry key="clients-per-group">5</entry> <entry key="duration">240</entry> Added: foraging/trunk/src/main/resources/configuration/indiana-experiments/open-access-chat/round0.xml =================================================================== --- foraging/trunk/src/main/resources/configuration/indiana-experiments/open-access-chat/round0.xml (rev 0) +++ foraging/trunk/src/main/resources/configuration/indiana-experiments/open-access-chat/round0.xml 2008-09-24 22:42:55 UTC (rev 53) @@ -0,0 +1,122 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd"> +<properties> +<comment>Foraging XML-ized experiment round configuration</comment> +<entry key="resource-width">13</entry> +<entry key="resource-depth">13</entry> +<entry key="practice-round">true</entry> +<entry key="private-property">true</entry> +<entry key="duration">240</entry> + +<entry key='regrowth-rate'>.01</entry> +<entry key='initial-distribution'>.25</entry> +<entry key='always-explicit'>true</entry> + +<entry key="quiz">true</entry> +<entry key="q1">C</entry> +<entry key="q2">B</entry> + +<entry key="instructions"> +<![CDATA[ +<h3>General Instructions</h3> +<p> +You appear on the screen as a yellow dot <img src="@CODEBASE_URL@/images/gem-self.gif">, +and your other group members appear as blue dots <img src="@CODEBASE_URL@/images/gem-other.gif">. +You move by pressing the four arrow keys to the right of your keyboard. You +can move either up, down, left, or right. You have to press a key for every +move of your yellow dot. In this experiment you can collect green diamond +shaped tokens +<img src="@CODEBASE_URL@/images/gem-token.gif"> and you will +earn two cents for each collected token. To collect a token, simply move your +yellow dot over a green token and press the <b>space bar</b>. If you move +over a token without pressing the <b>space bar</> you will NOT collect that +token. +</p> + +<p> +The tokens that you collect have the potential to regenerate. After you have +collected a green token, a new token can once again appear on that empty cell. +However, the rate at which new tokens will appear depends on the number of +adjacent cells that still have tokens. The more tokens in the 8 cells around +an empty cel, the faster a new token will appear on that empty cell. Tokens +generate new tokens. Thus the middle cell in Image 1 denoted with X will be +regenerated at a faster rate than the middle cell in Image 2. When all +neighboring cells are empty, there is no renewal. + +<table width="100%"> +<tr> +<td align="center"><b>Image 1</b></td> +<td align="center"><b>Image 2</b></td> +</tr> +<tr> +<td align="center"> +<img src="@CODEBASE_URL@/images/8neighbors.jpg" alt="image 1"> +</td> +<td align="center"> +<img src="@CODEBASE_URL@/images/5neighbors.jpg" alt="image 2"> +</td> +</tr> +</table> +<hr> +<h3>Practice Round Instructions</h3> +<hr> +<p> +You will now have four minutes to practice with the experimental environment. +The decisions you make in this round will NOT influence your earnings. At the +At the beginning of the practice round half of the cells are occupied +with green tokens. The environment is a 13 x 13 grid of cells. +</p> +<p> +When you push the <b>R</b> key you will reset the distribution of +the tokens to randomly occupying half of the cells with green tokens. +</p> + +<p><center><b>Please do not communicate with any other participant.</b></center></p> +<p>If you have any questions please raise your hand. <b>Do you have any +questions so far?</b></p> +]]> +</entry> + +<entry key="quiz-instructions"> +<![CDATA[ +<p> +Before we begin the practice round you need to answer the following questions +correctly. You can only continue when you have answered all questions +correctly. If an error is made you will need to answer the questions again. +</p> +<br> +<form> +Which of the statements is incorrect? <br> +<input type="radio" name="q1" value="A">Your decisions of where to collect tokens affect the regeneration of tokens.<br> +<input type="radio" name="q1" value="B">When you have collected all tokens on +the screen, no new tokens will appear.<br> +<input type="radio" name="q1" value="C">Tokens grow from the middle of the +screen.<br> +<input type="radio" name="q1" value="D">In order to collect a token you need +to press the space bar while your avatar is on a cell with a token.<br> +<br><br> + +Which sequence of situations is not possible? <br> +<img src="@CODEBASE_URL@/images/question2.jpg"><br> +<input type="radio" name="q2" value="A">A<br> +<input type="radio" name="q2" value="B">B<br> +<input type="radio" name="q2" value="C">C<br> +<br> +<input type="submit" name="submit" value="Submit"> +</form> +]]> +</entry> +<entry key="welcome-instructions"> +<![CDATA[ +<h3>Welcome</h3> +<p> +Welcome. You have already earned 5 dollars for showing up at this experiment. +You can earn more, up to a maximum of 40 dollars, by participating in this +experiment, which will take about an hour. The amount of money you earn +depends on your decisions as well as the decisions of your group members +during the four rounds of the experiment. +</p> +]]> +</entry> + +</properties> Added: foraging/trunk/src/main/resources/configuration/indiana-experiments/open-access-chat/round1.xml =================================================================== --- foraging/trunk/src/main/resources/configuration/indiana-experiments/open-access-chat/round1.xml (rev 0) +++ foraging/trunk/src/main/resources/configuration/indiana-experiments/open-access-chat/round1.xml 2008-09-24 22:42:55 UTC (rev 53) @@ -0,0 +1,48 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd"> +<properties> +<comment>Foraging XML-ized experiment round configuration</comment> +<entry key="display-group-tokens">true</entry> +<entry key="clients-per-group">5</entry> +<entry key="duration">240</entry> +<entry key="resource-depth">29</entry> +<entry key="resource-width">29</entry> + +<entry key='always-explicit'>true</entry> +<entry key='max-cell-occupancy'>1</entry> + +<entry key="initial-distribution">.25</entry> +<entry key="regrowth-rate">0.01</entry> + + +<entry key="instructions"> +<![CDATA[ +<h3>Round 1 Instructions</h3> +<hr> +<p> +This is the first round of the experiment. The length of the round is 4 +minutes. Like in the practice round you can collect green tokens. This time +you earn <b>two cents</b> for each token collected. This time you +<b>cannot</b> reset the distribution of green tokens. +</p> +<p> +In this round the renewable resource will become five times bigger. You +will share this larger environment with four other players in this room. +Each of you has been randomly assigned to one of several equal-sized +groups. Each of the groups is collecting tokens from an identical, but +separate resource. +</p> +<p> +Each of you has been assigned a number from 1 to 5. The other four players +will appear on the screen as blue dots +<img src="@CODEBASE_URL@/images/gem-other.gif"> with a white +number embedded in the dot. On the top right corner of the screen you can see +how many tokens each player has collected. +</p> +<p> +If you have any questions please raise your hand. <b>Do you have any +questions so far?</b> +</p> +]]> +</entry> +</properties> Added: foraging/trunk/src/main/resources/configuration/indiana-experiments/open-access-chat/round2.xml =================================================================== --- foraging/trunk/src/main/resources/configuration/indiana-experiments/open-access-chat/round2.xml (rev 0) +++ foraging/trunk/src/main/resources/configuration/indiana-experiments/open-access-chat/round2.xml 2008-09-24 22:42:55 UTC (rev 53) @@ -0,0 +1,30 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd"> +<properties> +<comment>Foraging XML-ized experiment round configuration</comment> +<entry key="display-group-tokens">true</entry> +<entry key="clients-per-group">5</entry> +<entry key="duration">240</entry> +<entry key="resource-depth">29</entry> +<entry key="resource-width">29</entry> + +<entry key='always-explicit'>true</entry> +<entry key='max-cell-occupancy'>1</entry> + +<entry key="initial-distribution">.25</entry> +<entry key="regrowth-rate">0.01</entry> + +<entry key="instructions"> +<![CDATA[ +<h3>Round 2 Instructions</h3> +<hr> +<p> +Round 2 is the same as round 1. +</p> +<p> +If you have any questions please raise your hand. <b>Do you have any +questions so far?</b> +</p> +]]> +</entry> +</properties> Added: foraging/trunk/src/main/resources/configuration/indiana-experiments/open-access-chat/round3.xml =================================================================== --- foraging/trunk/src/main/resources/configuration/indiana-experiments/open-access-chat/round3.xml (rev 0) +++ foraging/trunk/src/main/resources/configuration/indiana-experiments/open-access-chat/round3.xml 2008-09-24 22:42:55 UTC (rev 53) @@ -0,0 +1,39 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd"> +<properties> +<comment>Foraging XML-ized experiment round configuration</comment> +<entry key="display-group-tokens">true</entry> +<entry key="clients-per-group">5</entry> +<entry key="duration">240</entry> +<entry key="resource-depth">29</entry> +<entry key="resource-width">29</entry> + +<entry key='always-explicit'>true</entry> +<entry key='max-cell-occupancy'>1</entry> + +<!-- resource regrowth parameters --> +<entry key="initial-distribution">.25</entry> +<entry key="regrowth-rate">0.01</entry> + +<!-- +<entry key="patchy">true</entry> +<entry key="top-initial-distribution">0.50</entry> +<entry key="top-rate">0.02</entry> +<entry key="bottom-initial-distribution">0.25</entry> +<entry key="bottom-rate">0.01</entry> +--> + +<entry key="instructions"> +<![CDATA[ +<h3>Round 3 Instructions</h3> +<hr> +<p> +Round 3 is the same as round 2. +</p> +<p> +If you have any questions please raise your hand. <b>Do you have any +questions so far?</b> +</p> +]]> +</entry> +</properties> Added: foraging/trunk/src/main/resources/configuration/indiana-experiments/open-access-chat/round4.xml =================================================================== --- foraging/trunk/src/main/resources/configuration/indiana-experiments/open-access-chat/round4.xml (rev 0) +++ foraging/trunk/src/main/resources/configuration/indiana-experiments/open-access-chat/round4.xml 2008-09-24 22:42:55 UTC (rev 53) @@ -0,0 +1,68 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd"> +<properties> +<comment>Foraging XML-ized experiment round configuration</comment> +<entry key="display-group-tokens">true</entry> +<entry key="clients-per-group">5</entry> +<entry key="resource-depth">29</entry> +<entry key="resource-width">29</entry> +<entry key="duration">240</entry> + +<entry key='always-explicit'>true</entry> +<entry key='max-cell-occupancy'>1</entry> + +<!-- before this round begins, we have a chat session --> +<entry key="chat-enabled">true</entry> +<entry key="chat-duration">240</entry> + +<entry key="initial-distribution">.25</entry> +<entry key="regrowth-rate">0.01</entry> + +<entry key="instructions"> +<![CDATA[ +<h3>Round 4 Instructions</h3> +<hr> +<p> +Round 4 is the same as the previous two rounds with one exception. +</p> +<p> +Before the next round starts you can anonymously communicate by text messages +for four minutes with the other participants in your group. You can use this +opportunity to discuss the experiment and coordinate your actions to improve +your earnings. You may not promise them side-payments after the experiment is +completed or make any threats. You are also not allowed to reveal your real +identity. We are monitoring the chat traffic while you chat. +</p> +<p> +The length of this round is four minutes. +</p> +<p> +If you have any questions please raise your hand. <b>Do you have any +questions so far?</b> +</p> +]]> +</entry> + +<entry key="chat-instructions"> +<![CDATA[ +<p> +You can now chat with the other participants in your group for 4 minutes +total. During the chat round, you may communicate about any aspect of the +experiment that you would like to discuss with other participants with whom +you have been matched. You may not promise them side-payments after the +experiment is completed or threaten them with any consequence after the +experiment is finished. We are monitoring the chat traffic while you chat. If +we see that somebody reveals his or her identity, we have to stop the +experiment and remove the whole group from which this person is a member out +of this room. +</p> +<p> +You will see other participants labeled as "1", "2","3", "4", or "5" in the +chat box. You can send a chat message by typing into the textfield at the +bottom of the screen and clicking the "send" button with your mouse or +pressing the "enter" key on your keyboard. +</p> +]]> +</entry> + +</properties> Added: foraging/trunk/src/main/resources/configuration/indiana-experiments/open-access-chat/round5.xml =================================================================== --- foraging/trunk/src/main/resources/configuration/indiana-experiments/open-access-chat/round5.xml (rev 0) +++ foraging/trunk/src/main/resources/configuration/indiana-experiments/open-access-chat/round5.xml 2008-09-24 22:42:55 UTC (rev 53) @@ -0,0 +1,68 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd"> +<properties> +<comment>Foraging XML-ized experiment round configuration</comment> +<entry key="display-group-tokens">true</entry> +<entry key="clients-per-group">5</entry> +<entry key="resource-depth">29</entry> +<entry key="resource-width">29</entry> +<entry key="duration">240</entry> + +<entry key="initial-distribution">.25</entry> +<entry key="regrowth-rate">0.01</entry> + +<entry key='always-explicit'>true</entry> +<entry key='max-cell-occupancy'>1</entry> + +<!-- before this round begins, we have a chat session --> +<entry key="chat-enabled">true</entry> +<entry key="chat-duration">240</entry> + +<entry key="instructions"> +<![CDATA[ +<h3>Round 5 Instructions</h3> +<hr> +<p> +Round 5 is the same as round 4.</p> +<p> +The length of this round is again four minutes. +</p> +<p> +If you have any questions please raise your hand. <b>Do you have any +questions so far?</b> +</p> +]]> +</entry> + +<entry key="chat-instructions"> +<![CDATA[ +<p> +You can now chat with the other participants in your group for 4 minutes +total. During the chat round, you may communicate about any aspect of the +experiment that you would like to discuss with other participants with whom +you have been matched. You may not promise them side-payments after the +experiment is completed or threaten them with any consequence after the +experiment is finished. We are monitoring the chat traffic while you chat. If +we see that somebody reveals his or her identity, we have to stop the +experiment and remove the whole group from which this person is a member out +of this room. +</p> +<p> +You will see other participants labeled as "1", "2","3", "4", or "5" in the +chat box. You can send a chat message by typing into the textfield at the +bottom of the screen and clicking the "send" button with your mouse or +pressing the "enter" key on your keyboard. +</p> +]]> +</entry> + +<entry key='private-chat-instructions'> +<![CDATA[ +You may send private messages to a specific participant by clicking on the +appropriately labeled button (1, 2, 3, 4, or 5) before typing your message in +the chat box and sending it. By default you are communicating with all +members of your group. +]]> +</entry> + +</properties> Added: foraging/trunk/src/main/resources/configuration/indiana-experiments/open-access-chat/round6.xml =================================================================== --- foraging/trunk/src/main/resources/configuration/indiana-experiments/open-access-chat/round6.xml (rev 0) +++ foraging/trunk/src/main/resources/configuration/indiana-experiments/open-access-chat/round6.xml 2008-09-24 22:42:55 UTC (rev 53) @@ -0,0 +1,75 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd"> +<properties> +<comment>Foraging XML-ized experiment round configuration</comment> +<entry key="display-group-tokens">true</entry> +<entry key="clients-per-group">5</entry> +<entry key="resource-depth">29</entry> +<entry key="resource-width">29</entry> +<entry key="duration">240</entry> + +<entry key="initial-distribution">.25</entry> +<entry key="regrowth-rate">0.01</entry> + +<entry key='always-explicit'>true</entry> +<entry key='max-cell-occupancy'>1</entry> + +<!-- before this round begins, we have a chat session --> +<entry key="chat-enabled">true</entry> +<entry key="chat-duration">240</entry> + +<entry key="instructions"> +<![CDATA[ +<h3>Round 6 Instructions</h3> +<hr> +<p> +Round 6 is the same as round 5.</p> +<p> +The length of this round is again four minutes. +</p> +<p> +If you have any questions please raise your hand. <b>Do you have any +questions so far?</b> +</p> +]]> +</entry> + +<entry key="last-round-debriefing"> +<![CDATA[ +<p> +This was the last round, but not the end of the experiment. We will now +determine your payments. While we are doing this, we request that you +carefully fill out a brief survey. +</p> +<p> +When we are ready we will call you one by one to the room next door. We will +pay you there in private. Please wait until your computer number is called, +and then proceed to the room next door to turn in your computer number and +your survey. +</p> +<p> +Please answer the survey carefully and thank you for participating. +</p> +]]> +</entry> + +<entry key="chat-instructions"> +<![CDATA[ +<p> +You can now chat with the other participants in your group for 4 minutes +total. During the chat round, you may communicate about any aspect of the +experiment that you would like to discuss with other participants with whom +you have been matched. You may not promise them side-payments after the +experiment is completed or threaten them with any consequence after the +experiment is finished. We are monitoring the chat traffic while you chat. If +we detect that somebody has revealed their identity, we will have to stop the +experiment and remove that person's entire group from the experiment. +</p> +<p> +You will see other participants labeled as "1", "2","3", "4", or "5" in the +chat box. You can send a chat message by typing into the textfield at the +bottom of the screen and clicking the "send" button with your mouse or +pressing the "enter" key on your keyboard. </p> +]]> +</entry> +</properties> Added: foraging/trunk/src/main/resources/configuration/indiana-experiments/open-access-chat/server.xml =================================================================== --- foraging/trunk/src/main/resources/configuration/indiana-experiments/open-access-chat/server.xml (rev 0) +++ foraging/trunk/src/main/resources/configuration/indiana-experiments/open-access-chat/server.xml 2008-09-24 22:42:55 UTC (rev 53) @@ -0,0 +1,30 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd"> +<properties> +<comment>Costly Sanctioning XML-ized experiment round configuration</comment> +<entry key="hostname">@SERVER_ADDRESS@</entry> +<entry key="port">@PORT_NUMBER@</entry> +<entry key="round0">round0.xml</entry> +<entry key="round1">round1.xml</entry> +<entry key="round2">round2.xml</entry> +<entry key="round3">round3.xml</entry> +<entry key="round4">round4.xml</entry> +<entry key="round5">round5.xml</entry> +<entry key="round6">round6.xml</entry> +<entry key="wait-for-participants">true</entry> +<entry key="number-of-rounds">7</entry> +<entry key="facilitator-instructions"> +<![CDATA[ +<h3>Facilitator Instructions</h3> +<p> +Welcome to the facilitator interface. This interface allows you to control +the experiment. You may only modify configuration parameters <b>before</b> +you start the experiment by selecting the Configuration menu. When all the +participants are ready to begin the experiment, you can start the experiment +by selecting Experiment -> Start. After a round has been completed you +will be able to view the statistics for all of the participants. You can +begin the next round by selecting Round -> Start. +</p> +]]> +</entry> +</properties> Modified: foraging/trunk/src/main/resources/configuration/indiana-experiments/round1.xml =================================================================== --- foraging/trunk/src/main/resources/configuration/indiana-experiments/round1.xml 2008-09-12 20:46:29 UTC (rev 52) +++ foraging/trunk/src/main/resources/configuration/indiana-experiments/round1.xml 2008-09-24 22:42:55 UTC (rev 53) @@ -1,7 +1,7 @@ <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd"> <properties> -<comment>CSAN XML-ized experiment round configuration</comment> +<comment>Foraging XML-ized experiment round configuration</comment> <entry key="display-group-tokens">true</entry> <entry key="clients-per-group">5</entry> <entry key="duration">240</entry> Modified: foraging/trunk/src/main/resources/configuration/indiana-experiments/round2.xml =================================================================== --- foraging/trunk/src/main/resources/configuration/indiana-experiments/round2.xml 2008-09-12 20:46:29 UTC (rev 52) +++ foraging/trunk/src/main/resources/configuration/indiana-experiments/round2.xml 2008-09-24 22:42:55 UTC (rev 53) @@ -1,7 +1,7 @@ <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd"> <properties> -<comment>CSAN XML-ized experiment round configuration</comment> +<comment>Foraging XML-ized experiment round configuration</comment> <entry key="display-group-tokens">true</entry> <entry key="clients-per-group">5</entry> <entry key="duration">240</entry> Modified: foraging/trunk/src/main/resources/configuration/indiana-experiments/round3.xml =================================================================== --- foraging/trunk/src/main/resources/configuration/indiana-experiments/round3.xml 2008-09-12 20:46:29 UTC (rev 52) +++ foraging/trunk/src/main/resources/configuration/indiana-experiments/round3.xml 2008-09-24 22:42:55 UTC (rev 53) @@ -1,7 +1,7 @@ <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd"> <properties> -<comment>CSAN XML-ized experiment round configuration</comment> +<comment>Foraging XML-ized experiment round configuration</comment> <entry key="display-group-tokens">true</entry> <entry key="clients-per-group">5</entry> <entry key="duration">240</entry> Modified: foraging/trunk/src/main/resources/configuration/indiana-experiments/round4.xml =================================================================== --- foraging/trunk/src/main/resources/configuration/indiana-experiments/round4.xml 2008-09-12 20:46:29 UTC (rev 52) +++ foraging/trunk/src/main/resources/configuration/indiana-experiments/round4.xml 2008-09-24 22:42:55 UTC (rev 53) @@ -1,7 +1,7 @@ <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd"> <properties> -<comment>CSAN XML-ized experiment round configuration</comment> +<comment>Foraging XML-ized experiment round configuration</comment> <entry key="display-group-tokens">true</entry> <entry key="clients-per-group">5</entry> <entry key="resource-depth">29</entry> Modified: foraging/trunk/src/main/resources/configuration/indiana-experiments/round5.xml =================================================================== --- foraging/trunk/src/main/resources/configuration/indiana-experiments/round5.xml 2008-09-12 20:46:29 UTC (rev 52) +++ foraging/trunk/src/main/resources/configuration/indiana-experiments/round5.xml 2008-09-24 22:42:55 UTC (rev 53) @@ -1,7 +1,7 @@ <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd"> <properties> -<comment>CSAN XML-ized experiment round configuration</comment> +<comment>Foraging XML-ized experiment round configuration</comment> <entry key="display-group-tokens">true</entry> <entry key="clients-per-group">5</entry> <entry key="resource-depth">29</entry> Modified: foraging/trunk/src/main/resources/configuration/indiana-experiments/round6.xml =================================================================== --- foraging/trunk/src/main/resources/configuration/indiana-experiments/round6.xml 2008-09-12 20:46:29 UTC (rev 52) +++ foraging/trunk/src/main/resources/configuration/indiana-experiments/round6.xml 2008-09-24 22:42:55 UTC (rev 53) @@ -1,7 +1,7 @@ <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd"> <properties> -<comment>CSAN XML-ized experiment round configuration</comment> +<comment>Foraging XML-ized experiment round configuration</comment> <entry key="display-group-tokens">true</entry> <entry key="clients-per-group">5</entry> <entry key="resource-depth">29</entry> Modified: foraging/trunk/src/main/resources/configuration/round1.xml =================================================================== --- foraging/trunk/src/main/resources/configuration/round1.xml 2008-09-12 20:46:29 UTC (rev 52) +++ foraging/trunk/src/main/resources/configuration/round1.xml 2008-09-24 22:42:55 UTC (rev 53) @@ -1,7 +1,7 @@ <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd"> <properties> -<comment>CSAN XML-ized experiment round configuration</comment> +<comment>Foraging XML-ized experiment round configuration</comment> <entry key="display-group-tokens">true</entry> <entry key="clients-per-group">4</entry> <entry key="duration">240</entry> Modified: foraging/trunk/src/main/resources/configuration/round2.xml =================================================================== --- foraging/trunk/src/main/resources/configuration/round2.xml 2008-09-12 20:46:29 UTC (rev 52) +++ foraging/trunk/src/main/resources/configuration/round2.xml 2008-09-24 22:42:55 UTC (rev 53) @@ -1,7 +1,7 @@ <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd"> <properties> -<comment>CSAN XML-ized experiment round configuration</comment> +<comment>Foraging XML-ized experiment round configuration</comment> <entry key="display-group-tokens">true</entry> <entry key="clients-per-group">4</entry> <entry key="duration">240</entry> Modified: foraging/trunk/src/main/resources/configuration/round3.xml =================================================================== --- foraging/trunk/src/main/resources/configuration/round3.xml 2008-09-12 20:46:29 UTC (rev 52) +++ foraging/trunk/src/main/resources/configuration/round3.xml 2008-09-24 22:42:55 UTC (rev 53) @@ -1,7 +1,7 @@ <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd"> <properties> -<comment>CSAN XML-ized experiment round configuration</comment> +<comment>Foraging XML-ized experiment round configuration</comment> <entry key="practice-round">true</entry> <entry key='resource-width'>8</entry> <entry key='resource-depth'>8</entry> Modified: foraging/trunk/src/main/resources/configuration/round4.xml =================================================================== --- foraging/trunk/src/main/resources/configuration/round4.xml 2008-09-12 20:46:29 UTC (rev 52) +++ foraging/trunk/src/main/resources/configuration/round4.xml 2008-09-24 22:42:55 UTC (rev 53) @@ -1,7 +1,7 @@ <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd"> <properties> -<comment>CSAN XML-ized experiment round configuration</comment> +<comment>Foraging XML-ized experiment round configuration</comment> <entry key="practice-round">false</entry> <entry key='resource-width'>8</entry> <entry key='resource-depth'>8</entry> Modified: foraging/trunk/src/main/resources/configuration/server.xml =================================================================== --- foraging/trunk/src/main/resources/configuration/server.xml 2008-09-12 20:46:29 UTC (rev 52) +++ foraging/trunk/src/main/resources/configuration/server.xml 2008-09-24 22:42:55 UTC (rev 53) @@ -1,7 +1,7 @@ <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd"> <properties> -<comment>CSAN XML-ized experiment round configuration</comment> +<comment>Foraging XML experiment configuration</comment> <entry key="hostname">@SERVER_ADDRESS@</entry> <entry key="port">@PORT... [truncated message content] |
From: <al...@us...> - 2008-09-12 22:19:33
|
Revision: 52 http://virtualcommons.svn.sourceforge.net/virtualcommons/?rev=52&view=rev Author: alllee Date: 2008-09-12 20:46:29 +0000 (Fri, 12 Sep 2008) Log Message: ----------- adding createFromXml to SavedRoundData. Refactor later. Modified Paths: -------------- csidex/trunk/src/main/java/edu/asu/commons/experiment/Persister.java csidex/trunk/src/main/java/edu/asu/commons/experiment/SavedRoundData.java Modified: csidex/trunk/src/main/java/edu/asu/commons/experiment/Persister.java =================================================================== --- csidex/trunk/src/main/java/edu/asu/commons/experiment/Persister.java 2008-09-09 01:06:15 UTC (rev 51) +++ csidex/trunk/src/main/java/edu/asu/commons/experiment/Persister.java 2008-09-12 20:46:29 UTC (rev 52) @@ -27,6 +27,19 @@ import edu.asu.commons.event.EventTypeProcessor; import edu.asu.commons.event.PersistableEvent; +/** + * $Id$ + * + * Base class responsible for persistence strategies. + * + * TODO: clean up path generation for the files associated with different persistence types.. currently + * it is an ad-hoc mess. + * + * @author <a href='mailto:All...@as...'>Allen Lee</a> + * @version $Revision$ + * @param <T> + * @param <R> + */ public abstract class Persister<T extends ExperimentConfiguration<R>, R extends ExperimentRoundParameters<T>> { @@ -69,17 +82,9 @@ initializeChatLogFileHandler(); } - private void initializeXmlSave() { - xmlEnabled = roundConfiguration.getParentConfiguration().getPersistenceType().isXmlEnabled(); - if ( xmlEnabled ) { - String xmlSaveFilePath = getXmlSaveFilePath(); - logger.info("saving xml files to: " + xmlSaveFilePath); - createDirectoryIfNeeded(xmlSaveFilePath); - } - } - private String getXmlSaveFilePath() { - return getDefaultSavePath() + File.separator + roundConfiguration.getRoundNumber() + ".save.xml"; + return String.format("%s%s%d-round-save.xml", getDefaultSavePath(), File.separator, roundConfiguration.getRoundNumber()); +// return getDefaultSavePath() + File.separator + roundConfiguration.getRoundNumber() + ".save.xml"; } public Persister(EventChannel channel, T experimentConfiguration) { @@ -276,6 +281,7 @@ public static String getRoundSaveFilePath(String directory, int roundNumber) { return String.format("%s%sround-%d.save", directory, File.separator, roundNumber); +// return String.format("%s%s%d-round-save.xml", directory, File.separator, roundNumber); } public static SavedRoundData restoreSavedRoundData(File directory, int roundNumber) { @@ -286,6 +292,8 @@ throw new IllegalArgumentException("Directory " + directory.getAbsolutePath() + " does not exist."); } String roundSaveFilePath = getRoundSaveFilePath(directory.getAbsolutePath(), roundNumber); + // how best to flip between binary and XML? The round save file path is different for both.. + return SavedRoundData.create(roundSaveFilePath); } Modified: csidex/trunk/src/main/java/edu/asu/commons/experiment/SavedRoundData.java =================================================================== --- csidex/trunk/src/main/java/edu/asu/commons/experiment/SavedRoundData.java 2008-09-09 01:06:15 UTC (rev 51) +++ csidex/trunk/src/main/java/edu/asu/commons/experiment/SavedRoundData.java 2008-09-12 20:46:29 UTC (rev 52) @@ -7,6 +7,8 @@ import java.util.SortedSet; import java.util.logging.Logger; +import com.thoughtworks.xstream.XStream; + import edu.asu.commons.conf.ExperimentRoundParameters; import edu.asu.commons.event.PersistableEvent; @@ -50,6 +52,48 @@ setActions(actions); } + public static SavedRoundData createFromXml(String roundSaveFilePath) { + ObjectInputStream stream = null; + XStream xstream = new XStream(); + SavedRoundData savedRoundData = new SavedRoundData(roundSaveFilePath); + try { + // FIXME: duplication across BinarySavedRoundData, refactor + stream = xstream.createObjectInputStream(new FileInputStream(roundSaveFilePath)); + + ExperimentRoundParameters roundParameters = (ExperimentRoundParameters) stream.readObject(); + logger.info("round parameters: " + roundParameters); + savedRoundData.setRoundParameters(roundParameters); + + DataModel dataModel = (DataModel) stream.readObject(); + logger.info("dataModel: " + dataModel); + savedRoundData.setDataModel(dataModel); + SortedSet<PersistableEvent> actions = (SortedSet<PersistableEvent>) stream.readObject(); + logger.info("actions: " + actions); + savedRoundData.setActions(actions); + return savedRoundData; + } + catch (IOException e) { + e.printStackTrace(); + logger.severe("Unable to load savefile from path: " + roundSaveFilePath + " exception: " + e); + throw new RuntimeException(e); + } + catch (ClassNotFoundException e) { + e.printStackTrace(); + logger.severe(e.getMessage()); + throw new RuntimeException(e); + } + finally { + if (stream != null) { + try { + stream.close(); + } + catch (IOException e) { + e.printStackTrace(); + } + } + } + } + public static SavedRoundData create(String roundSaveFilePath) { ObjectInputStream stream = null; SavedRoundData savedRoundData = new SavedRoundData(roundSaveFilePath); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <al...@us...> - 2008-09-09 01:06:05
|
Revision: 51 http://virtualcommons.svn.sourceforge.net/virtualcommons/?rev=51&view=rev Author: alllee Date: 2008-09-09 01:06:15 +0000 (Tue, 09 Sep 2008) Log Message: ----------- changing pom to refer to tdar archiva instance instead of csid archiva (better bandwidth, resources, etc.). TODO: get ivy dependency mechanism to automatically pull xstream and xpp3 transitive dependencies from maven repository Modified Paths: -------------- foraging/trunk/ivy.xml foraging/trunk/ivysettings.xml foraging/trunk/pom.xml foraging/trunk/src/main/java/edu/asu/commons/foraging/model/Resource.java foraging/trunk/src/main/java/edu/asu/commons/foraging/server/ForagingPersister.java foraging/trunk/src/main/java/edu/asu/commons/foraging/server/ForagingServer.java Modified: foraging/trunk/ivy.xml =================================================================== --- foraging/trunk/ivy.xml 2008-09-09 01:03:57 UTC (rev 50) +++ foraging/trunk/ivy.xml 2008-09-09 01:06:15 UTC (rev 51) @@ -6,9 +6,7 @@ <info organisation="edu.asu.commons" module="foraging"/> <dependencies> <dependency org='junit' name='junit' rev='4.4'/> - <dependency org='com.thoughtworks.xstream' name='xstream' rev='1.3' transitive='false'/> - <dependency org='xpp3' name='xpp3' rev='1.1.4c' transitive='false' /> - <dependency org="edu.asu.commons" name="csidex" rev="0.1.1"/> + <dependency org="edu.asu.commons" name="csidex" rev="latest.integration"/> <dependency org='net.java.dev.jogl' name='jogl' rev='1.1.1'/> <dependency org='net.java.dev.jogl' name='gluegen-rt' rev='1.1.1'/> </dependencies> Modified: foraging/trunk/ivysettings.xml =================================================================== --- foraging/trunk/ivysettings.xml 2008-09-09 01:03:57 UTC (rev 50) +++ foraging/trunk/ivysettings.xml 2008-09-09 01:06:15 UTC (rev 51) @@ -3,12 +3,15 @@ vim:sts=2:sw=2: --> <ivysettings> - <settings defaultResolver="csid-archiva" checkUpToDate="false"/> + <settings defaultResolver="tdar-archiva" checkUpToDate="false"/> <resolvers> - <ibiblio name='csid-archiva' m2compatible='true' root='http://csid.asu.edu/archiva/repository/internal'/> + <ibiblio name='tdar-archiva' m2compatible='true' root='http://dev.tdar.org/archiva/repository/internal'/> <filesystem name="internal"> <ivy pattern="${repository.dir}/[module]/ivy-[revision].xml"/> <artifact pattern="${repository.dir}/[module]/[artifact]-[revision].[ext]"/> </filesystem> </resolvers> + <modules> + <module organisation='edu.asu.commons' name='csidex' resolver='internal'/> + </modules> </ivysettings> Modified: foraging/trunk/pom.xml =================================================================== --- foraging/trunk/pom.xml 2008-09-09 01:03:57 UTC (rev 50) +++ foraging/trunk/pom.xml 2008-09-09 01:06:15 UTC (rev 51) @@ -13,9 +13,9 @@ <url>http://commons.asu.edu/foraging</url> <repositories> <repository> - <id>csid.asu.edu</id> - <name>CSID Maven2 repository</name> - <url>http://csid.asu.edu/archiva/repository/internal</url> + <id>dev.tdar.org</id> + <name>tDAR Maven2 repository</name> + <url>http://dev.tdar.org/archiva/repository/internal</url> </repository> <repository> <id>java.net</id> Modified: foraging/trunk/src/main/java/edu/asu/commons/foraging/model/Resource.java =================================================================== --- foraging/trunk/src/main/java/edu/asu/commons/foraging/model/Resource.java 2008-09-09 01:03:57 UTC (rev 50) +++ foraging/trunk/src/main/java/edu/asu/commons/foraging/model/Resource.java 2008-09-09 01:06:15 UTC (rev 51) @@ -2,7 +2,6 @@ import java.awt.Point; import java.io.Serializable; -import java.util.Random; import edu.asu.commons.foraging.conf.RoundConfiguration; import edu.asu.commons.util.Duration; @@ -10,7 +9,7 @@ /** * $Id$ * - * A simple resource struct encapsulating an age and a Point where the resource exists. + * A simple resource struct encapsulating an age and a 2D Point where the resource resides. * * @author <a href='All...@as...'>Allen Lee</a>, Deepali Bhagvat * @version $Revision$ @@ -102,8 +101,6 @@ return String.format("[%d, %d] - %d", position.x, position.y, age); } - boolean shouldCheck = false; - public void harvestFruits() { decreaseAge(); if (fruitHarvestDelay == null) { Modified: foraging/trunk/src/main/java/edu/asu/commons/foraging/server/ForagingPersister.java =================================================================== --- foraging/trunk/src/main/java/edu/asu/commons/foraging/server/ForagingPersister.java 2008-09-09 01:03:57 UTC (rev 50) +++ foraging/trunk/src/main/java/edu/asu/commons/foraging/server/ForagingPersister.java 2008-09-09 01:06:15 UTC (rev 51) @@ -18,6 +18,6 @@ // FIXME: path only works for unix. Should detect OS instead and have a Windows-safe fail safe directory. @Override protected String getFailSafeSaveDirectory() { - return "/tmp/csan-failsafe"; + return "/tmp/foraging-failsafe"; } } Modified: foraging/trunk/src/main/java/edu/asu/commons/foraging/server/ForagingServer.java =================================================================== --- foraging/trunk/src/main/java/edu/asu/commons/foraging/server/ForagingServer.java 2008-09-09 01:03:57 UTC (rev 50) +++ foraging/trunk/src/main/java/edu/asu/commons/foraging/server/ForagingServer.java 2008-09-09 01:06:15 UTC (rev 51) @@ -713,7 +713,10 @@ } /** - * Main entry point. + * Main entry point. Configuration options: + * + * conf.dir, e.g -Dconf.dir=path/to/configuration + * */ public static void main(String[] args) { ForagingServer server = new ForagingServer(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <al...@us...> - 2008-09-09 01:03:48
|
Revision: 50 http://virtualcommons.svn.sourceforge.net/virtualcommons/?rev=50&view=rev Author: alllee Date: 2008-09-09 01:03:57 +0000 (Tue, 09 Sep 2008) Log Message: ----------- starting to add ivy support to csidex and minor hygiene for persistence scheme. Default persistence scheme is now both XML and binary. Still need to test XML save file restoration. Modified Paths: -------------- csidex/trunk/pom.xml csidex/trunk/src/main/java/edu/asu/commons/conf/ExperimentConfiguration.java csidex/trunk/src/main/java/edu/asu/commons/conf/ExperimentRoundParameters.java csidex/trunk/src/main/java/edu/asu/commons/experiment/Persister.java Added Paths: ----------- csidex/trunk/ivy.xml csidex/trunk/ivysettings.xml Added: csidex/trunk/ivy.xml =================================================================== --- csidex/trunk/ivy.xml (rev 0) +++ csidex/trunk/ivy.xml 2008-09-09 01:03:57 UTC (rev 50) @@ -0,0 +1,15 @@ +<?xml version="1.0"?> +<!-- +vim:sts=2:sw=2: +--> +<ivy-module version="2.0"> + <info organisation="edu.asu.commons" module="csidex"/> + <dependencies> + <dependency org='junit' name='junit' rev='4.4'/> + <dependency org='xpp3' name='xpp3' rev='1.1.4c'/> + <dependency org='com.thoughtworks.xstream' name='xstream' rev='1.3'/> + </dependencies> +</ivy-module> + + + Added: csidex/trunk/ivysettings.xml =================================================================== --- csidex/trunk/ivysettings.xml (rev 0) +++ csidex/trunk/ivysettings.xml 2008-09-09 01:03:57 UTC (rev 50) @@ -0,0 +1,14 @@ +<?xml version="1.0"?> +<!-- +vim:sts=2:sw=2: +--> +<ivysettings> + <settings defaultResolver="tdar-archiva" checkUpToDate="false"/> + <resolvers> + <ibiblio name='tdar-archiva' m2compatible='true' root='http://dev.tdar.org/archiva/repository/internal'/> + <filesystem name="internal"> + <ivy pattern="${repository.dir}/[module]/ivy-[revision].xml"/> + <artifact pattern="${repository.dir}/[module]/[artifact]-[revision].[ext]"/> + </filesystem> + </resolvers> +</ivysettings> Modified: csidex/trunk/pom.xml =================================================================== --- csidex/trunk/pom.xml 2008-09-04 16:57:40 UTC (rev 49) +++ csidex/trunk/pom.xml 2008-09-09 01:03:57 UTC (rev 50) @@ -25,9 +25,9 @@ </repository> </repositories> <packaging>jar</packaging> - <version>0.1</version> + <version>0.1-SNAPSHOT</version> <name>csidex</name> - <url>http://commons.asu.edu/csidex</url> + <url>http://commons.asu.edu/software/csidex</url> <dependencies> <dependency> <groupId>junit</groupId> Modified: csidex/trunk/src/main/java/edu/asu/commons/conf/ExperimentConfiguration.java =================================================================== --- csidex/trunk/src/main/java/edu/asu/commons/conf/ExperimentConfiguration.java 2008-09-04 16:57:40 UTC (rev 49) +++ csidex/trunk/src/main/java/edu/asu/commons/conf/ExperimentConfiguration.java 2008-09-09 01:03:57 UTC (rev 50) @@ -187,7 +187,7 @@ } public PersistenceType getPersistenceType() { - String persistenceType = assistant.getStringProperty("persistence-type", "BINARY"); + String persistenceType = assistant.getStringProperty("persistence-type", "ALL"); return PersistenceType.valueOf(persistenceType); } Modified: csidex/trunk/src/main/java/edu/asu/commons/conf/ExperimentRoundParameters.java =================================================================== --- csidex/trunk/src/main/java/edu/asu/commons/conf/ExperimentRoundParameters.java 2008-09-04 16:57:40 UTC (rev 49) +++ csidex/trunk/src/main/java/edu/asu/commons/conf/ExperimentRoundParameters.java 2008-09-09 01:03:57 UTC (rev 50) @@ -11,7 +11,6 @@ * * Per-round experimental parameters for a given Experiment server instance. * - * FIXME: add Base class. * * @author <a href='al...@cs...'>Allen Lee</a> * @version $Revision$ @@ -134,8 +133,5 @@ public boolean isLastRound() { return parentConfiguration.isLastRound(); } - - } - } Modified: csidex/trunk/src/main/java/edu/asu/commons/experiment/Persister.java =================================================================== --- csidex/trunk/src/main/java/edu/asu/commons/experiment/Persister.java 2008-09-04 16:57:40 UTC (rev 49) +++ csidex/trunk/src/main/java/edu/asu/commons/experiment/Persister.java 2008-09-09 01:03:57 UTC (rev 50) @@ -73,17 +73,8 @@ xmlEnabled = roundConfiguration.getParentConfiguration().getPersistenceType().isXmlEnabled(); if ( xmlEnabled ) { String xmlSaveFilePath = getXmlSaveFilePath(); - System.err.println("saving xml files to: " + xmlSaveFilePath); + logger.info("saving xml files to: " + xmlSaveFilePath); createDirectoryIfNeeded(xmlSaveFilePath); - /* - try { - xmlPrintWriter = new PrintWriter(getRoundSaveFilePath(persistenceDirectory + File.separator + "xml", roundConfiguration.getRoundNumber())); - } - catch (IOException e) { - e.printStackTrace(); - logger.severe("Could not initialize xml print writer."); - } - */ } } @@ -335,7 +326,7 @@ objectOutputStream = new ObjectOutputStream(new FileOutputStream(configurationSavePath)); objectOutputStream.writeObject(experimentConfiguration); objectOutputStream.flush(); - + // save a copy as XML as well objectOutputStream = xstream.createObjectOutputStream(new FileOutputStream(configurationSavePath + ".xml")); objectOutputStream.writeObject(experimentConfiguration); objectOutputStream.flush(); @@ -350,6 +341,7 @@ private <E extends DataModel<R>> void saveRound(E serverDataModel, String persistenceDirectory) throws IOException { String saveDestination = getSavePath(persistenceDirectory); + logger.info("saving to " + saveDestination); ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream(getRoundSaveFilePath(saveDestination, roundConfiguration.getRoundNumber()))); try { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <al...@us...> - 2008-09-04 16:57:32
|
Revision: 49 http://virtualcommons.svn.sourceforge.net/virtualcommons/?rev=49&view=rev Author: alllee Date: 2008-09-04 16:57:40 +0000 (Thu, 04 Sep 2008) Log Message: ----------- reworking XML persistence, still needs testing. Modified Paths: -------------- csidex/trunk/pom.xml csidex/trunk/src/main/java/edu/asu/commons/event/ChatEvent.java csidex/trunk/src/main/java/edu/asu/commons/experiment/Persister.java Modified: csidex/trunk/pom.xml =================================================================== --- csidex/trunk/pom.xml 2008-08-27 05:14:19 UTC (rev 48) +++ csidex/trunk/pom.xml 2008-09-04 16:57:40 UTC (rev 49) @@ -8,6 +8,11 @@ <artifactId>csidex</artifactId> <repositories> <repository> + <id>dev.tdar.org</id> + <name>tDAR Maven2 repository</name> + <url>http://dev.tdar.org/archiva/repository/internal</url> + </repository> + <repository> <id>csid.asu.edu</id> <name>CSID Maven2 repository</name> <url>http://csid.asu.edu/archiva/repository/internal</url> Modified: csidex/trunk/src/main/java/edu/asu/commons/event/ChatEvent.java =================================================================== --- csidex/trunk/src/main/java/edu/asu/commons/event/ChatEvent.java 2008-08-27 05:14:19 UTC (rev 48) +++ csidex/trunk/src/main/java/edu/asu/commons/event/ChatEvent.java 2008-09-04 16:57:40 UTC (rev 49) @@ -8,7 +8,7 @@ * $Id$ * * Sent from the server to a client target (with Identifier getId()) from the client identified by getSource(). - * Essentially the same as a ChatRequest, but with permuted instance fields. + * Essentially the same as a ChatRequest, but with permuted Identifier parameters. * * @author <a href='All...@as...'>Allen Lee</a> * @version $Revision$ @@ -24,14 +24,14 @@ private boolean addressedToAll; - public ChatEvent(Identifier id, String message, Identifier source) { - super(id); + public ChatEvent(Identifier target, String message, Identifier source) { + super(target); this.message = message; this.source = source; } - public ChatEvent(Identifier id, String message, Identifier source, boolean addressedToAll) { - super(id); + public ChatEvent(Identifier target, String message, Identifier source, boolean addressedToAll) { + super(target); this.message = message; this.source = source; this.addressedToAll = addressedToAll; @@ -42,7 +42,7 @@ } public Identifier getTarget() { - return isAddressedToAll() ? Identifier.ALL : id; + return isAddressedToAll() ? Identifier.ALL : super.id; } public String toString() { Modified: csidex/trunk/src/main/java/edu/asu/commons/experiment/Persister.java =================================================================== --- csidex/trunk/src/main/java/edu/asu/commons/experiment/Persister.java 2008-08-27 05:14:19 UTC (rev 48) +++ csidex/trunk/src/main/java/edu/asu/commons/experiment/Persister.java 2008-09-04 16:57:40 UTC (rev 49) @@ -18,8 +18,7 @@ import java.util.logging.Level; import java.util.logging.Logger; -import com.thoughtworks.xstream.persistence.FileStreamStrategy; -import com.thoughtworks.xstream.persistence.XmlSet; +import com.thoughtworks.xstream.XStream; import edu.asu.commons.conf.ExperimentConfiguration; import edu.asu.commons.conf.ExperimentRoundParameters; @@ -50,11 +49,11 @@ private String persistenceDirectory; private EventChannel channel; -// private final XStream xstream = new XStream(); -// private PrintWriter xmlPrintWriter; + private final XStream xstream = new XStream(); private boolean xmlEnabled; - private XmlSet xmlSet; + + // private boolean usingEventChannel; @@ -76,7 +75,6 @@ String xmlSaveFilePath = getXmlSaveFilePath(); System.err.println("saving xml files to: " + xmlSaveFilePath); createDirectoryIfNeeded(xmlSaveFilePath); - xmlSet = new XmlSet(new FileStreamStrategy(new File(xmlSaveFilePath))); /* try { xmlPrintWriter = new PrintWriter(getRoundSaveFilePath(persistenceDirectory + File.separator + "xml", roundConfiguration.getRoundNumber())); @@ -90,7 +88,7 @@ } private String getXmlSaveFilePath() { - return getDefaultSavePath() + File.separator + roundConfiguration.getRoundNumber() + ".round.xml"; + return getDefaultSavePath() + File.separator + roundConfiguration.getRoundNumber() + ".save.xml"; } public Persister(EventChannel channel, T experimentConfiguration) { @@ -148,17 +146,8 @@ synchronized (actions) { actions.add(event); } - if (isXmlEnabled()) { - synchronized (xmlSet) { - xmlSet.add(event); - } - } } - private boolean isXmlEnabled() { - return xmlEnabled; - } - public void store(ChatRequest request) { request.timestamp(); // FIXME: this is inefficient, but chat data shouldn't be too huge.. should it? @@ -176,7 +165,7 @@ public final void initialize(R roundConfiguration) { clear(); this.roundConfiguration = roundConfiguration; - initializeXmlSave(); + xmlEnabled = roundConfiguration.getParentConfiguration().getPersistenceType().isXmlEnabled(); } /** @@ -346,22 +335,21 @@ objectOutputStream = new ObjectOutputStream(new FileOutputStream(configurationSavePath)); objectOutputStream.writeObject(experimentConfiguration); objectOutputStream.flush(); + + objectOutputStream = xstream.createObjectOutputStream(new FileOutputStream(configurationSavePath + ".xml")); + objectOutputStream.writeObject(experimentConfiguration); + objectOutputStream.flush(); } finally { - try { - if (objectOutputStream != null) { - objectOutputStream.close(); - } - } - catch (IOException e) { - e.printStackTrace(); + if (objectOutputStream != null) { + objectOutputStream.close(); } } } private <E extends DataModel<R>> void saveRound(E serverDataModel, String persistenceDirectory) throws IOException { String saveDestination = getSavePath(persistenceDirectory); - int roundNumber = roundConfiguration.getRoundNumber(); + ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream(getRoundSaveFilePath(saveDestination, roundConfiguration.getRoundNumber()))); try { @@ -376,8 +364,22 @@ oos.flush(); } finally { - oos.close(); + if (oos != null) oos.close(); } + try { + if (xmlEnabled) { + oos = xstream.createObjectOutputStream(new FileOutputStream(getXmlSaveFilePath())); + oos.writeObject(roundConfiguration); + oos.writeObject(serverDataModel); + synchronized (actions) { + oos.writeObject(actions); + } + oos.flush(); + } + } + finally { + if (oos != null) oos.close(); + } } private void createDirectoryIfNeeded(String directoryName) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: Allen L. (V. Commons-JIRA) <all...@as...> - 2008-09-03 19:13:27
|
graphical installer ------------------- Key: CSAN-10 URL: https://csid.asu.edu/jira/browse/CSAN-10 Project: Foraging Experiment Issue Type: Improvement Reporter: Allen Lee Assignee: Allen Lee Create a graphical install that allows the user to configure and deploy the foraging experiment. -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: https://csid.asu.edu/jira/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira |
From: <al...@us...> - 2008-08-27 05:14:10
|
Revision: 48 http://virtualcommons.svn.sourceforge.net/virtualcommons/?rev=48&view=rev Author: alllee Date: 2008-08-27 05:14:19 +0000 (Wed, 27 Aug 2008) Log Message: ----------- minor improvements for repl(), removing generic datatype from Util.join Modified Paths: -------------- csidex/trunk/src/main/java/edu/asu/commons/conf/ExperimentConfiguration.java csidex/trunk/src/main/java/edu/asu/commons/experiment/AbstractExperiment.java csidex/trunk/src/main/java/edu/asu/commons/util/Utils.java Modified: csidex/trunk/src/main/java/edu/asu/commons/conf/ExperimentConfiguration.java =================================================================== --- csidex/trunk/src/main/java/edu/asu/commons/conf/ExperimentConfiguration.java 2008-08-22 22:22:55 UTC (rev 47) +++ csidex/trunk/src/main/java/edu/asu/commons/conf/ExperimentConfiguration.java 2008-08-27 05:14:19 UTC (rev 48) @@ -41,7 +41,7 @@ public static abstract class Base<E extends ExperimentRoundParameters> implements ExperimentConfiguration<E> { - private final static long serialVersionUID = 1679614060238100147L; + private final static long serialVersionUID = 8936075404166796486L; public static String defaultConfigurationDirectory; private final static String DEFAULT_CONF_DIR = "conf/"; Modified: csidex/trunk/src/main/java/edu/asu/commons/experiment/AbstractExperiment.java =================================================================== --- csidex/trunk/src/main/java/edu/asu/commons/experiment/AbstractExperiment.java 2008-08-22 22:22:55 UTC (rev 47) +++ csidex/trunk/src/main/java/edu/asu/commons/experiment/AbstractExperiment.java 2008-08-27 05:14:19 UTC (rev 48) @@ -193,12 +193,12 @@ } public void repl() { - BufferedReader input = new BufferedReader(new InputStreamReader(System.in)); + BufferedReader reader = new BufferedReader(new InputStreamReader(System.in)); String line = ""; while (true) { System.out.print("> "); try { - line = input.readLine(); + line = reader.readLine().trim(); } catch (IOException e) { e.printStackTrace(); @@ -206,7 +206,7 @@ } // EOF gives null (Ctrl-D) if (line == null || "exit".equals(line)) { - System.out.println("Exiting..."); + System.out.println("VC Server Console exiting."); System.exit(0); } else if ("help".equals(line)) { @@ -214,6 +214,9 @@ System.out.println("\tstart - start an experiment"); System.out.println("\tstop - stop an experiment"); System.out.println("\tclients - show connected clients"); + System.out.println("\tdump - dump current thread's stack"); + System.out.println("\tshow-threads - display all threads"); + System.out.println("\thelp - display this help"); displayCustomHelp(); } else if ("dump".equals(line)) { @@ -222,8 +225,12 @@ else if ("show-threads".equals(line)) { showThreads(); } + else if ("".equals(line)) { + // ignore empty input + continue; + } else { - processReplInput(line); + processReplInput(line, reader); } } } @@ -267,8 +274,8 @@ System.out.println("No more options available."); } - public void processReplInput(String line) { - System.out.println("Unhandled input: " + line + " - overload processReplInput to handle these cases properly."); + public void processReplInput(String line, BufferedReader reader) { + System.out.println("Unhandled input: [" + line + "] - overload processReplInput to handle these cases properly."); } public static void waitOn(final Object lock) { Modified: csidex/trunk/src/main/java/edu/asu/commons/util/Utils.java =================================================================== --- csidex/trunk/src/main/java/edu/asu/commons/util/Utils.java 2008-08-22 22:22:55 UTC (rev 47) +++ csidex/trunk/src/main/java/edu/asu/commons/util/Utils.java 2008-08-27 05:14:19 UTC (rev 48) @@ -98,7 +98,7 @@ * If the delimiter also occurs in the list of objects waiting to be * toString()-ed, this method does not make sure it escapes them. */ - public static <T> String join(char delimiter, T ... objects) { + public static String join(char delimiter, Object ... objects) { return join(false, delimiter, objects); } /* @@ -108,7 +108,7 @@ * If the delimiter also occurs in the list of objects waiting to be * toString()-ed, this method does not make sure it escapes them. */ - public static <T> String join(boolean shouldQuote, char delimiter, T ... objects) { + public static String join(boolean shouldQuote, char delimiter, Object ... objects) { StringBuilder builder = new StringBuilder(); for (int i = 0; i < objects.length; i++) { addString(builder, objects[i].toString().trim(), shouldQuote); @@ -149,7 +149,7 @@ return builder.toString(); } - public static <T, R> List<R> map(List<T> in, MapOp<T, R> op) { + public static <T, R> List<R> map(Collection<T> in, MapOp<T, R> op) { List<R> out = new ArrayList<R>(in.size()); for (T t: in) { out.add(op.apply(t)); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <al...@us...> - 2008-08-22 22:22:45
|
Revision: 47 http://virtualcommons.svn.sourceforge.net/virtualcommons/?rev=47&view=rev Author: alllee Date: 2008-08-22 22:22:55 +0000 (Fri, 22 Aug 2008) Log Message: ----------- updated save file converter Modified Paths: -------------- foraging/trunk/src/main/java/edu/asu/commons/foraging/util/ForagingSaveFileConverter.java Modified: foraging/trunk/src/main/java/edu/asu/commons/foraging/util/ForagingSaveFileConverter.java =================================================================== --- foraging/trunk/src/main/java/edu/asu/commons/foraging/util/ForagingSaveFileConverter.java 2008-08-21 16:56:18 UTC (rev 46) +++ foraging/trunk/src/main/java/edu/asu/commons/foraging/util/ForagingSaveFileConverter.java 2008-08-22 22:22:55 UTC (rev 47) @@ -43,9 +43,9 @@ if (allSaveFilesDirectory.exists() && allSaveFilesDirectory.isDirectory()) { List<SaveFileProcessor> processors = new ArrayList<SaveFileProcessor>(); processors.addAll(Arrays.asList( - new ForagingSaveFileProcessor(), - new SummaryStatisticsProcessor(), - new ForagingSummarySaveFileProcessor())); + new AllDataProcessor(), + new AggregateTimeIntervalProcessor(), + new SummaryProcessor())); Persister.processSaveFiles(allSaveFilesDirectory, processors); return true; } @@ -60,7 +60,7 @@ convert(args[0]); } - private static class ForagingSummarySaveFileProcessor extends SaveFileProcessor.Base { + private static class SummaryProcessor extends SaveFileProcessor.Base { @Override public void process(SavedRoundData savedRoundData, PrintWriter writer) { ServerDataModel serverDataModel = (ServerDataModel) savedRoundData.getDataModel(); @@ -76,13 +76,19 @@ } */ List<GroupDataModel> groups = new ArrayList<GroupDataModel>(serverDataModel.getGroups()); - writer.println("Group #, Members, ..., Resources Left, Final Resource Positions"); for (GroupDataModel group: groups) { + int totalConsumedGroupTokens = 0; + ArrayList<String> clientTokens = new ArrayList<String>(); + for (ClientData data : group.getClientDataMap().values()) { + clientTokens.add(String.format("%s, %s", data.getId(), data.getTotalTokens())); + totalConsumedGroupTokens += data.getTotalTokens(); + } writer.println( String.format("%s, %s, %s, %s", "Group #" + groups.indexOf(group), - Utils.join(',', new TreeSet<Identifier>(group.getClientIdentifiers())), + Utils.join(',', clientTokens), group.getResourceDistributionSize(), + totalConsumedGroupTokens, Utils.join(',', group.getResourceDistribution().keySet()) )); } @@ -94,11 +100,11 @@ } } - private static class ForagingSaveFileProcessor extends SaveFileProcessor.Base { + private static class AllDataProcessor extends SaveFileProcessor.Base { @Override public String getOutputFileExtension() { - return "-foraging_all-data.txt"; + return "-all-data.txt"; } @Override @@ -113,8 +119,7 @@ } private void processData2d(SavedRoundData savedRoundData, PrintWriter writer) { - RoundConfiguration roundConfiguration = (RoundConfiguration) savedRoundData.getRoundParameters(); - System.err.println("is chat enabled? " + roundConfiguration.isChatEnabled() + roundConfiguration.getRoundNumber()); +// RoundConfiguration roundConfiguration = (RoundConfiguration) savedRoundData.getRoundParameters(); SortedSet<PersistableEvent> actions = savedRoundData.getActions(); ServerDataModel model = (ServerDataModel) savedRoundData.getDataModel(); Map<Identifier, ClientStats> clientStats = createClientStats(model); @@ -238,7 +243,7 @@ } - public static class SummaryStatisticsProcessor extends SaveFileProcessor.Base { + public static class AggregateTimeIntervalProcessor extends SaveFileProcessor.Base { private static int secondsPerInterval = 5; public void process(SavedRoundData savedRoundData, PrintWriter writer) { // populate the ordered identifiers, try directly from the participant tokens map that @@ -251,7 +256,22 @@ RoundConfiguration roundConfiguration = (RoundConfiguration) savedRoundData.getRoundParameters(); TreeSet<Identifier> orderedIdentifiers = new TreeSet<Identifier>(serverDataModel.getClientDataMap().keySet()); List<GroupDataModel> groups = new ArrayList<GroupDataModel>(serverDataModel.getGroups()); + +// XXX: not really any better than the below, and actually more inefficient to boot. Damn. +// List<String> foo = Utils.map(orderedIdentifiers, new Utils.MapOp<Identifier, String>() { +// public String apply(Identifier id) { +// return id + " movement"; +// } +// }); + + List<String> movementHeader = new ArrayList<String>(); + List<String> collectedTokensHeader = new ArrayList<String>(); + for (Identifier id: orderedIdentifiers) { + movementHeader.add(id + " moves"); + collectedTokensHeader.add(id + " tokens collected"); + } + // headers for average probability of a token for each group // List<String> tokenProbabilityGroupNumberHeader = new ArrayList<String>(); // headers for tokens left in each group @@ -275,9 +295,9 @@ // write out the header String header = Utils.join(',', "Period", // moves taken - Utils.join(',', orderedIdentifiers), + Utils.join(',', movementHeader), // tokens - Utils.join(',', orderedIdentifiers), + Utils.join(',', collectedTokensHeader), // group token probabilities // Utils.join(',', tokenProbabilityGroupNumberHeader), // group total tokens left @@ -430,5 +450,4 @@ return clientStats; } - -} +} \ 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: <see...@us...> - 2008-08-21 16:56:10
|
Revision: 46 http://virtualcommons.svn.sourceforge.net/virtualcommons/?rev=46&view=rev Author: seematalele Date: 2008-08-21 16:56:18 +0000 (Thu, 21 Aug 2008) Log Message: ----------- -tie is working properly -resource depletion : changed the experiment.inc, forestry_v2 module.tested for 8 students; it is working properly -put some instructions for perticipants in the forestry_v2 module -whole experiment is working properly Modified Paths: -------------- vcweb/trunk/virtualcommons/experiment/experiment.inc vcweb/trunk/virtualcommons/experiment/experiment.install vcweb/trunk/virtualcommons/experiment/experiment.module vcweb/trunk/virtualcommons/experiment/games/forestry_v2/forestry_v2.module vcweb/trunk/virtualcommons/experiment/rules/rules.install vcweb/trunk/virtualcommons/experiment/student_login/student_login.module vcweb/trunk/virtualcommons/experiment/survey/survey.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-21 00:47:39 UTC (rev 45) +++ vcweb/trunk/virtualcommons/experiment/experiment.inc 2008-08-21 16:56:18 UTC (rev 46) @@ -104,7 +104,7 @@ public function save() { //insert into game table - drupal_set_message(t('students:' . $this->no_of_students)); + //drupal_set_message(t('students:' . $this->no_of_students)); if ($this->game_id == -1) { $this->game_id = db_next_id('{vc_game}_id'); db_query("INSERT INTO {vc_game} (id, users_id, vc_experiment_id, no_of_students,vc_stage_id,current_round_no) VALUES (%d,%d,%d,%d,%d,%d)", @@ -141,7 +141,7 @@ { //$turn= (int) $turn[$i]; db_query("Insert into {vc_student} (id,vc_group_id,start_flag,turn_no) values('%s',${group_id},false,%d)",$student_id,$turn[$i]); - drupal_set_message(t('Student ID : %stud Turn is: %key<br>'. gettype($turn[$i]) ,array('%stud'=>$student_id,'%key'=>$turn[$i]))); + //drupal_set_message(t('Student ID : %stud Turn is: %key<br>'. gettype($turn[$i]) ,array('%stud'=>$student_id,'%key'=>$turn[$i]))); $i++; } @@ -171,10 +171,12 @@ $result_group_id=db_query("select id from vc_group where vc_game_id=%d",$this->game_id); while($data=db_fetch_object($result_group_id)) { - $stud_voting_cnt=db_result(db_query("select count(*) from vc_student_voting v where v.vc_student_id in (select id from vc_student where vc_group_id=%d)",$data->id)); + $stud_voting_cnt=db_result(db_query("select count(*) from vc_student_voting v + where v.vc_student_id in (select id from vc_student where vc_group_id=%d) + AND v.consider_flag=false ",$data->id)); $actual_student=db_result(db_query(" select count(*) from vc_student where vc_group_id=%d",$data->id)); // drupal_set_message(t('stud_voting_cnt: '. $stud_voting_cnt)); - //drupal_set_message(t('actual students are: '.$actual_student)); + //drupal_set_message(t('actual students are: '.$data->id)); if($stud_voting_cnt==$actual_student) { $flag=1; @@ -182,11 +184,11 @@ else { $flag=0; - drupal_set_message(t('else Flag is: '.$flag)); + //drupal_set_message(t('else Flag is: '.$flag)); } } - drupal_set_message(t('isvotingDone Flag is: '.$flag)); + //drupal_set_message(t('isvotingDone Flag is: '.$flag)); return $flag; } // FIXME: turn into $forestryGame->init() overloaded method @@ -260,8 +262,31 @@ FROM vc_stage s inner join vc_game g on s.vc_experiment_id=g.vc_experiment_id WHERE g.id=%d', $this->game_id)); return $this->isStageOver() && ($max_stage_number == $this->getCurrentStageNumber()); - } + + private function IsResourceOverForAllGroup() + { + $counter_to_check_group_resources=0; + $no_of_groups=db_result(db_query("select count(*) from vc_group where vc_game_id=%d",$this->game_id)); + + $result_group=db_query("select count(s.vc_group_id) as cnt, s.vc_group_id as group_id from vc_group g, vc_student s + where s.vc_group_id=g.id and g.vc_game_id=%d group by s.vc_group_id",$this->game_id); + + while($data=db_fetch_object($result_group)) + { + $no_of_students=$data->cnt; + $group_id=$data->group_id; + $min_resource=db_result(db_query('select min(max_resource_level) as min_resource from vc_forestry_3player_harvest_table')); + $current_resource=db_result(db_query('select common_resource_pool from vc_forestry_common_resource_pool + where vc_group_id=%d and vc_game_id=%d',$group_id,$this->game_id)); + + if($current_resource <= $min_resource) + $counter_to_check_group_resources++; + + } + return ($counter_to_check_group_resources==$no_of_groups); + + } public function isLastRound() { @@ -270,7 +295,7 @@ public function isStageOver() { - return ($this->getCurrentRoundNo() > $this->getNumberOfRounds()); + return (($this->getCurrentRoundNo() > $this->getNumberOfRounds()) || ($this->IsResourceOverForAllGroup())); } public function getTurnSequence($group_id) { @@ -287,7 +312,7 @@ $valid_ids = array(); while ($data = db_fetch_object($result)) { $valid_ids[] = $data->id; - drupal_set_message(t($data->id. ' , ')); + //drupal_set_message(t($data->id. ' , ')); } return $valid_ids; @@ -345,7 +370,7 @@ private function generate_default_decisions($group_id, $round_no, $stage_id) { $result = db_query('SELECT id FROM vc_student WHERE vc_group_id=%d', $group_id); - drupal_get_messages(); + //drupal_get_messages(); while ($fetch_object = db_fetch_object($result)) { $student_id = $fetch_object->id; $harvest_decision = db_result(db_query("SELECT harvest_decision @@ -353,10 +378,10 @@ WHERE vc_student_id='%s' AND round_no=%d AND vc_stage_id=%d", $student_id, $round_no, $stage_id)); - drupal_set_message("harvest decision is submitted is student :" . $harvest_decision); + // drupal_set_message("harvest decision is submitted is student :" . $harvest_decision); if ($harvest_decision == '') { - drupal_set_message("if harvest decision is submitted is empty :" . $harvest_decision); + //drupal_set_message("if harvest decision is submitted is empty :" . $harvest_decision); $this->insert_default_decision($student_id, $round_no,$stage_id); } } @@ -404,7 +429,7 @@ { // roll the dice $dice = rand(1, 6); - $dice = 6; + // $dice = 6; if ($dice == 6) { // check to see if we need to assess fines @@ -431,8 +456,8 @@ //update start flag if ($this->isLastRound()) { - drupal_get_messages(); - drupal_set_message('Student flag is updated to TRUE'); + //drupal_get_messages(); + //drupal_set_message('Student flag is updated to TRUE'); $this->updateStartFlag(false); } @@ -454,11 +479,11 @@ } - public function setRoundNo($round_no) + public function setRoundNo() { //drupal_set_mesage(t('Round is : ' . $round_no)); - if ($round_no > ($this->getNumberOfRounds())) { + // if ($round_no > ($this->getNumberOfRounds())) { // reset round number to 1 $this->current_round_no = 1; @@ -473,10 +498,10 @@ // 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); @@ -492,17 +517,17 @@ $result_resource=db_query("select max_resources,vc_group_id from vc_forestry_common_resource_pool where vc_game_id=%d",$this->game_id); - if($data=db_fetch_object($result_resource)) + while($data=db_fetch_object($result_resource)) { //$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 ); + //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()); + $this->setRoundNo(); } - public function assign_Rules_To_Groups() + /* public function assign_Rules_To_Groups() { //determine the rule for a group $result_group=db_query("select id from vc_group where vc_game_id=%d",$this->game_id); @@ -576,7 +601,12 @@ $tie=implode(',',$tie_rules); drupal_get_messages(); drupal_set_message(t( 'Tie happened in Group no: ' . $group_id .'.<br> Rules are :' . $tie),'warning'); - db_query("Insert into {vc_tie} (vc_group_id,tie_rules_id) values (%d,'%s')",$group_id,$tie); + + if() + { + saveTie($group_id,$tie); + } + return TRUE; } @@ -592,21 +622,151 @@ }//end of while - }//end of init function + }//end of function*/ + public function assign_Rules_To_Groups() + { + $max_rule_cnt=0;$rule_id=array();$rule_cnt=array();$tie_rules=array();$max_rule_id=0; + //determine the rule for a group + $result_group=db_query("select id from vc_group where vc_game_id=%d",$this->game_id); + while($data=db_fetch_object($result_group)) + { + $group_id=$data->id; + //$result_voting=db_query("select vc_rules_id,count(vc_rules_id) as rule_cnt from vc_student_voting where vc_student_id in (select id from vc_student where vc_group_id=%d) group by vc_rules_id",$group_id); + /*$result_voting=db_query(" select vc_rules_id, count(vc_rules_id) as rule_cnt from vc_student_voting v + where v.time_created >= (select max(time_created) from vc_student_voting vv where v.vc_student_id=vv.vc_student_id) and + v.vc_student_id in (select id from vc_student where vc_group_id=%d) group by vc_rules_id",$group_id);*/ + $result_voting =db_query("select vc_rules_id,count(vc_rules_id) as rule_cnt from vc_student_voting + where vc_student_id in (select id from vc_student where vc_group_id=%d) + and consider_flag=false group by vc_rules_id",$group_id); + //if(db_fetch_object($result_voting)=='') + // { + // drupal_get_messages(); + // drupal_set_message('result is: ' . $result_voting); + /* if(db_fetch_object($result_voting)<> '') + { + + array_push($rule_id,$data->vc_rules_id); + array_push($rule_cnt,$data->rule_cnt);*/ + + + while($data=db_fetch_object($result_voting)) + { + array_push($rule_id,$data->vc_rules_id); + array_push($rule_cnt,$data->rule_cnt); + //$voting[$data->vc_rules_id]=$data->rule_cnt; + + } + + //make consider flag=true for the next round. + db_query("update vc_student_voting set consider_flag=true + where vc_student_id in (select id from vc_student where vc_group_id=%d)",$group_id); + + // drupal_set_message(t('count of an array is :' . count($rule_cnt))); + if(count($rule_cnt)==1) + { + $max_rule_cnt=$rule_cnt[0]; + $max_rule_id=$rule_id[0]; + //drupal_set_message(t( 'NOT Tie' . '$max_rule_id: ' . $max_rule_id)); + db_query("update vc_group set vc_selected_rules_id =%d where id=%d",$max_rule_id,$group_id); + drupal_set_message(t('Group No : '. db_result(db_query("select group_no from vc_group where id=%d",$group_id))),'warning'); + drupal_set_message(t( 'is assigned Rule No: '.db_result(db_query("select rule_no from vc_rules where id=%d",$max_rule_id)) . '<br>'),'warning'); + } + else + { + for($i=0;$i<count($rule_cnt);$i++)//for1 + { + for($j=$i+1;$j<count($rule_cnt);$j++)//for2 + { + //drupal_set_message(t('rule cnt i: '. $rule_cnt[$i] . 'rule cnt j: '.$rule_cnt[$j])); + if($rule_cnt[$i]<$rule_cnt[$j]) + { + if($max_rule_cnt < $rule_cnt[$j]) + { + $max_rule_cnt=$rule_cnt[$j]; + $max_rule_id=$rule_id[$j]; + //drupal_set_message(t( '$max_rule_id is : ' . $rule_id[$j])); + } + } + else + { + + if($rule_cnt[$i]==$rule_cnt[$j]) + { + //echo '<br/>Equal $i ' . $i. ' $j ' .$j; + array_push($tie_rules,$rule_id[$i],$rule_id[$j]); + $tie_rule_cnt=$rule_cnt[$i]; + //drupal_set_message(t('rule cnt i: '. $tie_rules[$i] . 'rule cnt j: '.$tie_rules[$j])); + } + else if($max < $rule_cnt[$i]) + { + $max_rule_cnt=$rule_cnt[$i]; + $max_rule_id=$rule_id[$i]; + // drupal_set_message(t( '$max_rule_id is : ' . $rule_id[$i])); + } + } + + } + + }//end of for1 + + //echo '<br/> Max: '. $max ; + //drupal_set_message(t( '$max_rule_cnt is : ' . $max_rule_cnt)); + + if(($max_rule_cnt==$tie_rule_cnt) || ($max_rule_cnt==0)) + { + + $tie=implode(',',$tie_rules); + //drupal_get_messages(); + // drupal_set_message(t( 'Tie happened in Group no: ' . $group_id .'<br> Rules are :' . $tie),'warning'); + //check if the group id exists in vc_tie.If it exists it means that for $group_id, tie had alredy happened previously. + //So chosse one rule randomly from tie rules + $prev_tie_result=db_result(db_query("select tie_rules_id from vc_tie where vc_group_id=%d",$group_id)); + if($prev_tie_result == '') + $this->saveTie($group_id,$tie); + + else + { + $max_rule_id=array_rand($tie_rules,1); + db_query("update vc_group set vc_selected_rules_id =%d where id=%d",$tie_rules[$max_rule_id],$group_id); + drupal_set_message(t('Group No : '. db_result(db_query("select group_no from vc_group where id=%d",$group_id))),'warning'); + drupal_set_message(t( 'is assigned Rule No: '.db_result(db_query("select rule_no from vc_rules where id=%d",$max_rule_id)) . '<br>'),'warning'); + } + + + return TRUE; + + } + else + { + //drupal_set_message(t( 'NOT Tie' . '$max_rule_id: ' . $max_rule_id)); + db_query("update vc_group set vc_selected_rules_id =%d where id=%d",$max_rule_id,$group_id); + drupal_set_message(t('Group No : '. db_result(db_query("select group_no from vc_group where id=%d",$group_id))),'warning'); + drupal_set_message(t( 'is assigned Rule No: '.db_result(db_query("select rule_no from vc_rules where id=%d",$max_rule_id)) . '<br>'),'warning'); + return FALSE; + } + + // drupal_set_message(t('Rule id : ' . $final_rule_id.'Group id is: ' . $group_id)); + } + //} + }//end of while + + + }//end of init function*/ - public function saveTie() + + private function saveTie($group_id,$tie) { + db_query("Insert into {vc_tie} (vc_group_id,tie_rules_id) values (%d,'%s')",$group_id,$tie); } // several ways to implement this - // 1. use array_rand to get a set of random keys into the array // 2. use shuffle and then take an array_slice from 0 to $how_many - private function generateTurnSequence($how_many, $no_of_students,$rule_no) { - if($rule_no==1) - { + 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); + // 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(); @@ -620,15 +780,8 @@ // drupal_set_message($keys[$i]); $turn_sequence[] = $students[$keys[$i]]; } - } - else - { - - } - - - return $turn_sequence; - + return $turn_sequence; + } public function initRules() @@ -659,10 +812,10 @@ $how_many = 2; break; default: - drupal_set_message("For some reason there were $no_of_student students - should never happen!"); + drupal_set_message(t("For some reason there were $no_of_student students - should never happen!"),'warning'); break; } - $turn_sequence_array=$this->generateTurnSequence($how_many, $no_of_student,$rule_no); + $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) { @@ -725,7 +878,7 @@ break; default: - drupal_set_message("For some reason there were $no_of_student students - should never happen!"); + drupal_set_message(t("For some reason there were $no_of_student students - should never happen!"),'warning'); break; } @@ -779,7 +932,7 @@ return $this->game->getGameId(); } else { - drupal_set_message(t('the game is null..')); + //drupal_set_message(t('the game is null..')); return 5; } } @@ -903,14 +1056,17 @@ $rule_id=array(); $final_rule_no=array(); $rule_id=explode(',',$result_voting); - drupal_set_message(t('Tie Rules are : ' . $result_voting)); + //drupal_set_message(t('Tie Rules are : ' . $result_voting)); for($i=0;$i<count($rule_id);$i++) { - array_push($final_rule_no,db_result(db_query("select rule_no from vc_rules where id =%d",$rule_id[$i]))); - drupal_set_message(t('Tie Rules are : ' . $rule_id[$i] )); + $result=db_query("select rule_no,description from vc_rules where id =%d",$rule_id[$i]); + if($data=db_fetch_object($result)) + { + $final_rule_no[$data->rule_no]=$data->description; + } } - //drupal_set_message(t('Rule no : ' . $final_rule_no[0].' ' .$final_rule_no[1]. 'Group id is: ' . $this->group_id)); + return $final_rule_no; } @@ -941,6 +1097,28 @@ db_result(db_query("select description select vc_selected_rules_id from vc_group where id=%d",$this->group_id)); }*/ + public function isStageOver() + { + return (($this->getGame()->getCurrentRoundNo() > $this->getGame()->getNumberOfRounds()) || ($this->IsResourceOver())); + } + public function isResourceOver() + { + $flag=0; + $number_of_players=$this->no_of_students; + $min_resource=db_result(db_query("select min(max_resource_level) from {vc_forestry_${number_of_players}player_harvest_table")); + $current_resource=db_result(db_query('select common_resource_pool from vc_forestry_common_resource_pool + where vc_group_id=%d and vc_game_id=%d',$this->group_id,$this->game_id)); + drupal_set_message(t('min resource level is: '.$min_resource . 'and current resource level is: '.$current_resource)); + if($current_resource <= $min_resource) + $flag=1; + else + $flag=0; + + + drupal_set_message(t('in resource function returning flag is: ' .$flag)); + return $flag; + + } }//end of Group @@ -1083,7 +1261,7 @@ public function save($round_no, $harvest_decision,$stage_id=0) { - drupal_set_message($stage_id); + //drupal_set_message($stage_id); if($stage_id <> 0) { // $stage_id = $this->getGroup()->getGame()->getCurrentStageId(); @@ -1122,7 +1300,7 @@ if(!($this->getGroup()->isGameFinished())) { $valid_id=$this->getGroup()->getGame()->getValidStudentIds($this->getGroup()->getId()); - drupal_set_message(t('Group id is : '. $this->group_id. 'Student Id is : '. $this->stud_id . ' Valid student ids are: ' . $valid_id[0] . ',' . $valid_id[1])); + //drupal_set_message(t('Group id is : '. $this->group_id. 'Student Id is : '. $this->stud_id . ' Valid student ids are: ' . $valid_id[0] . ',' . $valid_id[1])); if(in_array($this->stud_id,$valid_id)) { $flag= TRUE; @@ -1130,7 +1308,7 @@ } else $flag= FALSE; - drupal_set_message(t('flag for student turn : '. $flag)); + // drupal_set_message(t('flag for student turn : '. $flag)); return $flag; } @@ -1150,7 +1328,7 @@ public function getRules($stage_id) { - drupal_set_message(t('current stage is : ' . $stage_id)); + //drupal_set_message(t('current stage is : ' . $stage_id)); $result=db_query("Select rule_no,description from vc_rules where vc_stage_id=%d",$stage_id ); while($data=db_fetch_object($result)) { @@ -1163,7 +1341,7 @@ public function saveStudentVoting($stud_id,$rule_no,$stage_id) { $rule_id=db_result(db_query("select id from vc_rules where vc_stage_id=%d and rule_no=%d",$stage_id,$rule_no)); - db_query("insert into {vc_student_voting} (vc_student_id,vc_rules_id) values('%s',%d)",$stud_id,$rule_id); + db_query("insert into {vc_student_voting} (vc_student_id,vc_rules_id,consider_flag) values('%s',%d,false)",$stud_id,$rule_id); } } Modified: vcweb/trunk/virtualcommons/experiment/experiment.install =================================================================== --- vcweb/trunk/virtualcommons/experiment/experiment.install 2008-08-21 00:47:39 UTC (rev 45) +++ vcweb/trunk/virtualcommons/experiment/experiment.install 2008-08-21 16:56:18 UTC (rev 46) @@ -73,6 +73,7 @@ start_flag BOOL default false, turn_no INT NOT NULL, + played_flag BOOL NOT NULL, PRIMARY KEY(id), FOREIGN KEY(vc_group_id) REFERENCES vc_group(id) Modified: vcweb/trunk/virtualcommons/experiment/experiment.module =================================================================== --- vcweb/trunk/virtualcommons/experiment/experiment.module 2008-08-21 00:47:39 UTC (rev 45) +++ vcweb/trunk/virtualcommons/experiment/experiment.module 2008-08-21 16:56:18 UTC (rev 46) @@ -177,7 +177,7 @@ $lname=$teacher->getlname();*/ - drupal_set_message(t('Thanks for filling out the form. Your Game will start soon. ')); + drupal_set_message(t('Thanks for filling out the form. Your Game will start soon. '),'warning'); //db_query("Insert into {virtualcommons_conducts} (users_id, virtualcommons_experiments_id ,date, no_of_students ) values(%d,%d,NOW(),%d)",$teacher_id,$result,$no_student); Modified: vcweb/trunk/virtualcommons/experiment/games/forestry_v2/forestry_v2.module =================================================================== --- vcweb/trunk/virtualcommons/experiment/games/forestry_v2/forestry_v2.module 2008-08-21 00:47:39 UTC (rev 45) +++ vcweb/trunk/virtualcommons/experiment/games/forestry_v2/forestry_v2.module 2008-08-21 16:56:18 UTC (rev 46) @@ -13,16 +13,34 @@ * Implementation of hook_menu(). */ function forestry_v2_menu($may_cache) { - $items = array(); - if ($may_cache) { + //$student = Session::get('student'); + //$stage_no = $student->getGroup()->getGame()->getCurrentStageNumber(); + $items = array(); + if ($may_cache) { + $items[] = array('path' => 'forestry/info', + 'title' => t('Forestry Game Information'), + 'callback' => 'forestry_info', + 'type'=>MENU_CALLBACK, + 'access' => TRUE//user_access('Only Teachers') + ); + + $items[] = array('path' => 'forestry/decision_info', + 'title' => t('Forestry Game Decision Information'), + 'callback' => 'forestry_decision_info', + 'type'=>MENU_CALLBACK, + 'access' => TRUE//user_access('Only Teachers') + ); + + $items[] = array('path' => 'forestry/intro', 'title' => t('Forestry Game'), 'callback' => 'forestry_intro', 'type'=>MENU_CALLBACK, 'access' => TRUE//user_access('Only Teachers') ); + $items[]=array( 'path' => 'forestry/play', - 'title' => t('Forestry Game - Round Active'), + 'title' => t('Forestry Game - Round Active '), 'callback' => 'forestry_play', //'callback arguments'=>array(forestry_game_stage1_multiform), 'type'=>MENU_CALLBACK, @@ -49,6 +67,72 @@ } } + +function forestry_info() +{ + $student = Session::get('student'); + $output = t('<br><h2>Welcome to the Forestry game!</h2>'); + $output.= '<p>In this exercise it is intended to recreate a situation in which a group must make decisions about the use of a forest. + Depending upong the group size, area of forest with initial resource will be determined; which is always set to maximum resource level. + For group of 3 participants, initial resource(maximum resource level) will be 60, + while for group of 4 or 5 participants, initial resource will be 80 or 100 respectively. + You will play several rounds equivalent to, for example, years or seasons. Each round you have to make a decision + about how many resource units you want to harvest. You can harvest a maximum of 5 units and minimum of 0 units of the resource. + {You earn $x for each unit you collect from the harvesting the forest.}. Between the rounds the resource is regrowing. + For each ten units of the existing resource, one new unit is added for the next round. + For example, after everybody make harvest decision in the first round, there are 24 trees available. This leads to a regrowth of 2 new trees, + and thus for the next round 26 trees will be available for harvesting. The forest can not grow to more than maximum resource level.</p>'; + //<p>You participate in a '. $student->getgroup()->getNumberOfStudents().' person group.</p>'; + $output.=drupal_get_form('forestry_info_form'); + return $output; +} +function forestry_info_form() +{ + $form['submit'] = array( + '#type' => 'submit', + '#value' => t('Next') + ); + + return $form; +} + +function forestry_info_form_submit($form,$form_values) +{ + return 'forestry/intro'; +} + +function forestry_decision_info() +{ + $student = Session::get('student'); + $output = t('<br><h2>Welcome to the Forestry game!</h2>'); + $output.= '<p>In this exercise it is intended to recreate a situation in which a group must make decisions about the use of a forest. The group sizes are 3,4 or 5. + You will play several rounds equivalent to, for example, years or seasons.<br> + Depending upong the group size, area of forest with initial resource will be determined. For group of 3 participants, initial resource will be 60, + while for group of 4 or 5 participants, initial resource will be 80 or 100, respectively. + Each round you have to make a decision about how many resource units you want to harvest. You can harvest a maximum of 5 units and + minimum of 0 units of the resource. {You earn $x for each unit you collect from the harvesting the forest.}. Between the rounds the + resource is regrowing.For each ten units of the existing resource, one new unit is added for the next round. For example, after the harvest + there are 24 trees available. This leads to a regrowth of 2 new trees, and thus for the next round 26 trees will be available. + The forest can not grow to more than 100 units.</p>'; + $output.=drupal_get_form('forestry_info_form'); + return $output; +} +function forestry_decision_info_form() +{ + $form['submit'] = array( + '#type' => 'submit', + '#value' => t('Next') + ); + + return $form; +} + +function forestry_decision_info_form_submit($form,$form_values) +{ + return 'forestry/play'; +} + + /** * */ @@ -137,6 +221,7 @@ function forestry_play() { // Return the HTML generated from the $form data structure. $student = Session::get('student'); + $start=0; // check if user is properly authenticated if (! $student ) { return drupal_get_form('student_login_nameform'); @@ -154,8 +239,17 @@ { $output .= generate_harvest_table(); $output .= generate_results_table(); - - $output .= ( $student->canStart() ) ? drupal_get_form('forestry_play_multiform') : drupal_get_form('forestry_wait_form'); + drupal_set_message(t('resource over flag is: '. $student->getGroup()->isResourceOver())); + if($student->canStart()) + { + if($student->getGroup()->isResourceOver()) + $start=1; + + } + else + $start=1; + drupal_set_message(t('start flag is: '. $start)); + $output .= (!$start) ? drupal_get_form('forestry_play_multiform') : drupal_get_form('forestry_wait_form'); } return $output; } @@ -174,7 +268,7 @@ $resource_before=0; $round_no = $group->getGame()->getCurrentRoundNo(); -drupal_set_message($round_no); +//drupal_set_message($round_no); if($student->getGroup()->getGame()->isVotingEnabled()) { @@ -183,12 +277,17 @@ { if($student->isTurn()) { - $form['turn']=array( + $msg='You are allowed to harvest in this round.'; + } + else + { + $msg='You can harvest but are not allowed to in this round. If you harvest and you get caught by a monitor (chance one out of six) you have to payback the harvest plus a fine of 3 units'; + } + $form['turn']=array( '#type'=>'item', - '#value'=>t('You have been chosen for this round. You can harvest.') + '#value'=>$msg ); - } } } //store the round no in hidden field @@ -393,13 +492,16 @@ making their decisions and the facilitator instructs you to click on the next button. Clicking on the next button before the facilitator is ready will have no effect.'), - 'warning', FALSE); + 'warning', FALSE); + // drupal_set_message(t('resource over flag:'.$group->isResourceOver())); if ($group->isGameFinished()) { drupal_set_message(t('The game is over. Thanks for participating.'), 'warning', FALSE); } - else if($group->getGame()->isStageOver() || $group->getGame()->isLastRound()) + + else if( $group->getGame()->isLastRound() || $group->isResourceOver() || $group->getGame()->isStageOver() + ) { 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/rules/rules.install =================================================================== --- vcweb/trunk/virtualcommons/experiment/rules/rules.install 2008-08-21 00:47:39 UTC (rev 45) +++ vcweb/trunk/virtualcommons/experiment/rules/rules.install 2008-08-21 16:56:18 UTC (rev 46) @@ -13,6 +13,7 @@ id INT AUTO_INCREMENT, vc_student_id varchar(14) NOT NULL, vc_rules_id INT NOT NULL, + consider_flag BOOL NOT NULL, time_created TIMESTAMP NOT NULL, PRIMARY KEY(id), @@ -83,6 +84,7 @@ function rules_uninstall() { db_query("DROP TABLE {vc_student_voting}"); + db_query("DROP TABLE {vc_tie}"); drupal_set_message(t('Student Voting table is successfully deleted from the database.')); } Modified: vcweb/trunk/virtualcommons/experiment/student_login/student_login.module =================================================================== --- vcweb/trunk/virtualcommons/experiment/student_login/student_login.module 2008-08-21 00:47:39 UTC (rev 45) +++ vcweb/trunk/virtualcommons/experiment/student_login/student_login.module 2008-08-21 16:56:18 UTC (rev 46) @@ -73,5 +73,5 @@ { $_SESSION['student_id']=$form_values['id']; - return 'forestry/intro'; + return 'forestry/info'; } Modified: vcweb/trunk/virtualcommons/experiment/survey/survey.module =================================================================== --- vcweb/trunk/virtualcommons/experiment/survey/survey.module 2008-08-21 00:47:39 UTC (rev 45) +++ vcweb/trunk/virtualcommons/experiment/survey/survey.module 2008-08-21 16:56:18 UTC (rev 46) @@ -118,11 +118,19 @@ // Otherwise a bug occurs if the student finishes voting and the survey before // the teacher has processed votes // if ($group->all_students_voted()) { - return 'rule_decision'; + + // return 'rule_decision'; // } // else { // return 'voting/wait'; //} + if($group->getGame()->isRuleSelected() || $group->isTieHappened()) + { + return 'rule_decision'; + } + else + return 'voting/wait'; + } @@ -145,24 +153,26 @@ //t('There is a tie between votings. You need to vote again for the following rules') if($tie_flag) { - $rule_no=$group->getRuleNo(); + $rule=$group->getRuleNo(); $form['rule']=array( - '#title'=>t('There is a tie between following rules. Please vote again. If tie happens one more time after this voting, final rule will be randomly chosen from the following rules.'), - '#type'=>'item', + '#title'=>t('There is a tie between following rules after voting. You can vote again for these rules. If this results again in tie, we draw randomely a winner.'), + '#type'=>'item' ); - $form['rule1']=array( + foreach($rule as $key=>$value) + { + //drupal_set_message(t('Rule no : ' . $key.' ' .$value)); + + $form['rule'.$key]=array( + '#prefix'=>'<div class="indicator">', '#title'=>t('Rule No. '), '#type'=>'item', - '#value'=>$rule_no[0] + '#value'=>t($key . '<p>' . $value . '</p>' ), + '#suffix'=>'</div>' ); - $form['rule2']=array( - '#title'=>t('Rule No. '), - '#type'=>'item', - '#value'=>$rule_no[1] - ); + } $form['vote']=array( - '#prefix'=>'<div class="indicator">', + '#prefix'=>'<div class="indicator">', '#type'=>'textfield', '#title'=>t('Your Vote'), '#default_value'=>'0', @@ -175,6 +185,7 @@ '#value' => t('Vote'), '#suffix'=>'</div>' ); + } else @@ -186,7 +197,7 @@ //drupal_set_message(t('Selected rule no is: '. $key . 'Description is : ' . $value)); $form['rule']=array( - '#title'=>t('Please be patience until others voting decision has made. Teacher will tell you when to click the next button. '), + '#title'=>t('The following rule is chosen for your group. Since other groups have not finished their voting procedure, please have some patience before we go to next round. '), '#type'=>'item', ); @@ -229,8 +240,8 @@ { if($form_values['submit']=="Next") { + return 'forestry/intro'; - } else if($form_values['submit']=="Vote") { @@ -239,7 +250,45 @@ $rule_no=(int) $form_values['vote']; $rules=new Rules(); $rules->saveStudentVoting($student->getId(),$rule_no,$group->getCurrentStageId()); + return 'voting/wait'; } // FIXME: return to the appropriate experiment - return 'forestry/intro'; + } + +function voting_wait() +{ + $output='<b>Please be patience until others voting decision has made. Teacher will tell you when to click the next button.</b>'; + $output .= drupal_get_form('voting_wait_form'); + return $output; +} + + +function voting_wait_form() +{ + + $form['submit'] = array( + '#type' => 'submit', + '#value' => t('Next') + ); + return $form; + +} + +function voting_wait_form_submit($form,$form_values) +{ + $student=Session::get('student'); + //check whether teacher processed the votings + if( $student->getGroup()->getGame()->isRuleSelected()) + { + return 'rule_decision'; + } + else + return 'voting/wait'; + + +} + + + + Modified: vcweb/trunk/virtualcommons/experiment/teacher_dashboard/teacher_dashboard.module =================================================================== --- vcweb/trunk/virtualcommons/experiment/teacher_dashboard/teacher_dashboard.module 2008-08-21 00:47:39 UTC (rev 45) +++ vcweb/trunk/virtualcommons/experiment/teacher_dashboard/teacher_dashboard.module 2008-08-21 16:56:18 UTC (rev 46) @@ -93,6 +93,7 @@ if ($game->isFinished()) { // $output = t('The game is over.'); + drupal_get_messages(); drupal_set_message(t('<h2 align="center" style="color:#990000">The game is over. Thanks for participating!</h2>')); /* $form['final_msg']=array( @@ -126,7 +127,7 @@ if($start_flag) { //drupal_get_messages(); - drupal_set_message(t('This stage needs voting. Please tell students to vote.'),'warning',FALSE); + // drupal_set_message(t('This stage needs voting. Please tell students to vote.'),'warning',FALSE); $form['submit'] = array( '#type' => 'submit', '#value' => t('Start Stage') @@ -205,18 +206,13 @@ { if(! $game->isRuleSelected()) { - if($game->assign_Rules_To_Groups()) - { - $game->saveTie(); - } - else - { - $rule_no=$game->initRules(); - } + $game->assign_Rules_To_Groups(); + $rule_no=$game->initRules(); + } } else - form_set_error('submit',t('Please tell students to vote. Without voting you can not proceed to Stage 2')); + form_set_error('submit',t('This stage needs voting. Please tell students to vote.')); } //$game->is_Rule_Selected_For_All_Groups(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <al...@us...> - 2008-08-21 00:47:31
|
Revision: 45 http://virtualcommons.svn.sourceforge.net/virtualcommons/?rev=45&view=rev Author: alllee Date: 2008-08-21 00:47:39 +0000 (Thu, 21 Aug 2008) Log Message: ----------- - bumping version of csidex with minor fixes, major revision coming soon with savedata persistence overhaul - sending BufferedReader to processReplInput in case additional input is needed - making ForagingSaveFileConverter invokable from the server console - fixing https://csid.asu.edu/jira/browse/CSAN-6 chat field focus issue Modified Paths: -------------- foraging/trunk/build.xml foraging/trunk/ivy.xml foraging/trunk/pom.xml foraging/trunk/src/main/java/edu/asu/commons/foraging/client/ChatPanel.java foraging/trunk/src/main/java/edu/asu/commons/foraging/server/ForagingServer.java foraging/trunk/src/main/java/edu/asu/commons/foraging/util/ForagingSaveFileConverter.java foraging/trunk/src/main/resources/configuration/round1.xml Modified: foraging/trunk/build.xml =================================================================== --- foraging/trunk/build.xml 2008-08-18 23:05:42 UTC (rev 44) +++ foraging/trunk/build.xml 2008-08-21 00:47:39 UTC (rev 45) @@ -78,7 +78,7 @@ <property name="javadoc.dir" value="docs/javadoc"/> <property name="javadoc.private.dir" value="docs/private"/> - <property name='lib.dir' value='lib/default'/> + <property name='lib.dir' value='lib'/> <!-- Set up the CLASSPATH, includes all jars in the lib directory and all built files for both the main project Modified: foraging/trunk/ivy.xml =================================================================== --- foraging/trunk/ivy.xml 2008-08-18 23:05:42 UTC (rev 44) +++ foraging/trunk/ivy.xml 2008-08-21 00:47:39 UTC (rev 45) @@ -8,7 +8,7 @@ <dependency org='junit' name='junit' rev='4.4'/> <dependency org='com.thoughtworks.xstream' name='xstream' rev='1.3' transitive='false'/> <dependency org='xpp3' name='xpp3' rev='1.1.4c' transitive='false' /> - <dependency org="edu.asu.commons" name="csidex" rev="0.1"/> + <dependency org="edu.asu.commons" name="csidex" rev="0.1.1"/> <dependency org='net.java.dev.jogl' name='jogl' rev='1.1.1'/> <dependency org='net.java.dev.jogl' name='gluegen-rt' rev='1.1.1'/> </dependencies> Modified: foraging/trunk/pom.xml =================================================================== --- foraging/trunk/pom.xml 2008-08-18 23:05:42 UTC (rev 44) +++ foraging/trunk/pom.xml 2008-08-21 00:47:39 UTC (rev 45) @@ -34,7 +34,7 @@ <dependency> <groupId>edu.asu.commons</groupId> <artifactId>csidex</artifactId> - <version>0.1</version> + <version>0.1.1</version> </dependency> <dependency> <groupId>net.java.dev.jogl</groupId> Modified: foraging/trunk/src/main/java/edu/asu/commons/foraging/client/ChatPanel.java =================================================================== --- foraging/trunk/src/main/java/edu/asu/commons/foraging/client/ChatPanel.java 2008-08-18 23:05:42 UTC (rev 44) +++ foraging/trunk/src/main/java/edu/asu/commons/foraging/client/ChatPanel.java 2008-08-21 00:47:39 UTC (rev 45) @@ -10,6 +10,8 @@ import java.awt.event.ActionListener; import java.awt.event.KeyAdapter; import java.awt.event.KeyEvent; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; import java.util.ArrayList; import java.util.Collections; import java.util.List; @@ -104,8 +106,13 @@ add(targetHandlePanel, BorderLayout.NORTH); add(chatField, BorderLayout.CENTER); add(sendButton, BorderLayout.SOUTH); + setChatFieldFocus(); } + private void setChatFieldFocus() { + chatField.requestFocusInWindow(); + } + private void sendMessage() { String message = chatField.getText(); // System.err.println("message: " + message); @@ -126,7 +133,7 @@ } else { targetHandleLabel.setText(getChatHandle(targetIdentifier)); } - chatField.requestFocusInWindow(); + setChatFieldFocus(); } } @@ -252,7 +259,7 @@ // if (client.getDataModel().getRoundConfiguration().shouldD // add(participantButtonPanel, BorderLayout.EAST); add(textEntryPanel, BorderLayout.SOUTH); - + textEntryPanel.setChatFieldFocus(); } public void clear() { Modified: foraging/trunk/src/main/java/edu/asu/commons/foraging/server/ForagingServer.java =================================================================== --- foraging/trunk/src/main/java/edu/asu/commons/foraging/server/ForagingServer.java 2008-08-18 23:05:42 UTC (rev 44) +++ foraging/trunk/src/main/java/edu/asu/commons/foraging/server/ForagingServer.java 2008-08-21 00:47:39 UTC (rev 45) @@ -1,5 +1,6 @@ package edu.asu.commons.foraging.server; +import java.io.BufferedReader; import java.io.IOException; import java.util.ArrayList; import java.util.Collections; @@ -53,6 +54,7 @@ import edu.asu.commons.foraging.model.GroupDataModel; import edu.asu.commons.foraging.model.ResourceDispenser; import edu.asu.commons.foraging.model.ServerDataModel; +import edu.asu.commons.foraging.util.ForagingSaveFileConverter; import edu.asu.commons.net.Dispatcher; import edu.asu.commons.net.Identifier; import edu.asu.commons.net.event.ConnectionEvent; @@ -122,7 +124,7 @@ } @Override - public void processReplInput(String input) { + public void processReplInput(String input, BufferedReader reader) { if (input.equals("clients")) { System.out.println("Connected Clients:"); for (Identifier id: clients.keySet()) { @@ -147,6 +149,22 @@ System.out.println("Skipping post round sanctioning"); Utils.notify(postRoundSanctioningSignal); } + else if (input.equals("process-savefiles")) { + System.out.print("Please enter the save directory path: "); + try { + String path = reader.readLine(); + boolean converted = ForagingSaveFileConverter.convert(path); + if (! converted) { + System.out.println("Unable to convert from path: " + path); + } + } + catch (IOException e) { + e.printStackTrace(); + } + catch (RuntimeException e) { + e.printStackTrace(); + } + } } @@ -695,7 +713,7 @@ } /** - * Main entry point. + * Main entry point. */ public static void main(String[] args) { ForagingServer server = new ForagingServer(); Modified: foraging/trunk/src/main/java/edu/asu/commons/foraging/util/ForagingSaveFileConverter.java =================================================================== --- foraging/trunk/src/main/java/edu/asu/commons/foraging/util/ForagingSaveFileConverter.java 2008-08-18 23:05:42 UTC (rev 44) +++ foraging/trunk/src/main/java/edu/asu/commons/foraging/util/ForagingSaveFileConverter.java 2008-08-21 00:47:39 UTC (rev 45) @@ -15,6 +15,7 @@ import edu.asu.commons.event.ChatRequest; import edu.asu.commons.event.PersistableEvent; +import edu.asu.commons.experiment.Persister; import edu.asu.commons.experiment.SaveFileProcessor; import edu.asu.commons.experiment.SavedRoundData; import edu.asu.commons.foraging.conf.RoundConfiguration; @@ -31,27 +32,32 @@ import edu.asu.commons.foraging.model.ResourceDispenser; import edu.asu.commons.foraging.model.ServerDataModel; import edu.asu.commons.foraging.model.ResourceDispenser.StochasticGenerator; -import edu.asu.commons.foraging.server.ForagingPersister; import edu.asu.commons.net.Identifier; import edu.asu.commons.util.Utils; public class ForagingSaveFileConverter { + public static boolean convert(String saveDataDirectory) { + File allSaveFilesDirectory = new File(saveDataDirectory); + if (allSaveFilesDirectory.exists() && allSaveFilesDirectory.isDirectory()) { + List<SaveFileProcessor> processors = new ArrayList<SaveFileProcessor>(); + processors.addAll(Arrays.asList( + new ForagingSaveFileProcessor(), + new SummaryStatisticsProcessor(), + new ForagingSummarySaveFileProcessor())); + Persister.processSaveFiles(allSaveFilesDirectory, processors); + return true; + } + return false; + } - public static void main(String[] args) { if (args.length == 0) { - System.err.println("Usage: java " + ForagingSaveFileConverter.class + " <savedata-directory>"); + System.err.println("Usage: java " + ForagingSaveFileConverter.class + " <save-data-directory>"); System.exit(0); } - File allSaveFilesDirectory = new File(args[0]); - List<SaveFileProcessor> processors = new ArrayList<SaveFileProcessor>(); - processors.addAll(Arrays.asList( - new ForagingSaveFileProcessor(), - new SummaryStatisticsProcessor(), - new ForagingSummarySaveFileProcessor())); - ForagingPersister.processSaveFiles(allSaveFilesDirectory, processors); + convert(args[0]); } private static class ForagingSummarySaveFileProcessor extends SaveFileProcessor.Base { @@ -70,6 +76,7 @@ } */ List<GroupDataModel> groups = new ArrayList<GroupDataModel>(serverDataModel.getGroups()); + writer.println("Group #, Members, ..., Resources Left, Final Resource Positions"); for (GroupDataModel group: groups) { writer.println( String.format("%s, %s, %s, %s", Modified: foraging/trunk/src/main/resources/configuration/round1.xml =================================================================== --- foraging/trunk/src/main/resources/configuration/round1.xml 2008-08-18 23:05:42 UTC (rev 44) +++ foraging/trunk/src/main/resources/configuration/round1.xml 2008-08-21 00:47:39 UTC (rev 45) @@ -12,6 +12,7 @@ <entry key="initial-distribution">.25</entry> <entry key="regrowth-rate">0.01</entry> +<entry key='chat-enabled'>true</entry> <!-- This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: Allen L. (V. Commons-JIRA) <all...@as...> - 2008-08-21 00:04:22
|
[ https://csid.asu.edu/jira/browse/CSAN-8?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Allen Lee resolved CSAN-8. -------------------------- Resolution: Fixed Done, had to be performed on the legacy CSAN codebase (not the one in SF) due to package restructuring. > generate data files for Indiana 2D experiments (aggregate + detailed) > --------------------------------------------------------------------- > > Key: CSAN-8 > URL: https://csid.asu.edu/jira/browse/CSAN-8 > Project: Foraging Experiment > Issue Type: Task > Components: 2D Visualization > Reporter: Allen Lee > Assignee: Allen Lee > > Collect all the save files sent by Yajing over the past few months from Indiana and generate data for the Indiana experiments. -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: https://csid.asu.edu/jira/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira |
From: <see...@us...> - 2008-08-18 23:05:37
|
Revision: 44 http://virtualcommons.svn.sourceforge.net/virtualcommons/?rev=44&view=rev Author: seematalele Date: 2008-08-18 23:05:42 +0000 (Mon, 18 Aug 2008) Log Message: ----------- rule 2 and rule 3 are working properly for 3,4,5 groups and vc_tie table is created.Values are inserted into the vc_tie table properly. Modified Paths: -------------- vcweb/trunk/virtualcommons/experiment/experiment.inc vcweb/trunk/virtualcommons/experiment/rules/rules.install vcweb/trunk/virtualcommons/experiment/survey/survey.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-18 06:44:06 UTC (rev 43) +++ vcweb/trunk/virtualcommons/experiment/experiment.inc 2008-08-18 23:05:42 UTC (rev 44) @@ -236,7 +236,8 @@ $resources_after=$data->resources_after; $group_round_data = array($round_no,$group_no,$total_harvest_decision,$resources_before,$resources_after); if ( $data->vc_rules_id ) { - array_push($group_round_data, $data->vc_rules_id, $data->dice); + + array_push($group_round_data, db_result(db_query("select rule_no from vc_rules where id=%d",$data->vc_rules_id)), $data->dice); } $stage_data[$stage_id][] = $group_round_data; } @@ -273,10 +274,8 @@ } public function getTurnSequence($group_id) { - return db_result(db_query('select turn_sequence - FROM vc_forestry_turn_sequence s, vc_group gr, vc_game ga - WHERE s.vc_group_id=%d AND ga.id=gr.vc_game_id AND ga.current_round_no=s.round_no AND s.vc_rules_id=gr.vc_selected_rules_id', - $group_id)); + return db_result(db_query(' select turn_sequence from vc_forestry_turn_sequence where vc_group_id=%d and vc_game_id=%d and round_no=%d', + $group_id,$this->game_id,$this->getCurrentRoundNo())); } public function getValidStudentIds($group_id) { @@ -301,7 +300,8 @@ WHERE fs.harvest_decision > 0 AND s.vc_group_id=%d AND fs.round_no=%d - AND s.turn_no NOT IN (%s)', $group_id, $this->getCurrentRoundNo(), $turn_sequence); + AND fs.vc_stage_id=%d + AND s.turn_no NOT IN (%s)', $group_id, $this->getCurrentRoundNo(),$this->getCurrentStageId(), $turn_sequence); while ($data = db_fetch_object($result)) { $fine = $data->harvest_decision + 3; $dice = 6; @@ -313,32 +313,29 @@ } private function assessFines($group_id, $current_rule_number) { - switch ($current_rule_number) { + switch ($current_rule_number) + { case 1: case 2: - $this->assessTurnSequenceFines($group_id); - break; + $this->assessTurnSequenceFines($group_id); + break; case 3: - $students=db_query("select id from vc_student where vc_group_id=%d",$group_id); - while($student_data=db_fetch_object($students)) - { - $result=db_query("Select id,harvest_decision,total_points from vc_forestry_student - where vc_student_id='%s' and round_no=%d ",$student_data->id,$this->getCurrentRoundNo()); - if($data=db_fetch_object($result)) + //$students=db_query("select id from vc_student where vc_group_id=%d",$group_id); + $result = db_query("SELECT fs.id, fs.harvest_decision, fs.total_points + FROM vc_forestry_student fs INNER JOIN vc_student s ON fs.vc_student_id=s.id + WHERE fs.harvest_decision > 2 + AND s.vc_group_id=%d + AND fs.round_no=%d + AND fs.vc_stage_id=%d", + $group_id, $this->getCurrentRoundNo(),$this->getCurrentStageId()); + while($data=db_fetch_object($result)) { - if($data->harvest_decision > 2) - { - $fine = $data->harvest_decision + 3; - $total_points = $data->total_points - $fine; - db_query('UPDATE vc_forestry_student SET fine=%d, total_points=%d - WHERE id=%d', $fine, $total_points, $data->id); - } - + $fine = $data->harvest_decision + 3; + $total_points = $data->total_points - $fine; + db_query('UPDATE vc_forestry_student SET fine=%d, total_points=%d + WHERE id=%d', $fine, $total_points, $data->id); } - - } - - break; + break; default: form_set_error(t('Current rule number is invalid: ' . $current_rule_number)); break; @@ -407,7 +404,7 @@ { // roll the dice $dice = rand(1, 6); - // $dice = 6; + $dice = 6; if ($dice == 6) { // check to see if we need to assess fines @@ -572,15 +569,22 @@ //echo '<br/> Max: '. $max ; drupal_set_message(t( '$max_rule_cnt is : ' . $max_rule_cnt)); + if(($max_rule_cnt==$tie_rule_cnt) || ($max_rule_cnt==0)) { - drupal_set_message(t( 'Tie')); + + $tie=implode(',',$tie_rules); + drupal_get_messages(); + drupal_set_message(t( 'Tie happened in Group no: ' . $group_id .'.<br> Rules are :' . $tie),'warning'); + db_query("Insert into {vc_tie} (vc_group_id,tie_rules_id) values (%d,'%s')",$group_id,$tie); + return TRUE; } else { drupal_set_message(t( 'NOT Tie' . '$max_rule_id: ' . $max_rule_id)); - db_query("update vc_group set vc_selected_rules_id =%d where id=%d",$max_rule_id,$group_id); + db_query("update vc_group set vc_selected_rules_id =%d where id=%d",$max_rule_id,$group_id); + return FALSE; } // drupal_set_message(t('Rule id : ' . $final_rule_id.'Group id is: ' . $group_id)); @@ -589,6 +593,11 @@ }//end of init function + + public function saveTie() + { + + } // several ways to implement this - // 1. use array_rand to get a set of random keys into the array @@ -695,14 +704,14 @@ $prev_round_no=$round_no-1; $turn_seq=array(); //get the sequnce number for the last round number, determine the sequence - $seq=db_query("Select turn_sequence from vc_forestry_turn_sequence where vc_game_id=%d and vc_group_id=%d and round_no=%d and vc_rules_id=%d",$this->game_id,$group_id,$prev_round_no,$selected_rule_id); + $seq=db_result(db_query("Select turn_sequence from vc_forestry_turn_sequence where vc_game_id=%d and vc_group_id=%d and round_no=%d and vc_rules_id=%d",$this->game_id,$group_id,$prev_round_no,$selected_rule_id)); $temp_seq=explode(',',$seq); $last_element=end($temp_seq); for($j=0;$j<$how_many;$j++) { if($last_element<$no_of_student) { - $turn_seq[]=$last_element++; + $turn_seq[]=++$last_element; } else { @@ -710,8 +719,9 @@ $last_element=1; } } + $turn_sequence = implode(',',$turn_seq); } - $turn_sequence = implode(',',$turn_seq); + break; default: @@ -787,9 +797,6 @@ return new TableData(array('Resource Level', 'Maximum Harvest Decision'), $data); } - - - public function getTurnSequence() { return $this->game->getTurnSequence($this->group_id); } @@ -842,23 +849,26 @@ public function getSelectedRule() { $result_rule=db_query("select rule_no, description from vc_rules r, vc_group g where r.id =g.vc_selected_rules_id and g.id=%d",$this->group_id); - //$rule=array(); + $rule=array(); if ($data_rule=db_fetch_object($result_rule)) { - $rule[]=array($data_rule->rule_no); - $rule[]=array($data_rule->description); + //$rule[]=array($data_rule->rule_no); + //$rule[]=array($data_rule->description); + array_push($rule,$data_rule->rule_no,$data_rule->description); //drupal_set_message(t($data_rule->description)); } // drupal_set_message(t('Description is:' . $rule[1][0] )); return $rule; } - public function getRuleNo() + /*public function getRuleNo() { + $result_voting=db_query(" select vc_rules_id, count(vc_rules_id) from vc_student_voting v where v.time_created >= (select max(time_created) from vc_student_voting vv where v.vc_student_id=vv.vc_student_id) and - v.vc_student_id in (select id from vc_student where vc_group_id=%d) group by vc_rules_id",$group_id); - $rule_id=array(); + v.vc_student_id in (select id from vc_student where vc_group_id=%d) group by vc_rules_id",$group_id); + $result_voting=db_result(db_query("select tie_rules_id from vc_tie where vc_group_id=%d ",$this->group_id)); + $rule_id=array(); $rule_cnt=array(); $final_rule_no=array(); while($data=db_fetch_object($result_voting)) @@ -884,7 +894,26 @@ } //drupal_set_message(t('Rule no : ' . $final_rule_no[0].' ' .$final_rule_no[1]. 'Group id is: ' . $this->group_id)); return $final_rule_no; + }*/ + + public function getRuleNo() + { + + $result_voting=db_result(db_query("select tie_rules_id from vc_tie where vc_group_id=%d ",$this->group_id)); + $rule_id=array(); + $final_rule_no=array(); + $rule_id=explode(',',$result_voting); + drupal_set_message(t('Tie Rules are : ' . $result_voting)); + for($i=0;$i<count($rule_id);$i++) + { + array_push($final_rule_no,db_result(db_query("select rule_no from vc_rules where id =%d",$rule_id[$i]))); + drupal_set_message(t('Tie Rules are : ' . $rule_id[$i] )); + + } + //drupal_set_message(t('Rule no : ' . $final_rule_no[0].' ' .$final_rule_no[1]. 'Group id is: ' . $this->group_id)); + return $final_rule_no; } + public function getResourcesAvailable() { return db_result(db_query('SELECT common_resource_pool @@ -977,9 +1006,10 @@ $decision_table = array(); $voting_enabled=db_result(db_query("select voting from vc_stage where id=%d",$stage_id)); - $round_header = array('Round Number', 'Your Harvest Decision', 'Resources Before', 'Resources After'); + $round_header = array('Round Number', 'Your Harvest Decision', 'Resources Before', 'Resources After','Total Points'); if ($voting_enabled) { - array_push($round_header, 'Penalty', 'Total Points'); + $round_header = array('Round Number', 'Your Harvest Decision', 'Resources Before', 'Resources After','Penalty','Total Points'); + //array_push($round_header, 'Penalty', 'Total Points'); } while($student_data=db_fetch_object($student_decision)) { @@ -1001,9 +1031,10 @@ $resources_after="?"; } - $current_round_data = array($round_no,$harvest_decision,$resources_before,$resources_after); + $current_round_data = array($round_no,$harvest_decision,$resources_before,$resources_after,$total_points); if($voting_enabled) { - array_push($current_round_data, $fine, $total_points); + $current_round_data = array($round_no,$harvest_decision,$resources_before,$resources_after,$fine,$total_points); + //array_push($current_round_data, $fine, $total_points); } $round_data[] = $current_round_data; } @@ -1057,12 +1088,13 @@ { // $stage_id = $this->getGroup()->getGame()->getCurrentStageId(); } - $total = db_result(db_query("SELECT sum(harvest_decision) + $total = db_result(db_query("SELECT total_points FROM {vc_forestry_student} WHERE vc_student_id='%s' - AND vc_stage_id=%d", + AND vc_stage_id=%d + AND round_no=%d", $this->stud_id, - $stage_id)); + $stage_id,$round_no-1)); $total=$total+$harvest_decision; db_query("INSERT INTO {vc_forestry_student} (round_no,vc_student_id,vc_stage_id,harvest_decision, total_points) VALUES (%d,'%s',%d,%d, %d)", $round_no,$this->stud_id,$stage_id,$harvest_decision, $total); Modified: vcweb/trunk/virtualcommons/experiment/rules/rules.install =================================================================== --- vcweb/trunk/virtualcommons/experiment/rules/rules.install 2008-08-18 06:44:06 UTC (rev 43) +++ vcweb/trunk/virtualcommons/experiment/rules/rules.install 2008-08-18 23:05:42 UTC (rev 44) @@ -23,9 +23,26 @@ ON DELETE CASCADE )ENGINE=InnoDB /*!40100 DEFAULT CHARACTER SET UTF8 */"); + + + db_query("CREATE TABLE {vc_tie} + ( + id INT AUTO_INCREMENT, + vc_group_id INT NOT NULL, + tie_rules_id varchar(255) NOT NULL, + + time_created TIMESTAMP NOT NULL, + PRIMARY KEY(id), + FOREIGN KEY(vc_group_id) REFERENCES vc_group(id) + ON DELETE CASCADE + )ENGINE=InnoDB /*!40100 DEFAULT CHARACTER SET UTF8 */"); + + $flag=TRUE; + + break; case 'pgsql': Modified: vcweb/trunk/virtualcommons/experiment/survey/survey.module =================================================================== --- vcweb/trunk/virtualcommons/experiment/survey/survey.module 2008-08-18 06:44:06 UTC (rev 43) +++ vcweb/trunk/virtualcommons/experiment/survey/survey.module 2008-08-18 23:05:42 UTC (rev 44) @@ -6,7 +6,7 @@ static $loaded = FALSE; if (!$loaded) { - $path = drupal_get_path('module', 'forestry_stage1'); + $path = drupal_get_path('module', 'forestry_v2'); drupal_add_css($path .'/form.css'); $loaded = TRUE; } @@ -180,7 +180,8 @@ else { $rule_info=$group->getSelectedRule(); - foreach ($rule_info as $key=>$value) + // foreach ($rule_info as $key=>$value) + for($i=0;$i<count($rule_info);$i++) { //drupal_set_message(t('Selected rule no is: '. $key . 'Description is : ' . $value)); @@ -192,12 +193,12 @@ $form['rule']=array( '#title'=>t('Selected Rule no is '), '#type'=>'item', - '#value'=>$key + '#value'=>$rule_info[0] ); $form['rule_description']=array( '#title'=>t('Description for this rule is '), '#type'=>'item', - '#value'=>$value[0] + '#value'=>$rule_info[1] ); $form['submit'] = array( '#type' => 'submit', Modified: vcweb/trunk/virtualcommons/experiment/teacher_dashboard/teacher_dashboard.module =================================================================== --- vcweb/trunk/virtualcommons/experiment/teacher_dashboard/teacher_dashboard.module 2008-08-18 06:44:06 UTC (rev 43) +++ vcweb/trunk/virtualcommons/experiment/teacher_dashboard/teacher_dashboard.module 2008-08-18 23:05:42 UTC (rev 44) @@ -47,7 +47,7 @@ function display_stage_data($game) { $all_stage_data = $game->getAllGroupRoundInfo(); $header_novoting=array('Round No','Group No', 'Group Harvest Decision','Resources Before','Resources After'); - $header_voting=array('Round No','Group No', 'Group Harvest Decision','Resources Before','Resources After', 'Dice', 'Rule #'); + $header_voting=array('Round No','Group No', 'Group Harvest Decision','Resources Before','Resources After', 'Rule #','Dice'); foreach ($all_stage_data as $stage_id => $stage_data) { $stage_no = $game->getStageNumber($stage_id); @@ -125,7 +125,7 @@ ); if($start_flag) { - drupal_get_messages(); + //drupal_get_messages(); drupal_set_message(t('This stage needs voting. Please tell students to vote.'),'warning',FALSE); $form['submit'] = array( '#type' => 'submit', @@ -205,8 +205,14 @@ { if(! $game->isRuleSelected()) { - $game->assign_Rules_To_Groups(); - $rule_no=$game->initRules(); + if($game->assign_Rules_To_Groups()) + { + $game->saveTie(); + } + else + { + $rule_no=$game->initRules(); + } } } else This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <see...@us...> - 2008-08-18 06:43:56
|
Revision: 43 http://virtualcommons.svn.sourceforge.net/virtualcommons/?rev=43&view=rev Author: seematalele Date: 2008-08-18 06:44:06 +0000 (Mon, 18 Aug 2008) Log Message: ----------- written code for rule 2 and rule 3 but needs to do testing. Modified Paths: -------------- vcweb/trunk/virtualcommons/experiment/experiment.inc vcweb/trunk/virtualcommons/experiment/games/forestry_v2/forestry_v2.module Modified: vcweb/trunk/virtualcommons/experiment/experiment.inc =================================================================== --- vcweb/trunk/virtualcommons/experiment/experiment.inc 2008-08-16 00:02:36 UTC (rev 42) +++ vcweb/trunk/virtualcommons/experiment/experiment.inc 2008-08-18 06:44:06 UTC (rev 43) @@ -319,7 +319,25 @@ $this->assessTurnSequenceFines($group_id); break; case 3: + $students=db_query("select id from vc_student where vc_group_id=%d",$group_id); + while($student_data=db_fetch_object($students)) + { + $result=db_query("Select id,harvest_decision,total_points from vc_forestry_student + where vc_student_id='%s' and round_no=%d ",$student_data->id,$this->getCurrentRoundNo()); + if($data=db_fetch_object($result)) + { + if($data->harvest_decision > 2) + { + $fine = $data->harvest_decision + 3; + $total_points = $data->total_points - $fine; + db_query('UPDATE vc_forestry_student SET fine=%d, total_points=%d + WHERE id=%d', $fine, $total_points, $data->id); + } + } + + } + break; default: form_set_error(t('Current rule number is invalid: ' . $current_rule_number)); @@ -425,11 +443,8 @@ { $this->updateStartFlag(true); } - - - - //update current round_no + //update current round_no $round_no=$round_no+1; $this->current_round_no = $round_no; @@ -578,12 +593,14 @@ // several ways to implement this - // 1. use array_rand to get a set of random keys into the array // 2. use shuffle and then take an array_slice from 0 to $how_many - 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(); + private function generateTurnSequence($how_many, $no_of_students,$rule_no) { + if($rule_no==1) + { + $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)) { @@ -594,6 +611,11 @@ // drupal_set_message($keys[$i]); $turn_sequence[] = $students[$keys[$i]]; } + } + else + { + + } return $turn_sequence; @@ -631,7 +653,7 @@ 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); + $turn_sequence_array=$this->generateTurnSequence($how_many, $no_of_student,$rule_no); //if $turn_sequence is an array then only implode with ',' else directly put the value in the database if($how_many <> 1) { @@ -662,14 +684,41 @@ case 4: case 5: $how_many = 2; - - - break; - default: + + if($round_no==1) + { + //For the first round initialise the turn sequence + $turn_sequence="1,2"; + } + else + { + $prev_round_no=$round_no-1; + $turn_seq=array(); + //get the sequnce number for the last round number, determine the sequence + $seq=db_query("Select turn_sequence from vc_forestry_turn_sequence where vc_game_id=%d and vc_group_id=%d and round_no=%d and vc_rules_id=%d",$this->game_id,$group_id,$prev_round_no,$selected_rule_id); + $temp_seq=explode(',',$seq); + $last_element=end($temp_seq); + for($j=0;$j<$how_many;$j++) + { + if($last_element<$no_of_student) + { + $turn_seq[]=$last_element++; + } + else + { + $turn_seq[]=1; + $last_element=1; + } + } + } + $turn_sequence = implode(',',$turn_seq); + 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); Modified: vcweb/trunk/virtualcommons/experiment/games/forestry_v2/forestry_v2.module =================================================================== --- vcweb/trunk/virtualcommons/experiment/games/forestry_v2/forestry_v2.module 2008-08-16 00:02:36 UTC (rev 42) +++ vcweb/trunk/virtualcommons/experiment/games/forestry_v2/forestry_v2.module 2008-08-18 06:44:06 UTC (rev 43) @@ -178,15 +178,18 @@ if($student->getGroup()->getGame()->isVotingEnabled()) { - if($student->isTurn()) - { - $form['turn']=array( - '#type'=>'item', - '#value'=>t('You have been chosen for this round. You can harvest.') + $rule_no=$group->getGame()->getCurrentRuleNumber($group->getId()); + if($rule_no<>3) + { + if($student->isTurn()) + { + $form['turn']=array( + '#type'=>'item', + '#value'=>t('You have been chosen for this round. You can harvest.') - ); - - } + ); + } + } } //store the round no in hidden field $form['round_no']=array( This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
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. |
From: <see...@us...> - 2008-08-15 00:15:05
|
Revision: 41 http://virtualcommons.svn.sourceforge.net/virtualcommons/?rev=41&view=rev Author: seematalele Date: 2008-08-15 00:15:12 +0000 (Fri, 15 Aug 2008) Log Message: ----------- Made some changes in experiment.inc and teacher_dashboard and forestry_v2.module in order to work stage transition smoothly. Rule 1 is working correctly. Modified Paths: -------------- vcweb/trunk/virtualcommons/experiment/experiment.inc vcweb/trunk/virtualcommons/experiment/experiment.module 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-14 00:12:32 UTC (rev 40) +++ vcweb/trunk/virtualcommons/experiment/experiment.inc 2008-08-15 00:15:12 UTC (rev 41) @@ -150,7 +150,7 @@ public function isVotingEnabled() { $flag=db_result(db_query("select s.voting from vc_stage s inner join vc_game g on s.id=g.vc_stage_id and g.id=%d", $this->game_id)); - drupal_set_message(t('Voting Flag is: '.$flag)); + // drupal_set_message(t('Voting Flag is: '.$flag)); return $flag; } @@ -158,11 +158,37 @@ return db_result(db_query("select voting from vc_stage where id=%d", $stage_id)); } - public function isVotingDone() + //determine if rule is selected for every group + public function isRuleSelected() { $count=db_result(db_query("select count(*) from vc_group where vc_game_id=%d and vc_selected_rules_id is null",$this->game_id)); return $count==0; } + //determine whether all students have done voting. + public function isVotingDone() + { + $flag=0; + $result_group_id=db_query("select id from vc_group where vc_game_id=%d",$this->game_id); + while($data=db_fetch_object($result_group_id)) + { + $stud_voting_cnt=db_result(db_query("select count(*) from vc_student_voting v where v.vc_student_id in (select id from vc_student where vc_group_id=%d)",$data->id)); + $actual_student=db_result(db_query(" select count(*) from vc_student where vc_group_id=%d",$data->id)); + // drupal_set_message(t('stud_voting_cnt: '. $stud_voting_cnt)); + //drupal_set_message(t('actual students are: '.$actual_student)); + if($stud_voting_cnt==$actual_student) + { + $flag=1; + } + else + { + $flag=0; + drupal_set_message(t('else Flag is: '.$flag)); + } + + } + drupal_set_message(t('isvotingDone Flag is: '.$flag)); + return $flag; + } // FIXME: turn into $forestryGame->init() overloaded method public function initForestry() { @@ -304,23 +330,27 @@ private function generate_default_decisions($group_id, $round_no, $stage_id) { $result = db_query('SELECT id FROM vc_student WHERE vc_group_id=%d', $group_id); - + drupal_get_messages(); while ($fetch_object = db_fetch_object($result)) { $student_id = $fetch_object->id; $harvest_decision = db_result(db_query("SELECT harvest_decision FROM vc_forestry_student WHERE vc_student_id='%s' AND round_no=%d AND vc_stage_id=%d", $student_id, $round_no, $stage_id)); - if (! $harvest_decision) { - $this->insert_default_decision($student_id, $round_no); + + drupal_set_message("harvest decision is submitted is student :" . $harvest_decision); + if ($harvest_decision == '') + { + drupal_set_message("if harvest decision is submitted is empty :" . $harvest_decision); + $this->insert_default_decision($student_id, $round_no,$stage_id); } } } - private function insert_default_decision($student_id, $round_no) { + private function insert_default_decision($student_id, $round_no,$stage_id) { // FIXME: how will this work for IrrigationStudent or FisheryStudent $student = new ForestryStudent($student_id); - $student->save($round_no, DEFAULT_HARVEST_DECISION); + $student->save($round_no, DEFAULT_HARVEST_DECISION, $stage_id); } @@ -368,7 +398,7 @@ } $selected_rule_id=db_result(db_query("select vc_selected_rules_id from vc_group where id=%d",$group_id)); // db_query("insert into {vc_forestry_group_round_info}(vc_rules_id,dice) values (%d,%d) where vc_game_id=%d and vc_stage_id=%d and vc_group_id=%d",$selected_rule_id,$dice,$this->game_id,$stage_id,$group_id); - $this->initRules(); + //$this->initRules(); db_query("Insert into {vc_forestry_group_round_info} (round_no,vc_game_id,vc_group_id,vc_stage_id,total_harvest_decision,resources_before,resources_after,vc_rules_id,dice) values(%d,%d,%d,%d,%d,%d,%d,%d,%d)", $round_no,$this->game_id,$group_id,$stage_id,$total_harvest_decision,$resources_before,$resources_available,$selected_rule_id,$dice); @@ -388,12 +418,12 @@ if (! $this->isLastRound()) { $this->updateStartFlag(true); } - $this->prev_round_no=$round_no; + // $this->prev_round_no=$round_no; //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)); + // 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 @@ -463,14 +493,15 @@ $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)) { - 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_group_id=%d and vc_game_id=%d",$data->max_resources,$data->vc_group_id,$this>game_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()); + } - + public function assign_Rules_To_Groups() + { //determine the rule for a group - - $result_group=db_query("select id from vc_group where vc_game_id=%d",$this->game_id); while($data=db_fetch_object($result_group)) { @@ -488,59 +519,66 @@ //$voting[$data->vc_rules_id]=$data->rule_cnt; } - //drupal_set_message(t('count of an array is :' . count($rule_cnt))); - for($i=0;$i<count($rule_cnt);$i++)//for1 + drupal_set_message(t('count of an array is :' . count($rule_cnt))); + if(count($rule_cnt)==1) { - for($j=$i+1;$j<count($rule_cnt);$j++)//for2 - { + $max_rule_cnt=$rule_cnt[0]; + $max_rule_id=$rule_id[0]; + drupal_set_message(t( 'NOT Tie' . '$max_rule_id: ' . $max_rule_id)); + db_query("update vc_group set vc_selected_rules_id =%d where id=%d",$max_rule_id,$group_id); + } + else + { + for($i=0;$i<count($rule_cnt);$i++)//for1 + { + for($j=$i+1;$j<count($rule_cnt);$j++)//for2 + { + if($rule_cnt[$i]<$rule_cnt[$j]) + { + if($max_rule_cnt < $rule_cnt[$j]) + { + $max_rule_cnt=$rule_cnt[$j]; + $max_rule_id=$rule_id[$j]; + drupal_set_message(t( '$max_rule_id is : ' . $rule_id[$j])); + } + } + else + { - - if($rule_cnt[$i]<$rule_cnt[$j]) - { - if($max_rule_cnt < $rule_cnt[$j]) - { - $max_rule_cnt=$rule_cnt[$j]; - $max_rule_id=$rule_id[$j]; - drupal_set_message(t( '$max_rule_id is : ' . $rule_id[$j])); - } - } - else - { - - if($rule_cnt[$i]==$rule_cnt[$j]) - { + if($rule_cnt[$i]==$rule_cnt[$j]) + { //echo '<br/>Equal $i ' . $i. ' $j ' .$j; - array_push($tie_rules,$rule_id[$i],$rule_id[$j]); - $tie_rule_cnt=$rule_cnt[$i]; - drupal_set_message(t('rule cnt i: '. $tie_rules[$i] . 'rule cnt j: '.$tie_rules[$j])); - } - else if($max < $rule_cnt[$i]) - { - $max_rule_cnt=$rule_cnt[$i]; - $max_rule_id=$rule_id[$i]; - drupal_set_message(t( '$max_rule_id is : ' . $rule_id[$i])); - } - } + array_push($tie_rules,$rule_id[$i],$rule_id[$j]); + $tie_rule_cnt=$rule_cnt[$i]; + drupal_set_message(t('rule cnt i: '. $tie_rules[$i] . 'rule cnt j: '.$tie_rules[$j])); + } + else if($max < $rule_cnt[$i]) + { + $max_rule_cnt=$rule_cnt[$i]; + $max_rule_id=$rule_id[$i]; + drupal_set_message(t( '$max_rule_id is : ' . $rule_id[$i])); + } + } - } + } - }//end of for1 - + }//end of for1 + //echo '<br/> Max: '. $max ; - drupal_set_message(t( '$max_rule_cnt is : ' . $max_rule_cnt)); - if(($max_rule_cnt==$tie_rule_cnt) || ($max_rule_cnt==0)) - { - drupal_set_message(t( 'Tie')); + drupal_set_message(t( '$max_rule_cnt is : ' . $max_rule_cnt)); + if(($max_rule_cnt==$tie_rule_cnt) || ($max_rule_cnt==0)) + { + drupal_set_message(t( 'Tie')); - } - else - { - drupal_set_message(t( 'NOT Tie' . '$max_rule_id: ' . $max_rule_id)); - db_query("update vc_group set vc_selected_rules_id =%d where id=%d",$max_rule_id,$group_id); - } + } + else + { + drupal_set_message(t( 'NOT Tie' . '$max_rule_id: ' . $max_rule_id)); + db_query("update vc_group set vc_selected_rules_id =%d where id=%d",$max_rule_id,$group_id); + } // drupal_set_message(t('Rule id : ' . $final_rule_id.'Group id is: ' . $group_id)); - + } }//end of while @@ -554,10 +592,16 @@ drupal_set_message("no of students need to be selected for this round are :" . $how_many); $keys = array_rand( range(1, $no_of_students), $how_many ); $turn_sequence = array(); - foreach ($keys as $key) { - $turn_sequence[] = $students[$key]; - } - return $turn_sequence; + + for($i=0;$i<count($keys);$i++) + { + drupal_set_message($students[$i]); + $turn_sequence[] = $students[$i]; + } + + + return $turn_sequence; + } public function initRules() @@ -786,25 +830,8 @@ db_result(db_query("select description select vc_selected_rules_id from vc_group where id=%d",$this->group_id)); }*/ - public function isTurn($stud_id) - { - $flag=FALSE; - if(!($this->isGameFinished())) - { - $valid_id=$this->game->getValidStudentIds($this->group_id); - drupal_set_message(t('Group id is : '. $this->group_id. 'Student Id is : '. $stud_id . ' Valid student ids are: ' . $valid_id[0] . ',' . $valid_id[1])); - if(in_array($stud_id,$valid_id)) - { - $flag= TRUE; - } - } - else - $flag= FALSE; - drupal_set_message(t('flag for student turn : '. $flag)); - return $flag; - } + - }//end of Group /** @@ -854,7 +881,7 @@ $stage_ids = $game->getAllStageIds(); $all_data = array(); foreach ($stage_ids as $stage_id) { - $all_data[] = $this->getStageData($stage_id); + $all_data[$stage_id][] = $this->getStageData($stage_id); } return $all_data; } @@ -941,15 +968,20 @@ } */ - public function save($round_no, $harvest_decision) + public function save($round_no, $harvest_decision,$stage_id=0) { - $stage_id = $this->getGroup()->getGame()->getCurrentStageId(); + drupal_set_message($stage_id); + if($stage_id <> 0) + { + // $stage_id = $this->getGroup()->getGame()->getCurrentStageId(); + } $total = db_result(db_query("SELECT sum(harvest_decision) FROM {vc_forestry_student} WHERE vc_student_id='%s' AND vc_stage_id=%d", $this->stud_id, $stage_id)); + $total=$total+$harvest_decision; db_query("INSERT INTO {vc_forestry_student} (round_no,vc_student_id,vc_stage_id,harvest_decision, total_points) VALUES (%d,'%s',%d,%d, %d)", $round_no,$this->stud_id,$stage_id,$harvest_decision, $total); } @@ -969,8 +1001,26 @@ return $this->getGroup()->getGame()->isVotingEnabled() && $this->getGroup()->isTieHappened(); } + + public function isTurn() + { + $flag=FALSE; + if(!($this->getGroup()->isGameFinished())) + { + $valid_id=$this->getGroup()->getGame()->getValidStudentIds($this->getGroup()->getId()); + drupal_set_message(t('Group id is : '. $this->group_id. 'Student Id is : '. $this->stud_id . ' Valid student ids are: ' . $valid_id[0] . ',' . $valid_id[1])); + if(in_array($this->stud_id,$valid_id)) + { + $flag= TRUE; + } + } + else + $flag= FALSE; + drupal_set_message(t('flag for student turn : '. $flag)); + return $flag; + } + - /* XXX: unsafe operation, should only be set by the facilitator (teacher) public function updateStageId($stage_no,$experiment_id,$game_id) { Modified: vcweb/trunk/virtualcommons/experiment/experiment.module =================================================================== --- vcweb/trunk/virtualcommons/experiment/experiment.module 2008-08-14 00:12:32 UTC (rev 40) +++ vcweb/trunk/virtualcommons/experiment/experiment.module 2008-08-15 00:15:12 UTC (rev 41) @@ -196,10 +196,10 @@ $form['#id']='studentgroup'; $game=Session::get('game'); $exp_name = $game->getExperimentName(); - drupal_set_message(t("experiment name: " . $exp_name)); +// drupal_set_message(t("experiment name: " . $exp_name)); $no_of_student = $game->getNumberOfStudents(); - drupal_set_message(t("num students: " . $no_of_student)); + //drupal_set_message(t("num students: " . $no_of_student)); $no_of_groups=0; $groups_3=0; $groups_4=0; @@ -319,7 +319,7 @@ $form['game_info']=array( '#type'=>'fieldset', - '#title'=>t('Experiment Information'), + '#title'=>t('<b>Experiment Information</b>'), '#tree' => TRUE ); @@ -332,7 +332,7 @@ $form['group_info']=array( '#type'=>'fieldset', - '#title'=>t('Group Information'), + '#title'=>t('<b>Group Information</b>'), '#tree' => TRUE ); Modified: vcweb/trunk/virtualcommons/experiment/games/forestry_v2/forestry_v2.module =================================================================== --- vcweb/trunk/virtualcommons/experiment/games/forestry_v2/forestry_v2.module 2008-08-14 00:12:32 UTC (rev 40) +++ vcweb/trunk/virtualcommons/experiment/games/forestry_v2/forestry_v2.module 2008-08-15 00:15:12 UTC (rev 41) @@ -96,16 +96,23 @@ function generate_all_results_table() { $student = Session::get('student'); $table_data_array = $student->getAllStageData(); - $result = '<fieldset><legend><b>Round Results</b></legend>'; + //$result = '<fieldset><legend><b>Round Results</b></legend>'; if ($student->getGroup()->getGame()->getCurrentRoundNo() == 1) { - $result .= 'No results available yet for the first round'; + $result = 'No results available yet for the first round'; } else { - foreach ($table_data_array as $table_data) { - $result .= theme_table($table_data->header, $table_data->rows); + foreach ($table_data_array as $stage_id=>$table_data) { + $stage_no = $student->getGroup()->getGame()->getStageNumber($stage_id); + $result.='<fieldset><legend><b>Stage '.$stage_no.'</b></legend>'; + foreach($table_data as $key=>$value) + { + + $result .= theme_table($value->header, $value->rows); + } + $result .= '</fieldset>'; } } - $result .= '</fieldset>'; +// $result .= '</fieldset>'; return $result; } @@ -136,7 +143,7 @@ } $group = $student->getGroup(); if ($group->getGame()->isFinished()) { - $output = 'The experiment is now over. Your results are listed below. Thanks for participating!'; + $output = '<br/><h3 align="center" style="color:#990000">The experiment is now over. Your results are listed below. Thanks for participating!</h3><br/>'; $output .= generate_all_results_table(); } else if ($student->shouldVote()) @@ -147,6 +154,7 @@ { $output .= generate_harvest_table(); $output .= generate_results_table(); + $output .= ( $student->canStart() ) ? drupal_get_form('forestry_play_multiform') : drupal_get_form('forestry_wait_form'); } return $output; @@ -167,6 +175,19 @@ $round_no = $group->getGame()->getCurrentRoundNo(); +if($student->getGroup()->getGame()->isVotingEnabled()) +{ + + if($student->isTurn()) + { + $form['turn']=array( + '#type'=>'item', + '#value'=>t('You have been chosen for this round. You can harvest.') + + ); + + } +} //store the round no in hidden field $form['round_no']=array( '#type'=>'hidden', @@ -302,37 +323,11 @@ $round_no=$form_values['round_no']; - /* - //get the student and set it - $stud_id=$_SESSION['student_id']; - $student=new ForestryStudent(); - $student->setStudentId($stud_id); - $stage_id=$group->getCurrentStageId(); - $resources_before=(int) $_SESSION['prev_resource']; - drupal_set_message(t('resource_before:'. $resources_before)); - $student->setStageId($stage_id); - */ - - - $student->save($round_no,$stud_harvest_decision); + + $student->save($round_no,$stud_harvest_decision,$group->getGame()->getCurrentStageId()); $student->updateStartFlag(false); return 'forestry/play'; - /* - $no_rounds=$group->getNumberOfRounds(); - if($form_values['indicator']['submit']=="Next Stage") - { - //$stage_no=2; - // $exp_id=$group->getExperimentId(); - //$game_id=$group->getGameId(); - drupal_set_message("in next stage button functionality"); - unset($_SESSION['prev_resource']); - - return 'rules'; - } - else - return 'forestry_stage1_part2'; - */ } function theme_forestry_play_multiform($form) Modified: vcweb/trunk/virtualcommons/experiment/teacher_dashboard/teacher_dashboard.module =================================================================== --- vcweb/trunk/virtualcommons/experiment/teacher_dashboard/teacher_dashboard.module 2008-08-14 00:12:32 UTC (rev 40) +++ vcweb/trunk/virtualcommons/experiment/teacher_dashboard/teacher_dashboard.module 2008-08-15 00:15:12 UTC (rev 41) @@ -103,9 +103,9 @@ else { if ($game->isVotingEnabled()) { - if (!($game->isVotingDone())) + if (!($game->isRuleSelected())) { - $stage_flag=TRUE; + $start_flag=TRUE; } } else @@ -123,7 +123,18 @@ '#value' => ($stage_flag) ? t('Go to Next Stage') : t('Next Round'), '#attributes' => array('onClick' => 'return confirm("Go to the next round? Any participants with unsubmitted harvest decisions will receive a default harvest decision.")') ); + if($start_flag) + { + drupal_set_message(t('This stage needs voting. Please tell students to vote.'),'warning',FALSE); + $form['submit'] = array( + '#type' => 'submit', + '#value' => t('Start Stage') + ); + // unset($_SESSION['next_stage']); + + } + } return $form; @@ -134,8 +145,8 @@ { // $virtual_conduct_id=(int) $form_values['game_id']; $game= Session::get('game'); - drupal_set_message(t($form_values['submit'])); - /* if($form_values['submit']=="Go to Next Stage") + // drupal_set_message(t($form_values['submit'])); + /* if($form_values['submit']=="Start Stage") { if (($game->isVotingEnabled())) { @@ -167,13 +178,12 @@ { //initialise the stage 2 - drupal_set_message(t('Go to stage 2')); + // drupal_set_message(t('Go to stage 2')); // FIXME: initNextStage is actually an initialization for voting stage - // remove that assumption - - $game->setRoundNo($game->getCurrentRoundNo()); $game->initNextStage(); - if ($game->isVotingEnabled()) + + /*if ($game->isVotingEnabled()) { if ($game->isVotingDone()) { @@ -182,10 +192,28 @@ else form_set_error('submit',t('Please tell students to vote. Without voting you can not proceed to Stage 2')); - } - + }*/ +// $_SESSION['next_stage']='pressed'; } + else if($form_values['submit']=="Start Stage") + { + if ($game->isVotingEnabled()) + { + if($game->isvotingDone()) + { + if(! $game->isRuleSelected()) + { + $game->assign_Rules_To_Groups(); + $rule_no=$game->initRules(); + } + } + else + form_set_error('submit',t('Please tell students to vote. Without voting you can not proceed to Stage 2')); + + } + //$game->is_Rule_Selected_For_All_Groups(); + } return 'teacher_dashboard'; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <al...@us...> - 2008-08-14 00:12:29
|
Revision: 40 http://virtualcommons.svn.sourceforge.net/virtualcommons/?rev=40&view=rev Author: alllee Date: 2008-08-14 00:12:32 +0000 (Thu, 14 Aug 2008) Log Message: ----------- Seema fixed some bugs in generate_results_table and harvest decision validation. Refined wait loops for students and next stage/next round logic. Modified Paths: -------------- vcweb/trunk/virtualcommons/experiment/experiment.inc vcweb/trunk/virtualcommons/experiment/experiment.module vcweb/trunk/virtualcommons/experiment/games/forestry_v2/forestry_v2.module vcweb/trunk/virtualcommons/experiment/rules/rules.module vcweb/trunk/virtualcommons/experiment/survey/survey.info vcweb/trunk/virtualcommons/experiment/survey/survey.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-13 09:32:34 UTC (rev 39) +++ vcweb/trunk/virtualcommons/experiment/experiment.inc 2008-08-14 00:12:32 UTC (rev 40) @@ -1,4 +1,7 @@ <?php +// FIXME: default decision should be a field in vc_game and configured +// by the facilitator +define('DEFAULT_HARVEST_DECISION', 0); class Session { public static function put($ses_var, $object) { @@ -233,9 +236,13 @@ } + public function isLastRound() + { + return ($this->getCurrentRoundNo() == $this->getNumberOfRounds()); + } + public function isStageOver() { - //drupal_set_message(t('Current round no is: ' .$this->getCurrentRoundNo() . ' and no of rounds are: ' .$this->getNumberOfRounds())); return ($this->getCurrentRoundNo() > $this->getNumberOfRounds()); } @@ -295,6 +302,28 @@ } + private function generate_default_decisions($group_id, $round_no, $stage_id) { + $result = db_query('SELECT id FROM vc_student WHERE vc_group_id=%d', $group_id); + + while ($fetch_object = db_fetch_object($result)) { + $student_id = $fetch_object->id; + $harvest_decision = db_result(db_query("SELECT harvest_decision + FROM vc_forestry_student + WHERE vc_student_id='%s' AND round_no=%d AND vc_stage_id=%d", + $student_id, $round_no, $stage_id)); + if (! $harvest_decision) { + $this->insert_default_decision($student_id, $round_no); + } + } + } + + private function insert_default_decision($student_id, $round_no) { + // FIXME: how will this work for IrrigationStudent or FisheryStudent + $student = new ForestryStudent($student_id); + $student->save($round_no, DEFAULT_HARVEST_DECISION); + } + + public function nextRound() { $round_no=$this->getCurrentRoundNo(); @@ -310,6 +339,7 @@ // FIXME: preprocess the groups and insert default decisions for // all students that haven't made a harvest decision. $group_id=$data->group_id; + $this->generate_default_decisions($group_id, $round_no, $stage_id); $resources_before=$crp=$data->crp; $max_resources=$data->max_r; @@ -355,7 +385,9 @@ } //update start flag - $this->updateStartFlag(true); + if (! $this->isLastRound()) { + $this->updateStartFlag(true); + } $this->prev_round_no=$round_no; //update current round_no @@ -598,7 +630,7 @@ return $this->student; } - public function getGroupId() { + public function getId() { return $this->group_id; } @@ -678,23 +710,14 @@ public function isTieHappened() { $selected_rule_id=db_result(db_query("select vc_selected_rules_id from vc_group where id=%d",$this->group_id)); - if($selected_rule_id ==NULL) - { - return true; - } - else - { - return false; - - } - + return ($selected_rule_id == NULL); } public function getSelectedRule() { $result_rule=db_query("select rule_no, description from vc_rules r, vc_group g where r.id =g.vc_selected_rules_id and g.id=%d",$this->group_id); //$rule=array(); - while($data_rule=db_fetch_object($result_rule)) + if ($data_rule=db_fetch_object($result_rule)) { $rule[]=array($data_rule->rule_no); $rule[]=array($data_rule->description); @@ -781,6 +804,7 @@ return $flag; } + }//end of Group /** @@ -792,11 +816,15 @@ private $turn_no; private $group; - public function __construct($student_id, $group) { + public function __construct($student_id, $group=NULL) { $this->stud_id = $student_id; $this->group = $group; } + public function getId() { + return $this->stud_id; + } + public function getLatestResource($group_id,$game_id) { return db_result(db_query("Select common_resource_pool from vc_forestry_common_resource_pool where vc_group_id=%d and vc_game_id=%d",$group_id,$game_id)); @@ -831,11 +859,19 @@ return $all_data; } + public function getCurrentStageData() { + return $this->getStageData($this->getGroup()->getGame()->getCurrentStageId()); + } + public function getStageData($stage_id) { $student_decision = db_query("select round_no,harvest_decision,fine,total_points from vc_forestry_student where vc_student_id='%s' and vc_stage_id=%d order by round_no",$this->stud_id,$stage_id); $decision_table = array(); $voting_enabled=db_result(db_query("select voting from vc_stage where id=%d",$stage_id)); + $round_header = array('Round Number', 'Your Harvest Decision', 'Resources Before', 'Resources After'); + if ($voting_enabled) { + array_push($round_header, 'Penalty', 'Total Points'); + } while($student_data=db_fetch_object($student_decision)) { $round_no=$student_data->round_no; @@ -843,21 +879,26 @@ $fine=$student_data->fine; $total_points=$student_data->total_points; //get the resource info from vc_forestry_group_round_information - $fetch_object = db_fetch_object(db_query("select resources_before,resources_after from vc_forestry_group_round_info where vc_group_id=%d and vc_game_id=%d and round_no=%d and vc_stage_id=%d", - $this->group->getGroupId(),$this->group->getGame()->getGameId(),$round_no,$stage_id)); + $fetch_object = db_fetch_object(db_query("SELECT resources_before,resources_after + FROM vc_forestry_group_round_info + WHERE vc_group_id=%d and vc_game_id=%d and round_no=%d and vc_stage_id=%d", + $this->group->getId(),$this->group->getGame()->getGameId(),$round_no,$stage_id)); if ($fetch_object) { $resources_before=$fetch_object->resources_before; $resources_after=$fetch_object->resources_after; } - $round_header = array('Round Number', 'Harvest Decision', 'Resources Before', 'Resources After'); - $round_data = array($round_no,$harvest_decision,$resources_before,$resources_after); + else { + $resources_before=$resources_after; + $resources_after="?"; + } + + $current_round_data = array($round_no,$harvest_decision,$resources_before,$resources_after); if($voting_enabled) { - array_push($round_data, $fine, $total_points); - array_push($round_header, 'Penalty', 'Total Points'); + array_push($current_round_data, $fine, $total_points); } - $decision_table[] = new TableData($round_header, $round_data); + $round_data[] = $current_round_data; } - return $decision_table; + return new TableData($round_header, $round_data); } /* @@ -923,6 +964,13 @@ return db_result(db_query("select start_flag from vc_student where id ='%s' ",$this->stud_id)); } + public function shouldVote() + { + return $this->getGroup()->getGame()->isVotingEnabled() + && $this->getGroup()->isTieHappened(); + } + + /* XXX: unsafe operation, should only be set by the facilitator (teacher) public function updateStageId($stage_no,$experiment_id,$game_id) { Modified: vcweb/trunk/virtualcommons/experiment/experiment.module =================================================================== --- vcweb/trunk/virtualcommons/experiment/experiment.module 2008-08-13 09:32:34 UTC (rev 39) +++ vcweb/trunk/virtualcommons/experiment/experiment.module 2008-08-14 00:12:32 UTC (rev 40) @@ -1,4 +1,5 @@ <?php + // vim:sts=2:sw=2:filetype=php // $Id$ Modified: vcweb/trunk/virtualcommons/experiment/games/forestry_v2/forestry_v2.module =================================================================== --- vcweb/trunk/virtualcommons/experiment/games/forestry_v2/forestry_v2.module 2008-08-13 09:32:34 UTC (rev 39) +++ vcweb/trunk/virtualcommons/experiment/games/forestry_v2/forestry_v2.module 2008-08-14 00:12:32 UTC (rev 40) @@ -93,8 +93,7 @@ return '<fieldset><legend><b>Maximum Harvest Table</b></legend>'.theme_table($harvest_table->header, $harvest_table->rows).'</fieldset>'; } - -function generate_results_table() { +function generate_all_results_table() { $student = Session::get('student'); $table_data_array = $student->getAllStageData(); $result = '<fieldset><legend><b>Round Results</b></legend>'; @@ -108,8 +107,25 @@ } $result .= '</fieldset>'; return $result; + } +function generate_results_table() { + $student = Session::get('student'); + $table_data = $student->getCurrentStageData(Round); + $result = '<fieldset><legend><b>Current Stage Results</b></legend>'; + if ($student->getGroup()->getGame()->getCurrentRoundNo() == 1) { + $result .= 'No results available yet for the first round'; + } + else { + $result .= theme_table($table_data->header, $table_data->rows); + } + $result .= '</fieldset>'; + return $result; +} + + + // primary forestry controller function forestry_play() { // Return the HTML generated from the $form data structure. @@ -121,9 +137,14 @@ $group = $student->getGroup(); if ($group->getGame()->isFinished()) { $output = 'The experiment is now over. Your results are listed below. Thanks for participating!'; - $output .= generate_results_table(); + $output .= generate_all_results_table(); } - else { + else if ($student->shouldVote()) + { + return drupal_get_form('voting_rules_form'); + } + else + { $output .= generate_harvest_table(); $output .= generate_results_table(); $output .= ( $student->canStart() ) ? drupal_get_form('forestry_play_multiform') : drupal_get_form('forestry_wait_form'); @@ -139,6 +160,8 @@ $student = Session::get('student'); $group = $student->getGroup(); + $resource_available=$group->getResourcesAvailable(); + $_SESSION['prev_resource']=$resource_available; $resource_after=0; $resource_before=0; @@ -155,10 +178,10 @@ '#title'=>t('<b>Round @number</b>',array('@number'=>$round_no)) ); -$form['indicator']['resources_available']=array( + $form['indicator']['resources_available']=array( '#type'=>'item', '#title'=>t('Resources Available'), - '#value'=>$group->getResourcesAvailable() + '#value'=>$resource_available ); @@ -181,7 +204,7 @@ -function forestry_play_multiform_validatewrong($form_id,$form_values) +function forestry_play_multiform_validate($form_id,$form_values) { $harvest_decision=$form_values['indicator']['harvest_decision']; $resource=(int) $_SESSION['prev_resource']; @@ -288,7 +311,7 @@ $resources_before=(int) $_SESSION['prev_resource']; drupal_set_message(t('resource_before:'. $resources_before)); $student->setStageId($stage_id); - */ + */ $student->save($round_no,$stud_harvest_decision); @@ -296,20 +319,20 @@ return 'forestry/play'; /* - $no_rounds=$group->getNumberOfRounds(); - if($form_values['indicator']['submit']=="Next Stage") - { - //$stage_no=2; - // $exp_id=$group->getExperimentId(); - //$game_id=$group->getGameId(); - drupal_set_message("in next stage button functionality"); - unset($_SESSION['prev_resource']); + $no_rounds=$group->getNumberOfRounds(); + if($form_values['indicator']['submit']=="Next Stage") + { + //$stage_no=2; + // $exp_id=$group->getExperimentId(); + //$game_id=$group->getGameId(); + drupal_set_message("in next stage button functionality"); + unset($_SESSION['prev_resource']); - return 'rules'; + return 'rules'; } else - return 'forestry_stage1_part2'; - */ + return 'forestry_stage1_part2'; + */ } function theme_forestry_play_multiform($form) @@ -362,7 +385,7 @@ { $student = Session::get('student'); $group = $student->getGroup(); - $group_id=$group->getGroupId(); + $group_id=$group->getId(); $game_id=$group->getGameId(); // FIXME: hack only in place for Drupal 5, can get rid of in Drupal 6 in // favor of the $repeat parameter in drupal_set_message @@ -372,18 +395,18 @@ making their decisions and the facilitator instructs you to click on the next button. Clicking on the next button before the facilitator is ready will have no effect.'), - 'warning', FALSE); + 'warning', FALSE); if ($group->isGameFinished()) { drupal_set_message(t('The game is over. Thanks for participating.'), - 'warning', FALSE); + 'warning', FALSE); } - else if($group->getGame()->isStageOver()) + else if($group->getGame()->isLastRound() || $group->getGame()->isStageOver()) { - drupal_set_message(t('This stage is now over.'), 'warning', FALSE); + drupal_set_message(t('This stage is now over. The next stage should begin shortly.'), 'warning', FALSE); $form['submit'] = array( '#type' => 'submit', - '#value' => t('Go to the next stage') + '#value' => t('Next Stage') ); } else Modified: vcweb/trunk/virtualcommons/experiment/rules/rules.module =================================================================== --- vcweb/trunk/virtualcommons/experiment/rules/rules.module 2008-08-13 09:32:34 UTC (rev 39) +++ vcweb/trunk/virtualcommons/experiment/rules/rules.module 2008-08-14 00:12:32 UTC (rev 40) @@ -1,131 +1,131 @@ <?php +// vim:filetype=php function rules_load() { - static $loaded = FALSE; - - if (!$loaded) { - $path = drupal_get_path('module', 'forestry_stage1'); - drupal_add_css($path .'/form.css'); - $loaded = TRUE; - } + static $loaded = FALSE; + + if (!$loaded) { + $path = drupal_get_path('module', 'forestry_stage1'); + drupal_add_css($path .'/form.css'); + $loaded = TRUE; + } } function rules_menu($may_cache) { $items = array(); if ($may_cache) { - -$items[]=array( 'path' => 'rules', - 'title' => t('Stage 2 - Rules'), - 'callback' => 'stage2_rules', - 'type'=>MENU_CALLBACK, + + $items[]=array( 'path' => 'rules', + 'title' => t('Rules'), + 'callback' => 'voting_rules', + 'type'=>MENU_CALLBACK, 'access' => TRUE//user_access('Only Teachers') ); } -else -{ -rules_load(); -} - + else + { + rules_load(); + } + return $items; } -function stage2_rules() { +function voting_rules() { // Return the HTML generated from the $form data structure. - $output = drupal_get_form('stage2_rulesform'); + $output = drupal_get_form('voting_rules_form'); return $output; } -function stage2_rulesform() +function voting_rules_form() { -$form['#id']='stage2_rules'; -$form['#tree'] = TRUE; -$stud_id=$_SESSION['student_id']; + $form['#id']='voting_rules'; + $form['#tree'] = TRUE; + $student = Session::get('student'); + $group = $student->getGroup(); -$group=Session::get('group'); + $rules=new Rules(); + $rules_data=$rules->getRules($group->getCurrentStageId()); -$rules=new Rules(); -$rules_data=$rules->getRules($group->getCurrentStageId()); + foreach($rules_data as $key=>$value) + { + drupal_set_message(t('$key is : ' . $key)); + $header[]='Rule '.$key; + $rule_no=$key; + foreach($value as $key=>$value1) + { + $final_row[0][$rule_no]=$value1; -foreach($rules_data as $key=>$value) -{ - drupal_set_message(t('$key is : ' . $key)); - $header[]='Rule '.$key; - $rule_no=$key; - foreach($value as $key=>$value1) - { - $final_row[0][$rule_no]=$value1; - - } + } -} + } -$form['resource']=array( - '#type'=>'fieldset', - '#title'=>t('<b>Rules</b>'), + $form['resource']=array( + '#type'=>'fieldset', + '#title'=>t('<b>Rules</b>'), - ); -$form['resource']['table']=array( - '#type'=>'markup', - '#value'=>theme('table',$header,$final_row) - ); + ); + $form['resource']['table']=array( + '#type'=>'markup', + '#value'=>theme('table',$header,$final_row) + ); -$form['indicator']=array( - '#type'=>'fieldset', - '#title'=>t('<b>Voting</b>'), - '#prefix'=>'<div class="indicator">' - ); + $form['indicator']=array( + '#type'=>'fieldset', + '#title'=>t('<b>Voting</b>'), + '#prefix'=>'<div class="indicator">' + ); -$form['indicator']['vote']=array( - '#type'=>'textfield', - '#title'=>t('Your Vote'), - '#default_value'=>'0', - '#size'=>1, - '#maxlength'=>1, - '#required'=>TRUE - ); + $form['indicator']['vote']=array( + '#type'=>'textfield', + '#title'=>t('Your Vote'), + '#default_value'=>'0', + '#size'=>1, + '#maxlength'=>1, + '#required'=>TRUE + ); - $form['indicator']['submit'] = array( - '#type' => 'submit', - '#value' => t('Vote!!!'), - '#suffix'=>'</div>' - ); + $form['indicator']['submit'] = array( + '#type' => 'submit', + '#value' => t('Vote'), + '#suffix'=>'</div>' + ); -return $form; + return $form; } -function stage2_rulesform_validate($form_id,$form_values) +function voting_rules_form_validate($form_id,$form_values) { - $vote=$form_values['indicator']['vote']; - if(preg_match('/[^1-3]+/',$vote)) - { - form_set_error('vote',t('Vote can not be alphabet or special character. It must be either 1, 2 or 3.')); - } - return; + $vote=$form_values['indicator']['vote']; + if(preg_match('/[^1-3]+/',$vote)) + { + form_set_error('vote',t('You must vote for Rule 1, 2 or 3.')); + } + return; } -function stage2_rulesform_submit($form,$form_values) +function voting_rules_form_submit($form,$form_values) { - $stud_id=$_SESSION['student_id']; - $rule_no=(int) $form_values['indicator']['vote']; - $group=Session::get('group'); - $rules=new Rules(); - $rules->saveStudentVoting($stud_id,$rule_no,$group->getCurrentStageId()); - - //$exp_name=db_result(db_query("select exp_name from virtualcommons_experiments where id in(select virtualcommons_experiments_id from virtualcommons_conducts where id in (select virtualcommons_conducts_id from virtualcommons_student where id='%s'))",$_SESSION['student_id'])); - //$virtual_conduct_id=db_result(db_query("select virtualcommons_conducts_id from virtualcommons_student where id='%s' ",$stud_id)); - //db_query("update virtualcommons_conducts set virtualcommons_rule_no=%d where id=%d",$rule_no,$virtual_conduct_id); - - return 'survey'; - - + $rule_no=(int) $form_values['indicator']['vote']; + $student = Session::get('student'); + $group=$student->getGroup(); + $rules=new Rules(); + $rules->saveStudentVoting($student->getId(),$rule_no,$group->getCurrentStageId()); + //$exp_name=db_result(db_query("select exp_name from virtualcommons_experiments where id in(select virtualcommons_experiments_id from virtualcommons_conducts where id in (select virtualcommons_conducts_id from virtualcommons_student where id='%s'))",$_SESSION['student_id'])); + //$virtual_conduct_id=db_result(db_query("select virtualcommons_conducts_id from virtualcommons_student where id='%s' ",$stud_id)); + //db_query("update virtualcommons_conducts set virtualcommons_rule_no=%d where id=%d",$rule_no,$virtual_conduct_id); + + return 'survey'; + + + } Modified: vcweb/trunk/virtualcommons/experiment/survey/survey.info =================================================================== --- vcweb/trunk/virtualcommons/experiment/survey/survey.info 2008-08-13 09:32:34 UTC (rev 39) +++ vcweb/trunk/virtualcommons/experiment/survey/survey.info 2008-08-14 00:12:32 UTC (rev 40) @@ -1,4 +1,4 @@ -; $Id: rules.info 17 2008-07-30 22:56:29Z alllee $ +; $Id: survey.info 17 2008-07-30 22:56:29Z alllee $ name = Survey For The Games description = Allows student to fill the survey after voting for the rules. package=Virtual Commons Modified: vcweb/trunk/virtualcommons/experiment/survey/survey.module =================================================================== --- vcweb/trunk/virtualcommons/experiment/survey/survey.module 2008-08-13 09:32:34 UTC (rev 39) +++ vcweb/trunk/virtualcommons/experiment/survey/survey.module 2008-08-14 00:12:32 UTC (rev 40) @@ -1,5 +1,5 @@ <?php -//vim:sts=2:sw=2:filetype=php +// vim:sts=2:sw=2:filetype=php function rule_decision_load() { @@ -22,6 +22,12 @@ 'type'=>MENU_CALLBACK, 'access' => TRUE//user_access('Only Teachers') ); + $items[]=array( 'path' => 'voting/wait', + // 'title' => t('Rule Decision'), + 'callback' => 'voting_wait', + 'type'=>MENU_CALLBACK, + 'access' => TRUE//user_access('Only Teachers') + ); $items[]=array( 'path' => 'rule_decision', // 'title' => t('Rule Decision'), 'callback' => 'voting_rule_decision', @@ -52,14 +58,12 @@ { $form['#id']='survey_form'; $form['#tree'] = TRUE; - $stud_id=$_SESSION['student_id']; + $student = Session::get('student'); + $group = $student->getGroup(); - //$group=Session::get('group'); - - //$exp_id=$group->getExperimentId(); + $exp_id=$group->getExperimentId(); $survey=new Survey(); - $exp_id=2; $survey_data=$survey->getSurveyQuestions($exp_id); $_SESSION['survey_data']=$survey_data; $header[]='Survey Questions'; @@ -72,31 +76,26 @@ foreach($Q_array as $Q=>$ans) { - $form['resource'][$rule][$Q]['option']=array( '#type'=>'radios', '#title'=>t('<b>Q'. ++$Q_cnt . '. '. $Q.'</b>'), '#options'=>$ans, '#required'=>TRUE - ); } } - $form['submit'] = array( '#type' => 'submit', - '#value' => t('Submit!!!'), - + '#value' => t('Submit'), ); - return $form; } function survey_form_submit($form,$form_values) { - $stud_id=$_SESSION['student_id']; - $group=Session::get('group'); + $student = Session::get('student'); + $group=$student->getGroup(); $survey=new Survey(); // $rules->saveStudentSurvey($stud_id,$ans); @@ -108,30 +107,22 @@ foreach($Q_array as $Q=>$ans) { // drupal_set_message(t('Question is: '. $Q . 'answers are:'. $ans[$form_values['resource'][$rule][$Q]['option']])); - $survey->saveSurveyResponse($stage_id,$stud_id,$rule,$Q,$ans[$form_values['resource'][$rule][$Q]['option']]); + $survey->saveSurveyResponse($stage_id,$student->getId(),$rule,$Q,$ans[$form_values['resource'][$rule][$Q]['option']]); $i++; } } - - /*if($exp_name=='Forestry Game') - { - return 'forestry'; - } - - else if($exp_name=='Fishery Game') - { - return 'fishery'; - } - - else if($exp_name=='Water Irrigation Game') - { - return 'water'; - - }*/ - return 'rule_decision'; - +// FIXME: should be smarter about detecting whether or not teachers voted and +// send student into a wait loop until the teacher has processed votes. +// Otherwise a bug occurs if the student finishes voting and the survey before +// the teacher has processed votes +// if ($group->all_students_voted()) { + return 'rule_decision'; + // } + // else { + // return 'voting/wait'; + //} } @@ -148,8 +139,8 @@ function rule_decision_form() { - $stud_id=$_SESSION['student_id']; - $group=Session::get('group'); + $student=Session::get('student'); + $group=$student->getGroup(); $tie_flag=$group->isTieHappened(); //t('There is a tie between votings. You need to vote again for the following rules') if($tie_flag) @@ -211,22 +202,17 @@ $form['submit'] = array( '#type' => 'submit', '#value' => t('Next') - ); - } - } - return $form; - } function rule_decision_form_validate($form_id,$form_values) { $vote=$form_values['vote']; - if($form_vlaues['submit']=="Vote") + if($form_values['submit']=="Vote") { if(preg_match('/[^1-3]+/',$vote)) @@ -247,17 +233,12 @@ } else if($form_values['submit']=="Vote") { - $stud_id=$_SESSION['student_id']; + $student=Session::get('student'); + $group=$student->getGroup(); $rule_no=(int) $form_values['vote']; - drupal_set_message(t('student id: '. $stud_id . 'rule no is: ' . $rule_no)); - $group=Session::get('group'); $rules=new Rules(); - $rules->saveStudentVoting($stud_id,$rule_no,$group->getCurrentStageId()); + $rules->saveStudentVoting($student->getId(),$rule_no,$group->getCurrentStageId()); } - return 'forestry'; - - - - - + // FIXME: return to the appropriate experiment + return 'forestry/intro'; } Modified: vcweb/trunk/virtualcommons/experiment/teacher_dashboard/teacher_dashboard.module =================================================================== --- vcweb/trunk/virtualcommons/experiment/teacher_dashboard/teacher_dashboard.module 2008-08-13 09:32:34 UTC (rev 39) +++ vcweb/trunk/virtualcommons/experiment/teacher_dashboard/teacher_dashboard.module 2008-08-14 00:12:32 UTC (rev 40) @@ -120,7 +120,8 @@ $form['submit'] = array( '#type' => 'submit', - '#value' => ($stage_flag) ? t('Go to Next Stage') : t('Next Round') + '#value' => ($stage_flag) ? t('Go to Next Stage') : t('Next Round'), + '#attributes' => array('onClick' => 'return confirm("Go to the next round? Any participants with unsubmitted harvest decisions will receive a default harvest decision.")') ); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <al...@us...> - 2008-08-13 09:32:26
|
Revision: 39 http://virtualcommons.svn.sourceforge.net/virtualcommons/?rev=39&view=rev Author: alllee Date: 2008-08-13 09:32:34 +0000 (Wed, 13 Aug 2008) Log Message: ----------- refactoring forestry_v2 module and experiment.inc classes heavily. still need to fix the generate_results_table and getAllStageData() methods. Modified Paths: -------------- vcweb/trunk/virtualcommons/experiment/experiment.inc vcweb/trunk/virtualcommons/experiment/games/forestry_v2/forestry_v2.module vcweb/trunk/virtualcommons/experiment/student_login/student_login.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-11 23:16:36 UTC (rev 38) +++ vcweb/trunk/virtualcommons/experiment/experiment.inc 2008-08-13 09:32:34 UTC (rev 39) @@ -18,7 +18,16 @@ } } +class TableData { + public $header; + public $rows; + public function __construct($header, $rows) { + $this->header = $header; + $this->rows = $rows; + } +} + class Game { private $game_id; private $teacher_id; @@ -48,6 +57,18 @@ return $this->no_of_students; } + public function getAllStageIds() { + $result = db_query('SELECT s.id FROM vc_stage s + INNER JOIN vc_experiment e ON s.vc_experiment_id=e.id + INNER JOIN vc_game g ON e.id=g.vc_experiment_id + WHERE g.id=%d ORDER BY s.stage_no', $this->game_id); + $stage_ids = array(); + while ($fetch_object = db_fetch_object($result)) { + $stage_ids[] = $fetch_object->id; + } + return $stage_ids; + } + // FIXME: remove current_stage_no from this session object since it is // unsafe if the browser exits public function getStageId($current_stage_no) { @@ -206,23 +227,23 @@ public function isFinished() { $max_stage_number = db_result(db_query('SELECT max(stage_no) - FROM vc_stage s inner join vc_game g on s.vc_experiment_id=g.vc_experiment_id - WHERE g.id=%d', $this->game_id)); + FROM vc_stage s inner join vc_game g on s.vc_experiment_id=g.vc_experiment_id + WHERE g.id=%d', $this->game_id)); return $this->isStageOver() && ($max_stage_number == $this->getCurrentStageNumber()); } public function isStageOver() { - drupal_set_message(t('Current round no is: ' .$this->getCurrentRoundNo() . ' and no of rounds are: ' .$this->getNumberOfRounds())); - return ($this->getCurrentRoundNo() - 1 == $this->getNumberOfRounds()); + //drupal_set_message(t('Current round no is: ' .$this->getCurrentRoundNo() . ' and no of rounds are: ' .$this->getNumberOfRounds())); + return ($this->getCurrentRoundNo() > $this->getNumberOfRounds()); } public function getTurnSequence($group_id) { return db_result(db_query('select turn_sequence - FROM vc_forestry_turn_sequence s, vc_group gr, vc_game ga - WHERE s.vc_group_id=%d AND ga.id=gr.vc_game_id AND ga.current_round_no=s.round_no AND s.vc_rules_id=gr.vc_selected_rules_id', - $group_id)); + FROM vc_forestry_turn_sequence s, vc_group gr, vc_game ga + WHERE s.vc_group_id=%d AND ga.id=gr.vc_game_id AND ga.current_round_no=s.round_no AND s.vc_rules_id=gr.vc_selected_rules_id', + $group_id)); } public function getValidStudentIds($group_id) { @@ -236,7 +257,7 @@ $valid_ids[] = $data->id; drupal_set_message(t($data->id. ' , ')); } - + return $valid_ids; } @@ -245,9 +266,9 @@ $result = db_query('SELECT fs.id, fs.harvest_decision, fs.total_points FROM vc_forestry_student fs INNER JOIN vc_student s ON fs.vc_student_id=s.id WHERE fs.harvest_decision > 0 - AND s.vc_group_id=%d - AND fs.round_no=%d - AND s.turn_no NOT IN (%s)', $group_id, $this->getCurrentRoundNo(), $turn_sequence); + AND s.vc_group_id=%d + AND fs.round_no=%d + AND s.turn_no NOT IN (%s)', $group_id, $this->getCurrentRoundNo(), $turn_sequence); while ($data = db_fetch_object($result)) { $fine = $data->harvest_decision + 3; $dice = 6; @@ -289,17 +310,7 @@ // FIXME: preprocess the groups and insert default decisions for // all students that haven't made a harvest decision. $group_id=$data->group_id; - $current_rule_number = $this->getCurrentRuleNumber($group_id); - if ($voting_enabled) { - // roll the dice - $dice = rand(1, 6); - $dice = 6; - if ($dice == 6) { - // check to see if we need to assess fines - $this->assessFines($group_id, $current_rule_number); - - } - } + $resources_before=$crp=$data->crp; $max_resources=$data->max_r; $total_harvest_decision = db_result(db_query("select sum(harvest_decision) @@ -313,9 +324,32 @@ } //insert into group-round info - db_query("Insert into {vc_forestry_group_round_info} (round_no,vc_game_id,vc_group_id,vc_stage_id,total_harvest_decision,resources_before,resources_after) - values(%d,%d,%d,%d,%d,%d,%d)", - $round_no,$this->game_id,$group_id,$stage_id,$total_harvest_decision,$resources_before,$resources_available); + $current_rule_number = $this->getCurrentRuleNumber($group_id); + if ($voting_enabled) + { + // roll the dice + $dice = rand(1, 6); + // $dice = 6; + if ($dice == 6) + { + // check to see if we need to assess fines + $this->assessFines($group_id, $current_rule_number); + + } + $selected_rule_id=db_result(db_query("select vc_selected_rules_id from vc_group where id=%d",$group_id)); + // db_query("insert into {vc_forestry_group_round_info}(vc_rules_id,dice) values (%d,%d) where vc_game_id=%d and vc_stage_id=%d and vc_group_id=%d",$selected_rule_id,$dice,$this->game_id,$stage_id,$group_id); + $this->initRules(); + db_query("Insert into {vc_forestry_group_round_info} (round_no,vc_game_id,vc_group_id,vc_stage_id,total_harvest_decision,resources_before,resources_after,vc_rules_id,dice) + values(%d,%d,%d,%d,%d,%d,%d,%d,%d)", + $round_no,$this->game_id,$group_id,$stage_id,$total_harvest_decision,$resources_before,$resources_available,$selected_rule_id,$dice); + + } + else + { + db_query("Insert into {vc_forestry_group_round_info} (round_no,vc_game_id,vc_group_id,vc_stage_id,total_harvest_decision,resources_before,resources_after) + values(%d,%d,%d,%d,%d,%d,%d)", + $round_no,$this->game_id,$group_id,$stage_id,$total_harvest_decision,$resources_before,$resources_available); + } //update forestry common pool db_query("update {vc_forestry_common_resource_pool} set common_resource_pool=%d where vc_game_id=%d and vc_group_id=%d",$resources_available,$this->game_id,$group_id); } @@ -348,14 +382,19 @@ $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());*/ + $this->setRoundNo($this->getCurrentRoundNo());*/ } public function setRoundNo($round_no) { - //drupal_set_mesage(t('Round is : ' . $round_no)); + //drupal_set_mesage(t('Round is : ' . $round_no)); if ($round_no > ($this->getNumberOfRounds())) { // reset round number to 1 $this->current_round_no = 1; @@ -388,19 +427,21 @@ { //reset the forestry common resource pool + $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)) { - 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_group_id=%d and vc_game_id=%d",$data->max_resources,$data->vc_group_id,$this>game_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 ); } + //determine the rule for a group - - $result_group=db_query("select id from vc_group where vc_game_id=%d",$this->game_id); - while($data=db_fetch_object($result_group)) - { + + $result_group=db_query("select id from vc_group where vc_game_id=%d",$this->game_id); + while($data=db_fetch_object($result_group)) + { $group_id=$data->id; //$result_voting=db_query("select vc_rules_id,count(vc_rules_id) as rule_cnt from vc_student_voting where vc_student_id in (select id from vc_student where vc_group_id=%d) group by vc_rules_id",$group_id); $result_voting=db_query(" select vc_rules_id, count(vc_rules_id) as rule_cnt from vc_student_voting v @@ -428,7 +469,7 @@ { $max_rule_cnt=$rule_cnt[$j]; $max_rule_id=$rule_id[$j]; - drupal_set_message(t( '$max_rule_id is : ' . $rule_id[$j])); + drupal_set_message(t( '$max_rule_id is : ' . $rule_id[$j])); } } else @@ -439,13 +480,13 @@ //echo '<br/>Equal $i ' . $i. ' $j ' .$j; array_push($tie_rules,$rule_id[$i],$rule_id[$j]); $tie_rule_cnt=$rule_cnt[$i]; - drupal_set_message(t('rule cnt i: '. $tie_rules[$i] . 'rule cnt j: '.$tie_rules[$j])); + drupal_set_message(t('rule cnt i: '. $tie_rules[$i] . 'rule cnt j: '.$tie_rules[$j])); } else if($max < $rule_cnt[$i]) { $max_rule_cnt=$rule_cnt[$i]; $max_rule_id=$rule_id[$i]; - drupal_set_message(t( '$max_rule_id is : ' . $rule_id[$i])); + drupal_set_message(t( '$max_rule_id is : ' . $rule_id[$i])); } } @@ -469,8 +510,8 @@ // drupal_set_message(t('Rule id : ' . $final_rule_id.'Group id is: ' . $group_id)); }//end of while - + }//end of init function // several ways to implement this - @@ -478,6 +519,7 @@ // 2. use shuffle and then take an array_slice from 0 to $how_many 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_rand( range(1, $no_of_students), $how_many ); $turn_sequence = array(); foreach ($keys as $key) { @@ -546,11 +588,16 @@ private $group_no; private $no_of_students; private $experiment_id; + private $student; public function getNumberOfStudents() { return $this->no_of_students; } + public function getStudent() { + return $this->student; + } + public function getGroupId() { return $this->group_id; } @@ -569,7 +616,22 @@ } } + public function generate_harvest_table() { + $number_of_players = $this->no_of_students; + $result = db_query("SELECT min_resource_level,max_resource_level,individual_harvest_level from {vc_forestry_${number_of_players}player_harvest_table}"); + while($harvest_data=db_fetch_object($result)) + { + $min=$harvest_data->min_resource_level; + $max=$harvest_data->max_resource_level; + $ind=$harvest_data->individual_harvest_level; + $data[]=array($min.' - '.$max,$ind); + } + return new TableData(array('Resource Level', 'Maximum Harvest Decision'), $data); + } + + + public function getTurnSequence() { return $this->game->getTurnSequence($this->group_id); } @@ -599,8 +661,8 @@ $group->game = new Game($group->game_id); $group->group_id = $fetch_object->group_id; $group->no_of_students = db_result(db_query("SELECT count(*) FROM vc_student WHERE vc_group_id=%d", $group->group_id)); - drupal_set_message( t('generating a new game for group with game_id: '.$group->game->getGameId() . ':'.$group->group_id) ); - return $group; + $group->student = new ForestryStudent($studentId, $group); + return $group->student; } return false; } @@ -673,42 +735,50 @@ } //drupal_set_message(t('Rule no : ' . $final_rule_no[0].' ' .$final_rule_no[1]. 'Group id is: ' . $this->group_id)); return $final_rule_no; + } + public function getResourcesAvailable() { + return db_result(db_query('SELECT common_resource_pool + FROM vc_forestry_common_resource_pool + WHERE vc_group_id=%d', $this->group_id)); } -public function isGameFinished() -{ -return $this->game->isFinished(); + public function getMaximumResourcesAvailable() { + return db_result(db_query('SELECT max_resources + FROM vc_forestry_common_resource_pool + WHERE vc_group_id=%d', $this->group_id)); + } -} + public function isGameFinished() + { + return $this->game->isFinished(); + } -public function isStageOver() -{ -drupal_set_message(t('$this->game->getCurrentRoundNo(): ' . $this->game->getCurrentRoundNo() . ' $this->game->getNumberOfRounds()'. $this->game->getNumberOfRounds())); - return ($this->game->getCurrentRoundNo() -1 == $this->game->getNumberOfRounds()); -} -public function getRoundNo() -{ + public function getRoundNo() + { return $this->game->getCurrentRoundNo(); -} + } /*public function getRuleDescription() { db_result(db_query("select description select vc_selected_rules_id from vc_group where id=%d",$this->group_id)); }*/ -public function isTurn($stud_id) + public function isTurn($stud_id) { - $valid_id=$this->game->getValidStudentIds($this->group_id); - $flag=FALSE; - drupal_set_message(t('Group id is : '. $this->group_id. 'Student Id is : '. $stud_id . ' Valid student ids are: ' . $valid_id[0] . ',' . $valid_id[1])); - if(in_array($stud_id,$valid_id)) - { - $flag= TRUE; - } - else - $flag= FALSE; - drupal_set_message(t('flag for student turn : '. $flag)); - return $flag; + $flag=FALSE; + if(!($this->isGameFinished())) + { + $valid_id=$this->game->getValidStudentIds($this->group_id); + drupal_set_message(t('Group id is : '. $this->group_id. 'Student Id is : '. $stud_id . ' Valid student ids are: ' . $valid_id[0] . ',' . $valid_id[1])); + if(in_array($stud_id,$valid_id)) + { + $flag= TRUE; + } + } + else + $flag= FALSE; + drupal_set_message(t('flag for student turn : '. $flag)); + return $flag; } }//end of Group @@ -718,12 +788,14 @@ */ class ForestryStudent { - private $round_no; private $stud_id; - private $stage_id; - private $harvest_decision; private $turn_no; + private $group; + public function __construct($student_id, $group) { + $this->stud_id = $student_id; + $this->group = $group; + } public function getLatestResource($group_id,$game_id) { @@ -735,33 +807,70 @@ return $this->turn_no; } - public function setStudentId($stud_id) - { - $this->stud_id=$stud_id; - } - public function setStageId($stage_id) - { - $this->stage_id=$stage_id; + public function getGroup() { + return $this->group; } - - /* public function getRoundNo($game_id,$stage_id) - { - //$this-> - return db_result(db_query("select current_round_no from vc_game where id=%d and vc_stage_id=%d",$game_id,$stage_id)); - //drupal_set_message(t('round no is:' .$stage_id . $this->round_no . $game_id)); -// return $this->round_no; + /* public function getRoundNo($game_id,$stage_id) + { + //$this-> + return db_result(db_query("select current_round_no from vc_game where id=%d and vc_stage_id=%d",$game_id,$stage_id)); + + //drupal_set_message(t('round no is:' .$stage_id . $this->round_no . $game_id)); + // return $this->round_no; }*/ + public function getAllStageData() { + $game = $this->group->getGame(); + $stage_ids = $game->getAllStageIds(); + $all_data = array(); + foreach ($stage_ids as $stage_id) { + $all_data[] = $this->getStageData($stage_id); + } + return $all_data; + } + + public function getStageData($stage_id) { + $student_decision = db_query("select round_no,harvest_decision,fine,total_points from vc_forestry_student where vc_student_id='%s' and vc_stage_id=%d order by round_no",$this->stud_id,$stage_id); + $decision_table = array(); + $voting_enabled=db_result(db_query("select voting from vc_stage where id=%d",$stage_id)); + + while($student_data=db_fetch_object($student_decision)) + { + $round_no=$student_data->round_no; + $harvest_decision=$student_data->harvest_decision; + $fine=$student_data->fine; + $total_points=$student_data->total_points; + //get the resource info from vc_forestry_group_round_information + $fetch_object = db_fetch_object(db_query("select resources_before,resources_after from vc_forestry_group_round_info where vc_group_id=%d and vc_game_id=%d and round_no=%d and vc_stage_id=%d", + $this->group->getGroupId(),$this->group->getGame()->getGameId(),$round_no,$stage_id)); + if ($fetch_object) { + $resources_before=$fetch_object->resources_before; + $resources_after=$fetch_object->resources_after; + } + $round_header = array('Round Number', 'Harvest Decision', 'Resources Before', 'Resources After'); + $round_data = array($round_no,$harvest_decision,$resources_before,$resources_after); + if($voting_enabled) { + array_push($round_data, $fine, $total_points); + array_push($round_header, 'Penalty', 'Total Points'); + } + $decision_table[] = new TableData($round_header, $round_data); + } + return $decision_table; + } + + /* public function getForestryStudentInfo($group_id,$game_id,$stage_id) { - $student_decision=db_query("select round_no,harvest_decision from vc_forestry_student where vc_student_id= '%s' and vc_stage_id=%d ",$this->stud_id,$stage_id); + $student_decision=db_query("select round_no,harvest_decision,fine,total_points from vc_forestry_student where vc_student_id= '%s' and vc_stage_id=%d ",$this->stud_id,$stage_id); while($student_data=db_fetch_object($student_decision)) { $round_no=$student_data->round_no; $harvest_decision=$student_data->harvest_decision; - $round_no=(int)$round_no; + $round_no=(int)$round_no; + $fine=$student_data->fine; + $total_points=$student_data->total_points; //get the resource info from vc_forestry_group_round_information $resource_info= db_query("select resources_before,resources_after from vc_forestry_group_round_info where vc_group_id=%d and vc_game_id=%d and round_no=%d and vc_stage_id=%d",$group_id,$game_id,$round_no,$stage_id); while($data_resource=db_fetch_object($resource_info)) @@ -769,23 +878,39 @@ $resources_before=$data_resource->resources_before; $resources_after=$data_resource->resources_after; } - $final_row[]=array($round_no,$harvest_decision,$resources_before,$resources_after); + + $flag=db_result(db_query("select voting from vc_stage where id=%d",$stage_id)); + drupal_set_message(t('flag for voting is: '. $flag)); + drupal_set_message(t('fine is: '. $fine . ' and total_points are: '.$total_points)); + if($flag) + $final_row[]=array($round_no,$harvest_decision,$resources_before,$resources_after,$fine,$total_points); + else + $final_row[]=array($round_no,$harvest_decision,$resources_before,$resources_after); + //array_push($final_row,$fine,$total_points); } $this->round_no=$round_no; + /* foreach($final_row as $key=>$value) + { + foreach($value as $key1=>$value1) + + drupal_set_message(t('data for the prev round is: '. $value1)); + } + return $final_row; - } + */ - public function saveForestryStudentInfo($round_no,$stud_harvest_decision) + public function save($round_no, $harvest_decision) { + $stage_id = $this->getGroup()->getGame()->getCurrentStageId(); $total = db_result(db_query("SELECT sum(harvest_decision) FROM {vc_forestry_student} WHERE vc_student_id='%s' - AND vc_stage_id=%d", - $this->stud_id, - $this->stage_id)); - db_query("Insert into {vc_forestry_student} (round_no,vc_student_id,vc_stage_id,harvest_decision, total_points) values(%d,'%s',%d,%d, %d)", - $round_no,$this->stud_id,$this->stage_id,$stud_harvest_decision, $total); + AND vc_stage_id=%d", + $this->stud_id, + $stage_id)); + db_query("INSERT INTO {vc_forestry_student} (round_no,vc_student_id,vc_stage_id,harvest_decision, total_points) VALUES (%d,'%s',%d,%d, %d)", + $round_no,$this->stud_id,$stage_id,$harvest_decision, $total); } public function updateStartFlag($flag) @@ -793,17 +918,19 @@ db_query("update vc_student set start_flag=%d where id ='%s' ",$flag,$this->stud_id); } - public function getStartFlag() + public function canStart() { return db_result(db_query("select start_flag from vc_student where id ='%s' ",$this->stud_id)); } + /* XXX: unsafe operation, should only be set by the facilitator (teacher) public function updateStageId($stage_no,$experiment_id,$game_id) { db_query("update vc_game set vc_stage_id=(select id from vc_stage where stage_no= %d and vc_experiment_id=%d) where id=%d;",$stage_no,$experiment_id,$game_id); } - + */ + } class Rules @@ -811,7 +938,7 @@ public function getRules($stage_id) { - drupal_set_message(t('current stage is : ' . $stage_id)); + drupal_set_message(t('current stage is : ' . $stage_id)); $result=db_query("Select rule_no,description from vc_rules where vc_stage_id=%d",$stage_id ); while($data=db_fetch_object($result)) { Modified: vcweb/trunk/virtualcommons/experiment/games/forestry_v2/forestry_v2.module =================================================================== --- vcweb/trunk/virtualcommons/experiment/games/forestry_v2/forestry_v2.module 2008-08-11 23:16:36 UTC (rev 38) +++ vcweb/trunk/virtualcommons/experiment/games/forestry_v2/forestry_v2.module 2008-08-13 09:32:34 UTC (rev 39) @@ -15,29 +15,20 @@ function forestry_v2_menu($may_cache) { $items = array(); if ($may_cache) { - $items[] = array('path' => 'forestry', + $items[] = array('path' => 'forestry/intro', 'title' => t('Forestry Game'), - 'callback' => 'forestry_v2_page', + 'callback' => 'forestry_intro', 'type'=>MENU_CALLBACK, 'access' => TRUE//user_access('Only Teachers') ); - - //forestry stage 1 menu - $items[]=array( 'path' => 'forestry_stage1', - 'title' => t('Forestry Game - Stage 1'), - 'callback' => 'forestry_game_stage1', + $items[]=array( 'path' => 'forestry/play', + 'title' => t('Forestry Game - Round Active'), + 'callback' => 'forestry_play', //'callback arguments'=>array(forestry_game_stage1_multiform), 'type'=>MENU_CALLBACK, 'access' => TRUE//user_access('Only Teachers') ); - $items[]=array( 'path' => 'forestry_stage1_part2', - 'title' => t('Forestry Game - Stage 1'), - 'callback'=>'forestry_game_stage1_part2', - // 'callback argument' => array('forestry_game_stage1_part2'), - 'type'=>MENU_CALLBACK, - 'access' => TRUE//user_access('Only Teachers') - ); } else @@ -59,247 +50,138 @@ } /** - * Called when user goes to example.com/?q=forestry + * */ -function forestry_v2_page() { - $output = t('Please note the following maximum harvest table.'); +function forestry_intro() { + $output = t('Welcome to the Forestry game! (Add more instructions here?). The following table lists the maximum harvest decisions you can make associated with a given resource level range.'); // Return the HTML generated from the $form data structure. - $output .= drupal_get_form('forestry_v2_nameform'); + $output .= generate_harvest_table(); + $output .= drupal_get_form('forestry_intro_form'); return $output; } + /** - * Defines a form. + * Returns the initial harvest table. */ -function forestry_v2_nameform() { - //$form['#method']='post'; - //+$form['#action']='http://localhost/drupal/?q=studentgroup'; - $form['#id']='forestry_v2'; - $header = array('Current Resource Level', 'Individual Maximum Harvest Level'); - - $stud_id=$_SESSION['student_id']; - $group = Session::get('group'); - drupal_set_message(' group id: ' . $group->getGroupId() ); - // FIXME: merge harvest tables into single table - - $game_id=$group->getGameId(); - $group_id=$group->getGroupId(); - $result_group=$group->getNumberOfStudents(); - drupal_set_message(t('Group no'. $result_group)); - $result = db_query("SELECT min_resource_level,max_resource_level,individual_harvest_level from {vc_forestry_${result_group}player_harvest_table}"); - /* - - if($result_group==5) - { - $result=db_query(db_rewrite_sql("Select min_resource_level,max_resource_level,individual_harvest_level from {virtualcommons_forestry_5player_harvest_table}")); - - } - else if($result_group==4) - { - $result=db_query(db_rewrite_sql("Select min_resource_level,max_resource_level,individual_harvest_level from {virtualcommons_forestry_4player_harvest_table}")); - } - else if($result_group==3) - { - $result=db_query(db_rewrite_sql("Select min_resource_level,max_resource_level,individual_harvest_level from virtualcommons_forestry_3player_harvest_table")); - } - } - */ - -while($harvest_data=db_fetch_object($result)) -{ - $min=$harvest_data->min_resource_level; - $max=$harvest_data->max_resource_level; - $ind=$harvest_data->individual_harvest_level; - $row[]=array($min.' - '.$max,$ind); - //drupal_set_message(t($min . " " . $max . " " . $ind)); +function forestry_intro_form() { + $form['#id']='forestry_intro'; + $form['submit'] = array( + '#type' => 'submit', + '#value' => t('Next') + ); + return $form; } -$_SESSION['harvest_table']=$row; - -$form['harvest_table']=array( - '#type'=>'markup', - '#value'=>theme('table',$header,$row) - ); - -$form['submit'] = array( - '#type' => 'submit', - '#value' => t('Next') - ); -return $form; -} /** * Invoked after the student has successfully logged in and is trying to click * "Next" to start the game. */ -function forestry_v2_nameform_submit($form_id, $form_values) +function forestry_intro_form_submit($form_id, $form_values) { - $stud_id=$_SESSION['student_id']; - $group = Session::get('group'); - $flag=$group->getStartFlag($stud_id); - $game_id = $group->getGameId(); - drupal_set_message(t('Student Flag is: '.$flag)); - if($flag) { - $current_stage_no = $group->getCurrentStageNumber(); - $current_stage_no = (int) $current_stage_no; - drupal_set_message(t('current stage is: '. $current_stage_no)); - return 'forestry_stage1'; - /* - else if($current_stage_no==2) - { - $current_rule_no=$group->getCurrentRuleNumber(); - switch($current_rule_no) - { - case 1: - return 'forestry_stage2_rule1'; - case 2: - return 'forestry_stage2_rule2'; - case 3: - return 'forestry_stage2_rule3'; - } + return 'forestry/play'; +} - } - */ +function forestry_end() { + $output = '<h3>The experiment is now over. Thanks for participating!</h3>'; + $output .= generate_results_table(); + return $output; +} + +function generate_harvest_table() { + $student = Session::get('student'); + $harvest_table = $student->getGroup()->generate_harvest_table(); + $_SESSION['harvest_table']=$harvest_table->rows; + return '<fieldset><legend><b>Maximum Harvest Table</b></legend>'.theme_table($harvest_table->header, $harvest_table->rows).'</fieldset>'; +} + + +function generate_results_table() { + $student = Session::get('student'); + $table_data_array = $student->getAllStageData(); + $result = '<fieldset><legend><b>Round Results</b></legend>'; + if ($student->getGroup()->getGame()->getCurrentRoundNo() == 1) { + $result .= 'No results available yet for the first round'; } else { - return 'forestry'; + foreach ($table_data_array as $table_data) { + $result .= theme_table($table_data->header, $table_data->rows); + } } + $result .= '</fieldset>'; + return $result; } -//Forestry Stage 1 Begins - -function forestry_game_stage1() { - +// primary forestry controller +function forestry_play() { // Return the HTML generated from the $form data structure. - $output = drupal_get_form('forestry_game_stage1_multiform'); + $student = Session::get('student'); + // check if user is properly authenticated + if (! $student ) { + return drupal_get_form('student_login_nameform'); + } + $group = $student->getGroup(); + if ($group->getGame()->isFinished()) { + $output = 'The experiment is now over. Your results are listed below. Thanks for participating!'; + $output .= generate_results_table(); + } + else { + $output .= generate_harvest_table(); + $output .= generate_results_table(); + $output .= ( $student->canStart() ) ? drupal_get_form('forestry_play_multiform') : drupal_get_form('forestry_wait_form'); + } return $output; } - - -function forestry_game_stage1_multiform() +function forestry_play_multiform() { + $form['#id']='forestry_play_multiform'; + $form['#tree'] = TRUE; - $form['#id']='forestry_game_stage1_multiform'; - $group = Session::get('group'); - $student=new ForestryStudent(); + $student = Session::get('student'); + $group = $student->getGroup(); - $form['#tree'] = TRUE; $resource_after=0; $resource_before=0; - $stud_id=$_SESSION['student_id']; - $resource_available=0; - $round_no=0; - $student->setStudentId($stud_id); - //get the availble resource from the database + $round_no = $group->getGame()->getCurrentRoundNo(); - $group_id=$group->getGroupId(); - $game_id=$group->getGameId(); - $round_no=$group->getRoundNo(); - drupal_set_message(t('group id : '. $group_id . ' Game id: '. $game_id)); - $resource_available= $student->getLatestResource($group_id,$game_id); - - drupal_set_message(t('reosurce available : '. $resource_available)); - $resource_available =(int) $resource_available; - //FIXME:later on use session objects to do all session activity - if(!isset($_SESSION['prev_resource'])) - { - $_SESSION['prev_resource']=$resource_available; - drupal_set_message(t('PREV resource is NOW set to : ' . $resource_available)); - } - $_SESSION['prev_resource']=$resource_available; - $current_stage_id=$group->getCurrentStageId(); - drupal_set_message(t('current stage id: '. $current_stage_id)); - $game = $group->getGame(); - if ( $game->isVotingEnabled() ) { - $header=array("Round Number","Your Harvest Decision","Resources Before","Resources After",'Penalty', 'Net Gain', ); - if($group->isTurn($stud_id)) - $form['turn']=array( - '#type'=>'item', - '#value'=>t('You have chosen for this round to harvest. You can harvest for this round.') - ); - - } - else { - $header=array("Round Number","Your Harvest Decision","Resources Before","Resources After"); - } - - $row=$student->getForestryStudentInfo($group_id,$game_id,$current_stage_id); - - // $stage_id=$group->getCurrentStageId(); - - - - drupal_set_message(t('round no: ' .$round_no .' '. gettype($round_no) )); - - //store the round no in hidden field - $form['round_no']=array( '#type'=>'hidden', - '#value'=>$round_no + '#value'=>$round_no ); - - // $no_rounds = $group->getNumberOfRounds(); - drupal_set_message(t('game id:' . $group->getGameId())); - $no_rounds=$group->getNumberOfRounds(); - drupal_set_message(t('no of rounds are: '.$no_rounds)); - if($round_no <= $no_rounds) - { + $form['indicator']=array( + '#type'=>'fieldset', + '#title'=>t('<b>Round @number</b>',array('@number'=>$round_no)) + ); - $form['resources_available']=array( +$form['indicator']['resources_available']=array( + '#type'=>'item', + '#title'=>t('Resources Available'), + '#value'=>$group->getResourcesAvailable() + ); - '#type'=>'item', - '#title'=>t('Resources Available'), - '#value'=>$resource_available - ); - $form['indicator']=array( - '#type'=>'fieldset', - '#title'=>t('<b>Round @number</b>',array('@number'=>$round_no)) - ); - - $form['indicator']['harvest_decision']=array( - '#type'=>'textfield', - '#title'=>t('Your Harvest Decision'), - '#default_value'=>'0', - '#size'=>2, - '#maxlength'=>2, - '#required'=>TRUE - ); - $form['indicator']['submit'] = array( - '#type' => 'submit', - '#value' => t('Submit') - ); - - } - else - { -// $stage_no=$group->getCurrentStageNumber(); - // drupal_set_message(t('Stage no is : '.$stage_no)); - $form['indicator']['submit'] = array( - '#type' => 'submit', - '#value' => t('Next Stage') - ); - } - - $form['resource']=array( - '#type'=>'fieldset', - '#title'=>t('<b>Resources</b>'), - + $form['indicator']['harvest_decision']=array( + '#type'=>'textfield', + '#title'=>t('Your Harvest Decision'), + '#default_value'=>'0', + '#size'=>2, + '#maxlength'=>2, + '#required'=>TRUE ); - $form['resource']['table']=array( - '#type'=>'markup', - '#value'=>theme('table',$header,$row) + $form['indicator']['submit'] = array( + '#type' => 'submit', + '#value' => t('Submit') ); - Session::put('forestry_student',$student); return $form; } -function forestry_game_stage1_multiform_validate($form_id,$form_values) +function forestry_play_multiform_validatewrong($form_id,$form_values) { $harvest_decision=$form_values['indicator']['harvest_decision']; $resource=(int) $_SESSION['prev_resource']; @@ -312,6 +194,10 @@ } else { + // FIXME: Seema, you have got to be kidding me. You are using this to + // determine whether or not the harvest decision is between the min and + // max??? I am going to leave this here to force you to figure out a + // better solution, which is very easy to come up with. $harvest_table= $_SESSION['harvest_table']; @@ -376,9 +262,10 @@ } -function forestry_game_stage1_multiform_submit($form_id,$form_values) +function forestry_play_multiform_submit($form_id,$form_values) { - $group = Session::get('group'); + $student = Session::get('student'); + $group = $student->getGroup(); $harvest_table=$_SESSION['harvest_table']; //$harvest_tbl=explode("-",$harvest_table); @@ -391,47 +278,47 @@ $round_no=$form_values['round_no']; - $round_no=(int) $round_no; + /* //get the student and set it $stud_id=$_SESSION['student_id']; $student=new ForestryStudent(); $student->setStudentId($stud_id); $stage_id=$group->getCurrentStageId(); $resources_before=(int) $_SESSION['prev_resource']; - drupal_set_message(t('resource_before:'. $resources_before)); - $student->setStageId($stage_id); - $student->saveForestryStudentInfo($round_no,$stud_harvest_decision); - $flag=false; - $student->updateStartFlag($flag); + */ + + + $student->save($round_no,$stud_harvest_decision); + $student->updateStartFlag(false); + return 'forestry/play'; + + /* $no_rounds=$group->getNumberOfRounds(); - - $no_rounds=(int) $no_rounds; - drupal_set_message(t('$actual_no_rounds' . $no_rounds . '$current_round_no' . $round_no)); if($form_values['indicator']['submit']=="Next Stage") { - $stage_no=2; - $exp_id=$group->getExperimentId(); - $game_id=$group->getGameId(); + //$stage_no=2; + // $exp_id=$group->getExperimentId(); + //$game_id=$group->getGameId(); + drupal_set_message("in next stage button functionality"); unset($_SESSION['prev_resource']); return 'rules'; } else return 'forestry_stage1_part2'; - - + */ } -function theme_forestry_game_stage1_multiform($form) +function theme_forestry_play_multiform($form) { $output='<div class="indicator"><table style="text-align: center; width: 100%;" border="0" cellpadding="0" cellspacing="0">'; - $output.='<h2 align="center" style="color:#990000">'; - $output.=drupal_render($form['turn']); - $output.='</h2> + $output.='<h2 align="center" style="color:#990000">'; + $output.=drupal_render($form['turn']); + $output.='</h2> <tbody> <tr> <td style="width: 80%;"> </td> @@ -471,119 +358,48 @@ } -function forestry_game_stage1_part2() +function forestry_wait_form() { - - // $output=t('Please click the Next button for next round'); - $output.=drupal_get_form('forestry_game_stage1_part2form'); - return $output; -} - -function forestry_game_stage1_part2form() -{ - -$student=Session::get('forestry_student'); -$stage_flag=FALSE; -$group=Session::get('group'); -$group_id=$group->getGroupId(); + $student = Session::get('student'); + $group = $student->getGroup(); + $group_id=$group->getGroupId(); $game_id=$group->getGameId(); - if ($group->isGameFinished()) - { - drupal_set_message('The game is over. Thanks for participating!'); -// $_SESSION['finished']='game'; - } - else - { - $stage_flag=$group->isStageOver(); - } - if($stage_flag) - { - $header=array("Round Number","Your Harvest Decision","Resources Before","Resources After"); - $row=$student->getForestryStudentInfo($group_id,$game_id); - - $form['stage_info']=array( - '#type'=>'item', - '#value'=>t(' Following is the summary of your harvest decision for this stage. This stage is over.') - ); - - $form['resource']=array( - '#type'=>'fieldset', - '#title'=>t('<b>Resources</b>'), - - ); - $form['resource']['table']=array( - '#type'=>'markup', - '#value'=>theme('table',$header,$row) - ); - - $form['submit'] = array( - '#type' => 'submit', - '#value' => t('Next Stage') - ); - unset($_SESSION['finished']); - } - - - else - { - $form['submit'] = array( - '#type' => 'submit', - '#value' => t('Next Round') - ); - } + // FIXME: hack only in place for Drupal 5, can get rid of in Drupal 6 in + // favor of the $repeat parameter in drupal_set_message + drupal_get_messages(); + drupal_set_message( + t('Please wait until the rest of the participants finish + making their decisions and the facilitator instructs you to click on + the next button. Clicking on the next button before the facilitator is + ready will have no effect.'), + 'warning', FALSE); + if ($group->isGameFinished()) + { + drupal_set_message(t('The game is over. Thanks for participating.'), + 'warning', FALSE); + } + else if($group->getGame()->isStageOver()) + { + drupal_set_message(t('This stage is now over.'), 'warning', FALSE); + $form['submit'] = array( + '#type' => 'submit', + '#value' => t('Go to the next stage') + ); + } + else + { + $form['submit'] = array( + '#type' => 'submit', + '#value' => t('Next Round') + ); + } return $form; - + } -function forestry_game_stage1_part2form_submit($form_id,$form_values) +function forestry_wait_form_submit($form_id,$form_values) { - - $stud_id=$_SESSION['student_id']; - $student=Session::get('forestry_student'); - $group=Session::get('group'); - - - $stage_flag=FALSE; - drupal_set_message(t($form_values['submit'])); - $flag=$student->getStartFlag(); -//if($round_no >= $no_rounds) { } - - /*if($form_values['submit']=="Next Round") - { - $flag=$student->getStartFlag(); -drupal_set_message(t('flag'.$flag)); - if ($group->isGameFinished()) - { - drupal_set_message('The game is over. Thanks for participating!'); -// $_SESSION['finished']='game'; - } - else - { - $stage_flag=$group->isStageOver(); -// if($stage_flag) - //if(!(isset($_SESSION['finished']))) - //$_SESSION['finished']='stage'; - drupal_set_message(t('stage flag is: ' . $stage_flag)); - }*/ - if($flag) - { - // if($stage_flag) - return 'forestry_stage1'; - } - else { - return 'forestry_stage1_part2'; - } - - - - - - + return 'forestry/play'; } - - - - - Modified: vcweb/trunk/virtualcommons/experiment/student_login/student_login.module =================================================================== --- vcweb/trunk/virtualcommons/experiment/student_login/student_login.module 2008-08-11 23:16:36 UTC (rev 38) +++ vcweb/trunk/virtualcommons/experiment/student_login/student_login.module 2008-08-13 09:32:34 UTC (rev 39) @@ -58,26 +58,20 @@ function student_login_nameform_validate($form_id,$form_values) { $stud_id=$form_values['id']; - $group = Group::findByStudentId($stud_id); - if ($group) { + $student = Group::findByStudentId($stud_id); + if ($student) { // set the game object into the session, currently only contains the // game_id - Session::put('group',$group); + Session::put('student',$student); } else { form_set_error('id',t('Invalid Student ID. Please contact your instructor.')); } } - - function student_login_nameform_submit($form_id,$form_values) { $_SESSION['student_id']=$form_values['id']; - return 'forestry'; + return 'forestry/intro'; } - - - - Modified: vcweb/trunk/virtualcommons/experiment/teacher_dashboard/teacher_dashboard.module =================================================================== --- vcweb/trunk/virtualcommons/experiment/teacher_dashboard/teacher_dashboard.module 2008-08-11 23:16:36 UTC (rev 38) +++ vcweb/trunk/virtualcommons/experiment/teacher_dashboard/teacher_dashboard.module 2008-08-13 09:32:34 UTC (rev 39) @@ -76,7 +76,7 @@ // display all stage data $all_stage_data = $game->getAllGroupRoundInfo(); $header_novoting=array('Round No','Group No', 'Group Harvest Decision','Resources Before','Resources After'); - $header_voting=array('Round No','Group No', 'Group Harvest Decision','Resources Before','Resources After', 'Dice', 'Rule #'); + $header_voting=array('Round No','Group No', 'Group Harvest Decision','Resources Before','Resources After', 'Rule #', 'Dice'); foreach ($all_stage_data as $stage_id => $stage_data) { $stage_no = $game->getStageNumber($stage_id); @@ -84,7 +84,7 @@ '#type'=>'fieldset', '#title'=>t("<b>Stage ${stage_no}</b>") ); - $header = ($game->isVotingEnabledForStage($stageId) ? $header_voting : $header_novoting); + $header = ($game->isVotingEnabledForStage($stage_id) ? $header_voting : $header_novoting); $form['stage_'.$stage_no]['table']=array( '#type'=>'markup', '#value'=>theme('table',$header,$stage_data) @@ -93,7 +93,7 @@ if ($game->isFinished()) { // $output = t('The game is over.'); - drupal_set_message('The game is over. Thanks for participating!'); + drupal_set_message(t('<h2 align="center" style="color:#990000">The game is over. Thanks for participating!</h2>')); /* $form['final_msg']=array( '#type'=>'markup', @@ -116,7 +116,7 @@ } - drupal_set_message(t('Stage flag is:' .$stage_flag)); + //drupal_set_message(t('Stage flag is:' .$stage_flag)); $form['submit'] = array( '#type' => 'submit', @@ -156,7 +156,6 @@ //set flag, when flag=TRUE it means round is even , when flag=FALSE it means //that round is uneven. Ja! $game=Session::get('game'); - $game->setRoundNo($game->getCurrentRoundNo()); if($form_values['submit']=="Next Round") { // $no_rounds = $game->getNumberOfRounds(); @@ -190,4 +189,4 @@ } -?> \ 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: <see...@us...> - 2008-08-11 23:16:28
|
Revision: 38 http://virtualcommons.svn.sourceforge.net/virtualcommons/?rev=38&view=rev Author: seematalele Date: 2008-08-11 23:16:36 +0000 (Mon, 11 Aug 2008) Log Message: ----------- written code for rule 1 in forestry_v2 module. Modified Paths: -------------- vcweb/trunk/virtualcommons/experiment/experiment.inc vcweb/trunk/virtualcommons/experiment/experiment.module 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-09 01:56:09 UTC (rev 37) +++ vcweb/trunk/virtualcommons/experiment/experiment.inc 2008-08-11 23:16:36 UTC (rev 38) @@ -214,6 +214,7 @@ public function isStageOver() { + drupal_set_message(t('Current round no is: ' .$this->getCurrentRoundNo() . ' and no of rounds are: ' .$this->getNumberOfRounds())); return ($this->getCurrentRoundNo() - 1 == $this->getNumberOfRounds()); } @@ -226,14 +227,16 @@ public function getValidStudentIds($group_id) { $turn_sequence = $this->getTurnSequence($group_id); - $result = db_query('SELECT vc_student_id + $result = db_query('SELECT id FROM vc_student WHERE vc_group_id=%d AND turn_no IN (%s)', $group_id, $turn_sequence); $valid_ids = array(); while ($data = db_fetch_object($result)) { - $valid_ids[] = $data->vc_student_id; + $valid_ids[] = $data->id; + drupal_set_message(t($data->id. ' , ')); } + return $valid_ids; } @@ -294,6 +297,7 @@ if ($dice == 6) { // check to see if we need to assess fines $this->assessFines($group_id, $current_rule_number); + } } $resources_before=$crp=$data->crp; @@ -393,9 +397,10 @@ //determine the rule for a group - $result_group=db_query("select id from vc_group where vc_game_id=%d",$this->game_id); - while($data=db_fetch_object($result_group)) - { + + $result_group=db_query("select id from vc_group where vc_game_id=%d",$this->game_id); + while($data=db_fetch_object($result_group)) + { $group_id=$data->id; //$result_voting=db_query("select vc_rules_id,count(vc_rules_id) as rule_cnt from vc_student_voting where vc_student_id in (select id from vc_student where vc_group_id=%d) group by vc_rules_id",$group_id); $result_voting=db_query(" select vc_rules_id, count(vc_rules_id) as rule_cnt from vc_student_voting v @@ -464,6 +469,7 @@ // drupal_set_message(t('Rule id : ' . $final_rule_id.'Group id is: ' . $group_id)); }//end of while + }//end of init function @@ -563,6 +569,7 @@ } } + public function getTurnSequence() { return $this->game->getTurnSequence($this->group_id); } @@ -669,15 +676,41 @@ } +public function isGameFinished() +{ +return $this->game->isFinished(); +} +public function isStageOver() +{ +drupal_set_message(t('$this->game->getCurrentRoundNo(): ' . $this->game->getCurrentRoundNo() . ' $this->game->getNumberOfRounds()'. $this->game->getNumberOfRounds())); + return ($this->game->getCurrentRoundNo() -1 == $this->game->getNumberOfRounds()); +} +public function getRoundNo() +{ + return $this->game->getCurrentRoundNo(); +} /*public function getRuleDescription() { db_result(db_query("select description select vc_selected_rules_id from vc_group where id=%d",$this->group_id)); }*/ +public function isTurn($stud_id) + { + $valid_id=$this->game->getValidStudentIds($this->group_id); + $flag=FALSE; + drupal_set_message(t('Group id is : '. $this->group_id. 'Student Id is : '. $stud_id . ' Valid student ids are: ' . $valid_id[0] . ',' . $valid_id[1])); + if(in_array($stud_id,$valid_id)) + { + $flag= TRUE; + } + else + $flag= FALSE; + drupal_set_message(t('flag for student turn : '. $flag)); + return $flag; + } - }//end of Group /** @@ -711,26 +744,26 @@ { $this->stage_id=$stage_id; } - - public function getRoundNo($game_id,$stage_id) + + /* public function getRoundNo($game_id,$stage_id) { //$this-> - $this->round_no=db_result(db_query("select current_round_no from vc_game where id=%d and vc_stage_id=%d",$game_id,$stage_id)); + return db_result(db_query("select current_round_no from vc_game where id=%d and vc_stage_id=%d",$game_id,$stage_id)); //drupal_set_message(t('round no is:' .$stage_id . $this->round_no . $game_id)); - return $this->round_no; - } +// return $this->round_no; + }*/ - public function getForestryStudentInfo($group_id,$game_id) + public function getForestryStudentInfo($group_id,$game_id,$stage_id) { - $student_decision=db_query("select round_no,harvest_decision from vc_forestry_student where vc_student_id= '%s' ",$this->stud_id); + $student_decision=db_query("select round_no,harvest_decision from vc_forestry_student where vc_student_id= '%s' and vc_stage_id=%d ",$this->stud_id,$stage_id); while($student_data=db_fetch_object($student_decision)) { $round_no=$student_data->round_no; $harvest_decision=$student_data->harvest_decision; $round_no=(int)$round_no; //get the resource info from vc_forestry_group_round_information - $resource_info= db_query("select resources_before,resources_after from vc_forestry_group_round_info where vc_group_id=%d and vc_game_id=%d and round_no=%d",$group_id,$game_id,$round_no); + $resource_info= db_query("select resources_before,resources_after from vc_forestry_group_round_info where vc_group_id=%d and vc_game_id=%d and round_no=%d and vc_stage_id=%d",$group_id,$game_id,$round_no,$stage_id); while($data_resource=db_fetch_object($resource_info)) { $resources_before=$data_resource->resources_before; @@ -769,6 +802,7 @@ { db_query("update vc_game set vc_stage_id=(select id from vc_stage where stage_no= %d and vc_experiment_id=%d) where id=%d;",$stage_no,$experiment_id,$game_id); } + } Modified: vcweb/trunk/virtualcommons/experiment/experiment.module =================================================================== --- vcweb/trunk/virtualcommons/experiment/experiment.module 2008-08-09 01:56:09 UTC (rev 37) +++ vcweb/trunk/virtualcommons/experiment/experiment.module 2008-08-11 23:16:36 UTC (rev 38) @@ -13,7 +13,7 @@ -function experiment_perm() +function experiment_menuperm() { return array('Only Teachers'); Modified: vcweb/trunk/virtualcommons/experiment/games/forestry_v2/forestry_v2.module =================================================================== --- vcweb/trunk/virtualcommons/experiment/games/forestry_v2/forestry_v2.module 2008-08-09 01:56:09 UTC (rev 37) +++ vcweb/trunk/virtualcommons/experiment/games/forestry_v2/forestry_v2.module 2008-08-11 23:16:36 UTC (rev 38) @@ -193,6 +193,7 @@ $group_id=$group->getGroupId(); $game_id=$group->getGameId(); + $round_no=$group->getRoundNo(); drupal_set_message(t('group id : '. $group_id . ' Game id: '. $game_id)); $resource_available= $student->getLatestResource($group_id,$game_id); @@ -205,20 +206,27 @@ drupal_set_message(t('PREV resource is NOW set to : ' . $resource_available)); } $_SESSION['prev_resource']=$resource_available; - + $current_stage_id=$group->getCurrentStageId(); + drupal_set_message(t('current stage id: '. $current_stage_id)); $game = $group->getGame(); if ( $game->isVotingEnabled() ) { $header=array("Round Number","Your Harvest Decision","Resources Before","Resources After",'Penalty', 'Net Gain', ); + if($group->isTurn($stud_id)) + $form['turn']=array( + '#type'=>'item', + '#value'=>t('You have chosen for this round to harvest. You can harvest for this round.') + ); + } else { $header=array("Round Number","Your Harvest Decision","Resources Before","Resources After"); } - $row=$student->getForestryStudentInfo($group_id,$game_id); + $row=$student->getForestryStudentInfo($group_id,$game_id,$current_stage_id); - $stage_id=$group->getCurrentStageId(); + // $stage_id=$group->getCurrentStageId(); - $round_no=$student->getRoundNo($game_id,$stage_id); + drupal_set_message(t('round no: ' .$round_no .' '. gettype($round_no) )); @@ -230,7 +238,7 @@ '#value'=>$round_no ); - drupal_set_message(t('current stage id: '. $group->getCurrentStageId())); + // $no_rounds = $group->getNumberOfRounds(); drupal_set_message(t('game id:' . $group->getGameId())); $no_rounds=$group->getNumberOfRounds(); @@ -258,6 +266,10 @@ '#maxlength'=>2, '#required'=>TRUE ); + $form['indicator']['submit'] = array( + '#type' => 'submit', + '#value' => t('Submit') + ); } else @@ -268,10 +280,8 @@ '#type' => 'submit', '#value' => t('Next Stage') ); - + } - } - $form['resource']=array( '#type'=>'fieldset', '#title'=>t('<b>Resources</b>'), @@ -392,31 +402,12 @@ drupal_set_message(t('resource_before:'. $resources_before)); - //insert into the database virtualcommons_forestry_student - // $group_id;$group->getGroupId(); - // $group_no=db_result(db_query(" select group_no from virtualcommons_student where id='%s'",$stud_id)); $student->setStageId($stage_id); $student->saveForestryStudentInfo($round_no,$stud_harvest_decision); - //db_query("Insert into {virtualcommons_forestry_student} (round_no,virtualcommons_student_id,virtualcommons_stage_no,virtualcommons_student_group_no,harvest_decision,date) values(%d,'%s',%d,%d,%d,NOW())",$round_no,$stud_id,1,$group_no,$stud_harvest_decision); - - //check whether everybody has made decision about harvesting - - /*$virtual_conducts_id=db_result(db_query(" select virtualcommons_conducts_id from virtualcommons_student where id='%s'",$stud_id)); - - $db_harvest_decision=db_result(db_query("select harvest_decision from virtualcommons_forestry_common_resource_pool where virtualcommons_student_group_no=%d and virtualcommons_conducts_id=%d",$group_no,$virtual_conducts_id)); - $harvest_decision=$stud_harvest_decision; - - $db_harvest_decision=(int) $db_harvest_decision; - $temp_harvest_decision=$harvest_decision + $db_harvest_decision; - - db_query(" update virtualcommons_forestry_common_resource_pool set harvest_decision=%d where virtualcommons_student_group_no=%d and virtualcommons_conducts_id=%d",$temp_harvest_decision,$group_no,$virtual_conducts_id);*/ - - //disable for next round until teacher clicks the button - //db_query("update virtualcommons_student set start_flag=false where id='%s'",$stud_id); $flag=false; $student->updateStartFlag($flag); $no_rounds=$group->getNumberOfRounds(); - //$no_rounds=db_result(db_query("Select no_of_rounds from virtualcommons_stage where stage_no=1 and virtualcommons_experiments_id=2")); + $no_rounds=(int) $no_rounds; drupal_set_message(t('$actual_no_rounds' . $no_rounds . '$current_round_no' . $round_no)); if($form_values['indicator']['submit']=="Next Stage") @@ -424,8 +415,6 @@ $stage_no=2; $exp_id=$group->getExperimentId(); $game_id=$group->getGameId(); - // $student->updateStageId($stage_no,$exp_id,$game_id); - //db_query("update virtualcommons_conducts set virtualcommons_stage_no=%d where id=%d",2,$virtual_conducts_id); unset($_SESSION['prev_resource']); return 'rules'; @@ -439,7 +428,10 @@ function theme_forestry_game_stage1_multiform($form) { $output='<div class="indicator"><table style="text-align: center; width: 100%;" border="0" - cellpadding="0" cellspacing="0"> + cellpadding="0" cellspacing="0">'; + $output.='<h2 align="center" style="color:#990000">'; + $output.=drupal_render($form['turn']); + $output.='</h2> <tbody> <tr> <td style="width: 80%;"> </td> @@ -482,7 +474,7 @@ function forestry_game_stage1_part2() { - $output=t('Please click the Next button for next round'); + // $output=t('Please click the Next button for next round'); $output.=drupal_get_form('forestry_game_stage1_part2form'); return $output; } @@ -490,12 +482,57 @@ function forestry_game_stage1_part2form() { +$student=Session::get('forestry_student'); +$stage_flag=FALSE; +$group=Session::get('group'); +$group_id=$group->getGroupId(); + $game_id=$group->getGameId(); + if ($group->isGameFinished()) + { + drupal_set_message('The game is over. Thanks for participating!'); +// $_SESSION['finished']='game'; + } + else + { + $stage_flag=$group->isStageOver(); + } + if($stage_flag) + { + $header=array("Round Number","Your Harvest Decision","Resources Before","Resources After"); + $row=$student->getForestryStudentInfo($group_id,$game_id); + + $form['stage_info']=array( + '#type'=>'item', + '#value'=>t(' Following is the summary of your harvest decision for this stage. This stage is over.') + ); + + $form['resource']=array( + '#type'=>'fieldset', + '#title'=>t('<b>Resources</b>'), - $form['submit'] = array( - '#type' => 'submit', - '#value' => t('Next Round') - ); + ); + $form['resource']['table']=array( + '#type'=>'markup', + '#value'=>theme('table',$header,$row) + ); + + $form['submit'] = array( + '#type' => 'submit', + '#value' => t('Next Stage') + ); + unset($_SESSION['finished']); + } + + + else + { + $form['submit'] = array( + '#type' => 'submit', + '#value' => t('Next Round') + ); + } return $form; + } @@ -505,20 +542,45 @@ $stud_id=$_SESSION['student_id']; $student=Session::get('forestry_student'); + $group=Session::get('group'); + + + $stage_flag=FALSE; + drupal_set_message(t($form_values['submit'])); $flag=$student->getStartFlag(); - /*$round_no=db_result(db_query(" select max(round_no) from virtualcommons_forestry_student where virtualcommons_student_id='%s'",$stud_id)); - $round_no=(int) $round_no; - drupal_set_message(t('curr round'.$round_no)); - $flag=db_result(db_query("Select start_flag from virtualcommons_student where id='%s'",$stud_id)); - $no_rounds=db_result(db_query("Select no_of_rounds from virtualcommons_stage where stage_no=1 and virtualcommons_experiments_id=2")); - $no_rounds=(int) $no_rounds;*/ - drupal_set_message(t('flag'.$flag)); - //if($round_no >= $no_rounds) { } - if($flag) - return 'forestry_stage1'; - else if(!($flag)) - return 'forestry_stage1_part2'; +//if($round_no >= $no_rounds) { } + /*if($form_values['submit']=="Next Round") + { + $flag=$student->getStartFlag(); +drupal_set_message(t('flag'.$flag)); + if ($group->isGameFinished()) + { + drupal_set_message('The game is over. Thanks for participating!'); +// $_SESSION['finished']='game'; + } + else + { + $stage_flag=$group->isStageOver(); +// if($stage_flag) + //if(!(isset($_SESSION['finished']))) + //$_SESSION['finished']='stage'; + drupal_set_message(t('stage flag is: ' . $stage_flag)); + }*/ + if($flag) + { + // if($stage_flag) + return 'forestry_stage1'; + } + else { + return 'forestry_stage1_part2'; + } + + + + + + } Modified: vcweb/trunk/virtualcommons/experiment/teacher_dashboard/teacher_dashboard.module =================================================================== --- vcweb/trunk/virtualcommons/experiment/teacher_dashboard/teacher_dashboard.module 2008-08-09 01:56:09 UTC (rev 37) +++ vcweb/trunk/virtualcommons/experiment/teacher_dashboard/teacher_dashboard.module 2008-08-11 23:16:36 UTC (rev 38) @@ -111,8 +111,8 @@ else { $stage_flag=$game->isStageOver(); - if($stage_flag) - $game->setRoundNo($game->getCurrentRoundNo()); + // if($stage_flag) + //$game->setRoundNo($game->getCurrentRoundNo()); } @@ -134,7 +134,7 @@ // $virtual_conduct_id=(int) $form_values['game_id']; $game= Session::get('game'); drupal_set_message(t($form_values['submit'])); - if($form_values['submit']=="Go to Next Stage") + /* if($form_values['submit']=="Go to Next Stage") { if (($game->isVotingEnabled())) { @@ -144,7 +144,7 @@ } } - } + }*/ } @@ -156,6 +156,7 @@ //set flag, when flag=TRUE it means round is even , when flag=FALSE it means //that round is uneven. Ja! $game=Session::get('game'); + $game->setRoundNo($game->getCurrentRoundNo()); if($form_values['submit']=="Next Round") { // $no_rounds = $game->getNumberOfRounds(); @@ -164,13 +165,13 @@ } else if($form_values['submit']=="Go to Next Stage") { //initialise the stage 2 + - drupal_set_message(t('Go to stage 2')); // FIXME: initNextStage is actually an initialization for voting stage - // remove that assumption - + $game->setRoundNo($game->getCurrentRoundNo()); $game->initNextStage(); if ($game->isVotingEnabled()) { @@ -178,11 +179,15 @@ { $rule_no=$game->initRules(); } + else + form_set_error('submit',t('Please tell students to vote. Without voting you can not proceed to Stage 2')); } + } return 'teacher_dashboard'; } +?> \ 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: <see...@us...> - 2008-08-09 01:56:00
|
Revision: 37 http://virtualcommons.svn.sourceforge.net/virtualcommons/?rev=37&view=rev Author: seematalele Date: 2008-08-09 01:56:09 +0000 (Sat, 09 Aug 2008) Log Message: ----------- wrote the logic for voting rules in experiment.inc & put the code to check if the game is over or not in teacher dashboard Modified Paths: -------------- vcweb/trunk/virtualcommons/experiment/experiment.inc vcweb/trunk/virtualcommons/experiment/games/forestry_v2/forestry_v2.install vcweb/trunk/virtualcommons/experiment/games/forestry_v2/forestry_v2.module vcweb/trunk/virtualcommons/experiment/rules/rules.module vcweb/trunk/virtualcommons/experiment/survey/survey.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-08 06:31:48 UTC (rev 36) +++ vcweb/trunk/virtualcommons/experiment/experiment.inc 2008-08-09 01:56:09 UTC (rev 37) @@ -1,7 +1,5 @@ <?php - - class Session { public static function put($ses_var, $object) { //if( ! isset($_SESSION[$ses_var]) ) { @@ -29,7 +27,7 @@ private $current_round_no; private $no_of_students; private $experiment_name; - private $prev_round_no; + private $prev_round_no; public function __construct($game_id, $experiment_id=-1, $teacher_id=-1, $no_of_students=-1) { $this->game_id = $game_id; @@ -38,7 +36,7 @@ $this->no_of_students = $no_of_students; $this->current_stage_no = 1; $this->current_round_no = 1; - $this->prev_round_no=1; + $this->prev_round_no=1; $this->experiment_name = db_result(db_query("select e.name from vc_experiment e where e.id=%d", $experiment_id)); } @@ -128,8 +126,8 @@ public function isVotingEnabled() { $flag=db_result(db_query("select s.voting from vc_stage s inner join vc_game g on s.id=g.vc_stage_id and g.id=%d", $this->game_id)); - drupal_set_message(t('Voting Flag is: '.$flag)); - return $flag; + drupal_set_message(t('Voting Flag is: '.$flag)); + return $flag; } public function isVotingEnabledForStage($stage_id) { @@ -139,7 +137,6 @@ public function isVotingDone() { $count=db_result(db_query("select count(*) from vc_group where vc_game_id=%d and vc_selected_rules_id is null",$this->game_id)); - drupal_set_message(t('Is voting done Flag: '.$count)); return $count==0; } // FIXME: turn into $forestryGame->init() overloaded method @@ -200,30 +197,117 @@ return db_result(db_query("SELECT s.stage_no FROM {vc_game g, vc_stage s} WHERE g.vc_stage_id=s.id AND g.id=%d", $this->game_id)); } - /*public function getPrevRoundNo() - { - - return ($this->getCurrentRoundNo() -1); - }*/ - public function processGroups() + /*public function getPrevRoundNo() + { + + return ($this->getCurrentRoundNo() -1); + }*/ + + public function isFinished() { + $max_stage_number = db_result(db_query('SELECT max(stage_no) + FROM vc_stage s inner join vc_game g on s.vc_experiment_id=g.vc_experiment_id + WHERE g.id=%d', $this->game_id)); + return $this->isStageOver() && ($max_stage_number == $this->getCurrentStageNumber()); + + } + + public function isStageOver() + { + return ($this->getCurrentRoundNo() - 1 == $this->getNumberOfRounds()); + } + + public function getTurnSequence($group_id) { + return db_result(db_query('select turn_sequence + FROM vc_forestry_turn_sequence s, vc_group gr, vc_game ga + WHERE s.vc_group_id=%d AND ga.id=gr.vc_game_id AND ga.current_round_no=s.round_no AND s.vc_rules_id=gr.vc_selected_rules_id', + $group_id)); + } + + public function getValidStudentIds($group_id) { + $turn_sequence = $this->getTurnSequence($group_id); + $result = db_query('SELECT vc_student_id + FROM vc_student + WHERE vc_group_id=%d + AND turn_no IN (%s)', $group_id, $turn_sequence); + $valid_ids = array(); + while ($data = db_fetch_object($result)) { + $valid_ids[] = $data->vc_student_id; + } + return $valid_ids; + } + + public function assessTurnSequenceFines($group_id) { + $turn_sequence = $this->getTurnSequence($group_id); + $result = db_query('SELECT fs.id, fs.harvest_decision, fs.total_points + FROM vc_forestry_student fs INNER JOIN vc_student s ON fs.vc_student_id=s.id + WHERE fs.harvest_decision > 0 + AND s.vc_group_id=%d + AND fs.round_no=%d + AND s.turn_no NOT IN (%s)', $group_id, $this->getCurrentRoundNo(), $turn_sequence); + while ($data = db_fetch_object($result)) { + $fine = $data->harvest_decision + 3; + $dice = 6; + $total_points = $data->total_points - $fine; + db_query('UPDATE vc_forestry_student SET fine=%d, total_points=%d + WHERE id=%d', $fine, $total_points, $data->id); + } + + } + + private function assessFines($group_id, $current_rule_number) { + switch ($current_rule_number) { + case 1: + case 2: + $this->assessTurnSequenceFines($group_id); + break; + case 3: + + break; + default: + form_set_error(t('Current rule number is invalid: ' . $current_rule_number)); + break; + } + + } + + public function nextRound() + { $round_no=$this->getCurrentRoundNo(); $stage_id=$this->getCurrentStageId(); - $result = db_query(" select c.vc_group_id as group_id,c.common_resource_pool as crp,c.max_resources as max_r from vc_forestry_common_resource_pool c, vc_group g where c.vc_group_id =g.id and g.vc_game_id=%d",$this->game_id); + $result = db_query(" select c.vc_group_id as group_id,c.common_resource_pool as crp,c.max_resources as max_r + from vc_forestry_common_resource_pool c, vc_group g where c.vc_group_id =g.id and g.vc_game_id=%d",$this->game_id); + // processing each group + + $voting_enabled = $this->isVotingEnabled(); + while($data = db_fetch_object($result)) { + // FIXME: preprocess the groups and insert default decisions for + // all students that haven't made a harvest decision. $group_id=$data->group_id; + $current_rule_number = $this->getCurrentRuleNumber($group_id); + if ($voting_enabled) { + // roll the dice + $dice = rand(1, 6); + $dice = 6; + if ($dice == 6) { + // check to see if we need to assess fines + $this->assessFines($group_id, $current_rule_number); + } + } $resources_before=$crp=$data->crp; $max_resources=$data->max_r; $total_harvest_decision = db_result(db_query("select sum(harvest_decision) - from vc_forestry_student - where vc_student_id in (select id from vc_student where vc_group_id=%d) and round_no=%d", - $group_id,$round_no)); + from vc_forestry_student + where vc_student_id in (select id from vc_student where vc_group_id=%d) and vc_stage_id=%d and round_no=%d", + $group_id,$stage_id,$round_no)); $resources_available=$crp-$total_harvest_decision; $resources_available=$resources_available+($resources_available*0.1); if($resources_available > $max_resources) { $resources_available=$max_resources; } + //insert into group-round info db_query("Insert into {vc_forestry_group_round_info} (round_no,vc_game_id,vc_group_id,vc_stage_id,total_harvest_decision,resources_before,resources_after) values(%d,%d,%d,%d,%d,%d,%d)", @@ -231,45 +315,49 @@ //update forestry common pool db_query("update {vc_forestry_common_resource_pool} set common_resource_pool=%d where vc_game_id=%d and vc_group_id=%d",$resources_available,$this->game_id,$group_id); } + //update start flag $this->updateStartFlag(true); - $this->prev_round_no=$round_no; + $this->prev_round_no=$round_no; //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 + $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 + $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; + $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($this->isStageOver()) + $this->setRoundNo($this->getCurrentRoundNo());*/ } -public function setRoundNo($round_no) -{ + public function setRoundNo($round_no) + { - if ($round_no > ($this->getNumberOfRounds())) { + //drupal_set_mesage(t('Round is : ' . $round_no)); + 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 + // 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) { @@ -286,89 +374,163 @@ db_query("UPDATE {vc_game} SET current_round_no=%d WHERE id=%d", $this->current_round_no, $this->game_id); -} + } -//Stage 2 + //Stage 2 -public function initNextStage() -{ -//reset the forestry common resource pool + public function initNextStage() + { + //reset the forestry common resource pool - $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)) - { - 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); + $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)) + { + 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); - } + } -//determine the rule for a group + //determine the rule for a group - $result_group=db_query("select id from vc_group where vc_game_id=%d",$this->game_id); - while($data=db_fetch_object($result_group)) - { - $group_id=$data->id; - $result_voting=db_query("select vc_rules_id,count(vc_rules_id) as rule_cnt from vc_student_voting where vc_student_id in (select id from vc_student where vc_group_id=%d) group by vc_rules_id",$group_id); - $max_rule_cnt=0;$rule_id=array();$rule_cnt=array();$tie_rules=array();$max_rule_id=0; - while($data=db_fetch_object($result_voting)) - { - array_push($rule_id,$data->vc_rules_id); - array_push($rule_cnt,$data->rule_cnt); - //$voting[$data->vc_rules_id]=$data->rule_cnt; - - } - for($i=0;$i<count($rule_cnt);$i++)//for1 - { - for($j=$i+1;$j<count($rule_cnt);$j++)//for2 - { - - if($rule_cnt[$i]<$rule_cnt[$j]) - { - if($max_rule_cnt < $rule_cnt[$j]) - { - $max_rule_cnt=$rule_cnt[$j]; - $max_rule_id=$rule_id[$j]; - } - } - else - { - - if($rule_cnt[$i]==$rule_cnt[$j]) - { - //echo '<br/>Equal $i ' . $i. ' $j ' .$j; - array_push($tie_rules,$rule_id[$i],$rule_id[$j]); - $tie_rule_cnt=$rule_cnt[$i]; - } - elseif($max < $rule_cnt[$i]) - { - $max_rule_cnt=$rule_cnt[$i]; - $max_rule_id=$rule_id[$i]; - } - } - - } + $result_group=db_query("select id from vc_group where vc_game_id=%d",$this->game_id); + while($data=db_fetch_object($result_group)) + { + $group_id=$data->id; + //$result_voting=db_query("select vc_rules_id,count(vc_rules_id) as rule_cnt from vc_student_voting where vc_student_id in (select id from vc_student where vc_group_id=%d) group by vc_rules_id",$group_id); + $result_voting=db_query(" select vc_rules_id, count(vc_rules_id) as rule_cnt from vc_student_voting v + where v.time_created >= (select max(time_created) from vc_student_voting vv where v.vc_student_id=vv.vc_student_id) and + v.vc_student_id in (select id from vc_student where vc_group_id=%d) group by vc_rules_id",$group_id); - }//end of for1 + $max_rule_cnt=0;$rule_id=array();$rule_cnt=array();$tie_rules=array();$max_rule_id=0; + while($data=db_fetch_object($result_voting)) + { + array_push($rule_id,$data->vc_rules_id); + array_push($rule_cnt,$data->rule_cnt); + //$voting[$data->vc_rules_id]=$data->rule_cnt; - //echo '<br/> Max: '. $max ; - if($max_rule_cnt==$tie_rule_cnt) - { - drupal_set_message(t( '<br/>tie')); - - } - else - { - drupal_set_message(t( '<br/>NOT tie')); - db_query("update vc_group set vc_selected_rules_id =%d where id=%d",$max_rule_id,$group_id); - } + } + //drupal_set_message(t('count of an array is :' . count($rule_cnt))); + for($i=0;$i<count($rule_cnt);$i++)//for1 + { + for($j=$i+1;$j<count($rule_cnt);$j++)//for2 + { -// drupal_set_message(t('Rule id : ' . $final_rule_id.'Group id is: ' . $group_id)); - }//end of while + if($rule_cnt[$i]<$rule_cnt[$j]) + { + if($max_rule_cnt < $rule_cnt[$j]) + { + $max_rule_cnt=$rule_cnt[$j]; + $max_rule_id=$rule_id[$j]; + drupal_set_message(t( '$max_rule_id is : ' . $rule_id[$j])); + } + } + else + { -}//end of init function + if($rule_cnt[$i]==$rule_cnt[$j]) + { + //echo '<br/>Equal $i ' . $i. ' $j ' .$j; + array_push($tie_rules,$rule_id[$i],$rule_id[$j]); + $tie_rule_cnt=$rule_cnt[$i]; + drupal_set_message(t('rule cnt i: '. $tie_rules[$i] . 'rule cnt j: '.$tie_rules[$j])); + } + else if($max < $rule_cnt[$i]) + { + $max_rule_cnt=$rule_cnt[$i]; + $max_rule_id=$rule_id[$i]; + drupal_set_message(t( '$max_rule_id is : ' . $rule_id[$i])); + } + } + } + + }//end of for1 + + //echo '<br/> Max: '. $max ; + drupal_set_message(t( '$max_rule_cnt is : ' . $max_rule_cnt)); + if(($max_rule_cnt==$tie_rule_cnt) || ($max_rule_cnt==0)) + { + drupal_set_message(t( 'Tie')); + + } + else + { + drupal_set_message(t( 'NOT Tie' . '$max_rule_id: ' . $max_rule_id)); + db_query("update vc_group set vc_selected_rules_id =%d where id=%d",$max_rule_id,$group_id); + } + + // drupal_set_message(t('Rule id : ' . $final_rule_id.'Group id is: ' . $group_id)); + + }//end of while + + }//end of init function + + // several ways to implement this - + // 1. use array_rand to get a set of random keys into the array + // 2. use shuffle and then take an array_slice from 0 to $how_many + private function generateTurnSequence($how_many, $no_of_students) { + $students = range(1,$no_of_students); + $keys = array_rand( range(1, $no_of_students), $how_many ); + $turn_sequence = array(); + foreach ($keys as $key) { + $turn_sequence[] = $students[$key]; + } + return $turn_sequence; + } + + public function initRules() + { + $result_group=db_query("select id,vc_selected_rules_id from vc_group where vc_game_id=%d",$this->game_id); + while($data=db_fetch_object($result_group)) + { + $group_id=$data->id; + $selected_rule_id=$data->vc_selected_rules_id; + $selected_rule_no=db_result(db_query("select rule_no from vc_rules where id=%d",$selected_rule_id)); + $no_of_student=db_result(db_query("SELECT count(*) FROM vc_student WHERE vc_group_id=%d",$group_id)); + $round_no=$this->getCurrentRoundNo(); + + // FIXME: see if we can encapsulate this within the Rules + // themselves, because this appears to be specific to a forestry + // game. + if($selected_rule_no==1) + { + // pick N students for the lottery + switch ($no_of_student) { + case 3: + // in even numbered rounds, pick only 1 person, otherwise + // pick two. + $how_many = ($round_no % 2) + 1; + 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 = implode(',', $this->generateTurnSequence($how_many, $no_of_student)); + 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 + } + else if($selected_rule_no==3) + { + //setting for rule 3 + } + } + $this->updateStartFlag(true); + } + public function getCurrentRuleNumber($group_id) { + return db_result(db_query("SELECT r.rule_no FROM {vc_rules r, vc_group g} WHERE r.id=g.vc_selected_rules_id AND g.id=%d", $group_id)); + } + + }//end of class Game class Group { @@ -387,6 +549,10 @@ return $this->group_id; } + public function getGame() { + return $this->game; + } + public function getGameId() { if ( isset($this->game) ) { return $this->game->getGameId(); @@ -397,6 +563,10 @@ } } + public function getTurnSequence() { + return $this->game->getTurnSequence($this->group_id); + } + public function getExperimentId() { return $this->game->getExperimentId(); } @@ -410,7 +580,7 @@ } public function getCurrentRuleNumber() { - return db_result(db_query("SELECT r.rule_no FROM {vc_rules r, vc_group g} WHERE r.id=g.vc_selected_rules_id AND g.id=%d", $this->group_id)); + return $this->game->getCurrentRuleNumber(); } @@ -436,76 +606,78 @@ return $this->game->getCurrentStageId(); } - public function isTieHappened() - { - $selected_rule_id=db_result(db_query("select vc_selected_rules_id from vc_group where id=%d",$this->group_id)); - if($selected_rule_id ==NULL) - { - return true; - } - else - { - return false; - - } - - } - - public function getSelectedRule() - { - $result_rule=db_query("select rule_no, description from vc_rules r, vc_group g where r.id =g.vc_selected_rules_id and g.id=%d",$this->group_id); - //$rule=array(); - while($data_rule=db_fetch_object($result_rule)) - { - $rule[]=array($data_rule->rule_no); - $rule[]=array($data_rule->description); - //drupal_set_message(t($data_rule->description)); - } - // drupal_set_message(t('Description is:' . $rule[1][0] )); - return $rule; - } + public function isTieHappened() + { + $selected_rule_id=db_result(db_query("select vc_selected_rules_id from vc_group where id=%d",$this->group_id)); + if($selected_rule_id ==NULL) + { + return true; + } + else + { + return false; - public function getRuleNo() - { - $result_voting=db_query("select vc_rules_id,count(vc_rules_id) as rule_cnt from vc_student_voting where vc_student_id in (select id from vc_student where vc_group_id=%d) group by vc_rules_id",$group_id); - $rule_id=array(); - $rule1_cnt=array(); - $final_rule_no=array(); - while($data=db_fetch_object($result_voting)) - { - array_push($rule_id,$data->vc_rules_id); - array_push($rule_cnt,$data->rule_cnt); - } - for($i=0;$i<count($rule_cnt);$i++) - { - for($j=$i+1;$j<count($rule_cnt);$j++) - { - - if($rule_cnt[$i]==$rule_cnt[$j]) - { - //echo '$i ' . $i. ' $j ' .$j; - //array_push($final_rule_id - array_push($final_rule_no,db_result(db_query("select rule_no from vc_rules where id =%d",$rule_id[$i]))); - array_push($final_rule_no,db_result(db_query("select rule_no from vc_rules where id =%d",$rule_id[$j]))); + } - } - } + } - } - drupal_set_message(t('Rule no : ' . $final_rule_no[0].' ' .$final_rule_no[1]. 'Group id is: ' . $group_id)); - return $final_rule_no; + public function getSelectedRule() + { + $result_rule=db_query("select rule_no, description from vc_rules r, vc_group g where r.id =g.vc_selected_rules_id and g.id=%d",$this->group_id); + //$rule=array(); + while($data_rule=db_fetch_object($result_rule)) + { + $rule[]=array($data_rule->rule_no); + $rule[]=array($data_rule->description); + //drupal_set_message(t($data_rule->description)); + } + // drupal_set_message(t('Description is:' . $rule[1][0] )); + return $rule; + } - } + public function getRuleNo() + { + $result_voting=db_query(" select vc_rules_id, count(vc_rules_id) from vc_student_voting v + where v.time_created >= (select max(time_created) from vc_student_voting vv where v.vc_student_id=vv.vc_student_id) and + v.vc_student_id in (select id from vc_student where vc_group_id=%d) group by vc_rules_id",$group_id); + $rule_id=array(); + $rule_cnt=array(); + $final_rule_no=array(); + while($data=db_fetch_object($result_voting)) + { + array_push($rule_id,$data->vc_rules_id); + array_push($rule_cnt,$data->rule_cnt); + } + for($i=0;$i<count($rule_cnt);$i++) + { + for($j=$i+1;$j<count($rule_cnt);$j++) + { - + if($rule_cnt[$i]==$rule_cnt[$j]) + { + //echo '$i ' . $i. ' $j ' .$j; + //array_push($final_rule_id + array_push($final_rule_no,db_result(db_query("select rule_no from vc_rules where id =%d",$rule_id[$i]))); + array_push($final_rule_no,db_result(db_query("select rule_no from vc_rules where id =%d",$rule_id[$j]))); - /*public function getRuleDescription() - { - db_result(db_query("select description select vc_selected_rules_id from vc_group where id=%d",$this->group_id)); - - }*/ + } + } - + } + //drupal_set_message(t('Rule no : ' . $final_rule_no[0].' ' .$final_rule_no[1]. 'Group id is: ' . $this->group_id)); + return $final_rule_no; + + } + + + + /*public function getRuleDescription() + { + db_result(db_query("select description select vc_selected_rules_id from vc_group where id=%d",$this->group_id)); + + }*/ + + }//end of Group /** @@ -540,9 +712,12 @@ $this->stage_id=$stage_id; } - public function getRoundNo() + public function getRoundNo($game_id,$stage_id) { - db_result(db_query("select current_round_no from vc_game where id=%d",$this->game_id)); + //$this-> + $this->round_no=db_result(db_query("select current_round_no from vc_game where id=%d and vc_stage_id=%d",$game_id,$stage_id)); + + //drupal_set_message(t('round no is:' .$stage_id . $this->round_no . $game_id)); return $this->round_no; } @@ -570,7 +745,14 @@ public function saveForestryStudentInfo($round_no,$stud_harvest_decision) { - db_query("Insert into {vc_forestry_student} (round_no,vc_student_id,vc_stage_id,harvest_decision) values(%d,'%s',%d,%d)",$round_no,$this->stud_id,$this->stage_id,$stud_harvest_decision); + $total = db_result(db_query("SELECT sum(harvest_decision) + FROM {vc_forestry_student} + WHERE vc_student_id='%s' + AND vc_stage_id=%d", + $this->stud_id, + $this->stage_id)); + db_query("Insert into {vc_forestry_student} (round_no,vc_student_id,vc_stage_id,harvest_decision, total_points) values(%d,'%s',%d,%d, %d)", + $round_no,$this->stud_id,$this->stage_id,$stud_harvest_decision, $total); } public function updateStartFlag($flag) @@ -593,61 +775,63 @@ class Rules { - public function getRules($stage_id) - { - $result=db_query("Select rule_no,description from vc_rules where vc_stage_id=%d",$stage_id ); - while($data=db_fetch_object($result)) - { - $rules[$data->rule_no]=array($data->description); - } + public function getRules($stage_id) + { + drupal_set_message(t('current stage is : ' . $stage_id)); + $result=db_query("Select rule_no,description from vc_rules where vc_stage_id=%d",$stage_id ); + while($data=db_fetch_object($result)) + { + $rules[$data->rule_no]=array($data->description); + } - return $rules; - } + return $rules; + } - public function saveStudentVoting($stud_id,$rule_no,$stage_id) - { - $rule_id=db_result(db_query("select id from vc_rules where vc_stage_id=%d and rule_no=%d",$stage_id,$rule_no)); - db_query("insert into {vc_student_voting} (vc_student_id,vc_rules_id) values('%s',%d)",$stud_id,$rule_id); - - } + public function saveStudentVoting($stud_id,$rule_no,$stage_id) + { + $rule_id=db_result(db_query("select id from vc_rules where vc_stage_id=%d and rule_no=%d",$stage_id,$rule_no)); + db_query("insert into {vc_student_voting} (vc_student_id,vc_rules_id) values('%s',%d)",$stud_id,$rule_id); + + } } class Survey { - - public function getSurveyQuestions($exp_id) - { - $survey_id=db_result(db_query("Select id from vc_survey where vc_experiment_id=%d",$exp_id)); - $Q_result=db_query("Select id,vc_rules_id,questions from vc_survey_questions where vc_survey_id=%d",$survey_id); - - //get questions - while($survey=db_fetch_object($Q_result)) - { - $Q_id=$survey->id; - $rule_id=$survey->vc_rules_id; - $questions=$survey->questions; - $rule_no=db_result(db_query("select rule_no from vc_rules where id= %d",$rule_id)); - - //get options for questions - $option_result=db_query("select min_value,max_value from vc_survey_questions_options where vc_survey_questions_id=%d",$Q_id); - while($survey_ans=db_fetch_object($option_result)) - { - $survey_data[$rule_no][$questions]=array($survey_ans->min_value,1,2,3,4,5,$survey_ans->max_value); - } + public function getSurveyQuestions($exp_id) + { + $survey_id=db_result(db_query("Select id from vc_survey where vc_experiment_id=%d",$exp_id)); + $Q_result=db_query("Select id,vc_rules_id,questions from vc_survey_questions where vc_survey_id=%d",$survey_id); - } - - return $survey_data; - } + //get questions + while($survey=db_fetch_object($Q_result)) + { + $Q_id=$survey->id; + $rule_id=$survey->vc_rules_id; + $questions=$survey->questions; + $rule_no=db_result(db_query("select rule_no from vc_rules where id= %d",$rule_id)); + //get options for questions + $option_result=db_query("select min_value,max_value from vc_survey_questions_options where vc_survey_questions_id=%d",$Q_id); - public function saveSurveyResponse($stage_id,$stud_id,$rule,$Q,$ans) - { - $rule_id=db_result(db_query("select id from vc_rules where rule_no=%d and vc_stage_id=%d",$rule,$stage_id)); - $Q_id=db_result(db_query("select id from vc_survey_questions where vc_rules_id=%d and questions='%s'",$rule_id,$Q)); - db_query("insert into {vc_survey_response} (vc_student_id,vc_survey_questions_id,response) values('%s',%d,'%s')",$stud_id,$Q_id,$ans); - - } + while($survey_ans=db_fetch_object($option_result)) + { + $survey_data[$rule_no][$questions]=array($survey_ans->min_value,1,2,3,4,5,$survey_ans->max_value); + } + } + + return $survey_data; + } + + + public function saveSurveyResponse($stage_id,$stud_id,$rule,$Q,$ans) + { + $rule_id=db_result(db_query("select id from vc_rules where rule_no=%d and vc_stage_id=%d",$rule,$stage_id)); + $Q_id=db_result(db_query("select id from vc_survey_questions where vc_rules_id=%d and questions='%s'",$rule_id,$Q)); + db_query("insert into {vc_survey_response} (vc_student_id,vc_survey_questions_id,response) values('%s',%d,'%s')",$stud_id,$Q_id,$ans); + + } + } + Modified: vcweb/trunk/virtualcommons/experiment/games/forestry_v2/forestry_v2.install =================================================================== --- vcweb/trunk/virtualcommons/experiment/games/forestry_v2/forestry_v2.install 2008-08-08 06:31:48 UTC (rev 36) +++ vcweb/trunk/virtualcommons/experiment/games/forestry_v2/forestry_v2.install 2008-08-09 01:56:09 UTC (rev 37) @@ -87,8 +87,8 @@ vc_student_id varchar(14) NOT NULL, vc_stage_id int NOT NULL, harvest_decision int NOT NULL, - fine int, - total_points int, + fine int default 0, + total_points int default 0, date TIMESTAMP NOT NULL, PRIMARY KEY(id), Modified: vcweb/trunk/virtualcommons/experiment/games/forestry_v2/forestry_v2.module =================================================================== --- vcweb/trunk/virtualcommons/experiment/games/forestry_v2/forestry_v2.module 2008-08-08 06:31:48 UTC (rev 36) +++ vcweb/trunk/virtualcommons/experiment/games/forestry_v2/forestry_v2.module 2008-08-09 01:56:09 UTC (rev 37) @@ -140,13 +140,13 @@ $current_stage_no = $group->getCurrentStageNumber(); $current_stage_no = (int) $current_stage_no; drupal_set_message(t('current stage is: '. $current_stage_no)); - if($current_stage_no==1) - return 'forestry_stage1'; + return 'forestry_stage1'; + /* else if($current_stage_no==2) { $current_rule_no=$group->getCurrentRuleNumber(); switch($current_rule_no) - { + { case 1: return 'forestry_stage2_rule1'; case 2: @@ -156,6 +156,7 @@ } } + */ } else { return 'forestry'; @@ -166,7 +167,6 @@ function forestry_game_stage1() { - drupal_set_message(t('reosurce available ')); // Return the HTML generated from the $form data structure. $output = drupal_get_form('forestry_game_stage1_multiform'); return $output; @@ -205,12 +205,21 @@ drupal_set_message(t('PREV resource is NOW set to : ' . $resource_available)); } $_SESSION['prev_resource']=$resource_available; - $header=array("Round Number","Your Harvest Decision","Resources Before","Resources After"); - $final_row=$student->getForestryStudentInfo($group_id,$game_id); + $game = $group->getGame(); + if ( $game->isVotingEnabled() ) { + $header=array("Round Number","Your Harvest Decision","Resources Before","Resources After",'Penalty', 'Net Gain', ); + } + else { + $header=array("Round Number","Your Harvest Decision","Resources Before","Resources After"); + } - $round_no=$student->getRoundNo()+1; + $row=$student->getForestryStudentInfo($group_id,$game_id); + $stage_id=$group->getCurrentStageId(); + + $round_no=$student->getRoundNo($game_id,$stage_id); + drupal_set_message(t('round no: ' .$round_no .' '. gettype($round_no) )); @@ -249,10 +258,7 @@ '#maxlength'=>2, '#required'=>TRUE ); - $form['indicator']['submit'] = array( - '#type' => 'submit', - '#value' => t('Next') - ); + } else { @@ -262,18 +268,18 @@ '#type' => 'submit', '#value' => t('Next Stage') ); + } - $form['resource']=array( - + $form['resource']=array( '#type'=>'fieldset', '#title'=>t('<b>Resources</b>'), ); - $form['resource']['table']=array( + $form['resource']['table']=array( '#type'=>'markup', - '#value'=>theme('table',$header,$final_row) + '#value'=>theme('table',$header,$row) ); Session::put('forestry_student',$student); @@ -418,7 +424,7 @@ $stage_no=2; $exp_id=$group->getExperimentId(); $game_id=$group->getGameId(); - $student->updateStageId($stage_no,$exp_id,$game_id); + // $student->updateStageId($stage_no,$exp_id,$game_id); //db_query("update virtualcommons_conducts set virtualcommons_stage_no=%d where id=%d",2,$virtual_conducts_id); unset($_SESSION['prev_resource']); @@ -484,6 +490,7 @@ function forestry_game_stage1_part2form() { + $form['submit'] = array( '#type' => 'submit', '#value' => t('Next Round') Modified: vcweb/trunk/virtualcommons/experiment/rules/rules.module =================================================================== --- vcweb/trunk/virtualcommons/experiment/rules/rules.module 2008-08-08 06:31:48 UTC (rev 36) +++ vcweb/trunk/virtualcommons/experiment/rules/rules.module 2008-08-09 01:56:09 UTC (rev 37) @@ -116,11 +116,12 @@ $stud_id=$_SESSION['student_id']; $rule_no=(int) $form_values['indicator']['vote']; $group=Session::get('group'); + $rules=new Rules(); + $rules->saveStudentVoting($stud_id,$rule_no,$group->getCurrentStageId()); + //$exp_name=db_result(db_query("select exp_name from virtualcommons_experiments where id in(select virtualcommons_experiments_id from virtualcommons_conducts where id in (select virtualcommons_conducts_id from virtualcommons_student where id='%s'))",$_SESSION['student_id'])); //$virtual_conduct_id=db_result(db_query("select virtualcommons_conducts_id from virtualcommons_student where id='%s' ",$stud_id)); //db_query("update virtualcommons_conducts set virtualcommons_rule_no=%d where id=%d",$rule_no,$virtual_conduct_id); - $rules=new Rules(); - $rules->saveStudentVoting($stud_id,$rule_no,$group->getCurrentStageId()); return 'survey'; Modified: vcweb/trunk/virtualcommons/experiment/survey/survey.module =================================================================== --- vcweb/trunk/virtualcommons/experiment/survey/survey.module 2008-08-08 06:31:48 UTC (rev 36) +++ vcweb/trunk/virtualcommons/experiment/survey/survey.module 2008-08-09 01:56:09 UTC (rev 37) @@ -1,39 +1,40 @@ <?php +//vim:sts=2:sw=2:filetype=php function rule_decision_load() { - static $loaded = FALSE; - - if (!$loaded) { - $path = drupal_get_path('module', 'forestry_stage1'); - drupal_add_css($path .'/form.css'); - $loaded = TRUE; - } + static $loaded = FALSE; + + if (!$loaded) { + $path = drupal_get_path('module', 'forestry_stage1'); + drupal_add_css($path .'/form.css'); + $loaded = TRUE; + } } function survey_menu($may_cache) { $items = array(); if ($may_cache) { - -$items[]=array( 'path' => 'survey', + + $items[]=array( 'path' => 'survey', 'title' => t('Survey'), 'callback' => 'survey', - 'type'=>MENU_CALLBACK, + 'type'=>MENU_CALLBACK, 'access' => TRUE//user_access('Only Teachers') ); -$items[]=array( 'path' => 'rule_decision', - // 'title' => t('Rule Decision'), + $items[]=array( 'path' => 'rule_decision', + // 'title' => t('Rule Decision'), 'callback' => 'voting_rule_decision', - 'type'=>MENU_CALLBACK, + 'type'=>MENU_CALLBACK, 'access' => TRUE//user_access('Only Teachers') ); } -else -{ -rule_decision_load(); -} - + else + { + rule_decision_load(); + } + return $items; } @@ -41,7 +42,7 @@ // Return the HTML generated from the $form data structure. -$output='Till we determine the results of the voting, please fill out a following survey'; + $output='Till we determine the results of the voting, please fill out a following survey'; $output .= drupal_get_form('survey_form'); return $output; } @@ -49,88 +50,88 @@ function survey_form() { -$form['#id']='survey_form'; -$form['#tree'] = TRUE; -$stud_id=$_SESSION['student_id']; + $form['#id']='survey_form'; + $form['#tree'] = TRUE; + $stud_id=$_SESSION['student_id']; -//$group=Session::get('group'); + //$group=Session::get('group'); -//$exp_id=$group->getExperimentId(); -$survey=new Survey(); -$exp_id=2; -$survey_data=$survey->getSurveyQuestions($exp_id); -$_SESSION['survey_data']=$survey_data; -$header[]='Survey Questions'; -foreach($survey_data as $rule=>$Q_array) -{ - $form['resource'][$rule]=array( - '#type'=>'fieldset', - '#title'=>t('<b>Rule '. $rule. '</b>'), - ); - - foreach($Q_array as $Q=>$ans) - { + //$exp_id=$group->getExperimentId(); + $survey=new Survey(); + $exp_id=2; + $survey_data=$survey->getSurveyQuestions($exp_id); + $_SESSION['survey_data']=$survey_data; + $header[]='Survey Questions'; + foreach($survey_data as $rule=>$Q_array) + { + $form['resource'][$rule]=array( + '#type'=>'fieldset', + '#title'=>t('<b>Rule '. $rule. '</b>'), + ); - $form['resource'][$rule][$Q]['option']=array( - '#type'=>'radios', - '#title'=>t('<b>Q'. ++$Q_cnt . '. '. $Q.'</b>'), - '#options'=>$ans, - '#required'=>TRUE + foreach($Q_array as $Q=>$ans) + { - ); - } -} + $form['resource'][$rule][$Q]['option']=array( + '#type'=>'radios', + '#title'=>t('<b>Q'. ++$Q_cnt . '. '. $Q.'</b>'), + '#options'=>$ans, + '#required'=>TRUE -$form['submit'] = array( - '#type' => 'submit', - '#value' => t('Submit!!!'), - - ); + ); + } + } -return $form; + $form['submit'] = array( + '#type' => 'submit', + '#value' => t('Submit!!!'), + + ); + + return $form; } function survey_form_submit($form,$form_values) { - $stud_id=$_SESSION['student_id']; - $group=Session::get('group'); - - $survey=new Survey(); -// $rules->saveStudentSurvey($stud_id,$ans); - $survey_data=$_SESSION['survey_data']; - $stage_id=$group->getCurrentStageId(); - $i=0; - foreach($survey_data as $rule=>$Q_array) - { - foreach($Q_array as $Q=>$ans) - { - // drupal_set_message(t('Question is: '. $Q . 'answers are:'. $ans[$form_values['resource'][$rule][$Q]['option']])); - $survey->saveSurveyResponse($stage_id,$stud_id,$rule,$Q,$ans[$form_values['resource'][$rule][$Q]['option']]); - $i++; - - } - } + $stud_id=$_SESSION['student_id']; + $group=Session::get('group'); - - /*if($exp_name=='Forestry Game') - { - return 'forestry'; - } + $survey=new Survey(); + // $rules->saveStudentSurvey($stud_id,$ans); + $survey_data=$_SESSION['survey_data']; + $stage_id=$group->getCurrentStageId(); + $i=0; + foreach($survey_data as $rule=>$Q_array) + { + foreach($Q_array as $Q=>$ans) + { + // drupal_set_message(t('Question is: '. $Q . 'answers are:'. $ans[$form_values['resource'][$rule][$Q]['option']])); + $survey->saveSurveyResponse($stage_id,$stud_id,$rule,$Q,$ans[$form_values['resource'][$rule][$Q]['option']]); + $i++; - else if($exp_name=='Fishery Game') - { - return 'fishery'; - } - - else if($exp_name=='Water Irrigation Game') - { - return 'water'; - - }*/ -return 'rule_decision'; + } + } + + /*if($exp_name=='Forestry Game') + { + return 'forestry'; + } + + else if($exp_name=='Fishery Game') + { + return 'fishery'; + } + + else if($exp_name=='Water Irrigation Game') + { + return 'water'; + + }*/ + return 'rule_decision'; + } @@ -139,7 +140,7 @@ function voting_rule_decision() { - $output='Voting decision has been done.'; + $output='Voting decision has been done.'; $output .= drupal_get_form('rule_decision_form'); return $output; @@ -147,92 +148,116 @@ function rule_decision_form() { - $stud_id=$_SESSION['student_id']; - $group=Session::get('group'); - $tie_flag=$group->isTieHappened(); - //t('There is a tie between votings. You need to vote again for the following rules') - if($tie_flag) - { - $rule_no=$group->getRuleNo(); - $form['rule1']=array( - '#title'=>t('Rule No. '), - '#type'=>'item', - '#value'=>$rule_no[0] - ); - $form['rule2']=array( - '#title'=>t('Rule No. '), - '#type'=>'item', - '#value'=>$rule_no[1] - ); - - $form['vote']=array( - '#prefix'=>'<div class="indicator">', - '#type'=>'textfield', - '#title'=>t('Your Vote'), - '#default_value'=>'0', - '#size'=>1, - '#maxlength'=>1, - '#required'=>TRUE - ); - $form['submit'] = array( - '#type' => 'submit', - '#value' => t('Vote'), - '#suffix'=>'</div>' - ); + $stud_id=$_SESSION['student_id']; + $group=Session::get('group'); + $tie_flag=$group->isTieHappened(); + //t('There is a tie between votings. You need to vote again for the following rules') + if($tie_flag) + { + $rule_no=$group->getRuleNo(); + $form['rule']=array( + '#title'=>t('There is a tie between following rules. Please vote again. If tie happens one more time after this voting, final rule will be randomly chosen from the following rules.'), + '#type'=>'item', + ); + $form['rule1']=array( + '#title'=>t('Rule No. '), + '#type'=>'item', + '#value'=>$rule_no[0] + ); + $form['rule2']=array( + '#title'=>t('Rule No. '), + '#type'=>'item', + '#value'=>$rule_no[1] + ); - } - else - { - $rule_info=$group->getSelectedRule(); - foreach ($rule_info as $key=>$value) - { - //drupal_set_message(t('Selected rule no is: '. $key . 'Description is : ' . $value)); + $form['vote']=array( + '#prefix'=>'<div class="indicator">', + '#type'=>'textfield', + '#title'=>t('Your Vote'), + '#default_value'=>'0', + '#size'=>1, + '#maxlength'=>1, + '#required'=>TRUE + ); + $form['submit'] = array( + '#type' => 'submit', + '#value' => t('Vote'), + '#suffix'=>'</div>' + ); - $form['rule']=array( - '#title'=>t('Please be patience until others voting decision has made. Teacher will tell you when to click the next button. '), - '#type'=>'item', - ); - - $form['rule']=array( - '#title'=>t('Selected Rule no is '), - '#type'=>'item', - '#value'=>$key - ); - $form['rule_description']=array( - '#title'=>t('Description for this rule is '), - '#type'=>'item', - '#value'=>$value[0] - ); - $form['submit'] = array( - '#type' => 'submit', - '#value' => t('Next') + } + else + { + $rule_info=$group->getSelectedRule(); + foreach ($rule_info as $key=>$value) + { + //drupal_set_message(t('Selected rule no is: '. $key . 'Description is : ' . $value)); - ); - - } - - } + $form['rule']=array( + '#title'=>t('Please be patience until others voting decision has made. Teacher will tell you when to click the next button. '), + '#type'=>'item', + ); - return $form; + $form['rule']=array( + '#title'=>t('Selected Rule no is '), + '#type'=>'item', + '#value'=>$key + ); + $form['rule_description']=array( + '#title'=>t('Description for this rule is '), + '#type'=>'item', + '#value'=>$value[0] + ); + $form['submit'] = array( + '#type' => 'submit', + '#value' => t('Next') + ); + + } + + } + + return $form; + } function rule_decision_form_validate($form_id,$form_values) { + $vote=$form_values['vote']; + if($form_vlaues['submit']=="Vote") + { + if(preg_match('/[^1-3]+/',$vote)) + { + form_set_error('vote',t('Vote can not be alphabet or special character. It must be either 1, 2 or 3.')); + } + } + return; + } function rule_decision_form_submit($form,$form_values) { - if($form_values['submit']=="Next") - { - $stud_id=$_SESSION['student_id']; - $group=Session::get('group'); - return 'forestry'; - - } - + if($form_values['submit']=="Next") + { + } + else if($form_values['submit']=="Vote") + { + $stud_id=$_SESSION['student_id']; + $rule_no=(int) $form_values['vote']; + drupal_set_message(t('student id: '. $stud_id . 'rule no is: ' . $rule_no)); + $group=Session::get('group'); + $rules=new Rules(); + $rules->saveStudentVoting($stud_id,$rule_no,$group->getCurrentStageId()); + } + return 'forestry'; + + + + + } Modified: vcweb/trunk/virtualcommons/experiment/teacher_dashboard/teacher_dashboard.module =================================================================== --- vcweb/trunk/virtualcommons/experiment/teacher_dashboard/teacher_dashboard.module 2008-08-08 06:31:48 UTC (rev 36) +++ vcweb/trunk/virtualcommons/experiment/teacher_dashboard/teacher_dashboard.module 2008-08-09 01:56:09 UTC (rev 37) @@ -30,7 +30,6 @@ function teacher_dashboard() { - // Return the HTML generated from the $form data structure. $teacher_id=$GLOBALS['user']->uid; //db_query( @@ -45,46 +44,41 @@ } +function display_stage_data($game) { + $all_stage_data = $game->getAllGroupRoundInfo(); + $header_novoting=array('Round No','Group No', 'Group Harvest Decision','Resources Before','Resources After'); + $header_voting=array('Round No','Group No', 'Group Harvest Decision','Resources Before','Resources After', 'Dice', 'Rule #'); + foreach ($all_stage_data as $stage_id => $stage_data) + { + $stage_no = $game->getStageNumber($stage_id); + $form['stage_'.$stage_no]=array( + '#type'=>'fieldset', + '#title'=>t("<b>Stage ${stage_no}</b>") + ); + $header = ($game->isVotingEnabledForStage($stageId) ? $header_voting : $header_novoting); + $form['stage_'.$stage_no]['table']=array( + '#type'=>'markup', + '#value'=>theme('table',$header,$stage_data) + ); + } + +} + function teacher_dashboard_multiform($form_values=NULL) { - $form['#id']='teacher_dashboard_multiform'; $form['#multistep']=TRUE; $game = Session::get('game'); // $teacher_id=$GLOBALS['user']->uid; $round_no=0; $stage_flag=FALSE; -//$form['#redirect']=FALSE; - $curr_round_no=$game->getCurrentRoundNo(); - $no_rounds= $game->getNumberOfRounds(); - - // $no_rounds=(int) $no_rounds; - drupal_set_message(t('no of rounds are: ' . $no_rounds . ' and current round no is: '. $curr_round_no)); - if(($curr_round_no-1) == $no_rounds) - { - // if(isset($_SESSION['next_stage'])) - //{ - // $stage_flag=FALSE; - - //unset($_SESSION['next_stage']); - //} - //else - //{ - $stage_flag=TRUE; - - - // $form['#redirect']=TRUE; - //} - } - drupal_set_message(t('Stage flag is:' .$stage_flag)); + // display all stage data + $all_stage_data = $game->getAllGroupRoundInfo(); $header_novoting=array('Round No','Group No', 'Group Harvest Decision','Resources Before','Resources After'); $header_voting=array('Round No','Group No', 'Group Harvest Decision','Resources Before','Resources After', 'Dice', 'Rule #'); - - $all_stage_data = $game->getAllGroupRoundInfo(); - foreach ($all_stage_data as $stage_id => $stage_data) - { + { $stage_no = $game->getStageNumber($stage_id); $form['stage_'.$stage_no]=array( '#type'=>'fieldset', @@ -97,25 +91,40 @@ ); } - if($stage_flag) - { - $form['submit'] = array( - '#type' => 'submit', - '#value' => t('Go to Next Stage') - ); - $stage_flag=FALSE; - - } - else - { - $form['submit'] = array( - '#type' => 'submit', - '#value' => t('Next Round') - ); - } - + if ($game->isFinished()) { + // $output = t('The game is over.'); + drupal_set_message('The game is over. Thanks for participating!'); + /* + $form['final_msg']=array( + '#type'=>'markup', + '#value'=>'<h3>The game is over. Thank you for participating!!!</h3>'); + */ + } + else { + if ($game->isVotingEnabled()) + { + if (!($game->isVotingDone())) + { + $stage_flag=TRUE; + } + } + else + { + $stage_flag=$game->isStageOver(); + if($stage_flag) + $game->setRoundNo($game->getCurrentRoundNo()); + + + } + drupal_set_message(t('Stage flag is:' .$stage_flag)); - + $form['submit'] = array( + '#type' => 'submit', + '#value' => ($stage_flag) ? t('Go to Next Stage') : t('Next Round') + ); + + } + return $form; } @@ -127,14 +136,14 @@ drupal_set_message(t($form_values['submit'])); if($form_values['submit']=="Go to Next Stage") { - if (!($game->isVotingEnabled())) - { - if (!($game->isVotingDone())) - { - form_set_error('submit',t('Please tell students to vote. Without voting you can not proceed to Stage 2')); - } - - } + if (($game->isVotingEnabled())) + { + if (!($game->isVotingDone())) + { + form_set_error('submit',t('Please tell students to vote. Without voting you can not proceed to Stage 2')); + } + + } } } @@ -149,115 +158,31 @@ $game=Session::get('game'); if($form_values['submit']=="Next Round") { - $no_rounds = $game->getNumberOfRounds(); - $curr_round_no = $game->getCurrentRoundNo(); - $game->processGroups(); + // $no_rounds = $game->getNumberOfRounds(); + // $curr_round_no = $game->getCurrentRoundNo(); + $game->nextRound(); } else if($form_values['submit']=="Go to Next Stage") { //initialise the stage 2 - - $game->setRoundNo($game->getCurrentRoundNo()); - drupal_set_message(t('Go to stage 2')); - // $round_no=1; - // $_SESSION['next_stage']='pressed'; - //make initialisation for stage2 - $game->initNextStage(); - $current_stage_no = $game->getCurrentStageNumber(); - drupal_set_message(t('current stage is: '. $current_stage_no)); - if($current_stage_no==2) + drupal_set_message(t('Go to stage 2')); + // FIXME: initNextStage is actually an initialization for voting stage - + // remove that assumption + + + $game->initNextStage(); + if ($game->isVotingEnabled()) { - $rule_no=$game->getCurrentRuleNumber(); - - if($rule_no==1) - { - while($data=db_fetch_object($result_group)) + if ($game->isVotingDone()) { - $no_of_student=$data->cnt; - $group_no=$data->group_no; - if($no_of_student==3) - { - if(($round_no%2)==0) //even - { - $stud=rand(1,$no_of_student); - drupal_set_message(t('1 insert')); - db_query("insert into {virtualcommons_forestry_turn_sequence} - (virtualcommons_stage_no,round_no,virtualcommons_student_group_no,virtualcommons_rules_no,turn_sequence,virtualcommons_conducts_id) - values (%d,%d,%d,%d,'%s',%d)",2,$round_no,$group_no,$rule_no,$stud,$virtual_conduct_id); - } - else //uneven - { - $stud1=rand(1,$no_of_student); - $stud2=rand(1,$no_of_student); + $rule_no=$game->initRules(); + } - while($stud1 == $stud2) - { - $stud1=rand(1,$no_of_student); - $stud2=rand(1,$no_of_student); - } - $stud=$stud1.$stud2; - drupal_set_message(t('2 insert')); - db_query("insert into {virtualcommons_forestry_turn_sequence} - (virtualcommons_stage_no,round_no,virtualcommons_student_group_no,virtualcommons_rules_no,turn_sequence,virtualcommons_conducts_id) - values (%d,%d,%d,%d,'%s',%d)",2,$round_no,$group_no,$rule_no,$stud,$virtual_conduct_id); - } - } - - - - if($no_of_student==4) - { - $stud1=rand(1,$no_of_student); - $stud2=rand(1,$no_of_student); - - while($stud1 == $stud2) - { - $stud1=rand(1,$no_of_student); - $stud2=rand(1,$no_of_student); - } - $stud=$stud1.$stud2; - drupal_set_message(t('3 insert')); - db_query("insert into {virtualcommons_forestry_turn_sequence} - (virtualcommons_stage_no,round_no,virtualcommons_student_group_no,virtualcommons_rules_no,turn_sequence,virtualcommons_conducts_id) - values (%d,%d,%d,%d,'%s',%d)",2,$round_no,$group_no,$rule_no,$stud,$virtual_conduct_id); - } - - - if($no_of_student==5) - { - $stud1=rand(1,$no_of_student); - $stud2=rand(1,$no_of_student); - - while($stud1 == $stud2) - { - $stud1=rand(1,$no_of_student); - $stud2=rand(1,$no_of_student); - } - $stud=$stud1.$stud2; - drupal_set_message(t('4 insert')); - db_query("insert into {virtualcommons_forestry_turn_sequence} - (virtualcommons_stage_no,round_no,virtualcommons_student_group_no,virtualcommons_rules_no,turn_sequence,virtualcommons_conducts_id) - values (%d,%d,%d,%d,'%s',%d)",2,$round_no,$group_no,$rule_no,$stud,$virtual_conduct_id); - - } - - - }//end of while - - }//end of rule 1 - else if($rule_no==2) - { } - else if($rule_no==3) - { - } - } - return 'teacher_dashboard'; } + return 'teacher_dashboard'; +} - - - This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <al...@us...> - 2008-08-08 06:31:39
|
Revision: 36 http://virtualcommons.svn.sourceforge.net/virtualcommons/?rev=36&view=rev Author: alllee Date: 2008-08-08 06:31:48 +0000 (Fri, 08 Aug 2008) Log Message: ----------- tagging foraging 0.1 release Added Paths: ----------- foraging/tags/foraging-0.1/ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <see...@us...> - 2008-08-07 06:19:26
|
Revision: 35 http://virtualcommons.svn.sourceforge.net/virtualcommons/?rev=35&view=rev Author: seematalele Date: 2008-08-07 06:19:36 +0000 (Thu, 07 Aug 2008) Log Message: ----------- written submit functionality in survey.module . Modified Paths: -------------- vcweb/trunk/virtualcommons/experiment/games/forestry_v2/forestry_v2.module vcweb/trunk/virtualcommons/experiment/survey/survey.module vcweb/trunk/virtualcommons/experiment/teacher_dashboard/teacher_dashboard.module Modified: vcweb/trunk/virtualcommons/experiment/games/forestry_v2/forestry_v2.module =================================================================== --- vcweb/trunk/virtualcommons/experiment/games/forestry_v2/forestry_v2.module 2008-08-07 06:17:20 UTC (rev 34) +++ vcweb/trunk/virtualcommons/experiment/games/forestry_v2/forestry_v2.module 2008-08-07 06:19:36 UTC (rev 35) @@ -135,6 +135,7 @@ $group = Session::get('group'); $flag=$group->getStartFlag($stud_id); $game_id = $group->getGameId(); + drupal_set_message(t('Student Flag is: '.$flag)); if($flag) { $current_stage_no = $group->getCurrentStageNumber(); $current_stage_no = (int) $current_stage_no; @@ -144,7 +145,8 @@ else if($current_stage_no==2) { $current_rule_no=$group->getCurrentRuleNumber(); - switch($current_rule_no) { + switch($current_rule_no) + { case 1: return 'forestry_stage2_rule1'; case 2: Modified: vcweb/trunk/virtualcommons/experiment/survey/survey.module =================================================================== --- vcweb/trunk/virtualcommons/experiment/survey/survey.module 2008-08-07 06:17:20 UTC (rev 34) +++ vcweb/trunk/virtualcommons/experiment/survey/survey.module 2008-08-07 06:19:36 UTC (rev 35) @@ -229,6 +229,7 @@ { $stud_id=$_SESSION['student_id']; $group=Session::get('group'); + return 'forestry'; } Modified: vcweb/trunk/virtualcommons/experiment/teacher_dashboard/teacher_dashboard.module =================================================================== --- vcweb/trunk/virtualcommons/experiment/teacher_dashboard/teacher_dashboard.module 2008-08-07 06:17:20 UTC (rev 34) +++ vcweb/trunk/virtualcommons/experiment/teacher_dashboard/teacher_dashboard.module 2008-08-07 06:19:36 UTC (rev 35) @@ -163,17 +163,14 @@ //make initialisation for stage2 $game->initNextStage(); + $current_stage_no = $game->getCurrentStageNumber(); + drupal_set_message(t('current stage is: '. $current_stage_no)); + if($current_stage_no==2) + { + $rule_no=$game->getCurrentRuleNumber(); - /* $rule_no=db_result(db_query("select virtualcommons_rule_no from virtualcommons_conducts where id=%d",$virtual_conduct_id)); - $group_no=db_result(db_query(" select virtualcommons_student_group_no from {virtualcommons_forestry_student} where virtualcommons_student_id in (select id from {virtualcommons_student} where virtualcommons_conducts_id=%d) group by virtualcommons_student_group_no",$virtual_conduct_id)); - drupal_set_message(t($group_no .' ' . $virtual_conduct_id)); - // $max_resource=db_result(db_query("select max_harvest_decision from virtualcommons_forestry_common_resource_pool where virtualcommons_student_group_no=%d and virtualcommons_conducts_id=%d",$group_no,$virtual_conduct_id)); - //db_query("update {virtualcommons_forestry_common_resource_pool} set common_resource_pool=%d, harvest_decision=%d where virtualcommons_student_group_no=%d and virtualcommons_conducts_id=%d",$max_resource,$harvest_decision,$group_no,$virtual_conduct_id); - - $result_group=db_query("select count(group_no) AS cnt,group_no from {virtualcommons_student} where virtualcommons_conducts_id= %d group by group_no",$virtual_conduct_id);*/ - - if($rule_no==1) + if($rule_no==1) { while($data=db_fetch_object($result_group)) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <see...@us...> - 2008-08-07 06:17:10
|
Revision: 34 http://virtualcommons.svn.sourceforge.net/virtualcommons/?rev=34&view=rev Author: seematalele Date: 2008-08-07 06:17:20 +0000 (Thu, 07 Aug 2008) Log Message: ----------- made changes in initNextStage function in experiment.inc. rule_id was updating wrong in database,after changes it is updating correctly Modified Paths: -------------- vcweb/trunk/virtualcommons/experiment/experiment.inc Modified: vcweb/trunk/virtualcommons/experiment/experiment.inc =================================================================== --- vcweb/trunk/virtualcommons/experiment/experiment.inc 2008-08-07 04:01:26 UTC (rev 33) +++ vcweb/trunk/virtualcommons/experiment/experiment.inc 2008-08-07 06:17:20 UTC (rev 34) @@ -310,7 +310,7 @@ { $group_id=$data->id; $result_voting=db_query("select vc_rules_id,count(vc_rules_id) as rule_cnt from vc_student_voting where vc_student_id in (select id from vc_student where vc_group_id=%d) group by vc_rules_id",$group_id); - $max=0;$rule_id=array();$rule_cnt=array(); + $max_rule_cnt=0;$rule_id=array();$rule_cnt=array();$tie_rules=array();$max_rule_id=0; while($data=db_fetch_object($result_voting)) { array_push($rule_id,$data->vc_rules_id); @@ -325,8 +325,11 @@ if($rule_cnt[$i]<$rule_cnt[$j]) { - if($max < $rule_cnt[$j]) - $max=$rule_cnt[$j]; + if($max_rule_cnt < $rule_cnt[$j]) + { + $max_rule_cnt=$rule_cnt[$j]; + $max_rule_id=$rule_id[$j]; + } } else { @@ -337,8 +340,11 @@ array_push($tie_rules,$rule_id[$i],$rule_id[$j]); $tie_rule_cnt=$rule_cnt[$i]; } - elseif($max < $rule_cnt[$i]) - $max=$rule_cnt[$i]; + elseif($max < $rule_cnt[$i]) + { + $max_rule_cnt=$rule_cnt[$i]; + $max_rule_id=$rule_id[$i]; + } } } @@ -346,7 +352,7 @@ }//end of for1 //echo '<br/> Max: '. $max ; - if($max==$tie_rule_cnt) + if($max_rule_cnt==$tie_rule_cnt) { drupal_set_message(t( '<br/>tie')); @@ -354,7 +360,7 @@ else { drupal_set_message(t( '<br/>NOT tie')); - db_query("update vc_group set vc_selected_rules_id =%d where id=%d",$max,$group_id); + db_query("update vc_group set vc_selected_rules_id =%d where id=%d",$max_rule_id,$group_id); } // drupal_set_message(t('Rule id : ' . $final_rule_id.'Group id is: ' . $group_id)); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <see...@us...> - 2008-08-07 04:01:16
|
Revision: 33 http://virtualcommons.svn.sourceforge.net/virtualcommons/?rev=33&view=rev Author: seematalele Date: 2008-08-07 04:01:26 +0000 (Thu, 07 Aug 2008) Log Message: ----------- added logic for rule tie and finding maximum rule in experiment.inc Modified Paths: -------------- vcweb/trunk/virtualcommons/experiment/experiment.inc vcweb/trunk/virtualcommons/experiment/survey/survey.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-07 00:15:35 UTC (rev 32) +++ vcweb/trunk/virtualcommons/experiment/experiment.inc 2008-08-07 04:01:26 UTC (rev 33) @@ -310,27 +310,59 @@ { $group_id=$data->id; $result_voting=db_query("select vc_rules_id,count(vc_rules_id) as rule_cnt from vc_student_voting where vc_student_id in (select id from vc_student where vc_group_id=%d) group by vc_rules_id",$group_id); - $max=0; + $max=0;$rule_id=array();$rule_cnt=array(); while($data=db_fetch_object($result_voting)) { - $rule_id=$data->vc_rules_id; - $rule_cnt=$data->rule_cnt; + array_push($rule_id,$data->vc_rules_id); + array_push($rule_cnt,$data->rule_cnt); //$voting[$data->vc_rules_id]=$data->rule_cnt; - if($rule_cnt> $max) + + } + for($i=0;$i<count($rule_cnt);$i++)//for1 + { + for($j=$i+1;$j<count($rule_cnt);$j++)//for2 { - $max =$rule_cnt; - $final_rule_id=$rule_id; + + if($rule_cnt[$i]<$rule_cnt[$j]) + { + if($max < $rule_cnt[$j]) + $max=$rule_cnt[$j]; + } + else + { + + if($rule_cnt[$i]==$rule_cnt[$j]) + { + //echo '<br/>Equal $i ' . $i. ' $j ' .$j; + array_push($tie_rules,$rule_id[$i],$rule_id[$j]); + $tie_rule_cnt=$rule_cnt[$i]; + } + elseif($max < $rule_cnt[$i]) + $max=$rule_cnt[$i]; + } + } - - } - drupal_set_message(t('Rule id : ' . $final_rule_id.'Group id is: ' . $group_id)); - db_query("update vc_group set vc_selected_rules_id =%d where id=%d",$final_rule_id,$group_id); - } + }//end of for1 - -} + //echo '<br/> Max: '. $max ; + if($max==$tie_rule_cnt) + { + drupal_set_message(t( '<br/>tie')); + + } + else + { + drupal_set_message(t( '<br/>NOT tie')); + db_query("update vc_group set vc_selected_rules_id =%d where id=%d",$max,$group_id); + } +// drupal_set_message(t('Rule id : ' . $final_rule_id.'Group id is: ' . $group_id)); + + }//end of while + +}//end of init function + }//end of class Game class Group { @@ -398,17 +430,69 @@ return $this->game->getCurrentStageId(); } + public function isTieHappened() + { + $selected_rule_id=db_result(db_query("select vc_selected_rules_id from vc_group where id=%d",$this->group_id)); + if($selected_rule_id ==NULL) + { + return true; + } + else + { + return false; + + } + + } + public function getSelectedRule() { - $result_rule= db_result(db_query("select rule_no,description from vc_rules where id = (select vc_selected_rules_id from vc_group where id=%d);",$this->group_id )); - while($data=db_fetch_object($result_rule)) + $result_rule=db_query("select rule_no, description from vc_rules r, vc_group g where r.id =g.vc_selected_rules_id and g.id=%d",$this->group_id); + //$rule=array(); + while($data_rule=db_fetch_object($result_rule)) { - $rule_info=array($data->rule_no,$data->description); + $rule[]=array($data_rule->rule_no); + $rule[]=array($data_rule->description); + //drupal_set_message(t($data_rule->description)); } - return $rule_info; - + // drupal_set_message(t('Description is:' . $rule[1][0] )); + return $rule; } + public function getRuleNo() + { + $result_voting=db_query("select vc_rules_id,count(vc_rules_id) as rule_cnt from vc_student_voting where vc_student_id in (select id from vc_student where vc_group_id=%d) group by vc_rules_id",$group_id); + $rule_id=array(); + $rule1_cnt=array(); + $final_rule_no=array(); + while($data=db_fetch_object($result_voting)) + { + array_push($rule_id,$data->vc_rules_id); + array_push($rule_cnt,$data->rule_cnt); + } + for($i=0;$i<count($rule_cnt);$i++) + { + for($j=$i+1;$j<count($rule_cnt);$j++) + { + + if($rule_cnt[$i]==$rule_cnt[$j]) + { + //echo '$i ' . $i. ' $j ' .$j; + //array_push($final_rule_id + array_push($final_rule_no,db_result(db_query("select rule_no from vc_rules where id =%d",$rule_id[$i]))); + array_push($final_rule_no,db_result(db_query("select rule_no from vc_rules where id =%d",$rule_id[$j]))); + + } + } + + } + drupal_set_message(t('Rule no : ' . $final_rule_no[0].' ' .$final_rule_no[1]. 'Group id is: ' . $group_id)); + return $final_rule_no; + + } + + + /*public function getRuleDescription() { db_result(db_query("select description select vc_selected_rules_id from vc_group where id=%d",$this->group_id)); Modified: vcweb/trunk/virtualcommons/experiment/survey/survey.module =================================================================== --- vcweb/trunk/virtualcommons/experiment/survey/survey.module 2008-08-07 00:15:35 UTC (rev 32) +++ vcweb/trunk/virtualcommons/experiment/survey/survey.module 2008-08-07 04:01:26 UTC (rev 33) @@ -1,7 +1,7 @@ <?php -/*function rules_load() { +function rule_decision_load() { static $loaded = FALSE; if (!$loaded) { @@ -9,7 +9,7 @@ drupal_add_css($path .'/form.css'); $loaded = TRUE; } -}*/ +} function survey_menu($may_cache) { $items = array(); @@ -29,10 +29,10 @@ ); } -/*else +else { -rules_load(); -}*/ +rule_decision_load(); +} return $items; } @@ -149,24 +149,20 @@ { $stud_id=$_SESSION['student_id']; $group=Session::get('group'); - - $rule_info=$group->getSelectedRule(); - if(count($rule_info)==0) + $tie_flag=$group->isTieHappened(); + //t('There is a tie between votings. You need to vote again for the following rules') + if($tie_flag) { - $form['rule']=array( - '#title'=>t('Selected Rule no is '), - '#type'=>'item', - '#value'=>t('There is a tie between votings. You need to vote again for the following rules') - ); + $rule_no=$group->getRuleNo(); $form['rule1']=array( '#title'=>t('Rule No. '), '#type'=>'item', - '#value'=>$rule_1 + '#value'=>$rule_no[0] ); $form['rule2']=array( '#title'=>t('Rule No. '), '#type'=>'item', - '#value'=>$rule_2 + '#value'=>$rule_no[1] ); $form['vote']=array( @@ -177,30 +173,46 @@ '#size'=>1, '#maxlength'=>1, '#required'=>TRUE - ); - - $form['submit'] = array( + ); + $form['submit'] = array( '#type' => 'submit', - '#value' => t('Vote!!!'), + '#value' => t('Vote'), '#suffix'=>'</div>' ); - } else { - $form['rule']=array( + $rule_info=$group->getSelectedRule(); + foreach ($rule_info as $key=>$value) + { + //drupal_set_message(t('Selected rule no is: '. $key . 'Description is : ' . $value)); + + $form['rule']=array( + '#title'=>t('Please be patience until others voting decision has made. Teacher will tell you when to click the next button. '), + '#type'=>'item', + ); + + $form['rule']=array( '#title'=>t('Selected Rule no is '), '#type'=>'item', - '#value'=>$rule_info[0] + '#value'=>$key ); - - $form['rule_description']=array( - '#title'=>t('Rule Description is : ' ), + $form['rule_description']=array( + '#title'=>t('Description for this rule is '), '#type'=>'item', - '#value'=>$rule_info[1] + '#value'=>$value[0] ); + $form['submit'] = array( + '#type' => 'submit', + '#value' => t('Next') + + ); + + } + } + return $form; } @@ -213,6 +225,13 @@ function rule_decision_form_submit($form,$form_values) { + if($form_values['submit']=="Next") + { + $stud_id=$_SESSION['student_id']; + $group=Session::get('group'); + + } + } Modified: vcweb/trunk/virtualcommons/experiment/teacher_dashboard/teacher_dashboard.module =================================================================== --- vcweb/trunk/virtualcommons/experiment/teacher_dashboard/teacher_dashboard.module 2008-08-07 00:15:35 UTC (rev 32) +++ vcweb/trunk/virtualcommons/experiment/teacher_dashboard/teacher_dashboard.module 2008-08-07 04:01:26 UTC (rev 33) @@ -127,10 +127,13 @@ drupal_set_message(t($form_values['submit'])); if($form_values['submit']=="Go to Next Stage") { - if (!($game->isVotingEnabled())) { - if (!($game->isVotingDone())) { + if (!($game->isVotingEnabled())) + { + if (!($game->isVotingDone())) + { form_set_error('submit',t('Please tell students to vote. Without voting you can not proceed to Stage 2')); - } + } + } } } @@ -153,7 +156,7 @@ else if($form_values['submit']=="Go to Next Stage") { //initialise the stage 2 - $game->setRoundNo($game->getCurrentRoundNo()); + $game->setRoundNo($game->getCurrentRoundNo()); drupal_set_message(t('Go to stage 2')); // $round_no=1; // $_SESSION['next_stage']='pressed'; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |