Best practice forum (Archived)

Error when grading quiz in course with Course Set Completion Message - 2.5.7

 
Jeff King
Error when grading quiz in course with Course Set Completion Message - 2.5.7
by Jeff King - Tuesday, 11 February 2014, 1:51 PM
 

Hi,
I believe I have found a bug with Totara relating to marking + course set completion + messaging.

When marking a quiz that would result in a person completing a course set, a database error is thrown if you happen to have a “Course Set Completed” message setup for the Program.
This is with Totara 2.5.7.

Steps to reproduce:
1) Create 2 courses X and Y
2) Now add a quiz to course X with 1 essay question in it worth 10 points
3) Create a Program A, and add X as a course set. Now add Y as a second course set, so that X needs to be completed so that Y will be available.
4) Now while still editing the Program go to the Messages tab and add a “Course Set Completed” message.
5) Assign user “Bob” to the Program as an individual.
6) Now log in as Bob, and take the quiz
7) Now log back in as an admin, and navigate to the quiz
8) Click Results -> Manual Grading, and click “grade” in the “To Grade” column
9) Attempt to give the question 10 points, and click “Save”
10) A “Database Transaction Error” is displayed.

With development debugging turned on, the stack trace is:

Debug info: This code can not be excecuted in transaction
Error code: dmltransactionexception
Stack trace:
line 2309 of /lib/dml/moodle_database.php: dml_transaction_exception thrown
line 61 of /lib/messagelib.php: call to moodle_database->transactions_forbidden()
line 209 of /totara/message/messagelib.php: call to message_send()
line 317 of /totara/message/messagelib.php: call to tm_message_send()
line 542 of /totara/program/program_message.class.php: call to tm_alert_send()
line 1158 of /totara/program/lib.php: call to prog_noneventbased_message->send_message()
line ? of unknownfile: call to prog_eventhandler_courseset_completed()
line 299 of /lib/eventslib.php: call to call_user_func()
line 521 of /lib/eventslib.php: call to events_dispatch()
line 233 of /totara/program/program_courseset.class.php: call to events_trigger()
line 760 of /totara/program/program_courseset.class.php: call to course_set->update_courseset_complete()
line 1514 of /totara/program/lib.php: call to multi_course_set->check_courseset_complete()
line 322 of /completion/completion_completion.php: call to prog_update_completion()
line 531 of /completion/completion_completion.php: call to completion_completion->mark_complete()
line 244 of /completion/completion_completion.php: call to completion_completion->aggregate()
line 129 of /completion/completion_criteria_completion.php: call to completion_completion->mark_inprogress()
line 121 of /completion/criteria/completion_criteria_grade.php: call to completion_criteria_completion->mark_complete()
line 264 of /completion/completion_criteria_completion.php: call to completion_criteria_grade->review()
line ? of unknownfile: call to completion_handle_criteria_course_calc()
line 299 of /lib/eventslib.php: call to call_user_func()
line 521 of /lib/eventslib.php: call to events_dispatch()
line 814 of /lib/grade/grade_grade.php: call to events_trigger()
line 263 of /lib/grade/grade_object.php: call to grade_grade->notify_changed()
line 771 of /lib/grade/grade_grade.php: call to grade_object->update()
line 624 of /lib/grade/grade_category.php: call to grade_grade->update()
line 511 of /lib/grade/grade_category.php: call to grade_category->aggregate_grades()
line 678 of /lib/grade/grade_item.php: call to grade_category->generate_grades()
line 1073 of /lib/gradelib.php: call to grade_item->regrade_final_grades()
line 1722 of /lib/grade/grade_item.php: call to grade_regrade_final_grades()
line 284 of /lib/gradelib.php: call to grade_item->update_raw_grade()
line 764 of /mod/quiz/lib.php: call to grade_update()
line 622 of /mod/quiz/lib.php: call to quiz_grade_item_update()
line 569 of /mod/quiz/locallib.php: call to quiz_update_grades()
line 1355 of /mod/quiz/attemptlib.php: call to quiz_save_best_grade()
line 488 of /mod/quiz/report/grading/report.php: call to quiz_attempt->process_submitted_actions()
line 111 of /mod/quiz/report/grading/report.php: call to quiz_grading_report->process_submitted_data()
line 100 of /mod/quiz/report.php: call to quiz_grading_report->display()

