[virtualcommons-svn] SF.net SVN: virtualcommons:[16] vcweb/trunk/virtualcommons
Status: Beta
Brought to you by:
alllee
|
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] |