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: <see...@us...> - 2008-08-07 00:15:26
|
Revision: 32 http://virtualcommons.svn.sourceforge.net/virtualcommons/?rev=32&view=rev Author: seematalele Date: 2008-08-07 00:15:35 +0000 (Thu, 07 Aug 2008) Log Message: ----------- move forestry info folder from forestry to forestry_v2 Added Paths: ----------- vcweb/trunk/virtualcommons/experiment/games/forestry_v2/forestry_info/ Removed Paths: ------------- vcweb/trunk/virtualcommons/experiment/games/forestry/forestry_info/ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <al...@us...> - 2008-08-07 00:09:39
|
Revision: 31 http://virtualcommons.svn.sourceforge.net/virtualcommons/?rev=31&view=rev Author: alllee Date: 2008-08-07 00:09:49 +0000 (Thu, 07 Aug 2008) Log Message: ----------- adding form.css to forestry_v2 Added Paths: ----------- vcweb/trunk/virtualcommons/experiment/games/forestry_v2/form.css Added: vcweb/trunk/virtualcommons/experiment/games/forestry_v2/form.css =================================================================== --- vcweb/trunk/virtualcommons/experiment/games/forestry_v2/form.css (rev 0) +++ vcweb/trunk/virtualcommons/experiment/games/forestry_v2/form.css 2008-08-07 00:09:49 UTC (rev 31) @@ -0,0 +1,6 @@ +.indicator .form-item label { + display: inline; + font-weight: bold; +} + + This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <al...@us...> - 2008-08-07 00:06:01
|
Revision: 30 http://virtualcommons.svn.sourceforge.net/virtualcommons/?rev=30&view=rev Author: alllee Date: 2008-08-07 00:06:11 +0000 (Thu, 07 Aug 2008) Log Message: ----------- more recent survey.module Modified Paths: -------------- vcweb/trunk/virtualcommons/experiment/survey/survey.module Modified: vcweb/trunk/virtualcommons/experiment/survey/survey.module =================================================================== --- vcweb/trunk/virtualcommons/experiment/survey/survey.module 2008-08-07 00:02:50 UTC (rev 29) +++ vcweb/trunk/virtualcommons/experiment/survey/survey.module 2008-08-07 00:06:11 UTC (rev 30) @@ -21,6 +21,12 @@ 'type'=>MENU_CALLBACK, 'access' => TRUE//user_access('Only Teachers') ); +$items[]=array( 'path' => 'rule_decision', + // 'title' => t('Rule Decision'), + 'callback' => 'voting_rule_decision', + 'type'=>MENU_CALLBACK, + 'access' => TRUE//user_access('Only Teachers') + ); } /*else @@ -123,7 +129,90 @@ return 'water'; }*/ -return 'survey'; +return 'rule_decision'; } + +//Rule Decision + +function voting_rule_decision() +{ + + $output='Voting decision has been done.'; + $output .= drupal_get_form('rule_decision_form'); + return $output; + +} + +function rule_decision_form() +{ + $stud_id=$_SESSION['student_id']; + $group=Session::get('group'); + + $rule_info=$group->getSelectedRule(); + if(count($rule_info)==0) + { + $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') + ); + $form['rule1']=array( + '#title'=>t('Rule No. '), + '#type'=>'item', + '#value'=>$rule_1 + ); + $form['rule2']=array( + '#title'=>t('Rule No. '), + '#type'=>'item', + '#value'=>$rule_2 + ); + + $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>' + ); + + + } + else + { + $form['rule']=array( + '#title'=>t('Selected Rule no is '), + '#type'=>'item', + '#value'=>$rule_info[0] + ); + + $form['rule_description']=array( + '#title'=>t('Rule Description is : ' ), + '#type'=>'item', + '#value'=>$rule_info[1] + ); + } + return $form; + +} + +function rule_decision_form_validate($form_id,$form_values) +{ + + +} + +function rule_decision_form_submit($form,$form_values) +{ + + +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <al...@us...> - 2008-08-07 00:02:42
|
Revision: 29 http://virtualcommons.svn.sourceforge.net/virtualcommons/?rev=29&view=rev Author: alllee Date: 2008-08-07 00:02:50 +0000 (Thu, 07 Aug 2008) Log Message: ----------- moving teacher_dashboard and rules under experiment Added Paths: ----------- vcweb/trunk/virtualcommons/experiment/rules/ vcweb/trunk/virtualcommons/experiment/teacher_dashboard/ Removed Paths: ------------- vcweb/trunk/virtualcommons/experiment/games/rules/ vcweb/trunk/virtualcommons/experiment/games/teacher_dashboard/ vcweb/trunk/virtualcommons/experiment/survey-questions.sql Deleted: vcweb/trunk/virtualcommons/experiment/survey-questions.sql =================================================================== --- vcweb/trunk/virtualcommons/experiment/survey-questions.sql 2008-08-06 23:58:18 UTC (rev 28) +++ vcweb/trunk/virtualcommons/experiment/survey-questions.sql 2008-08-07 00:02:50 UTC (rev 29) @@ -1,119 +0,0 @@ -insert into vc_survey(vc_experiment_id) values('1'); -insert into vc_survey(vc_experiment_id) values('2'); -insert into vc_survey(vc_experiment_id) values('3'); - -insert into vc_survey_questions(vc_survey_id,vc_rules_id,questions) values(1,1,'How efficient do you think this rule is for managing the fishing grounds?'); -insert into vc_survey_questions(vc_survey_id,vc_rules_id,questions) values(1,1,'How fair do you think this rule is for managing the fishing grounds? '); -insert into vc_survey_questions(vc_survey_id,vc_rules_id,questions) values(1,1,'How much personal freedom do you think this rule allows you in managing the fishing grounds?'); -insert into vc_survey_questions(vc_survey_id,vc_rules_id,questions) values(1,1,'How much do you think this rule would advance your own self-interest as measured by your total earning?'); -insert into vc_survey_questions(vc_survey_id,vc_rules_id,questions) values(1,1,'All things considered how attractive do you find this rule?'); - -insert into vc_survey_questions(vc_survey_id,vc_rules_id,questions) values(1,2,'How efficient do you think this rule is for managing the fishing grounds?'); -insert into vc_survey_questions(vc_survey_id,vc_rules_id,questions) values(1,2,'How fair do you think this rule is for managing the fishing grounds? '); -insert into vc_survey_questions(vc_survey_id,vc_rules_id,questions) values(1,2,'How much personal freedom do you think this rule allows you in managing the fishing grounds?'); -insert into vc_survey_questions(vc_survey_id,vc_rules_id,questions) values(1,2,'How much do you think this rule would advance your own self-interest as measured by your total earning?'); -insert into vc_survey_questions(vc_survey_id,vc_rules_id,questions) values(1,2,'All things considered how attractive do you find this rule?'); - -insert into vc_survey_questions(vc_survey_id,vc_rules_id,questions) values(1,3,'How efficient do you think this rule is for managing the fishing grounds?'); -insert into vc_survey_questions(vc_survey_id,vc_rules_id,questions) values(1,3,'How fair do you think this rule is for managing the fishing grounds? '); -insert into vc_survey_questions(vc_survey_id,vc_rules_id,questions) values(1,3,'How much personal freedom do you think this rule allows you in managing the fishing grounds?'); -insert into vc_survey_questions(vc_survey_id,vc_rules_id,questions) values(1,3,'How much do you think this rule would advance your own self-interest as measured by your total earning?'); -insert into vc_survey_questions(vc_survey_id,vc_rules_id,questions) values(1,3,'All things considered how attractive do you find this rule?'); - -insert into vc_survey_questions(vc_survey_id,vc_rules_id,questions) values(2,4,'How efficient do you think this rule is for managing the forest?'); -insert into vc_survey_questions(vc_survey_id,vc_rules_id,questions) values(2,4,'How fair do you think this rule is for managing the forest? '); -insert into vc_survey_questions(vc_survey_id,vc_rules_id,questions) values(2,4,'How much personal freedom do you think this rule allows you in managing the forest?'); -insert into vc_survey_questions(vc_survey_id,vc_rules_id,questions) values(2,4,'How much do you think this rule would advance your own self-interest as measured by your total earning?'); -insert into vc_survey_questions(vc_survey_id,vc_rules_id,questions) values(2,4,'All things considered how attractive do you find this rule?'); - - -insert into vc_survey_questions(vc_survey_id,vc_rules_id,questions) values(2,5,'How efficient do you think this rule is for managing the forest?'); -insert into vc_survey_questions(vc_survey_id,vc_rules_id,questions) values(2,5,'How fair do you think this rule is for managing the forest? '); -insert into vc_survey_questions(vc_survey_id,vc_rules_id,questions) values(2,5,'How much personal freedom do you think this rule allows you in managing the forest?'); -insert into vc_survey_questions(vc_survey_id,vc_rules_id,questions) values(2,5,'How much do you think this rule would advance your own self-interest as measured by your total earning?'); -insert into vc_survey_questions(vc_survey_id,vc_rules_id,questions) values(2,5,'All things considered how attractive do you find this rule?'); - - -insert into vc_survey_questions(vc_survey_id,vc_rules_id,questions) values(2,6,'How efficient do you think this rule is for managing the fishing grounds?'); -insert into vc_survey_questions(vc_survey_id,vc_rules_id,questions) values(2,6,'How fair do you think this rule is for managing the fishing grounds? '); -insert into vc_survey_questions(vc_survey_id,vc_rules_id,questions) values(2,6,'How much personal freedom do you think this rule allows you in managing the fishing grounds?'); -insert into vc_survey_questions(vc_survey_id,vc_rules_id,questions) values(2,6,'How much do you think this rule would advance your own self-interest as measured by your total earning?'); -insert into vc_survey_questions(vc_survey_id,vc_rules_id,questions) values(2,6,'All things considered how attractive do you find this rule?'); - - -insert into vc_survey_questions(vc_survey_id,vc_rules_id,questions) values(3,7,'How efficient do you think this rule is for managing the irrigation system?'); -insert into vc_survey_questions(vc_survey_id,vc_rules_id,questions) values(3,7,'How fair do you think this rule is for managing the irrigation system? '); -insert into vc_survey_questions(vc_survey_id,vc_rules_id,questions) values(3,7,'How much personal freedom do you think this rule allows you in managing the irrigation system?'); -insert into vc_survey_questions(vc_survey_id,vc_rules_id,questions) values(3,7,'How much do you think this rule would advance your own self-interest as measured by your total earning?'); -insert into vc_survey_questions(vc_survey_id,vc_rules_id,questions) values(3,7,'All things considered how attractive do you find this rule?'); - - -insert into vc_survey_questions(vc_survey_id,vc_rules_id,questions) values(3,8,'How efficient do you think this rule is for managing the irrigation system?'); -insert into vc_survey_questions(vc_survey_id,vc_rules_id,questions) values(3,8,'How fair do you think this rule is for managing the irrigation system? '); -insert into vc_survey_questions(vc_survey_id,vc_rules_id,questions) values(3,8,'How much personal freedom do you think this rule allows you in managing the irrigation system?'); -insert into vc_survey_questions(vc_survey_id,vc_rules_id,questions) values(3,8,'How much do you think this rule would advance your own self-interest as measured by your total earning?'); -insert into vc_survey_questions(vc_survey_id,vc_rules_id,questions) values(3,8,'All things considered how attractive do you find this rule?'); - - -insert into vc_survey_questions(vc_survey_id,vc_rules_id,questions) values(3,9,'How efficient do you think this rule is for managing the irrigation system?'); -insert into vc_survey_questions(vc_survey_id,vc_rules_id,questions) values(3,9,'How fair do you think this rule is for managing the irrigation system? '); -insert into vc_survey_questions(vc_survey_id,vc_rules_id,questions) values(3,9,'How much personal freedom do you think this rule allows you in managing the irrigation system?'); -insert into vc_survey_questions(vc_survey_id,vc_rules_id,questions) values(3,9,'How much do you think this rule would advance your own self-interest as measured by your total earning?'); -insert into vc_survey_questions(vc_survey_id,vc_rules_id,questions) values(3,9,'All things considered how attractive do you find this rule?'); - -insert into vc_survey_questions_options(vc_survey_questions_id,min_value,max_value) values(1,'not at all efficient','very efficient'); -insert into vc_survey_questions_options(vc_survey_questions_id,min_value,max_value) values(2,'not at all fair','very fair'); -insert into vc_survey_questions_options(vc_survey_questions_id,min_value,max_value) values(3,'no freedom at all','complete freedom'); -insert into vc_survey_questions_options(vc_survey_questions_id,min_value,max_value) values(4,'not at all','very much'); -insert into vc_survey_questions_options(vc_survey_questions_id,min_value,max_value) values(5,'not attractive at all','Very attractive'); - -insert into vc_survey_questions_options(vc_survey_questions_id,min_value,max_value) values(6,'not at all efficient','very efficient'); -insert into vc_survey_questions_options(vc_survey_questions_id,min_value,max_value) values(7,'not at all fair','very fair'); -insert into vc_survey_questions_options(vc_survey_questions_id,min_value,max_value) values(8,'no freedom at all','complete freedom'); -insert into vc_survey_questions_options(vc_survey_questions_id,min_value,max_value) values(9,'not at all','very much'); -insert into vc_survey_questions_options(vc_survey_questions_id,min_value,max_value) values(10,'not attractive at all','Very attractive'); - -insert into vc_survey_questions_options(vc_survey_questions_id,min_value,max_value) values(11,'not at all efficient','very efficient'); -insert into vc_survey_questions_options(vc_survey_questions_id,min_value,max_value) values(12,'not at all fair','very fair'); -insert into vc_survey_questions_options(vc_survey_questions_id,min_value,max_value) values(13,'no freedom at all','complete freedom'); -insert into vc_survey_questions_options(vc_survey_questions_id,min_value,max_value) values(14,'not at all','very much'); -insert into vc_survey_questions_options(vc_survey_questions_id,min_value,max_value) values(15,'not attractive at all','Very attractive'); - - -insert into vc_survey_questions_options(vc_survey_questions_id,min_value,max_value) values(16,'not at all efficient','very efficient'); -insert into vc_survey_questions_options(vc_survey_questions_id,min_value,max_value) values(17,'not at all fair','very fair'); -insert into vc_survey_questions_options(vc_survey_questions_id,min_value,max_value) values(18,'no freedom at all','complete freedom'); -insert into vc_survey_questions_options(vc_survey_questions_id,min_value,max_value) values(19,'not at all','very much'); -insert into vc_survey_questions_options(vc_survey_questions_id,min_value,max_value) values(20,'not attractive at all','Very attractive'); - - -insert into vc_survey_questions_options(vc_survey_questions_id,min_value,max_value) values(21,'not at all efficient','very efficient'); -insert into vc_survey_questions_options(vc_survey_questions_id,min_value,max_value) values(22,'not at all fair','very fair'); -insert into vc_survey_questions_options(vc_survey_questions_id,min_value,max_value) values(23,'no freedom at all','complete freedom'); -insert into vc_survey_questions_options(vc_survey_questions_id,min_value,max_value) values(24,'not at all','very much'); -insert into vc_survey_questions_options(vc_survey_questions_id,min_value,max_value) values(25,'not attractive at all','Very attractive'); - -insert into vc_survey_questions_options(vc_survey_questions_id,min_value,max_value) values(26,'not at all efficient','very efficient'); -insert into vc_survey_questions_options(vc_survey_questions_id,min_value,max_value) values(27,'not at all fair','very fair'); -insert into vc_survey_questions_options(vc_survey_questions_id,min_value,max_value) values(28,'no freedom at all','complete freedom'); -insert into vc_survey_questions_options(vc_survey_questions_id,min_value,max_value) values(29,'not at all','very much'); -insert into vc_survey_questions_options(vc_survey_questions_id,min_value,max_value) values(30,'not attractive at all','Very attractive'); - -insert into vc_survey_questions_options(vc_survey_questions_id,min_value,max_value) values(31,'not at all efficient','very efficient'); -insert into vc_survey_questions_options(vc_survey_questions_id,min_value,max_value) values(32,'not at all fair','very fair'); -insert into vc_survey_questions_options(vc_survey_questions_id,min_value,max_value) values(33,'no freedom at all','complete freedom'); -insert into vc_survey_questions_options(vc_survey_questions_id,min_value,max_value) values(34,'not at all','very much'); -insert into vc_survey_questions_options(vc_survey_questions_id,min_value,max_value) values(35,'not attractive at all','Very attractive'); - -insert into vc_survey_questions_options(vc_survey_questions_id,min_value,max_value) values(36,'not at all efficient','very efficient'); -insert into vc_survey_questions_options(vc_survey_questions_id,min_value,max_value) values(37,'not at all fair','very fair'); -insert into vc_survey_questions_options(vc_survey_questions_id,min_value,max_value) values(38,'no freedom at all','complete freedom'); -insert into vc_survey_questions_options(vc_survey_questions_id,min_value,max_value) values(39,'not at all','very much'); -insert into vc_survey_questions_options(vc_survey_questions_id,min_value,max_value) values(40,'not attractive at all','Very attractive'); - -insert into vc_survey_questions_options(vc_survey_questions_id,min_value,max_value) values(41,'not at all efficient','very efficient'); -insert into vc_survey_questions_options(vc_survey_questions_id,min_value,max_value) values(42,'not at all fair','very fair'); -insert into vc_survey_questions_options(vc_survey_questions_id,min_value,max_value) values(43,'no freedom at all','complete freedom'); -insert into vc_survey_questions_options(vc_survey_questions_id,min_value,max_value) values(44,'not at all','very much'); -insert into vc_survey_questions_options(vc_survey_questions_id,min_value,max_value) values(45,'not attractive at all','Very attractive'); - This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <al...@us...> - 2008-08-06 23:58:11
|
Revision: 28 http://virtualcommons.svn.sourceforge.net/virtualcommons/?rev=28&view=rev Author: alllee Date: 2008-08-06 23:58:18 +0000 (Wed, 06 Aug 2008) Log Message: ----------- moving games into experiment Modified Paths: -------------- vcweb/trunk/virtualcommons/experiment/experiment.inc vcweb/trunk/virtualcommons/experiment/games/rules/rules.install vcweb/trunk/virtualcommons/experiment/games/rules/rules.module vcweb/trunk/virtualcommons/experiment/survey-questions.sql Added Paths: ----------- vcweb/trunk/virtualcommons/experiment/games/ vcweb/trunk/virtualcommons/experiment/games/forestry_v2/forestry_v2.install vcweb/trunk/virtualcommons/experiment/games/forestry_v2/forestry_v2.module vcweb/trunk/virtualcommons/experiment/games/teacher_dashboard/teacher_dashboard.install vcweb/trunk/virtualcommons/experiment/games/teacher_dashboard/teacher_dashboard.module Removed Paths: ------------- vcweb/trunk/virtualcommons/experiment/games/forestry_v2/forestry_v2.install vcweb/trunk/virtualcommons/experiment/games/forestry_v2/forestry_v2.module vcweb/trunk/virtualcommons/experiment/games/teacher_dashboard/teacher_dashboard.install vcweb/trunk/virtualcommons/experiment/games/teacher_dashboard/teacher_dashboard.module vcweb/trunk/virtualcommons/games/ Modified: vcweb/trunk/virtualcommons/experiment/experiment.inc =================================================================== --- vcweb/trunk/virtualcommons/experiment/experiment.inc 2008-08-06 05:48:17 UTC (rev 27) +++ vcweb/trunk/virtualcommons/experiment/experiment.inc 2008-08-06 23:58:18 UTC (rev 28) @@ -29,6 +29,7 @@ private $current_round_no; 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; @@ -37,6 +38,7 @@ $this->no_of_students = $no_of_students; $this->current_stage_no = 1; $this->current_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)); } @@ -125,7 +127,9 @@ } public function isVotingEnabled() { - return 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)); + $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; } public function isVotingEnabledForStage($stage_id) { @@ -135,6 +139,7 @@ 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 @@ -195,6 +200,11 @@ 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() { $round_no=$this->getCurrentRoundNo(); @@ -223,10 +233,14 @@ } //update start flag $this->updateStartFlag(true); + $this->prev_round_no=$round_no; - //update crrent round_no + //update current round_no $round_no=$round_no+1; - if ($round_no > ($this->getNumberOfRounds())) { + $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 @@ -243,11 +257,80 @@ } 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); } +public function setRoundNo($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 + + $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); + + +} + + + +//Stage 2 + +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); + + } + +//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=0; + while($data=db_fetch_object($result_voting)) + { + $rule_id=$data->vc_rules_id; + $rule_cnt=$data->rule_cnt; + //$voting[$data->vc_rules_id]=$data->rule_cnt; + if($rule_cnt> $max) + { + $max =$rule_cnt; + $final_rule_id=$rule_id; + } + + } + 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 class Game class Group { @@ -315,7 +398,24 @@ return $this->game->getCurrentStageId(); } + 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)) + { + $rule_info=array($data->rule_no,$data->description); + } + return $rule_info; + + } + /*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 /** @@ -352,6 +452,7 @@ public function getRoundNo() { + db_result(db_query("select current_round_no from vc_game where id=%d",$this->game_id)); return $this->round_no; } @@ -392,9 +493,71 @@ return db_result(db_query("select start_flag from vc_student where id ='%s' ",$this->stud_id)); } - public function updateStageId($stage_no,$experiment_id) + 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); + 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 +{ + + 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); + } + + 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); + + } +} + +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); + } + + } + + 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); + + } + +} Deleted: vcweb/trunk/virtualcommons/experiment/games/forestry_v2/forestry_v2.install =================================================================== --- vcweb/trunk/virtualcommons/games/forestry_v2/forestry_v2.install 2008-08-02 00:29:43 UTC (rev 21) +++ vcweb/trunk/virtualcommons/experiment/games/forestry_v2/forestry_v2.install 2008-08-06 23:58:18 UTC (rev 28) @@ -1,200 +0,0 @@ -<?php -// vim:sts=2:sw=2:filetype=php -// $Id$ -/** - * Implementation of hook_install(). - */ -function forestry_v2_install() { - switch ($GLOBALS['db_type']) { - case 'mysql': - case 'mysqli': - db_query("CREATE TABLE {vc_forestry_common_resource_pool} - ( - id INT AUTO_INCREMENT, - vc_group_id INT NOT NULL, - common_resource_pool INT NOT NULL, - harvest_decision INT NOT NULL, - vc_game_id INT NOT NULL, - max_harvest_decision INT NOT NULL, - - PRIMARY KEY(id), - FOREIGN KEY(vc_group_id) REFERENCES vc_group(id) - ON DELETE CASCADE, - - FOREIGN KEY(vc_game_id) REFERENCES vc_game(id) - ON DELETE CASCADE - - )ENGINE=InnoDB /*!40100 DEFAULT CHARACTER SET UTF8 */"); - - //Forestry Game Harvest Tables. - db_query("CREATE TABLE {vc_forestry_5player_harvest_table} - ( - id INT AUTO_INCREMENT, - min_resource_level INT NOT NULL, - max_resource_level INT NOT NULL, - individual_harvest_level INT NOT NULL, - - PRIMARY KEY(id) - )ENGINE=InnoDB /*!40100 DEFAULT CHARACTER SET UTF8 */"); - - db_query("INSERT INTO {vc_forestry_5player_harvest_table} (min_resource_level,max_resource_level,individual_harvest_level) values(25,100,5)"); - db_query("INSERT INTO {vc_forestry_5player_harvest_table} (min_resource_level,max_resource_level,individual_harvest_level) values(20,24,4)"); - db_query("INSERT INTO {vc_forestry_5player_harvest_table} (min_resource_level,max_resource_level,individual_harvest_level) values(15,19,3)"); - db_query("INSERT INTO {vc_forestry_5player_harvest_table} (min_resource_level,max_resource_level,individual_harvest_level) values(10,14,2)"); - db_query("INSERT INTO {vc_forestry_5player_harvest_table} (min_resource_level,max_resource_level,individual_harvest_level) values(5,9,1)"); - db_query("INSERT INTO {vc_forestry_5player_harvest_table} (min_resource_level,max_resource_level,individual_harvest_level) values(0,4,0)"); - - - - db_query("CREATE TABLE {vc_forestry_4player_harvest_table} ( - id INT AUTO_INCREMENT, - min_resource_level INT NOT NULL, - max_resource_level INT NOT NULL, - individual_harvest_level INT NOT NULL, - - PRIMARY KEY(id) - - )ENGINE=InnoDB /*!40100 DEFAULT CHARACTER SET UTF8 */"); - - - db_query("INSERT INTO {vc_forestry_4player_harvest_table} (min_resource_level,max_resource_level,individual_harvest_level) values(20,80,5)"); - db_query("INSERT INTO {vc_forestry_4player_harvest_table} (min_resource_level,max_resource_level,individual_harvest_level) values(16,19,4)"); - db_query("INSERT INTO {vc_forestry_4player_harvest_table} (min_resource_level,max_resource_level,individual_harvest_level) values(12,15,3)"); - db_query("INSERT INTO {vc_forestry_4player_harvest_table} (min_resource_level,max_resource_level,individual_harvest_level) values(8,11,2)"); - db_query("INSERT INTO {vc_forestry_4player_harvest_table} (min_resource_level,max_resource_level,individual_harvest_level) values(4,7,1)"); - db_query("INSERT INTO {vc_forestry_4player_harvest_table} (min_resource_level,max_resource_level,individual_harvest_level) values(0,3,0)"); - - db_query("CREATE TABLE {vc_forestry_3player_harvest_table} ( - id INT AUTO_INCREMENT, - min_resource_level INT NOT NULL, - max_resource_level INT NOT NULL, - individual_harvest_level INT NOT NULL, - - PRIMARY KEY(id) - - )ENGINE=InnoDB /*!40100 DEFAULT CHARACTER SET UTF8 */"); - - db_query("INSERT INTO {vc_forestry_3player_harvest_table} (min_resource_level,max_resource_level,individual_harvest_level) values(15,60,5)"); - db_query("INSERT INTO {vc_forestry_3player_harvest_table} (min_resource_level,max_resource_level,individual_harvest_level) values(12,14,4)"); - db_query("INSERT INTO {vc_forestry_3player_harvest_table} (min_resource_level,max_resource_level,individual_harvest_level) values(9,11,3)"); - db_query("INSERT INTO {vc_forestry_3player_harvest_table} (min_resource_level,max_resource_level,individual_harvest_level) values(6,8,2)"); - db_query("INSERT INTO {vc_forestry_3player_harvest_table} (min_resource_level,max_resource_level,individual_harvest_level) values(3,5,1)"); - db_query("INSERT INTO {vc_forestry_3player_harvest_table} (min_resource_level,max_resource_level,individual_harvest_level) values(0,2,0)"); - - db_query("CREATE TABLE {vc_forestry_student} ( - id int NOT NULL AUTO_INCREMENT, - round_no int NOT NULL, - vc_student_id varchar(14) NOT NULL, - vc_stage_id int NOT NULL, - harvest_decision int NOT NULL, - fine int, - total_points int, - date TIMESTAMP NOT NULL, - - PRIMARY KEY(id), - - FOREIGN KEY(vc_student_id) REFERENCES vc_student(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_forestry_turn_sequence} ( - id int AUTO_INCREMENT, - round_no int NOT NULL, - turn_sequence varchar(10) NOT NULL, - vc_group_id int NOT NULL, - vc_rules_id int NOT NULL, - vc_game_id int NOT NULL, - - PRIMARY KEY(id), - - FOREIGN KEY(vc_group_id) REFERENCES vc_group(id) - ON DELETE CASCADE, - - FOREIGN KEY(vc_rules_id) REFERENCES vc_rules(id) - ON DELETE CASCADE, - - FOREIGN KEY(vc_game_id) REFERENCES vc_game(id) - ON DELETE CASCADE - - )ENGINE=InnoDB /*!40100 DEFAULT CHARACTER SET UTF8 */"); - - - $flag=TRUE; - break; - case 'pgsql': - - db_query("CREATE TABLE {vc_forestry_student} ( - id int NOT NULL AUTO_INCREMENT, - round_no int NOT NULL, - vc_student_id varchar(14) NOT NULL, - vc_stage_id int NOT NULL, - harvest_decision int NOT NULL, - fine int, - total_points int, - date TIMESTAMP NOT NULL, - - PRIMARY KEY(id), - - FOREIGN KEY(vc_student_id) REFERENCES vc_student(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_forestry_turn_sequence} ( - id int NOT NULL AUTO_INCREMENT, - round_no int NOT NULL, - turn_sequence varchar(10) NOT NULL, - vc_rules_id int NOT NULL, - vc_group_id int NOT NULL, - vc_game_id int NOT NULL, - - PRIMARY KEY(id), - - FOREIGN KEY(vc_group_id) REFERENCES vc_group(id) - ON DELETE CASCADE, - - FOREIGN KEY(vc_rules_id) REFERENCES vc_rules(id) - ON DELETE CASCADE, - - FOREIGN KEY(vc_game_id) REFERENCES vc_conducts(id) - ON DELETE CASCADE - - ) /*!40100 DEFAULT CHARACTER SET UTF8 */"); - $flag=TRUE; - break; - default: - drupal_set_message(t('Unsupported Database')); - } - if($flag) - { - drupal_set_message(t('Forestry stage database is successfully created.')); - } - else - { - drupal_set_message(t('Forestry stage database is NOT successfully created.'),'error'); - } -} - -/** - * Implementation of hook_uninstall(). - */ -function forestry_v2_uninstall() -{ - db_query("DROP TABLE {vc_forestry_3player_harvest_table}"); - db_query("DROP TABLE {vc_forestry_4player_harvest_table}"); - db_query("DROP TABLE {vc_forestry_5player_harvest_table}"); - db_query("DROP TABLE {vc_forestry_common_resource_pool}"); - db_query("DROP TABLE {vc_forestry_student}"); - db_query("DROP TABLE {vc_forestry_turn_sequence}"); - drupal_set_message(t('Forestry stage table is successfully deleted from the database.')); -} - Copied: vcweb/trunk/virtualcommons/experiment/games/forestry_v2/forestry_v2.install (from rev 23, vcweb/trunk/virtualcommons/games/forestry_v2/forestry_v2.install) =================================================================== --- vcweb/trunk/virtualcommons/experiment/games/forestry_v2/forestry_v2.install (rev 0) +++ vcweb/trunk/virtualcommons/experiment/games/forestry_v2/forestry_v2.install 2008-08-06 23:58:18 UTC (rev 28) @@ -0,0 +1,200 @@ +<?php +// vim:sts=2:sw=2:filetype=php +// $Id$ +/** + * Implementation of hook_install(). + */ +function forestry_v2_install() { + switch ($GLOBALS['db_type']) { + case 'mysql': + case 'mysqli': + db_query("CREATE TABLE {vc_forestry_common_resource_pool} + ( + id INT AUTO_INCREMENT, + vc_group_id INT NOT NULL, + common_resource_pool INT NOT NULL, + + vc_game_id INT NOT NULL, + max_resources INT NOT NULL, + + PRIMARY KEY(id), + FOREIGN KEY(vc_group_id) REFERENCES vc_group(id) + ON DELETE CASCADE, + + FOREIGN KEY(vc_game_id) REFERENCES vc_game(id) + ON DELETE CASCADE + + )ENGINE=InnoDB /*!40100 DEFAULT CHARACTER SET UTF8 */"); + + //Forestry Game Harvest Tables. + db_query("CREATE TABLE {vc_forestry_5player_harvest_table} + ( + id INT AUTO_INCREMENT, + min_resource_level INT NOT NULL, + max_resource_level INT NOT NULL, + individual_harvest_level INT NOT NULL, + + PRIMARY KEY(id) + )ENGINE=InnoDB /*!40100 DEFAULT CHARACTER SET UTF8 */"); + + db_query("INSERT INTO {vc_forestry_5player_harvest_table} (min_resource_level,max_resource_level,individual_harvest_level) values(25,100,5)"); + db_query("INSERT INTO {vc_forestry_5player_harvest_table} (min_resource_level,max_resource_level,individual_harvest_level) values(20,24,4)"); + db_query("INSERT INTO {vc_forestry_5player_harvest_table} (min_resource_level,max_resource_level,individual_harvest_level) values(15,19,3)"); + db_query("INSERT INTO {vc_forestry_5player_harvest_table} (min_resource_level,max_resource_level,individual_harvest_level) values(10,14,2)"); + db_query("INSERT INTO {vc_forestry_5player_harvest_table} (min_resource_level,max_resource_level,individual_harvest_level) values(5,9,1)"); + db_query("INSERT INTO {vc_forestry_5player_harvest_table} (min_resource_level,max_resource_level,individual_harvest_level) values(0,4,0)"); + + + + db_query("CREATE TABLE {vc_forestry_4player_harvest_table} ( + id INT AUTO_INCREMENT, + min_resource_level INT NOT NULL, + max_resource_level INT NOT NULL, + individual_harvest_level INT NOT NULL, + + PRIMARY KEY(id) + + )ENGINE=InnoDB /*!40100 DEFAULT CHARACTER SET UTF8 */"); + + + db_query("INSERT INTO {vc_forestry_4player_harvest_table} (min_resource_level,max_resource_level,individual_harvest_level) values(20,80,5)"); + db_query("INSERT INTO {vc_forestry_4player_harvest_table} (min_resource_level,max_resource_level,individual_harvest_level) values(16,19,4)"); + db_query("INSERT INTO {vc_forestry_4player_harvest_table} (min_resource_level,max_resource_level,individual_harvest_level) values(12,15,3)"); + db_query("INSERT INTO {vc_forestry_4player_harvest_table} (min_resource_level,max_resource_level,individual_harvest_level) values(8,11,2)"); + db_query("INSERT INTO {vc_forestry_4player_harvest_table} (min_resource_level,max_resource_level,individual_harvest_level) values(4,7,1)"); + db_query("INSERT INTO {vc_forestry_4player_harvest_table} (min_resource_level,max_resource_level,individual_harvest_level) values(0,3,0)"); + + db_query("CREATE TABLE {vc_forestry_3player_harvest_table} ( + id INT AUTO_INCREMENT, + min_resource_level INT NOT NULL, + max_resource_level INT NOT NULL, + individual_harvest_level INT NOT NULL, + + PRIMARY KEY(id) + + )ENGINE=InnoDB /*!40100 DEFAULT CHARACTER SET UTF8 */"); + + db_query("INSERT INTO {vc_forestry_3player_harvest_table} (min_resource_level,max_resource_level,individual_harvest_level) values(15,60,5)"); + db_query("INSERT INTO {vc_forestry_3player_harvest_table} (min_resource_level,max_resource_level,individual_harvest_level) values(12,14,4)"); + db_query("INSERT INTO {vc_forestry_3player_harvest_table} (min_resource_level,max_resource_level,individual_harvest_level) values(9,11,3)"); + db_query("INSERT INTO {vc_forestry_3player_harvest_table} (min_resource_level,max_resource_level,individual_harvest_level) values(6,8,2)"); + db_query("INSERT INTO {vc_forestry_3player_harvest_table} (min_resource_level,max_resource_level,individual_harvest_level) values(3,5,1)"); + db_query("INSERT INTO {vc_forestry_3player_harvest_table} (min_resource_level,max_resource_level,individual_harvest_level) values(0,2,0)"); + + db_query("CREATE TABLE {vc_forestry_student} ( + id int NOT NULL AUTO_INCREMENT, + round_no int NOT NULL, + vc_student_id varchar(14) NOT NULL, + vc_stage_id int NOT NULL, + harvest_decision int NOT NULL, + fine int, + total_points int, + date TIMESTAMP NOT NULL, + + PRIMARY KEY(id), + + FOREIGN KEY(vc_student_id) REFERENCES vc_student(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_forestry_turn_sequence} ( + id int AUTO_INCREMENT, + round_no int NOT NULL, + turn_sequence varchar(10) NOT NULL, + vc_group_id int NOT NULL, + vc_rules_id int NOT NULL, + vc_game_id int NOT NULL, + + PRIMARY KEY(id), + + FOREIGN KEY(vc_group_id) REFERENCES vc_group(id) + ON DELETE CASCADE, + + FOREIGN KEY(vc_rules_id) REFERENCES vc_rules(id) + ON DELETE CASCADE, + + FOREIGN KEY(vc_game_id) REFERENCES vc_game(id) + ON DELETE CASCADE + + )ENGINE=InnoDB /*!40100 DEFAULT CHARACTER SET UTF8 */"); + + + $flag=TRUE; + break; + case 'pgsql': + + db_query("CREATE TABLE {vc_forestry_student} ( + id int NOT NULL AUTO_INCREMENT, + round_no int NOT NULL, + vc_student_id varchar(14) NOT NULL, + vc_stage_id int NOT NULL, + harvest_decision int NOT NULL, + fine int, + total_points int, + date TIMESTAMP NOT NULL, + + PRIMARY KEY(id), + + FOREIGN KEY(vc_student_id) REFERENCES vc_student(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_forestry_turn_sequence} ( + id int NOT NULL AUTO_INCREMENT, + round_no int NOT NULL, + turn_sequence varchar(10) NOT NULL, + vc_rules_id int NOT NULL, + vc_group_id int NOT NULL, + vc_game_id int NOT NULL, + + PRIMARY KEY(id), + + FOREIGN KEY(vc_group_id) REFERENCES vc_group(id) + ON DELETE CASCADE, + + FOREIGN KEY(vc_rules_id) REFERENCES vc_rules(id) + ON DELETE CASCADE, + + FOREIGN KEY(vc_game_id) REFERENCES vc_conducts(id) + ON DELETE CASCADE + + ) /*!40100 DEFAULT CHARACTER SET UTF8 */"); + $flag=TRUE; + break; + default: + drupal_set_message(t('Unsupported Database')); + } + if($flag) + { + drupal_set_message(t('Forestry stage database is successfully created.')); + } + else + { + drupal_set_message(t('Forestry stage database is NOT successfully created.'),'error'); + } +} + +/** + * Implementation of hook_uninstall(). + */ +function forestry_v2_uninstall() +{ + db_query("DROP TABLE {vc_forestry_3player_harvest_table}"); + db_query("DROP TABLE {vc_forestry_4player_harvest_table}"); + db_query("DROP TABLE {vc_forestry_5player_harvest_table}"); + db_query("DROP TABLE {vc_forestry_common_resource_pool}"); + db_query("DROP TABLE {vc_forestry_student}"); + db_query("DROP TABLE {vc_forestry_turn_sequence}"); + drupal_set_message(t('Forestry stage table is successfully deleted from the database.')); +} + Deleted: vcweb/trunk/virtualcommons/experiment/games/forestry_v2/forestry_v2.module =================================================================== --- vcweb/trunk/virtualcommons/games/forestry_v2/forestry_v2.module 2008-08-02 00:29:43 UTC (rev 21) +++ vcweb/trunk/virtualcommons/experiment/games/forestry_v2/forestry_v2.module 2008-08-06 23:58:18 UTC (rev 28) @@ -1,528 +0,0 @@ -<?php -// vim:sts=2:sw=2:filetype=php -// $Id$ - -include_once('./' . drupal_get_path('module', 'experiment') . '/experiment.inc'); - - -/** - * implement the _user hook. - **/ -// $Id$ -/** - * Implementation of hook_menu(). - */ -function forestry_v2_menu($may_cache) { - $items = array(); - if ($may_cache) { - $items[] = array('path' => 'forestry', - 'title' => t('Forestry Game'), - 'callback' => 'forestry_v2_page', - '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', - //'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 -{ - forestry_v2_load(); -} - - return $items; -} - -function forestry_v2_load() { - static $loaded = FALSE; - - if (!$loaded) { - $path = drupal_get_path('module', 'forestry_v2'); - drupal_add_css($path .'/form.css'); - $loaded = TRUE; - } -} - -/** - * Called when user goes to example.com/?q=forestry - */ -function forestry_v2_page() { - $output = t('Please note the following maximum harvest table.'); - // Return the HTML generated from the $form data structure. - $output .= drupal_get_form('forestry_v2_nameform'); - return $output; -} -/** - * Defines a form. - */ -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 = unserialize($_SESSION['group']); - // 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)); - } - $_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) -{ - $stud_id=$_SESSION['student_id']; - $group = unserialize($_SESSION['group']); - $flag=$group->getStartFlag($stud_id); - $game_id = $group->getGameId(); - if($flag) { - $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'; - 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'; - } - - } - } - else { - return 'forestry'; - } -} - -//Forestry Stage 1 Begins - -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; -} - - - -function forestry_game_stage1_multiform() -{ - - $form['#id']='forestry_game_stage1_multiform'; - $group = unserialize($_SESSION['group']); - $student=new ForestryStudent(); - - $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 - - $group_id=$group->getGroupId(); - $game_id=$group->getGameId(); - 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; - 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; - $header=array("Round Number","Your Harvest Decision","Resources Before","Resources After"); - - $final_row=$student->getForestryStudentInfo($group_id,$game_id); - - /*$result=db_query("select round_no,harvest_decision from virtualcommons_forestry_student where virtualcommons_student_id= '%s' ",$stud_id); - while($data=db_fetch_object($result)) - { - $round_no=$data->round_no; - $harvest_decision=$data->harvest_decision; - $round_no=(int)$round_no; - //$resources_before=$data->resources_before; - //$resources_after=$data->resources_after; - $resource_info= db_query("select resources_before,resources_after from virtualcommons_forestry_group_information where virtualcommons_student_group_no=%d and virtualcommons_conducts_id=%d and round_no=%d",$group_no,$conducts_id,$round_no); - while($data_resource=db_fetch_object($resource_info)) - { - $resources_before=$data_resource->resources_before; - $resources_after=$data_resource->resources_after; - } - $final_row[]=array($round_no,$harvest_decision,$resources_before,$resources_after); - }*/ - $round_no=$student->getRoundNo(); - $round_no=$round_no+1; - 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 - ); - - -$no_rounds=$group->getNoOfRounds(); -//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('no of rounds are: '.$no_rounds)); -if($round_no <= $no_rounds) -{ - - $form['resources_available']=array( - - '#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('Next') - ); -} -else -{ - $stage_no=$group->getCurrentStageNumber(); - $stage_no=(int) $stage_no; - $form['indicator']['submit'] = array( - '#type' => 'submit', - '#value' => t('Stage '.$stage_no+1) - ); - -} - - $form['resource']=array( - - '#type'=>'fieldset', - '#title'=>t('<b>Resources</b>'), - - ); - $form['resource']['table']=array( - '#type'=>'markup', - '#value'=>theme('table',$header,$final_row) - ); - - -return $form; - -} - - - -function forestry_game_stage1_multiform_validate($form_id,$form_values) -{ -$harvest_decision=$form_values['indicator']['harvest_decision']; -$resource=(int) $_SESSION['prev_resource']; -//$resource=100; -$flag=FALSE; - -if(preg_match('/[^0-9]+/',$harvest_decision)) -{ - form_set_error('harvest_decision',t('Harvest Decison can not be alphabet or special character.')); -} -else -{ - - $harvest_table= $_SESSION['harvest_table']; - - foreach($harvest_table as $key=> $value) - { - - if(!$flag) - { - foreach($value as $key=>$value) - { - - if($key==0) - { - //get min and maximum value of the resource - $harvest_tbl=explode("-",$value); - $min_resource=(int) $harvest_tbl[0]; - $max_resource=(int) $harvest_tbl[1]; - - } - else if($key==1) - { - //get the maximum units player can invest - $harvest_units=(int) $value; - /*drupal_set_message(t('Min : '.$min_resource)); - drupal_set_message(t('Max : '.$max_resource)); - drupal_set_message(t('Units can harvest: '.$harvest_units)); - drupal_set_message(t('Resource can harvest: '.$resource)); - drupal_set_message(t('comparision: '. ($harvest_decision > $harvest_units)));*/ - if(($resource >= $min_resource) && ($resource <= $max_resource)) - { - //depending upon the resource available player can invest units. e.g in group of 5 and resource available=100 then player can invest max 5 units. - //drupal_set_message(t('resource condition successful: ')); - $harvest_decision=(int) $harvest_decision; - if($harvest_decision > $harvest_units) - { - if($harvest_units ==0 ) - form_set_error('harvest_decision',t('Current Resource Level is very low. You can not harvest anything. <br><b>GAME OVER!!!</b>')); - else - form_set_error('harvest_decision',t('Harvest Decison can not be more than %harvest_units.',array('%harvest_units'=>$harvest_units))); - $flag=TRUE; - } - else - $flag=FALSE; - - } - - } - }//end of for1 - - }// end of if(flag) - -if($flag) - break; - - }//end of for 2 - -} - - -return; - -} - - -function forestry_game_stage1_multiform_submit($form_id,$form_values) -{ - $group = unserialize($_SESSION['group']); - - $harvest_table=$_SESSION['harvest_table']; - //$harvest_tbl=explode("-",$harvest_table); - $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)); - - $stud_harvest_decision=(int) $form_values['indicator']['harvest_decision']; - - - $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)); - - //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->getNoOfRounds(); - //$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']=="Stage 2") -{ - $stage_no=2; - $exp_id=$group->getExperimentId(); - $student->updateStageId($stage_no,$exp_id); - //db_query("update virtualcommons_conducts set virtualcommons_stage_no=%d where id=%d",2,$virtual_conducts_id); - unset($_SESSION['prev_resource']); - - return 'rules'; -} -else - return 'forestry_stage1_part2'; - - -} - -function theme_forestry_game_stage1_multiform($form) -{ -$output='<div class="indicator"><table style="text-align: center; width: 100%;" border="0" - cellpadding="0" cellspacing="0"> - <tbody> - <tr> - <td style="width: 80%;"> </td> - - <td nowrap>'; -$output.=drupal_render($form ['resources_available']); -$output.='</td> - </tr> - - - <tr> - <td style="width: 30%;" colspan="2" rowspan="1">'; -$output.= drupal_render($form['indicator']); - - -$output.= drupal_render($form['indicator']['harvest_decision']); -$output.='</td>'; - //<td style="text-align: center;" colspan="2" rowspan="1">'; -$output.=drupal_render($form['indicator']['submit']); -$output.=' - </tr><tr> <td> </td> </tr> -<tr> - <td colspan="2" rowspan="1">'; - -$output.=drupal_render($form['resource']); - -$output.=drupal_render($form['resource']['table']); -$output.=' - </td> - </tr> - </tbody> - </table> -</div>'; -$output.=drupal_render($form); -return $output; - -} - - -function forestry_game_stage1_part2() -{ - -$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() -{ - - $form['submit'] = array( - '#type' => 'submit', - '#value' => t('Next Round') - ); -return $form; -} - - - -function forestry_game_stage1_part2form_submit($form_id,$form_values) -{ - $stud_id=$_SESSION['student_id']; - $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'; - -} - - - - - Copied: vcweb/trunk/virtualcommons/experiment/games/forestry_v2/forestry_v2.module (from rev 22, vcweb/trunk/virtualcommons/games/forestry_v2/forestry_v2.module) =================================================================== --- vcweb/trunk/virtualcommons/experiment/games/forestry_v2/forestry_v2.module (rev 0) +++ vcweb/trunk/virtualcommons/experiment/games/forestry_v2/forestry_v2.module 2008-08-06 23:58:18 UTC (rev 28) @@ -0,0 +1,518 @@ +<?php +// vim:sts=2:sw=2:filetype=php +// $Id$ + +include_once('./' . drupal_get_path('module', 'experiment') . '/experiment.inc'); + + +/** + * implement the _user hook. + **/ +// $Id$ +/** + * Implementation of hook_menu(). + */ +function forestry_v2_menu($may_cache) { + $items = array(); + if ($may_cache) { + $items[] = array('path' => 'forestry', + 'title' => t('Forestry Game'), + 'callback' => 'forestry_v2_page', + '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', + //'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 + { + forestry_v2_load(); + } + + return $items; +} + +function forestry_v2_load() { + static $loaded = FALSE; + + if (!$loaded) { + $path = drupal_get_path('module', 'forestry_v2'); + drupal_add_css($path .'/form.css'); + $loaded = TRUE; + } +} + +/** + * Called when user goes to example.com/?q=forestry + */ +function forestry_v2_page() { + $output = t('Please note the following maximum harvest table.'); + // Return the HTML generated from the $form data structure. + $output .= drupal_get_form('forestry_v2_nameform'); + return $output; +} +/** + * Defines a form. + */ +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)); +} +$_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) +{ + $stud_id=$_SESSION['student_id']; + $group = Session::get('group'); + $flag=$group->getStartFlag($stud_id); + $game_id = $group->getGameId(); + if($flag) { + $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'; + 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'; + } + + } + } + else { + return 'forestry'; + } +} + +//Forestry Stage 1 Begins + +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; +} + + + +function forestry_game_stage1_multiform() +{ + + $form['#id']='forestry_game_stage1_multiform'; + $group = Session::get('group'); + $student=new ForestryStudent(); + + $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 + + $group_id=$group->getGroupId(); + $game_id=$group->getGameId(); + 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; + $header=array("Round Number","Your Harvest Decision","Resources Before","Resources After"); + + $final_row=$student->getForestryStudentInfo($group_id,$game_id); + + $round_no=$student->getRoundNo()+1; + + 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 + ); + + 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(); + drupal_set_message(t('no of rounds are: '.$no_rounds)); + if($round_no <= $no_rounds) + { + + $form['resources_available']=array( + + '#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('Next') + ); + } + 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['resource']['table']=array( + '#type'=>'markup', + '#value'=>theme('table',$header,$final_row) + ); + + Session::put('forestry_student',$student); + return $form; + +} + + + +function forestry_game_stage1_multiform_validate($form_id,$form_values) +{ + $harvest_decision=$form_values['indicator']['harvest_decision']; + $resource=(int) $_SESSION['prev_resource']; + //$resource=100; + $flag=FALSE; + + if(preg_match('/[^0-9]+/',$harvest_decision)) + { + form_set_error('harvest_decision',t('Harvest Decison can not be alphabet or special character.')); + } + else + { + + $harvest_table= $_SESSION['harvest_table']; + + foreach($harvest_table as $key=> $value) + { + + if(!$flag) + { + foreach($value as $key=>$value) + { + + if($key==0) + { + //get min and maximum value of the resource + $harvest_tbl=explode("-",$value); + $min_resource=(int) $harvest_tbl[0]; + $max_resource=(int) $harvest_tbl[1]; + + } + else if($key==1) + { + //get the maximum units player can invest + $harvest_units=(int) $value; + /*drupal_set_message(t('Min : '.$min_resource)); + drupal_set_message(t('Max : '.$max_resource)); + drupal_set_message(t('Units can harvest: '.$harvest_units)); + drupal_set_message(t('Resource can harvest: '.$resource)); + drupal_set_message(t('comparision: '. ($harvest_decision > $harvest_units)));*/ + if(($resource >= $min_resource) && ($resource <= $max_resource)) + { + //depending upon the resource available player can invest units. e.g in group of 5 and resource available=100 then player can invest max 5 units. + //drupal_set_message(t('resource condition successful: ')); + $harvest_decision=(int) $harvest_decision; + if($harvest_decision > $harvest_units) + { + if($harvest_units ==0 ) + form_set_error('harvest_decision',t('Current Resource Level is very low. You can not harvest anything. <br><b>GAME OVER!!!</b>')); + else + form_set_error('harvest_decision',t('Harvest Decison can not be more than %harvest_units.',array('%harvest_units'=>$harvest_units))); + $flag=TRUE; + } + else + $flag=FALSE; + + } + + } + }//end of for1 + + }// end of if(flag) + + if($flag) + break; + + }//end of for 2 + + } + + + return; + +} + + +function forestry_game_stage1_multiform_submit($form_id,$form_values) +{ + $group = Session::get('group'); + + $harvest_table=$_SESSION['harvest_table']; + //$harvest_tbl=explode("-",$harvest_table); + $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)); + + $stud_harvest_decision=(int) $form_values['indicator']['harvest_decision']; + + + $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)); + + //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... [truncated message content] |
From: <see...@us...> - 2008-08-06 05:48:08
|
Revision: 27 http://virtualcommons.svn.sourceforge.net/virtualcommons/?rev=27&view=rev Author: seematalele Date: 2008-08-06 05:48:17 +0000 (Wed, 06 Aug 2008) Log Message: ----------- Changes the rule.install file : student id was int now made it as varchar Modified Paths: -------------- vcweb/trunk/virtualcommons/games/rules/rules.install Modified: vcweb/trunk/virtualcommons/games/rules/rules.install =================================================================== --- vcweb/trunk/virtualcommons/games/rules/rules.install 2008-08-06 05:22:25 UTC (rev 26) +++ vcweb/trunk/virtualcommons/games/rules/rules.install 2008-08-06 05:48:17 UTC (rev 27) @@ -11,7 +11,7 @@ db_query("CREATE TABLE {vc_student_voting} ( id INT AUTO_INCREMENT, - vc_student_id INT NOT NULL, + vc_student_id varchar(14) NOT NULL, vc_rules_id INT NOT NULL, time_created TIMESTAMP NOT NULL, This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <see...@us...> - 2008-08-06 05:22:17
|
Revision: 26 http://virtualcommons.svn.sourceforge.net/virtualcommons/?rev=26&view=rev Author: seematalele Date: 2008-08-06 05:22:25 +0000 (Wed, 06 Aug 2008) Log Message: ----------- Added Paths: ----------- vcweb/trunk/virtualcommons/experiment/survey/ vcweb/trunk/virtualcommons/experiment/survey/survey.info vcweb/trunk/virtualcommons/experiment/survey/survey.install vcweb/trunk/virtualcommons/experiment/survey/survey.module vcweb/trunk/virtualcommons/experiment/survey/survey_questions.sql Added: vcweb/trunk/virtualcommons/experiment/survey/survey.info =================================================================== --- vcweb/trunk/virtualcommons/experiment/survey/survey.info (rev 0) +++ vcweb/trunk/virtualcommons/experiment/survey/survey.info 2008-08-06 05:22:25 UTC (rev 26) @@ -0,0 +1,5 @@ +; $Id: rules.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 +version = "$Rev$" Added: vcweb/trunk/virtualcommons/experiment/survey/survey.install =================================================================== --- vcweb/trunk/virtualcommons/experiment/survey/survey.install (rev 0) +++ vcweb/trunk/virtualcommons/experiment/survey/survey.install 2008-08-06 05:22:25 UTC (rev 26) @@ -0,0 +1,279 @@ +<?php +// vim:sts=2:sw=2:filetype=php +// $Id$ +/** + * Implementation of hook_install(). + */ +function survey_install() { + switch ($GLOBALS['db_type']) { + case 'mysql': + case 'mysqli': + +db_query("CREATE TABLE {vc_survey} +( + id int AUTO_INCREMENT, + vc_experiment_id int NOT NULL, + date_of_creation TIMESTAMP, + + PRIMARY KEY(id), + + FOREIGN KEY(vc_experiment_id) REFERENCES vc_experiment(id) + ON DELETE CASCADE + +)ENGINE=InnoDB /*!40100 DEFAULT CHARACTER SET UTF8 */"); + +db_query("CREATE TABLE {vc_survey_questions} +( + id int AUTO_INCREMENT, + vc_survey_id int NOT NULL, + vc_rules_id int NOT NULL, + questions varchar(500) default ' ', + + + PRIMARY KEY(id), + + FOREIGN KEY(vc_survey_id) REFERENCES vc_survey(id) + ON DELETE CASCADE, + + FOREIGN KEY(vc_rules_id) REFERENCES vc_rules(id) + ON DELETE CASCADE + +)ENGINE=InnoDB /*!40100 DEFAULT CHARACTER SET UTF8 */"); + + +db_query("CREATE TABLE {vc_survey_questions_options} +( + id int AUTO_INCREMENT, + vc_survey_questions_id int NOT NULL, + min_value varchar(100) NOT NULL, + max_value varchar(100) NOT NULL, + + PRIMARY KEY(id), + + FOREIGN KEY(vc_survey_questions_id) REFERENCES vc_survey_questions(id) + ON DELETE CASCADE + +)ENGINE=InnoDB /*!40100 DEFAULT CHARACTER SET UTF8 */"); + +db_query("CREATE TABLE {vc_survey_response} +( + id int AUTO_INCREMENT, + vc_student_id varchar(14) NOT NULL, + vc_survey_questions_id int NOT NULL, + response varchar(100) NOT NULL, + + + PRIMARY KEY(id), + + FOREIGN KEY(vc_student_id) REFERENCES vc_student(id) + ON DELETE CASCADE, + + + FOREIGN KEY(vc_survey_questions_id) REFERENCES vc_survey_questions(id) + ON DELETE CASCADE + +)ENGINE=InnoDB /*!40100 DEFAULT CHARACTER SET UTF8 */"); + + +db_query("insert into { vc_survey} (vc_experiment_id) values('1')"); +db_query("insert into { vc_survey} (vc_experiment_id) values('2')"); +db_query("insert into { vc_survey} (vc_experiment_id) values('3')"); + +db_query("insert into { vc_survey_questions} (vc_survey_id,vc_rules_id,questions) values(1,1,'How efficient do you think this rule is for managing the fishing grounds?')"); +db_query("insert into { vc_survey_questions} (vc_survey_id,vc_rules_id,questions) values(1,1,'How fair do you think this rule is for managing the fishing grounds? ')"); +db_query("insert into { vc_survey_questions} (vc_survey_id,vc_rules_id,questions) values(1,1,'How much personal freedom do you think this rule allows you in managing the fishing grounds?')"); +db_query("insert into { vc_survey_questions} (vc_survey_id,vc_rules_id,questions) values(1,1,'How much do you think this rule would advance your own self-interest as measured by your total earning?')"); +db_query("insert into { vc_survey_questions} (vc_survey_id,vc_rules_id,questions) values(1,1,'All things considered how attractive do you find this rule?')"); + +db_query("insert into { vc_survey_questions} (vc_survey_id,vc_rules_id,questions) values(1,2,'How efficient do you think this rule is for managing the fishing grounds?')"); +db_query("insert into { vc_survey_questions} (vc_survey_id,vc_rules_id,questions) values(1,2,'How fair do you think this rule is for managing the fishing grounds? ')"); +db_query("insert into { vc_survey_questions} (vc_survey_id,vc_rules_id,questions) values(1,2,'How much personal freedom do you think this rule allows you in managing the fishing grounds?')"); +db_query("insert into { vc_survey_questions} (vc_survey_id,vc_rules_id,questions) values(1,2,'How much do you think this rule would advance your own self-interest as measured by your total earning?')"); +db_query("insert into { vc_survey_questions} (vc_survey_id,vc_rules_id,questions) values(1,2,'All things considered how attractive do you find this rule?')"); + +db_query("insert into { vc_survey_questions} (vc_survey_id,vc_rules_id,questions) values(1,3,'How efficient do you think this rule is for managing the fishing grounds?')"); +db_query("insert into { vc_survey_questions} (vc_survey_id,vc_rules_id,questions) values(1,3,'How fair do you think this rule is for managing the fishing grounds? ')"); +db_query("insert into { vc_survey_questions} (vc_survey_id,vc_rules_id,questions) values(1,3,'How much personal freedom do you think this rule allows you in managing the fishing grounds?')"); +db_query("insert into { vc_survey_questions} (vc_survey_id,vc_rules_id,questions) values(1,3,'How much do you think this rule would advance your own self-interest as measured by your total earning?')"); +db_query("insert into { vc_survey_questions} (vc_survey_id,vc_rules_id,questions) values(1,3,'All things considered how attractive do you find this rule?')"); + +db_query("insert into { vc_survey_questions} (vc_survey_id,vc_rules_id,questions) values(2,4,'How efficient do you think this rule is for managing the forest?')"); +db_query("insert into { vc_survey_questions} (vc_survey_id,vc_rules_id,questions) values(2,4,'How fair do you think this rule is for managing the forest? ')"); +db_query("insert into { vc_survey_questions} (vc_survey_id,vc_rules_id,questions) values(2,4,'How much personal freedom do you think this rule allows you in managing the forest?')"); +db_query("insert into { vc_survey_questions} (vc_survey_id,vc_rules_id,questions) values(2,4,'How much do you think this rule would advance your own self-interest as measured by your total earning?')"); +db_query("insert into { vc_survey_questions} (vc_survey_id,vc_rules_id,questions) values(2,4,'All things considered how attractive do you find this rule?')"); + + +db_query("insert into { vc_survey_questions} (vc_survey_id,vc_rules_id,questions) values(2,5,'How efficient do you think this rule is for managing the forest?')"); +db_query("insert into { vc_survey_questions} (vc_survey_id,vc_rules_id,questions) values(2,5,'How fair do you think this rule is for managing the forest? ')"); +db_query("insert into { vc_survey_questions} (vc_survey_id,vc_rules_id,questions) values(2,5,'How much personal freedom do you think this rule allows you in managing the forest?')"); +db_query("insert into { vc_survey_questions} (vc_survey_id,vc_rules_id,questions) values(2,5,'How much do you think this rule would advance your own self-interest as measured by your total earning?')"); +db_query("insert into { vc_survey_questions} (vc_survey_id,vc_rules_id,questions) values(2,5,'All things considered how attractive do you find this rule?')"); + + +db_query("insert into { vc_survey_questions} (vc_survey_id,vc_rules_id,questions) values(2,6,'How efficient do you think this rule is for managing the forest?')"); +db_query("insert into { vc_survey_questions} (vc_survey_id,vc_rules_id,questions) values(2,6,'How fair do you think this rule is for managing the forest? ')"); +db_query("insert into { vc_survey_questions} (vc_survey_id,vc_rules_id,questions) values(2,6,'How much personal freedom do you think this rule allows you in managing the forest?')"); +db_query("insert into { vc_survey_questions} (vc_survey_id,vc_rules_id,questions) values(2,6,'How much do you think this rule would advance your own self-interest as measured by your total earning?')"); +db_query("insert into { vc_survey_questions} (vc_survey_id,vc_rules_id,questions) values(2,6,'All things considered how attractive do you find this rule?')"); + + +db_query("insert into { vc_survey_questions} (vc_survey_id,vc_rules_id,questions) values(3,7,'How efficient do you think this rule is for managing the irrigation system?')"); +db_query("insert into { vc_survey_questions} (vc_survey_id,vc_rules_id,questions) values(3,7,'How fair do you think this rule is for managing the irrigation system? ')"); +db_query("insert into { vc_survey_questions} (vc_survey_id,vc_rules_id,questions) values(3,7,'How much personal freedom do you think this rule allows you in managing the irrigation system?')"); +db_query("insert into { vc_survey_questions} (vc_survey_id,vc_rules_id,questions) values(3,7,'How much do you think this rule would advance your own self-interest as measured by your total earning?')"); +db_query("insert into { vc_survey_questions} (vc_survey_id,vc_rules_id,questions) values(3,7,'All things considered how attractive do you find this rule?')"); + + +db_query("insert into { vc_survey_questions} (vc_survey_id,vc_rules_id,questions) values(3,8,'How efficient do you think this rule is for managing the irrigation system?')"); +db_query("insert into { vc_survey_questions} (vc_survey_id,vc_rules_id,questions) values(3,8,'How fair do you think this rule is for managing the irrigation system? ')"); +db_query("insert into { vc_survey_questions} (vc_survey_id,vc_rules_id,questions) values(3,8,'How much personal freedom do you think this rule allows you in managing the irrigation system?')"); +db_query("insert into { vc_survey_questions} (vc_survey_id,vc_rules_id,questions) values(3,8,'How much do you think this rule would advance your own self-interest as measured by your total earning?')"); +db_query("insert into { vc_survey_questions} (vc_survey_id,vc_rules_id,questions) values(3,8,'All things considered how attractive do you find this rule?')"); + + +db_query("insert into { vc_survey_questions} (vc_survey_id,vc_rules_id,questions) values(3,9,'How efficient do you think this rule is for managing the irrigation system?')"); +db_query("insert into { vc_survey_questions} (vc_survey_id,vc_rules_id,questions) values(3,9,'How fair do you think this rule is for managing the irrigation system? ')"); +db_query("insert into { vc_survey_questions} (vc_survey_id,vc_rules_id,questions) values(3,9,'How much personal freedom do you think this rule allows you in managing the irrigation system?')"); +db_query("insert into { vc_survey_questions} (vc_survey_id,vc_rules_id,questions) values(3,9,'How much do you think this rule would advance your own self-interest as measured by your total earning?')"); +db_query("insert into { vc_survey_questions} (vc_survey_id,vc_rules_id,questions) values(3,9,'All things considered how attractive do you find this rule?')"); + +db_query("insert into { vc_survey_questions_options} (vc_survey_questions_id,min_value,max_value) values(1,'not at all efficient','very efficient')"); +db_query("insert into { vc_survey_questions_options} (vc_survey_questions_id,min_value,max_value) values(2,'not at all fair','very fair')"); +db_query("insert into { vc_survey_questions_options} (vc_survey_questions_id,min_value,max_value) values(3,'no freedom at all','complete freedom')"); +db_query("insert into { vc_survey_questions_options} (vc_survey_questions_id,min_value,max_value) values(4,'not at all','very much')"); +db_query("insert into { vc_survey_questions_options} (vc_survey_questions_id,min_value,max_value) values(5,'not attractive at all','Very attractive')"); + +db_query("insert into { vc_survey_questions_options} (vc_survey_questions_id,min_value,max_value) values(6,'not at all efficient','very efficient')"); +db_query("insert into { vc_survey_questions_options} (vc_survey_questions_id,min_value,max_value) values(7,'not at all fair','very fair')"); +db_query("insert into { vc_survey_questions_options} (vc_survey_questions_id,min_value,max_value) values(8,'no freedom at all','complete freedom')"); +db_query("insert into { vc_survey_questions_options} (vc_survey_questions_id,min_value,max_value) values(9,'not at all','very much')"); +db_query("insert into { vc_survey_questions_options} (vc_survey_questions_id,min_value,max_value) values(10,'not attractive at all','Very attractive')"); + +db_query("insert into { vc_survey_questions_options} (vc_survey_questions_id,min_value,max_value) values(11,'not at all efficient','very efficient')"); +db_query("insert into { vc_survey_questions_options} (vc_survey_questions_id,min_value,max_value) values(12,'not at all fair','very fair')"); +db_query("insert into { vc_survey_questions_options} (vc_survey_questions_id,min_value,max_value) values(13,'no freedom at all','complete freedom')"); +db_query("insert into { vc_survey_questions_options} (vc_survey_questions_id,min_value,max_value) values(14,'not at all','very much')"); +db_query("insert into { vc_survey_questions_options} (vc_survey_questions_id,min_value,max_value) values(15,'not attractive at all','Very attractive')"); + + +db_query("insert into { vc_survey_questions_options} (vc_survey_questions_id,min_value,max_value) values(16,'not at all efficient','very efficient')"); +db_query("insert into { vc_survey_questions_options} (vc_survey_questions_id,min_value,max_value) values(17,'not at all fair','very fair')"); +db_query("insert into { vc_survey_questions_options} (vc_survey_questions_id,min_value,max_value) values(18,'no freedom at all','complete freedom')"); +db_query("insert into { vc_survey_questions_options} (vc_survey_questions_id,min_value,max_value) values(19,'not at all','very much')"); +db_query("insert into { vc_survey_questions_options} (vc_survey_questions_id,min_value,max_value) values(20,'not attractive at all','Very attractive')"); + + +db_query("insert into { vc_survey_questions_options} (vc_survey_questions_id,min_value,max_value) values(21,'not at all efficient','very efficient')"); +db_query("insert into { vc_survey_questions_options} (vc_survey_questions_id,min_value,max_value) values} (22,'not at all fair','very fair')"); +db_query("insert into { vc_survey_questions_options} (vc_survey_questions_id,min_value,max_value) values(23,'no freedom at all','complete freedom')"); +db_query("insert into { vc_survey_questions_options} (vc_survey_questions_id,min_value,max_value) values(24,'not at all','very much')"); +db_query("insert into { vc_survey_questions_options} (vc_survey_questions_id,min_value,max_value) values(25,'not attractive at all','Very attractive')"); + +db_query("insert into { vc_survey_questions_options} (vc_survey_questions_id,min_value,max_value) values(26,'not at all efficient','very efficient')"); +db_query("insert into { vc_survey_questions_options} (vc_survey_questions_id,min_value,max_value) values(27,'not at all fair','very fair')"); +db_query("insert into { vc_survey_questions_options} (vc_survey_questions_id,min_value,max_value) values(28,'no freedom at all','complete freedom')"); +db_query("insert into { vc_survey_questions_options} (vc_survey_questions_id,min_value,max_value) values(29,'not at all','very much')"); +db_query("insert into { vc_survey_questions_options} (vc_survey_questions_id,min_value,max_value) values(30,'not attractive at all','Very attractive')"); + +db_query("insert into { vc_survey_questions_options} (vc_survey_questions_id,min_value,max_value) values(31,'not at all efficient','very efficient')"); +db_query("insert into { vc_survey_questions_options} (vc_survey_questions_id,min_value,max_value) values(32,'not at all fair','very fair')"); +db_query("insert into { vc_survey_questions_options} (vc_survey_questions_id,min_value,max_value) values(33,'no freedom at all','complete freedom')"); +db_query("insert into { vc_survey_questions_options} (vc_survey_questions_id,min_value,max_value) values(34,'not at all','very much')"); +db_query("insert into { vc_survey_questions_options} (vc_survey_questions_id,min_value,max_value) values(35,'not attractive at all','Very attractive')"); + +db_query("insert into { vc_survey_questions_options} (vc_survey_questions_id,min_value,max_value) values(36,'not at all efficient','very efficient')"); +db_query("insert into { vc_survey_questions_options} (vc_survey_questions_id,min_value,max_value) values(37,'not at all fair','very fair')"); +db_query("insert into { vc_survey_questions_options} (vc_survey_questions_id,min_value,max_value) values(38,'no freedom at all','complete freedom')"); +db_query("insert into { vc_survey_questions_options} (vc_survey_questions_id,min_value,max_value) values(39,'not at all','very much')"); +db_query("insert into { vc_survey_questions_options} (vc_survey_questions_id,min_value,max_value) values(40,'not attractive at all','Very attractive')"); + +db_query("insert into { vc_survey_questions_options} (vc_survey_questions_id,min_value,max_value) values(41,'not at all efficient','very efficient')"); +db_query("insert into { vc_survey_questions_options} (vc_survey_questions_id,min_value,max_value) values(42,'not at all fair','very fair')"); +db_query("insert into { vc_survey_questions_options} (vc_survey_questions_id,min_value,max_value) values(43,'no freedom at all','complete freedom')"); +db_query("insert into {vc_survey_questions_options} (vc_survey_questions_id,min_value,max_value) values(44,'not at all','very much')"); +db_query("insert into {vc_survey_questions_options} (vc_survey_questions_id,min_value,max_value) values(45,'not attractive at all','Very attractive')"); + + + $flag=TRUE; + break; + case 'pgsql': + + +db_query("CREATE TABLE {vc_survey} +( + id int AUTO_INCREMENT, + vc_experiments_id int NOT NULL, + date_of_creation DATE, + + PRIMARY KEY(id), + + FOREIGN KEY(vc_experiments_id) REFERENCES vc_experiments(id) + ON DELETE CASCADE + +)ENGINE=InnoDB /*!40100 DEFAULT CHARACTER SET UTF8 */"); + +db_query("CREATE TABLE {vc_survey_questions} +( + id int NOT NULL AUTO_INCREMENT, + vc_survey_id int NOT NULL, + vc_rules_id int NOT NULL, + questions varchar(500) default ' ', + + + PRIMARY KEY(id), + + FOREIGN KEY(vc_survey_id) REFERENCES vc_survey(id) + ON DELETE CASCADE, + + FOREIGN KEY(vc_rules_id) REFERENCES vc_rules(id) + ON DELETE CASCADE + +)ENGINE=InnoDB /*!40100 DEFAULT CHARACTER SET UTF8 */"); + + +db_query("CREATE TABLE {vc_survey_questions_options} +( + id int NOT NULL AUTO_INCREMENT, + vc_survey_questions_id int NOT NULL, + min_value varchar(100) NOT NULL, + max_value varchar(100) NOT NULL, + + + PRIMARY KEY(id), + + FOREIGN KEY(vc_survey_questions_id) REFERENCES vc_survey_questions(id) + ON DELETE CASCADE + +)ENGINE=InnoDB /*!40100 DEFAULT CHARACTER SET UTF8 */"); + + + $flag=TRUE; + break; + default: + drupal_set_message(t('Unsupported Database')); + } + if($flag) + { + drupal_set_message(t('Survey table is successfully created.')); + } + else + { + drupal_set_message(t('Survey table is NOT successfully created.'),'error'); + } +} + +/** + * Implementation of hook_uninstall(). + */ +function survey_uninstall() +{ + db_query("DROP TABLE {vc_survey_response}"); + db_query("DROP TABLE {vc_survey_questions_options}"); + db_query("DROP TABLE {vc_survey_questions}"); + db_query("DROP TABLE {vc_survey}"); + + + drupal_set_message(t('Survey table is successfully deleted from the database.')); +} + Added: vcweb/trunk/virtualcommons/experiment/survey/survey.module =================================================================== --- vcweb/trunk/virtualcommons/experiment/survey/survey.module (rev 0) +++ vcweb/trunk/virtualcommons/experiment/survey/survey.module 2008-08-06 05:22:25 UTC (rev 26) @@ -0,0 +1,129 @@ +<?php + + +/*function rules_load() { + 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', + 'title' => t('Survey'), + 'callback' => 'survey', + 'type'=>MENU_CALLBACK, + 'access' => TRUE//user_access('Only Teachers') + ); + + } +/*else +{ +rules_load(); +}*/ + + return $items; +} + +function survey() { + + + // 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 .= drupal_get_form('survey_form'); + return $output; +} + + +function survey_form() +{ +$form['#id']='survey_form'; +$form['#tree'] = TRUE; +$stud_id=$_SESSION['student_id']; + +//$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) + { + + $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; +} + + +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++; + + } + } + + + /*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 'survey'; + +} + Added: vcweb/trunk/virtualcommons/experiment/survey/survey_questions.sql =================================================================== --- vcweb/trunk/virtualcommons/experiment/survey/survey_questions.sql (rev 0) +++ vcweb/trunk/virtualcommons/experiment/survey/survey_questions.sql 2008-08-06 05:22:25 UTC (rev 26) @@ -0,0 +1,119 @@ +insert into vc_survey(vc_experiment_id) values('1'); +insert into vc_survey(vc_experiment_id) values('2'); +insert into vc_survey(vc_experiment_id) values('3'); + +insert into vc_survey_questions(vc_survey_id,vc_rules_id,questions) values(1,1,'How efficient do you think this rule is for managing the fishing grounds?'); +insert into vc_survey_questions(vc_survey_id,vc_rules_id,questions) values(1,1,'How fair do you think this rule is for managing the fishing grounds? '); +insert into vc_survey_questions(vc_survey_id,vc_rules_id,questions) values(1,1,'How much personal freedom do you think this rule allows you in managing the fishing grounds?'); +insert into vc_survey_questions(vc_survey_id,vc_rules_id,questions) values(1,1,'How much do you think this rule would advance your own self-interest as measured by your total earning?'); +insert into vc_survey_questions(vc_survey_id,vc_rules_id,questions) values(1,1,'All things considered how attractive do you find this rule?'); + +insert into vc_survey_questions(vc_survey_id,vc_rules_id,questions) values(1,2,'How efficient do you think this rule is for managing the fishing grounds?'); +insert into vc_survey_questions(vc_survey_id,vc_rules_id,questions) values(1,2,'How fair do you think this rule is for managing the fishing grounds? '); +insert into vc_survey_questions(vc_survey_id,vc_rules_id,questions) values(1,2,'How much personal freedom do you think this rule allows you in managing the fishing grounds?'); +insert into vc_survey_questions(vc_survey_id,vc_rules_id,questions) values(1,2,'How much do you think this rule would advance your own self-interest as measured by your total earning?'); +insert into vc_survey_questions(vc_survey_id,vc_rules_id,questions) values(1,2,'All things considered how attractive do you find this rule?'); + +insert into vc_survey_questions(vc_survey_id,vc_rules_id,questions) values(1,3,'How efficient do you think this rule is for managing the fishing grounds?'); +insert into vc_survey_questions(vc_survey_id,vc_rules_id,questions) values(1,3,'How fair do you think this rule is for managing the fishing grounds? '); +insert into vc_survey_questions(vc_survey_id,vc_rules_id,questions) values(1,3,'How much personal freedom do you think this rule allows you in managing the fishing grounds?'); +insert into vc_survey_questions(vc_survey_id,vc_rules_id,questions) values(1,3,'How much do you think this rule would advance your own self-interest as measured by your total earning?'); +insert into vc_survey_questions(vc_survey_id,vc_rules_id,questions) values(1,3,'All things considered how attractive do you find this rule?'); + +insert into vc_survey_questions(vc_survey_id,vc_rules_id,questions) values(2,4,'How efficient do you think this rule is for managing the forest?'); +insert into vc_survey_questions(vc_survey_id,vc_rules_id,questions) values(2,4,'How fair do you think this rule is for managing the forest? '); +insert into vc_survey_questions(vc_survey_id,vc_rules_id,questions) values(2,4,'How much personal freedom do you think this rule allows you in managing the forest?'); +insert into vc_survey_questions(vc_survey_id,vc_rules_id,questions) values(2,4,'How much do you think this rule would advance your own self-interest as measured by your total earning?'); +insert into vc_survey_questions(vc_survey_id,vc_rules_id,questions) values(2,4,'All things considered how attractive do you find this rule?'); + + +insert into vc_survey_questions(vc_survey_id,vc_rules_id,questions) values(2,5,'How efficient do you think this rule is for managing the forest?'); +insert into vc_survey_questions(vc_survey_id,vc_rules_id,questions) values(2,5,'How fair do you think this rule is for managing the forest? '); +insert into vc_survey_questions(vc_survey_id,vc_rules_id,questions) values(2,5,'How much personal freedom do you think this rule allows you in managing the forest?'); +insert into vc_survey_questions(vc_survey_id,vc_rules_id,questions) values(2,5,'How much do you think this rule would advance your own self-interest as measured by your total earning?'); +insert into vc_survey_questions(vc_survey_id,vc_rules_id,questions) values(2,5,'All things considered how attractive do you find this rule?'); + + +insert into vc_survey_questions(vc_survey_id,vc_rules_id,questions) values(2,6,'How efficient do you think this rule is for managing the fishing grounds?'); +insert into vc_survey_questions(vc_survey_id,vc_rules_id,questions) values(2,6,'How fair do you think this rule is for managing the fishing grounds? '); +insert into vc_survey_questions(vc_survey_id,vc_rules_id,questions) values(2,6,'How much personal freedom do you think this rule allows you in managing the fishing grounds?'); +insert into vc_survey_questions(vc_survey_id,vc_rules_id,questions) values(2,6,'How much do you think this rule would advance your own self-interest as measured by your total earning?'); +insert into vc_survey_questions(vc_survey_id,vc_rules_id,questions) values(2,6,'All things considered how attractive do you find this rule?'); + + +insert into vc_survey_questions(vc_survey_id,vc_rules_id,questions) values(3,7,'How efficient do you think this rule is for managing the irrigation system?'); +insert into vc_survey_questions(vc_survey_id,vc_rules_id,questions) values(3,7,'How fair do you think this rule is for managing the irrigation system? '); +insert into vc_survey_questions(vc_survey_id,vc_rules_id,questions) values(3,7,'How much personal freedom do you think this rule allows you in managing the irrigation system?'); +insert into vc_survey_questions(vc_survey_id,vc_rules_id,questions) values(3,7,'How much do you think this rule would advance your own self-interest as measured by your total earning?'); +insert into vc_survey_questions(vc_survey_id,vc_rules_id,questions) values(3,7,'All things considered how attractive do you find this rule?'); + + +insert into vc_survey_questions(vc_survey_id,vc_rules_id,questions) values(3,8,'How efficient do you think this rule is for managing the irrigation system?'); +insert into vc_survey_questions(vc_survey_id,vc_rules_id,questions) values(3,8,'How fair do you think this rule is for managing the irrigation system? '); +insert into vc_survey_questions(vc_survey_id,vc_rules_id,questions) values(3,8,'How much personal freedom do you think this rule allows you in managing the irrigation system?'); +insert into vc_survey_questions(vc_survey_id,vc_rules_id,questions) values(3,8,'How much do you think this rule would advance your own self-interest as measured by your total earning?'); +insert into vc_survey_questions(vc_survey_id,vc_rules_id,questions) values(3,8,'All things considered how attractive do you find this rule?'); + + +insert into vc_survey_questions(vc_survey_id,vc_rules_id,questions) values(3,9,'How efficient do you think this rule is for managing the irrigation system?'); +insert into vc_survey_questions(vc_survey_id,vc_rules_id,questions) values(3,9,'How fair do you think this rule is for managing the irrigation system? '); +insert into vc_survey_questions(vc_survey_id,vc_rules_id,questions) values(3,9,'How much personal freedom do you think this rule allows you in managing the irrigation system?'); +insert into vc_survey_questions(vc_survey_id,vc_rules_id,questions) values(3,9,'How much do you think this rule would advance your own self-interest as measured by your total earning?'); +insert into vc_survey_questions(vc_survey_id,vc_rules_id,questions) values(3,9,'All things considered how attractive do you find this rule?'); + +insert into vc_survey_questions_options(vc_survey_questions_id,min_value,max_value) values(1,'not at all efficient','very efficient'); +insert into vc_survey_questions_options(vc_survey_questions_id,min_value,max_value) values(2,'not at all fair','very fair'); +insert into vc_survey_questions_options(vc_survey_questions_id,min_value,max_value) values(3,'no freedom at all','complete freedom'); +insert into vc_survey_questions_options(vc_survey_questions_id,min_value,max_value) values(4,'not at all','very much'); +insert into vc_survey_questions_options(vc_survey_questions_id,min_value,max_value) values(5,'not attractive at all','Very attractive'); + +insert into vc_survey_questions_options(vc_survey_questions_id,min_value,max_value) values(6,'not at all efficient','very efficient'); +insert into vc_survey_questions_options(vc_survey_questions_id,min_value,max_value) values(7,'not at all fair','very fair'); +insert into vc_survey_questions_options(vc_survey_questions_id,min_value,max_value) values(8,'no freedom at all','complete freedom'); +insert into vc_survey_questions_options(vc_survey_questions_id,min_value,max_value) values(9,'not at all','very much'); +insert into vc_survey_questions_options(vc_survey_questions_id,min_value,max_value) values(10,'not attractive at all','Very attractive'); + +insert into vc_survey_questions_options(vc_survey_questions_id,min_value,max_value) values(11,'not at all efficient','very efficient'); +insert into vc_survey_questions_options(vc_survey_questions_id,min_value,max_value) values(12,'not at all fair','very fair'); +insert into vc_survey_questions_options(vc_survey_questions_id,min_value,max_value) values(13,'no freedom at all','complete freedom'); +insert into vc_survey_questions_options(vc_survey_questions_id,min_value,max_value) values(14,'not at all','very much'); +insert into vc_survey_questions_options(vc_survey_questions_id,min_value,max_value) values(15,'not attractive at all','Very attractive'); + + +insert into vc_survey_questions_options(vc_survey_questions_id,min_value,max_value) values(16,'not at all efficient','very efficient'); +insert into vc_survey_questions_options(vc_survey_questions_id,min_value,max_value) values(17,'not at all fair','very fair'); +insert into vc_survey_questions_options(vc_survey_questions_id,min_value,max_value) values(18,'no freedom at all','complete freedom'); +insert into vc_survey_questions_options(vc_survey_questions_id,min_value,max_value) values(19,'not at all','very much'); +insert into vc_survey_questions_options(vc_survey_questions_id,min_value,max_value) values(20,'not attractive at all','Very attractive'); + + +insert into vc_survey_questions_options(vc_survey_questions_id,min_value,max_value) values(21,'not at all efficient','very efficient'); +insert into vc_survey_questions_options(vc_survey_questions_id,min_value,max_value) values(22,'not at all fair','very fair'); +insert into vc_survey_questions_options(vc_survey_questions_id,min_value,max_value) values(23,'no freedom at all','complete freedom'); +insert into vc_survey_questions_options(vc_survey_questions_id,min_value,max_value) values(24,'not at all','very much'); +insert into vc_survey_questions_options(vc_survey_questions_id,min_value,max_value) values(25,'not attractive at all','Very attractive'); + +insert into vc_survey_questions_options(vc_survey_questions_id,min_value,max_value) values(26,'not at all efficient','very efficient'); +insert into vc_survey_questions_options(vc_survey_questions_id,min_value,max_value) values(27,'not at all fair','very fair'); +insert into vc_survey_questions_options(vc_survey_questions_id,min_value,max_value) values(28,'no freedom at all','complete freedom'); +insert into vc_survey_questions_options(vc_survey_questions_id,min_value,max_value) values(29,'not at all','very much'); +insert into vc_survey_questions_options(vc_survey_questions_id,min_value,max_value) values(30,'not attractive at all','Very attractive'); + +insert into vc_survey_questions_options(vc_survey_questions_id,min_value,max_value) values(31,'not at all efficient','very efficient'); +insert into vc_survey_questions_options(vc_survey_questions_id,min_value,max_value) values(32,'not at all fair','very fair'); +insert into vc_survey_questions_options(vc_survey_questions_id,min_value,max_value) values(33,'no freedom at all','complete freedom'); +insert into vc_survey_questions_options(vc_survey_questions_id,min_value,max_value) values(34,'not at all','very much'); +insert into vc_survey_questions_options(vc_survey_questions_id,min_value,max_value) values(35,'not attractive at all','Very attractive'); + +insert into vc_survey_questions_options(vc_survey_questions_id,min_value,max_value) values(36,'not at all efficient','very efficient'); +insert into vc_survey_questions_options(vc_survey_questions_id,min_value,max_value) values(37,'not at all fair','very fair'); +insert into vc_survey_questions_options(vc_survey_questions_id,min_value,max_value) values(38,'no freedom at all','complete freedom'); +insert into vc_survey_questions_options(vc_survey_questions_id,min_value,max_value) values(39,'not at all','very much'); +insert into vc_survey_questions_options(vc_survey_questions_id,min_value,max_value) values(40,'not attractive at all','Very attractive'); + +insert into vc_survey_questions_options(vc_survey_questions_id,min_value,max_value) values(41,'not at all efficient','very efficient'); +insert into vc_survey_questions_options(vc_survey_questions_id,min_value,max_value) values(42,'not at all fair','very fair'); +insert into vc_survey_questions_options(vc_survey_questions_id,min_value,max_value) values(43,'no freedom at all','complete freedom'); +insert into vc_survey_questions_options(vc_survey_questions_id,min_value,max_value) values(44,'not at all','very much'); +insert into vc_survey_questions_options(vc_survey_questions_id,min_value,max_value) values(45,'not attractive at all','Very attractive'); + This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <al...@us...> - 2008-08-05 20:10:22
|
Revision: 25 http://virtualcommons.svn.sourceforge.net/virtualcommons/?rev=25&view=rev Author: alllee Date: 2008-08-05 20:10:29 +0000 (Tue, 05 Aug 2008) Log Message: ----------- updating Archiva location in POM and ivy Modified Paths: -------------- foraging/trunk/build.xml foraging/trunk/ivysettings.xml foraging/trunk/pom.xml Modified: foraging/trunk/build.xml =================================================================== --- foraging/trunk/build.xml 2008-08-05 20:07:15 UTC (rev 24) +++ foraging/trunk/build.xml 2008-08-05 20:10:29 UTC (rev 25) @@ -180,7 +180,7 @@ <param name='main.class' value='${server.class}'/> <param name='jar.name' value='server.jar'/> </antcall> - <move file='dist/server.jar' tofile='server.jar'/> + <move file='${dist.dir}/server.jar' tofile='server.jar'/> </target> <target name='build-jar'> Modified: foraging/trunk/ivysettings.xml =================================================================== --- foraging/trunk/ivysettings.xml 2008-08-05 20:07:15 UTC (rev 24) +++ foraging/trunk/ivysettings.xml 2008-08-05 20:10:29 UTC (rev 25) @@ -5,7 +5,7 @@ <ivysettings> <settings defaultResolver="csid-archiva" checkUpToDate="false"/> <resolvers> - <ibiblio name='csid-archiva' m2compatible='true' root='http://csid.asu.edu:8080/archiva/repository/internal'/> + <ibiblio name='csid-archiva' m2compatible='true' root='http://csid.asu.edu/archiva/repository/internal'/> <filesystem name="internal"> <ivy pattern="${repository.dir}/[module]/ivy-[revision].xml"/> <artifact pattern="${repository.dir}/[module]/[artifact]-[revision].[ext]"/> Modified: foraging/trunk/pom.xml =================================================================== --- foraging/trunk/pom.xml 2008-08-05 20:07:15 UTC (rev 24) +++ foraging/trunk/pom.xml 2008-08-05 20:10:29 UTC (rev 25) @@ -15,7 +15,7 @@ <repository> <id>csid.asu.edu</id> <name>CSID Maven2 repository</name> - <url>http://csid.asu.edu:8080/archiva/repository/internal</url> + <url>http://csid.asu.edu/archiva/repository/internal</url> </repository> <repository> <id>java.net</id> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <al...@us...> - 2008-08-05 20:07:12
|
Revision: 24 http://virtualcommons.svn.sourceforge.net/virtualcommons/?rev=24&view=rev Author: alllee Date: 2008-08-05 20:07:15 +0000 (Tue, 05 Aug 2008) Log Message: ----------- changing Archiva URL and fixing a compile error in Persister (though we need to rethink XmlSet persistence since it makes performance incredibly slow) Modified Paths: -------------- csidex/trunk/pom.xml csidex/trunk/src/main/java/edu/asu/commons/experiment/Persister.java Modified: csidex/trunk/pom.xml =================================================================== --- csidex/trunk/pom.xml 2008-08-05 00:36:14 UTC (rev 23) +++ csidex/trunk/pom.xml 2008-08-05 20:07:15 UTC (rev 24) @@ -10,7 +10,7 @@ <repository> <id>csid.asu.edu</id> <name>CSID Maven2 repository</name> - <url>http://csid.asu.edu:8080/archiva/repository/internal</url> + <url>http://csid.asu.edu/archiva/repository/internal</url> </repository> <repository> <id>java.net</id> 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-05 00:36:14 UTC (rev 23) +++ csidex/trunk/src/main/java/edu/asu/commons/experiment/Persister.java 2008-08-05 20:07:15 UTC (rev 24) @@ -53,6 +53,7 @@ // private final XStream xstream = new XStream(); // private PrintWriter xmlPrintWriter; private boolean xmlEnabled; + private XmlSet xmlSet; // private boolean usingEventChannel; @@ -315,11 +316,12 @@ } private void saveExperimentConfiguration(T experimentConfiguration) { - try { doSaveExperimentConfiguration(experimentConfiguration, persistenceDirectory); } catch (FileNotFoundException recoverable) { + // FIXME: this is duplicated across the regular save() as well, + // see if we can extract the algorithm out. recoverable.printStackTrace(); try { doSaveExperimentConfiguration(experimentConfiguration, getFailSafeSaveDirectory()); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <al...@us...> - 2008-08-05 00:36:06
|
Revision: 23 http://virtualcommons.svn.sourceforge.net/virtualcommons/?rev=23&view=rev Author: alllee Date: 2008-08-05 00:36:14 +0000 (Tue, 05 Aug 2008) Log Message: ----------- refactored teacher_dashboard's stage display and getAllGroupRoundInfo to return a hashtable of stage_ids mapped to an array of arrays representing the group round info for that stage. some minor schema cleanup Modified Paths: -------------- vcweb/trunk/virtualcommons/experiment/experiment.inc vcweb/trunk/virtualcommons/experiment/experiment.install vcweb/trunk/virtualcommons/games/forestry_v2/forestry_v2.install vcweb/trunk/virtualcommons/games/teacher_dashboard/teacher_dashboard.install vcweb/trunk/virtualcommons/games/teacher_dashboard/teacher_dashboard.module Modified: vcweb/trunk/virtualcommons/experiment/experiment.inc =================================================================== --- vcweb/trunk/virtualcommons/experiment/experiment.inc 2008-08-04 20:13:03 UTC (rev 22) +++ vcweb/trunk/virtualcommons/experiment/experiment.inc 2008-08-05 00:36:14 UTC (rev 23) @@ -1,9 +1,11 @@ <?php + + class Session { public static function put($ses_var, $object) { //if( ! isset($_SESSION[$ses_var]) ) { - $_SESSION[$ses_var] = serialize($object); + $_SESSION[$ses_var] = serialize($object); //} } public static function get($ses_var) { @@ -46,15 +48,21 @@ return $this->no_of_students; } - public function getInitialStageId() { - return db_result(db_query("select id from vc_stage where vc_experiment_id=%d and stage_no=%d",$this->experiment_id,$this->current_stage_no)); + // FIXME: remove current_stage_no from this session object since it is + // unsafe if the browser exits + public function getStageId($current_stage_no) { + return db_result(db_query("select id from vc_stage where vc_experiment_id=%d and stage_no=%d",$this->experiment_id, $current_stage_no)); } public function getCurrentStageId() { return db_result(db_query("select vc_stage_id from vc_game where id=%d",$this->game_id)); } + public function getCurrentRoundNo() { + return db_result(db_query("select current_round_no from vc_game where id=%d",$this->game_id)); + } + public function getGameId() { return $this->game_id; } @@ -80,7 +88,7 @@ $this->teacher_id, $this->experiment_id, $this->no_of_students, - $this->getInitialStageId(), + $this->getStageId($this->current_stage_no), $this->current_round_no); } } @@ -103,7 +111,7 @@ { //drupal_set_message(t('Group Key is: %key<br>' ,array('%key'=>$key))); $group_id=db_next_id('vc_group_id'); - db_query("Insert into {vc_group} (id,group_no,vc_game_id,vc_stage_id) values(%d,%d,%d,%d)",$group_id,$group,$this->game_id,$this->stage_id); + db_query("Insert into {vc_group} (id,group_no,vc_game_id) values(%d,%d,%d)",$group_id,$group,$this->game_id); $i=0; foreach ($value as $key=>$student_id) { @@ -116,41 +124,37 @@ } } + public function isVotingEnabled() { + return 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)); + } + + public function isVotingEnabledForStage($stage_id) { + return db_result(db_query("select voting from vc_stage where id=%d", $stage_id)); + } + 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",$game_id)); + $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; } - // FIXME: figure out if we can move to forestry at some point + // FIXME: turn into $forestryGame->init() overloaded method public function initForestry() { - $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); + $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_student=$data->cnt; - $group_no=$data->group_id; + $group_id=$data->group_id; //drupal_set_message(t($no_of_student.' '. $group_no)); - if($no_of_student == 5) - { - db_query("Insert into {vc_forestry_common_resource_pool} (vc_group_id,common_resource_pool,vc_game_id, harvest_decision,max_harvest_decision) values(%d,%d,%d,%d,%d)",$group_no,100,$this->game_id,0,100); - - } - - else if($no_of_student == 4) - { - db_query("Insert into {vc_forestry_common_resource_pool} (vc_group_id,common_resource_pool,vc_game_id, harvest_decision,max_harvest_decision) values(%d,%d,%d,%d,%d)",$group_no,80,$this->game_id,0,80); - } - - - else if($no_of_student == 3) - { - db_query("Insert into {vc_forestry_common_resource_pool} (vc_group_id,common_resource_pool,vc_game_id,harvest_decision,max_harvest_decision) values(%d,%d,%d,%d,%d)",$group_no,60,$this->game_id,0,60); - } - + $this->initGroup($no_of_student, $group_id); } + } - + private function initGroup($number_of_students, $group_id) { + $resource_max = $number_of_students * 20; + db_query("Insert into {vc_forestry_common_resource_pool} (vc_group_id,common_resource_pool,vc_game_id,max_resources) values(%d,%d,%d,%d)", + $group_id, $resource_max, $this->game_id, $resource_max); } public function updateStartFlag($flag) @@ -158,23 +162,31 @@ db_query("update vc_student set start_flag=%d where vc_group_id in (select id from vc_group where vc_game_id=%d)",$flag,$this->game_id); } + public function getStageNumber($stage_id) { + return db_result(db_query("SELECT stage_no FROM {vc_stage} WHERE id=%d", $stage_id)); + } + + // returns { stage_id -> {group round data, ...}, ... } public function getAllGroupRoundInfo() { - $result=db_query("SELECT round_no, vc_group_id, total_harvest_decision, resources_before, resources_after, vc_rules_id, dice - FROM {vc_forestry_group_round_info} - WHERE vc_game_id=%d and vc_stage_id=%d", - $this->game_id, $this->getCurrentStageId()); + $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 + ORDER BY round_no", + $this->game_id); $stage_data = array(); while($data = db_fetch_object($result)) { $round_no=$data->round_no; - $group_id=$data->vc_group_id; + $group_no=$data->group_no; + $stage_id=$data->vc_stage_id; + $total_harvest_decision=$data->total_harvest_decision; $resources_before=$data->resources_before; $resources_after=$data->resources_after; - $group_round_data = array($round_no,$group_no,$total_harvest_decision,$resource_before,$resource_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); } - $stage_data[] = $group_round_data; + $stage_data[$stage_id][] = $group_round_data; } return $stage_data; } @@ -183,7 +195,59 @@ 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 processGroups() + { + $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); + while($data = db_fetch_object($result)) + { + $group_id=$data->group_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 round_no=%d", + $group_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)", + $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); + } + //update start flag + $this->updateStartFlag(true); + //update crrent round_no + $round_no=$round_no+1; + 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); + } + + }//end of class Game class Group { Modified: vcweb/trunk/virtualcommons/experiment/experiment.install =================================================================== --- vcweb/trunk/virtualcommons/experiment/experiment.install 2008-08-04 20:13:03 UTC (rev 22) +++ vcweb/trunk/virtualcommons/experiment/experiment.install 2008-08-05 00:36:14 UTC (rev 23) @@ -59,12 +59,10 @@ id INT AUTO_INCREMENT, group_no INT NOT NULL, vc_game_id INT NOT NULL, - vc_stage_id INT NOT NULL, vc_selected_rules_id INT NULL, PRIMARY KEY(id), FOREIGN KEY(vc_game_id) REFERENCES vc_game(id), - FOREIGN KEY(vc_stage_id) REFERENCES vc_stage(id), FOREIGN KEY(vc_selected_rules_id) REFERENCES vc_rules(id) ) ENGINE=InnoDB /*!40100 DEFAULT CHARACTER SET UTF8 */"); @@ -183,6 +181,8 @@ db_query("DROP TABLE {vc_student}"); db_query("DROP TABLE {vc_group}"); + db_query("delete from sequences where name='vc_game_id'"); + db_query("delete from sequences where name='vc_group_id'"); db_query("DROP TABLE {vc_game}"); db_query("DROP TABLE {vc_rules}"); db_query("DROP TABLE {vc_stage}"); Modified: vcweb/trunk/virtualcommons/games/forestry_v2/forestry_v2.install =================================================================== --- vcweb/trunk/virtualcommons/games/forestry_v2/forestry_v2.install 2008-08-04 20:13:03 UTC (rev 22) +++ vcweb/trunk/virtualcommons/games/forestry_v2/forestry_v2.install 2008-08-05 00:36:14 UTC (rev 23) @@ -13,9 +13,9 @@ id INT AUTO_INCREMENT, vc_group_id INT NOT NULL, common_resource_pool INT NOT NULL, - harvest_decision INT NOT NULL, + vc_game_id INT NOT NULL, - max_harvest_decision INT NOT NULL, + max_resources INT NOT NULL, PRIMARY KEY(id), FOREIGN KEY(vc_group_id) REFERENCES vc_group(id) Modified: vcweb/trunk/virtualcommons/games/teacher_dashboard/teacher_dashboard.install =================================================================== --- vcweb/trunk/virtualcommons/games/teacher_dashboard/teacher_dashboard.install 2008-08-04 20:13:03 UTC (rev 22) +++ vcweb/trunk/virtualcommons/games/teacher_dashboard/teacher_dashboard.install 2008-08-05 00:36:14 UTC (rev 23) @@ -20,7 +20,7 @@ total_harvest_decision int NOT NULL, resources_before int NOT NULL, resources_after int NOT NULL, - vc_rules_id int NOT NULL, + vc_rules_id int default NULL, dice int default 0, PRIMARY KEY(id), @@ -52,7 +52,7 @@ total_harvest_decision int NOT NULL, resources_before int NOT NULL, resources_after int NOT NULL, - vc_rules_id int NOT NULL, + vc_rules_id int default NULL, dice int default 0, Modified: vcweb/trunk/virtualcommons/games/teacher_dashboard/teacher_dashboard.module =================================================================== --- vcweb/trunk/virtualcommons/games/teacher_dashboard/teacher_dashboard.module 2008-08-04 20:13:03 UTC (rev 22) +++ vcweb/trunk/virtualcommons/games/teacher_dashboard/teacher_dashboard.module 2008-08-05 00:36:14 UTC (rev 23) @@ -3,359 +3,288 @@ function teacher_dashboard_menu($may_cache) { - $items = array(); - if ($may_cache) - { + $items = array(); + if ($may_cache) + { - $items[]=array( 'path' => 'teacher_dashboard', - 'title' => t('Teacher Dashboard'), - 'callback' => 'teacher_dashboard', - 'type'=>MENU_CALLBACK, - 'access' => user_access('Only Teachers') - ); + $items[]=array( 'path' => 'teacher_dashboard', + 'title' => t('Teacher Dashboard'), + 'callback' => 'teacher_dashboard', + 'type'=>MENU_CALLBACK, + 'access' => user_access('Only Teachers') + ); - $items[]=array( 'path' => 'teacher_dashboard_part2', - 'title' => t('Teacher Dashboard'), - 'callback'=>'teacher_dashboard_part2', - // 'callback argument' => array('forestry_game_stage1_part2'), - 'type'=>MENU_CALLBACK, - 'access' => user_access('Only Teachers') - ); - } - /*else { - teacher_load(); - }*/ - return $items; + $items[]=array( 'path' => 'teacher_dashboard_part2', + 'title' => t('Teacher Dashboard'), + 'callback'=>'teacher_dashboard_part2', + // 'callback argument' => array('forestry_game_stage1_part2'), + 'type'=>MENU_CALLBACK, + 'access' => user_access('Only Teachers') + ); + } + /*else { + teacher_load(); + }*/ + return $items; } function teacher_dashboard() { - // Return the HTML generated from the $form data structure. - $teacher_id=$GLOBALS['user']->uid; - //db_query( - //drupal_set_message(t($teacher_id)); -// $virtual_conduct_id=db_result(db_query("select max(id) from {virtualcommons_conducts} where users_id=%d group by users_id",$teacher_id)); + // Return the HTML generated from the $form data structure. + $teacher_id=$GLOBALS['user']->uid; + //db_query( + //drupal_set_message(t($teacher_id)); + // $virtual_conduct_id=db_result(db_query("select max(id) from {virtualcommons_conducts} where users_id=%d group by users_id",$teacher_id)); // $exp_name=db_result(db_query("select exp_name from virtualcommons_experiments where id =(select virtualcommons_experiments_id from virtualcommons_conducts where id=%d)",$virtual_conduct_id)); - $game = Session::get('game'); - $exp_name=$game->getExperimentName(); - $output=t('<br> <h2>'. $exp_name . '</h2>'); - $output .= drupal_get_form('teacher_dashboard_multiform'); - return $output; + $game = Session::get('game'); + $exp_name=$game->getExperimentName(); + $output=t('<br> <h2>'. $exp_name . '</h2>'); + $output .= drupal_get_form('teacher_dashboard_multiform'); + return $output; } 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['#id']='teacher_dashboard_multiform'; + $form['#multistep']=TRUE; + $game = Session::get('game'); + // $teacher_id=$GLOBALS['user']->uid; + $round_no=0; + $stage_flag=FALSE; - //$virtual_conduct_id=db_result(db_query("select max(id),users_id from {virtualcommons_conducts} where users_id=%d group by users_id",$teacher_id)); + //$virtual_conduct_id=db_result(db_query("select max(id),users_id from {virtualcommons_conducts} where users_id=%d group by users_id",$teacher_id)); - //retrive values for stage 1 + //retrive values for stage 1 - $header_stage1=array('Round No','Group No', 'Group Harvest Decision','Resources Before','Resources After'); - $row_stage1 = $game->getAllGroupRoundInfo(); - if(!isset($form_values)) - { //$round_no=(int) $round_no; - $step=0; - drupal_set_message(t('step when form values are null: '.$step)); - } - else - { - $step=(int) $form_values['step']; - $step++; - drupal_set_message(t('step when form values are not null: '.$step)); - } + if(!isset($form_values)) + { //$round_no=(int) $round_no; + $step=0; + drupal_set_message(t('step when form values are null: '.$step)); + } + else + { + $step=(int) $form_values['step']; + $step++; + drupal_set_message(t('step when form values are not null: '.$step)); + } - $no_rounds= $game->getNumberOfRounds(); -// $no_rounds=(int) $no_rounds; - drupal_set_message(t('no of rounds are: '.$no_rounds)); - if($round_no==$no_rounds) + $no_rounds= $game->getNumberOfRounds(); + // $no_rounds=(int) $no_rounds; + drupal_set_message(t('no of rounds are: '.$no_rounds)); + if($round_no==$no_rounds) + { + if(isset($_SESSION['next_stage'])) { - if(isset($_SESSION['next_stage'])) - { - $stage_flag=FALSE; - unset($_SESSION['next_stage']); - } - else - $stage_flag=TRUE; + $stage_flag=FALSE; + unset($_SESSION['next_stage']); } + else + $stage_flag=TRUE; + } - // $_SESSION['step']=$step; + // $_SESSION['step']=$step; - //$form['#redirect']=FALSE; + //$form['#redirect']=FALSE; - $form['round_no']=array('#type'=>'hidden','#value'=>$round_no); - $form['game_id']=array('#type'=>'hidden','#value'=>$virtual_conduct_id); - //$form['exp_name']=array('#type'=>'hidden','#value'=>$exp_name); - //$form['step']=array('#type'=>'hidden','#value'=>$step); - $form['stage1']=array( - '#type'=>'fieldset', - '#title'=>t('<b>Stage 1</b>') - ); + $form['round_no']=array('#type'=>'hidden','#value'=>$round_no); + $form['game_id']=array('#type'=>'hidden','#value'=>$virtual_conduct_id); + //$form['exp_name']=array('#type'=>'hidden','#value'=>$exp_name); + //$form['step']=array('#type'=>'hidden','#value'=>$step); + $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 #'); - $form['stage1']['table']=array( - '#type'=>'markup', - '#value'=>theme('table',$header_stage1,$row_stage1) - ); + // $row_stage1 = $game->getAllGroupRoundInfo(); + $all_stage_data = $game->getAllGroupRoundInfo(); - $form['stage2']=array( - '#type'=>'fieldset', - '#title'=>t('<b>Stage 2</b>') - ); + 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) + ); + } - $form['stage2']['table']=array( - '#type'=>'markup', - '#value'=>theme('table',$header_stage2,$row_stage2) - ); - if($stage_flag) - { - $form['submit'] = array( - '#type' => 'submit', - '#value' => t('Go to Stage 2') - ); - $stage_flag=FALSE; - } - else - { - $form['submit'] = array( - '#type' => 'submit', - '#value' => t('Next Round') - ); - } - return $form; -} + /* + $form['stage1']['table']=array( + '#type'=>'markup', + '#value'=>theme('table',$header_stage1,$row_stage1) + ); + $form['stage2']=array( + '#type'=>'fieldset', + '#title'=>t('<b>Stage 2</b>') + ); -function teacher_dashboard_multiform_validate($form_id,$form_values) -{ -// $virtual_conduct_id=(int) $form_values['game_id']; -$game= Session::get('game'); - if($form_values['submit']=="Next Round") - { - } -//students should vote initially, then only after students finished voting, teacher can go to next stage. - else if($form_values['submit']=="Go to Stage 2") - { - if($game->isVotingDone()) - { - form_set_error('submit',t('Please tell students to vote. Without voting you can not proceed to Stage 2')); - } - } + $form['stage2']['table']=array( + '#type'=>'markup', + '#value'=>theme('table',$header_stage2,$row_stage2) + ); + */ - return; + 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') + ); + } + return $form; +} +function teacher_dashboard_multiform_validate($form_id,$form_values) +{ + // $virtual_conduct_id=(int) $form_values['game_id']; + $game= Session::get('game'); + 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')); + } + } } function teacher_dashboard_multiform_submit($form_id,$form_values) { - //for player 3, in stage 2; for even rounds only 1 student will be ramdomely 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. - $round_no=(int) $form_values['round_no']; - $virtual_conduct_id=$form_values['game_id']; - $group_no=0; - //$flag_stage2_3player=FALSE; - //$step=(int) $form_values['step']; - $exp_name=$form_values['exp_name']; - //to avoid teacher clicking the button multiple times. check step and round_no - //drupal_set_message(t('step: '.$form_values['step'].'round no: '.$round_no)); + //for player 3, in stage 2; for even rounds only 1 student will be ramdomely + //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! + $game=Session::get('game'); + //to avoid teacher clicking the button multiple times. check step and round_no + //drupal_set_message(t('step: '.$form_values['step'].'round no: '.$round_no)); - if($form_values['submit']=="Next Round") - { - //if($step== $round_no) - //{ - drupal_set_message(t('in if. exp name: '.$exp_name)); + if($form_values['submit']=="Next Round") + { + $no_rounds = $game->getNumberOfRounds(); + $curr_round_no = $game->getCurrentRoundNo(); + $game->processGroups(); + } + else if($form_values['submit']=="Go to Stage 2") + { //initialise the stage 2 + // drupal_set_message(t('Go to stage 2')); + drupal_set_message(t('Go to stage 2')); + $round_no=1; + $_SESSION['next_stage']='pressed'; + //make initialisation for stage2 + $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); - // FIXME - $stage_no=db_result(db_query("select virtualcommons_stage_no from virtualcommons_conducts where id=%d",$virtual_conduct_id)); - $exp_id=db_result(db_query("Select id from virtualcommons_experiments where exp_name='Forestry Game' ")); - $curr_stage_no=(int)$stage_no; - $no_rounds=db_result(db_query("select no_of_rounds from virtualcommons_stage where virtualcommons_experiments_id=%d and stage_no=%d",$exp_id,$curr_stage_no)); - $no_rounds=(int) $no_rounds; + $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); - - $result=db_query(" select max(round_no) as round_no,virtualcommons_student_group_no,virtualcommons_stage_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($result)); - while($data=db_fetch_object($result)) + if($rule_no==1) + { + while($data=db_fetch_object($result_group)) + { + $no_of_student=$data->cnt; + $group_no=$data->group_no; + if($no_of_student==3) { - $round_no=$data->round_no; - $group_no=$data->virtualcommons_student_group_no; - $curr_stage_no=$data->virtualcommons_stage_no; - drupal_set_message(t('no of rounds: '. $no_rounds.'curr round no'.$round_no)); + 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); - if($no_rounds >= $round_no) + while($stud1 == $stud2) { - //stage 1 is going on. retrive values from stage1 - drupal_set_message(t('forestry stage1')); - $result= db_query("Select common_resource_pool,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); - while($data=db_fetch_object($result)) - { - $resource_available=(int) $data->common_resource_pool; - $max_resource=(int) $data->max_harvest_decision; - - } - - //get the total harvest decision - $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_conduct_id)); - $harvest_decision=(int) $harvest_decision; - $resources_before=$resource_available; - - //subtract the total harvest decision for that round from the resources - $temp=$resource_available - $harvest_decision; - - - //assign 10% of the available resource - $temp_resource_available=(int) ($temp/10); - $resource_available=$temp + $temp_resource_available; - - if($resource_available >= $max_resource) - $resource_available=$max_resource; - - db_query("Insert into {virtualcommons_forestry_group_information}(round_no,virtualcommons_conducts_id,virtualcommons_student_group_no,total_harvest_decision,resources_before,resources_after,virtualcommons_stage_no) values(%d,%d,%d,%d,%d,%d,%d)",$round_no,$virtual_conduct_id,$group_no,$harvest_decision,$resources_before,$resource_available,1); - - $harvest_decision=0; - //update the virtualcommons_forestry_common_resource_pool and virtualcommons_student - 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",$resource_available,$harvest_decision,$group_no,$virtual_conduct_id); - - - - //update the virtualcommons_forestry_student_stage1 table also - //db_query("update {virtualcommons_forestry_student_stage1} set resources_after=%d where virtualcommons_student_group_no=%d and round_no=%d",$resource_available,$group_no,$round_no); - db_query("update virtualcommons_student set start_flag=true where virtualcommons_conducts_id=%d and group_no=%d",$virtual_conduct_id,$group_no); - if($round_no==$no_rounds) - { //initialise for stage2 - - - } + $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); + } + } - else - { - //stage2 - drupal_set_message(t('forestry stage2')); - db_query("update virtualcommons_student set start_flag=true where virtualcommons_conducts_id=%d and group_no=%d",$virtual_conduct_id,$group_no); - } - }//end of 2nd while + if($no_of_student==4) + { + $stud1=rand(1,$no_of_student); + $stud2=rand(1,$no_of_student); - } - else if($form_values['submit']=="Go to Stage 2") - { //initialise the stage 2 - // drupal_set_message(t('Go to stage 2')); - drupal_set_message(t('Go to stage 2')); - $round_no=1; - $_SESSION['next_stage']='pressed'; - //make initialisation for stage2 - $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); + 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); + } - $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($no_of_student==5) { - while($data=db_fetch_object($result_group)) - { - $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); + $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('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); - } - } + 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); + } - if($no_of_student==4) - { - $stud1=rand(1,$no_of_student); - $stud2=rand(1,$no_of_student); + }//end of while - 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'; - + }//end of rule 1 + else if($rule_no==2) + { } + else if($rule_no==3) + { + } + } + 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-04 20:13:11
|
Revision: 22 http://virtualcommons.svn.sourceforge.net/virtualcommons/?rev=22&view=rev Author: alllee Date: 2008-08-04 20:13:03 +0000 (Mon, 04 Aug 2008) Log Message: ----------- refactored Group and Game and fixed some bugs in forestry. Modified Paths: -------------- vcweb/trunk/virtualcommons/experiment/experiment.inc vcweb/trunk/virtualcommons/experiment/experiment.module vcweb/trunk/virtualcommons/experiment/student_login/student_login.module vcweb/trunk/virtualcommons/games/forestry_v2/forestry_v2.module vcweb/trunk/virtualcommons/games/teacher_dashboard/teacher_dashboard.module Modified: vcweb/trunk/virtualcommons/experiment/experiment.inc =================================================================== --- vcweb/trunk/virtualcommons/experiment/experiment.inc 2008-08-02 00:29:43 UTC (rev 21) +++ vcweb/trunk/virtualcommons/experiment/experiment.inc 2008-08-04 20:13:03 UTC (rev 22) @@ -2,9 +2,9 @@ class Session { public static function put($ses_var, $object) { - if( ! isset($_SESSION[$ses_var]) ) { + //if( ! isset($_SESSION[$ses_var]) ) { $_SESSION[$ses_var] = serialize($object); - } + //} } public static function get($ses_var) { if( isset($_SESSION[$ses_var]) ) { @@ -28,8 +28,8 @@ private $no_of_students; private $experiment_name; - public function __construct($experiment_id, $teacher_id, $no_of_students) { - $this->game_id = db_next_id('{vc_game}_id'); + public function __construct($game_id, $experiment_id=-1, $teacher_id=-1, $no_of_students=-1) { + $this->game_id = $game_id; $this->experiment_id = $experiment_id; $this->teacher_id = $teacher_id; $this->no_of_students = $no_of_students; @@ -39,19 +39,23 @@ } public function getNumberOfRounds() { - return db_result(db_query("select s.no_of_rounds from vc_stage s, vc_game g where s.id=g.id and g.id=%d",$this->game_id)); + 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() { return $this->no_of_students; } - public function getCurrentStageId() { + public function getInitialStageId() { return db_result(db_query("select id from vc_stage where vc_experiment_id=%d and stage_no=%d",$this->experiment_id,$this->current_stage_no)); } - // FIXME: perhaps this should return a list of games eventually - public function getGameID() { + public function getCurrentStageId() { + return db_result(db_query("select vc_stage_id from vc_game where id=%d",$this->game_id)); + } + + + public function getGameId() { return $this->game_id; } @@ -69,13 +73,16 @@ public function save() { //insert into game table drupal_set_message(t('students:' . $this->no_of_students)); - 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)", - $this->game_id, - $this->teacher_id, - $this->experiment_id, - $this->no_of_students, - $this->getCurrentStageId(), - $this->current_round_no); + 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)", + $this->game_id, + $this->teacher_id, + $this->experiment_id, + $this->no_of_students, + $this->getInitialStageId(), + $this->current_round_no); + } } public function getExperimentId() { @@ -87,21 +94,21 @@ } public function saveGroupStudent($student_array) { - $turn=array(1,2,3,4,5); + $turn=range(1,5); // $prev_group_no=0; // $temp=-1; $i=0; - $this->stage_id=db_result(db_query("select vc_stage_id from vc_game where id =%d",$this->game_id)); + $this->stage_id=db_result(db_query("select vc_stage_id from vc_game where id=%d",$this->game_id)); foreach ($student_array as $group=>$value) { - //drupal_set_message(t('Group Key is: %key<br>' ,array('%key'=>$key))); - db_query("Insert into {vc_group} (group_no,vc_game_id,vc_stage_id) values(%d,%d,%d)",$group,$this->game_id,$this->stage_id); + $group_id=db_next_id('vc_group_id'); + db_query("Insert into {vc_group} (id,group_no,vc_game_id,vc_stage_id) values(%d,%d,%d,%d)",$group_id,$group,$this->game_id,$this->stage_id); $i=0; foreach ($value as $key=>$student_id) { //$turn= (int) $turn[$i]; - db_query("Insert into {vc_student} (id,vc_group_id,start_flag,turn_no) values('%s',LAST_INSERT_ID(),false,%d)",$student_id,$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]))); $i++; @@ -109,6 +116,11 @@ } } + 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",$game_id)); + return $count==0; + } // FIXME: figure out if we can move to forestry at some point public function initForestry() { @@ -148,9 +160,9 @@ public function getAllGroupRoundInfo() { $result=db_query("SELECT round_no, vc_group_id, total_harvest_decision, resources_before, resources_after, vc_rules_id, dice - FROM {vc_forestry_group_round_info} - WHERE vc_game_id=%d and vc_stage_id=%d", - $this->game_id, $this->getCurrentStageId()); + FROM {vc_forestry_group_round_info} + WHERE vc_game_id=%d and vc_stage_id=%d", + $this->game_id, $this->getCurrentStageId()); $stage_data = array(); while($data = db_fetch_object($result)) { $round_no=$data->round_no; @@ -167,10 +179,15 @@ return $stage_data; } + public function getCurrentStageNumber() { + 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)); + } + }//end of class Game class Group { + private $game; private $game_id; private $group_id; private $group_no; @@ -186,20 +203,25 @@ } public function getGameId() { - return $this->game_id; + if ( isset($this->game) ) { + return $this->game->getGameId(); + } + else { + drupal_set_message(t('the game is null..')); + return 5; + } } - public function getExperimentId() - { - return db_result(db_query("select vc_experiment_id from vc_game where id=%d",$this->game_id)); + public function getExperimentId() { + return $this->game->getExperimentId(); + } - } public function getStartFlag($student_id) { return db_result(db_query("SELECT start_flag FROM {vc_student} WHERE id='%s'",$student_id)); } public function getCurrentStageNumber() { - 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)); + return $this->game->getCurrentStageNumber(); } public function getCurrentRuleNumber() { @@ -212,36 +234,24 @@ if ($fetch_object) { $group = new Group(); $group->game_id = $fetch_object->game_id; + $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; } return false; } - public static function checkStudentId($studentId) { - $fetch_object = db_fetch_object(db_query("SELECT g.id AS group_id, g.vc_game_id AS game_id from {vc_student s, vc_group g} where s.id='%s' AND s.vc_group_id=g.id",$studentId)); - if ($fetch_object) { - $group = new Group(); - $group->game_id = $fetch_object->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)); - return $group; - } - return false; + public function getNumberOfRounds() { + return $this->game->getNumberOfRounds(); } - public function getNoOfRounds() - { - return db_result(db_query("select s.no_of_rounds from vc_stage s, vc_game g where s.id=g.id and g.id=%d",$this->game_id)); + public function getCurrentStageId() { + return $this->game->getCurrentStageId(); } - public function getCurrentStageId() - { - return db_result(db_query("select vc_stage_id from vc_game where id=%d",$this->game_id)); - } - }//end of Group /** @@ -313,6 +323,11 @@ db_query("update vc_student set start_flag=%d where id ='%s' ",$flag,$this->stud_id); } + public function getStartFlag() + { + return db_result(db_query("select start_flag from vc_student where id ='%s' ",$this->stud_id)); + } + public function updateStageId($stage_no,$experiment_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); Modified: vcweb/trunk/virtualcommons/experiment/experiment.module =================================================================== --- vcweb/trunk/virtualcommons/experiment/experiment.module 2008-08-02 00:29:43 UTC (rev 21) +++ vcweb/trunk/virtualcommons/experiment/experiment.module 2008-08-04 20:13:03 UTC (rev 22) @@ -150,7 +150,7 @@ $experiment_id=$form_values['games']; $no_student=(int) $form_values['no_student']; - $game=new Game($experiment_id, $teacher_id, $no_student); + $game=new Game(-1, $experiment_id, $teacher_id, $no_student); $game->save(); Session::put('game', $game); Modified: vcweb/trunk/virtualcommons/experiment/student_login/student_login.module =================================================================== --- vcweb/trunk/virtualcommons/experiment/student_login/student_login.module 2008-08-02 00:29:43 UTC (rev 21) +++ vcweb/trunk/virtualcommons/experiment/student_login/student_login.module 2008-08-04 20:13:03 UTC (rev 22) @@ -58,16 +58,15 @@ function student_login_nameform_validate($form_id,$form_values) { $stud_id=$form_values['id']; - $group = Group::checkStudentId($stud_id); + $group = Group::findByStudentId($stud_id); if ($group) { // set the game object into the session, currently only contains the // game_id - $_SESSION['group'] = serialize($group); + Session::put('group',$group); } else { - form_set_error('id',t('Invalid Student ID. Please contact your instructor.')); + form_set_error('id',t('Invalid Student ID. Please contact your instructor.')); } - } Modified: vcweb/trunk/virtualcommons/games/forestry_v2/forestry_v2.module =================================================================== --- vcweb/trunk/virtualcommons/games/forestry_v2/forestry_v2.module 2008-08-02 00:29:43 UTC (rev 21) +++ vcweb/trunk/virtualcommons/games/forestry_v2/forestry_v2.module 2008-08-04 20:13:03 UTC (rev 22) @@ -13,44 +13,44 @@ * Implementation of hook_menu(). */ function forestry_v2_menu($may_cache) { - $items = array(); - if ($may_cache) { - $items[] = array('path' => 'forestry', - 'title' => t('Forestry Game'), - 'callback' => 'forestry_v2_page', - 'type'=>MENU_CALLBACK, - 'access' => TRUE//user_access('Only Teachers') - ); + $items = array(); + if ($may_cache) { + $items[] = array('path' => 'forestry', + 'title' => t('Forestry Game'), + 'callback' => 'forestry_v2_page', + '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', - //'callback arguments'=>array(forestry_game_stage1_multiform), - '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', + //'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') - ); + $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 -{ - forestry_v2_load(); -} + } + else + { + forestry_v2_load(); + } - return $items; + return $items; } function forestry_v2_load() { static $loaded = FALSE; - + if (!$loaded) { $path = drupal_get_path('module', 'forestry_v2'); drupal_add_css($path .'/form.css'); @@ -62,67 +62,68 @@ * Called when user goes to example.com/?q=forestry */ function forestry_v2_page() { - $output = t('Please note the following maximum harvest table.'); - // Return the HTML generated from the $form data structure. - $output .= drupal_get_form('forestry_v2_nameform'); - return $output; + $output = t('Please note the following maximum harvest table.'); + // Return the HTML generated from the $form data structure. + $output .= drupal_get_form('forestry_v2_nameform'); + return $output; } /** * Defines a form. */ 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'); + //$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 = unserialize($_SESSION['group']); - // FIXME: merge harvest tables into single table + $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}"); -/* + $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}")); + 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")); - } - } - */ + } + 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)); - } - $_SESSION['harvest_table']=$row; +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)); +} +$_SESSION['harvest_table']=$row; - $form['harvest_table']=array( - '#type'=>'markup', - '#value'=>theme('table',$header,$row) - ); +$form['harvest_table']=array( + '#type'=>'markup', + '#value'=>theme('table',$header,$row) + ); - $form['submit'] = array( - '#type' => 'submit', - '#value' => t('Next') - ); - return $form; +$form['submit'] = array( + '#type' => 'submit', + '#value' => t('Next') + ); +return $form; } /** * Invoked after the student has successfully logged in and is trying to click @@ -130,33 +131,33 @@ */ function forestry_v2_nameform_submit($form_id, $form_values) { - $stud_id=$_SESSION['student_id']; - $group = unserialize($_SESSION['group']); - $flag=$group->getStartFlag($stud_id); - $game_id = $group->getGameId(); - if($flag) { - $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'; - 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'; - } + $stud_id=$_SESSION['student_id']; + $group = Session::get('group'); + $flag=$group->getStartFlag($stud_id); + $game_id = $group->getGameId(); + if($flag) { + $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'; + 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'; + } - } - } - else { - return 'forestry'; - } + } + } + else { + return 'forestry'; + } } //Forestry Stage 1 Begins @@ -164,9 +165,9 @@ 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; + // Return the HTML generated from the $form data structure. + $output = drupal_get_form('forestry_game_stage1_multiform'); + return $output; } @@ -175,121 +176,106 @@ { $form['#id']='forestry_game_stage1_multiform'; - $group = unserialize($_SESSION['group']); + $group = Session::get('group'); $student=new ForestryStudent(); $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 - + $group_id=$group->getGroupId(); $game_id=$group->getGameId(); - drupal_set_message(t('group id : '. $group_id . ' Game id'. $game_id)); + 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; + 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); - /*$result=db_query("select round_no,harvest_decision from virtualcommons_forestry_student where virtualcommons_student_id= '%s' ",$stud_id); - while($data=db_fetch_object($result)) - { - $round_no=$data->round_no; - $harvest_decision=$data->harvest_decision; - $round_no=(int)$round_no; - //$resources_before=$data->resources_before; - //$resources_after=$data->resources_after; - $resource_info= db_query("select resources_before,resources_after from virtualcommons_forestry_group_information where virtualcommons_student_group_no=%d and virtualcommons_conducts_id=%d and round_no=%d",$group_no,$conducts_id,$round_no); - while($data_resource=db_fetch_object($resource_info)) - { - $resources_before=$data_resource->resources_before; - $resources_after=$data_resource->resources_after; - } - $final_row[]=array($round_no,$harvest_decision,$resources_before,$resources_after); - }*/ - $round_no=$student->getRoundNo(); - $round_no=$round_no+1; + $round_no=$student->getRoundNo()+1; + drupal_set_message(t('round no: ' .$round_no .' '. gettype($round_no) )); -//store the round no in hidden field + //store the round no in hidden field -$form['round_no']=array( - '#type'=>'hidden', - '#value'=>$round_no - ); + $form['round_no']=array( + '#type'=>'hidden', + '#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(); + drupal_set_message(t('no of rounds are: '.$no_rounds)); + if($round_no <= $no_rounds) + { -$no_rounds=$group->getNoOfRounds(); -//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('no of rounds are: '.$no_rounds)); -if($round_no <= $no_rounds) -{ + $form['resources_available']=array( - $form['resources_available']=array( - - '#type'=>'item', - '#title'=>t('Resources Available'), - '#value'=>$resource_available - ); - - $form['indicator']=array( - '#type'=>'fieldset', - '#title'=>t('<b>Round @number</b>',array('@number'=>$round_no)) - ); + '#type'=>'item', + '#title'=>t('Resources Available'), + '#value'=>$resource_available + ); - $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('Next') - ); -} -else -{ - $stage_no=$group->getCurrentStageNumber(); - $stage_no=(int) $stage_no; - $form['indicator']['submit'] = array( - '#type' => 'submit', - '#value' => t('Stage '.$stage_no+1) - ); + $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('Next') + ); + } + else + { + $stage_no=$group->getCurrentStageNumber(); + $stage_no=(int) $stage_no; + $form['indicator']['submit'] = array( + '#type' => 'submit', + '#value' => t('Stage '.$stage_no+1) + ); - $form['resource']=array( + } - '#type'=>'fieldset', - '#title'=>t('<b>Resources</b>'), + $form['resource']=array( - ); - $form['resource']['table']=array( - '#type'=>'markup', - '#value'=>theme('table',$header,$final_row) - ); + '#type'=>'fieldset', + '#title'=>t('<b>Resources</b>'), + ); + $form['resource']['table']=array( + '#type'=>'markup', + '#value'=>theme('table',$header,$final_row) + ); -return $form; + Session::put('forestry_student',$student); + return $form; } @@ -297,84 +283,84 @@ function forestry_game_stage1_multiform_validate($form_id,$form_values) { -$harvest_decision=$form_values['indicator']['harvest_decision']; -$resource=(int) $_SESSION['prev_resource']; -//$resource=100; -$flag=FALSE; + $harvest_decision=$form_values['indicator']['harvest_decision']; + $resource=(int) $_SESSION['prev_resource']; + //$resource=100; + $flag=FALSE; -if(preg_match('/[^0-9]+/',$harvest_decision)) -{ - form_set_error('harvest_decision',t('Harvest Decison can not be alphabet or special character.')); -} -else -{ + if(preg_match('/[^0-9]+/',$harvest_decision)) + { + form_set_error('harvest_decision',t('Harvest Decison can not be alphabet or special character.')); + } + else + { - $harvest_table= $_SESSION['harvest_table']; + $harvest_table= $_SESSION['harvest_table']; - foreach($harvest_table as $key=> $value) - { + foreach($harvest_table as $key=> $value) + { - if(!$flag) - { - foreach($value as $key=>$value) - { - - if($key==0) - { - //get min and maximum value of the resource - $harvest_tbl=explode("-",$value); - $min_resource=(int) $harvest_tbl[0]; - $max_resource=(int) $harvest_tbl[1]; + if(!$flag) + { + foreach($value as $key=>$value) + { - } - else if($key==1) - { - //get the maximum units player can invest - $harvest_units=(int) $value; - /*drupal_set_message(t('Min : '.$min_resource)); - drupal_set_message(t('Max : '.$max_resource)); - drupal_set_message(t('Units can harvest: '.$harvest_units)); - drupal_set_message(t('Resource can harvest: '.$resource)); - drupal_set_message(t('comparision: '. ($harvest_decision > $harvest_units)));*/ - if(($resource >= $min_resource) && ($resource <= $max_resource)) - { - //depending upon the resource available player can invest units. e.g in group of 5 and resource available=100 then player can invest max 5 units. - //drupal_set_message(t('resource condition successful: ')); - $harvest_decision=(int) $harvest_decision; - if($harvest_decision > $harvest_units) - { - if($harvest_units ==0 ) - form_set_error('harvest_decision',t('Current Resource Level is very low. You can not harvest anything. <br><b>GAME OVER!!!</b>')); - else - form_set_error('harvest_decision',t('Harvest Decison can not be more than %harvest_units.',array('%harvest_units'=>$harvest_units))); - $flag=TRUE; - } - else - $flag=FALSE; + if($key==0) + { + //get min and maximum value of the resource + $harvest_tbl=explode("-",$value); + $min_resource=(int) $harvest_tbl[0]; + $max_resource=(int) $harvest_tbl[1]; - } - - } - }//end of for1 + } + else if($key==1) + { + //get the maximum units player can invest + $harvest_units=(int) $value; + /*drupal_set_message(t('Min : '.$min_resource)); + drupal_set_message(t('Max : '.$max_resource)); + drupal_set_message(t('Units can harvest: '.$harvest_units)); + drupal_set_message(t('Resource can harvest: '.$resource)); + drupal_set_message(t('comparision: '. ($harvest_decision > $harvest_units)));*/ + if(($resource >= $min_resource) && ($resource <= $max_resource)) + { + //depending upon the resource available player can invest units. e.g in group of 5 and resource available=100 then player can invest max 5 units. + //drupal_set_message(t('resource condition successful: ')); + $harvest_decision=(int) $harvest_decision; + if($harvest_decision > $harvest_units) + { + if($harvest_units ==0 ) + form_set_error('harvest_decision',t('Current Resource Level is very low. You can not harvest anything. <br><b>GAME OVER!!!</b>')); + else + form_set_error('harvest_decision',t('Harvest Decison can not be more than %harvest_units.',array('%harvest_units'=>$harvest_units))); + $flag=TRUE; + } + else + $flag=FALSE; - }// end of if(flag) + } -if($flag) - break; + } + }//end of for1 - }//end of for 2 - -} + }// end of if(flag) + if($flag) + break; -return; + }//end of for 2 + } + + + return; + } function forestry_game_stage1_multiform_submit($form_id,$form_values) { - $group = unserialize($_SESSION['group']); + $group = Session::get('group'); $harvest_table=$_SESSION['harvest_table']; //$harvest_tbl=explode("-",$harvest_table); @@ -399,127 +385,130 @@ 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)); + // $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); + //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)); + /*$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=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_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);*/ + 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); + //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->getNoOfRounds(); + $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']=="Stage 2") -{ - $stage_no=2; - $exp_id=$group->getExperimentId(); - $student->updateStageId($stage_no,$exp_id); - //db_query("update virtualcommons_conducts set virtualcommons_stage_no=%d where id=%d",2,$virtual_conducts_id); - unset($_SESSION['prev_resource']); + $no_rounds=(int) $no_rounds; + drupal_set_message(t('$actual_no_rounds' . $no_rounds . '$current_round_no' . $round_no)); + if($form_values['indicator']['submit']=="Stage 2") + { + $stage_no=2; + $exp_id=$group->getExperimentId(); + $student->updateStageId($stage_no,$exp_id); + //db_query("update virtualcommons_conducts set virtualcommons_stage_no=%d where id=%d",2,$virtual_conducts_id); + unset($_SESSION['prev_resource']); - return 'rules'; -} -else - return 'forestry_stage1_part2'; + return 'rules'; + } + else + return 'forestry_stage1_part2'; } function theme_forestry_game_stage1_multiform($form) { -$output='<div class="indicator"><table style="text-align: center; width: 100%;" border="0" - cellpadding="0" cellspacing="0"> - <tbody> + $output='<div class="indicator"><table style="text-align: center; width: 100%;" border="0" + cellpadding="0" cellspacing="0"> + <tbody> <tr> - <td style="width: 80%;"> </td> - - <td nowrap>'; -$output.=drupal_render($form ['resources_available']); -$output.='</td> + <td style="width: 80%;"> </td> + + <td nowrap>'; + $output.=drupal_render($form ['resources_available']); + $output.='</td> </tr> <tr> - <td style="width: 30%;" colspan="2" rowspan="1">'; -$output.= drupal_render($form['indicator']); - - -$output.= drupal_render($form['indicator']['harvest_decision']); -$output.='</td>'; - //<td style="text-align: center;" colspan="2" rowspan="1">'; -$output.=drupal_render($form['indicator']['submit']); -$output.=' - </tr><tr> <td> </td> </tr> -<tr> - <td colspan="2" rowspan="1">'; + <td style="width: 30%;" colspan="2" rowspan="1">'; + $output.= drupal_render($form['indicator']); -$output.=drupal_render($form['resource']); -$output.=drupal_render($form['resource']['table']); -$output.=' - </td> - </tr> - </tbody> - </table> -</div>'; -$output.=drupal_render($form); -return $output; - + $output.= drupal_render($form['indicator']['harvest_decision']); + $output.='</td>'; + //<td style="text-align: center;" colspan="2" rowspan="1">'; + $output.=drupal_render($form['indicator']['submit']); + $output.=' + </tr><tr> <td> </td> </tr> + <tr> + <td colspan="2" rowspan="1">'; + + $output.=drupal_render($form['resource']); + + $output.=drupal_render($form['resource']['table']); + $output.=' + </td> + </tr> + </tbody> + </table> + </div>'; + $output.=drupal_render($form); + return $output; + } function forestry_game_stage1_part2() { -$output=t('Please click the Next button for next round'); -$output.=drupal_get_form('forestry_game_stage1_part2form'); -return $output; + $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() { - $form['submit'] = array( - '#type' => 'submit', - '#value' => t('Next Round') - ); -return $form; + $form['submit'] = array( + '#type' => 'submit', + '#value' => t('Next Round') + ); + return $form; } function forestry_game_stage1_part2form_submit($form_id,$form_values) { - $stud_id=$_SESSION['student_id']; - $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'; + $stud_id=$_SESSION['student_id']; + $student=Session::get('forestry_student'); + $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'; + } Modified: vcweb/trunk/virtualcommons/games/teacher_dashboard/teacher_dashboard.module =================================================================== --- vcweb/trunk/virtualcommons/games/teacher_dashboard/teacher_dashboard.module 2008-08-02 00:29:43 UTC (rev 21) +++ vcweb/trunk/virtualcommons/games/teacher_dashboard/teacher_dashboard.module 2008-08-04 20:13:03 UTC (rev 22) @@ -136,17 +136,19 @@ return $form; } + function teacher_dashboard_multiform_validate($form_id,$form_values) { - $virtual_conduct_id=(int) $form_values['game_id']; +// $virtual_conduct_id=(int) $form_values['game_id']; +$game= Session::get('game'); if($form_values['submit']=="Next Round") { } - +//students should vote initially, then only after students finished voting, teacher can go to next stage. else if($form_values['submit']=="Go to Stage 2") { - $rule_no=db_result(db_query("Select virtualcommons_rule_no from virtualcommons_conducts where id=%d",$virtual_conduct_id)); - if($rule_no==0) + + if($game->isVotingDone()) { form_set_error('submit',t('Please tell students to vote. Without voting you can not proceed to Stage 2')); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <al...@us...> - 2008-08-02 00:29:34
|
Revision: 21 http://virtualcommons.svn.sourceforge.net/virtualcommons/?rev=21&view=rev Author: alllee Date: 2008-08-02 00:29:43 +0000 (Sat, 02 Aug 2008) Log Message: ----------- renaming Session methods to put/get instead of store/load Modified Paths: -------------- vcweb/trunk/virtualcommons/experiment/experiment.inc vcweb/trunk/virtualcommons/experiment/experiment.module vcweb/trunk/virtualcommons/games/teacher_dashboard/teacher_dashboard.module Modified: vcweb/trunk/virtualcommons/experiment/experiment.inc =================================================================== --- vcweb/trunk/virtualcommons/experiment/experiment.inc 2008-08-02 00:15:56 UTC (rev 20) +++ vcweb/trunk/virtualcommons/experiment/experiment.inc 2008-08-02 00:29:43 UTC (rev 21) @@ -1,12 +1,12 @@ <?php class Session { - public static function store($ses_var, $object) { + public static function put($ses_var, $object) { if( ! isset($_SESSION[$ses_var]) ) { $_SESSION[$ses_var] = serialize($object); } } - public static function load($ses_var) { + public static function get($ses_var) { if( isset($_SESSION[$ses_var]) ) { return unserialize($_SESSION[$ses_var]); } Modified: vcweb/trunk/virtualcommons/experiment/experiment.module =================================================================== --- vcweb/trunk/virtualcommons/experiment/experiment.module 2008-08-02 00:15:56 UTC (rev 20) +++ vcweb/trunk/virtualcommons/experiment/experiment.module 2008-08-02 00:29:43 UTC (rev 21) @@ -152,7 +152,7 @@ $game=new Game($experiment_id, $teacher_id, $no_student); $game->save(); - Session::store('game', $game); + Session::put('game', $game); /* //Fishery if($game_name==1) @@ -193,7 +193,7 @@ { $form['#id']='studentgroup'; - $game=Session::load('game'); + $game=Session::get('game'); $exp_name = $game->getExperimentName(); drupal_set_message(t("experiment name: " . $exp_name)); @@ -366,7 +366,7 @@ $id=$GLOBALS['user']->uid; $table=$_SESSION['student_info']; - $game = Session::load('game'); + $game = Session::get('game'); $game->saveGroupStudent($table); Modified: vcweb/trunk/virtualcommons/games/teacher_dashboard/teacher_dashboard.module =================================================================== --- vcweb/trunk/virtualcommons/games/teacher_dashboard/teacher_dashboard.module 2008-08-02 00:15:56 UTC (rev 20) +++ vcweb/trunk/virtualcommons/games/teacher_dashboard/teacher_dashboard.module 2008-08-02 00:29:43 UTC (rev 21) @@ -37,7 +37,7 @@ //drupal_set_message(t($teacher_id)); // $virtual_conduct_id=db_result(db_query("select max(id) from {virtualcommons_conducts} where users_id=%d group by users_id",$teacher_id)); // $exp_name=db_result(db_query("select exp_name from virtualcommons_experiments where id =(select virtualcommons_experiments_id from virtualcommons_conducts where id=%d)",$virtual_conduct_id)); - $game = Session::load('game'); + $game = Session::get('game'); $exp_name=$game->getExperimentName(); $output=t('<br> <h2>'. $exp_name . '</h2>'); $output .= drupal_get_form('teacher_dashboard_multiform'); @@ -50,7 +50,7 @@ $form['#id']='teacher_dashboard_multiform'; $form['#multistep']=TRUE; - $game = Session::load('game'); + $game = Session::get('game'); // $teacher_id=$GLOBALS['user']->uid; $round_no=0; $stage_flag=FALSE; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <al...@us...> - 2008-08-02 00:15:47
|
Revision: 20 http://virtualcommons.svn.sourceforge.net/virtualcommons/?rev=20&view=rev Author: alllee Date: 2008-08-02 00:15:56 +0000 (Sat, 02 Aug 2008) Log Message: ----------- TODO: teacher dashboard, give Group a Game reference, and then add forestry student records Modified Paths: -------------- vcweb/trunk/virtualcommons/experiment/experiment.inc vcweb/trunk/virtualcommons/experiment/experiment.module vcweb/trunk/virtualcommons/games/forestry_v2/forestry_v2.module vcweb/trunk/virtualcommons/games/teacher_dashboard/teacher_dashboard.install vcweb/trunk/virtualcommons/games/teacher_dashboard/teacher_dashboard.module Modified: vcweb/trunk/virtualcommons/experiment/experiment.inc =================================================================== --- vcweb/trunk/virtualcommons/experiment/experiment.inc 2008-08-01 01:19:07 UTC (rev 19) +++ vcweb/trunk/virtualcommons/experiment/experiment.inc 2008-08-02 00:15:56 UTC (rev 20) @@ -1,71 +1,92 @@ <?php -class Game -{ +class Session { + public static function store($ses_var, $object) { + if( ! isset($_SESSION[$ses_var]) ) { + $_SESSION[$ses_var] = serialize($object); + } + } + public static function load($ses_var) { + if( isset($_SESSION[$ses_var]) ) { + return unserialize($_SESSION[$ses_var]); + } + else return false; + } + + public static function remove($ses_var) { + unset($_SESSION[$ses_var]); + } +} + + +class Game { private $game_id; - private $exp_id; - private $game_name; private $teacher_id; private $experiment_id; - private $stage_id; - private $round_no; - private $no_of_student; + private $current_stage_no; + private $current_round_no; + private $no_of_students; + private $experiment_name; - // FIXME: perhaps this should return a list of games eventually - public function getGameID() - { - $this->game_id=db_result(db_query("Select max(id) from vc_game where users_id=%d",$this->teacher_id)); - return $this->game_id; + public function __construct($experiment_id, $teacher_id, $no_of_students) { + $this->game_id = db_next_id('{vc_game}_id'); + $this->experiment_id = $experiment_id; + $this->teacher_id = $teacher_id; + $this->no_of_students = $no_of_students; + $this->current_stage_no = 1; + $this->current_round_no = 1; + $this->experiment_name = db_result(db_query("select e.name from vc_experiment e where e.id=%d", $experiment_id)); } - public function setExpId($exp_id) - { - $this->exp_id=$exp_id; + public function getNumberOfRounds() { + return db_result(db_query("select s.no_of_rounds from vc_stage s, vc_game g where s.id=g.id and g.id=%d",$this->game_id)); + } + public function getNumberOfStudents() { + return $this->no_of_students; } - - public function setTeacherId($teacher_id) - { - $this->teacher_id=$teacher_id; - + public function getCurrentStageId() { + return db_result(db_query("select id from vc_stage where vc_experiment_id=%d and stage_no=%d",$this->experiment_id,$this->current_stage_no)); } - public function setStageId($stage_no) - { - $this->stage_id=db_result(db_query("select id from vc_stage where vc_experiment_id =%d and stage_no=%d",$this->exp_id,$stage_no)); - - + // FIXME: perhaps this should return a list of games eventually + public function getGameID() { + return $this->game_id; } - public function setNoOfStudent($no_of_student) - { - $this->no_of_student=$no_of_student; - + public static function findLatestGame($teacher_id) { + // FIXME: return actual Game object if necessary + $game = new Game(); + $game->game_id = db_result(db_query("SELECT id from vc_game where users_id=%d ORDER BY date_created DESC LIMIT 1" ,$this->teacher_id)); + return $game; } - - public function setRoundNo($round_no) - { - $this->round_no=$round_no; + public function getExperimentName() { + return $this->experiment_name; } - - public function saveGame() - { - - //$this->exp_id=db_result(db_query("Select id from {vc_experiment} where name LIKE '%s'",$this->game_name)); - - + public function save() { //insert into game table - drupal_set_message(t('game name:'.$this->game_name)); - db_query("Insert into {vc_game} (users_id, vc_experiment_id, no_of_students,vc_stage_id,current_round_no ) values(%d,%d,%d,%d,%d)",$this->teacher_id,$this->exp_id,$this->no_of_student,$this->stage_id,$this->round_no); + drupal_set_message(t('students:' . $this->no_of_students)); + 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)", + $this->game_id, + $this->teacher_id, + $this->experiment_id, + $this->no_of_students, + $this->getCurrentStageId(), + $this->current_round_no); + } + public function getExperimentId() { + return db_result(db_query("select vc_experiment_id from vc_game where id=%d",$this->game_id)); } + public function setCurrentStageNo($current_stage_no) { + $this->current_stage_no = $current_stage_no; + } - public function saveGroupStudent($student_array) - { + public function saveGroupStudent($student_array) { $turn=array(1,2,3,4,5); // $prev_group_no=0; // $temp=-1; @@ -86,38 +107,36 @@ } } - - } -// FIXME: figure out if we can move to forestry at some point + // FIXME: figure out if we can move to forestry at some point public function initForestry() { $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_student=$data->cnt; - $group_no=$data->group_id; - //drupal_set_message(t($no_of_student.' '. $group_no)); - if($no_of_student == 5) - { - db_query("Insert into {vc_forestry_common_resource_pool} (vc_group_id,common_resource_pool,vc_game_id, harvest_decision,max_harvest_decision) values(%d,%d,%d,%d,%d)",$group_no,100,$this->game_id,0,100); + while($data=db_fetch_object($result_group)) + { + $no_of_student=$data->cnt; + $group_no=$data->group_id; + //drupal_set_message(t($no_of_student.' '. $group_no)); + if($no_of_student == 5) + { + db_query("Insert into {vc_forestry_common_resource_pool} (vc_group_id,common_resource_pool,vc_game_id, harvest_decision,max_harvest_decision) values(%d,%d,%d,%d,%d)",$group_no,100,$this->game_id,0,100); - } + } - else if($no_of_student == 4) - { - db_query("Insert into {vc_forestry_common_resource_pool} (vc_group_id,common_resource_pool,vc_game_id, harvest_decision,max_harvest_decision) values(%d,%d,%d,%d,%d)",$group_no,80,$this->game_id,0,80); - } + else if($no_of_student == 4) + { + db_query("Insert into {vc_forestry_common_resource_pool} (vc_group_id,common_resource_pool,vc_game_id, harvest_decision,max_harvest_decision) values(%d,%d,%d,%d,%d)",$group_no,80,$this->game_id,0,80); + } - else if($no_of_student == 3) - { - db_query("Insert into {vc_forestry_common_resource_pool} (vc_group_id,common_resource_pool,vc_game_id,harvest_decision,max_harvest_decision) values(%d,%d,%d,%d,%d)",$group_no,60,$this->game_id,0,60); - } + else if($no_of_student == 3) + { + db_query("Insert into {vc_forestry_common_resource_pool} (vc_group_id,common_resource_pool,vc_game_id,harvest_decision,max_harvest_decision) values(%d,%d,%d,%d,%d)",$group_no,60,$this->game_id,0,60); + } - } + } } @@ -127,7 +146,28 @@ db_query("update vc_student set start_flag=%d where vc_group_id in (select id from vc_group where vc_game_id=%d)",$flag,$this->game_id); } + public function getAllGroupRoundInfo() { + $result=db_query("SELECT round_no, vc_group_id, total_harvest_decision, resources_before, resources_after, vc_rules_id, dice + FROM {vc_forestry_group_round_info} + WHERE vc_game_id=%d and vc_stage_id=%d", + $this->game_id, $this->getCurrentStageId()); + $stage_data = array(); + while($data = db_fetch_object($result)) { + $round_no=$data->round_no; + $group_id=$data->vc_group_id; + $total_harvest_decision=$data->total_harvest_decision; + $resources_before=$data->resources_before; + $resources_after=$data->resources_after; + $group_round_data = array($round_no,$group_no,$total_harvest_decision,$resource_before,$resource_after); + if ( $data->vc_rules_id ) { + array_push($group_round_data, $data->vc_rules_id, $data->dice); + } + $stage_data[] = $group_round_data; + } + return $stage_data; + } + }//end of class Game class Group { @@ -135,6 +175,7 @@ private $group_id; private $group_no; private $no_of_students; + private $experiment_id; public function getNumberOfStudents() { return $this->no_of_students; @@ -148,6 +189,11 @@ return $this->game_id; } + public function getExperimentId() + { + return db_result(db_query("select vc_experiment_id from vc_game where id=%d",$this->game_id)); + + } public function getStartFlag($student_id) { return db_result(db_query("SELECT start_flag FROM {vc_student} WHERE id='%s'",$student_id)); } @@ -160,6 +206,19 @@ 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)); } + + public static function findByStudentId($studentId) { + $fetch_object = db_fetch_object(db_query("SELECT g.id AS group_id, g.vc_game_id AS game_id from {vc_student s, vc_group g} where s.id='%s' AND s.vc_group_id=g.id",$studentId)); + if ($fetch_object) { + $group = new Group(); + $group->game_id = $fetch_object->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)); + return $group; + } + return false; + } + public static function checkStudentId($studentId) { $fetch_object = db_fetch_object(db_query("SELECT g.id AS group_id, g.vc_game_id AS game_id from {vc_student s, vc_group g} where s.id='%s' AND s.vc_group_id=g.id",$studentId)); if ($fetch_object) { @@ -172,30 +231,91 @@ return false; } -} + public function getNoOfRounds() + { + return db_result(db_query("select s.no_of_rounds from vc_stage s, vc_game g where s.id=g.id and g.id=%d",$this->game_id)); + } + public function getCurrentStageId() + { + return db_result(db_query("select vc_stage_id from vc_game where id=%d",$this->game_id)); + } +}//end of Group +/** + * FIXME: Fill in documentation here, Seema. + */ +class ForestryStudent +{ + private $round_no; + private $stud_id; + private $stage_id; + private $harvest_decision; + private $turn_no; -/*class Student - { - private $teacher_id; - private $stud_id; - private $start_flag; - private $group_id; - private $turn_no; - function public getStartFlag() - { - return $this->start_flag; - } + 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)); + } - function public getTurnNo() - { - return $this->turn_no; - } + public function getTurnNo() + { + 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 getRoundNo() + { + return $this->round_no; + } + + public function getForestryStudentInfo($group_id,$game_id) + { + $student_decision=db_query("select round_no,harvest_decision from vc_forestry_student where vc_student_id= '%s' ",$this->stud_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); + while($data_resource=db_fetch_object($resource_info)) + { + $resources_before=$data_resource->resources_before; + $resources_after=$data_resource->resources_after; + } + $final_row[]=array($round_no,$harvest_decision,$resources_before,$resources_after); + } + $this->round_no=$round_no; + return $final_row; + + } + + 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); + } + + public function updateStartFlag($flag) + { + db_query("update vc_student set start_flag=%d where id ='%s' ",$flag,$this->stud_id); + } + + public function updateStageId($stage_no,$experiment_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); + } + +} Modified: vcweb/trunk/virtualcommons/experiment/experiment.module =================================================================== --- vcweb/trunk/virtualcommons/experiment/experiment.module 2008-08-01 01:19:07 UTC (rev 19) +++ vcweb/trunk/virtualcommons/experiment/experiment.module 2008-08-02 00:15:56 UTC (rev 20) @@ -15,7 +15,7 @@ function experiment_perm() { - return array('Only Teachers'); + return array('Only Teachers'); } @@ -24,98 +24,98 @@ * Implementation of hook_menu(). */ function experiment_menu($may_cache) { - $items = array(); - if ($may_cache) { - $items[] = array( - 'path' => 'experiment', - 'title' => t('Experiments'), - 'callback' => 'experiment_page', - 'type'=>MENU_CALLBACK, - 'access' => user_access('Only Teachers') - ); - $items[] = array( - 'path' => 'studentgroup', - 'title' => t('Student Information'), - 'callback' => 'drupal_get_form', - 'callback arguments'=>array(studentgroup), - 'type'=>MENU_CALLBACK, - 'access' => user_access('Only Teachers') - ); - /* $items[]=array( 'path' => 'game_start', - // 'title' => t('Forestry Game - Stage 1'), - 'callback'=>'game_start', - // 'callback argument' => array('forestry_game_stage1_part2'), - 'type'=>MENU_CALLBACK, - 'access' => user_access('Only Teachers') - );*/ - } - return $items; + $items = array(); + if ($may_cache) { + $items[] = array( + 'path' => 'experiment', + 'title' => t('Experiments'), + 'callback' => 'experiment_page', + 'type'=>MENU_CALLBACK, + 'access' => user_access('Only Teachers') + ); + $items[] = array( + 'path' => 'studentgroup', + 'title' => t('Student Information'), + 'callback' => 'drupal_get_form', + 'callback arguments'=>array(studentgroup), + 'type'=>MENU_CALLBACK, + 'access' => user_access('Only Teachers') + ); + /* $items[]=array( 'path' => 'game_start', + // 'title' => t('Forestry Game - Stage 1'), + 'callback'=>'game_start', + // 'callback argument' => array('forestry_game_stage1_part2'), + 'type'=>MENU_CALLBACK, + 'access' => user_access('Only Teachers') + );*/ + } + return $items; } /** * Called when user goes to example.com/?q=experiment */ function experiment_page() { - $output = t('Please submit the following form in order to conduct the experiments in the class.'); - // Return the HTML generated from the $form data structure. - $output .= drupal_get_form('experiment_nameform'); - return $output; + $output = t('Please submit the following form in order to conduct the experiments in the class.'); + // Return the HTML generated from the $form data structure. + $output .= drupal_get_form('experiment_nameform'); + return $output; } /** * Defines a form. */ function experiment_nameform() { - $form['#method']='post'; - //+$form['#action']='http://localhost/drupal/?q=studentgroup'; - $form['#id']='experiment'; - $form['no_student'] = array( - '#title' => t('How many Students are participating'), - '#type' => 'textfield', - '#description' => t('Depending on the number of students groups will be formed.'), - '#required'=>TRUE + $form['#method']='post'; + //+$form['#action']='http://localhost/drupal/?q=studentgroup'; + $form['#id']='experiment'; + $form['no_student'] = array( + '#title' => t('How many Students are participating'), + '#type' => 'textfield', + '#description' => t('Depending on the number of students groups will be formed.'), + '#required'=>TRUE - ); + ); - $form['games']=array( - '#type'=>'select', - '#title'=>'Select the Game from the following experiments', - '#default_value'=>variable_get('games',0), - '#options'=> array(t('Choose One '),t('Fishery Game'),t('Forestry Game'),t('Water Irrigation Game')), - '#required'=>TRUE + $form['games']=array( + '#type'=>'select', + '#title'=>'Select the Game from the following experiments', + '#default_value'=>variable_get('games',0), + '#options'=> array(t('Choose One '),t('Fishery Game'),t('Forestry Game'),t('Water Irrigation Game')), + '#required'=>TRUE - ); + ); - $form['terms_usage']=array( - '#type'=>'fieldset', - //'#title'=>t('Terms of Usage') - ); + $form['terms_usage']=array( + '#type'=>'fieldset', + //'#title'=>t('Terms of Usage') + ); - $form['terms_usage']['info']=array( + $form['terms_usage']['info']=array( - '#type'=>'item', - '#title'=>t('Terms and conditions'), - '#description'=>t('<p>Material on this site is used only for educational purpose. None of the material on this site may be used for any other purpose. <br/>All rights reserved and granted by Dr Marco Janssen.</p>') - ); + '#type'=>'item', + '#title'=>t('Terms and conditions'), + '#description'=>t('<p>Material on this site is used only for educational purpose. None of the material on this site may be used for any other purpose. <br/>All rights reserved and granted by Dr Marco Janssen.</p>') + ); - $form['terms_usage']['agree'] = array( - '#type' => 'radios', - '#options' => array(t('I Agree'),t('I Disagree')), - '#title'=>t('By selecting the "I Agree" option, you certifiy that you are agree above terms of use'), - '#default_value'=>variable_get('agree',1), + $form['terms_usage']['agree'] = array( + '#type' => 'radios', + '#options' => array(t('I Agree'),t('I Disagree')), + '#title'=>t('By selecting the "I Agree" option, you certifiy that you are agree above terms of use'), + '#default_value'=>variable_get('agree',1), - ); - $form['submit'] = array( - '#type' => 'submit', - '#value' => t('Submit') - ); + ); + $form['submit'] = array( + '#type' => 'submit', + '#value' => t('Submit') + ); - return $form; + return $form; } /** * Validate the form. @@ -123,22 +123,22 @@ function experiment_nameform_validate($form_id, $form_values) { - // We notify the form API that this field has failed validation. - if ($form_values['games'] == 0) - { - form_set_error('games', - t('Please choose the game.')); - } - if($form_values['agree']==1) - { - form_set_error('agree',t('You have to agree the terms before you play any game.')); - } + // We notify the form API that this field has failed validation. + if ($form_values['games'] == 0) + { + form_set_error('games', + t('Please choose the game.')); + } + if($form_values['agree']==1) + { + form_set_error('agree',t('You have to agree the terms before you play any game.')); + } - //To Check for numbers. - if(preg_match('/[^0-9]+/',$form_values['no_student'])) - { - form_set_error('no_student',t('Number of experiments can not be alphabets. ')); - } + //To Check for numbers. + if(preg_match('/[^0-9]+/',$form_values['no_student'])) + { + form_set_error('no_student',t('Number of experiments can not be alphabets. ')); + } } /** @@ -146,58 +146,42 @@ */ function experiment_nameform_submit($form_id, $form_values) { - $teacher_id=$GLOBALS['user']->uid; - $game_name=$form_values['games']; - $no_student=(int) $form_values['no_student']; - - $game=new Game(); - $game->setExpId($game_name); - $game->setTeacherId($teacher_id); - $game->setStageId(1); - $game->setNoOfStudent($no_student); - $game->setRoundNo(1); - $game->saveGame(); - - if(!isset($_SESSION['no_of_student'])) - { - $_SESSION['no_student']=$no_student; - } + $teacher_id=$GLOBALS['user']->uid; + $experiment_id=$form_values['games']; + $no_student=(int) $form_values['no_student']; + $game=new Game($experiment_id, $teacher_id, $no_student); + $game->save(); + Session::store('game', $game); - if(!isset($_SESSION['game_name'])) - { - $_SESSION['game_name']=$game_name; - } + /* //Fishery + if($game_name==1) + { + $result=db_result(db_query("Select id from {virtualcommons_experiments} where exp_name LIKE '%%Fishery%%' ")); + } + //Forestry + else if($game_name==2) + { + $result=db_result(db_query("Select id from {virtualcommons_experiments} where exp_name LIKE '%%Forestry%%' ")); + } + //Water Irrigation + else if($game_name==3) + { + $result=db_result(db_query("Select id from {virtualcommons_experiments} where exp_name LIKE '%%Water%%' ")); + } - /* //Fishery - if($game_name==1) - { - $result=db_result(db_query("Select id from {virtualcommons_experiments} where exp_name LIKE '%%Fishery%%' ")); - } - //Forestry - else if($game_name==2) - { - $result=db_result(db_query("Select id from {virtualcommons_experiments} where exp_name LIKE '%%Forestry%%' ")); - } + /*$teacher=new Teacher($result,'talele'); + $fname=$teacher->getfname(); + $lname=$teacher->getlname();*/ - //Water Irrigation - else if($game_name==3) - { - $result=db_result(db_query("Select id from {virtualcommons_experiments} where exp_name LIKE '%%Water%%' ")); - } - /*$teacher=new Teacher($result,'talele'); - $fname=$teacher->getfname(); - $lname=$teacher->getlname();*/ + drupal_set_message(t('Thanks for filling out the form. Your Game will start soon. ')); + //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); - drupal_set_message(t('Thanks for filling out the form. Your Game will start soon. ')); - - //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); - - //echo 'Thanks for filling out the form. Your Game will start soon,'. $fname; - return 'studentgroup'; + //echo 'Thanks for filling out the form. Your Game will start soon,'. $fname; + return 'studentgroup'; } /** Old studentgroup module code cut'n'paste job */ @@ -208,176 +192,168 @@ function studentgroup() { - $form['#id']='studentgroup'; - $exp_name=$_SESSION['game_name']; - $no=$_SESSION['no_student']; - //unset($_SESSION['game_name']); - unset($_SESSION['no_student']); + $form['#id']='studentgroup'; + $game=Session::load('game'); + $exp_name = $game->getExperimentName(); + drupal_set_message(t("experiment name: " . $exp_name)); - //drupal_set_message(t('Game name is %exp_name .<br> No of Students are %no',array('%exp_name'=>$exp_name,'%no'=>$no))); - if($exp_name==1) - $exp_name="Fishery Game"; - else if($exp_name==2) - $exp_name="Forestry Game"; - else if($exp_name==3) - $exp_name="Water Irrigation Game"; + $no_of_student = $game->getNumberOfStudents(); + drupal_set_message(t("num students: " . $no_of_student)); + $no_of_groups=0; + $groups_3=0; + $groups_4=0; + $groups_5=0; + $header = array('Group ID', 'Student ID'); - //$no=$_POST['no_student']; - $no_of_student=(int)$no; - $no_of_groups=0; - $groups_3=0; - $groups_4=0; - $groups_5=0; - $header = array('Group ID', 'Student ID'); + // FIXME: seema will fix this later + //no of groups + $groups_5=((int)($no_of_student/5)); - //no of groups - $groups_5=((int)($no_of_student/5)); + $x= $no_of_student%5; - $x= $no_of_student%5; + if($x==0) + { + $no_of_groups=$groups_5; + } + else if($x==1) + { + $groups_5=$groups_5-1; + $groups_3=2; + $no_of_groups=$groups_5 + $groups_3; + } - if($x==0) - { - $no_of_groups=$groups_5; - } - else if($x==1) - { - $groups_5=$groups_5-1; - $groups_3=2; - $no_of_groups=$groups_5 + $groups_3; - } + else if($x==2) + { + $groups_5=$groups_5-1; + $groups_3=1; + $groups_4=1; + $no_of_groups=$groups_5 + $groups_3 + $groups_4; + } + else if($x==3) + { - else if($x==2) - { - $groups_5=$groups_5-1; - $groups_3=1; - $groups_4=1; - $no_of_groups=$groups_5 + $groups_3 + $groups_4; - } - else if($x==3) - { + $groups_3=1; + $no_of_groups=$groups_3 + $groups_5; + } - $groups_3=1; - $no_of_groups=$groups_3 + $groups_5; - } + else if($x==4) + { - else if($x==4) - { + $groups_4=1; + $no_of_groups=$groups_4 + $groups_5; + } - $groups_4=1; - $no_of_groups=$groups_4 + $groups_5; - } + $no_student5=5*$groups_5; + $no_student4=4*$groups_4; + $no_student3=3*$groups_3; - $no_student5=5*$groups_5; - $no_student4=4*$groups_4; - $no_student3=3*$groups_3; + $var=10; + $group_no=1; - $var=10; - $group_no=1; - - // FIXME: duplicated algorithm for generating student ids - if($groups_5 <> 0) + // FIXME: duplicated algorithm for generating student ids + if($groups_5 <> 0) + { + for($i=0;$i<$groups_5;$i++) { - for($i=0;$i<$groups_5;$i++) - { - $groupArray = array(); - for($j=0;$j<5;$j++) - { - $stud_id=uniqid(rand(0,9), false); - $row[]=array('Group '.$group_no,$stud_id); - $groupArray[] = $stud_id; + $groupArray = array(); + for($j=0;$j<5;$j++) + { + $stud_id=uniqid(rand(0,9), false); + $row[]=array('Group '.$group_no,$stud_id); + $groupArray[] = $stud_id; -// $row_submit[]=array($group_no,$stud_id); + // $row_submit[]=array($group_no,$stud_id); - } - $row_submit[$group_no++] = $groupArray; - } + } + $row_submit[$group_no++] = $groupArray; } - if($groups_4 <> 0) + } + if($groups_4 <> 0) + { + for($i=0;$i<$groups_4;$i++) { - for($i=0;$i<$groups_4;$i++) - { - $groupArray = array(); - for($j=0;$j<4;$j++) - { - $stud_id=uniqid(rand(0,9),false); - $row[]=array('Group '.$group_no,$stud_id); - $groupArray[] = $stud_id; -// $row_submit[]=array($group_no,$stud_id); + $groupArray = array(); + for($j=0;$j<4;$j++) + { + $stud_id=uniqid(rand(0,9),false); + $row[]=array('Group '.$group_no,$stud_id); + $groupArray[] = $stud_id; + // $row_submit[]=array($group_no,$stud_id); - } + } - $row_submit[$group_no++] = $groupArray; - } + $row_submit[$group_no++] = $groupArray; } - if($groups_3 <> 0) + } + if($groups_3 <> 0) + { + for($i=0;$i<$groups_3;$i++) { - for($i=0;$i<$groups_3;$i++) - { - $groupArray = array(); - for($j=0;$j<3;$j++) - { - $stud_id=uniqid(rand(0,9), false); - $row[]=array('Group '.$group_no,$stud_id); - $groupArray[] = $stud_id; -// $row_submit[]=array($group_no,$stud_id); - } - $row_submit[$group_no++] = $groupArray; - } + $groupArray = array(); + for($j=0;$j<3;$j++) + { + $stud_id=uniqid(rand(0,9), false); + $row[]=array('Group '.$group_no,$stud_id); + $groupArray[] = $stud_id; + // $row_submit[]=array($group_no,$stud_id); + } + $row_submit[$group_no++] = $groupArray; } + } - if(!isset($_SESSION['student_info'])) - { - $_SESSION['student_info']=$row_submit; - /*foreach ($_SESSION['student_info'] as $key=>$value) - { - drupal_set_message(t('Key is: %key<br>',array('%key'=>$key))); - foreach ($value as $key=>$value) - { - drupal_set_message(t('Key inner is: %key<br> Value inner is: %value',array('%key'=>$key,'%value'=>$value))); - } - }*/ - } + if(!isset($_SESSION['student_info'])) + { + $_SESSION['student_info']=$row_submit; + /*foreach ($_SESSION['student_info'] as $key=>$value) + { + drupal_set_message(t('Key is: %key<br>',array('%key'=>$key))); + foreach ($value as $key=>$value) + { + drupal_set_message(t('Key inner is: %key<br> Value inner is: %value',array('%key'=>$key,'%value'=>$value))); + } + }*/ + } - $form['game_info']=array( - '#type'=>'fieldset', - '#title'=>t('Experiment Information'), - '#tree' => TRUE - ); + $form['game_info']=array( + '#type'=>'fieldset', + '#title'=>t('Experiment Information'), + '#tree' => TRUE + ); - $form['game_info']['info']=array( - '#title'=>t('Please note the following information carefully.'), - '#type'=>'item', - '#description'=>t('<h3>Name of Experiments: '.$exp_name.'<br/>No of Students: '.$no_of_student.'<br/>No of Groups: '.$no_of_groups.'</h3>') - ); + $form['game_info']['info']=array( + '#title'=>t('Please note the following information carefully.'), + '#type'=>'item', + '#description'=>t('<h3>Name of Experiments: '.$exp_name.'<br/>No of Students: '.$no_of_student.'<br/>No of Groups: '.$no_of_groups.'</h3>') + ); - $form['group_info']=array( - '#type'=>'fieldset', - '#title'=>t('Group Information'), - '#tree' => TRUE - ); + $form['group_info']=array( + '#type'=>'fieldset', + '#title'=>t('Group Information'), + '#tree' => TRUE + ); - $form['group_info']['info1']=array( - '#title'=>t('Please assign the following Student IDs to the students.Please do not tell Group IDs to them. After assigning Student IDs, you can tell students to sign using Student Login Page.'), - '#description'=>t('<h3>Number of group of 3 Students: '.$groups_3.'<br/>Number of group of 4 Students: '.$groups_4.'<br/>Number of group of 5 Students: '.$groups_5.'</h3>'), - '#type'=>'item' + $form['group_info']['info1']=array( + '#title'=>t('Please assign the following Student IDs to the students.Please do not tell Group IDs to them. After assigning Student IDs, you can tell students to sign using Student Login Page.'), + '#description'=>t('<h3>Number of group of 3 Students: '.$groups_3.'<br/>Number of group of 4 Students: '.$groups_4.'<br/>Number of group of 5 Students: '.$groups_5.'</h3>'), + '#type'=>'item' - ); + ); - $form['group_info']['table_info']=array( + $form['group_info']['table_info']=array( - '#type'=>'markup', - '#value'=>theme('table',$header,$row) - ); + '#type'=>'markup', + '#value'=>theme('table',$header,$row) + ); - $form['submit'] = array( - '#type' => 'submit', - '#value' => t('Start Game!!!') - ); + $form['submit'] = array( + '#type' => 'submit', + '#value' => t('Start Game!!!') + ); - return $form; + return $form; } @@ -385,73 +361,71 @@ // "start game" function studentgroup_submit($form_id, $form_values) { - //put it in the database student + //put it in the database student - $id=$GLOBALS['user']->uid; - $table=$_SESSION['student_info']; + $id=$GLOBALS['user']->uid; + $table=$_SESSION['student_info']; - $game=new Game(); - $game->setTeacherId($id); - $virtual_conduct_id=$game->getGameID(); - $game->saveGroupStudent($table); + $game = Session::load('game'); + $game->saveGroupStudent($table); - - //depending upon the experiment game, assign the resource table to each group. - $exp_name=$_SESSION['game_name']; - if($exp_name==1) - { - //$exp_name="Fishery Game"; - } + //depending upon the experiment game, assign the resource table to each group. + $exp_name = $game->getExperimentId(); + if($exp_name==1) + { + //$exp_name="Fishery Game"; - else if($exp_name==2) - { - //$exp_name="Forestry Game"; - $game->initForestry(); - } - - else if($exp_name==3) - { - $exp_name="Water Irrigation Game"; - } + } - unset($_SESSION['student_info']); - unset($_SESSION['game_name']); - - //set flag=1 in vc_student and allow them to play - $flag=1; - $game->updateStartFlag($flag); + else if($exp_name==2) + { + //$exp_name="Forestry Game"; + $game->initForestry(); + } - return 'teacher_dashboard'; + else if($exp_name==3) + { + $exp_name="Water Irrigation Game"; + } + unset($_SESSION['student_info']); + unset($_SESSION['game_name']); + + //set flag=1 in vc_student and allow them to play + $flag=1; + $game->updateStartFlag($flag); + + return 'teacher_dashboard'; + } /*function game_start() -{ - $output=t('Please click the Start Game button.'); - $output.=drupal_get_form('game_start_form'); - return $output; -} + { + $output=t('Please click the Start Game button.'); + $output.=drupal_get_form('game_start_form'); + return $output; + } -function game_start_form() -{ - $form['submit'] = array( - '#type' => 'submit', - '#value' => t('Start Game!!!') - ); - return $form; -} + function game_start_form() + { + $form['submit'] = array( + '#type' => 'submit', + '#value' => t('Start Game!!!') + ); + return $form; + } -function game_start_form_submit($form_id,$form_values) -{ - $teacher_id=$GLOBALS['user']->uid; - $virtual_conduct_id=db_result(db_query("select max(id),users_id from {virtualcommons_conducts} where users_id=%d group by users_id",$teacher_id)); + function game_start_form_submit($form_id,$form_values) + { + $teacher_id=$GLOBALS['user']->uid; + $virtual_conduct_id=db_result(db_query("select max(id),users_id from {virtualcommons_conducts} where users_id=%d group by users_id",$teacher_id)); - db_query("update virtualcommons_student set start_flag=true where virtualcommons_conducts_id=%d",$virtual_conduct_id); - return 'teacher_dashboard'; -}*/ + db_query("update virtualcommons_student set start_flag=true where virtualcommons_conducts_id=%d",$virtual_conduct_id); + return 'teacher_dashboard'; + }*/ Modified: vcweb/trunk/virtualcommons/games/forestry_v2/forestry_v2.module =================================================================== --- vcweb/trunk/virtualcommons/games/forestry_v2/forestry_v2.module 2008-08-01 01:19:07 UTC (rev 19) +++ vcweb/trunk/virtualcommons/games/forestry_v2/forestry_v2.module 2008-08-02 00:15:56 UTC (rev 20) @@ -4,25 +4,10 @@ include_once('./' . drupal_get_path('module', 'experiment') . '/experiment.inc'); -/* -function __autoload($class_name) { - drupal_set_message(t('Trying to load ' . $class_name)); - require_once('./' . drupal_get_path('module', 'experiment') . '/experiment.inc'); -} -*/ - /** * implement the _user hook. **/ - - -/*function forestry_v2_perm() - { - return array('Only Teachers'); - - }*/ - // $Id$ /** * Implementation of hook_menu(). @@ -37,10 +22,42 @@ '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', + //'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 +{ + forestry_v2_load(); +} + return $items; } + +function forestry_v2_load() { + static $loaded = FALSE; + + if (!$loaded) { + $path = drupal_get_path('module', 'forestry_v2'); + drupal_add_css($path .'/form.css'); + $loaded = TRUE; + } +} + /** * Called when user goes to example.com/?q=forestry */ @@ -119,6 +136,8 @@ $game_id = $group->getGameId(); if($flag) { $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'; else if($current_stage_no==2) @@ -140,5 +159,370 @@ } } +//Forestry Stage 1 Begins +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; +} + + + +function forestry_game_stage1_multiform() +{ + + $form['#id']='forestry_game_stage1_multiform'; + $group = unserialize($_SESSION['group']); + $student=new ForestryStudent(); + + $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 + + $group_id=$group->getGroupId(); + $game_id=$group->getGameId(); + 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; + 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; + $header=array("Round Number","Your Harvest Decision","Resources Before","Resources After"); + + $final_row=$student->getForestryStudentInfo($group_id,$game_id); + + /*$result=db_query("select round_no,harvest_decision from virtualcommons_forestry_student where virtualcommons_student_id= '%s' ",$stud_id); + while($data=db_fetch_object($result)) + { + $round_no=$data->round_no; + $harvest_decision=$data->harvest_decision; + $round_no=(int)$round_no; + //$resources_before=$data->resources_before; + //$resources_after=$data->resources_after; + $resource_info= db_query("select resources_before,resources_after from virtualcommons_forestry_group_information where virtualcommons_student_group_no=%d and virtualcommons_conducts_id=%d and round_no=%d",$group_no,$conducts_id,$round_no); + while($data_resource=db_fetch_object($resource_info)) + { + $resources_before=$data_resource->resources_before; + $resources_after=$data_resource->resources_after; + } + $final_row[]=array($round_no,$harvest_decision,$resources_before,$resources_after); + }*/ + $round_no=$student->getRoundNo(); + $round_no=$round_no+1; + 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 + ); + + +$no_rounds=$group->getNoOfRounds(); +//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('no of rounds are: '.$no_rounds)); +if($round_no <= $no_rounds) +{ + + $form['resources_available']=array( + + '#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('Next') + ); +} +else +{ + $stage_no=$group->getCurrentStageNumber(); + $stage_no=(int) $stage_no; + $form['indicator']['submit'] = array( + '#type' => 'submit', + '#value' => t('Stage '.$stage_no+1) + ); + +} + + $form['resource']=array( + + '#type'=>'fieldset', + '#title'=>t('<b>Resources</b>'), + + ); + $form['resource']['table']=array( + '#type'=>'markup', + '#value'=>theme('table',$header,$final_row) + ); + + +return $form; + +} + + + +function forestry_game_stage1_multiform_validate($form_id,$form_values) +{ +$harvest_decision=$form_values['indicator']['harvest_decision']; +$resource=(int) $_SESSION['prev_resource']; +//$resource=100; +$flag=FALSE; + +if(preg_match('/[^0-9]+/',$harvest_decision)) +{ + form_set_error('harvest_decision',t('Harvest Decison can not be alphabet or special character.')); +} +else +{ + + $harvest_table= $_SESSION['harvest_table']; + + foreach($harvest_table as $key=> $value) + { + + if(!$flag) + { + foreach($value as $key=>$value) + { + + if($key==0) + { + //get min and maximum value of the resource + $harvest_tbl=explode("-",$value); + $min_resource=(int) $harvest_tbl[0]; + $max_resource=(int) $harvest_tbl[1]; + + } + else if($key==1) + { + //get the maximum units player can invest + $harvest_units=(int) $value; + /*drupal_set_message(t('Min : '.$min_resource)); + drupal_set_message(t('Max : '.$max_resource)); + drupal_set_message(t('Units can harvest: '.$harvest_units)); + drupal_set_message(t('Resource can harvest: '.$resource)); + drupal_set_message(t('comparision: '. ($harvest_decision > $harvest_units)));*/ + if(($resource >= $min_resource) && ($resource <= $max_resource)) + { + //depending upon the resource available player can invest units. e.g in group of 5 and resource available=100 then player can invest max 5 units. + //drupal_set_message(t('resource condition successful: ')); + $harvest_decision=(int) $harvest_decision; + if($harvest_decision > $harvest_units) + { + if($harvest_units ==0 ) + form_set_error('harvest_decision',t('Current Resource Level is very low. You can not harvest anything. <br><b>GAME OVER!!!</b>')); + else + form_set_error('harvest_decision',t('Harvest Decison can not be more than %harvest_units.',array('%harvest_units'=>$harvest_units))); + $flag=TRUE; + } + else + $flag=FALSE; + + } + + } + }//end of for1 + + }// end of if(flag) + +if($flag) + break; + + }//end of for 2 + +} + + +return; + +} + + +function forestry_game_stage1_multiform_submit($form_id,$form_values) +{ + $group = unserialize($_SESSION['group']); + + $harvest_table=$_SESSION['harvest_table']; + //$harvest_tbl=explode("-",$harvest_table); + $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)); + + $stud_harvest_decision=(int) $form_values['indicator']['harvest_decision']; + + + $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)); + + //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->getNoOfRounds(); + //$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']=="Stage 2") +{ + $stage_no=2; + $exp_id=$group->getExperimentId(); + $student->updateStageId($stage_no,$exp_id); + //db_query("update virtualcommons_conducts set virtualcommons_stage_no=%d where id=%d",2,$virtual_conducts_id); + unset($_SESSION['prev_resource']); + + return 'rules'; +} +else + return 'forestry_stage1_part2'; + + +} + +function theme_forestry_game_stage1_multiform($form) +{ +$output='<div class="indicator"><table style="text-align: center; width: 100%;" border="0" + cellpadding="0" cellspacing="0"> + <tbody> + <tr> + <td style="width: 80%;"> </td> + + <td nowrap>'; +$output.=drupal_render($form ['resources_available']); +$output.='</td> + </tr> + + + <tr> + <td style="width: 30%;" colspan="2" rowspan="1">'; +$output.= drupal_render($form['indicator']); + + +$output.= drupal_render($form['indicator']['harvest_decision']); +$output.='</td>'; + //<td style="text-align: center;" colspan="2" rowspan="1">'; +$output.=drupal_render($form['indicator']['submit']); +$output.=' + </tr><tr> <td> </td> </tr> +<tr> + <td colspan="2" rowspan="1">'; + +$output.=drupal_render($form['resource']); + +$output.=drupal_render($form['resource']['table']); +$output.=' + </td> + </tr> + </tbody> + </table> +</div>'; +$output.=drupal_render($form); +return $output; + +} + + +function forestry_game_stage1_part2() +{ + +$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() +{ + + $form['submit'] = array( + '#type' => 'submit', + '#value' => t('Next Round') + ); +return $form; +} + + + +function forestry_game_stage1_part2form_submit($form_id,$form_values) +{ + $stud_id=$_SESSION['student_id']; + $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'; + +} + + + + + Modified: vcweb/trunk/virtualcommons/games/teacher_dashboard/teacher_dashboard.install =================================================================== --- vcweb/trunk/virtualcommons/games/teacher_dashboard/teacher_dashboard.install 2008-08-01 01:19:07 UTC (rev 19) +++ vcweb/trunk/virtualcommons/games/teacher_dashboard/teacher_dashboard.install 2008-08-02 00:15:56 UTC (rev 20) @@ -16,13 +16,13 @@ round_no int NOT NULL, vc_game_id int NOT NULL, vc_group_id int NOT NULL, + vc_stage_id int NOT NULL, total_harvest_decision int NOT NULL, resources_before int NOT NULL, resources_after int NOT NULL, vc_rules_id int NOT NULL, dice int default 0, - PRIMARY KEY(id), FOREIGN KEY(vc_game_id) REFERENCES vc_game(id) @@ -31,6 +31,8 @@ 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_rules_id) REFERENCES vc_rules(id) ON DELETE CASCADE @@ -87,7 +89,6 @@ function teacher_dashboard_uninstall() { - db_query("DROP TABLE {vc_forestry_group_round_info}"); drupal_set_message(t('Forestry Group Round Information is successfully deleted from the database. We hope.')); } Modified: vcweb/trunk/virtualcommons/games/teacher_dashboard/teacher_dashboard.module =================================================================== --- vcweb/trunk/virtualcommons/games/teacher_dashboard/teacher_dashboard.module 2008-08-01 01:19:07 UTC (rev 19) +++ vcweb/trunk/virtualcommons/games/teacher_dashboard/teacher_dashboard.module 2008-08-02 00:15:56 UTC (rev 20) @@ -1,28 +1,30 @@ <?php +// vim:sts=2:sw=2:filetype=php + function teacher_dashboard_menu($may_cache) { $items = array(); if ($may_cache) - { - - $items[]=array( 'path' => 'teacher_dashboard', - 'title' => t('Teacher Dashboard'), - 'callback' => 'teacher_dashboard', - 'type'=>MENU_CALLBACK, - 'access' => user_access('Only Teachers') - ); - - $items[]=array( 'path' => 'teacher_dashboard_part2', - 'title' => t('Teacher Dashboard'), - 'callback'=>'teacher_dashboard_part2', - // 'callback argument' => array('forestry_game_stage1_part2'), - 'type'=>MENU_CALLBACK, - 'access' => user_access('Only Teachers') - ); + { + + $items[]=array( 'path' => 'teacher_dashboard', + 'title' => t('Teacher Dashboard'), + 'callback' => 'teacher_dashboard', + 'type'=>MENU_CALLBACK, + 'access' => user_access('Only Teachers') + ); + + $items[]=array( 'path' => 'teacher_dashboard_part2', + 'title' => t('Teacher Dashboard'), + 'callback'=>'teacher_dashboard_part2', + // 'callback argument' => array('forestry_game_stage1_part2'), + 'type'=>MENU_CALLBACK, + 'access' => user_access('Only Teachers') + ); } -/*else { - teacher_load(); - }*/ + /*else { + teacher_load(); + }*/ return $items; } @@ -30,12 +32,14 @@ { // Return the HTML generated from the $form data structure. -$teacher_id=$GLOBALS['user']->uid; -//db_query( - //drupal_set_message(t($teacher_id)); - $virtual_conduct_id=db_result(db_query("select max(id) from {virtualcommons_conducts} where users_id=%d group by users_id",$teacher_id)); - $exp_name=db_result(db_query("select exp_name from virtualcommons_experiments where id =(select virtualcommons_experiments_id from virtualcommons_conducts where id=%d)",$virtual_conduct_id)); - $output=t('<br> <h2>'. $exp_name . '</h2>'); + $teacher_id=$GLOBALS['user']->uid; + //db_query( + //drupal_set_message(t($teacher_id)); +// $virtual_conduct_id=db_result(db_query("select max(id) from {virtualcommons_conducts} where users_id=%d group by users_id",$teacher_id)); + // $exp_name=db_result(db_query("select exp_name from virtualcommons_experiments where id =(select virtualcommons_experiments_id from virtualcommons_conducts where id=%d)",$virtual_conduct_id)); + $game = Session::load('game'); + $exp_name=$game->getExperimentName(); + $output=t('<br> <h2>'. $exp_name . '</h2>'); $output .= drupal_get_form('teacher_dashboard_multiform'); return $output; } @@ -44,126 +48,111 @@ function teacher_dashboard_multiform($form_values=NULL) { - $form['#id']='teacher_dashboard_multiform'; - $form['#multistep']=TRUE; - $teacher_id=$GLOBALS['user']->uid; - $round_no=0; - $stage_flag=FALSE; - - $virtual_conduct_id=db_result(db_query("select max(id),users_id from {virtualcommons_conducts} where users_id=%d group by users_id",$teacher_id)); - - //retrive values for stage 1 - - $header_stage1=array('Round No','Group No', 'Group Harvest Decision','Resources Before','Resources After'); - $result=db_query(" select round_no,virtualcommons_student_group_no,total_harvest_decision,resources_after,resources_before from {virtualcommons_forestry_group_information} where virtualcommons_conducts_id=%d and virtualcommons_stage_no=%d",$virtual_conduct_id,1); + $form['#id']='teacher_dashboard_multiform'; + $form['#multistep']=TRUE; + $game = Session::load('game'); + // $teacher_id=$GLOBALS['user']->uid; + $round_no=0; + $stage_flag=FALSE; - while($data=db_fetch_object($result)) - { - $round_no=$data->round_no; - $group_no=$data->virtualcommons_student_group_no; - $total_harvest_decision=$data->total_harvest_decision; - $resource_before=$data->resources_before; - $resource_after=$data->resources_after; - $row_stage1[]=array($round_no,$group_no,$total_harvest_decision,$resource_before,$resource_after); - } - - + //$virtual_conduct_id=db_result(db_query("select max(id),users_id from {virtualcommons_conducts} where users_id=%d group by users_id",$teacher_id)); - if(!isset($form_values)) - { //$round_no=(int) $round_no; - $step=0; - drupal_set_message(t('step when form values are null: '.$step)); - } - else - { - $step=(int) $form_values['step']; - $step++; - drupal_set_message(t('step when form values are not null: '.$step)); - } - -$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('no of rounds are: '.$no_rounds)); -if($round_no==$no_rounds) -{ - if(isset($_SESSION['next_stage'])) - { - $stage_flag=FALSE; - unset($_SESSION['next_stage']); - } - else - $stage_flag=TRUE; -} - - // $_SESSION['step']=$step; + //retrive values for stage 1 - //$form['#redirect']=FALSE; + $header_stage1=array('Round No','Group No', 'Group Harvest Decision','Resources Before','Resources After'); + $row_stage1 = $game->getAllGroupRoundInfo(); - $form['round_no']=array('#type'=>'hidden','#value'=>$round_no); - $form['game_id']=array('#type'=>'hidden','#value'=>$virtual_conduct_id); - //$form['exp_name']=array('#type'=>'hidden','#value'=>$exp_name); - //$form['step']=array('#type'=>'hidden','#value'=>$step); - $form['stage1']=array( - '#type'=>'fieldset', - '#title'=>t('<b>Stage 1</b>') - ); + if(!isset($form_values)) + { //$round_no=(int) $round_no; + $step=0; + drupal_set_message(t('step when form values are null: '.$step)); + } + else + { + $step=(int) $form_values['step']; + $step++; + drupal_set_message(t('step when form values are not null: '.$step)); + } + $no_rounds= $game->getNumberOfRounds(); +// $no_rounds=(int) $no_rounds; + drupal_set_message(t('no of rounds are: '.$no_rounds)); + if($round_no==$no_rounds) + { + if(isset($_SESSION['next_stage'])) + { + $stage_flag=FALSE; + unset($_SESSION['next_stage']); + } + else + $stage_flag=TRUE; + } - $form['stage1']['table']=array( - '#type'=>'markup', - '#value'=>theme('table',$header_stage1,$row_stage1) - ); + // $_SESSION['step']=$step; - $form['stage2']=array( - '#type'=>'fieldset', - '#title'=>t('<b>Stage 2</b>') - ); + //$form['#redirect']=FALSE; + $form['round_no']=array('#type'=>'hidden','#value'=>$round_no); + $form['game_id']=array('#type'=>'hidden','#value'=>$virtual_conduct_id); + //$form['exp_name']=array('#type'=>'hidden','#value'=>$exp_name); + //$form['step']=array('#type'=>'hidden','#value'=>$step); + $form['stage1']=array( + '#type'=>'fieldset', + '#title'=>t('<b>Stage 1</b>') + ); - $form['stage2']['table']=array( - '#type'=>'markup', - '#value'=>theme('table',$header_stage2,$row_stage2) - ); - if($stage_flag) - { - $form['submit'] = array( - '#type' => 'submit', - '#value' => t('Go to Stage 2') - ); - $stage_flag=FALSE; - } - else - { - $form['submit'] = array( - '#type' => 'submit', - '#value' => t('Next Round') - ); - } + $form['stage1']['table']=array( + '#type'=>'markup', + '#value'=>theme('table',$header_stage1,$row_stage1) + ... [truncated message content] |
From: <al...@us...> - 2008-08-01 01:18:59
|
Revision: 19 http://virtualcommons.svn.sourceforge.net/virtualcommons/?rev=19&view=rev Author: alllee Date: 2008-08-01 01:19:07 +0000 (Fri, 01 Aug 2008) Log Message: ----------- * adding classes via experiment.inc * student login done * initializing groups + students done TODO: actual experiment in forestry_v2.module and teacher_dashboard Modified Paths: -------------- vcweb/trunk/virtualcommons/experiment/experiment.install vcweb/trunk/virtualcommons/experiment/experiment.module vcweb/trunk/virtualcommons/experiment/student_login/student_login.module vcweb/trunk/virtualcommons/games/teacher_dashboard/teacher_dashboard.info vcweb/trunk/virtualcommons/games/teacher_dashboard/teacher_dashboard.install Added Paths: ----------- vcweb/trunk/virtualcommons/experiment/experiment.inc vcweb/trunk/virtualcommons/experiment/init-experiment.sql vcweb/trunk/virtualcommons/experiment/survey-questions.sql vcweb/trunk/virtualcommons/games/forestry_v2/ vcweb/trunk/virtualcommons/games/forestry_v2/forestry_v2.info vcweb/trunk/virtualcommons/games/forestry_v2/forestry_v2.install vcweb/trunk/virtualcommons/games/forestry_v2/forestry_v2.module vcweb/trunk/virtualcommons/games/rules/rules.install Added: vcweb/trunk/virtualcommons/experiment/experiment.inc =================================================================== --- vcweb/trunk/virtualcommons/experiment/experiment.inc (rev 0) +++ vcweb/trunk/virtualcommons/experiment/experiment.inc 2008-08-01 01:19:07 UTC (rev 19) @@ -0,0 +1,201 @@ +<?php + +class Game +{ + private $game_id; + private $exp_id; + private $game_name; + private $teacher_id; + private $experiment_id; + private $stage_id; + private $round_no; + private $no_of_student; + + // FIXME: perhaps this should return a list of games eventually + public function getGameID() + { + $this->game_id=db_result(db_query("Select max(id) from vc_game where users_id=%d",$this->teacher_id)); + return $this->game_id; + } + + public function setExpId($exp_id) + { + $this->exp_id=$exp_id; + + } + + + public function setTeacherId($teacher_id) + { + $this->teacher_id=$teacher_id; + + } + + public function setStageId($stage_no) + { + $this->stage_id=db_result(db_query("select id from vc_stage where vc_experiment_id =%d and stage_no=%d",$this->exp_id,$stage_no)); + + + } + + public function setNoOfStudent($no_of_student) + { + $this->no_of_student=$no_of_student; + + } + + + public function setRoundNo($round_no) + { + $this->round_no=$round_no; + } + + + public function saveGame() + { + + //$this->exp_id=db_result(db_query("Select id from {vc_experiment} where name LIKE '%s'",$this->game_name)); + + + //insert into game table + drupal_set_message(t('game name:'.$this->game_name)); + db_query("Insert into {vc_game} (users_id, vc_experiment_id, no_of_students,vc_stage_id,current_round_no ) values(%d,%d,%d,%d,%d)",$this->teacher_id,$this->exp_id,$this->no_of_student,$this->stage_id,$this->round_no); + + } + + + public function saveGroupStudent($student_array) + { + $turn=array(1,2,3,4,5); + // $prev_group_no=0; + // $temp=-1; + $i=0; + $this->stage_id=db_result(db_query("select vc_stage_id from vc_game where id =%d",$this->game_id)); + foreach ($student_array as $group=>$value) + { + + //drupal_set_message(t('Group Key is: %key<br>' ,array('%key'=>$key))); + db_query("Insert into {vc_group} (group_no,vc_game_id,vc_stage_id) values(%d,%d,%d)",$group,$this->game_id,$this->stage_id); + $i=0; + foreach ($value as $key=>$student_id) + { + //$turn= (int) $turn[$i]; + db_query("Insert into {vc_student} (id,vc_group_id,start_flag,turn_no) values('%s',LAST_INSERT_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]))); + $i++; + + } + } + + + } + +// FIXME: figure out if we can move to forestry at some point + public function initForestry() + { + $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_student=$data->cnt; + $group_no=$data->group_id; + //drupal_set_message(t($no_of_student.' '. $group_no)); + if($no_of_student == 5) + { + db_query("Insert into {vc_forestry_common_resource_pool} (vc_group_id,common_resource_pool,vc_game_id, harvest_decision,max_harvest_decision) values(%d,%d,%d,%d,%d)",$group_no,100,$this->game_id,0,100); + + } + + else if($no_of_student == 4) + { + db_query("Insert into {vc_forestry_common_resource_pool} (vc_group_id,common_resource_pool,vc_game_id, harvest_decision,max_harvest_decision) values(%d,%d,%d,%d,%d)",$group_no,80,$this->game_id,0,80); + } + + + else if($no_of_student == 3) + { + db_query("Insert into {vc_forestry_common_resource_pool} (vc_group_id,common_resource_pool,vc_game_id,harvest_decision,max_harvest_decision) values(%d,%d,%d,%d,%d)",$group_no,60,$this->game_id,0,60); + } + + } + + + } + + public function updateStartFlag($flag) + { + db_query("update vc_student set start_flag=%d where vc_group_id in (select id from vc_group where vc_game_id=%d)",$flag,$this->game_id); + } + + +}//end of class Game + +class Group { + private $game_id; + private $group_id; + private $group_no; + private $no_of_students; + + public function getNumberOfStudents() { + return $this->no_of_students; + } + + public function getGroupId() { + return $this->group_id; + } + + public function getGameId() { + return $this->game_id; + } + + public function getStartFlag($student_id) { + return db_result(db_query("SELECT start_flag FROM {vc_student} WHERE id='%s'",$student_id)); + } + + public function getCurrentStageNumber() { + 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 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)); + } + + public static function checkStudentId($studentId) { + $fetch_object = db_fetch_object(db_query("SELECT g.id AS group_id, g.vc_game_id AS game_id from {vc_student s, vc_group g} where s.id='%s' AND s.vc_group_id=g.id",$studentId)); + if ($fetch_object) { + $group = new Group(); + $group->game_id = $fetch_object->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)); + return $group; + } + return false; + } + +} + + + + + +/*class Student + { + private $teacher_id; + private $stud_id; + private $start_flag; + private $group_id; + private $turn_no; + + function public getStartFlag() + { + return $this->start_flag; + } + + function public getTurnNo() + { + return $this->turn_no; + } + + + + }*/ Modified: vcweb/trunk/virtualcommons/experiment/experiment.install =================================================================== --- vcweb/trunk/virtualcommons/experiment/experiment.install 2008-07-30 22:59:46 UTC (rev 18) +++ vcweb/trunk/virtualcommons/experiment/experiment.install 2008-08-01 01:19:07 UTC (rev 19) @@ -25,40 +25,33 @@ no_of_practice_rounds INT DEFAULT 0, vc_experiment_id INT NOT NULL, - PRIMARY KEY(id), - + PRIMARY KEY(id), 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} ( id INT AUTO_INCREMENT, rule_no INT NOT NULL, vc_stage_id INT NOT NULL, - rule_description TEXT, + description MEDIUMTEXT, name enum('Lottery', 'Rotation', 'Property Rights'), - PRIMARY KEY(id), - + PRIMARY KEY(id), 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} ( id INT AUTO_INCREMENT, users_id INT NOT NULL, vc_experiment_id INT NOT NULL, - date_created TIMESTAMP NOT NULL, no_of_students INT NOT NULL, vc_stage_id INT NOT NULL, current_round_no INT NOT NULL, + date_created TIMESTAMP NOT NULL, - PRIMARY KEY(id), - + PRIMARY KEY(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} @@ -69,225 +62,116 @@ vc_stage_id INT NOT NULL, vc_selected_rules_id INT NULL, - PRIMARY KEY(id), - + PRIMARY KEY(id), FOREIGN KEY(vc_game_id) REFERENCES vc_game(id), FOREIGN KEY(vc_stage_id) REFERENCES vc_stage(id), FOREIGN KEY(vc_selected_rules_id) REFERENCES vc_rules(id) - - ) ENGINE=InnoDB /*!40100 DEFAULT CHARACTER SET UTF8 */"); db_query("CREATE TABLE {vc_student} ( id varchar(14), vc_group_id INT NOT NULL, - vc_game_id INT NOT NULL, + start_flag BOOL default false, turn_no INT NOT NULL, PRIMARY KEY(id), + FOREIGN KEY(vc_group_id) REFERENCES vc_group(id) - - FOREIGN KEY(vc_group_id) REFERENCES vc_group(id), - FOREIGN KEY(vc_game_id) REFERENCES vc_game(id) - ) ENGINE=InnoDB /*!40100 DEFAULT CHARACTER SET UTF8 */"); - db_query("CREATE TABLE {vc_forestry_common_resource_pool} - ( - id INT AUTO_INCREMENT, - vc_group_id INT NOT NULL, - common_resource_pool INT NOT NULL, - harvest_decision INT NOT NULL, - vc_game_id INT NOT NULL, - max_harvest_decision INT NOT NULL, + - PRIMARY KEY(id), - FOREIGN KEY(vc_group_id) REFERENCES vc_group(id) - ON DELETE CASCADE, +db_query("insert into {vc_experiment} (name) values('Fishery Game')"); +db_query("insert into {vc_experiment} (name) values('Forestry Game')"); +db_query("insert into {vc_experiment} (name) values('Water Irrigation Game')"); - FOREIGN KEY(vc_game_id) REFERENCES vc_game(id) - ON DELETE CASCADE +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 +AABBAABBAABBAA of a ban where you are not allowed to harvest. It means that: +Round 1 ban in A +Round 2 ban in A +Round 3 ban in B +Round 4 ban in B +Round 5 ban in A +Round 6 ban in A +Round 7 ban in B +Round 8 ban in B +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: +Round 1: extracts wood the player A, B +Round 2 extracts wood the player C, D +Round 3: extracts wood the player E, A +Round 4: extracts wood the player B, C +Round 5: extracts wood the player D, E +Round 6: extracts wood the player A, B +Round 7: extracts wood the player C, D +Round 8 extracts wood the player E, A +Round 9: extracts wood the player B, C +Round 10: extracts wood the player D, E +If this rule is chosen, players get randomly a character A, B, C, D or E. player 1 may for example get turn D. - )ENGINE=InnoDB /*!40100 DEFAULT CHARACTER SET UTF8 */"); +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: +Round 1: ABCDE +Round 2: BCDEA +Round 3: CDEAB +Round 4: DEABC +Round 5: EABCD +Round 6: ABCDE +Round 7: BCDEA +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.')"); + $flag=TRUE; - - //Forestry Game Harvest Tables. - db_query("CREATE TABLE {vc_forestry_5player_harvest_table} ( - id INT AUTO_INCREMENT, - min_resource_level INT NOT NULL, - max_resource_level INT NOT NULL, - individual_harvest_level INT NOT NULL, + break; + case 'pgsql': + db_query("CREATE TABLE {vc_student} ( - PRIMARY KEY(id) + id varchar(14) NOT NULL, + group_id INT NOT NULL, + vc_game_id INT NOT NULL, - )ENGINE=InnoDB /*!40100 DEFAULT CHARACTER SET UTF8 */"); + PRIMARY KEY(id), + FOREIGN KEY(vc_game_id) REFERENCES vc_game(id) + ON DELETE CASCADE + )"); + $flag=TRUE; - db_query("INSERT INTO {vc_forestry_5player_harvest_table} (min_resource_level,max_resource_level,individual_harvest_level) values(25,100,5)"); - db_query("INSERT INTO {vc_forestry_5player_harvest_table} (min_resource_level,max_resource_level,individual_harvest_level) values(20,24,4)"); - db_query("INSERT INTO {vc_forestry_5player_harvest_table} (min_resource_level,max_resource_level,individual_harvest_level) values(15,19,3)"); - db_query("INSERT INTO {vc_forestry_5player_harvest_table} (min_resource_level,max_resource_level,individual_harvest_level) values(10,14,2)"); - db_query("INSERT INTO {vc_forestry_5player_harvest_table} (min_resource_level,max_resource_level,individual_harvest_level) values(5,9,1)"); - db_query("INSERT INTO {vc_forestry_5player_harvest_table} (min_resource_level,max_resource_level,individual_harvest_level) values(0,4,0)"); - - db_query("CREATE TABLE {vc_forestry_4player_harvest_table} ( - id INT AUTO_INCREMENT, - min_resource_level INT NOT NULL, - max_resource_level INT NOT NULL, - individual_harvest_level INT NOT NULL, - - PRIMARY KEY(id) - - )ENGINE=InnoDB /*!40100 DEFAULT CHARACTER SET UTF8 */"); - - - db_query("INSERT INTO {vc_forestry_4player_harvest_table} (min_resource_level,max_resource_level,individual_harvest_level) values(20,80,5)"); - db_query("INSERT INTO {vc_forestry_4player_harvest_table} (min_resource_level,max_resource_level,individual_harvest_level) values(16,19,4)"); - db_query("INSERT INTO {vc_forestry_4player_harvest_table} (min_resource_level,max_resource_level,individual_harvest_level) values(12,15,3)"); - db_query("INSERT INTO {vc_forestry_4player_harvest_table} (min_resource_level,max_resource_level,individual_harvest_level) values(8,11,2)"); - db_query("INSERT INTO {vc_forestry_4player_harvest_table} (min_resource_level,max_resource_level,individual_harvest_level) values(4,7,1)"); - db_query("INSERT INTO {vc_forestry_4player_harvest_table} (min_resource_level,max_resource_level,individual_harvest_level) values(0,3,0)"); - - db_query("CREATE TABLE {vc_forestry_3player_harvest_table} ( - id INT AUTO_INCREMENT, - min_resource_level INT NOT NULL, - max_resource_level INT NOT NULL, - individual_harvest_level INT NOT NULL, - - PRIMARY KEY(id) - - )ENGINE=InnoDB /*!40100 DEFAULT CHARACTER SET UTF8 */"); - - db_query("INSERT INTO {vc_forestry_3player_harvest_table} (min_resource_level,max_resource_level,individual_harvest_level) values(15,60,5)"); - db_query("INSERT INTO {vc_forestry_3player_harvest_table} (min_resource_level,max_resource_level,individual_harvest_level) values(12,14,4)"); - db_query("INSERT INTO {vc_forestry_3player_harvest_table} (min_resource_level,max_resource_level,individual_harvest_level) values(9,11,3)"); - db_query("INSERT INTO {vc_forestry_3player_harvest_table} (min_resource_level,max_resource_level,individual_harvest_level) values(6,8,2)"); - db_query("INSERT INTO {vc_forestry_3player_harvest_table} (min_resource_level,max_resource_level,individual_harvest_level) values(3,5,1)"); - db_query("INSERT INTO {vc_forestry_3player_harvest_table} (min_resource_level,max_resource_level,individual_harvest_level) values(0,2,0)"); - - - $flag=TRUE; - - break; - case 'pgsql': - db_query("CREATE TABLE {vc_student} ( - - id varchar(14) NOT NULL, - group_id INT NOT NULL, - vc_game_id INT NOT NULL, - - PRIMARY KEY(id), - - FOREIGN KEY(vc_game_id) REFERENCES vc_game(id) - ON DELETE CASCADE - )"); - - //Forestry Game Harvest Tables. - db_query("CREATE TABLE {vc_forestry_5player_harvest_table} ( - id INT NOT NULL AUTO_INCREMENT, - min_resource_level INT NOT NULL, - max_resource_level INT NOT NULL, - individual_harvest_level INT NOT NULL, - - PRIMARY KEY(id) - - ) /*!40100 DEFAULT CHARACTER SET UTF8 */"); - - - db_query("INSERT INTO {vc_forestry_5player_harvest_table} (min_resource_level,max_resource_level,individual_harvest_level) values(25,100,5)"); - db_query("INSERT INTO {vc_forestry_5player_harvest_table} (min_resource_level,max_resource_level,individual_harvest_level) values(20,24,4)"); - db_query("INSERT INTO {vc_forestry_5player_harvest_table} (min_resource_level,max_resource_level,individual_harvest_level) values(15,19,3)"); - db_query("INSERT INTO {vc_forestry_5player_harvest_table} (min_resource_level,max_resource_level,individual_harvest_level) values(10,14,2)"); - db_query("INSERT INTO {vc_forestry_5player_harvest_table} (min_resource_level,max_resource_level,individual_harvest_level) values(5,9,1)"); - db_query("INSERT INTO {vc_forestry_5player_harvest_table} (min_resource_level,max_resource_level,individual_harvest_level) values(0,4,0)"); - - - - db_query("CREATE TABLE {vc_forestry_4player_harvest_table} ( - id INT NOT NULL AUTO_INCREMENT, - min_resource_level INT NOT NULL, - max_resource_level INT NOT NULL, - individual_harvest_level INT NOT NULL, - - PRIMARY KEY(id) - - ) /*!40100 DEFAULT CHARACTER SET UTF8 */"); - - - db_query("INSERT INTO {vc_forestry_4player_harvest_table} (min_resource_level,max_resource_level,individual_harvest_level) values(20,80,5)"); - db_query("INSERT INTO {vc_forestry_4player_harvest_table} (min_resource_level,max_resource_level,individual_harvest_level) values(16,19,4)"); - db_query("INSERT INTO {vc_forestry_4player_harvest_table} (min_resource_level,max_resource_level,individual_harvest_level) values(12,15,3)"); - db_query("INSERT INTO {vc_forestry_4player_harvest_table} (min_resource_level,max_resource_level,individual_harvest_level) values(8,11,2)"); - db_query("INSERT INTO {vc_forestry_4player_harvest_table} (min_resource_level,max_resource_level,individual_harvest_level) values(4,7,1)"); - db_query("INSERT INTO {vc_forestry_4player_harvest_table} (min_resource_level,max_resource_level,individual_harvest_level) values(0,3,0)"); - - - - - db_query("CREATE TABLE {vc_forestry_3player_harvest_table} ( - id INT NOT NULL AUTO_INCREMENT, - min_resource_level INT NOT NULL, - max_resource_level INT NOT NULL, - individual_harvest_level INT NOT NULL, - - PRIMARY KEY(id) - - ) /*!40100 DEFAULT CHARACTER SET UTF8 */"); - - db_query("INSERT INTO {vc_forestry_3player_harvest_table} (min_resource_level,max_resource_level,individual_harvest_level) values(15,60,5)"); - db_query("INSERT INTO {vc_forestry_3player_harvest_table} (min_resource_level,max_resource_level,individual_harvest_level) values(12,14,4)"); - db_query("INSERT INTO {vc_forestry_3player_harvest_table} (min_resource_level,max_resource_level,individual_harvest_level) values(9,11,3)"); - db_query("INSERT INTO {vc_forestry_3player_harvest_table} (min_resource_level,max_resource_level,individual_harvest_level) values(6,8,2)"); - db_query("INSERT INTO {vc_forestry_3player_harvest_table} (min_resource_level,max_resource_level,individual_harvest_level) values(3,5,1)"); - db_query("INSERT INTO {vc_forestry_3player_harvest_table} (min_resource_level,max_resource_level,individual_harvest_level) values(0,2,0)"); - - //assign the students turn for stage 2 of forestry - db_query("CREATE TABLE {vc_forestry_student_turn} ( - id INT NOT NULL AUTO_INCREMENT, - vc_student_id varchar(14) NOT NULL, - vc_stage_id INT NOT NULL, - vc_student_group_id INT NOT NULL, - - - PRIMARY KEY(id), - - FOREIGN KEY(vc_student_id) REFERENCES vc_student(id) - ON DELETE CASCADE, - - FOREIGN KEY(vc_stage_id) REFERENCES vc_stage(id) - ON DELETE CASCADE, - - FOREIGN KEY(vc_student_group_id) REFERENCES vc_student(group_id) - ON DELETE CASCADE - - - ) /*!40100 DEFAULT CHARACTER SET UTF8 */"); - - - - $flag=TRUE; - - - - break; - default: - drupal_set_message(t('Unsupported Database')); + break; + default: + drupal_set_message(t('Unsupported Database')); } if($flag) { - drupal_set_message(t('Experiment core tables is successfully created.')); + drupal_set_message(t('Experiment core tables successfully created.')); } else { - drupal_set_message(t('Experiment core tables is NOT successfully created.'),'error'); + drupal_set_message(t('Experiment core tables NOT created.'),'error'); } } @@ -296,17 +180,13 @@ */ function experiment_uninstall() { - db_query("DROP TABLE {vc_forestry_3player_harvest_table}"); - db_query("DROP TABLE {vc_forestry_4player_harvest_table}"); - db_query("DROP TABLE {vc_forestry_5player_harvest_table}"); + db_query("DROP TABLE {vc_student}"); + db_query("DROP TABLE {vc_group}"); + + db_query("DROP TABLE {vc_game}"); + db_query("DROP TABLE {vc_rules}"); + db_query("DROP TABLE {vc_stage}"); + db_query("DROP TABLE {vc_experiment}"); - db_query("DROP TABLE {vc_forestry_common_resource_pool}"); - db_query("DROP TABLE {vc_student}"); - db_query("DROP TABLE {vc_group}"); - db_query("DROP TABLE {vc_game}"); - db_query("DROP TABLE {vc_rules}"); - db_query("DROP TABLE {vc_stage}"); - db_query("DROP TABLE {vc_experiment}"); - - drupal_set_message(t('Experiment core tables were successfully deleted from the database. We hope.')); + drupal_set_message(t('Experiment core tables were successfully deleted from the database. We hope.')); } Modified: vcweb/trunk/virtualcommons/experiment/experiment.module =================================================================== --- vcweb/trunk/virtualcommons/experiment/experiment.module 2008-07-30 22:59:46 UTC (rev 18) +++ vcweb/trunk/virtualcommons/experiment/experiment.module 2008-08-01 01:19:07 UTC (rev 19) @@ -2,8 +2,9 @@ // vim:sts=2:sw=2:filetype=php // $Id$ -//$path=drupal_get_filename('module', 'virtualcommons'); -//include('teacher.php'); // or require etc. +//$path=drupal_get_filename('module', 'vcweb'); +//ini_set('include_path', '.:/classes'); +include_once ('experiment.inc'); // or require etc. //include('sites/all/modules/virtualcommons/experiment/class_files/teacher.php'); /** @@ -40,13 +41,13 @@ 'type'=>MENU_CALLBACK, 'access' => user_access('Only Teachers') ); - $items[]=array( 'path' => 'game_start', + /* $items[]=array( 'path' => 'game_start', // 'title' => t('Forestry Game - Stage 1'), 'callback'=>'game_start', // 'callback argument' => array('forestry_game_stage1_part2'), 'type'=>MENU_CALLBACK, 'access' => user_access('Only Teachers') - ); + );*/ } return $items; } @@ -147,8 +148,17 @@ { $teacher_id=$GLOBALS['user']->uid; $game_name=$form_values['games']; - $no_student=$form_values['no_student']; - if(!isset($_SESSION['no_of_student'])) + $no_student=(int) $form_values['no_student']; + + $game=new Game(); + $game->setExpId($game_name); + $game->setTeacherId($teacher_id); + $game->setStageId(1); + $game->setNoOfStudent($no_student); + $game->setRoundNo(1); + $game->saveGame(); + + if(!isset($_SESSION['no_of_student'])) { $_SESSION['no_student']=$no_student; } @@ -160,7 +170,7 @@ } - //Fishery + /* //Fishery if($game_name==1) { $result=db_result(db_query("Select id from {virtualcommons_experiments} where exp_name LIKE '%%Fishery%%' ")); @@ -184,7 +194,8 @@ drupal_set_message(t('Thanks for filling out the form. Your Game will start soon. ')); - 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); + //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); + //echo 'Thanks for filling out the form. Your Game will start soon,'. $fname; return 'studentgroup'; } @@ -263,47 +274,54 @@ $var=10; $group_no=1; + // FIXME: duplicated algorithm for generating student ids if($groups_5 <> 0) { for($i=0;$i<$groups_5;$i++) { + $groupArray = array(); for($j=0;$j<5;$j++) { $stud_id=uniqid(rand(0,9), false); $row[]=array('Group '.$group_no,$stud_id); - $row_submit[]=array($group_no,$stud_id); + $groupArray[] = $stud_id; - } +// $row_submit[]=array($group_no,$stud_id); - $group_no++; + } + $row_submit[$group_no++] = $groupArray; } } if($groups_4 <> 0) { for($i=0;$i<$groups_4;$i++) { + $groupArray = array(); for($j=0;$j<4;$j++) { $stud_id=uniqid(rand(0,9),false); $row[]=array('Group '.$group_no,$stud_id); - $row_submit[]=array($group_no,$stud_id); + $groupArray[] = $stud_id; +// $row_submit[]=array($group_no,$stud_id); } - $group_no++; + $row_submit[$group_no++] = $groupArray; } } if($groups_3 <> 0) { for($i=0;$i<$groups_3;$i++) { + $groupArray = array(); for($j=0;$j<3;$j++) { $stud_id=uniqid(rand(0,9), false); $row[]=array('Group '.$group_no,$stud_id); - $row_submit[]=array($group_no,$stud_id); + $groupArray[] = $stud_id; +// $row_submit[]=array($group_no,$stud_id); } - $group_no++; + $row_submit[$group_no++] = $groupArray; } } @@ -363,54 +381,21 @@ } - +// invoked after groups have already been created and the teacher clicks +// "start game" function studentgroup_submit($form_id, $form_values) { //put it in the database student $id=$GLOBALS['user']->uid; $table=$_SESSION['student_info']; - $virtual_conduct_id=db_result(db_query("select max(id),users_id from {virtualcommons_conducts} where users_id=%d group by users_id",$id)); - $turn=array('1','2','3','4','5'); - $prev_group_no=0; - $temp=-1; - $i=0; - foreach ($table as $key=>$value) - { - drupal_set_message(t('Key is: %key<br>',array('%key'=>$i))); - foreach ($value as $key=>$value) - { + $game=new Game(); + $game->setTeacherId($id); + $virtual_conduct_id=$game->getGameID(); + $game->saveGroupStudent($table); - if($key==0) - { - $group_no=$value; - if($temp <> $group_no) - { - $temp=$group_no; - $i=0; - } - - - } - else if($key==1) - { - $stud_id=$value; - drupal_set_message(t('Group Id is %group Student id is: %value Turn id is %turn',array('%turn'=>$turn[$i],'%value'=>$stud_id,'%group'=>$group_no))); - db_query("Insert into {virtualcommons_student} (id,group_no,virtualcommons_conducts_id,start_flag,turn_no) values('%s',%d,%d,false,%d)",$stud_id,$group_no,$virtual_conduct_id,$turn[$i]); - - - /* db_query("insert into {virtualcommons_forestry_student_turn} - (turn_no,virtualcommons_student_id,virtualcommons_stage_id,virtualcommons_student_group_no) - values('%s','%s',2,%d)",$turn[$i],$stud_id,$group_no);*/ - - $i++; - - } - - } - } - + //depending upon the experiment game, assign the resource table to each group. $exp_name=$_SESSION['game_name']; if($exp_name==1) @@ -422,35 +407,9 @@ else if($exp_name==2) { //$exp_name="Forestry Game"; - $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); - - while($data=db_fetch_object($result_group)) - { - $no_of_student=$data->cnt; - $group_no=$data->group_no; - //drupal_set_message(t($no_of_student.' '. $group_no)); - if($no_of_student == 5) - { - db_query("Insert into {virtualcommons_forestry_common_resource_pool} (virtualcommons_student_group_no,common_resource_pool,virtualcommons_conducts_id, harvest_decision,max_harvest_decision) - values(%d,%d,%d,%d,%d)",$group_no,100,$virtual_conduct_id,0,100); - - } - - else if($no_of_student == 4) - { - db_query("Insert into {virtualcommons_forestry_common_resource_pool} (virtualcommons_student_group_no,common_resource_pool,virtualcommons_conducts_id, harvest_decision,max_harvest_decision) - values(%d,%d,%d,%d,%d)",$group_no,80,$virtual_conduct_id,0,80); - } - - - else if($no_of_student == 3) - { - db_query("Insert into {virtualcommons_forestry_common_resource_pool} (virtualcommons_student_group_no,common_resource_pool,virtualcommons_conducts_id, harvest_decision,max_harvest_decision) values(%d,%d,%d,%d,%d)",$group_no,60,$virtual_conduct_id,0,60); - } - - } - + $game->initForestry(); } + else if($exp_name==3) { $exp_name="Water Irrigation Game"; @@ -458,15 +417,19 @@ unset($_SESSION['student_info']); unset($_SESSION['game_name']); + + //set flag=1 in vc_student and allow them to play + $flag=1; + $game->updateStartFlag($flag); - return 'game_start'; + return 'teacher_dashboard'; } -function game_start() +/*function game_start() { $output=t('Please click the Start Game button.'); $output.=drupal_get_form('game_start_form'); @@ -490,5 +453,5 @@ db_query("update virtualcommons_student set start_flag=true where virtualcommons_conducts_id=%d",$virtual_conduct_id); return 'teacher_dashboard'; -} +}*/ Added: vcweb/trunk/virtualcommons/experiment/init-experiment.sql =================================================================== --- vcweb/trunk/virtualcommons/experiment/init-experiment.sql (rev 0) +++ vcweb/trunk/virtualcommons/experiment/init-experiment.sql 2008-08-01 01:19:07 UTC (rev 19) @@ -0,0 +1,62 @@ +db_query("insert into {vc_experiment} (name) values('Fishery Game')"); +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,'No',3)"); +db_query("insert into { vc_stage} (stage_no,vc_experiment_id,no_of_rounds,voting,no_of_practice_rounds) values(2,1,10,'Yes',0)"); +db_query("insert into { vc_stage} (stage_no,vc_experiment_id,no_of_rounds,voting,no_of_practice_rounds) values(1,2,10,'No',3)"); +db_query("insert into { vc_stage} (stage_no,vc_experiment_id,no_of_rounds,voting,no_of_practice_rounds) values(2,2,10,'Yes',0)"); +db_query("insert into { vc_stage} (stage_no,vc_experiment_id,no_of_rounds,voting,no_of_practice_rounds) values(1,3,10,'No',3)"); +db_query("insert into { vc_stage} (stage_no,vc_experiment_id,no_of_rounds,voting,no_of_practice_rounds) values(2,3,10,'Yes',0)"); + +db_query("insert into { vc_rules} (vc_stage_id,rule_no,name,description) values(1,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(1,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 +Round 3 ban in B +Round 4 ban in B +Round 5 ban in A +Round 6 ban in A +Round 7 ban in B +Round 8 ban in B +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(1,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(2,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(2,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 +Round 4: extracts wood the player B, C +Round 5: extracts wood the player D, E +Round 6: extracts wood the player A, B +Round 7: extracts wood the player C, D +Round 8 extracts wood the player E, A +Round 9: extracts wood the player B, C +Round 10: extracts wood the player D, E + +If this rule is chosen, players get randomly a character A, B, C, D or E. player 1 may for example get turn D. + +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(2,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(3,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(3,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 +Round 4: DEABC +Round 5: EABCD +Round 6: ABCDE +Round 7: BCDEA +Round 8: CDEAB +Round 9: DEABC +Round 10: EABCD')"); +db_query("insert into { vc_rules} (vc_stage_id,rule_no,name,description) values(3,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.')"); + + + + + Modified: vcweb/trunk/virtualcommons/experiment/student_login/student_login.module =================================================================== --- vcweb/trunk/virtualcommons/experiment/student_login/student_login.module 2008-07-30 22:59:46 UTC (rev 18) +++ vcweb/trunk/virtualcommons/experiment/student_login/student_login.module 2008-08-01 01:19:07 UTC (rev 19) @@ -1,9 +1,12 @@ <?php // $Id$ +// vim:sts=2:sw=2:filetype=php /** * implement the _user hook. */ +include_once('./' . drupal_get_path('module', 'experiment') . '/experiment.inc'); + function student_login_perm() { return array('Only Students'); @@ -19,7 +22,7 @@ 'path' => 'student_login', 'title' => t('Student Login'), 'callback' => 'drupal_get_form', - 'callback arguments'=>array(student_login_nameform), + 'callback arguments'=>array(student_login_nameform), 'access' => TRUE//user_access('Only Students') ); @@ -28,47 +31,52 @@ return $items; } function student_login_nameform() { -$form = array(); -$form['#id']='student_form'; -$form['student_info'] = array( - '#title' => t('Student Information'), - '#type' => 'fieldset', -'#description'=>t('Please enter correct the student ID, you received from your teacher.') + $form = array(); + $form['#id']='student_form'; + $form['student_info'] = array( + '#title' => t('Student Information'), + '#type' => 'fieldset', + '#description'=>t('Please enter correct the student ID, you received from your teacher.') -); -$form['student_info']['id'] = array( - '#title' => t('Enter the Student ID'), - '#type' => 'textfield', - '#required'=>TRUE + ); + $form['student_info']['id'] = array( + '#title' => t('Enter the Student ID'), + '#type' => 'textfield', + '#required'=>TRUE -); + ); -$form['submit'] = array( - '#type' => 'submit', - '#value' => t('Start Game!!!') -); -return $form; + $form['submit'] = array( + '#type' => 'submit', + '#value' => t('Start Game!!!') + ); + return $form; } function student_login_nameform_validate($form_id,$form_values) { -$stud_id=$form_values['id']; -$result=db_result(db_query("Select id from {virtualcommons_student} where id='%s'",$stud_id)); + $stud_id=$form_values['id']; + $group = Group::checkStudentId($stud_id); + if ($group) { + // set the game object into the session, currently only contains the + // game_id + $_SESSION['group'] = serialize($group); + } + else { + form_set_error('id',t('Invalid Student ID. Please contact your instructor.')); + } -if($result=='') - 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']; + $_SESSION['student_id']=$form_values['id']; -return 'forestry'; + return 'forestry'; } Added: vcweb/trunk/virtualcommons/experiment/survey-questions.sql =================================================================== --- vcweb/trunk/virtualcommons/experiment/survey-questions.sql (rev 0) +++ vcweb/trunk/virtualcommons/experiment/survey-questions.sql 2008-08-01 01:19:07 UTC (rev 19) @@ -0,0 +1,119 @@ +insert into vc_survey(vc_experiment_id,date_of_creation) values('1','2008-07-01'); +insert into vc_survey(vc_experiment_id,date_of_creation) values('2','2008-07-01'); +insert into vc_survey(vc_experiment_id,date_of_creation) values('3','2008-07-01'); + +insert into vc_survey_questions(vc_survey_id,vc_rules_id,questions) values(1,1,'How efficient do you think this rule is for managing the fishing grounds?'); +insert into vc_survey_questions(vc_survey_id,vc_rules_id,questions) values(1,1,'How fair do you think this rule is for managing the fishing grounds? '); +insert into vc_survey_questions(vc_survey_id,vc_rules_id,questions) values(1,1,'How much personal freedom do you think this rule allows you in managing the fishing grounds?'); +insert into vc_survey_questions(vc_survey_id,vc_rules_id,questions) values(1,1,'How much do you think this rule would advance your own self-interest as measured by your total earning?'); +insert into vc_survey_questions(vc_survey_id,vc_rules_id,questions) values(1,1,'All things considered how attractive do you find this rule?'); + +insert into vc_survey_questions(vc_survey_id,vc_rules_id,questions) values(1,2,'How efficient do you think this rule is for managing the fishing grounds?'); +insert into vc_survey_questions(vc_survey_id,vc_rules_id,questions) values(1,2,'How fair do you think this rule is for managing the fishing grounds? '); +insert into vc_survey_questions(vc_survey_id,vc_rules_id,questions) values(1,2,'How much personal freedom do you think this rule allows you in managing the fishing grounds?'); +insert into vc_survey_questions(vc_survey_id,vc_rules_id,questions) values(1,2,'How much do you think this rule would advance your own self-interest as measured by your total earning?'); +insert into vc_survey_questions(vc_survey_id,vc_rules_id,questions) values(1,2,'All things considered how attractive do you find this rule?'); + +insert into vc_survey_questions(vc_survey_id,vc_rules_id,questions) values(1,3,'How efficient do you think this rule is for managing the fishing grounds?'); +insert into vc_survey_questions(vc_survey_id,vc_rules_id,questions) values(1,3,'How fair do you think this rule is for managing the fishing grounds? '); +insert into vc_survey_questions(vc_survey_id,vc_rules_id,questions) values(1,3,'How much personal freedom do you think this rule allows you in managing the fishing grounds?'); +insert into vc_survey_questions(vc_survey_id,vc_rules_id,questions) values(1,3,'How much do you think this rule would advance your own self-interest as measured by your total earning?'); +insert into vc_survey_questions(vc_survey_id,vc_rules_id,questions) values(1,3,'All things considered how attractive do you find this rule?'); + +insert into vc_survey_questions(vc_survey_id,vc_rules_id,questions) values(2,4,'How efficient do you think this rule is for managing the forest?'); +insert into vc_survey_questions(vc_survey_id,vc_rules_id,questions) values(2,4,'How fair do you think this rule is for managing the forest? '); +insert into vc_survey_questions(vc_survey_id,vc_rules_id,questions) values(2,4,'How much personal freedom do you think this rule allows you in managing the forest?'); +insert into vc_survey_questions(vc_survey_id,vc_rules_id,questions) values(2,4,'How much do you think this rule would advance your own self-interest as measured by your total earning?'); +insert into vc_survey_questions(vc_survey_id,vc_rules_id,questions) values(2,4,'All things considered how attractive do you find this rule?'); + + +insert into vc_survey_questions(vc_survey_id,vc_rules_id,questions) values(2,5,'How efficient do you think this rule is for managing the forest?'); +insert into vc_survey_questions(vc_survey_id,vc_rules_id,questions) values(2,5,'How fair do you think this rule is for managing the forest? '); +insert into vc_survey_questions(vc_survey_id,vc_rules_id,questions) values(2,5,'How much personal freedom do you think this rule allows you in managing the forest?'); +insert into vc_survey_questions(vc_survey_id,vc_rules_id,questions) values(2,5,'How much do you think this rule would advance your own self-interest as measured by your total earning?'); +insert into vc_survey_questions(vc_survey_id,vc_rules_id,questions) values(2,5,'All things considered how attractive do you find this rule?'); + + +insert into vc_survey_questions(vc_survey_id,vc_rules_id,questions) values(2,6,'How efficient do you think this rule is for managing the fishing grounds?'); +insert into vc_survey_questions(vc_survey_id,vc_rules_id,questions) values(2,6,'How fair do you think this rule is for managing the fishing grounds? '); +insert into vc_survey_questions(vc_survey_id,vc_rules_id,questions) values(2,6,'How much personal freedom do you think this rule allows you in managing the fishing grounds?'); +insert into vc_survey_questions(vc_survey_id,vc_rules_id,questions) values(2,6,'How much do you think this rule would advance your own self-interest as measured by your total earning?'); +insert into vc_survey_questions(vc_survey_id,vc_rules_id,questions) values(2,6,'All things considered how attractive do you find this rule?'); + + +insert into vc_survey_questions(vc_survey_id,vc_rules_id,questions) values(3,7,'How efficient do you think this rule is for managing the irrigation system?'); +insert into vc_survey_questions(vc_survey_id,vc_rules_id,questions) values(3,7,'How fair do you think this rule is for managing the irrigation system? '); +insert into vc_survey_questions(vc_survey_id,vc_rules_id,questions) values(3,7,'How much personal freedom do you think this rule allows you in managing the irrigation system?'); +insert into vc_survey_questions(vc_survey_id,vc_rules_id,questions) values(3,7,'How much do you think this rule would advance your own self-interest as measured by your total earning?'); +insert into vc_survey_questions(vc_survey_id,vc_rules_id,questions) values(3,7,'All things considered how attractive do you find this rule?'); + + +insert into vc_survey_questions(vc_survey_id,vc_rules_id,questions) values(3,8,'How efficient do you think this rule is for managing the irrigation system?'); +insert into vc_survey_questions(vc_survey_id,vc_rules_id,questions) values(3,8,'How fair do you think this rule is for managing the irrigation system? '); +insert into vc_survey_questions(vc_survey_id,vc_rules_id,questions) values(3,8,'How much personal freedom do you think this rule allows you in managing the irrigation system?'); +insert into vc_survey_questions(vc_survey_id,vc_rules_id,questions) values(3,8,'How much do you think this rule would advance your own self-interest as measured by your total earning?'); +insert into vc_survey_questions(vc_survey_id,vc_rules_id,questions) values(3,8,'All things considered how attractive do you find this rule?'); + + +insert into vc_survey_questions(vc_survey_id,vc_rules_id,questions) values(3,9,'How efficient do you think this rule is for managing the irrigation system?'); +insert into vc_survey_questions(vc_survey_id,vc_rules_id,questions) values(3,9,'How fair do you think this rule is for managing the irrigation system? '); +insert into vc_survey_questions(vc_survey_id,vc_rules_id,questions) values(3,9,'How much personal freedom do you think this rule allows you in managing the irrigation system?'); +insert into vc_survey_questions(vc_survey_id,vc_rules_id,questions) values(3,9,'How much do you think this rule would advance your own self-interest as measured by your total earning?'); +insert into vc_survey_questions(vc_survey_id,vc_rules_id,questions) values(3,9,'All things considered how attractive do you find this rule?'); + +insert into vc_survey_questions_options(vc_survey_questions_id,min_value,max_value) values(1,'not at all efficient','very efficient'); +insert into vc_survey_questions_options(vc_survey_questions_id,min_value,max_value) values(2,'not at all fair','very fair'); +insert into vc_survey_questions_options(vc_survey_questions_id,min_value,max_value) values(3,'no freedom at all','complete freedom'); +insert into vc_survey_questions_options(vc_survey_questions_id,min_value,max_value) values(4,'not at all','very much'); +insert into vc_survey_questions_options(vc_survey_questions_id,min_value,max_value) values(5,'not attractive at all','Very attractive'); + +insert into vc_survey_questions_options(vc_survey_questions_id,min_value,max_value) values(6,'not at all efficient','very efficient'); +insert into vc_survey_questions_options(vc_survey_questions_id,min_value,max_value) values(7,'not at all fair','very fair'); +insert into vc_survey_questions_options(vc_survey_questions_id,min_value,max_value) values(8,'no freedom at all','complete freedom'); +insert into vc_survey_questions_options(vc_survey_questions_id,min_value,max_value) values(9,'not at all','very much'); +insert into vc_survey_questions_options(vc_survey_questions_id,min_value,max_value) values(10,'not attractive at all','Very attractive'); + +insert into vc_survey_questions_options(vc_survey_questions_id,min_value,max_value) values(11,'not at all efficient','very efficient'); +insert into vc_survey_questions_options(vc_survey_questions_id,min_value,max_value) values(12,'not at all fair','very fair'); +insert into vc_survey_questions_options(vc_survey_questions_id,min_value,max_value) values(13,'no freedom at all','complete freedom'); +insert into vc_survey_questions_options(vc_survey_questions_id,min_value,max_value) values(14,'not at all','very much'); +insert into vc_survey_questions_options(vc_survey_questions_id,min_value,max_value) values(15,'not attractive at all','Very attractive'); + + +insert into vc_survey_questions_options(vc_survey_questions_id,min_value,max_value) values(16,'not at all efficient','very efficient'); +insert into vc_survey_questions_options(vc_survey_questions_id,min_value,max_value) values(17,'not at all fair','very fair'); +insert into vc_survey_questions_options(vc_survey_questions_id,min_value,max_value) values(18,'no freedom at all','complete freedom'); +insert into vc_survey_questions_options(vc_survey_questions_id,min_value,max_value) values(19,'not at all','very much'); +insert into vc_survey_questions_options(vc_survey_questions_id,min_value,max_value) values(20,'not attractive at all','Very attractive'); + + +insert into vc_survey_questi... [truncated message content] |
From: <al...@us...> - 2008-07-30 22:59:37
|
Revision: 18 http://virtualcommons.svn.sourceforge.net/virtualcommons/?rev=18&view=rev Author: alllee Date: 2008-07-30 22:59:46 +0000 (Wed, 30 Jul 2008) Log Message: ----------- no longer used, user module + profile module is employed instead Removed Paths: ------------- vcweb/trunk/virtualcommons/teacherform/ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <al...@us...> - 2008-07-30 22:56:27
|
Revision: 17 http://virtualcommons.svn.sourceforge.net/virtualcommons/?rev=17&view=rev Author: alllee Date: 2008-07-30 22:56:29 +0000 (Wed, 30 Jul 2008) Log Message: ----------- adding svn properties and Seema completed the working basic experiment.install schema Modified Paths: -------------- vcweb/trunk/virtualcommons/experiment/student_login/student_login.info vcweb/trunk/virtualcommons/games/teacher_dashboard/teacher_dashboard.install Added Paths: ----------- vcweb/trunk/virtualcommons/experiment/experiment.info vcweb/trunk/virtualcommons/experiment/experiment.install vcweb/trunk/virtualcommons/experiment/experiment.module Removed Paths: ------------- vcweb/trunk/virtualcommons/experiment/core/ Property Changed: ---------------- vcweb/trunk/virtualcommons/autoassignrole/.project vcweb/trunk/virtualcommons/autoassignrole/.settings/org.eclipse.php.core.prefs vcweb/trunk/virtualcommons/autoassignrole/.settings/org.eclipse.php.core.projectOptions.prefs vcweb/trunk/virtualcommons/autoassignrole/LICENSE.txt vcweb/trunk/virtualcommons/autoassignrole/README.txt vcweb/trunk/virtualcommons/autoassignrole/autoassignrole.info vcweb/trunk/virtualcommons/autoassignrole/autoassignrole.install vcweb/trunk/virtualcommons/autoassignrole/autoassignrole.module vcweb/trunk/virtualcommons/experiment/student_login/student_login.info vcweb/trunk/virtualcommons/experiment/student_login/student_login.module vcweb/trunk/virtualcommons/games/fishery/fishery_info/fishery_info.info vcweb/trunk/virtualcommons/games/fishery/fishery_info/fishery_info.module vcweb/trunk/virtualcommons/games/forestry/forestry_game/forestry_game.info vcweb/trunk/virtualcommons/games/forestry/forestry_game/forestry_game.install vcweb/trunk/virtualcommons/games/forestry/forestry_game/forestry_game.module vcweb/trunk/virtualcommons/games/forestry/forestry_info/forestry_info.info vcweb/trunk/virtualcommons/games/forestry/forestry_info/forestry_info.module vcweb/trunk/virtualcommons/games/forestry/forestry_stage1/forestry_stage1.info vcweb/trunk/virtualcommons/games/forestry/forestry_stage1/forestry_stage1.module vcweb/trunk/virtualcommons/games/forestry/forestry_stage1/form.css vcweb/trunk/virtualcommons/games/forestry/forestry_stage1/theme/forestry_stage1.tpl.php vcweb/trunk/virtualcommons/games/forestry/forestry_stage1/theme/form.css vcweb/trunk/virtualcommons/games/forestry/forestry_stage1/theme/template.php vcweb/trunk/virtualcommons/games/forestry/forestry_stage2/forestry_stage2.info vcweb/trunk/virtualcommons/games/forestry/forestry_stage2/forestry_stage2.install vcweb/trunk/virtualcommons/games/forestry/forestry_stage2/forestry_stage2.module vcweb/trunk/virtualcommons/games/forestry/forestry_stage2/theme/forestry_stage2.tpl.php vcweb/trunk/virtualcommons/games/forestry/forestry_stage2/theme/form.css vcweb/trunk/virtualcommons/games/forestry/forestry_stage2/theme/template.php vcweb/trunk/virtualcommons/games/rules/form.css vcweb/trunk/virtualcommons/games/rules/rules.info vcweb/trunk/virtualcommons/games/rules/rules.module vcweb/trunk/virtualcommons/games/teacher_dashboard/teacher_dashboard.info vcweb/trunk/virtualcommons/games/teacher_dashboard/teacher_dashboard.install vcweb/trunk/virtualcommons/games/teacher_dashboard/teacher_dashboard.module vcweb/trunk/virtualcommons/games/water/water_info/water_info.info vcweb/trunk/virtualcommons/games/water/water_info/water_info.module vcweb/trunk/virtualcommons/teacherform/teacherform.info vcweb/trunk/virtualcommons/teacherform/teacherform.install vcweb/trunk/virtualcommons/teacherform/teacherform.module vcweb/trunk/virtualcommons/try/try.info vcweb/trunk/virtualcommons/try/try.module Property changes on: vcweb/trunk/virtualcommons/autoassignrole/.project ___________________________________________________________________ Added: svn:keywords + Date Id Revision Property changes on: vcweb/trunk/virtualcommons/autoassignrole/.settings/org.eclipse.php.core.prefs ___________________________________________________________________ Added: svn:keywords + Date Id Revision Property changes on: vcweb/trunk/virtualcommons/autoassignrole/.settings/org.eclipse.php.core.projectOptions.prefs ___________________________________________________________________ Added: svn:keywords + Date Id Revision Property changes on: vcweb/trunk/virtualcommons/autoassignrole/LICENSE.txt ___________________________________________________________________ Added: svn:keywords + Date Id Revision Property changes on: vcweb/trunk/virtualcommons/autoassignrole/README.txt ___________________________________________________________________ Added: svn:keywords + Date Id Revision Property changes on: vcweb/trunk/virtualcommons/autoassignrole/autoassignrole.info ___________________________________________________________________ Added: svn:keywords + Date Id Revision Property changes on: vcweb/trunk/virtualcommons/autoassignrole/autoassignrole.install ___________________________________________________________________ Added: svn:keywords + Date Id Revision Property changes on: vcweb/trunk/virtualcommons/autoassignrole/autoassignrole.module ___________________________________________________________________ Added: svn:keywords + Date Id Revision Added: vcweb/trunk/virtualcommons/experiment/experiment.info =================================================================== --- vcweb/trunk/virtualcommons/experiment/experiment.info (rev 0) +++ vcweb/trunk/virtualcommons/experiment/experiment.info 2008-07-30 22:56:29 UTC (rev 17) @@ -0,0 +1,6 @@ +; $Id$ +name = Experiment Core +description = Provides core essential experiment functionality and metadata +package=Virtual Commons +version = "$Rev$" + Property changes on: vcweb/trunk/virtualcommons/experiment/experiment.info ___________________________________________________________________ Added: svn:keywords + Date Id Revision Added: vcweb/trunk/virtualcommons/experiment/experiment.install =================================================================== --- vcweb/trunk/virtualcommons/experiment/experiment.install (rev 0) +++ vcweb/trunk/virtualcommons/experiment/experiment.install 2008-07-30 22:56:29 UTC (rev 17) @@ -0,0 +1,312 @@ +<?php +// vim:sts=2:sw=2:filetype=php +// $Id$ +/** + * Implementation of hook_install(). + */ + +function experiment_install() { + switch ($GLOBALS['db_type']) { + case 'mysql': + case 'mysqli': + db_query("CREATE TABLE {vc_experiment} + ( + id INT AUTO_INCREMENT, + name varchar(255) NOT NULL, + description MEDIUMTEXT, + PRIMARY KEY(id) + ) ENGINE=InnoDB /*!40100 DEFAULT CHARACTER SET UTF8 */"); + db_query("CREATE TABLE {vc_stage} + ( + id INT AUTO_INCREMENT, + stage_no INT NOT NULL, + no_of_rounds INT NOT NULL, + voting BOOL DEFAULT false, + no_of_practice_rounds INT DEFAULT 0, + vc_experiment_id INT NOT NULL, + + PRIMARY KEY(id), + + 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} + ( + id INT AUTO_INCREMENT, + rule_no INT NOT NULL, + vc_stage_id INT NOT NULL, + rule_description TEXT, + name enum('Lottery', 'Rotation', 'Property Rights'), + + PRIMARY KEY(id), + + 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} + ( + id INT AUTO_INCREMENT, + users_id INT NOT NULL, + vc_experiment_id INT NOT NULL, + date_created TIMESTAMP NOT NULL, + no_of_students INT NOT NULL, + vc_stage_id INT NOT NULL, + current_round_no INT 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) + + ) ENGINE=InnoDB /*!40100 DEFAULT CHARACTER SET UTF8 */"); + + db_query("CREATE TABLE {vc_group} + ( + id INT AUTO_INCREMENT, + group_no INT NOT NULL, + vc_game_id INT NOT NULL, + vc_stage_id INT NOT NULL, + vc_selected_rules_id INT NULL, + + PRIMARY KEY(id), + + FOREIGN KEY(vc_game_id) REFERENCES vc_game(id), + FOREIGN KEY(vc_stage_id) REFERENCES vc_stage(id), + FOREIGN KEY(vc_selected_rules_id) REFERENCES vc_rules(id) + + + ) ENGINE=InnoDB /*!40100 DEFAULT CHARACTER SET UTF8 */"); + + db_query("CREATE TABLE {vc_student} + ( + id varchar(14), + vc_group_id INT NOT NULL, + vc_game_id INT NOT NULL, + start_flag BOOL default false, + turn_no INT NOT NULL, + + PRIMARY KEY(id), + + + FOREIGN KEY(vc_group_id) REFERENCES vc_group(id), + FOREIGN KEY(vc_game_id) REFERENCES vc_game(id) + + ) ENGINE=InnoDB /*!40100 DEFAULT CHARACTER SET UTF8 */"); + + db_query("CREATE TABLE {vc_forestry_common_resource_pool} + ( + id INT AUTO_INCREMENT, + vc_group_id INT NOT NULL, + common_resource_pool INT NOT NULL, + harvest_decision INT NOT NULL, + vc_game_id INT NOT NULL, + max_harvest_decision INT NOT NULL, + + + PRIMARY KEY(id), + FOREIGN KEY(vc_group_id) REFERENCES vc_group(id) + ON DELETE CASCADE, + + FOREIGN KEY(vc_game_id) REFERENCES vc_game(id) + ON DELETE CASCADE + + + + )ENGINE=InnoDB /*!40100 DEFAULT CHARACTER SET UTF8 */"); + + + + //Forestry Game Harvest Tables. + db_query("CREATE TABLE {vc_forestry_5player_harvest_table} ( + id INT AUTO_INCREMENT, + min_resource_level INT NOT NULL, + max_resource_level INT NOT NULL, + individual_harvest_level INT NOT NULL, + + PRIMARY KEY(id) + + )ENGINE=InnoDB /*!40100 DEFAULT CHARACTER SET UTF8 */"); + + + db_query("INSERT INTO {vc_forestry_5player_harvest_table} (min_resource_level,max_resource_level,individual_harvest_level) values(25,100,5)"); + db_query("INSERT INTO {vc_forestry_5player_harvest_table} (min_resource_level,max_resource_level,individual_harvest_level) values(20,24,4)"); + db_query("INSERT INTO {vc_forestry_5player_harvest_table} (min_resource_level,max_resource_level,individual_harvest_level) values(15,19,3)"); + db_query("INSERT INTO {vc_forestry_5player_harvest_table} (min_resource_level,max_resource_level,individual_harvest_level) values(10,14,2)"); + db_query("INSERT INTO {vc_forestry_5player_harvest_table} (min_resource_level,max_resource_level,individual_harvest_level) values(5,9,1)"); + db_query("INSERT INTO {vc_forestry_5player_harvest_table} (min_resource_level,max_resource_level,individual_harvest_level) values(0,4,0)"); + + + + db_query("CREATE TABLE {vc_forestry_4player_harvest_table} ( + id INT AUTO_INCREMENT, + min_resource_level INT NOT NULL, + max_resource_level INT NOT NULL, + individual_harvest_level INT NOT NULL, + + PRIMARY KEY(id) + + )ENGINE=InnoDB /*!40100 DEFAULT CHARACTER SET UTF8 */"); + + + db_query("INSERT INTO {vc_forestry_4player_harvest_table} (min_resource_level,max_resource_level,individual_harvest_level) values(20,80,5)"); + db_query("INSERT INTO {vc_forestry_4player_harvest_table} (min_resource_level,max_resource_level,individual_harvest_level) values(16,19,4)"); + db_query("INSERT INTO {vc_forestry_4player_harvest_table} (min_resource_level,max_resource_level,individual_harvest_level) values(12,15,3)"); + db_query("INSERT INTO {vc_forestry_4player_harvest_table} (min_resource_level,max_resource_level,individual_harvest_level) values(8,11,2)"); + db_query("INSERT INTO {vc_forestry_4player_harvest_table} (min_resource_level,max_resource_level,individual_harvest_level) values(4,7,1)"); + db_query("INSERT INTO {vc_forestry_4player_harvest_table} (min_resource_level,max_resource_level,individual_harvest_level) values(0,3,0)"); + + db_query("CREATE TABLE {vc_forestry_3player_harvest_table} ( + id INT AUTO_INCREMENT, + min_resource_level INT NOT NULL, + max_resource_level INT NOT NULL, + individual_harvest_level INT NOT NULL, + + PRIMARY KEY(id) + + )ENGINE=InnoDB /*!40100 DEFAULT CHARACTER SET UTF8 */"); + + db_query("INSERT INTO {vc_forestry_3player_harvest_table} (min_resource_level,max_resource_level,individual_harvest_level) values(15,60,5)"); + db_query("INSERT INTO {vc_forestry_3player_harvest_table} (min_resource_level,max_resource_level,individual_harvest_level) values(12,14,4)"); + db_query("INSERT INTO {vc_forestry_3player_harvest_table} (min_resource_level,max_resource_level,individual_harvest_level) values(9,11,3)"); + db_query("INSERT INTO {vc_forestry_3player_harvest_table} (min_resource_level,max_resource_level,individual_harvest_level) values(6,8,2)"); + db_query("INSERT INTO {vc_forestry_3player_harvest_table} (min_resource_level,max_resource_level,individual_harvest_level) values(3,5,1)"); + db_query("INSERT INTO {vc_forestry_3player_harvest_table} (min_resource_level,max_resource_level,individual_harvest_level) values(0,2,0)"); + + + $flag=TRUE; + + break; + case 'pgsql': + db_query("CREATE TABLE {vc_student} ( + + id varchar(14) NOT NULL, + group_id INT NOT NULL, + vc_game_id INT NOT NULL, + + PRIMARY KEY(id), + + FOREIGN KEY(vc_game_id) REFERENCES vc_game(id) + ON DELETE CASCADE + )"); + + //Forestry Game Harvest Tables. + db_query("CREATE TABLE {vc_forestry_5player_harvest_table} ( + id INT NOT NULL AUTO_INCREMENT, + min_resource_level INT NOT NULL, + max_resource_level INT NOT NULL, + individual_harvest_level INT NOT NULL, + + PRIMARY KEY(id) + + ) /*!40100 DEFAULT CHARACTER SET UTF8 */"); + + + db_query("INSERT INTO {vc_forestry_5player_harvest_table} (min_resource_level,max_resource_level,individual_harvest_level) values(25,100,5)"); + db_query("INSERT INTO {vc_forestry_5player_harvest_table} (min_resource_level,max_resource_level,individual_harvest_level) values(20,24,4)"); + db_query("INSERT INTO {vc_forestry_5player_harvest_table} (min_resource_level,max_resource_level,individual_harvest_level) values(15,19,3)"); + db_query("INSERT INTO {vc_forestry_5player_harvest_table} (min_resource_level,max_resource_level,individual_harvest_level) values(10,14,2)"); + db_query("INSERT INTO {vc_forestry_5player_harvest_table} (min_resource_level,max_resource_level,individual_harvest_level) values(5,9,1)"); + db_query("INSERT INTO {vc_forestry_5player_harvest_table} (min_resource_level,max_resource_level,individual_harvest_level) values(0,4,0)"); + + + + db_query("CREATE TABLE {vc_forestry_4player_harvest_table} ( + id INT NOT NULL AUTO_INCREMENT, + min_resource_level INT NOT NULL, + max_resource_level INT NOT NULL, + individual_harvest_level INT NOT NULL, + + PRIMARY KEY(id) + + ) /*!40100 DEFAULT CHARACTER SET UTF8 */"); + + + db_query("INSERT INTO {vc_forestry_4player_harvest_table} (min_resource_level,max_resource_level,individual_harvest_level) values(20,80,5)"); + db_query("INSERT INTO {vc_forestry_4player_harvest_table} (min_resource_level,max_resource_level,individual_harvest_level) values(16,19,4)"); + db_query("INSERT INTO {vc_forestry_4player_harvest_table} (min_resource_level,max_resource_level,individual_harvest_level) values(12,15,3)"); + db_query("INSERT INTO {vc_forestry_4player_harvest_table} (min_resource_level,max_resource_level,individual_harvest_level) values(8,11,2)"); + db_query("INSERT INTO {vc_forestry_4player_harvest_table} (min_resource_level,max_resource_level,individual_harvest_level) values(4,7,1)"); + db_query("INSERT INTO {vc_forestry_4player_harvest_table} (min_resource_level,max_resource_level,individual_harvest_level) values(0,3,0)"); + + + + + db_query("CREATE TABLE {vc_forestry_3player_harvest_table} ( + id INT NOT NULL AUTO_INCREMENT, + min_resource_level INT NOT NULL, + max_resource_level INT NOT NULL, + individual_harvest_level INT NOT NULL, + + PRIMARY KEY(id) + + ) /*!40100 DEFAULT CHARACTER SET UTF8 */"); + + db_query("INSERT INTO {vc_forestry_3player_harvest_table} (min_resource_level,max_resource_level,individual_harvest_level) values(15,60,5)"); + db_query("INSERT INTO {vc_forestry_3player_harvest_table} (min_resource_level,max_resource_level,individual_harvest_level) values(12,14,4)"); + db_query("INSERT INTO {vc_forestry_3player_harvest_table} (min_resource_level,max_resource_level,individual_harvest_level) values(9,11,3)"); + db_query("INSERT INTO {vc_forestry_3player_harvest_table} (min_resource_level,max_resource_level,individual_harvest_level) values(6,8,2)"); + db_query("INSERT INTO {vc_forestry_3player_harvest_table} (min_resource_level,max_resource_level,individual_harvest_level) values(3,5,1)"); + db_query("INSERT INTO {vc_forestry_3player_harvest_table} (min_resource_level,max_resource_level,individual_harvest_level) values(0,2,0)"); + + //assign the students turn for stage 2 of forestry + db_query("CREATE TABLE {vc_forestry_student_turn} ( + id INT NOT NULL AUTO_INCREMENT, + vc_student_id varchar(14) NOT NULL, + vc_stage_id INT NOT NULL, + vc_student_group_id INT NOT NULL, + + + PRIMARY KEY(id), + + FOREIGN KEY(vc_student_id) REFERENCES vc_student(id) + ON DELETE CASCADE, + + FOREIGN KEY(vc_stage_id) REFERENCES vc_stage(id) + ON DELETE CASCADE, + + FOREIGN KEY(vc_student_group_id) REFERENCES vc_student(group_id) + ON DELETE CASCADE + + + ) /*!40100 DEFAULT CHARACTER SET UTF8 */"); + + + + $flag=TRUE; + + + + break; + default: + drupal_set_message(t('Unsupported Database')); + } + if($flag) + { + drupal_set_message(t('Experiment core tables is successfully created.')); + } + else + { + drupal_set_message(t('Experiment core tables is NOT successfully created.'),'error'); + } +} + +/** + * Implementation of hook_uninstall(). + */ +function experiment_uninstall() { + + db_query("DROP TABLE {vc_forestry_3player_harvest_table}"); + db_query("DROP TABLE {vc_forestry_4player_harvest_table}"); + db_query("DROP TABLE {vc_forestry_5player_harvest_table}"); + + db_query("DROP TABLE {vc_forestry_common_resource_pool}"); + db_query("DROP TABLE {vc_student}"); + db_query("DROP TABLE {vc_group}"); + db_query("DROP TABLE {vc_game}"); + db_query("DROP TABLE {vc_rules}"); + db_query("DROP TABLE {vc_stage}"); + db_query("DROP TABLE {vc_experiment}"); + + drupal_set_message(t('Experiment core tables were successfully deleted from the database. We hope.')); +} Property changes on: vcweb/trunk/virtualcommons/experiment/experiment.install ___________________________________________________________________ Added: svn:keywords + Date Id Revision Added: vcweb/trunk/virtualcommons/experiment/experiment.module =================================================================== --- vcweb/trunk/virtualcommons/experiment/experiment.module (rev 0) +++ vcweb/trunk/virtualcommons/experiment/experiment.module 2008-07-30 22:56:29 UTC (rev 17) @@ -0,0 +1,494 @@ +<?php +// vim:sts=2:sw=2:filetype=php +// $Id$ + +//$path=drupal_get_filename('module', 'virtualcommons'); +//include('teacher.php'); // or require etc. +//include('sites/all/modules/virtualcommons/experiment/class_files/teacher.php'); + +/** + * implements the _user hook. + **/ + + + +function experiment_perm() +{ + return array('Only Teachers'); + +} + +// $Id$ +/** + * Implementation of hook_menu(). + */ +function experiment_menu($may_cache) { + $items = array(); + if ($may_cache) { + $items[] = array( + 'path' => 'experiment', + 'title' => t('Experiments'), + 'callback' => 'experiment_page', + 'type'=>MENU_CALLBACK, + 'access' => user_access('Only Teachers') + ); + $items[] = array( + 'path' => 'studentgroup', + 'title' => t('Student Information'), + 'callback' => 'drupal_get_form', + 'callback arguments'=>array(studentgroup), + 'type'=>MENU_CALLBACK, + 'access' => user_access('Only Teachers') + ); + $items[]=array( 'path' => 'game_start', + // 'title' => t('Forestry Game - Stage 1'), + 'callback'=>'game_start', + // 'callback argument' => array('forestry_game_stage1_part2'), + 'type'=>MENU_CALLBACK, + 'access' => user_access('Only Teachers') + ); + } + return $items; +} +/** + * Called when user goes to example.com/?q=experiment + */ +function experiment_page() { + $output = t('Please submit the following form in order to conduct the experiments in the class.'); + // Return the HTML generated from the $form data structure. + $output .= drupal_get_form('experiment_nameform'); + return $output; +} +/** + * Defines a form. + */ +function experiment_nameform() { + + $form['#method']='post'; + //+$form['#action']='http://localhost/drupal/?q=studentgroup'; + $form['#id']='experiment'; + $form['no_student'] = array( + '#title' => t('How many Students are participating'), + '#type' => 'textfield', + '#description' => t('Depending on the number of students groups will be formed.'), + '#required'=>TRUE + + ); + + $form['games']=array( + '#type'=>'select', + '#title'=>'Select the Game from the following experiments', + '#default_value'=>variable_get('games',0), + '#options'=> array(t('Choose One '),t('Fishery Game'),t('Forestry Game'),t('Water Irrigation Game')), + '#required'=>TRUE + + ); + + + $form['terms_usage']=array( + '#type'=>'fieldset', + //'#title'=>t('Terms of Usage') + ); + + + $form['terms_usage']['info']=array( + + '#type'=>'item', + '#title'=>t('Terms and conditions'), + '#description'=>t('<p>Material on this site is used only for educational purpose. None of the material on this site may be used for any other purpose. <br/>All rights reserved and granted by Dr Marco Janssen.</p>') + ); + + + $form['terms_usage']['agree'] = array( + '#type' => 'radios', + '#options' => array(t('I Agree'),t('I Disagree')), + '#title'=>t('By selecting the "I Agree" option, you certifiy that you are agree above terms of use'), + '#default_value'=>variable_get('agree',1), + + + ); + $form['submit'] = array( + '#type' => 'submit', + '#value' => t('Submit') + ); + + + + return $form; +} +/** + * Validate the form. + */ +function experiment_nameform_validate($form_id, $form_values) +{ + + // We notify the form API that this field has failed validation. + if ($form_values['games'] == 0) + { + form_set_error('games', + t('Please choose the game.')); + } + if($form_values['agree']==1) + { + form_set_error('agree',t('You have to agree the terms before you play any game.')); + } + + //To Check for numbers. + if(preg_match('/[^0-9]+/',$form_values['no_student'])) + { + form_set_error('no_student',t('Number of experiments can not be alphabets. ')); + } + +} +/** + * Handle post-validation form submission. + */ +function experiment_nameform_submit($form_id, $form_values) +{ + $teacher_id=$GLOBALS['user']->uid; + $game_name=$form_values['games']; + $no_student=$form_values['no_student']; + if(!isset($_SESSION['no_of_student'])) + { + $_SESSION['no_student']=$no_student; + } + + + if(!isset($_SESSION['game_name'])) + { + $_SESSION['game_name']=$game_name; + } + + + //Fishery + if($game_name==1) + { + $result=db_result(db_query("Select id from {virtualcommons_experiments} where exp_name LIKE '%%Fishery%%' ")); + } + //Forestry + else if($game_name==2) + { + $result=db_result(db_query("Select id from {virtualcommons_experiments} where exp_name LIKE '%%Forestry%%' ")); + } + + //Water Irrigation + else if($game_name==3) + { + $result=db_result(db_query("Select id from {virtualcommons_experiments} where exp_name LIKE '%%Water%%' ")); + } + + /*$teacher=new Teacher($result,'talele'); + $fname=$teacher->getfname(); + $lname=$teacher->getlname();*/ + + + drupal_set_message(t('Thanks for filling out the form. Your Game will start soon. ')); + + 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); + //echo 'Thanks for filling out the form. Your Game will start soon,'. $fname; + return 'studentgroup'; +} + +/** Old studentgroup module code cut'n'paste job */ +/** + * Called when user goes to example.com/?q=studentgroup + */ + +function studentgroup() +{ + + $form['#id']='studentgroup'; + $exp_name=$_SESSION['game_name']; + $no=$_SESSION['no_student']; + //unset($_SESSION['game_name']); + unset($_SESSION['no_student']); + + //drupal_set_message(t('Game name is %exp_name .<br> No of Students are %no',array('%exp_name'=>$exp_name,'%no'=>$no))); + if($exp_name==1) + $exp_name="Fishery Game"; + else if($exp_name==2) + $exp_name="Forestry Game"; + else if($exp_name==3) + $exp_name="Water Irrigation Game"; + + //$no=$_POST['no_student']; + $no_of_student=(int)$no; + $no_of_groups=0; + $groups_3=0; + $groups_4=0; + $groups_5=0; + $header = array('Group ID', 'Student ID'); + + //no of groups + $groups_5=((int)($no_of_student/5)); + + $x= $no_of_student%5; + + if($x==0) + { + $no_of_groups=$groups_5; + } + else if($x==1) + { + $groups_5=$groups_5-1; + $groups_3=2; + $no_of_groups=$groups_5 + $groups_3; + } + + else if($x==2) + { + $groups_5=$groups_5-1; + $groups_3=1; + $groups_4=1; + $no_of_groups=$groups_5 + $groups_3 + $groups_4; + } + else if($x==3) + { + + $groups_3=1; + $no_of_groups=$groups_3 + $groups_5; + } + + else if($x==4) + { + + $groups_4=1; + $no_of_groups=$groups_4 + $groups_5; + } + + $no_student5=5*$groups_5; + $no_student4=4*$groups_4; + $no_student3=3*$groups_3; + + $var=10; + $group_no=1; + + if($groups_5 <> 0) + { + for($i=0;$i<$groups_5;$i++) + { + for($j=0;$j<5;$j++) + { + $stud_id=uniqid(rand(0,9), false); + $row[]=array('Group '.$group_no,$stud_id); + $row_submit[]=array($group_no,$stud_id); + + } + + $group_no++; + } + } + if($groups_4 <> 0) + { + for($i=0;$i<$groups_4;$i++) + { + for($j=0;$j<4;$j++) + { + $stud_id=uniqid(rand(0,9),false); + $row[]=array('Group '.$group_no,$stud_id); + $row_submit[]=array($group_no,$stud_id); + + } + + $group_no++; + } + } + if($groups_3 <> 0) + { + for($i=0;$i<$groups_3;$i++) + { + for($j=0;$j<3;$j++) + { + $stud_id=uniqid(rand(0,9), false); + $row[]=array('Group '.$group_no,$stud_id); + $row_submit[]=array($group_no,$stud_id); + } + $group_no++; + } + } + + + if(!isset($_SESSION['student_info'])) + { + $_SESSION['student_info']=$row_submit; + /*foreach ($_SESSION['student_info'] as $key=>$value) + { + drupal_set_message(t('Key is: %key<br>',array('%key'=>$key))); + foreach ($value as $key=>$value) + { + drupal_set_message(t('Key inner is: %key<br> Value inner is: %value',array('%key'=>$key,'%value'=>$value))); + } + }*/ + } + + + $form['game_info']=array( + '#type'=>'fieldset', + '#title'=>t('Experiment Information'), + '#tree' => TRUE + ); + + + $form['game_info']['info']=array( + '#title'=>t('Please note the following information carefully.'), + '#type'=>'item', + '#description'=>t('<h3>Name of Experiments: '.$exp_name.'<br/>No of Students: '.$no_of_student.'<br/>No of Groups: '.$no_of_groups.'</h3>') + ); + + $form['group_info']=array( + '#type'=>'fieldset', + '#title'=>t('Group Information'), + '#tree' => TRUE + ); + + $form['group_info']['info1']=array( + '#title'=>t('Please assign the following Student IDs to the students.Please do not tell Group IDs to them. After assigning Student IDs, you can tell students to sign using Student Login Page.'), + '#description'=>t('<h3>Number of group of 3 Students: '.$groups_3.'<br/>Number of group of 4 Students: '.$groups_4.'<br/>Number of group of 5 Students: '.$groups_5.'</h3>'), + '#type'=>'item' + + ); + + $form['group_info']['table_info']=array( + + '#type'=>'markup', + '#value'=>theme('table',$header,$row) + ); + + $form['submit'] = array( + '#type' => 'submit', + '#value' => t('Start Game!!!') + ); + + return $form; +} + + + +function studentgroup_submit($form_id, $form_values) +{ + //put it in the database student + + $id=$GLOBALS['user']->uid; + $table=$_SESSION['student_info']; + $virtual_conduct_id=db_result(db_query("select max(id),users_id from {virtualcommons_conducts} where users_id=%d group by users_id",$id)); + $turn=array('1','2','3','4','5'); + $prev_group_no=0; + $temp=-1; + $i=0; + foreach ($table as $key=>$value) + { + + drupal_set_message(t('Key is: %key<br>',array('%key'=>$i))); + foreach ($value as $key=>$value) + { + + if($key==0) + { + $group_no=$value; + if($temp <> $group_no) + { + $temp=$group_no; + $i=0; + } + + + } + else if($key==1) + { + $stud_id=$value; + drupal_set_message(t('Group Id is %group Student id is: %value Turn id is %turn',array('%turn'=>$turn[$i],'%value'=>$stud_id,'%group'=>$group_no))); + db_query("Insert into {virtualcommons_student} (id,group_no,virtualcommons_conducts_id,start_flag,turn_no) values('%s',%d,%d,false,%d)",$stud_id,$group_no,$virtual_conduct_id,$turn[$i]); + + + /* db_query("insert into {virtualcommons_forestry_student_turn} + (turn_no,virtualcommons_student_id,virtualcommons_stage_id,virtualcommons_student_group_no) + values('%s','%s',2,%d)",$turn[$i],$stud_id,$group_no);*/ + + $i++; + + } + + } + } + + //depending upon the experiment game, assign the resource table to each group. + $exp_name=$_SESSION['game_name']; + if($exp_name==1) + { + //$exp_name="Fishery Game"; + + } + + else if($exp_name==2) + { + //$exp_name="Forestry Game"; + $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); + + while($data=db_fetch_object($result_group)) + { + $no_of_student=$data->cnt; + $group_no=$data->group_no; + //drupal_set_message(t($no_of_student.' '. $group_no)); + if($no_of_student == 5) + { + db_query("Insert into {virtualcommons_forestry_common_resource_pool} (virtualcommons_student_group_no,common_resource_pool,virtualcommons_conducts_id, harvest_decision,max_harvest_decision) + values(%d,%d,%d,%d,%d)",$group_no,100,$virtual_conduct_id,0,100); + + } + + else if($no_of_student == 4) + { + db_query("Insert into {virtualcommons_forestry_common_resource_pool} (virtualcommons_student_group_no,common_resource_pool,virtualcommons_conducts_id, harvest_decision,max_harvest_decision) + values(%d,%d,%d,%d,%d)",$group_no,80,$virtual_conduct_id,0,80); + } + + + else if($no_of_student == 3) + { + db_query("Insert into {virtualcommons_forestry_common_resource_pool} (virtualcommons_student_group_no,common_resource_pool,virtualcommons_conducts_id, harvest_decision,max_harvest_decision) values(%d,%d,%d,%d,%d)",$group_no,60,$virtual_conduct_id,0,60); + } + + } + + } + else if($exp_name==3) + { + $exp_name="Water Irrigation Game"; + } + + unset($_SESSION['student_info']); + unset($_SESSION['game_name']); + + return 'game_start'; + +} + + + + +function game_start() +{ + $output=t('Please click the Start Game button.'); + $output.=drupal_get_form('game_start_form'); + return $output; +} + + +function game_start_form() +{ + $form['submit'] = array( + '#type' => 'submit', + '#value' => t('Start Game!!!') + ); + return $form; +} + +function game_start_form_submit($form_id,$form_values) +{ + $teacher_id=$GLOBALS['user']->uid; + $virtual_conduct_id=db_result(db_query("select max(id),users_id from {virtualcommons_conducts} where users_id=%d group by users_id",$teacher_id)); + + db_query("update virtualcommons_student set start_flag=true where virtualcommons_conducts_id=%d",$virtual_conduct_id); + return 'teacher_dashboard'; +} + Property changes on: vcweb/trunk/virtualcommons/experiment/experiment.module ___________________________________________________________________ Added: svn:keywords + Date Id Revision Modified: vcweb/trunk/virtualcommons/experiment/student_login/student_login.info =================================================================== --- vcweb/trunk/virtualcommons/experiment/student_login/student_login.info 2008-07-30 19:39:33 UTC (rev 16) +++ vcweb/trunk/virtualcommons/experiment/student_login/student_login.info 2008-07-30 22:56:29 UTC (rev 17) @@ -1,6 +1,8 @@ ; $Id$ name =Student Registration Form description = Allows students to register at virtual Commons using this registration form. +dependencies = experiment + package=Virtual Commons version = "student v1.1" Property changes on: vcweb/trunk/virtualcommons/experiment/student_login/student_login.info ___________________________________________________________________ Added: svn:keywords + Date Id Revision Property changes on: vcweb/trunk/virtualcommons/experiment/student_login/student_login.module ___________________________________________________________________ Added: svn:keywords + Date Id Revision Property changes on: vcweb/trunk/virtualcommons/games/fishery/fishery_info/fishery_info.info ___________________________________________________________________ Added: svn:keywords + Date Id Revision Property changes on: vcweb/trunk/virtualcommons/games/fishery/fishery_info/fishery_info.module ___________________________________________________________________ Added: svn:keywords + Date Id Revision Property changes on: vcweb/trunk/virtualcommons/games/forestry/forestry_game/forestry_game.info ___________________________________________________________________ Added: svn:keywords + Date Id Revision Property changes on: vcweb/trunk/virtualcommons/games/forestry/forestry_game/forestry_game.install ___________________________________________________________________ Added: svn:keywords + Date Id Revision Property changes on: vcweb/trunk/virtualcommons/games/forestry/forestry_game/forestry_game.module ___________________________________________________________________ Added: svn:keywords + Date Id Revision Property changes on: vcweb/trunk/virtualcommons/games/forestry/forestry_info/forestry_info.info ___________________________________________________________________ Added: svn:keywords + Date Id Revision Property changes on: vcweb/trunk/virtualcommons/games/forestry/forestry_info/forestry_info.module ___________________________________________________________________ Added: svn:keywords + Date Id Revision Property changes on: vcweb/trunk/virtualcommons/games/forestry/forestry_stage1/forestry_stage1.info ___________________________________________________________________ Added: svn:keywords + Date Id Revision Property changes on: vcweb/trunk/virtualcommons/games/forestry/forestry_stage1/forestry_stage1.module ___________________________________________________________________ Added: svn:keywords + Date Id Revision Property changes on: vcweb/trunk/virtualcommons/games/forestry/forestry_stage1/form.css ___________________________________________________________________ Added: svn:keywords + Date Id Revision Property changes on: vcweb/trunk/virtualcommons/games/forestry/forestry_stage1/theme/forestry_stage1.tpl.php ___________________________________________________________________ Added: svn:keywords + Date Id Revision Property changes on: vcweb/trunk/virtualcommons/games/forestry/forestry_stage1/theme/form.css ___________________________________________________________________ Added: svn:keywords + Date Id Revision Property changes on: vcweb/trunk/virtualcommons/games/forestry/forestry_stage1/theme/template.php ___________________________________________________________________ Added: svn:keywords + Date Id Revision Property changes on: vcweb/trunk/virtualcommons/games/forestry/forestry_stage2/forestry_stage2.info ___________________________________________________________________ Added: svn:keywords + Date Id Revision Property changes on: vcweb/trunk/virtualcommons/games/forestry/forestry_stage2/forestry_stage2.install ___________________________________________________________________ Added: svn:keywords + Date Id Revision Property changes on: vcweb/trunk/virtualcommons/games/forestry/forestry_stage2/forestry_stage2.module ___________________________________________________________________ Added: svn:keywords + Date Id Revision Property changes on: vcweb/trunk/virtualcommons/games/forestry/forestry_stage2/theme/forestry_stage2.tpl.php ___________________________________________________________________ Added: svn:keywords + Date Id Revision Property changes on: vcweb/trunk/virtualcommons/games/forestry/forestry_stage2/theme/form.css ___________________________________________________________________ Added: svn:keywords + Date Id Revision Property changes on: vcweb/trunk/virtualcommons/games/forestry/forestry_stage2/theme/template.php ___________________________________________________________________ Added: svn:keywords + Date Id Revision Property changes on: vcweb/trunk/virtualcommons/games/rules/form.css ___________________________________________________________________ Added: svn:keywords + Date Id Revision Property changes on: vcweb/trunk/virtualcommons/games/rules/rules.info ___________________________________________________________________ Added: svn:keywords + Date Id Revision Property changes on: vcweb/trunk/virtualcommons/games/rules/rules.module ___________________________________________________________________ Added: svn:keywords + Date Id Revision Property changes on: vcweb/trunk/virtualcommons/games/teacher_dashboard/teacher_dashboard.info ___________________________________________________________________ Added: svn:keywords + Date Id Revision Modified: vcweb/trunk/virtualcommons/games/teacher_dashboard/teacher_dashboard.install =================================================================== --- vcweb/trunk/virtualcommons/games/teacher_dashboard/teacher_dashboard.install 2008-07-30 19:39:33 UTC (rev 16) +++ vcweb/trunk/virtualcommons/games/teacher_dashboard/teacher_dashboard.install 2008-07-30 22:56:29 UTC (rev 17) @@ -0,0 +1,78 @@ + +<?php +function teacher_dashboard_install() + { + switch ($GLOBALS['db_type']) + { + case 'mysql': + case 'mysqli': + db_query("CREATE TABLE {vc_forestry_group_round_info} + ( + id int NOT NULL AUTO_INCREMENT, + round_no int NOT NULL, + vc_game_id int NOT NULL, + vc_group_id int NOT NULL, + total_harvest_decision int NOT NULL, + resources_before int NOT NULL, + resources_after int NOT NULL, + vc_rules_id int NOT NULL, + dice int default 0, + + + PRIMARY KEY(id), + + FOREIGN KEY(vc_group_id) REFERENCES vc_group(group_id) + ON DELETE CASCADE, + + FOREIGN KEY(vc_game_id) REFERENCES vc_game(id) + ON DELETE CASCADE, + + FOREIGN KEY(vc_rules_id) REFERENCES vc_rules(id) + ON DELETE CASCADE + + + )ENGINE=InnoDB /*!40100 DEFAULT CHARACTER SET UTF8 */"); + + $flag=TRUE; + + break; + case 'pgsql': + db_query("CREATE TABLE {vc_forestry_group_round_info} + ( + id int NOT NULL AUTO_INCREMENT, + round_no int NOT NULL, + vc_game_id int NOT NULL, + vc_group_id int NOT NULL, + total_harvest_decision int NOT NULL, + resources_before int NOT NULL, + resources_after int NOT NULL, + vc_rules_id int NOT NULL, + dice int default 0, + + + PRIMARY KEY(id), + + FOREIGN KEY(vc_group_id) REFERENCES vc_group(group_id) + ON DELETE CASCADE, + + FOREIGN KEY(vc_game_id) REFERENCES vc_game(id) + ON DELETE CASCADE, + + FOREIGN KEY(vc_rules_id) REFERENCES vc_rules(id) + ON DELETE CASCADE + + + ) /*!40100 DEFAULT CHARACTER SET UTF8 */"); + + $flag=TRUE; + + break; +} +} + +function experiment_uninstall() +{ + + db_query("DROP TABLE {vc_forestry_group_round_info}"); + drupal_set_message(t('Forestry Group Round Information is successfully deleted from the database. We hope.')); +} Property changes on: vcweb/trunk/virtualcommons/games/teacher_dashboard/teacher_dashboard.install ___________________________________________________________________ Added: svn:keywords + Date Id Revision Property changes on: vcweb/trunk/virtualcommons/games/teacher_dashboard/teacher_dashboard.module ___________________________________________________________________ Added: svn:keywords + Date Id Revision Property changes on: vcweb/trunk/virtualcommons/games/water/water_info/water_info.info ___________________________________________________________________ Added: svn:keywords + Date Id Revision Property changes on: vcweb/trunk/virtualcommons/games/water/water_info/water_info.module ___________________________________________________________________ Added: svn:keywords + Date Id Revision Property changes on: vcweb/trunk/virtualcommons/teacherform/teacherform.info ___________________________________________________________________ Added: svn:keywords + Date Id Revision Property changes on: vcweb/trunk/virtualcommons/teacherform/teacherform.install ___________________________________________________________________ Added: svn:keywords + Date Id Revision Property changes on: vcweb/trunk/virtualcommons/teacherform/teacherform.module ___________________________________________________________________ Added: svn:keywords + Date Id Revision Property changes on: vcweb/trunk/virtualcommons/try/try.info ___________________________________________________________________ Added: svn:keywords + Date Id Revision Property changes on: vcweb/trunk/virtualcommons/try/try.module ___________________________________________________________________ Added: svn:keywords + Date Id Revision This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <al...@us...> - 2008-07-30 19:39:30
|
Revision: 16 http://virtualcommons.svn.sourceforge.net/virtualcommons/?rev=16&view=rev Author: alllee Date: 2008-07-30 19:39:33 +0000 (Wed, 30 Jul 2008) Log Message: ----------- adding schema definition for updated virtual commons web experiments TODO finish other table definitions in experiment.install Modified Paths: -------------- vcweb/trunk/virtualcommons/experiment/core/experiment.install Added Paths: ----------- vcweb/trunk/virtualcommons/games/teacher_dashboard/teacher_dashboard.info vcweb/trunk/virtualcommons/games/teacher_dashboard/teacher_dashboard.install vcweb/trunk/virtualcommons/games/teacher_dashboard/teacher_dashboard.module Removed Paths: ------------- vcweb/trunk/virtualcommons/games/teacher_dashboard/teacher.info vcweb/trunk/virtualcommons/games/teacher_dashboard/teacher.install vcweb/trunk/virtualcommons/games/teacher_dashboard/teacher.module Modified: vcweb/trunk/virtualcommons/experiment/core/experiment.install =================================================================== --- vcweb/trunk/virtualcommons/experiment/core/experiment.install 2008-07-30 18:48:28 UTC (rev 15) +++ vcweb/trunk/virtualcommons/experiment/core/experiment.install 2008-07-30 19:39:33 UTC (rev 16) @@ -8,264 +8,324 @@ switch ($GLOBALS['db_type']) { case 'mysql': case 'mysqli': - db_query("CREATE TABLE {virtualcommons_student} - ( - id varchar(14) NOT NULL, - group_no int NOT NULL, - virtualcommons_conducts_id int NOT NULL, - start_flag BOOL default false, - turn_no varchar(1) NOT NULL, + db_query("CREATE TABLE {vc_experiment} + ( + id INT NOT NULL AUTO_INCREMENT, + name varchar(255) NOT NULL, + description mediumtext + ) ENGINE=InnoDB /*!40100 DEFAULT CHARACTER SET UTF8 */"); + db_query("CREATE TABLE {vc_stage} + ( + id INT NOT NULL AUTO_INCREMENT, + stage_no INT NOT NULL, + no_of_rounds INT NOT NULL, + voting BOOL DEFAULT false, + no_of_practice_rounds INT DEFAULT 0, + vc_experiment_id INT NOT NULL, - PRIMARY KEY(id), + FOREIGN KEY (vc_experiment_id) REFERENCES vc_experiment(id) ON DELETE CASCADE - FOREIGN KEY(virtualcommons_conducts_id) REFERENCES virtualcommons_conducts(id) - ON DELETE CASCADE + ) ENGINE=InnoDB /*!40100 DEFAULT CHARACTER SET UTF8 */"); + db_query("CREATE TABLE {vc_rules} + ( + id INT NOT NULL AUTO_INCREMENT, + rule_no INT NOT NULL, + vc_stage_id INT NOT NULL, + rule_description TEXT, + name enum('Lottery', 'Rotation', 'Property Rights'), - ) TYPE=InnoDB /*!40100 DEFAULT CHARACTER SET UTF8 */"); + FOREIGN KEY (vc_stage_id) REFERENCES vc_stage(id) ON DELETE CASCADE - db_query("CREATE TABLE {virtualcommons_forestry_common_resource_pool} - ( - id int NOT NULL AUTO_INCREMENT, - virtualcommons_student_group_no int NOT NULL, - common_resource_pool int NOT NULL, - harvest_decision int NOT NULL, - virtualcommons_conducts_id int NOT NULL, - max_harvest_decision int NOT NULL, + ) ENGINE=InnoDB /*!40100 DEFAULT CHARACTER SET UTF8 */"); + db_query("CREATE TABLE {vc_game} + ( + id INT PRIMARY KEY AUTO_INCREMENT, + users_id INT NOT NULL, + vc_experiment_id INT NOT NULL, + date_created TIMESTAMP NOT NULL, + no_of_students INT NOT NULL, + vc_stage_id INT NOT NULL, + current_round_no INT NOT NULL, + FOREIGN KEY(users_id) REFERENCES users(id), + FOREIGN KEY(vc_experiment_id) REFERENCES vc_experiment(id) ON DELETE CASCADE, - PRIMARY KEY(id), - FOREIGN KEY(virtualcommons_student_group_no) REFERENCES virtualcommons_student(group_no) - 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} + ( + id INT PRIMARY KEY AUTO_INCREMENT, + group_no INT NOT NULL, + vc_game_id INT NOT NULL, + vc_stage_id INT NOT NULL, + vc_selected_rules_id INT NULL, - FOREIGN KEY(virtualcommons_conducts_id) REFERENCES virtualcommons_conducts(id) - ON DELETE CASCADE + FOREIGN KEY(vc_game_id) REFERENCES vc_game(id), + FOREIGN KEY(vc_stage_id) REFERENCES vc_stage(id), + FOREIGN KEY(vc_selected_rules_id) REFERENCES vc_rules(id) + ) ENGINE=InnoDB /*!40100 DEFAULT CHARACTER SET UTF8 */"); - ) /*!40100 DEFAULT CHARACTER SET UTF8 */"); + db_query("CREATE TABLE {vc_student} + ( + id varchar(14) NOT NULL, + vc_group_id INT NOT NULL, + vc_game_id INT NOT NULL, + start_flag BOOL default false, + turn_no INT NOT NULL, + PRIMARY KEY(id), + FOREIGN KEY(vc_game_id) REFERENCES vc_game(id), + FOREIGN KEY(vc_group_id) REFERENCES vc_group(id) + ) ENGINE=InnoDB /*!40100 DEFAULT CHARACTER SET UTF8 */"); - db_query("CREATE TABLE {virtualcommons_forestry_group_information} - ( - id int NOT NULL AUTO_INCREMENT, - round_no int NOT NULL, - virtualcommons_conducts_id int NOT NULL, - virtualcommons_student_group_no int NOT NULL, - total_harvest_decision int NOT NULL, - resources_before int NOT NULL, - resources_after int NOT NULL, - virtualcommons_stage_no int NOT NULL, - virtualcommons_rules_no int(1), - dice int(1) , + db_query("CREATE TABLE {virtualcommons_forestry_common_resource_pool} + ( + id int NOT NULL AUTO_INCREMENT, + virtualcommons_student_group_no int NOT NULL, + common_resource_pool int NOT NULL, + harvest_decision int NOT NULL, + virtualcommons_conducts_id int NOT NULL, + max_harvest_decision int NOT NULL, - PRIMARY KEY(id), - FOREIGN KEY(virtualcommons_student_group_no) REFERENCES virtualcommons_student(group_no) - ON DELETE CASCADE, - FOREIGN KEY(virtualcommons_conducts_id) REFERENCES virtualcommons_conducts(id) - ON DELETE CASCADE, + PRIMARY KEY(id), + FOREIGN KEY(virtualcommons_student_group_no) REFERENCES virtualcommons_student(group_no) + ON DELETE CASCADE, - FOREIGN KEY(virtualcommons_stage_no) REFERENCES virtualcommons_stage(stage_no) - ON DELETE CASCADE, + FOREIGN KEY(virtualcommons_conducts_id) REFERENCES virtualcommons_conducts(id) + ON DELETE CASCADE - FOREIGN KEY(virtualcommons_rules_no) REFERENCES virtualcommons_rules(rule_no) - ON DELETE CASCADE ) /*!40100 DEFAULT CHARACTER SET UTF8 */"); - //Forestry Game Harvest Tables. - db_query("CREATE TABLE {virtualcommons_forestry_5player_harvest_table} ( - id int NOT NULL AUTO_INCREMENT, - min_resource_level int NOT NULL, - max_resource_level int NOT NULL, - individual_harvest_level int NOT NULL, - PRIMARY KEY(id) - ) /*!40100 DEFAULT CHARACTER SET UTF8 */"); + db_query("CREATE TABLE {virtualcommons_forestry_group_information} + ( + id int NOT NULL AUTO_INCREMENT, + round_no int NOT NULL, + virtualcommons_conducts_id int NOT NULL, + virtualcommons_student_group_no int NOT NULL, + total_harvest_decision int NOT NULL, + resources_before int NOT NULL, + resources_after int NOT NULL, + virtualcommons_stage_no int NOT NULL, + virtualcommons_rules_no int(1), + dice int(1) , - db_query("Insert into {virtualcommons_forestry_5player_harvest_table} (min_resource_level,max_resource_level,individual_harvest_level) values(25,100,5)"); - db_query("Insert into {virtualcommons_forestry_5player_harvest_table} (min_resource_level,max_resource_level,individual_harvest_level) values(20,24,4)"); - db_query("Insert into {virtualcommons_forestry_5player_harvest_table} (min_resource_level,max_resource_level,individual_harvest_level) values(15,19,3)"); - db_query("Insert into {virtualcommons_forestry_5player_harvest_table} (min_resource_level,max_resource_level,individual_harvest_level) values(10,14,2)"); - db_query("Insert into {virtualcommons_forestry_5player_harvest_table} (min_resource_level,max_resource_level,individual_harvest_level) values(5,9,1)"); - db_query("Insert into {virtualcommons_forestry_5player_harvest_table} (min_resource_level,max_resource_level,individual_harvest_level) values(0,4,0)"); + PRIMARY KEY(id), + FOREIGN KEY(virtualcommons_student_group_no) REFERENCES virtualcommons_student(group_no) + ON DELETE CASCADE, + FOREIGN KEY(virtualcommons_conducts_id) REFERENCES virtualcommons_conducts(id) + ON DELETE CASCADE, - db_query("CREATE TABLE {virtualcommons_forestry_4player_harvest_table} ( - id int NOT NULL AUTO_INCREMENT, - min_resource_level int NOT NULL, - max_resource_level int NOT NULL, - individual_harvest_level int NOT NULL, + FOREIGN KEY(virtualcommons_stage_no) REFERENCES virtualcommons_stage(stage_no) + ON DELETE CASCADE, - PRIMARY KEY(id) + FOREIGN KEY(virtualcommons_rules_no) REFERENCES virtualcommons_rules(rule_no) + ON DELETE CASCADE - ) /*!40100 DEFAULT CHARACTER SET UTF8 */"); + ) /*!40100 DEFAULT CHARACTER SET UTF8 */"); - db_query("Insert into {virtualcommons_forestry_4player_harvest_table} (min_resource_level,max_resource_level,individual_harvest_level) values(20,80,5)"); - db_query("Insert into {virtualcommons_forestry_4player_harvest_table} (min_resource_level,max_resource_level,individual_harvest_level) values(16,19,4)"); - db_query("Insert into {virtualcommons_forestry_4player_harvest_table} (min_resource_level,max_resource_level,individual_harvest_level) values(12,15,3)"); - db_query("Insert into {virtualcommons_forestry_4player_harvest_table} (min_resource_level,max_resource_level,individual_harvest_level) values(8,11,2)"); - db_query("Insert into {virtualcommons_forestry_4player_harvest_table} (min_resource_level,max_resource_level,individual_harvest_level) values(4,7,1)"); - db_query("Insert into {virtualcommons_forestry_4player_harvest_table} (min_resource_level,max_resource_level,individual_harvest_level) values(0,3,0)"); + //Forestry Game Harvest Tables. + db_query("CREATE TABLE {virtualcommons_forestry_5player_harvest_table} ( + id int NOT NULL AUTO_INCREMENT, + min_resource_level int NOT NULL, + max_resource_level int NOT NULL, + individual_harvest_level int NOT NULL, - db_query("CREATE TABLE {virtualcommons_forestry_3player_harvest_table} ( - id int NOT NULL AUTO_INCREMENT, - min_resource_level int NOT NULL, - max_resource_level int NOT NULL, - individual_harvest_level int NOT NULL, + PRIMARY KEY(id) - PRIMARY KEY(id) + ) /*!40100 DEFAULT CHARACTER SET UTF8 */"); - ) /*!40100 DEFAULT CHARACTER SET UTF8 */"); - db_query("Insert into {virtualcommons_forestry_3player_harvest_table} (min_resource_level,max_resource_level,individual_harvest_level) values(15,60,5)"); - db_query("Insert into {virtualcommons_forestry_3player_harvest_table} (min_resource_level,max_resource_level,individual_harvest_level) values(12,14,4)"); - db_query("Insert into {virtualcommons_forestry_3player_harvest_table} (min_resource_level,max_resource_level,individual_harvest_level) values(9,11,3)"); - db_query("Insert into {virtualcommons_forestry_3player_harvest_table} (min_resource_level,max_resource_level,individual_harvest_level) values(6,8,2)"); - db_query("Insert into {virtualcommons_forestry_3player_harvest_table} (min_resource_level,max_resource_level,individual_harvest_level) values(3,5,1)"); - db_query("Insert into {virtualcommons_forestry_3player_harvest_table} (min_resource_level,max_resource_level,individual_harvest_level) values(0,2,0)"); + db_query("Insert into {virtualcommons_forestry_5player_harvest_table} (min_resource_level,max_resource_level,individual_harvest_level) values(25,100,5)"); + db_query("Insert into {virtualcommons_forestry_5player_harvest_table} (min_resource_level,max_resource_level,individual_harvest_level) values(20,24,4)"); + db_query("Insert into {virtualcommons_forestry_5player_harvest_table} (min_resource_level,max_resource_level,individual_harvest_level) values(15,19,3)"); + db_query("Insert into {virtualcommons_forestry_5player_harvest_table} (min_resource_level,max_resource_level,individual_harvest_level) values(10,14,2)"); + db_query("Insert into {virtualcommons_forestry_5player_harvest_table} (min_resource_level,max_resource_level,individual_harvest_level) values(5,9,1)"); + db_query("Insert into {virtualcommons_forestry_5player_harvest_table} (min_resource_level,max_resource_level,individual_harvest_level) values(0,4,0)"); - // old teacher_experiment install - db_query("CREATE TABLE {virtualcommons_conducts} ( - id int NOT NULL AUTO_INCREMENT, - users_id int NOT NULL, - virtualcommons_experiments_id int NOT NULL, - date DATE NOT NULL, - no_of_students int NOT NULL, - virtualcommons_stage_no int default 1, - virtualcommons_rule_no int default 0, - PRIMARY KEY(id), - FOREIGN KEY(users_id) REFERENCES users(id) - ON DELETE CASCADE, + db_query("CREATE TABLE {virtualcommons_forestry_4player_harvest_table} ( + id int NOT NULL AUTO_INCREMENT, + min_resource_level int NOT NULL, + max_resource_level int NOT NULL, + individual_harvest_level int NOT NULL, - FOREIGN KEY(virtualcommons_experiments_id) REFERENCES virtualcommons_experiments(id) - ON DELETE CASCADE, + PRIMARY KEY(id) - FOREIGN KEY(virtualcommons_stage_no) REFERENCES virtualcommons_stage(stage_no) - ON DELETE CASCADE, + ) /*!40100 DEFAULT CHARACTER SET UTF8 */"); - FOREIGN KEY(virtualcommons_rule_no) REFERENCES virtualcommons_rules(rule_no) - ON DELETE CASCADE + db_query("Insert into {virtualcommons_forestry_4player_harvest_table} (min_resource_level,max_resource_level,individual_harvest_level) values(20,80,5)"); + db_query("Insert into {virtualcommons_forestry_4player_harvest_table} (min_resource_level,max_resource_level,individual_harvest_level) values(16,19,4)"); + db_query("Insert into {virtualcommons_forestry_4player_harvest_table} (min_resource_level,max_resource_level,individual_harvest_level) values(12,15,3)"); + db_query("Insert into {virtualcommons_forestry_4player_harvest_table} (min_resource_level,max_resource_level,individual_harvest_level) values(8,11,2)"); + db_query("Insert into {virtualcommons_forestry_4player_harvest_table} (min_resource_level,max_resource_level,individual_harvest_level) values(4,7,1)"); + db_query("Insert into {virtualcommons_forestry_4player_harvest_table} (min_resource_level,max_resource_level,individual_harvest_level) values(0,3,0)"); - ) /*!40100 DEFAULT CHARACTER SET UTF8 */"); - $flag=TRUE; + db_query("CREATE TABLE {virtualcommons_forestry_3player_harvest_table} ( + id int NOT NULL AUTO_INCREMENT, + min_resource_level int NOT NULL, + max_resource_level int NOT NULL, + individual_harvest_level int NOT NULL, - break; + PRIMARY KEY(id) + + ) /*!40100 DEFAULT CHARACTER SET UTF8 */"); + + db_query("Insert into {virtualcommons_forestry_3player_harvest_table} (min_resource_level,max_resource_level,individual_harvest_level) values(15,60,5)"); + db_query("Insert into {virtualcommons_forestry_3player_harvest_table} (min_resource_level,max_resource_level,individual_harvest_level) values(12,14,4)"); + db_query("Insert into {virtualcommons_forestry_3player_harvest_table} (min_resource_level,max_resource_level,individual_harvest_level) values(9,11,3)"); + db_query("Insert into {virtualcommons_forestry_3player_harvest_table} (min_resource_level,max_resource_level,individual_harvest_level) values(6,8,2)"); + db_query("Insert into {virtualcommons_forestry_3player_harvest_table} (min_resource_level,max_resource_level,individual_harvest_level) values(3,5,1)"); + db_query("Insert into {virtualcommons_forestry_3player_harvest_table} (min_resource_level,max_resource_level,individual_harvest_level) values(0,2,0)"); + + // old teacher_experiment install + db_query("CREATE TABLE {virtualcommons_conducts} ( + id int NOT NULL AUTO_INCREMENT, + users_id int NOT NULL, + virtualcommons_experiments_id int NOT NULL, + date DATE NOT NULL, + no_of_students int NOT NULL, + virtualcommons_stage_no int default 1, + virtualcommons_rule_no int default 0, + + PRIMARY KEY(id), + + FOREIGN KEY(users_id) REFERENCES users(id) + ON DELETE CASCADE, + + FOREIGN KEY(virtualcommons_experiments_id) REFERENCES virtualcommons_experiments(id) + ON DELETE CASCADE, + + FOREIGN KEY(virtualcommons_stage_no) REFERENCES virtualcommons_stage(stage_no) + ON DELETE CASCADE, + + FOREIGN KEY(virtualcommons_rule_no) REFERENCES virtualcommons_rules(rule_no) + ON DELETE CASCADE + + + ) /*!40100 DEFAULT CHARACTER SET UTF8 */"); + $flag=TRUE; + + break; case 'pgsql': - db_query("CREATE TABLE {virtualcommons_student} ( + db_query("CREATE TABLE {virtualcommons_student} ( - id varchar(14) NOT NULL, - group_no int NOT NULL, - virtualcommons_conducts_id int NOT NULL, + id varchar(14) NOT NULL, + group_no int NOT NULL, + virtualcommons_conducts_id int NOT NULL, - PRIMARY KEY(id), + PRIMARY KEY(id), - FOREIGN KEY(virtualcommons_conducts_id) REFERENCES virtualcommons_conducts(id) - ON DELETE CASCADE - )"); + FOREIGN KEY(virtualcommons_conducts_id) REFERENCES virtualcommons_conducts(id) + ON DELETE CASCADE + )"); - //Forestry Game Harvest Tables. - db_query("CREATE TABLE {virtualcommons_forestry_5player_harvest_table} ( - id int NOT NULL AUTO_INCREMENT, - min_resource_level int NOT NULL, - max_resource_level int NOT NULL, - individual_harvest_level int NOT NULL, + //Forestry Game Harvest Tables. + db_query("CREATE TABLE {virtualcommons_forestry_5player_harvest_table} ( + id int NOT NULL AUTO_INCREMENT, + min_resource_level int NOT NULL, + max_resource_level int NOT NULL, + individual_harvest_level int NOT NULL, - PRIMARY KEY(id) + PRIMARY KEY(id) - ) /*!40100 DEFAULT CHARACTER SET UTF8 */"); + ) /*!40100 DEFAULT CHARACTER SET UTF8 */"); - db_query("Insert into {virtualcommons_forestry_5player_harvest_table} (min_resource_level,max_resource_level,individual_harvest_level) values(25,100,5)"); - db_query("Insert into {virtualcommons_forestry_5player_harvest_table} (min_resource_level,max_resource_level,individual_harvest_level) values(20,24,4)"); - db_query("Insert into {virtualcommons_forestry_5player_harvest_table} (min_resource_level,max_resource_level,individual_harvest_level) values(15,19,3)"); - db_query("Insert into {virtualcommons_forestry_5player_harvest_table} (min_resource_level,max_resource_level,individual_harvest_level) values(10,14,2)"); - db_query("Insert into {virtualcommons_forestry_5player_harvest_table} (min_resource_level,max_resource_level,individual_harvest_level) values(5,9,1)"); - db_query("Insert into {virtualcommons_forestry_5player_harvest_table} (min_resource_level,max_resource_level,individual_harvest_level) values(0,4,0)"); + db_query("Insert into {virtualcommons_forestry_5player_harvest_table} (min_resource_level,max_resource_level,individual_harvest_level) values(25,100,5)"); + db_query("Insert into {virtualcommons_forestry_5player_harvest_table} (min_resource_level,max_resource_level,individual_harvest_level) values(20,24,4)"); + db_query("Insert into {virtualcommons_forestry_5player_harvest_table} (min_resource_level,max_resource_level,individual_harvest_level) values(15,19,3)"); + db_query("Insert into {virtualcommons_forestry_5player_harvest_table} (min_resource_level,max_resource_level,individual_harvest_level) values(10,14,2)"); + db_query("Insert into {virtualcommons_forestry_5player_harvest_table} (min_resource_level,max_resource_level,individual_harvest_level) values(5,9,1)"); + db_query("Insert into {virtualcommons_forestry_5player_harvest_table} (min_resource_level,max_resource_level,individual_harvest_level) values(0,4,0)"); - db_query("CREATE TABLE {virtualcommons_forestry_4player_harvest_table} ( - id int NOT NULL AUTO_INCREMENT, - min_resource_level int NOT NULL, - max_resource_level int NOT NULL, - individual_harvest_level int NOT NULL, + db_query("CREATE TABLE {virtualcommons_forestry_4player_harvest_table} ( + id int NOT NULL AUTO_INCREMENT, + min_resource_level int NOT NULL, + max_resource_level int NOT NULL, + individual_harvest_level int NOT NULL, - PRIMARY KEY(id) + PRIMARY KEY(id) - ) /*!40100 DEFAULT CHARACTER SET UTF8 */"); + ) /*!40100 DEFAULT CHARACTER SET UTF8 */"); - db_query("Insert into {virtualcommons_forestry_4player_harvest_table} (min_resource_level,max_resource_level,individual_harvest_level) values(20,80,5)"); - db_query("Insert into {virtualcommons_forestry_4player_harvest_table} (min_resource_level,max_resource_level,individual_harvest_level) values(16,19,4)"); - db_query("Insert into {virtualcommons_forestry_4player_harvest_table} (min_resource_level,max_resource_level,individual_harvest_level) values(12,15,3)"); - db_query("Insert into {virtualcommons_forestry_4player_harvest_table} (min_resource_level,max_resource_level,individual_harvest_level) values(8,11,2)"); - db_query("Insert into {virtualcommons_forestry_4player_harvest_table} (min_resource_level,max_resource_level,individual_harvest_level) values(4,7,1)"); - db_query("Insert into {virtualcommons_forestry_4player_harvest_table} (min_resource_level,max_resource_level,individual_harvest_level) values(0,3,0)"); + db_query("Insert into {virtualcommons_forestry_4player_harvest_table} (min_resource_level,max_resource_level,individual_harvest_level) values(20,80,5)"); + db_query("Insert into {virtualcommons_forestry_4player_harvest_table} (min_resource_level,max_resource_level,individual_harvest_level) values(16,19,4)"); + db_query("Insert into {virtualcommons_forestry_4player_harvest_table} (min_resource_level,max_resource_level,individual_harvest_level) values(12,15,3)"); + db_query("Insert into {virtualcommons_forestry_4player_harvest_table} (min_resource_level,max_resource_level,individual_harvest_level) values(8,11,2)"); + db_query("Insert into {virtualcommons_forestry_4player_harvest_table} (min_resource_level,max_resource_level,individual_harvest_level) values(4,7,1)"); + db_query("Insert into {virtualcommons_forestry_4player_harvest_table} (min_resource_level,max_resource_level,individual_harvest_level) values(0,3,0)"); - db_query("CREATE TABLE {virtualcommons_forestry_3player_harvest_table} ( - id int NOT NULL AUTO_INCREMENT, - min_resource_level int NOT NULL, - max_resource_level int NOT NULL, - individual_harvest_level int NOT NULL, + db_query("CREATE TABLE {virtualcommons_forestry_3player_harvest_table} ( + id int NOT NULL AUTO_INCREMENT, + min_resource_level int NOT NULL, + max_resource_level int NOT NULL, + individual_harvest_level int NOT NULL, - PRIMARY KEY(id) + PRIMARY KEY(id) - ) /*!40100 DEFAULT CHARACTER SET UTF8 */"); + ) /*!40100 DEFAULT CHARACTER SET UTF8 */"); - db_query("Insert into {virtualcommons_forestry_3player_harvest_table} (min_resource_level,max_resource_level,individual_harvest_level) values(15,60,5)"); - db_query("Insert into {virtualcommons_forestry_3player_harvest_table} (min_resource_level,max_resource_level,individual_harvest_level) values(12,14,4)"); - db_query("Insert into {virtualcommons_forestry_3player_harvest_table} (min_resource_level,max_resource_level,individual_harvest_level) values(9,11,3)"); - db_query("Insert into {virtualcommons_forestry_3player_harvest_table} (min_resource_level,max_resource_level,individual_harvest_level) values(6,8,2)"); - db_query("Insert into {virtualcommons_forestry_3player_harvest_table} (min_resource_level,max_resource_level,individual_harvest_level) values(3,5,1)"); - db_query("Insert into {virtualcommons_forestry_3player_harvest_table} (min_resource_level,max_resource_level,individual_harvest_level) values(0,2,0)"); + db_query("Insert into {virtualcommons_forestry_3player_harvest_table} (min_resource_level,max_resource_level,individual_harvest_level) values(15,60,5)"); + db_query("Insert into {virtualcommons_forestry_3player_harvest_table} (min_resource_level,max_resource_level,individual_harvest_level) values(12,14,4)"); + db_query("Insert into {virtualcommons_forestry_3player_harvest_table} (min_resource_level,max_resource_level,individual_harvest_level) values(9,11,3)"); + db_query("Insert into {virtualcommons_forestry_3player_harvest_table} (min_resource_level,max_resource_level,individual_harvest_level) values(6,8,2)"); + db_query("Insert into {virtualcommons_forestry_3player_harvest_table} (min_resource_level,max_resource_level,individual_harvest_level) values(3,5,1)"); + db_query("Insert into {virtualcommons_forestry_3player_harvest_table} (min_resource_level,max_resource_level,individual_harvest_level) values(0,2,0)"); - //assign the students turn for stage 2 of forestry - db_query("CREATE TABLE {virtualcommons_forestry_student_turn} ( - id int NOT NULL AUTO_INCREMENT, - virtualcommons_student_id varchar(14) NOT NULL, - virtualcommons_stage_id int NOT NULL, - virtualcommons_student_group_no int NOT NULL, + //assign the students turn for stage 2 of forestry + db_query("CREATE TABLE {virtualcommons_forestry_student_turn} ( + id int NOT NULL AUTO_INCREMENT, + virtualcommons_student_id varchar(14) NOT NULL, + virtualcommons_stage_id int NOT NULL, + virtualcommons_student_group_no int NOT NULL, - PRIMARY KEY(id), + PRIMARY KEY(id), - FOREIGN KEY(virtualcommons_student_id) REFERENCES virtualcommons_student(id) - ON DELETE CASCADE, + FOREIGN KEY(virtualcommons_student_id) REFERENCES virtualcommons_student(id) + ON DELETE CASCADE, - FOREIGN KEY(virtualcommons_stage_id) REFERENCES virtualcommons_stage(id) - ON DELETE CASCADE, + FOREIGN KEY(virtualcommons_stage_id) REFERENCES virtualcommons_stage(id) + ON DELETE CASCADE, - FOREIGN KEY(virtualcommons_student_group_no) REFERENCES virtualcommons_student(group_no) - ON DELETE CASCADE + FOREIGN KEY(virtualcommons_student_group_no) REFERENCES virtualcommons_student(group_no) + ON DELETE CASCADE - ) /*!40100 DEFAULT CHARACTER SET UTF8 */"); + ) /*!40100 DEFAULT CHARACTER SET UTF8 */"); - $flag=TRUE; + $flag=TRUE; - break; + break; default: - drupal_set_message(t('Unsupported Database')); + drupal_set_message(t('Unsupported Database')); } if($flag) { Deleted: vcweb/trunk/virtualcommons/games/teacher_dashboard/teacher.info =================================================================== --- vcweb/trunk/virtualcommons/games/teacher_dashboard/teacher.info 2008-07-30 18:48:28 UTC (rev 15) +++ vcweb/trunk/virtualcommons/games/teacher_dashboard/teacher.info 2008-07-30 19:39:33 UTC (rev 16) @@ -1,6 +0,0 @@ -; $Id$ -name = Teacher Dashboard -description = Allows teacher to see progress of the game. -package=Virtual Commons Game -version = "teacher dashboard v1.1" - Deleted: vcweb/trunk/virtualcommons/games/teacher_dashboard/teacher.module =================================================================== --- vcweb/trunk/virtualcommons/games/teacher_dashboard/teacher.module 2008-07-30 18:48:28 UTC (rev 15) +++ vcweb/trunk/virtualcommons/games/teacher_dashboard/teacher.module 2008-07-30 19:39:33 UTC (rev 16) @@ -1,369 +0,0 @@ -<?php -function teacher_menu($may_cache) -{ - $items = array(); - if ($may_cache) - { - - $items[]=array( 'path' => 'teacher_dashboard', - 'title' => t('Teacher Dashboard'), - 'callback' => 'teacher_dashboard', - 'type'=>MENU_CALLBACK, - 'access' => user_access('Only Teachers') - ); - - $items[]=array( 'path' => 'teacher_dashboard_part2', - 'title' => t('Teacher Dashboard'), - 'callback'=>'teacher_dashboard_part2', - // 'callback argument' => array('forestry_game_stage1_part2'), - 'type'=>MENU_CALLBACK, - 'access' => user_access('Only Teachers') - ); - } -/*else { - teacher_load(); - }*/ - return $items; -} - -function teacher_dashboard() -{ - - // Return the HTML generated from the $form data structure. -$teacher_id=$GLOBALS['user']->uid; -//db_query( - //drupal_set_message(t($teacher_id)); - $virtual_conduct_id=db_result(db_query("select max(id) from {virtualcommons_conducts} where users_id=%d group by users_id",$teacher_id)); - $exp_name=db_result(db_query("select exp_name from virtualcommons_experiments where id =(select virtualcommons_experiments_id from virtualcommons_conducts where id=%d)",$virtual_conduct_id)); - $output=t('<br> <h2>'. $exp_name . '</h2>'); - $output .= drupal_get_form('teacher_dashboard_multiform'); - return $output; -} - - -function teacher_dashboard_multiform($form_values=NULL) -{ - - $form['#id']='teacher_dashboard_multiform'; - $form['#multistep']=TRUE; - $teacher_id=$GLOBALS['user']->uid; - $round_no=0; - $stage_flag=FALSE; - - $virtual_conduct_id=db_result(db_query("select max(id),users_id from {virtualcommons_conducts} where users_id=%d group by users_id",$teacher_id)); - - //retrive values for stage 1 - - $header_stage1=array('Round No','Group No', 'Group Harvest Decision','Resources Before','Resources After'); - $result=db_query(" select round_no,virtualcommons_student_group_no,total_harvest_decision,resources_after,resources_before from {virtualcommons_forestry_group_information} where virtualcommons_conducts_id=%d and virtualcommons_stage_no=%d",$virtual_conduct_id,1); - - while($data=db_fetch_object($result)) - { - $round_no=$data->round_no; - $group_no=$data->virtualcommons_student_group_no; - $total_harvest_decision=$data->total_harvest_decision; - $resource_before=$data->resources_before; - $resource_after=$data->resources_after; - $row_stage1[]=array($round_no,$group_no,$total_harvest_decision,$resource_before,$resource_after); - } - - - - if(!isset($form_values)) - { //$round_no=(int) $round_no; - $step=0; - drupal_set_message(t('step when form values are null: '.$step)); - } - else - { - $step=(int) $form_values['step']; - $step++; - drupal_set_message(t('step when form values are not null: '.$step)); - } - -$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('no of rounds are: '.$no_rounds)); -if($round_no==$no_rounds) -{ - if(isset($_SESSION['next_stage'])) - { - $stage_flag=FALSE; - unset($_SESSION['next_stage']); - } - else - $stage_flag=TRUE; -} - - // $_SESSION['step']=$step; - - //$form['#redirect']=FALSE; - - $form['round_no']=array('#type'=>'hidden','#value'=>$round_no); - $form['game_id']=array('#type'=>'hidden','#value'=>$virtual_conduct_id); - //$form['exp_name']=array('#type'=>'hidden','#value'=>$exp_name); - //$form['step']=array('#type'=>'hidden','#value'=>$step); - $form['stage1']=array( - '#type'=>'fieldset', - '#title'=>t('<b>Stage 1</b>') - ); - - - $form['stage1']['table']=array( - '#type'=>'markup', - '#value'=>theme('table',$header_stage1,$row_stage1) - ); - - $form['stage2']=array( - '#type'=>'fieldset', - '#title'=>t('<b>Stage 2</b>') - ); - - - $form['stage2']['table']=array( - '#type'=>'markup', - '#value'=>theme('table',$header_stage2,$row_stage2) - ); - - if($stage_flag) - { - $form['submit'] = array( - '#type' => 'submit', - '#value' => t('Go to Stage 2') - ); - $stage_flag=FALSE; - } - else - { - $form['submit'] = array( - '#type' => 'submit', - '#value' => t('Next Round') - ); - } - - - - return $form; - -} - -function teacher_dashboard_multiform_validate($form_id,$form_values) -{ - $virtual_conduct_id=(int) $form_values['game_id']; - if($form_values['submit']=="Next Round") - { - } - - else if($form_values['submit']=="Go to Stage 2") - { - $rule_no=db_result(db_query("Select virtualcommons_rule_no from virtualcommons_conducts where id=%d",$virtual_conduct_id)); - if($rule_no==0) - { - form_set_error('submit',t('Please tell students to vote. Without voting you can not proceed to Stage 2')); - } - } - -return; - - -} - - -function teacher_dashboard_multiform_submit($form_id,$form_values) -{ - - //for player 3, in stage 2; for even rounds only 1 student will be ramdomely 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. - $round_no=(int) $form_values['round_no']; - $virtual_conduct_id=$form_values['game_id']; - $group_no=0; - //$flag_stage2_3player=FALSE; - //$step=(int) $form_values['step']; - $exp_name=$form_values['exp_name']; -//to avoid teacher clicking the button multiple times. check step and round_no - //drupal_set_message(t('step: '.$form_values['step'].'round no: '.$round_no)); - - if($form_values['submit']=="Next Round") - { - //if($step== $round_no) - //{ - drupal_set_message(t('in if. exp name: '.$exp_name)); - - $stage_no=db_result(db_query("select virtualcommons_stage_no from virtualcommons_conducts where id=%d",$virtual_conduct_id)); - $exp_id=db_result(db_query("Select id from virtualcommons_experiments where exp_name='Forestry Game' ")); - $curr_stage_no=(int)$stage_no; - $no_rounds=db_result(db_query("select no_of_rounds from virtualcommons_stage where virtualcommons_experiments_id=%d and stage_no=%d",$exp_id,$curr_stage_no)); - $no_rounds=(int) $no_rounds; - - - $result=db_query(" select max(round_no) as round_no,virtualcommons_student_group_no,virtualcommons_stage_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($result)); - while($data=db_fetch_object($result)) - { - $round_no=$data->round_no; - $group_no=$data->virtualcommons_student_group_no; - $curr_stage_no=$data->virtualcommons_stage_no; - drupal_set_message(t('no of rounds: '. $no_rounds.'curr round no'.$round_no)); - - if($no_rounds >= $round_no) - { - //stage 1 is going on. retrive values from stage1 - drupal_set_message(t('forestry stage1')); - $result= db_query("Select common_resource_pool,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); - while($data=db_fetch_object($result)) - { - $resource_available=(int) $data->common_resource_pool; - $max_resource=(int) $data->max_harvest_decision; - - } - - //get the total harvest decision - $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_conduct_id)); - $harvest_decision=(int) $harvest_decision; - $resources_before=$resource_available; - - //subtract the total harvest decision for that round from the resources - $temp=$resource_available - $harvest_decision; - - - //assign 10% of the available resource - $temp_resource_available=(int) ($temp/10); - $resource_available=$temp + $temp_resource_available; - - if($resource_available >= $max_resource) - $resource_available=$max_resource; - - db_query("Insert into {virtualcommons_forestry_group_information}(round_no,virtualcommons_conducts_id,virtualcommons_student_group_no,total_harvest_decision,resources_before,resources_after,virtualcommons_stage_no) values(%d,%d,%d,%d,%d,%d,%d)",$round_no,$virtual_conduct_id,$group_no,$harvest_decision,$resources_before,$resource_available,1); - - $harvest_decision=0; - //update the virtualcommons_forestry_common_resource_pool and virtualcommons_student - 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",$resource_available,$harvest_decision,$group_no,$virtual_conduct_id); - - - - //update the virtualcommons_forestry_student_stage1 table also - //db_query("update {virtualcommons_forestry_student_stage1} set resources_after=%d where virtualcommons_student_group_no=%d and round_no=%d",$resource_available,$group_no,$round_no); - db_query("update virtualcommons_student set start_flag=true where virtualcommons_conducts_id=%d and group_no=%d",$virtual_conduct_id,$group_no); - if($round_no==$no_rounds) - { //initialise for stage2 - - - } - } - - else - { - //stage2 - drupal_set_message(t('forestry stage2')); - db_query("update virtualcommons_student set start_flag=true where virtualcommons_conducts_id=%d and group_no=%d",$virtual_conduct_id,$group_no); - - } - }//end of 2nd while - - - } - else if($form_values['submit']=="Go to Stage 2") - { //initialise the stage 2 -// drupal_set_message(t('Go to stage 2')); - drupal_set_message(t('Go to stage 2')); - $round_no=1; - $_SESSION['next_stage']='pressed'; - //make initialisation for stage2 - $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) - { - while($data=db_fetch_object($result_group)) - { - $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); - - 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'; - -} - - - - - Copied: vcweb/trunk/virtualcommons/games/teacher_dashboard/teacher_dashboard.info (from rev 12, vcweb/trunk/virtualcommons/games/teacher_dashboard/teacher.info) =================================================================== --- vcweb/trunk/virtualcommons/games/teacher_dashboard/teacher_dashboard.info (rev 0) +++ vcweb/trunk/virtualcommons/games/teacher_dashboard/teacher_dashboard.info 2008-07-30 19:39:33 UTC (rev 16) @@ -0,0 +1,6 @@ +; $Id$ +name = Teacher Dashboard +description = Allows teacher to see progress of the game. +package=Virtual Commons Game +version = "teacher dashboard v1.1" + Copied: vcweb/trunk/virtualcommons/games/teacher_dashboard/teacher_dashboard.module (from rev 12, vcweb/trunk/virtualcommons/games/teacher_dashboard/teacher.module) =================================================================== --- vcweb/trunk/virtualcommons/games/teacher_dashboard/teacher_dashboard.module (rev 0) +++ vcweb/trunk/virtualcommons/games/teacher_dashboard/teacher_dashboard.module 2008-07-30 19:39:33 UTC (rev 16) @@ -0,0 +1,369 @@ +<?php +function teacher_dashboard_menu($may_cache) +{ + $items = array(); + if ($may_cache) + { + + $items[]=array( 'path' => 'teacher_dashboard', + 'title' => t('Teacher Dashboard'), + 'callback' => 'teacher_dashboard', + 'type'=>MENU_CALLBACK, + 'access' => user_access('Only Teachers') + ); + + $items[]=array( 'path' => 'teacher_dashboard_part2', + 'title' => t('Teacher Dashboard'), + 'callback'=>'teacher_dashboard_part2', + // 'callback argument' => array('forestry_game_stage1_part2'), + 'type'=>MENU_CALLBACK, + 'access' => user_access('Only Teachers') + ); + } +/*else { + teacher_load(); + }*/ + return $items; +} + +function teacher_dashboard() +{ + + // Return the HTML generated from the $form data structure. +$teacher_id=$GLOBALS['user']->uid; +//db_query( + //drupal_set_message(t($teacher_id)); + $virtual_conduct_id=db_result(db_query("select max(id) from {virtualcommons_conducts} where users_id=%d group by users_id",$teacher_id)); + $exp_name=db_result(db_query("select exp_name from virtualcommons_experiments where id =(select virtualcommons_experiments_id from virtualcommons_conducts where id=%d)",$virtual_conduct_id)); + $output=t('<br> <h2>'. $exp_name . '</h2>'); + $output .= drupal_get_form('teacher_dashboard_multiform'); + return $output; +} + + +function teacher_dashboard_multiform($form_values=NULL) +{ + + $form['#id']='teacher_dashboard_multiform'; + $form['#multistep']=TRUE; + $teacher_id=$GLOBALS['user']->uid; + $round_no=0; + $stage_flag=FALSE; + + $virtual_conduct_id=db_result(db_query("select max(id),users_id from {virtualcommons_conducts} where users_id=%d group by users_id",$teacher_id)); + + //retrive values for stage 1 + + $header_stage1=array('Round No','Group No', 'Group Harvest Decision','Resources Before','Resources After'); + $result=db_query(" select round_no,virtualcommons_student_group_no,total_harvest_decision,resources_after,resources_before from {virtualcommons_forestry_group_information} where virtualcommons_conducts_id=%d and virtualcommons_stage_no=%d",$virtual_conduct_id,1); + + while($data=db_fetch_object($result)) + { + $round_no=$data->round_no; + $group_no=$data->virtualcommons_student_group_no; + $total_harvest_decision=$data->total_harvest_decision; + $resource_before=$data->resources_before; + $resource_after=$data->resources_after; + $row_stage1[]=array($round_no,$group_no,$total_harvest_decision,$resource_before,$resource_after); + } + + + + if(!isset($form_values)) + { //$round_no=(int) $round_no; + $step=0; + drupal_set_message(t('step when form values are null: '.$step)); + } + else + { + $step=(int) $form_values['step']; + $step++; + drupal_set_message(t('step when form values are not null: '.$step)); + } + +$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('no of rounds are: '.$no_rounds)); +if($round_no==$no_rounds) +{ + if(isset($_SESSION['next_stage'])) + { + $stage_flag=FALSE; + unset($_SESSION['next_stage']); + } + else + $stage_flag=TRUE; +} + + // $_SESSION['step']=$step; + + //$form['#redirect']=FALSE; + + $form['round_no']=array('#type'=>'hidden','#value'=>$round_no); + $form['game_id']=array('#type'=>'hidden','#value'=>$virtual_conduct_id); + //$form['exp_name']=array('#type'=>'hidden','#value'=>$exp_name); + //$form['step']=array('#type'=>'hidden','#value'=>$step); + $form['stage1']=array( + '#type'=>'fieldset', + '#title'=>t('<b>Stage 1</b>') + ); + + + $form['stage1']['table']=array( + '#type'=>'markup', + '#value'=>theme('table',$header_stage1,$row_stage1) + ); + + $form['stage2']=array( + '#type'=>'fieldset', + '#title'=>t('<b>Stage 2</b>') + ); + + + $form['stage2']['table']=array( + '#type'=>'markup', + '#value'=>theme('table',$header_stage2,$row_stage2) + ); + + if($stage_flag) + { + $form['submit'] = array( + '#type' => 'submit', + '#value' => t('Go to Stage 2') + ); + $stage_flag=FALSE; + } + else + { + $form['submit'] = array( + '#type' => 'submit', + '#value' => t('Next Round') + ); + } + + + + return $form; + +} + +function teacher_dashboard_multiform_validate($form_id,$form_values) +{ + $virtual_conduct_id=(int) $form_values['game_id']; + if($form_values['submit']=="Next Round") + { + } + + else if($form_values['submit']=="Go to Stage 2") + { + $rule_no=db_result(db_query("Select virtualcommons_rule_no from virtualcommons_conducts where id=%d",$virtual_conduct_id)); + if($rule_no==0) + { + form_set_error('submit',t('Please tell students to vote. Without voting you can not proceed to Stage 2')); + } + } + +return; + + +} + + +function teacher_dashboard_multiform_submit($form_id,$form_values) +{ + + //for player 3, in stage 2; for even rounds only 1 student will be ramdomely 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. + $round_no=(int) $form_values['round_no']; + $virtual_conduct_id=$form_values['game_id']; + $group_no=0; + //$flag_stage2_3player=FALSE; + //$step=(int) $form_values['step']; + $exp_name=$form_values['exp_name']; +//to avoid teacher clicking the button multiple times. check step and round_no + //drupal_set_message(t('step: '.$form_values['step'].'round no: '.$round_no)); + + if($form_values['submit']=="Next Round") + { + //if($step== $round_no) + //{ + drupal_set_message(t('in if. exp name: '.$exp_name)); + + $stage_no=db_result(db_query("select virtualcommons_stage_no from virtualcommons_conducts where id=%d",$virtual_conduct_id)); + $exp_id=db_result(db_query("Select id from virtualcommons_experiments where exp_name='Forestry Game' ")); + $curr_stage_no=(int)$stage_no; + $no_rounds=db_result(db_query("select no_of_rounds from virtualcommons_stage where virtualcommons_experiments_id=%d and stage_no=%d",$exp_id,$curr_stage_no)); + $no_rounds=(int) $no_rounds; + + + $result=db_query(" select max(round_no) as round_no,virtualcommons_student_group_no,virtualcommons_stage_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($result)); + while($data=db_fetch_object($result)) + { + $round_no=$data->round_no; + $group_no=$data->virtualcommons_student_group_no; + $curr_stage_no=$data->virtualcommons_stage_no; + drupal_set_message(t('no of rounds: '. $no_rounds.'curr round no'.$round_no)); + + if($no_rounds >= $round_no) + { + //stage 1 is going on. retrive values from stage1 + drupal_set_message(t('forestry stage1')); + $result= db_query("Select common_resource_pool,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); + while($data=db_fetch_object($result)) + { + $resource_available=(int) $data->common_resource_pool; + $max_resource=(int) $data->max_harvest_decision; + + } + + //get the total harvest decision + $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_conduct_id)); + $harvest_decision=(int) $harvest_decision; + $resources_before=$resource_available; + + //subtract the total harvest decision for that round from the resources + $temp=$resource_available - $harvest_decision; + + + //assign 10% of the available resource + $temp_resource_available=(int) ($temp/10); + $resource_available=$temp + $temp_resource_available; + + if($resource_available >= $max_resource) + $resource_available=$max_resource; + + db_query("Insert into {virtualcommons_forestry_group_information}(round_no,virtualcommons_conducts_id,virtualcommons_student_group_no,total_harvest_decision,resources_before,resources_after,virtualcommons_stage_no) values(%d,%d,%d,%d,%d,%d,%d)",$round_no,$virtual_conduct_id,$group_no,$harvest_decision,$resources_before,$resource_available,1); + + $harvest_decision=0; + //update the virtualcommons_forestry_common_resource_pool and virtualcommons_student + 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",$resource_available,$harvest_decision,$group_no,$virtual_conduct_id); + + + + //update the virtualcommons_forestry_student_stage1 table also + //db_query("update {virtualcommons_forestry_student_stage1} set resources_after=%d where virtualcommons_student_group_no=%d and round_no=%d",$resource_available,$group_no,$round_no); + db_query("update virtualcommons_student set start_flag=true where virtualcommons_conducts_id=%d and group_no=%d",$virtual_conduct_id,$group_no); + if($round_no==$no_rounds) + { //initialise for stage2 + + + } + } + + else + { + //stage2 + drupal_set_message(t('forestry stage2')); + db_query("update virtualcommons_student set start_flag=true where virtualcommons_conducts_id=%d and group_no=%d",$virtual_conduct_id,$group_no); + + } + }//end of 2nd while + + + } + else if($form_values['submit']=="Go to Stage 2") + { //initialise the stage 2 +// drupal_set_message(t('Go to stage 2')); + drupal_set_message(t('Go to stage 2')); + $round_no=1; + $_SESSION['next_stage']='pressed'; + //make initialisation for stage2 + $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) + { + while($data=db_fetch_object($result_group)) + { + $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); + + 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,virtualcommo... [truncated message content] |
From: <al...@us...> - 2008-07-30 18:48:23
|
Revision: 15 http://virtualcommons.svn.sourceforge.net/virtualcommons/?rev=15&view=rev Author: alllee Date: 2008-07-30 18:48:28 +0000 (Wed, 30 Jul 2008) Log Message: ----------- merging studentgroup and teacher_experiments modules into experiment core Added Paths: ----------- vcweb/trunk/virtualcommons/experiment/core/ vcweb/trunk/virtualcommons/experiment/core/experiment.info vcweb/trunk/virtualcommons/experiment/core/experiment.install vcweb/trunk/virtualcommons/experiment/core/experiment.module Removed Paths: ------------- vcweb/trunk/virtualcommons/experiment/studentgroup/ vcweb/trunk/virtualcommons/experiment/teacher_experiments/ Added: vcweb/trunk/virtualcommons/experiment/core/experiment.info =================================================================== --- vcweb/trunk/virtualcommons/experiment/core/experiment.info (rev 0) +++ vcweb/trunk/virtualcommons/experiment/core/experiment.info 2008-07-30 18:48:28 UTC (rev 15) @@ -0,0 +1,6 @@ +; $Id$ +name = Experiment Core +description = Provides core essential experiment functionality and metadata +package=Virtual Commons +version = "$Rev$" + Added: vcweb/trunk/virtualcommons/experiment/core/experiment.install =================================================================== --- vcweb/trunk/virtualcommons/experiment/core/experiment.install (rev 0) +++ vcweb/trunk/virtualcommons/experiment/core/experiment.install 2008-07-30 18:48:28 UTC (rev 15) @@ -0,0 +1,292 @@ +<?php +// vim:sts=2:sw=2:filetype=php +// $Id$ +/** + * Implementation of hook_install(). + */ +function experiment_install() { + switch ($GLOBALS['db_type']) { + case 'mysql': + case 'mysqli': + db_query("CREATE TABLE {virtualcommons_student} + ( + id varchar(14) NOT NULL, + group_no int NOT NULL, + virtualcommons_conducts_id int NOT NULL, + start_flag BOOL default false, + turn_no varchar(1) NOT NULL, + + PRIMARY KEY(id), + + FOREIGN KEY(virtualcommons_conducts_id) REFERENCES virtualcommons_conducts(id) + ON DELETE CASCADE + + ) TYPE=InnoDB /*!40100 DEFAULT CHARACTER SET UTF8 */"); + + db_query("CREATE TABLE {virtualcommons_forestry_common_resource_pool} + ( + id int NOT NULL AUTO_INCREMENT, + virtualcommons_student_group_no int NOT NULL, + common_resource_pool int NOT NULL, + harvest_decision int NOT NULL, + virtualcommons_conducts_id int NOT NULL, + max_harvest_decision int NOT NULL, + + + + PRIMARY KEY(id), + FOREIGN KEY(virtualcommons_student_group_no) REFERENCES virtualcommons_student(group_no) + ON DELETE CASCADE, + + FOREIGN KEY(virtualcommons_conducts_id) REFERENCES virtualcommons_conducts(id) + ON DELETE CASCADE + + + + ) /*!40100 DEFAULT CHARACTER SET UTF8 */"); + + + + + db_query("CREATE TABLE {virtualcommons_forestry_group_information} + ( + id int NOT NULL AUTO_INCREMENT, + round_no int NOT NULL, + virtualcommons_conducts_id int NOT NULL, + virtualcommons_student_group_no int NOT NULL, + total_harvest_decision int NOT NULL, + resources_before int NOT NULL, + resources_after int NOT NULL, + virtualcommons_stage_no int NOT NULL, + virtualcommons_rules_no int(1), + dice int(1) , + + + PRIMARY KEY(id), + FOREIGN KEY(virtualcommons_student_group_no) REFERENCES virtualcommons_student(group_no) + ON DELETE CASCADE, + + FOREIGN KEY(virtualcommons_conducts_id) REFERENCES virtualcommons_conducts(id) + ON DELETE CASCADE, + + FOREIGN KEY(virtualcommons_stage_no) REFERENCES virtualcommons_stage(stage_no) + ON DELETE CASCADE, + + FOREIGN KEY(virtualcommons_rules_no) REFERENCES virtualcommons_rules(rule_no) + ON DELETE CASCADE + + + ) /*!40100 DEFAULT CHARACTER SET UTF8 */"); + + //Forestry Game Harvest Tables. + db_query("CREATE TABLE {virtualcommons_forestry_5player_harvest_table} ( + id int NOT NULL AUTO_INCREMENT, + min_resource_level int NOT NULL, + max_resource_level int NOT NULL, + individual_harvest_level int NOT NULL, + + PRIMARY KEY(id) + + ) /*!40100 DEFAULT CHARACTER SET UTF8 */"); + + + db_query("Insert into {virtualcommons_forestry_5player_harvest_table} (min_resource_level,max_resource_level,individual_harvest_level) values(25,100,5)"); + db_query("Insert into {virtualcommons_forestry_5player_harvest_table} (min_resource_level,max_resource_level,individual_harvest_level) values(20,24,4)"); + db_query("Insert into {virtualcommons_forestry_5player_harvest_table} (min_resource_level,max_resource_level,individual_harvest_level) values(15,19,3)"); + db_query("Insert into {virtualcommons_forestry_5player_harvest_table} (min_resource_level,max_resource_level,individual_harvest_level) values(10,14,2)"); + db_query("Insert into {virtualcommons_forestry_5player_harvest_table} (min_resource_level,max_resource_level,individual_harvest_level) values(5,9,1)"); + db_query("Insert into {virtualcommons_forestry_5player_harvest_table} (min_resource_level,max_resource_level,individual_harvest_level) values(0,4,0)"); + + + + db_query("CREATE TABLE {virtualcommons_forestry_4player_harvest_table} ( + id int NOT NULL AUTO_INCREMENT, + min_resource_level int NOT NULL, + max_resource_level int NOT NULL, + individual_harvest_level int NOT NULL, + + PRIMARY KEY(id) + + ) /*!40100 DEFAULT CHARACTER SET UTF8 */"); + + + db_query("Insert into {virtualcommons_forestry_4player_harvest_table} (min_resource_level,max_resource_level,individual_harvest_level) values(20,80,5)"); + db_query("Insert into {virtualcommons_forestry_4player_harvest_table} (min_resource_level,max_resource_level,individual_harvest_level) values(16,19,4)"); + db_query("Insert into {virtualcommons_forestry_4player_harvest_table} (min_resource_level,max_resource_level,individual_harvest_level) values(12,15,3)"); + db_query("Insert into {virtualcommons_forestry_4player_harvest_table} (min_resource_level,max_resource_level,individual_harvest_level) values(8,11,2)"); + db_query("Insert into {virtualcommons_forestry_4player_harvest_table} (min_resource_level,max_resource_level,individual_harvest_level) values(4,7,1)"); + db_query("Insert into {virtualcommons_forestry_4player_harvest_table} (min_resource_level,max_resource_level,individual_harvest_level) values(0,3,0)"); + + db_query("CREATE TABLE {virtualcommons_forestry_3player_harvest_table} ( + id int NOT NULL AUTO_INCREMENT, + min_resource_level int NOT NULL, + max_resource_level int NOT NULL, + individual_harvest_level int NOT NULL, + + PRIMARY KEY(id) + + ) /*!40100 DEFAULT CHARACTER SET UTF8 */"); + + db_query("Insert into {virtualcommons_forestry_3player_harvest_table} (min_resource_level,max_resource_level,individual_harvest_level) values(15,60,5)"); + db_query("Insert into {virtualcommons_forestry_3player_harvest_table} (min_resource_level,max_resource_level,individual_harvest_level) values(12,14,4)"); + db_query("Insert into {virtualcommons_forestry_3player_harvest_table} (min_resource_level,max_resource_level,individual_harvest_level) values(9,11,3)"); + db_query("Insert into {virtualcommons_forestry_3player_harvest_table} (min_resource_level,max_resource_level,individual_harvest_level) values(6,8,2)"); + db_query("Insert into {virtualcommons_forestry_3player_harvest_table} (min_resource_level,max_resource_level,individual_harvest_level) values(3,5,1)"); + db_query("Insert into {virtualcommons_forestry_3player_harvest_table} (min_resource_level,max_resource_level,individual_harvest_level) values(0,2,0)"); + + // old teacher_experiment install + db_query("CREATE TABLE {virtualcommons_conducts} ( + id int NOT NULL AUTO_INCREMENT, + users_id int NOT NULL, + virtualcommons_experiments_id int NOT NULL, + date DATE NOT NULL, + no_of_students int NOT NULL, + virtualcommons_stage_no int default 1, + virtualcommons_rule_no int default 0, + + PRIMARY KEY(id), + + FOREIGN KEY(users_id) REFERENCES users(id) + ON DELETE CASCADE, + + FOREIGN KEY(virtualcommons_experiments_id) REFERENCES virtualcommons_experiments(id) + ON DELETE CASCADE, + + FOREIGN KEY(virtualcommons_stage_no) REFERENCES virtualcommons_stage(stage_no) + ON DELETE CASCADE, + + FOREIGN KEY(virtualcommons_rule_no) REFERENCES virtualcommons_rules(rule_no) + ON DELETE CASCADE + + + ) /*!40100 DEFAULT CHARACTER SET UTF8 */"); + $flag=TRUE; + + break; + case 'pgsql': + db_query("CREATE TABLE {virtualcommons_student} ( + + id varchar(14) NOT NULL, + group_no int NOT NULL, + virtualcommons_conducts_id int NOT NULL, + + PRIMARY KEY(id), + + FOREIGN KEY(virtualcommons_conducts_id) REFERENCES virtualcommons_conducts(id) + ON DELETE CASCADE + )"); + + //Forestry Game Harvest Tables. + db_query("CREATE TABLE {virtualcommons_forestry_5player_harvest_table} ( + id int NOT NULL AUTO_INCREMENT, + min_resource_level int NOT NULL, + max_resource_level int NOT NULL, + individual_harvest_level int NOT NULL, + + PRIMARY KEY(id) + + ) /*!40100 DEFAULT CHARACTER SET UTF8 */"); + + + db_query("Insert into {virtualcommons_forestry_5player_harvest_table} (min_resource_level,max_resource_level,individual_harvest_level) values(25,100,5)"); + db_query("Insert into {virtualcommons_forestry_5player_harvest_table} (min_resource_level,max_resource_level,individual_harvest_level) values(20,24,4)"); + db_query("Insert into {virtualcommons_forestry_5player_harvest_table} (min_resource_level,max_resource_level,individual_harvest_level) values(15,19,3)"); + db_query("Insert into {virtualcommons_forestry_5player_harvest_table} (min_resource_level,max_resource_level,individual_harvest_level) values(10,14,2)"); + db_query("Insert into {virtualcommons_forestry_5player_harvest_table} (min_resource_level,max_resource_level,individual_harvest_level) values(5,9,1)"); + db_query("Insert into {virtualcommons_forestry_5player_harvest_table} (min_resource_level,max_resource_level,individual_harvest_level) values(0,4,0)"); + + + + db_query("CREATE TABLE {virtualcommons_forestry_4player_harvest_table} ( + id int NOT NULL AUTO_INCREMENT, + min_resource_level int NOT NULL, + max_resource_level int NOT NULL, + individual_harvest_level int NOT NULL, + + PRIMARY KEY(id) + + ) /*!40100 DEFAULT CHARACTER SET UTF8 */"); + + + db_query("Insert into {virtualcommons_forestry_4player_harvest_table} (min_resource_level,max_resource_level,individual_harvest_level) values(20,80,5)"); + db_query("Insert into {virtualcommons_forestry_4player_harvest_table} (min_resource_level,max_resource_level,individual_harvest_level) values(16,19,4)"); + db_query("Insert into {virtualcommons_forestry_4player_harvest_table} (min_resource_level,max_resource_level,individual_harvest_level) values(12,15,3)"); + db_query("Insert into {virtualcommons_forestry_4player_harvest_table} (min_resource_level,max_resource_level,individual_harvest_level) values(8,11,2)"); + db_query("Insert into {virtualcommons_forestry_4player_harvest_table} (min_resource_level,max_resource_level,individual_harvest_level) values(4,7,1)"); + db_query("Insert into {virtualcommons_forestry_4player_harvest_table} (min_resource_level,max_resource_level,individual_harvest_level) values(0,3,0)"); + + + + + db_query("CREATE TABLE {virtualcommons_forestry_3player_harvest_table} ( + id int NOT NULL AUTO_INCREMENT, + min_resource_level int NOT NULL, + max_resource_level int NOT NULL, + individual_harvest_level int NOT NULL, + + PRIMARY KEY(id) + + ) /*!40100 DEFAULT CHARACTER SET UTF8 */"); + + db_query("Insert into {virtualcommons_forestry_3player_harvest_table} (min_resource_level,max_resource_level,individual_harvest_level) values(15,60,5)"); + db_query("Insert into {virtualcommons_forestry_3player_harvest_table} (min_resource_level,max_resource_level,individual_harvest_level) values(12,14,4)"); + db_query("Insert into {virtualcommons_forestry_3player_harvest_table} (min_resource_level,max_resource_level,individual_harvest_level) values(9,11,3)"); + db_query("Insert into {virtualcommons_forestry_3player_harvest_table} (min_resource_level,max_resource_level,individual_harvest_level) values(6,8,2)"); + db_query("Insert into {virtualcommons_forestry_3player_harvest_table} (min_resource_level,max_resource_level,individual_harvest_level) values(3,5,1)"); + db_query("Insert into {virtualcommons_forestry_3player_harvest_table} (min_resource_level,max_resource_level,individual_harvest_level) values(0,2,0)"); + + //assign the students turn for stage 2 of forestry + db_query("CREATE TABLE {virtualcommons_forestry_student_turn} ( + id int NOT NULL AUTO_INCREMENT, + virtualcommons_student_id varchar(14) NOT NULL, + virtualcommons_stage_id int NOT NULL, + virtualcommons_student_group_no int NOT NULL, + + + PRIMARY KEY(id), + + FOREIGN KEY(virtualcommons_student_id) REFERENCES virtualcommons_student(id) + ON DELETE CASCADE, + + FOREIGN KEY(virtualcommons_stage_id) REFERENCES virtualcommons_stage(id) + ON DELETE CASCADE, + + FOREIGN KEY(virtualcommons_student_group_no) REFERENCES virtualcommons_student(group_no) + ON DELETE CASCADE + + + ) /*!40100 DEFAULT CHARACTER SET UTF8 */"); + + + + $flag=TRUE; + + + + break; + default: + drupal_set_message(t('Unsupported Database')); + } + if($flag) + { + drupal_set_message(t('Student database is successfully created.')); + } + else + { + drupal_set_message(t('Student database is NOT successfully created.'),'error'); + } +} + +/** + * Implementation of hook_uninstall(). + */ +function experiment_uninstall() { + db_query("DROP TABLE {virtualcommons_student}"); + db_query("DROP TABLE {virtualcommons_forestry_common_resource_pool}"); + db_query("DROP TABLE {virtualcommons_forestry_3player_harvest_table}"); + db_query("DROP TABLE {virtualcommons_forestry_4player_harvest_table}"); + db_query("DROP TABLE {virtualcommons_forestry_5player_harvest_table}"); + db_query("DROP TABLE {virtualcommons_forestry_group_information}"); + db_query("DROP TABLE {virtualcommons_conducts}"); + drupal_set_message(t('Experiment core tables were successfully deleted from the database. We hope.')); +} Added: vcweb/trunk/virtualcommons/experiment/core/experiment.module =================================================================== --- vcweb/trunk/virtualcommons/experiment/core/experiment.module (rev 0) +++ vcweb/trunk/virtualcommons/experiment/core/experiment.module 2008-07-30 18:48:28 UTC (rev 15) @@ -0,0 +1,494 @@ +<?php +// vim:sts=2:sw=2:filetype=php +// $Id$ + +//$path=drupal_get_filename('module', 'virtualcommons'); +//include('teacher.php'); // or require etc. +//include('sites/all/modules/virtualcommons/teacher_experiments/class_files/teacher.php'); + +/** + * implements the _user hook. + **/ + + + +function teacher_experiments_perm() +{ + return array('Only Teachers'); + +} + +// $Id$ +/** + * Implementation of hook_menu(). + */ +function teacher_experiments_menu($may_cache) { + $items = array(); + if ($may_cache) { + $items[] = array( + 'path' => 'teacher_experiments', + 'title' => t('Experiments'), + 'callback' => 'teacher_experiments_page', + 'type'=>MENU_CALLBACK, + 'access' => user_access('Only Teachers') + ); + $items[] = array( + 'path' => 'studentgroup', + 'title' => t('Student Information'), + 'callback' => 'drupal_get_form', + 'callback arguments'=>array(studentgroup), + 'type'=>MENU_CALLBACK, + 'access' => user_access('Only Teachers') + ); + $items[]=array( 'path' => 'game_start', + // 'title' => t('Forestry Game - Stage 1'), + 'callback'=>'game_start', + // 'callback argument' => array('forestry_game_stage1_part2'), + 'type'=>MENU_CALLBACK, + 'access' => user_access('Only Teachers') + ); + } + return $items; +} +/** + * Called when user goes to example.com/?q=teacher_experiments + */ +function teacher_experiments_page() { + $output = t('Please submit the following form in order to conduct the experiments in the class.'); + // Return the HTML generated from the $form data structure. + $output .= drupal_get_form('teacher_experiments_nameform'); + return $output; +} +/** + * Defines a form. + */ +function teacher_experiments_nameform() { + + $form['#method']='post'; + //+$form['#action']='http://localhost/drupal/?q=studentgroup'; + $form['#id']='teacher_experiments'; + $form['no_student'] = array( + '#title' => t('How many Students are participating'), + '#type' => 'textfield', + '#description' => t('Depending on the number of students groups will be formed.'), + '#required'=>TRUE + + ); + + $form['games']=array( + '#type'=>'select', + '#title'=>'Select the Game from the following experiments', + '#default_value'=>variable_get('games',0), + '#options'=> array(t('Choose One '),t('Fishery Game'),t('Forestry Game'),t('Water Irrigation Game')), + '#required'=>TRUE + + ); + + + $form['terms_usage']=array( + '#type'=>'fieldset', + //'#title'=>t('Terms of Usage') + ); + + + $form['terms_usage']['info']=array( + + '#type'=>'item', + '#title'=>t('Terms and conditions'), + '#description'=>t('<p>Material on this site is used only for educational purpose. None of the material on this site may be used for any other purpose. <br/>All rights reserved and granted by Dr Marco Janssen.</p>') + ); + + + $form['terms_usage']['agree'] = array( + '#type' => 'radios', + '#options' => array(t('I Agree'),t('I Disagree')), + '#title'=>t('By selecting the "I Agree" option, you certifiy that you are agree above terms of use'), + '#default_value'=>variable_get('agree',1), + + + ); + $form['submit'] = array( + '#type' => 'submit', + '#value' => t('Submit') + ); + + + + return $form; +} +/** + * Validate the form. + */ +function teacher_experiments_nameform_validate($form_id, $form_values) +{ + + // We notify the form API that this field has failed validation. + if ($form_values['games'] == 0) + { + form_set_error('games', + t('Please choose the game.')); + } + if($form_values['agree']==1) + { + form_set_error('agree',t('You have to agree the terms before you play any game.')); + } + + //To Check for numbers. + if(preg_match('/[^0-9]+/',$form_values['no_student'])) + { + form_set_error('no_student',t('Number of experiments can not be alphabets. ')); + } + +} +/** + * Handle post-validation form submission. + */ +function teacher_experiments_nameform_submit($form_id, $form_values) +{ + $teacher_id=$GLOBALS['user']->uid; + $game_name=$form_values['games']; + $no_student=$form_values['no_student']; + if(!isset($_SESSION['no_of_student'])) + { + $_SESSION['no_student']=$no_student; + } + + + if(!isset($_SESSION['game_name'])) + { + $_SESSION['game_name']=$game_name; + } + + + //Fishery + if($game_name==1) + { + $result=db_result(db_query("Select id from {virtualcommons_experiments} where exp_name LIKE '%%Fishery%%' ")); + } + //Forestry + else if($game_name==2) + { + $result=db_result(db_query("Select id from {virtualcommons_experiments} where exp_name LIKE '%%Forestry%%' ")); + } + + //Water Irrigation + else if($game_name==3) + { + $result=db_result(db_query("Select id from {virtualcommons_experiments} where exp_name LIKE '%%Water%%' ")); + } + + /*$teacher=new Teacher($result,'talele'); + $fname=$teacher->getfname(); + $lname=$teacher->getlname();*/ + + + drupal_set_message(t('Thanks for filling out the form. Your Game will start soon. ')); + + 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); + //echo 'Thanks for filling out the form. Your Game will start soon,'. $fname; + return 'studentgroup'; +} + +/** Old studentgroup module code cut'n'paste job */ +/** + * Called when user goes to example.com/?q=studentgroup + */ + +function studentgroup() +{ + + $form['#id']='studentgroup'; + $exp_name=$_SESSION['game_name']; + $no=$_SESSION['no_student']; + //unset($_SESSION['game_name']); + unset($_SESSION['no_student']); + + //drupal_set_message(t('Game name is %exp_name .<br> No of Students are %no',array('%exp_name'=>$exp_name,'%no'=>$no))); + if($exp_name==1) + $exp_name="Fishery Game"; + else if($exp_name==2) + $exp_name="Forestry Game"; + else if($exp_name==3) + $exp_name="Water Irrigation Game"; + + //$no=$_POST['no_student']; + $no_of_student=(int)$no; + $no_of_groups=0; + $groups_3=0; + $groups_4=0; + $groups_5=0; + $header = array('Group ID', 'Student ID'); + + //no of groups + $groups_5=((int)($no_of_student/5)); + + $x= $no_of_student%5; + + if($x==0) + { + $no_of_groups=$groups_5; + } + else if($x==1) + { + $groups_5=$groups_5-1; + $groups_3=2; + $no_of_groups=$groups_5 + $groups_3; + } + + else if($x==2) + { + $groups_5=$groups_5-1; + $groups_3=1; + $groups_4=1; + $no_of_groups=$groups_5 + $groups_3 + $groups_4; + } + else if($x==3) + { + + $groups_3=1; + $no_of_groups=$groups_3 + $groups_5; + } + + else if($x==4) + { + + $groups_4=1; + $no_of_groups=$groups_4 + $groups_5; + } + + $no_student5=5*$groups_5; + $no_student4=4*$groups_4; + $no_student3=3*$groups_3; + + $var=10; + $group_no=1; + + if($groups_5 <> 0) + { + for($i=0;$i<$groups_5;$i++) + { + for($j=0;$j<5;$j++) + { + $stud_id=uniqid(rand(0,9), false); + $row[]=array('Group '.$group_no,$stud_id); + $row_submit[]=array($group_no,$stud_id); + + } + + $group_no++; + } + } + if($groups_4 <> 0) + { + for($i=0;$i<$groups_4;$i++) + { + for($j=0;$j<4;$j++) + { + $stud_id=uniqid(rand(0,9),false); + $row[]=array('Group '.$group_no,$stud_id); + $row_submit[]=array($group_no,$stud_id); + + } + + $group_no++; + } + } + if($groups_3 <> 0) + { + for($i=0;$i<$groups_3;$i++) + { + for($j=0;$j<3;$j++) + { + $stud_id=uniqid(rand(0,9), false); + $row[]=array('Group '.$group_no,$stud_id); + $row_submit[]=array($group_no,$stud_id); + } + $group_no++; + } + } + + + if(!isset($_SESSION['student_info'])) + { + $_SESSION['student_info']=$row_submit; + /*foreach ($_SESSION['student_info'] as $key=>$value) + { + drupal_set_message(t('Key is: %key<br>',array('%key'=>$key))); + foreach ($value as $key=>$value) + { + drupal_set_message(t('Key inner is: %key<br> Value inner is: %value',array('%key'=>$key,'%value'=>$value))); + } + }*/ + } + + + $form['game_info']=array( + '#type'=>'fieldset', + '#title'=>t('Experiment Information'), + '#tree' => TRUE + ); + + + $form['game_info']['info']=array( + '#title'=>t('Please note the following information carefully.'), + '#type'=>'item', + '#description'=>t('<h3>Name of Experiments: '.$exp_name.'<br/>No of Students: '.$no_of_student.'<br/>No of Groups: '.$no_of_groups.'</h3>') + ); + + $form['group_info']=array( + '#type'=>'fieldset', + '#title'=>t('Group Information'), + '#tree' => TRUE + ); + + $form['group_info']['info1']=array( + '#title'=>t('Please assign the following Student IDs to the students.Please do not tell Group IDs to them. After assigning Student IDs, you can tell students to sign using Student Login Page.'), + '#description'=>t('<h3>Number of group of 3 Students: '.$groups_3.'<br/>Number of group of 4 Students: '.$groups_4.'<br/>Number of group of 5 Students: '.$groups_5.'</h3>'), + '#type'=>'item' + + ); + + $form['group_info']['table_info']=array( + + '#type'=>'markup', + '#value'=>theme('table',$header,$row) + ); + + $form['submit'] = array( + '#type' => 'submit', + '#value' => t('Start Game!!!') + ); + + return $form; +} + + + +function studentgroup_submit($form_id, $form_values) +{ + //put it in the database student + + $id=$GLOBALS['user']->uid; + $table=$_SESSION['student_info']; + $virtual_conduct_id=db_result(db_query("select max(id),users_id from {virtualcommons_conducts} where users_id=%d group by users_id",$id)); + $turn=array('1','2','3','4','5'); + $prev_group_no=0; + $temp=-1; + $i=0; + foreach ($table as $key=>$value) + { + + drupal_set_message(t('Key is: %key<br>',array('%key'=>$i))); + foreach ($value as $key=>$value) + { + + if($key==0) + { + $group_no=$value; + if($temp <> $group_no) + { + $temp=$group_no; + $i=0; + } + + + } + else if($key==1) + { + $stud_id=$value; + drupal_set_message(t('Group Id is %group Student id is: %value Turn id is %turn',array('%turn'=>$turn[$i],'%value'=>$stud_id,'%group'=>$group_no))); + db_query("Insert into {virtualcommons_student} (id,group_no,virtualcommons_conducts_id,start_flag,turn_no) values('%s',%d,%d,false,%d)",$stud_id,$group_no,$virtual_conduct_id,$turn[$i]); + + + /* db_query("insert into {virtualcommons_forestry_student_turn} + (turn_no,virtualcommons_student_id,virtualcommons_stage_id,virtualcommons_student_group_no) + values('%s','%s',2,%d)",$turn[$i],$stud_id,$group_no);*/ + + $i++; + + } + + } + } + + //depending upon the experiment game, assign the resource table to each group. + $exp_name=$_SESSION['game_name']; + if($exp_name==1) + { + //$exp_name="Fishery Game"; + + } + + else if($exp_name==2) + { + //$exp_name="Forestry Game"; + $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); + + while($data=db_fetch_object($result_group)) + { + $no_of_student=$data->cnt; + $group_no=$data->group_no; + //drupal_set_message(t($no_of_student.' '. $group_no)); + if($no_of_student == 5) + { + db_query("Insert into {virtualcommons_forestry_common_resource_pool} (virtualcommons_student_group_no,common_resource_pool,virtualcommons_conducts_id, harvest_decision,max_harvest_decision) + values(%d,%d,%d,%d,%d)",$group_no,100,$virtual_conduct_id,0,100); + + } + + else if($no_of_student == 4) + { + db_query("Insert into {virtualcommons_forestry_common_resource_pool} (virtualcommons_student_group_no,common_resource_pool,virtualcommons_conducts_id, harvest_decision,max_harvest_decision) + values(%d,%d,%d,%d,%d)",$group_no,80,$virtual_conduct_id,0,80); + } + + + else if($no_of_student == 3) + { + db_query("Insert into {virtualcommons_forestry_common_resource_pool} (virtualcommons_student_group_no,common_resource_pool,virtualcommons_conducts_id, harvest_decision,max_harvest_decision) values(%d,%d,%d,%d,%d)",$group_no,60,$virtual_conduct_id,0,60); + } + + } + + } + else if($exp_name==3) + { + $exp_name="Water Irrigation Game"; + } + + unset($_SESSION['student_info']); + unset($_SESSION['game_name']); + + return 'game_start'; + +} + + + + +function game_start() +{ + $output=t('Please click the Start Game button.'); + $output.=drupal_get_form('game_start_form'); + return $output; +} + + +function game_start_form() +{ + $form['submit'] = array( + '#type' => 'submit', + '#value' => t('Start Game!!!') + ); + return $form; +} + +function game_start_form_submit($form_id,$form_values) +{ + $teacher_id=$GLOBALS['user']->uid; + $virtual_conduct_id=db_result(db_query("select max(id),users_id from {virtualcommons_conducts} where users_id=%d group by users_id",$teacher_id)); + + db_query("update virtualcommons_student set start_flag=true where virtualcommons_conducts_id=%d",$virtual_conduct_id); + 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-07-30 18:23:05
|
Revision: 14 http://virtualcommons.svn.sourceforge.net/virtualcommons/?rev=14&view=rev Author: alllee Date: 2008-07-30 18:23:09 +0000 (Wed, 30 Jul 2008) Log Message: ----------- renaming studentform to student_login module Added Paths: ----------- vcweb/trunk/virtualcommons/experiment/student_login/student_login.info vcweb/trunk/virtualcommons/experiment/student_login/student_login.module Removed Paths: ------------- vcweb/trunk/virtualcommons/experiment/student_login/studentform.info vcweb/trunk/virtualcommons/experiment/student_login/studentform.module Copied: vcweb/trunk/virtualcommons/experiment/student_login/student_login.info (from rev 13, vcweb/trunk/virtualcommons/experiment/student_login/studentform.info) =================================================================== --- vcweb/trunk/virtualcommons/experiment/student_login/student_login.info (rev 0) +++ vcweb/trunk/virtualcommons/experiment/student_login/student_login.info 2008-07-30 18:23:09 UTC (rev 14) @@ -0,0 +1,6 @@ +; $Id$ +name =Student Registration Form +description = Allows students to register at virtual Commons using this registration form. +package=Virtual Commons +version = "student v1.1" + Copied: vcweb/trunk/virtualcommons/experiment/student_login/student_login.module (from rev 13, vcweb/trunk/virtualcommons/experiment/student_login/studentform.module) =================================================================== --- vcweb/trunk/virtualcommons/experiment/student_login/student_login.module (rev 0) +++ vcweb/trunk/virtualcommons/experiment/student_login/student_login.module 2008-07-30 18:23:09 UTC (rev 14) @@ -0,0 +1,76 @@ +<?php +// $Id$ +/** + * implement the _user hook. + */ + +function student_login_perm() +{ + return array('Only Students'); + +} + + + +function student_login_menu($may_cache) { + $items = array(); + if ($may_cache) { + $items[] = array( + 'path' => 'student_login', + 'title' => t('Student Login'), + 'callback' => 'drupal_get_form', + 'callback arguments'=>array(student_login_nameform), + 'access' => TRUE//user_access('Only Students') + ); + + + } + return $items; +} +function student_login_nameform() { +$form = array(); +$form['#id']='student_form'; +$form['student_info'] = array( + '#title' => t('Student Information'), + '#type' => 'fieldset', +'#description'=>t('Please enter correct the student ID, you received from your teacher.') + +); +$form['student_info']['id'] = array( + '#title' => t('Enter the Student ID'), + '#type' => 'textfield', + '#required'=>TRUE + +); + +$form['submit'] = array( + '#type' => 'submit', + '#value' => t('Start Game!!!') +); +return $form; + +} + + +function student_login_nameform_validate($form_id,$form_values) +{ +$stud_id=$form_values['id']; +$result=db_result(db_query("Select id from {virtualcommons_student} where id='%s'",$stud_id)); + +if($result=='') + 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'; +} + + + + Deleted: vcweb/trunk/virtualcommons/experiment/student_login/studentform.info =================================================================== --- vcweb/trunk/virtualcommons/experiment/student_login/studentform.info 2008-07-30 18:18:15 UTC (rev 13) +++ vcweb/trunk/virtualcommons/experiment/student_login/studentform.info 2008-07-30 18:23:09 UTC (rev 14) @@ -1,6 +0,0 @@ -; $Id$ -name =Student Registration Form -description = Allows students to register at virtual Commons using this registration form. -package=Virtual Commons -version = "student v1.1" - Deleted: vcweb/trunk/virtualcommons/experiment/student_login/studentform.module =================================================================== --- vcweb/trunk/virtualcommons/experiment/student_login/studentform.module 2008-07-30 18:18:15 UTC (rev 13) +++ vcweb/trunk/virtualcommons/experiment/student_login/studentform.module 2008-07-30 18:23:09 UTC (rev 14) @@ -1,76 +0,0 @@ -<?php -// $Id$ -/** - * implement the _user hook. - */ - -function studentform_perm() -{ - return array('Only Students'); - -} - - - -function studentform_menu($may_cache) { - $items = array(); - if ($may_cache) { - $items[] = array( - 'path' => 'student_login', - 'title' => t('Student Login'), - 'callback' => 'drupal_get_form', - 'callback arguments'=>array(studentform_nameform), - 'access' => TRUE//user_access('Only Students') - ); - - - } - return $items; -} -function studentform_nameform() { -$form = array(); -$form['#id']='student_form'; -$form['student_info'] = array( - '#title' => t('Student Information'), - '#type' => 'fieldset', -'#description'=>t('Please enter correct the student ID, you received from your teacher.') - -); -$form['student_info']['id'] = array( - '#title' => t('Enter the Student ID'), - '#type' => 'textfield', - '#required'=>TRUE - -); - -$form['submit'] = array( - '#type' => 'submit', - '#value' => t('Start Game!!!') -); -return $form; - -} - - -function studentform_nameform_validate($form_id,$form_values) -{ -$stud_id=$form_values['id']; -$result=db_result(db_query("Select id from {virtualcommons_student} where id='%s'",$stud_id)); - -if($result=='') - form_set_error('id',t('Invalid Student ID. Please contact your instructor.')); - -} - - - -function studentform_nameform_submit($form_id,$form_values) -{ -$_SESSION['student_id']=$form_values['id']; - -return 'forestry'; -} - - - - This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <al...@us...> - 2008-07-30 18:18:09
|
Revision: 13 http://virtualcommons.svn.sourceforge.net/virtualcommons/?rev=13&view=rev Author: alllee Date: 2008-07-30 18:18:15 +0000 (Wed, 30 Jul 2008) Log Message: ----------- renaming to student_login Added Paths: ----------- vcweb/trunk/virtualcommons/experiment/student_login/ Removed Paths: ------------- vcweb/trunk/virtualcommons/experiment/studentform/ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <al...@us...> - 2008-07-30 18:13:09
|
Revision: 12 http://virtualcommons.svn.sourceforge.net/virtualcommons/?rev=12&view=rev Author: alllee Date: 2008-07-30 18:13:15 +0000 (Wed, 30 Jul 2008) Log Message: ----------- renaming to teacher_dashboard Added Paths: ----------- vcweb/trunk/virtualcommons/games/teacher_dashboard/ Removed Paths: ------------- vcweb/trunk/virtualcommons/games/teacher/ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <al...@us...> - 2008-07-30 18:11:36
|
Revision: 11 http://virtualcommons.svn.sourceforge.net/virtualcommons/?rev=11&view=rev Author: alllee Date: 2008-07-30 18:11:41 +0000 (Wed, 30 Jul 2008) Log Message: ----------- creating master experiment module to merge these modules' functionality Added Paths: ----------- vcweb/trunk/virtualcommons/experiment/ vcweb/trunk/virtualcommons/experiment/studentform/ vcweb/trunk/virtualcommons/experiment/studentgroup/ vcweb/trunk/virtualcommons/experiment/teacher_experiments/ Removed Paths: ------------- vcweb/trunk/virtualcommons/studentform/ vcweb/trunk/virtualcommons/studentgroup/ vcweb/trunk/virtualcommons/teacher_experiments/ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <see...@us...> - 2008-07-30 16:46:50
|
Revision: 10 http://virtualcommons.svn.sourceforge.net/virtualcommons/?rev=10&view=rev Author: seematalele Date: 2008-07-30 16:46:55 +0000 (Wed, 30 Jul 2008) Log Message: ----------- Final version of modules with No Object Orientation. Modified Paths: -------------- vcweb/trunk/virtualcommons/games/forestry/forestry_stage2/forestry_stage2.install vcweb/trunk/virtualcommons/games/forestry/forestry_stage2/forestry_stage2.module vcweb/trunk/virtualcommons/games/teacher/teacher.module vcweb/trunk/virtualcommons/teacher_experiments/teacher.php vcweb/trunk/virtualcommons/teacher_experiments/teacher_experiments.module Modified: vcweb/trunk/virtualcommons/games/forestry/forestry_stage2/forestry_stage2.install =================================================================== --- vcweb/trunk/virtualcommons/games/forestry/forestry_stage2/forestry_stage2.install 2008-07-28 23:48:52 UTC (rev 9) +++ vcweb/trunk/virtualcommons/games/forestry/forestry_stage2/forestry_stage2.install 2008-07-30 16:46:55 UTC (rev 10) @@ -28,7 +28,7 @@ ON DELETE CASCADE, FOREIGN KEY(virtualcommons_conducts_id) REFERENCES virtualcommons_conducts(id) - ON DELETE CASCADE, + ON DELETE CASCADE ) /*!40100 DEFAULT CHARACTER SET UTF8 */"); @@ -135,11 +135,11 @@ } if($flag) { -drupal_set_message(t('Forestry database is successfully created.')); +drupal_set_message(t('Forestry database stage2 is successfully created.')); } else { -drupal_set_message(t('Forestry database is NOT successfully created.'),'error'); +drupal_set_message(t('Forestry database stage2 is NOT successfully created.'),'error'); } } @@ -151,6 +151,6 @@ // db_query("DROP TABLE {virtualcommons_forestry_student_stage2}"); db_query("DROP TABLE {virtualcommons_forestry_turn_sequence}"); -drupal_set_message(t('Forestry database is successfully deleted from the database.')); +drupal_set_message(t('Forestry stage2 database is successfully deleted from the database.')); } Modified: vcweb/trunk/virtualcommons/games/forestry/forestry_stage2/forestry_stage2.module =================================================================== --- vcweb/trunk/virtualcommons/games/forestry/forestry_stage2/forestry_stage2.module 2008-07-28 23:48:52 UTC (rev 9) +++ vcweb/trunk/virtualcommons/games/forestry/forestry_stage2/forestry_stage2.module 2008-07-30 16:46:55 UTC (rev 10) @@ -53,6 +53,7 @@ return $output; } + function forestry_stage2_rule1_multiform() { $flag=FALSE; //uneven, if no of students are 3 in a group @@ -87,31 +88,19 @@ else { - $result=db_query(" select group_id,virtualcommons_conducts_id from virtualcommons_student where id='%s'",$stud_id); + $result=db_query(" select group_no,virtualcommons_conducts_id from virtualcommons_student where id='%s'",$stud_id); while($data=db_fetch_object($result)) { - $group_id=$data->group_id; + $group_no=$data->group_id; $conducts_id=$data->virtualcommons_conducts_id; } - //determine the no of students in a group from student id - $no_of_stud=db_result(db_query("select count(group_id) as cnt from virtualcommons_student where virtualcommons_conducts_id=%d and group_id=%d group by group_id",$conducts_id,$group_id)); - - //depending upon the no of students present in the group, draw randomly students from group - - if($no_of_stud ==4 or $no_of_stud==5) - { - - - } - else if($no_of_stud==3) - { - - } - + } +db_query("select turn_sequence from virtualcommons_forestry_turn_sequence where virtualcommons_conducts_id=%d and virtualcommons_student_group_no=%d and virtualcommons_rules_no=%d"); + $_SESSION['prev_resource']=$resource_available; Modified: vcweb/trunk/virtualcommons/games/teacher/teacher.module =================================================================== --- vcweb/trunk/virtualcommons/games/teacher/teacher.module 2008-07-28 23:48:52 UTC (rev 9) +++ vcweb/trunk/virtualcommons/games/teacher/teacher.module 2008-07-30 16:46:55 UTC (rev 10) @@ -55,7 +55,7 @@ //retrive values for stage 1 $header_stage1=array('Round No','Group No', 'Group Harvest Decision','Resources Before','Resources After'); - $result=db_query(" select round_no,virtualcommons_student_group_no,total_harvest_decision,resources_after,resources_before from {virtualcommons_forestry_group_information} where virtualcommons_conducts_id=%d and virtualcommons_stage_no",$virtual_conduct_id); + $result=db_query(" select round_no,virtualcommons_student_group_no,total_harvest_decision,resources_after,resources_before from {virtualcommons_forestry_group_information} where virtualcommons_conducts_id=%d and virtualcommons_stage_no=%d",$virtual_conduct_id,1); while($data=db_fetch_object($result)) { @@ -66,6 +66,7 @@ $resource_after=$data->resources_after; $row_stage1[]=array($round_no,$group_no,$total_harvest_decision,$resource_before,$resource_after); } + if(!isset($form_values)) @@ -84,7 +85,16 @@ $no_rounds=(int) $no_rounds; drupal_set_message(t('no of rounds are: '.$no_rounds)); if($round_no==$no_rounds) - $stage_flag=TRUE; +{ + if(isset($_SESSION['next_stage'])) + { + $stage_flag=FALSE; + unset($_SESSION['next_stage']); + } + else + $stage_flag=TRUE; +} + // $_SESSION['step']=$step; //$form['#redirect']=FALSE; @@ -137,6 +147,28 @@ } +function teacher_dashboard_multiform_validate($form_id,$form_values) +{ + $virtual_conduct_id=(int) $form_values['game_id']; + if($form_values['submit']=="Next Round") + { + } + + else if($form_values['submit']=="Go to Stage 2") + { + $rule_no=db_result(db_query("Select virtualcommons_rule_no from virtualcommons_conducts where id=%d",$virtual_conduct_id)); + if($rule_no==0) + { + form_set_error('submit',t('Please tell students to vote. Without voting you can not proceed to Stage 2')); + } + } + +return; + + +} + + function teacher_dashboard_multiform_submit($form_id,$form_values) { @@ -231,9 +263,10 @@ } else if($form_values['submit']=="Go to Stage 2") { //initialise the stage 2 +// drupal_set_message(t('Go to stage 2')); drupal_set_message(t('Go to stage 2')); $round_no=1; - + $_SESSION['next_stage']='pressed'; //make initialisation for stage2 $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)); @@ -254,6 +287,7 @@ 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); @@ -263,12 +297,13 @@ $stud1=rand(1,$no_of_student); $stud2=rand(1,$no_of_student); - while($stud1 <> $stud2) + 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); @@ -282,12 +317,13 @@ $stud1=rand(1,$no_of_student); $stud2=rand(1,$no_of_student); - while($stud1 <> $stud2) + 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); @@ -299,12 +335,13 @@ $stud1=rand(1,$no_of_student); $stud2=rand(1,$no_of_student); - while($stud1 <> $stud2) + 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); @@ -321,7 +358,7 @@ else if($rule_no==3) { } - + } return 'teacher_dashboard'; } Modified: vcweb/trunk/virtualcommons/teacher_experiments/teacher.php =================================================================== --- vcweb/trunk/virtualcommons/teacher_experiments/teacher.php 2008-07-28 23:48:52 UTC (rev 9) +++ vcweb/trunk/virtualcommons/teacher_experiments/teacher.php 2008-07-30 16:46:55 UTC (rev 10) @@ -5,19 +5,22 @@ private $fname; private $lname; - public function __construct($fname, $lName) { + public function __construct($fname, $lname) { $this->fname = $fname; $this->lname = $lname; } - - public function getfname() { return $this->fname; } + public function getlname() + { + return $this->lname; + } + } Modified: vcweb/trunk/virtualcommons/teacher_experiments/teacher_experiments.module =================================================================== --- vcweb/trunk/virtualcommons/teacher_experiments/teacher_experiments.module 2008-07-28 23:48:52 UTC (rev 9) +++ vcweb/trunk/virtualcommons/teacher_experiments/teacher_experiments.module 2008-07-30 16:46:55 UTC (rev 10) @@ -1,7 +1,7 @@ <?php //$path=drupal_get_filename('module', 'virtualcommons'); -//include($path.'/teacher_experiments/teacher.php'); // or require etc. +//include('teacher.php'); // or require etc. //include('sites/all/modules/virtualcommons/teacher_experiments/class_files/teacher.php'); // $Id$ @@ -147,8 +147,8 @@ { $_SESSION['game_name']=$game_name; } + - //Fishery if($game_name==1) { @@ -166,9 +166,13 @@ $result=db_result(db_query("Select id from {virtualcommons_experiments} where exp_name LIKE '%%Water%%' ")); } +/*$teacher=new Teacher($result,'talele'); +$fname=$teacher->getfname(); +$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. ')); + 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); //echo 'Thanks for filling out the form. Your Game will start soon,'. $fname; return 'studentgroup'; @@ -176,4 +180,4 @@ -?> + This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <see...@us...> - 2008-07-28 23:48:45
|
Revision: 9 http://virtualcommons.svn.sourceforge.net/virtualcommons/?rev=9&view=rev Author: seematalele Date: 2008-07-28 23:48:52 +0000 (Mon, 28 Jul 2008) Log Message: ----------- initial version of virtualcommons web based forestry game. Added Paths: ----------- vcweb/trunk/virtualcommons/ vcweb/trunk/virtualcommons/autoassignrole/ vcweb/trunk/virtualcommons/autoassignrole/.project vcweb/trunk/virtualcommons/autoassignrole/.settings/ vcweb/trunk/virtualcommons/autoassignrole/.settings/org.eclipse.php.core.prefs vcweb/trunk/virtualcommons/autoassignrole/.settings/org.eclipse.php.core.projectOptions.prefs vcweb/trunk/virtualcommons/autoassignrole/LICENSE.txt vcweb/trunk/virtualcommons/autoassignrole/README.txt vcweb/trunk/virtualcommons/autoassignrole/autoassignrole.info vcweb/trunk/virtualcommons/autoassignrole/autoassignrole.install vcweb/trunk/virtualcommons/autoassignrole/autoassignrole.module vcweb/trunk/virtualcommons/games/ vcweb/trunk/virtualcommons/games/fishery/ vcweb/trunk/virtualcommons/games/fishery/fishery_info/ vcweb/trunk/virtualcommons/games/fishery/fishery_info/fishery_info.info vcweb/trunk/virtualcommons/games/fishery/fishery_info/fishery_info.module vcweb/trunk/virtualcommons/games/forestry/ vcweb/trunk/virtualcommons/games/forestry/forestry_game/ vcweb/trunk/virtualcommons/games/forestry/forestry_game/forestry_game.info vcweb/trunk/virtualcommons/games/forestry/forestry_game/forestry_game.install vcweb/trunk/virtualcommons/games/forestry/forestry_game/forestry_game.module vcweb/trunk/virtualcommons/games/forestry/forestry_info/ vcweb/trunk/virtualcommons/games/forestry/forestry_info/forestry_info.info vcweb/trunk/virtualcommons/games/forestry/forestry_info/forestry_info.module vcweb/trunk/virtualcommons/games/forestry/forestry_stage1/ vcweb/trunk/virtualcommons/games/forestry/forestry_stage1/forestry_stage1.info vcweb/trunk/virtualcommons/games/forestry/forestry_stage1/forestry_stage1.module vcweb/trunk/virtualcommons/games/forestry/forestry_stage1/form.css vcweb/trunk/virtualcommons/games/forestry/forestry_stage1/theme/ vcweb/trunk/virtualcommons/games/forestry/forestry_stage1/theme/forestry_stage1.tpl.php vcweb/trunk/virtualcommons/games/forestry/forestry_stage1/theme/form.css vcweb/trunk/virtualcommons/games/forestry/forestry_stage1/theme/template.php vcweb/trunk/virtualcommons/games/forestry/forestry_stage2/ vcweb/trunk/virtualcommons/games/forestry/forestry_stage2/forestry_stage2.info vcweb/trunk/virtualcommons/games/forestry/forestry_stage2/forestry_stage2.install vcweb/trunk/virtualcommons/games/forestry/forestry_stage2/forestry_stage2.module vcweb/trunk/virtualcommons/games/forestry/forestry_stage2/theme/ vcweb/trunk/virtualcommons/games/forestry/forestry_stage2/theme/forestry_stage2.tpl.php vcweb/trunk/virtualcommons/games/forestry/forestry_stage2/theme/form.css vcweb/trunk/virtualcommons/games/forestry/forestry_stage2/theme/template.php vcweb/trunk/virtualcommons/games/rules/ vcweb/trunk/virtualcommons/games/rules/form.css vcweb/trunk/virtualcommons/games/rules/rules.info vcweb/trunk/virtualcommons/games/rules/rules.module vcweb/trunk/virtualcommons/games/teacher/ vcweb/trunk/virtualcommons/games/teacher/teacher.info vcweb/trunk/virtualcommons/games/teacher/teacher.install vcweb/trunk/virtualcommons/games/teacher/teacher.module vcweb/trunk/virtualcommons/games/water/ vcweb/trunk/virtualcommons/games/water/water_info/ vcweb/trunk/virtualcommons/games/water/water_info/water_info.info vcweb/trunk/virtualcommons/games/water/water_info/water_info.module vcweb/trunk/virtualcommons/studentform/ vcweb/trunk/virtualcommons/studentform/studentform.info vcweb/trunk/virtualcommons/studentform/studentform.module vcweb/trunk/virtualcommons/studentgroup/ vcweb/trunk/virtualcommons/studentgroup/studentgroup.info vcweb/trunk/virtualcommons/studentgroup/studentgroup.install vcweb/trunk/virtualcommons/studentgroup/studentgroup.module vcweb/trunk/virtualcommons/teacher_experiments/ vcweb/trunk/virtualcommons/teacher_experiments/teacher.php vcweb/trunk/virtualcommons/teacher_experiments/teacher_experiments.info vcweb/trunk/virtualcommons/teacher_experiments/teacher_experiments.install vcweb/trunk/virtualcommons/teacher_experiments/teacher_experiments.module vcweb/trunk/virtualcommons/teacherform/ vcweb/trunk/virtualcommons/teacherform/teacherform.info vcweb/trunk/virtualcommons/teacherform/teacherform.install vcweb/trunk/virtualcommons/teacherform/teacherform.module vcweb/trunk/virtualcommons/try/ vcweb/trunk/virtualcommons/try/try.info vcweb/trunk/virtualcommons/try/try.module Added: vcweb/trunk/virtualcommons/autoassignrole/.project =================================================================== --- vcweb/trunk/virtualcommons/autoassignrole/.project (rev 0) +++ vcweb/trunk/virtualcommons/autoassignrole/.project 2008-07-28 23:48:52 UTC (rev 9) @@ -0,0 +1,22 @@ +<?xml version="1.0" encoding="UTF-8"?> +<projectDescription> + <name>autoassignrole</name> + <comment></comment> + <projects> + </projects> + <buildSpec> + <buildCommand> + <name>org.eclipse.php.core.PhpIncrementalProjectBuilder</name> + <arguments> + </arguments> + </buildCommand> + <buildCommand> + <name>org.eclipse.wst.validation.validationbuilder</name> + <arguments> + </arguments> + </buildCommand> + </buildSpec> + <natures> + <nature>org.eclipse.php.core.PHPNature</nature> + </natures> +</projectDescription> Added: vcweb/trunk/virtualcommons/autoassignrole/.settings/org.eclipse.php.core.prefs =================================================================== --- vcweb/trunk/virtualcommons/autoassignrole/.settings/org.eclipse.php.core.prefs (rev 0) +++ vcweb/trunk/virtualcommons/autoassignrole/.settings/org.eclipse.php.core.prefs 2008-07-28 23:48:52 UTC (rev 9) @@ -0,0 +1,4 @@ +#Wed Jan 30 10:53:12 GMT-07:00 2008 +eclipse.preferences.version=1 +phpVersion=php5 +use_asp_tags_as_php=false Added: vcweb/trunk/virtualcommons/autoassignrole/.settings/org.eclipse.php.core.projectOptions.prefs =================================================================== --- vcweb/trunk/virtualcommons/autoassignrole/.settings/org.eclipse.php.core.projectOptions.prefs (rev 0) +++ vcweb/trunk/virtualcommons/autoassignrole/.settings/org.eclipse.php.core.projectOptions.prefs 2008-07-28 23:48:52 UTC (rev 9) @@ -0,0 +1,5 @@ +#Wed Jan 30 10:53:12 GMT-07:00 2008 +eclipse.preferences.version=1 +org.eclipse.php.core.contextRoot= +org.eclipse.php.core.defaultEncoding= +org.eclipse.php.core.includePath=<?xml version\="1.0" encoding\="UTF-8"?>\n<includepath>\n</includepath>\n Added: vcweb/trunk/virtualcommons/autoassignrole/LICENSE.txt =================================================================== --- vcweb/trunk/virtualcommons/autoassignrole/LICENSE.txt (rev 0) +++ vcweb/trunk/virtualcommons/autoassignrole/LICENSE.txt 2008-07-28 23:48:52 UTC (rev 9) @@ -0,0 +1,274 @@ +GNU GENERAL PUBLIC LICENSE + + Version 2, June 1991 + +Copyright (C) 1989, 1991 Free Software Foundation, Inc. 675 Mass Ave, +Cambridge, MA 02139, USA. Everyone is permitted to copy and distribute +verbatim copies of this license document, but changing it is not allowed. + + Preamble + +The licenses for most software are designed to take away your freedom to +share and change it. By contrast, the GNU General Public License is +intended to guarantee your freedom to share and change free software--to +make sure the software is free for all its users. This General Public License +applies to most of the Free Software Foundation's software and to any other +program whose authors commit to using it. (Some other Free Software +Foundation software is covered by the GNU Library General Public License +instead.) You can apply it to your programs, too. + +When we speak of free software, we are referring to freedom, not price. Our +General Public Licenses are designed to make sure that you have the +freedom to distribute copies of free software (and charge for this service if +you wish), that you receive source code or can get it if you want it, that you +can change the software or use pieces of it in new free programs; and that +you know you can do these things. + +To protect your rights, we need to make restrictions that forbid anyone to +deny you these rights or to ask you to surrender the rights. These restrictions +translate to certain responsibilities for you if you distribute copies of the +software, or if you modify it. + +For example, if you distribute copies of such a program, whether gratis or for +a fee, you must give the recipients all the rights that you have. You must make +sure that they, too, receive or can get the source code. And you must show +them these terms so they know their rights. + +We protect your rights with two steps: (1) copyright the software, and (2) +offer you this license which gives you legal permission to copy, distribute +and/or modify the software. + +Also, for each author's protection and ours, we want to make certain that +everyone understands that there is no warranty for this free software. If the +software is modified by someone else and passed on, we want its recipients +to know that what they have is not the original, so that any problems +introduced by others will not reflect on the original authors' reputations. + +Finally, any free program is threatened constantly by software patents. We +wish to avoid the danger that redistributors of a free program will individually +obtain patent licenses, in effect making the program proprietary. To prevent +this, we have made it clear that any patent must be licensed for everyone's +free use or not licensed at all. + +The precise terms and conditions for copying, distribution and modification +follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND + MODIFICATION + +0. This License applies to any program or other work which contains a notice +placed by the copyright holder saying it may be distributed under the terms +of this General Public License. The "Program", below, refers to any such +program or work, and a "work based on the Program" means either the +Program or any derivative work under copyright law: that is to say, a work +containing the Program or a portion of it, either verbatim or with +modifications and/or translated into another language. (Hereinafter, translation +is included without limitation in the term "modification".) Each licensee is +addressed as "you". + +Activities other than copying, distribution and modification are not covered +by this License; they are outside its scope. The act of running the Program is +not restricted, and the output from the Program is covered only if its contents +constitute a work based on the Program (independent of having been made +by running the Program). Whether that is true depends on what the Program +does. + +1. You may copy and distribute verbatim copies of the Program's source +code as you receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice and +disclaimer of warranty; keep intact all the notices that refer to this License +and to the absence of any warranty; and give any other recipients of the +Program a copy of this License along with the Program. + +You may charge a fee for the physical act of transferring a copy, and you +may at your option offer warranty protection in exchange for a fee. + +2. You may modify your copy or copies of the Program or any portion of it, +thus forming a work based on the Program, and copy and distribute such +modifications or work under the terms of Section 1 above, provided that you +also meet all of these conditions: + +a) You must cause the modified files to carry prominent notices stating that +you changed the files and the date of any change. + +b) You must cause any work that you distribute or publish, that in whole or in +part contains or is derived from the Program or any part thereof, to be +licensed as a whole at no charge to all third parties under the terms of this +License. + +c) If the modified program normally reads commands interactively when run, +you must cause it, when started running for such interactive use in the most +ordinary way, to print or display an announcement including an appropriate +copyright notice and a notice that there is no warranty (or else, saying that +you provide a warranty) and that users may redistribute the program under +these conditions, and telling the user how to view a copy of this License. +(Exception: if the Program itself is interactive but does not normally print such +an announcement, your work based on the Program is not required to print +an announcement.) + +These requirements apply to the modified work as a whole. If identifiable +sections of that work are not derived from the Program, and can be +reasonably considered independent and separate works in themselves, then +this License, and its terms, do not apply to those sections when you distribute +them as separate works. But when you distribute the same sections as part +of a whole which is a work based on the Program, the distribution of the +whole must be on the terms of this License, whose permissions for other +licensees extend to the entire whole, and thus to each and every part +regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest your rights to +work written entirely by you; rather, the intent is to exercise the right to +control the distribution of derivative or collective works based on the +Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of a +storage or distribution medium does not bring the other work under the scope +of this License. + +3. You may copy and distribute the Program (or a work based on it, under +Section 2) in object code or executable form under the terms of Sections 1 +and 2 above provided that you also do one of the following: + +a) Accompany it with the complete corresponding machine-readable source +code, which must be distributed under the terms of Sections 1 and 2 above +on a medium customarily used for software interchange; or, + +b) Accompany it with a written offer, valid for at least three years, to give +any third party, for a charge no more than your cost of physically performing +source distribution, a complete machine-readable copy of the corresponding +source code, to be distributed under the terms of Sections 1 and 2 above on +a medium customarily used for software interchange; or, + +c) Accompany it with the information you received as to the offer to distribute +corresponding source code. (This alternative is allowed only for +noncommercial distribution and only if you received the program in object +code or executable form with such an offer, in accord with Subsection b +above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source code +means all the source code for all modules it contains, plus any associated +interface definition files, plus the scripts used to control compilation and +installation of the executable. However, as a special exception, the source +code distributed need not include anything that is normally distributed (in +either source or binary form) with the major components (compiler, kernel, +and so on) of the operating system on which the executable runs, unless that +component itself accompanies the executable. + +If distribution of executable or object code is made by offering access to +copy from a designated place, then offering equivalent access to copy the +source code from the same place counts as distribution of the source code, +even though third parties are not compelled to copy the source along with the +object code. + +4. You may not copy, modify, sublicense, or distribute the Program except as +expressly provided under this License. Any attempt otherwise to copy, +modify, sublicense or distribute the Program is void, and will automatically +terminate your rights under this License. However, parties who have received +copies, or rights, from you under this License will not have their licenses +terminated so long as such parties remain in full compliance. + +5. You are not required to accept this License, since you have not signed it. +However, nothing else grants you permission to modify or distribute the +Program or its derivative works. These actions are prohibited by law if you +do not accept this License. Therefore, by modifying or distributing the +Program (or any work based on the Program), you indicate your acceptance +of this License to do so, and all its terms and conditions for copying, +distributing or modifying the Program or works based on it. + +6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the original +licensor to copy, distribute or modify the Program subject to these terms and +conditions. You may not impose any further restrictions on the recipients' +exercise of the rights granted herein. You are not responsible for enforcing +compliance by third parties to this License. + +7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), conditions +are imposed on you (whether by court order, agreement or otherwise) that +contradict the conditions of this License, they do not excuse you from the +conditions of this License. If you cannot distribute so as to satisfy +simultaneously your obligations under this License and any other pertinent +obligations, then as a consequence you may not distribute the Program at all. +For example, if a patent license would not permit royalty-free redistribution +of the Program by all those who receive copies directly or indirectly through +you, then the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under any +particular circumstance, the balance of the section is intended to apply and +the section as a whole is intended to apply in other circumstances. + +It is not the purpose of this section to induce you to infringe any patents or +other property right claims or to contest validity of any such claims; this +section has the sole purpose of protecting the integrity of the free software +distribution system, which is implemented by public license practices. Many +people have made generous contributions to the wide range of software +distributed through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing to +distribute software through any other system and a licensee cannot impose +that choice. + +This section is intended to make thoroughly clear what is believed to be a +consequence of the rest of this License. + +8. If the distribution and/or use of the Program is restricted in certain +countries either by patents or by copyrighted interfaces, the original copyright +holder who places the Program under this License may add an explicit +geographical distribution limitation excluding those countries, so that +distribution is permitted only in or among countries not thus excluded. In such +case, this License incorporates the limitation as if written in the body of this +License. + +9. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will be +similar in spirit to the present version, but may differ in detail to address new +problems or concerns. + +Each version is given a distinguishing version number. If the Program specifies +a version number of this License which applies to it and "any later version", +you have the option of following the terms and conditions either of that +version or of any later version published by the Free Software Foundation. If +the Program does not specify a version number of this License, you may +choose any version ever published by the Free Software Foundation. + +10. If you wish to incorporate parts of the Program into other free programs +whose distribution conditions are different, write to the author to ask for +permission. For software which is copyrighted by the Free Software +Foundation, write to the Free Software Foundation; we sometimes make +exceptions for this. Our decision will be guided by the two goals of +preserving the free status of all derivatives of our free software and of +promoting the sharing and reuse of software generally. + + NO WARRANTY + +11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, +THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT +PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE +STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR +OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT +WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, +INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND +PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL +NECESSARY SERVICING, REPAIR OR CORRECTION. + +12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR +AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR +ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE +LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, +SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES +ARISING OUT OF THE USE OR INABILITY TO USE THE +PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA +OR DATA BEING RENDERED INACCURATE OR LOSSES +SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE +PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN +IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF +THE POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS Added: vcweb/trunk/virtualcommons/autoassignrole/README.txt =================================================================== --- vcweb/trunk/virtualcommons/autoassignrole/README.txt (rev 0) +++ vcweb/trunk/virtualcommons/autoassignrole/README.txt 2008-07-28 23:48:52 UTC (rev 9) @@ -0,0 +1,17 @@ +; $Id $ + +Auto Assign Role +================================================================================ + +This module automatically assigns new users to a specific role when the user +initially signs up for their account. It was written in response to a question +on the support mailing list ... The list asked that it be submitted as a module + so here it is. + +How to use +-------------------------------------------------------------------------------- + +1. Activate the Module +3. Set permissions admin >> user >> access +2. Go into admin >> settings >> autoassignrole and enter the role you want the + new users to have. You have to type the role correctly or it will not work. \ No newline at end of file Added: vcweb/trunk/virtualcommons/autoassignrole/autoassignrole.info =================================================================== --- vcweb/trunk/virtualcommons/autoassignrole/autoassignrole.info (rev 0) +++ vcweb/trunk/virtualcommons/autoassignrole/autoassignrole.info 2008-07-28 23:48:52 UTC (rev 9) @@ -0,0 +1,10 @@ +; $Id $ +name = "Auto Assign Role" +description = "Designate a role to assign all new users to." + + +; Information added by drupal.org packaging script on 2008-02-12 +version = "5.x-1.1" +project = "autoassignrole" +datestamp = "1202837702" + Added: vcweb/trunk/virtualcommons/autoassignrole/autoassignrole.install =================================================================== --- vcweb/trunk/virtualcommons/autoassignrole/autoassignrole.install (rev 0) +++ vcweb/trunk/virtualcommons/autoassignrole/autoassignrole.install 2008-07-28 23:48:52 UTC (rev 9) @@ -0,0 +1,10 @@ +<?php +/** + * Implementation of hook_uninstall(). + */ +function autoassignrole_uninstall() { + $vars = db_query("select name from variable where name like 'AUTOASSIGNROLE_%%'"); + while ($var = db_fetch_object($vars)) { + variable_del($var->name); + } +} \ No newline at end of file Added: vcweb/trunk/virtualcommons/autoassignrole/autoassignrole.module =================================================================== --- vcweb/trunk/virtualcommons/autoassignrole/autoassignrole.module (rev 0) +++ vcweb/trunk/virtualcommons/autoassignrole/autoassignrole.module 2008-07-28 23:48:52 UTC (rev 9) @@ -0,0 +1,233 @@ +<?php +define("AUTOASSIGNROLE_ROLE", ""); +define("AUTOASSIGNROLE_ROLE_ACTIVE", 0); +define("AUTOASSIGNROLE_ROLE_USER_ACTIVE", 0); +define("AUTOASSIGNROLE_ROLE_USER", ""); +define("AUTOASSIGNROLE_ROLE_USER_MULTIPLE", 0); +define("AUTOASSIGNROLE_ROLE_USER_DESCRIPTION", ""); +define("AUTOASSIGNROLE_ROLE_USER_TITLE", t("Role")); +define("AUTOASSIGNROLE_ROLE_SORT", "SORT_ASC"); + +/** + * Implementation of hook_menu(). + * + * @return array + */ +function autoassignrole_menu($may_cache) { + $items = array(); + if ($may_cache) { + $items[] = array( + 'path' => 'admin/user/autoassignrole', + 'title' => t('Auto assign role'), + 'description' => t('Auto Assign Role Settings.'), + 'callback' => 'drupal_get_form', + 'callback arguments' => 'autoassignrole_settings', + 'access' => user_access('administer autoassignrole'), + ); + } + return $items; +} +function autoassignrole_settings() { + $form['autoassignrole_settings_auto'] = array( + '#type' => 'fieldset', + '#title' => t('Automatic Role Assignment'), + '#collapsible' => TRUE, + '#collapsed' => TRUE, + ); + $form['autoassignrole_settings_auto']['AUTOASSIGNROLE_ROLE_ACTIVE'] = array( + '#type' => 'radios', + '#title' => t('Automatic role assignment'), + '#description' => t('Automatic role assignment occurs when the user first logins to the account. This happens without the users knowledge.'), + '#default_value' => variable_get('AUTOASSIGNROLE_ROLE_ACTIVE',0), + '#options' => array(1 => t('Enabled'), 0 => t('Disabled')), + ); + $form['autoassignrole_settings_auto']['AUTOASSIGNROLE_ROLE'] = array( + '#type' => 'checkboxes', + '#title' => t('Role'), + '#default_value' => variable_get('AUTOASSIGNROLE_ROLE',''), + '#options' => user_roles(), + '#description' => t('Select the roles to assign new users.'), + ); + $form['autoassignrole_settings_user'] = array( + '#type' => 'fieldset', + '#title' => t('User Role Assignment'), + '#collapsible' => TRUE, + '#collapsed' => TRUE, + ); + $form['autoassignrole_settings_user']['AUTOASSIGNROLE_ROLE_USER_ACTIVE'] = array( + '#type' => 'radios', + '#title' => t('User Role Assignment'), + '#description' => t('The end user will be allowed to select the following roes when they log in.'), + '#default_value' => variable_get('AUTOASSIGNROLE_ROLE_USER_ACTIVE',0), + '#options' => array(1 => t('Enabled'), 0 => t('Disabled')), + ); + $form['autoassignrole_settings_user']['AUTOASSIGNROLE_ROLE_USER'] = array( + '#type' => 'checkboxes', + '#title' => t('Role'), + '#default_value' => variable_get('AUTOASSIGNROLE_ROLE_USER',''), + '#options' => user_roles(), + '#description' => t('Select the roles that are offered to new users.'), + ); + $form['autoassignrole_settings_user']['AUTOASSIGNROLE_ROLE_USER_MULTIPLE'] = array( + '#type' => 'radios', + '#title' => t('User Role Selection'), + '#description' => t('Should the end user be allowed to choose a single role or can they choose multiple roles?'), + '#default_value' => variable_get('AUTOASSIGNROLE_ROLE_USER_MULTIPLE',0), + '#options' => array(0 => t('Single Role'), 1 => t('Multiple Roles')), + ); + $form['autoassignrole_settings_user']['AUTOASSIGNROLE_ROLE_USER_REQUIRED'] = array( + '#type' => 'checkbox', + '#title' => t('Required'), + '#description' => t('Should the end user be required to choose a role?'), + '#default_value' => variable_get('AUTOASSIGNROLE_ROLE_USER_REQUIRED',0), + ); + $form['autoassignrole_settings_user']['AUTOASSIGNROLE_ROLE_SORT'] = array( + '#type' => 'select', + '#title' => t('Sorting'), + '#description' => t('Default sort order of roles the user will see.'), + '#default_value' => variable_get('AUTOASSIGNROLE_ROLE_SORT','SORT_ASC'), + '#options' => array('SORT_ASC' => t('Ascending'), 'SORT_DESC' => t('Descending')), + ); + $form['autoassignrole_settings_user']['AUTOASSIGNROLE_ROLE_USER_FIELDSET'] = array( + '#type' => 'textfield', + '#title' => t('User Role Fieldset Title'), + '#description' => t('The title of the fieldset that contains role options.'), + '#default_value' => variable_get('AUTOASSIGNROLE_ROLE_USER_FIELDSET', 'User Role Selection'), + '#size' => 60, + '#maxlength' => 128, + '#required' => FALSE, + ); + $form['autoassignrole_settings_user']['AUTOASSIGNROLE_ROLE_USER_TITLE'] = array( + '#type' => 'textfield', + '#title' => t('User Role Title'), + '#description' => t('The title of the field that contains the role options the end user sees during registration.'), + '#default_value' => variable_get('AUTOASSIGNROLE_ROLE_USER_TITLE',""), + '#size' => 60, + '#maxlength' => 128, + '#required' => FALSE, + ); + $form['autoassignrole_settings_user']['AUTOASSIGNROLE_ROLE_USER_DESCRIPTION'] = array( + '#type' => 'textarea', + '#title' => t('User Role Description'), + '#description' => t('The description displayed to the end user when they are selecting thier role during registration.'), + '#default_value' => variable_get('AUTOASSIGNROLE_ROLE_USER_DESCRIPTION',""), + '#required' => FALSE, + ); + return system_settings_form($form); +} +/** + * Implementation of hook_perm(). + * @return array + */ +function autoassignrole_perm() { + return array('administer autoassignrole'); +} + +/** + * Implementation of hook_user(). + */ +function autoassignrole_user($type, &$edit, &$user, $category = NULL) { + switch ($type) { + case 'insert': + if(variable_get('AUTOASSIGNROLE_ROLE_ACTIVE','0') == 1) { + $roles = variable_get('AUTOASSIGNROLE_ROLE','0'); + if(is_array($roles)) { + $sql = 'INSERT INTO {users_roles} (uid, rid) values (%d, %d)'; + foreach($roles as $key => $value) { + if($value > 0) { + db_query($sql, $user->uid, $value); + } + } + } + } + if(variable_get('AUTOASSIGNROLE_ROLE_USER_ACTIVE','0') == 1) { + $sql = 'INSERT INTO {users_roles} (uid, rid) values (%d, %d)'; + if(is_array($edit['AUTOASSIGNROLE_ROLE_USER'])) { + foreach($edit['AUTOASSIGNROLE_ROLE_USER'] as $key => $value) { + if($value > 0) { + db_query($sql, $user->uid, $value); + } + } + } else { + db_query($sql, $user->uid, $edit['AUTOASSIGNROLE_ROLE_USER']); + } + } + break; + } +} + +function autoassignrole_form_alter($form_id, &$form) { + if ($form_id == "user_register" && variable_get('AUTOASSIGNROLE_ROLE_USER_ACTIVE','0') == 1) { + $form['autoassignrole_user'] = array( + '#type' => 'fieldset', + '#title' => variable_get('AUTOASSIGNROLE_ROLE_USER_FIELDSET','User Role Selection'), + '#collapsible' => FALSE, + '#collapsed' => FALSE, + ); + $form['autoassignrole_user']['AUTOASSIGNROLE_ROLE_USER'] = array( + '#type' => _autoassignrole_user_input('type'), + '#title' => variable_get('AUTOASSIGNROLE_ROLE_USER_TITLE',""), + '#options' => _autoassignrole_intersect(), + '#required' => _autoassignrole_user_input('required'), + '#description' => variable_get('AUTOASSIGNROLE_ROLE_USER_DESCRIPTION',""), + ); + } +} +function _autoassignrole_user_input($args) { + switch ($args) { + case 'type': + if(variable_get('AUTOASSIGNROLE_ROLE_USER_MULTIPLE',0) == 0) { + $type = 'radios'; + } else { + $type = 'checkboxes'; + } + return $type; + break; + case 'required': + if(variable_get('AUTOASSIGNROLE_ROLE_USER_REQUIRED',0) == 0) { + $required = FALSE; + } else { + $required = TRUE; + } + return $required; + break; + } +} + +function _autoassignrole_intersect() { + $autoassignrole_roles = variable_get("AUTOASSIGNROLE_ROLE_USER",""); + foreach($autoassignrole_roles as $key => $value) { + if($value == 0) { + unset($autoassignrole_roles[$key]); + } + } + $result = _autoassignrole_array_intersect_key(user_roles(), $autoassignrole_roles); + if(variable_get("AUTOASSIGNROLE_ROLE_SORT", "SORT_ASC") == "SORT_ASC") { + array_multisort($result,SORT_ASC); + } else { + array_multisort($result,SORT_DESC); + } + return $result; +} +function _autoassignrole_array_intersect_key($isec, $keys) { + $argc = func_num_args(); + if ($argc > 2) { + for ($i = 1; !empty($isec) && $i < $argc; $i++) { + $arr = func_get_arg($i); + foreach (array_keys($isec) as $key) { + if (!isset($arr[$key])) { + unset($isec[$key]); + } + } + } + return $isec; + } else { + $res = array(); + foreach (array_keys($isec) as $key) { + if (isset($keys[$key])) { + $res[$key] = $isec[$key]; + } + } + return $res; + } +} Added: vcweb/trunk/virtualcommons/games/fishery/fishery_info/fishery_info.info =================================================================== --- vcweb/trunk/virtualcommons/games/fishery/fishery_info/fishery_info.info (rev 0) +++ vcweb/trunk/virtualcommons/games/fishery/fishery_info/fishery_info.info 2008-07-28 23:48:52 UTC (rev 9) @@ -0,0 +1,6 @@ +; $Id$ +name = Fishery Game Information +description = Fishery Game Information. +package=Virtual Commons Game +version = "fishery_info v1.1" + Added: vcweb/trunk/virtualcommons/games/fishery/fishery_info/fishery_info.module =================================================================== --- vcweb/trunk/virtualcommons/games/fishery/fishery_info/fishery_info.module (rev 0) +++ vcweb/trunk/virtualcommons/games/fishery/fishery_info/fishery_info.module 2008-07-28 23:48:52 UTC (rev 9) @@ -0,0 +1,86 @@ +<?php +//$Id$ + +function fishery_info_menu($may_cache) +{ + $items=array(); + if($may_cache) + { + + $items[]=array( + 'path'=>'games/fishery', + 'title'=>t('Fishery Game'), + 'callback'=>'fishery_info_intro', + 'type'=>MENU_CALLBACK + ); + + $items[]=array( + 'path'=>'games/fishery/documentation', + 'title'=>t('Documentation'), + 'type'=>MENU_DEFAULT_LOCAL_TASK, + 'callback'=>'fishery_info_documentation', + 'access'=>TRUE, + 'weight'=>0 + ); + + $items[]=array( + 'path'=>'games/fishery/tutorial', + 'title'=>t('Tutorial'), + 'type'=>MENU_LOCAL_TASK, + 'callback'=>'fishery_info_tutorial', + 'access'=>TRUE, + 'weight'=>1 + ); + + $items[]=array( + 'path'=>'games/fishery/links', + 'title'=>t('Links'), + 'type'=>MENU_LOCAL_TASK, + 'callback'=>'fishery_info_links', + 'access'=>TRUE, + 'weight'=>2 + ); + } + return $items; +} + +function fishery_info_intro() +{ +return t('<b>Fishery Introduction:</b><br/> +<p>In the fishery game participants decide each round where to fish and how much effort to exert. +There are two locations A and B they can choose to go to, and they can choose to exert low or +high levels of effort. There is a slightly higher return from a high effort compare to a low effort +(see Table 4 below). The payoff table is the same for both locations, and the initial state of the +resource is the high fish availability. However, when the total effort in a location is five or +more units, the state of the fish stock will move to the low availability. This situation can only +be reversed when in two consecutive rounds not more than one unit of effort is invested in +that location. When participants behave opportunistically they move to the low state of both +resources in two rounds, and get stuck in that situation for the remainder of the rounds. For a +sequence of 10 rounds, this opportunistic behavior will result in 200 tokens for the 5 people +group. However, if they would be able to coordinate their efforts, the cooperative solution +leads to 382 tokens by spreading the effort equally over the two resources where at least two +people do not exert the maximum effort.</p>'); + +} + +function fishery_info_documentation() +{ +return t('<b>Fishery documentation:</b><br/><p>This is a documentation page.</p>'); + + +} + +function fishery_info_tutorial() +{ +return t('<b>Fishery Tutorial:</b><br/><p>This is a tutorial page.</p>'); + + +} + + +function fishery_info_links() +{ +return t('<b>Fishery Links:</b><br/><p>This is a Link page.</p>'); + +} + Added: vcweb/trunk/virtualcommons/games/forestry/forestry_game/forestry_game.info =================================================================== --- vcweb/trunk/virtualcommons/games/forestry/forestry_game/forestry_game.info (rev 0) +++ vcweb/trunk/virtualcommons/games/forestry/forestry_game/forestry_game.info 2008-07-28 23:48:52 UTC (rev 9) @@ -0,0 +1,6 @@ +; $Id$ +name = Forestry Game +description = Allows students to play Forestry Game. +package=Virtual Commons Game +version = "forestry v1.1" + Added: vcweb/trunk/virtualcommons/games/forestry/forestry_game/forestry_game.install =================================================================== --- vcweb/trunk/virtualcommons/games/forestry/forestry_game/forestry_game.install (rev 0) +++ vcweb/trunk/virtualcommons/games/forestry/forestry_game/forestry_game.install 2008-07-28 23:48:52 UTC (rev 9) @@ -0,0 +1,89 @@ +<?php +// $Id$ +/** + * Implementation of hook_install(). + */ +function forestry_game_install() { + switch ($GLOBALS['db_type']) { + case 'mysql': + case 'mysqli': + + db_query("CREATE TABLE {virtualcommons_forestry_student} ( + id int NOT NULL AUTO_INCREMENT, + round_no int NOT NULL, + virtualcommons_student_id varchar(14) NOT NULL, + virtualcommons_stage_no int NOT NULL, + virtualcommons_student_group_no int NOT NULL, + harvest_decision int NOT NULL, + turn_no int default NULL, + fine int, + total_points int, + date DATE NOT NULL, + + PRIMARY KEY(id), + + FOREIGN KEY(virtualcommons_student_id) REFERENCES virtualcommons_student(id) + ON DELETE CASCADE, + + FOREIGN KEY(virtualcommons_stage_no) REFERENCES virtualcommons_stage(stage_no) + ON DELETE CASCADE, + + FOREIGN KEY(virtualcommons_student_group_no) REFERENCES virtualcommons_student(group_no) + ON DELETE CASCADE + + + ) /*!40100 DEFAULT CHARACTER SET UTF8 */"); + +$flag=TRUE; + break; + case 'pgsql': + + db_query("CREATE TABLE {virtualcommons_forestry_student} ( + id int NOT NULL AUTO_INCREMENT, + round_no int NOT NULL, + virtualcommons_student_id varchar(14) NOT NULL, + virtualcommons_stage_no int NOT NULL, + virtualcommons_student_group_no int NOT NULL, + harvest_decision int NOT NULL, + turn_no, + fine int default 0, + total_points int deafult 0, + date DATE NOT NULL, + + PRIMARY KEY(id), + + FOREIGN KEY(virtualcommons_student_id) REFERENCES virtualcommons_student(id) + ON DELETE CASCADE, + + FOREIGN KEY(virtualcommons_stage_no) REFERENCES virtualcommons_stage(stage_no) + ON DELETE CASCADE, + + FOREIGN KEY(virtualcommons_student_group_no) REFERENCES virtualcommons_student(group_no) + ON DELETE CASCADE + + + ) /*!40100 DEFAULT CHARACTER SET UTF8 */"); + +$flag=TRUE; + break; +default: +drupal_set_message(t('Unsupported Database')); + } +if($flag) +{ +drupal_set_message(t('Forestry stage1 database is successfully created.')); +} +else +{ +drupal_set_message(t('Forestry stage1 database is NOT successfully created.'),'error'); +} +} + +/** + * Implementation of hook_uninstall(). + */ +function forestry_game_uninstall() { + db_query("DROP TABLE {virtualcommons_forestry_student}"); + drupal_set_message(t('Forestry stage table is successfully deleted from the database.')); +} + Added: vcweb/trunk/virtualcommons/games/forestry/forestry_game/forestry_game.module =================================================================== --- vcweb/trunk/virtualcommons/games/forestry/forestry_game/forestry_game.module (rev 0) +++ vcweb/trunk/virtualcommons/games/forestry/forestry_game/forestry_game.module 2008-07-28 23:48:52 UTC (rev 9) @@ -0,0 +1,159 @@ +<?php + +//$path=drupal_get_filename('module', 'virtualcommons'); +//include($path.'/forestry/teacher.php'); // or require etc. +//include('sites/all/modules/virtualcommons/forestry/class_files/teacher.php'); + +// $Id$ +/** + * implement the _user hook. + + +**/ + + + +/*function forestry_game_perm() +{ + return array('Only Teachers'); + +}*/ + +// $Id$ +/** + * Implementation of hook_menu(). + */ +function forestry_game_menu($may_cache) { + $items = array(); + if ($may_cache) { + $items[] = array('path' => 'forestry', + 'title' => t('Forestry Game'), + 'callback' => 'forestry_game_page', + 'type'=>MENU_CALLBACK, + 'access' => TRUE//user_access('Only Teachers') + ); + + + } + return $items; +} +/** + * Called when user goes to example.com/?q=forestry + */ +function forestry_game_page() { + $output = t('Please note the following maximum harvest table.'); + // Return the HTML generated from the $form data structure. + $output .= drupal_get_form('forestry_game_nameform'); + return $output; +} +/** + * Defines a form. + */ +function forestry_game_nameform() { + +//$form['#method']='post'; +//+$form['#action']='http://localhost/drupal/?q=studentgroup'; +$form['#id']='forestry_game'; +$header = array('Current Resource Level', 'Individual Maximum Harvest Level'); + +$stud_id=$_SESSION['student_id']; + +$result_conducts=db_query("select virtualcommons_conducts_id,group_no from {virtualcommons_student} where id='%s'",$stud_id); +$cnt=0; +while($data=db_fetch_object($result_conducts)) +{ +$id=$data->virtualcommons_conducts_id; +$group_no=$data->group_no; +//drupal_set_message(t($id.' '. $group_no)); +$result_group=db_result(db_query("select count(group_no) from {virtualcommons_student} where virtualcommons_conducts_id= %d and group_no= %d group by group_no",$id,$group_no)); +//drupal_set_message(t('Group no'. $result_group)); +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($data2=db_fetch_object($result)) +{ +$min=$data2->min_resource_level; + +$max=$data2->max_resource_level; +$ind=$data2->individual_harvest_level; +$row[]=array($min.' - '.$max,$ind); +$cnt++; +//drupal_set_message(t($min . " " . $max . " " . $ind)); +} +//drupal_set_message(t('Count is: '. $cnt)); +$_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; +} +/** + * Validate the form. + */ +/** + * Handle post-validation form submission. + */ +function forestry_game_nameform_submit($form_id, $form_values) +{ + $stud_id=$_SESSION['student_id']; + $flag=db_result(db_query("Select start_flag from virtualcommons_student where id='%s'",$stud_id)); + $virtual_conduct_id=db_result(db_query("select virtualcommons_conducts_id from virtualcommons_student where id='%s' ",$stud_id)); + $virtualcommons_stage_no=db_result(db_query("select virtualcommons_stage_no from virtualcommons_conducts where id=%d",$virtual_conduct_id)); + $virtualcommons_stage_no=(int) $virtualcommons_stage_no; + if($flag) + { + if($virtualcommons_stage_no==1) + return 'forestry_stage1'; + else if($virtualcommons_stage_no==2) + { + $virtualcommons_rule_no=db_result(db_query("select virtualcommons_rule_no from virtualcommons_conducts where id=%d",$virtual_conduct_id)); + $virtualcommons_rule_no=(int) $virtualcommons_rule_no; + if($virtualcommons_rule_no==1) + { + return 'forestry_stage2_rule1'; + + } + if($virtualcommons_rule_no==2) + { + return 'forestry_stage2_rule2'; + } + if($virtualcommons_rule_no==3) + { + return 'forestry_stage2_rule3'; + } + + } + } + else + return 'forestry'; +} + + + Added: vcweb/trunk/virtualcommons/games/forestry/forestry_info/forestry_info.info =================================================================== --- vcweb/trunk/virtualcommons/games/forestry/forestry_info/forestry_info.info (rev 0) +++ vcweb/trunk/virtualcommons/games/forestry/forestry_info/forestry_info.info 2008-07-28 23:48:52 UTC (rev 9) @@ -0,0 +1,6 @@ +; $Id$ +name = Forestry Game Information +description = Forestry Game Information. +package=Virtual Commons Game +version = "forestry_info v1.1" + Added: vcweb/trunk/virtualcommons/games/forestry/forestry_info/forestry_info.module =================================================================== --- vcweb/trunk/virtualcommons/games/forestry/forestry_info/forestry_info.module (rev 0) +++ vcweb/trunk/virtualcommons/games/forestry/forestry_info/forestry_info.module 2008-07-28 23:48:52 UTC (rev 9) @@ -0,0 +1,77 @@ +<?php +//$Id$ + +function forestry_info_menu($may_cache) +{ + $items=array(); + if($may_cache) + { + + $items[]=array( + 'path'=>'games/forestry', + 'title'=>t('Forestry Game'), + 'callback'=>'forestry_info_intro', + 'type'=>MENU_CALLBACK + ); + + $items[]=array( + 'path'=>'games/forestry/documentation', + 'title'=>t('Background'), + 'type'=>MENU_DEFAULT_LOCAL_TASK, + 'callback'=>'forestry_info_documentation', + 'access'=>TRUE, + 'weight'=>0 + ); + + $items[]=array( + 'path'=>'games/forestry/tutorial', + 'title'=>t('Tutorial'), + 'type'=>MENU_LOCAL_TASK, + 'callback'=>'forestry_info_tutorial', + 'access'=>TRUE, + 'weight'=>1 + ); + + $items[]=array( + 'path'=>'games/forestry/links', + 'title'=>t('Links'), + 'type'=>MENU_LOCAL_TASK, + 'callback'=>'forestry_info_links', + 'access'=>TRUE, + 'weight'=>2 + ); + } + return $items; +} + +function forestry_info_intro() +{ +return t('<b>Forestry Background:</b><br/> +<p>The key feature of the forestry game is the renewable component of the stock of timber. The +stock is represented as 100 magnets, trees, on a board. In each round participants can take a +maximum of 5 magnets from the board. The stock will regenerate. For every 10 magnets on +the board, one magnet is added, with a maximum of 100 magnets. </p>'); + +} + +function forestry_info_documentation() +{ +return t('<b>Forestry Background:</b><br/><p>The forestry experiment represents a basic dynamic resource. Starting with a pristine resource, participants can collect every round some of it’s units. There is a 10% regrowth of the resource between the rounds, but if more than 10% is collected every round, the resource will decline. The challenge in this experiment is to limit the amount of units participants collect from the resource to avoid overharvesting.</p>'); + + +} + +function forestry_info_tutorial() +{ +return t('<b>Forestry Tutorial:</b><br/><p>This is a tutorial page.</p>'); + + +} + + +function forestry_info_links() +{ +return t('<b>Forestry Links:</b><br/><p>This is a Link page.</p>'); + +} + Added: vcweb/trunk/virtualcommons/games/forestry/forestry_stage1/forestry_stage1.info =================================================================== --- vcweb/trunk/virtualcommons/games/forestry/forestry_stage1/forestry_stage1.info (rev 0) +++ vcweb/trunk/virtualcommons/games/forestry/forestry_stage1/forestry_stage1.info 2008-07-28 23:48:52 UTC (rev 9) @@ -0,0 +1,6 @@ +; $Id$ +name = Forestry Game Stage1 +description = Forestry Game Stage1. +package=Virtual Commons Game +version = "forestry_stage1 v1.1" + Added: vcweb/trunk/virtualcommons/games/forestry/forestry_stage1/forestry_stage1.module =================================================================== --- vcweb/trunk/virtualcommons/games/forestry/forestry_stage1/forestry_stage1.module (rev 0) +++ vcweb/trunk/virtualcommons/games/forestry/forestry_stage1/forestry_stage1.module 2008-07-28 23:48:52 UTC (rev 9) @@ -0,0 +1,386 @@ +<?php + +function forestry_stage1_menu($may_cache) { + $items = array(); + if ($may_cache) { + +$items[]=array( 'path' => 'forestry_stage1', + 'title' => t('Forestry Game - Stage 1'), + 'callback' => 'forestry_game_stage1', + '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 { + forestry_stage1_load(); + } + return $items; +} + +function forestry_game_stage1() { + + // Return the HTML generated from the $form data structure. + $output = drupal_get_form('forestry_game_stage1_multiform'); + return $output; +} + +function forestry_stage1_load() { + static $loaded = FALSE; + + if (!$loaded) { + $path = drupal_get_path('module', 'forestry_stage1'); + drupal_add_css($path .'/form.css'); + $loaded = TRUE; + } +} + +function forestry_game_stage1_multiform() +{ + +$form['#id']='forestry_game_stage1_multiform'; +//$form['#multistep']=TRUE; +$form['#tree'] = TRUE; +$resource_after=0; +$resource_before=0; + +$stud_id=$_SESSION['student_id']; +$resource_available=0; +$round_no=0; + + + //get the availble resource from the database + $result=db_query("select group_no,virtualcommons_conducts_id from virtualcommons_student where id='%s'",$stud_id); + while($data=db_fetch_object($result)) + { + $group_no=$data->group_no; + $conducts_id=$data->virtualcommons_conducts_id; + } + + $resource_available= db_result(db_query("Select common_resource_pool from virtualcommons_forestry_common_resource_pool where virtualcommons_student_group_no=%d and virtualcommons_conducts_id=%d",$group_no,$conducts_id)); + drupal_set_message(t('reosurce available : '. $resource_available)); + $resource_available =(int) $resource_available; + + 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; + + $header=array("Round Number","Your Harvest Decision","Resources Before","Resources After"); + $result=db_query("select round_no,harvest_decision from virtualcommons_forestry_student where virtualcommons_student_id= '%s' ",$stud_id); + while($data=db_fetch_object($result)) + { + $round_no=$data->round_no; + $harvest_decision=$data->harvest_decision; + $round_no=(int)$round_no; + //$resources_before=$data->resources_before; + //$resources_after=$data->resources_after; + $resource_info= db_query("select resources_before,resources_after from virtualcommons_forestry_group_information where virtualcommons_student_group_no=%d and virtualcommons_conducts_id=%d and round_no=%d",$group_no,$conducts_id,$round_no); + while($data_resource=db_fetch_object($resource_info)) + { + $resources_before=$data_resource->resources_before; + $resources_after=$data_resource->resources_after; + } + $final_row[]=array($round_no,$harvest_decision,$resources_before,$resources_after); + } + $round_no=$round_no+1; + drupal_set_message(t('round no: ' . $round_no)); + + + +//store the round no in hidden field + +$form['round_no']=array( + '#type'=>'hidden', + '#value'=>$round_no + ); + + +$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('no of rounds are: '.$no_rounds)); +if($round_no <= $no_rounds) +{ + + $form['resources_available']=array( + + '#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('Next') + ); +} +else +{ + $form['indicator']['submit'] = array( + '#type' => 'submit', + '#value' => t('Stage 2') + ); + +} + + $form['resource']=array( + + '#type'=>'fieldset', + '#title'=>t('<b>Resources</b>'), + + ); + $form['resource']['table']=array( + '#type'=>'markup', + '#value'=>theme('table',$header,$final_row) + ); + + +return $form; + +} + + + +function forestry_game_stage1_multiform_validate($form_id,$form_values) +{ +$harvest_decision=$form_values['indicator']['harvest_decision']; +$resource=(int) $_SESSION['prev_resource']; +//$resource=100; +$flag=FALSE; + +if(preg_match('/[^0-9]+/',$harvest_decision)) +{ + form_set_error('harvest_decision',t('Harvest Decison can not be alphabet or special character.')); +} +else +{ + + $harvest_table= $_SESSION['harvest_table']; + + foreach($harvest_table as $key=> $value) + { + + if(!$flag) + { + foreach($value as $key=>$value) + { + + if($key==0) + { + //get min and maximum value of the resource + $harvest_tbl=explode("-",$value); + $min_resource=(int) $harvest_tbl[0]; + $max_resource=(int) $harvest_tbl[1]; + + } + else if($key==1) + { + //get the maximum units player can invest + $harvest_units=(int) $value; + /*drupal_set_message(t('Min : '.$min_resource)); + drupal_set_message(t('Max : '.$max_resource)); + drupal_set_message(t('Units can harvest: '.$harvest_units)); + drupal_set_message(t('Resource can harvest: '.$resource)); + drupal_set_message(t('comparision: '. ($harvest_decision > $harvest_units)));*/ + if(($resource >= $min_resource) && ($resource <= $max_resource)) + { + //depending upon the resource available player can invest units. e.g in group of 5 and resource available=100 then player can invest max 5 units. + //drupal_set_message(t('resource condition successful: ')); + $harvest_decision=(int) $harvest_decision; + if($harvest_decision > $harvest_units) + { + if($harvest_units ==0 ) + form_set_error('harvest_decision',t('Current Resource Level is very low. You can not harvest anything. <br><b>GAME OVER!!!</b>')); + else + form_set_error('harvest_decision',t('Harvest Decison can not be more than %harvest_units.',array('%harvest_units'=>$harvest_units))); + $flag=TRUE; + } + else + $flag=FALSE; + + } + + } + }//end of for1 + + }// end of if(flag) + +if($flag) + break; + + }//end of for 2 + +} + + +return; + +} + + +function forestry_game_stage1_multiform_submit($form_id,$form_values) +{ + +$harvest_table=$_SESSION['harvest_table']; +//$harvest_tbl=explode("-",$harvest_table); +$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)); + +$stud_harvest_decision=(int) $form_values['indicator']['harvest_decision']; + + +$round_no=$form_values['round_no']; +$round_no=(int) $round_no; + +//get the student +$stud_id=$_SESSION['student_id']; + +$resources_before=(int) $_SESSION['prev_resource']; + +drupal_set_message(t('resource_before:'. $resources_before)); + +//insert into the database virtualcommons_forestry_student +$group_no=db_result(db_query(" select group_no from virtualcommons_student where id='%s'",$stud_id)); +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); + + $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('$no_rounds' . $no_rounds . '$round_no' . $round_no)); +if($form_values['indicator']['submit']=="Stage 2") +{ + db_query("update virtualcommons_conducts set virtualcommons_stage_no=%d where id=%d",2,$virtual_conducts_id); + unset($_SESSION['prev_resource']); + + return 'rules'; +} +else + return 'forestry_stage1_part2'; + + +} + +function theme_forestry_game_stage1_multiform($form) +{ +$output='<div class="indicator"><table style="text-align: center; width: 100%;" border="0" + cellpadding="0" cellspacing="0"> + <tbody> + <tr> + <td style="width: 80%;"> </td> + + <td>'; +$output.=drupal_render($form ['resources_available']); +$output.='</td> + </tr> + + + <tr> + <td style="width: 30%;" colspan="2" rowspan="1">'; +$output.= drupal_render($form['indicator']); + + +$output.= drupal_render($form['indicator']['harvest_decision']); +$output.='</td>'; + //<td style="text-align: center;" colspan="2" rowspan="1">'; +$output.=drupal_render($form['indicator']['submit']); +$output.=' + </tr><tr> <td> </td> </tr> +<tr> + <td colspan="2" rowspan="1">'; + +$output.=drupal_render($form['resource']); + +$output.=drupal_render($form['resource']['table']); +$output.=' + </td> + </tr> + </tbody> + </table> +</div>'; +$output.=drupal_render($form); +return $output; + +} + + +function forestry_game_stage1_part2() +{ + +$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() +{ + + $form['submit'] = array( + '#type' => 'submit', + '#value' => t('Next Round') + ); +return $form; +} + + + +function forestry_game_stage1_part2form_submit($form_id,$form_values) +{ + $stud_id=$_SESSION['student_id']; + $round_no=db_result(db_query(" select max(round_no) from virtualcommons_forestry_student wher... [truncated message content] |
From: <al...@us...> - 2008-07-26 06:18:23
|
Revision: 8 http://virtualcommons.svn.sourceforge.net/virtualcommons/?rev=8&view=rev Author: alllee Date: 2008-07-26 06:18:33 +0000 (Sat, 26 Jul 2008) Log Message: ----------- changing compile to -source 1.6 Modified Paths: -------------- foraging/trunk/build.xml foraging/trunk/pom.xml Modified: foraging/trunk/build.xml =================================================================== --- foraging/trunk/build.xml 2008-07-26 05:19:15 UTC (rev 7) +++ foraging/trunk/build.xml 2008-07-26 06:18:33 UTC (rev 8) @@ -42,7 +42,7 @@ uri="antlib:org.apache.ivy.ant" classpathref="ivy.lib.path"/> </target> - <target name='resolve' description='--> retrieve dependencies with ivy'> + <target name='resolve' depends='init-ivy' description='--> retrieve dependencies with ivy'> <ivy:retrieve pattern='${lib.dir}/[conf]/[artifact].[ext]'/> </target> @@ -113,7 +113,7 @@ </echo> </target> - <target name='build-all' depends='facilitator-jar, client-jar, server-jar, compile, clean'/> + <target name='build-all' depends='facilitator-jar, client-jar, server-jar, compile'/> <!-- deploys the client jar to the appropriate webapps directory. --> <target name='deploy' depends='build-all'> @@ -288,21 +288,11 @@ </target> - <!-- Build private-level documentation --> - <target name="private-docs"> - <javadoc sourcepath="${src.dir}" - destdir="${javadoc.private.dir}" - packagenames="*" - link="http://java.sun.com/j2se/1.4/docs/api/" - source="1.4" - access="private"/> - </target> - <!-- Compile Tests --> <target name="compile-tests" depends="compile"> <javac srcdir="${test.src.dir}" destdir="${test.build.dir}" - source="1.5" + source="1.6" debug="on"> <!-- <compilerarg value='-Xlint:unchecked'/> --> <classpath refid="project.classpath" /> Modified: foraging/trunk/pom.xml =================================================================== --- foraging/trunk/pom.xml 2008-07-26 05:19:15 UTC (rev 7) +++ foraging/trunk/pom.xml 2008-07-26 06:18:33 UTC (rev 8) @@ -53,8 +53,8 @@ <plugin> <artifactId>maven-compiler-plugin</artifactId> <configuration> - <source>1.5</source> - <target>1.5</target> + <source>1.6</source> + <target>1.6</target> </configuration> </plugin> </plugins> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |