-
Type:
Bug
-
Status: Closed
-
Priority:
Minor
-
Resolution: Fixed
-
Affects Version/s: 2.0.3, 2.1, 2.2
-
Component/s: Quiz
-
Labels:
-
Environment:Moodle 2.0.1 - Moodle 2.0.3
-
Database:Any
-
Testing Instructions:
-
Affected Branches:MOODLE_20_STABLE, MOODLE_21_STABLE, MOODLE_22_STABLE
-
Fixed Branches:MOODLE_20_STABLE, MOODLE_21_STABLE
-
Pull from Repository:
-
Pull Master Branch:
-
Pull Master Diff URL:
A quiz instance without questions and variable layout/Question order turned in "shuffled randomly" creates an endless loop in mod/quiz/locallib.php line 348.
To make a quick fix i made this:
function quiz_repaginate($layout, $perpage, $shuffle = false) {
$layout = str_replace(',0', '', $layout); // remove existing page breaks
$questions = explode(',', $layout);
//remove empty pages from beginning
if(count($questions)!==1){ //only paginate if there is at least one question
while (reset($questions) == '0')
if ($shuffle)
{ shuffle($questions); } $i = 1;
$layout = '';
foreach ($questions as $question) {
if ($perpage and $i > $perpage)
$layout .= $question.',';
$i++;
}
return $layout.'0';
}
}