Multiple Grade Items Break Course Renderer

Issue #932 resolved
Tristan daCosta created an issue

If assignment activity is using a Grade and an Outcome, two grade items exist (in grade_items table) for that iteminstance.

For roles which cannot grade (student) the activity summary looks for a single grade item. If more than one are found, course content won't load.

Student who have been graded using Outcome & Grade cannot view content region. Only the content region is not rendered. Blocks/header/footer all render correctly.

Confirmed by removing second iteminstance directly from DB (only way to remove outcome if a grade has already been saved) OR removing the grade from grade_grades table

You get different results depending on which format you use. Below is the output (including debugging) when using Topics format.

Found more than one record in fetch() !

More information about this error

Debug info: 
Error code: morethanonerecordinfetch
Stack trace:
line 482 of /lib/setuplib.php: moodle_exception thrown
line 163 of /lib/grade/grade_object.php: call to print_error()
line 354 of /lib/grade/grade_item.php: call to grade_object::fetch_helper()
line 176 of /theme/adaptable/classes/activity.php: call to grade_item::fetch()
line 239 of /theme/adaptable/classes/activity.php: call to theme_adaptable\activity::std_meta()
line ? of unknownfile: call to theme_adaptable\activity::assign_meta()
line 43 of /theme/adaptable/classes/activity.php: call to call_user_func()
line 743 of /theme/adaptable/classes/output/core/course_renderer.php: call to theme_adaptable\activity::module_meta()
line 703 of /theme/adaptable/classes/output/core/course_renderer.php: call to theme_adaptable\output\core\course_renderer->course_section_cm_get_meta()
line 846 of /course/renderer.php: call to theme_adaptable\output\core\course_renderer->course_section_cm()
line 1039 of /course/renderer.php: call to core_course_renderer->course_section_cm_list_item()
line 888 of /course/format/renderer.php: call to core_course_renderer->course_section_cm_list()
line 57 of /course/format/topics/format.php: call to format_section_renderer_base->print_multiple_section_page()
line 280 of /course/view.php: call to require()

To reproduce:

  1. Add an outcome to the course (using the Outcomes link in Admin block)
  2. Create or edit existing assignment
  3. Ensure both Grade and Outcome have been selected in the assignment settings
  4. Ensure there is at least 1 separate account with a student role
  5. Grade student assignment and save (no submission needs to be made by student)
  6. "Login As" the enrolled student

You could open a second browser and be logged in as the student in order to test the course page at each step.

Comments (16)

  1. Tristan daCosta reporter

    Even if you select "None" for grading, a grade entry is made (NULL). So adding an outcome regardless if you have a grading method set will produce error as 2 gradeitems now exist for that assignment.

  2. Tristan daCosta reporter

    Sorry, I should have said that I've tested with Clean & Boost themes and courses render as expected with no errors. There is no assignment summary which is the difference.

    Am I correct in thinking that the summary/status under assignment is an Adaptable feature? Like in the screenshot below? (submitted, graded status) I can't find any settings to enable this on other themes.

    Screen Shot 2018-09-14 at 7.12.13 pm.png

  3. Manoj Solanki

    Error has been reproduced. There is also an issue when viewing as teacher or admin (roles that allow editing of course etc) as per screenshot.

    outcomeissueadaptable.PNG

  4. Manoj Solanki

    Hi Tristan,

    I've done a fix for this. I still want to do some more testing on this. If you have a test system, are you able to update to the latest version of Adaptable from here in Bitbucket? It would be great if you could see if it resolves your case and any further testing to ensure display of the assignment submission (summary) all looks ok.

    Thanks,

    M

    P.S. Yes the assignment summary under the assignment title is an Adaptable feature that is not in Clean and Boost (at the time of writing) :)

  5. Tristan daCosta reporter

    Hi Manoj. Thanks for taking the time to look into this.

    I've applied your last 2 commits as a patch onto a test moodle running the latest official release (2018073000). Is this OK or will i be missing any other commits in relation to activity summary?

    I think we may be replicating slightly differently as I've noticed the error you attached in the screenshot above is not the error I'm referring to. I do still get that same debugging error (as a student or a teacher), but there is an additional error that the student sees that is actually rendered on the page and prevents the course content from rendering. Are you able to reproduce this other error?

    Student View Screen Shot 2018-09-18 at 1.16.23 pm.png

    Teacher View Screen Shot 2018-09-18 at 1.20.00 pm.png

  6. Manoj Solanki

    Hi,

    Are you testing on a fresh course and going through the same process noted earlier to produce the error? I've tried this on a couple of courses and not able to get any errors. Both with outcomes attached to assignment. One of them I did grading and added an outcome. I've tested on 3.4 and 3.5 (20180907). If possible, could you do a video capture of creating the activity, adding the outcomes to the activity, grading it and finally viewing as a student if that's ok?

    Thanks,

    M

    P.S. Just rereading your comment, I believe you meant using the latest official release of Adaptable (I assumed Moodle). It looks like the error messages may point to line numbers from the old code. So maybe just update the test system with latest Adaptable code by just grabbing latest version from here in Bitbucket (e.g. doing "git pull" if possible). Just to be sure.

  7. Tristan daCosta reporter

    Thanks Manoj.

    Apologies, it is indeed working correctly now! Must have been my mistake while patching.

    Thanks again for your prompt response to this!

  8. Log in to comment