Issue Details (XML | Word | Printable)

Key: MDL-13673
Type: Bug Bug
Status: Resolved Resolved
Resolution: Duplicate
Priority: Minor Minor
Assignee: Tim Hunt
Reporter: Igor Plisco
Votes: 0
Watchers: 0
Operations

Add/Edit UI Mockup to this issue
If you were logged in you would be able to see more operations.
Moodle

Pagination works only for shuffled quiz

Created: 26/Feb/08 11:02 PM   Updated: 28/Feb/08 12:14 AM
Return to search
Component/s: Quiz
Affects Version/s: 1.9
Fix Version/s: None

Issue Links:
Duplicate
 

Participants: Igor Plisco and Tim Hunt
Security Level: None
Resolved date: 26/Feb/08
Affected Branches: MOODLE_19_STABLE


 Description  « Hide
If you set "Shuffle questions" to "No", all questions are displayed on one page regardles of value of "Questions per page".

It's because in the mod/quiz/locallib.php the pagination is called only when 'shufflequestions' flag is on. I see no reason to not call the pagination for non-shuffles quizes too.

Fix:

$ diff -U2 locallib.php.old locallib.php
--- locallib.php.old 2008-02-26 16:58:24.000000000 +0300
+++ locallib.php 2008-02-26 16:57:43.000000000 +0300
@@ -65,9 +65,5 @@
         $attempt->userid = $USER->id;
         $attempt->preview = 0;
- if ($quiz->shufflequestions) {
- $attempt->layout = quiz_repaginate($quiz->questions, $quiz->questionsperpage, true);
- } else {
- $attempt->layout = $quiz->questions;
- }
+ $attempt->layout = quiz_repaginate($quiz->questions, $quiz->questionsperpage, $quiz->shufflequestions);
     }



 All   Comments   Change History   Version Control      Sort Order: Ascending order - Click to sort in descending order
Tim Hunt added a comment - 26/Feb/08 11:43 PM
There is a reason why you proposed change is bad - manually paginated quizzes. See the linked bug for a fuller explanation.

Please try to find exiting bug reports before adding a new one.


Igor Plisco added a comment - 27/Feb/08 06:11 PM
OK, first part of the MDL-6353 tells almost the same. It even better describes why current behaviour creates problems to the user.

But this problem has not been solved for about an year and a half. I suggest simple and efficient solution of the problem.

For my solution to work at manual pagination too, one can set 'Questions per page' to 'Unlimited', which adds no automatic page breaks:

if ($perpage and $i > $perpage) { $layout .= '0,'; $i = 1; }

But it removes current pagination. To prevent this removing one should either prevent executing of the first line in the function quiz_repaginate. that is, change

$layout = str_replace(',0', '', $layout); // remove existing page breaks

to
if ($perpage) { $layout = str_replace(',0', '', $layout); // remove existing page breaks }

or simply return from the function if 'perpage' is set to 0:

if ($perpage) { return $layout; }


Igor Plisco added a comment - 28/Feb/08 12:14 AM
The shortest patch affects only 2 lines:

=====================
$ diff -U2 locallib.php.old locallib.php
— locallib.php.old 2008-02-27 18:11:08.000000000 +0300
+++ locallib.php 2008-02-27 18:12:03.000000000 +0300
@@ -65,6 +65,6 @@
$attempt->userid = $USER->id;
$attempt->preview = 0;

  • if ($quiz->shufflequestions) {
  • $attempt->layout = quiz_repaginate($quiz->questions, $quiz->questionsperpage, true);
    + if ($quiz->questionsperpage) { + $attempt->layout = quiz_repaginate($quiz->questions, $quiz->questionsperpage, $quiz->shufflequestions); } else {
    $attempt->layout = $quiz->questions;
    =======================

If you want to use manual pagination, you simply set 'Questions per page' to 'Unlimited'.