Grades not transferring for most students

Grades not transferring for most students

by N W -
Number of replies: 12

Hello,

I'm using the LTI tool on Moodle 3.11. The remote site is also using 3.11.

I think everything is set up correctly as the quiz grades for 1 or 2 students are being transferred automatically to the remote site. However, it is not transferring grades for the majority of the attempts.

I'm awarding badges based on the grades and consequently these are not being attributed either.

What could be the cause of this error?

Thank you in advance.

Average of ratings: -
In reply to N W

Re: Grades not transferring for most students

by Jake Dallimore -
Picture of Core developers Picture of Moodle HQ Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers Picture of Testers
That's a little hard to say, without knowing the full story. Some things to check though:
  • Can you see enrolments for all the students in question in the provider/tool site? An enrolment is an indicator that the student has in fact launched into the quiz from the consumer/platform site.
  • Grade sync will only sync changes in grades, so be mindful of that.
  • Verify that "Require course or activity completion prior to grade synchronisation" isn't checked in the tool/provider. This impacts grade sync.
  • Run the task via "Run now" in the site admin scheduled tasks list on the tool/provider site. Alternatively, you can run the job directly, via the command line with:

    php admin/cli/scheduled_task.php --execute="\enrol_lti\task\sync_grades"


    You should be able to then see the output of the job and see what the tool is attempting to sync. That may give you some more information which helps.
Cheers,
Jake


In reply to Jake Dallimore

Re: Grades not transferring for most students

by N W -
Hello Jake,
Thanks for the speedy reply.
I checked the settings and it is all as you suggest. The enrolments are "no roles". I'm changing them manually to "student" role.
Also,  the maximum grades are different in the consumer site (/100) and the provider site (/30) - could this be causing a conflict?
Running the sync_grades task shows some invalid grade and invalid contextid messages and a large number of Fail Delay (see screenshot)

Skipping - Invalid grade for the user '966' in the tool '40' for the course '258'.
Skipping - Invalid grade for the user '972' in the tool '40' for the course '258'.
Completed - Synced grades for tool '40' in the course '258'. Processed 29 users; sent 0 grades.

Starting - Grade sync for shared tool '41' for the course '258'.
Failed - Invalid contextid '5089' for the tool '41'.
Completed - Synced grades for tool '41' in the course '258'. Processed 1 users; sent 0 grades.
How do I rectify these errors?
Thanks
Attachment 2022-10-05_13-19-12.png
Attachment 2022-10-05_13-49-56.png
In reply to N W

Re: Grades not transferring for most students

by Jake Dallimore -
Picture of Core developers Picture of Moodle HQ Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers Picture of Testers
Thanks for the info. The first thing to note is that you don't need to assign the student role. In fact, doing so may grant access to the student to other activities in the course - activities you didn't intend to grant access to. I wouldn't recommend doing this. The student role is applied at the context level with an LTI launch (at activity level), so to see it, you need to inspect the role assignments there. None of that will affect grade sync, though - just thought I'd clarify.

All those settings in the screenshots look fine to me too. The maximum grade can differ between the two, that's fine. It'll send a fraction over. E.g. 0.3 or whatever, and the recipient system will resolve that to the correct numerical grade.

I can see two things from those task logs:
  1. Some users have invalid grades - and this just means that the grade probably hasn't been awarded yet - that's fine if that is indeed the case. The task just reports it so we know the user was looked at really.
  2. Some tools are published but are no longer linked to valid (existing) activities or courses.  This is what the "Invalid context xxx" trace means. You'll need to edit the published tool (in the tool site) and assign an activity or course. This happens when you delete an activity usually, and the tool is left behind in a stale state. I've recently patched this in MDL-68843.
You mentioned "a large number of Fail Delay" but I'm not seeing that above, and I'm not quite sure what you mean there - could you clarify on that (or post a section of the task log)?

One more thing I'd like to know is how you're setting up the tool instance in the consumer site. Are you using the Launch URL and secret (LTI 1.1) or the Registration URL (LTI 2.0) to do this?

Thanks again for the info.

Jake

In reply to Jake Dallimore

Re: Grades not transferring for most students

by N W -
Hello Jake,
I'll look at reassigning the tool to its activity.
Here's the screenshot for the Fail Delay in Scheduled Tasks (I cleared it yesterday)!
I'm using the Cartridge URL in both Secure Tool URL and Tool URL fields (not the Launch URL) and secret to set up the tool. Maybe this is the problem?

Thanks

Attachment 2022-10-06_06-50-26.png
Attachment cartridge.png
In reply to N W

Re: Grades not transferring for most students

by Jake Dallimore -
Picture of Core developers Picture of Moodle HQ Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers Picture of Testers
That's actually the tool URL, not the cartridge URL (cartridge URLs end with .xml), and that seems to be configured just fine. If you're worried, just launch into the tool; if it's not configured correctly, you'll know about it (it won't launch). It also definitely won't launch if you haven't linked a valid activity to the published tool (so definitely check/fix that).

The fail delay is a mechanism used to delay future runs of the task when the task is failing a lot, and it's used to make sure we don't retry too often under fail conditions. If the task is working properly (without throwing exceptions), then it'll run as originally configured (which may be every minute, every 30, etc). In your case, the delay is currently very high, at 61440 seconds (17 hours), so that very well could be the reason you're not seeing grade sync happening - because it's only running ~ 1 times/day.

So, there must be exceptions being thrown in the run, but I'm not seeing them in the small sample of the task output shown above. Clicking "Run now" should allow you to see this, and then we can troubleshoot that further. That, or you can clear the fail delay (but the problem may come back again if you don't resolve/address the source of the exceptions). If you can post the exceptions here, that would be helpful. You're looking for something like:
"Scheduled task failed: Publish as LTI tool grade sync (enrol_lti\task\sync_grades)" at the bottom of the task run output.

Hope that helps
Jake
In reply to Jake Dallimore

Re: Grades not transferring for most students

by N W -
Hello Jake,
Here are the exceptions:

Starting - Grade sync for shared tool '39' for the course '258'.
Failed - Invalid contextid '5088' for the tool '39'.
(x67)

Starting - Grade sync for shared tool '41' for the course '258'.
Failed - Invalid contextid '5089' for the tool '41'.
Completed - Synced grades for tool '41' in the course '258'. Processed 1 users; sent 0 grades.

Scheduled task failed: Publier comme outil LTI de synchro des notes (enrol_lti\task\sync_grades),Erreur de programmation détectée. Ceci doit être corrigé par un programmeur : Invalid context id specified context::instance_by_id()

How do I find  the contextids and the tools 39 and 41?
Thanks
In reply to N W

Re: Grades not transferring for most students

by Jake Dallimore -
Picture of Core developers Picture of Moodle HQ Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers Picture of Testers
Ok, so we're getting somewhere now. Ignore those first "Failed - Invalid context" traces. Those aren't the exceptions. What we're really concerned with is the exception that causes the task to fail. In this case, that's the:

Invalid context id specified context::instance_by_id()

message at the end of the task run (the point during execution which throws the exception).

This can only occur in certain circumstances: when the tool context id is either not an integer or is empty.

Can you attach the last few lines of the trace? This should show what the task was doing right before it failed, and it may include some more useful information, such as the tool id.

Thanks in advance!
Jake
In reply to Jake Dallimore

Re: Grades not transferring for most students

by N W -
Here are the last few lines of the trace:

Skipping - Invalid grade for the user '966' in the tool '40' for the course '258'.
Skipping - Invalid grade for the user '972' in the tool '40' for the course '258'.
Completed - Synced grades for tool '40' in the course '258'. Processed 29 users; sent 0 grades.

Starting - Grade sync for shared tool '41' for the course '258'.
Failed - Invalid contextid '5089' for the tool '41'.
Completed - Synced grades for tool '41' in the course '258'. Processed 1 users; sent 0 grades.

Starting - Grade sync for shared tool '42' for the course '258'.
Completed - Synced grades for tool '42' in the course '258'. Processed 0 users; sent 0 grades.


Starting - Grade sync for shared tool '43' for the course '258'.
... used 1155 dbqueries
... used 1.9368200302124 seconds
Scheduled task failed: Publier comme outil LTI de synchro des notes (enrol_lti\task\sync_grades),Erreur de programmation détectée. Ceci doit être corrigé par un programmeur : Invalid context id specified context::instance_by_id()
In reply to N W

Re: Grades not transferring for most students

by Jake Dallimore -
Picture of Core developers Picture of Moodle HQ Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers Picture of Testers
Ok, that last one looks like it may be the culprit. You can see that it doesn't finish with the normal "Completed - xxx" trace like the rest. If you have database access, it would be interesting to see what the following returns:

SELECT contextid from DBPREFIX_enrol_lti_tools where id = 43;

You'll need to replace the DBPREFIX bit with the relevant prefix for your site.

Failing that, you'll need to try to find the tool in a course. There really isn't an easy way to do this by id, so you'll need to check the 'id' param for each 'edit tool settings' link (the cog on the published tools page). If there are only a handful of tools on the site, this may be feasible.

Let me know how you go

Jake
Average of ratings:Useful (1)
In reply to Jake Dallimore

Re: Grades not transferring for most students

by N W -
GOT IT!
Problem solved!

THANK YOU
In reply to N W

Re: Grades not transferring for most students

by Jake Dallimore -
Picture of Core developers Picture of Moodle HQ Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers Picture of Testers
Glad you got to the bottom of this one.

If possible, would you mind sharing the solution that worked for you here? It would certainly help others, and would help us patch the issue too (we don't really want to get into situations like this to begin with if we can avoid it)

Thanks
Jake
In reply to Jake Dallimore

Re: Grades not transferring for most students

by N W -
So I found an LTI activity with an coding error in another unused course. I removed the enrolment method in that course and it unblocked the transfer of grades.
Average of ratings:Useful (2)