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

Saving lesson cluster page after editing tries to save non-existing answers

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 2.2.2, 2.8.1
    • Fix Version/s: 2.9
    • Component/s: Lesson
    • Labels:
    • Affected Branches:
      MOODLE_22_STABLE, MOODLE_28_STABLE
    • Fixed Branches:
      MOODLE_29_STABLE

      Description

      When editing an existing cluster page in mod/lesson, the following error appears:
      Notice: Undefined property: stdClass::$answer in /var/www/moodle2-dev/mod/lesson/locallib.php on line 2153
      This blocks the workflow, but only if debuglevel is high enough and if errors are displayed within the HTML.

      It appears the save script doesn't check for the presence of answers and just assumes there are some. The comment on this same file on the previous line (2152) assumes code doesn't need to make an isset() check because of the magic __isset() method used by the get_answers() getter. However, the getter is not used in this case.

      I propose to simply add an isset() check in line 2153, replacing it like this:

      if (isset($this->answers[$i]->answer) && $this->answers[$i]->answer != '') {
      

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              jmvedrine Jean-Michel Vedrine
              Reporter:
              monidu Nicolas Dunand
              Participants:
              Component watchers:
              Adrian Greeve, Jake Dallimore, Mathew May, Mihail Geshoski, Peter Dias, Sujith Haridasan
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Fix Release Date:
                11/May/15