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

Edit quiz page corrupts the question variable when displaying random questions

    XMLWordPrintable

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.6.3, 2.7, 2.8
    • 2.6.4, 2.7.1
    • Quiz
    • MOODLE_26_STABLE, MOODLE_27_STABLE, MOODLE_28_STABLE
    • MOODLE_26_STABLE, MOODLE_27_STABLE
    • 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

    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

              timhunt Tim Hunt
              timhunt Tim Hunt
              Eric Merrill Eric Merrill
              Eloy Lafuente (stronk7) Eloy Lafuente (stronk7)
              John Okely John Okely
              Tim Hunt, Ilya Tregubov, Kevin Percy, Mathew May, Mihail Geshoski, Shamim Rezaie
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:
                14/Jul/14