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

Error in complete report for Workshop activity

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Blocker
    • Resolution: Fixed
    • Affects Version/s: 2.6.1, 2.7.1
    • Fix Version/s: 2.6.6, 2.7.3
    • Component/s: Reports, Workshop
    • Labels:
    • Testing Instructions:
      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
    • Affected Branches:
      MOODLE_26_STABLE, MOODLE_27_STABLE
    • Fixed Branches:
      MOODLE_26_STABLE, MOODLE_27_STABLE
    • Pull from Repository:
    • Pull Master Branch:
      MDL-44536-master-workshop-complete-report

      Description

      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.

        Gliffy Diagrams

          Attachments

            Issue Links

              Activity

                People

                • Votes:
                  4 Vote for this issue
                  Watchers:
                  9 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved:
                    Fix Release Date:
                    10/Nov/14