Note that if I then remove the Course Set Complete message, I am able to mark the quiz.

Let me know if you can take a look at this and if you can successfully reproduce the problem.

Jeff King
Re: Error when grading quiz in course with Course Set Completion Message - 2.5.7
by Jeff King - Tuesday, 11 February 2014, 4:01 PM
 

Hello Again,
I have been experiencing another issue related to completion with a couple of our customers sites. Completion status is sometimes inconsistent. One example is that the criteria for a course will show as a complete, and the course itself shows as complete. However, if there is a second course that has the first course as a criteria, it doesn’t show as complete there.

For example, go to a course and then navigate to Reports->Course Completion, then click on a persons name to see the completion details for that user. That’s what I am using as an example below.

Example:

Course A has 4 criteria:
1) View Book X
2) View and achieve grade in Quiz Y
3) View and achieve grade in Quiz X
4) Course grade of at least 70%

Course B has 4 criteria:
1) View Book 1
2) View and achieve grade in Quiz 2
3) Course grade of at least 70%
4) Completion of Other courses: Course A

In many cases we are seeing all of Course A’s criteria set as “Yes” in the Complete column, but Course B has the “Completion of Other courses: Course A” showing as “No” in the Complete column.

I have had some trouble reproducing this on a clean site, but we have a few customers experiencing this problem.

There have also been cases where the Status is “Completed” but the Complete column is “No”, which doesn’t make much sense. So it seems like completion isn’t getting totally processed.

Have you seen cases like this before? Is there other information we could provide to help diagnose this issue?

Thanks,

Jeff 

? ?
Re: Error when grading quiz in course with Course Set Completion Message - 2.5.7
by ? ? - Thursday, 13 February 2014, 4:47 PM
 

Hi Jeff,

Yes there was a bug uncovered recently where completion conditions involving completion of dependent courses did not work in all circumstances. It was fixed as part of 2.5.7 - are you on that version? An upgrade will hopefully fix this.

Let me know if you are on 2.5.7 and still having problems though.

Matthew Lee
Re: Error when grading quiz in course with Course Set Completion Message - 2.5.7
by Matthew Lee - Thursday, 13 February 2014, 7:36 PM
 

Hi Ciarin

 

Jeff is on vacation for the next week so I can answer this. Yes, we are on Version 2.5.7 (Build: 20140204.00) and still seeing it.

 

Matt

? ?
Re: Error when grading quiz in course with Course Set Completion Message - 2.5.7
by ? ? - Tuesday, 11 February 2014, 6:34 PM
 

Hi Jeff,

Yeah messages cannot be sent within a database transaction, that's a known Moodle bug. https://tracker.moodle.org/browse/MDL-30029

In your case grading the quiz triggers course completion, and when the course is completed the courseset is complete, so then it tries to send a message...but the original quiz grader report had started a transaction so the system halts.

Unfortunately the only way around this is to remove the transaction call. In mod/quiz/report/grading/report.php, around line 473 there is function process_submitted_data(). Delete the following lines within this function

$transaction = $DB->start_delegated_transaction();

and a little further down

$transaction->allow_commit();

We'll get a patch in for the next 2.5 release but this should allow you to continue using this course and program in the meantime.

? ?
Re: Error when grading quiz in course with Course Set Completion Message - 2.5.7
by ? ? - Tuesday, 11 February 2014, 7:25 PM
 

There are also two identical transaction calls in mod/quiz/attemptlib.php, process_submitted_actions, around line 1336, that should be commented out or removed.

Jeff King
Re: Error when grading quiz in course with Course Set Completion Message - 2.5.7
by Jeff King - Tuesday, 11 February 2014, 10:21 PM
 

Thanks, I will give that a try.

? ?
Re: Error when grading quiz in course with Course Set Completion Message - 2.5.7
by ? ? - Monday, 17 February 2014, 8:23 PM
 

A fix for the multiple dependent courses completion issue was included in today's (18th Feb 2014) release of Totara 2.5.8