Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

MDL-27483 make quiz repagination more robust.

  • Loading branch information...
commit b11d3741226004ea6e64a04aaf015e878c8736ae 1 parent 3372846
@timhunt timhunt authored stronk7 committed
Showing with 7 additions and 6 deletions.
  1. +2 −1  mod/quiz/lib.php
  2. +5 −5 mod/quiz/locallib.php
View
3  mod/quiz/lib.php
@@ -101,7 +101,8 @@ function quiz_update_instance($quiz, $mform) {
// Repaginate, if asked to.
if (!$quiz->shufflequestions && !empty($quiz->repaginatenow)) {
require_once($CFG->dirroot . '/mod/quiz/locallib.php');
- $quiz->questions = quiz_repaginate($oldquiz->questions, $quiz->questionsperpage);
+ $quiz->questions = quiz_repaginate(quiz_clean_layout($oldquiz->questions, true),
+ $quiz->questionsperpage);
}
unset($quiz->repaginatenow);
View
10 mod/quiz/locallib.php
@@ -84,11 +84,9 @@ function quiz_create_attempt($quiz, $attemptnumber, $lastattempt, $timenow, $isp
$attempt->quiz = $quiz->id;
$attempt->userid = $USER->id;
$attempt->preview = 0;
+ $attempt->layout = quiz_clean_layout($quiz->questions, true);
if ($quiz->shufflequestions) {
- $attempt->layout = quiz_clean_layout(quiz_repaginate(
- $quiz->questions, $quiz->questionsperpage, true), true);
- } else {
- $attempt->layout = quiz_clean_layout($quiz->questions, true);
+ $attempt->layout = quiz_repaginate($attempt->layout, $quiz->questionsperpage, true);
}
} else {
// Build on last attempt.
@@ -240,7 +238,9 @@ function quiz_number_of_questions_in_quiz($layout) {
/**
* Re-paginates the quiz layout
*
- * @param string $layout The string representing the quiz layout.
+ * @param string $layout The string representing the quiz layout. If there is
+ * if there is any doubt about the quality of the input data, call
+ * quiz_clean_layout before you call this function.
* @param int $perpage The number of questions per page
* @param bool $shuffle Should the questions be reordered randomly?
* @return string the new layout string
Please sign in to comment.
Something went wrong with that request. Please try again.