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

Fatal error caused by missing public "make_answer" method

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 2.8.7, 2.9.1
    • Fix Version/s: 2.8.8, 2.9.2
    • Component/s: Quiz
    • Environment:
      Linux : Ubuntu 14.04
    • Database:
      PostgreSQL
    • Testing Instructions:
      Hide
      1. Create a new quiz with a time out of 10 seconds and a grace period of 1 day.
      2. Add one calculated multi choice question to the quiz.
      3. Add three valid answers to this question.
      4. Create a normal student and enrol them in the parent course.
      5. Log in as this student and attempt the quiz.
      6. Answer the question, then allow the quiz timer to expire so that the quiz becomes overdue.
      7. Log in as an administrator and edit the quiz.
      8. Remove one of the question answers so that there are only two.
      9. Log in as the student and attempt to view the quiz (visit mod/quiz/view.php). This will result in a fatal error.
      10. Apply the patch.
      11. Refresh the quiz page.
      12. The page should now load without any errors.
      Show
      Create a new quiz with a time out of 10 seconds and a grace period of 1 day. Add one calculated multi choice question to the quiz. Add three valid answers to this question. Create a normal student and enrol them in the parent course. Log in as this student and attempt the quiz. Answer the question, then allow the quiz timer to expire so that the quiz becomes overdue. Log in as an administrator and edit the quiz. Remove one of the question answers so that there are only two. Log in as the student and attempt to view the quiz (visit mod/quiz/view.php). This will result in a fatal error. Apply the patch. Refresh the quiz page. The page should now load without any errors.
    • Affected Branches:
      MOODLE_28_STABLE, MOODLE_29_STABLE
    • Fixed Branches:
      MOODLE_28_STABLE, MOODLE_29_STABLE
    • Pull from Repository:
    • Pull Master Branch:
      MDL-50800-master

      Description

      There appears to be a bug in the calculated multiple choice question type which can cause fatal PHP errors under some (relatively uncommon) conditions. On the site where I encountered the problem, this fatal error was causing cron to fail.

      In the qtype_multichoice_base class there is an apply_attempt_state class which performs a check for missing quiz question answers.

      When this code gets executed, it makes a call to the "make_answer" method on the question type in use. In the base multi choice question class, this function is protected, so most of the multi choice question types which extend this class also override it with a public version of make_answer which can be called from apply_attempt_state.

      The qtype_calculatedmulti question class defined in question/type/calculatedmulti/questiontype.php appears to be missing this override method, which causes a fatal error when make_answer is called on a calculated multi choice question.

      I've included a patch which adds the public make_answer method exactly as it's been included for other multi choice question types (e.g. in question/type/multichoice/questiontype.php).

        Attachments

          Activity

            People

            Assignee:
            adamr Adam Riddell
            Reporter:
            adamr Adam Riddell
            Peer reviewer:
            Tim Hunt Tim Hunt
            Integrator:
            Dan Poltawski Dan Poltawski
            Tester:
            Frédéric Massart Frédéric Massart
            Participants:
            Component watchers:
            Tim Hunt, Andrew Lyons, Dongsheng Cai, Huong Nguyen, Jun Pataleta, Michael Hawkins, Shamim Rezaie, Simey Lameze
            Votes:
            1 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:
              Fix Release Date:
              14/Sep/15