diff --git a/admin/environment.xml b/admin/environment.xml
index fe56aa2e253..e2c68ad7808 100644
--- a/admin/environment.xml
+++ b/admin/environment.xml
@@ -4110,9 +4110,6 @@
-
-
-
diff --git a/lang/en/admin.php b/lang/en/admin.php
index a5127aba93c..886bd7aabd3 100644
--- a/lang/en/admin.php
+++ b/lang/en/admin.php
@@ -1586,7 +1586,7 @@ $string['yuicomboloading'] = 'YUI combo loading';
$string['ziprequired'] = 'The Zip PHP extension is now required by Moodle, info-ZIP binaries or PclZip library are not used anymore.';
$string['manageqbanks'] = 'Manage question bank plugins';
$string['modassignmentinuse'] = 'Your site is still using the Assignment 2.2 plugin. Before upgrading you must 1) backup any Assignment 2.2 activities that you want to keep and restore them as Assignment activities, and 2) delete all Assignment 2.2 data from the database.';
-
+$string['modassignmentsubpluginsexist'] = 'Assignment 2.2. subplugins may be present. The mod/assignment folder and all of its subplugins need to be removed before upgrading.';
$string['caching'] = 'Caching';
$string['cachesettings'] = 'Cache settings';
diff --git a/lib/db/upgrade.php b/lib/db/upgrade.php
index e7e618b43f9..c94cf1768f2 100644
--- a/lib/db/upgrade.php
+++ b/lib/db/upgrade.php
@@ -3191,20 +3191,6 @@ privatefiles,moodle|/user/files.php';
upgrade_main_savepoint(true, 2023031400.02);
}
- if ($oldversion < 2023032800.01) {
- // If mod_assignment is no longer present, remove it.
- if (!file_exists($CFG->dirroot . '/mod/assignment/version.php')) {
- uninstall_plugin('assignment', 'offline');
- uninstall_plugin('assignment', 'online');
- uninstall_plugin('assignment', 'upload');
- uninstall_plugin('assignment', 'uploadsingle');
- uninstall_plugin('mod', 'assignment');
- }
-
- // Main savepoint reached.
- upgrade_main_savepoint(true, 2023032800.01);
- }
-
if ($oldversion < 2023040600.01) {
// If logstore_legacy is no longer present, remove it.
if (!file_exists($CFG->dirroot . '/admin/tool/log/store/legacy/version.php')) {
@@ -3228,5 +3214,47 @@ privatefiles,moodle|/user/files.php';
upgrade_main_savepoint(true, 2023041100.00);
}
+ if ($oldversion < 2023042000.00) {
+ // If mod_assignment is no longer present, remove it.
+ if (!file_exists($CFG->dirroot . '/mod/assignment/version.php')) {
+ // Delete all mod_assignment grade_grades orphaned data.
+ $DB->delete_records_select(
+ 'grade_grades', "itemid IN (SELECT id FROM {grade_items} WHERE itemtype = 'mod' AND itemmodule = 'assignment')"
+ );
+
+ // Delete all mod_assignment grade_grades_history orphaned data.
+ $DB->delete_records('grade_grades_history', ['source' => 'mod/assignment']);
+
+ // Delete all mod_assignment grade_items orphaned data.
+ $DB->delete_records('grade_items', ['itemtype' => 'mod', 'itemmodule' => 'assignment']);
+
+ // Delete all mod_assignment grade_items_history orphaned data.
+ $DB->delete_records('grade_items_history', ['itemtype' => 'mod', 'itemmodule' => 'assignment']);
+
+ // Delete core mod_assignment subplugins.
+ uninstall_plugin('assignment', 'offline');
+ uninstall_plugin('assignment', 'online');
+ uninstall_plugin('assignment', 'upload');
+ uninstall_plugin('assignment', 'uploadsingle');
+
+ // Delete other mod_assignment subplugins.
+ $pluginnamelike = $DB->sql_like('plugin', ':pluginname');
+ $subplugins = $DB->get_fieldset_select('config_plugins', 'plugin', "$pluginnamelike AND name = :name", [
+ 'pluginname' => $DB->sql_like_escape('assignment_') . '%',
+ 'name' => 'version',
+ ]);
+ foreach ($subplugins as $subplugin) {
+ [$plugin, $subpluginname] = explode('_', $subplugin, 2);
+ uninstall_plugin($plugin, $subpluginname);
+ }
+
+ // Delete mod_assignment.
+ uninstall_plugin('mod', 'assignment');
+ }
+
+ // Main savepoint reached.
+ upgrade_main_savepoint(true, 2023042000.00);
+ }
+
return true;
}
diff --git a/lib/upgradelib.php b/lib/upgradelib.php
index 1a229c5d3b7..2b234f5ff25 100644
--- a/lib/upgradelib.php
+++ b/lib/upgradelib.php
@@ -2824,12 +2824,20 @@ function check_xmlrpc_usage(environment_results $result): ?environment_results {
function check_mod_assignment(environment_results $result): ?environment_results {
global $CFG, $DB;
- // Check the number of records.
- if (!file_exists("{$CFG->dirroot}/mod/assignment/version.php") && $DB->get_manager()->table_exists('assignment')
- && $DB->count_records('assignment') > 0) {
- $result->setInfo('Assignment 2.2 is in use');
- $result->setFeedbackStr('modassignmentinuse');
- return $result;
+ if (!file_exists("{$CFG->dirroot}/mod/assignment/version.php")) {
+ // Check for mod_assignment instances.
+ if ($DB->get_manager()->table_exists('assignment') && $DB->count_records('assignment') > 0) {
+ $result->setInfo('Assignment 2.2 is in use');
+ $result->setFeedbackStr('modassignmentinuse');
+ return $result;
+ }
+
+ // Check for mod_assignment subplugins.
+ if (is_dir($CFG->dirroot . '/mod/assignment/type')) {
+ $result->setInfo('Assignment 2.2 subplugins present');
+ $result->setFeedbackStr('modassignmentsubpluginsexist');
+ return $result;
+ }
}
return null;
diff --git a/version.php b/version.php
index 9e04c422948..e7f2d875428 100644
--- a/version.php
+++ b/version.php
@@ -29,7 +29,7 @@
defined('MOODLE_INTERNAL') || die();
-$version = 2023041900.00; // YYYYMMDD = weekly release date of this DEV branch.
+$version = 2023042000.00; // YYYYMMDD = weekly release date of this DEV branch.
// RR = release increments - 00 in DEV branches.
// .XX = incremental changes.
$release = '4.2rc1 (Build: 20230418)'; // Human-friendly version name