MDL-65399 mod_quiz: remove_slot should update the existing info

The remove_slot method should update the remaining slot's slot
attribute. It also should update the remaining slot's question number
and section info.
This commit is contained in:
Shamim Rezaie 2019-04-23 11:15:43 +10:00
parent 8affd823a4
commit a834294228
2 changed files with 30 additions and 0 deletions

View file

@ -720,6 +720,24 @@ class mod_quiz_structure_testcase extends advanced_testcase {
$this->assertFalse($DB->record_exists('question', array('id' => $randomq->id)));
}
/**
* Unit test to make sue it is not possible to remove all slots in a section at once.
*
* @expectedException coding_exception
*/
public function test_cannot_remove_all_slots_in_a_section() {
$quizobj = $this->create_test_quiz(array(
array('TF1', 1, 'truefalse'),
array('TF2', 1, 'truefalse'),
'Heading 2',
array('TF3', 2, 'truefalse'),
));
$structure = \mod_quiz\structure::create_for_quiz($quizobj);
$structure->remove_slot(1);
$structure->remove_slot(2);
}
/**
* @expectedException coding_exception
*/