Merge branch 'MDL-77224-402' of https://github.com/paulholden/moodle into MOODLE_402_STABLE
This commit is contained in:
@@ -252,5 +252,20 @@ function xmldb_h5pactivity_upgrade($oldversion) {
|
||||
// Automatically generated Moodle v4.2.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
if ($oldversion < 2023042401) {
|
||||
|
||||
// Remove any orphaned attempt/result records (pointing to non-existing activities).
|
||||
$DB->delete_records_select('h5pactivity_attempts', 'NOT EXISTS (
|
||||
SELECT 1 FROM {h5pactivity} h5p WHERE h5p.id = {h5pactivity_attempts}.h5pactivityid
|
||||
)');
|
||||
|
||||
$DB->delete_records_select('h5pactivity_attempts_results', 'NOT EXISTS (
|
||||
SELECT 1 FROM {h5pactivity_attempts} attempt WHERE attempt.id = {h5pactivity_attempts_results}.attemptid
|
||||
)');
|
||||
|
||||
// H5pactivity savepoint reached.
|
||||
upgrade_mod_savepoint(true, 2023042401, 'h5pactivity');
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -152,6 +152,13 @@ function h5pactivity_delete_instance(int $id): bool {
|
||||
$xapihandler->wipe_states($context->id);
|
||||
}
|
||||
|
||||
// Remove activity record, and all associated attempt data.
|
||||
$attemptids = $DB->get_fieldset_select('h5pactivity_attempts', 'id', 'h5pactivityid = ?', [$id]);
|
||||
if ($attemptids) {
|
||||
$DB->delete_records_list('h5pactivity_attempts_results', 'attemptid', $attemptids);
|
||||
$DB->delete_records_list('h5pactivity_attempts', 'id', $attemptids);
|
||||
}
|
||||
|
||||
$DB->delete_records('h5pactivity', ['id' => $id]);
|
||||
|
||||
h5pactivity_grade_item_delete($activity);
|
||||
|
||||
@@ -25,5 +25,5 @@
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
$plugin->component = 'mod_h5pactivity';
|
||||
$plugin->version = 2023042400;
|
||||
$plugin->version = 2023042401;
|
||||
$plugin->requires = 2023041800;
|
||||
|
||||
Reference in New Issue
Block a user