make compatible with PHP 5.1.2 by removing variable assignments in calls to functions e.g. myfunction($a=1); Micro-incremented version number to 2.1.15

This commit is contained in:
gbateson 2006-03-30 03:17:51 +00:00
parent 475e9de86f
commit c20b623804
6 changed files with 772 additions and 759 deletions

View file

@ -1,10 +1,10 @@
This is v2.1.14 of the HotPot module
This is v2.1.15 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
- PHP 4.1 thru 5.1.2
- MySQL and PostgreSQL databases
This module may be distributed under the terms of the General Public License

View file

@ -166,23 +166,23 @@ define("HOTPOT_DISPLAYNEXT_INDEX", "2");
// possible return values:
// false:
// display moderr.html (if exists) OR "Could not update" and return to couse view
// string:
// display as error message and return to course view
// false:
// display moderr.html (if exists) OR "Could not update" and return to couse view
// string:
// display as error message and return to course view
// true (or non-zero number):
// continue to $hp->redirect (if set) OR hotpot/view.php (to displsay quiz)
// continue to $hp->redirect (if set) OR hotpot/view.php (to displsay quiz)
// $hp is an object containing the values of the form in mod.html
// i.e. all the fields in the 'hotpot' table, plus the following:
// $hp->course : an id in the 'course' table
// $hp->coursemodule : an id in the 'course_modules' table
// $hp->section : an id in the 'course_sections' table
// $hp->module : an id in the 'modules' table
// $hp->modulename : always 'hotpot'
// $hp->instance : an id in the 'hotpot' table
// $hp->mode : 'add' or 'update'
// $hp->sesskey : unique string required for Moodle's session management
// $hp->course : an id in the 'course' table
// $hp->coursemodule : an id in the 'course_modules' table
// $hp->section : an id in the 'course_sections' table
// $hp->module : an id in the 'modules' table
// $hp->modulename : always 'hotpot'
// $hp->instance : an id in the 'hotpot' table
// $hp->mode : 'add' or 'update'
// $hp->sesskey : unique string required for Moodle's session management
function hotpot_add_instance(&$hp) {
if (hotpot_set_form_values($hp)) {
@ -1255,9 +1255,9 @@ class hotpot_xml_tree {
if (empty($str)) {
$this->xml = array();
} else {
if (empty($CFG->unicodedb)) {
$str = utf8_encode($str);
}
if (empty($CFG->unicodedb)) {
$str = utf8_encode($str);
}
$this->xml = xmlize($str, 0);
}
$this->xml_root = $xml_root;
@ -1268,9 +1268,9 @@ class hotpot_xml_tree {
eval('$value = &$this->xml'.$this->xml_root.$tags.$more_tags.';');
if (is_string($value)) {
if (empty($CFG->unicodedb)) {
$value = utf8_decode($value);
}
if (empty($CFG->unicodedb)) {
$value = utf8_decode($value);
}
// decode angle brackets
$value = strtr($value, array('&#x003C;'=>'<', '&#x003E;'=>'>', '&#x0026;'=>'&'));
@ -1296,7 +1296,7 @@ class hotpot_xml_tree {
// encode unicode characters as HTML entities
// (in particular, accented charaters that have not been encoded by HP)
// unicode characetsr can be detected by checking the hex value of a character
// unicode characters can be detected by checking the hex value of a character
// 00 - 7F : ascii char (roman alphabet + punctuation)
// 80 - BF : byte 2, 3 or 4 of a unicode char
// C0 - DF : 1st byte of 2-byte char
@ -1306,20 +1306,6 @@ class hotpot_xml_tree {
// 80 - FF : single-byte, non-ascii char
$search = '#('.'[\xc0-\xdf][\x80-\xbf]'.'|'.'[\xe0-\xef][\x80-\xbf]{2}'.'|'.'[\xf0-\xff][\x80-\xbf]{3}'.'|'.'[\x80-\xff]'.')#se';
$value = preg_replace($search, "hotpot_utf8_to_html_entity('\\1')", $value);
// NOTICE
// ======
// the following lines have been removed because
// the final "preg_replace" takes several SECONDS to run
// encode any orphaned angle brackets back to html entities
//if (empty($this->tag_pattern)) {
// $q = "'"; // single quote
// $qq = '"'; // double quote
// $this->tag_pattern = '<(([^>'.$q.$qq.']*)|('."{$q}[^$q]*$q".')|('."{$qq}[^$qq]*$qq".'))*>';
//}
//$value = preg_replace('/<([^>]*'.$this->tag_pattern.')/', '&lt;$1', $value);
//$value = preg_replace('/('.$this->tag_pattern.'[^<]*)>/', '$1&gt;', $value);
}
return $value;
}
@ -1389,9 +1375,9 @@ class hotpot_xml_quiz extends hotpot_xml_tree {
$this->create_html = $create_html;
// extract fields from $obj
// course : the course id
// reference : the filename within the files folder
// location : "site" files folder or "course" files folder
// course : the course id
// reference : the filename within the files folder
// location : "site" files folder or "course" files folder
// navigation : type of navigation required in quiz
// forceplugins : force Moodle compatible media players
$this->course = $this->obj_value($obj, 'course');
@ -1664,10 +1650,10 @@ class hotpot_xml_quiz extends hotpot_xml_tree {
$filepath = "$Q\.($filetype)";
// pattern to match <param> tags which contain the file path
// wmp : url
// wmp : url
// quicktime : src
// realplayer : src
// flash : movie (doesn't need replacing)
// flash : movie (doesn't need replacing)
$param_url = "/<param$s{$n}name=$q(src|url)$q$s{$n}value=$q($filepath)$q$n>/is";
// pattern to match <a> tags which link to multimedia files (not swf)
@ -2176,7 +2162,7 @@ if (!function_exists('html_entity_decode')) {
// required for Moodle 1.x
if (!isset($CFG->pixpath)) {
$CFG->pixpath = "$CFG->wwwroot/pix";
$CFG->pixpath = "$CFG->wwwroot/pix";
}
if (!defined('PARAM_RAW')) define('PARAM_RAW', 0x0000);

View file

@ -3,9 +3,10 @@
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
// create the tables
$tables = array();
$this->create_clickreport_table($hotpot, $cm, $course, $users, $attempts, $questions, $options, $tables);
// print the tables
$this->print_report($course, $hotpot, $tables, $options);
return true;
}

View file

@ -1,8 +1,10 @@
<?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) {
$this->create_overview_table($hotpot, $cm, $course, $users, $attempts, $questions, $options, $tables=array());
$tables = array();
$this->create_overview_table($hotpot, $cm, $course, $users, $attempts, $questions, $options, $tables);
$this->print_report($course, $hotpot, $tables, $options);
return true;
}

View file

@ -411,9 +411,9 @@ class hotpot_xml_quiz_template extends hotpot_xml_template_default {
return $i;
}
function v6_expand_MatchDivItems() {
$str = '';
$this->get_jmatch_items($l_items=array(), $r_items = array());
$l_items = array();
$r_items = array();
$this->get_jmatch_items($l_items, $r_items);
$l_keys = $this->shuffle_jmatch_items($l_items);
$r_keys = $this->shuffle_jmatch_items($r_items);
@ -422,6 +422,8 @@ class hotpot_xml_quiz_template extends hotpot_xml_template_default {
foreach ($r_keys as $key) {
$options .= '<option value="'.$key.'">'.$r_items[$key]['text'][0]['#'].'</option>'."\n";
}
$str = '';
foreach ($l_keys as $key) {
$str .= '<tr><td class="LeftItem">'.$l_items[$key]['text'][0]['#'].'</td>';
$str .= '<td class="RightItem"><select id="s'.$key.'_'.$key.'">'.$options.'</select></td>';
@ -693,8 +695,11 @@ class hotpot_xml_quiz_template extends hotpot_xml_template_default {
// specials (JMatch)
function v6_expand_FixedArray() {
$l_items = array();
$r_items = array();
$this->get_jmatch_items($l_items, $r_items);
$str = '';
$this->get_jmatch_items($l_items=array(), $r_items = array());
foreach ($l_items as $i=>$item) {
$str .= "F[$i] = new Array();\n";
$str .= "F[$i][0] = '".$this->js_safe($item['text'][0]['#'], true)."';\n";
@ -703,8 +708,11 @@ class hotpot_xml_quiz_template extends hotpot_xml_template_default {
return $str;
}
function v6_expand_DragArray() {
$l_items = array();
$r_items = array();
$this->get_jmatch_items($l_items, $r_items);
$str = '';
$this->get_jmatch_items($l_items=array(), $r_items = array());
foreach ($r_items as $i=>$item) {
$str .= "D[$i] = new Array();\n";
$str .= "D[$i][0] = '".$this->js_safe($item['text'][0]['#'], true)."';\n";
@ -1085,7 +1093,11 @@ class hotpot_xml_quiz_template extends hotpot_xml_template_default {
// jcross6.js_
function v6_expand_LetterArray() {
$this->v6_get_jcross_grid($row=NULL, $r_max=0, $c_max=0);
$row=NULL;
$r_max=0;
$c_max=0;
$this->v6_get_jcross_grid($row, $r_max, $c_max);
$str = '';
for($r=0; $r<=$r_max; $r++) {
$str .= "L[$r] = new Array(";
@ -1097,7 +1109,11 @@ class hotpot_xml_quiz_template extends hotpot_xml_template_default {
return $str;
}
function v6_expand_GuessArray() {
$this->v6_get_jcross_grid($row=NULL, $r_max=0, $c_max=0);
$row=NULL;
$r_max=0;
$c_max=0;
$this->v6_get_jcross_grid($row, $r_max, $c_max);
$str = '';
for($r=0; $r<=$r_max; $r++) {
$str .= "G[$r] = new Array('".str_repeat("','", $c_max)."');\n";
@ -1105,7 +1121,11 @@ class hotpot_xml_quiz_template extends hotpot_xml_template_default {
return $str;
}
function v6_expand_ClueNumArray() {
$this->v6_get_jcross_grid($row=NULL, $r_max=0, $c_max=0);
$row=NULL;
$r_max=0;
$c_max=0;
$this->v6_get_jcross_grid($row, $r_max, $c_max);
$i = 0; // clue index
$str = '';
for($r=0; $r<=$r_max; $r++) {
@ -1128,7 +1148,11 @@ class hotpot_xml_quiz_template extends hotpot_xml_template_default {
return $str;
}
function v6_expand_GridBody() {
$this->v6_get_jcross_grid($row=NULL, $r_max=0, $c_max=0);
$row=NULL;
$r_max=0;
$c_max=0;
$this->v6_get_jcross_grid($row, $r_max, $c_max);
$i = 0; // clue index;
$str = '';
for($r=0; $r<=$r_max; $r++) {

View file

@ -3,8 +3,8 @@
/// Code fragment to define the version of hotpot
/// This fragment is called by moodle_needs_upgrading() and /admin/index.php
/////////////////////////////////////////////////////////////////////////////////
$module->version = 2005090714; // release date of this version (see note below)
$module->release = 'v2.1.14'; // human-friendly version name (used in mod/hotpot/lib.php)
$module->version = 2005090715; // release date of this version (see note below)
$module->release = 'v2.1.15'; // human-friendly version name (used in mod/hotpot/lib.php)
$module->cron = 0; // period for cron to check this module (secs)
// interpretation of YYYYMMDDXY version numbers
// YYYY : year