Skip to content

Commit

Permalink
Merge branch 'MDL-29176_21' of git://github.com/timhunt/moodle into M…
Browse files Browse the repository at this point in the history
…OODLE_21_STABLE
  • Loading branch information
Sam Hemelryk committed Dec 18, 2011
2 parents dd98ec6 + 5c91aac commit f158171
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion mod/quiz/edit.php
Expand Up @@ -356,11 +356,19 @@ function module_specific_controls($totalnumber, $recurse, $category, $cmid, $cmo
//move to the end of the selected page //move to the end of the selected page
$pagebreakpositions = array_keys($questions, 0); $pagebreakpositions = array_keys($questions, 0);
$numpages = count($pagebreakpositions); $numpages = count($pagebreakpositions);

// Ensure the target page number is in range. // 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]; $moveselectedpos = $pagebreakpositions[$moveselectedonpage - 1];

// Do the move.
array_splice($questions, $moveselectedpos, 0, $selectedquestionids); array_splice($questions, $moveselectedpos, 0, $selectedquestionids);
$quiz->questions = implode(',', $questions); $quiz->questions = implode(',', $questions);

// Update the database.
$DB->set_field('quiz', 'questions', $quiz->questions, array('id' => $quiz->id)); $DB->set_field('quiz', 'questions', $quiz->questions, array('id' => $quiz->id));
$deletepreviews = true; $deletepreviews = true;
} }
Expand Down

0 comments on commit f158171

Please sign in to comment.