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

Quizzes with no questions may cause upgrade exception

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Critical
    • Resolution: Fixed
    • Affects Version/s: 2.7
    • Fix Version/s: 2.7.1
    • Component/s: Quiz
    • Labels:
    • Testing Instructions:
      Hide
      1. In Moodle 2.6, create a quiz with no questions, just a page.
      2. In the quiz table, find your quiz and change sumgrades to 20.
      3. In the database, add a record in quiz_question_instances with the quiz set to the id of the quiz you created, question of 0, and a sum grade of 10.
      4. Upgrade to Moodle 2.7
      5. Confirm no exceptions errors occur. If debugging it on, you expect to see one or twos warning during the quiz upgrade - unused questions, and updating sumgrade
      Show
      In Moodle 2.6, create a quiz with no questions, just a page. In the quiz table, find your quiz and change sumgrades to 20. In the database, add a record in quiz_question_instances with the quiz set to the id of the quiz you created, question of 0, and a sum grade of 10. Upgrade to Moodle 2.7 Confirm no exceptions errors occur. If debugging it on, you expect to see one or twos warning during the quiz upgrade - unused questions, and updating sumgrade
    • Affected Branches:
      MOODLE_27_STABLE
    • Fixed Branches:
      MOODLE_27_STABLE

      Description

      In an edge case, the 2.7 upgrade steps may cause a fatal exception during upgrade:

      Debug info: ERROR: null value in column "sumgrades" violates not-null constraint
      DETAIL: Failing row contains (1, 2, 1, , 1, 0, 0, 0, autoabandon, 0, deferredfeedback, 0, 0, 1, 2, -1, 69904, 4368, 4368, 4368, 4368, 4368, 4368, 1, free, 0, 1, ,,0,0,0,,,0,0,0, null, 10.00000, 0, 1399919648, , , -, 0, 0, 0, 0).
      UPDATE mdl_quiz SET sumgrades = NULL WHERE id = $1
      [array (
      0 => '1',
      )]
      Error code: dmlwriteexception
      

      I tracked it down to a sumgrades check which doesn't check for a valid value before attempting to save it.

        Attachments

          Activity

            People

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

              Dates

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