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

Edit quiz page corrupts the question variable when displaying random questions

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 2.6.3, 2.7, 2.8
    • Fix Version/s: 2.6.4, 2.7.1
    • Component/s: Quiz
    • Labels:
    • Testing Instructions:
      Hide

      (In what follows, the question type does not matter. True/false chosen because it is quickest to create. You only need to type name and question text.)

      1. Create a new quiz called 'MDL-45970 quiz'.
      2. Go to the 'Edit quiz' page. (Make sure you are on the 'Edit quiz' tab, not 'Order and paging'.)
      3. Click 'Add random qusestion...' and choose Random question using a new category, Name: 'Variants of question 1', then submit.
      4. Click 'Add a question...' and create a true-false question, setting the category for that question to 'Default for MDL-45970 quiz', then Save.
      5. Click the down-arrow beside question 2, so it moves onto a new page.
      6. Verify that no notices were shown.

      Before this fix, these steps lead to

      Notice: Undefined property: stdClass::$slot in /home/rajesht/moodles/t/moodle/mod/quiz/editlib.php on line 702

      Show
      (In what follows, the question type does not matter. True/false chosen because it is quickest to create. You only need to type name and question text.) Create a new quiz called ' MDL-45970 quiz'. Go to the 'Edit quiz' page. (Make sure you are on the 'Edit quiz' tab, not 'Order and paging'.) Click 'Add random qusestion...' and choose Random question using a new category, Name: 'Variants of question 1', then submit. Click 'Add a question...' and create a true-false question, setting the category for that question to 'Default for MDL-45970 quiz', then Save. Click the down-arrow beside question 2, so it moves onto a new page. Verify that no notices were shown. Before this fix, these steps lead to Notice: Undefined property: stdClass::$slot in /home/rajesht/moodles/t/moodle/mod/quiz/editlib.php on line 702
    • Affected Branches:
      MOODLE_26_STABLE, MOODLE_27_STABLE, MOODLE_28_STABLE
    • Fixed Branches:
      MOODLE_26_STABLE, MOODLE_27_STABLE
    • Pull from Repository:
    • Pull Master Branch:

      Description

      (11:12:16 AM) Rajesh Taneja: +++ b/mod/quiz/editlib.php
      @@ -882,8 +882,8 @@ function quiz_print_randomquestion(&$question, &$pageurl, &$quiz, $quiz_qbanktoo
       
               // Then list them.
               echo '<ul>';
      -        foreach ($questionstoshow as $question) {
      -            echo '<li>' . quiz_question_tostring($question, true) . '</li>';
      +        foreach ($questionstoshow as $question1) {
      +            echo '<li>' . quiz_question_tostring($question1, true) . '</li>';
               }
      (11:12:40 AM) Rajesh Taneja: This was updating reference and causing the problem...
      

      Note that the loop changes $question, which is passed into the function by reference.

        Attachments

          Issue Links

            Activity

              People

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

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Fix Release Date:
                  14/Jul/14