MDL-14679 upgrade $DB conversion

This commit is contained in:
skodak
2008-05-31 18:05:42 +00:00
parent ab122f4604
commit 219f652b91
45 changed files with 94 additions and 476 deletions
+1 -1
View File
@@ -19,7 +19,7 @@
function xmldb_backup_upgrade($oldversion=0) {
global $CFG, $THEME, $db;
global $CFG, $THEME, $DB;
$result = true;
@@ -7,7 +7,7 @@ class block_activity_modules extends block_list {
}
function get_content() {
global $CFG, $COURSE;
global $CFG, $COURSE, $DB;
if($this->content !== NULL) {
return $this->content;
@@ -21,7 +21,7 @@ class block_activity_modules extends block_list {
if ($COURSE->id == $this->instance->pageid) {
$course = $COURSE;
} else {
$course = get_record('course', 'id', $this->instance->pageid);
$course = get_record('course', array('id'=>$this->instance->pageid));
}
require_once($CFG->dirroot.'/course/lib.php');
+1 -1
View File
@@ -19,7 +19,7 @@
function xmldb_block_activity_modules_upgrade($oldversion=0) {
global $CFG, $THEME, $db;
global $CFG, $THEME, $DB;
$result = true;
+1 -1
View File
@@ -19,7 +19,7 @@
function xmldb_block_admin_upgrade($oldversion=0) {
global $CFG, $THEME, $db;
global $CFG, $THEME, $DB;
$result = true;
+11 -12
View File
@@ -39,8 +39,7 @@ class block_blog_tags extends block_base {
}
function get_content() {
global $CFG, $SITE, $COURSE, $USER;
global $CFG, $SITE, $COURSE, $USER, $DB;
if (empty($CFG->usetags) || empty($CFG->bloglevel)) {
$this->content->text = '';
@@ -74,20 +73,20 @@ class block_blog_tags extends block_base {
$timewithin = time() - $this->config->timewithin * 24 * 60 * 60; /// convert to seconds
$sql = 'SELECT t.id, t.tagtype, t.rawname, t.name, COUNT(DISTINCT ti.id) AS ct ';
$sql .= "FROM {$CFG->prefix}tag t, {$CFG->prefix}tag_instance ti, {$CFG->prefix}post p ";
$sql .= 'WHERE t.id = ti.tagid ';
$sql .= 'AND p.id = ti.itemid ';
// admins should be able to read all tags
if (!has_capability('moodle/user:readuserblogs', get_context_instance(CONTEXT_SYSTEM))) {
$sql .= 'AND (p.publishstate = \'site\' or p.publishstate=\'public\') ';
$type .= " AND (p.publishstate = 'site' or p.publishstate='public')";
}
$sql .= "AND ti.timemodified > {$timewithin} ";
$sql .= 'GROUP BY t.id, t.tagtype, t.name, t.rawname ';
$sql .= 'ORDER BY ct DESC, t.name ASC';
if ($tags = get_records_sql($sql, 0, $this->config->numberoftags)) {
$sql = "SELECT t.id, t.tagtype, t.rawname, t.name, COUNT(DISTINCT ti.id) AS ct
FROM {tag} t, {tag_instance} ti, {post} p
WHERE t.id = ti.tagid AND p.id = ti.itemid
$type
AND ti.timemodified > $timewithin
GROUP BY t.id, t.tagtype, t.name, t.rawname
ORDER BY ct DESC, t.name ASC";
if ($tags = get_records_sql($sql, null, 0, $this->config->numberoftags)) {
/// There are 2 things to do:
/// 1. tags with the same count should have the same size class
+1 -1
View File
@@ -19,7 +19,7 @@
function xmldb_block_calendar_month_upgrade($oldversion=0) {
global $CFG, $THEME, $db;
global $CFG, $THEME, $DB;
$result = true;
+1 -1
View File
@@ -19,7 +19,7 @@
function xmldb_block_calendar_upcoming_upgrade($oldversion=0) {
global $CFG, $THEME, $db;
global $CFG, $THEME, $DB;
$result = true;
+1 -1
View File
@@ -19,7 +19,7 @@
function xmldb_block_course_list_upgrade($oldversion=0) {
global $CFG, $THEME, $db;
global $CFG, $THEME, $DB;
$result = true;
+1 -1
View File
@@ -19,7 +19,7 @@
function xmldb_block_course_summary_upgrade($oldversion=0) {
global $CFG, $THEME, $db;
global $CFG, $THEME, $DB;
$result = true;
+4 -2
View File
@@ -19,7 +19,9 @@
function xmldb_blocks_upgrade($oldversion=0) {
global $CFG, $THEME, $db;
global $CFG, $THEME, $DB;
$dbman = $DB->get_manager();
$result = true;
@@ -40,7 +42,7 @@ function xmldb_blocks_upgrade($oldversion=0) {
$field->set_attributes(XMLDB_TYPE_TEXT, 'small', null, null, null, null, null, null, 'visible');
/// Launch change of nullability for field configdata
$result = $result && change_field_notnull($table, $field);
$result = $result && $dbman->change_field_notnull($table, $field);
}
+1 -1
View File
@@ -19,7 +19,7 @@
function xmldb_block_news_items_upgrade($oldversion=0) {
global $CFG, $THEME, $db;
global $CFG, $THEME, $DB;
$result = true;
+1 -1
View File
@@ -19,7 +19,7 @@
function xmldb_block_online_users_upgrade($oldversion=0) {
global $CFG, $THEME, $db;
global $CFG, $THEME, $DB;
$result = true;
+1 -1
View File
@@ -19,7 +19,7 @@
function xmldb_block_participants_upgrade($oldversion=0) {
global $CFG, $THEME, $db;
global $CFG, $THEME, $DB;
$result = true;
+1 -1
View File
@@ -19,7 +19,7 @@
function xmldb_block_recent_activity_upgrade($oldversion=0) {
global $CFG, $THEME, $db;
global $CFG, $THEME, $DB;
$result = true;
+2 -2
View File
@@ -19,7 +19,7 @@
function xmldb_block_rss_client_upgrade($oldversion=0) {
global $CFG, $THEME, $db;
global $CFG, $THEME, $DB;
$result = true;
@@ -30,7 +30,7 @@ function xmldb_block_rss_client_upgrade($oldversion=0) {
if ($result && $oldversion < 2007080100) { //New version in version.php
/// block_rss_timeout config setting must be block_rss_client_timeout
set_field('config', 'name', 'block_rss_client_timeout', 'name', 'block_rss_timeout');
$DB->set_field('config', 'name', 'block_rss_client_timeout', array('name'=>'block_rss_timeout'));
}
return $result;
+1 -1
View File
@@ -19,7 +19,7 @@
function xmldb_block_search_upgrade($oldversion=0) {
global $CFG, $THEME, $db;
global $CFG, $THEME, $DB;
$result = true;
+1 -1
View File
@@ -19,7 +19,7 @@
function xmldb_block_search_forums_upgrade($oldversion=0) {
global $CFG, $THEME, $db;
global $CFG, $THEME, $DB;
$result = true;
+5 -3
View File
@@ -8,8 +8,10 @@ class block_section_links extends block_base {
}
function instance_config($instance) {
global $DB;
parent::instance_config($instance);
$course = get_record('course', 'id', $this->instance->pageid);
$course = get_record('course', array('id'=>$this->instance->pageid));
if (isset($course->format)) {
if ($course->format == 'topics') {
$this->title = get_string('topics', 'block_section_links');
@@ -26,7 +28,7 @@ class block_section_links extends block_base {
}
function get_content() {
global $CFG, $USER, $COURSE;
global $CFG, $USER, $COURSE, $DB;
$highlight = 0;
@@ -45,7 +47,7 @@ class block_section_links extends block_base {
if ($this->instance->pageid == $COURSE->id) {
$course = $COURSE;
} else {
$course = get_record('course', 'id', $this->instance->pageid);
$course = get_record('course', array('id'=>$this->instance->pageid));
}
$context = get_context_instance(CONTEXT_COURSE, $course->id);
+1 -1
View File
@@ -19,7 +19,7 @@
function xmldb_block_section_links_upgrade($oldversion=0) {
global $CFG, $THEME, $db;
global $CFG, $THEME, $DB;
$result = true;
@@ -11,7 +11,7 @@ class block_site_main_menu extends block_list {
}
function get_content() {
global $USER, $CFG, $COURSE;
global $USER, $CFG, $COURSE, $DB;
if ($this->content !== NULL) {
return $this->content;
@@ -29,7 +29,7 @@ class block_site_main_menu extends block_list {
if ($COURSE->id == $this->instance->pageid) {
$course = $COURSE;
} else {
$course = get_record('course', 'id', $this->instance->pageid);
$course = get_record('course', array('id'=>$this->instance->pageid));
}
require_once($CFG->dirroot.'/course/lib.php');
@@ -11,7 +11,7 @@ class block_social_activities extends block_list {
}
function get_content() {
global $USER, $CFG, $COURSE;
global $USER, $CFG, $COURSE, $DB;
if ($this->content !== NULL) {
return $this->content;
@@ -29,7 +29,7 @@ class block_social_activities extends block_list {
if ($COURSE->id == $this->instance->pageid) {
$course = $COURSE;
} else {
$course = get_record('course', 'id', $this->instance->pageid);
$course = get_record('course', array('id'=>$this->instance->pageid));
}
require_once($CFG->dirroot.'/course/lib.php');
+1 -1
View File
@@ -19,7 +19,7 @@
function xmldb_block_social_activities_upgrade($oldversion=0) {
global $CFG, $THEME, $db;
global $CFG, $THEME, $DB;
$result = true;
+1 -1
View File
@@ -19,7 +19,7 @@
function xmldb_enrol_paypal_upgrade($oldversion=0) {
global $CFG, $THEME, $db;
global $CFG, $THEME, $DB;
$result = true;
+1 -1
View File
@@ -30,7 +30,7 @@
}
if (! $course = get_record("course", "id", $id) ) {
if (! $course = $DB->get_record("course", array("id"=>$id))) {
print_error('invalidcourseid');
}
+2 -3
View File
@@ -5,8 +5,7 @@
//Modifications by stronk7.
function activitynames_filter($courseid, $text) {
global $CFG, $COURSE;
global $CFG, $COURSE, $DB;
// Trivial-cache - keyed on $cachedcourseid
static $activitylist = null;
@@ -30,7 +29,7 @@
if ($COURSE->id == $courseid) {
$course = $COURSE;
} else {
$course = get_record("course", "id", $courseid);
$course = $DB->get_record("course", array("id"=>$courseid));
}
if (!isset($course->modinfo)) {
+1 -1
View File
@@ -28,7 +28,7 @@
$algebra = substr($query,8,$splitpos);
$md5 = md5($algebra);
if (strpos($query,'ShowDB') || strpos($query,'DeleteDB')) {
$texcache = get_record("cache_filters","filter","algebra", "md5key", $md5);
$texcache = $DB->get_record("cache_filters", array("filter"=>"algebra", "md5key"=>$md5));
}
if (strpos($query,'ShowDB')) {
if ($texcache) {
+6 -7
View File
@@ -86,8 +86,7 @@ function string_file_picture_algebra($imagefile, $tex= "", $height="", $width=""
function algebra_filter ($courseid, $text) {
global $CFG;
global $CFG, $DB;
/// Do a quick check using stripos to avoid unnecessary wor
if (!preg_match('/<algebra/i',$text) && !strstr($text,'@@')) {
@@ -101,9 +100,9 @@ function algebra_filter ($courseid, $text) {
# }
# if (strstr($scriptname,'post.php')) {
# $parent = forum_get_post_full($_GET['reply']);
# $discussion = get_record("forum_discussions","id",$parent->discussion);
# $discussion = $DB->get_record("forum_discussions",array("id"=>$parent->discussion));
# } else if (strstr($scriptname,'discuss.php')) {
# $discussion = get_record("forum_discussions","id",$_GET['d'] );
# $discussion = $DB->get_record("forum_discussions", array("id"=>$_GET['d']));
# } else {
# return $text;
# }
@@ -140,7 +139,7 @@ function algebra_filter ($courseid, $text) {
}
$md5 = md5($algebra);
$filename = $md5 . ".gif";
if (! $texcache = get_record("cache_filters","filter","algebra", "md5key", $md5)) {
if (! $texcache = $DB->get_record("cache_filters", array("filter"=>"algebra", "md5key"=>$md5))) {
$algebra = str_replace('&lt;','<',$algebra);
$algebra = str_replace('&gt;','>',$algebra);
$algebra = str_replace('<>','#',$algebra);
@@ -219,9 +218,9 @@ function algebra_filter ($courseid, $text) {
$texcache->filter = 'algebra';
$texcache->version = 1;
$texcache->md5key = $md5;
$texcache->rawtext = addslashes($texexp);
$texcache->rawtext = $texexp;
$texcache->timemodified = time();
insert_record("cache_filters",$texcache, false);
$DB->insert_record("cache_filters",$texcache, false);
$text = str_replace( $matches[0][$i], string_file_picture_algebra($filename, $texexp, '', '', $align), $text);
} else {
$text = str_replace( $matches[0][$i],"<b>Undetermined error:</b> ",$text);
+1 -1
View File
@@ -40,7 +40,7 @@
if (!file_exists($pathname)) {
$md5 = str_replace('.gif','',$image);
if ($texcache = get_record('cache_filters', 'filter', 'algebra', 'md5key', $md5)) {
if ($texcache = $DB->get_record('cache_filters', array('filter'=>'algebra', 'md5key'=>$md5))) {
if (!file_exists($CFG->dataroot.'/filter/algebra')) {
make_upload_directory('filter/algebra');
}
+2 -11
View File
@@ -19,20 +19,11 @@
function xmldb_chat_upgrade($oldversion=0) {
global $CFG, $THEME, $db;
global $CFG, $THEME, $DB;
$result = true;
if ($result && $oldversion < 2007012100) {
/// Changing precision of field lang on table chat_users to (30)
$table = new XMLDBTable('chat_users');
$field = new XMLDBField('lang');
$field->setAttributes(XMLDB_TYPE_CHAR, '30', null, XMLDB_NOTNULL, null, null, null, null, 'course');
/// Launch change of precision for field lang
$result = $result && change_field_precision($table, $field);
}
//===== 1.9.0 upgrade line ======//
return $result;
}
+3 -1
View File
@@ -19,7 +19,7 @@
function xmldb_choice_upgrade($oldversion=0) {
global $CFG, $THEME, $db;
global $CFG, $THEME, $DB;
$result = true;
@@ -32,6 +32,8 @@ function xmldb_choice_upgrade($oldversion=0) {
/// $result = result of "/lib/ddllib.php" function calls
/// }
//===== 1.9.0 upgrade line ======//
return $result;
}
+10 -10
View File
@@ -19,7 +19,7 @@
function xmldb_forum_upgrade($oldversion=0) {
global $CFG, $THEME, $db;
global $CFG, $THEME, $DB;
$result = true;
@@ -54,21 +54,21 @@ function xmldb_forum_upgrade($oldversion=0) {
$roles = implode(',', $roles);
$sql = "SELECT fs.userid, f.id AS forumid
FROM {$CFG->prefix}forum f
JOIN {$CFG->prefix}course c ON c.id = f.course
JOIN {$CFG->prefix}context ctx ON (ctx.instanceid = c.id AND ctx.contextlevel = ".CONTEXT_COURSE.")
JOIN {$CFG->prefix}forum_subscriptions fs ON fs.forum = f.id
LEFT JOIN {$CFG->prefix}role_assignments ra ON (ra.contextid = ctx.id AND ra.userid = fs.userid AND ra.roleid IN ($roles))
FROM {forum} f
JOIN {course} c ON c.id = f.course
JOIN {context} ctx ON (ctx.instanceid = c.id AND ctx.contextlevel = ".CONTEXT_COURSE.")
JOIN {forum_subscriptions} fs ON fs.forum = f.id
LEFT JOIN {role_assignments} ra ON (ra.contextid = ctx.id AND ra.userid = fs.userid AND ra.roleid IN ($roles))
WHERE ra.id IS NULL";
if ($rs = get_recordset_sql($sql)) {
if ($rs = $DB->get_recordset_sql($sql)) {
$DB->set_debug(false);
while ($remove = rs_fetch_next_record($rs)) {
delete_records('forum_subscriptions', 'userid', $remove->userid, 'forum', $remove->forumid);
foreach ($rs as $remove) {
$DB->delete_records('forum_subscriptions', array('userid'=>$remove->userid, 'forum'=>$remove->forumid));
echo '.';
}
$DB->set_debug(true);
rs_close($rs);
$rs-close();
}
}
+2 -36
View File
@@ -19,7 +19,7 @@
function xmldb_glossary_upgrade($oldversion=0) {
global $CFG, $THEME, $db;
global $CFG, $THEME, $DB;
$result = true;
@@ -32,42 +32,8 @@ function xmldb_glossary_upgrade($oldversion=0) {
/// $result = result of "/lib/ddllib.php" function calls
/// }
if ($result && $oldversion < 2006111400) {
//===== 1.9.0 upgrade line ======//
/// MDL-10475, set override for legacy:student before dropping studentcanpost
/// if the glossary disables student postings
if ($glossaries = get_records('glossary', 'studentcanpost', '0')) {
foreach ($glossaries as $glossary) {
if ($cm = get_coursemodule_from_instance('glossary', $glossary->id)) {
// add student override in this instance
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
// find all roles with legacy:student
if ($studentroles = get_roles_with_capability('moodle/legacy:student', CAP_ALLOW)) {
foreach ($studentroles as $studentrole) {
assign_capability('mod/glossary:write', CAP_PREVENT, $studentrole->id, $context->id);
}
}
}
}
}
/// Define field studentcanpost to be dropped from glossary
$table = new XMLDBTable('glossary');
$field = new XMLDBField('studentcanpost');
/// Launch drop field studentcanpost
$result = $result && drop_field($table, $field);
}
if ($result && $oldversion < 2007072200) {
require_once($CFG->dirroot.'/mod/glossary/lib.php');
// too much debug output
$db->debug = false;
glossary_update_grades();
$db->debug = true;
}
return $result;
}
+3 -1
View File
@@ -19,7 +19,7 @@
function xmldb_label_upgrade($oldversion=0) {
global $CFG, $THEME, $db;
global $CFG, $THEME, $DB;
$result = true;
@@ -32,6 +32,8 @@ function xmldb_label_upgrade($oldversion=0) {
/// $result = result of "/lib/ddllib.php" function calls
/// }
//===== 1.9.0 upgrade line ======//
return $result;
}
+2 -55
View File
@@ -19,7 +19,7 @@
function xmldb_quiz_upgrade($oldversion=0) {
global $CFG, $THEME, $db;
global $CFG, $THEME, $DB;
$result = true;
@@ -28,60 +28,7 @@ function xmldb_quiz_upgrade($oldversion=0) {
/// this comment lines once this file start handling proper
/// upgrade code.
if ($result && $oldversion < 2007022800) {
/// Ensure that there are not existing duplicate entries in the database.
$duplicateunits = get_records_select('question_numerical_units', "id > (SELECT MIN(iqnu.id)
FROM {$CFG->prefix}question_numerical_units iqnu
WHERE iqnu.question = {$CFG->prefix}question_numerical_units.question AND
iqnu.unit = {$CFG->prefix}question_numerical_units.unit)", '', 'id');
if ($duplicateunits) {
delete_records_select('question_numerical_units', 'id IN (' . implode(',', array_keys($duplicateunits)) . ')');
}
/// Define index question-unit (unique) to be added to question_numerical_units
$table = new XMLDBTable('question_numerical_units');
$index = new XMLDBIndex('question-unit');
$index->setAttributes(XMLDB_INDEX_UNIQUE, array('question', 'unit'));
/// Launch add index question-unit
$result = $result && add_index($table, $index);
}
if ($result && $oldversion < 2007070200) {
/// Changing precision of field timelimit on table quiz to (10)
$table = new XMLDBTable('quiz');
$field = new XMLDBField('timelimit');
$field->setAttributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0', 'timemodified');
/// Launch change of precision for field timelimit
$result = $result && change_field_precision($table, $field);
}
if ($result && $oldversion < 2007072200) {
require_once $CFG->dirroot.'/mod/quiz/lib.php';
// too much debug output
$db->debug = false;
quiz_update_grades();
$db->debug = true;
}
// Separate control for when overall feedback is displayed, independant of the question feedback settings.
if ($result && $oldversion < 2007072600) {
// Adjust the quiz review options so that overall feedback is displayed whenever feedback is.
$result = $result && execute_sql('UPDATE ' . $CFG->prefix . 'quiz SET review = ' .
sql_bitor(sql_bitand('review', sql_bitnot(QUIZ_REVIEW_OVERALLFEEDBACK)),
sql_bitor(sql_bitand('review', QUIZ_REVIEW_FEEDBACK & QUIZ_REVIEW_IMMEDIATELY) . ' * 65536',
sql_bitor(sql_bitand('review', QUIZ_REVIEW_FEEDBACK & QUIZ_REVIEW_OPEN) . ' * 16384',
sql_bitand('review', QUIZ_REVIEW_FEEDBACK & QUIZ_REVIEW_CLOSED) . ' * 4096'))));
// Same adjustment to the defaults for new quizzes.
$result = $result && set_config('quiz_review', ($CFG->quiz_review & ~QUIZ_REVIEW_OVERALLFEEDBACK) |
(($CFG->quiz_review & QUIZ_REVIEW_FEEDBACK & QUIZ_REVIEW_IMMEDIATELY) << 16) |
(($CFG->quiz_review & QUIZ_REVIEW_FEEDBACK & QUIZ_REVIEW_OPEN) << 14) |
(($CFG->quiz_review & QUIZ_REVIEW_FEEDBACK & QUIZ_REVIEW_CLOSED) << 12));
}
//===== 1.9.0 upgrade line ======//
return $result;
}
+2 -31
View File
@@ -19,7 +19,7 @@
function xmldb_resource_upgrade($oldversion=0) {
global $CFG, $THEME, $db;
global $CFG, $THEME, $DB;
$result = true;
@@ -32,36 +32,7 @@ function xmldb_resource_upgrade($oldversion=0) {
/// $result = result of "/lib/ddllib.php" function calls
/// }
if ($result && $oldversion < 2007011700) {
//move format from options to reference field because it was colliding with course blocks setting
execute_sql("UPDATE {$CFG->prefix}resource SET reference=options WHERE type='text' AND reference='' AND options!='showblocks'");
//ignore result
}
if ($result && $oldversion < 2007012000) {
/// Changing nullability of field summary on table resource to null
$table = new XMLDBTable('resource');
$field = new XMLDBField('summary');
$field->setAttributes(XMLDB_TYPE_TEXT, 'small', null, null, null, null, null, null, 'reference');
/// Launch change of nullability for field summary
$result = $result && change_field_notnull($table, $field);
}
if ($result && $oldversion < 2007012001) {
if ($CFG->dbfamily == 'mysql') { // Only needed under mysql. The rest are long texts since ages
/// Changing precision of field alltext on table resource to (medium)
$table = new XMLDBTable('resource');
$field = new XMLDBField('alltext');
$field->setAttributes(XMLDB_TYPE_TEXT, 'medium', null, XMLDB_NOTNULL, null, null, null, null, 'summary');
/// Launch change of precision for field alltext
$result = $result && change_field_precision($table, $field);
}
}
//===== 1.9.0 upgrade line ======//
return $result;
}
+2 -268
View File
@@ -19,277 +19,11 @@
function xmldb_scorm_upgrade($oldversion=0) {
global $CFG, $THEME, $db;
global $CFG, $THEME, $DB;
$result = true;
if ($result && $oldversion < 2006103100) {
/// Create the new sco optionals data table
/// Define table scorm_scoes_data to be created
$table = new XMLDBTable('scorm_scoes_data');
/// Adding fields to table scorm_scoes_data
$table->addFieldInfo('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null, null, null);
$table->addFieldInfo('scoid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0');
$table->addFieldInfo('name', XMLDB_TYPE_CHAR, '255', null, XMLDB_NOTNULL, null, null, null, null);
$table->addFieldInfo('value', XMLDB_TYPE_TEXT, 'small', null, XMLDB_NOTNULL, null, null, null, null);
/// Adding keys to table scorm_scoes_data
$table->addKeyInfo('primary', XMLDB_KEY_PRIMARY, array('id'));
/// Adding indexes to table scorm_scoes_data
$table->addIndexInfo('scoid', XMLDB_INDEX_NOTUNIQUE, array('scoid'));
/// Launch create table for scorm_scoes_data
$result = $result && create_table($table);
/// The old fields used in scorm_scoes
$fields = array('parameters' => '',
'prerequisites' => '',
'maxtimeallowed' => '',
'timelimitaction' => '',
'datafromlms' => '',
'masteryscore' => '',
'next' => '0',
'previous' => '0');
/// Retrieve old datas
if ($scorms = get_records('scorm')) {
foreach ($scorms as $scorm) {
if ($olddatas = get_records('scorm_scoes','scorm', $scorm->id)) {
foreach ($olddatas as $olddata) {
$newdata = new stdClass();
$newdata->scoid = $olddata->id;
foreach ($fields as $field => $value) {
if ($olddata->$field != $value) {
$newdata->name = addslashes($field);
$newdata->value = addslashes($olddata->$field);
$id = insert_record('scorm_scoes_data', $newdata);
$result = $result && ($id != 0);
}
}
}
}
}
}
/// Remove no more used fields
$table = new XMLDBTable('scorm_scoes');
foreach ($fields as $field => $value) {
$field = new XMLDBField($field);
$result = $result && drop_field($table, $field);
}
}
if ($result && $oldversion < 2006120900) {
/// Define table scorm_seq_objective to be created
$table = new XMLDBTable('scorm_seq_objective');
/// Adding fields to table scorm_seq_objective
$table->addFieldInfo('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null, null, null);
$table->addFieldInfo('scoid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0');
$table->addFieldInfo('primaryobj', XMLDB_TYPE_INTEGER, '1', null, XMLDB_NOTNULL, null, null, null, '0');
$table->addFieldInfo('objectiveid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0');
$table->addFieldInfo('satisfiedbymeasure', XMLDB_TYPE_INTEGER, '1', null, XMLDB_NOTNULL, null, null, null, '1');
$table->addFieldInfo('minnormalizedmeasure', XMLDB_TYPE_FLOAT, '11, 4', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0.0000');
/// Adding keys to table scorm_seq_objective
$table->addKeyInfo('primary', XMLDB_KEY_PRIMARY, array('id'));
$table->addKeyInfo('scorm_objective_uniq', XMLDB_KEY_UNIQUE, array('scoid', 'id'));
$table->addKeyInfo('scorm_objective_scoid', XMLDB_KEY_FOREIGN, array('scoid'), 'scorm_scoes', array('id'));
/// Launch create table for scorm_seq_objective
$result = $result && create_table($table);
/// Define table scorm_seq_mapinfo to be created
$table = new XMLDBTable('scorm_seq_mapinfo');
/// Adding fields to table scorm_seq_mapinfo
$table->addFieldInfo('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null, null, null);
$table->addFieldInfo('scoid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0');
$table->addFieldInfo('objectiveid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0');
$table->addFieldInfo('targetobjectiveid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0');
$table->addFieldInfo('readsatisfiedstatus', XMLDB_TYPE_INTEGER, '1', null, XMLDB_NOTNULL, null, null, null, '1');
$table->addFieldInfo('readnormalizedmeasure', XMLDB_TYPE_INTEGER, '1', null, XMLDB_NOTNULL, null, null, null, '1');
$table->addFieldInfo('writesatisfiedstatus', XMLDB_TYPE_INTEGER, '1', null, XMLDB_NOTNULL, null, null, null, '0');
$table->addFieldInfo('writenormalizedmeasure', XMLDB_TYPE_INTEGER, '1', null, XMLDB_NOTNULL, null, null, null, '0');
/// Adding keys to table scorm_seq_mapinfo
$table->addKeyInfo('primary', XMLDB_KEY_PRIMARY, array('id'));
$table->addKeyInfo('scorm_mapinfo_uniq', XMLDB_KEY_UNIQUE, array('scoid', 'id', 'objectiveid'));
$table->addKeyInfo('scorm_mapinfo_scoid', XMLDB_KEY_FOREIGN, array('scoid'), 'scorm_scoes', array('id'));
$table->addKeyInfo('scorm_mapinfo_objectiveid', XMLDB_KEY_FOREIGN, array('objectiveid'), 'scorm_seq_objective', array('id'));
/// Launch create table for scorm_seq_mapinfo
$result = $result && create_table($table);
/// Define table scorm_seq_ruleconds to be created
$table = new XMLDBTable('scorm_seq_ruleconds');
/// Adding fields to table scorm_seq_ruleconds
$table->addFieldInfo('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null, null, null);
$table->addFieldInfo('scoid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0');
$table->addFieldInfo('conditioncombination', XMLDB_TYPE_CHAR, '3', null, XMLDB_NOTNULL, null, null, null, 'all');
$table->addFieldInfo('ruletype', XMLDB_TYPE_INTEGER, '2', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0');
$table->addFieldInfo('action', XMLDB_TYPE_CHAR, '25', null, XMLDB_NOTNULL, null, null, null, null);
/// Adding keys to table scorm_seq_ruleconds
$table->addKeyInfo('primary', XMLDB_KEY_PRIMARY, array('id'));
$table->addKeyInfo('scorm_ruleconds_un', XMLDB_KEY_UNIQUE, array('scoid', 'id'));
$table->addKeyInfo('scorm_ruleconds_scoid', XMLDB_KEY_FOREIGN, array('scoid'), 'scorm_scoes', array('id'));
/// Launch create table for scorm_seq_ruleconds
$result = $result && create_table($table);
/// Define table scorm_seq_rulecond to be created
$table = new XMLDBTable('scorm_seq_rulecond');
/// Adding fields to table scorm_seq_rulecond
$table->addFieldInfo('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null, null, null);
$table->addFieldInfo('scoid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0');
$table->addFieldInfo('ruleconditionsid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0');
$table->addFieldInfo('refrencedobjective', XMLDB_TYPE_CHAR, '255', null, XMLDB_NOTNULL, null, null, null, null);
$table->addFieldInfo('measurethreshold', XMLDB_TYPE_FLOAT, '11, 4', null, XMLDB_NOTNULL, null, null, null, '0.0000');
$table->addFieldInfo('operator', XMLDB_TYPE_CHAR, '5', null, XMLDB_NOTNULL, null, null, null, 'noOp');
$table->addFieldInfo('cond', XMLDB_TYPE_CHAR, '30', null, XMLDB_NOTNULL, null, null, null, 'always');
/// Adding keys to table scorm_seq_rulecond
$table->addKeyInfo('primary', XMLDB_KEY_PRIMARY, array('id'));
$table->addKeyInfo('scorm_rulecond_uniq', XMLDB_KEY_UNIQUE, array('id', 'scoid', 'ruleconditionsid'));
$table->addKeyInfo('scorm_rulecond_scoid', XMLDB_KEY_FOREIGN, array('scoid'), 'scorm_scoes', array('id'));
$table->addKeyInfo('scorm_rulecond_ruleconditionsid', XMLDB_KEY_FOREIGN, array('ruleconditionsid'), 'scorm_seq_ruleconds', array('id'));
/// Launch create table for scorm_seq_rulecond
$result = $result && create_table($table);
/// Define table scorm_seq_rolluprule to be created
$table = new XMLDBTable('scorm_seq_rolluprule');
/// Adding fields to table scorm_seq_rolluprule
$table->addFieldInfo('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null, null, null);
$table->addFieldInfo('scoid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0');
$table->addFieldInfo('childactivityset', XMLDB_TYPE_CHAR, '15', null, XMLDB_NOTNULL, null, null, null, null);
$table->addFieldInfo('minimumcount', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0');
$table->addFieldInfo('minimumpercent', XMLDB_TYPE_FLOAT, '11, 4', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0.0000');
$table->addFieldInfo('conditioncombination', XMLDB_TYPE_CHAR, '3', null, XMLDB_NOTNULL, null, null, null, 'all');
$table->addFieldInfo('action', XMLDB_TYPE_CHAR, '15', null, XMLDB_NOTNULL, null, null, null, null);
/// Adding keys to table scorm_seq_rolluprule
$table->addKeyInfo('primary', XMLDB_KEY_PRIMARY, array('id'));
$table->addKeyInfo('scorm_rolluprule_uniq', XMLDB_KEY_UNIQUE, array('scoid', 'id'));
$table->addKeyInfo('scorm_rolluprule_scoid', XMLDB_KEY_FOREIGN, array('scoid'), 'scorm_scoes', array('id'));
/// Launch create table for scorm_seq_rolluprule
$result = $result && create_table($table);
/// Define table scorm_seq_rolluprulecond to be created
$table = new XMLDBTable('scorm_seq_rolluprulecond');
/// Adding fields to table scorm_seq_rolluprulecond
$table->addFieldInfo('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null, null, null);
$table->addFieldInfo('scoid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0');
$table->addFieldInfo('rollupruleid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0');
$table->addFieldInfo('operator', XMLDB_TYPE_CHAR, '5', null, XMLDB_NOTNULL, null, null, null, 'noOp');
$table->addFieldInfo('cond', XMLDB_TYPE_CHAR, '25', null, XMLDB_NOTNULL, null, null, null, null);
/// Adding keys to table scorm_seq_rolluprulecond
$table->addKeyInfo('primary', XMLDB_KEY_PRIMARY, array('id'));
$table->addKeyInfo('scorm_rulluprulecond_uniq', XMLDB_KEY_UNIQUE, array('scoid', 'rollupruleid', 'id'));
$table->addKeyInfo('scorm_rolluprulecond_scoid', XMLDB_KEY_FOREIGN, array('scoid'), 'scorm_scoes', array('id'));
$table->addKeyInfo('scorm_rolluprulecond_rolluprule', XMLDB_KEY_FOREIGN, array('rollupruleid'), 'scorm_seq_rolluprule', array('id'));
/// Launch create table for scorm_seq_rolluprulecond
$result = $result && create_table($table);
}
//Adding new field to table scorm
if ($result && $oldversion < 2007011800) {
/// Define field format to be added to data_comments
$table = new XMLDBTable('scorm');
$field = new XMLDBField('md5_result');
$field->setAttributes(XMLDB_TYPE_CHAR, '32' , null, null, null, null, null, null, null);
/// Launch add field format
$result = $result && add_field($table, $field);
$field = new XMLDBField('external');
$field->setAttributes(XMLDB_TYPE_INTEGER, '2', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0', null);
$result = $result && add_field($table, $field);
}
if ($result && $oldversion < 2007012400) {
/// Rename field external on table scorm to updatefreq
$table = new XMLDBTable('scorm');
$field = new XMLDBField('external');
if (field_exists($table, $field)) {
$field->setAttributes(XMLDB_TYPE_INTEGER, '1', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0', 'maxattempt');
/// Launch rename field updatefreq
$result = $result && rename_field($table, $field, 'updatefreq');
} else {
$field = new XMLDBField('updatefreq');
$field->setAttributes(XMLDB_TYPE_INTEGER, '1', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0', 'maxattempt');
$result = $result && add_field($table, $field);
}
/// Rename field md5_result on table scorm to md5hash
$field = new XMLDBField('md5_result');
if (field_exists($table, $field)) {
$field->setAttributes(XMLDB_TYPE_CHAR, '32', null, XMLDB_NOTNULL, null, null, null, null, 'updatefreq');
/// Launch rename field md5hash
$result = $result && rename_field($table, $field, 'md5hash');
} else {
$field = new XMLDBField('md5hash');
$field->setAttributes(XMLDB_TYPE_CHAR, '32', null, XMLDB_NOTNULL, null, null, null, '', 'updatefreq');
$result = $result && add_field($table, $field);
}
}
if ($result && $oldversion < 2007031300) {
if ($scorms = get_records('scorm')) {
foreach ($scorms as $scorm) {
if ($scoes = get_records('scorm_scoes','scorm',$scorm->id)) {
foreach ($scoes as $sco) {
if ($tracks = get_records('scorm_scoes_track','scoid',$sco->id)) {
foreach ($tracks as $track) {
$element = preg_replace('/\.N(\d+)\./',".\$1.",$track->element);
if ($track->element != $element) {
$track->element = $element;
update_record('scorm_scoes_track',$track);
}
}
}
}
}
}
}
}
if ($result && $oldversion < 2007081001) {
require_once($CFG->dirroot.'/mod/scorm/lib.php');
// too much debug output
$db->debug = false;
scorm_update_grades();
$db->debug = true;
}
// Adding missing 'version' field to table scorm
if ($result && $oldversion < 2007110500) {
$table = new XMLDBTable('scorm');
$field = new XMLDBField('version');
$field->setAttributes(XMLDB_TYPE_CHAR, '9', null, XMLDB_NOTNULL, null, null, null, 'scorm_12', 'summary');
$result = $result && add_field($table, $field);
}
//===== 1.9.0 upgrade line ======//
return $result;
}
+3 -1
View File
@@ -19,7 +19,7 @@
function xmldb_survey_upgrade($oldversion=0) {
global $CFG, $THEME, $db;
global $CFG, $THEME, $DB;
$result = true;
@@ -32,6 +32,8 @@ function xmldb_survey_upgrade($oldversion=0) {
/// $result = result of "/lib/ddllib.php" function calls
/// }
//===== 1.9.0 upgrade line ======//
return $result;
}
+3 -1
View File
@@ -19,7 +19,7 @@
function xmldb_wiki_upgrade($oldversion=0) {
global $CFG, $THEME, $db;
global $CFG, $THEME, $DB;
$result = true;
@@ -32,6 +32,8 @@ function xmldb_wiki_upgrade($oldversion=0) {
/// $result = result of "/lib/ddllib.php" function calls
/// }
//===== 1.9.0 upgrade line ======//
return $result;
}
+1 -1
View File
@@ -19,7 +19,7 @@
function xmldb_qtype_calculated_upgrade($oldversion=0) {
global $CFG, $THEME, $db;
global $CFG, $THEME, $DB;
$result = true;
+1 -1
View File
@@ -19,7 +19,7 @@
function xmldb_qtype_essay_upgrade($oldversion=0) {
global $CFG, $THEME, $db;
global $CFG, $THEME, $DB;
$result = true;
+1 -1
View File
@@ -19,7 +19,7 @@
function xmldb_qtype_match_upgrade($oldversion=0) {
global $CFG, $THEME, $db;
global $CFG, $THEME, $DB;
$result = true;
+1 -1
View File
@@ -19,7 +19,7 @@
function xmldb_qtype_multianswer_upgrade($oldversion=0) {
global $CFG, $THEME, $db;
global $CFG, $THEME, $DB;
$result = true;
+1 -1
View File
@@ -19,7 +19,7 @@
function xmldb_qtype_randomsamatch_upgrade($oldversion=0) {
global $CFG, $THEME, $db;
global $CFG, $THEME, $DB;
$result = true;
+1 -1
View File
@@ -19,7 +19,7 @@
function xmldb_qtype_shortanswer_upgrade($oldversion=0) {
global $CFG, $THEME, $db;
global $CFG, $THEME, $DB;
$result = true;
+1 -1
View File
@@ -19,7 +19,7 @@
function xmldb_qtype_truefalse_upgrade($oldversion=0) {
global $CFG, $THEME, $db;
global $CFG, $THEME, $DB;
$result = true;