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

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

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Minor Minor
    • 2.9
    • 2.2.2, 2.8.1
    • Lesson
    • MOODLE_22_STABLE, MOODLE_28_STABLE
    • MOODLE_29_STABLE

      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 != '') {
      

            jmvedrine Jean-Michel Vedrine
            monidu Nicolas Dunand
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved:

                Error rendering 'clockify-timesheets-time-tracking-reports:timer-sidebar'. Please contact your Jira administrators.