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

Coding error when Feedback activity is in Recent Activity - User id is required when printing user avatar image.

    Details

    • Testing Instructions:
      Hide
      1. Activate feedback module at the admin settings
      2. Add a feedback instance to a course.
      3. Make sure the course has the Recent Activity block.
      4. Complete the feedback activity. It isn't important what user you use.
      5. In the recent activity block, click "Full report of recent activity."
      6. No error raises
      Show
      Activate feedback module at the admin settings Add a feedback instance to a course. Make sure the course has the Recent Activity block. Complete the feedback activity. It isn't important what user you use. In the recent activity block, click "Full report of recent activity." No error raises
    • Affected Branches:
      MOODLE_23_STABLE
    • Fixed Branches:
      MOODLE_23_STABLE, MOODLE_24_STABLE
    • Pull from Repository:
    • Pull Master Branch:
      MDL-37628-master

      Description

      After a student submits a Feedback activity, it causes a coding error in the Recent Activity block.

      Coding error detected, it must be fixed by a programmer: User id is required when printing user avatar image.

      More information about this error

      Debug info:
      Error code: codingerror
      Stack trace:
      line 186 of /lib/outputcomponents.php: coding_exception thrown
      line 1897 of /lib/outputrenderers.php: call to user_picture->__construct()
      line 487 of /mod/feedback/lib.php: call to core_renderer->user_picture()
      line 263 of /course/recent.php: call to feedback_print_recent_mod_activity()

      Steps to reproduce:
      1. Add a feedback activity to a course.
      2. Make sure the course has the Recent Activity block.
      3. Complete the feedback activity. (Normally a student does this, but it breaks as admin too)
      4. In the recent activity block, click "Full report of recent activity."
      5. Receive error.

      We have used these steps to reproduce this on a pure Moodle 2.3.3 site with no non-standard plugins, themes, or customizations.

      feedback_print_recent_mod_activity() calls user_picture() to display the user's avatar. user_picture() expects the user object to have an "id" field but its id field is called "userid" instead.

      Because this is causing a critical problem with a plugin for many of our clients, we are implementing a quick fix at the top of feedback_print_recent_mod_activity():

          if (is_object($activity->user)) {
              //Simple fix: user_picture expects user->id.
              $activity->user->id = $activity->user->userid;
          }
      

      Anyone who needs a quick fix may feel free to use this but I'm not sure if this is the best way to fix it permanently.

        Gliffy Diagrams

          Attachments

            Activity

              People

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

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Fix Release Date:
                  11/Mar/13