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

Error in complete report for Workshop activity

XMLWordPrintable

    • MOODLE_26_STABLE, MOODLE_27_STABLE
    • MOODLE_26_STABLE, MOODLE_27_STABLE
    • MDL-44536-master-workshop-complete-report
    • Hide
      1. Create a workshop instance in a course
      2. Have some students enrolled in the course
      3. Pick a random enrolled student, open his profile page and follow the side block Administration > Profile settings for ... > Activity reports > Complete report
      4. TEST: Make sure the reported coding error is not reported
      Show
      Create a workshop instance in a course Have some students enrolled in the course Pick a random enrolled student, open his profile page and follow the side block Administration > Profile settings for ... > Activity reports > Complete report TEST: Make sure the reported coding error is not reported

      If I have a Workshop module in a course and then go to view a "complete report", I get the following error:

      Coding error detected, it must be fixed by a programmer: PHP catchable fatal error

      More information about this error

      Debug info: Argument 2 passed to workshop::__construct() must be an instance of stdClass, instance of cm_info given, called in [dirroot]/mod/workshop/lib.php on line 305 and defined
      Error code: codingerror
      Stack trace:
      line 393 of /lib/setuplib.php: coding_exception thrown
      line 190 of /mod/workshop/locallib.php: call to default_error_handler()
      line 305 of /mod/workshop/lib.php: call to workshop->__construct()
      line 131 of /report/outline/user.php: call to workshop_user_complete()

      The complete report is the one found here:

      https://MOODLE_URL/report/outline/user.php?id=USERID&course=COURSEID&mode=complete

      The error is happening with this line of code in report/outline/user.php:

      $user_complete($course, $user, $mod, $instance);
      

      Which points to:

      function workshop_user_complete($course, $user, $mod, $workshop) {
          global $CFG, $DB, $OUTPUT;
          require_once(dirname(__FILE__).'/locallib.php');
          require_once($CFG->libdir.'/gradelib.php');
       
          $workshop   = new workshop($workshop, $mod, $course);
          $grades     = grade_get_grades($course->id, 'mod', 'workshop', $workshop->id, $user->id);
      

      The new workshop line is passing in $mod which is of class cm_info but the constructor function is expecting a stdClass object.

      public function __construct(stdclass $dbrecord, stdclass $cm, stdclass $course, stdclass $context=null)
      

      I can workaround this for now by using the following band-aid:

      $cm = get_coursemodule_from_id('workshop', $mod->id);
      $workshop   = new workshop($workshop, $cm, $course);
      $grades     = grade_get_grades($course->id, 'mod', 'workshop', $workshop->id, $user->id);
      

      It appears to work, but I have no idea what bizarre and unpredictable effects it might have, so I am hoping someone with a greater understanding than myself could weigh in.

            mudrd8mz David Mudrák (@mudrd8mz)
            hernan43 Ray Hernandez
            Dan Poltawski Dan Poltawski
            Sam Hemelryk Sam Hemelryk
            Adrian Greeve Adrian Greeve
            Votes:
            4 Vote for this issue
            Watchers:
            9 Start watching this issue

              Created:
              Updated:
              Resolved:

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