gjbarnard / moodle-format_topcoll

Collapsed Topics course format for Moodle.
http://docs.moodle.org/en/Collapsed_Topics_course_format
GNU General Public License v3.0
35 stars 60 forks source link

Error Found more than one record in fetch() after grading assignment #144

Open thebenkahn opened 11 months ago

thebenkahn commented 11 months ago

Describe the bug After grading as assignment, students who have been graded get an error when viewing the course.

The error only presents for students who have been graded. Switching to another course format resolves the error.

The course only has 12 assignment grade items, and a course grade category, there are no other grade items or grade categories. I have checked for any duplicate items in the mdl_grade_items table and not found any - and can access the grade book normally, or access the course normally using weeks/topics formats so I don't think there are actually any duplicates.

Additionally, if I backup and restore the course to a new shell, I cannot reproduce the error.

I hate the open a bug with no clear replication steps but am at a loss and hoping you might be able to point out what the code is trying to do here if I'm missing something. It seems like it is just checking the course section for assignments and getting the grade info, but is there another table I should be looking in for duplicated records?

Debug info: Error code: morethanonerecordinfetch

Stack trace: line 163 of /lib/grade/grade_object.php: moodle_exception thrown line 367 of /lib/grade/grade_item.php: call to grade_object::fetch_helper() line 155 of /course/format/topcoll/classes/activity.php: call to grade_item::fetch() line 180 of /course/format/topcoll/classes/activity.php: call to format_topcoll\activity::std_meta() line ? of unknownfile: call to format_topcoll\activity::assign_meta() line 78 of /course/format/topcoll/classes/activity.php: call to call_user_func() line 87 of /course/format/topcoll/classes/output/courseformat/content/cm.php: call to format_topcoll\activity::module_meta() line 60 of /course/format/topcoll/classes/output/courseformat/content/cm.php: call to format_topcoll\output\courseformat\content\cm->course_section_cm_get_meta() line 107 of /course/format/classes/output/local/content/section/cmitem.php: call to format_topcoll\output\courseformat\content\cm->export_for_template() line 122 of /course/format/classes/output/local/content/section/cmlist.php: call to core_courseformat\output\local\content\section\cmitem->export_for_template() line 504 of /lib/outputrenderers.php: call to core_courseformat\output\local\content\section\cmlist->export_for_template() line 108 of /course/format/classes/output/section_renderer.php: call to plugin_renderer_base->render() line 98 of /course/format/topcoll/classes/output/format_renderer_migration_toolbox.php: call to core_courseformat\output\section_renderer->render() line 510 of /course/format/topcoll/classes/output/renderer.php: call to format_topcoll\output\renderer->course_section_cmlist() line 956 of /course/format/topcoll/classes/output/renderer.php: call to format_topcoll\output\renderer->topcoll_section() line 86 of /course/format/topcoll/format.php: call to format_topcoll\output\renderer->multiple_section_page() line 290 of /course/view.php: call to require()

Versions (please complete the following information):

Additional context Add any other context about the problem here.

gjb2048 commented 11 months ago

@thebenkahn I've seen this before with the Adaptable theme ages ago and also thought it had been fixed here - but then I can't remember the exact nature of what happened. Currently snowed under with things. Will look when I get a chance, but might be some time.

gjb2048 commented 11 months ago

@thebenkahn I think its an issue with your site as similar to https://moodle.org/mod/forum/discuss.php?d=440281.

thebenkahn commented 11 months ago

Hey Gareth

Thank you much for the response. I had already done a check for duplicate grade_items, assignments, course modules, completion criteria....running the query in that thread returns no results.

SELECT courseid, itemmodule, iteminstance, itemnumber, COUNT() FROM mdl_grade_items WHERE itemtype='mod' GROUP BY courseid,itemmodule,iteminstance,itemnumber HAVING COUNT() > 1;

I'll keep poking at it.

gjb2048 commented 10 months ago

@thebenkahn Any update to this please?

thebenkahn commented 10 months ago

@gjb2048 - sorry I had meant to come back and comment. It did turn out to be a duplicate grade item. It was tricky because the duplicates were not in the same course as is typically the case. Reviewing the code for grade_object::fetch_helper() we noticed the SQL it used did not filter to the course it is used in. The client had tried to import a course from a different LMS (who knows what process that entailed) and created a bunch of grade items with ID numbers that existed elsewhere on the site. Thank you again for looking in to it.

gjb2048 commented 10 months ago

Dear @thebenkahn,

Thank you for getting back to me. Please could you ask your client if they would compensate me for my time? As I don't mind looking at issues that could be problems with my code. However in this case they have clearly done something incompetently stupid that has caused me to go on a pointless wild goose chase. I'm self employed, so the time I've spent on this has cost me!

Gareth