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