Details
-
Type:
Bug
-
Status:
Open
-
Priority:
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.
Attachments
Issue Links
| This issue has been marked as being related by: | ||||
| MDL-12923 | Wrong context check in advanced recent activity |
|
|
|
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