mirror of
https://github.com/moodle/moodle.git
synced 2025-08-04 16:36:37 +02:00
merging changes from MOODLE_16_STABLE
This commit is contained in:
parent
889e6b46f4
commit
a8ff58dd2c
7 changed files with 147 additions and 137 deletions
|
@ -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)
|
||||
|
|
|
@ -11,13 +11,13 @@ function hotpot_upgrade($oldversion) {
|
|||
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();
|
||||
}
|
||||
|
@ -41,50 +41,11 @@ function hotpot_upgrade($oldversion) {
|
|||
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');
|
||||
|
||||
if ($oldversion < 2006071600) {
|
||||
require_once $update_to_v2;
|
||||
$ok = $ok && hotpot_update_to_v2_1_21();
|
||||
}
|
||||
|
||||
|
||||
return $ok;
|
||||
}
|
||||
?>
|
||||
|
|
|
@ -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));
|
||||
|
|
|
@ -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,18 +298,21 @@ 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();
|
||||
if (isset($record->$key)) {
|
||||
$old_ids = explode(',', $record->$key);
|
||||
foreach ($old_ids as $old_id) {
|
||||
if (empty($old_id)) {
|
||||
// do nothing
|
||||
} else {
|
||||
$key_record = backup_getid($restore->backup_unique_code, $key_table, $old_id);
|
||||
if ($key_record) {
|
||||
$new_ids[] = $key_record->new_id;
|
||||
|
@ -321,12 +330,33 @@ function hotpot_restore_record(&$restore, $status, &$xml, $table, $foreign_keys,
|
|||
$ok = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
$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;
|
||||
|
|
|
@ -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 = 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->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
|
||||
|
|
|
@ -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');
|
||||
}
|
||||
|
||||
|
|
|
@ -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 "</b></td></tr>\n";
|
||||
$i = 1;
|
||||
|
@ -1436,7 +1442,11 @@
|
|||
echo "$jumptitle</td></tr>\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 "<tr><td align=\"right\" width=\"20%\"><b>".get_string("score", "lesson")." $i:";
|
||||
echo "</b></td><td width=\"80%\">\n";
|
||||
echo "$answer->score</td></tr>\n";
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue