Moodle

Course Module ID Incorrect on Advanced Search Activity Report

Details

  • Type: Bug Bug
  • Status: Open Open
  • Priority: Major Major
  • Resolution: Unresolved
  • Affects Version/s: 1.8.2
  • Fix Version/s: None
  • Component/s: Other
  • Labels:
    None
  • Environment:
    Linux
  • Database:
    MySQL
  • Affected Branches:
    MOODLE_18_STABLE

Description

Getting "Course Module ID was incorrect" error on an Advanced Search in recent activity report.

I am clicking on the Full Report of Recent Activity link in the Recent Activity block in any course. I then go to the Advanced Search link because I want to look at the details of what a particular participant has done. Even if I leave it at all participants, I get the error.
Settings are:
All Participants
All activities
Since All days
Sort by Date-most recent first

Then click the Show Recent Activity button.
I get a list of assignments, etc. If I click on an assignment to view more details about it, I get an error that "The Course Module ID was Incorrect". When I click the Continue button, I am brought back to my Moodle front page.
It appears that there have been other issues with this same error, but not this exact issue. I've attached screen shots of my Advanced Search criteria as well as the error message. This happens in every class that I try although it doesn't seem to happen if I click on a forum post, only an assignment link like the first one in the search criteria screen shot.

Issue Links

Activity

Hide
Caroline Moore added a comment -

I am confirming that this issue is present in 1.8.3 as well.

The problem is within certain activity modules' lib.php files, in the function [modulename]_get_recent_mod_activity.

For some activities, the link to the specific activity instance requires a different parameter than the links to the responses to that activity (e.g. quiz vs. quiz attempt, or assignment vs. submission).

We created a fix for this bug for the quiz module. When linking to a quiz instance, one must use the id field from the mdl_course_modules table, whereas when linking to a quiz attempt, one must use the instance field from the mdl_course_modules table.

When sorted, the link to the parent object uses the instance field instead of the id field. The solution is to add the course_module.id field to the SELECT statement in the query and add it as a separate member attribute to the activity object.

The link to the parent object must then be changed in the print_recent_mod_activity function (just below the abovementioned function) to use this new member attribute.

The reason the code works when results are not sorted is because the link to the parent object (e.g. quiz instance) comes from the original returned array. When results are sorted, the print function ignores these topic and parent object array elements.

Changes we made:

file: mod/quiz/lib.php
line 373 changed to: q.course, q.sumgrades as maxgrade, cm.instance, cm.section, cm.id as modid
line 407 added: $tmpactivity->content->modid = $quiz->modid;
(one linebreak added at line 408)
line 437 (formerly 436) change to: echo "<a href=\"$CFG->wwwroot/mod/quiz/view.php?id=" . $activity->content->modid . "\">"

Debugged and fix created at HackFest by Ben Willard and Caroline Moore

Show
Caroline Moore added a comment - I am confirming that this issue is present in 1.8.3 as well. The problem is within certain activity modules' lib.php files, in the function [modulename]_get_recent_mod_activity. For some activities, the link to the specific activity instance requires a different parameter than the links to the responses to that activity (e.g. quiz vs. quiz attempt, or assignment vs. submission). We created a fix for this bug for the quiz module. When linking to a quiz instance, one must use the id field from the mdl_course_modules table, whereas when linking to a quiz attempt, one must use the instance field from the mdl_course_modules table. When sorted, the link to the parent object uses the instance field instead of the id field. The solution is to add the course_module.id field to the SELECT statement in the query and add it as a separate member attribute to the activity object. The link to the parent object must then be changed in the print_recent_mod_activity function (just below the abovementioned function) to use this new member attribute. The reason the code works when results are not sorted is because the link to the parent object (e.g. quiz instance) comes from the original returned array. When results are sorted, the print function ignores these topic and parent object array elements. Changes we made: file: mod/quiz/lib.php line 373 changed to: q.course, q.sumgrades as maxgrade, cm.instance, cm.section, cm.id as modid line 407 added: $tmpactivity->content->modid = $quiz->modid; (one linebreak added at line 408) line 437 (formerly 436) change to: echo "<a href=\"$CFG->wwwroot/mod/quiz/view.php?id=" . $activity->content->modid . "\">" Debugged and fix created at HackFest by Ben Willard and Caroline Moore
Hide
Caroline Moore added a comment -

Modules that are NOT experiencing this problem:
Forum (no link to parent activity)
Assignment: Offline activity (no child responses)

Modules that ARE experiencing this problem:
Quiz
Workshop
Assignment: Upload a Single File
Assignment: Advanced Upload
Assignment: Online text

Show
Caroline Moore added a comment - Modules that are NOT experiencing this problem: Forum (no link to parent activity) Assignment: Offline activity (no child responses) Modules that ARE experiencing this problem: Quiz Workshop Assignment: Upload a Single File Assignment: Advanced Upload Assignment: Online text
Hide
Dan Poltawski added a comment -

The important part to reproduce this bug is to have activity and change to a date sorting

Show
Dan Poltawski added a comment - The important part to reproduce this bug is to have activity and change to a date sorting
Hide
Dan Poltawski added a comment -

In the case of quiz and workshop this appears to be a bug in mixup of what $activity->instance is (it is the id of the activity, rather than the cmid).

Patch for example:
diff -ruN /home/dan/moodle/moodle/mod/assignment/lib.php mod/assignment/lib.php
— /home/dan/moodle/moodle/mod/assignment/lib.php 2008-01-10 10:38:18.000000000 +0000
+++ mod/assignment/lib.php 2008-01-10 21:36:35.000000000 +0000
@@ -2475,7 +2475,7 @@
if ($detail) { echo "<img src=\"$CFG->modpixpath/$activity->type/icon.gif\" ". "class=\"icon\" alt=\"$activity->type\"> "; - echo "<a href=\"$CFG->wwwroot/mod/assignment/view.php?id=" . $activity->instance . "\">" + echo "<a href=\"$CFG->wwwroot/mod/assignment/view.php?a=" . $activity->instance . "\">" . format_string($activity->name,true) . "</a> - "; }
diff -ruN /home/dan/moodle/moodle/mod/quiz/lib.php mod/quiz/lib.php
— /home/dan/moodle/moodle/mod/quiz/lib.php 2008-01-08 15:25:20.000000000 +0000
+++ mod/quiz/lib.php 2008-01-10 21:35:01.000000000 +0000
@@ -588,7 +588,7 @@
if ($detail) { echo "<img src=\"$CFG->modpixpath/$activity->type/icon.gif\" ". "class=\"icon\" alt=\"$activity->type\" /> "; - echo "<a href=\"$CFG->wwwroot/mod/quiz/view.php?id=" . $activity->instance . "\">" + echo "<a href=\"$CFG->wwwroot/mod/quiz/view.php?q=" . $activity->instance . "\">" . format_string($activity->name,true) . "</a> - "; }

Show
Dan Poltawski added a comment - In the case of quiz and workshop this appears to be a bug in mixup of what $activity->instance is (it is the id of the activity, rather than the cmid). Patch for example: diff -ruN /home/dan/moodle/moodle/mod/assignment/lib.php mod/assignment/lib.php — /home/dan/moodle/moodle/mod/assignment/lib.php 2008-01-10 10:38:18.000000000 +0000 +++ mod/assignment/lib.php 2008-01-10 21:36:35.000000000 +0000 @@ -2475,7 +2475,7 @@ if ($detail) { echo "<img src=\"$CFG->modpixpath/$activity->type/icon.gif\" ". "class=\"icon\" alt=\"$activity->type\"> "; - echo "<a href=\"$CFG->wwwroot/mod/assignment/view.php?id=" . $activity->instance . "\">" + echo "<a href=\"$CFG->wwwroot/mod/assignment/view.php?a=" . $activity->instance . "\">" . format_string($activity->name,true) . "</a> - "; } diff -ruN /home/dan/moodle/moodle/mod/quiz/lib.php mod/quiz/lib.php — /home/dan/moodle/moodle/mod/quiz/lib.php 2008-01-08 15:25:20.000000000 +0000 +++ mod/quiz/lib.php 2008-01-10 21:35:01.000000000 +0000 @@ -588,7 +588,7 @@ if ($detail) { echo "<img src=\"$CFG->modpixpath/$activity->type/icon.gif\" ". "class=\"icon\" alt=\"$activity->type\" /> "; - echo "<a href=\"$CFG->wwwroot/mod/quiz/view.php?id=" . $activity->instance . "\">" + echo "<a href=\"$CFG->wwwroot/mod/quiz/view.php?q=" . $activity->instance . "\">" . format_string($activity->name,true) . "</a> - "; }

People

Vote (5)
Watch (5)

Dates

  • Created:
    Updated: