Error in cron for LTI grade sync

Error in cron for LTI grade sync

by Ryan Nutt -
Number of replies: 7

I'm embedding Moodle quizzes into Canvas and having issues with grades getting sent back to Canvas. (I find that the quiz and question bank system in Moodle is way better than Canvas, which is why I'm doing it this way.)

But grades aren't syncing, which seems to be a somewhat common issue. I noticed that the fail delay gradually creeps up on the scheduled task until it's @ 24 hours.

Found that I'm getting the following message when the task tries to run.

Execute scheduled task: Publish as LTI tool grade sync (enrol_lti\task\sync_grades)
... started 09:11:18. Current memory use 5.7MB.
Starting - Grade sync for shared tool '2' for the course '2'.
Skipping - Empty sourceid for the user '6' in the tool '2' for the course '2'.
Skipping - Empty sourceid for the user '3' in the tool '2' for the course '2'.
... used 4 dbqueries
... used 0.017449855804443 seconds
Scheduled task failed: Publish as LTI tool grade sync (enrol_lti\task\sync_grades),Can not find data record in database table context.
Cron script completed correctly
Cron completed at 09:11:18. Memory used 7MB.
Execution took 0.044808 seconds
I assume that's the reason that grades aren't syncing, but I'm not sure where to look to track down what's not happening. My Moodle is self hosted, so I have full access to CLI, database, and can upgrade if I need to. 

This was all working flawlessly last year, once I remembered to turn on the cron job, so I'm a little perplexed why it's stopped. 

Any thoughts or suggestions would be greatly appreciated. 

Average of ratings: Useful (1)
In reply to Ryan Nutt

Re: Error in cron for LTI grade sync

by Ryan Nutt -
Going to self reply a fix on this one.

I was too focused on the can not find data record part of the message and missed the empty sourceid part. The resource ID #2 was an old quiz that I had done to test and that had been deleted. When I disabled that one under LTI providers it worked like a champ.
Average of ratings: Useful (2)
In reply to Ryan Nutt

Re: Error in cron for LTI grade sync

by Veronica Volz -
A similar thing happened to me last week with CRON. I ended up having to remove all of the users’ LTI links... I am concerned that this is a bug, since a few people have reported it happening lately. How did you locate your resource To remove it? I had the error on Resource ID 548 but didn’t know where to find it to remove it.
Thanks!
In reply to Veronica Volz

Re: Error in cron for LTI grade sync

by Ryan Nutt -
I went through my list of activities that were published as LTI tools and found #2. Fortunately, it was an early one and was just one I had used for testing. Plus, there were only about 20 on the server because it's just me using it. Clicked the eye next to that tool to disable and ran cron again and everything worked.

Funny side note, when it started working it sent back grades on a quiz that we took the previous week. All those grades got flagged as late in Canvas. My kids freaked out.
Average of ratings: Useful (2)
In reply to Ryan Nutt

Re: Error in cron for LTI grade sync

by Veronica Volz -

Ah, ok, I see, thank you. Yes, the same also happened with my student grades, it took about 4 hours after it started working but they all magically appeared in Canvas. 

I bet you and your students were relieved when they showed up!

smile

In reply to Ryan Nutt

Re: Error in cron for LTI grade sync

by Arnaud Trouvé -
Picture of Core developers Picture of Plugin developers Picture of Plugins guardians

Thanks for sharing the solution !
FYI I have reported this behaviour in the tracker https://tracker.moodle.org/browse/MDL-66671

In reply to Arnaud Trouvé

Re: Error in cron for LTI grade sync

by Veronica Volz -

Thank you Arnaud! 

Could you tell us what to do (or not do) in order not to receive this error in the future? 

Will this be fixed soon? This is quite important as my site uses thousands of LTI links exclusively.

In reply to Veronica Volz

Re: Error in cron for LTI grade sync

by Veronica Volz -
This is happening again, is there anyway of fixing it manually? Without removing resources?
Can anyone help please?