MDL-61614 Quiz: Deleting a quiz slot should delete its random tags

This commit is contained in:
Shamim Rezaie 2018-04-11 10:52:17 +10:00
parent 66aa172cbb
commit 3090719d7d
2 changed files with 4 additions and 1 deletions

View File

@ -914,6 +914,7 @@ class structure {
$maxslot = $DB->get_field_sql('SELECT MAX(slot) FROM {quiz_slots} WHERE quizid = ?', array($this->get_quizid()));
$trans = $DB->start_delegated_transaction();
$DB->delete_records('quiz_slot_tags', array('slotid' => $slot->id));
$DB->delete_records('quiz_slots', array('id' => $slot->id));
for ($i = $slot->slot + 1; $i <= $maxslot; $i++) {
$DB->set_field('quiz_slots', 'slot', $i - 1,

View File

@ -183,7 +183,9 @@ function quiz_delete_instance($id) {
WHERE slot.quizid = ? AND q.qtype = ?";
$questionids = $DB->get_fieldset_sql($sql, array($quiz->id, 'random'));
// We need to do this before we try and delete randoms, otherwise they would still be 'in use'.
// We need to do the following deletes before we try and delete randoms, otherwise they would still be 'in use'.
$quizslots = $DB->get_fieldset_select('quiz_slots', 'id', 'quizid = ?', array($quiz->id));
$DB->delete_records_list('quiz_slot_tags', 'slotid', $quizslots);
$DB->delete_records('quiz_slots', array('quizid' => $quiz->id));
$DB->delete_records('quiz_sections', array('quizid' => $quiz->id));