Skip to content

Commit

Permalink
Merge branch 'mdl55979-master' of https://github.com/tlock/moodle
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewnicols committed Jul 17, 2017
2 parents 5a842a9 + 72b8806 commit 5ee30c0
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
3 changes: 2 additions & 1 deletion mod/quiz/classes/structure.php
Original file line number Diff line number Diff line change
Expand Up @@ -715,7 +715,8 @@ public function move_slot($idmove, $idmoveafter, $page) {
}

$followingslotnumber = $moveafterslotnumber + 1;
if ($followingslotnumber == $movingslotnumber) {
// Prevent checking against non-existance slot when already at the last slot.
if ($followingslotnumber == $movingslotnumber && !$this->is_last_slot_in_quiz($followingslotnumber)) {
$followingslotnumber += 1;
}

Expand Down
18 changes: 18 additions & 0 deletions mod/quiz/tests/structure_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,24 @@ public function test_move_slot_end_of_one_page_to_start_of_next() {
), $structure);
}

public function test_move_last_slot_to_previous_page_emptying_the_last_page() {
$quizobj = $this->create_test_quiz(array(
array('TF1', 1, 'truefalse'),
array('TF2', 2, 'truefalse'),
));
$structure = \mod_quiz\structure::create_for_quiz($quizobj);

$idtomove = $structure->get_question_in_slot(2)->slotid;
$idmoveafter = $structure->get_question_in_slot(1)->slotid;
$structure->move_slot($idtomove, $idmoveafter, '1');

$structure = \mod_quiz\structure::create_for_quiz($quizobj);
$this->assert_quiz_layout(array(
array('TF1', 1, 'truefalse'),
array('TF2', 1, 'truefalse'),
), $structure);
}

public function test_end_of_one_section_to_start_of_next() {
$quizobj = $this->create_test_quiz(array(
array('TF1', 1, 'truefalse'),
Expand Down

0 comments on commit 5ee30c0

Please sign in to comment.