Merge branch 'MDL-51580' of git://github.com/stronk7/moodle
This commit is contained in:
@@ -1558,4 +1558,142 @@
|
||||
</CUSTOM_CHECK>
|
||||
</CUSTOM_CHECKS>
|
||||
</MOODLE>
|
||||
<MOODLE version="3.1" requires="2.7">
|
||||
<UNICODE level="required">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="unicoderequired" />
|
||||
</FEEDBACK>
|
||||
</UNICODE>
|
||||
<DATABASE level="required">
|
||||
<VENDOR name="mariadb" version="5.5.31" />
|
||||
<VENDOR name="mysql" version="5.5.31" />
|
||||
<VENDOR name="postgres" version="9.1" />
|
||||
<VENDOR name="mssql" version="10.0" />
|
||||
<VENDOR name="oracle" version="10.2" />
|
||||
</DATABASE>
|
||||
<PHP version="5.4.4" level="required">
|
||||
</PHP>
|
||||
<PCREUNICODE level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="pcreunicodewarning" />
|
||||
</FEEDBACK>
|
||||
</PCREUNICODE>
|
||||
<PHP_EXTENSIONS>
|
||||
<PHP_EXTENSION name="iconv" level="required">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="iconvrequired" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="mbstring" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="mbstringrecommended" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="curl" level="required">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="curlrequired" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="openssl" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="opensslrecommended" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="tokenizer" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="tokenizerrecommended" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="xmlrpc" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="xmlrpcrecommended" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="soap" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="soaprecommended" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="ctype" level="required">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="ctyperequired" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="zip" level="required">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="ziprequired" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="zlib" level="required">
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="gd" level="required">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="gdrequired" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="simplexml" level="required">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="simplexmlrequired" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="spl" level="required">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="splrequired" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="pcre" level="required">
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="dom" level="required">
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="xml" level="required">
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="intl" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="intlrecommended" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="json" level="required">
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="hash" level="required"/>
|
||||
</PHP_EXTENSIONS>
|
||||
<PHP_SETTINGS>
|
||||
<PHP_SETTING name="memory_limit" value="96M" level="required">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="settingmemorylimit" />
|
||||
</FEEDBACK>
|
||||
</PHP_SETTING>
|
||||
<PHP_SETTING name="file_uploads" value="1" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="settingfileuploads" />
|
||||
</FEEDBACK>
|
||||
</PHP_SETTING>
|
||||
<PHP_SETTING name="opcache.enable" value="1" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="opcacherecommended" />
|
||||
</FEEDBACK>
|
||||
</PHP_SETTING>
|
||||
</PHP_SETTINGS>
|
||||
<CUSTOM_CHECKS>
|
||||
<CUSTOM_CHECK file="lib/upgradelib.php" function="check_database_storage_engine" level="required">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="unsupporteddbstorageengine" />
|
||||
</FEEDBACK>
|
||||
</CUSTOM_CHECK>
|
||||
<CUSTOM_CHECK file="question/engine/upgrade/upgradelib.php" function="quiz_attempts_upgraded" level="required">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="quizattemptsupgradedmessage" />
|
||||
</FEEDBACK>
|
||||
</CUSTOM_CHECK>
|
||||
<CUSTOM_CHECK file="lib/upgradelib.php" function="check_slasharguments" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="slashargumentswarning" />
|
||||
</FEEDBACK>
|
||||
</CUSTOM_CHECK>
|
||||
<CUSTOM_CHECK file="lib/upgradelib.php" function="check_database_tables_row_format" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="unsupporteddbtablerowformat" />
|
||||
</FEEDBACK>
|
||||
</CUSTOM_CHECK>
|
||||
</CUSTOM_CHECKS>
|
||||
</MOODLE>
|
||||
</COMPATIBILITY_MATRIX>
|
||||
|
||||
@@ -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.
|
||||
|
||||
+3
-28
@@ -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.
|
||||
|
||||
@@ -236,8 +236,6 @@ $string['novirtualquestiontype'] = 'No virtual question type for question type {
|
||||
$string['numqas'] = 'No. question attempts';
|
||||
$string['numquestions'] = 'No. questions';
|
||||
$string['numquestionsandhidden'] = '{$a->numquestions} (+{$a->numhidden} hidden)';
|
||||
$string['orphanedquestionscategory'] = 'Questions saved from deleted categories';
|
||||
$string['orphanedquestionscategoryinfo'] = 'Occasionally, typically due to old software bugs, questions can remain in the database even though the corresponding question category has been deleted. Of course, this should not happen, it has happened in the past on this site. This category has been created automatically, and the orphaned questions moved here so that you can manage them. Note that any images or media files used by these questions have probably been lost.';
|
||||
$string['page-question-x'] = 'Any question page';
|
||||
$string['page-question-edit'] = 'Question editing page';
|
||||
$string['page-question-category'] = 'Question category page';
|
||||
|
||||
+10
-3545
File diff suppressed because it is too large
Load Diff
@@ -76,387 +76,6 @@ function upgrade_mysql_get_supported_tables() {
|
||||
return $tables;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove all signed numbers from current database and change
|
||||
* text fields to long texts - mysql only.
|
||||
*/
|
||||
function upgrade_mysql_fix_unsigned_and_lob_columns() {
|
||||
// We are not using standard API for changes of column
|
||||
// because everything 'signed'-related will be removed soon.
|
||||
|
||||
// If anybody already has numbers higher than signed limit the execution stops
|
||||
// and tables must be fixed manually before continuing upgrade.
|
||||
|
||||
global $DB;
|
||||
|
||||
if ($DB->get_dbfamily() !== 'mysql') {
|
||||
return;
|
||||
}
|
||||
|
||||
$pbar = new progress_bar('mysqlconvertunsignedlobs', 500, true);
|
||||
|
||||
$prefix = $DB->get_prefix();
|
||||
$tables = upgrade_mysql_get_supported_tables();
|
||||
|
||||
$tablecount = count($tables);
|
||||
$i = 0;
|
||||
foreach ($tables as $table) {
|
||||
$i++;
|
||||
|
||||
$changes = array();
|
||||
|
||||
$sql = "SHOW COLUMNS FROM `{{$table}}`";
|
||||
$rs = $DB->get_recordset_sql($sql);
|
||||
foreach ($rs as $column) {
|
||||
$column = (object)array_change_key_case((array)$column, CASE_LOWER);
|
||||
if (stripos($column->type, 'unsigned') !== false) {
|
||||
$maxvalue = 0;
|
||||
if (preg_match('/^int/i', $column->type)) {
|
||||
$maxvalue = 2147483647;
|
||||
} else if (preg_match('/^medium/i', $column->type)) {
|
||||
$maxvalue = 8388607;
|
||||
} else if (preg_match('/^smallint/i', $column->type)) {
|
||||
$maxvalue = 32767;
|
||||
} else if (preg_match('/^tinyint/i', $column->type)) {
|
||||
$maxvalue = 127;
|
||||
}
|
||||
if ($maxvalue) {
|
||||
// Make sure nobody is abusing our integer ranges - moodle int sizes are in digits, not bytes!!!
|
||||
$invalidcount = $DB->get_field_sql("SELECT COUNT('x') FROM `{{$table}}` WHERE `$column->field` > :maxnumber", array('maxnumber'=>$maxvalue));
|
||||
if ($invalidcount) {
|
||||
throw new moodle_exception('notlocalisederrormessage', 'error', new moodle_url('/admin/'), "Database table '{$table}'' contains unsigned column '{$column->field}' with $invalidcount values that are out of allowed range, upgrade can not continue.");
|
||||
}
|
||||
}
|
||||
$type = preg_replace('/unsigned/i', 'signed', $column->type);
|
||||
$notnull = ($column->null === 'NO') ? 'NOT NULL' : 'NULL';
|
||||
$default = (!is_null($column->default) and $column->default !== '') ? "DEFAULT '$column->default'" : '';
|
||||
$autoinc = (stripos($column->extra, 'auto_increment') !== false) ? 'AUTO_INCREMENT' : '';
|
||||
// Primary and unique not necessary here, change_database_structure does not add prefix.
|
||||
$changes[] = "MODIFY COLUMN `$column->field` $type $notnull $default $autoinc";
|
||||
|
||||
} else if ($column->type === 'tinytext' or $column->type === 'mediumtext' or $column->type === 'text') {
|
||||
$notnull = ($column->null === 'NO') ? 'NOT NULL' : 'NULL';
|
||||
$default = (!is_null($column->default) and $column->default !== '') ? "DEFAULT '$column->default'" : '';
|
||||
// Primary, unique and inc are not supported for texts.
|
||||
$changes[] = "MODIFY COLUMN `$column->field` LONGTEXT $notnull $default";
|
||||
|
||||
} else if ($column->type === 'tinyblob' or $column->type === 'mediumblob' or $column->type === 'blob') {
|
||||
$notnull = ($column->null === 'NO') ? 'NOT NULL' : 'NULL';
|
||||
$default = (!is_null($column->default) and $column->default !== '') ? "DEFAULT '$column->default'" : '';
|
||||
// Primary, unique and inc are not supported for blobs.
|
||||
$changes[] = "MODIFY COLUMN `$column->field` LONGBLOB $notnull $default";
|
||||
}
|
||||
|
||||
}
|
||||
$rs->close();
|
||||
|
||||
if ($changes) {
|
||||
// Set appropriate timeout - 1 minute per thousand of records should be enough, min 60 minutes just in case.
|
||||
$count = $DB->count_records($table, array());
|
||||
$timeout = ($count/1000)*60;
|
||||
$timeout = ($timeout < 60*60) ? 60*60 : (int)$timeout;
|
||||
upgrade_set_timeout($timeout);
|
||||
|
||||
$sql = "ALTER TABLE `{$prefix}$table` ".implode(', ', $changes);
|
||||
$DB->change_database_structure($sql);
|
||||
}
|
||||
|
||||
$pbar->update($i, $tablecount, "Converted unsigned/lob columns in MySQL database - $i/$tablecount.");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Migrate NTEXT to NVARCHAR(MAX).
|
||||
*/
|
||||
function upgrade_mssql_nvarcharmax() {
|
||||
global $DB;
|
||||
|
||||
if ($DB->get_dbfamily() !== 'mssql') {
|
||||
return;
|
||||
}
|
||||
|
||||
$pbar = new progress_bar('mssqlconvertntext', 500, true);
|
||||
|
||||
$prefix = $DB->get_prefix();
|
||||
$tables = $DB->get_tables(false);
|
||||
|
||||
$tablecount = count($tables);
|
||||
$i = 0;
|
||||
foreach ($tables as $table) {
|
||||
$i++;
|
||||
|
||||
$columns = array();
|
||||
|
||||
$sql = "SELECT column_name
|
||||
FROM INFORMATION_SCHEMA.COLUMNS
|
||||
WHERE table_name = '{{$table}}' AND UPPER(data_type) = 'NTEXT'";
|
||||
$rs = $DB->get_recordset_sql($sql);
|
||||
foreach ($rs as $column) {
|
||||
$columns[] = $column->column_name;
|
||||
}
|
||||
$rs->close();
|
||||
|
||||
if ($columns) {
|
||||
// Set appropriate timeout - 1 minute per thousand of records should be enough, min 60 minutes just in case.
|
||||
$count = $DB->count_records($table, array());
|
||||
$timeout = ($count/1000)*60;
|
||||
$timeout = ($timeout < 60*60) ? 60*60 : (int)$timeout;
|
||||
upgrade_set_timeout($timeout);
|
||||
|
||||
$updates = array();
|
||||
foreach ($columns as $column) {
|
||||
// Change the definition.
|
||||
$sql = "ALTER TABLE {$prefix}$table ALTER COLUMN $column NVARCHAR(MAX)";
|
||||
$DB->change_database_structure($sql);
|
||||
$updates[] = "$column = $column";
|
||||
}
|
||||
|
||||
// Now force the migration of text data to new optimised storage.
|
||||
$sql = "UPDATE {{$table}} SET ".implode(', ', $updates);
|
||||
$DB->execute($sql);
|
||||
}
|
||||
|
||||
$pbar->update($i, $tablecount, "Converted NTEXT to NVARCHAR(MAX) columns in MS SQL Server database - $i/$tablecount.");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Migrate IMAGE to VARBINARY(MAX).
|
||||
*/
|
||||
function upgrade_mssql_varbinarymax() {
|
||||
global $DB;
|
||||
|
||||
if ($DB->get_dbfamily() !== 'mssql') {
|
||||
return;
|
||||
}
|
||||
|
||||
$pbar = new progress_bar('mssqlconvertimage', 500, true);
|
||||
|
||||
$prefix = $DB->get_prefix();
|
||||
$tables = $DB->get_tables(false);
|
||||
|
||||
$tablecount = count($tables);
|
||||
$i = 0;
|
||||
foreach ($tables as $table) {
|
||||
$i++;
|
||||
|
||||
$columns = array();
|
||||
|
||||
$sql = "SELECT column_name
|
||||
FROM INFORMATION_SCHEMA.COLUMNS
|
||||
WHERE table_name = '{{$table}}' AND UPPER(data_type) = 'IMAGE'";
|
||||
$rs = $DB->get_recordset_sql($sql);
|
||||
foreach ($rs as $column) {
|
||||
$columns[] = $column->column_name;
|
||||
}
|
||||
$rs->close();
|
||||
|
||||
if ($columns) {
|
||||
// Set appropriate timeout - 1 minute per thousand of records should be enough, min 60 minutes just in case.
|
||||
$count = $DB->count_records($table, array());
|
||||
$timeout = ($count/1000)*60;
|
||||
$timeout = ($timeout < 60*60) ? 60*60 : (int)$timeout;
|
||||
upgrade_set_timeout($timeout);
|
||||
|
||||
foreach ($columns as $column) {
|
||||
// Change the definition.
|
||||
$sql = "ALTER TABLE {$prefix}$table ALTER COLUMN $column VARBINARY(MAX)";
|
||||
$DB->change_database_structure($sql);
|
||||
}
|
||||
|
||||
// Binary columns should not be used, do not waste time optimising the storage.
|
||||
}
|
||||
|
||||
$pbar->update($i, $tablecount, "Converted IMAGE to VARBINARY(MAX) columns in MS SQL Server database - $i/$tablecount.");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This upgrade script fixes the mismatches between DB fields course_modules.section
|
||||
* and course_sections.sequence. It makes sure that each module is included
|
||||
* in the sequence of at least one section.
|
||||
* Note that this script is different from admin/cli/fix_course_sortorder.php
|
||||
* in the following ways:
|
||||
* 1. It does not fix the cases when module appears several times in section(s) sequence(s) -
|
||||
* it will be done automatically on the next viewing of the course.
|
||||
* 2. It does not remove non-existing modules from section sequences - administrator
|
||||
* has to run the CLI script to do it.
|
||||
* 3. When this script finds an orphaned module it adds it to the section but makes hidden
|
||||
* where CLI script does not change the visiblity specified in the course_modules table.
|
||||
*/
|
||||
function upgrade_course_modules_sequences() {
|
||||
global $DB;
|
||||
|
||||
// Find all modules that point to the section which does not point back to this module.
|
||||
$sequenceconcat = $DB->sql_concat("','", "s.sequence", "','");
|
||||
$moduleconcat = $DB->sql_concat("'%,'", "m.id", "',%'");
|
||||
$sql = "SELECT m.id, m.course, m.section, s.sequence
|
||||
FROM {course_modules} m LEFT OUTER JOIN {course_sections} s
|
||||
ON m.course = s.course and m.section = s.id
|
||||
WHERE s.sequence IS NULL OR ($sequenceconcat NOT LIKE $moduleconcat)
|
||||
ORDER BY m.course";
|
||||
$rs = $DB->get_recordset_sql($sql);
|
||||
$sections = null;
|
||||
foreach ($rs as $cm) {
|
||||
if (!isset($sections[$cm->course])) {
|
||||
// Retrieve all sections for the course (only once for each corrupt course).
|
||||
$sections = array($cm->course =>
|
||||
$DB->get_records('course_sections', array('course' => $cm->course),
|
||||
'section', 'id, section, sequence, visible'));
|
||||
if (empty($sections[$cm->course])) {
|
||||
// Very odd - the course has a module in it but has no sections. Create 0-section.
|
||||
$newsection = array('sequence' => '', 'section' => 0, 'visible' => 1);
|
||||
$newsection['id'] = $DB->insert_record('course_sections',
|
||||
$newsection + array('course' => $cm->course, 'summary' => '', 'summaryformat' => FORMAT_HTML));
|
||||
$sections[$cm->course] = array($newsection['id'] => (object)$newsection);
|
||||
}
|
||||
}
|
||||
// Attempt to find the section that has this module in it's sequence.
|
||||
// If there are several of them, pick the last because this is what get_fast_modinfo() does.
|
||||
$sectionid = null;
|
||||
foreach ($sections[$cm->course] as $section) {
|
||||
if (!empty($section->sequence) && in_array($cm->id, preg_split('/,/', $section->sequence))) {
|
||||
$sectionid = $section->id;
|
||||
}
|
||||
}
|
||||
if ($sectionid) {
|
||||
// Found the section. Update course_module to point to the correct section.
|
||||
$params = array('id' => $cm->id, 'section' => $sectionid);
|
||||
if (!$sections[$cm->course][$sectionid]->visible) {
|
||||
$params['visible'] = 0;
|
||||
}
|
||||
$DB->update_record('course_modules', $params);
|
||||
} else {
|
||||
// No section in the course has this module in it's sequence.
|
||||
if (isset($sections[$cm->course][$cm->section])) {
|
||||
// Try to add module to the section it points to (if it is valid).
|
||||
$sectionid = $cm->section;
|
||||
} else {
|
||||
// Section not found. Just add to the first available section.
|
||||
reset($sections[$cm->course]);
|
||||
$sectionid = key($sections[$cm->course]);
|
||||
}
|
||||
$newsequence = ltrim($sections[$cm->course][$sectionid]->sequence . ',' . $cm->id, ',');
|
||||
$sections[$cm->course][$sectionid]->sequence = $newsequence;
|
||||
$DB->update_record('course_sections', array('id' => $sectionid, 'sequence' => $newsequence));
|
||||
// Make module invisible because it was not displayed at all before this upgrade script.
|
||||
$DB->update_record('course_modules', array('id' => $cm->id, 'section' => $sectionid, 'visible' => 0, 'visibleold' => 0));
|
||||
}
|
||||
}
|
||||
$rs->close();
|
||||
unset($sections);
|
||||
|
||||
// Note that we don't need to reset course cache here because it is reset automatically after upgrade.
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates a single item (course module or course section) to transfer the
|
||||
* availability settings from the old to the new format.
|
||||
*
|
||||
* Note: We do not convert groupmembersonly for modules at present. If we did,
|
||||
* $groupmembersonly would be set to the groupmembersonly option for the
|
||||
* module. Since we don't, it will be set to 0 for modules, and 1 for sections
|
||||
* if they have a grouping.
|
||||
*
|
||||
* @param int $groupmembersonly 1 if activity has groupmembersonly option
|
||||
* @param int $groupingid Grouping id (0 = none)
|
||||
* @param int $availablefrom Available from time (0 = none)
|
||||
* @param int $availableuntil Available until time (0 = none)
|
||||
* @param int $showavailability Show availability (1) or hide activity entirely
|
||||
* @param array $availrecs Records from course_modules/sections_availability
|
||||
* @param array $fieldrecs Records from course_modules/sections_avail_fields
|
||||
*/
|
||||
function upgrade_availability_item($groupmembersonly, $groupingid,
|
||||
$availablefrom, $availableuntil, $showavailability,
|
||||
array $availrecs, array $fieldrecs) {
|
||||
global $CFG, $DB;
|
||||
$conditions = array();
|
||||
$shows = array();
|
||||
|
||||
// Group members only condition (if enabled).
|
||||
if ($CFG->enablegroupmembersonly && $groupmembersonly) {
|
||||
if ($groupingid) {
|
||||
$conditions[] = '{"type":"grouping"' .
|
||||
($groupingid ? ',"id":' . $groupingid : '') . '}';
|
||||
} else {
|
||||
// No grouping specified, so allow any group.
|
||||
$conditions[] = '{"type":"group"}';
|
||||
}
|
||||
// Group members only condition was not displayed to students.
|
||||
$shows[] = 'false';
|
||||
|
||||
// In the unlikely event that the site had enablegroupmembers only
|
||||
// but NOT enableavailability, we need to turn this on now.
|
||||
if (!$CFG->enableavailability) {
|
||||
set_config('enableavailability', 1);
|
||||
}
|
||||
}
|
||||
|
||||
// Date conditions.
|
||||
if ($availablefrom) {
|
||||
$conditions[] = '{"type":"date","d":">=","t":' . $availablefrom . '}';
|
||||
$shows[] = $showavailability ? 'true' : 'false';
|
||||
}
|
||||
if ($availableuntil) {
|
||||
$conditions[] = '{"type":"date","d":"<","t":' . $availableuntil . '}';
|
||||
// Until dates never showed to students.
|
||||
$shows[] = 'false';
|
||||
}
|
||||
|
||||
// Conditions from _availability table.
|
||||
foreach ($availrecs as $rec) {
|
||||
if (!empty($rec->sourcecmid)) {
|
||||
// Completion condition.
|
||||
$conditions[] = '{"type":"completion","cm":' . $rec->sourcecmid .
|
||||
',"e":' . $rec->requiredcompletion . '}';
|
||||
} else {
|
||||
// Grade condition.
|
||||
$minmax = '';
|
||||
if (!empty($rec->grademin)) {
|
||||
$minmax .= ',"min":' . sprintf('%.5f', $rec->grademin);
|
||||
}
|
||||
if (!empty($rec->grademax)) {
|
||||
$minmax .= ',"max":' . sprintf('%.5f', $rec->grademax);
|
||||
}
|
||||
$conditions[] = '{"type":"grade","id":' . $rec->gradeitemid . $minmax . '}';
|
||||
}
|
||||
$shows[] = $showavailability ? 'true' : 'false';
|
||||
}
|
||||
|
||||
// Conditions from _fields table.
|
||||
foreach ($fieldrecs as $rec) {
|
||||
if (isset($rec->userfield)) {
|
||||
// Standard field.
|
||||
$fieldbit = ',"sf":' . json_encode($rec->userfield);
|
||||
} else {
|
||||
// Custom field.
|
||||
$fieldbit = ',"cf":' . json_encode($rec->shortname);
|
||||
}
|
||||
// Value is not included for certain operators.
|
||||
switch($rec->operator) {
|
||||
case 'isempty':
|
||||
case 'isnotempty':
|
||||
$valuebit = '';
|
||||
break;
|
||||
|
||||
default:
|
||||
$valuebit = ',"v":' . json_encode($rec->value);
|
||||
break;
|
||||
}
|
||||
$conditions[] = '{"type":"profile","op":"' . $rec->operator . '"' .
|
||||
$fieldbit . $valuebit . '}';
|
||||
$shows[] = $showavailability ? 'true' : 'false';
|
||||
}
|
||||
|
||||
// If there are some conditions, set them into database.
|
||||
if ($conditions) {
|
||||
return '{"op":"&","showc":[' . implode(',', $shows) . '],' .
|
||||
'"c":[' . implode(',', $conditions) . ']}';
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Using data for a single course-module that has groupmembersonly enabled,
|
||||
* returns the new availability value that incorporates the correct
|
||||
|
||||
@@ -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.
|
||||
|
||||
+12
-235
@@ -43,80 +43,6 @@ class core_upgradelib_testcase extends advanced_testcase {
|
||||
$this->assertFalse(upgrade_stale_php_files_present());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the {@link upgrade_grade_item_fix_sortorder() function with
|
||||
* faked duplicate sortorder data.
|
||||
*/
|
||||
public function test_upgrade_grade_item_fix_sortorder() {
|
||||
global $DB;
|
||||
|
||||
$this->resetAfterTest(true);
|
||||
|
||||
// The purpose of this test is to make sure that after upgrade script
|
||||
// there is no duplicates in the field grade_items.sortorder (for each course)
|
||||
// and the result of query "SELECT id FROM grade_items WHERE courseid=? ORDER BY sortorder, id" does not change.
|
||||
$sequencesql = 'SELECT id FROM {grade_items} WHERE courseid=? ORDER BY sortorder, id';
|
||||
|
||||
// Each set is used for filling the db with fake data and will be representing the result of query:
|
||||
// "SELECT sortorder from {grade_items} WHERE courseid=? ORDER BY id".
|
||||
$testsets = array(
|
||||
// Items that need no action.
|
||||
array(1,2,3),
|
||||
array(5,6,7),
|
||||
array(7,6,1,3,2,5),
|
||||
// Items with sortorder duplicates
|
||||
array(1,2,2,3,3,4,5),
|
||||
// Only one sortorder duplicate.
|
||||
array(1,1),
|
||||
array(3,3),
|
||||
// Non-sequential sortorders with one or multiple duplicates.
|
||||
array(3,3,7,5,6,6,9,10,8,3),
|
||||
array(7,7,3),
|
||||
array(3,4,5,3,5,4,7,1)
|
||||
);
|
||||
$origsequences = array();
|
||||
|
||||
// Generate the data and remember the initial sequence or items.
|
||||
foreach ($testsets as $testset) {
|
||||
$course = $this->getDataGenerator()->create_course();
|
||||
foreach ($testset as $sortorder) {
|
||||
$this->insert_fake_grade_item_sortorder($course->id, $sortorder);
|
||||
}
|
||||
$DB->get_records('grade_items');
|
||||
$origsequences[$course->id] = $DB->get_fieldset_sql($sequencesql, array($course->id));
|
||||
}
|
||||
|
||||
$duplicatedetectionsql = "SELECT courseid, sortorder
|
||||
FROM {grade_items}
|
||||
GROUP BY courseid, sortorder
|
||||
HAVING COUNT(id) > 1";
|
||||
|
||||
// Verify there are duplicates before we start the fix.
|
||||
$dupes = $DB->record_exists_sql($duplicatedetectionsql);
|
||||
$this->assertTrue($dupes);
|
||||
|
||||
// Do the work.
|
||||
upgrade_grade_item_fix_sortorder();
|
||||
|
||||
// Verify that no duplicates are left in the database.
|
||||
$dupes = $DB->record_exists_sql($duplicatedetectionsql);
|
||||
$this->assertFalse($dupes);
|
||||
|
||||
// Verify that sequences are exactly the same as they were before upgrade script.
|
||||
$idx = 0;
|
||||
foreach ($origsequences as $courseid => $origsequence) {
|
||||
if (count(($testsets[$idx])) == count(array_unique($testsets[$idx]))) {
|
||||
// If there were no duplicates for this course verify that sortorders are not modified.
|
||||
$newsortorders = $DB->get_fieldset_sql("SELECT sortorder from {grade_items} WHERE courseid=? ORDER BY id", array($courseid));
|
||||
$this->assertEquals($testsets[$idx], $newsortorders);
|
||||
}
|
||||
$newsequence = $DB->get_fieldset_sql($sequencesql, array($courseid));
|
||||
$this->assertEquals($origsequence, $newsequence,
|
||||
"Sequences do not match for test set $idx : ".join(',', $testsets[$idx]));
|
||||
$idx++;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Populate some fake grade items into the database with specified
|
||||
* sortorder and course id.
|
||||
@@ -150,57 +76,6 @@ class core_upgradelib_testcase extends advanced_testcase {
|
||||
return $DB->get_record('grade_items', array('id' => $item->id));
|
||||
}
|
||||
|
||||
public function test_upgrade_fix_missing_root_folders() {
|
||||
global $DB, $SITE;
|
||||
|
||||
$this->resetAfterTest(true);
|
||||
|
||||
// Setup some broken data...
|
||||
// Create two resources (and associated file areas).
|
||||
$this->setAdminUser();
|
||||
$resource1 = $this->getDataGenerator()->get_plugin_generator('mod_resource')
|
||||
->create_instance(array('course' => $SITE->id));
|
||||
$resource2 = $this->getDataGenerator()->get_plugin_generator('mod_resource')
|
||||
->create_instance(array('course' => $SITE->id));
|
||||
|
||||
// Delete the folder record of resource1 to simulate broken data.
|
||||
$context = context_module::instance($resource1->cmid);
|
||||
$selectargs = array('contextid' => $context->id,
|
||||
'component' => 'mod_resource',
|
||||
'filearea' => 'content',
|
||||
'itemid' => 0);
|
||||
|
||||
// Verify file records exist.
|
||||
$areafilecount = $DB->count_records('files', $selectargs);
|
||||
$this->assertNotEmpty($areafilecount);
|
||||
|
||||
// Delete the folder record.
|
||||
$folderrecord = $selectargs;
|
||||
$folderrecord['filepath'] = '/';
|
||||
$folderrecord['filename'] = '.';
|
||||
|
||||
// Get previous folder record.
|
||||
$oldrecord = $DB->get_record('files', $folderrecord);
|
||||
$DB->delete_records('files', $folderrecord);
|
||||
|
||||
// Verify the folder record has been removed.
|
||||
$newareafilecount = $DB->count_records('files', $selectargs);
|
||||
$this->assertSame($newareafilecount, $areafilecount - 1);
|
||||
|
||||
$this->assertFalse($DB->record_exists('files', $folderrecord));
|
||||
|
||||
// Run the upgrade step!
|
||||
upgrade_fix_missing_root_folders();
|
||||
|
||||
// Verify the folder record has been restored.
|
||||
$newareafilecount = $DB->count_records('files', $selectargs);
|
||||
$this->assertSame($newareafilecount, $areafilecount);
|
||||
|
||||
$newrecord = $DB->get_record('files', $folderrecord, '*', MUST_EXIST);
|
||||
// Verify the hash is correctly created.
|
||||
$this->assertSame($oldrecord->pathnamehash, $newrecord->pathnamehash);
|
||||
}
|
||||
|
||||
public function test_upgrade_fix_missing_root_folders_draft() {
|
||||
global $DB, $SITE;
|
||||
|
||||
@@ -245,115 +120,6 @@ class core_upgradelib_testcase extends advanced_testcase {
|
||||
$this->assertEquals($originalhash, $newhash);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests the upgrade of an individual course-module or section from the
|
||||
* old to new availability system. (This test does not use the database
|
||||
* so it can run any time.)
|
||||
*/
|
||||
public function test_upgrade_availability_item() {
|
||||
global $CFG;
|
||||
$this->resetAfterTest();
|
||||
|
||||
// This function is in the other upgradelib.
|
||||
require_once($CFG->libdir . '/db/upgradelib.php');
|
||||
|
||||
// Groupmembersonly (or nothing). Show option on but ignored.
|
||||
// Note: This $CFG option doesn't exist any more but we are testing the
|
||||
// upgrade function so it did exist then...
|
||||
$CFG->enablegroupmembersonly = 0;
|
||||
$this->assertNull(
|
||||
upgrade_availability_item(1, 0, 0, 0, 1, array(), array()));
|
||||
$CFG->enablegroupmembersonly = 1;
|
||||
$this->assertNull(
|
||||
upgrade_availability_item(0, 0, 0, 0, 1, array(), array()));
|
||||
$this->assertEquals(
|
||||
'{"op":"&","showc":[false],"c":[{"type":"group"}]}',
|
||||
upgrade_availability_item(1, 0, 0, 0, 1, array(), array()));
|
||||
$this->assertEquals(
|
||||
'{"op":"&","showc":[false],"c":[{"type":"grouping","id":4}]}',
|
||||
upgrade_availability_item(1, 4, 0, 0, 1, array(), array()));
|
||||
|
||||
// Dates (with show/hide options - until date always hides).
|
||||
$this->assertEquals(
|
||||
'{"op":"&","showc":[true],"c":[{"type":"date","d":">=","t":996}]}',
|
||||
upgrade_availability_item(0, 0, 996, 0, 1, array(), array()));
|
||||
$this->assertEquals(
|
||||
'{"op":"&","showc":[false],"c":[{"type":"date","d":">=","t":997}]}',
|
||||
upgrade_availability_item(0, 0, 997, 0, 0, array(), array()));
|
||||
$this->assertEquals(
|
||||
'{"op":"&","showc":[false],"c":[{"type":"date","d":"<","t":998}]}',
|
||||
upgrade_availability_item(0, 0, 0, 998, 1, array(), array()));
|
||||
$this->assertEquals(
|
||||
'{"op":"&","showc":[true,false],"c":[' .
|
||||
'{"type":"date","d":">=","t":995},{"type":"date","d":"<","t":999}]}',
|
||||
upgrade_availability_item(0, 0, 995, 999, 1, array(), array()));
|
||||
|
||||
// Grade (show option works as normal).
|
||||
$availrec = (object)array(
|
||||
'sourcecmid' => null, 'requiredcompletion' => null,
|
||||
'gradeitemid' => 13, 'grademin' => null, 'grademax' => null);
|
||||
$this->assertEquals(
|
||||
'{"op":"&","showc":[true],"c":[{"type":"grade","id":13}]}',
|
||||
upgrade_availability_item(0, 0, 0, 0, 1, array($availrec), array()));
|
||||
$availrec->grademin = 4.1;
|
||||
$this->assertEquals(
|
||||
'{"op":"&","showc":[false],"c":[{"type":"grade","id":13,"min":4.10000}]}',
|
||||
upgrade_availability_item(0, 0, 0, 0, 0, array($availrec), array()));
|
||||
$availrec->grademax = 9.9;
|
||||
$this->assertEquals(
|
||||
'{"op":"&","showc":[true],"c":[{"type":"grade","id":13,"min":4.10000,"max":9.90000}]}',
|
||||
upgrade_availability_item(0, 0, 0, 0, 1, array($availrec), array()));
|
||||
$availrec->grademin = null;
|
||||
$this->assertEquals(
|
||||
'{"op":"&","showc":[true],"c":[{"type":"grade","id":13,"max":9.90000}]}',
|
||||
upgrade_availability_item(0, 0, 0, 0, 1, array($availrec), array()));
|
||||
|
||||
// Completion (show option normal).
|
||||
$availrec->grademax = null;
|
||||
$availrec->gradeitemid = null;
|
||||
$availrec->sourcecmid = 666;
|
||||
$availrec->requiredcompletion = 1;
|
||||
$this->assertEquals(
|
||||
'{"op":"&","showc":[true],"c":[{"type":"completion","cm":666,"e":1}]}',
|
||||
upgrade_availability_item(0, 0, 0, 0, 1, array($availrec), array()));
|
||||
$this->assertEquals(
|
||||
'{"op":"&","showc":[false],"c":[{"type":"completion","cm":666,"e":1}]}',
|
||||
upgrade_availability_item(0, 0, 0, 0, 0, array($availrec), array()));
|
||||
|
||||
// Profile conditions (custom/standard field, values/not, show option normal).
|
||||
$fieldrec = (object)array('userfield' => 'email', 'operator' => 'isempty',
|
||||
'value' => '', 'shortname' => null);
|
||||
$this->assertEquals(
|
||||
'{"op":"&","showc":[true],"c":[{"type":"profile","op":"isempty","sf":"email"}]}',
|
||||
upgrade_availability_item(0, 0, 0, 0, 1, array(), array($fieldrec)));
|
||||
$fieldrec->value = '@';
|
||||
$fieldrec->operator = 'contains';
|
||||
$this->assertEquals(
|
||||
'{"op":"&","showc":[true],"c":[{"type":"profile","op":"contains","sf":"email","v":"@"}]}',
|
||||
upgrade_availability_item(0, 0, 0, 0, 1, array(), array($fieldrec)));
|
||||
$fieldrec->operator = 'isnotempty';
|
||||
$fieldrec->userfield = null;
|
||||
$fieldrec->shortname = 'frogtype';
|
||||
$this->assertEquals(
|
||||
'{"op":"&","showc":[false],"c":[{"type":"profile","op":"isnotempty","cf":"frogtype"}]}',
|
||||
upgrade_availability_item(0, 0, 0, 0, 0, array(), array($fieldrec)));
|
||||
|
||||
// Everything at once.
|
||||
$this->assertEquals('{"op":"&","showc":[false,true,false,true,true,true],' .
|
||||
'"c":[{"type":"grouping","id":13},' .
|
||||
'{"type":"date","d":">=","t":990},' .
|
||||
'{"type":"date","d":"<","t":991},' .
|
||||
'{"type":"grade","id":665,"min":70.00000},' .
|
||||
'{"type":"completion","cm":42,"e":2},' .
|
||||
'{"type":"profile","op":"isempty","sf":"email"}]}',
|
||||
upgrade_availability_item(1, 13, 990, 991, 1, array(
|
||||
(object)array('sourcecmid' => null, 'gradeitemid' => 665, 'grademin' => 70),
|
||||
(object)array('sourcecmid' => 42, 'gradeitemid' => null, 'requiredcompletion' => 2)
|
||||
), array(
|
||||
(object)array('userfield' => 'email', 'shortname' => null, 'operator' => 'isempty'),
|
||||
)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test upgrade minmaxgrade step.
|
||||
*/
|
||||
@@ -488,6 +254,8 @@ class core_upgradelib_testcase extends advanced_testcase {
|
||||
|
||||
$this->resetAfterTest(true);
|
||||
|
||||
require_once($CFG->libdir . '/db/upgradelib.php');
|
||||
|
||||
$c = array();
|
||||
$a = array();
|
||||
$gi = array();
|
||||
@@ -551,8 +319,11 @@ class core_upgradelib_testcase extends advanced_testcase {
|
||||
*/
|
||||
public function test_upgrade_calculated_grade_items_freeze() {
|
||||
global $DB, $CFG;
|
||||
|
||||
$this->resetAfterTest();
|
||||
|
||||
require_once($CFG->libdir . '/db/upgradelib.php');
|
||||
|
||||
// Create a user.
|
||||
$user = $this->getDataGenerator()->create_user();
|
||||
|
||||
@@ -679,8 +450,11 @@ class core_upgradelib_testcase extends advanced_testcase {
|
||||
|
||||
function test_upgrade_calculated_grade_items_regrade() {
|
||||
global $DB, $CFG;
|
||||
|
||||
$this->resetAfterTest();
|
||||
|
||||
require_once($CFG->libdir . '/db/upgradelib.php');
|
||||
|
||||
// Create a user.
|
||||
$user = $this->getDataGenerator()->create_user();
|
||||
|
||||
@@ -743,9 +517,12 @@ class core_upgradelib_testcase extends advanced_testcase {
|
||||
}
|
||||
|
||||
public function test_upgrade_course_tags() {
|
||||
global $DB;
|
||||
global $DB, $CFG;
|
||||
|
||||
$this->resetAfterTest();
|
||||
|
||||
require_once($CFG->libdir . '/db/upgradelib.php');
|
||||
|
||||
// Running upgrade script when there are no tags.
|
||||
upgrade_course_tags();
|
||||
$this->assertFalse($DB->record_exists('tag_instance', array()));
|
||||
|
||||
@@ -3,6 +3,19 @@ information provided here is intended especially for developers.
|
||||
|
||||
=== 3.1 ===
|
||||
|
||||
* The following functions, previously used (exclusively) by upgrade steps are not available
|
||||
anymore because of the upgrade cleanup performed for this version. See MDL-51580 for more info:
|
||||
- upgrade_mysql_fix_unsigned_and_lob_columns()
|
||||
- upgrade_course_completion_remove_duplicates()
|
||||
- upgrade_save_orphaned_questions()
|
||||
- upgrade_rename_old_backup_files_using_shortname()
|
||||
- upgrade_mssql_nvarcharmax()
|
||||
- upgrade_mssql_varbinarymax()
|
||||
- upgrade_fix_missing_root_folders()
|
||||
- upgrade_course_modules_sequences()
|
||||
- upgrade_grade_item_fix_sortorder()
|
||||
- upgrade_availability_item()
|
||||
|
||||
* Plugins can extend the navigation for user by declaring the following callback:
|
||||
<frankenstyle>_extend_navigation_user(navigation_node $parentnode, stdClass $user,
|
||||
context_user $context, stdClass $course,
|
||||
|
||||
@@ -1915,300 +1915,6 @@ function admin_mnet_method_profile(Zend_Server_Reflection_Function_Abstract $fun
|
||||
return $profile;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* This function finds duplicate records (based on combinations of fields that should be unique)
|
||||
* and then progamatically generated a "most correct" version of the data, update and removing
|
||||
* records as appropriate
|
||||
*
|
||||
* Thanks to Dan Marsden for help
|
||||
*
|
||||
* @param string $table Table name
|
||||
* @param array $uniques Array of field names that should be unique
|
||||
* @param array $fieldstocheck Array of fields to generate "correct" data from (optional)
|
||||
* @return void
|
||||
*/
|
||||
function upgrade_course_completion_remove_duplicates($table, $uniques, $fieldstocheck = array()) {
|
||||
global $DB;
|
||||
|
||||
// Find duplicates
|
||||
$sql_cols = implode(', ', $uniques);
|
||||
|
||||
$sql = "SELECT {$sql_cols} FROM {{$table}} GROUP BY {$sql_cols} HAVING (count(id) > 1)";
|
||||
$duplicates = $DB->get_recordset_sql($sql, array());
|
||||
|
||||
// Loop through duplicates
|
||||
foreach ($duplicates as $duplicate) {
|
||||
$pointer = 0;
|
||||
|
||||
// Generate SQL for finding records with these duplicate uniques
|
||||
$sql_select = implode(' = ? AND ', $uniques).' = ?'; // builds "fieldname = ? AND fieldname = ?"
|
||||
$uniq_values = array();
|
||||
foreach ($uniques as $u) {
|
||||
$uniq_values[] = $duplicate->$u;
|
||||
}
|
||||
|
||||
$sql_order = implode(' DESC, ', $uniques).' DESC'; // builds "fieldname DESC, fieldname DESC"
|
||||
|
||||
// Get records with these duplicate uniques
|
||||
$records = $DB->get_records_select(
|
||||
$table,
|
||||
$sql_select,
|
||||
$uniq_values,
|
||||
$sql_order
|
||||
);
|
||||
|
||||
// Loop through and build a "correct" record, deleting the others
|
||||
$needsupdate = false;
|
||||
$origrecord = null;
|
||||
foreach ($records as $record) {
|
||||
$pointer++;
|
||||
if ($pointer === 1) { // keep 1st record but delete all others.
|
||||
$origrecord = $record;
|
||||
} else {
|
||||
// If we have fields to check, update original record
|
||||
if ($fieldstocheck) {
|
||||
// we need to keep the "oldest" of all these fields as the valid completion record.
|
||||
// but we want to ignore null values
|
||||
foreach ($fieldstocheck as $f) {
|
||||
if ($record->$f && (($origrecord->$f > $record->$f) || !$origrecord->$f)) {
|
||||
$origrecord->$f = $record->$f;
|
||||
$needsupdate = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
$DB->delete_records($table, array('id' => $record->id));
|
||||
}
|
||||
}
|
||||
if ($needsupdate || isset($origrecord->reaggregate)) {
|
||||
// If this table has a reaggregate field, update to force recheck on next cron run
|
||||
if (isset($origrecord->reaggregate)) {
|
||||
$origrecord->reaggregate = time();
|
||||
}
|
||||
$DB->update_record($table, $origrecord);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Find questions missing an existing category and associate them with
|
||||
* a category which purpose is to gather them.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function upgrade_save_orphaned_questions() {
|
||||
global $DB;
|
||||
|
||||
// Looking for orphaned questions
|
||||
$orphans = $DB->record_exists_select('question',
|
||||
'NOT EXISTS (SELECT 1 FROM {question_categories} WHERE {question_categories}.id = {question}.category)');
|
||||
if (!$orphans) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Generate a unique stamp for the orphaned questions category, easier to identify it later on
|
||||
$uniquestamp = "unknownhost+120719170400+orphan";
|
||||
$systemcontext = context_system::instance();
|
||||
|
||||
// Create the orphaned category at system level
|
||||
$cat = $DB->get_record('question_categories', array('stamp' => $uniquestamp,
|
||||
'contextid' => $systemcontext->id));
|
||||
if (!$cat) {
|
||||
$cat = new stdClass();
|
||||
$cat->parent = 0;
|
||||
$cat->contextid = $systemcontext->id;
|
||||
$cat->name = get_string('orphanedquestionscategory', 'question');
|
||||
$cat->info = get_string('orphanedquestionscategoryinfo', 'question');
|
||||
$cat->sortorder = 999;
|
||||
$cat->stamp = $uniquestamp;
|
||||
$cat->id = $DB->insert_record("question_categories", $cat);
|
||||
}
|
||||
|
||||
// Set a category to those orphans
|
||||
$params = array('catid' => $cat->id);
|
||||
$DB->execute('UPDATE {question} SET category = :catid WHERE NOT EXISTS
|
||||
(SELECT 1 FROM {question_categories} WHERE {question_categories}.id = {question}.category)', $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* Rename old backup files to current backup files.
|
||||
*
|
||||
* When added the setting 'backup_shortname' (MDL-28657) the backup file names did not contain the id of the course.
|
||||
* Further we fixed that behaviour by forcing the id to be always present in the file name (MDL-33812).
|
||||
* This function will explore the backup directory and attempt to rename the previously created files to include
|
||||
* the id in the name. Doing this will put them back in the process of deleting the excess backups for each course.
|
||||
*
|
||||
* This function manually recreates the file name, instead of using
|
||||
* {@link backup_plan_dbops::get_default_backup_filename()}, use it carefully if you're using it outside of the
|
||||
* usual upgrade process.
|
||||
*
|
||||
* @see backup_cron_automated_helper::remove_excess_backups()
|
||||
* @link http://tracker.moodle.org/browse/MDL-35116
|
||||
* @return void
|
||||
* @since Moodle 2.4
|
||||
*/
|
||||
function upgrade_rename_old_backup_files_using_shortname() {
|
||||
global $CFG;
|
||||
$dir = get_config('backup', 'backup_auto_destination');
|
||||
$useshortname = get_config('backup', 'backup_shortname');
|
||||
if (empty($dir) || !is_dir($dir) || !is_writable($dir)) {
|
||||
return;
|
||||
}
|
||||
|
||||
require_once($CFG->dirroot.'/backup/util/includes/backup_includes.php');
|
||||
$backupword = str_replace(' ', '_', core_text::strtolower(get_string('backupfilename')));
|
||||
$backupword = trim(clean_filename($backupword), '_');
|
||||
$filename = $backupword . '-' . backup::FORMAT_MOODLE . '-' . backup::TYPE_1COURSE . '-';
|
||||
$regex = '#^'.preg_quote($filename, '#').'.*\.mbz$#';
|
||||
$thirtyapril = strtotime('30 April 2012 00:00');
|
||||
|
||||
// Reading the directory.
|
||||
if (!$files = scandir($dir)) {
|
||||
return;
|
||||
}
|
||||
foreach ($files as $file) {
|
||||
// Skip directories and files which do not start with the common prefix.
|
||||
// This avoids working on files which are not related to this issue.
|
||||
if (!is_file($dir . '/' . $file) || !preg_match($regex, $file)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Extract the information from the XML file.
|
||||
try {
|
||||
$bcinfo = backup_general_helper::get_backup_information_from_mbz($dir . '/' . $file);
|
||||
} catch (backup_helper_exception $e) {
|
||||
// Some error while retrieving the backup informations, skipping...
|
||||
continue;
|
||||
}
|
||||
|
||||
// Make sure this a course backup.
|
||||
if ($bcinfo->format !== backup::FORMAT_MOODLE || $bcinfo->type !== backup::TYPE_1COURSE) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Skip the backups created before the short name option was initially introduced (MDL-28657).
|
||||
// This was integrated on the 2nd of May 2012. Let's play safe with timezone and use the 30th of April.
|
||||
if ($bcinfo->backup_date < $thirtyapril) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Let's check if the file name contains the ID where it is supposed to be, if it is the case then
|
||||
// we will skip the file. Of course it could happen that the course ID is identical to the course short name
|
||||
// even though really unlikely, but then renaming this file is not necessary. If the ID is not found in the
|
||||
// file name then it was probably the short name which was used.
|
||||
$idfilename = $filename . $bcinfo->original_course_id . '-';
|
||||
$idregex = '#^'.preg_quote($idfilename, '#').'.*\.mbz$#';
|
||||
if (preg_match($idregex, $file)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Generating the file name manually. We do not use backup_plan_dbops::get_default_backup_filename() because
|
||||
// it will query the database to get some course information, and the course could not exist any more.
|
||||
$newname = $filename . $bcinfo->original_course_id . '-';
|
||||
if ($useshortname) {
|
||||
$shortname = str_replace(' ', '_', $bcinfo->original_course_shortname);
|
||||
$shortname = core_text::strtolower(trim(clean_filename($shortname), '_'));
|
||||
$newname .= $shortname . '-';
|
||||
}
|
||||
|
||||
$backupdateformat = str_replace(' ', '_', get_string('backupnameformat', 'langconfig'));
|
||||
$date = userdate($bcinfo->backup_date, $backupdateformat, 99, false);
|
||||
$date = core_text::strtolower(trim(clean_filename($date), '_'));
|
||||
$newname .= $date;
|
||||
|
||||
if (isset($bcinfo->root_settings['users']) && !$bcinfo->root_settings['users']) {
|
||||
$newname .= '-nu';
|
||||
} else if (isset($bcinfo->root_settings['anonymize']) && $bcinfo->root_settings['anonymize']) {
|
||||
$newname .= '-an';
|
||||
}
|
||||
$newname .= '.mbz';
|
||||
|
||||
// Final check before attempting the renaming.
|
||||
if ($newname == $file || file_exists($dir . '/' . $newname)) {
|
||||
continue;
|
||||
}
|
||||
@rename($dir . '/' . $file, $dir . '/' . $newname);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Detect duplicate grade item sortorders and resort the
|
||||
* items to remove them.
|
||||
*/
|
||||
function upgrade_grade_item_fix_sortorder() {
|
||||
global $DB;
|
||||
|
||||
// The simple way to fix these sortorder duplicates would be simply to resort each
|
||||
// affected course. But in order to reduce the impact of this upgrade step we're trying
|
||||
// to do it more efficiently by doing a series of update statements rather than updating
|
||||
// every single grade item in affected courses.
|
||||
|
||||
$sql = "SELECT DISTINCT g1.courseid
|
||||
FROM {grade_items} g1
|
||||
JOIN {grade_items} g2 ON g1.courseid = g2.courseid
|
||||
WHERE g1.sortorder = g2.sortorder AND g1.id != g2.id
|
||||
ORDER BY g1.courseid ASC";
|
||||
foreach ($DB->get_fieldset_sql($sql) as $courseid) {
|
||||
$transaction = $DB->start_delegated_transaction();
|
||||
$items = $DB->get_records('grade_items', array('courseid' => $courseid), '', 'id, sortorder, sortorder AS oldsort');
|
||||
|
||||
// Get all duplicates in course order, highest sort order, and higest id first so that we can make space at the
|
||||
// bottom higher end of the sort orders and work down by id.
|
||||
$sql = "SELECT DISTINCT g1.id, g1.sortorder
|
||||
FROM {grade_items} g1
|
||||
JOIN {grade_items} g2 ON g1.courseid = g2.courseid
|
||||
WHERE g1.sortorder = g2.sortorder AND g1.id != g2.id AND g1.courseid = :courseid
|
||||
ORDER BY g1.sortorder DESC, g1.id DESC";
|
||||
|
||||
// This is the O(N*N) like the database version we're replacing, but at least the constants are a billion times smaller...
|
||||
foreach ($DB->get_records_sql($sql, array('courseid' => $courseid)) as $duplicate) {
|
||||
foreach ($items as $item) {
|
||||
if ($item->sortorder > $duplicate->sortorder || ($item->sortorder == $duplicate->sortorder && $item->id > $duplicate->id)) {
|
||||
$item->sortorder += 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
foreach ($items as $item) {
|
||||
if ($item->sortorder != $item->oldsort) {
|
||||
$DB->update_record('grade_items', array('id' => $item->id, 'sortorder' => $item->sortorder));
|
||||
}
|
||||
}
|
||||
|
||||
$transaction->allow_commit();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Detect file areas with missing root directory records and add them.
|
||||
*/
|
||||
function upgrade_fix_missing_root_folders() {
|
||||
global $DB, $USER;
|
||||
|
||||
$transaction = $DB->start_delegated_transaction();
|
||||
|
||||
$sql = "SELECT contextid, component, filearea, itemid
|
||||
FROM {files}
|
||||
WHERE (component <> 'user' OR filearea <> 'draft')
|
||||
GROUP BY contextid, component, filearea, itemid
|
||||
HAVING MAX(CASE WHEN filename = '.' AND filepath = '/' THEN 1 ELSE 0 END) = 0";
|
||||
|
||||
$rs = $DB->get_recordset_sql($sql);
|
||||
$defaults = array('filepath' => '/',
|
||||
'filename' => '.',
|
||||
'userid' => 0, // Don't rely on any particular user for these system records.
|
||||
'filesize' => 0,
|
||||
'timecreated' => time(),
|
||||
'timemodified' => time(),
|
||||
'contenthash' => sha1(''));
|
||||
foreach ($rs as $r) {
|
||||
$pathhash = sha1("/$r->contextid/$r->component/$r->filearea/$r->itemid/.");
|
||||
$DB->insert_record('files', (array)$r + $defaults +
|
||||
array('pathnamehash' => $pathhash));
|
||||
}
|
||||
$rs->close();
|
||||
$transaction->allow_commit();
|
||||
}
|
||||
|
||||
/**
|
||||
* Detect draft file areas with missing root directory records and add them.
|
||||
*/
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
|
||||
+3
-455
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,54 +0,0 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// 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
|
||||
// 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/>.
|
||||
|
||||
/**
|
||||
* Assignment upgrade script.
|
||||
*
|
||||
* @package mod_assignment
|
||||
* @copyright 2013 Damyon Wiese
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
/**
|
||||
* Inform admins about assignments that still need upgrading.
|
||||
*/
|
||||
function mod_assignment_pending_upgrades_notification($count) {
|
||||
$admins = get_admins();
|
||||
|
||||
if (empty($admins)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$a = new stdClass;
|
||||
$a->count = $count;
|
||||
$a->docsurl = get_docs_url('Assignment_upgrade_tool');
|
||||
foreach ($admins as $admin) {
|
||||
$message = new stdClass();
|
||||
$message->component = 'moodle';
|
||||
$message->name = 'notices';
|
||||
$message->userfrom = \core_user::get_noreply_user();
|
||||
$message->userto = $admin;
|
||||
$message->smallmessage = get_string('pendingupgrades_message_small', 'mod_assignment');
|
||||
$message->subject = get_string('pendingupgrades_message_subject', 'mod_assignment');
|
||||
$message->fullmessage = get_string('pendingupgrades_message_content', 'mod_assignment', $a);
|
||||
$message->fullmessagehtml = get_string('pendingupgrades_message_content', 'mod_assignment', $a);
|
||||
$message->fullmessageformat = FORMAT_PLAIN;
|
||||
$message->notification = 1;
|
||||
message_send($message);
|
||||
}
|
||||
}
|
||||
@@ -41,7 +41,4 @@ $string['page-mod-assignment-submissions'] = 'Assignment module submission page'
|
||||
$string['pluginname'] = 'Assignment 2.2 (Disabled)';
|
||||
$string['upgradenotification'] = 'This activity is based on an older assignment module.';
|
||||
$string['viewassignmentupgradetool'] = 'View the assignment upgrade tool';
|
||||
$string['pendingupgrades_message_small'] = 'This plugin has been disabled. All remaining assignments must be upgraded to the new assignment module using the assignment upgrade tool.';
|
||||
$string['pendingupgrades_message_subject'] = 'Important information regarding Assignment 2.2';
|
||||
$string['pendingupgrades_message_content'] = 'As part of the upgrade to Moodle 2.7, the legacy Assignment 2.2 activity has been disabled. Backups from the legacy Assignment 2.2 activity will seamlessly restore to the newer Assignment activity. All remaining instances of the legacy Assignment 2.2 activity must be upgraded using the assignment upgrade tool {$a->docsurl}. There are {$a->count} instances of the legacy Assignment 2.2 activity on this site that require upgrading. Users will not be able to access the content of these activities until they have been upgraded.';
|
||||
$string['pluginadministration'] = 'Assignment 2.2 (Disabled) administration';
|
||||
|
||||
@@ -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.
|
||||
|
||||
|
||||
@@ -1,172 +0,0 @@
|
||||
<?php
|
||||
// This file is part of Book module for Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// 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
|
||||
// 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/>.
|
||||
|
||||
/**
|
||||
* Book module upgrade related helper functions
|
||||
*
|
||||
* @package mod_book
|
||||
* @copyright 2010 Petr Skoda {@link http://skodak.org}
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
defined('MOODLE_INTERNAL') || die;
|
||||
|
||||
/**
|
||||
* Migrate book files stored in moddata folders.
|
||||
*
|
||||
* Please note it was a big mistake to store the files there in the first place!
|
||||
*
|
||||
* @param stdClass $book
|
||||
* @param stdClass $context
|
||||
* @param string $path
|
||||
* @return void
|
||||
*/
|
||||
function mod_book_migrate_moddata_dir_to_legacy($book, $context, $path) {
|
||||
global $OUTPUT, $CFG;
|
||||
|
||||
$base = "$CFG->dataroot/$book->course/$CFG->moddata/book/$book->id";
|
||||
$fulldir = $base.$path;
|
||||
|
||||
if (!is_dir($fulldir)) {
|
||||
// does not exist
|
||||
return;
|
||||
}
|
||||
|
||||
$fs = get_file_storage();
|
||||
$items = new DirectoryIterator($fulldir);
|
||||
|
||||
foreach ($items as $item) {
|
||||
if ($item->isDot()) {
|
||||
unset($item); // release file handle
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($item->isLink()) {
|
||||
// do not follow symlinks - they were never supported in moddata, sorry
|
||||
unset($item); // release file handle
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($item->isFile()) {
|
||||
if (!$item->isReadable()) {
|
||||
echo $OUTPUT->notification(" File not readable, skipping: ".$fulldir.$item->getFilename());
|
||||
unset($item); // release file handle
|
||||
continue;
|
||||
}
|
||||
|
||||
$filepath = clean_param("/$CFG->moddata/book/$book->id".$path, PARAM_PATH);
|
||||
$filename = clean_param($item->getFilename(), PARAM_FILE);
|
||||
|
||||
if ($filename === '') {
|
||||
// unsupported chars, sorry
|
||||
unset($item); // release file handle
|
||||
continue;
|
||||
}
|
||||
|
||||
if (core_text::strlen($filepath) > 255) {
|
||||
echo $OUTPUT->notification(" File path longer than 255 chars, skipping: ".$fulldir.$item->getFilename());
|
||||
unset($item); // release file handle
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!$fs->file_exists($context->id, 'course', 'legacy', '0', $filepath, $filename)) {
|
||||
$file_record = array('contextid'=>$context->id, 'component'=>'course', 'filearea'=>'legacy', 'itemid'=>0, 'filepath'=>$filepath, 'filename'=>$filename,
|
||||
'timecreated'=>$item->getCTime(), 'timemodified'=>$item->getMTime());
|
||||
$fs->create_file_from_pathname($file_record, $fulldir.$item->getFilename());
|
||||
}
|
||||
$oldpathname = $fulldir.$item->getFilename();
|
||||
unset($item); // release file handle
|
||||
@unlink($oldpathname);
|
||||
|
||||
} else {
|
||||
// migrate recursively all subdirectories
|
||||
$oldpathname = $base.$item->getFilename().'/';
|
||||
$subpath = $path.$item->getFilename().'/';
|
||||
unset($item); // release file handle
|
||||
mod_book_migrate_moddata_dir_to_legacy($book, $context, $subpath);
|
||||
@rmdir($oldpathname); // deletes dir if empty
|
||||
}
|
||||
}
|
||||
unset($items); // release file handles
|
||||
}
|
||||
|
||||
/**
|
||||
* Migrate legacy files in intro and chapters
|
||||
* @return void
|
||||
*/
|
||||
function mod_book_migrate_all_areas() {
|
||||
global $DB, $OUTPUT;
|
||||
|
||||
$rsbooks = $DB->get_recordset('book');
|
||||
foreach($rsbooks as $book) {
|
||||
upgrade_set_timeout(360); // set up timeout, may also abort execution
|
||||
$cm = get_coursemodule_from_instance('book', $book->id);
|
||||
if (empty($cm) || empty($cm->id)) {
|
||||
echo $OUTPUT->notification("Course module not found, skipping: {$book->name}");
|
||||
continue;
|
||||
}
|
||||
$context = context_module::instance($cm->id);
|
||||
mod_book_migrate_area($book, 'intro', 'book', $book->course, $context, 'mod_book', 'intro', 0);
|
||||
|
||||
$rschapters = $DB->get_recordset('book_chapters', array('bookid'=>$book->id));
|
||||
foreach ($rschapters as $chapter) {
|
||||
mod_book_migrate_area($chapter, 'content', 'book_chapters', $book->course, $context, 'mod_book', 'chapter', $chapter->id);
|
||||
}
|
||||
$rschapters->close();
|
||||
}
|
||||
$rsbooks->close();
|
||||
}
|
||||
|
||||
/**
|
||||
* Migrate one area, this should be probably part of moodle core...
|
||||
*
|
||||
* @param stdClass $record object to migrate files (book, chapter)
|
||||
* @param string $field field in the record we are going to migrate
|
||||
* @param string $table DB table containing the information to migrate
|
||||
* @param int $courseid id of the course the book module belongs to
|
||||
* @param context_module $context context of the book module
|
||||
* @param string $component component to be used for the migrated files
|
||||
* @param string $filearea filearea to be used for the migrated files
|
||||
* @param int $itemid id to be used for the migrated files
|
||||
* @return void
|
||||
*/
|
||||
function mod_book_migrate_area($record, $field, $table, $courseid, $context, $component, $filearea, $itemid) {
|
||||
global $CFG, $DB;
|
||||
|
||||
$fs = get_file_storage();
|
||||
|
||||
foreach(array(get_site()->id, $courseid) as $cid) {
|
||||
$matches = null;
|
||||
$ooldcontext = context_course::instance($cid);
|
||||
if (preg_match_all("|$CFG->wwwroot/file.php(\?file=)?/$cid(/[^\s'\"&\?#]+)|", $record->$field, $matches)) {
|
||||
$file_record = array('contextid'=>$context->id, 'component'=>$component, 'filearea'=>$filearea, 'itemid'=>$itemid);
|
||||
foreach ($matches[2] as $i=>$filepath) {
|
||||
if (!$file = $fs->get_file_by_hash(sha1("/$ooldcontext->id/course/legacy/0".$filepath))) {
|
||||
continue;
|
||||
}
|
||||
try {
|
||||
if (!$newfile = $fs->get_file_by_hash(sha1("/$context->id/$component/$filearea/$itemid".$filepath))) {
|
||||
$fs->create_file_from_storedfile($file_record, $file);
|
||||
}
|
||||
$record->$field = str_replace($matches[0][$i], '@@PLUGINFILE@@'.$filepath, $record->$field);
|
||||
} catch (Exception $ex) {
|
||||
// ignore problems
|
||||
}
|
||||
$DB->set_field($table, $field, $record->$field, array('id'=>$record->id));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,13 @@
|
||||
This files describes API changes in the book code.
|
||||
|
||||
=== 3.1 ===
|
||||
|
||||
* The following functions, previously used (exclusively) by upgrade steps are not available
|
||||
anymore because of the upgrade cleanup performed for this version. See MDL-51580 for more info:
|
||||
- mod_book_migrate_moddata_dir_to_legacy()
|
||||
- mod_book_migrate_all_areas()
|
||||
- mod_book_migrate_area()
|
||||
|
||||
=== 3.0 ===
|
||||
|
||||
* External function mod_book_external::get_books_by_courses returned parameter "name" has been changed to PARAM_RAW,
|
||||
@@ -8,4 +16,4 @@ This files describes API changes in the book code.
|
||||
=== 2.7 ===
|
||||
|
||||
* bogus legacy log calls were removed
|
||||
* \mod_book\event\chapter_deleted::set_legacy_logdata() was removed
|
||||
* \mod_book\event\chapter_deleted::set_legacy_logdata() was removed
|
||||
|
||||
+3
-23
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
|
||||
+3
-111
@@ -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
-26
@@ -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.
|
||||
|
||||
+1
-248
@@ -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
-26
@@ -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.
|
||||
|
||||
+5
-49
@@ -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.
|
||||
|
||||
+3
-126
@@ -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.
|
||||
|
||||
@@ -1,55 +0,0 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// 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
|
||||
// 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/>.
|
||||
|
||||
/**
|
||||
* Locallib.
|
||||
*
|
||||
* @package portfolio_boxnet
|
||||
* @copyright 2013 Frédéric Massart
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
/**
|
||||
* Send a message to the admin in regard with the APIv1 migration.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function portfolio_boxnet_admin_upgrade_notification() {
|
||||
$admins = get_admins();
|
||||
|
||||
if (empty($admins)) {
|
||||
return;
|
||||
}
|
||||
$a = new stdClass();
|
||||
$a->docsurl = get_docs_url('Box.net_APIv1_migration');
|
||||
|
||||
foreach ($admins as $admin) {
|
||||
$message = new stdClass();
|
||||
$message->component = 'moodle';
|
||||
$message->name = 'notices';
|
||||
$message->userfrom = get_admin();
|
||||
$message->userto = $admin;
|
||||
$message->smallmessage = get_string('apiv1migration_message_small', 'portfolio_boxnet');
|
||||
$message->subject = get_string('apiv1migration_message_subject', 'portfolio_boxnet');
|
||||
$message->fullmessage = get_string('apiv1migration_message_content', 'portfolio_boxnet', $a);
|
||||
$message->fullmessagehtml = get_string('apiv1migration_message_content', 'portfolio_boxnet', $a);
|
||||
$message->fullmessageformat = FORMAT_PLAIN;
|
||||
$message->notification = 1;
|
||||
message_send($message);
|
||||
}
|
||||
}
|
||||
@@ -23,9 +23,6 @@
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
$string['apiv1migration_message_content'] = 'As part of the recent Moodle upgrade to 2.6, the Box portfolio plugin has been disabled. To re-enable it, you need to re-configure it as described in the documentation {$a->docsurl}.';
|
||||
$string['apiv1migration_message_small'] = 'This plugin has been disabled, as it requires configuration as described in the documentation Box APIv1 migration.';
|
||||
$string['apiv1migration_message_subject'] = 'Important information regarding Box portfolio plugin';
|
||||
$string['clientid'] = 'Client ID';
|
||||
$string['clientsecret'] = 'Client secret';
|
||||
$string['existingfolder'] = 'Existing folder to put file(s) into';
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -1,53 +0,0 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// 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
|
||||
// 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/>.
|
||||
|
||||
/**
|
||||
* Googledocs portfolio upgrade script.
|
||||
*
|
||||
* @package portfolio_googledocs
|
||||
* @copyright 2013 Dan Poltawski <[email protected]>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
/**
|
||||
* Inform admins about setup required for googledocs change.
|
||||
*/
|
||||
function portfolio_googledocs_admin_upgrade_notification() {
|
||||
$admins = get_admins();
|
||||
|
||||
if (empty($admins)) {
|
||||
return;
|
||||
}
|
||||
$a = new stdClass;
|
||||
$a->docsurl = get_docs_url('Google_OAuth_2.0_setup');
|
||||
|
||||
foreach ($admins as $admin) {
|
||||
$message = new stdClass();
|
||||
$message->component = 'moodle';
|
||||
$message->name = 'notices';
|
||||
$message->userfrom = get_admin();
|
||||
$message->userto = $admin;
|
||||
$message->smallmessage = get_string('oauth2upgrade_message_small', 'portfolio_googledocs');
|
||||
$message->subject = get_string('oauth2upgrade_message_subject', 'portfolio_googledocs');
|
||||
$message->fullmessage = get_string('oauth2upgrade_message_content', 'portfolio_googledocs', $a);
|
||||
$message->fullmessagehtml = get_string('oauth2upgrade_message_content', 'portfolio_googledocs', $a);
|
||||
$message->fullmessageformat = FORMAT_PLAIN;
|
||||
$message->notification = 1;
|
||||
message_send($message);
|
||||
}
|
||||
}
|
||||
@@ -28,9 +28,6 @@ $string['nooauthcredentials'] = 'OAuth credentials required.';
|
||||
$string['nooauthcredentials_help'] = 'To use the Google Drive portfolio plugin you must configure OAuth credentials in the portfolio settings.';
|
||||
$string['nosessiontoken'] = 'A session token does not exist preventing export to google.';
|
||||
$string['oauthinfo'] = '<p>To use this plugin, you must register your site with Google, as described in the documentation <a href="{$a->docsurl}">Google OAuth 2.0 setup</a>.</p><p>As part of the registration process, you will need to enter the following URL as \'Authorized Redirect URIs\':</p><p>{$a->callbackurl}</p><p>Once registered, you will be provided with a client ID and secret which can be used to configure all Google Drive and Picasa plugins.</p>';
|
||||
$string['oauth2upgrade_message_subject'] = 'Important information regarding Google Drive portfolio plugin';
|
||||
$string['oauth2upgrade_message_content'] = 'As part of the upgrade to Moodle 2.3, the Google Drive portfolio plugin has been disabled. To re-enable it, your Moodle site needs to be registered with Google, as described in the documentation {$a->docsurl}, in order to obtain a client ID and secret. The client ID and secret can then be used to configure all Google Drive and Picasa plugins.';
|
||||
$string['oauth2upgrade_message_small'] = 'This plugin has been disabled, as it requires configuration as described in the documentation Google OAuth 2.0 setup.';
|
||||
$string['pluginname'] = 'Google Drive';
|
||||
$string['sendfailed'] = 'The file {$a} failed to transfer to google';
|
||||
$string['secret'] = 'Secret';
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -1,53 +0,0 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// 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
|
||||
// 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/>.
|
||||
|
||||
/**
|
||||
* Picasa portfolio upgrade script.
|
||||
*
|
||||
* @package portfolio_picasa
|
||||
* @copyright 2013 Dan Poltawski <[email protected]>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
/**
|
||||
* Inform admins about setup required for picasa change.
|
||||
*/
|
||||
function portfolio_picasa_admin_upgrade_notification() {
|
||||
$admins = get_admins();
|
||||
|
||||
if (empty($admins)) {
|
||||
return;
|
||||
}
|
||||
$a = new stdClass;
|
||||
$a->docsurl = get_docs_url('Google_OAuth_2.0_setup');
|
||||
|
||||
foreach ($admins as $admin) {
|
||||
$message = new stdClass();
|
||||
$message->component = 'moodle';
|
||||
$message->name = 'notices';
|
||||
$message->userfrom = get_admin();
|
||||
$message->userto = $admin;
|
||||
$message->smallmessage = get_string('oauth2upgrade_message_small', 'portfolio_picasa');
|
||||
$message->subject = get_string('oauth2upgrade_message_subject', 'portfolio_picasa');
|
||||
$message->fullmessage = get_string('oauth2upgrade_message_content', 'portfolio_picasa', $a);
|
||||
$message->fullmessagehtml = get_string('oauth2upgrade_message_content', 'portfolio_picasa', $a);
|
||||
$message->fullmessageformat = FORMAT_PLAIN;
|
||||
$message->notification = 1;
|
||||
message_send($message);
|
||||
}
|
||||
}
|
||||
@@ -27,9 +27,6 @@ $string['noauthtoken'] = 'An authentication token has not been received from Goo
|
||||
$string['nooauthcredentials'] = 'OAuth credentials required.';
|
||||
$string['nooauthcredentials_help'] = 'To use the Picasa portfolio plugin you must configure OAuth credentials in the portfolio settings.';
|
||||
$string['oauthinfo'] = '<p>To use this plugin, you must register your site with Google, as described in the documentation <a href="{$a->docsurl}">Google OAuth 2.0 setup</a>.</p><p>As part of the registration process, you will need to enter the following URL as \'Authorized Redirect URIs\':</p><p>{$a->callbackurl}</p><p>Once registered, you will be provided with a client ID and secret which can be used to configure all Google Drive and Picasa plugins.</p>';
|
||||
$string['oauth2upgrade_message_subject'] = 'Important information regarding Picasa portfolio plugin';
|
||||
$string['oauth2upgrade_message_content'] = 'As part of the upgrade to Moodle 2.3, the Picasa portfolio plugin has been disabled. To re-enable it, your Moodle site needs to be registered with Google, as described in the documentation {$a->docsurl}, in order to obtain a client ID and secret. The client ID and secret can then be used to configure all Google Drive and Picasa plugins.';
|
||||
$string['oauth2upgrade_message_small'] = 'This plugin has been disabled, as it requires configuration as described in the documentation Google OAuth 2.0 setup.';
|
||||
$string['pluginname'] = 'Picasa';
|
||||
$string['sendfailed'] = 'The file {$a} failed to transfer to Picasa';
|
||||
$string['secret'] = 'Secret';
|
||||
|
||||
@@ -1,6 +1,14 @@
|
||||
This files describes API changes in /portfolio/ portfolio system,
|
||||
information provided here is intended especially for developers.
|
||||
|
||||
=== 3.1 ===
|
||||
|
||||
* The following functions, previously used (exclusively) by upgrade steps are not available
|
||||
anymore because of the upgrade cleanup performed for this version. See MDL-51580 for more info:
|
||||
- portfolio_picasa_admin_upgrade_notification()
|
||||
- portfolio_googledocs_admin_upgrade_notification()
|
||||
- portfolio_boxnet_admin_upgrade_notification()
|
||||
|
||||
=== 2.4 ===
|
||||
|
||||
The set_callback_options function's third parameter has been changed from a file path
|
||||
|
||||
@@ -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.
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user