Skip to content
Browse files

removed bad newlines, which caused double-spacing in PHP source

  • Loading branch information...
1 parent 2cc5770 commit 64b4e0f155c2c9a1f27dc41f018a910bd5853a99 gbateson committed
View
256 mod/hotpot/README.TXT
@@ -1,151 +1,105 @@
-This is v2.1.5 of the HotPot module
- This module allows teachers to administer Hot Potatoes and TexToys quizzes via Moodle.
- It has been tested on:
- - Hot Potatoes 6
- - Moodle 1.1 thru 1.6
- - PHP 4.1 thru 5.0
- - MySQL and PostgreSQL databases
-
- This module may be distributed under the terms of the General Public License
- (see http://www.gnu.org/licenses/gpl.txt for details)
-
- This software is provided "AS IS" without a warranty of any kind.
-
- Sponsors who have generously contributed to the development of this software:
-
- - Agencia de Gestio d'Ajuts Universitaris i de Recerca (AGAUR),
- Autonomous Government of Catalonia, Spain
- (via Josep M. Fontana, Universitat Pompeu Fabra)
-
- - Rikkyo Univeristy, Japan (via Paul Allum)
-
- - Universite de Franche-Comte, France (via Glenys Hanson)
-
-
-================
-IMPORTANT NOTICE
-================
-* Please be sure to use Hot Potatoes according to the conditions of use which are listed at the end of this file. If you restrict use via a required Moodle login, you most likely can still meet the 'freely available' condition if you make the same material on a separate URL that permits free access. Otherwise, please purchase a license.
-
-
-TO INSTALL OR UPDATE THIS MODULE
-
-1. Install the core scripts of the hotpot module
-
- EITHER:
- (a) download the zip file into the "moodle/mod" folder on your Moodle site
- (b) unzip the zip file. This will create a folder called "moodle/mod/hotpot" on your Moodle site
-
- OR:
- (a) download the zip file onto your PC
- (b) upzip the zip file on your PC. This will create a "hotpot" folder on your PC
- (c) create a folder called "hotpot" on your Moodle site in the "moodle/mod" folder
- (d) upload the contents of the "hotpot" folder on your PC to the "moodle/mod/hotpot" folder on the Moodle site
-
-2. Install the messages and help files of the hotpot module
-
- EITHER:
- (a) copy "moodle/mod/hotpot/lang/en/hotpot.php" on the Moodle site to "moodle/lang/en/hotpot.php"
- (b) copy "moodle/mod/hotpot/lang/en/help/hotpot" on the Moodle site to "moodle/lang/en/help/hotpot"
- (c) repeat for other languages you require from the "moodle/mod/hotpot/lang" folder
-
- OR:
- (a) upload the "hotpot/lang/en/hotpot.php" file on your PC to "moodle/lang/en/hotpot.php" on the Moodle site
- (b) create a folder called "hotpot" on your Moodle site in the "moodle/lang/en/help" folder
- (c) upload the contents of the "hotpot/lang/en/help/hotpot" folder on your PC to the "moodle/lang/en/help/hotpot" folder on the Moodle site
- (d) repeat for other languages you require from the "moodle/mod/hotpot/lang" folder
-
-3. copy and set up the file icons
- [This step is not required for Moodle 1.5 and later, and is optional for Moodle 1.1 to 1.4]
-
- (a) copy the files in the "mod/hotpot/pix/f" folder on your Moodle site to "moodle/pix/f"
- (b) open the "moodle/files/mimetypes.php" file on your Moodle site with a text editor
- (c) insert the following lines just AFTER the line which reads "$mimeinfo = array (":
-
- // additional mimetypes for the "hotpot" module
- "jcb" => array ("type"=>"text/xml", "icon"=>"jcb.gif"),
- "jcl" => array ("type"=>"text/xml", "icon"=>"jcl.gif"),
- "jcw" => array ("type"=>"text/xml", "icon"=>"jcw.gif"),
- "jmt" => array ("type"=>"text/xml", "icon"=>"jmt.gif"),
- "jmx" => array ("type"=>"text/xml", "icon"=>"jmx.gif"),
- "jqz" => array ("type"=>"text/xml", "icon"=>"jqz.gif"),
- "rhb" => array ("type"=>"text/xml", "icon"=>"xml.gif"),
- "sqt" => array ("type"=>"text/xml", "icon"=>"xml.gif"),
-
- (d) save the changes and close the file
-
-4. enable import from Hot Potatoes XML files to Moodle's Quiz module
- [This step is not required for Moodle 1.5 and later, and is optional for Moodle 1.1 to 1.4]
-
- (a) create a folder called "hotpot" on your Moodle site in the "moodle/mod/quiz/format" folder
- (b) copy the "contents of the "moodle/mod/hotpot/quiz/format/hotpot" folder on your Moodle site to the "moodle/mod/quiz/format/hotpot" folder
- (c) open the "moodle/lang/en/quiz.php" file on your Moodle site with a text editor
- (d) insert the following line just BEFORE the final line which reads "?>":
-
- $string['hotpot'] = 'Hot Potatoes XML format';
-
- (d) save the changes and close the file
-
- Steps (e), (f) and (g) are only required on Moodle 1.4.5
-
- (e) open the "moodle/mod/quiz/import.php" file on your Moodle site with a text editor
- (f) if necessary, add 'hotpot' to the "fileformats" array on lines 9-10:
-
- $fileformats = array('aiken','aon','blackboard','coursetestmanager',
- 'gift','learnwise','missingword','webct','xml','hotpot' );
-
- (g) save the changes and close the file
-
-5. Login to your Moodle site as an administrator.
-
- a) If you are installing this module for the first time, you should see a report saying that the following (prefix)_hotpot tables have been successfuly created:
- hotpot
- hotpot_attempts
- hotpot_questions
- hotpot_responses
- hotpot_strings
-
- b) If you are updating the module, you will probably see messages indicating the progress of the update
-
- c) If you get error messages, please copy and save them to a file on your PC, and then ask for help on Moodle's HotPot support forum:
- go to http://moodle.org
- then click "Free Support",
- then click "HotPot"
-
-
-TO USE THIS MODULE:
-
-1. Create a Hot Potatoes quiz of any type using Version 6 of Hot Potatoes.
-
-2. Upload the quiz's source file (".jcl", ".jcw", ".jmt", ".jmx", ".jqz") or ".html" file to the file area of the intended course.
-
-3. Also upload any graphics, sound files, stylesheets or javascripts that the quiz uses
-
-4. On the main page for the course, confirm editing is turned on (click the "Turn editing on" button) then select "ADD / Hot Potatoes XML Quiz".
-
-6, The "Adding a new Hot Potatoes Quiz" page appears. Click the "Choose or Upload a file ..." button and select the desired quiz file.
-
-7. Review the other settings for the quiz and click "Save Changes" when you are ready
-
-8. You can view reports of the results via the "Hot Potatoes Quizzes" link on the "Activities menu". Students will see links to all the quizzes. Administrators and teachers will additionally see links to the statistical reports for each quiz.
-
-9. You can also import the questions from the Hot Potatoes source file to the Moodle Quiz database, if you installed "mod/quiz/format/hotpot/format.php"
-
-
-==============================
-HOT POTATOES CONDITIONS OF USE
-==============================
-
-**Reproduced from the Hot Potatoes site**
-
-Hot Potatoes is offered free to the educational community by the University of Victoria Humanities Computing and Media Centre (formerly the Language Centre), under certain conditions. Hot Potatoes is free for use by state educational institutions which are non-profit making, on the condition that the material produced using the program is freely available to anyone via the WWW. However, you need to purchase a licence under any of the following conditions:
-* You do not work for a public sector educational establishment.
-* You charge money for access to the material you make with Hot Potatoes.
-* You restrict access to the material in some way. (The only exception here is if you have an account on www.hotpot.net, where you ARE allowed to use password restrictions.)
-* You want to use the Masher program included with the Hot Potatoes suite.
-
-For more information on licences, and details on how to purchase one, check out our Website at:
- http://www.halfbakedsoftware.com/hotpot/
-
-If you intend using the programs to generate more than a handful of exercises, please make sure you register. This costs you nothing -- see How to register for details.
-Martin Holmes, Half-Baked Software and the University of Victoria HCMC, 1998-2004.
+This is v2.1.5 of the HotPot module
+ This module allows teachers to administer Hot Potatoes and TexToys quizzes via Moodle.
+ It has been tested on:
+ - Hot Potatoes 6
+ - Moodle 1.1 thru 1.6
+ - PHP 4.1 thru 5.0
+ - MySQL and PostgreSQL databases
+ This module may be distributed under the terms of the General Public License
+ (see http://www.gnu.org/licenses/gpl.txt for details)
+ This software is provided "AS IS" without a warranty of any kind.
+ Sponsors who have generously contributed to the development of this software:
+ - Agencia de Gestio d'Ajuts Universitaris i de Recerca (AGAUR),
+ Autonomous Government of Catalonia, Spain
+ (via Josep M. Fontana, Universitat Pompeu Fabra)
+ - Rikkyo Univeristy, Japan (via Paul Allum)
+ - Universite de Franche-Comte, France (via Glenys Hanson)
+================
+IMPORTANT NOTICE
+================
+* Please be sure to use Hot Potatoes according to the conditions of use which are listed at the end of this file. If you restrict use via a required Moodle login, you most likely can still meet the 'freely available' condition if you make the same material on a separate URL that permits free access. Otherwise, please purchase a license.
+TO INSTALL OR UPDATE THIS MODULE
+1. Install the core scripts of the hotpot module
+ EITHER:
+ (a) download the zip file into the "moodle/mod" folder on your Moodle site
+ (b) unzip the zip file. This will create a folder called "moodle/mod/hotpot" on your Moodle site
+ OR:
+ (a) download the zip file onto your PC
+ (b) upzip the zip file on your PC. This will create a "hotpot" folder on your PC
+ (c) create a folder called "hotpot" on your Moodle site in the "moodle/mod" folder
+ (d) upload the contents of the "hotpot" folder on your PC to the "moodle/mod/hotpot" folder on the Moodle site
+2. Install the messages and help files of the hotpot module
+ EITHER:
+ (a) copy "moodle/mod/hotpot/lang/en/hotpot.php" on the Moodle site to "moodle/lang/en/hotpot.php"
+ (b) copy "moodle/mod/hotpot/lang/en/help/hotpot" on the Moodle site to "moodle/lang/en/help/hotpot"
+ (c) repeat for other languages you require from the "moodle/mod/hotpot/lang" folder
+ OR:
+ (a) upload the "hotpot/lang/en/hotpot.php" file on your PC to "moodle/lang/en/hotpot.php" on the Moodle site
+ (b) create a folder called "hotpot" on your Moodle site in the "moodle/lang/en/help" folder
+ (c) upload the contents of the "hotpot/lang/en/help/hotpot" folder on your PC to the "moodle/lang/en/help/hotpot" folder on the Moodle site
+ (d) repeat for other languages you require from the "moodle/mod/hotpot/lang" folder
+3. copy and set up the file icons
+ [This step is not required for Moodle 1.5 and later, and is optional for Moodle 1.1 to 1.4]
+ (a) copy the files in the "mod/hotpot/pix/f" folder on your Moodle site to "moodle/pix/f"
+ (b) open the "moodle/files/mimetypes.php" file on your Moodle site with a text editor
+ (c) insert the following lines just AFTER the line which reads "$mimeinfo = array (":
+ // additional mimetypes for the "hotpot" module
+ "jcb" => array ("type"=>"text/xml", "icon"=>"jcb.gif"),
+ "jcl" => array ("type"=>"text/xml", "icon"=>"jcl.gif"),
+ "jcw" => array ("type"=>"text/xml", "icon"=>"jcw.gif"),
+ "jmt" => array ("type"=>"text/xml", "icon"=>"jmt.gif"),
+ "jmx" => array ("type"=>"text/xml", "icon"=>"jmx.gif"),
+ "jqz" => array ("type"=>"text/xml", "icon"=>"jqz.gif"),
+ "rhb" => array ("type"=>"text/xml", "icon"=>"xml.gif"),
+ "sqt" => array ("type"=>"text/xml", "icon"=>"xml.gif"),
+ (d) save the changes and close the file
+4. enable import from Hot Potatoes XML files to Moodle's Quiz module
+ [This step is not required for Moodle 1.5 and later, and is optional for Moodle 1.1 to 1.4]
+ (a) create a folder called "hotpot" on your Moodle site in the "moodle/mod/quiz/format" folder
+ (b) copy the "contents of the "moodle/mod/hotpot/quiz/format/hotpot" folder on your Moodle site to the "moodle/mod/quiz/format/hotpot" folder
+ (c) open the "moodle/lang/en/quiz.php" file on your Moodle site with a text editor
+ (d) insert the following line just BEFORE the final line which reads "?>":
+ $string['hotpot'] = 'Hot Potatoes XML format';
+ (d) save the changes and close the file
+
+ Steps (e), (f) and (g) are only required on Moodle 1.4.5
+ (e) open the "moodle/mod/quiz/import.php" file on your Moodle site with a text editor
+ (f) if necessary, add 'hotpot' to the "fileformats" array on lines 9-10:
+ $fileformats = array('aiken','aon','blackboard','coursetestmanager',
+ 'gift','learnwise','missingword','webct','xml','hotpot' );
+ (g) save the changes and close the file
+5. Login to your Moodle site as an administrator.
+ a) If you are installing this module for the first time, you should see a report saying that the following (prefix)_hotpot tables have been successfuly created:
+ hotpot
+ hotpot_attempts
+ hotpot_questions
+ hotpot_responses
+ hotpot_strings
+ b) If you are updating the module, you will probably see messages indicating the progress of the update
+
+ c) If you get error messages, please copy and save them to a file on your PC, and then ask for help on Moodle's HotPot support forum:
+ go to http://moodle.org
+ then click "Free Support",
+ then click "HotPot"
+TO USE THIS MODULE:
+1. Create a Hot Potatoes quiz of any type using Version 6 of Hot Potatoes.
+2. Upload the quiz's source file (".jcl", ".jcw", ".jmt", ".jmx", ".jqz") or ".html" file to the file area of the intended course.
+3. Also upload any graphics, sound files, stylesheets or javascripts that the quiz uses
+4. On the main page for the course, confirm editing is turned on (click the "Turn editing on" button) then select "ADD / Hot Potatoes XML Quiz".
+6, The "Adding a new Hot Potatoes Quiz" page appears. Click the "Choose or Upload a file ..." button and select the desired quiz file.
+7. Review the other settings for the quiz and click "Save Changes" when you are ready
+8. You can view reports of the results via the "Hot Potatoes Quizzes" link on the "Activities menu". Students will see links to all the quizzes. Administrators and teachers will additionally see links to the statistical reports for each quiz.
+9. You can also import the questions from the Hot Potatoes source file to the Moodle Quiz database, if you installed "mod/quiz/format/hotpot/format.php"
+==============================
+HOT POTATOES CONDITIONS OF USE
+==============================
+**Reproduced from the Hot Potatoes site**
+Hot Potatoes is offered free to the educational community by the University of Victoria Humanities Computing and Media Centre (formerly the Language Centre), under certain conditions. Hot Potatoes is free for use by state educational institutions which are non-profit making, on the condition that the material produced using the program is freely available to anyone via the WWW. However, you need to purchase a licence under any of the following conditions:
+* You do not work for a public sector educational establishment.
+* You charge money for access to the material you make with Hot Potatoes.
+* You restrict access to the material in some way. (The only exception here is if you have an account on www.hotpot.net, where you ARE allowed to use password restrictions.)
+* You want to use the Masher program included with the Hot Potatoes suite.
+For more information on licences, and details on how to purchase one, check out our Website at:
+ http://www.halfbakedsoftware.com/hotpot/
+If you intend using the programs to generate more than a handful of exercises, please make sure you register. This costs you nothing -- see How to register for details.
+Martin Holmes, Half-Baked Software and the University of Victoria HCMC, 1998-2004.
View
597 mod/hotpot/backuplib.php
@@ -1,330 +1,267 @@
-<?PHP //$Id$
- //This php script contains all the stuff to backup/restore
- //quiz mods
-
- //-----------------------------------------------------------
- // This is the "graphical" structure of the hotpot mod:
- //-----------------------------------------------------------
- //
- // hotpot
- // (CL, pk->id,
- // fk->course, files)
- // |
- // +--------------+---------------+
- // | |
- // hotpot_attempts hotpot_questions
- // (UL, pk->id, (UL, pk->id,
- // fk->hotpot) fk->hotpot, text)
- // | | |
- // +-------------------+----------+ |
- // | | |
- // hotpot_details hotpot_responses |
- // (UL, pk->id, (UL, pk->id, |
- // fk->attempt) fk->attempt, question, |
- // correct, wrong, ignored) |
- // | |
- // +-------+-------+
- // |
- // hotpot_strings
- // (UL, pk->id)
- //
- // Meaning: pk->primary key field of the table
- // fk->foreign key to link with parent
- // nt->nested field (recursive data)
- // CL->course level info
- // UL->user level info
- // files->table may have files
- //
- //-----------------------------------------------------------
-
- function hotpot_backup_mods($bf, $preferences) {
- // $bf : resource id for b(ackup) f(ile)
- // $preferences : object containing switches and settings for this backup
-
- $level = 3;
- $status = true;
-
- $table = 'hotpot';
- $select = "course=$preferences->backup_course";
-
- $records_tag = '';
- $records_tags = array();
-
- $record_tag = 'MOD';
- $record_tags = array('MODTYPE'=>'hotpot');
-
- $excluded_tags = array();
-
- $more_backup = '';
- if ($preferences->mods['hotpot']->userinfo) {
- $more_backup .= '$GLOBALS["hotpot_backup_string_ids"] = array();';
- $more_backup .= '$status = hotpot_backup_attempts($bf, $record, $level, $status);';
- $more_backup .= '$status = hotpot_backup_questions($bf, $record, $level, $status);';
- $more_backup .= '$status = hotpot_backup_strings($bf, $record, $level, $status);';
- $more_backup .= 'unset($GLOBALS["hotpot_backup_string_ids"]);'; // tidy up
- }
-
- return hotpot_backup_records(
- $bf, $status, $level,
- $table, $select,
- $records_tag, $records_tags,
- $record_tag, $record_tags,
- $excluded_tags, $more_backup
- );
- }
- function hotpot_backup_attempts($bf, &$parent, $level, $status) {
- // $parent is a reference to a hotpot record
-
- $table = 'hotpot_attempts';
- $select = "hotpot=$parent->id";
-
- $records_tag = 'ATTEMPT_DATA';
- $records_tags = array();
-
- $record_tag = 'ATTEMPT';
- $record_tags = array();
-
- $more_backup = '';
- $more_backup .= 'hotpot_backup_details($bf, $record, $level, $status);';
- $more_backup .= 'hotpot_backup_responses($bf, $record, $level, $status);';
-
- $excluded_tags = array('hotpot');
-
- return hotpot_backup_records(
- $bf, $status, $level,
- $table, $select,
- $records_tag, $records_tags,
- $record_tag, $record_tags,
- $excluded_tags, $more_backup
- );
- }
- function hotpot_backup_details($bf, &$parent, $level, $status) {
- // $parent is a reference to an attempt record
-
- $table = 'hotpot_details';
- $select = "attempt=$parent->id";
-
- $records_tag = '';
- $records_tags = array();
-
- $record_tag = '';
- $record_tags = array();
-
- $more_backup = '';
- $excluded_tags = array('id','attempt');
-
- return hotpot_backup_records(
- $bf, $status, $level,
- $table, $select,
- $records_tag, $records_tags,
- $record_tag, $record_tags,
- $excluded_tags, $more_backup
- );
- }
- function hotpot_backup_responses($bf, &$parent, $level, $status) {
- // $parent is a reference to an attempt record
-
- $table = 'hotpot_responses';
- $select = "attempt=$parent->id";
-
- $records_tag = 'RESPONSE_DATA';
- $records_tags = array();
-
- $record_tag = 'RESPONSE';
- $record_tags = array();
-
- $more_backup = 'hotpot_backup_string_ids($record, array("correct","wrong","ignored"));';
- $excluded_tags = array('id','attempt');
-
- return hotpot_backup_records(
- $bf, $status, $level,
- $table, $select,
- $records_tag, $records_tags,
- $record_tag, $record_tags,
- $excluded_tags, $more_backup
- );
- }
- function hotpot_backup_questions($bf, &$parent, $level, $status) {
- // $parent is a reference to an hotpot record
-
- $table = 'hotpot_questions';
- $select = "hotpot=$parent->id";
-
- $records_tag = 'QUESTION_DATA';
- $records_tags = array();
-
- $record_tag = 'QUESTION';
- $record_tags = array();
-
- $more_backup = 'hotpot_backup_string_ids($record, array("text"));';
- $excluded_tags = array('hotpot');
-
- return hotpot_backup_records(
- $bf, $status, $level,
- $table, $select,
- $records_tag, $records_tags,
- $record_tag, $record_tags,
- $excluded_tags, $more_backup
- );
- }
- function hotpot_backup_string_ids(&$record, $fields) {
- // as the questions and responses tables are backed up
- // this function is called to store the ids of strings.
- // The string ids are used later by "hotpot_backup_strings"
- // $GLOBALS['hotpot_backup_string_ids'] was initialized in "hotpot_backup_mods"
-
- // store the ids of strings used in this $record's $fields
- foreach ($fields as $field) {
- if (empty($record->$field)) {
- // do nothing
- } else {
- $value = $record->$field;
- $ids = explode(',', "$value");
- foreach ($ids as $id) {
- if (empty($id)) {
- // do nothing
- } else {
- $GLOBALS['hotpot_backup_string_ids'][$id] = true;
- }
- }
- }
- }
- }
- function hotpot_backup_strings($bf, $record, $level, $status) {
- // This functions backups the strings used
- // in the question and responses for a single hotpot activity
- // The ids of the strings were stored by "hotpot_backup_string_ids"
- // $GLOBALS['hotpot_backup_string_ids'] was initialized in "hotpot_backup_mods"
-
- // retrieve $ids of strings to be backed up
- $ids = array_keys($GLOBALS['hotpot_backup_string_ids']);
-
- if (empty($ids)) {
- // no strings to backup
- } else {
-
- sort($ids);
- $ids = implode(',', $ids);
-
- $table = 'hotpot_strings';
- $select = "id IN ($ids)";
-
- $records_tag = 'STRING_DATA';
- $records_tags = array();
-
- $record_tag = 'STRING';
- $record_tags = array();
-
- $more_backup = '';
- $excluded_tags = array('');
-
- $status = hotpot_backup_records(
- $bf, $status, $level,
- $table, $select,
- $records_tag, $records_tags,
- $record_tag, $record_tags,
- $excluded_tags, $more_backup
- );
- }
- return $status;
- }
-
- function hotpot_backup_records(&$bf, $status, $level, $table, $select, $records_tag, $records_tags, $record_tag, $record_tags, $excluded_tags, $more_backup) {
- // general purpose backup function
-
- // $bf : resource id of backup file
- // $status : current status of backup (true or false)
- // $level : current depth level in the backup XML tree
-
- // $table : table from which records will be selected and backed up
- // $select : SQL selection string
-
- // $records_tag : optional XML tag which starts a group of records (and descends a level)
- // $records_tags : optional XML tags to be inserted at the start of a group of records
-
- // $record_tag : optional XML tag which starts a record (and descends a level)
- // $record_tags : optional XML tags to be inserted at the start of a record
-
- // $excluded_tags : fields which will NOT be backed up from the records
- // $more_backup : optional PHP code to be eval(uated) for each record
-
- // If any of the "fwrite" statements fail,
- // no further "fwrite"s will be attempted
- // and the function returns "false".
- // Otherwise, the function returns "true".
-
- if ($status && ($records = get_records_select($table, $select, 'id'))) {
-
- // start a group of records
- if ($records_tag) {
- $status = $status && fwrite($bf, start_tag($records_tag, $level, true));
- $level++;
-
- foreach ($records_tags as $tag) {
- $status = $status && fwrite($bf, full_tag($tag, $level, false, $value));
- }
- }
-
- foreach ($records as $record) {
-
- // start a single record
- if ($record_tag) {
- $status = $status && fwrite($bf, start_tag($record_tag, $level, true));
- $level++;
-
- foreach ($record_tags as $tag=>$value) {
- $status = $status && fwrite($bf, full_tag($tag, $level, false, $value));
- }
- }
-
- // backup fields in this record
- $tags = get_object_vars($record);
- foreach ($tags as $tag=>$value) {
- if (!is_numeric($tag) && !in_array($tag, $excluded_tags)) {
- $status = $status && fwrite($bf, full_tag($tag, $level, false, $value));
- }
- }
-
- // backup related records, if required
- if ($more_backup) {
- eval($more_backup);
- }
-
- // end a single record
- if ($record_tag) {
- $level--;
- $status = $status && fwrite($bf, end_tag($record_tag, $level, true));
- }
- }
-
- // end a group of records
- if ($records_tag) {
- $level--;
- $status = $status && fwrite($bf, end_tag($records_tag, $level, true));
- }
- }
-
- return $status;
- }
-
- ////Return an array of info (name, value)
- function hotpot_check_backup_mods($course, $user_data=false, $backup_unique_code) {
-
- // the course data
- $info[0][0] = get_string('modulenameplural','hotpot');
- $info[0][1] = count_records('hotpot', 'course', $course);
-
- // the user_data, if requested
- if ($user_data) {
- global $CFG;
- $table = "{$CFG->prefix}hotpot h, {$CFG->prefix}hotpot_attempts a";
- $select = "h.course = $course AND h.id = a.hotpot";
-
- $info[1][0] = get_string('attempts', 'quiz');
- $info[1][1] = count_records_sql("SELECT COUNT(*) FROM $table WHERE $select");
- }
-
- return $info;
- }
-
-?>
+<?PHP //$Id$
+ //This php script contains all the stuff to backup/restore
+ //quiz mods
+ //-----------------------------------------------------------
+ // This is the "graphical" structure of the hotpot mod:
+ //-----------------------------------------------------------
+ //
+ // hotpot
+ // (CL, pk->id,
+ // fk->course, files)
+ // |
+ // +--------------+---------------+
+ // | |
+ // hotpot_attempts hotpot_questions
+ // (UL, pk->id, (UL, pk->id,
+ // fk->hotpot) fk->hotpot, text)
+ // | | |
+ // +-------------------+----------+ |
+ // | | |
+ // hotpot_details hotpot_responses |
+ // (UL, pk->id, (UL, pk->id, |
+ // fk->attempt) fk->attempt, question, |
+ // correct, wrong, ignored) |
+ // | |
+ // +-------+-------+
+ // |
+ // hotpot_strings
+ // (UL, pk->id)
+ //
+ // Meaning: pk->primary key field of the table
+ // fk->foreign key to link with parent
+ // nt->nested field (recursive data)
+ // CL->course level info
+ // UL->user level info
+ // files->table may have files
+ //
+ //-----------------------------------------------------------
+ function hotpot_backup_mods($bf, $preferences) {
+ // $bf : resource id for b(ackup) f(ile)
+ // $preferences : object containing switches and settings for this backup
+ $level = 3;
+ $status = true;
+ $table = 'hotpot';
+ $select = "course=$preferences->backup_course";
+ $records_tag = '';
+ $records_tags = array();
+ $record_tag = 'MOD';
+ $record_tags = array('MODTYPE'=>'hotpot');
+ $excluded_tags = array();
+ $more_backup = '';
+ if ($preferences->mods['hotpot']->userinfo) {
+ $more_backup .= '$GLOBALS["hotpot_backup_string_ids"] = array();';
+ $more_backup .= '$status = hotpot_backup_attempts($bf, $record, $level, $status);';
+ $more_backup .= '$status = hotpot_backup_questions($bf, $record, $level, $status);';
+ $more_backup .= '$status = hotpot_backup_strings($bf, $record, $level, $status);';
+ $more_backup .= 'unset($GLOBALS["hotpot_backup_string_ids"]);'; // tidy up
+ }
+ return hotpot_backup_records(
+ $bf, $status, $level,
+ $table, $select,
+ $records_tag, $records_tags,
+ $record_tag, $record_tags,
+ $excluded_tags, $more_backup
+ );
+ }
+ function hotpot_backup_attempts($bf, &$parent, $level, $status) {
+ // $parent is a reference to a hotpot record
+ $table = 'hotpot_attempts';
+ $select = "hotpot=$parent->id";
+ $records_tag = 'ATTEMPT_DATA';
+ $records_tags = array();
+ $record_tag = 'ATTEMPT';
+ $record_tags = array();
+ $more_backup = '';
+ $more_backup .= 'hotpot_backup_details($bf, $record, $level, $status);';
+ $more_backup .= 'hotpot_backup_responses($bf, $record, $level, $status);';
+ $excluded_tags = array('hotpot');
+ return hotpot_backup_records(
+ $bf, $status, $level,
+ $table, $select,
+ $records_tag, $records_tags,
+ $record_tag, $record_tags,
+ $excluded_tags, $more_backup
+ );
+ }
+ function hotpot_backup_details($bf, &$parent, $level, $status) {
+ // $parent is a reference to an attempt record
+ $table = 'hotpot_details';
+ $select = "attempt=$parent->id";
+ $records_tag = '';
+ $records_tags = array();
+ $record_tag = '';
+ $record_tags = array();
+ $more_backup = '';
+ $excluded_tags = array('id','attempt');
+ return hotpot_backup_records(
+ $bf, $status, $level,
+ $table, $select,
+ $records_tag, $records_tags,
+ $record_tag, $record_tags,
+ $excluded_tags, $more_backup
+ );
+ }
+ function hotpot_backup_responses($bf, &$parent, $level, $status) {
+ // $parent is a reference to an attempt record
+ $table = 'hotpot_responses';
+ $select = "attempt=$parent->id";
+ $records_tag = 'RESPONSE_DATA';
+ $records_tags = array();
+ $record_tag = 'RESPONSE';
+ $record_tags = array();
+ $more_backup = 'hotpot_backup_string_ids($record, array("correct","wrong","ignored"));';
+ $excluded_tags = array('id','attempt');
+ return hotpot_backup_records(
+ $bf, $status, $level,
+ $table, $select,
+ $records_tag, $records_tags,
+ $record_tag, $record_tags,
+ $excluded_tags, $more_backup
+ );
+ }
+ function hotpot_backup_questions($bf, &$parent, $level, $status) {
+ // $parent is a reference to an hotpot record
+ $table = 'hotpot_questions';
+ $select = "hotpot=$parent->id";
+ $records_tag = 'QUESTION_DATA';
+ $records_tags = array();
+ $record_tag = 'QUESTION';
+ $record_tags = array();
+ $more_backup = 'hotpot_backup_string_ids($record, array("text"));';
+ $excluded_tags = array('hotpot');
+ return hotpot_backup_records(
+ $bf, $status, $level,
+ $table, $select,
+ $records_tag, $records_tags,
+ $record_tag, $record_tags,
+ $excluded_tags, $more_backup
+ );
+ }
+ function hotpot_backup_string_ids(&$record, $fields) {
+ // as the questions and responses tables are backed up
+ // this function is called to store the ids of strings.
+ // The string ids are used later by "hotpot_backup_strings"
+ // $GLOBALS['hotpot_backup_string_ids'] was initialized in "hotpot_backup_mods"
+ // store the ids of strings used in this $record's $fields
+ foreach ($fields as $field) {
+ if (empty($record->$field)) {
+ // do nothing
+ } else {
+ $value = $record->$field;
+ $ids = explode(',', "$value");
+ foreach ($ids as $id) {
+ if (empty($id)) {
+ // do nothing
+ } else {
+ $GLOBALS['hotpot_backup_string_ids'][$id] = true;
+ }
+ }
+ }
+ }
+ }
+ function hotpot_backup_strings($bf, $record, $level, $status) {
+ // This functions backups the strings used
+ // in the question and responses for a single hotpot activity
+ // The ids of the strings were stored by "hotpot_backup_string_ids"
+ // $GLOBALS['hotpot_backup_string_ids'] was initialized in "hotpot_backup_mods"
+ // retrieve $ids of strings to be backed up
+ $ids = array_keys($GLOBALS['hotpot_backup_string_ids']);
+ if (empty($ids)) {
+ // no strings to backup
+ } else {
+ sort($ids);
+ $ids = implode(',', $ids);
+ $table = 'hotpot_strings';
+ $select = "id IN ($ids)";
+ $records_tag = 'STRING_DATA';
+ $records_tags = array();
+ $record_tag = 'STRING';
+ $record_tags = array();
+ $more_backup = '';
+ $excluded_tags = array('');
+ $status = hotpot_backup_records(
+ $bf, $status, $level,
+ $table, $select,
+ $records_tag, $records_tags,
+ $record_tag, $record_tags,
+ $excluded_tags, $more_backup
+ );
+ }
+ return $status;
+ }
+ function hotpot_backup_records(&$bf, $status, $level, $table, $select, $records_tag, $records_tags, $record_tag, $record_tags, $excluded_tags, $more_backup) {
+ // general purpose backup function
+ // $bf : resource id of backup file
+ // $status : current status of backup (true or false)
+ // $level : current depth level in the backup XML tree
+ // $table : table from which records will be selected and backed up
+ // $select : SQL selection string
+ // $records_tag : optional XML tag which starts a group of records (and descends a level)
+ // $records_tags : optional XML tags to be inserted at the start of a group of records
+ // $record_tag : optional XML tag which starts a record (and descends a level)
+ // $record_tags : optional XML tags to be inserted at the start of a record
+ // $excluded_tags : fields which will NOT be backed up from the records
+ // $more_backup : optional PHP code to be eval(uated) for each record
+ // If any of the "fwrite" statements fail,
+ // no further "fwrite"s will be attempted
+ // and the function returns "false".
+ // Otherwise, the function returns "true".
+ if ($status && ($records = get_records_select($table, $select, 'id'))) {
+ // start a group of records
+ if ($records_tag) {
+ $status = $status && fwrite($bf, start_tag($records_tag, $level, true));
+ $level++;
+ foreach ($records_tags as $tag) {
+ $status = $status && fwrite($bf, full_tag($tag, $level, false, $value));
+ }
+ }
+ foreach ($records as $record) {
+ // start a single record
+ if ($record_tag) {
+ $status = $status && fwrite($bf, start_tag($record_tag, $level, true));
+ $level++;
+ foreach ($record_tags as $tag=>$value) {
+ $status = $status && fwrite($bf, full_tag($tag, $level, false, $value));
+ }
+ }
+ // backup fields in this record
+ $tags = get_object_vars($record);
+ foreach ($tags as $tag=>$value) {
+ if (!is_numeric($tag) && !in_array($tag, $excluded_tags)) {
+ $status = $status && fwrite($bf, full_tag($tag, $level, false, $value));
+ }
+ }
+ // backup related records, if required
+ if ($more_backup) {
+ eval($more_backup);
+ }
+ // end a single record
+ if ($record_tag) {
+ $level--;
+ $status = $status && fwrite($bf, end_tag($record_tag, $level, true));
+ }
+ }
+ // end a group of records
+ if ($records_tag) {
+ $level--;
+ $status = $status && fwrite($bf, end_tag($records_tag, $level, true));
+ }
+ }
+ return $status;
+ }
+ ////Return an array of info (name, value)
+ function hotpot_check_backup_mods($course, $user_data=false, $backup_unique_code) {
+ // the course data
+ $info[0][0] = get_string('modulenameplural','hotpot');
+ $info[0][1] = count_records('hotpot', 'course', $course);
+ // the user_data, if requested
+ if ($user_data) {
+ global $CFG;
+ $table = "{$CFG->prefix}hotpot h, {$CFG->prefix}hotpot_attempts a";
+ $select = "h.course = $course AND h.id = a.hotpot";
+ $info[1][0] = get_string('attempts', 'quiz');
+ $info[1][1] = count_records_sql("SELECT COUNT(*) FROM $table WHERE $select");
+ }
+ return $info;
+ }
+?>
View
80 mod/hotpot/db/mysql.php
@@ -1,43 +1,37 @@
-<?PHP
-
-function hotpot_upgrade($oldversion) {
- global $CFG;
- $ok = true;
-
- if ($oldversion < 2004021400) {
- execute_sql(" ALTER TABLE `{$CFG->prefix}hotpot_events` ADD `starttime` INT(10) unsigned NOT NULL DEFAULT '0' AFTER `time`");
- execute_sql(" ALTER TABLE `{$CFG->prefix}hotpot_events` ADD `endtime` INT(10) unsigned NOT NULL DEFAULT '0' AFTER `time`");
- }
-
- // update from HotPot v1 to HotPot v2
- if ($oldversion < 2005031400) {
- $ok = $ok && hotpot_get_update_to_v2();
- $ok = $ok && hotpot_update_to_v2_from_v1();
- }
-
- // update to HotPot v2.1
- if ($oldversion < 2005090700) {
- $ok = $ok && hotpot_get_update_to_v2();
- $ok = $ok && hotpot_update_to_v2_1();
- }
-
- // update to from HotPot v2.1.0 or v2.1.1 to HotPot v2.1.2
- if ($oldversion > 2005031419 && $oldversion < 2005090702) {
- $ok = $ok && hotpot_get_update_to_v2();
- $ok = $ok && hotpot_update_to_v2_1_2();
- }
-
- return $ok;
-}
-function hotpot_get_update_to_v2() {
- global $CFG;
- $filepath = "$CFG->dirroot/mod/hotpot/db/update_to_v2.php";
- if (file_exists($filepath) && is_readable($filepath)) {
- include_once $filepath;
- $ok = true;
- } else {
- $ok = false;
- }
- return $ok;
-}
-?>
+<?PHP
+function hotpot_upgrade($oldversion) {
+ global $CFG;
+ $ok = true;
+ if ($oldversion < 2004021400) {
+ execute_sql(" ALTER TABLE `{$CFG->prefix}hotpot_events` ADD `starttime` INT(10) unsigned NOT NULL DEFAULT '0' AFTER `time`");
+ execute_sql(" ALTER TABLE `{$CFG->prefix}hotpot_events` ADD `endtime` INT(10) unsigned NOT NULL DEFAULT '0' AFTER `time`");
+ }
+ // update from HotPot v1 to HotPot v2
+ if ($oldversion < 2005031400) {
+ $ok = $ok && hotpot_get_update_to_v2();
+ $ok = $ok && hotpot_update_to_v2_from_v1();
+ }
+ // update to HotPot v2.1
+ if ($oldversion < 2005090700) {
+ $ok = $ok && hotpot_get_update_to_v2();
+ $ok = $ok && hotpot_update_to_v2_1();
+ }
+ // update to from HotPot v2.1.0 or v2.1.1 to HotPot v2.1.2
+ if ($oldversion > 2005031419 && $oldversion < 2005090702) {
+ $ok = $ok && hotpot_get_update_to_v2();
+ $ok = $ok && hotpot_update_to_v2_1_2();
+ }
+ return $ok;
+}
+function hotpot_get_update_to_v2() {
+ global $CFG;
+ $filepath = "$CFG->dirroot/mod/hotpot/db/update_to_v2.php";
+ if (file_exists($filepath) && is_readable($filepath)) {
+ include_once $filepath;
+ $ok = true;
+ } else {
+ $ok = false;
+ }
+ return $ok;
+}
+?>
View
211 mod/hotpot/db/mysql.sql
@@ -1,112 +1,101 @@
-#
-# Table structure for table `hotpot`
-#
-
-CREATE TABLE prefix_hotpot (
- id int(10) unsigned NOT NULL auto_increment,
- course int(10) unsigned NOT NULL default '0',
- name varchar(255) NOT NULL default '',
- reference varchar(255) NOT NULL default '',
- summary text NOT NULL,
- timeopen int(10) unsigned NOT NULL default '0',
- timeclose int(10) unsigned NOT NULL default '0',
- attempts smallint(6) NOT NULL default '0',
- grademethod tinyint(4) NOT NULL default '1',
- review tinyint(4) NOT NULL default '0',
- grade int(10) NOT NULL default '0',
- timecreated int(10) unsigned NOT NULL default '0',
- timemodified int(10) unsigned NOT NULL default '0',
- location int(4) unsigned NOT NULL default '0',
- navigation int(4) unsigned NOT NULL default '1',
- outputformat int(4) unsigned NOT NULL default '1',
- shownextquiz int(4) unsigned NOT NULL default '0',
- forceplugins int(4) unsigned NOT NULL default '0',
- password varchar(255) NOT NULL default '',
- subnet varchar(255) NOT NULL default '',
- clickreporting tinyint(4) unsigned NOT NULL default '0',
- studentfeedback tinyint(4) unsigned NOT NULL default '0',
- studentfeedbackurl varchar(255) default NULL,
- PRIMARY KEY (id)
-) TYPE=MyISAM COMMENT='details about Hot Potatoes quizzes';
-
-#
-# Table structure for table `hotpot_attempts`
-#
-
-CREATE TABLE prefix_hotpot_attempts (
- id int(10) unsigned NOT NULL auto_increment,
- hotpot int(10) unsigned NOT NULL default '0',
- userid int(10) unsigned NOT NULL default '0',
- starttime int(10) unsigned default NULL,
- endtime int(10) unsigned default NULL,
- score int(6) unsigned default NULL,
- penalties int(6) unsigned default NULL,
- attempt int(6) unsigned NOT NULL default '0',
- timestart int(10) unsigned default NULL,
- timefinish int(10) unsigned default NULL,
- status tinyint(4) unsigned NOT NULL default '1',
- clickreportid int(10) unsigned default NULL,
- PRIMARY KEY (id),
- KEY prefix_hotpot_attempts_hotpot_idx (hotpot),
- KEY prefix_hotpot_attempts_userid_idx (userid)
-) TYPE=MyISAM COMMENT='details about Hot Potatoes quiz attempts';
-
-#
-# Table structure for table `hotpot_details`
-#
-
-CREATE TABLE prefix_hotpot_details (
- id int(10) unsigned NOT NULL auto_increment,
- attempt int(10) unsigned NOT NULL,
- details text,
- PRIMARY KEY (id),
- KEY prefix_hotpot_details_attempt_idx (attempt)
-) TYPE=MyISAM COMMENT='raw details (as XML) of Hot Potatoes quiz attempts';
-
-#
-# Table structure for table `hotpot_questions`
-#
-
-CREATE TABLE prefix_hotpot_questions (
- id int(10) unsigned NOT NULL auto_increment,
- name text NOT NULL,
- type tinyint(4) unsigned default NULL,
- text int(10) unsigned default NULL,
- hotpot int(10) unsigned NOT NULL default '0',
- PRIMARY KEY (id),
- KEY prefix_hotpot_questions_name_idx (name(20)),
- KEY prefix_hotpot_questions_hotpot_idx (hotpot)
-) TYPE=MyISAM COMMENT='details about questions in Hot Potatatoes quiz attempts';
-
-#
-# Table structure for table `hotpot_responses`
-#
-
-CREATE TABLE prefix_hotpot_responses (
- id int(10) unsigned NOT NULL auto_increment,
- attempt int(10) unsigned NOT NULL default '0',
- question int(10) unsigned NOT NULL default '0',
- score smallint(8) default NULL,
- weighting smallint(8) default NULL,
- correct varchar(255) default NULL,
- wrong varchar(255) default NULL,
- ignored varchar(255) default NULL,
- hints smallint(6) default NULL,
- clues smallint(6) default NULL,
- checks smallint(6) default NULL,
- PRIMARY KEY (id),
- KEY prefix_hotpot_responses_attempt_idx (attempt),
- KEY prefix_hotpot_responses_question_idx (question)
-) TYPE=MyISAM COMMENT='details about responses in Hot Potatatoes quiz attempts';
-
-#
-# Table structure for table `hotpot_strings`
-#
-
-CREATE TABLE prefix_hotpot_strings (
- id int(10) unsigned NOT NULL auto_increment,
- string text NOT NULL,
- PRIMARY KEY (id),
- KEY prefix_hotpot_strings_string_idx (string(20))
-) TYPE=MyISAM COMMENT='strings used in Hot Potatatoes questions and responses';
+#
+# Table structure for table `hotpot`
+#
+CREATE TABLE prefix_hotpot (
+ id int(10) unsigned NOT NULL auto_increment,
+ course int(10) unsigned NOT NULL default '0',
+ name varchar(255) NOT NULL default '',
+ reference varchar(255) NOT NULL default '',
+ summary text NOT NULL,
+ timeopen int(10) unsigned NOT NULL default '0',
+ timeclose int(10) unsigned NOT NULL default '0',
+ attempts smallint(6) NOT NULL default '0',
+ grademethod tinyint(4) NOT NULL default '1',
+ review tinyint(4) NOT NULL default '0',
+ grade int(10) NOT NULL default '0',
+ timecreated int(10) unsigned NOT NULL default '0',
+ timemodified int(10) unsigned NOT NULL default '0',
+ location int(4) unsigned NOT NULL default '0',
+ navigation int(4) unsigned NOT NULL default '1',
+ outputformat int(4) unsigned NOT NULL default '1',
+ shownextquiz int(4) unsigned NOT NULL default '0',
+ forceplugins int(4) unsigned NOT NULL default '0',
+ password varchar(255) NOT NULL default '',
+ subnet varchar(255) NOT NULL default '',
+ clickreporting tinyint(4) unsigned NOT NULL default '0',
+ studentfeedback tinyint(4) unsigned NOT NULL default '0',
+ studentfeedbackurl varchar(255) default NULL,
+ PRIMARY KEY (id)
+) TYPE=MyISAM COMMENT='details about Hot Potatoes quizzes';
+#
+# Table structure for table `hotpot_attempts`
+#
+CREATE TABLE prefix_hotpot_attempts (
+ id int(10) unsigned NOT NULL auto_increment,
+ hotpot int(10) unsigned NOT NULL default '0',
+ userid int(10) unsigned NOT NULL default '0',
+ starttime int(10) unsigned default NULL,
+ endtime int(10) unsigned default NULL,
+ score int(6) unsigned default NULL,
+ penalties int(6) unsigned default NULL,
+ attempt int(6) unsigned NOT NULL default '0',
+ timestart int(10) unsigned default NULL,
+ timefinish int(10) unsigned default NULL,
+ status tinyint(4) unsigned NOT NULL default '1',
+ clickreportid int(10) unsigned default NULL,
+ PRIMARY KEY (id),
+ KEY prefix_hotpot_attempts_hotpot_idx (hotpot),
+ KEY prefix_hotpot_attempts_userid_idx (userid)
+) TYPE=MyISAM COMMENT='details about Hot Potatoes quiz attempts';
+#
+# Table structure for table `hotpot_details`
+#
+CREATE TABLE prefix_hotpot_details (
+ id int(10) unsigned NOT NULL auto_increment,
+ attempt int(10) unsigned NOT NULL,
+ details text,
+ PRIMARY KEY (id),
+ KEY prefix_hotpot_details_attempt_idx (attempt)
+) TYPE=MyISAM COMMENT='raw details (as XML) of Hot Potatoes quiz attempts';
+#
+# Table structure for table `hotpot_questions`
+#
+CREATE TABLE prefix_hotpot_questions (
+ id int(10) unsigned NOT NULL auto_increment,
+ name text NOT NULL,
+ type tinyint(4) unsigned default NULL,
+ text int(10) unsigned default NULL,
+ hotpot int(10) unsigned NOT NULL default '0',
+ PRIMARY KEY (id),
+ KEY prefix_hotpot_questions_name_idx (name(20)),
+ KEY prefix_hotpot_questions_hotpot_idx (hotpot)
+) TYPE=MyISAM COMMENT='details about questions in Hot Potatatoes quiz attempts';
+#
+# Table structure for table `hotpot_responses`
+#
+CREATE TABLE prefix_hotpot_responses (
+ id int(10) unsigned NOT NULL auto_increment,
+ attempt int(10) unsigned NOT NULL default '0',
+ question int(10) unsigned NOT NULL default '0',
+ score smallint(8) default NULL,
+ weighting smallint(8) default NULL,
+ correct varchar(255) default NULL,
+ wrong varchar(255) default NULL,
+ ignored varchar(255) default NULL,
+ hints smallint(6) default NULL,
+ clues smallint(6) default NULL,
+ checks smallint(6) default NULL,
+ PRIMARY KEY (id),
+ KEY prefix_hotpot_responses_attempt_idx (attempt),
+ KEY prefix_hotpot_responses_question_idx (question)
+) TYPE=MyISAM COMMENT='details about responses in Hot Potatatoes quiz attempts';
+#
+# Table structure for table `hotpot_strings`
+#
+CREATE TABLE prefix_hotpot_strings (
+ id int(10) unsigned NOT NULL auto_increment,
+ string text NOT NULL,
+ PRIMARY KEY (id),
+ KEY prefix_hotpot_strings_string_idx (string(20))
+) TYPE=MyISAM COMMENT='strings used in Hot Potatatoes questions and responses';
View
72 mod/hotpot/db/postgres7.php
@@ -1,39 +1,33 @@
-<?PHP
-
-function hotpot_upgrade($oldversion) {
- global $CFG;
-
- $ok = true;
-
- // update from HotPot v1 to HotPot v2
- if ($oldversion < 2005031400) {
- $ok = $ok && hotpot_get_update_to_v2();
- $ok = $ok && hotpot_update_to_v2_from_v1();
- }
-
- // update to HotPot v2.1
- if ($oldversion < 2005090700) {
- $ok = $ok && hotpot_get_update_to_v2();
- $ok = $ok && hotpot_update_to_v2_1();
- }
-
- // update to from HotPot v2.1.0 or v2.1.1 to HotPot v2.1.2
- if ($oldversion > 2005031419 && $oldversion < 2005090702) {
- $ok = $ok && hotpot_get_update_to_v2();
- $ok = $ok && hotpot_update_to_v2_1_2();
- }
-
- return $ok;
-}
-function hotpot_get_update_to_v2() {
- global $CFG;
- $filepath = "$CFG->dirroot/mod/hotpot/db/update_to_v2.php";
- if (file_exists($filepath) && is_readable($filepath)) {
- include_once $filepath;
- $ok = true;
- } else {
- $ok = false;
- }
- return $ok;
-}
-?>
+<?PHP
+function hotpot_upgrade($oldversion) {
+ global $CFG;
+ $ok = true;
+ // update from HotPot v1 to HotPot v2
+ if ($oldversion < 2005031400) {
+ $ok = $ok && hotpot_get_update_to_v2();
+ $ok = $ok && hotpot_update_to_v2_from_v1();
+ }
+ // update to HotPot v2.1
+ if ($oldversion < 2005090700) {
+ $ok = $ok && hotpot_get_update_to_v2();
+ $ok = $ok && hotpot_update_to_v2_1();
+ }
+ // update to from HotPot v2.1.0 or v2.1.1 to HotPot v2.1.2
+ if ($oldversion > 2005031419 && $oldversion < 2005090702) {
+ $ok = $ok && hotpot_get_update_to_v2();
+ $ok = $ok && hotpot_update_to_v2_1_2();
+ }
+ return $ok;
+}
+function hotpot_get_update_to_v2() {
+ global $CFG;
+ $filepath = "$CFG->dirroot/mod/hotpot/db/update_to_v2.php";
+ if (file_exists($filepath) && is_readable($filepath)) {
+ include_once $filepath;
+ $ok = true;
+ } else {
+ $ok = false;
+ }
+ return $ok;
+}
+?>
View
212 mod/hotpot/db/postgres7.sql
@@ -1,114 +1,98 @@
-#
-# Table structure for table `hotpot`
-#
-
-CREATE TABLE prefix_hotpot (
- id SERIAL PRIMARY KEY,
- course INT4 NOT NULL default '0',
- name VARCHAR(255) NOT NULL default '',
- summary TEXT,
- timeopen INT4 NOT NULL default '0',
- timeclose INT4 NOT NULL default '0',
- location INT2 NOT NULL default '0',
- reference VARCHAR(255) NOT NULL default '',
- navigation INT2 NOT NULL default '1',
- outputformat INT2 NOT NULL default '1',
- forceplugins INT2 NOT NULL default '0',
- shownextquiz INT2 NOT NULL default '0',
- microreporting INT2 NOT NULL default '0',
- studentfeedback VARCHAR(255) NOT NULL default '0',
-
- review INT2 NOT NULL default '0',
- grade INT4 NOT NULL default '0',
- grademethod INT2 NOT NULL default '1',
- attempts INT2 NOT NULL default '0',
-
- password VARCHAR(255) NOT NULL default '',
- subnet VARCHAR(255) NOT NULL default '',
- timecreated INT4 NOT NULL default '0',
- timemodified INT4 NOT NULL default '0'
-);
-COMMENT ON TABLE prefix_hotpot IS 'details about Hot Potatoes quizzes';
-
-
-#
-# Table structure for table `hotpot_attempts`
-#
-
-CREATE TABLE prefix_hotpot_attempts (
- id SERIAL PRIMARY KEY,
- hotpot INT4 NOT NULL default '0',
- userid INT4 NOT NULL default '0',
- groupid INT4 NOT NULL default '0',
- attempt INT2 NOT NULL default '0',
- score INT2,
- penalties INT2,
- starttime INT4,
- endtime INT4,
- timestart INT4 NOT NULL default '0',
- timefinish INT4 NOT NULL default '0',
- status INT2 NOT NULL default '1',
- microreportid INT4
-);
-COMMENT ON TABLE prefix_hotpot IS 'details about Hot Potatoes quiz attempts';
-CREATE INDEX prefix_hotpot_attempts_hotpot_idx ON prefix_hotpot_attempts (hotpot);
-CREATE INDEX prefix_hotpot_attempts_userid_idx ON prefix_hotpot_attempts (userid);
-
-
-#
-# Table structure for table `prefix_hotpot_details`
-#
-
-CREATE TABLE prefix_hotpot_details (
- id SERIAL PRIMARY KEY,
- attempt INT4 NOT NULL default '0',
- details TEXT
-);
-COMMENT ON TABLE prefix_hotpot_details IS 'raw details (as XML) of Hot Potatoes quiz attempts';
-CREATE INDEX prefix_hotpot_details_attempt_idx ON prefix_hotpot_details (attempt);
-
-
-#
-# Table structure for table `hotpot_questions`
-#
-
-CREATE TABLE prefix_hotpot_questions (
- id SERIAL PRIMARY KEY,
- name TEXT,
- type INT2 NOT NULL default '0',
- text INT4 NULL,
- hotpot INT4 NOT NULL default '0'
-);
-COMMENT ON TABLE prefix_hotpot_questions IS 'details about questions in Hot Potatatoes quiz attempts';
-CREATE INDEX prefix_hotpot_questions_hotpot_idx ON prefix_hotpot_questions (hotpot);
-
-#
-# Table structure for table `hotpot_responses`
-#
-
-CREATE TABLE prefix_hotpot_responses (
- id SERIAL PRIMARY KEY,
- attempt INT4 NOT NULL default '0',
- question INT4 NOT NULL default '0',
- score INT2,
- weighting INT2,
- correct VARCHAR(255),
- wrong VARCHAR(255),
- ignored VARCHAR(255),
- hints INT2,
- clues INT2,
- checks INT2
-);
-COMMENT ON TABLE prefix_hotpot_responses IS 'details about responses in Hot Potatatoes quiz attempts';
-CREATE INDEX prefix_hotpot_responses_attempt_idx ON prefix_hotpot_responses (attempt);
-CREATE INDEX prefix_hotpot_responses_question_idx ON prefix_hotpot_responses (question);
-
-#
-# Table structure for table `hotpot_strings`
-#
-
-CREATE TABLE prefix_hotpot_strings (
- id SERIAL PRIMARY KEY,
- string TEXT NOT NULL
-);
-COMMENT ON TABLE prefix_hotpot_strings IS 'strings used in Hot Potatatoes questions and responses';
+#
+# Table structure for table `hotpot`
+#
+CREATE TABLE prefix_hotpot (
+ id SERIAL PRIMARY KEY,
+ course INT4 NOT NULL default '0',
+ name VARCHAR(255) NOT NULL default '',
+ summary TEXT,
+ timeopen INT4 NOT NULL default '0',
+ timeclose INT4 NOT NULL default '0',
+ location INT2 NOT NULL default '0',
+ reference VARCHAR(255) NOT NULL default '',
+ navigation INT2 NOT NULL default '1',
+ outputformat INT2 NOT NULL default '1',
+ forceplugins INT2 NOT NULL default '0',
+ shownextquiz INT2 NOT NULL default '0',
+ microreporting INT2 NOT NULL default '0',
+ studentfeedback VARCHAR(255) NOT NULL default '0',
+ review INT2 NOT NULL default '0',
+ grade INT4 NOT NULL default '0',
+ grademethod INT2 NOT NULL default '1',
+ attempts INT2 NOT NULL default '0',
+ password VARCHAR(255) NOT NULL default '',
+ subnet VARCHAR(255) NOT NULL default '',
+ timecreated INT4 NOT NULL default '0',
+ timemodified INT4 NOT NULL default '0'
+);
+COMMENT ON TABLE prefix_hotpot IS 'details about Hot Potatoes quizzes';
+#
+# Table structure for table `hotpot_attempts`
+#
+CREATE TABLE prefix_hotpot_attempts (
+ id SERIAL PRIMARY KEY,
+ hotpot INT4 NOT NULL default '0',
+ userid INT4 NOT NULL default '0',
+ groupid INT4 NOT NULL default '0',
+ attempt INT2 NOT NULL default '0',
+ score INT2,
+ penalties INT2,
+ starttime INT4,
+ endtime INT4,
+ timestart INT4 NOT NULL default '0',
+ timefinish INT4 NOT NULL default '0',
+ status INT2 NOT NULL default '1',
+ microreportid INT4
+);
+COMMENT ON TABLE prefix_hotpot IS 'details about Hot Potatoes quiz attempts';
+CREATE INDEX prefix_hotpot_attempts_hotpot_idx ON prefix_hotpot_attempts (hotpot);
+CREATE INDEX prefix_hotpot_attempts_userid_idx ON prefix_hotpot_attempts (userid);
+#
+# Table structure for table `prefix_hotpot_details`
+#
+CREATE TABLE prefix_hotpot_details (
+ id SERIAL PRIMARY KEY,
+ attempt INT4 NOT NULL default '0',
+ details TEXT
+);
+COMMENT ON TABLE prefix_hotpot_details IS 'raw details (as XML) of Hot Potatoes quiz attempts';
+CREATE INDEX prefix_hotpot_details_attempt_idx ON prefix_hotpot_details (attempt);
+#
+# Table structure for table `hotpot_questions`
+#
+CREATE TABLE prefix_hotpot_questions (
+ id SERIAL PRIMARY KEY,
+ name TEXT,
+ type INT2 NOT NULL default '0',
+ text INT4 NULL,
+ hotpot INT4 NOT NULL default '0'
+);
+COMMENT ON TABLE prefix_hotpot_questions IS 'details about questions in Hot Potatatoes quiz attempts';
+CREATE INDEX prefix_hotpot_questions_hotpot_idx ON prefix_hotpot_questions (hotpot);
+#
+# Table structure for table `hotpot_responses`
+#
+CREATE TABLE prefix_hotpot_responses (
+ id SERIAL PRIMARY KEY,
+ attempt INT4 NOT NULL default '0',
+ question INT4 NOT NULL default '0',
+ score INT2,
+ weighting INT2,
+ correct VARCHAR(255),
+ wrong VARCHAR(255),
+ ignored VARCHAR(255),
+ hints INT2,
+ clues INT2,
+ checks INT2
+);
+COMMENT ON TABLE prefix_hotpot_responses IS 'details about responses in Hot Potatatoes quiz attempts';
+CREATE INDEX prefix_hotpot_responses_attempt_idx ON prefix_hotpot_responses (attempt);
+CREATE INDEX prefix_hotpot_responses_question_idx ON prefix_hotpot_responses (question);
+#
+# Table structure for table `hotpot_strings`
+#
+CREATE TABLE prefix_hotpot_strings (
+ id SERIAL PRIMARY KEY,
+ string TEXT NOT NULL
+);
+COMMENT ON TABLE prefix_hotpot_strings IS 'strings used in Hot Potatatoes questions and responses';
View
2,373 mod/hotpot/db/update_to_v2.php
1,075 additions, 1,298 deletions not shown because the diff is too large. Please use a local Git client to view these changes.
View
6,168 mod/hotpot/hotpot-full.js
2,880 additions, 3,288 deletions not shown because the diff is too large. Please use a local Git client to view these changes.
View
104 mod/hotpot/iframe.js
@@ -1,52 +1,52 @@
-<!--
-function domSniffer() {
- var t = true;
- var s = navigator.userAgent;
- if (s.indexOf("Mac") >=0) this.mac = t;
- if (s.indexOf("Opera") >=0) this.opera = t;
- var d = document;
- if (d.layers) this.n4 = t;
- if (d.childNodes) this.dom = t;
- if (d.all && d.plugins) this.ie = t;
-}
-function getContentH(lyr) {
- return (is.n4) ? lyr.document.height : (is.ie) ? (is.mac ? lyr.offsetHeight : lyr.scrollHeight) : (is.opera) ? lyr.style.pixelHeight : (is.dom) ? lyr.offsetHeight : 0;
-}
-function px(i) {
- return i + "px";
-}
-function setSize(obj, w, h) {
- if (is.n4) {
- if (w) obj.width = w;
- if (h) obj.height = h;
- } else if (is.opera) {
- // opera 5 needs pixelWidth/Height
- if (w) obj.style.pixelWidth = w;
- if (h) obj.style.pixelHeight = h;
- } else {
- if (w) obj.style.width = px(w);
- if (h) obj.style.height = px(h);
- }
-}
-function getElement(id, lyr) {
- var d = (document.layers && lyr) ? lyr.document : document;
- var obj = (document.layers) ? eval("d."+id) : (d.all) ? d.all[id] : (d.getElementById) ? d.getElementById(id) : null;
- return obj;
-}
-is = new domSniffer();
-function set_iframe_height(id) {
- var iframe = getElement(id);
- if (iframe) {
- var obj = iframe.document || iframe.contentDocument || null; // IE || FireFox
- if (obj) {
- if (obj.body) {
- obj = obj.body;
- }
- var h = getContentH(obj);
- if (h) {
- setSize(iframe, 0, h);
- }
- }
- }
-}
-//-->
+<!--
+function domSniffer() {
+ var t = true;
+ var s = navigator.userAgent;
+ if (s.indexOf("Mac") >=0) this.mac = t;
+ if (s.indexOf("Opera") >=0) this.opera = t;
+ var d = document;
+ if (d.layers) this.n4 = t;
+ if (d.childNodes) this.dom = t;
+ if (d.all && d.plugins) this.ie = t;
+}
+function getContentH(lyr) {
+ return (is.n4) ? lyr.document.height : (is.ie) ? (is.mac ? lyr.offsetHeight : lyr.scrollHeight) : (is.opera) ? lyr.style.pixelHeight : (is.dom) ? lyr.offsetHeight : 0;
+}
+function px(i) {
+ return i + "px";
+}
+function setSize(obj, w, h) {
+ if (is.n4) {
+ if (w) obj.width = w;
+ if (h) obj.height = h;
+ } else if (is.opera) {
+ // opera 5 needs pixelWidth/Height
+ if (w) obj.style.pixelWidth = w;
+ if (h) obj.style.pixelHeight = h;
+ } else {
+ if (w) obj.style.width = px(w);
+ if (h) obj.style.height = px(h);
+ }
+}
+function getElement(id, lyr) {
+ var d = (document.layers && lyr) ? lyr.document : document;
+ var obj = (document.layers) ? eval("d."+id) : (d.all) ? d.all[id] : (d.getElementById) ? d.getElementById(id) : null;
+ return obj;
+}
+is = new domSniffer();
+function set_iframe_height(id) {
+ var iframe = getElement(id);
+ if (iframe) {
+ var obj = iframe.document || iframe.contentDocument || null; // IE || FireFox
+ if (obj) {
+ if (obj.body) {
+ obj = obj.body;
+ }
+ var h = getContentH(obj);
+ if (h) {
+ setSize(iframe, 0, h);
+ }
+ }
+ }
+}
+//-->
View
1,178 mod/hotpot/report/click/report.php
@@ -1,639 +1,539 @@
-<?php // $Id$
-
-/// Overview report just displays a big table of all the attempts
-
-class hotpot_report extends hotpot_default_report {
-
- function display(&$hotpot, &$cm, &$course, &$users, &$attempts, &$questions, &$options) {
- global $CFG;
-
- // create the table
- $this->create_clickreport_table($hotpot, $cm, $course, $users, $attempts, $questions, $options, $tables=array());
-
- // print the table
- $this->print_report($course, $hotpot, $tables, $options);
-
-
- return true;
- }
-
- function create_clickreport_table(&$hotpot, &$cm, &$course, &$users, &$attempts, &$questions, &$options, &$tables) {
-
- global $CFG;
-
- $is_html = ($options['reportformat']=='htm');
-
- // time and date format strings // date format strings
- $strftimetime = '%H:%M:%S';
- $strftimedate = get_string('strftimedate');
-
- // get the current time and max execution time
- $start_report_time = microtime();
- $max_execution_time = ini_get('max_execution_time');
-
- $correct = get_string('reportcorrectsymbol', 'hotpot');
- $wrong = get_string('reportwrongsymbol', 'hotpot');
- $nottried = get_string('reportnottriedsymbol', 'hotpot');
-
- // shortcuts for font tags
- $blank = $is_html ? '&nbsp;' : "";
-
- // store question count
- $questioncount = count($questions);
-
- // array to map columns onto question ids ($col => $id)
- $questionids = array_keys($questions);
-
- // store exercise type
- $exercisetype = $this->get_exercisetype($questions, $questionids, $blank);
-
- // initialize details ('events' must go last)
- $details = array('checks', 'status', 'answers', 'changes', 'hints', 'clues', 'events');
-
- // initialize $table
- unset($table);
- $table->border = 1;
- $table->width = '100%';
-
- // initialize legend, if necessary
- if (!empty($options['reportshowlegend'])) {
- $table->legend = array();
- }
-
- // start $table headings
- $this->set_head($options, $table, 'exercise');
- $this->set_head($options, $table, 'user');
- $this->set_head($options, $table, 'attempt');
- $this->set_head($options, $table, 'click');
-
- // store clicktype column number
- $clicktype_col = count($table->head)-1;
-
- // finish $table headings
- $this->set_head($options, $table, 'details', $exercisetype, $details, $questioncount);
- $this->set_head($options, $table, 'totals', $exercisetype);
-
- // set align and wrap
- $this->set_align_and_wrap($table);
-
- // is link to review allowed?
- $allow_review = ($is_html && (isteacher($course->id) || $hotpot->review));
-
- // initialize array of data values
- $this->data = array();
-
- // set exercise data values
- $this->set_data_exercise($cm, $course, $hotpot, $questions, $questionids, $questioncount, $blank);
-
- // add details of users' responses
- foreach ($users as $user) {
- $this->set_data_user($options, $course, $user);
-
- unset($clickreportid);
- foreach ($user->attempts as $attempt) {
-
- // initialize totals for
- $click = array(
- 'qnumber' => array(),
- 'correct' => array(),
- 'wrong' => array(),
- 'answers' => array(),
- 'hints' => array(),
- 'clues' => array(),
- 'changes' => array(),
- 'checks' => array(),
- 'events' => array(),
- 'score' => array(),
- 'weighting' => array()
- );
- $clicktypes = array();
-
- // is the start of a new attempt?
- // (clicks in the same attempt have the same clickreportid)
- if (!isset($clickreportid) || $clickreportid != $attempt->clickreportid) {
-
- $clickcount = 1;
- $clickreportid = $attempt->clickreportid;
-
- // initialize totals for all clicks in this attempt
- $clicks = $click; // $click has just been initialized
-
- $this->set_data_attempt($attempt, $strftimedate, $strftimetime, $blank);
- }
- $cells = array();
- $this->set_data($cells, 'exercise');
- $this->set_data($cells, 'user');
- $this->set_data($cells, 'attempt');
-
- // get responses to questions in this attempt
- foreach ($attempt->responses as $response) {
-
- // set $q(uestion number)
- $q = array_search($response->question, $questionids);
- $click['qnumber'][$q] = true;
-
- // was this question answered correctly?
- if ($answer = hotpot_strings($response->correct)) {
-
- // mark the question as correctly answered
- if (empty($clicks['correct'][$q])) {
- $click['correct'][$q] = true;
- $clicks['correct'][$q] = true;
- }
- // unset 'wrong' flags, if necessary
- if (isset($click['wrong'][$q])) {
- unset($click['wrong'][$q]);
- }
- if (isset($clicks['wrong'][$q])) {
- unset($clicks['wrong'][$q]);
- }
-
- // otherwise, was the question answered wrongly?
- } else if ($answer = hotpot_strings($response->wrong)) {
-
- // mark the question as wrongly answered
- $click['wrong'][$q] = true;
- $clicks['wrong'][$q] = true;
-
- } else { // not correct or wrong (curious?!)
- unset($answer);
- }
-
- if (!empty($click['correct'][$q]) || !empty($click['wrong'][$q])) {
- $click['score'][$q] = $response->score;
- $clicks['score'][$q] = $response->score;
-
- $weighting = isset($response->weighting) ? $response->weighting : 100;
- $click['weighting'][$q] = $weighting;
- $clicks['weighting'][$q] =$weighting;
- }
-
- foreach($details as $detail) {
- switch ($detail) {
- case 'answers':
- if (isset($answer) && is_string($answer) && !empty($answer)) {
- $click[$detail][$q] = $answer;
- }
- break;
- case 'hints':
- case 'clues':
- case 'checks':
- if (isset($response->$detail) && is_numeric($response->$detail) && $response->$detail>0) {
- if (!isset($click[$detail][$q]) || $click[$detail][$q] < $response->$detail) {
- $click[$detail][$q] = $response->$detail;
- }
- }
- break;
- }
- } // end foreach $detail
-
- } // end foreach $response
-
- $click['types'] = array();
- $this->data['details'] = array();
-
- foreach($details as $detail) {
-
- for ($q=0; $q<$questioncount; $q++) {
- switch ($detail) {
- case 'status':
- if (isset($clicks['correct'][$q])) {
- $this->data['details'][] = $correct;
- } else if (isset($clicks['wrong'][$q])) {
- $this->data['details'][] = $wrong;
- } else if (isset($click['qnumber'][$q])) {
- $this->data['details'][] = $nottried;
- } else { // this question did not appear in this attempt
- $this->data['details'][] = $blank;
- }
- break;
- case 'answers':
- case 'hints':
- case 'clues':
- case 'checks':
- if (!isset($clicks[$detail][$q])) {
- if (!isset($click[$detail][$q])) {
- $this->data['details'][] = $blank;
- } else {
- $clicks[$detail][$q] = $click[$detail][$q];
- if ($detail=='answers') {
- $this->set_legend($table, $q, $click[$detail][$q], $questions[$questionids[$q]]);
- }
- $this->data['details'][] = $click[$detail][$q];
- $this->update_event_count($click, $detail, $q);
- }
- } else {
- if (!isset($click[$detail][$q])) {
- $this->data['details'][] = $blank;
- } else {
- $difference = '';
- if ($detail=='answers') {
- if ($click[$detail][$q] != $clicks[$detail][$q]) {
- $pattern = '/^'.preg_quote($clicks[$detail][$q], '/').',/';
- $difference = preg_replace($pattern, '', $click[$detail][$q], 1);
- }
- } else { // hints, clues, checks
- if ($click[$detail][$q] > $clicks[$detail][$q]) {
- $difference = $click[$detail][$q] - $clicks[$detail][$q];
- }
- }
- if ($difference) {
- $clicks[$detail][$q] = $click[$detail][$q];
- $click[$detail][$q] = $difference;
- if ($detail=='answers') {
- $this->set_legend($table, $q, $difference, $questions[$questionids[$q]]);
- }
- $this->data['details'][] = $difference;
- $this->update_event_count($click, $detail, $q);
- } else {
- unset($click[$detail][$q]);
- $this->data['details'][] = $blank;
- }
- }
- }
- break;
- case 'changes':
- case 'events':
- if (empty($click[$detail][$q])) {
- $this->data['details'][] = $blank;
- } else {
- $this->data['details'][] = $click[$detail][$q];
- }
- break;
- default:
- // do nothing
- break;
- } // end switch
- } // for $q
- } // foreach $detail
-
- // set data cell values for
- $this->set_data_click(
- $allow_review ? '<a href="review.php?hp='.$hotpot->id.'&attempt='.$attempt->id.'">'.$clickcount.'</a>' : $clickcount,
- trim(userdate($attempt->timefinish, $strftimetime)),
- $exercisetype,
- $click
- );
- $this->set_data($cells, 'click');
- $this->set_data($cells, 'details');
-
- $this->set_data_totals($click, $clicks, $questioncount, $blank, $attempt);
- $this->set_data($cells, 'totals');
-
- $table->data[] = $cells;
- $clickcount++;
-
- } // end foreach $attempt
-
- // insert 'tabledivider' between users
- $table->data[] = 'hr';
-
- } // end foreach $user
-
- // remove final 'hr' from data rows
- array_pop($table->data);
-
- if ($is_html && $CFG->hotpot_showtimes) {
- $count = count($users);
- $duration = sprintf("%0.3f", microtime_diff($start_report_time, microtime()));
- print "$count users processed in $duration seconds (".sprintf("%0.3f", $duration/$count).' secs/user)<hr size="1" noshade="noshade" />'."\n";
- }
-
- $tables[] = &$table;
- $this->create_legend_table($tables, $table);
-
- } // end function
-
- function get_exercisetype(&$questions, &$questionids, &$blank) {
- if (empty($questions)) {
- $type = $blank;
- } else {
- switch ($questions[$questionids[0]]->type) {
- case HOTPOT_JCB:
- $type = "JCB";
- break;
- case HOTPOT_JCLOZE :
- $type = "JCloze";
- break;
- case HOTPOT_JCROSS :
- $type = "JCross";
- break;
- case HOTPOT_JMATCH :
- $type = "JMatch";
- break;
- case HOTPOT_JMIX :
- $type = "JMix";
- break;
- case HOTPOT_JQUIZ :
- $type = "JQuiz";
- break;
- case HOTPOT_TEXTOYS_RHUBARB :
- $type = "Rhubarb";
- break;
- case HOTPOT_TEXTOYS_SEQUITUR :
- $type = "Sequitur";
- break;
- default:
- $type = $blank;
- }
- }
- return $type;
- }
- function set_head(&$options, &$table, $zone, $exercisetype='', $details=array(), $questioncount=0) {
-
- if (empty($table->head)) {
- $table->head = array();
- }
- switch ($zone) {
-
- case 'exercise':
- array_push($table->head,
- get_string('reportcoursename', 'hotpot'),
- get_string('reportsectionnumber', 'hotpot'),
- get_string('reportexercisenumber', 'hotpot'),
- get_string('reportexercisename', 'hotpot'),
- get_string('reportexercisetype', 'hotpot'),
- get_string('reportnumberofquestions', 'hotpot')
- );
- break;
- case 'user':
- array_push($table->head,
- get_string('reportstudentid', 'hotpot'),
- get_string('reportlogindate', 'hotpot'),
- get_string('reportlogintime', 'hotpot'),
- get_string('reportlogofftime', 'hotpot')
- );
- break;
- case 'attempt':
- array_push($table->head,
- get_string('reportattemptnumber', 'hotpot'),
- get_string('reportattemptstart', 'hotpot'),
- get_string('reportattemptfinish', 'hotpot')
- );
- break;
- case 'click':
- array_push($table->head,
- get_string('reportclicknumber', 'hotpot'),
- get_string('reportclicktime', 'hotpot'),
- get_string('reportclicktype', 'hotpot')
- );
- break;
-
- case 'details':
- foreach($details as $detail) {
-
- if ($exercisetype=='JQuiz' && $detail=='clues') {
- $detail = 'showanswer';
- }
- $detail = get_string("report$detail", 'hotpot');
-
- for ($i=0; $i<$questioncount; $i++) {
- $str = get_string('questionshort', 'hotpot', $i+1);
- if ($i==0 || $options['reportformat']!='htm') {
- $str = "$detail $str";
- }
- $table->head[] = $str;
- }
- }
- break;
-
- case 'totals':
-
- $reportpercentscore =get_string('reportpercentscore', 'hotpot');
- if (!function_exists('clean_getstring_data')) { // Moodle 1.4 (and less)
- $reportpercentscore = str_replace('%', '%%', $reportpercentscore);
- }
-
- array_push($table->head,
- get_string('reportthisclick', 'hotpot', get_string('reportquestionstried', 'hotpot')),
- get_string('reportsofar', 'hotpot', get_string('reportquestionstried', 'hotpot')),
-
- get_string('reportthisclick', 'hotpot', get_string('reportright', 'hotpot')),
- get_string('reportthisclick', 'hotpot', get_string('reportwrong', 'hotpot')),
- get_string('reportthisclick', 'hotpot', get_string('reportnottried', 'hotpot')),
-
- get_string('reportsofar', 'hotpot', get_string('reportright', 'hotpot')),
- get_string('reportsofar', 'hotpot', get_string('reportwrong', 'hotpot')),
- get_string('reportsofar', 'hotpot', get_string('reportnottried', 'hotpot')),
-
- get_string('reportthisclick', 'hotpot', get_string('reportanswers', 'hotpot')),
- get_string('reportthisclick', 'hotpot', get_string('reporthints', 'hotpot')),
- get_string('reportthisclick', 'hotpot', get_string($exercisetype=='JQuiz' ? 'reportshowanswer' : 'reportclues', 'hotpot')),
- get_string('reportthisclick', 'hotpot', get_string('reportevents', 'hotpot')),
-
- get_string('reportsofar', 'hotpot', get_string('reporthints', 'hotpot')),
- get_string('reportsofar', 'hotpot', get_string($exercisetype=='JQuiz' ? 'reportshowanswer' : 'reportclues', 'hotpot')),
-
- get_string('reportthisclick', 'hotpot', get_string('reportrawscore', 'hotpot')),
- get_string('reportthisclick', 'hotpot', get_string('reportmaxscore', 'hotpot')),
- get_string('reportthisclick', 'hotpot', $reportpercentscore),
-
- get_string('reportsofar', 'hotpot', get_string('reportrawscore', 'hotpot')),
- get_string('reportsofar', 'hotpot', get_string('reportmaxscore', 'hotpot')),
- get_string('reportsofar', 'hotpot', $reportpercentscore),
-
- get_string('reporthotpotscore', 'hotpot')
- );
- break;
- } // end switch
- }
- function set_align_and_wrap(&$table) {
- $count = count($table->head);
- for ($i=0; $i<$count; $i++) {
-
- if ($i==0 || $i==1 || $i==2 || $i==4 || $i==5 || $i>=7) {
- // numeric (and short text) columns
- $table->align[] = 'center';
- $table->wrap[] = '';
- } else {
- // text columns
- $table->align[] = 'left';
- $table->wrap[] = 'nowrap';
- }
- }
- }
-
- function set_data_exercise(&$cm, &$course, &$hotpot, &$questions, &$questionids, &$questioncount, &$blank) {
- // get exercise details (course name, section number, activity number, quiztype and question count)
- $record = get_record("course_sections", "id", $cm->section);
- $this->data['exercise'] = array(
- 'course' => $course->shortname,
- 'section' => empty($record) ? $blank : $record->section+1,
- 'number' => empty($record) ? $blank : array_search($cm->id, explode(',', $record->sequence))+1,
- 'name' => $hotpot->name,
- 'type' => $this->get_exercisetype($questions, $questionids, $blank),
- 'questioncount' => $questioncount
- );
- }
- function set_data_user(&$options, &$course, &$user) {
- global $CFG;
-
- // shortcut to first attempt record (which also hold user info)
- $attempt = &$user->attempts[0];
-
- $idnumber = $attempt->idnumber;
- if (empty($idnumber)) {
- $idnumber = fullname($attempt);
- }
- if ($options['reportformat']=='htm') {
- $idnumber = '<a href="'.$CFG->wwwroot.'/user/view.php?id='.$attempt->userid.'&course='.$course->id.'">'.$idnumber.'</a>';
- }
- $this->data['user'] = array(
- 'idnumber' => $idnumber,
- );
- }
-
- function set_data_attempt(&$attempt, &$strftimedate, &$strftimetime, &$blank) {
- global $CFG;
-
- $records = get_records_sql_menu("
- SELECT userid, MAX(time) AS logintime
- FROM {$CFG->prefix}log
- WHERE userid=$attempt->userid AND action='login' AND time<$attempt->timestart
- GROUP BY userid
- ");
-
- if (empty($records)) {
- $logindate = $blank;
- $logintime = $blank;
- } else {
- $logintime = $records[$attempt->userid];
- $logindate = trim(userdate($logintime, $strftimedate));
- $logintime = trim(userdate($logintime, $strftimetime));
- }
-
- $records = get_records_sql_menu("
- SELECT userid, MIN(time) AS logouttime
- FROM {$CFG->prefix}log
- WHERE userid=$attempt->userid AND action='logout' AND time>$attempt->cr_timefinish
- GROUP BY userid
- ");
-
- if (empty($records)) {
- $logouttime = $blank;
- } else {
- $logouttime = $records[$attempt->userid];
- $logouttime = trim(userdate($logouttime, $strftimetime));
- }
-
-
- $this->data['attempt'] = array(
- 'logindate' => $logindate,
- 'logintime' => $logintime,
- 'logouttime' => $logouttime,
-
- 'number' => $attempt->attempt,
- 'start' => trim(userdate($attempt->timestart, $strftimetime)),
- 'finish' => trim(userdate($attempt->cr_timefinish, $strftimetime)),
- );
- }
-
- function set_data_click($number, $time, $exercisetype, $click) {
- $types = array();
- foreach (array_keys($click['types']) as $type) {
- if ($exercisetype=='JQuiz' && $type=='clues') {
- $type = 'showanswer';
- } else {
- // remove final 's'
- $type = substr($type, 0, strlen($type)-1);
- }
- // $types[] = get_string($type, 'hotpot');
- $types[] = $type;
- }
-
- $this->data['click'] = array(
- 'number' => $number,
- 'time' => $time,
- 'type' => empty($types) ? '??' : implode(',', $types)
- );
- }
-
- function set_data_totals(&$click, &$clicks, &$questioncount, &$blank, &$attempt) {
- $count= array(
- 'click' => array(
- 'correct' => count($click['correct']),
- 'wrong' => count($click['wrong']),
- 'answers' => count($click['answers']),
- 'hints' => array_sum($click['hints']),
- 'clues' => array_sum($click['clues']),
- 'events' => array_sum($click['events']),
- 'score' => array_sum($click['score']),
- 'maxscore' => array_sum($click['weighting']),
- ),
- 'clicks' => array(
- 'correct' => count($clicks['correct']),
- 'wrong' => count($clicks['wrong']),
- 'answers' => count($clicks['answers']),
- 'hints' => array_sum($clicks['hints']),
- 'clues' => array_sum($clicks['clues']),
- 'score' => array_sum($clicks['score']),
- 'maxscore' => array_sum($clicks['weighting']),
- )
- );
-
- foreach ($count as $period=>$values) {
- $count[$period]['nottried'] = $questioncount - ($values['correct'] + $values['wrong']);
- $count[$period]['percent'] = empty($values['maxscore']) ? $blank : round(100 * $values['score'] / $values['maxscore'], 0);
-
- // blank out zero click values
- if ($period=='click') {
- foreach ($values as $detail=>$value) {
- if ($detail=='answers' || $detail=='hints' || $detail=='clues' || $detail=='events') {
- if (empty($value)) {
- $count[$period][$detail] = $blank;
- }
- }
- }
- }
- }
-
- $this->data['totals'] = array(
-
- $count['click']['answers'], // "q's tried"
- $count['clicks']['answers'], // "q's tried so far"
- $count['click']['correct'], // "right"
- $count['click']['wrong'], // "wrong"
- $count['click']['nottried'], // "not tried"
- $count['clicks']['correct'], // "right so far"
- $count['clicks']['wrong'], // "wrong so far"
- $count['clicks']['nottried'], // "not tried so far"
-
- $count['click']['answers'], // "answers",
- $count['click']['hints'], // "hints",
- $count['click']['clues'], // "clues",
- $count['click']['events'], // "answers",
-
- $count['clicks']['hints'], // "hints so far",
- $count['clicks']['clues'], // "clues so far",
-
- $count['click']['score'], // 'raw score',
- $count['click']['maxscore'], // 'max score',
- $count['click']['percent'], // '% score'
-
- $count['clicks']['score'], // 'raw score,
- $count['clicks']['maxscore'], // 'max score,
- $count['clicks']['percent'], // '% score