Permalink
Browse files

MDL-29176 quiz editing: can't move questions onto a new page.

  • Loading branch information...
1 parent cb8e878 commit 98402da0944e1da7763aaf98b660bec7b76b6515 @timhunt timhunt committed Dec 15, 2011
Showing with 9 additions and 1 deletion.
  1. +9 −1 mod/quiz/edit.php
View
@@ -356,11 +356,19 @@ function module_specific_controls($totalnumber, $recurse, $category, $cmid, $cmo
//move to the end of the selected page
$pagebreakpositions = array_keys($questions, 0);
$numpages = count($pagebreakpositions);
+
// Ensure the target page number is in range.
- $moveselectedonpage = max(1, min($moveselectedonpage, $pagebreakpositions));
+ for ($i = $moveselectedonpage; $i > $numpages; $i--) {
+ $questions[] = 0;
+ $pagebreakpositions[] = count($questions) - 1;
+ }
$moveselectedpos = $pagebreakpositions[$moveselectedonpage - 1];
+
+ // Do the move.
array_splice($questions, $moveselectedpos, 0, $selectedquestionids);
$quiz->questions = implode(',', $questions);
+
+ // Update the database.
$DB->set_field('quiz', 'questions', $quiz->questions, array('id' => $quiz->id));
$deletepreviews = true;
}

0 comments on commit 98402da

Please sign in to comment.