mirror of
https://github.com/moodle/moodle.git
synced 2025-04-14 13:02:07 +02:00
MDL-51580 upgrade: clean < 2.7.0 upgrade steps
This just deletes all the upgrade steps previous to 2.7.0. Some small adjustments, like adding missing MOODLE_INTERNAL or tweaking globals can also be applied when needed. Next commit will get rid of/deprecate all the upgradelib functions not used anymore in codebase.
This commit is contained in:
parent
bf5c764f3c
commit
e8c82aac82
@ -24,29 +24,10 @@
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
function xmldb_tool_customlang_upgrade($oldversion) {
|
||||
global $CFG, $DB, $OUTPUT;
|
||||
|
||||
$dbman = $DB->get_manager();
|
||||
|
||||
|
||||
// Moodle v2.3.0 release upgrade line
|
||||
// Put any upgrade step following this
|
||||
|
||||
|
||||
// Moodle v2.4.0 release upgrade line
|
||||
// Put any upgrade step following this
|
||||
|
||||
|
||||
// Moodle v2.5.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
|
||||
// Moodle v2.6.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Moodle v2.7.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
global $CFG;
|
||||
|
||||
// Moodle v2.8.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
@ -31,20 +31,7 @@ defined('MOODLE_INTERNAL') || die();
|
||||
* @return bool always true
|
||||
*/
|
||||
function xmldb_tool_log_upgrade($oldversion) {
|
||||
global $CFG, $DB, $OUTPUT;
|
||||
|
||||
$dbman = $DB->get_manager();
|
||||
|
||||
if ($oldversion < 2014040600) {
|
||||
// Reset logging defaults in dev branches,
|
||||
// in production upgrade the install.php is executed instead.
|
||||
require_once(__DIR__ . '/install.php');
|
||||
xmldb_tool_log_install();
|
||||
upgrade_plugin_savepoint(true, 2014040600, 'tool', 'log');
|
||||
}
|
||||
|
||||
// Moodle v2.7.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
global $CFG;
|
||||
|
||||
// Moodle v2.8.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
@ -22,19 +22,10 @@
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
function xmldb_logstore_database_upgrade($oldversion) {
|
||||
|
||||
if ($oldversion < 2014041700) {
|
||||
// Clean up old config.
|
||||
unset_config('excludelevels', 'logstore_database');
|
||||
unset_config('excludeactions', 'logstore_database');
|
||||
|
||||
// Savepoint reached.
|
||||
upgrade_plugin_savepoint(true, 2014041700, 'logstore', 'database');
|
||||
}
|
||||
|
||||
// Moodle v2.7.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
global $CFG;
|
||||
|
||||
// Moodle v2.8.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
@ -22,97 +22,10 @@
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
function xmldb_logstore_standard_upgrade($oldversion) {
|
||||
global $CFG, $DB;
|
||||
|
||||
$dbman = $DB->get_manager();
|
||||
|
||||
if ($oldversion < 2014032000) {
|
||||
|
||||
// Define field anonymous to be added to logstore_standard_log.
|
||||
$table = new xmldb_table('logstore_standard_log');
|
||||
$field = new xmldb_field('anonymous', XMLDB_TYPE_INTEGER, '1', null, XMLDB_NOTNULL, null, '0', 'relateduserid');
|
||||
|
||||
// Conditionally launch add field anonymous.
|
||||
if (!$dbman->field_exists($table, $field)) {
|
||||
$dbman->add_field($table, $field);
|
||||
}
|
||||
|
||||
// Standard savepoint reached.
|
||||
upgrade_plugin_savepoint(true, 2014032000, 'logstore', 'standard');
|
||||
}
|
||||
|
||||
if ($oldversion < 2014041500) {
|
||||
|
||||
// Define index contextid-component (not unique) to be dropped form logstore_standard_log.
|
||||
$table = new xmldb_table('logstore_standard_log');
|
||||
$index = new xmldb_index('contextid-component', XMLDB_INDEX_NOTUNIQUE, array('contextid', 'component'));
|
||||
|
||||
// Conditionally launch drop index contextid-component.
|
||||
if ($dbman->index_exists($table, $index)) {
|
||||
$dbman->drop_index($table, $index);
|
||||
}
|
||||
|
||||
// Define index courseid (not unique) to be dropped form logstore_standard_log.
|
||||
$table = new xmldb_table('logstore_standard_log');
|
||||
$index = new xmldb_index('courseid', XMLDB_INDEX_NOTUNIQUE, array('courseid'));
|
||||
|
||||
// Conditionally launch drop index courseid.
|
||||
if ($dbman->index_exists($table, $index)) {
|
||||
$dbman->drop_index($table, $index);
|
||||
}
|
||||
|
||||
// Define index eventname (not unique) to be dropped form logstore_standard_log.
|
||||
$table = new xmldb_table('logstore_standard_log');
|
||||
$index = new xmldb_index('eventname', XMLDB_INDEX_NOTUNIQUE, array('eventname'));
|
||||
|
||||
// Conditionally launch drop index eventname.
|
||||
if ($dbman->index_exists($table, $index)) {
|
||||
$dbman->drop_index($table, $index);
|
||||
}
|
||||
|
||||
// Define index crud (not unique) to be dropped form logstore_standard_log.
|
||||
$table = new xmldb_table('logstore_standard_log');
|
||||
$index = new xmldb_index('crud', XMLDB_INDEX_NOTUNIQUE, array('crud'));
|
||||
|
||||
// Conditionally launch drop index crud.
|
||||
if ($dbman->index_exists($table, $index)) {
|
||||
$dbman->drop_index($table, $index);
|
||||
}
|
||||
|
||||
// Define index edulevel (not unique) to be dropped form logstore_standard_log.
|
||||
$table = new xmldb_table('logstore_standard_log');
|
||||
$index = new xmldb_index('edulevel', XMLDB_INDEX_NOTUNIQUE, array('edulevel'));
|
||||
|
||||
// Conditionally launch drop index edulevel.
|
||||
if ($dbman->index_exists($table, $index)) {
|
||||
$dbman->drop_index($table, $index);
|
||||
}
|
||||
|
||||
// Define index course-time (not unique) to be added to logstore_standard_log.
|
||||
$table = new xmldb_table('logstore_standard_log');
|
||||
$index = new xmldb_index('course-time', XMLDB_INDEX_NOTUNIQUE, array('courseid', 'anonymous', 'timecreated'));
|
||||
|
||||
// Conditionally launch add index course-time.
|
||||
if (!$dbman->index_exists($table, $index)) {
|
||||
$dbman->add_index($table, $index);
|
||||
}
|
||||
|
||||
// Define index user-module (not unique) to be added to logstore_standard_log.
|
||||
$table = new xmldb_table('logstore_standard_log');
|
||||
$index = new xmldb_index('user-module', XMLDB_INDEX_NOTUNIQUE, array('userid', 'contextlevel', 'contextinstanceid', 'crud', 'edulevel', 'timecreated'));
|
||||
|
||||
// Conditionally launch add index user-module.
|
||||
if (!$dbman->index_exists($table, $index)) {
|
||||
$dbman->add_index($table, $index);
|
||||
}
|
||||
|
||||
// Standard savepoint reached.
|
||||
upgrade_plugin_savepoint(true, 2014041500, 'logstore', 'standard');
|
||||
}
|
||||
|
||||
// Moodle v2.7.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
global $CFG;
|
||||
|
||||
// Moodle v2.8.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
@ -22,44 +22,19 @@
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
/**
|
||||
* @param int $oldversion the version we are upgrading from
|
||||
* @return bool result
|
||||
*/
|
||||
function xmldb_auth_cas_upgrade($oldversion) {
|
||||
|
||||
// Moodle v2.5.0 release upgrade line
|
||||
// Put any upgrade step following this
|
||||
|
||||
// MDL-39323 New setting in 2.5, make sure it's defined.
|
||||
if ($oldversion < 2013052100) {
|
||||
if (get_config('start_tls', 'auth/cas') === false) {
|
||||
set_config('start_tls', 0, 'auth/cas');
|
||||
}
|
||||
upgrade_plugin_savepoint(true, 2013052100, 'auth', 'cas');
|
||||
}
|
||||
|
||||
if ($oldversion < 2013091700) {
|
||||
// The value of the phpCAS language constants has changed from
|
||||
// 'langname' to 'CAS_Languages_Langname'.
|
||||
if ($cas_language = get_config('auth/cas', 'language')) {
|
||||
set_config('language', 'CAS_Languages_'.ucfirst($cas_language), 'auth/cas');
|
||||
}
|
||||
|
||||
upgrade_plugin_savepoint(true, 2013091700, 'auth', 'cas');
|
||||
}
|
||||
|
||||
// Moodle v2.6.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Moodle v2.7.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
global $CFG, $DB;
|
||||
|
||||
// Moodle v2.8.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
if ($oldversion < 2014111001) {
|
||||
global $DB;
|
||||
// From now on the default LDAP objectClass setting for AD has been changed, from 'user' to '(samaccounttype=805306368)'.
|
||||
if (is_enabled_auth('cas')
|
||||
&& ($DB->get_field('config_plugins', 'value', array('name' => 'user_type', 'plugin' => 'auth/cas')) === 'ad')
|
||||
|
@ -22,34 +22,19 @@
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
/**
|
||||
* @param int $oldversion the version we are upgrading from
|
||||
* @return bool result
|
||||
*/
|
||||
function xmldb_auth_ldap_upgrade($oldversion) {
|
||||
|
||||
// Moodle v2.5.0 release upgrade line
|
||||
// Put any upgrade step following this
|
||||
|
||||
// MDL-39323 New setting in 2.5, make sure it's defined.
|
||||
if ($oldversion < 2013052100) {
|
||||
if (get_config('start_tls', 'auth/ldap') === false) {
|
||||
set_config('start_tls', 0, 'auth/ldap');
|
||||
}
|
||||
upgrade_plugin_savepoint(true, 2013052100, 'auth', 'ldap');
|
||||
}
|
||||
|
||||
// Moodle v2.6.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Moodle v2.7.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
global $CFG, $DB;
|
||||
|
||||
// Moodle v2.8.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
if ($oldversion < 2014111001) {
|
||||
global $DB;
|
||||
// From now on the default LDAP objectClass setting for AD has been changed, from 'user' to '(samaccounttype=805306368)'.
|
||||
if (is_enabled_auth('ldap')
|
||||
&& ($DB->get_field('config_plugins', 'value', array('name' => 'user_type', 'plugin' => 'auth/ldap')) === 'ad')
|
||||
|
@ -22,33 +22,14 @@
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
/**
|
||||
* @param int $oldversion the version we are upgrading from
|
||||
* @return bool result
|
||||
*/
|
||||
function xmldb_auth_manual_upgrade($oldversion) {
|
||||
global $CFG, $DB, $OUTPUT;
|
||||
|
||||
$dbman = $DB->get_manager();
|
||||
|
||||
|
||||
// Moodle v2.3.0 release upgrade line
|
||||
// Put any upgrade step following this
|
||||
|
||||
|
||||
// Moodle v2.4.0 release upgrade line
|
||||
// Put any upgrade step following this
|
||||
|
||||
|
||||
// Moodle v2.5.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
|
||||
// Moodle v2.6.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Moodle v2.7.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
global $CFG;
|
||||
|
||||
// Moodle v2.8.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
@ -22,33 +22,14 @@
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
/**
|
||||
* @param int $oldversion the version we are upgrading from
|
||||
* @return bool result
|
||||
*/
|
||||
function xmldb_auth_mnet_upgrade($oldversion) {
|
||||
global $CFG, $DB, $OUTPUT;
|
||||
|
||||
$dbman = $DB->get_manager();
|
||||
|
||||
|
||||
// Moodle v2.3.0 release upgrade line
|
||||
// Put any upgrade step following this
|
||||
|
||||
|
||||
// Moodle v2.4.0 release upgrade line
|
||||
// Put any upgrade step following this
|
||||
|
||||
|
||||
// Moodle v2.5.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
|
||||
// Moodle v2.6.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Moodle v2.7.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
global $CFG;
|
||||
|
||||
// Moodle v2.8.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
@ -37,31 +37,14 @@
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
/**
|
||||
*
|
||||
* @param int $oldversion
|
||||
* @param object $block
|
||||
*/
|
||||
function xmldb_block_community_upgrade($oldversion) {
|
||||
global $CFG, $DB;
|
||||
|
||||
// Moodle v2.3.0 release upgrade line
|
||||
// Put any upgrade step following this
|
||||
|
||||
|
||||
// Moodle v2.4.0 release upgrade line
|
||||
// Put any upgrade step following this
|
||||
|
||||
|
||||
// Moodle v2.5.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
|
||||
// Moodle v2.6.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Moodle v2.7.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
global $CFG;
|
||||
|
||||
// Moodle v2.8.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
@ -37,6 +37,8 @@
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
/**
|
||||
* Handles upgrading instances of this block.
|
||||
*
|
||||
@ -44,31 +46,7 @@
|
||||
* @param object $block
|
||||
*/
|
||||
function xmldb_block_completionstatus_upgrade($oldversion, $block) {
|
||||
global $DB;
|
||||
|
||||
// Moodle v2.4.0 release upgrade line
|
||||
// Put any upgrade step following this.
|
||||
|
||||
if ($oldversion < 2012112901) {
|
||||
// Get the instances of this block.
|
||||
if ($blocks = $DB->get_records('block_instances', array('blockname' => 'completionstatus', 'pagetypepattern' => 'my-index'))) {
|
||||
// Loop through and remove them from the My Moodle page.
|
||||
foreach ($blocks as $block) {
|
||||
blocks_delete_instance($block);
|
||||
}
|
||||
}
|
||||
// Savepoint reached.
|
||||
upgrade_block_savepoint(true, 2012112901, 'completionstatus');
|
||||
}
|
||||
// Moodle v2.5.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
|
||||
// Moodle v2.6.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Moodle v2.7.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
global $CFG;
|
||||
|
||||
// Moodle v2.8.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
@ -80,4 +58,4 @@ function xmldb_block_completionstatus_upgrade($oldversion, $block) {
|
||||
// Put any upgrade step following this.
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -37,6 +37,8 @@
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
/**
|
||||
* Handles upgrading instances of this block.
|
||||
*
|
||||
@ -44,35 +46,7 @@
|
||||
* @param object $block
|
||||
*/
|
||||
function xmldb_block_course_summary_upgrade($oldversion, $block) {
|
||||
global $DB;
|
||||
|
||||
// Moodle v2.4.0 release upgrade line
|
||||
// Put any upgrade step following this.
|
||||
|
||||
if ($oldversion < 2012112901) {
|
||||
// Get the instances of this block.
|
||||
if ($blocks = $DB->get_records('block_instances', array('blockname' => 'course_summary', 'pagetypepattern' => 'my-index'))) {
|
||||
// Loop through and remove them from the My Moodle page.
|
||||
foreach ($blocks as $block) {
|
||||
blocks_delete_instance($block);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Savepoint reached.
|
||||
upgrade_block_savepoint(true, 2012112901, 'course_summary');
|
||||
}
|
||||
|
||||
|
||||
// Moodle v2.5.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
|
||||
// Moodle v2.6.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Moodle v2.7.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
global $CFG;
|
||||
|
||||
// Moodle v2.8.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
@ -84,4 +58,4 @@ function xmldb_block_course_summary_upgrade($oldversion, $block) {
|
||||
// Put any upgrade step following this.
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -23,32 +23,15 @@
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
/**
|
||||
* Upgrade code for the HTML block.
|
||||
*
|
||||
* @param int $oldversion
|
||||
* @param object $block
|
||||
*/
|
||||
function xmldb_block_html_upgrade($oldversion) {
|
||||
global $CFG, $DB;
|
||||
|
||||
// Moodle v2.3.0 release upgrade line
|
||||
// Put any upgrade step following this.
|
||||
|
||||
|
||||
// Moodle v2.4.0 release upgrade line
|
||||
// Put any upgrade step following this.
|
||||
|
||||
|
||||
// Moodle v2.5.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
|
||||
// Moodle v2.6.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Moodle v2.7.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
global $CFG;
|
||||
|
||||
// Moodle v2.8.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
@ -37,6 +37,8 @@
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
/**
|
||||
* As of the implementation of this block and the general navigation code
|
||||
* in Moodle 2.0 the body of immediate upgrade work for this block and
|
||||
@ -47,33 +49,11 @@
|
||||
* was complex due to us wanting to remvoe the outmoded blocks that this
|
||||
* block was going to replace.
|
||||
*
|
||||
* @global moodle_database $DB
|
||||
* @param int $oldversion
|
||||
* @param object $block
|
||||
*/
|
||||
function xmldb_block_navigation_upgrade($oldversion, $block) {
|
||||
global $DB;
|
||||
|
||||
// Moodle v2.2.0 release upgrade line
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Moodle v2.3.0 release upgrade line
|
||||
// Put any upgrade step following this.
|
||||
|
||||
|
||||
// Moodle v2.4.0 release upgrade line
|
||||
// Put any upgrade step following this.
|
||||
|
||||
|
||||
// Moodle v2.5.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
|
||||
// Moodle v2.6.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Moodle v2.7.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
global $CFG;
|
||||
|
||||
// Moodle v2.8.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
@ -85,4 +65,4 @@ function xmldb_block_navigation_upgrade($oldversion, $block) {
|
||||
// Put any upgrade step following this.
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -36,53 +36,16 @@
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
/**
|
||||
* Upgrade code for the recent activity block.
|
||||
*
|
||||
* @global moodle_database $DB
|
||||
* @param int $oldversion
|
||||
* @param object $block
|
||||
*/
|
||||
function xmldb_block_recent_activity_upgrade($oldversion, $block) {
|
||||
global $CFG, $DB;
|
||||
|
||||
$dbman = $DB->get_manager(); // loads ddl manager and xmldb classes
|
||||
|
||||
if ($oldversion < 2014012000) {
|
||||
|
||||
// Define table block_recent_activity to be created.
|
||||
$table = new xmldb_table('block_recent_activity');
|
||||
|
||||
// Adding fields to table block_recent_activity.
|
||||
$table->add_field('id', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
|
||||
$table->add_field('courseid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null);
|
||||
$table->add_field('cmid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null);
|
||||
$table->add_field('timecreated', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null);
|
||||
$table->add_field('userid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null);
|
||||
$table->add_field('action', XMLDB_TYPE_INTEGER, '1', null, XMLDB_NOTNULL, null, null);
|
||||
$table->add_field('modname', XMLDB_TYPE_CHAR, '20', null, null, null, null);
|
||||
|
||||
// Adding keys to table block_recent_activity.
|
||||
$table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
|
||||
|
||||
// Adding indexes to table block_recent_activity.
|
||||
$table->add_index('coursetime', XMLDB_INDEX_NOTUNIQUE, array('courseid', 'timecreated'));
|
||||
|
||||
// Conditionally launch create table for block_recent_activity.
|
||||
if (!$dbman->table_exists($table)) {
|
||||
$dbman->create_table($table);
|
||||
// Insert dummy log record for each existing course to notify that their logs need to be migrated.
|
||||
$DB->execute('INSERT INTO {block_recent_activity} (timecreated, userid, courseid, cmid, action) '.
|
||||
'SELECT ?, 0, id, 0, 3 FROM {course}',
|
||||
array(time()));
|
||||
}
|
||||
|
||||
// Recent_activity savepoint reached.
|
||||
upgrade_block_savepoint(true, 2014012000, 'recent_activity');
|
||||
}
|
||||
|
||||
// Moodle v2.7.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
global $CFG;
|
||||
|
||||
// Moodle v2.8.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
@ -37,6 +37,8 @@
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
/**
|
||||
* Upgrade code for the section links block.
|
||||
*
|
||||
@ -45,46 +47,7 @@
|
||||
* @param object $block
|
||||
*/
|
||||
function xmldb_block_section_links_upgrade($oldversion, $block) {
|
||||
global $DB;
|
||||
|
||||
// Moodle v2.3.0 release upgrade line
|
||||
// Put any upgrade step following this
|
||||
|
||||
// Moodle v2.4.0 release upgrade line
|
||||
// Put any upgrade step following this
|
||||
|
||||
if ($oldversion < 2013012200.00) {
|
||||
|
||||
// The section links block used to use its own crazy plugin name.
|
||||
// Here we are converting it to the proper component name.
|
||||
$oldplugin = 'blocks/section_links';
|
||||
$newplugin = 'block_section_links';
|
||||
|
||||
// Use the proper API here... thats what we should be doing as it ensures any caches etc are cleared
|
||||
// along the way!
|
||||
// It may be quicker to just write an SQL statement but that would be reckless.
|
||||
$config = get_config($oldplugin);
|
||||
if (!empty($config)) {
|
||||
foreach ($config as $name => $value) {
|
||||
set_config($name, $value, $newplugin);
|
||||
unset_config($name, $oldplugin);
|
||||
}
|
||||
}
|
||||
|
||||
// Main savepoint reached.
|
||||
upgrade_block_savepoint(true, 2013012200.00, 'section_links');
|
||||
}
|
||||
|
||||
|
||||
// Moodle v2.5.0 release upgrade line
|
||||
// Put any upgrade step following this
|
||||
|
||||
|
||||
// Moodle v2.6.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Moodle v2.7.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
global $CFG;
|
||||
|
||||
// Moodle v2.8.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
@ -37,6 +37,8 @@
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
/**
|
||||
* Handles upgrading instances of this block.
|
||||
*
|
||||
@ -44,35 +46,7 @@
|
||||
* @param object $block
|
||||
*/
|
||||
function xmldb_block_selfcompletion_upgrade($oldversion, $block) {
|
||||
global $DB;
|
||||
|
||||
// Moodle v2.4.0 release upgrade line
|
||||
// Put any upgrade step following this.
|
||||
|
||||
if ($oldversion < 2012112901) {
|
||||
// Get the instances of this block.
|
||||
if ($blocks = $DB->get_records('block_instances', array('blockname' => 'selfcompletion', 'pagetypepattern' => 'my-index'))) {
|
||||
// Loop through and remove them from the My Moodle page.
|
||||
foreach ($blocks as $block) {
|
||||
blocks_delete_instance($block);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Savepoint reached.
|
||||
upgrade_block_savepoint(true, 2012112901, 'selfcompletion');
|
||||
}
|
||||
|
||||
|
||||
// Moodle v2.5.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
|
||||
// Moodle v2.6.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Moodle v2.7.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
global $CFG;
|
||||
|
||||
// Moodle v2.8.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
@ -84,4 +58,4 @@ function xmldb_block_selfcompletion_upgrade($oldversion, $block) {
|
||||
// Put any upgrade step following this.
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -37,6 +37,8 @@
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
/**
|
||||
* As of the implementation of this block and the general navigation code
|
||||
* in Moodle 2.0 the body of immediate upgrade work for this block and
|
||||
@ -47,33 +49,11 @@
|
||||
* was complex due to us wanting to remvoe the outmoded blocks that this
|
||||
* block was going to replace.
|
||||
*
|
||||
* @global moodle_database $DB
|
||||
* @param int $oldversion
|
||||
* @param object $block
|
||||
*/
|
||||
function xmldb_block_settings_upgrade($oldversion, $block) {
|
||||
global $DB;
|
||||
|
||||
// Moodle v2.2.0 release upgrade line
|
||||
// Put any upgrade step following this
|
||||
|
||||
// Moodle v2.3.0 release upgrade line
|
||||
// Put any upgrade step following this
|
||||
|
||||
|
||||
// Moodle v2.4.0 release upgrade line
|
||||
// Put any upgrade step following this
|
||||
|
||||
|
||||
// Moodle v2.5.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
|
||||
// Moodle v2.6.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Moodle v2.7.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
global $CFG;
|
||||
|
||||
// Moodle v2.8.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
@ -85,4 +65,4 @@ function xmldb_block_settings_upgrade($oldversion, $block) {
|
||||
// Put any upgrade step following this.
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -23,29 +23,9 @@
|
||||
*/
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
function xmldb_enrol_database_upgrade($oldversion) {
|
||||
global $CFG, $DB;
|
||||
|
||||
$dbman = $DB->get_manager();
|
||||
|
||||
|
||||
// Moodle v2.3.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
|
||||
// Moodle v2.4.0 release upgrade line
|
||||
// Put any upgrade step following this
|
||||
|
||||
|
||||
// Moodle v2.5.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
|
||||
// Moodle v2.6.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Moodle v2.7.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
global $CFG;
|
||||
|
||||
// Moodle v2.8.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
@ -25,28 +25,7 @@
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
function xmldb_enrol_flatfile_upgrade($oldversion) {
|
||||
global $CFG, $DB;
|
||||
|
||||
$dbman = $DB->get_manager();
|
||||
|
||||
|
||||
// Moodle v2.3.0 release upgrade line
|
||||
// Put any upgrade step following this
|
||||
|
||||
|
||||
// Moodle v2.4.0 release upgrade line
|
||||
// Put any upgrade step following this
|
||||
|
||||
|
||||
// Moodle v2.5.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
|
||||
// Moodle v2.6.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Moodle v2.7.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
global $CFG;
|
||||
|
||||
// Moodle v2.8.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
@ -18,44 +18,14 @@
|
||||
* This file keeps track of upgrades to the guest enrolment plugin.
|
||||
*
|
||||
* @package enrol_guest
|
||||
* @copyright 2011 Petr Skoda {@link http://skodak.org
|
||||
* @copyright 2011 Petr Skoda {@link http://skodak.org}
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
function xmldb_enrol_guest_upgrade($oldversion) {
|
||||
global $CFG, $DB, $OUTPUT;
|
||||
|
||||
$dbman = $DB->get_manager();
|
||||
|
||||
// Moodle v2.2.0 release upgrade line
|
||||
// Put any upgrade step following this
|
||||
|
||||
if ($oldversion < 2011112901) {
|
||||
// convert all null passwords to empty strings
|
||||
$DB->set_field('enrol', 'password', '', array('enrol'=>'guest', 'password'=>null));
|
||||
|
||||
upgrade_plugin_savepoint(true, 2011112901, 'enrol', 'guest');
|
||||
}
|
||||
|
||||
// Moodle v2.3.0 release upgrade line
|
||||
// Put any upgrade step following this
|
||||
|
||||
|
||||
// Moodle v2.4.0 release upgrade line
|
||||
// Put any upgrade step following this
|
||||
|
||||
|
||||
// Moodle v2.5.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
|
||||
// Moodle v2.6.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Moodle v2.7.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
global $CFG;
|
||||
|
||||
// Moodle v2.8.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
@ -68,5 +38,3 @@ function xmldb_enrol_guest_upgrade($oldversion) {
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
@ -31,24 +31,7 @@ defined('MOODLE_INTERNAL') || die();
|
||||
* @return bool true
|
||||
*/
|
||||
function xmldb_enrol_imsenterprise_upgrade($oldversion) {
|
||||
global $CFG, $DB;
|
||||
|
||||
$dbman = $DB->get_manager();
|
||||
|
||||
// Moodle v2.3.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Moodle v2.4.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Moodle v2.5.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Moodle v2.6.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Moodle v2.7.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
global $CFG;
|
||||
|
||||
// Moodle v2.8.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
@ -18,47 +18,14 @@
|
||||
* This file keeps track of upgrades to the manual enrolment plugin
|
||||
*
|
||||
* @package enrol_manual
|
||||
* @copyright 2012 Petr Skoda {@link http://skodak.org
|
||||
* @copyright 2012 Petr Skoda {@link http://skodak.org}
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
function xmldb_enrol_manual_upgrade($oldversion) {
|
||||
global $CFG, $DB, $OUTPUT;
|
||||
|
||||
$dbman = $DB->get_manager();
|
||||
|
||||
// Moodle v2.3.0 release upgrade line
|
||||
// Put any upgrade step following this
|
||||
|
||||
if ($oldversion < 2012100702) {
|
||||
// Set default expiry threshold to 1 day.
|
||||
$DB->execute("UPDATE {enrol} SET expirythreshold = 86400 WHERE enrol = 'manual' AND expirythreshold = 0");
|
||||
upgrade_plugin_savepoint(true, 2012100702, 'enrol', 'manual');
|
||||
}
|
||||
|
||||
if ($oldversion < 2012101400) {
|
||||
// Delete obsoleted settings, now using expiry* prefix to make them more consistent.
|
||||
unset_config('notifylast', 'enrol_manual');
|
||||
unset_config('notifyhour', 'enrol_manual');
|
||||
upgrade_plugin_savepoint(true, 2012101400, 'enrol', 'manual');
|
||||
}
|
||||
|
||||
|
||||
// Moodle v2.4.0 release upgrade line
|
||||
// Put any upgrade step following this
|
||||
|
||||
|
||||
// Moodle v2.5.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
|
||||
// Moodle v2.6.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Moodle v2.7.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
global $CFG;
|
||||
|
||||
// Moodle v2.8.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
@ -77,5 +44,3 @@ function xmldb_enrol_manual_upgrade($oldversion) {
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
@ -26,28 +25,7 @@
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
function xmldb_enrol_mnet_upgrade($oldversion) {
|
||||
global $CFG, $DB;
|
||||
|
||||
$dbman = $DB->get_manager();
|
||||
|
||||
|
||||
// Moodle v2.3.0 release upgrade line
|
||||
// Put any upgrade step following this
|
||||
|
||||
|
||||
// Moodle v2.4.0 release upgrade line
|
||||
// Put any upgrade step following this
|
||||
|
||||
|
||||
// Moodle v2.5.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
|
||||
// Moodle v2.6.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Moodle v2.7.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
global $CFG;
|
||||
|
||||
// Moodle v2.8.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
@ -40,29 +40,10 @@
|
||||
// Please do not forget to use upgrade_set_timeout()
|
||||
// before any action that may take longer time to finish.
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
function xmldb_enrol_paypal_upgrade($oldversion) {
|
||||
global $CFG, $DB;
|
||||
|
||||
$dbman = $DB->get_manager();
|
||||
|
||||
|
||||
// Moodle v2.3.0 release upgrade line
|
||||
// Put any upgrade step following this
|
||||
|
||||
|
||||
// Moodle v2.4.0 release upgrade line
|
||||
// Put any upgrade step following this
|
||||
|
||||
|
||||
// Moodle v2.5.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
|
||||
// Moodle v2.6.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Moodle v2.7.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
global $CFG;
|
||||
|
||||
// Moodle v2.8.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
@ -18,52 +18,14 @@
|
||||
* This file keeps track of upgrades to the self enrolment plugin
|
||||
*
|
||||
* @package enrol_self
|
||||
* @copyright 2012 Petr Skoda {@link http://skodak.org
|
||||
* @copyright 2012 Petr Skoda {@link http://skodak.org}
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
function xmldb_enrol_self_upgrade($oldversion) {
|
||||
global $CFG, $DB, $OUTPUT;
|
||||
|
||||
$dbman = $DB->get_manager();
|
||||
|
||||
// Moodle v2.3.0 release upgrade line
|
||||
// Put any upgrade step following this
|
||||
|
||||
if ($oldversion < 2012101400) {
|
||||
// Set default expiry threshold to 1 day.
|
||||
$DB->execute("UPDATE {enrol} SET expirythreshold = 86400 WHERE enrol = 'self' AND expirythreshold = 0");
|
||||
upgrade_plugin_savepoint(true, 2012101400, 'enrol', 'self');
|
||||
}
|
||||
|
||||
if ($oldversion < 2012120600) {
|
||||
// Enable new self enrolments everywhere.
|
||||
$DB->execute("UPDATE {enrol} SET customint6 = 1 WHERE enrol = 'self'");
|
||||
upgrade_plugin_savepoint(true, 2012120600, 'enrol', 'self');
|
||||
}
|
||||
|
||||
|
||||
// Moodle v2.4.0 release upgrade line
|
||||
// Put any upgrade step following this
|
||||
|
||||
|
||||
// Moodle v2.5.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
|
||||
// Moodle v2.6.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
if ($oldversion < 2013112100) {
|
||||
// Set customint1 (group enrolment key) to 0 if it was not set (null).
|
||||
$DB->execute("UPDATE {enrol} SET customint1 = 0 WHERE enrol = 'self' AND customint1 IS NULL");
|
||||
upgrade_plugin_savepoint(true, 2013112100, 'enrol', 'self');
|
||||
}
|
||||
|
||||
// Moodle v2.7.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
global $CFG;
|
||||
|
||||
// Moodle v2.8.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
@ -76,5 +38,3 @@ function xmldb_enrol_self_upgrade($oldversion) {
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
@ -22,6 +22,8 @@
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
/**
|
||||
* @param int $oldversion the version we are upgrading from
|
||||
* @return bool result
|
||||
@ -31,9 +33,6 @@ function xmldb_filter_mathjaxloader_upgrade($oldversion) {
|
||||
|
||||
$dbman = $DB->get_manager();
|
||||
|
||||
// Moodle v2.7.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
if ($oldversion < 2014081100) {
|
||||
|
||||
$sslcdnurl = get_config('filter_mathjaxloader', 'httpsurl');
|
||||
|
@ -23,54 +23,14 @@
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
/**
|
||||
* @param int $oldversion the version we are upgrading from
|
||||
* @return bool result
|
||||
*/
|
||||
function xmldb_filter_mediaplugin_upgrade($oldversion) {
|
||||
global $CFG, $DB;
|
||||
|
||||
$dbman = $DB->get_manager();
|
||||
|
||||
|
||||
if ($oldversion < 2011121200) {
|
||||
// Move all the media enable setttings that are now handled by core media renderer.
|
||||
foreach (array('html5video', 'html5audio', 'mp3', 'flv', 'wmp', 'qt', 'rm',
|
||||
'youtube', 'vimeo', 'swf') as $type) {
|
||||
$existingkey = 'filter_mediaplugin_enable_' . $type;
|
||||
if (array_key_exists($existingkey, $CFG)) {
|
||||
set_config('core_media_enable_' . $type, $CFG->{$existingkey});
|
||||
unset_config($existingkey);
|
||||
}
|
||||
}
|
||||
|
||||
// Override setting for html5 to turn it on (previous default was off; because
|
||||
// of changes in the way fallbacks are handled, this is now unlikely to cause
|
||||
// a problem, and is required for mobile a/v support on non-Flash devices, so
|
||||
// this change is basically needed in order to maintain existing behaviour).
|
||||
set_config('core_media_enable_html5video', 1);
|
||||
set_config('core_media_enable_html5audio', 1);
|
||||
|
||||
upgrade_plugin_savepoint(true, 2011121200, 'filter', 'mediaplugin');
|
||||
}
|
||||
|
||||
// Moodle v2.3.0 release upgrade line
|
||||
// Put any upgrade step following this
|
||||
|
||||
|
||||
// Moodle v2.4.0 release upgrade line
|
||||
// Put any upgrade step following this
|
||||
|
||||
|
||||
// Moodle v2.5.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
|
||||
// Moodle v2.6.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Moodle v2.7.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
global $CFG;
|
||||
|
||||
// Moodle v2.8.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
@ -23,50 +23,14 @@
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
/**
|
||||
* @param int $oldversion the version we are upgrading from
|
||||
* @return bool result
|
||||
*/
|
||||
function xmldb_filter_tex_upgrade($oldversion) {
|
||||
global $CFG, $DB;
|
||||
|
||||
$dbman = $DB->get_manager();
|
||||
|
||||
|
||||
// Moodle v2.3.0 release upgrade line
|
||||
// Put any upgrade step following this
|
||||
|
||||
|
||||
// Moodle v2.4.0 release upgrade line
|
||||
// Put any upgrade step following this
|
||||
|
||||
|
||||
// Moodle v2.5.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
|
||||
// Moodle v2.6.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
if ($oldversion < 2013120300) {
|
||||
$settings = array(
|
||||
'density', 'latexbackground', 'convertformat', 'pathlatex',
|
||||
'convertformat', 'pathconvert', 'pathdvips', 'latexpreamble');
|
||||
|
||||
// Move tex settings to config_pluins and delete entries from the config table.
|
||||
foreach ($settings as $setting) {
|
||||
$existingkey = 'filter_tex_'.$setting;
|
||||
if (array_key_exists($existingkey, $CFG)) {
|
||||
set_config($setting, $CFG->{$existingkey}, 'filter_tex');
|
||||
unset_config($existingkey);
|
||||
}
|
||||
}
|
||||
|
||||
upgrade_plugin_savepoint(true, 2013120300, 'filter', 'tex');
|
||||
}
|
||||
|
||||
// Moodle v2.7.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
global $CFG;
|
||||
|
||||
// Moodle v2.8.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
@ -31,30 +31,7 @@ defined('MOODLE_INTERNAL') || die();
|
||||
* @return bool true
|
||||
*/
|
||||
function xmldb_gradingform_rubric_upgrade($oldversion) {
|
||||
global $CFG, $DB, $OUTPUT;
|
||||
|
||||
$dbman = $DB->get_manager();
|
||||
|
||||
// Moodle v2.2.0 release upgrade line
|
||||
// Put any upgrade step following this
|
||||
|
||||
// Moodle v2.3.0 release upgrade line
|
||||
// Put any upgrade step following this
|
||||
|
||||
|
||||
// Moodle v2.4.0 release upgrade line
|
||||
// Put any upgrade step following this
|
||||
|
||||
|
||||
// Moodle v2.5.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
|
||||
// Moodle v2.6.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Moodle v2.7.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
global $CFG;
|
||||
|
||||
// Moodle v2.8.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
3555
lib/db/upgrade.php
3555
lib/db/upgrade.php
File diff suppressed because it is too large
Load Diff
@ -34,25 +34,6 @@ function xmldb_editor_atto_upgrade($oldversion) {
|
||||
|
||||
$dbman = $DB->get_manager();
|
||||
|
||||
if ($oldversion < 2014032800) {
|
||||
// Make Atto the default.
|
||||
$currenteditors = $CFG->texteditors;
|
||||
$neweditors = array();
|
||||
|
||||
$list = explode(',', $currenteditors);
|
||||
array_push($neweditors, 'atto');
|
||||
foreach ($list as $editor) {
|
||||
if ($editor != 'atto') {
|
||||
array_push($neweditors, $editor);
|
||||
}
|
||||
}
|
||||
|
||||
set_config('texteditors', implode(',', $neweditors));
|
||||
upgrade_plugin_savepoint(true, 2014032800, 'editor', 'atto');
|
||||
}
|
||||
|
||||
// Moodle v2.7.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
if ($oldversion < 2014081400) {
|
||||
|
||||
// Define table editor_atto_autosave to be created.
|
||||
|
@ -27,137 +27,6 @@ defined('MOODLE_INTERNAL') || die();
|
||||
function xmldb_editor_tinymce_upgrade($oldversion) {
|
||||
global $CFG, $DB;
|
||||
|
||||
$dbman = $DB->get_manager();
|
||||
|
||||
|
||||
if ($oldversion < 2012083100) {
|
||||
// Reset redesigned editor toolbar setting.
|
||||
unset_config('customtoolbar', 'editor_tinymce');
|
||||
upgrade_plugin_savepoint(true, 2012083100, 'editor', 'tinymce');
|
||||
}
|
||||
|
||||
|
||||
// Moodle v2.4.0 release upgrade line
|
||||
// Put any upgrade step following this
|
||||
|
||||
|
||||
// Moodle v2.5.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
if ($oldversion < 2013061400) {
|
||||
// Reset redesigned editor toolbar setting.
|
||||
$oldorder = "fontselect,fontsizeselect,formatselect,|,undo,redo,|,search,replace,|,fullscreen
|
||||
|
||||
bold,italic,underline,strikethrough,sub,sup,|,justifyleft,justifycenter,justifyright,|,cleanup,removeformat,pastetext,pasteword,|,forecolor,backcolor,|,ltr,rtl
|
||||
|
||||
bullist,numlist,outdent,indent,|,link,unlink,|,image,nonbreaking,charmap,table,|,code";
|
||||
|
||||
$neworder = "formatselect,bold,italic,|,bullist,numlist,|,link,unlink,|,image
|
||||
|
||||
undo,redo,|,underline,strikethrough,sub,sup,|,justifyleft,justifycenter,justifyright,|,outdent,indent,|,forecolor,backcolor,|,ltr,rtl,|,nonbreaking,charmap,table
|
||||
|
||||
fontselect,fontsizeselect,code,search,replace,|,cleanup,removeformat,pastetext,pasteword,|,fullscreen";
|
||||
$currentorder = get_config('editor_tinymce', 'customtoolbar');
|
||||
if ($currentorder == $oldorder) {
|
||||
unset_config('customtoolbar', 'editor_tinymce');
|
||||
set_config('customtoolbar', $neworder, 'editor_tinymce');
|
||||
}
|
||||
upgrade_plugin_savepoint(true, 2013061400, 'editor', 'tinymce');
|
||||
}
|
||||
|
||||
if ($oldversion < 2013070500) {
|
||||
// Insert wrap plugin to nicely wrap the toolbars on small screens.
|
||||
$oldorder = "formatselect,bold,italic,|,bullist,numlist,|,link,unlink,|,image
|
||||
|
||||
undo,redo,|,underline,strikethrough,sub,sup,|,justifyleft,justifycenter,justifyright,|,outdent,indent,|,forecolor,backcolor,|,ltr,rtl,|,nonbreaking,charmap,table
|
||||
|
||||
fontselect,fontsizeselect,code,search,replace,|,cleanup,removeformat,pastetext,pasteword,|,fullscreen";
|
||||
|
||||
$neworder = "formatselect,bold,italic,wrap,bullist,numlist,|,link,unlink,|,image
|
||||
|
||||
undo,redo,|,underline,strikethrough,sub,sup,|,justifyleft,justifycenter,justifyright,wrap,outdent,indent,|,forecolor,backcolor,|,ltr,rtl,|,nonbreaking,charmap,table
|
||||
|
||||
fontselect,fontsizeselect,wrap,code,search,replace,|,cleanup,removeformat,pastetext,pasteword,|,fullscreen";
|
||||
$currentorder = get_config('editor_tinymce', 'customtoolbar');
|
||||
if ($currentorder == $oldorder) {
|
||||
unset_config('customtoolbar', 'editor_tinymce');
|
||||
set_config('customtoolbar', $neworder, 'editor_tinymce');
|
||||
} else {
|
||||
// Simple auto conversion algorithm.
|
||||
$toolbars = explode("\n", $oldorder);
|
||||
$newtoolbars = array();
|
||||
foreach ($toolbars as $toolbar) {
|
||||
$sepcount = substr_count($toolbar, '|');
|
||||
|
||||
if ($sepcount > 0) {
|
||||
// We assume the middle separator (rounding down).
|
||||
$divisionindex = round($sepcount / 2, 0, PHP_ROUND_HALF_DOWN);
|
||||
|
||||
$buttons = explode(',', $toolbar);
|
||||
$index = 0;
|
||||
foreach ($buttons as $key => $button) {
|
||||
if ($button === "|") {
|
||||
if ($index == $divisionindex) {
|
||||
$buttons[$key] = 'wrap';
|
||||
break;
|
||||
} else {
|
||||
$index += 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
$toolbar = implode(',', $buttons);
|
||||
}
|
||||
array_push($newtoolbars, $toolbar);
|
||||
}
|
||||
$neworder = implode("\n", $newtoolbars);
|
||||
|
||||
// Set the new config.
|
||||
unset_config('customtoolbar', 'editor_tinymce');
|
||||
set_config('customtoolbar', $neworder, 'editor_tinymce');
|
||||
}
|
||||
upgrade_plugin_savepoint(true, 2013070500, 'editor', 'tinymce');
|
||||
}
|
||||
|
||||
if ($oldversion < 2013102900) {
|
||||
// Reset redesigned editor toolbar setting.
|
||||
$currentorder = get_config('editor_tinymce', 'customtoolbar');
|
||||
// Start with a wrap.
|
||||
$neworder = "wrap,". $currentorder;
|
||||
// Replace all separators with wraps to allow for proper display of groups.
|
||||
$neworder = preg_replace('/\|\|*/', "wrap", $neworder);
|
||||
// Insert a wrap between the format selector and the bold button.
|
||||
$neworder = str_replace("formatselect,bold", "formatselect,wrap,bold", $neworder);
|
||||
set_config('customtoolbar', $neworder, 'editor_tinymce');
|
||||
upgrade_plugin_savepoint(true, 2013102900, 'editor', 'tinymce');
|
||||
}
|
||||
|
||||
if ($oldversion < 2013110600) {
|
||||
// Reset redesigned editor toolbar setting.
|
||||
$currentorder = get_config('editor_tinymce', 'customtoolbar');
|
||||
$olddefaultorder = "wrap,formatselect,wrap,bold,italic,wrap,bullist,numlist,wrap,link,unlink,wrap,image
|
||||
|
||||
undo,redo,wrap,underline,strikethrough,sub,sup,wrap,justifyleft,justifycenter,justifyright,wrap,outdent,indent,wrap,forecolor,backcolor,wrap,ltr,rtl,wrap,nonbreaking,charmap,table
|
||||
|
||||
fontselect,fontsizeselect,wrap,code,search,replace,wrap,cleanup,removeformat,pastetext,pasteword,wrap,fullscreen";
|
||||
$neworder = "wrap,formatselect,wrap,bold,italic,wrap,bullist,numlist,wrap,link,unlink,wrap,image
|
||||
|
||||
undo,redo,wrap,underline,strikethrough,sub,sup,wrap,justifyleft,justifycenter,justifyright,wrap,outdent,indent,wrap,forecolor,backcolor,wrap,ltr,rtl
|
||||
|
||||
fontselect,fontsizeselect,wrap,code,search,replace,wrap,nonbreaking,charmap,table,wrap,cleanup,removeformat,pastetext,pasteword,wrap,fullscreen";
|
||||
if ($currentorder == $olddefaultorder) {
|
||||
set_config('customtoolbar', $neworder, 'editor_tinymce');
|
||||
}
|
||||
|
||||
upgrade_plugin_savepoint(true, 2013110600, 'editor', 'tinymce');
|
||||
}
|
||||
|
||||
// Moodle v2.6.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
|
||||
// Moodle v2.7.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
if ($oldversion < 2014062900) {
|
||||
// We only want to delete DragMath from the customtoolbar setting if the directory no longer exists. If
|
||||
// the directory is present then it means it has been restored, so do not remove any settings.
|
||||
|
@ -25,30 +25,7 @@
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
function xmldb_tinymce_spellchecker_upgrade($oldversion) {
|
||||
global $CFG, $DB;
|
||||
require_once(__DIR__.'/upgradelib.php');
|
||||
|
||||
$dbman = $DB->get_manager();
|
||||
|
||||
if ($oldversion < 2012051800) {
|
||||
tinymce_spellchecker_migrate_settings();
|
||||
upgrade_plugin_savepoint(true, 2012051800, 'tinymce', 'spellchecker');
|
||||
}
|
||||
|
||||
|
||||
// Moodle v2.4.0 release upgrade line
|
||||
// Put any upgrade step following this
|
||||
|
||||
|
||||
// Moodle v2.5.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
|
||||
// Moodle v2.6.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Moodle v2.7.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
global $CFG;
|
||||
|
||||
// Moodle v2.8.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
@ -22,37 +22,15 @@
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU Public License
|
||||
*/
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
/**
|
||||
* Upgrade code for the email message processor
|
||||
*
|
||||
* @param int $oldversion The version that we are upgrading from
|
||||
*/
|
||||
function xmldb_message_email_upgrade($oldversion) {
|
||||
global $CFG, $DB;
|
||||
|
||||
$dbman = $DB->get_manager();
|
||||
|
||||
|
||||
// Moodle v2.2.0 release upgrade line
|
||||
// Put any upgrade step following this
|
||||
|
||||
// Moodle v2.3.0 release upgrade line
|
||||
// Put any upgrade step following this
|
||||
|
||||
|
||||
// Moodle v2.4.0 release upgrade line
|
||||
// Put any upgrade step following this
|
||||
|
||||
|
||||
// Moodle v2.5.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
|
||||
// Moodle v2.6.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Moodle v2.7.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
global $CFG;
|
||||
|
||||
// Moodle v2.8.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
@ -65,5 +43,3 @@ function xmldb_message_email_upgrade($oldversion) {
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
@ -22,37 +22,15 @@
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
/**
|
||||
* Upgrade code for the jabber message processor
|
||||
*
|
||||
* @param int $oldversion The version that we are upgrading from
|
||||
*/
|
||||
function xmldb_message_jabber_upgrade($oldversion) {
|
||||
global $CFG, $DB;
|
||||
|
||||
$dbman = $DB->get_manager();
|
||||
|
||||
|
||||
// Moodle v2.2.0 release upgrade line
|
||||
// Put any upgrade step following this
|
||||
|
||||
// Moodle v2.3.0 release upgrade line
|
||||
// Put any upgrade step following this
|
||||
|
||||
|
||||
// Moodle v2.4.0 release upgrade line
|
||||
// Put any upgrade step following this
|
||||
|
||||
|
||||
// Moodle v2.5.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
|
||||
// Moodle v2.6.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Moodle v2.7.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
global $CFG;
|
||||
|
||||
// Moodle v2.8.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
@ -65,5 +43,3 @@ function xmldb_message_jabber_upgrade($oldversion) {
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
@ -22,37 +22,15 @@
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU Public License
|
||||
*/
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
/**
|
||||
* Upgrade code for the popup message processor
|
||||
*
|
||||
* @param int $oldversion The version that we are upgrading from
|
||||
*/
|
||||
function xmldb_message_popup_upgrade($oldversion) {
|
||||
global $CFG, $DB;
|
||||
|
||||
$dbman = $DB->get_manager();
|
||||
|
||||
|
||||
// Moodle v2.2.0 release upgrade line
|
||||
// Put any upgrade step following this
|
||||
|
||||
// Moodle v2.3.0 release upgrade line
|
||||
// Put any upgrade step following this
|
||||
|
||||
|
||||
// Moodle v2.4.0 release upgrade line
|
||||
// Put any upgrade step following this
|
||||
|
||||
|
||||
// Moodle v2.5.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
|
||||
// Moodle v2.6.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Moodle v2.7.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
global $CFG;
|
||||
|
||||
// Moodle v2.8.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
@ -65,5 +43,3 @@ function xmldb_message_popup_upgrade($oldversion) {
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
@ -22,6 +22,8 @@
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
/**
|
||||
* upgrade this assignment instance - this function could be skipped but it will be needed later
|
||||
* @param int $oldversion The old version of the assign module
|
||||
@ -32,461 +34,6 @@ function xmldb_assign_upgrade($oldversion) {
|
||||
|
||||
$dbman = $DB->get_manager();
|
||||
|
||||
if ($oldversion < 2012051700) {
|
||||
|
||||
// Define field to be added to assign.
|
||||
$table = new xmldb_table('assign');
|
||||
$field = new xmldb_field('sendlatenotifications', XMLDB_TYPE_INTEGER, '2', null,
|
||||
XMLDB_NOTNULL, null, '0', 'sendnotifications');
|
||||
|
||||
// Conditionally launch add field.
|
||||
if (!$dbman->field_exists($table, $field)) {
|
||||
$dbman->add_field($table, $field);
|
||||
}
|
||||
|
||||
// Assign savepoint reached.
|
||||
upgrade_mod_savepoint(true, 2012051700, 'assign');
|
||||
}
|
||||
|
||||
// Moodle v2.3.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
if ($oldversion < 2012071800) {
|
||||
|
||||
// Define field requiresubmissionstatement to be added to assign.
|
||||
$table = new xmldb_table('assign');
|
||||
$field = new xmldb_field('requiresubmissionstatement', XMLDB_TYPE_INTEGER, '2', null,
|
||||
XMLDB_NOTNULL, null, '0', 'timemodified');
|
||||
|
||||
// Conditionally launch add field requiresubmissionstatement.
|
||||
|
||||
if (!$dbman->field_exists($table, $field)) {
|
||||
$dbman->add_field($table, $field);
|
||||
}
|
||||
|
||||
// Assign savepoint reached.
|
||||
upgrade_mod_savepoint(true, 2012071800, 'assign');
|
||||
}
|
||||
|
||||
if ($oldversion < 2012081600) {
|
||||
|
||||
// Define field to be added to assign.
|
||||
$table = new xmldb_table('assign');
|
||||
$field = new xmldb_field('completionsubmit', XMLDB_TYPE_INTEGER, '2', null,
|
||||
XMLDB_NOTNULL, null, '0', 'timemodified');
|
||||
|
||||
// Conditionally launch add field.
|
||||
if (!$dbman->field_exists($table, $field)) {
|
||||
$dbman->add_field($table, $field);
|
||||
}
|
||||
|
||||
// Assign savepoint reached.
|
||||
upgrade_mod_savepoint(true, 2012081600, 'assign');
|
||||
}
|
||||
|
||||
// Individual extension dates support.
|
||||
if ($oldversion < 2012082100) {
|
||||
|
||||
// Define field cutoffdate to be added to assign.
|
||||
$table = new xmldb_table('assign');
|
||||
$field = new xmldb_field('cutoffdate', XMLDB_TYPE_INTEGER, '10', null,
|
||||
XMLDB_NOTNULL, null, '0', 'completionsubmit');
|
||||
|
||||
// Conditionally launch add field cutoffdate.
|
||||
if (!$dbman->field_exists($table, $field)) {
|
||||
$dbman->add_field($table, $field);
|
||||
}
|
||||
// If prevent late is on - set cutoffdate to due date.
|
||||
|
||||
// Now remove the preventlatesubmissions column.
|
||||
$field = new xmldb_field('preventlatesubmissions', XMLDB_TYPE_INTEGER, '2', null,
|
||||
XMLDB_NOTNULL, null, '0', 'nosubmissions');
|
||||
if ($dbman->field_exists($table, $field)) {
|
||||
// Set the cutoffdate to the duedate if preventlatesubmissions was enabled.
|
||||
$sql = 'UPDATE {assign} SET cutoffdate = duedate WHERE preventlatesubmissions = 1';
|
||||
$DB->execute($sql);
|
||||
|
||||
$dbman->drop_field($table, $field);
|
||||
}
|
||||
|
||||
// Define field extensionduedate to be added to assign_grades.
|
||||
$table = new xmldb_table('assign_grades');
|
||||
$field = new xmldb_field('extensionduedate', XMLDB_TYPE_INTEGER, '10', null,
|
||||
XMLDB_NOTNULL, null, '0', 'mailed');
|
||||
|
||||
// Conditionally launch add field extensionduedate.
|
||||
if (!$dbman->field_exists($table, $field)) {
|
||||
$dbman->add_field($table, $field);
|
||||
}
|
||||
|
||||
// Assign savepoint reached.
|
||||
upgrade_mod_savepoint(true, 2012082100, 'assign');
|
||||
}
|
||||
|
||||
// Team assignment support.
|
||||
if ($oldversion < 2012082300) {
|
||||
|
||||
// Define field to be added to assign.
|
||||
$table = new xmldb_table('assign');
|
||||
$field = new xmldb_field('teamsubmission', XMLDB_TYPE_INTEGER, '2', null,
|
||||
XMLDB_NOTNULL, null, '0', 'cutoffdate');
|
||||
|
||||
// Conditionally launch add field.
|
||||
if (!$dbman->field_exists($table, $field)) {
|
||||
$dbman->add_field($table, $field);
|
||||
}
|
||||
$field = new xmldb_field('requireallteammemberssubmit', XMLDB_TYPE_INTEGER, '2', null,
|
||||
XMLDB_NOTNULL, null, '0', 'teamsubmission');
|
||||
// Conditionally launch add field.
|
||||
if (!$dbman->field_exists($table, $field)) {
|
||||
$dbman->add_field($table, $field);
|
||||
}
|
||||
$field = new xmldb_field('teamsubmissiongroupingid', XMLDB_TYPE_INTEGER, '10', null,
|
||||
XMLDB_NOTNULL, null, '0', 'requireallteammemberssubmit');
|
||||
// Conditionally launch add field.
|
||||
if (!$dbman->field_exists($table, $field)) {
|
||||
$dbman->add_field($table, $field);
|
||||
}
|
||||
$index = new xmldb_index('teamsubmissiongroupingid',
|
||||
XMLDB_INDEX_NOTUNIQUE,
|
||||
array('teamsubmissiongroupingid'));
|
||||
// Conditionally launch add index.
|
||||
if (!$dbman->index_exists($table, $index)) {
|
||||
$dbman->add_index($table, $index);
|
||||
}
|
||||
$table = new xmldb_table('assign_submission');
|
||||
$field = new xmldb_field('groupid', XMLDB_TYPE_INTEGER, '10', null,
|
||||
XMLDB_NOTNULL, null, '0', 'status');
|
||||
// Conditionally launch add field.
|
||||
if (!$dbman->field_exists($table, $field)) {
|
||||
$dbman->add_field($table, $field);
|
||||
}
|
||||
upgrade_mod_savepoint(true, 2012082300, 'assign');
|
||||
}
|
||||
if ($oldversion < 2012082400) {
|
||||
|
||||
// Define table assign_user_mapping to be created.
|
||||
$table = new xmldb_table('assign_user_mapping');
|
||||
|
||||
// Adding fields to table assign_user_mapping.
|
||||
$table->add_field('id', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
|
||||
$table->add_field('assignment', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, '0');
|
||||
$table->add_field('userid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, '0');
|
||||
|
||||
// Adding keys to table assign_user_mapping.
|
||||
$table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
|
||||
$table->add_key('assignment', XMLDB_KEY_FOREIGN, array('assignment'), 'assign', array('id'));
|
||||
$table->add_key('user', XMLDB_KEY_FOREIGN, array('userid'), 'user', array('id'));
|
||||
|
||||
// Conditionally launch create table for assign_user_mapping.
|
||||
if (!$dbman->table_exists($table)) {
|
||||
$dbman->create_table($table);
|
||||
}
|
||||
|
||||
// Define field blindmarking to be added to assign.
|
||||
$table = new xmldb_table('assign');
|
||||
$field = new xmldb_field('blindmarking', XMLDB_TYPE_INTEGER, '2', null,
|
||||
XMLDB_NOTNULL, null, '0', 'teamsubmissiongroupingid');
|
||||
|
||||
if (!$dbman->field_exists($table, $field)) {
|
||||
$dbman->add_field($table, $field);
|
||||
}
|
||||
|
||||
// Define field revealidentities to be added to assign.
|
||||
$table = new xmldb_table('assign');
|
||||
$field = new xmldb_field('revealidentities', XMLDB_TYPE_INTEGER, '2', null,
|
||||
XMLDB_NOTNULL, null, '0', 'blindmarking');
|
||||
|
||||
if (!$dbman->field_exists($table, $field)) {
|
||||
$dbman->add_field($table, $field);
|
||||
}
|
||||
|
||||
// Assignment savepoint reached.
|
||||
upgrade_mod_savepoint(true, 2012082400, 'assign');
|
||||
}
|
||||
|
||||
// Moodle v2.4.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
if ($oldversion < 2013030600) {
|
||||
upgrade_set_timeout(60*20);
|
||||
|
||||
// Some assignments (upgraded from 2.2 assignment) have duplicate entries in the assign_submission
|
||||
// and assign_grades tables for a single user. This needs to be cleaned up before we can add the unique indexes
|
||||
// below.
|
||||
|
||||
// Only do this cleanup if the attempt number field has not been added to the table yet.
|
||||
$table = new xmldb_table('assign_submission');
|
||||
$field = new xmldb_field('attemptnumber', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, '0', 'groupid');
|
||||
if (!$dbman->field_exists($table, $field)) {
|
||||
// OK safe to cleanup duplicates here.
|
||||
|
||||
$sql = 'SELECT assignment, userid, groupid from {assign_submission} ' .
|
||||
'GROUP BY assignment, userid, groupid HAVING (count(id) > 1)';
|
||||
$badrecords = $DB->get_recordset_sql($sql);
|
||||
|
||||
foreach ($badrecords as $badrecord) {
|
||||
$params = array('userid'=>$badrecord->userid,
|
||||
'groupid'=>$badrecord->groupid,
|
||||
'assignment'=>$badrecord->assignment);
|
||||
$duplicates = $DB->get_records('assign_submission', $params, 'timemodified DESC', 'id, timemodified');
|
||||
if ($duplicates) {
|
||||
// Take the first (last updated) entry out of the list so it doesn't get deleted.
|
||||
$valid = array_shift($duplicates);
|
||||
$deleteids = array();
|
||||
foreach ($duplicates as $duplicate) {
|
||||
$deleteids[] = $duplicate->id;
|
||||
}
|
||||
|
||||
list($sqlids, $sqlidparams) = $DB->get_in_or_equal($deleteids);
|
||||
$DB->delete_records_select('assign_submission', 'id ' . $sqlids, $sqlidparams);
|
||||
}
|
||||
}
|
||||
|
||||
$badrecords->close();
|
||||
}
|
||||
|
||||
// Same cleanup required for assign_grades
|
||||
// Only do this cleanup if the attempt number field has not been added to the table yet.
|
||||
$table = new xmldb_table('assign_grades');
|
||||
$field = new xmldb_field('attemptnumber', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, '0', 'grade');
|
||||
if (!$dbman->field_exists($table, $field)) {
|
||||
// OK safe to cleanup duplicates here.
|
||||
|
||||
$sql = 'SELECT assignment, userid from {assign_grades} GROUP BY assignment, userid HAVING (count(id) > 1)';
|
||||
$badrecords = $DB->get_recordset_sql($sql);
|
||||
|
||||
foreach ($badrecords as $badrecord) {
|
||||
$params = array('userid'=>$badrecord->userid,
|
||||
'assignment'=>$badrecord->assignment);
|
||||
$duplicates = $DB->get_records('assign_grades', $params, 'timemodified DESC', 'id, timemodified');
|
||||
if ($duplicates) {
|
||||
// Take the first (last updated) entry out of the list so it doesn't get deleted.
|
||||
$valid = array_shift($duplicates);
|
||||
$deleteids = array();
|
||||
foreach ($duplicates as $duplicate) {
|
||||
$deleteids[] = $duplicate->id;
|
||||
}
|
||||
|
||||
list($sqlids, $sqlidparams) = $DB->get_in_or_equal($deleteids);
|
||||
$DB->delete_records_select('assign_grades', 'id ' . $sqlids, $sqlidparams);
|
||||
}
|
||||
}
|
||||
|
||||
$badrecords->close();
|
||||
}
|
||||
|
||||
// Define table assign_user_flags to be created.
|
||||
$table = new xmldb_table('assign_user_flags');
|
||||
|
||||
// Adding fields to table assign_user_flags.
|
||||
$table->add_field('id', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
|
||||
$table->add_field('userid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, '0');
|
||||
$table->add_field('assignment', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, '0');
|
||||
$table->add_field('locked', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, '0');
|
||||
$table->add_field('mailed', XMLDB_TYPE_INTEGER, '4', null, XMLDB_NOTNULL, null, '0');
|
||||
$table->add_field('extensionduedate', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, '0');
|
||||
|
||||
// Adding keys to table assign_user_flags.
|
||||
$table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
|
||||
$table->add_key('userid', XMLDB_KEY_FOREIGN, array('userid'), 'user', array('id'));
|
||||
$table->add_key('assignment', XMLDB_KEY_FOREIGN, array('assignment'), 'assign', array('id'));
|
||||
|
||||
// Adding indexes to table assign_user_flags.
|
||||
$table->add_index('mailed', XMLDB_INDEX_NOTUNIQUE, array('mailed'));
|
||||
|
||||
// Conditionally launch create table for assign_user_flags.
|
||||
if (!$dbman->table_exists($table)) {
|
||||
$dbman->create_table($table);
|
||||
|
||||
// Copy the flags from the old table to the new one.
|
||||
$sql = 'INSERT INTO {assign_user_flags}
|
||||
(assignment, userid, locked, mailed, extensionduedate)
|
||||
SELECT assignment, userid, locked, mailed, extensionduedate
|
||||
FROM {assign_grades}';
|
||||
$DB->execute($sql);
|
||||
}
|
||||
|
||||
// And delete the old columns.
|
||||
// Define index mailed (not unique) to be dropped form assign_grades.
|
||||
$table = new xmldb_table('assign_grades');
|
||||
$index = new xmldb_index('mailed', XMLDB_INDEX_NOTUNIQUE, array('mailed'));
|
||||
|
||||
// Conditionally launch drop index mailed.
|
||||
if ($dbman->index_exists($table, $index)) {
|
||||
$dbman->drop_index($table, $index);
|
||||
}
|
||||
|
||||
// Define field locked to be dropped from assign_grades.
|
||||
$table = new xmldb_table('assign_grades');
|
||||
$field = new xmldb_field('locked');
|
||||
|
||||
// Conditionally launch drop field locked.
|
||||
if ($dbman->field_exists($table, $field)) {
|
||||
$dbman->drop_field($table, $field);
|
||||
}
|
||||
|
||||
// Define field mailed to be dropped from assign_grades.
|
||||
$table = new xmldb_table('assign_grades');
|
||||
$field = new xmldb_field('mailed');
|
||||
|
||||
// Conditionally launch drop field mailed.
|
||||
if ($dbman->field_exists($table, $field)) {
|
||||
$dbman->drop_field($table, $field);
|
||||
}
|
||||
|
||||
// Define field extensionduedate to be dropped from assign_grades.
|
||||
$table = new xmldb_table('assign_grades');
|
||||
$field = new xmldb_field('extensionduedate');
|
||||
|
||||
// Conditionally launch drop field extensionduedate.
|
||||
if ($dbman->field_exists($table, $field)) {
|
||||
$dbman->drop_field($table, $field);
|
||||
}
|
||||
|
||||
// Define field attemptreopenmethod to be added to assign.
|
||||
$table = new xmldb_table('assign');
|
||||
$field = new xmldb_field('attemptreopenmethod', XMLDB_TYPE_CHAR, '10', null,
|
||||
XMLDB_NOTNULL, null, 'none', 'revealidentities');
|
||||
|
||||
// Conditionally launch add field attemptreopenmethod.
|
||||
if (!$dbman->field_exists($table, $field)) {
|
||||
$dbman->add_field($table, $field);
|
||||
}
|
||||
|
||||
// Define field maxattempts to be added to assign.
|
||||
$table = new xmldb_table('assign');
|
||||
$field = new xmldb_field('maxattempts', XMLDB_TYPE_INTEGER, '6', null, XMLDB_NOTNULL, null, '-1', 'attemptreopenmethod');
|
||||
|
||||
// Conditionally launch add field maxattempts.
|
||||
if (!$dbman->field_exists($table, $field)) {
|
||||
$dbman->add_field($table, $field);
|
||||
}
|
||||
|
||||
// Define field attemptnumber to be added to assign_submission.
|
||||
$table = new xmldb_table('assign_submission');
|
||||
$field = new xmldb_field('attemptnumber', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, '0', 'groupid');
|
||||
|
||||
// Conditionally launch add field attemptnumber.
|
||||
if (!$dbman->field_exists($table, $field)) {
|
||||
$dbman->add_field($table, $field);
|
||||
}
|
||||
|
||||
// Define index attemptnumber (not unique) to be added to assign_submission.
|
||||
$table = new xmldb_table('assign_submission');
|
||||
$index = new xmldb_index('attemptnumber', XMLDB_INDEX_NOTUNIQUE, array('attemptnumber'));
|
||||
// Conditionally launch add index attemptnumber.
|
||||
if (!$dbman->index_exists($table, $index)) {
|
||||
$dbman->add_index($table, $index);
|
||||
}
|
||||
|
||||
// Define field attemptnumber to be added to assign_grades.
|
||||
$table = new xmldb_table('assign_grades');
|
||||
$field = new xmldb_field('attemptnumber', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, '0', 'grade');
|
||||
|
||||
// Conditionally launch add field attemptnumber.
|
||||
if (!$dbman->field_exists($table, $field)) {
|
||||
$dbman->add_field($table, $field);
|
||||
}
|
||||
|
||||
// Define index attemptnumber (not unique) to be added to assign_grades.
|
||||
$table = new xmldb_table('assign_grades');
|
||||
$index = new xmldb_index('attemptnumber', XMLDB_INDEX_NOTUNIQUE, array('attemptnumber'));
|
||||
|
||||
// Conditionally launch add index attemptnumber.
|
||||
if (!$dbman->index_exists($table, $index)) {
|
||||
$dbman->add_index($table, $index);
|
||||
}
|
||||
|
||||
// Define index uniqueattemptsubmission (unique) to be added to assign_submission.
|
||||
$table = new xmldb_table('assign_submission');
|
||||
$index = new xmldb_index('uniqueattemptsubmission',
|
||||
XMLDB_INDEX_UNIQUE,
|
||||
array('assignment', 'userid', 'groupid', 'attemptnumber'));
|
||||
|
||||
// Conditionally launch add index uniqueattempt.
|
||||
if (!$dbman->index_exists($table, $index)) {
|
||||
$dbman->add_index($table, $index);
|
||||
}
|
||||
|
||||
// Define index uniqueattemptgrade (unique) to be added to assign_grades.
|
||||
$table = new xmldb_table('assign_grades');
|
||||
$index = new xmldb_index('uniqueattemptgrade', XMLDB_INDEX_UNIQUE, array('assignment', 'userid', 'attemptnumber'));
|
||||
|
||||
// Conditionally launch add index uniqueattempt.
|
||||
if (!$dbman->index_exists($table, $index)) {
|
||||
$dbman->add_index($table, $index);
|
||||
}
|
||||
|
||||
// Module assign savepoint reached.
|
||||
upgrade_mod_savepoint(true, 2013030600, 'assign');
|
||||
}
|
||||
|
||||
// Moodle v2.5.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
if ($oldversion < 2013061101) {
|
||||
// Define field markingworkflow to be added to assign.
|
||||
$table = new xmldb_table('assign');
|
||||
$field = new xmldb_field('markingworkflow', XMLDB_TYPE_INTEGER, '2', null, XMLDB_NOTNULL, null, '0', 'maxattempts');
|
||||
|
||||
// Conditionally launch add field markingworkflow.
|
||||
if (!$dbman->field_exists($table, $field)) {
|
||||
$dbman->add_field($table, $field);
|
||||
}
|
||||
|
||||
// Define field markingallocation to be added to assign.
|
||||
$field = new xmldb_field('markingallocation', XMLDB_TYPE_INTEGER, '2', null, XMLDB_NOTNULL, null, '0', 'markingworkflow');
|
||||
if (!$dbman->field_exists($table, $field)) {
|
||||
$dbman->add_field($table, $field);
|
||||
}
|
||||
|
||||
// Define field workflowstate to be added to assign_grades.
|
||||
$table = new xmldb_table('assign_user_flags');
|
||||
$field = new xmldb_field('workflowstate', XMLDB_TYPE_CHAR, '20', null, null, null, null, 'extensionduedate');
|
||||
|
||||
// Conditionally launch add field workflowstate.
|
||||
if (!$dbman->field_exists($table, $field)) {
|
||||
$dbman->add_field($table, $field);
|
||||
}
|
||||
|
||||
// Define field allocatedmarker to be added to assign_grades.
|
||||
$field = new xmldb_field('allocatedmarker', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, '0', 'workflowstate');
|
||||
// Conditionally launch add field workflowstate.
|
||||
if (!$dbman->field_exists($table, $field)) {
|
||||
$dbman->add_field($table, $field);
|
||||
}
|
||||
upgrade_mod_savepoint(true, 2013061101, 'assign');
|
||||
}
|
||||
|
||||
// Moodle v2.6.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
if ($oldversion < 2014010801) {
|
||||
|
||||
// Define field sendstudentnotifications to be added to assign.
|
||||
$table = new xmldb_table('assign');
|
||||
$field = new xmldb_field('sendstudentnotifications',
|
||||
XMLDB_TYPE_INTEGER,
|
||||
'2',
|
||||
null,
|
||||
XMLDB_NOTNULL,
|
||||
null,
|
||||
'1',
|
||||
'markingallocation');
|
||||
|
||||
// Conditionally launch add field sendstudentnotifications.
|
||||
if (!$dbman->field_exists($table, $field)) {
|
||||
$dbman->add_field($table, $field);
|
||||
}
|
||||
|
||||
// Assign savepoint reached.
|
||||
upgrade_mod_savepoint(true, 2014010801, 'assign');
|
||||
}
|
||||
|
||||
// Moodle v2.7.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
if ($oldversion < 2014051201) {
|
||||
|
||||
// Cleanup bad database records where assignid is missing.
|
||||
@ -495,6 +42,7 @@ function xmldb_assign_upgrade($oldversion) {
|
||||
// Assign savepoint reached.
|
||||
upgrade_mod_savepoint(true, 2014051201, 'assign');
|
||||
}
|
||||
|
||||
if ($oldversion < 2014072400) {
|
||||
|
||||
// Add "latest" column to submissions table to mark the latest attempt.
|
||||
|
@ -22,27 +22,15 @@
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
/**
|
||||
* Stub for upgrade code
|
||||
* @param int $oldversion
|
||||
* @return bool
|
||||
*/
|
||||
function xmldb_assignfeedback_comments_upgrade($oldversion) {
|
||||
// Do the upgrades.
|
||||
// Moodle v2.3.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Moodle v2.4.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Moodle v2.5.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Moodle v2.6.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Moodle v2.7.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
global $CFG;
|
||||
|
||||
// Moodle v2.8.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
@ -32,44 +32,6 @@ defined('MOODLE_INTERNAL') || die();
|
||||
function xmldb_assignfeedback_editpdf_upgrade($oldversion) {
|
||||
global $CFG;
|
||||
|
||||
if ($oldversion < 2013110800) {
|
||||
|
||||
// Check that no stamps where uploaded.
|
||||
$fs = get_file_storage();
|
||||
$stamps = $fs->get_area_files(context_system::instance()->id, 'assignfeedback_editpdf',
|
||||
'stamps', 0, "filename", false);
|
||||
|
||||
// Add default stamps.
|
||||
if (empty($stamps)) {
|
||||
// List of default stamps.
|
||||
$defaultstamps = array('smile.png', 'sad.png', 'tick.png', 'cross.png');
|
||||
|
||||
// Stamp file object.
|
||||
$filerecord = new stdClass;
|
||||
$filerecord->component = 'assignfeedback_editpdf';
|
||||
$filerecord->contextid = context_system::instance()->id;
|
||||
$filerecord->userid = get_admin()->id;
|
||||
$filerecord->filearea = 'stamps';
|
||||
$filerecord->filepath = '/';
|
||||
$filerecord->itemid = 0;
|
||||
|
||||
// Add all default stamps.
|
||||
foreach ($defaultstamps as $stamp) {
|
||||
$filerecord->filename = $stamp;
|
||||
$fs->create_file_from_pathname($filerecord,
|
||||
$CFG->dirroot . '/mod/assign/feedback/editpdf/pix/' . $filerecord->filename);
|
||||
}
|
||||
}
|
||||
|
||||
upgrade_plugin_savepoint(true, 2013110800, 'assignfeedback', 'editpdf');
|
||||
}
|
||||
|
||||
// Moodle v2.6.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Moodle v2.7.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Moodle v2.8.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
|
@ -22,27 +22,15 @@
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
/**
|
||||
* Stub for upgrade code
|
||||
* @param int $oldversion
|
||||
* @return bool
|
||||
*/
|
||||
function xmldb_assignfeedback_file_upgrade($oldversion) {
|
||||
// Do the upgrades.
|
||||
// Moodle v2.3.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Moodle v2.4.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Moodle v2.5.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Moodle v2.6.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Moodle v2.7.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
global $CFG;
|
||||
|
||||
// Moodle v2.8.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
@ -22,26 +22,15 @@
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
/**
|
||||
* Stub for upgrade code
|
||||
* @param int $oldversion
|
||||
* @return bool
|
||||
*/
|
||||
function xmldb_assignsubmission_comments_upgrade($oldversion) {
|
||||
// Moodle v2.3.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Moodle v2.4.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Moodle v2.5.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Moodle v2.6.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Moodle v2.7.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
global $CFG;
|
||||
|
||||
// Moodle v2.8.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
@ -54,5 +43,3 @@ function xmldb_assignsubmission_comments_upgrade($oldversion) {
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
@ -22,24 +22,15 @@
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
/**
|
||||
* Stub for upgrade code
|
||||
* @param int $oldversion
|
||||
* @return bool
|
||||
*/
|
||||
function xmldb_assignsubmission_file_upgrade($oldversion) {
|
||||
|
||||
// Moodle v2.4.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Moodle v2.5.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Moodle v2.6.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Moodle v2.7.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
global $CFG;
|
||||
|
||||
// Moodle v2.8.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
@ -52,5 +43,3 @@ function xmldb_assignsubmission_file_upgrade($oldversion) {
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
@ -22,26 +22,15 @@
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
/**
|
||||
* Stub for upgrade code
|
||||
* @param int $oldversion
|
||||
* @return bool
|
||||
*/
|
||||
function xmldb_assignsubmission_onlinetext_upgrade($oldversion) {
|
||||
// Moodle v2.3.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Moodle v2.4.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Moodle v2.5.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Moodle v2.6.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Moodle v2.7.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
global $CFG;
|
||||
|
||||
// Moodle v2.8.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
@ -54,5 +43,3 @@ function xmldb_assignsubmission_onlinetext_upgrade($oldversion) {
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
// This file keeps track of upgrades to
|
||||
// the assignment module
|
||||
//
|
||||
@ -20,107 +19,10 @@
|
||||
// Please do not forget to use upgrade_set_timeout()
|
||||
// before any action that may take longer time to finish.
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
function xmldb_assignment_upgrade($oldversion) {
|
||||
global $CFG, $DB, $OUTPUT;
|
||||
|
||||
require_once(__DIR__.'/upgradelib.php');
|
||||
|
||||
$dbman = $DB->get_manager();
|
||||
|
||||
// Moodle v2.2.0 release upgrade line
|
||||
// Put any upgrade step following this
|
||||
|
||||
// Moodle v2.3.0 release upgrade line
|
||||
// Put any upgrade step following this
|
||||
|
||||
|
||||
if ($oldversion < 2012061701) {
|
||||
// Fixed/updated numfiles field in assignment_submissions table to count the actual
|
||||
// number of files has been uploaded when sendformarking is disabled
|
||||
upgrade_set_timeout(600); // increase excution time for in large sites
|
||||
$fs = get_file_storage();
|
||||
|
||||
// Fetch the moduleid for use in the course_modules table
|
||||
$moduleid = $DB->get_field('modules', 'id', array('name' => 'assignment'), MUST_EXIST);
|
||||
|
||||
$selectcount = 'SELECT COUNT(s.id) ';
|
||||
$select = 'SELECT s.id, cm.id AS cmid ';
|
||||
$query = 'FROM {assignment_submissions} s
|
||||
JOIN {assignment} a ON a.id = s.assignment
|
||||
JOIN {course_modules} cm ON a.id = cm.instance AND cm.module = :moduleid
|
||||
WHERE assignmenttype = :assignmenttype';
|
||||
|
||||
$params = array('moduleid' => $moduleid, 'assignmenttype' => 'upload');
|
||||
|
||||
$countsubmissions = $DB->count_records_sql($selectcount.$query, $params);
|
||||
$submissions = $DB->get_recordset_sql($select.$query, $params);
|
||||
|
||||
$pbar = new progress_bar('assignmentupgradenumfiles', 500, true);
|
||||
$i = 0;
|
||||
foreach ($submissions as $sub) {
|
||||
$i++;
|
||||
if ($context = context_module::instance($sub->cmid)) {
|
||||
$sub->numfiles = count($fs->get_area_files($context->id, 'mod_assignment', 'submission', $sub->id, 'sortorder', false));
|
||||
$DB->update_record('assignment_submissions', $sub);
|
||||
}
|
||||
$pbar->update($i, $countsubmissions, "Counting files of submissions ($i/$countsubmissions)");
|
||||
}
|
||||
$submissions->close();
|
||||
|
||||
// assignment savepoint reached
|
||||
upgrade_mod_savepoint(true, 2012061701, 'assignment');
|
||||
}
|
||||
|
||||
// Moodle v2.4.0 release upgrade line
|
||||
// Put any upgrade step following this
|
||||
|
||||
|
||||
// Moodle v2.5.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
|
||||
// Moodle v2.6.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
if ($oldversion < 2013121900) {
|
||||
// Define table assignment_upgrade to be created.
|
||||
$table = new xmldb_table('assignment_upgrade');
|
||||
|
||||
// Adding fields to table assignment_upgrade.
|
||||
$table->add_field('id', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
|
||||
$table->add_field('oldcmid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, '0');
|
||||
$table->add_field('oldinstance', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, '0');
|
||||
$table->add_field('newcmid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, '0');
|
||||
$table->add_field('newinstance', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, '0');
|
||||
$table->add_field('timecreated', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, '0');
|
||||
|
||||
// Adding keys to table assignment_upgrade.
|
||||
$table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
|
||||
|
||||
// Adding indexes to table assignment_upgrade.
|
||||
$table->add_index('oldcmid', XMLDB_INDEX_NOTUNIQUE, array('oldcmid'));
|
||||
$table->add_index('oldinstance', XMLDB_INDEX_NOTUNIQUE, array('oldinstance'));
|
||||
|
||||
// Conditionally launch create table for assignment_upgrade.
|
||||
if (!$dbman->table_exists($table)) {
|
||||
$dbman->create_table($table);
|
||||
}
|
||||
|
||||
if ($module = $DB->get_record("modules", array("name" => "assignment"))) {
|
||||
$DB->set_field("modules", "visible", "0", array("id" => $module->id)); // Hide module.
|
||||
}
|
||||
|
||||
$count = $DB->count_records('assignment');
|
||||
if ($count) {
|
||||
mod_assignment_pending_upgrades_notification($count);
|
||||
}
|
||||
|
||||
// Assignment savepoint reached.
|
||||
upgrade_mod_savepoint(true, 2013121900, 'assignment');
|
||||
}
|
||||
|
||||
// Moodle v2.7.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
global $CFG;
|
||||
|
||||
// Moodle v2.8.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
@ -133,5 +35,3 @@ function xmldb_assignment_upgrade($oldversion) {
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
@ -34,176 +34,6 @@ function xmldb_book_upgrade($oldversion) {
|
||||
|
||||
$dbman = $DB->get_manager();
|
||||
|
||||
// Moodle v2.2.0 release upgrade line
|
||||
// Put any upgrade step following this
|
||||
|
||||
// Moodle v2.3.0 release upgrade line
|
||||
// Put any upgrade step following this
|
||||
|
||||
// Note: The next steps (up to 2012090408 included, are a "replay" of old upgrade steps,
|
||||
// because some sites updated to Moodle 2.3 didn't have the latest contrib mod_book
|
||||
// installed, so some required changes were missing.
|
||||
//
|
||||
// All the steps are run conditionally so sites upgraded from latest contrib mod_book or
|
||||
// new (2.3 and upwards) sites won't get affected.
|
||||
//
|
||||
// Warn: It will be safe to delete these steps once Moodle 2.5 (not 2.4!) is declared as minimum
|
||||
// requirement (environment.xml) in some future Moodle 2.x version. Never, never, before!
|
||||
//
|
||||
// See MDL-35297 and commit msg for more information.
|
||||
|
||||
if ($oldversion < 2012090401) {
|
||||
// Rename field summary on table book to intro
|
||||
$table = new xmldb_table('book');
|
||||
$field = new xmldb_field('summary', XMLDB_TYPE_TEXT, null, null, null, null, null, 'name');
|
||||
|
||||
// Launch rename field summary
|
||||
if ($dbman->field_exists($table, $field)) {
|
||||
$dbman->rename_field($table, $field, 'intro');
|
||||
}
|
||||
|
||||
// book savepoint reached
|
||||
upgrade_mod_savepoint(true, 2012090401, 'book');
|
||||
}
|
||||
|
||||
if ($oldversion < 2012090402) {
|
||||
// Define field introformat to be added to book
|
||||
$table = new xmldb_table('book');
|
||||
$field = new xmldb_field('introformat', XMLDB_TYPE_INTEGER, '4', null, XMLDB_NOTNULL, null, '0', 'intro');
|
||||
|
||||
// Launch add field introformat
|
||||
if (!$dbman->field_exists($table, $field)) {
|
||||
$dbman->add_field($table, $field);
|
||||
// Conditionally migrate to html format in intro
|
||||
// Si está activo el htmleditor!!!!!
|
||||
if ($CFG->texteditors !== 'textarea') {
|
||||
$rs = $DB->get_recordset('book', array('introformat'=>FORMAT_MOODLE), '', 'id,intro,introformat');
|
||||
foreach ($rs as $b) {
|
||||
$b->intro = text_to_html($b->intro, false, false, true);
|
||||
$b->introformat = FORMAT_HTML;
|
||||
$DB->update_record('book', $b);
|
||||
upgrade_set_timeout();
|
||||
}
|
||||
unset($b);
|
||||
$rs->close();
|
||||
}
|
||||
}
|
||||
|
||||
// book savepoint reached
|
||||
upgrade_mod_savepoint(true, 2012090402, 'book');
|
||||
}
|
||||
|
||||
if ($oldversion < 2012090403) {
|
||||
// Define field introformat to be added to book
|
||||
$table = new xmldb_table('book_chapters');
|
||||
$field = new xmldb_field('contentformat', XMLDB_TYPE_INTEGER, '4', null, XMLDB_NOTNULL, null, '0', 'content');
|
||||
|
||||
// Launch add field introformat
|
||||
if (!$dbman->field_exists($table, $field)) {
|
||||
$dbman->add_field($table, $field);
|
||||
|
||||
$DB->set_field('book_chapters', 'contentformat', FORMAT_HTML, array());
|
||||
}
|
||||
|
||||
// book savepoint reached
|
||||
upgrade_mod_savepoint(true, 2012090403, 'book');
|
||||
}
|
||||
|
||||
if ($oldversion < 2012090404) {
|
||||
require_once("$CFG->dirroot/mod/book/db/upgradelib.php");
|
||||
|
||||
$sqlfrom = "FROM {book} b
|
||||
JOIN {modules} m ON m.name = 'book'
|
||||
JOIN {course_modules} cm ON (cm.module = m.id AND cm.instance = b.id)";
|
||||
|
||||
$count = $DB->count_records_sql("SELECT COUNT('x') $sqlfrom");
|
||||
|
||||
if ($rs = $DB->get_recordset_sql("SELECT b.id, b.course, cm.id AS cmid $sqlfrom ORDER BY b.course, b.id")) {
|
||||
|
||||
$pbar = new progress_bar('migratebookfiles', 500, true);
|
||||
|
||||
$i = 0;
|
||||
foreach ($rs as $book) {
|
||||
$i++;
|
||||
upgrade_set_timeout(360); // set up timeout, may also abort execution
|
||||
$pbar->update($i, $count, "Migrating book files - $i/$count.");
|
||||
|
||||
$context = context_module::instance($book->cmid);
|
||||
|
||||
mod_book_migrate_moddata_dir_to_legacy($book, $context, '/');
|
||||
|
||||
// remove dirs if empty
|
||||
@rmdir("$CFG->dataroot/$book->course/$CFG->moddata/book/$book->id/");
|
||||
@rmdir("$CFG->dataroot/$book->course/$CFG->moddata/book/");
|
||||
@rmdir("$CFG->dataroot/$book->course/$CFG->moddata/");
|
||||
@rmdir("$CFG->dataroot/$book->course/");
|
||||
}
|
||||
$rs->close();
|
||||
}
|
||||
|
||||
// book savepoint reached
|
||||
upgrade_mod_savepoint(true, 2012090404, 'book');
|
||||
}
|
||||
|
||||
if ($oldversion < 2012090405) {
|
||||
// Define field disableprinting to be dropped from book
|
||||
$table = new xmldb_table('book');
|
||||
$field = new xmldb_field('disableprinting');
|
||||
|
||||
// Conditionally launch drop field disableprinting
|
||||
if ($dbman->field_exists($table, $field)) {
|
||||
$dbman->drop_field($table, $field);
|
||||
}
|
||||
|
||||
// book savepoint reached
|
||||
upgrade_mod_savepoint(true, 2012090405, 'book');
|
||||
}
|
||||
|
||||
if ($oldversion < 2012090406) {
|
||||
unset_config('book_tocwidth');
|
||||
|
||||
// book savepoint reached
|
||||
upgrade_mod_savepoint(true, 2012090406, 'book');
|
||||
}
|
||||
|
||||
if ($oldversion < 2012090407) {
|
||||
require_once("$CFG->dirroot/mod/book/db/upgradelib.php");
|
||||
|
||||
mod_book_migrate_all_areas();
|
||||
|
||||
upgrade_mod_savepoint(true, 2012090407, 'book');
|
||||
}
|
||||
|
||||
if ($oldversion < 2012090408) {
|
||||
|
||||
// Define field revision to be added to book
|
||||
$table = new xmldb_table('book');
|
||||
$field = new xmldb_field('revision', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, '0', 'customtitles');
|
||||
|
||||
// Conditionally launch add field revision
|
||||
if (!$dbman->field_exists($table, $field)) {
|
||||
$dbman->add_field($table, $field);
|
||||
}
|
||||
|
||||
// book savepoint reached
|
||||
upgrade_mod_savepoint(true, 2012090408, 'book');
|
||||
}
|
||||
// End of MDL-35297 "replayed" steps.
|
||||
|
||||
// Moodle v2.4.0 release upgrade line
|
||||
// Put any upgrade step following this
|
||||
|
||||
|
||||
// Moodle v2.5.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
|
||||
// Moodle v2.6.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Moodle v2.7.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Moodle v2.8.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
|
@ -22,28 +22,10 @@
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
function xmldb_chat_upgrade($oldversion) {
|
||||
global $CFG, $DB;
|
||||
|
||||
$dbman = $DB->get_manager();
|
||||
|
||||
// Moodle v2.2.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Moodle v2.3.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Moodle v2.4.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Moodle v2.5.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Moodle v2.6.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Moodle v2.7.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
global $CFG;
|
||||
|
||||
// Moodle v2.8.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
@ -56,5 +38,3 @@ function xmldb_chat_upgrade($oldversion) {
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
// This file keeps track of upgrades to
|
||||
// the choice module
|
||||
//
|
||||
@ -20,33 +19,13 @@
|
||||
// Please do not forget to use upgrade_set_timeout()
|
||||
// before any action that may take longer time to finish.
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
function xmldb_choice_upgrade($oldversion) {
|
||||
global $CFG, $DB;
|
||||
|
||||
$dbman = $DB->get_manager();
|
||||
|
||||
|
||||
// Moodle v2.2.0 release upgrade line
|
||||
// Put any upgrade step following this
|
||||
|
||||
// Moodle v2.3.0 release upgrade line
|
||||
// Put any upgrade step following this
|
||||
|
||||
|
||||
// Moodle v2.4.0 release upgrade line
|
||||
// Put any upgrade step following this
|
||||
|
||||
|
||||
// Moodle v2.5.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
|
||||
// Moodle v2.6.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Moodle v2.7.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
if ($oldversion < 2014051201) {
|
||||
|
||||
// Define field allowmultiple to be added to choice.
|
||||
@ -103,5 +82,3 @@ function xmldb_choice_upgrade($oldversion) {
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
// This file keeps track of upgrades to
|
||||
// the data module
|
||||
//
|
||||
@ -20,120 +19,13 @@
|
||||
// Please do not forget to use upgrade_set_timeout()
|
||||
// before any action that may take longer time to finish.
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
function xmldb_data_upgrade($oldversion) {
|
||||
global $CFG, $DB, $OUTPUT;
|
||||
global $CFG, $DB;
|
||||
|
||||
$dbman = $DB->get_manager();
|
||||
|
||||
|
||||
// Moodle v2.2.0 release upgrade line
|
||||
// Put any upgrade step following this
|
||||
|
||||
// Moodle v2.3.0 release upgrade line
|
||||
// Put any upgrade step following this
|
||||
|
||||
if ($oldversion < 2012112901) {
|
||||
// Check if there is a directory containing any old presets.
|
||||
$olddatadir = $CFG->dataroot . '/data';
|
||||
$oldpresetdir = "$olddatadir/preset";
|
||||
if (file_exists($oldpresetdir)) {
|
||||
// Get directory contents.
|
||||
$userfolders = new DirectoryIterator($oldpresetdir);
|
||||
// Store the system context, these are site wide presets.
|
||||
$context = context_system::instance();
|
||||
// Create file storage object.
|
||||
$fs = get_file_storage();
|
||||
// Create array of accepted files.
|
||||
$arracceptedfilenames = array('singletemplate.html', 'listtemplateheader.html', 'listtemplate.html',
|
||||
'listtemplatefooter.html', 'addtemplate.html', 'rsstemplate.html',
|
||||
'rsstitletemplate.html', 'csstemplate.css', 'jstemplate.js',
|
||||
'asearchtemplate.html', 'preset.xml');
|
||||
// Loop through all the folders, they should represent userids.
|
||||
foreach ($userfolders as $userfolder) {
|
||||
// If it is a file, skip it.
|
||||
if ($userfolder->isFile()) {
|
||||
continue;
|
||||
}
|
||||
// The folder name should represent the user id.
|
||||
$userid = $userfolder->getFilename();
|
||||
// Skip if it is not numeric.
|
||||
if (!is_numeric($userid)) {
|
||||
continue;
|
||||
}
|
||||
// Skip if the number does not correspond to a user (does not matter if user was deleted).
|
||||
if (!$DB->record_exists('user', array('id' => $userid))) {
|
||||
continue;
|
||||
}
|
||||
// Open this folder.
|
||||
$presetfolders = new DirectoryIterator("$oldpresetdir/$userid");
|
||||
foreach ($presetfolders as $presetfolder) {
|
||||
// If it is a file, skip it.
|
||||
if ($presetfolder->isFile()) {
|
||||
continue;
|
||||
}
|
||||
// Save the name of the preset.
|
||||
$presetname = $presetfolder->getFilename();
|
||||
// Get the files in this preset folder.
|
||||
$presetfiles = new DirectoryIterator("$oldpresetdir/$userid/$presetname");
|
||||
// Now we want to get the contents of the presets.
|
||||
foreach ($presetfiles as $file) {
|
||||
// If it is not a file, skip it.
|
||||
if (!$file->isFile()) {
|
||||
continue;
|
||||
}
|
||||
// Set the filename.
|
||||
$filename = $file->getFilename();
|
||||
// If it is not in the array of accepted file names skip it.
|
||||
if (!in_array($filename, $arracceptedfilenames)) {
|
||||
continue;
|
||||
}
|
||||
// Store the full file path.
|
||||
$fullfilepath = "$oldpresetdir/$userid/$presetname/$filename";
|
||||
// Create file record.
|
||||
$filerecord = array('contextid' => $context->id,
|
||||
'component' => 'mod_data',
|
||||
'filearea' => 'site_presets',
|
||||
'itemid' => 0,
|
||||
'filename' => $filename,
|
||||
'userid' => $userid);
|
||||
// Check to ensure it does not already exists in the file directory.
|
||||
if (!$fs->file_exists($context->id, 'mod_data', 'site_presets', 0, '/' . $presetfolder . '/', $filename)) {
|
||||
$filerecord['filepath'] = '/' . $presetfolder . '/';
|
||||
} else {
|
||||
$filerecord['filepath'] = '/' . $presetfolder . '_' . $userid . '_old/';
|
||||
}
|
||||
$fs->create_file_from_pathname($filerecord, $fullfilepath);
|
||||
// Remove the file.
|
||||
@unlink($fullfilepath);
|
||||
}
|
||||
// Remove the preset directory.
|
||||
@rmdir("$oldpresetdir/$userid/$presetname");
|
||||
}
|
||||
// Remove the user directory.
|
||||
@rmdir("$oldpresetdir/$userid");
|
||||
}
|
||||
// Remove the final directories.
|
||||
@rmdir("$oldpresetdir");
|
||||
@rmdir("$olddatadir");
|
||||
}
|
||||
|
||||
upgrade_mod_savepoint(true, 2012112901, 'data');
|
||||
}
|
||||
|
||||
// Moodle v2.4.0 release upgrade line
|
||||
// Put any upgrade step following this
|
||||
|
||||
|
||||
// Moodle v2.5.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
|
||||
// Moodle v2.6.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Moodle v2.7.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Moodle v2.8.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
|
@ -34,32 +34,10 @@
|
||||
// Please do not forget to use upgrade_set_timeout()
|
||||
// before any action that may take longer time to finish.
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
function xmldb_feedback_upgrade($oldversion) {
|
||||
global $CFG, $DB;
|
||||
|
||||
$dbman = $DB->get_manager();
|
||||
|
||||
|
||||
// Moodle v2.2.0 release upgrade line
|
||||
// Put any upgrade step following this
|
||||
|
||||
// Moodle v2.3.0 release upgrade line
|
||||
// Put any upgrade step following this
|
||||
|
||||
|
||||
// Moodle v2.4.0 release upgrade line
|
||||
// Put any upgrade step following this
|
||||
|
||||
|
||||
// Moodle v2.5.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
|
||||
// Moodle v2.6.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Moodle v2.7.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
global $CFG;
|
||||
|
||||
// Moodle v2.8.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
@ -72,5 +50,3 @@ function xmldb_feedback_upgrade($oldversion) {
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
@ -48,76 +47,7 @@ defined('MOODLE_INTERNAL') || die();
|
||||
function xmldb_folder_upgrade($oldversion) {
|
||||
global $CFG, $DB;
|
||||
|
||||
$dbman = $DB->get_manager();
|
||||
|
||||
|
||||
// Moodle v2.2.0 release upgrade line
|
||||
// Put any upgrade step following this
|
||||
|
||||
// Moodle v2.3.0 release upgrade line
|
||||
// Put any upgrade step following this
|
||||
|
||||
// Moodle v2.4.0 release upgrade line
|
||||
// Put any upgrade step following this
|
||||
|
||||
if ($oldversion < 2013012100) {
|
||||
|
||||
// Define field display to be added to folder
|
||||
$table = new xmldb_table('folder');
|
||||
$field = new xmldb_field('display', XMLDB_TYPE_INTEGER, '4', null, XMLDB_NOTNULL, null, '0', 'timemodified');
|
||||
|
||||
// Conditionally launch add field display
|
||||
if (!$dbman->field_exists($table, $field)) {
|
||||
$dbman->add_field($table, $field);
|
||||
}
|
||||
|
||||
// folder savepoint reached
|
||||
upgrade_mod_savepoint(true, 2013012100, 'folder');
|
||||
}
|
||||
|
||||
if ($oldversion < 2013031500) {
|
||||
|
||||
// Define field showexpanded to be added to folder
|
||||
$table = new xmldb_table('folder');
|
||||
$field = new xmldb_field('showexpanded', XMLDB_TYPE_INTEGER, '1', null, XMLDB_NOTNULL, null, '1', 'revision');
|
||||
|
||||
// Conditionally launch add field showexpanded
|
||||
if (!$dbman->field_exists($table, $field)) {
|
||||
$dbman->add_field($table, $field);
|
||||
}
|
||||
|
||||
// folder savepoint reached
|
||||
upgrade_mod_savepoint(true, 2013031500, 'folder');
|
||||
}
|
||||
|
||||
// Rename show_expanded to showexpanded (see MDL-38646).
|
||||
if ($oldversion < 2013040700) {
|
||||
|
||||
// Rename site config setting.
|
||||
$showexpanded = get_config('folder', 'show_expanded');
|
||||
set_config('showexpanded', $showexpanded, 'folder');
|
||||
set_config('show_expanded', null, 'folder');
|
||||
|
||||
// Rename table column.
|
||||
$table = new xmldb_table('folder');
|
||||
$field = new xmldb_field('show_expanded', XMLDB_TYPE_INTEGER, '1', null, XMLDB_NOTNULL, null, '1', 'revision');
|
||||
if ($dbman->field_exists($table, $field)) {
|
||||
$dbman->rename_field($table, $field, 'showexpanded');
|
||||
}
|
||||
|
||||
// folder savepoint reached
|
||||
upgrade_mod_savepoint(true, 2013040700, 'folder');
|
||||
}
|
||||
|
||||
// Moodle v2.5.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
|
||||
// Moodle v2.6.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Moodle v2.7.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
$dbman = $DB->get_manager(); // Loads ddl manager and xmldb classes.
|
||||
|
||||
// Moodle v2.8.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
@ -41,104 +40,13 @@
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
function xmldb_forum_upgrade($oldversion) {
|
||||
global $CFG, $DB, $OUTPUT;
|
||||
global $CFG, $DB;
|
||||
|
||||
$dbman = $DB->get_manager(); // Loads ddl manager and xmldb classes.
|
||||
|
||||
// Moodle v2.2.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Moodle v2.3.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Moodle v2.4.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
if ($oldversion < 2013020500) {
|
||||
|
||||
// Define field displaywordcount to be added to forum.
|
||||
$table = new xmldb_table('forum');
|
||||
$field = new xmldb_field('displaywordcount', XMLDB_TYPE_INTEGER, '1', null, XMLDB_NOTNULL, null, '0', 'completionposts');
|
||||
|
||||
// Conditionally launch add field displaywordcount.
|
||||
if (!$dbman->field_exists($table, $field)) {
|
||||
$dbman->add_field($table, $field);
|
||||
}
|
||||
|
||||
// Forum savepoint reached.
|
||||
upgrade_mod_savepoint(true, 2013020500, 'forum');
|
||||
}
|
||||
|
||||
// Forcefully assign mod/forum:allowforcesubscribe to frontpage role, as we missed that when
|
||||
// capability was introduced.
|
||||
if ($oldversion < 2013021200) {
|
||||
// If capability mod/forum:allowforcesubscribe is defined then set it for frontpage role.
|
||||
if (get_capability_info('mod/forum:allowforcesubscribe')) {
|
||||
assign_legacy_capabilities('mod/forum:allowforcesubscribe', array('frontpage' => CAP_ALLOW));
|
||||
}
|
||||
// Forum savepoint reached.
|
||||
upgrade_mod_savepoint(true, 2013021200, 'forum');
|
||||
}
|
||||
|
||||
|
||||
// Moodle v2.5.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
if ($oldversion < 2013071000) {
|
||||
// Define table forum_digests to be created.
|
||||
$table = new xmldb_table('forum_digests');
|
||||
|
||||
// Adding fields to table forum_digests.
|
||||
$table->add_field('id', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
|
||||
$table->add_field('userid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null);
|
||||
$table->add_field('forum', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null);
|
||||
$table->add_field('maildigest', XMLDB_TYPE_INTEGER, '1', null, XMLDB_NOTNULL, null, '-1');
|
||||
|
||||
// Adding keys to table forum_digests.
|
||||
$table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
|
||||
$table->add_key('userid', XMLDB_KEY_FOREIGN, array('userid'), 'user', array('id'));
|
||||
$table->add_key('forum', XMLDB_KEY_FOREIGN, array('forum'), 'forum', array('id'));
|
||||
$table->add_key('forumdigest', XMLDB_KEY_UNIQUE, array('forum', 'userid', 'maildigest'));
|
||||
|
||||
// Conditionally launch create table for forum_digests.
|
||||
if (!$dbman->table_exists($table)) {
|
||||
$dbman->create_table($table);
|
||||
}
|
||||
|
||||
// Forum savepoint reached.
|
||||
upgrade_mod_savepoint(true, 2013071000, 'forum');
|
||||
}
|
||||
|
||||
// Moodle v2.6.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
if ($oldversion < 2014040400) {
|
||||
|
||||
// Define index userid-postid (not unique) to be dropped form forum_read.
|
||||
$table = new xmldb_table('forum_read');
|
||||
$index = new xmldb_index('userid-postid', XMLDB_INDEX_NOTUNIQUE, array('userid', 'postid'));
|
||||
|
||||
// Conditionally launch drop index userid-postid.
|
||||
if ($dbman->index_exists($table, $index)) {
|
||||
$dbman->drop_index($table, $index);
|
||||
}
|
||||
|
||||
|
||||
// Define index postid-userid (not unique) to be added to forum_read.
|
||||
$index = new xmldb_index('postid-userid', XMLDB_INDEX_NOTUNIQUE, array('postid', 'userid'));
|
||||
|
||||
// Conditionally launch add index postid-userid.
|
||||
if (!$dbman->index_exists($table, $index)) {
|
||||
$dbman->add_index($table, $index);
|
||||
}
|
||||
|
||||
// Forum savepoint reached.
|
||||
upgrade_mod_savepoint(true, 2014040400, 'forum');
|
||||
}
|
||||
|
||||
// Moodle v2.7.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
if ($oldversion < 2014051201) {
|
||||
|
||||
// Incorrect values that need to be replaced.
|
||||
|
@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
// This file keeps track of upgrades to
|
||||
// the glossary module
|
||||
//
|
||||
@ -21,47 +20,10 @@
|
||||
// before any action that may take longer time to finish.
|
||||
|
||||
function xmldb_glossary_upgrade($oldversion) {
|
||||
global $CFG, $DB, $OUTPUT;
|
||||
global $CFG, $DB;
|
||||
|
||||
$dbman = $DB->get_manager();
|
||||
|
||||
|
||||
// Moodle v2.2.0 release upgrade line
|
||||
// Put any upgrade step following this
|
||||
|
||||
if ($oldversion < 2012022000) {
|
||||
|
||||
// Define field approvaldisplayformat to be added to glossary
|
||||
$table = new xmldb_table('glossary');
|
||||
$field = new xmldb_field('approvaldisplayformat', XMLDB_TYPE_CHAR, '50', null, XMLDB_NOTNULL, null, 'default', 'defaultapproval');
|
||||
|
||||
// Conditionally launch add field approvaldisplayformat
|
||||
if (!$dbman->field_exists($table, $field)) {
|
||||
$dbman->add_field($table, $field);
|
||||
}
|
||||
|
||||
// glossary savepoint reached
|
||||
upgrade_mod_savepoint(true, 2012022000, 'glossary');
|
||||
}
|
||||
|
||||
// Moodle v2.3.0 release upgrade line
|
||||
// Put any upgrade step following this
|
||||
|
||||
|
||||
// Moodle v2.4.0 release upgrade line
|
||||
// Put any upgrade step following this
|
||||
|
||||
|
||||
// Moodle v2.5.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
|
||||
// Moodle v2.6.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Moodle v2.7.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Moodle v2.8.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
@ -88,5 +50,3 @@ function xmldb_glossary_upgrade($oldversion) {
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
@ -29,27 +29,7 @@ defined('MOODLE_INTERNAL') || die();
|
||||
* @param int $oldversion
|
||||
*/
|
||||
function xmldb_imscp_upgrade($oldversion) {
|
||||
global $CFG, $DB;
|
||||
|
||||
$dbman = $DB->get_manager();
|
||||
|
||||
// Moodle v2.2.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Moodle v2.3.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Moodle v2.4.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Moodle v2.5.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Moodle v2.6.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Moodle v2.7.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
global $CFG;
|
||||
|
||||
// Moodle v2.8.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
@ -46,46 +45,7 @@
|
||||
defined('MOODLE_INTERNAL') || die;
|
||||
|
||||
function xmldb_label_upgrade($oldversion) {
|
||||
global $CFG, $DB;
|
||||
|
||||
$dbman = $DB->get_manager();
|
||||
|
||||
|
||||
// Moodle v2.2.0 release upgrade line
|
||||
// Put any upgrade step following this
|
||||
|
||||
// Moodle v2.3.0 release upgrade line
|
||||
// Put any upgrade step following this
|
||||
|
||||
|
||||
// Moodle v2.4.0 release upgrade line
|
||||
// Put any upgrade step following this
|
||||
|
||||
if ($oldversion < 2013021400) {
|
||||
// find all courses that contain labels and reset their cache
|
||||
$modid = $DB->get_field_sql("SELECT id FROM {modules} WHERE name=?",
|
||||
array('label'));
|
||||
if ($modid) {
|
||||
$courses = $DB->get_fieldset_sql('SELECT DISTINCT course '.
|
||||
'FROM {course_modules} WHERE module=?', array($modid));
|
||||
foreach ($courses as $courseid) {
|
||||
rebuild_course_cache($courseid, true);
|
||||
}
|
||||
}
|
||||
|
||||
// label savepoint reached
|
||||
upgrade_mod_savepoint(true, 2013021400, 'label');
|
||||
}
|
||||
|
||||
// Moodle v2.5.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
|
||||
// Moodle v2.6.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Moodle v2.7.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
global $CFG;
|
||||
|
||||
// Moodle v2.8.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
@ -98,5 +58,3 @@ function xmldb_label_upgrade($oldversion) {
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
@ -47,37 +46,14 @@ defined('MOODLE_INTERNAL') || die();
|
||||
*
|
||||
* @global stdClass $CFG
|
||||
* @global moodle_database $DB
|
||||
* @global core_renderer $OUTPUT
|
||||
* @param int $oldversion
|
||||
* @return bool
|
||||
*/
|
||||
function xmldb_lesson_upgrade($oldversion) {
|
||||
global $CFG, $DB, $OUTPUT;
|
||||
global $CFG, $DB;
|
||||
|
||||
$dbman = $DB->get_manager();
|
||||
|
||||
|
||||
// Moodle v2.2.0 release upgrade line
|
||||
// Put any upgrade step following this
|
||||
|
||||
// Moodle v2.3.0 release upgrade line
|
||||
// Put any upgrade step following this
|
||||
|
||||
|
||||
// Moodle v2.4.0 release upgrade line
|
||||
// Put any upgrade step following this
|
||||
|
||||
|
||||
// Moodle v2.5.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
|
||||
// Moodle v2.6.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Moodle v2.7.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
if ($oldversion < 2014091001) {
|
||||
$table = new xmldb_table('lesson');
|
||||
$field = new xmldb_field('intro', XMLDB_TYPE_TEXT, null, null, null, null, null, 'name');
|
||||
|
@ -65,24 +65,6 @@ function xmldb_lti_upgrade($oldversion) {
|
||||
|
||||
$dbman = $DB->get_manager();
|
||||
|
||||
// Moodle v2.2.0 release upgrade line
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Moodle v2.3.0 release upgrade line
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Moodle v2.4.0 release upgrade line
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Moodle v2.5.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Moodle v2.6.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Moodle v2.7.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
if ($oldversion < 2014060201) {
|
||||
|
||||
// Changing type of field grade on table lti to int.
|
||||
@ -199,4 +181,3 @@ function xmldb_lti_upgrade($oldversion) {
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
@ -46,31 +45,7 @@
|
||||
defined('MOODLE_INTERNAL') || die;
|
||||
|
||||
function xmldb_page_upgrade($oldversion) {
|
||||
global $CFG, $DB;
|
||||
|
||||
$dbman = $DB->get_manager();
|
||||
|
||||
|
||||
// Moodle v2.2.0 release upgrade line
|
||||
// Put any upgrade step following this
|
||||
|
||||
// Moodle v2.3.0 release upgrade line
|
||||
// Put any upgrade step following this
|
||||
|
||||
|
||||
// Moodle v2.4.0 release upgrade line
|
||||
// Put any upgrade step following this
|
||||
|
||||
|
||||
// Moodle v2.5.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
|
||||
// Moodle v2.6.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Moodle v2.7.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
global $CFG;
|
||||
|
||||
// Moodle v2.8.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
@ -22,10 +22,8 @@
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
|
||||
/**
|
||||
* Quiz module upgrade function.
|
||||
* @param string $oldversion the version we are upgrading from.
|
||||
@ -35,746 +33,6 @@ function xmldb_quiz_upgrade($oldversion) {
|
||||
|
||||
$dbman = $DB->get_manager();
|
||||
|
||||
// Moodle v2.2.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
if ($oldversion < 2011120700) {
|
||||
|
||||
// Define field lastcron to be dropped from quiz_reports.
|
||||
$table = new xmldb_table('quiz_reports');
|
||||
$field = new xmldb_field('lastcron');
|
||||
|
||||
// Conditionally launch drop field lastcron.
|
||||
if ($dbman->field_exists($table, $field)) {
|
||||
$dbman->drop_field($table, $field);
|
||||
}
|
||||
|
||||
// Quiz savepoint reached.
|
||||
upgrade_mod_savepoint(true, 2011120700, 'quiz');
|
||||
}
|
||||
|
||||
if ($oldversion < 2011120701) {
|
||||
|
||||
// Define field cron to be dropped from quiz_reports.
|
||||
$table = new xmldb_table('quiz_reports');
|
||||
$field = new xmldb_field('cron');
|
||||
|
||||
// Conditionally launch drop field cron.
|
||||
if ($dbman->field_exists($table, $field)) {
|
||||
$dbman->drop_field($table, $field);
|
||||
}
|
||||
|
||||
// Quiz savepoint reached.
|
||||
upgrade_mod_savepoint(true, 2011120701, 'quiz');
|
||||
}
|
||||
|
||||
if ($oldversion < 2011120703) {
|
||||
// Track page of quiz attempts.
|
||||
$table = new xmldb_table('quiz_attempts');
|
||||
|
||||
$field = new xmldb_field('currentpage', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, 0);
|
||||
|
||||
if (!$dbman->field_exists($table, $field)) {
|
||||
$dbman->add_field($table, $field);
|
||||
}
|
||||
upgrade_mod_savepoint(true, 2011120703, 'quiz');
|
||||
}
|
||||
|
||||
if ($oldversion < 2012030901) {
|
||||
// Configuration option for navigation method.
|
||||
$table = new xmldb_table('quiz');
|
||||
|
||||
$field = new xmldb_field('navmethod', XMLDB_TYPE_CHAR, '16', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, 'free');
|
||||
|
||||
if (!$dbman->field_exists($table, $field)) {
|
||||
$dbman->add_field($table, $field);
|
||||
}
|
||||
upgrade_mod_savepoint(true, 2012030901, 'quiz');
|
||||
}
|
||||
|
||||
if ($oldversion < 2012040198) {
|
||||
// This step was added later. In MDL-32727, it was found that adding the
|
||||
// unique index on quiz-userid-attempt sometimes failed because of
|
||||
// duplicate entries {quizid}-{userid}-{attempt}. We do two things to
|
||||
// prevent these problems. First, here, we delete all preview attempts.
|
||||
|
||||
// This code is an approximate copy-and-paste from
|
||||
// question_engine_data_mapper::delete_questions_usage_by_activities
|
||||
// Note that, for simplicity, the MySQL performance hack has been removed.
|
||||
// Since this code is for upgrade only, performance in not so critical,
|
||||
// where as simplicity of testing the code is.
|
||||
|
||||
// Note that there is a limit to how far I am prepared to go in eliminating
|
||||
// all calls to library functions in this upgrade code. The only library
|
||||
// function still being used in question_engine::get_all_response_file_areas();
|
||||
// I think it is pretty safe not to inline it here.
|
||||
|
||||
// Get a list of response variables that have files.
|
||||
require_once($CFG->dirroot . '/question/type/questiontypebase.php');
|
||||
$variables = array();
|
||||
foreach (core_component::get_plugin_list('qtype') as $qtypename => $path) {
|
||||
$file = $path . '/questiontype.php';
|
||||
if (!is_readable($file)) {
|
||||
continue;
|
||||
}
|
||||
include_once($file);
|
||||
$class = 'qtype_' . $qtypename;
|
||||
if (!class_exists($class)) {
|
||||
continue;
|
||||
}
|
||||
$qtype = new $class();
|
||||
if (!method_exists($qtype, 'response_file_areas')) {
|
||||
continue;
|
||||
}
|
||||
$variables += $qtype->response_file_areas();
|
||||
}
|
||||
|
||||
// Conver that to a list of actual file area names.
|
||||
$fileareas = array();
|
||||
foreach (array_unique($variables) as $variable) {
|
||||
$fileareas[] = 'response_' . $variable;
|
||||
}
|
||||
// No point checking if this is empty as an optimisation, because essay
|
||||
// has response file areas, so the array will never be empty.
|
||||
|
||||
// Get all the contexts where there are previews.
|
||||
$contextids = $DB->get_records_sql_menu("
|
||||
SELECT DISTINCT qu.contextid, 1
|
||||
FROM {question_usages} qu
|
||||
JOIN {quiz_attempts} quiza ON quiza.uniqueid = qu.id
|
||||
WHERE quiza.preview = 1");
|
||||
|
||||
// Loop over contexts and files areas, deleting all files.
|
||||
$fs = get_file_storage();
|
||||
foreach ($contextids as $contextid => $notused) {
|
||||
foreach ($fileareas as $filearea) {
|
||||
upgrade_set_timeout(300);
|
||||
$fs->delete_area_files_select($contextid, 'question', $filearea,
|
||||
"IN (SELECT qas.id
|
||||
FROM {question_attempt_steps} qas
|
||||
JOIN {question_attempts} qa ON qa.id = qas.questionattemptid
|
||||
JOIN {quiz_attempts} quiza ON quiza.uniqueid = qa.questionusageid
|
||||
WHERE quiza.preview = 1)");
|
||||
}
|
||||
}
|
||||
|
||||
// Now delete the question data associated with the previews.
|
||||
$DB->delete_records_select('question_attempt_step_data', "attemptstepid IN (
|
||||
SELECT qas.id
|
||||
FROM {question_attempt_steps} qas
|
||||
JOIN {question_attempts} qa ON qa.id = qas.questionattemptid
|
||||
JOIN {quiz_attempts} quiza ON quiza.uniqueid = qa.questionusageid
|
||||
WHERE quiza.preview = 1)");
|
||||
|
||||
$DB->delete_records_select('question_attempt_steps', "questionattemptid IN (
|
||||
SELECT qa.id
|
||||
FROM {question_attempts} qa
|
||||
JOIN {quiz_attempts} quiza ON quiza.uniqueid = qa.questionusageid
|
||||
WHERE quiza.preview = 1)");
|
||||
|
||||
$DB->delete_records_select('question_attempts', "{question_attempts}.questionusageid IN (
|
||||
SELECT uniqueid FROM {quiz_attempts} WHERE preview = 1)");
|
||||
|
||||
$DB->delete_records_select('question_usages', "{question_usages}.id IN (
|
||||
SELECT uniqueid FROM {quiz_attempts} WHERE preview = 1)");
|
||||
|
||||
// Finally delete the previews.
|
||||
$DB->delete_records('quiz_attempts', array('preview' => 1));
|
||||
|
||||
// Quiz savepoint reached.
|
||||
upgrade_mod_savepoint(true, 2012040198, 'quiz');
|
||||
}
|
||||
|
||||
if ($oldversion < 2012040199) {
|
||||
// This step was added later. In MDL-32727, it was found that adding the
|
||||
// unique index on quiz-userid-attempt sometimes failed because of
|
||||
// duplicate entries {quizid}-{userid}-{attempt}.
|
||||
// Here, if there are still duplicate entires, we renumber the values in
|
||||
// the attempt column.
|
||||
|
||||
// Load all the problem quiz attempts.
|
||||
$problems = $DB->get_recordset_sql('
|
||||
SELECT qa.id, qa.quiz, qa.userid, qa.attempt
|
||||
FROM {quiz_attempts} qa
|
||||
JOIN (
|
||||
SELECT DISTINCT quiz, userid
|
||||
FROM {quiz_attempts}
|
||||
GROUP BY quiz, userid, attempt
|
||||
HAVING COUNT(1) > 1
|
||||
) problems_view ON problems_view.quiz = qa.quiz AND
|
||||
problems_view.userid = qa.userid
|
||||
ORDER BY qa.quiz, qa.userid, qa.attempt, qa.id');
|
||||
|
||||
// Renumber them.
|
||||
$currentquiz = null;
|
||||
$currentuserid = null;
|
||||
$attempt = 1;
|
||||
foreach ($problems as $problem) {
|
||||
if ($problem->quiz !== $currentquiz || $problem->userid !== $currentuserid) {
|
||||
$currentquiz = $problem->quiz;
|
||||
$currentuserid = $problem->userid;
|
||||
$attempt = 1;
|
||||
}
|
||||
if ($attempt != $problem->attempt) {
|
||||
$DB->set_field('quiz_attempts', 'attempt', $attempt, array('id' => $problem->id));
|
||||
}
|
||||
$attempt += 1;
|
||||
}
|
||||
|
||||
$problems->close();
|
||||
|
||||
// Quiz savepoint reached.
|
||||
upgrade_mod_savepoint(true, 2012040199, 'quiz');
|
||||
}
|
||||
|
||||
if ($oldversion < 2012040200) {
|
||||
// Define index userid to be dropped form quiz_attempts.
|
||||
$table = new xmldb_table('quiz_attempts');
|
||||
$index = new xmldb_index('userid', XMLDB_INDEX_NOTUNIQUE, array('userid'));
|
||||
|
||||
// Conditionally launch drop index quiz-userid-attempt.
|
||||
if ($dbman->index_exists($table, $index)) {
|
||||
$dbman->drop_index($table, $index);
|
||||
}
|
||||
|
||||
// Quiz savepoint reached.
|
||||
upgrade_mod_savepoint(true, 2012040200, 'quiz');
|
||||
}
|
||||
|
||||
if ($oldversion < 2012040201) {
|
||||
|
||||
// Define key userid (foreign) to be added to quiz_attempts.
|
||||
$table = new xmldb_table('quiz_attempts');
|
||||
$key = new xmldb_key('userid', XMLDB_KEY_FOREIGN, array('userid'), 'user', array('id'));
|
||||
|
||||
// Launch add key userid.
|
||||
$dbman->add_key($table, $key);
|
||||
|
||||
// Quiz savepoint reached.
|
||||
upgrade_mod_savepoint(true, 2012040201, 'quiz');
|
||||
}
|
||||
|
||||
if ($oldversion < 2012040202) {
|
||||
|
||||
// Define index quiz-userid-attempt (unique) to be added to quiz_attempts.
|
||||
$table = new xmldb_table('quiz_attempts');
|
||||
$index = new xmldb_index('quiz-userid-attempt', XMLDB_INDEX_UNIQUE, array('quiz', 'userid', 'attempt'));
|
||||
|
||||
// Conditionally launch add index quiz-userid-attempt.
|
||||
if (!$dbman->index_exists($table, $index)) {
|
||||
$dbman->add_index($table, $index);
|
||||
}
|
||||
|
||||
// Quiz savepoint reached.
|
||||
upgrade_mod_savepoint(true, 2012040202, 'quiz');
|
||||
}
|
||||
|
||||
if ($oldversion < 2012040203) {
|
||||
|
||||
// Define field state to be added to quiz_attempts.
|
||||
$table = new xmldb_table('quiz_attempts');
|
||||
$field = new xmldb_field('state', XMLDB_TYPE_CHAR, '16', null, XMLDB_NOTNULL, null, 'inprogress', 'preview');
|
||||
|
||||
// Conditionally launch add field state.
|
||||
if (!$dbman->field_exists($table, $field)) {
|
||||
$dbman->add_field($table, $field);
|
||||
}
|
||||
|
||||
// Quiz savepoint reached.
|
||||
upgrade_mod_savepoint(true, 2012040203, 'quiz');
|
||||
}
|
||||
|
||||
if ($oldversion < 2012040204) {
|
||||
|
||||
// Update quiz_attempts.state for finished attempts.
|
||||
$DB->set_field_select('quiz_attempts', 'state', 'finished', 'timefinish > 0');
|
||||
|
||||
// Other, more complex transitions (basically abandoned attempts), will
|
||||
// be handled by cron later.
|
||||
|
||||
// Quiz savepoint reached.
|
||||
upgrade_mod_savepoint(true, 2012040204, 'quiz');
|
||||
}
|
||||
|
||||
if ($oldversion < 2012040205) {
|
||||
|
||||
// Define field overduehandling to be added to quiz.
|
||||
$table = new xmldb_table('quiz');
|
||||
$field = new xmldb_field('overduehandling', XMLDB_TYPE_CHAR, '16', null, XMLDB_NOTNULL, null, 'autoabandon', 'timelimit');
|
||||
|
||||
// Conditionally launch add field overduehandling.
|
||||
if (!$dbman->field_exists($table, $field)) {
|
||||
$dbman->add_field($table, $field);
|
||||
}
|
||||
|
||||
// Quiz savepoint reached.
|
||||
upgrade_mod_savepoint(true, 2012040205, 'quiz');
|
||||
}
|
||||
|
||||
if ($oldversion < 2012040206) {
|
||||
|
||||
// Define field graceperiod to be added to quiz.
|
||||
$table = new xmldb_table('quiz');
|
||||
$field = new xmldb_field('graceperiod', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, '0', 'overduehandling');
|
||||
|
||||
// Conditionally launch add field graceperiod.
|
||||
if (!$dbman->field_exists($table, $field)) {
|
||||
$dbman->add_field($table, $field);
|
||||
}
|
||||
|
||||
// Quiz savepoint reached.
|
||||
upgrade_mod_savepoint(true, 2012040206, 'quiz');
|
||||
}
|
||||
|
||||
// Moodle v2.3.0 release upgrade line
|
||||
// Put any upgrade step following this.
|
||||
|
||||
if ($oldversion < 2012061702) {
|
||||
|
||||
// MDL-32791 somebody reported having nonsense rows in their
|
||||
// quiz_question_instances which caused various problems. These rows
|
||||
// are meaningless, hence this upgrade step to clean them up.
|
||||
$DB->delete_records('quiz_question_instances', array('question' => 0));
|
||||
|
||||
// Quiz savepoint reached.
|
||||
upgrade_mod_savepoint(true, 2012061702, 'quiz');
|
||||
}
|
||||
|
||||
if ($oldversion < 2012061703) {
|
||||
|
||||
// MDL-34702 the questiondecimalpoints column was created with default -2
|
||||
// when it should have been -1, and no-one has noticed in the last 2+ years!
|
||||
|
||||
// Changing the default of field questiondecimalpoints on table quiz to -1.
|
||||
$table = new xmldb_table('quiz');
|
||||
$field = new xmldb_field('questiondecimalpoints', XMLDB_TYPE_INTEGER, '4', null, XMLDB_NOTNULL, null, '-1', 'decimalpoints');
|
||||
|
||||
// Launch change of default for field questiondecimalpoints.
|
||||
$dbman->change_field_default($table, $field);
|
||||
|
||||
// Correct any wrong values.
|
||||
$DB->set_field('quiz', 'questiondecimalpoints', -1, array('questiondecimalpoints' => -2));
|
||||
|
||||
// Quiz savepoint reached.
|
||||
upgrade_mod_savepoint(true, 2012061703, 'quiz');
|
||||
}
|
||||
|
||||
if ($oldversion < 2012100801) {
|
||||
|
||||
// Define field timecheckstate to be added to quiz_attempts.
|
||||
$table = new xmldb_table('quiz_attempts');
|
||||
$field = new xmldb_field('timecheckstate', XMLDB_TYPE_INTEGER, '10', null, null, null, '0', 'timemodified');
|
||||
|
||||
// Conditionally launch add field timecheckstate.
|
||||
if (!$dbman->field_exists($table, $field)) {
|
||||
$dbman->add_field($table, $field);
|
||||
}
|
||||
|
||||
// Define index state-timecheckstate (not unique) to be added to quiz_attempts.
|
||||
$table = new xmldb_table('quiz_attempts');
|
||||
$index = new xmldb_index('state-timecheckstate', XMLDB_INDEX_NOTUNIQUE, array('state', 'timecheckstate'));
|
||||
|
||||
// Conditionally launch add index state-timecheckstate.
|
||||
if (!$dbman->index_exists($table, $index)) {
|
||||
$dbman->add_index($table, $index);
|
||||
}
|
||||
|
||||
// Overdue cron no longer needs these.
|
||||
unset_config('overduelastrun', 'quiz');
|
||||
unset_config('overduedoneto', 'quiz');
|
||||
|
||||
// Update timecheckstate on all open attempts.
|
||||
require_once($CFG->dirroot . '/mod/quiz/locallib.php');
|
||||
quiz_update_open_attempts(array());
|
||||
|
||||
// quiz savepoint reached
|
||||
upgrade_mod_savepoint(true, 2012100801, 'quiz');
|
||||
}
|
||||
|
||||
// Moodle v2.4.0 release upgrade line
|
||||
// Put any upgrade step following this.
|
||||
|
||||
if ($oldversion < 2013031900) {
|
||||
// Quiz manual grading UI should be controlled by mod/quiz:grade, not :viewreports.
|
||||
$DB->set_field('quiz_reports', 'capability', 'mod/quiz:grade', array('name' => 'grading'));
|
||||
|
||||
// Mod quiz savepoint reached.
|
||||
upgrade_mod_savepoint(true, 2013031900, 'quiz');
|
||||
}
|
||||
|
||||
// Moodle v2.5.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Moodle v2.6.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
if ($oldversion < 2014011300) {
|
||||
|
||||
// Define key quiz (foreign) to be dropped form quiz_question_instances.
|
||||
$table = new xmldb_table('quiz_question_instances');
|
||||
$key = new xmldb_key('quiz', XMLDB_KEY_FOREIGN, array('quiz'), 'quiz', array('id'));
|
||||
|
||||
// Launch drop key quiz.
|
||||
$dbman->drop_key($table, $key);
|
||||
|
||||
// Quiz savepoint reached.
|
||||
upgrade_mod_savepoint(true, 2014011300, 'quiz');
|
||||
}
|
||||
|
||||
if ($oldversion < 2014011301) {
|
||||
|
||||
// Rename field quiz on table quiz_question_instances to quizid.
|
||||
$table = new xmldb_table('quiz_question_instances');
|
||||
$field = new xmldb_field('quiz', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, '0', 'id');
|
||||
|
||||
// Launch rename field quiz.
|
||||
$dbman->rename_field($table, $field, 'quizid');
|
||||
|
||||
// Quiz savepoint reached.
|
||||
upgrade_mod_savepoint(true, 2014011301, 'quiz');
|
||||
}
|
||||
|
||||
if ($oldversion < 2014011302) {
|
||||
|
||||
// Define key quizid (foreign) to be added to quiz_question_instances.
|
||||
$table = new xmldb_table('quiz_question_instances');
|
||||
$key = new xmldb_key('quizid', XMLDB_KEY_FOREIGN, array('quizid'), 'quiz', array('id'));
|
||||
|
||||
// Launch add key quizid.
|
||||
$dbman->add_key($table, $key);
|
||||
|
||||
// Quiz savepoint reached.
|
||||
upgrade_mod_savepoint(true, 2014011302, 'quiz');
|
||||
}
|
||||
|
||||
if ($oldversion < 2014011303) {
|
||||
|
||||
// Define key question (foreign) to be dropped form quiz_question_instances.
|
||||
$table = new xmldb_table('quiz_question_instances');
|
||||
$key = new xmldb_key('question', XMLDB_KEY_FOREIGN, array('question'), 'question', array('id'));
|
||||
|
||||
// Launch drop key question.
|
||||
$dbman->drop_key($table, $key);
|
||||
|
||||
// Quiz savepoint reached.
|
||||
upgrade_mod_savepoint(true, 2014011303, 'quiz');
|
||||
}
|
||||
|
||||
if ($oldversion < 2014011304) {
|
||||
|
||||
// Rename field question on table quiz_question_instances to questionid.
|
||||
$table = new xmldb_table('quiz_question_instances');
|
||||
$field = new xmldb_field('question', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, '0', 'quiz');
|
||||
|
||||
// Launch rename field question.
|
||||
$dbman->rename_field($table, $field, 'questionid');
|
||||
|
||||
// Quiz savepoint reached.
|
||||
upgrade_mod_savepoint(true, 2014011304, 'quiz');
|
||||
}
|
||||
|
||||
if ($oldversion < 2014011305) {
|
||||
|
||||
// Define key questionid (foreign) to be added to quiz_question_instances.
|
||||
$table = new xmldb_table('quiz_question_instances');
|
||||
$key = new xmldb_key('questionid', XMLDB_KEY_FOREIGN, array('questionid'), 'question', array('id'));
|
||||
|
||||
// Launch add key questionid.
|
||||
$dbman->add_key($table, $key);
|
||||
|
||||
// Quiz savepoint reached.
|
||||
upgrade_mod_savepoint(true, 2014011305, 'quiz');
|
||||
}
|
||||
|
||||
if ($oldversion < 2014011306) {
|
||||
|
||||
// Rename field grade on table quiz_question_instances to maxmark.
|
||||
$table = new xmldb_table('quiz_question_instances');
|
||||
$field = new xmldb_field('grade', XMLDB_TYPE_NUMBER, '12, 7', null, XMLDB_NOTNULL, null, '0', 'question');
|
||||
|
||||
// Launch rename field grade.
|
||||
$dbman->rename_field($table, $field, 'maxmark');
|
||||
|
||||
// Quiz savepoint reached.
|
||||
upgrade_mod_savepoint(true, 2014011306, 'quiz');
|
||||
}
|
||||
|
||||
if ($oldversion < 2014021300) {
|
||||
|
||||
// Define field needsupgradetonewqe to be dropped from quiz_attempts.
|
||||
$table = new xmldb_table('quiz_attempts');
|
||||
$field = new xmldb_field('needsupgradetonewqe');
|
||||
|
||||
// Conditionally launch drop field needsupgradetonewqe.
|
||||
if ($dbman->field_exists($table, $field)) {
|
||||
$dbman->drop_field($table, $field);
|
||||
}
|
||||
|
||||
// Quiz savepoint reached.
|
||||
upgrade_mod_savepoint(true, 2014021300, 'quiz');
|
||||
}
|
||||
|
||||
if ($oldversion < 2014022000) {
|
||||
|
||||
// Define table quiz_question_instances to be renamed to quiz_slots.
|
||||
$table = new xmldb_table('quiz_question_instances');
|
||||
|
||||
// Launch rename table for quiz_question_instances.
|
||||
$dbman->rename_table($table, 'quiz_slots');
|
||||
|
||||
// Quiz savepoint reached.
|
||||
upgrade_mod_savepoint(true, 2014022000, 'quiz');
|
||||
}
|
||||
|
||||
if ($oldversion < 2014022001) {
|
||||
|
||||
// Define field slot to be added to quiz_slots.
|
||||
$table = new xmldb_table('quiz_slots');
|
||||
$field = new xmldb_field('slot', XMLDB_TYPE_INTEGER, '10', null, null, null, null, 'id');
|
||||
|
||||
// Conditionally launch add field slot.
|
||||
if (!$dbman->field_exists($table, $field)) {
|
||||
$dbman->add_field($table, $field);
|
||||
}
|
||||
|
||||
// Quiz savepoint reached.
|
||||
upgrade_mod_savepoint(true, 2014022001, 'quiz');
|
||||
}
|
||||
|
||||
if ($oldversion < 2014022002) {
|
||||
|
||||
// Define field page to be added to quiz_slots.
|
||||
$table = new xmldb_table('quiz_slots');
|
||||
$field = new xmldb_field('page', XMLDB_TYPE_INTEGER, '10', null, null, null, null, 'quizid');
|
||||
|
||||
// Conditionally launch add field page.
|
||||
if (!$dbman->field_exists($table, $field)) {
|
||||
$dbman->add_field($table, $field);
|
||||
}
|
||||
|
||||
// Quiz savepoint reached.
|
||||
upgrade_mod_savepoint(true, 2014022002, 'quiz');
|
||||
}
|
||||
|
||||
if ($oldversion < 2014022003) {
|
||||
|
||||
// Use the information in the old quiz.questions column to fill in the
|
||||
// new slot and page columns.
|
||||
$numquizzes = $DB->count_records('quiz');
|
||||
if ($numquizzes > 0) {
|
||||
$pbar = new progress_bar('quizquestionstoslots', 500, true);
|
||||
$transaction = $DB->start_delegated_transaction();
|
||||
|
||||
$numberdone = 0;
|
||||
$quizzes = $DB->get_recordset('quiz', null, 'id', 'id,questions,sumgrades');
|
||||
foreach ($quizzes as $quiz) {
|
||||
if ($quiz->questions === '') {
|
||||
$questionsinorder = array();
|
||||
} else {
|
||||
$questionsinorder = explode(',', $quiz->questions);
|
||||
}
|
||||
|
||||
$questionidtoslotrowid = $DB->get_records_menu('quiz_slots',
|
||||
array('quizid' => $quiz->id), '', 'id, questionid');
|
||||
|
||||
$problemfound = false;
|
||||
$currentpage = 1;
|
||||
$slot = 1;
|
||||
foreach ($questionsinorder as $questionid) {
|
||||
if ($questionid === '0') {
|
||||
// Page break.
|
||||
$currentpage++;
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($questionid === '') {
|
||||
// This can happen as the result of old restore bugs.
|
||||
// There can be a missing number in the list of ids.
|
||||
// All we can do about this is ignore it, which is what
|
||||
// the quiz system used to do. See MDL-45321.
|
||||
continue;
|
||||
}
|
||||
|
||||
$key = array_search($questionid, $questionidtoslotrowid);
|
||||
if ($key !== false) {
|
||||
// Normal case. quiz_slots entry is present.
|
||||
// Just need to add slot and page.
|
||||
$quizslot = new stdClass();
|
||||
$quizslot->id = $key;
|
||||
$quizslot->slot = $slot;
|
||||
$quizslot->page = $currentpage;
|
||||
$DB->update_record('quiz_slots', $quizslot);
|
||||
|
||||
unset($questionidtoslotrowid[$key]); // So we can do a sanity check later.
|
||||
$slot++;
|
||||
continue;
|
||||
|
||||
} else {
|
||||
// This should not happen. The question was listed in
|
||||
// quiz.questions, but there was not an entry for it in
|
||||
// quiz_slots (formerly quiz_question_instances).
|
||||
// Previously, if such question ids were found, then
|
||||
// starting an attempt at the quiz would throw an exception.
|
||||
// Here, we try to add the missing data.
|
||||
$problemfound = true;
|
||||
$defaultmark = $DB->get_field('question', 'defaultmark',
|
||||
array('id' => $questionid), IGNORE_MISSING);
|
||||
if ($defaultmark === false) {
|
||||
debugging('During upgrade, detected that question ' .
|
||||
$questionid . ' was listed as being part of quiz ' .
|
||||
$quiz->id . ' but this question no longer exists. Ignoring it.', DEBUG_NORMAL);
|
||||
|
||||
// Non-existent question. Ignore it completely.
|
||||
continue;
|
||||
}
|
||||
|
||||
debugging('During upgrade, detected that question ' .
|
||||
$questionid . ' was listed as being part of quiz ' .
|
||||
$quiz->id . ' but there was not entry for it in ' .
|
||||
'quiz_question_instances/quiz_slots. Creating an entry with default mark.', DEBUG_NORMAL);
|
||||
$quizslot = new stdClass();
|
||||
$quizslot->quizid = $quiz->id;
|
||||
$quizslot->slot = $slot;
|
||||
$quizslot->page = $currentpage;
|
||||
$quizslot->questionid = $questionid;
|
||||
$quizslot->maxmark = $defaultmark;
|
||||
$DB->insert_record('quiz_slots', $quizslot);
|
||||
|
||||
$slot++;
|
||||
continue;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Now, as a sanity check, ensure we have done all the
|
||||
// quiz_slots rows linked to this quiz.
|
||||
if (!empty($questionidtoslotrowid)) {
|
||||
debugging('During upgrade, detected that questions ' .
|
||||
implode(', ', array_values($questionidtoslotrowid)) .
|
||||
' had instances in quiz ' . $quiz->id . ' but were not actually used. ' .
|
||||
'The instances have been removed.', DEBUG_NORMAL);
|
||||
|
||||
$DB->delete_records_list('quiz_slots', 'id', array_keys($questionidtoslotrowid));
|
||||
$problemfound = true;
|
||||
}
|
||||
|
||||
// If there were problems found, we probably need to re-compute
|
||||
// quiz.sumgrades.
|
||||
if ($problemfound) {
|
||||
// C/f the quiz_update_sumgrades function in locallib.php,
|
||||
// but note that what we do here is a bit simpler.
|
||||
$newsumgrades = $DB->get_field_sql(
|
||||
"SELECT SUM(maxmark)
|
||||
FROM {quiz_slots}
|
||||
WHERE quizid = ?",
|
||||
array($quiz->id));
|
||||
if (!$newsumgrades) {
|
||||
$newsumgrades = 0;
|
||||
}
|
||||
if (abs($newsumgrades - $quiz->sumgrades) > 0.000005) {
|
||||
debugging('Because of the previously mentioned problems, ' .
|
||||
'sumgrades for quiz ' . $quiz->id .
|
||||
' was changed from ' . $quiz->sumgrades . ' to ' .
|
||||
$newsumgrades . ' You should probably check that this quiz is still working: ' .
|
||||
$CFG->wwwroot . '/mod/quiz/view.php?q=' . $quiz->id . '.', DEBUG_NORMAL);
|
||||
$DB->set_field('quiz', 'sumgrades', $newsumgrades, array('id' => $quiz->id));
|
||||
}
|
||||
}
|
||||
|
||||
// Done with this quiz. Update progress bar.
|
||||
$numberdone++;
|
||||
$pbar->update($numberdone, $numquizzes,
|
||||
"Upgrading quiz structure - {$numberdone}/{$numquizzes}.");
|
||||
}
|
||||
|
||||
$transaction->allow_commit();
|
||||
}
|
||||
|
||||
// Quiz savepoint reached.
|
||||
upgrade_mod_savepoint(true, 2014022003, 'quiz');
|
||||
}
|
||||
|
||||
if ($oldversion < 2014022004) {
|
||||
|
||||
// If, for any reason, there were any quiz_slots missed, then try
|
||||
// to do something about that now before we add the NOT NULL constraints.
|
||||
// In fact, becuase of the sanity check at the end of the above check,
|
||||
// any such quiz_slots rows must refer to a non-existent quiz id, so
|
||||
// delete them.
|
||||
$DB->delete_records_select('quiz_slots',
|
||||
'NOT EXISTS (SELECT 1 FROM {quiz} q WHERE q.id = quizid)');
|
||||
|
||||
// Quiz savepoint reached.
|
||||
upgrade_mod_savepoint(true, 2014022004, 'quiz');
|
||||
|
||||
// Now, if any quiz_slots rows are left with slot or page NULL, something
|
||||
// is badly wrong.
|
||||
if ($DB->record_exists_select('quiz_slots', 'slot IS NULL OR page IS NULL')) {
|
||||
throw new coding_exception('Something went wrong in the quiz upgrade step for MDL-43749. ' .
|
||||
'Some quiz_slots still contain NULLs which will break the NOT NULL constraints we need to add. ' .
|
||||
'Please report this problem at http://tracker.moodle.org/ so that it can be investigated. Thank you.');
|
||||
}
|
||||
}
|
||||
|
||||
if ($oldversion < 2014022005) {
|
||||
|
||||
// Changing nullability of field slot on table quiz_slots to not null.
|
||||
$table = new xmldb_table('quiz_slots');
|
||||
$field = new xmldb_field('slot', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null, 'id');
|
||||
|
||||
// Launch change of nullability for field slot.
|
||||
$dbman->change_field_notnull($table, $field);
|
||||
|
||||
// Quiz savepoint reached.
|
||||
upgrade_mod_savepoint(true, 2014022005, 'quiz');
|
||||
}
|
||||
|
||||
if ($oldversion < 2014022006) {
|
||||
|
||||
// Changing nullability of field page on table quiz_slots to not null.
|
||||
$table = new xmldb_table('quiz_slots');
|
||||
$field = new xmldb_field('page', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null, 'quizid');
|
||||
|
||||
// Launch change of nullability for field page.
|
||||
$dbman->change_field_notnull($table, $field);
|
||||
|
||||
// Quiz savepoint reached.
|
||||
upgrade_mod_savepoint(true, 2014022006, 'quiz');
|
||||
}
|
||||
|
||||
if ($oldversion < 2014022007) {
|
||||
|
||||
// Define index quizid-slot (unique) to be added to quiz_slots.
|
||||
$table = new xmldb_table('quiz_slots');
|
||||
$index = new xmldb_index('quizid-slot', XMLDB_INDEX_UNIQUE, array('quizid', 'slot'));
|
||||
|
||||
// Conditionally launch add index quizid-slot.
|
||||
if (!$dbman->index_exists($table, $index)) {
|
||||
$dbman->add_index($table, $index);
|
||||
}
|
||||
|
||||
// Quiz savepoint reached.
|
||||
upgrade_mod_savepoint(true, 2014022007, 'quiz');
|
||||
}
|
||||
|
||||
if ($oldversion < 2014022008) {
|
||||
|
||||
// Define field questions to be dropped from quiz.
|
||||
$table = new xmldb_table('quiz');
|
||||
$field = new xmldb_field('questions');
|
||||
|
||||
// Conditionally launch drop field questions.
|
||||
if ($dbman->field_exists($table, $field)) {
|
||||
$dbman->drop_field($table, $field);
|
||||
}
|
||||
|
||||
// Quiz savepoint reached.
|
||||
upgrade_mod_savepoint(true, 2014022008, 'quiz');
|
||||
}
|
||||
|
||||
// Moodle v2.7.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
if ($oldversion < 2014052800) {
|
||||
|
||||
// Define field completionattemptsexhausted to be added to quiz.
|
||||
|
@ -22,39 +22,14 @@
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
|
||||
/**
|
||||
* Quiz overview report upgrade function.
|
||||
* @param number $oldversion
|
||||
*/
|
||||
function xmldb_quiz_overview_upgrade($oldversion) {
|
||||
global $CFG, $DB;
|
||||
|
||||
$dbman = $DB->get_manager();
|
||||
|
||||
// Moodle v2.2.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Moodle v2.3.0 release upgrade line
|
||||
// Put any upgrade step following this
|
||||
|
||||
|
||||
// Moodle v2.4.0 release upgrade line
|
||||
// Put any upgrade step following this
|
||||
|
||||
|
||||
// Moodle v2.5.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
|
||||
// Moodle v2.6.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Moodle v2.7.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
global $CFG;
|
||||
|
||||
// Moodle v2.8.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
@ -28,113 +28,7 @@ defined('MOODLE_INTERNAL') || die();
|
||||
* Quiz statistics report upgrade code.
|
||||
*/
|
||||
function xmldb_quiz_statistics_upgrade($oldversion) {
|
||||
global $DB;
|
||||
|
||||
$dbman = $DB->get_manager();
|
||||
|
||||
// Moodle v2.2.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Moodle v2.3.0 release upgrade line
|
||||
// Put any upgrade step following this
|
||||
|
||||
// Moodle v2.4.0 release upgrade line
|
||||
// Put any upgrade step following this
|
||||
|
||||
// Moodle v2.5.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
if ($oldversion < 2013092000) {
|
||||
|
||||
// Define table question_statistics to be dropped.
|
||||
$table = new xmldb_table('quiz_question_statistics');
|
||||
|
||||
// Conditionally launch drop table for question_statistics.
|
||||
if ($dbman->table_exists($table)) {
|
||||
$dbman->drop_table($table);
|
||||
}
|
||||
|
||||
// Define table question_response_analysis to be dropped.
|
||||
$table = new xmldb_table('quiz_question_response_stats');
|
||||
|
||||
// Conditionally launch drop table for question_response_analysis.
|
||||
if ($dbman->table_exists($table)) {
|
||||
$dbman->drop_table($table);
|
||||
}
|
||||
|
||||
$table = new xmldb_table('quiz_statistics');
|
||||
$field = new xmldb_field('quizid');
|
||||
|
||||
if ($dbman->field_exists($table, $field)) {
|
||||
$dbman->drop_field($table, $field);
|
||||
}
|
||||
|
||||
$field = new xmldb_field('groupid');
|
||||
|
||||
if ($dbman->field_exists($table, $field)) {
|
||||
$dbman->drop_field($table, $field);
|
||||
}
|
||||
|
||||
$field = new xmldb_field('hashcode', XMLDB_TYPE_CHAR, '40', null, XMLDB_NOTNULL, null, null, 'id');
|
||||
|
||||
if (!$dbman->field_exists($table, $field)) {
|
||||
$dbman->add_field($table, $field);
|
||||
}
|
||||
|
||||
// Main savepoint reached.
|
||||
upgrade_plugin_savepoint(true, 2013092000, 'quiz', 'statistics');
|
||||
}
|
||||
|
||||
if ($oldversion < 2013093000) {
|
||||
// Define table quiz_statistics to be dropped.
|
||||
$table = new xmldb_table('quiz_statistics');
|
||||
|
||||
// Conditionally launch drop table for quiz_statistics.
|
||||
if ($dbman->table_exists($table)) {
|
||||
$dbman->drop_table($table);
|
||||
}
|
||||
|
||||
// Define table quiz_statistics to be created.
|
||||
$table = new xmldb_table('quiz_statistics');
|
||||
|
||||
// Adding fields to table quiz_statistics.
|
||||
$table->add_field('id', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
|
||||
$table->add_field('hashcode', XMLDB_TYPE_CHAR, '40', null, XMLDB_NOTNULL, null, null);
|
||||
$table->add_field('whichattempts', XMLDB_TYPE_INTEGER, '4', null, XMLDB_NOTNULL, null, null);
|
||||
$table->add_field('timemodified', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null);
|
||||
$table->add_field('firstattemptscount', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null);
|
||||
$table->add_field('highestattemptscount', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null);
|
||||
$table->add_field('lastattemptscount', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null);
|
||||
$table->add_field('allattemptscount', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null);
|
||||
$table->add_field('firstattemptsavg', XMLDB_TYPE_NUMBER, '15, 5', null, null, null, null);
|
||||
$table->add_field('highestattemptsavg', XMLDB_TYPE_NUMBER, '15, 5', null, null, null, null);
|
||||
$table->add_field('lastattemptsavg', XMLDB_TYPE_NUMBER, '15, 5', null, null, null, null);
|
||||
$table->add_field('allattemptsavg', XMLDB_TYPE_NUMBER, '15, 5', null, null, null, null);
|
||||
$table->add_field('median', XMLDB_TYPE_NUMBER, '15, 5', null, null, null, null);
|
||||
$table->add_field('standarddeviation', XMLDB_TYPE_NUMBER, '15, 5', null, null, null, null);
|
||||
$table->add_field('skewness', XMLDB_TYPE_NUMBER, '15, 10', null, null, null, null);
|
||||
$table->add_field('kurtosis', XMLDB_TYPE_NUMBER, '15, 5', null, null, null, null);
|
||||
$table->add_field('cic', XMLDB_TYPE_NUMBER, '15, 10', null, null, null, null);
|
||||
$table->add_field('errorratio', XMLDB_TYPE_NUMBER, '15, 10', null, null, null, null);
|
||||
$table->add_field('standarderror', XMLDB_TYPE_NUMBER, '15, 10', null, null, null, null);
|
||||
|
||||
// Adding keys to table quiz_statistics.
|
||||
$table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
|
||||
|
||||
// Conditionally launch create table for quiz_statistics.
|
||||
if (!$dbman->table_exists($table)) {
|
||||
$dbman->create_table($table);
|
||||
}
|
||||
|
||||
// Statistics savepoint reached.
|
||||
upgrade_plugin_savepoint(true, 2013093000, 'quiz', 'statistics');
|
||||
}
|
||||
|
||||
// Moodle v2.6.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Moodle v2.7.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
global $CFG;
|
||||
|
||||
// Moodle v2.8.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
@ -147,4 +41,3 @@ function xmldb_quiz_statistics_upgrade($oldversion) {
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
@ -46,31 +45,7 @@
|
||||
defined('MOODLE_INTERNAL') || die;
|
||||
|
||||
function xmldb_resource_upgrade($oldversion) {
|
||||
global $CFG, $DB;
|
||||
|
||||
$dbman = $DB->get_manager();
|
||||
|
||||
|
||||
// Moodle v2.2.0 release upgrade line
|
||||
// Put any upgrade step following this
|
||||
|
||||
// Moodle v2.3.0 release upgrade line
|
||||
// Put any upgrade step following this
|
||||
|
||||
|
||||
// Moodle v2.4.0 release upgrade line
|
||||
// Put any upgrade step following this
|
||||
|
||||
|
||||
// Moodle v2.5.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
|
||||
// Moodle v2.6.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Moodle v2.7.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
global $CFG;
|
||||
|
||||
// Moodle v2.8.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
@ -22,6 +22,7 @@
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
/**
|
||||
* @global moodle_database $DB
|
||||
@ -33,252 +34,6 @@ function xmldb_scorm_upgrade($oldversion) {
|
||||
|
||||
$dbman = $DB->get_manager();
|
||||
|
||||
|
||||
// Moodle v2.2.0 release upgrade line
|
||||
// Put any upgrade step following this
|
||||
|
||||
if ($oldversion < 2012032100) {
|
||||
unset_config('updatetime', 'scorm');
|
||||
upgrade_mod_savepoint(true, 2012032100, 'scorm');
|
||||
}
|
||||
|
||||
// Adding completion fields to scorm table
|
||||
if ($oldversion < 2012032101) {
|
||||
$table = new xmldb_table('scorm');
|
||||
|
||||
$field = new xmldb_field('completionstatusrequired', XMLDB_TYPE_INTEGER, '1', XMLDB_UNSIGNED, null, null, null, 'timemodified');
|
||||
if (!$dbman->field_exists($table, $field)) {
|
||||
$dbman->add_field($table, $field);
|
||||
}
|
||||
|
||||
$field = new xmldb_field('completionscorerequired', XMLDB_TYPE_INTEGER, '2', XMLDB_UNSIGNED, null, null, null, 'completionstatusrequired');
|
||||
if (!$dbman->field_exists($table, $field)) {
|
||||
$dbman->add_field($table, $field);
|
||||
}
|
||||
|
||||
upgrade_mod_savepoint(true, 2012032101, 'scorm');
|
||||
}
|
||||
|
||||
// Moodle v2.3.0 release upgrade line
|
||||
// Put any upgrade step following this
|
||||
|
||||
//rename config var from maxattempts to maxattempt
|
||||
if ($oldversion < 2012061701) {
|
||||
$maxattempts = get_config('scorm', 'maxattempts');
|
||||
$maxattempts_adv = get_config('scorm', 'maxattempts_adv');
|
||||
set_config('maxattempt', $maxattempts, 'scorm');
|
||||
set_config('maxattempt_adv', $maxattempts_adv, 'scorm');
|
||||
|
||||
unset_config('maxattempts', 'scorm'); //remove old setting.
|
||||
unset_config('maxattempts_adv', 'scorm'); //remove old setting.
|
||||
upgrade_mod_savepoint(true, 2012061701, 'scorm');
|
||||
}
|
||||
|
||||
|
||||
// Moodle v2.4.0 release upgrade line
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Moodle v2.5.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Remove old imsrepository type - convert any existing records to external type to help prevent major errors.
|
||||
if ($oldversion < 2013081301) {
|
||||
require_once($CFG->dirroot . '/mod/scorm/lib.php');
|
||||
$scorms = $DB->get_recordset('scorm', array('scormtype' => 'imsrepository'));
|
||||
foreach ($scorms as $scorm) {
|
||||
$scorm->scormtype = SCORM_TYPE_EXTERNAL;
|
||||
if (!empty($CFG->repository)) { // Fix path to imsmanifest if $CFG->repository is set.
|
||||
$scorm->reference = $CFG->repository.substr($scorm->reference, 1).'/imsmanifest.xml';
|
||||
$scorm->sha1hash = sha1($scorm->reference);
|
||||
}
|
||||
$scorm->revision++;
|
||||
$DB->update_record('scorm', $scorm);
|
||||
}
|
||||
upgrade_mod_savepoint(true, 2013081301, 'scorm');
|
||||
}
|
||||
|
||||
// Fix AICC parent/child relationships (MDL-37394).
|
||||
if ($oldversion < 2013081302) {
|
||||
// Get all AICC packages.
|
||||
$aiccpackages = $DB->get_recordset('scorm', array('version' => 'AICC'), '', 'id');
|
||||
foreach ($aiccpackages as $aicc) {
|
||||
$sql = "UPDATE {scorm_scoes}
|
||||
SET parent = organization
|
||||
WHERE scorm = ?
|
||||
AND " . $DB->sql_isempty('scorm_scoes', 'manifest', false, false) . "
|
||||
AND " . $DB->sql_isnotempty('scorm_scoes', 'organization', false, false) . "
|
||||
AND parent = '/'";
|
||||
$DB->execute($sql, array($aicc->id));
|
||||
}
|
||||
$aiccpackages->close();
|
||||
upgrade_mod_savepoint(true, 2013081302, 'scorm');
|
||||
}
|
||||
|
||||
if ($oldversion < 2013081303) {
|
||||
|
||||
// Define field sortorder to be added to scorm_scoes.
|
||||
$table = new xmldb_table('scorm_scoes');
|
||||
$field = new xmldb_field('sortorder', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, '0', 'title');
|
||||
|
||||
// Conditionally launch add field sortorder.
|
||||
if (!$dbman->field_exists($table, $field)) {
|
||||
$dbman->add_field($table, $field);
|
||||
}
|
||||
|
||||
// Scorm savepoint reached.
|
||||
upgrade_mod_savepoint(true, 2013081303, 'scorm');
|
||||
}
|
||||
|
||||
if ($oldversion < 2013090100) {
|
||||
global $CFG;
|
||||
$table = new xmldb_table('scorm');
|
||||
|
||||
$field = new xmldb_field('nav', XMLDB_TYPE_INTEGER, '1', XMLDB_UNSIGNED, true, null, 1, 'hidetoc');
|
||||
if (!$dbman->field_exists($table, $field)) {
|
||||
$dbman->add_field($table, $field);
|
||||
}
|
||||
|
||||
$field = new xmldb_field('navpositionleft', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, null, null, -100, 'nav');
|
||||
if (!$dbman->field_exists($table, $field)) {
|
||||
$dbman->add_field($table, $field);
|
||||
}
|
||||
|
||||
$field = new xmldb_field('navpositiontop', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, null, null, -100, 'navpositionleft');
|
||||
if (!$dbman->field_exists($table, $field)) {
|
||||
$dbman->add_field($table, $field);
|
||||
}
|
||||
|
||||
$field = new xmldb_field('hidenav');
|
||||
if ($dbman->field_exists($table, $field)) {
|
||||
// Update nav setting to show floating navigation buttons under TOC.
|
||||
$DB->set_field('scorm', 'nav', 2, array('hidenav' => 0));
|
||||
$DB->set_field('scorm', 'navpositionleft', 215, array('hidenav' => 2));
|
||||
$DB->set_field('scorm', 'navpositiontop', 300, array('hidenav' => 2));
|
||||
|
||||
// Update nav setting to disable navigation buttons.
|
||||
$DB->set_field('scorm', 'nav', 0, array('hidenav' => 1));
|
||||
// Drop hidenav field.
|
||||
$dbman->drop_field($table, $field);
|
||||
}
|
||||
|
||||
$hide = get_config('scorm', 'hidenav');
|
||||
unset_config('hidenav', 'scorm');
|
||||
if (!empty($hide)) {
|
||||
require_once($CFG->dirroot . '/mod/scorm/lib.php');
|
||||
set_config('nav', SCORM_NAV_DISABLED, 'scorm');
|
||||
}
|
||||
|
||||
$hideadv = get_config('scorm', 'hidenav_adv');
|
||||
unset_config('hidenav_adv', 'scorm');
|
||||
set_config('nav_adv', $hideadv, 'scorm');
|
||||
|
||||
upgrade_mod_savepoint(true, 2013090100, 'scorm');
|
||||
}
|
||||
|
||||
// Moodle v2.6.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
if ($oldversion < 2013110501) {
|
||||
// Fix invalid $scorm->launch records.
|
||||
// Get all scorms that have a launch value that references a sco from a different scorm.
|
||||
$sql = "SELECT s.*
|
||||
FROM {scorm} s
|
||||
LEFT JOIN {scorm_scoes} c ON s.launch = c.id
|
||||
WHERE c.id IS null OR s.id <> c.scorm";
|
||||
$scorms = $DB->get_recordset_sql($sql);
|
||||
foreach ($scorms as $scorm) {
|
||||
// Find the first launchable sco for this SCORM.
|
||||
// This scorm has an invalid launch param - we need to calculate it and get the first launchable sco.
|
||||
$sqlselect = 'scorm = ? AND '.$DB->sql_isnotempty('scorm_scoes', 'launch', false, true);
|
||||
// We use get_records here as we need to pass a limit in the query that works cross db.
|
||||
$scoes = $DB->get_records_select('scorm_scoes', $sqlselect, array($scorm->id), 'sortorder', 'id', 0, 1);
|
||||
if (!empty($scoes)) {
|
||||
$sco = reset($scoes); // We only care about the first record - the above query only returns one.
|
||||
$scorm->launch = $sco->id;
|
||||
$DB->update_record('scorm', $scorm);
|
||||
}
|
||||
}
|
||||
$scorms->close();
|
||||
|
||||
upgrade_mod_savepoint(true, 2013110501, 'scorm');
|
||||
}
|
||||
|
||||
if ($oldversion < 2014031700) {
|
||||
// Define field displayactivityname to be added to scorm.
|
||||
$table = new xmldb_table('scorm');
|
||||
$field = new xmldb_field(
|
||||
'displayactivityname',
|
||||
XMLDB_TYPE_INTEGER,
|
||||
'4',
|
||||
null,
|
||||
XMLDB_NOTNULL,
|
||||
null,
|
||||
'1',
|
||||
'completionscorerequired'
|
||||
);
|
||||
|
||||
// Conditionally launch add field displayactivityname.
|
||||
if (!$dbman->field_exists($table, $field)) {
|
||||
$dbman->add_field($table, $field);
|
||||
}
|
||||
|
||||
// Scorm savepoint reached.
|
||||
upgrade_mod_savepoint(true, 2014031700, 'scorm');
|
||||
}
|
||||
|
||||
if ($oldversion < 2014040200) {
|
||||
// Fix invalid $scorm->launch records that launch an org sco instead of a real sco.
|
||||
$sql = "SELECT s.*, c.identifier
|
||||
FROM {scorm} s
|
||||
LEFT JOIN {scorm_scoes} c ON s.launch = c.id
|
||||
WHERE ".$DB->sql_isempty('scorm_scoes', 'c.launch', false, true);
|
||||
$scorms = $DB->get_recordset_sql($sql);
|
||||
foreach ($scorms as $scorm) {
|
||||
upgrade_set_timeout(60); // Increase execution time just in case. (60 sec is minimum but prob excessive here).
|
||||
$originallaunch = $scorm->launch;
|
||||
// Find the first sco using the current identifier as it's parent
|
||||
// we use get records here as we need to pass a limit in the query that works cross db.
|
||||
$firstsco = $DB->get_records('scorm_scoes',
|
||||
array('scorm' => $scorm->id, 'parent' => $scorm->identifier), 'sortorder', '*', 0, 1);
|
||||
if (!empty($firstsco)) {
|
||||
$firstsco = reset($firstsco);
|
||||
}
|
||||
if (!empty($firstsco->launch)) {
|
||||
// Usual behavior - this is a valid sco with a launch param so use it.
|
||||
$scorm->launch = $firstsco->id;
|
||||
} else {
|
||||
// The firstsco found is not launchable - find the first launchable sco after this sco.
|
||||
$sqlselect = 'scorm = ? AND sortorder > ? AND '.$DB->sql_isnotempty('scorm_scoes', 'launch', false, true);
|
||||
// We use get_records here as we need to pass a limit in the query that works cross db.
|
||||
$scoes = $DB->get_records_select('scorm_scoes', $sqlselect,
|
||||
array($scorm->id, $firstsco->sortorder), 'sortorder', 'id', 0, 1);
|
||||
if (!empty($scoes)) {
|
||||
$sco = reset($scoes); // We only care about the first record - the above query only returns one.
|
||||
$scorm->launch = $sco->id;
|
||||
} else {
|
||||
// This is an invalid package - it has a default org that doesn't contain a launchable sco.
|
||||
// Check for any valid sco with a launch param.
|
||||
$sqlselect = 'scorm = ? AND '.$DB->sql_isnotempty('scorm_scoes', 'launch', false, true);
|
||||
// We use get_records here as we need to pass a limit in the query that works cross db.
|
||||
$scoes = $DB->get_records_select('scorm_scoes', $sqlselect, array($scorm->id), 'sortorder', 'id', 0, 1);
|
||||
if (!empty($scoes)) {
|
||||
$sco = reset($scoes); // We only care about the first record - the above query only returns one.
|
||||
$scorm->launch = $sco->id;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($originallaunch != $scorm->launch) {
|
||||
$DB->update_record('scorm', $scorm);
|
||||
}
|
||||
}
|
||||
$scorms->close();
|
||||
|
||||
upgrade_mod_savepoint(true, 2014040200, 'scorm');
|
||||
}
|
||||
|
||||
// Moodle v2.7.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
if ($oldversion < 2014072500) {
|
||||
|
||||
// Define field autocommit to be added to scorm.
|
||||
@ -340,5 +95,3 @@ function xmldb_scorm_upgrade($oldversion) {
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
// This file keeps track of upgrades to
|
||||
// the survey module
|
||||
//
|
||||
@ -20,32 +19,10 @@
|
||||
// Please do not forget to use upgrade_set_timeout()
|
||||
// before any action that may take longer time to finish.
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
function xmldb_survey_upgrade($oldversion) {
|
||||
global $CFG, $DB;
|
||||
|
||||
$dbman = $DB->get_manager();
|
||||
|
||||
|
||||
// Moodle v2.2.0 release upgrade line
|
||||
// Put any upgrade step following this
|
||||
|
||||
// Moodle v2.3.0 release upgrade line
|
||||
// Put any upgrade step following this
|
||||
|
||||
|
||||
// Moodle v2.4.0 release upgrade line
|
||||
// Put any upgrade step following this
|
||||
|
||||
|
||||
// Moodle v2.5.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
|
||||
// Moodle v2.6.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Moodle v2.7.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
global $CFG;
|
||||
|
||||
// Moodle v2.8.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
@ -58,5 +35,3 @@ function xmldb_survey_upgrade($oldversion) {
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
@ -46,31 +45,7 @@
|
||||
defined('MOODLE_INTERNAL') || die;
|
||||
|
||||
function xmldb_url_upgrade($oldversion) {
|
||||
global $CFG, $DB;
|
||||
|
||||
$dbman = $DB->get_manager();
|
||||
|
||||
|
||||
// Moodle v2.2.0 release upgrade line
|
||||
// Put any upgrade step following this
|
||||
|
||||
// Moodle v2.3.0 release upgrade line
|
||||
// Put any upgrade step following this
|
||||
|
||||
|
||||
// Moodle v2.4.0 release upgrade line
|
||||
// Put any upgrade step following this
|
||||
|
||||
|
||||
// Moodle v2.5.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
|
||||
// Moodle v2.6.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Moodle v2.7.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
global $CFG;
|
||||
|
||||
// Moodle v2.8.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
@ -9,11 +8,11 @@
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* This file keeps track of upgrades to the wiki module
|
||||
@ -36,53 +35,10 @@
|
||||
*
|
||||
*/
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
function xmldb_wiki_upgrade($oldversion) {
|
||||
global $CFG, $DB, $OUTPUT;
|
||||
|
||||
$dbman = $DB->get_manager();
|
||||
|
||||
|
||||
// Moodle v2.2.0 release upgrade line
|
||||
// Put any upgrade step following this
|
||||
|
||||
// Moodle v2.3.0 release upgrade line
|
||||
// Put any upgrade step following this
|
||||
|
||||
if ($oldversion < 2012061701) {
|
||||
// Drop all legacy upgrade tables, not used anymore.
|
||||
|
||||
$table = new xmldb_table('wiki_entries_old');
|
||||
if ($dbman->table_exists('wiki_entries_old')) {
|
||||
$dbman->drop_table($table);
|
||||
}
|
||||
|
||||
$table = new xmldb_table('wiki_locks_old');
|
||||
if ($dbman->table_exists('wiki_locks_old')) {
|
||||
$dbman->drop_table($table);
|
||||
}
|
||||
|
||||
$table = new xmldb_table('wiki_pages_old');
|
||||
if ($dbman->table_exists('wiki_pages_old')) {
|
||||
$dbman->drop_table($table);
|
||||
}
|
||||
|
||||
upgrade_plugin_savepoint(true, 2012061701, 'mod', 'wiki');
|
||||
}
|
||||
|
||||
|
||||
// Moodle v2.4.0 release upgrade line
|
||||
// Put any upgrade step following this
|
||||
|
||||
|
||||
// Moodle v2.5.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
|
||||
// Moodle v2.6.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Moodle v2.7.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
global $CFG;
|
||||
|
||||
// Moodle v2.8.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
@ -24,6 +23,8 @@
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
/**
|
||||
* Performs upgrade of the database structure and data
|
||||
*
|
||||
@ -34,131 +35,7 @@
|
||||
* @return bool result
|
||||
*/
|
||||
function xmldb_workshop_upgrade($oldversion) {
|
||||
global $CFG, $DB, $OUTPUT;
|
||||
|
||||
$dbman = $DB->get_manager();
|
||||
|
||||
// Moodle v2.2.0 release upgrade line
|
||||
|
||||
if ($oldversion < 2012033100) {
|
||||
// add the field 'phaseswitchassessment' to the 'workshop' table
|
||||
$table = new xmldb_table('workshop');
|
||||
$field = new xmldb_field('phaseswitchassessment', XMLDB_TYPE_INTEGER, '2', null, XMLDB_NOTNULL, null, '0', 'assessmentend');
|
||||
if (!$dbman->field_exists($table, $field)) {
|
||||
$dbman->add_field($table, $field);
|
||||
}
|
||||
upgrade_mod_savepoint(true, 2012033100, 'workshop');
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove all workshop calendar events
|
||||
*/
|
||||
if ($oldversion < 2012041700) {
|
||||
require_once($CFG->dirroot . '/calendar/lib.php');
|
||||
$events = $DB->get_records('event', array('modulename' => 'workshop'));
|
||||
foreach ($events as $event) {
|
||||
$event = calendar_event::load($event);
|
||||
$event->delete();
|
||||
}
|
||||
upgrade_mod_savepoint(true, 2012041700, 'workshop');
|
||||
}
|
||||
|
||||
/**
|
||||
* Recreate all workshop calendar events
|
||||
*/
|
||||
if ($oldversion < 2012041701) {
|
||||
require_once(dirname(dirname(__FILE__)) . '/lib.php');
|
||||
|
||||
$sql = "SELECT w.id, w.course, w.name, w.intro, w.introformat, w.submissionstart,
|
||||
w.submissionend, w.assessmentstart, w.assessmentend,
|
||||
cm.id AS cmid
|
||||
FROM {workshop} w
|
||||
JOIN {modules} m ON m.name = 'workshop'
|
||||
JOIN {course_modules} cm ON (cm.module = m.id AND cm.course = w.course AND cm.instance = w.id)";
|
||||
|
||||
$rs = $DB->get_recordset_sql($sql);
|
||||
|
||||
foreach ($rs as $workshop) {
|
||||
$cmid = $workshop->cmid;
|
||||
unset($workshop->cmid);
|
||||
workshop_calendar_update($workshop, $cmid);
|
||||
}
|
||||
$rs->close();
|
||||
upgrade_mod_savepoint(true, 2012041701, 'workshop');
|
||||
}
|
||||
|
||||
// Moodle v2.3.0 release upgrade line
|
||||
|
||||
/**
|
||||
* Add new fields conclusion and conclusionformat
|
||||
*/
|
||||
if ($oldversion < 2012102400) {
|
||||
$table = new xmldb_table('workshop');
|
||||
|
||||
$field = new xmldb_field('conclusion', XMLDB_TYPE_TEXT, null, null, null, null, null, 'phaseswitchassessment');
|
||||
if (!$dbman->field_exists($table, $field)) {
|
||||
$dbman->add_field($table, $field);
|
||||
}
|
||||
|
||||
$field = new xmldb_field('conclusionformat', XMLDB_TYPE_INTEGER, '3', null, XMLDB_NOTNULL, null, '1', 'conclusion');
|
||||
if (!$dbman->field_exists($table, $field)) {
|
||||
$dbman->add_field($table, $field);
|
||||
}
|
||||
|
||||
upgrade_mod_savepoint(true, 2012102400, 'workshop');
|
||||
}
|
||||
|
||||
|
||||
// Moodle v2.4.0 release upgrade line
|
||||
// Put any upgrade step following this
|
||||
|
||||
/**
|
||||
* Add overall feedback related fields into the workshop table.
|
||||
*/
|
||||
if ($oldversion < 2013032500) {
|
||||
$table = new xmldb_table('workshop');
|
||||
|
||||
$field = new xmldb_field('overallfeedbackmode', XMLDB_TYPE_INTEGER, '3', null, null, null, '1', 'conclusionformat');
|
||||
if (!$dbman->field_exists($table, $field)) {
|
||||
$dbman->add_field($table, $field);
|
||||
}
|
||||
|
||||
$field = new xmldb_field('overallfeedbackfiles', XMLDB_TYPE_INTEGER, '3', null, null, null, '0', 'overallfeedbackmode');
|
||||
if (!$dbman->field_exists($table, $field)) {
|
||||
$dbman->add_field($table, $field);
|
||||
}
|
||||
|
||||
$field = new xmldb_field('overallfeedbackmaxbytes', XMLDB_TYPE_INTEGER, '10', null, null, null, '100000', 'overallfeedbackfiles');
|
||||
if (!$dbman->field_exists($table, $field)) {
|
||||
$dbman->add_field($table, $field);
|
||||
}
|
||||
|
||||
upgrade_mod_savepoint(true, 2013032500, 'workshop');
|
||||
}
|
||||
|
||||
/**
|
||||
* Add feedbackauthorattachment field into the workshop_assessments table.
|
||||
*/
|
||||
if ($oldversion < 2013032501) {
|
||||
$table = new xmldb_table('workshop_assessments');
|
||||
$field = new xmldb_field('feedbackauthorattachment', XMLDB_TYPE_INTEGER, '3', null, null, null, '0', 'feedbackauthorformat');
|
||||
if (!$dbman->field_exists($table, $field)) {
|
||||
$dbman->add_field($table, $field);
|
||||
}
|
||||
|
||||
upgrade_mod_savepoint(true, 2013032501, 'workshop');
|
||||
}
|
||||
|
||||
|
||||
// Moodle v2.5.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
|
||||
// Moodle v2.6.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Moodle v2.7.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
global $CFG;
|
||||
|
||||
// Moodle v2.8.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
@ -23,6 +22,8 @@
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
/**
|
||||
* Performs upgrade of the database structure and data
|
||||
*
|
||||
@ -30,31 +31,7 @@
|
||||
* @return bool true
|
||||
*/
|
||||
function xmldb_workshopform_accumulative_upgrade($oldversion) {
|
||||
global $CFG, $DB, $OUTPUT;
|
||||
|
||||
$dbman = $DB->get_manager();
|
||||
|
||||
|
||||
// Moodle v2.2.0 release upgrade line
|
||||
// Put any upgrade step following this
|
||||
|
||||
// Moodle v2.3.0 release upgrade line
|
||||
// Put any upgrade step following this
|
||||
|
||||
|
||||
// Moodle v2.4.0 release upgrade line
|
||||
// Put any upgrade step following this
|
||||
|
||||
|
||||
// Moodle v2.5.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
|
||||
// Moodle v2.6.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Moodle v2.7.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
global $CFG;
|
||||
|
||||
// Moodle v2.8.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
@ -23,6 +22,8 @@
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
/**
|
||||
* Performs upgrade of the database structure and data
|
||||
*
|
||||
@ -30,31 +31,7 @@
|
||||
* @return bool true
|
||||
*/
|
||||
function xmldb_workshopform_comments_upgrade($oldversion) {
|
||||
global $CFG, $DB, $OUTPUT;
|
||||
|
||||
$dbman = $DB->get_manager();
|
||||
|
||||
|
||||
// Moodle v2.2.0 release upgrade line
|
||||
// Put any upgrade step following this
|
||||
|
||||
// Moodle v2.3.0 release upgrade line
|
||||
// Put any upgrade step following this
|
||||
|
||||
|
||||
// Moodle v2.4.0 release upgrade line
|
||||
// Put any upgrade step following this
|
||||
|
||||
|
||||
// Moodle v2.5.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
|
||||
// Moodle v2.6.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Moodle v2.7.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
global $CFG;
|
||||
|
||||
// Moodle v2.8.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
@ -23,6 +22,8 @@
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
/**
|
||||
* Performs upgrade of the database structure and data
|
||||
*
|
||||
@ -30,31 +31,7 @@
|
||||
* @return bool true
|
||||
*/
|
||||
function xmldb_workshopform_numerrors_upgrade($oldversion) {
|
||||
global $CFG, $DB, $OUTPUT;
|
||||
|
||||
$dbman = $DB->get_manager();
|
||||
|
||||
|
||||
// Moodle v2.2.0 release upgrade line
|
||||
// Put any upgrade step following this
|
||||
|
||||
// Moodle v2.3.0 release upgrade line
|
||||
// Put any upgrade step following this
|
||||
|
||||
|
||||
// Moodle v2.4.0 release upgrade line
|
||||
// Put any upgrade step following this
|
||||
|
||||
|
||||
// Moodle v2.5.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
|
||||
// Moodle v2.6.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Moodle v2.7.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
global $CFG;
|
||||
|
||||
// Moodle v2.8.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
@ -23,6 +22,8 @@
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
/**
|
||||
* Performs upgrade of the database structure and data
|
||||
*
|
||||
@ -30,31 +31,7 @@
|
||||
* @return bool true
|
||||
*/
|
||||
function xmldb_workshopform_rubric_upgrade($oldversion) {
|
||||
global $CFG, $DB, $OUTPUT;
|
||||
|
||||
$dbman = $DB->get_manager();
|
||||
|
||||
|
||||
// Moodle v2.2.0 release upgrade line
|
||||
// Put any upgrade step following this
|
||||
|
||||
// Moodle v2.3.0 release upgrade line
|
||||
// Put any upgrade step following this
|
||||
|
||||
|
||||
// Moodle v2.4.0 release upgrade line
|
||||
// Put any upgrade step following this
|
||||
|
||||
|
||||
// Moodle v2.5.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
|
||||
// Moodle v2.6.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Moodle v2.7.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
global $CFG;
|
||||
|
||||
// Moodle v2.8.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
@ -31,38 +31,7 @@ defined('MOODLE_INTERNAL') || die();
|
||||
* @return bool result
|
||||
*/
|
||||
function xmldb_portfolio_boxnet_upgrade($oldversion) {
|
||||
global $CFG, $DB;
|
||||
|
||||
$dbman = $DB->get_manager();
|
||||
|
||||
if ($oldversion < 2013110602) {
|
||||
require_once($CFG->libdir . '/portfoliolib.php');
|
||||
require_once($CFG->dirroot . '/portfolio/boxnet/db/upgradelib.php');
|
||||
|
||||
$existing = $DB->get_record('portfolio_instance', array('plugin' => 'boxnet'), '*', IGNORE_MULTIPLE);
|
||||
if ($existing) {
|
||||
|
||||
// Only disable or message the admins when the portfolio hasn't been set for APIv2.
|
||||
$instance = portfolio_instance($existing->id, $existing);
|
||||
if ($instance->get_config('clientid') === null && $instance->get_config('clientsecret') === null) {
|
||||
|
||||
// Disable Box.net.
|
||||
$instance->set('visible', 0);
|
||||
$instance->save();
|
||||
|
||||
// Message the admins.
|
||||
portfolio_boxnet_admin_upgrade_notification();
|
||||
}
|
||||
}
|
||||
|
||||
upgrade_plugin_savepoint(true, 2013110602, 'portfolio', 'boxnet');
|
||||
}
|
||||
|
||||
// Moodle v2.6.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Moodle v2.7.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
global $CFG;
|
||||
|
||||
// Moodle v2.8.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
@ -14,49 +14,14 @@
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
/**
|
||||
* @param int $oldversion the version we are upgrading from
|
||||
* @return bool result
|
||||
*/
|
||||
function xmldb_portfolio_googledocs_upgrade($oldversion) {
|
||||
global $CFG, $DB;
|
||||
require_once(__DIR__.'/upgradelib.php');
|
||||
|
||||
$dbman = $DB->get_manager();
|
||||
|
||||
if ($oldversion < 2012053000) {
|
||||
// Delete old user preferences containing authsub tokens.
|
||||
$DB->delete_records('user_preferences', array('name' => 'google_authsub_sesskey'));
|
||||
upgrade_plugin_savepoint(true, 2012053000, 'portfolio', 'googledocs');
|
||||
}
|
||||
|
||||
if ($oldversion < 2012053001) {
|
||||
$existing = $DB->get_record('portfolio_instance', array('plugin' => 'googledocs'), '*', IGNORE_MULTIPLE);
|
||||
|
||||
if ($existing) {
|
||||
portfolio_googledocs_admin_upgrade_notification();
|
||||
}
|
||||
|
||||
upgrade_plugin_savepoint(true, 2012053001, 'portfolio', 'googledocs');
|
||||
}
|
||||
|
||||
// Moodle v2.3.0 release upgrade line
|
||||
// Put any upgrade step following this
|
||||
|
||||
|
||||
// Moodle v2.4.0 release upgrade line
|
||||
// Put any upgrade step following this
|
||||
|
||||
|
||||
// Moodle v2.5.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
|
||||
// Moodle v2.6.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Moodle v2.7.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
global $CFG;
|
||||
|
||||
// Moodle v2.8.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
@ -14,49 +14,14 @@
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
/**
|
||||
* @param int $oldversion the version we are upgrading from
|
||||
* @return bool result
|
||||
*/
|
||||
function xmldb_portfolio_picasa_upgrade($oldversion) {
|
||||
global $CFG, $DB;
|
||||
require_once(__DIR__.'/upgradelib.php');
|
||||
|
||||
$dbman = $DB->get_manager();
|
||||
|
||||
if ($oldversion < 2012053000) {
|
||||
// Delete old user preferences containing authsub tokens.
|
||||
$DB->delete_records('user_preferences', array('name' => 'google_authsub_sesskey_picasa'));
|
||||
upgrade_plugin_savepoint(true, 2012053000, 'portfolio', 'picasa');
|
||||
}
|
||||
|
||||
if ($oldversion < 2012053001) {
|
||||
$existing = $DB->get_record('portfolio_instance', array('plugin' => 'picasa'), '*', IGNORE_MISSING);
|
||||
|
||||
if ($existing) {
|
||||
portfolio_picasa_admin_upgrade_notification();
|
||||
}
|
||||
|
||||
upgrade_plugin_savepoint(true, 2012053001, 'portfolio', 'picasa');
|
||||
}
|
||||
|
||||
// Moodle v2.3.0 release upgrade line
|
||||
// Put any upgrade step following this
|
||||
|
||||
|
||||
// Moodle v2.4.0 release upgrade line
|
||||
// Put any upgrade step following this
|
||||
|
||||
|
||||
// Moodle v2.5.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
|
||||
// Moodle v2.6.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Moodle v2.7.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
global $CFG;
|
||||
|
||||
// Moodle v2.8.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
@ -22,79 +22,13 @@
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
|
||||
/**
|
||||
* Manual graded question behaviour upgrade code.
|
||||
*/
|
||||
function xmldb_qbehaviour_manualgraded_upgrade($oldversion) {
|
||||
global $CFG, $DB;
|
||||
|
||||
$dbman = $DB->get_manager();
|
||||
|
||||
// Moodle v2.4.0 release upgrade line
|
||||
// Put any upgrade step following this
|
||||
|
||||
if ($oldversion < 2013050200) {
|
||||
// Hide the manualgraded behaviour from the list of behaviours that users
|
||||
// can select in the user-interface. If a user accidentally chooses manual
|
||||
// graded behaviour for a quiz, there is no way to get the questions automatically
|
||||
// graded after the student has answered them. If teachers really want to do
|
||||
// this they can ask their admin to enable it on the manage behaviours
|
||||
// screen in the UI.
|
||||
$disabledbehaviours = get_config('question', 'disabledbehaviours');
|
||||
if (!empty($disabledbehaviours)) {
|
||||
$disabledbehaviours = explode(',', $disabledbehaviours);
|
||||
} else {
|
||||
$disabledbehaviours = array();
|
||||
}
|
||||
if (array_search('manualgraded', $disabledbehaviours) === false) {
|
||||
$disabledbehaviours[] = 'manualgraded';
|
||||
set_config('disabledbehaviours', implode(',', $disabledbehaviours), 'question');
|
||||
}
|
||||
|
||||
// Manual graded question behaviour savepoint reached.
|
||||
upgrade_plugin_savepoint(true, 2013050200, 'qbehaviour', 'manualgraded');
|
||||
}
|
||||
|
||||
if ($oldversion < 2013050800) {
|
||||
// Also, fix any other admin settings that currently select manualgraded behaviour.
|
||||
|
||||
// Work out a sensible default alternative to manualgraded.
|
||||
require_once($CFG->libdir . '/questionlib.php');
|
||||
$behaviours = question_engine::get_behaviour_options('');
|
||||
if (array_key_exists('deferredfeedback', $behaviours)) {
|
||||
$defaultbehaviour = 'deferredfeedback';
|
||||
} else {
|
||||
reset($behaviours);
|
||||
$defaultbehaviour = key($behaviours);
|
||||
}
|
||||
|
||||
// Fix the question preview default.
|
||||
if (get_config('question_preview', 'behaviour') == 'manualgraded') {
|
||||
set_config('behaviour', $defaultbehaviour, 'question_preview');
|
||||
}
|
||||
|
||||
// Fix the quiz settings default.
|
||||
if (get_config('quiz', 'preferredbehaviour') == 'manualgraded') {
|
||||
set_config('preferredbehaviour', $defaultbehaviour, 'quiz');
|
||||
}
|
||||
|
||||
// Manual graded question behaviour savepoint reached.
|
||||
upgrade_plugin_savepoint(true, 2013050800, 'qbehaviour', 'manualgraded');
|
||||
}
|
||||
|
||||
// Moodle v2.5.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
|
||||
// Moodle v2.6.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Moodle v2.7.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
global $CFG;
|
||||
|
||||
// Moodle v2.8.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
@ -107,4 +41,3 @@ function xmldb_qbehaviour_manualgraded_upgrade($oldversion) {
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -23,37 +23,14 @@
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
|
||||
/**
|
||||
* Upgrade code for the calculated question type.
|
||||
* @param int $oldversion the version we are upgrading from.
|
||||
*/
|
||||
function xmldb_qtype_calculated_upgrade($oldversion) {
|
||||
global $CFG, $DB;
|
||||
|
||||
$dbman = $DB->get_manager();
|
||||
|
||||
// Moodle v2.2.0 release upgrade line
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Moodle v2.3.0 release upgrade line
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Moodle v2.4.0 release upgrade line
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Moodle v2.5.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
|
||||
// Moodle v2.6.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Moodle v2.7.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
global $CFG;
|
||||
|
||||
// Moodle v2.8.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
@ -66,5 +43,3 @@ function xmldb_qtype_calculated_upgrade($oldversion) {
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
@ -23,156 +23,14 @@
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
|
||||
/**
|
||||
* Upgrade code for the essay question type.
|
||||
* @param int $oldversion the version we are upgrading from.
|
||||
*/
|
||||
function xmldb_qtype_essay_upgrade($oldversion) {
|
||||
global $CFG, $DB;
|
||||
|
||||
$dbman = $DB->get_manager();
|
||||
|
||||
// Moodle v2.2.0 release upgrade line
|
||||
// Put any upgrade step following this.
|
||||
|
||||
if ($oldversion < 2011102701) {
|
||||
$sql = "
|
||||
FROM {question} q
|
||||
JOIN {question_answers} qa ON qa.question = q.id
|
||||
|
||||
WHERE q.qtype = 'essay'
|
||||
AND " . $DB->sql_isnotempty('question_answers', 'feedback', false, true);
|
||||
// In Moodle <= 2.0 essay had both question.generalfeedback and question_answers.feedback
|
||||
// This was silly, and in Moodel >= 2.1 only question.generalfeedback. To avoid
|
||||
// dataloss, we concatenate question_answers.feedback onto the end of question.generalfeedback.
|
||||
$count = $DB->count_records_sql("
|
||||
SELECT COUNT(1) $sql");
|
||||
if ($count) {
|
||||
$progressbar = new progress_bar('essay23', 500, true);
|
||||
$done = 0;
|
||||
|
||||
$toupdate = $DB->get_recordset_sql("
|
||||
SELECT q.id,
|
||||
q.generalfeedback,
|
||||
q.generalfeedbackformat,
|
||||
qa.feedback,
|
||||
qa.feedbackformat
|
||||
$sql");
|
||||
|
||||
foreach ($toupdate as $data) {
|
||||
$progressbar->update($done, $count, "Updating essay feedback ({$done}/{$count}).");
|
||||
upgrade_set_timeout(60);
|
||||
if ($data->generalfeedbackformat == $data->feedbackformat) {
|
||||
$DB->set_field('question', 'generalfeedback',
|
||||
$data->generalfeedback . $data->feedback,
|
||||
array('id' => $data->id));
|
||||
|
||||
} else {
|
||||
$newdata = new stdClass();
|
||||
$newdata->id = $data->id;
|
||||
$newdata->generalfeedback =
|
||||
qtype_essay_convert_to_html($data->generalfeedback, $data->generalfeedbackformat) .
|
||||
qtype_essay_convert_to_html($data->feedback, $data->feedbackformat);
|
||||
$newdata->generalfeedbackformat = FORMAT_HTML;
|
||||
$DB->update_record('question', $newdata);
|
||||
}
|
||||
}
|
||||
|
||||
$progressbar->update($count, $count, "Updating essay feedback complete!");
|
||||
$toupdate->close();
|
||||
}
|
||||
|
||||
// Essay savepoint reached.
|
||||
upgrade_plugin_savepoint(true, 2011102701, 'qtype', 'essay');
|
||||
}
|
||||
|
||||
if ($oldversion < 2011102702) {
|
||||
// Then we delete the old question_answers rows for essay questions.
|
||||
$DB->delete_records_select('question_answers',
|
||||
"question IN (SELECT id FROM {question} WHERE qtype = 'essay')");
|
||||
|
||||
// Essay savepoint reached.
|
||||
upgrade_plugin_savepoint(true, 2011102702, 'qtype', 'essay');
|
||||
}
|
||||
|
||||
// Moodle v2.3.0 release upgrade line
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Moodle v2.4.0 release upgrade line
|
||||
// Put any upgrade step following this.
|
||||
|
||||
if ($oldversion < 2013011800) {
|
||||
// Then we delete the old question_answers rows for essay questions.
|
||||
$DB->delete_records_select('qtype_essay_options', "NOT EXISTS (
|
||||
SELECT 1 FROM {question} WHERE qtype = 'essay' AND
|
||||
{question}.id = {qtype_essay_options}.questionid)");
|
||||
|
||||
// Essay savepoint reached.
|
||||
upgrade_plugin_savepoint(true, 2013011800, 'qtype', 'essay');
|
||||
}
|
||||
|
||||
if ($oldversion < 2013021700) {
|
||||
// Create new fields responsetemplate and responsetemplateformat in qtyep_essay_options table.
|
||||
$table = new xmldb_table('qtype_essay_options');
|
||||
$field = new xmldb_field('responsetemplate', XMLDB_TYPE_TEXT, null, null,
|
||||
null, null, null, 'graderinfoformat');
|
||||
if (!$dbman->field_exists($table, $field)) {
|
||||
$dbman->add_field($table, $field);
|
||||
}
|
||||
|
||||
$field = new xmldb_field('responsetemplateformat', XMLDB_TYPE_INTEGER, '4',
|
||||
null, XMLDB_NOTNULL, null, '0', 'responsetemplate');
|
||||
if (!$dbman->field_exists($table, $field)) {
|
||||
$dbman->add_field($table, $field);
|
||||
}
|
||||
|
||||
$DB->execute("UPDATE {qtype_essay_options} SET responsetemplate = '',
|
||||
responsetemplateformat = " . FORMAT_HTML . " WHERE responsetemplate IS NULL");
|
||||
|
||||
// Essay savepoint reached.
|
||||
upgrade_plugin_savepoint(true, 2013021700, 'qtype', 'essay');
|
||||
}
|
||||
|
||||
// Moodle v2.5.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Moodle v2.6.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
if ($oldversion < 2014011300) {
|
||||
|
||||
// Create new field responserequired (indicates whether inline response is required).
|
||||
|
||||
$table = new xmldb_table('qtype_essay_options');
|
||||
$field = new xmldb_field('responserequired', XMLDB_TYPE_INTEGER, '2', null, XMLDB_NOTNULL, null, '1', 'responseformat');
|
||||
if (!$dbman->field_exists($table, $field)) {
|
||||
$dbman->add_field($table, $field);
|
||||
}
|
||||
|
||||
// Essay savepoint reached.
|
||||
upgrade_plugin_savepoint(true, 2014011300, 'qtype', 'essay');
|
||||
}
|
||||
|
||||
if ($oldversion < 2014011301) {
|
||||
|
||||
// Create new field attachmentsrequired (indicates whether attachments should be required).
|
||||
|
||||
$table = new xmldb_table('qtype_essay_options');
|
||||
$field = new xmldb_field('attachmentsrequired', XMLDB_TYPE_INTEGER, '4', null, XMLDB_NOTNULL, null, '0', 'attachments');
|
||||
if (!$dbman->field_exists($table, $field)) {
|
||||
$dbman->add_field($table, $field);
|
||||
}
|
||||
|
||||
// Essay savepoint reached.
|
||||
upgrade_plugin_savepoint(true, 2014011301, 'qtype', 'essay');
|
||||
}
|
||||
|
||||
// Moodle v2.7.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
global $CFG;
|
||||
|
||||
// Moodle v2.8.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
@ -185,33 +43,3 @@ function xmldb_qtype_essay_upgrade($oldversion) {
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert some content to HTML.
|
||||
* @param string $text the content to convert to HTML
|
||||
* @param int $oldformat One of the FORMAT_... constants.
|
||||
*/
|
||||
function qtype_essay_convert_to_html($text, $oldformat) {
|
||||
switch ($oldformat) {
|
||||
// Similar to format_text.
|
||||
|
||||
case FORMAT_PLAIN:
|
||||
$text = s($text);
|
||||
$text = str_replace(' ', ' ', $text);
|
||||
$text = nl2br($text);
|
||||
return $text;
|
||||
|
||||
case FORMAT_MARKDOWN:
|
||||
return markdown_to_html($text);
|
||||
|
||||
case FORMAT_MOODLE:
|
||||
return text_to_html($text);
|
||||
|
||||
case FORMAT_HTML:
|
||||
return $text;
|
||||
|
||||
default:
|
||||
throw new coding_exception(
|
||||
'Unexpected text format when upgrading essay questions.');
|
||||
}
|
||||
}
|
||||
|
@ -22,190 +22,14 @@
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
|
||||
/**
|
||||
* Upgrade code for the matching question type.
|
||||
* @param int $oldversion the version we are upgrading from.
|
||||
*/
|
||||
function xmldb_qtype_match_upgrade($oldversion) {
|
||||
global $CFG, $DB;
|
||||
|
||||
$dbman = $DB->get_manager();
|
||||
|
||||
// Moodle v2.2.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Moodle v2.3.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Moodle v2.4.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
if ($oldversion < 2013012099) {
|
||||
// Find duplicate rows before they break the 2013012103 step below.
|
||||
$problemids = $DB->get_recordset_sql("
|
||||
SELECT question, MIN(id) AS recordidtokeep
|
||||
FROM {question_match}
|
||||
GROUP BY question
|
||||
HAVING COUNT(1) > 1
|
||||
");
|
||||
foreach ($problemids as $problem) {
|
||||
$DB->delete_records_select('question_match',
|
||||
'question = ? AND id > ?',
|
||||
array($problem->question, $problem->recordidtokeep));
|
||||
}
|
||||
$problemids->close();
|
||||
|
||||
// Shortanswer savepoint reached.
|
||||
upgrade_plugin_savepoint(true, 2013012099, 'qtype', 'match');
|
||||
}
|
||||
|
||||
if ($oldversion < 2013012100) {
|
||||
|
||||
// Define table question_match to be renamed to qtype_match_options.
|
||||
$table = new xmldb_table('question_match');
|
||||
|
||||
// Launch rename table for qtype_match_options.
|
||||
$dbman->rename_table($table, 'qtype_match_options');
|
||||
|
||||
// Record that qtype_match savepoint was reached.
|
||||
upgrade_plugin_savepoint(true, 2013012100, 'qtype', 'match');
|
||||
}
|
||||
|
||||
if ($oldversion < 2013012101) {
|
||||
|
||||
// Define key question (foreign) to be dropped form qtype_match_options.
|
||||
$table = new xmldb_table('qtype_match_options');
|
||||
$key = new xmldb_key('question', XMLDB_KEY_FOREIGN, array('question'), 'question', array('id'));
|
||||
|
||||
// Launch drop key question.
|
||||
$dbman->drop_key($table, $key);
|
||||
|
||||
// Record that qtype_match savepoint was reached.
|
||||
upgrade_plugin_savepoint(true, 2013012101, 'qtype', 'match');
|
||||
}
|
||||
|
||||
if ($oldversion < 2013012102) {
|
||||
|
||||
// Rename field question on table qtype_match_options to questionid.
|
||||
$table = new xmldb_table('qtype_match_options');
|
||||
$field = new xmldb_field('question', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, '0', 'id');
|
||||
|
||||
// Launch rename field question.
|
||||
$dbman->rename_field($table, $field, 'questionid');
|
||||
|
||||
// Record that qtype_match savepoint was reached.
|
||||
upgrade_plugin_savepoint(true, 2013012102, 'qtype', 'match');
|
||||
}
|
||||
|
||||
if ($oldversion < 2013012103) {
|
||||
|
||||
// Define key questionid (foreign-unique) to be added to qtype_match_options.
|
||||
$table = new xmldb_table('qtype_match_options');
|
||||
$key = new xmldb_key('questionid', XMLDB_KEY_FOREIGN_UNIQUE, array('questionid'), 'question', array('id'));
|
||||
|
||||
// Launch add key questionid.
|
||||
$dbman->add_key($table, $key);
|
||||
|
||||
// Record that qtype_match savepoint was reached.
|
||||
upgrade_plugin_savepoint(true, 2013012103, 'qtype', 'match');
|
||||
}
|
||||
|
||||
if ($oldversion < 2013012104) {
|
||||
|
||||
// Define field subquestions to be dropped from qtype_match_options.
|
||||
$table = new xmldb_table('qtype_match_options');
|
||||
$field = new xmldb_field('subquestions');
|
||||
|
||||
// Conditionally launch drop field subquestions.
|
||||
if ($dbman->field_exists($table, $field)) {
|
||||
$dbman->drop_field($table, $field);
|
||||
}
|
||||
|
||||
// Record that qtype_match savepoint was reached.
|
||||
upgrade_plugin_savepoint(true, 2013012104, 'qtype', 'match');
|
||||
}
|
||||
|
||||
if ($oldversion < 2013012105) {
|
||||
|
||||
// Define table question_match_sub to be renamed to qtype_match_subquestions.
|
||||
$table = new xmldb_table('question_match_sub');
|
||||
|
||||
// Launch rename table for qtype_match_subquestions.
|
||||
$dbman->rename_table($table, 'qtype_match_subquestions');
|
||||
|
||||
// Record that qtype_match savepoint was reached.
|
||||
upgrade_plugin_savepoint(true, 2013012105, 'qtype', 'match');
|
||||
}
|
||||
|
||||
if ($oldversion < 2013012106) {
|
||||
|
||||
// Define key question (foreign) to be dropped form qtype_match_subquestions.
|
||||
$table = new xmldb_table('qtype_match_subquestions');
|
||||
$key = new xmldb_key('question', XMLDB_KEY_FOREIGN, array('question'), 'question', array('id'));
|
||||
|
||||
// Launch drop key question.
|
||||
$dbman->drop_key($table, $key);
|
||||
|
||||
// Record that qtype_match savepoint was reached.
|
||||
upgrade_plugin_savepoint(true, 2013012106, 'qtype', 'match');
|
||||
}
|
||||
|
||||
if ($oldversion < 2013012107) {
|
||||
|
||||
// Rename field question on table qtype_match_subquestions to questionid.
|
||||
$table = new xmldb_table('qtype_match_subquestions');
|
||||
$field = new xmldb_field('question', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, '0', 'id');
|
||||
|
||||
// Launch rename field question.
|
||||
$dbman->rename_field($table, $field, 'questionid');
|
||||
|
||||
// Record that qtype_match savepoint was reached.
|
||||
upgrade_plugin_savepoint(true, 2013012107, 'qtype', 'match');
|
||||
}
|
||||
|
||||
if ($oldversion < 2013012108) {
|
||||
|
||||
// Define key questionid (foreign) to be added to qtype_match_subquestions.
|
||||
$table = new xmldb_table('qtype_match_subquestions');
|
||||
$key = new xmldb_key('questionid', XMLDB_KEY_FOREIGN, array('questionid'), 'question', array('id'));
|
||||
|
||||
// Launch add key questionid.
|
||||
$dbman->add_key($table, $key);
|
||||
|
||||
// Record that qtype_match savepoint was reached.
|
||||
upgrade_plugin_savepoint(true, 2013012108, 'qtype', 'match');
|
||||
}
|
||||
|
||||
if ($oldversion < 2013012109) {
|
||||
|
||||
// Define field code to be dropped from qtype_match_subquestions.
|
||||
// The field code has not been needed since the new question engine in
|
||||
// Moodle 2.1. It should be safe to drop it now.
|
||||
$table = new xmldb_table('qtype_match_subquestions');
|
||||
$field = new xmldb_field('code');
|
||||
|
||||
// Conditionally launch drop field code.
|
||||
if ($dbman->field_exists($table, $field)) {
|
||||
$dbman->drop_field($table, $field);
|
||||
}
|
||||
|
||||
// Record that qtype_match savepoint was reached.
|
||||
upgrade_plugin_savepoint(true, 2013012109, 'qtype', 'match');
|
||||
}
|
||||
|
||||
// Moodle v2.5.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
|
||||
// Moodle v2.6.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Moodle v2.7.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
global $CFG;
|
||||
|
||||
// Moodle v2.8.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
@ -23,7 +23,6 @@
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
/**
|
||||
@ -35,25 +34,6 @@ function xmldb_qtype_multianswer_upgrade($oldversion) {
|
||||
|
||||
$dbman = $DB->get_manager();
|
||||
|
||||
// Moodle v2.2.0 release upgrade line
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Moodle v2.3.0 release upgrade line
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Moodle v2.4.0 release upgrade line
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Moodle v2.5.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
|
||||
// Moodle v2.6.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Moodle v2.7.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Moodle v2.8.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
|
@ -23,121 +23,14 @@
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
|
||||
/**
|
||||
* Upgrade code for the multiple choice question type.
|
||||
* @param int $oldversion the version we are upgrading from.
|
||||
*/
|
||||
function xmldb_qtype_multichoice_upgrade($oldversion) {
|
||||
global $CFG, $DB;
|
||||
|
||||
$dbman = $DB->get_manager();
|
||||
|
||||
// Moodle v2.2.0 release upgrade line
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Moodle v2.3.0 release upgrade line
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Moodle v2.4.0 release upgrade line
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Moodle v2.5.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
if ($oldversion < 2013092300) {
|
||||
// Find duplicate rows before they break the 2013092304 step below.
|
||||
$problemids = $DB->get_recordset_sql("
|
||||
SELECT question, MIN(id) AS recordidtokeep
|
||||
FROM {question_multichoice}
|
||||
GROUP BY question
|
||||
HAVING COUNT(1) > 1
|
||||
");
|
||||
foreach ($problemids as $problem) {
|
||||
$DB->delete_records_select('question_multichoice',
|
||||
'question = ? AND id > ?',
|
||||
array($problem->question, $problem->recordidtokeep));
|
||||
}
|
||||
$problemids->close();
|
||||
|
||||
// Shortanswer savepoint reached.
|
||||
upgrade_plugin_savepoint(true, 2013092300, 'qtype', 'multichoice');
|
||||
}
|
||||
|
||||
if ($oldversion < 2013092301) {
|
||||
|
||||
// Define table question_multichoice to be renamed to qtype_multichoice_options.
|
||||
$table = new xmldb_table('question_multichoice');
|
||||
|
||||
// Launch rename table for question_multichoice.
|
||||
$dbman->rename_table($table, 'qtype_multichoice_options');
|
||||
|
||||
// Record that qtype_match savepoint was reached.
|
||||
upgrade_plugin_savepoint(true, 2013092301, 'qtype', 'multichoice');
|
||||
}
|
||||
|
||||
if ($oldversion < 2013092302) {
|
||||
|
||||
// Define key question (foreign) to be dropped form qtype_multichoice_options.
|
||||
$table = new xmldb_table('qtype_multichoice_options');
|
||||
$key = new xmldb_key('question', XMLDB_KEY_FOREIGN, array('question'), 'question', array('id'));
|
||||
|
||||
// Launch drop key question.
|
||||
$dbman->drop_key($table, $key);
|
||||
|
||||
// Record that qtype_match savepoint was reached.
|
||||
upgrade_plugin_savepoint(true, 2013092302, 'qtype', 'multichoice');
|
||||
}
|
||||
|
||||
if ($oldversion < 2013092303) {
|
||||
|
||||
// Rename field question on table qtype_multichoice_options to questionid.
|
||||
$table = new xmldb_table('qtype_multichoice_options');
|
||||
$field = new xmldb_field('question', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, '0', 'id');
|
||||
|
||||
// Launch rename field question.
|
||||
$dbman->rename_field($table, $field, 'questionid');
|
||||
|
||||
// Record that qtype_match savepoint was reached.
|
||||
upgrade_plugin_savepoint(true, 2013092303, 'qtype', 'multichoice');
|
||||
}
|
||||
|
||||
if ($oldversion < 2013092304) {
|
||||
|
||||
// Define key questionid (foreign-unique) to be added to qtype_multichoice_options.
|
||||
$table = new xmldb_table('qtype_multichoice_options');
|
||||
$key = new xmldb_key('questionid', XMLDB_KEY_FOREIGN_UNIQUE, array('questionid'), 'question', array('id'));
|
||||
|
||||
// Launch add key questionid.
|
||||
$dbman->add_key($table, $key);
|
||||
|
||||
// Record that qtype_match savepoint was reached.
|
||||
upgrade_plugin_savepoint(true, 2013092304, 'qtype', 'multichoice');
|
||||
}
|
||||
|
||||
if ($oldversion < 2013092305) {
|
||||
|
||||
// Define field answers to be dropped from qtype_multichoice_options.
|
||||
$table = new xmldb_table('qtype_multichoice_options');
|
||||
$field = new xmldb_field('answers');
|
||||
|
||||
// Conditionally launch drop field answers.
|
||||
if ($dbman->field_exists($table, $field)) {
|
||||
$dbman->drop_field($table, $field);
|
||||
}
|
||||
|
||||
// Record that qtype_match savepoint was reached.
|
||||
upgrade_plugin_savepoint(true, 2013092305, 'qtype', 'multichoice');
|
||||
}
|
||||
|
||||
// Moodle v2.6.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Moodle v2.7.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
global $CFG;
|
||||
|
||||
// Moodle v2.8.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
@ -23,34 +23,14 @@
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
|
||||
/**
|
||||
* Upgrade code for the numerical question type.
|
||||
* @param int $oldversion the version we are upgrading from.
|
||||
*/
|
||||
function xmldb_qtype_numerical_upgrade($oldversion) {
|
||||
global $CFG, $DB;
|
||||
|
||||
$dbman = $DB->get_manager();
|
||||
|
||||
// Moodle v2.3.0 release upgrade line
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Moodle v2.4.0 release upgrade line
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Moodle v2.5.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
|
||||
// Moodle v2.6.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Moodle v2.7.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
global $CFG;
|
||||
|
||||
// Moodle v2.8.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
@ -22,10 +22,8 @@
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
|
||||
/**
|
||||
* Upgrade code for the random question type.
|
||||
* @param int $oldversion the version we are upgrading from.
|
||||
@ -33,26 +31,6 @@ defined('MOODLE_INTERNAL') || die();
|
||||
function xmldb_qtype_random_upgrade($oldversion) {
|
||||
global $CFG, $DB;
|
||||
|
||||
$dbman = $DB->get_manager();
|
||||
|
||||
// Moodle v2.2.0 release upgrade line
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Moodle v2.3.0 release upgrade line
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Moodle v2.4.0 release upgrade line
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Moodle v2.5.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Moodle v2.6.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Moodle v2.7.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
if ($oldversion < 2014060200) {
|
||||
$sql = "UPDATE {question}
|
||||
SET questiontext = '0'
|
||||
|
@ -22,173 +22,14 @@
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
|
||||
/**
|
||||
* Upgrade code for the random short answer matching question type.
|
||||
* @param int $oldversion the version we are upgrading from.
|
||||
*/
|
||||
function xmldb_qtype_randomsamatch_upgrade($oldversion) {
|
||||
global $CFG, $DB;
|
||||
|
||||
$dbman = $DB->get_manager();
|
||||
|
||||
// Moodle v2.2.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Moodle v2.3.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Moodle v2.4.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
if ($oldversion < 2013110501) {
|
||||
|
||||
// Define table question_randomsamatch to be renamed to qtype_randomsamatch_options.
|
||||
$table = new xmldb_table('question_randomsamatch');
|
||||
|
||||
// Launch rename table for qtype_randomsamatch_options.
|
||||
if ($dbman->table_exists($table)) {
|
||||
$dbman->rename_table($table, 'qtype_randomsamatch_options');
|
||||
}
|
||||
|
||||
// Record that qtype_randomsamatch savepoint was reached.
|
||||
upgrade_plugin_savepoint(true, 2013110501, 'qtype', 'randomsamatch');
|
||||
}
|
||||
|
||||
if ($oldversion < 2013110502) {
|
||||
|
||||
// Define key question (foreign) to be dropped form qtype_randomsamatch_options.
|
||||
$table = new xmldb_table('qtype_randomsamatch_options');
|
||||
$field = new xmldb_field('question', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, '0', 'id');
|
||||
|
||||
if ($dbman->field_exists($table, $field)) {
|
||||
// Launch drop key question.
|
||||
$key = new xmldb_key('question', XMLDB_KEY_FOREIGN, array('question'), 'question', array('id'));
|
||||
$dbman->drop_key($table, $key);
|
||||
|
||||
// Launch rename field question.
|
||||
$dbman->rename_field($table, $field, 'questionid');
|
||||
|
||||
$key = new xmldb_key('questionid', XMLDB_KEY_FOREIGN_UNIQUE, array('questionid'), 'question', array('id'));
|
||||
// Launch add key questionid.
|
||||
$dbman->add_key($table, $key);
|
||||
}
|
||||
|
||||
// Record that qtype_randomsamatch savepoint was reached.
|
||||
upgrade_plugin_savepoint(true, 2013110502, 'qtype', 'randomsamatch');
|
||||
}
|
||||
|
||||
if ($oldversion < 2013110503) {
|
||||
|
||||
// Add subcats field.
|
||||
$table = new xmldb_table('qtype_randomsamatch_options');
|
||||
|
||||
// Define field subcats to be added to qtype_randomsamatch_options.
|
||||
$field = new xmldb_field('subcats', XMLDB_TYPE_INTEGER, 2, null,
|
||||
XMLDB_NOTNULL, null, '1', 'choose');
|
||||
|
||||
// Conditionally launch add field subcats.
|
||||
if (!$dbman->field_exists($table, $field)) {
|
||||
$dbman->add_field($table, $field);
|
||||
}
|
||||
|
||||
// Add combined feedback fields.
|
||||
// Define field correctfeedback to be added to qtype_randomsamatch_options.
|
||||
$field = new xmldb_field('correctfeedback', XMLDB_TYPE_TEXT, 'small', null,
|
||||
null, null, null, 'subcats');
|
||||
|
||||
// Conditionally launch add field correctfeedback.
|
||||
if (!$dbman->field_exists($table, $field)) {
|
||||
$dbman->add_field($table, $field);
|
||||
|
||||
// Now fill it with ''.
|
||||
$DB->set_field('qtype_randomsamatch_options', 'correctfeedback', '');
|
||||
|
||||
// Now add the not null constraint.
|
||||
$field = new xmldb_field('correctfeedback', XMLDB_TYPE_TEXT, 'small', null,
|
||||
XMLDB_NOTNULL, null, null, 'subcats');
|
||||
$dbman->change_field_notnull($table, $field);
|
||||
}
|
||||
|
||||
// Define field correctfeedbackformat to be added to qtype_randomsamatch_options.
|
||||
$field = new xmldb_field('correctfeedbackformat', XMLDB_TYPE_INTEGER, '2', null,
|
||||
XMLDB_NOTNULL, null, '0', 'correctfeedback');
|
||||
|
||||
// Conditionally launch add field correctfeedbackformat.
|
||||
if (!$dbman->field_exists($table, $field)) {
|
||||
$dbman->add_field($table, $field);
|
||||
}
|
||||
|
||||
// Define field partiallycorrectfeedback to be added to qtype_randomsamatch_options.
|
||||
$field = new xmldb_field('partiallycorrectfeedback', XMLDB_TYPE_TEXT, 'small', null,
|
||||
null, null, null, 'correctfeedbackformat');
|
||||
|
||||
// Conditionally launch add field partiallycorrectfeedback.
|
||||
if (!$dbman->field_exists($table, $field)) {
|
||||
$dbman->add_field($table, $field);
|
||||
|
||||
// Now fill it with ''.
|
||||
$DB->set_field('qtype_randomsamatch_options', 'partiallycorrectfeedback', '');
|
||||
|
||||
// Now add the not null constraint.
|
||||
$field = new xmldb_field('partiallycorrectfeedback', XMLDB_TYPE_TEXT, 'small', null,
|
||||
XMLDB_NOTNULL, null, null, 'correctfeedbackformat');
|
||||
$dbman->change_field_notnull($table, $field);
|
||||
}
|
||||
|
||||
// Define field partiallycorrectfeedbackformat to be added to qtype_randomsamatch_options.
|
||||
$field = new xmldb_field('partiallycorrectfeedbackformat', XMLDB_TYPE_INTEGER, '2', null,
|
||||
XMLDB_NOTNULL, null, '0', 'partiallycorrectfeedback');
|
||||
|
||||
// Conditionally launch add field partiallycorrectfeedbackformat.
|
||||
if (!$dbman->field_exists($table, $field)) {
|
||||
$dbman->add_field($table, $field);
|
||||
}
|
||||
|
||||
// Define field incorrectfeedback to be added to qtype_randomsamatch_options.
|
||||
$field = new xmldb_field('incorrectfeedback', XMLDB_TYPE_TEXT, 'small', null,
|
||||
null, null, null, 'partiallycorrectfeedbackformat');
|
||||
|
||||
// Conditionally launch add field incorrectfeedback.
|
||||
if (!$dbman->field_exists($table, $field)) {
|
||||
$dbman->add_field($table, $field);
|
||||
|
||||
// Now fill it with ''.
|
||||
$DB->set_field('qtype_randomsamatch_options', 'incorrectfeedback', '');
|
||||
|
||||
// Now add the not null constraint.
|
||||
$field = new xmldb_field('incorrectfeedback', XMLDB_TYPE_TEXT, 'small', null,
|
||||
XMLDB_NOTNULL, null, null, 'partiallycorrectfeedbackformat');
|
||||
$dbman->change_field_notnull($table, $field);
|
||||
}
|
||||
|
||||
// Define field incorrectfeedbackformat to be added to qtype_randomsamatch_options.
|
||||
$field = new xmldb_field('incorrectfeedbackformat', XMLDB_TYPE_INTEGER, '2', null,
|
||||
XMLDB_NOTNULL, null, '0', 'incorrectfeedback');
|
||||
|
||||
// Conditionally launch add field incorrectfeedbackformat.
|
||||
if (!$dbman->field_exists($table, $field)) {
|
||||
$dbman->add_field($table, $field);
|
||||
}
|
||||
|
||||
// Define field shownumcorrect to be added to qtype_randomsamatch_options.
|
||||
$field = new xmldb_field('shownumcorrect', XMLDB_TYPE_INTEGER, '2', null,
|
||||
XMLDB_NOTNULL, null, '0', 'incorrectfeedbackformat');
|
||||
|
||||
// Conditionally launch add field shownumcorrect.
|
||||
if (!$dbman->field_exists($table, $field)) {
|
||||
$dbman->add_field($table, $field);
|
||||
}
|
||||
|
||||
// Record that qtype_randomsamatch savepoint was reached.
|
||||
upgrade_plugin_savepoint(true, 2013110503, 'qtype', 'randomsamatch');
|
||||
}
|
||||
|
||||
// Moodle v2.7.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
global $CFG;
|
||||
|
||||
// Moodle v2.8.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
@ -23,116 +23,14 @@
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
|
||||
/**
|
||||
* Upgrade code for the essay question type.
|
||||
* @param int $oldversion the version we are upgrading from.
|
||||
*/
|
||||
function xmldb_qtype_shortanswer_upgrade($oldversion) {
|
||||
global $CFG, $DB;
|
||||
|
||||
$dbman = $DB->get_manager();
|
||||
|
||||
// Moodle v2.4.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
if ($oldversion < 2013011799) {
|
||||
// Find duplicate rows before they break the 2013011803 step below.
|
||||
$problemids = $DB->get_recordset_sql("
|
||||
SELECT question, MIN(id) AS recordidtokeep
|
||||
FROM {question_shortanswer}
|
||||
GROUP BY question
|
||||
HAVING COUNT(1) > 1
|
||||
");
|
||||
foreach ($problemids as $problem) {
|
||||
$DB->delete_records_select('question_shortanswer',
|
||||
'question = ? AND id > ?',
|
||||
array($problem->question, $problem->recordidtokeep));
|
||||
}
|
||||
$problemids->close();
|
||||
|
||||
// Shortanswer savepoint reached.
|
||||
upgrade_plugin_savepoint(true, 2013011799, 'qtype', 'shortanswer');
|
||||
}
|
||||
|
||||
if ($oldversion < 2013011800) {
|
||||
|
||||
// Define field answers to be dropped from question_shortanswer.
|
||||
$table = new xmldb_table('question_shortanswer');
|
||||
$field = new xmldb_field('answers');
|
||||
|
||||
// Conditionally launch drop field answers.
|
||||
if ($dbman->field_exists($table, $field)) {
|
||||
$dbman->drop_field($table, $field);
|
||||
}
|
||||
|
||||
// Shortanswer savepoint reached.
|
||||
upgrade_plugin_savepoint(true, 2013011800, 'qtype', 'shortanswer');
|
||||
}
|
||||
|
||||
if ($oldversion < 2013011801) {
|
||||
|
||||
// Define key question (foreign) to be dropped form question_shortanswer.
|
||||
$table = new xmldb_table('question_shortanswer');
|
||||
$key = new xmldb_key('question', XMLDB_KEY_FOREIGN, array('question'), 'question', array('id'));
|
||||
|
||||
// Launch drop key question.
|
||||
$dbman->drop_key($table, $key);
|
||||
|
||||
// Shortanswer savepoint reached.
|
||||
upgrade_plugin_savepoint(true, 2013011801, 'qtype', 'shortanswer');
|
||||
}
|
||||
|
||||
if ($oldversion < 2013011802) {
|
||||
|
||||
// Rename field question on table question_shortanswer to questionid.
|
||||
$table = new xmldb_table('question_shortanswer');
|
||||
$field = new xmldb_field('question', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, '0', 'id');
|
||||
|
||||
// Launch rename field question.
|
||||
$dbman->rename_field($table, $field, 'questionid');
|
||||
|
||||
// Shortanswer savepoint reached.
|
||||
upgrade_plugin_savepoint(true, 2013011802, 'qtype', 'shortanswer');
|
||||
}
|
||||
|
||||
if ($oldversion < 2013011803) {
|
||||
|
||||
// Define key questionid (foreign-unique) to be added to question_shortanswer.
|
||||
$table = new xmldb_table('question_shortanswer');
|
||||
$key = new xmldb_key('questionid', XMLDB_KEY_FOREIGN_UNIQUE, array('questionid'), 'question', array('id'));
|
||||
|
||||
// Launch add key questionid.
|
||||
$dbman->add_key($table, $key);
|
||||
|
||||
// Shortanswer savepoint reached.
|
||||
upgrade_plugin_savepoint(true, 2013011803, 'qtype', 'shortanswer');
|
||||
}
|
||||
|
||||
if ($oldversion < 2013011804) {
|
||||
|
||||
// Define table qtype_shortanswer_options to be renamed to qtype_shortanswer_options.
|
||||
$table = new xmldb_table('question_shortanswer');
|
||||
|
||||
// Launch rename table for qtype_shortanswer_options.
|
||||
$dbman->rename_table($table, 'qtype_shortanswer_options');
|
||||
|
||||
// Shortanswer savepoint reached.
|
||||
upgrade_plugin_savepoint(true, 2013011804, 'qtype', 'shortanswer');
|
||||
}
|
||||
|
||||
// Moodle v2.5.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
|
||||
// Moodle v2.6.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Moodle v2.7.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
global $CFG;
|
||||
|
||||
// Moodle v2.8.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
@ -31,30 +31,7 @@ defined('MOODLE_INTERNAL') || die();
|
||||
* @return bool result
|
||||
*/
|
||||
function xmldb_repository_alfresco_upgrade($oldversion) {
|
||||
global $CFG, $DB;
|
||||
|
||||
$dbman = $DB->get_manager();
|
||||
|
||||
if ($oldversion < 2014020301) {
|
||||
require_once($CFG->dirroot . '/repository/lib.php');
|
||||
require_once($CFG->dirroot . '/repository/alfresco/db/upgradelib.php');
|
||||
|
||||
$params = array();
|
||||
$params['context'] = array();
|
||||
$params['onlyvisible'] = false;
|
||||
$params['type'] = 'alfresco';
|
||||
$instances = repository::get_instances($params);
|
||||
|
||||
// Notify the admin about the migration process if they are using the repo.
|
||||
if (!empty($instances)) {
|
||||
repository_alfresco_admin_security_key_notice();
|
||||
}
|
||||
|
||||
upgrade_plugin_savepoint(true, 2014020301, 'repository', 'alfresco');
|
||||
}
|
||||
|
||||
// Moodle v2.7.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
global $CFG;
|
||||
|
||||
// Moodle v2.8.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
@ -31,51 +31,7 @@ defined('MOODLE_INTERNAL') || die();
|
||||
* @return bool result
|
||||
*/
|
||||
function xmldb_repository_boxnet_upgrade($oldversion) {
|
||||
global $CFG, $DB;
|
||||
|
||||
$dbman = $DB->get_manager();
|
||||
|
||||
if ($oldversion < 2013110503) {
|
||||
// Delete old user preferences containing auth tokens.
|
||||
$DB->delete_records('user_preferences', array('name' => 'boxnet__auth_token'));
|
||||
upgrade_plugin_savepoint(true, 2013110503, 'repository', 'boxnet');
|
||||
}
|
||||
|
||||
if ($oldversion < 2013110700) {
|
||||
require_once($CFG->dirroot . '/repository/lib.php');
|
||||
require_once($CFG->dirroot . '/repository/boxnet/db/upgradelib.php');
|
||||
|
||||
$clientid = get_config('boxnet', 'clientid');
|
||||
$clientsecret = get_config('boxnet', 'clientsecret');
|
||||
|
||||
// Only proceed if the repository hasn't been set for APIv2 yet.
|
||||
if ($clientid === false && $clientsecret === false) {
|
||||
$params = array();
|
||||
$params['context'] = array();
|
||||
$params['onlyvisible'] = false;
|
||||
$params['type'] = 'boxnet';
|
||||
$instances = repository::get_instances($params);
|
||||
|
||||
// Notify the admin about the migration process if they are using the repo.
|
||||
if (!empty($instances)) {
|
||||
repository_boxnet_admin_upgrade_notification();
|
||||
}
|
||||
|
||||
// Hide the repository.
|
||||
$repositorytype = repository::get_type_by_typename('boxnet');
|
||||
if (!empty($repositorytype)) {
|
||||
$repositorytype->update_visibility(false);
|
||||
}
|
||||
}
|
||||
|
||||
upgrade_plugin_savepoint(true, 2013110700, 'repository', 'boxnet');
|
||||
}
|
||||
|
||||
// Moodle v2.6.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Moodle v2.7.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
global $CFG;
|
||||
|
||||
// Moodle v2.8.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
@ -14,40 +14,14 @@
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
/**
|
||||
* @param int $oldversion the version we are upgrading from
|
||||
* @return bool result
|
||||
*/
|
||||
function xmldb_repository_dropbox_upgrade($oldversion) {
|
||||
global $CFG, $DB;
|
||||
|
||||
$dbman = $DB->get_manager();
|
||||
|
||||
// Moodle v2.3.0 release upgrade line
|
||||
// Put any upgrade step following this
|
||||
|
||||
if ($oldversion < 2012080702) {
|
||||
// Set the default value for dropbox_cachelimit
|
||||
$value = get_config('dropbox', 'dropbox_cachelimit');
|
||||
if (empty($value)) {
|
||||
set_config('dropbox_cachelimit', 1024*1024, 'dropbox');
|
||||
}
|
||||
upgrade_plugin_savepoint(true, 2012080702, 'repository', 'dropbox');
|
||||
}
|
||||
|
||||
// Moodle v2.4.0 release upgrade line
|
||||
// Put any upgrade step following this
|
||||
|
||||
|
||||
// Moodle v2.5.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
|
||||
// Moodle v2.6.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Moodle v2.7.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
global $CFG;
|
||||
|
||||
// Moodle v2.8.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
@ -14,52 +14,14 @@
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
/**
|
||||
* @param int $oldversion the version we are upgrading from
|
||||
* @return bool result
|
||||
*/
|
||||
function xmldb_repository_googledocs_upgrade($oldversion) {
|
||||
global $CFG, $DB;
|
||||
require_once(__DIR__.'/upgradelib.php');
|
||||
|
||||
$dbman = $DB->get_manager();
|
||||
|
||||
if ($oldversion < 2012051400) {
|
||||
// Delete old user preferences containing authsub tokens.
|
||||
$DB->delete_records('user_preferences', array('name' => 'google_authsub_sesskey'));
|
||||
upgrade_plugin_savepoint(true, 2012051400, 'repository', 'googledocs');
|
||||
}
|
||||
|
||||
if ($oldversion < 2012053000) {
|
||||
require_once($CFG->dirroot.'/repository/lib.php');
|
||||
$existing = $DB->get_record('repository', array('type' => 'googledocs'), '*', IGNORE_MULTIPLE);
|
||||
|
||||
if ($existing) {
|
||||
$googledocsplugin = new repository_type('googledocs', array(), true);
|
||||
$googledocsplugin->delete();
|
||||
repository_googledocs_admin_upgrade_notification();
|
||||
}
|
||||
|
||||
upgrade_plugin_savepoint(true, 2012053000, 'repository', 'googledocs');
|
||||
}
|
||||
|
||||
// Moodle v2.3.0 release upgrade line
|
||||
// Put any upgrade step following this
|
||||
|
||||
|
||||
// Moodle v2.4.0 release upgrade line
|
||||
// Put any upgrade step following this
|
||||
|
||||
|
||||
// Moodle v2.5.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
|
||||
// Moodle v2.6.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Moodle v2.7.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
global $CFG;
|
||||
|
||||
// Moodle v2.8.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
@ -14,52 +14,14 @@
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
/**
|
||||
* @param int $oldversion the version we are upgrading from
|
||||
* @return bool result
|
||||
*/
|
||||
function xmldb_repository_picasa_upgrade($oldversion) {
|
||||
global $CFG, $DB;
|
||||
require_once(__DIR__.'/upgradelib.php');
|
||||
|
||||
$dbman = $DB->get_manager();
|
||||
|
||||
if ($oldversion < 2012051400) {
|
||||
// Delete old user preferences storing authsub tokens.
|
||||
$DB->delete_records('user_preferences', array('name' => 'google_authsub_sesskey_picasa'));
|
||||
upgrade_plugin_savepoint(true, 2012051400, 'repository', 'picasa');
|
||||
}
|
||||
|
||||
if ($oldversion < 2012053000) {
|
||||
require_once($CFG->dirroot.'/repository/lib.php');
|
||||
$existing = $DB->get_record('repository', array('type' => 'picasa'), '*', IGNORE_MULTIPLE);
|
||||
|
||||
if ($existing) {
|
||||
$picasaplugin = new repository_type('picasa', array(), true);
|
||||
$picasaplugin->delete();
|
||||
repository_picasa_admin_upgrade_notification();
|
||||
}
|
||||
|
||||
upgrade_plugin_savepoint(true, 2012053000, 'repository', 'picasa');
|
||||
}
|
||||
|
||||
// Moodle v2.3.0 release upgrade line
|
||||
// Put any upgrade step following this
|
||||
|
||||
|
||||
// Moodle v2.4.0 release upgrade line
|
||||
// Put any upgrade step following this
|
||||
|
||||
|
||||
// Moodle v2.5.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
|
||||
// Moodle v2.6.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Moodle v2.7.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
global $CFG;
|
||||
|
||||
// Moodle v2.8.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
@ -33,46 +33,6 @@ defined('MOODLE_INTERNAL') || die();
|
||||
function xmldb_theme_more_upgrade($oldversion) {
|
||||
global $CFG;
|
||||
|
||||
if ($oldversion < 2014032400) {
|
||||
|
||||
// Set the default background. If an image is already there then ignore.
|
||||
$fs = get_file_storage();
|
||||
$bg = $fs->get_area_files(context_system::instance()->id, 'theme_more', 'backgroundimage', 0);
|
||||
|
||||
// Add default background image.
|
||||
if (empty($bg)) {
|
||||
$filerecord = new stdClass();
|
||||
$filerecord->component = 'theme_more';
|
||||
$filerecord->contextid = context_system::instance()->id;
|
||||
$filerecord->userid = get_admin()->id;
|
||||
$filerecord->filearea = 'backgroundimage';
|
||||
$filerecord->filepath = '/';
|
||||
$filerecord->itemid = 0;
|
||||
$filerecord->filename = 'background.jpg';
|
||||
$fs->create_file_from_pathname($filerecord, $CFG->dirroot . '/theme/more/pix/background.jpg');
|
||||
}
|
||||
|
||||
upgrade_plugin_savepoint(true, 2014032400, 'theme', 'more');
|
||||
|
||||
}
|
||||
|
||||
if ($oldversion < 2014032401) {
|
||||
|
||||
// Set the default settings as they might already be set.
|
||||
set_config('textcolor', '#333366', 'theme_more');
|
||||
set_config('linkcolor', '#FF6500', 'theme_more');
|
||||
set_config('backgroundrepeat', 'repeat', 'theme_more');
|
||||
set_config('contentbackground', '#FFFFFF', 'theme_more');
|
||||
set_config('secondarybackground', '#FFFFFF', 'theme_more');
|
||||
set_config('invert', 1, 'theme_more');
|
||||
set_config('backgroundimage', '/background.jpg', 'theme_more');
|
||||
|
||||
upgrade_plugin_savepoint(true, 2014032401, 'theme', 'more');
|
||||
}
|
||||
|
||||
// Moodle v2.7.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Moodle v2.8.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user