Merge branch 'MDL-65809-master' of git://github.com/sarjona/moodle
This commit is contained in:
@@ -2982,4 +2982,185 @@
|
||||
</CUSTOM_CHECK>
|
||||
</CUSTOM_CHECKS>
|
||||
</MOODLE>
|
||||
<MOODLE version="3.9" requires="3.5">
|
||||
<UNICODE level="required">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="unicoderequired" />
|
||||
</FEEDBACK>
|
||||
</UNICODE>
|
||||
<DATABASE level="required">
|
||||
<VENDOR name="mariadb" version="10.2.29" />
|
||||
<VENDOR name="mysql" version="5.6" />
|
||||
<VENDOR name="postgres" version="9.5" />
|
||||
<VENDOR name="mssql" version="11.0" />
|
||||
<VENDOR name="oracle" version="11.2" />
|
||||
</DATABASE>
|
||||
<PHP version="7.2.0" 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="required">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="mbstringrequired" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="curl" level="required">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="curlrequired" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="openssl" level="required">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="opensslrequired" />
|
||||
</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="xmlreader" level="required">
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="intl" level="required">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="intlrequired" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="json" level="required">
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="hash" level="required"/>
|
||||
<PHP_EXTENSION name="fileinfo" 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_CHECK file="lib/upgradelib.php" function="check_unoconv_version" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="unoconvwarning" />
|
||||
</FEEDBACK>
|
||||
</CUSTOM_CHECK>
|
||||
<CUSTOM_CHECK file="lib/upgradelib.php" function="check_libcurl_version" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="libcurlwarning" />
|
||||
</FEEDBACK>
|
||||
</CUSTOM_CHECK>
|
||||
<CUSTOM_CHECK file="lib/upgradelib.php" function="check_mysql_file_format" level="required">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="unsupporteddbfileformat" />
|
||||
</FEEDBACK>
|
||||
</CUSTOM_CHECK>
|
||||
<CUSTOM_CHECK file="lib/upgradelib.php" function="check_mysql_file_per_table" level="required">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="unsupporteddbfilepertable" />
|
||||
</FEEDBACK>
|
||||
</CUSTOM_CHECK>
|
||||
<CUSTOM_CHECK file="lib/upgradelib.php" function="check_mysql_large_prefix" level="required">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="unsupporteddblargeprefix" />
|
||||
</FEEDBACK>
|
||||
</CUSTOM_CHECK>
|
||||
<CUSTOM_CHECK file="lib/upgradelib.php" function="check_is_https" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="ishttpswarning" />
|
||||
</FEEDBACK>
|
||||
</CUSTOM_CHECK>
|
||||
<CUSTOM_CHECK file="lib/upgradelib.php" function="check_mysql_incomplete_unicode_support" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="incompleteunicodesupport" />
|
||||
</FEEDBACK>
|
||||
</CUSTOM_CHECK>
|
||||
<CUSTOM_CHECK file="lib/upgradelib.php" function="check_sixtyfour_bits" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="sixtyfourbitswarning" />
|
||||
</FEEDBACK>
|
||||
</CUSTOM_CHECK>
|
||||
</CUSTOM_CHECKS>
|
||||
</MOODLE>
|
||||
</COMPATIBILITY_MATRIX>
|
||||
|
||||
@@ -29,12 +29,6 @@ defined('MOODLE_INTERNAL') || die();
|
||||
function xmldb_tool_customlang_upgrade($oldversion) {
|
||||
global $CFG;
|
||||
|
||||
// Automatically generated Moodle v3.3.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Automatically generated Moodle v3.4.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Automatically generated Moodle v3.5.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
|
||||
@@ -33,12 +33,6 @@ defined('MOODLE_INTERNAL') || die();
|
||||
function xmldb_tool_log_upgrade($oldversion) {
|
||||
global $CFG;
|
||||
|
||||
// Automatically generated Moodle v3.3.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Automatically generated Moodle v3.4.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Automatically generated Moodle v3.5.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
|
||||
@@ -27,12 +27,6 @@ defined('MOODLE_INTERNAL') || die();
|
||||
function xmldb_logstore_database_upgrade($oldversion) {
|
||||
global $CFG;
|
||||
|
||||
// Automatically generated Moodle v3.3.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Automatically generated Moodle v3.4.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Automatically generated Moodle v3.5.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
|
||||
@@ -27,12 +27,6 @@ defined('MOODLE_INTERNAL') || die();
|
||||
function xmldb_logstore_standard_upgrade($oldversion) {
|
||||
global $CFG;
|
||||
|
||||
// Automatically generated Moodle v3.3.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Automatically generated Moodle v3.4.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Automatically generated Moodle v3.5.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
|
||||
@@ -33,29 +33,6 @@ defined('MOODLE_INTERNAL') || die();
|
||||
function xmldb_tool_monitor_upgrade($oldversion) {
|
||||
global $CFG, $DB;
|
||||
|
||||
if ($oldversion < 2017021300) {
|
||||
|
||||
// Delete "orphaned" subscriptions.
|
||||
$sql = "SELECT DISTINCT s.courseid
|
||||
FROM {tool_monitor_subscriptions} s
|
||||
LEFT OUTER JOIN {course} c ON c.id = s.courseid
|
||||
WHERE s.courseid <> 0 and c.id IS NULL";
|
||||
$deletedcourses = $DB->get_field_sql($sql);
|
||||
if ($deletedcourses) {
|
||||
list($sql, $params) = $DB->get_in_or_equal($deletedcourses);
|
||||
$DB->execute("DELETE FROM {tool_monitor_subscriptions} WHERE courseid " . $sql, $params);
|
||||
}
|
||||
|
||||
// Monitor savepoint reached.
|
||||
upgrade_plugin_savepoint(true, 2017021300, 'tool', 'monitor');
|
||||
}
|
||||
|
||||
// Automatically generated Moodle v3.3.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Automatically generated Moodle v3.4.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Automatically generated Moodle v3.5.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
|
||||
@@ -35,12 +35,6 @@ use tool_usertours\manager;
|
||||
function xmldb_tool_usertours_upgrade($oldversion) {
|
||||
global $CFG, $DB;
|
||||
|
||||
// Automatically generated Moodle v3.3.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Automatically generated Moodle v3.4.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Automatically generated Moodle v3.5.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
|
||||
@@ -1,5 +1,14 @@
|
||||
This files describes API changes in /admin/*.
|
||||
|
||||
=== 3.9 ===
|
||||
|
||||
* The following functions, previously used (exclusively) by upgrade steps are not available anymore because of the upgrade cleanup performed for this version. See MDL-65809 for more info:
|
||||
- upgrade_fix_block_instance_configuration()
|
||||
- upgrade_theme_is_from_family()
|
||||
- upgrade_find_theme_location()
|
||||
- linkcoursesectionsupgradescriptwasrun setting
|
||||
- upgrade_block_positions()
|
||||
|
||||
=== 3.8 ===
|
||||
|
||||
* Admin setting "Open to Google" (opentogoogle) has been renamed to the more generic "Open to search engines" (opentowebcrawlers).
|
||||
|
||||
@@ -32,19 +32,6 @@ defined('MOODLE_INTERNAL') || die();
|
||||
function xmldb_auth_cas_upgrade($oldversion) {
|
||||
global $CFG;
|
||||
|
||||
if ($oldversion < 2017020700) {
|
||||
// Convert info in config plugins from auth/cas to auth_cas.
|
||||
upgrade_fix_config_auth_plugin_names('cas');
|
||||
upgrade_fix_config_auth_plugin_defaults('cas');
|
||||
upgrade_plugin_savepoint(true, 2017020700, 'auth', 'cas');
|
||||
}
|
||||
|
||||
// Automatically generated Moodle v3.3.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Automatically generated Moodle v3.4.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Automatically generated Moodle v3.5.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
|
||||
@@ -32,19 +32,6 @@ defined('MOODLE_INTERNAL') || die();
|
||||
function xmldb_auth_db_upgrade($oldversion) {
|
||||
global $CFG, $DB;
|
||||
|
||||
if ($oldversion < 2017032800) {
|
||||
// Convert info in config plugins from auth/db to auth_db
|
||||
upgrade_fix_config_auth_plugin_names('db');
|
||||
upgrade_fix_config_auth_plugin_defaults('db');
|
||||
upgrade_plugin_savepoint(true, 2017032800, 'auth', 'db');
|
||||
}
|
||||
|
||||
// Automatically generated Moodle v3.3.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Automatically generated Moodle v3.4.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Automatically generated Moodle v3.5.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
|
||||
@@ -32,19 +32,6 @@ defined('MOODLE_INTERNAL') || die();
|
||||
function xmldb_auth_email_upgrade($oldversion) {
|
||||
global $CFG, $DB;
|
||||
|
||||
if ($oldversion < 2017020700) {
|
||||
// Convert info in config plugins from auth/email to auth_email.
|
||||
upgrade_fix_config_auth_plugin_names('email');
|
||||
upgrade_fix_config_auth_plugin_defaults('email');
|
||||
upgrade_plugin_savepoint(true, 2017020700, 'auth', 'email');
|
||||
}
|
||||
|
||||
// Automatically generated Moodle v3.3.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Automatically generated Moodle v3.4.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Automatically generated Moodle v3.5.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
|
||||
@@ -32,37 +32,6 @@ defined('MOODLE_INTERNAL') || die();
|
||||
function xmldb_auth_ldap_upgrade($oldversion) {
|
||||
global $CFG;
|
||||
|
||||
if ($oldversion < 2017020700) {
|
||||
// Convert info in config plugins from auth/ldap to auth_ldap.
|
||||
upgrade_fix_config_auth_plugin_names('ldap');
|
||||
upgrade_fix_config_auth_plugin_defaults('ldap');
|
||||
upgrade_plugin_savepoint(true, 2017020700, 'auth', 'ldap');
|
||||
}
|
||||
|
||||
// Automatically generated Moodle v3.3.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
if ($oldversion < 2017080100) {
|
||||
// The "auth_ldap/coursecreators" setting was replaced with "auth_ldap/coursecreatorcontext" (created
|
||||
// dynamically from system-assignable roles) - so migrate any existing value to the first new slot.
|
||||
if ($ldapcontext = get_config('auth_ldap', 'creators')) {
|
||||
// Get info about the role that the old coursecreators setting would apply.
|
||||
$creatorrole = get_archetype_roles('coursecreator');
|
||||
$creatorrole = array_shift($creatorrole); // We can only use one, let's use the first.
|
||||
|
||||
// Create new setting.
|
||||
set_config($creatorrole->shortname . 'context', $ldapcontext, 'auth_ldap');
|
||||
|
||||
// Delete old setting.
|
||||
set_config('creators', null, 'auth_ldap');
|
||||
|
||||
upgrade_plugin_savepoint(true, 2017080100, 'auth', 'ldap');
|
||||
}
|
||||
}
|
||||
|
||||
// Automatically generated Moodle v3.4.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Automatically generated Moodle v3.5.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
|
||||
@@ -32,19 +32,6 @@ defined('MOODLE_INTERNAL') || die();
|
||||
function xmldb_auth_manual_upgrade($oldversion) {
|
||||
global $CFG;
|
||||
|
||||
if ($oldversion < 2017020700) {
|
||||
// Convert info in config plugins from auth/manual to auth_manual.
|
||||
upgrade_fix_config_auth_plugin_names('manual');
|
||||
upgrade_fix_config_auth_plugin_defaults('manual');
|
||||
upgrade_plugin_savepoint(true, 2017020700, 'auth', 'manual');
|
||||
}
|
||||
|
||||
// Automatically generated Moodle v3.3.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Automatically generated Moodle v3.4.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Automatically generated Moodle v3.5.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
|
||||
@@ -32,19 +32,6 @@ defined('MOODLE_INTERNAL') || die();
|
||||
function xmldb_auth_mnet_upgrade($oldversion) {
|
||||
global $CFG;
|
||||
|
||||
if ($oldversion < 2017020700) {
|
||||
// Convert info in config plugins from auth/mnet to auth_mnet.
|
||||
upgrade_fix_config_auth_plugin_names('mnet');
|
||||
upgrade_fix_config_auth_plugin_defaults('mnet');
|
||||
upgrade_plugin_savepoint(true, 2017020700, 'auth', 'mnet');
|
||||
}
|
||||
|
||||
// Automatically generated Moodle v3.3.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Automatically generated Moodle v3.4.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Automatically generated Moodle v3.5.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
|
||||
@@ -32,19 +32,6 @@ defined('MOODLE_INTERNAL') || die();
|
||||
function xmldb_auth_none_upgrade($oldversion) {
|
||||
global $CFG, $DB;
|
||||
|
||||
if ($oldversion < 2017020700) {
|
||||
// Convert info in config plugins from auth/none to auth_none.
|
||||
upgrade_fix_config_auth_plugin_names('none');
|
||||
upgrade_fix_config_auth_plugin_defaults('none');
|
||||
upgrade_plugin_savepoint(true, 2017020700, 'auth', 'none');
|
||||
}
|
||||
|
||||
// Automatically generated Moodle v3.3.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Automatically generated Moodle v3.4.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Automatically generated Moodle v3.5.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
|
||||
@@ -35,12 +35,6 @@ function xmldb_auth_oauth2_upgrade($oldversion) {
|
||||
|
||||
$dbman = $DB->get_manager();
|
||||
|
||||
// Automatically generated Moodle v3.3.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Automatically generated Moodle v3.4.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Automatically generated Moodle v3.5.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
|
||||
@@ -32,19 +32,6 @@ defined('MOODLE_INTERNAL') || die();
|
||||
function xmldb_auth_shibboleth_upgrade($oldversion) {
|
||||
global $CFG, $DB;
|
||||
|
||||
if ($oldversion < 2017020700) {
|
||||
// Convert info in config plugins from auth/shibboleth to auth_shibboleth.
|
||||
upgrade_fix_config_auth_plugin_names('shibboleth');
|
||||
upgrade_fix_config_auth_plugin_defaults('shibboleth');
|
||||
upgrade_plugin_savepoint(true, 2017020700, 'auth', 'shibboleth');
|
||||
}
|
||||
|
||||
// Automatically generated Moodle v3.3.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Automatically generated Moodle v3.4.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Automatically generated Moodle v3.5.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
|
||||
@@ -1,6 +1,12 @@
|
||||
This files describes API changes in /auth/* - plugins,
|
||||
information provided here is intended especially for developers.
|
||||
|
||||
=== 3.9 ===
|
||||
|
||||
* The following functions, previously used (exclusively) by upgrade steps are not available anymore because of the upgrade cleanup performed for this version. See MDL-65809 for more info:
|
||||
- upgrade_fix_config_auth_plugin_names()
|
||||
- upgrade_fix_config_auth_plugin_defaults()
|
||||
|
||||
=== 3.7 ===
|
||||
|
||||
* get_password_change_info() method is added to the base class and returns an array containing the subject and body of the message
|
||||
|
||||
@@ -45,12 +45,6 @@
|
||||
function xmldb_block_badges_upgrade($oldversion, $block) {
|
||||
global $CFG;
|
||||
|
||||
// Automatically generated Moodle v3.3.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Automatically generated Moodle v3.4.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Automatically generated Moodle v3.5.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
|
||||
@@ -45,12 +45,6 @@
|
||||
function xmldb_block_calendar_month_upgrade($oldversion, $block) {
|
||||
global $CFG;
|
||||
|
||||
// Automatically generated Moodle v3.3.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Automatically generated Moodle v3.4.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Automatically generated Moodle v3.5.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
|
||||
@@ -45,12 +45,6 @@
|
||||
function xmldb_block_calendar_upcoming_upgrade($oldversion, $block) {
|
||||
global $CFG;
|
||||
|
||||
// Automatically generated Moodle v3.3.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Automatically generated Moodle v3.4.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Automatically generated Moodle v3.5.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
|
||||
@@ -48,12 +48,6 @@ defined('MOODLE_INTERNAL') || die();
|
||||
function xmldb_block_completionstatus_upgrade($oldversion, $block) {
|
||||
global $CFG;
|
||||
|
||||
// Automatically generated Moodle v3.3.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Automatically generated Moodle v3.4.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Automatically generated Moodle v3.5.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
|
||||
@@ -48,12 +48,6 @@ defined('MOODLE_INTERNAL') || die();
|
||||
function xmldb_block_course_summary_upgrade($oldversion, $block) {
|
||||
global $CFG;
|
||||
|
||||
// Automatically generated Moodle v3.3.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Automatically generated Moodle v3.4.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Automatically generated Moodle v3.5.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
|
||||
@@ -33,12 +33,6 @@ defined('MOODLE_INTERNAL') || die();
|
||||
function xmldb_block_html_upgrade($oldversion) {
|
||||
global $CFG;
|
||||
|
||||
// Automatically generated Moodle v3.3.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Automatically generated Moodle v3.4.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Automatically generated Moodle v3.5.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
|
||||
@@ -55,12 +55,6 @@ defined('MOODLE_INTERNAL') || die();
|
||||
function xmldb_block_navigation_upgrade($oldversion, $block) {
|
||||
global $CFG;
|
||||
|
||||
// Automatically generated Moodle v3.3.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Automatically generated Moodle v3.4.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Automatically generated Moodle v3.5.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
|
||||
@@ -45,12 +45,6 @@
|
||||
function xmldb_block_quiz_results_upgrade($oldversion, $block) {
|
||||
global $CFG;
|
||||
|
||||
// Automatically generated Moodle v3.3.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Automatically generated Moodle v3.4.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Automatically generated Moodle v3.5.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
|
||||
@@ -47,12 +47,6 @@ defined('MOODLE_INTERNAL') || die();
|
||||
function xmldb_block_recent_activity_upgrade($oldversion, $block) {
|
||||
global $CFG;
|
||||
|
||||
// Automatically generated Moodle v3.3.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Automatically generated Moodle v3.4.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Automatically generated Moodle v3.5.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
|
||||
@@ -33,12 +33,6 @@ defined('MOODLE_INTERNAL') || die();
|
||||
function xmldb_block_rss_client_upgrade($oldversion) {
|
||||
global $CFG;
|
||||
|
||||
// Automatically generated Moodle v3.3.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Automatically generated Moodle v3.4.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Automatically generated Moodle v3.5.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
|
||||
@@ -49,12 +49,6 @@ defined('MOODLE_INTERNAL') || die();
|
||||
function xmldb_block_section_links_upgrade($oldversion, $block) {
|
||||
global $CFG;
|
||||
|
||||
// Automatically generated Moodle v3.3.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Automatically generated Moodle v3.4.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Automatically generated Moodle v3.5.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
|
||||
@@ -48,12 +48,6 @@ defined('MOODLE_INTERNAL') || die();
|
||||
function xmldb_block_selfcompletion_upgrade($oldversion, $block) {
|
||||
global $CFG;
|
||||
|
||||
// Automatically generated Moodle v3.3.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Automatically generated Moodle v3.4.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Automatically generated Moodle v3.5.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
|
||||
@@ -55,12 +55,6 @@ defined('MOODLE_INTERNAL') || die();
|
||||
function xmldb_block_settings_upgrade($oldversion, $block) {
|
||||
global $CFG;
|
||||
|
||||
// Automatically generated Moodle v3.3.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Automatically generated Moodle v3.4.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Automatically generated Moodle v3.5.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
|
||||
@@ -33,32 +33,6 @@ defined('MOODLE_INTERNAL') || die();
|
||||
function xmldb_format_topics_upgrade($oldversion) {
|
||||
global $CFG, $DB;
|
||||
|
||||
require_once($CFG->dirroot . '/course/format/topics/db/upgradelib.php');
|
||||
|
||||
if ($oldversion < 2017020200) {
|
||||
|
||||
// Remove 'numsections' option and hide or delete orphaned sections.
|
||||
format_topics_upgrade_remove_numsections();
|
||||
|
||||
upgrade_plugin_savepoint(true, 2017020200, 'format', 'topics');
|
||||
}
|
||||
|
||||
// Automatically generated Moodle v3.3.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Automatically generated Moodle v3.4.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
if ($oldversion < 2018030900) {
|
||||
|
||||
// During upgrade to Moodle 3.3 it could happen that general section (section 0) became 'invisible'.
|
||||
// It should always be visible.
|
||||
$DB->execute("UPDATE {course_sections} SET visible=1 WHERE visible=0 AND section=0 AND course IN
|
||||
(SELECT id FROM {course} WHERE format=?)", ['topics']);
|
||||
|
||||
upgrade_plugin_savepoint(true, 2018030900, 'format', 'topics');
|
||||
}
|
||||
|
||||
// Automatically generated Moodle v3.5.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
|
||||
@@ -1,144 +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/>.
|
||||
|
||||
/**
|
||||
* Upgrade scripts for course format "Topics"
|
||||
*
|
||||
* @package format_topics
|
||||
* @copyright 2017 Marina Glancy
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
/**
|
||||
* This method finds all courses in 'topics' format that have actual number of sections
|
||||
* different than their 'numsections' course format option.
|
||||
*
|
||||
* For courses where there are more sections than numsections, we call
|
||||
* {@link format_topics_upgrade_hide_extra_sections()} and
|
||||
* either delete or hide "orphaned" sections. For courses where there are fewer sections
|
||||
* than numsections, we call {@link format_topics_upgrade_add_empty_sections()} to add
|
||||
* these sections.
|
||||
*/
|
||||
function format_topics_upgrade_remove_numsections() {
|
||||
global $DB;
|
||||
|
||||
$sql1 = "SELECT c.id, max(cs.section) AS sectionsactual
|
||||
FROM {course} c
|
||||
JOIN {course_sections} cs ON cs.course = c.id
|
||||
WHERE c.format = :format1
|
||||
GROUP BY c.id";
|
||||
|
||||
$sql2 = "SELECT c.id, n.value AS numsections
|
||||
FROM {course} c
|
||||
JOIN {course_format_options} n ON n.courseid = c.id AND n.format = :format1 AND n.name = :numsections AND n.sectionid = 0
|
||||
WHERE c.format = :format2";
|
||||
|
||||
$params = ['format1' => 'topics', 'format2' => 'topics', 'numsections' => 'numsections'];
|
||||
|
||||
$actual = $DB->get_records_sql_menu($sql1, $params);
|
||||
$numsections = $DB->get_records_sql_menu($sql2, $params);
|
||||
$needfixing = [];
|
||||
$needsections = [];
|
||||
|
||||
$defaultnumsections = get_config('moodlecourse', 'numsections');
|
||||
|
||||
foreach ($actual as $courseid => $sectionsactual) {
|
||||
if (array_key_exists($courseid, $numsections)) {
|
||||
$n = (int)$numsections[$courseid];
|
||||
} else {
|
||||
$n = $defaultnumsections;
|
||||
}
|
||||
if ($sectionsactual > $n) {
|
||||
$needfixing[$courseid] = $n;
|
||||
} else if ($sectionsactual < $n) {
|
||||
$needsections[$courseid] = $n;
|
||||
}
|
||||
}
|
||||
unset($actual);
|
||||
unset($numsections);
|
||||
|
||||
foreach ($needfixing as $courseid => $numsections) {
|
||||
format_topics_upgrade_hide_extra_sections($courseid, $numsections);
|
||||
}
|
||||
|
||||
foreach ($needsections as $courseid => $numsections) {
|
||||
format_topics_upgrade_add_empty_sections($courseid, $numsections);
|
||||
}
|
||||
|
||||
$DB->delete_records('course_format_options', ['format' => 'topics', 'sectionid' => 0, 'name' => 'numsections']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Find all sections in the course with sectionnum bigger than numsections.
|
||||
* Either delete these sections or hide them
|
||||
*
|
||||
* We will only delete a section if it is completely empty and all sections below
|
||||
* it are also empty
|
||||
*
|
||||
* @param int $courseid
|
||||
* @param int $numsections
|
||||
*/
|
||||
function format_topics_upgrade_hide_extra_sections($courseid, $numsections) {
|
||||
global $DB;
|
||||
$sections = $DB->get_records_sql('SELECT id, name, summary, sequence, visible
|
||||
FROM {course_sections}
|
||||
WHERE course = ? AND section > ?
|
||||
ORDER BY section DESC', [$courseid, $numsections]);
|
||||
$candelete = true;
|
||||
$tohide = [];
|
||||
$todelete = [];
|
||||
foreach ($sections as $section) {
|
||||
if ($candelete && (!empty($section->summary) || !empty($section->sequence) || !empty($section->name))) {
|
||||
$candelete = false;
|
||||
}
|
||||
if ($candelete) {
|
||||
$todelete[] = $section->id;
|
||||
} else if ($section->visible) {
|
||||
$tohide[] = $section->id;
|
||||
}
|
||||
}
|
||||
if ($todelete) {
|
||||
// Delete empty sections in the end.
|
||||
// This is an upgrade script - no events or cache resets are needed.
|
||||
// We also know that these sections do not have any modules so it is safe to just delete records in the table.
|
||||
$DB->delete_records_list('course_sections', 'id', $todelete);
|
||||
}
|
||||
if ($tohide) {
|
||||
// Hide other orphaned sections.
|
||||
// This is different from what set_section_visible() does but we want to preserve actual
|
||||
// module visibility in this case.
|
||||
list($sql, $params) = $DB->get_in_or_equal($tohide);
|
||||
$DB->execute("UPDATE {course_sections} SET visible = 0 WHERE id " . $sql, $params);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This method adds empty sections to courses which have fewer sections than their
|
||||
* 'numsections' course format option and adds these empty sections.
|
||||
*
|
||||
* @param int $courseid
|
||||
* @param int $numsections
|
||||
*/
|
||||
function format_topics_upgrade_add_empty_sections($courseid, $numsections) {
|
||||
global $DB;
|
||||
$existingsections = $DB->get_fieldset_sql('SELECT section from {course_sections} WHERE course = ?', [$courseid]);
|
||||
$newsections = array_diff(range(0, $numsections), $existingsections);
|
||||
foreach ($newsections as $sectionnum) {
|
||||
course_create_section($courseid, $sectionnum, true);
|
||||
}
|
||||
}
|
||||
@@ -1,153 +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/>.
|
||||
|
||||
/**
|
||||
* format_topics unit tests for upgradelib
|
||||
*
|
||||
* @package format_topics
|
||||
* @copyright 2015 Marina Glancy
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
global $CFG;
|
||||
require_once($CFG->dirroot . '/course/lib.php');
|
||||
require_once($CFG->dirroot . '/course/format/topics/db/upgradelib.php');
|
||||
|
||||
/**
|
||||
* format_topics unit tests for upgradelib
|
||||
*
|
||||
* @package format_topics
|
||||
* @copyright 2017 Marina Glancy
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class format_topics_upgrade_testcase extends advanced_testcase {
|
||||
|
||||
/**
|
||||
* Test upgrade step to remove orphaned sections.
|
||||
*/
|
||||
public function test_numsections_no_actions() {
|
||||
global $DB;
|
||||
|
||||
$this->resetAfterTest(true);
|
||||
|
||||
$params = array('format' => 'topics', 'numsections' => 5, 'startdate' => 1445644800);
|
||||
$course = $this->getDataGenerator()->create_course($params);
|
||||
// This test is executed after 'numsections' option was already removed, add it manually.
|
||||
$DB->insert_record('course_format_options', ['courseid' => $course->id, 'format' => 'topics',
|
||||
'sectionid' => 0, 'name' => 'numsections', 'value' => '5']);
|
||||
|
||||
// There are 6 sections in the course (0-section and sections 1, ... 5).
|
||||
$this->assertEquals(6, $DB->count_records('course_sections', ['course' => $course->id]));
|
||||
|
||||
format_topics_upgrade_remove_numsections();
|
||||
|
||||
// There are still 6 sections in the course.
|
||||
$this->assertEquals(6, $DB->count_records('course_sections', ['course' => $course->id]));
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Test upgrade step to remove orphaned sections.
|
||||
*/
|
||||
public function test_numsections_delete_empty() {
|
||||
global $DB;
|
||||
|
||||
$this->resetAfterTest(true);
|
||||
|
||||
// Set default number of sections to 10.
|
||||
set_config('numsections', 10, 'moodlecourse');
|
||||
|
||||
$params1 = array('format' => 'topics', 'numsections' => 5, 'startdate' => 1445644800);
|
||||
$course1 = $this->getDataGenerator()->create_course($params1);
|
||||
$params2 = array('format' => 'topics', 'numsections' => 20, 'startdate' => 1445644800);
|
||||
$course2 = $this->getDataGenerator()->create_course($params2);
|
||||
// This test is executed after 'numsections' option was already removed, add it manually and
|
||||
// set it to be 2 less than actual number of sections.
|
||||
$DB->insert_record('course_format_options', ['courseid' => $course1->id, 'format' => 'topics',
|
||||
'sectionid' => 0, 'name' => 'numsections', 'value' => '3']);
|
||||
|
||||
// There are 6 sections in the first course (0-section and sections 1, ... 5).
|
||||
$this->assertEquals(6, $DB->count_records('course_sections', ['course' => $course1->id]));
|
||||
// There are 21 sections in the second course.
|
||||
$this->assertEquals(21, $DB->count_records('course_sections', ['course' => $course2->id]));
|
||||
|
||||
format_topics_upgrade_remove_numsections();
|
||||
|
||||
// Two sections were deleted in the first course.
|
||||
$this->assertEquals(4, $DB->count_records('course_sections', ['course' => $course1->id]));
|
||||
// The second course was reset to 11 sections (default plus 0-section).
|
||||
$this->assertEquals(11, $DB->count_records('course_sections', ['course' => $course2->id]));
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Test upgrade step to remove orphaned sections.
|
||||
*/
|
||||
public function test_numsections_hide_non_empty() {
|
||||
global $DB;
|
||||
|
||||
$this->resetAfterTest(true);
|
||||
|
||||
$params = array('format' => 'topics', 'numsections' => 5, 'startdate' => 1445644800);
|
||||
$course = $this->getDataGenerator()->create_course($params);
|
||||
|
||||
// Add a module to the second last section.
|
||||
$cm = $this->getDataGenerator()->create_module('forum', ['course' => $course->id, 'section' => 4]);
|
||||
|
||||
// This test is executed after 'numsections' option was already removed, add it manually and
|
||||
// set it to be 2 less than actual number of sections.
|
||||
$DB->insert_record('course_format_options', ['courseid' => $course->id, 'format' => 'topics',
|
||||
'sectionid' => 0, 'name' => 'numsections', 'value' => '3']);
|
||||
|
||||
// There are 6 sections.
|
||||
$this->assertEquals(6, $DB->count_records('course_sections', ['course' => $course->id]));
|
||||
|
||||
format_topics_upgrade_remove_numsections();
|
||||
|
||||
// One section was deleted and one hidden.
|
||||
$this->assertEquals(5, $DB->count_records('course_sections', ['course' => $course->id]));
|
||||
$this->assertEquals(0, $DB->get_field('course_sections', 'visible', ['course' => $course->id, 'section' => 4]));
|
||||
// The module is still visible.
|
||||
$this->assertEquals(1, $DB->get_field('course_modules', 'visible', ['id' => $cm->cmid]));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test upgrade step to add empty sections.
|
||||
*/
|
||||
public function test_numsections_add_empty_sections() {
|
||||
global $DB;
|
||||
|
||||
$this->resetAfterTest(true);
|
||||
|
||||
$params = array('format' => 'topics', 'numsections' => 16, 'startdate' => 1445644800);
|
||||
$course = $this->getDataGenerator()->create_course($params);
|
||||
|
||||
// This test is executed after 'numsections' option was already removed.
|
||||
// Set the 'numsections' course format value to 18, simulating the scenario in which there are fewer real sections.
|
||||
$DB->insert_record('course_format_options', ['courseid' => $course->id, 'format' => 'topics',
|
||||
'sectionid' => 0, 'name' => 'numsections', 'value' => '18']);
|
||||
|
||||
// There are 16 sections.
|
||||
$this->assertEquals(17, $DB->count_records('course_sections', ['course' => $course->id]));
|
||||
|
||||
format_topics_upgrade_remove_numsections();
|
||||
|
||||
// Confirm that the upgrade method added the missing empty sections.
|
||||
$this->assertEquals(19, $DB->count_records('course_sections', ['course' => $course->id]));
|
||||
}
|
||||
}
|
||||
@@ -2,6 +2,16 @@ This files describes API changes for course formats
|
||||
|
||||
Overview of this plugin type at http://docs.moodle.org/dev/Course_formats
|
||||
|
||||
=== 3.9 ===
|
||||
|
||||
* The following functions, previously used (exclusively) by upgrade steps are not available anymore because of the upgrade cleanup performed for this version. See MDL-65809 for more info:
|
||||
- format_topics_upgrade_remove_numsections()
|
||||
- format_topics_upgrade_hide_extra_sections()
|
||||
- format_topics_upgrade_add_empty_sections()
|
||||
- format_weeks_upgrade_remove_numsections()
|
||||
- format_weeks_upgrade_hide_extra_sections()
|
||||
- format_weeks_upgrade_add_empty_sections()
|
||||
|
||||
=== 3.8 ===
|
||||
|
||||
* The following functions have been finally deprecated and can not be used anymore:
|
||||
|
||||
@@ -33,68 +33,6 @@ defined('MOODLE_INTERNAL') || die();
|
||||
function xmldb_format_weeks_upgrade($oldversion) {
|
||||
global $CFG, $DB;
|
||||
|
||||
require_once($CFG->dirroot . '/course/format/weeks/lib.php');
|
||||
require_once($CFG->dirroot . '/course/format/weeks/db/upgradelib.php');
|
||||
|
||||
if ($oldversion < 2017020200) {
|
||||
|
||||
// Remove 'numsections' option and hide or delete orphaned sections.
|
||||
format_weeks_upgrade_remove_numsections();
|
||||
|
||||
upgrade_plugin_savepoint(true, 2017020200, 'format', 'weeks');
|
||||
}
|
||||
|
||||
if ($oldversion < 2017050300) {
|
||||
// Go through the existing courses using the weeks format with no value set for the 'automaticenddate'.
|
||||
$sql = "SELECT c.id, c.enddate, cfo.id as cfoid
|
||||
FROM {course} c
|
||||
LEFT JOIN {course_format_options} cfo
|
||||
ON cfo.courseid = c.id
|
||||
AND cfo.format = c.format
|
||||
AND cfo.name = :optionname
|
||||
AND cfo.sectionid = 0
|
||||
WHERE c.format = :format
|
||||
AND cfo.id IS NULL";
|
||||
$params = ['optionname' => 'automaticenddate', 'format' => 'weeks'];
|
||||
$courses = $DB->get_recordset_sql($sql, $params);
|
||||
foreach ($courses as $course) {
|
||||
$option = new stdClass();
|
||||
$option->courseid = $course->id;
|
||||
$option->format = 'weeks';
|
||||
$option->sectionid = 0;
|
||||
$option->name = 'automaticenddate';
|
||||
if (empty($course->enddate)) {
|
||||
$option->value = 1;
|
||||
$DB->insert_record('course_format_options', $option);
|
||||
|
||||
// Now, let's update the course end date.
|
||||
format_weeks::update_end_date($course->id);
|
||||
} else {
|
||||
$option->value = 0;
|
||||
$DB->insert_record('course_format_options', $option);
|
||||
}
|
||||
}
|
||||
$courses->close();
|
||||
|
||||
upgrade_plugin_savepoint(true, 2017050300, 'format', 'weeks');
|
||||
}
|
||||
|
||||
// Automatically generated Moodle v3.3.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Automatically generated Moodle v3.4.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
if ($oldversion < 2018030900) {
|
||||
|
||||
// During upgrade to Moodle 3.3 it could happen that general section (section 0) became 'invisible'.
|
||||
// It should always be visible.
|
||||
$DB->execute("UPDATE {course_sections} SET visible=1 WHERE visible=0 AND section=0 AND course IN
|
||||
(SELECT id FROM {course} WHERE format=?)", ['weeks']);
|
||||
|
||||
upgrade_plugin_savepoint(true, 2018030900, 'format', 'weeks');
|
||||
}
|
||||
|
||||
// Automatically generated Moodle v3.5.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
|
||||
@@ -1,144 +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/>.
|
||||
|
||||
/**
|
||||
* Upgrade scripts for course format "Weeks"
|
||||
*
|
||||
* @package format_weeks
|
||||
* @copyright 2017 Marina Glancy
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
/**
|
||||
* This method finds all courses in 'topics' format that have actual number of sections
|
||||
* different than their 'numsections' course format option.
|
||||
*
|
||||
* For courses where there are more sections than numsections, we call
|
||||
* {@link format_weeks_upgrade_hide_extra_sections()} and
|
||||
* either delete or hide "orphaned" sections. For courses where there are fewer sections
|
||||
* than numsections, we call {@link format_weeks_upgrade_add_empty_sections()} to add
|
||||
* these sections.
|
||||
*/
|
||||
function format_weeks_upgrade_remove_numsections() {
|
||||
global $DB;
|
||||
|
||||
$sql1 = "SELECT c.id, max(cs.section) AS sectionsactual
|
||||
FROM {course} c
|
||||
JOIN {course_sections} cs ON cs.course = c.id
|
||||
WHERE c.format = :format1
|
||||
GROUP BY c.id";
|
||||
|
||||
$sql2 = "SELECT c.id, n.value AS numsections
|
||||
FROM {course} c
|
||||
JOIN {course_format_options} n ON n.courseid = c.id AND n.format = :format1 AND n.name = :numsections AND n.sectionid = 0
|
||||
WHERE c.format = :format2";
|
||||
|
||||
$params = ['format1' => 'weeks', 'format2' => 'weeks', 'numsections' => 'numsections'];
|
||||
|
||||
$actual = $DB->get_records_sql_menu($sql1, $params);
|
||||
$numsections = $DB->get_records_sql_menu($sql2, $params);
|
||||
$needfixing = [];
|
||||
$needsections = [];
|
||||
|
||||
$defaultnumsections = get_config('moodlecourse', 'numsections');
|
||||
|
||||
foreach ($actual as $courseid => $sectionsactual) {
|
||||
if (array_key_exists($courseid, $numsections)) {
|
||||
$n = (int)$numsections[$courseid];
|
||||
} else {
|
||||
$n = $defaultnumsections;
|
||||
}
|
||||
if ($sectionsactual > $n) {
|
||||
$needfixing[$courseid] = $n;
|
||||
} else if ($sectionsactual < $n) {
|
||||
$needsections[$courseid] = $n;
|
||||
}
|
||||
}
|
||||
unset($actual);
|
||||
unset($numsections);
|
||||
|
||||
foreach ($needfixing as $courseid => $numsections) {
|
||||
format_weeks_upgrade_hide_extra_sections($courseid, $numsections);
|
||||
}
|
||||
|
||||
foreach ($needsections as $courseid => $numsections) {
|
||||
format_weeks_upgrade_add_empty_sections($courseid, $numsections);
|
||||
}
|
||||
|
||||
$DB->delete_records('course_format_options', ['format' => 'weeks', 'sectionid' => 0, 'name' => 'numsections']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Find all sections in the course with sectionnum bigger than numsections.
|
||||
* Either delete these sections or hide them
|
||||
*
|
||||
* We will only delete a section if it is completely empty and all sections below
|
||||
* it are also empty
|
||||
*
|
||||
* @param int $courseid
|
||||
* @param int $numsections
|
||||
*/
|
||||
function format_weeks_upgrade_hide_extra_sections($courseid, $numsections) {
|
||||
global $DB;
|
||||
$sections = $DB->get_records_sql('SELECT id, name, summary, sequence, visible
|
||||
FROM {course_sections}
|
||||
WHERE course = ? AND section > ?
|
||||
ORDER BY section DESC', [$courseid, $numsections]);
|
||||
$candelete = true;
|
||||
$tohide = [];
|
||||
$todelete = [];
|
||||
foreach ($sections as $section) {
|
||||
if ($candelete && (!empty($section->summary) || !empty($section->sequence) || !empty($section->name))) {
|
||||
$candelete = false;
|
||||
}
|
||||
if ($candelete) {
|
||||
$todelete[] = $section->id;
|
||||
} else if ($section->visible) {
|
||||
$tohide[] = $section->id;
|
||||
}
|
||||
}
|
||||
if ($todelete) {
|
||||
// Delete empty sections in the end.
|
||||
// This is an upgrade script - no events or cache resets are needed.
|
||||
// We also know that these sections do not have any modules so it is safe to just delete records in the table.
|
||||
$DB->delete_records_list('course_sections', 'id', $todelete);
|
||||
}
|
||||
if ($tohide) {
|
||||
// Hide other orphaned sections.
|
||||
// This is different from what set_section_visible() does but we want to preserve actual
|
||||
// module visibility in this case.
|
||||
list($sql, $params) = $DB->get_in_or_equal($tohide);
|
||||
$DB->execute("UPDATE {course_sections} SET visible = 0 WHERE id " . $sql, $params);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This method adds empty sections to courses which have fewer sections than their
|
||||
* 'numsections' course format option and adds these empty sections.
|
||||
*
|
||||
* @param int $courseid
|
||||
* @param int $numsections
|
||||
*/
|
||||
function format_weeks_upgrade_add_empty_sections($courseid, $numsections) {
|
||||
global $DB;
|
||||
$existingsections = $DB->get_fieldset_sql('SELECT section from {course_sections} WHERE course = ?', [$courseid]);
|
||||
$newsections = array_diff(range(0, $numsections), $existingsections);
|
||||
foreach ($newsections as $sectionnum) {
|
||||
course_create_section($courseid, $sectionnum, true);
|
||||
}
|
||||
}
|
||||
@@ -1,153 +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/>.
|
||||
|
||||
/**
|
||||
* format_weeks unit tests for upgradelib
|
||||
*
|
||||
* @package format_weeks
|
||||
* @copyright 2015 Marina Glancy
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
global $CFG;
|
||||
require_once($CFG->dirroot . '/course/lib.php');
|
||||
require_once($CFG->dirroot . '/course/format/weeks/db/upgradelib.php');
|
||||
|
||||
/**
|
||||
* format_weeks unit tests for upgradelib
|
||||
*
|
||||
* @package format_weeks
|
||||
* @copyright 2017 Marina Glancy
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class format_weeks_upgrade_testcase extends advanced_testcase {
|
||||
|
||||
/**
|
||||
* Test upgrade step to remove orphaned sections.
|
||||
*/
|
||||
public function test_numsections_no_actions() {
|
||||
global $DB;
|
||||
|
||||
$this->resetAfterTest(true);
|
||||
|
||||
$params = array('format' => 'weeks', 'numsections' => 5, 'startdate' => 1445644800);
|
||||
$course = $this->getDataGenerator()->create_course($params);
|
||||
// This test is executed after 'numsections' option was already removed, add it manually.
|
||||
$DB->insert_record('course_format_options', ['courseid' => $course->id, 'format' => 'weeks',
|
||||
'sectionid' => 0, 'name' => 'numsections', 'value' => '5']);
|
||||
|
||||
// There are 6 sections in the course (0-section and sections 1, ... 5).
|
||||
$this->assertEquals(6, $DB->count_records('course_sections', ['course' => $course->id]));
|
||||
|
||||
format_weeks_upgrade_remove_numsections();
|
||||
|
||||
// There are still 6 sections in the course.
|
||||
$this->assertEquals(6, $DB->count_records('course_sections', ['course' => $course->id]));
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Test upgrade step to remove orphaned sections.
|
||||
*/
|
||||
public function test_numsections_delete_empty() {
|
||||
global $DB;
|
||||
|
||||
$this->resetAfterTest(true);
|
||||
|
||||
// Set default number of sections to 10.
|
||||
set_config('numsections', 10, 'moodlecourse');
|
||||
|
||||
$params1 = array('format' => 'weeks', 'numsections' => 5, 'startdate' => 1445644800);
|
||||
$course1 = $this->getDataGenerator()->create_course($params1);
|
||||
$params2 = array('format' => 'weeks', 'numsections' => 20, 'startdate' => 1445644800);
|
||||
$course2 = $this->getDataGenerator()->create_course($params2);
|
||||
// This test is executed after 'numsections' option was already removed, add it manually and
|
||||
// set it to be 2 less than actual number of sections.
|
||||
$DB->insert_record('course_format_options', ['courseid' => $course1->id, 'format' => 'weeks',
|
||||
'sectionid' => 0, 'name' => 'numsections', 'value' => '3']);
|
||||
|
||||
// There are 6 sections in the first course (0-section and sections 1, ... 5).
|
||||
$this->assertEquals(6, $DB->count_records('course_sections', ['course' => $course1->id]));
|
||||
// There are 21 sections in the second course.
|
||||
$this->assertEquals(21, $DB->count_records('course_sections', ['course' => $course2->id]));
|
||||
|
||||
format_weeks_upgrade_remove_numsections();
|
||||
|
||||
// Two sections were deleted in the first course.
|
||||
$this->assertEquals(4, $DB->count_records('course_sections', ['course' => $course1->id]));
|
||||
// The second course was reset to 11 sections (default plus 0-section).
|
||||
$this->assertEquals(11, $DB->count_records('course_sections', ['course' => $course2->id]));
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Test upgrade step to remove orphaned sections.
|
||||
*/
|
||||
public function test_numsections_hide_non_empty() {
|
||||
global $DB;
|
||||
|
||||
$this->resetAfterTest(true);
|
||||
|
||||
$params = array('format' => 'weeks', 'numsections' => 5, 'startdate' => 1445644800);
|
||||
$course = $this->getDataGenerator()->create_course($params);
|
||||
|
||||
// Add a module to the second last section.
|
||||
$cm = $this->getDataGenerator()->create_module('forum', ['course' => $course->id, 'section' => 4]);
|
||||
|
||||
// This test is executed after 'numsections' option was already removed, add it manually and
|
||||
// set it to be 2 less than actual number of sections.
|
||||
$DB->insert_record('course_format_options', ['courseid' => $course->id, 'format' => 'weeks',
|
||||
'sectionid' => 0, 'name' => 'numsections', 'value' => '3']);
|
||||
|
||||
// There are 6 sections.
|
||||
$this->assertEquals(6, $DB->count_records('course_sections', ['course' => $course->id]));
|
||||
|
||||
format_weeks_upgrade_remove_numsections();
|
||||
|
||||
// One section was deleted and one hidden.
|
||||
$this->assertEquals(5, $DB->count_records('course_sections', ['course' => $course->id]));
|
||||
$this->assertEquals(0, $DB->get_field('course_sections', 'visible', ['course' => $course->id, 'section' => 4]));
|
||||
// The module is still visible.
|
||||
$this->assertEquals(1, $DB->get_field('course_modules', 'visible', ['id' => $cm->cmid]));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test upgrade step to add empty sections.
|
||||
*/
|
||||
public function test_numsections_add_empty_sections() {
|
||||
global $DB;
|
||||
|
||||
$this->resetAfterTest(true);
|
||||
|
||||
$params = array('format' => 'weeks', 'numsections' => 16, 'startdate' => 1445644800);
|
||||
$course = $this->getDataGenerator()->create_course($params);
|
||||
|
||||
// This test is executed after 'numsections' option was already removed.
|
||||
// Set the 'numsections' course format value to 18, simulating the scenario in which there are fewer real sections.
|
||||
$DB->insert_record('course_format_options', ['courseid' => $course->id, 'format' => 'weeks',
|
||||
'sectionid' => 0, 'name' => 'numsections', 'value' => '18']);
|
||||
|
||||
// There are 16 sections.
|
||||
$this->assertEquals(17, $DB->count_records('course_sections', ['course' => $course->id]));
|
||||
|
||||
format_weeks_upgrade_remove_numsections();
|
||||
|
||||
// Confirm that the upgrade method added the missing empty sections.
|
||||
$this->assertEquals(19, $DB->count_records('course_sections', ['course' => $course->id]));
|
||||
}
|
||||
}
|
||||
@@ -27,12 +27,6 @@ defined('MOODLE_INTERNAL') || die();
|
||||
function xmldb_enrol_database_upgrade($oldversion) {
|
||||
global $CFG;
|
||||
|
||||
// Automatically generated Moodle v3.3.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Automatically generated Moodle v3.4.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Automatically generated Moodle v3.5.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
|
||||
@@ -27,12 +27,6 @@ defined('MOODLE_INTERNAL') || die();
|
||||
function xmldb_enrol_flatfile_upgrade($oldversion) {
|
||||
global $CFG;
|
||||
|
||||
// Automatically generated Moodle v3.3.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Automatically generated Moodle v3.4.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Automatically generated Moodle v3.5.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
|
||||
@@ -27,12 +27,6 @@ defined('MOODLE_INTERNAL') || die();
|
||||
function xmldb_enrol_guest_upgrade($oldversion) {
|
||||
global $CFG;
|
||||
|
||||
// Automatically generated Moodle v3.3.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Automatically generated Moodle v3.4.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Automatically generated Moodle v3.5.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
|
||||
@@ -33,12 +33,6 @@ defined('MOODLE_INTERNAL') || die();
|
||||
function xmldb_enrol_imsenterprise_upgrade($oldversion) {
|
||||
global $CFG;
|
||||
|
||||
// Automatically generated Moodle v3.3.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Automatically generated Moodle v3.4.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Automatically generated Moodle v3.5.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
|
||||
@@ -37,28 +37,7 @@
|
||||
* @return boolean
|
||||
*/
|
||||
function xmldb_enrol_lti_upgrade($oldversion) {
|
||||
global $DB;
|
||||
|
||||
$dbman = $DB->get_manager();
|
||||
|
||||
if ($oldversion < 2017011300) {
|
||||
|
||||
// Changing precision of field value on table enrol_lti_lti2_nonce to (64).
|
||||
$table = new xmldb_table('enrol_lti_lti2_nonce');
|
||||
$field = new xmldb_field('value', XMLDB_TYPE_CHAR, '64', null, XMLDB_NOTNULL, null, null, 'consumerid');
|
||||
|
||||
// Launch change of precision for field value.
|
||||
$dbman->change_field_precision($table, $field);
|
||||
|
||||
// Lti savepoint reached.
|
||||
upgrade_plugin_savepoint(true, 2017011300, 'enrol', 'lti');
|
||||
}
|
||||
|
||||
// Automatically generated Moodle v3.3.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Automatically generated Moodle v3.4.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
global $CFG;
|
||||
|
||||
// Automatically generated Moodle v3.5.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
@@ -27,12 +27,6 @@ defined('MOODLE_INTERNAL') || die();
|
||||
function xmldb_enrol_manual_upgrade($oldversion) {
|
||||
global $CFG;
|
||||
|
||||
// Automatically generated Moodle v3.3.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Automatically generated Moodle v3.4.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Automatically generated Moodle v3.5.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
|
||||
@@ -27,12 +27,6 @@ defined('MOODLE_INTERNAL') || die();
|
||||
function xmldb_enrol_mnet_upgrade($oldversion) {
|
||||
global $CFG;
|
||||
|
||||
// Automatically generated Moodle v3.3.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Automatically generated Moodle v3.4.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Automatically generated Moodle v3.5.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
|
||||
@@ -47,12 +47,6 @@ function xmldb_enrol_paypal_upgrade($oldversion) {
|
||||
|
||||
$dbman = $DB->get_manager();
|
||||
|
||||
// Automatically generated Moodle v3.3.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Automatically generated Moodle v3.4.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Automatically generated Moodle v3.5.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
|
||||
@@ -27,12 +27,6 @@ defined('MOODLE_INTERNAL') || die();
|
||||
function xmldb_enrol_self_upgrade($oldversion) {
|
||||
global $CFG;
|
||||
|
||||
// Automatically generated Moodle v3.3.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Automatically generated Moodle v3.4.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Automatically generated Moodle v3.5.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
|
||||
@@ -31,129 +31,6 @@ defined('MOODLE_INTERNAL') || die();
|
||||
function xmldb_filter_mathjaxloader_upgrade($oldversion) {
|
||||
global $CFG;
|
||||
|
||||
require_once($CFG->dirroot . '/filter/mathjaxloader/db/upgradelib.php');
|
||||
|
||||
if ($oldversion < 2017040300) {
|
||||
|
||||
$httpsurl = get_config('filter_mathjaxloader', 'httpsurl');
|
||||
$newcdnurl = filter_mathjaxloader_upgrade_cdn_cloudflare($httpsurl, false);
|
||||
|
||||
set_config('httpsurl', $newcdnurl, 'filter_mathjaxloader');
|
||||
|
||||
$mathjaxconfig = get_config('filter_mathjaxloader', 'mathjaxconfig');
|
||||
if (strpos($mathjaxconfig, 'MathJax.Ajax.config.path') === false) {
|
||||
$newconfig = 'MathJax.Ajax.config.path["Contrib"] = "{wwwroot}/filter/mathjaxloader/contrib";' . "\n";
|
||||
$newconfig .= $mathjaxconfig;
|
||||
|
||||
set_config('mathjaxconfig', $newconfig, 'filter_mathjaxloader');
|
||||
}
|
||||
|
||||
upgrade_plugin_savepoint(true, 2017040300, 'filter', 'mathjaxloader');
|
||||
}
|
||||
|
||||
if ($oldversion < 2017042602) {
|
||||
|
||||
$httpsurl = get_config('filter_mathjaxloader', 'httpsurl');
|
||||
if ($httpsurl === "https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.0/MathJax.js") {
|
||||
set_config('httpsurl', 'https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js', 'filter_mathjaxloader');
|
||||
}
|
||||
|
||||
$mathjaxconfig = get_config('filter_mathjaxloader', 'mathjaxconfig');
|
||||
|
||||
if (strpos($mathjaxconfig, 'MathJax.Ajax.config.path') !== false) {
|
||||
// Now we need to remove this config again because mathjax 2.7.1 supports the extensions on the CDN.
|
||||
$configtoremove = 'MathJax.Ajax.config.path["Contrib"] = "{wwwroot}/filter/mathjaxloader/contrib";';
|
||||
|
||||
$mathjaxconfig = str_replace($configtoremove, '', $mathjaxconfig);
|
||||
|
||||
set_config('mathjaxconfig', $mathjaxconfig, 'filter_mathjaxloader');
|
||||
}
|
||||
|
||||
upgrade_plugin_savepoint(true, 2017042602, 'filter', 'mathjaxloader');
|
||||
}
|
||||
|
||||
// Automatically generated Moodle v3.3.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
if ($oldversion < 2017091900) {
|
||||
|
||||
$httpsurl = get_config('filter_mathjaxloader', 'httpsurl');
|
||||
if (empty($httpsurl)) {
|
||||
// URL is empty, most likely because of bad upgrade path. See MDL-59780.
|
||||
set_config('httpsurl', 'https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js', 'filter_mathjaxloader');
|
||||
}
|
||||
upgrade_plugin_savepoint(true, 2017091900, 'filter', 'mathjaxloader');
|
||||
}
|
||||
|
||||
if ($oldversion < 2017100900) {
|
||||
// Update the MathJax CDN URL to the new default if the site has been using default value.
|
||||
$httpsurl = get_config('filter_mathjaxloader', 'httpsurl');
|
||||
if ($httpsurl === 'https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js') {
|
||||
set_config('httpsurl', 'https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.2/MathJax.js', 'filter_mathjaxloader');
|
||||
}
|
||||
upgrade_plugin_savepoint(true, 2017100900, 'filter', 'mathjaxloader');
|
||||
}
|
||||
|
||||
if ($oldversion < 2017101200) {
|
||||
// Update default MathJax configuration so that it does not use the Accessible.js config (causes JS errors due to upstream bug).
|
||||
$previousdefault = '
|
||||
MathJax.Hub.Config({
|
||||
config: ["Accessible.js", "Safe.js"],
|
||||
errorSettings: { message: ["!"] },
|
||||
skipStartupTypeset: true,
|
||||
messageStyle: "none"
|
||||
});
|
||||
';
|
||||
|
||||
$newdefault = '
|
||||
MathJax.Hub.Config({
|
||||
config: ["default.js", "MMLorHTML.js", "Safe.js"],
|
||||
errorSettings: { message: ["!"] },
|
||||
skipStartupTypeset: true,
|
||||
messageStyle: "none"
|
||||
});
|
||||
';
|
||||
|
||||
$mathjaxconfig = get_config('filter_mathjaxloader', 'mathjaxconfig');
|
||||
|
||||
if (empty($mathjaxconfig) || filter_mathjaxloader_upgrade_mathjaxconfig_equal($mathjaxconfig, $previousdefault)) {
|
||||
set_config('mathjaxconfig', $newdefault, 'filter_mathjaxloader');
|
||||
}
|
||||
|
||||
upgrade_plugin_savepoint(true, 2017101200, 'filter', 'mathjaxloader');
|
||||
}
|
||||
|
||||
if ($oldversion < 2017102000) {
|
||||
// Re-add Accessible.js (we should not have removed it).
|
||||
$previousdefault = '
|
||||
MathJax.Hub.Config({
|
||||
config: ["default.js", "MMLorHTML.js", "Safe.js"],
|
||||
errorSettings: { message: ["!"] },
|
||||
skipStartupTypeset: true,
|
||||
messageStyle: "none"
|
||||
});
|
||||
';
|
||||
$newdefault = '
|
||||
MathJax.Hub.Config({
|
||||
config: ["Accessible.js", "Safe.js"],
|
||||
errorSettings: { message: ["!"] },
|
||||
skipStartupTypeset: true,
|
||||
messageStyle: "none"
|
||||
});
|
||||
';
|
||||
|
||||
$mathjaxconfig = get_config('filter_mathjaxloader', 'mathjaxconfig');
|
||||
|
||||
if (empty($mathjaxconfig) || filter_mathjaxloader_upgrade_mathjaxconfig_equal($mathjaxconfig, $previousdefault)) {
|
||||
set_config('mathjaxconfig', $newdefault, 'filter_mathjaxloader');
|
||||
}
|
||||
|
||||
upgrade_plugin_savepoint(true, 2017102000, 'filter', 'mathjaxloader');
|
||||
}
|
||||
|
||||
// Automatically generated Moodle v3.4.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Automatically generated Moodle v3.5.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
|
||||
@@ -1,95 +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/>.
|
||||
|
||||
/**
|
||||
* Random functions for mathjax upgrades.
|
||||
*
|
||||
* @package filter_mathjaxloader
|
||||
* @copyright 2017 Damyon Wiese ([email protected])
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
/**
|
||||
* This function takes an existing mathjax url and, if it was using the standard mathjax cdn,
|
||||
* upgrades it to use the cloudflare matchjax cdn (because the standard one is shutting down).
|
||||
* @param string $mathjaxurl - The current url.
|
||||
* @param boolean $httponly - Use http instead of https - really only for 3.1 upgrades.
|
||||
* @return string The new url.
|
||||
*/
|
||||
function filter_mathjaxloader_upgrade_cdn_cloudflare($mathjaxurl, $httponly = false) {
|
||||
$newcdnurl = $mathjaxurl;
|
||||
$cdnroot = 'https://cdn.mathjax.org/mathjax/';
|
||||
if ($httponly) {
|
||||
$cdnroot = 'http://cdn.mathjax.org/mathjax/';
|
||||
}
|
||||
$usingcdn = strpos($mathjaxurl, $cdnroot) === 0;
|
||||
if ($usingcdn) {
|
||||
$majorversion = substr($mathjaxurl, strlen($cdnroot), 3);
|
||||
$latestversion = '2.7.0';
|
||||
if ($majorversion == '2.6') {
|
||||
$latestversion = '2.6.1';
|
||||
} else if ($majorversion == '2.5') {
|
||||
$latestversion = '2.5.3';
|
||||
}
|
||||
|
||||
$offset = strpos($mathjaxurl, '/', strlen($cdnroot));
|
||||
if ($offset === false) {
|
||||
return $newcdnurl;
|
||||
}
|
||||
|
||||
$endofurl = substr($mathjaxurl, $offset + 1);
|
||||
|
||||
$newcdnbase = 'https://cdnjs.cloudflare.com/ajax/libs/mathjax/';
|
||||
if ($httponly) {
|
||||
$newcdnbase = 'http://cdnjs.cloudflare.com/ajax/libs/mathjax/';
|
||||
}
|
||||
|
||||
$newcdnurl = $newcdnbase . $latestversion . '/' . $endofurl;
|
||||
}
|
||||
|
||||
return $newcdnurl;
|
||||
}
|
||||
|
||||
/**
|
||||
* Compares two values of the 'mathjaxconfig' config option.
|
||||
*
|
||||
* This is used during the upgrade to see if the two text values of the 'mathjaxconfig' config option should be
|
||||
* considered equal of different. The strings are normalized so that EOL characters and whitespace is not significant.
|
||||
*
|
||||
* @param string $val1 value
|
||||
* @param string $val2 value
|
||||
* @return bool true if the texts should be considered equals, false otherwise
|
||||
*/
|
||||
function filter_mathjaxloader_upgrade_mathjaxconfig_equal($val1, $val2) {
|
||||
|
||||
$val1lines = preg_split("/[\r\n]/", $val1);
|
||||
$val2lines = preg_split("/[\r\n]/", $val2);
|
||||
|
||||
$val1lines = array_map('trim', $val1lines);
|
||||
$val2lines = array_map('trim', $val2lines);
|
||||
|
||||
$val1lines = array_filter($val1lines, function($value) {
|
||||
return $value !== '';
|
||||
});
|
||||
|
||||
$val2lines = array_filter($val2lines, function($value) {
|
||||
return $value !== '';
|
||||
});
|
||||
|
||||
return (implode(' ', $val1lines) === implode(' ', $val2lines));
|
||||
}
|
||||
@@ -1,124 +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/>.
|
||||
|
||||
/**
|
||||
* Unit test for the upgrade MathJax code.
|
||||
*
|
||||
* @package filter_mathjaxloader
|
||||
* @copyright 2017 Damyon Wiese
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
global $CFG;
|
||||
require_once($CFG->dirroot . '/filter/mathjaxloader/db/upgradelib.php');
|
||||
|
||||
/**
|
||||
* Unit test for the upgrade MathJax code.
|
||||
*
|
||||
* Test the functions in upgradelib.php
|
||||
*
|
||||
* @copyright 2017 Damyon Wiese
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class filter_mathjax_upgradelib_testcase extends advanced_testcase {
|
||||
|
||||
/**
|
||||
* Tests for {@link filter_mathjaxloader_upgrade_cdn_cloudflare()} function.
|
||||
*/
|
||||
public function test_filter_mathjaxloader_upgrade_cdn_cloudflare() {
|
||||
$current = 'https://cdn.mathjax.org/mathjax/2.7-latest/MathJax.js?...';
|
||||
$expected = 'https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.0/MathJax.js?...';
|
||||
$this->assertEquals($expected, filter_mathjaxloader_upgrade_cdn_cloudflare($current));
|
||||
|
||||
$current = 'http://cdn.mathjax.org/mathjax/2.7-latest/MathJax.js?...';
|
||||
$expected = 'http://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.0/MathJax.js?...';
|
||||
$this->assertEquals($expected, filter_mathjaxloader_upgrade_cdn_cloudflare($current, true));
|
||||
|
||||
$current = 'http://cdn.mathjax.org/mathjax/2.7-latest/MathJax.js?...';
|
||||
$expected = 'http://cdn.mathjax.org/mathjax/2.7-latest/MathJax.js?...';
|
||||
$this->assertEquals($expected, filter_mathjaxloader_upgrade_cdn_cloudflare($current, false));
|
||||
|
||||
$current = 'https://cdn.mathjax.org/mathjax/2.7-latest/MathJax.js?...';
|
||||
$expected = 'https://cdn.mathjax.org/mathjax/2.7-latest/MathJax.js?...';
|
||||
$this->assertEquals($expected, filter_mathjaxloader_upgrade_cdn_cloudflare($current, true));
|
||||
|
||||
$current = 'https://cdn.mathjax.org/mathjax/2.6-latest/MathJax.js?...';
|
||||
$expected = 'https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.6.1/MathJax.js?...';
|
||||
$this->assertEquals($expected, filter_mathjaxloader_upgrade_cdn_cloudflare($current));
|
||||
|
||||
$current = 'https://cdn.mathjax.org/mathjax/2.5-latest/MathJax.js?...';
|
||||
$expected = 'https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.5.3/MathJax.js?...';
|
||||
$this->assertEquals($expected, filter_mathjaxloader_upgrade_cdn_cloudflare($current));
|
||||
|
||||
// Dont touch non https links.
|
||||
$current = 'http://cdn.mathjax.org/mathjax/2.5-latest/MathJax.js?...';
|
||||
$expected = 'http://cdn.mathjax.org/mathjax/2.5-latest/MathJax.js?...';
|
||||
$this->assertEquals($expected, filter_mathjaxloader_upgrade_cdn_cloudflare($current));
|
||||
|
||||
// Dont touch non local links.
|
||||
$current = 'https://mylocalmirror/mathjax/2.7-latest/MathJax.js?...';
|
||||
$expected = 'https://mylocalmirror/mathjax/2.7-latest/MathJax.js?...';
|
||||
$this->assertEquals($expected, filter_mathjaxloader_upgrade_cdn_cloudflare($current));
|
||||
|
||||
// Try some unexpected things.
|
||||
$current = '';
|
||||
$expected = '';
|
||||
$this->assertEquals($expected, filter_mathjaxloader_upgrade_cdn_cloudflare($current));
|
||||
|
||||
// Try some unexpected things.
|
||||
$current = 'https://cdn.mathjax.org/mathjax/2.7-latest/MathJax.js';
|
||||
$expected = 'https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.0/MathJax.js';
|
||||
$this->assertEquals($expected, filter_mathjaxloader_upgrade_cdn_cloudflare($current));
|
||||
|
||||
// Try some unexpected things.
|
||||
$current = 'https://cdn.mathjax.org/mathjax/2.7-latest';
|
||||
$expected = 'https://cdn.mathjax.org/mathjax/2.7-latest';
|
||||
$this->assertEquals($expected, filter_mathjaxloader_upgrade_cdn_cloudflare($current));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests for {@link filter_mathjaxloader_upgrade_mathjaxconfig_equal()} function.
|
||||
*/
|
||||
public function test_filter_mathjaxloader_upgrade_mathjaxconfig_equal() {
|
||||
|
||||
$val1 = '';
|
||||
$val2 = "\n \r \r\n \t ";
|
||||
$this->assertTrue(filter_mathjaxloader_upgrade_mathjaxconfig_equal($val1, $val2));
|
||||
|
||||
$val1 = '0';
|
||||
$val2 = '';
|
||||
$this->assertFalse(filter_mathjaxloader_upgrade_mathjaxconfig_equal($val1, $val2));
|
||||
|
||||
$val1 = 'Hello Unittest, my old friend '.PHP_EOL."I've come to play with you again \r\n\r\n \t ";
|
||||
$val2 = ' Hello Unittest, my old friend '."\r\n\r\n"." I've come to play with you again \n\n\n ";
|
||||
$this->assertTrue(filter_mathjaxloader_upgrade_mathjaxconfig_equal($val1, $val2));
|
||||
|
||||
$val1 = "\n".'MathJax.Hub.Config({'."\n".' config: ["Accessible.js", "Safe.js"]'."\n".'});'."\n";
|
||||
$val2 = 'MathJax.Hub.Config({'."\r".'config: ["Accessible.js", "Safe.js"]'."\r".'});';
|
||||
$this->assertTrue(filter_mathjaxloader_upgrade_mathjaxconfig_equal($val1, $val2));
|
||||
|
||||
$val1 = "\r\n\t".'MathJax.Hub.Config({'."\r\n\t".' config: ["Accessible.js", "Safe.js"]'."\r\n".'}); '."\r\n\r\n";
|
||||
$val2 = 'MathJax.Hub.Config({'."\n".'config: ["Accessible.js", "Safe.js"]'."\r".'});';
|
||||
$this->assertTrue(filter_mathjaxloader_upgrade_mathjaxconfig_equal($val1, $val2));
|
||||
|
||||
$val2 = 'MathJax.Hub.Config({'."\n".'config: ["Significant.js"]'."\n".'});';
|
||||
$val2 = 'MathJax.Hub.Config({'."\n".'config: ["Signi ficant.js", "Safe.js"]'."\n".'});';
|
||||
$this->assertFalse(filter_mathjaxloader_upgrade_mathjaxconfig_equal($val1, $val2));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,12 +32,6 @@ defined('MOODLE_INTERNAL') || die();
|
||||
function xmldb_filter_mediaplugin_upgrade($oldversion) {
|
||||
global $CFG;
|
||||
|
||||
// Automatically generated Moodle v3.3.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Automatically generated Moodle v3.4.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Automatically generated Moodle v3.5.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
|
||||
@@ -32,12 +32,6 @@ defined('MOODLE_INTERNAL') || die();
|
||||
function xmldb_filter_tex_upgrade($oldversion) {
|
||||
global $CFG;
|
||||
|
||||
// Automatically generated Moodle v3.3.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Automatically generated Moodle v3.4.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Automatically generated Moodle v3.5.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
|
||||
@@ -1,6 +1,12 @@
|
||||
This file describes API changes in core filter API and plugins,
|
||||
information provided here is intended especially for developers.
|
||||
|
||||
=== 3.9 ===
|
||||
|
||||
* The following functions, previously used (exclusively) by upgrade steps are not available anymore because of the upgrade cleanup performed for this version. See MDL-65809 for more info:
|
||||
- filter_mathjaxloader_upgrade_cdn_cloudflare()
|
||||
- filter_mathjaxloader_upgrade_mathjaxconfig_equal()
|
||||
|
||||
=== 3.6 ===
|
||||
|
||||
* Although there is no API change that require you to update your filter,
|
||||
|
||||
@@ -37,12 +37,6 @@ defined('MOODLE_INTERNAL') || die();
|
||||
function xmldb_gradingform_guide_upgrade($oldversion) {
|
||||
global $DB;
|
||||
|
||||
// Automatically generated Moodle v3.3.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Automatically generated Moodle v3.4.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Automatically generated Moodle v3.5.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
|
||||
@@ -33,12 +33,6 @@ defined('MOODLE_INTERNAL') || die();
|
||||
function xmldb_gradingform_rubric_upgrade($oldversion) {
|
||||
global $CFG;
|
||||
|
||||
// Automatically generated Moodle v3.3.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Automatically generated Moodle v3.4.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Automatically generated Moodle v3.5.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
|
||||
@@ -32,22 +32,6 @@ defined('MOODLE_INTERNAL') || die();
|
||||
*/
|
||||
function xmldb_gradereport_overview_upgrade($oldversion) {
|
||||
|
||||
if ($oldversion < 2017051501) {
|
||||
$context = context_system::instance();
|
||||
$capability = 'gradereport/overview:view';
|
||||
|
||||
// Now allow authenticated user role to access that report.
|
||||
$authenticateduserroles = get_archetype_roles('user');
|
||||
foreach ($authenticateduserroles as $roleid => $notused) {
|
||||
assign_capability($capability, CAP_ALLOW, $roleid, $context->id);
|
||||
}
|
||||
|
||||
upgrade_plugin_savepoint(true, 2017051501, 'gradereport', 'overview');
|
||||
}
|
||||
|
||||
// Automatically generated Moodle v3.4.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Automatically generated Moodle v3.5.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
|
||||
@@ -29,12 +29,6 @@
|
||||
function xmldb_gradereport_user_upgrade($oldversion) {
|
||||
global $CFG;
|
||||
|
||||
// Automatically generated Moodle v3.3.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Automatically generated Moodle v3.4.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Automatically generated Moodle v3.5.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
|
||||
@@ -769,6 +769,7 @@ $string['maxeditingtime'] = 'Maximum time to edit posts';
|
||||
$string['maxusersperpage'] = ' Maximum users per page';
|
||||
$string['configmaxusersperpage'] = 'Maximum number of users displayed within user selector in course, group, cohort, webservice etc.';
|
||||
$string['mbstringrecommended'] = 'Installing the optional MBSTRING library is highly recommended in order to improve site performance, particularly if your site is supporting non-Latin languages.';
|
||||
$string['mbstringrequired'] = 'Installing the MBSTRING library is required in order to improve site performance, particularly if your site is supporting non-Latin languages.';
|
||||
$string['mediapluginavi'] = 'Enable .avi filter';
|
||||
$string['mediapluginflv'] = 'Enable .flv filter';
|
||||
$string['mediapluginimg'] = 'Enable auto-embedding of linked images';
|
||||
|
||||
@@ -32,12 +32,6 @@ defined('MOODLE_INTERNAL') || die();
|
||||
*/
|
||||
function xmldb_antivirus_clamav_upgrade($oldversion) {
|
||||
|
||||
// Automatically generated Moodle v3.3.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Automatically generated Moodle v3.4.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Automatically generated Moodle v3.5.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
|
||||
+10
-1686
File diff suppressed because it is too large
Load Diff
@@ -488,42 +488,6 @@ function upgrade_standardise_score($rawgrade, $sourcemin, $sourcemax, $targetmin
|
||||
return $standardisedvalue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete orphaned records in block_positions
|
||||
*/
|
||||
function upgrade_block_positions() {
|
||||
global $DB;
|
||||
$id = 'id';
|
||||
if ($DB->get_dbfamily() !== 'mysql') {
|
||||
// Field block_positions.subpage has type 'char', it can not be compared to int in db engines except for mysql.
|
||||
$id = $DB->sql_concat('?', 'id');
|
||||
}
|
||||
$sql = "DELETE FROM {block_positions}
|
||||
WHERE pagetype IN ('my-index', 'user-profile') AND subpage NOT IN (SELECT $id FROM {my_pages})";
|
||||
$DB->execute($sql, ['']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Fix configdata in block instances that are using the old object class that has been removed (deprecated).
|
||||
*/
|
||||
function upgrade_fix_block_instance_configuration() {
|
||||
global $DB;
|
||||
|
||||
$sql = "SELECT *
|
||||
FROM {block_instances}
|
||||
WHERE " . $DB->sql_isnotempty('block_instances', 'configdata', true, true);
|
||||
$blockinstances = $DB->get_recordset_sql($sql);
|
||||
foreach ($blockinstances as $blockinstance) {
|
||||
$configdata = base64_decode($blockinstance->configdata);
|
||||
list($updated, $configdata) = upgrade_fix_serialized_objects($configdata);
|
||||
if ($updated) {
|
||||
$blockinstance->configdata = base64_encode($configdata);
|
||||
$DB->update_record('block_instances', $blockinstance);
|
||||
}
|
||||
}
|
||||
$blockinstances->close();
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides a way to check and update a serialized string that uses the deprecated object class.
|
||||
*
|
||||
|
||||
@@ -32,68 +32,6 @@ defined('MOODLE_INTERNAL') || die();
|
||||
function xmldb_editor_atto_upgrade($oldversion) {
|
||||
global $CFG;
|
||||
|
||||
// Automatically generated Moodle v3.3.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Automatically generated Moodle v3.4.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
if ($oldversion < 2018041100) {
|
||||
$toolbar = get_config('editor_atto', 'toolbar');
|
||||
|
||||
if (strpos($toolbar, 'recordrtc') === false) {
|
||||
$glue = "\r\n";
|
||||
if (strpos($toolbar, $glue) === false) {
|
||||
$glue = "\n";
|
||||
}
|
||||
$groups = explode($glue, $toolbar);
|
||||
// Try to put recordrtc in files group.
|
||||
foreach ($groups as $i => $group) {
|
||||
$parts = explode('=', $group);
|
||||
if (trim($parts[0]) == 'files') {
|
||||
$groups[$i] = 'files = ' . trim($parts[1]) . ', recordrtc';
|
||||
// Update config variable.
|
||||
$toolbar = implode($glue, $groups);
|
||||
set_config('toolbar', $toolbar, 'editor_atto');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Atto editor savepoint reached.
|
||||
upgrade_plugin_savepoint(true, 2018041100, 'editor', 'atto');
|
||||
}
|
||||
|
||||
if ($oldversion < 2018051401) {
|
||||
$toolbar = get_config('editor_atto', 'toolbar');
|
||||
$glue = "\r\n";
|
||||
$iconorderold = 'image, media, managefiles, recordrtc';
|
||||
$iconordernew = 'image, media, recordrtc, managefiles';
|
||||
|
||||
if (strpos($toolbar, $glue) === false) {
|
||||
$glue = "\n";
|
||||
}
|
||||
|
||||
$groups = explode($glue, $toolbar);
|
||||
|
||||
// Reorder atto media icons if in default configuration.
|
||||
foreach ($groups as $i => $group) {
|
||||
$parts = explode('=', $group);
|
||||
|
||||
if (trim($parts[0]) == 'files') {
|
||||
if (trim(preg_replace('/,\s*/', ', ', $parts[1])) == $iconorderold) {
|
||||
$groups[$i] = 'files = ' . $iconordernew;
|
||||
|
||||
// Update config variable.
|
||||
$toolbar = implode($glue, $groups);
|
||||
set_config('toolbar', $toolbar, 'editor_atto');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Atto editor savepoint reached.
|
||||
upgrade_plugin_savepoint(true, 2018051401, 'editor', 'atto');
|
||||
}
|
||||
|
||||
// Automatically generated Moodle v3.5.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
|
||||
@@ -32,12 +32,6 @@ defined('MOODLE_INTERNAL') || die();
|
||||
function xmldb_atto_equation_upgrade($oldversion) {
|
||||
global $CFG;
|
||||
|
||||
// Automatically generated Moodle v3.3.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Automatically generated Moodle v3.4.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Automatically generated Moodle v3.5.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
|
||||
@@ -27,12 +27,6 @@ defined('MOODLE_INTERNAL') || die();
|
||||
function xmldb_editor_tinymce_upgrade($oldversion) {
|
||||
global $CFG;
|
||||
|
||||
// Automatically generated Moodle v3.3.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Automatically generated Moodle v3.4.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Automatically generated Moodle v3.5.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
|
||||
@@ -27,12 +27,6 @@ defined('MOODLE_INTERNAL') || die();
|
||||
function xmldb_tinymce_spellchecker_upgrade($oldversion) {
|
||||
global $CFG;
|
||||
|
||||
// Automatically generated Moodle v3.3.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Automatically generated Moodle v3.4.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Automatically generated Moodle v3.5.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
|
||||
@@ -650,100 +650,6 @@ class core_upgradelib_testcase extends advanced_testcase {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create two pages with blocks, delete one page and make sure upgrade script deletes orphaned blocks
|
||||
*/
|
||||
public function test_delete_block_positions() {
|
||||
global $DB, $CFG;
|
||||
require_once($CFG->dirroot . '/my/lib.php');
|
||||
$this->resetAfterTest();
|
||||
|
||||
// Make sure each block on system dashboard page has a position.
|
||||
$systempage = $DB->get_record('my_pages', array('userid' => null, 'private' => MY_PAGE_PRIVATE));
|
||||
$systemcontext = context_system::instance();
|
||||
$blockinstances = $DB->get_records('block_instances', array('parentcontextid' => $systemcontext->id,
|
||||
'pagetypepattern' => 'my-index', 'subpagepattern' => $systempage->id));
|
||||
$this->assertNotEmpty($blockinstances);
|
||||
foreach ($blockinstances as $bi) {
|
||||
$DB->insert_record('block_positions', ['subpage' => $systempage->id, 'pagetype' => 'my-index', 'contextid' => $systemcontext->id,
|
||||
'blockinstanceid' => $bi->id, 'visible' => 1, 'weight' => $bi->defaultweight]);
|
||||
}
|
||||
|
||||
// Create two users and make two copies of the system dashboard.
|
||||
$user1 = $this->getDataGenerator()->create_user();
|
||||
$user2 = $this->getDataGenerator()->create_user();
|
||||
$page1 = my_copy_page($user1->id, MY_PAGE_PRIVATE, 'my-index');
|
||||
$page2 = my_copy_page($user2->id, MY_PAGE_PRIVATE, 'my-index');
|
||||
|
||||
$context1 = context_user::instance($user1->id);
|
||||
$context2 = context_user::instance($user2->id);
|
||||
|
||||
// Delete second page without deleting block positions.
|
||||
$DB->delete_records('my_pages', ['id' => $page2->id]);
|
||||
|
||||
// Blocks are still here.
|
||||
$this->assertEquals(count($blockinstances), $DB->count_records('block_positions', ['subpage' => $page1->id, 'pagetype' => 'my-index', 'contextid' => $context1->id]));
|
||||
$this->assertEquals(count($blockinstances), $DB->count_records('block_positions', ['subpage' => $page2->id, 'pagetype' => 'my-index', 'contextid' => $context2->id]));
|
||||
|
||||
// Run upgrade script that should delete orphaned block_positions.
|
||||
upgrade_block_positions();
|
||||
|
||||
// First user still has all his block_positions, second user does not.
|
||||
$this->assertEquals(count($blockinstances), $DB->count_records('block_positions', ['subpage' => $page1->id, 'pagetype' => 'my-index', 'contextid' => $context1->id]));
|
||||
$this->assertEquals(0, $DB->count_records('block_positions', ['subpage' => $page2->id, 'pagetype' => 'my-index']));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the conversion of auth plugin settings names.
|
||||
*/
|
||||
public function test_upgrade_fix_config_auth_plugin_names() {
|
||||
$this->resetAfterTest();
|
||||
|
||||
// Let the plugin auth_foo use legacy format only.
|
||||
set_config('name1', 'val1', 'auth/foo');
|
||||
set_config('name2', 'val2', 'auth/foo');
|
||||
|
||||
// Let the plugin auth_bar use new format only.
|
||||
set_config('name1', 'val1', 'auth_bar');
|
||||
set_config('name2', 'val2', 'auth_bar');
|
||||
|
||||
// Let the plugin auth_baz use a mix of legacy and new format, with no conflicts.
|
||||
set_config('name1', 'val1', 'auth_baz');
|
||||
set_config('name1', 'val1', 'auth/baz');
|
||||
set_config('name2', 'val2', 'auth/baz');
|
||||
set_config('name3', 'val3', 'auth_baz');
|
||||
|
||||
// Let the plugin auth_qux use a mix of legacy and new format, with conflicts.
|
||||
set_config('name1', 'val1', 'auth_qux');
|
||||
set_config('name1', 'val2', 'auth/qux');
|
||||
|
||||
// Execute the migration.
|
||||
upgrade_fix_config_auth_plugin_names('foo');
|
||||
upgrade_fix_config_auth_plugin_names('bar');
|
||||
upgrade_fix_config_auth_plugin_names('baz');
|
||||
upgrade_fix_config_auth_plugin_names('qux');
|
||||
|
||||
// Assert that legacy settings are gone and no new were introduced.
|
||||
$this->assertEmpty((array) get_config('auth/foo'));
|
||||
$this->assertEmpty((array) get_config('auth/bar'));
|
||||
$this->assertEmpty((array) get_config('auth/baz'));
|
||||
$this->assertEmpty((array) get_config('auth/qux'));
|
||||
|
||||
// Assert values were simply kept where there was no conflict.
|
||||
$this->assertSame('val1', get_config('auth_foo', 'name1'));
|
||||
$this->assertSame('val2', get_config('auth_foo', 'name2'));
|
||||
|
||||
$this->assertSame('val1', get_config('auth_bar', 'name1'));
|
||||
$this->assertSame('val2', get_config('auth_bar', 'name2'));
|
||||
|
||||
$this->assertSame('val1', get_config('auth_baz', 'name1'));
|
||||
$this->assertSame('val2', get_config('auth_baz', 'name2'));
|
||||
$this->assertSame('val3', get_config('auth_baz', 'name3'));
|
||||
|
||||
// Assert the new format took precedence in case of conflict.
|
||||
$this->assertSame('val1', get_config('auth_qux', 'name1'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a collection of test themes to test determining parent themes.
|
||||
*
|
||||
@@ -783,44 +689,6 @@ class core_upgradelib_testcase extends advanced_testcase {
|
||||
return \org\bovigo\vfs\vfsStream::url('themes');
|
||||
}
|
||||
|
||||
/**
|
||||
* Test finding theme locations.
|
||||
*/
|
||||
public function test_upgrade_find_theme_location() {
|
||||
global $CFG;
|
||||
|
||||
$this->resetAfterTest();
|
||||
|
||||
$CFG->themedir = $this->create_testthemes();
|
||||
|
||||
$this->assertSame($CFG->dirroot . '/theme/boost', upgrade_find_theme_location('boost'));
|
||||
$this->assertSame($CFG->dirroot . '/theme/classic', upgrade_find_theme_location('classic'));
|
||||
|
||||
$this->assertSame($CFG->themedir . '/testtheme', upgrade_find_theme_location('testtheme'));
|
||||
$this->assertSame($CFG->themedir . '/childoftesttheme', upgrade_find_theme_location('childoftesttheme'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test figuring out if theme is or is a child of a certain theme.
|
||||
*/
|
||||
public function test_upgrade_theme_is_from_family() {
|
||||
global $CFG;
|
||||
|
||||
$this->resetAfterTest();
|
||||
|
||||
$CFG->themedir = $this->create_testthemes();
|
||||
|
||||
$this->assertTrue(upgrade_theme_is_from_family('boost', 'boost'), 'Boost is a boost theme');
|
||||
$this->assertTrue(upgrade_theme_is_from_family('boost', 'classic'), 'Classic is a boost base theme');
|
||||
$this->assertFalse(upgrade_theme_is_from_family('classic', 'boost'), 'Boost is not a classic theme');
|
||||
|
||||
$this->assertTrue(upgrade_theme_is_from_family('testtheme', 'childoftesttheme'), 'childoftesttheme is a testtheme');
|
||||
$this->assertFalse(upgrade_theme_is_from_family('testtheme', 'orphantheme'), 'ofphantheme is not a testtheme');
|
||||
$this->assertTrue(upgrade_theme_is_from_family('testtheme', 'infinite'), 'Infinite loop with testtheme parent is true');
|
||||
$this->assertFalse(upgrade_theme_is_from_family('testtheme', 'loop'), 'Infinite loop without testtheme parent is false');
|
||||
$this->assertTrue(upgrade_theme_is_from_family('testtheme', 'themewithbrokenparent'), 'No error on broken parent');
|
||||
}
|
||||
|
||||
/**
|
||||
* Data provider of serialized string.
|
||||
*
|
||||
@@ -890,36 +758,6 @@ class core_upgradelib_testcase extends advanced_testcase {
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Check that entries in the block_instances table are coverted over correctly.
|
||||
*
|
||||
* @dataProvider encoded_strings_dataprovider
|
||||
* @param string $original The original base64_encoded block config setting.
|
||||
* @param string $expected The expected base64_encoded block config setting.
|
||||
*/
|
||||
public function test_upgrade_fix_block_instance_configuration($original, $expected) {
|
||||
global $DB;
|
||||
|
||||
$this->resetAfterTest();
|
||||
|
||||
$data = new stdClass();
|
||||
$data->blockname = 'html';
|
||||
$data->parentcontextid = 1;
|
||||
$data->showinsubcontexts = 0;
|
||||
$data->requirebytheme = 0;
|
||||
$data->pagetypepattern = 'admin-setting-frontpagesettings';
|
||||
$data->defaultregion = 'side-post';
|
||||
$data->defaultweight = 1;
|
||||
$data->timecreated = time();
|
||||
$data->timemodified = time();
|
||||
|
||||
$data->configdata = $original;
|
||||
$entryid = $DB->insert_record('block_instances', $data);
|
||||
upgrade_fix_block_instance_configuration();
|
||||
$record = $DB->get_record('block_instances', ['id' => $entryid]);
|
||||
$this->assertEquals($expected, $record->configdata);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check that orphaned files are deleted.
|
||||
*/
|
||||
|
||||
@@ -2571,166 +2571,3 @@ function check_libcurl_version(environment_results $result) {
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fix how auth plugins are called in the 'config_plugins' table.
|
||||
*
|
||||
* For legacy reasons, the auth plugins did not always use their frankenstyle
|
||||
* component name in the 'plugin' column of the 'config_plugins' table. This is
|
||||
* a helper function to correctly migrate the legacy settings into the expected
|
||||
* and consistent way.
|
||||
*
|
||||
* @param string $plugin the auth plugin name such as 'cas', 'manual' or 'mnet'
|
||||
*/
|
||||
function upgrade_fix_config_auth_plugin_names($plugin) {
|
||||
global $CFG, $DB, $OUTPUT;
|
||||
|
||||
$legacy = (array) get_config('auth/'.$plugin);
|
||||
$current = (array) get_config('auth_'.$plugin);
|
||||
|
||||
// I don't want to rely on array_merge() and friends here just in case
|
||||
// there was some crazy setting with a numerical name.
|
||||
|
||||
if ($legacy) {
|
||||
$new = $legacy;
|
||||
} else {
|
||||
$new = [];
|
||||
}
|
||||
|
||||
if ($current) {
|
||||
foreach ($current as $name => $value) {
|
||||
if (isset($legacy[$name]) && ($legacy[$name] !== $value)) {
|
||||
// No need to pollute the output during unit tests.
|
||||
if (!empty($CFG->upgraderunning)) {
|
||||
$message = get_string('settingmigrationmismatch', 'core_auth', [
|
||||
'plugin' => 'auth_'.$plugin,
|
||||
'setting' => s($name),
|
||||
'legacy' => s($legacy[$name]),
|
||||
'current' => s($value),
|
||||
]);
|
||||
echo $OUTPUT->notification($message, \core\output\notification::NOTIFY_ERROR);
|
||||
|
||||
upgrade_log(UPGRADE_LOG_NOTICE, 'auth_'.$plugin, 'Setting values mismatch detected',
|
||||
'SETTING: '.$name. ' LEGACY: '.$legacy[$name].' CURRENT: '.$value);
|
||||
}
|
||||
}
|
||||
|
||||
$new[$name] = $value;
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($new as $name => $value) {
|
||||
set_config($name, $value, 'auth_'.$plugin);
|
||||
unset_config($name, 'auth/'.$plugin);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Populate the auth plugin settings with defaults if needed.
|
||||
*
|
||||
* As a result of fixing the auth plugins config storage, many settings would
|
||||
* be falsely reported as new ones by admin/upgradesettings.php. We do not want
|
||||
* to confuse admins so we try to reduce the bewilderment by pre-populating the
|
||||
* config_plugins table with default values. This should be done only for
|
||||
* disabled auth methods. The enabled methods have their settings already
|
||||
* stored, so reporting actual new settings for them is valid.
|
||||
*
|
||||
* @param string $plugin the auth plugin name such as 'cas', 'manual' or 'mnet'
|
||||
*/
|
||||
function upgrade_fix_config_auth_plugin_defaults($plugin) {
|
||||
global $CFG;
|
||||
|
||||
$pluginman = core_plugin_manager::instance();
|
||||
$enabled = $pluginman->get_enabled_plugins('auth');
|
||||
|
||||
if (isset($enabled[$plugin])) {
|
||||
// Do not touch settings of enabled auth methods.
|
||||
return;
|
||||
}
|
||||
|
||||
// We can't directly use {@link core\plugininfo\auth::load_settings()} here
|
||||
// because the plugins are not fully upgraded yet. Instead, we emulate what
|
||||
// that method does. We fetch a temporary instance of the plugin's settings
|
||||
// page to get access to the settings and their defaults. Note we are not
|
||||
// adding that temporary instance into the admin tree. Yes, this is a hack.
|
||||
|
||||
$plugininfo = $pluginman->get_plugin_info('auth_'.$plugin);
|
||||
$adminroot = admin_get_root();
|
||||
$ADMIN = $adminroot;
|
||||
$auth = $plugininfo;
|
||||
|
||||
$section = $plugininfo->get_settings_section_name();
|
||||
$settingspath = $plugininfo->full_path('settings.php');
|
||||
|
||||
if (file_exists($settingspath)) {
|
||||
$settings = new admin_settingpage($section, 'Emulated settings page for auth_'.$plugin, 'moodle/site:config');
|
||||
include($settingspath);
|
||||
|
||||
if ($settings) {
|
||||
admin_apply_default_settings($settings, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Search for a given theme in any of the parent themes of a given theme.
|
||||
*
|
||||
* @param string $needle The name of the theme you want to search for
|
||||
* @param string $themename The name of the theme you want to search for
|
||||
* @param string $checkedthemeforparents The name of all the themes already checked
|
||||
* @return bool True if found, false if not.
|
||||
*/
|
||||
function upgrade_theme_is_from_family($needle, $themename, $checkedthemeforparents = []) {
|
||||
global $CFG;
|
||||
|
||||
// Once we've started checking a theme, don't start checking it again. Prevent recursion.
|
||||
if (!empty($checkedthemeforparents[$themename])) {
|
||||
return false;
|
||||
}
|
||||
$checkedthemeforparents[$themename] = true;
|
||||
|
||||
if ($themename == $needle) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if ($themedir = upgrade_find_theme_location($themename)) {
|
||||
$THEME = new stdClass();
|
||||
require($themedir . '/config.php');
|
||||
$theme = $THEME;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (empty($theme->parents)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Recursively search through each parent theme.
|
||||
foreach ($theme->parents as $parent) {
|
||||
if (upgrade_theme_is_from_family($needle, $parent, $checkedthemeforparents)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds the theme location and verifies the theme has all needed files.
|
||||
*
|
||||
* @param string $themename The name of the theme you want to search for
|
||||
* @return string full dir path or null if not found
|
||||
* @see \theme_config::find_theme_location()
|
||||
*/
|
||||
function upgrade_find_theme_location($themename) {
|
||||
global $CFG;
|
||||
|
||||
if (file_exists("$CFG->dirroot/theme/$themename/config.php")) {
|
||||
$dir = "$CFG->dirroot/theme/$themename";
|
||||
} else if (!empty($CFG->themedir) and file_exists("$CFG->themedir/$themename/config.php")) {
|
||||
$dir = "$CFG->themedir/$themename";
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $dir;
|
||||
}
|
||||
|
||||
@@ -34,12 +34,6 @@ function xmldb_message_email_upgrade($oldversion) {
|
||||
|
||||
$dbman = $DB->get_manager();
|
||||
|
||||
// Automatically generated Moodle v3.3.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Automatically generated Moodle v3.4.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Automatically generated Moodle v3.5.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
|
||||
@@ -32,12 +32,6 @@ defined('MOODLE_INTERNAL') || die();
|
||||
function xmldb_message_jabber_upgrade($oldversion) {
|
||||
global $CFG;
|
||||
|
||||
// Automatically generated Moodle v3.3.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Automatically generated Moodle v3.4.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Automatically generated Moodle v3.5.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
|
||||
@@ -30,51 +30,7 @@ defined('MOODLE_INTERNAL') || die();
|
||||
* @param int $oldversion The version that we are upgrading from
|
||||
*/
|
||||
function xmldb_message_popup_upgrade($oldversion) {
|
||||
global $CFG, $DB;
|
||||
|
||||
$dbman = $DB->get_manager();
|
||||
|
||||
if ($oldversion < 2016122100) {
|
||||
|
||||
// Define index isread (not unique) to be added to message_popup.
|
||||
$table = new xmldb_table('message_popup');
|
||||
$index = new xmldb_index('isread', XMLDB_INDEX_NOTUNIQUE, array('isread'));
|
||||
|
||||
// Conditionally launch add index isread.
|
||||
if (!$dbman->index_exists($table, $index)) {
|
||||
$dbman->add_index($table, $index);
|
||||
}
|
||||
|
||||
// Popup savepoint reached.
|
||||
upgrade_plugin_savepoint(true, 2016122100, 'message', 'popup');
|
||||
}
|
||||
|
||||
// Automatically generated Moodle v3.3.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Automatically generated Moodle v3.4.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
if ($oldversion < 2018032800) {
|
||||
// Define table message_popup_notifications to be created.
|
||||
$table = new xmldb_table('message_popup_notifications');
|
||||
|
||||
// Adding fields to table message_popup_notifications.
|
||||
$table->add_field('id', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
|
||||
$table->add_field('notificationid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null);
|
||||
|
||||
// Adding keys to table message_popup_notifications.
|
||||
$table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
|
||||
$table->add_key('notificationid', XMLDB_KEY_FOREIGN, array('notificationid'), 'notifications', array('id'));
|
||||
|
||||
// Conditionally launch create table for message_popup_notifications.
|
||||
if (!$dbman->table_exists($table)) {
|
||||
$dbman->create_table($table);
|
||||
}
|
||||
|
||||
// Popup savepoint reached.
|
||||
upgrade_plugin_savepoint(true, 2018032800, 'message', 'popup');
|
||||
}
|
||||
global $CFG;
|
||||
|
||||
// Automatically generated Moodle v3.5.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
@@ -34,108 +34,6 @@ function xmldb_assign_upgrade($oldversion) {
|
||||
|
||||
$dbman = $DB->get_manager();
|
||||
|
||||
if ($oldversion < 2017021500) {
|
||||
// Fix event types of assign events.
|
||||
$params = [
|
||||
'modulename' => 'assign',
|
||||
'eventtype' => 'close'
|
||||
];
|
||||
$select = "modulename = :modulename AND eventtype = :eventtype";
|
||||
$DB->set_field_select('event', 'eventtype', 'due', $select, $params);
|
||||
|
||||
// Delete 'open' events.
|
||||
$params = [
|
||||
'modulename' => 'assign',
|
||||
'eventtype' => 'open'
|
||||
];
|
||||
$DB->delete_records('event', $params);
|
||||
|
||||
// Assign savepoint reached.
|
||||
upgrade_mod_savepoint(true, 2017021500, 'assign');
|
||||
}
|
||||
|
||||
if ($oldversion < 2017031300) {
|
||||
// Add a 'gradingduedate' field to the 'assign' table.
|
||||
$table = new xmldb_table('assign');
|
||||
$field = new xmldb_field('gradingduedate', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, 0, 'cutoffdate');
|
||||
|
||||
// Conditionally launch add field.
|
||||
if (!$dbman->field_exists($table, $field)) {
|
||||
$dbman->add_field($table, $field);
|
||||
}
|
||||
|
||||
// Assign savepoint reached.
|
||||
upgrade_mod_savepoint(true, 2017031300, 'assign');
|
||||
}
|
||||
|
||||
if ($oldversion < 2017042800) {
|
||||
// Update query to set the grading due date one week after the due date.
|
||||
// Only assign instances with grading due date not set and with a due date of not older than 3 weeks will be updated.
|
||||
$sql = "UPDATE {assign}
|
||||
SET gradingduedate = duedate + :weeksecs
|
||||
WHERE gradingduedate = 0
|
||||
AND duedate > :timelimit";
|
||||
|
||||
// Calculate the time limit, which is 3 weeks before the current date.
|
||||
$interval = new DateInterval('P3W');
|
||||
$timelimit = new DateTime();
|
||||
$timelimit->sub($interval);
|
||||
|
||||
// Update query params.
|
||||
$params = [
|
||||
'weeksecs' => WEEKSECS,
|
||||
'timelimit' => $timelimit->getTimestamp()
|
||||
];
|
||||
|
||||
// Execute DB update for assign instances.
|
||||
$DB->execute($sql, $params);
|
||||
|
||||
// Assign savepoint reached.
|
||||
upgrade_mod_savepoint(true, 2017042800, 'assign');
|
||||
}
|
||||
|
||||
// Automatically generated Moodle v3.3.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
if ($oldversion < 2017061200) {
|
||||
// Data fix any assign group override event priorities which may have been accidentally nulled due to a bug on the group
|
||||
// overrides edit form.
|
||||
|
||||
// First, find all assign group override events having null priority (and join their corresponding assign_overrides entry).
|
||||
$sql = "SELECT e.id AS id, o.sortorder AS priority
|
||||
FROM {assign_overrides} o
|
||||
JOIN {event} e ON (e.modulename = 'assign' AND o.assignid = e.instance AND e.groupid = o.groupid)
|
||||
WHERE o.groupid IS NOT NULL AND e.priority IS NULL
|
||||
ORDER BY o.id";
|
||||
$affectedrs = $DB->get_recordset_sql($sql);
|
||||
|
||||
// Now update the event's priority based on the assign_overrides sortorder we found. This uses similar logic to
|
||||
// assign_refresh_events(), except we've restricted the set of assignments and overrides we're dealing with here.
|
||||
foreach ($affectedrs as $record) {
|
||||
$DB->set_field('event', 'priority', $record->priority, ['id' => $record->id]);
|
||||
}
|
||||
$affectedrs->close();
|
||||
|
||||
// Main savepoint reached.
|
||||
upgrade_mod_savepoint(true, 2017061200, 'assign');
|
||||
}
|
||||
|
||||
if ($oldversion < 2017061205) {
|
||||
require_once($CFG->dirroot.'/mod/assign/upgradelib.php');
|
||||
$brokenassigns = get_assignments_with_rescaled_null_grades();
|
||||
|
||||
// Set config value.
|
||||
foreach ($brokenassigns as $assign) {
|
||||
set_config('has_rescaled_null_grades_' . $assign, 1, 'assign');
|
||||
}
|
||||
|
||||
// Main savepoint reached.
|
||||
upgrade_mod_savepoint(true, 2017061205, 'assign');
|
||||
}
|
||||
|
||||
// Automatically generated Moodle v3.4.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Automatically generated Moodle v3.5.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
|
||||
@@ -32,12 +32,6 @@ defined('MOODLE_INTERNAL') || die();
|
||||
function xmldb_assignfeedback_comments_upgrade($oldversion) {
|
||||
global $CFG;
|
||||
|
||||
// Automatically generated Moodle v3.3.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Automatically generated Moodle v3.4.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Automatically generated Moodle v3.5.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
|
||||
@@ -34,28 +34,6 @@ function xmldb_assignfeedback_editpdf_upgrade($oldversion) {
|
||||
|
||||
$dbman = $DB->get_manager();
|
||||
|
||||
if ($oldversion < 2017022700) {
|
||||
|
||||
// Get orphaned, duplicate files and delete them.
|
||||
$fs = get_file_storage();
|
||||
$sqllike = $DB->sql_like("filename", "?");
|
||||
$where = "component='assignfeedback_editpdf' AND filearea = 'importhtml' AND " . $sqllike;
|
||||
$filerecords = $DB->get_records_select("files", $where, ["onlinetext-%"]);
|
||||
foreach ($filerecords as $filerecord) {
|
||||
$file = $fs->get_file_instance($filerecord);
|
||||
$file->delete();
|
||||
}
|
||||
|
||||
// Editpdf savepoint reached.
|
||||
upgrade_plugin_savepoint(true, 2017022700, 'assignfeedback', 'editpdf');
|
||||
}
|
||||
|
||||
// Automatically generated Moodle v3.3.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Automatically generated Moodle v3.4.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Automatically generated Moodle v3.5.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
|
||||
@@ -32,12 +32,6 @@ defined('MOODLE_INTERNAL') || die();
|
||||
function xmldb_assignfeedback_file_upgrade($oldversion) {
|
||||
global $CFG;
|
||||
|
||||
// Automatically generated Moodle v3.3.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Automatically generated Moodle v3.4.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Automatically generated Moodle v3.5.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
|
||||
@@ -32,12 +32,6 @@ defined('MOODLE_INTERNAL') || die();
|
||||
function xmldb_assignsubmission_comments_upgrade($oldversion) {
|
||||
global $CFG;
|
||||
|
||||
// Automatically generated Moodle v3.3.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Automatically generated Moodle v3.4.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Automatically generated Moodle v3.5.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
|
||||
@@ -32,12 +32,6 @@ defined('MOODLE_INTERNAL') || die();
|
||||
function xmldb_assignsubmission_file_upgrade($oldversion) {
|
||||
global $CFG;
|
||||
|
||||
// Automatically generated Moodle v3.3.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Automatically generated Moodle v3.4.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Automatically generated Moodle v3.5.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
|
||||
@@ -32,12 +32,6 @@ defined('MOODLE_INTERNAL') || die();
|
||||
function xmldb_assignsubmission_onlinetext_upgrade($oldversion) {
|
||||
global $CFG;
|
||||
|
||||
// Automatically generated Moodle v3.3.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Automatically generated Moodle v3.4.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Automatically generated Moodle v3.5.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
|
||||
@@ -3785,71 +3785,6 @@ Anchor link 2:<a title=\"bananas\" href=\"../logo-240x60.gif\">Link text</a>
|
||||
$this->assertEquals(1, $completiondata->completionstate);
|
||||
}
|
||||
|
||||
public function get_assignments_with_rescaled_null_grades_provider() {
|
||||
return [
|
||||
'Negative less than one is errant' => [
|
||||
'grade' => -0.64,
|
||||
'count' => 1,
|
||||
],
|
||||
'Negative more than one is errant' => [
|
||||
'grade' => -30.18,
|
||||
'count' => 1,
|
||||
],
|
||||
'Negative one exactly is not errant' => [
|
||||
'grade' => ASSIGN_GRADE_NOT_SET,
|
||||
'count' => 0,
|
||||
],
|
||||
'Positive grade is not errant' => [
|
||||
'grade' => 1,
|
||||
'count' => 0,
|
||||
],
|
||||
'Large grade is not errant' => [
|
||||
'grade' => 100,
|
||||
'count' => 0,
|
||||
],
|
||||
'Zero grade is not errant' => [
|
||||
'grade' => 0,
|
||||
'count' => 0,
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Test determining if the assignment as any null grades that were rescaled.
|
||||
* @dataProvider get_assignments_with_rescaled_null_grades_provider
|
||||
*/
|
||||
public function test_get_assignments_with_rescaled_null_grades($grade, $count) {
|
||||
global $DB;
|
||||
|
||||
$this->resetAfterTest();
|
||||
|
||||
$course = $this->getDataGenerator()->create_course();
|
||||
$teacher = $this->getDataGenerator()->create_and_enrol($course, 'teacher');
|
||||
$student = $this->getDataGenerator()->create_and_enrol($course, 'student');
|
||||
|
||||
$this->setUser($teacher);
|
||||
$assign = $this->create_instance($course, [
|
||||
'grade' => 100,
|
||||
]);
|
||||
|
||||
// Try getting a student's grade. This will give a grade of -1.
|
||||
// Then we can override it with a bad negative grade.
|
||||
$assign->get_user_grade($student->id, true);
|
||||
|
||||
// Set the grade to something errant.
|
||||
$DB->set_field(
|
||||
'assign_grades',
|
||||
'grade',
|
||||
$grade,
|
||||
[
|
||||
'userid' => $student->id,
|
||||
'assignment' => $assign->get_instance()->id,
|
||||
]
|
||||
);
|
||||
|
||||
$this->assertCount($count, get_assignments_with_rescaled_null_grades());
|
||||
}
|
||||
|
||||
/**
|
||||
* Data provider for test_fix_null_grades
|
||||
* @return array[] Test data for test_fix_null_grades. Each element should contain grade, expectedcount and gradebookvalue
|
||||
|
||||
@@ -1,4 +1,10 @@
|
||||
This files describes API changes in the assign code.
|
||||
|
||||
=== 3.9 ===
|
||||
|
||||
* The following functions, previously used (exclusively) by upgrade steps are not available anymore because of the upgrade cleanup performed for this version. See MDL-65809 for more info:
|
||||
- get_assignments_with_rescaled_null_grades()
|
||||
|
||||
=== 3.8 ===
|
||||
* The allow_image_conversion method has been added to the submissionplugins. It determines whether the submission plugin
|
||||
allows image conversion or not. By default conversion is not allowed (except when overwritten in the submission plugin)
|
||||
|
||||
@@ -414,27 +414,3 @@ class assign_upgrade_manager {
|
||||
return $newcm;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines if the assignment as any null grades that were rescaled.
|
||||
*
|
||||
* Null grades are stored as -1 but should never be rescaled.
|
||||
*
|
||||
* @return int[] Array of the ids of all the assignments with rescaled null grades.
|
||||
*/
|
||||
function get_assignments_with_rescaled_null_grades() {
|
||||
global $DB;
|
||||
|
||||
$query = 'SELECT id, assignment FROM {assign_grades}
|
||||
WHERE grade < 0 AND grade <> -1';
|
||||
|
||||
$assignments = array_values($DB->get_records_sql($query));
|
||||
|
||||
$getassignmentid = function ($assignment) {
|
||||
return $assignment->assignment;
|
||||
};
|
||||
|
||||
$assignments = array_map($getassignmentid, $assignments);
|
||||
|
||||
return $assignments;
|
||||
}
|
||||
|
||||
@@ -24,12 +24,6 @@ defined('MOODLE_INTERNAL') || die();
|
||||
function xmldb_assignment_upgrade($oldversion) {
|
||||
global $CFG;
|
||||
|
||||
// Automatically generated Moodle v3.3.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Automatically generated Moodle v3.4.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Automatically generated Moodle v3.5.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
|
||||
@@ -32,12 +32,6 @@ defined('MOODLE_INTERNAL') || die;
|
||||
function xmldb_book_upgrade($oldversion) {
|
||||
global $CFG;
|
||||
|
||||
// Automatically generated Moodle v3.3.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Automatically generated Moodle v3.4.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Automatically generated Moodle v3.5.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
|
||||
+1
-36
@@ -25,42 +25,7 @@
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
function xmldb_chat_upgrade($oldversion) {
|
||||
global $CFG, $DB;
|
||||
|
||||
$dbman = $DB->get_manager();
|
||||
|
||||
// Automatically generated Moodle v3.3.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Automatically generated Moodle v3.4.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
if ($oldversion < 2017111301) {
|
||||
// Rename field 'system' on table 'chat_messages' as it is a reserved word in MySQL 8+.
|
||||
$table = new xmldb_table('chat_messages');
|
||||
$field = new xmldb_field('system');
|
||||
if ($dbman->field_exists($table, $field)) {
|
||||
$field->set_attributes(XMLDB_TYPE_INTEGER, '1', null, XMLDB_NOTNULL, null, '0', 'groupid');
|
||||
// Extend the execution time limit of the script to 2 hours.
|
||||
upgrade_set_timeout(7200);
|
||||
// Rename it to 'issystem'.
|
||||
$dbman->rename_field($table, $field, 'issystem');
|
||||
}
|
||||
|
||||
// Rename field 'system' on table 'chat_messages_current' as it is a reserved word in MySQL 8+.
|
||||
$table = new xmldb_table('chat_messages_current');
|
||||
$field = new xmldb_field('system');
|
||||
if ($dbman->field_exists($table, $field)) {
|
||||
$field->set_attributes(XMLDB_TYPE_INTEGER, '1', null, XMLDB_NOTNULL, null, '0', 'groupid');
|
||||
// Extend the execution time limit of the script to 5 minutes.
|
||||
upgrade_set_timeout(300);
|
||||
// Rename it to 'issystem'.
|
||||
$dbman->rename_field($table, $field, 'issystem');
|
||||
}
|
||||
|
||||
// Savepoint reached.
|
||||
upgrade_mod_savepoint(true, 2017111301, 'chat');
|
||||
}
|
||||
global $CFG;
|
||||
|
||||
// Automatically generated Moodle v3.5.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
@@ -24,12 +24,6 @@ defined('MOODLE_INTERNAL') || die();
|
||||
function xmldb_choice_upgrade($oldversion) {
|
||||
global $CFG;
|
||||
|
||||
// Automatically generated Moodle v3.3.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Automatically generated Moodle v3.4.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Automatically generated Moodle v3.5.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
|
||||
@@ -24,29 +24,6 @@ defined('MOODLE_INTERNAL') || die();
|
||||
function xmldb_data_upgrade($oldversion) {
|
||||
global $CFG, $DB;
|
||||
|
||||
$dbman = $DB->get_manager();
|
||||
|
||||
if ($oldversion < 2017032800) {
|
||||
|
||||
// Define field completionentries to be added to data. Require a number of entries to be considered complete.
|
||||
$table = new xmldb_table('data');
|
||||
$field = new xmldb_field('completionentries', XMLDB_TYPE_INTEGER, '10', null, null, null, '0', 'config');
|
||||
|
||||
// Conditionally launch add field timemodified.
|
||||
if (!$dbman->field_exists($table, $field)) {
|
||||
$dbman->add_field($table, $field);
|
||||
}
|
||||
|
||||
// Data savepoint reached.
|
||||
upgrade_mod_savepoint(true, 2017032800, 'data');
|
||||
}
|
||||
|
||||
// Automatically generated Moodle v3.3.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Automatically generated Moodle v3.4.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Automatically generated Moodle v3.5.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
|
||||
@@ -42,43 +42,7 @@
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
function xmldb_feedback_upgrade($oldversion) {
|
||||
global $CFG, $DB;
|
||||
|
||||
$dbman = $DB->get_manager(); // Loads ddl manager and xmldb classes.
|
||||
|
||||
if ($oldversion < 2017032800) {
|
||||
|
||||
// Delete duplicated records in feedback_completed. We just keep the last record of completion.
|
||||
// Related values in feedback_value won't be deleted (they won't be used and can be kept there as a backup).
|
||||
$sql = "SELECT MAX(id) as maxid, userid, feedback, courseid
|
||||
FROM {feedback_completed}
|
||||
WHERE userid <> 0 AND anonymous_response = :notanonymous
|
||||
GROUP BY userid, feedback, courseid
|
||||
HAVING COUNT(id) > 1";
|
||||
$params = ['notanonymous' => 2]; // FEEDBACK_ANONYMOUS_NO.
|
||||
|
||||
$duplicatedrows = $DB->get_recordset_sql($sql, $params);
|
||||
foreach ($duplicatedrows as $row) {
|
||||
$DB->delete_records_select('feedback_completed', 'userid = ? AND feedback = ? AND courseid = ? AND id <> ?'.
|
||||
' AND anonymous_response = ?', array(
|
||||
$row->userid,
|
||||
$row->feedback,
|
||||
$row->courseid,
|
||||
$row->maxid,
|
||||
2, // FEEDBACK_ANONYMOUS_NO.
|
||||
));
|
||||
}
|
||||
$duplicatedrows->close();
|
||||
|
||||
// Feedback savepoint reached.
|
||||
upgrade_mod_savepoint(true, 2017032800, 'feedback');
|
||||
}
|
||||
|
||||
// Automatically generated Moodle v3.3.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Automatically generated Moodle v3.4.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
global $CFG;
|
||||
|
||||
// Automatically generated Moodle v3.5.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
@@ -45,15 +45,7 @@
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
function xmldb_folder_upgrade($oldversion) {
|
||||
global $CFG, $DB;
|
||||
|
||||
$dbman = $DB->get_manager(); // Loads ddl manager and xmldb classes.
|
||||
|
||||
// Automatically generated Moodle v3.3.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Automatically generated Moodle v3.4.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
global $CFG;
|
||||
|
||||
// Automatically generated Moodle v3.5.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
@@ -47,57 +47,6 @@ function xmldb_forum_upgrade($oldversion) {
|
||||
|
||||
$dbman = $DB->get_manager(); // Loads ddl manager and xmldb classes.
|
||||
|
||||
// Automatically generated Moodle v3.3.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
if ($oldversion < 2017092200) {
|
||||
|
||||
// Remove duplicate entries from forum_subscriptions.
|
||||
// Find records with multiple userid/forum combinations and find the highest ID.
|
||||
// Later we will remove all those entries.
|
||||
$sql = "
|
||||
SELECT MIN(id) as minid, userid, forum
|
||||
FROM {forum_subscriptions}
|
||||
GROUP BY userid, forum
|
||||
HAVING COUNT(id) > 1";
|
||||
|
||||
if ($duplicatedrows = $DB->get_recordset_sql($sql)) {
|
||||
foreach ($duplicatedrows as $row) {
|
||||
$DB->delete_records_select('forum_subscriptions',
|
||||
'userid = :userid AND forum = :forum AND id <> :minid', (array)$row);
|
||||
}
|
||||
}
|
||||
$duplicatedrows->close();
|
||||
|
||||
// Define key useridforum (primary) to be added to forum_subscriptions.
|
||||
$table = new xmldb_table('forum_subscriptions');
|
||||
$key = new xmldb_key('useridforum', XMLDB_KEY_UNIQUE, array('userid', 'forum'));
|
||||
|
||||
// Launch add key useridforum.
|
||||
$dbman->add_key($table, $key);
|
||||
|
||||
// Forum savepoint reached.
|
||||
upgrade_mod_savepoint(true, 2017092200, 'forum');
|
||||
}
|
||||
|
||||
// Automatically generated Moodle v3.4.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
if ($oldversion < 2018032900) {
|
||||
|
||||
// Define field deleted to be added to forum_posts.
|
||||
$table = new xmldb_table('forum_posts');
|
||||
$field = new xmldb_field('deleted', XMLDB_TYPE_INTEGER, '1', null, XMLDB_NOTNULL, null, '0', 'mailnow');
|
||||
|
||||
// Conditionally launch add field deleted.
|
||||
if (!$dbman->field_exists($table, $field)) {
|
||||
$dbman->add_field($table, $field);
|
||||
}
|
||||
|
||||
// Forum savepoint reached.
|
||||
upgrade_mod_savepoint(true, 2018032900, 'forum');
|
||||
}
|
||||
|
||||
// Automatically generated Moodle v3.5.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
|
||||
@@ -20,13 +20,7 @@
|
||||
// before any action that may take longer time to finish.
|
||||
|
||||
function xmldb_glossary_upgrade($oldversion) {
|
||||
global $CFG, $DB;
|
||||
|
||||
// Automatically generated Moodle v3.3.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Automatically generated Moodle v3.4.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
global $DB;
|
||||
|
||||
// Automatically generated Moodle v3.5.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
@@ -31,12 +31,6 @@ defined('MOODLE_INTERNAL') || die();
|
||||
function xmldb_imscp_upgrade($oldversion) {
|
||||
global $CFG;
|
||||
|
||||
// Automatically generated Moodle v3.3.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Automatically generated Moodle v3.4.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Automatically generated Moodle v3.5.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
|
||||
@@ -45,24 +45,7 @@
|
||||
defined('MOODLE_INTERNAL') || die;
|
||||
|
||||
function xmldb_label_upgrade($oldversion) {
|
||||
global $CFG, $DB;
|
||||
|
||||
// Automatically generated Moodle v3.3.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
if ($oldversion < 2017062800) {
|
||||
// Update all records in 'course_modules' for labels to have showdescription = 1.
|
||||
if ($modid = $DB->get_field('modules', 'id', ['name' => 'label'])) {
|
||||
$DB->execute("UPDATE {course_modules} SET showdescription = ? WHERE module = ?",
|
||||
[1, $modid]);
|
||||
}
|
||||
|
||||
// Label savepoint reached.
|
||||
upgrade_mod_savepoint(true, 2017062800, 'label');
|
||||
}
|
||||
|
||||
// Automatically generated Moodle v3.4.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
global $CFG;
|
||||
|
||||
// Automatically generated Moodle v3.5.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
@@ -50,66 +50,7 @@ defined('MOODLE_INTERNAL') || die();
|
||||
* @return bool
|
||||
*/
|
||||
function xmldb_lesson_upgrade($oldversion) {
|
||||
global $CFG, $DB;
|
||||
|
||||
$dbman = $DB->get_manager();
|
||||
|
||||
if ($oldversion < 2016120515) {
|
||||
// Define new fields to be added to lesson.
|
||||
$table = new xmldb_table('lesson');
|
||||
$field = new xmldb_field('allowofflineattempts', XMLDB_TYPE_INTEGER, '1', null, null, null, 0, 'completiontimespent');
|
||||
// Conditionally launch add field allowofflineattempts.
|
||||
if (!$dbman->field_exists($table, $field)) {
|
||||
$dbman->add_field($table, $field);
|
||||
}
|
||||
// Lesson savepoint reached.
|
||||
upgrade_mod_savepoint(true, 2016120515, 'lesson');
|
||||
}
|
||||
if ($oldversion < 2016120516) {
|
||||
// New field for lesson_timer.
|
||||
$table = new xmldb_table('lesson_timer');
|
||||
$field = new xmldb_field('timemodifiedoffline', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, 0, 'completed');
|
||||
// Conditionally launch add field timemodifiedoffline.
|
||||
if (!$dbman->field_exists($table, $field)) {
|
||||
$dbman->add_field($table, $field);
|
||||
}
|
||||
// Lesson savepoint reached.
|
||||
upgrade_mod_savepoint(true, 2016120516, 'lesson');
|
||||
}
|
||||
|
||||
// Automatically generated Moodle v3.3.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
if ($oldversion < 2017051501) {
|
||||
|
||||
// Delete orphaned lesson answer and response files.
|
||||
$sql = "SELECT DISTINCT f.contextid, f.component, f.filearea, f.itemid
|
||||
FROM {files} f
|
||||
LEFT JOIN {lesson_answers} la ON f.itemid = la.id
|
||||
WHERE component = :component
|
||||
AND (filearea = :fileareaanswer OR filearea = :filearearesponse)
|
||||
AND la.id IS NULL";
|
||||
|
||||
$orphanedfiles = $DB->get_recordset_sql($sql, array('component' => 'mod_lesson', 'fileareaanswer' => 'page_answers',
|
||||
'filearearesponse' => 'page_responses'));
|
||||
$fs = get_file_storage();
|
||||
foreach ($orphanedfiles as $file) {
|
||||
$fs->delete_area_files($file->contextid, $file->component, $file->filearea, $file->itemid);
|
||||
}
|
||||
$orphanedfiles->close();
|
||||
|
||||
upgrade_mod_savepoint(true, 2017051501, 'lesson');
|
||||
}
|
||||
|
||||
if ($oldversion < 2019062400) {
|
||||
// Delete orphaned group overrides.
|
||||
$DB->delete_records_select('lesson_overrides', 'groupid = 0 AND userid IS NULL');
|
||||
|
||||
upgrade_mod_savepoint(true, 2019062400, 'lesson');
|
||||
}
|
||||
|
||||
// Automatically generated Moodle v3.4.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
global $CFG;
|
||||
|
||||
// Automatically generated Moodle v3.5.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
@@ -63,64 +63,6 @@ function xmldb_lti_upgrade($oldversion) {
|
||||
|
||||
$dbman = $DB->get_manager();
|
||||
|
||||
// Automatically generated Moodle v3.3.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Automatically generated Moodle v3.4.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
if ($oldversion < 2017111301) {
|
||||
|
||||
// A bug in the LTI plugin incorrectly inserted a grade item for
|
||||
// LTI instances which were set to not allow grading.
|
||||
// The change finds any LTI which does not have grading enabled,
|
||||
// and updates any grades to delete them.
|
||||
|
||||
$ltis = $DB->get_recordset_sql("
|
||||
SELECT
|
||||
l.id,
|
||||
l.course,
|
||||
l.instructorchoiceacceptgrades,
|
||||
t.enabledcapability,
|
||||
t.toolproxyid,
|
||||
tc.value AS acceptgrades
|
||||
FROM {lti} l
|
||||
INNER JOIN {grade_items} gt
|
||||
ON l.id = gt.iteminstance
|
||||
LEFT JOIN {lti_types} t
|
||||
ON t.id = l.typeid
|
||||
LEFT JOIN {lti_types_config} tc
|
||||
ON tc.typeid = t.id AND tc.name = 'acceptgrades'
|
||||
WHERE gt.itemmodule = 'lti'
|
||||
AND gt.itemtype = 'mod'
|
||||
");
|
||||
|
||||
foreach ($ltis as $lti) {
|
||||
$acceptgrades = true;
|
||||
if (empty($lti->toolproxyid)) {
|
||||
$typeacceptgrades = isset($lti->acceptgrades) ? $lti->acceptgrades : 2;
|
||||
if (!($typeacceptgrades == 1 ||
|
||||
($typeacceptgrades == 2 && $lti->instructorchoiceacceptgrades == 1))) {
|
||||
$acceptgrades = false;
|
||||
}
|
||||
} else {
|
||||
$enabledcapabilities = explode("\n", $lti->enabledcapability);
|
||||
$acceptgrades = in_array('Result.autocreate', $enabledcapabilities);
|
||||
}
|
||||
|
||||
if (!$acceptgrades) {
|
||||
// Required when doing CLI upgrade.
|
||||
require_once($CFG->libdir . '/gradelib.php');
|
||||
grade_update('mod/lti', $lti->course, 'mod', 'lti', $lti->id, 0, null, array('deleted' => 1));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$ltis->close();
|
||||
|
||||
upgrade_mod_savepoint(true, 2017111301, 'lti');
|
||||
}
|
||||
|
||||
// Automatically generated Moodle v3.5.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
|
||||
@@ -47,12 +47,6 @@ defined('MOODLE_INTERNAL') || die;
|
||||
function xmldb_page_upgrade($oldversion) {
|
||||
global $CFG;
|
||||
|
||||
// Automatically generated Moodle v3.3.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Automatically generated Moodle v3.4.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Automatically generated Moodle v3.5.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
|
||||
+1
-118
@@ -29,124 +29,7 @@ defined('MOODLE_INTERNAL') || die();
|
||||
* @param string $oldversion the version we are upgrading from.
|
||||
*/
|
||||
function xmldb_quiz_upgrade($oldversion) {
|
||||
global $CFG, $DB;
|
||||
|
||||
$dbman = $DB->get_manager();
|
||||
|
||||
// Automatically generated Moodle v3.3.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Automatically generated Moodle v3.4.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
if ($oldversion < 2018020700) {
|
||||
|
||||
$table = new xmldb_table('quiz_slots');
|
||||
|
||||
// Define field questioncategoryid to be added to quiz_slots.
|
||||
$field = new xmldb_field('questioncategoryid', XMLDB_TYPE_INTEGER, '10', null, null, null, null, 'questionid');
|
||||
// Conditionally launch add field questioncategoryid.
|
||||
if (!$dbman->field_exists($table, $field)) {
|
||||
$dbman->add_field($table, $field);
|
||||
}
|
||||
|
||||
// Define key questioncategoryid (foreign) to be added to quiz_slots.
|
||||
$key = new xmldb_key('questioncategoryid', XMLDB_KEY_FOREIGN, array('questioncategoryid'), 'question_categories', ['id']);
|
||||
// Launch add key questioncategoryid.
|
||||
$dbman->add_key($table, $key);
|
||||
|
||||
// Define field includingsubcategories to be added to quiz_slots.
|
||||
$field = new xmldb_field('includingsubcategories', XMLDB_TYPE_INTEGER, '4', null, null, null, null, 'questioncategoryid');
|
||||
// Conditionally launch add field includingsubcategories.
|
||||
if (!$dbman->field_exists($table, $field)) {
|
||||
$dbman->add_field($table, $field);
|
||||
}
|
||||
|
||||
// Quiz savepoint reached.
|
||||
upgrade_mod_savepoint(true, 2018020700, 'quiz');
|
||||
}
|
||||
|
||||
if ($oldversion < 2018020701) {
|
||||
// This SQL fetches all "random" questions from the question bank.
|
||||
$fromclause = "FROM {quiz_slots} qs
|
||||
JOIN {question} q ON q.id = qs.questionid
|
||||
WHERE q.qtype = ?";
|
||||
|
||||
// Get the total record count - used for the progress bar.
|
||||
$total = $DB->count_records_sql("SELECT count(qs.id) $fromclause", array('random'));
|
||||
|
||||
// Get the records themselves.
|
||||
$rs = $DB->get_recordset_sql("SELECT qs.id, q.category, q.questiontext $fromclause", array('random'));
|
||||
|
||||
$a = new stdClass();
|
||||
$a->total = $total;
|
||||
$a->done = 0;
|
||||
|
||||
// For each question, move the configuration data to the quiz_slots table.
|
||||
$pbar = new progress_bar('updatequizslotswithrandom', 500, true);
|
||||
foreach ($rs as $record) {
|
||||
$data = new stdClass();
|
||||
$data->id = $record->id;
|
||||
$data->questioncategoryid = $record->category;
|
||||
$data->includingsubcategories = empty($record->questiontext) ? 0 : 1;
|
||||
$DB->update_record('quiz_slots', $data);
|
||||
|
||||
// Update progress.
|
||||
$a->done++;
|
||||
$pbar->update($a->done, $a->total, get_string('updatequizslotswithrandomxofy', 'quiz', $a));
|
||||
}
|
||||
$rs->close();
|
||||
|
||||
// Quiz savepoint reached.
|
||||
upgrade_mod_savepoint(true, 2018020701, 'quiz');
|
||||
}
|
||||
|
||||
if ($oldversion < 2018040700) {
|
||||
|
||||
// Define field tags to be dropped from quiz_slots. This field was added earlier to master only.
|
||||
$table = new xmldb_table('quiz_slots');
|
||||
$field = new xmldb_field('tags');
|
||||
|
||||
// Conditionally launch drop field quizid.
|
||||
if ($dbman->field_exists($table, $field)) {
|
||||
$dbman->drop_field($table, $field);
|
||||
}
|
||||
|
||||
// Quiz savepoint reached.
|
||||
upgrade_mod_savepoint(true, 2018040700, 'quiz');
|
||||
}
|
||||
|
||||
if ($oldversion < 2018040800) {
|
||||
|
||||
// Define table quiz_slot_tags to be created.
|
||||
$table = new xmldb_table('quiz_slot_tags');
|
||||
|
||||
// Adding fields to table quiz_slot_tags.
|
||||
$table->add_field('id', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
|
||||
$table->add_field('slotid', XMLDB_TYPE_INTEGER, '10', null, null, null, null);
|
||||
$table->add_field('tagid', XMLDB_TYPE_INTEGER, '10', null, null, null, null);
|
||||
$table->add_field('tagname', XMLDB_TYPE_CHAR, '255', null, null, null, null);
|
||||
|
||||
// Adding keys to table quiz_slot_tags.
|
||||
$table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
|
||||
$table->add_key('slotid', XMLDB_KEY_FOREIGN, array('slotid'), 'quiz_slots', array('id'));
|
||||
$table->add_key('tagid', XMLDB_KEY_FOREIGN, array('tagid'), 'tag', array('id'));
|
||||
|
||||
// Conditionally launch create table for quiz_slot_tags.
|
||||
if (!$dbman->table_exists($table)) {
|
||||
$dbman->create_table($table);
|
||||
}
|
||||
|
||||
// Quiz savepoint reached.
|
||||
upgrade_mod_savepoint(true, 2018040800, 'quiz');
|
||||
}
|
||||
|
||||
if ($oldversion < 2019062400) {
|
||||
// Delete orphaned group overrides.
|
||||
$DB->delete_records_select('quiz_overrides', 'groupid = 0 AND userid IS NULL');
|
||||
|
||||
upgrade_mod_savepoint(true, 2019062400, 'quiz');
|
||||
}
|
||||
global $CFG;
|
||||
|
||||
// Automatically generated Moodle v3.5.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
@@ -33,12 +33,6 @@ function xmldb_quiz_overview_upgrade($oldversion) {
|
||||
|
||||
$dbman = $DB->get_manager();
|
||||
|
||||
// Automatically generated Moodle v3.3.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Automatically generated Moodle v3.4.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Automatically generated Moodle v3.5.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
|
||||
@@ -30,12 +30,6 @@ defined('MOODLE_INTERNAL') || die();
|
||||
function xmldb_quiz_statistics_upgrade($oldversion) {
|
||||
global $DB;
|
||||
|
||||
// Automatically generated Moodle v3.3.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Automatically generated Moodle v3.4.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Automatically generated Moodle v3.5.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
|
||||
@@ -47,12 +47,6 @@ defined('MOODLE_INTERNAL') || die;
|
||||
function xmldb_resource_upgrade($oldversion) {
|
||||
global $CFG;
|
||||
|
||||
// Automatically generated Moodle v3.3.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Automatically generated Moodle v3.4.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Automatically generated Moodle v3.5.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
|
||||
@@ -30,36 +30,10 @@ defined('MOODLE_INTERNAL') || die();
|
||||
* @return bool
|
||||
*/
|
||||
function xmldb_scorm_upgrade($oldversion) {
|
||||
global $CFG, $DB;
|
||||
global $DB;
|
||||
|
||||
$dbman = $DB->get_manager();
|
||||
|
||||
// Automatically generated Moodle v3.3.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Automatically generated Moodle v3.4.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
if ($oldversion < 2018032300) {
|
||||
set_config('scormstandard', get_config('scorm', 'scorm12standard'), 'scorm');
|
||||
unset_config('scorm12standard', 'scorm');
|
||||
|
||||
upgrade_mod_savepoint(true, 2018032300, 'scorm');
|
||||
}
|
||||
|
||||
if ($oldversion < 2018041100) {
|
||||
|
||||
// Changing precision of field completionscorerequired on table scorm to (10).
|
||||
$table = new xmldb_table('scorm');
|
||||
$field = new xmldb_field('completionscorerequired', XMLDB_TYPE_INTEGER, '10', null, null, null, null, 'completionstatusrequired');
|
||||
|
||||
// Launch change of precision for field completionscorerequired.
|
||||
$dbman->change_field_precision($table, $field);
|
||||
|
||||
// Scorm savepoint reached.
|
||||
upgrade_mod_savepoint(true, 2018041100, 'scorm');
|
||||
}
|
||||
|
||||
// Automatically generated Moodle v3.5.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
|
||||
@@ -24,12 +24,6 @@ defined('MOODLE_INTERNAL') || die();
|
||||
function xmldb_survey_upgrade($oldversion) {
|
||||
global $CFG;
|
||||
|
||||
// Automatically generated Moodle v3.3.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Automatically generated Moodle v3.4.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Automatically generated Moodle v3.5.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