From: skodak Date: Mon, 31 Jul 2006 18:10:02 +0000 (+0000) Subject: merging changes from MOODLE_16_STABLE X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=a8ff58dd2c85ecf140f1cf3374215800e9c2b070;p=moodle.git merging changes from MOODLE_16_STABLE --- diff --git a/mod/hotpot/README.TXT b/mod/hotpot/README.TXT index 8a58a9916f..443046b787 100644 --- a/mod/hotpot/README.TXT +++ b/mod/hotpot/README.TXT @@ -1,13 +1,14 @@ =============================================== -This is v2.1.20 of the HotPot module for Moodle +This is v2.1.21 of the HotPot module for Moodle =============================================== 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 + - Moodle 1.1 thru 1.7 - PHP 4.1 thru 5.1.2 - - MySQL and PostgreSQL databases + - MySQL 4.x thru 5.0 + - PostgreSQL 7.3 thru 8.2 This module may be distributed under the terms of the General Public License (see http://www.gnu.org/licenses/gpl.txt for details) diff --git a/mod/hotpot/db/postgres7.php b/mod/hotpot/db/postgres7.php index e5d5252217..e5f80e4f94 100644 --- a/mod/hotpot/db/postgres7.php +++ b/mod/hotpot/db/postgres7.php @@ -1,90 +1,51 @@ dirroot/mod/hotpot/db/update_to_v2.php"; - - // update from HotPot v1 to HotPot v2 - if ($oldversion < 2005031400) { - require_once $update_to_v2; - $ok = $ok && hotpot_update_to_v2_from_v1(); - } - // update to HotPot v2.1 - if ($oldversion < 2005090700) { - require_once $update_to_v2; - $ok = $ok && hotpot_update_to_v2_1(); - } - if ($oldversion > 2005031419 && $oldversion < 2005090702) { - // update to from HotPot v2.1.0 or v2.1.1 - require_once $update_to_v2; - $ok = $ok && hotpot_update_to_v2_1_2(); - } - if ($oldversion < 2005090706) { - require_once $update_to_v2; - $ok = $ok && hotpot_update_to_v2_1_6(); - } - if ($oldversion < 2005090708) { - require_once $update_to_v2; - $ok = $ok && hotpot_update_to_v2_1_8(); - } - if ($oldversion < 2006042103) { - require_once $update_to_v2; - $ok = $ok && hotpot_update_to_v2_1_16(); - } - if ($oldversion < 2006042602) { - require_once $update_to_v2; - $ok = $ok && hotpot_update_to_v2_1_17(); - } - if ($oldversion < 2006042803) { - require_once $update_to_v2; - $ok = $ok && hotpot_update_to_v2_1_18(); - } - - - if ($oldversion < 2006050201) { - - modify_database('', 'ALTER TABLE prefix_hotpot - ALTER COLUMN studentfeedbackurl SET DEFAULT \'\', - ALTER COLUMN studentfeedbackurl SET NOT NULL, - ALTER COLUMN clickreporting SET DEFAULT 0, - ALTER COLUMN studentfeedback SET DEFAULT 0'); - - modify_database('', 'ALTER TABLE prefix_hotpot_strings - ALTER COLUMN string SET DEFAULT \'\''); - - modify_database('', 'ALTER TABLE prefix_hotpot_responses - ALTER COLUMN hints TYPE int2, - ALTER COLUMN hints SET DEFAULT 0, - ALTER COLUMN ignored SET DEFAULT \'\', - ALTER COLUMN ignored SET NOT NULL, - ALTER COLUMN score TYPE int2, - ALTER COLUMN score SET DEFAULT 0, - ALTER COLUMN correct SET DEFAULT \'\', - ALTER COLUMN correct SET NOT NULL, - ALTER COLUMN weighting TYPE int2, - ALTER COLUMN weighting SET DEFAULT 0, - ALTER COLUMN wrong SET DEFAULT \'\', - ALTER COLUMN wrong SET NOT NULL, - ALTER COLUMN checks TYPE int2, - ALTER COLUMN checks SET DEFAULT 0, - ALTER COLUMN clues TYPE int2, - ALTER COLUMN clues SET DEFAULT 0'); - - modify_database('', 'ALTER TABLE prefix_hotpot_questions - ALTER COLUMN "type" SET DEFAULT 0'); - - modify_database('', 'ALTER TABLE prefix_hotpot_attempts - ALTER COLUMN penalties TYPE smallint, - ALTER COLUMN penalties SET DEFAULT 0, - ALTER COLUMN score TYPE smallint, - ALTER COLUMN score SET DEFAULT 0, - ALTER COLUMN status SET DEFAULT 1'); - - } - - - return $ok; + global $CFG; + $ok = true; + + // set path to update functions + $update_to_v2 = "$CFG->dirroot/mod/hotpot/db/update_to_v2.php"; + + // update from HotPot v1 to HotPot v2 + if ($oldversion < 2005031400) { + require_once $update_to_v2; + $ok = $ok && hotpot_update_to_v2_from_v1(); + } + + // update to HotPot v2.1 + if ($oldversion < 2005090700) { + require_once $update_to_v2; + $ok = $ok && hotpot_update_to_v2_1(); + } + if ($oldversion > 2005031419 && $oldversion < 2005090702) { + require_once $update_to_v2; + $ok = $ok && hotpot_update_to_v2_1_2(); + } + if ($oldversion < 2005090706) { + require_once $update_to_v2; + $ok = $ok && hotpot_update_to_v2_1_6(); + } + if ($oldversion < 2005090708) { + require_once $update_to_v2; + $ok = $ok && hotpot_update_to_v2_1_8(); + } + if ($oldversion < 2006042103) { + require_once $update_to_v2; + $ok = $ok && hotpot_update_to_v2_1_16(); + } + if ($oldversion < 2006042602) { + require_once $update_to_v2; + $ok = $ok && hotpot_update_to_v2_1_17(); + } + if ($oldversion < 2006042803) { + require_once $update_to_v2; + $ok = $ok && hotpot_update_to_v2_1_18(); + } + if ($oldversion < 2006071600) { + require_once $update_to_v2; + $ok = $ok && hotpot_update_to_v2_1_21(); + } + + return $ok; } ?> diff --git a/mod/hotpot/db/postgres7.sql b/mod/hotpot/db/postgres7.sql index fb36061c92..ceadffd09d 100644 --- a/mod/hotpot/db/postgres7.sql +++ b/mod/hotpot/db/postgres7.sql @@ -79,7 +79,7 @@ CREATE TABLE prefix_hotpot_questions ( COMMENT ON TABLE prefix_hotpot_questions IS 'details about questions in Hot Potatoes quiz attempts'; CREATE INDEX prefix_hotpot_questions_hotpot_idx ON prefix_hotpot_questions (hotpot); -CREATE INDEX prefix_hotpot_questions_name_idx ON prefix_hotpot_questions (SUBSTR(name,20)); +CREATE INDEX prefix_hotpot_questions_name_idx ON prefix_hotpot_questions (SUBSTR("name",20)); # # Table structure for table `hotpot_responses` @@ -113,4 +113,4 @@ CREATE TABLE prefix_hotpot_strings ( ); COMMENT ON TABLE prefix_hotpot_strings IS 'strings used in Hot Potatoes questions and responses'; -CREATE INDEX prefix_hotpot_strings_string_idx ON prefix_hotpot_strings (SUBSTR(string,20)); +CREATE INDEX prefix_hotpot_strings_string_idx ON prefix_hotpot_strings (SUBSTR("string",20)); diff --git a/mod/hotpot/restorelib.php b/mod/hotpot/restorelib.php index 20faec8b6d..c68b2f0f6f 100644 --- a/mod/hotpot/restorelib.php +++ b/mod/hotpot/restorelib.php @@ -203,7 +203,7 @@ function hotpot_restore_details(&$restore, $status, &$xml, &$record) { if (empty($record->details)) { $status = true; } else { - unset($details); + $details = new stdClass(); $details->attempt = $record->id; $details->details = $record->details; if (insert_record('hotpot_details', $details)) { @@ -226,7 +226,8 @@ function hotpot_restore_records(&$restore, $status, &$xml, $table, $foreign_keys // $record_TAG : (optional) the name of an XML tag which starts a single record // If no $record_TAG is specified, the block of records is assumed to be a single record // other parameters are explained in "hotpot_restore_record" below - $i = 0; + + $i = 0; // index for $records_TAG do { unset($xml_records); if ($records_TAG) { @@ -238,10 +239,8 @@ function hotpot_restore_records(&$restore, $status, &$xml, $table, $foreign_keys $xml_records = &$xml; } } - if (empty($xml_records)) { - // do nothing - } else { - $ii = 0; + if (isset($xml_records)) { + $ii = 0; // index for $record_TAG do { unset($xml_record); if ($record_TAG) { @@ -253,9 +252,7 @@ function hotpot_restore_records(&$restore, $status, &$xml, $table, $foreign_keys $xml_record = &$xml_records; } } - if (empty($xml_record)) { - // do nothing - } else { + if (isset($xml_record)) { $status = hotpot_restore_record( $restore, $status, $xml_record, $table, $foreign_keys, $more_restore, $secondary_key ); @@ -283,7 +280,16 @@ function hotpot_restore_record(&$restore, $status, &$xml, $table, $foreign_keys, // the name of the secondary key field, if any, in the current $record. // If this field is specified, then the current record will only be added // if the $record->$secondarykey value does not already exist in $table - unset($record); + + // maintain a cache of info on table columns + static $table_columns = array(); + if (empty($table_columns[$table])) { + global $CFG, $db; + $table_columns[$table] = $db->MetaColumns("$CFG->prefix$table"); + } + + // get values for fields in this record + $record = new stdClass(); $TAGS = array_keys($xml); foreach ($TAGS as $TAG) { $value = $xml[$TAG][0]['#']; @@ -292,41 +298,65 @@ function hotpot_restore_record(&$restore, $status, &$xml, $table, $foreign_keys, $record->$tag = backup_todb($value); } } + + // update secondary keys, if any $ok = true; foreach ($foreign_keys as $key=>$value) { if (is_numeric($value)) { $record->$key = $value; } else { - if (empty($record->$key)) { - $record->$key = NULL; - } else { - $key_table = $value; - $new_ids = array(); + $key_table = $value; + $new_ids = array(); + if (isset($record->$key)) { $old_ids = explode(',', $record->$key); foreach ($old_ids as $old_id) { - $key_record = backup_getid($restore->backup_unique_code, $key_table, $old_id); - if ($key_record) { - $new_ids[] = $key_record->new_id; + if (empty($old_id)) { + // do nothing } else { - // foreign key could not be updated - if (!defined('RESTORE_SILENTLY')) { - print ""; + $ok = false; } - $ok = false; } } - $record->$key = implode(',', $new_ids); + } + $record->$key = implode(',', $new_ids); + } + } + + // check all "not null" fields have been set + foreach ($table_columns[$table] as $column) { + if ($column->not_null) { + $name = $column->name; + if ($name<>'id' && empty($record->$name)) { + if (isset($column->default_value)) { + $default = $column->default_value; + } else { + if (preg_match('/int|decimal|double|float|time|year/i', $column->type)) { + $default = 0; + } else { + $default = ''; + } + } + $record->$name = $default; } } } + // check everything is OK so far - if ($ok && isset($record)) { + if ($ok) { // store old record id, if necessary if (isset($record->id)) { $record->old_id = $record->id; @@ -343,7 +373,7 @@ function hotpot_restore_record(&$restore, $status, &$xml, $table, $foreign_keys, } if (empty($record->id)) { // add the $record (and get new id) - $record->id = insert_record ($table, $record); + $record->id = insert_record($table, $record); } // check $record was added (or found) if (is_numeric($record->id)) { diff --git a/mod/hotpot/version.php b/mod/hotpot/version.php index f5312d53f7..f06dafac36 100644 --- a/mod/hotpot/version.php +++ b/mod/hotpot/version.php @@ -3,9 +3,9 @@ /// Code fragment to define the version of hotpot /// This fragment is called by moodle_needs_upgrading() and /admin/index.php ///////////////////////////////////////////////////////////////////////////////// -$module->version = 2006052200; // release date of this version (see note below) -$module->release = 'v2.1.20'; // human-friendly version name (used in mod/hotpot/lib.php) -$module->cron = 0; // period for cron to check this module (secs) +$module->version = 2006071600; // release date of this version (see note below) +$module->release = 'v2.1.21'; // 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 // MM : month diff --git a/mod/lesson/db/postgres7.php b/mod/lesson/db/postgres7.php index fad2d9b161..2a37294c1a 100644 --- a/mod/lesson/db/postgres7.php +++ b/mod/lesson/db/postgres7.php @@ -318,30 +318,38 @@ function lesson_upgrade($oldversion) { execute_sql('DROP TABLE '.$CFG->prefix.'lesson_essay', false); // properly set the correct default values - modify_database('', 'ALTER TABLE prefix_lesson - ALTER COLUMN activitylink TYPE int8, - ALTER COLUMN activitylink SET DEFAULT 0, - ALTER COLUMN dependency TYPE int8, - ALTER COLUMN dependency SET DEFAULT 0'); + table_column('lesson', 'activitylink', 'activitylink', 'integer', '8', '', '0'); + table_column('lesson', 'dependency', 'dependency', 'integer', '8', '', '0'); modify_database('', 'ALTER TABLE prefix_lesson_timer - ALTER COLUMN lessontime SET DEFAULT 0, - ALTER COLUMN lessonid SET DEFAULT 0, - ALTER COLUMN userid SET DEFAULT 0, + ALTER COLUMN lessontime SET DEFAULT 0'); + modify_database('', 'ALTER TABLE prefix_lesson_timer + ALTER COLUMN lessonid SET DEFAULT 0'); + modify_database('', 'ALTER TABLE prefix_lesson_timer + ALTER COLUMN userid SET DEFAULT 0'); + modify_database('', 'ALTER TABLE prefix_lesson_timer ALTER COLUMN starttime SET DEFAULT 0'); modify_database('', 'ALTER TABLE prefix_lesson_branch - ALTER COLUMN lessonid SET DEFAULT 0, - ALTER COLUMN timeseen SET DEFAULT 0, - ALTER COLUMN userid SET DEFAULT 0, - ALTER COLUMN retry SET DEFAULT 0, - ALTER COLUMN pageid SET DEFAULT 0, + ALTER COLUMN lessonid SET DEFAULT 0'); + modify_database('', 'ALTER TABLE prefix_lesson_branch + ALTER COLUMN timeseen SET DEFAULT 0'); + modify_database('', 'ALTER TABLE prefix_lesson_branch + ALTER COLUMN userid SET DEFAULT 0'); + modify_database('', 'ALTER TABLE prefix_lesson_branch + ALTER COLUMN retry SET DEFAULT 0'); + modify_database('', 'ALTER TABLE prefix_lesson_branch + ALTER COLUMN pageid SET DEFAULT 0'); + modify_database('', 'ALTER TABLE prefix_lesson_branch ALTER COLUMN flag SET DEFAULT 0'); modify_database('', 'ALTER TABLE prefix_lesson_high_scores - ALTER COLUMN nickname SET DEFAULT \'\', - ALTER COLUMN lessonid SET DEFAULT 0, - ALTER COLUMN gradeid SET DEFAULT 0, + ALTER COLUMN nickname SET DEFAULT \'\''); + modify_database('', 'ALTER TABLE prefix_lesson_high_scores + ALTER COLUMN lessonid SET DEFAULT 0'); + modify_database('', 'ALTER TABLE prefix_lesson_high_scores + ALTER COLUMN gradeid SET DEFAULT 0'); + modify_database('', 'ALTER TABLE prefix_lesson_high_scores ALTER COLUMN userid SET DEFAULT 0'); } diff --git a/mod/lesson/view.php b/mod/lesson/view.php index 3f62919bde..e826a47c15 100644 --- a/mod/lesson/view.php +++ b/mod/lesson/view.php @@ -1306,6 +1306,12 @@ case LESSON_ENDOFBRANCH : echo get_string("endofbranch", "lesson"); break; + case LESSON_CLUSTER : + echo get_string("clustertitle", "lesson"); + break; + case LESSON_ENDOFCLUSTER : + echo get_string("endofclustertitle", "lesson"); + break; } echo "\n"; $i = 1; @@ -1436,7 +1442,11 @@ echo "$jumptitle\n"; } } else { - if ($lesson->custom && $page->qtype != LESSON_BRANCHTABLE && $page->qtype != LESSON_ENDOFBRANCH) { + if ($lesson->custom and + $page->qtype != LESSON_BRANCHTABLE and + $page->qtype != LESSON_ENDOFBRANCH and + $page->qtype != LESSON_CLUSTER and + $page->qtype != LESSON_ENDOFCLUSTER) { echo "".get_string("score", "lesson")." $i:"; echo "\n"; echo "$answer->score\n";