Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-27483

Quiz repaginate enter in a endless loop

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 2.0.3, 2.1, 2.2
    • Fix Version/s: 2.0.4, 2.1.1
    • Component/s: Quiz
    • Labels:
    • Environment:
      Moodle 2.0.1 - Moodle 2.0.3
    • Database:
      Any
    • Testing Instructions:
      Hide

      1. Create a quiz and turning variable layout/Question order in "shuffled randomly" before adding any questions.
      2. Edit the quiz settings, change the number of questions per page, tick the repaginate now box, then save changes.

      Show
      1. Create a quiz and turning variable layout/Question order in "shuffled randomly" before adding any questions. 2. Edit the quiz settings, change the number of questions per page, tick the repaginate now box, then save changes.
    • 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:

      Description

      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')

      { array_shift($questions); }

      if ($shuffle)

      { shuffle($questions); }

      $i = 1;
      $layout = '';
      foreach ($questions as $question) {
      if ($perpage and $i > $perpage)

      { $layout .= '0,'; $i = 1; }

      $layout .= $question.',';
      $i++;
      }
      return $layout.'0';
      }
      }

        Gliffy Diagrams

          Attachments

            Activity

              People

              • Votes:
                1 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Fix Release Date:
                  1/Aug/11