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

Error viewing a social format course due to logging expectation.

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Critical Critical
    • 2.7
    • 2.7
    • Course
    • MOODLE_27_STABLE
    • MOODLE_27_STABLE
    • 45248-27
    • Hide

      1. Run behat with:

      --name "Restore a backup into a new course changing the course format afterwards"
      

      2. Manually test a social format is accessible.

      • Log in as admin.
      • Create a social course.
      • View the course.
      Show
      1. Run behat with: --name "Restore a backup into a new course changing the course format afterwards" 2. Manually test a social format is accessible. Log in as admin. Create a social course. View the course.

      Coding error detected, it must be fixed by a programmer: Context passed must be course context.

      More information about this error

      Debug info:
      Error code: codingerror
      Stack trace:
      line 115 of /lib/classes/event/course_viewed.php: coding_exception thrown
      line 252 of /lib/classes/event/base.php: call to core\event\course_viewed->validate_data()
      line 308 of /course/view.php: call to core\event\base::create()

      This first came to light by behat tests as illustrated by the following fail:

      (::) failed steps (::)
       
      01. Moodle exception: Coding error detected, it must be fixed by a programmer: Context passed must be course context. More information about this error
          
          Debug info:
           
          Error code: codingerror
          
          Stack trace:
           
          line 115 of /lib/classes/event/course_viewed.php: coding_exception thrown
          line 252 of /lib/classes/event/base.php: call to core\event\course_viewed->validate_data()
          line 289 of /course/view.php: call to core\event\base::create()
          In step `And I press "Save changes"'.                                                     # behat_forms::press_button()
          From scenario `Restore a backup into a new course changing the course format afterwards'. # /var/www/integration/backup/util/ui/tests/behat/restore_moodle2_courses.feature:82
          Of feature `Restore Moodle 2 course backups'.
      

      After a bit of research I find that it is in fact because of the social course format, looking at https://github.com/samhemelryk/moodle/blob/master/course/view.php#L286 before this line $context is instance of context_course.
      After this line $context is instance of context_module.

      Now it appears to me that the course format should not change $context (a downside to executing format code in the global scope).
      However I wonder if it is also a flaw of the logging code. I would bet that social isn't the only format that does this nasty. Perhaps we need to double check the context before instantiating the event data.

            samhemelryk Sam Hemelryk
            samhemelryk Sam Hemelryk
            Ankit Agarwal Ankit Agarwal
            Dan Poltawski Dan Poltawski
            Adrian Greeve Adrian Greeve
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved:

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