LTI 1.1 grading not working for some locales

Bug #2004852 reported by Marie-Eve Lévesque
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Mahara
21.10
Fix Released
High
Unassigned
22.04
Fix Released
High
Unassigned
22.10
Fix Released
High
Unassigned
23.04
Fix Released
High
Unassigned

Bug Description

With a LTI to a Moodle instance, when the teachers grades a submission, the grade is not sent to Moodle in some cases. I think it has to do with my server's locale set to french. The grade of 94%, for example, si translated to 0,94 instead of 0.94.

I printed some debug and was able to see the error "Score must be numeric". I also printed the xml from the $body variable (see attachment).

I made a few changes in function publish_lti_outcome of htdocs/module/lti/lib.php around line 1001 and it now works correctly.

$grade = $this->grade / 100;
$grade = str_replace(',', '.', $grade);
$smarty->assign('score', $grade);

This was tested with Mahara 22.10 and Moodle 3.11.

Revision history for this message
Marie-Eve Lévesque (marieeve83) wrote :
description: updated
Revision history for this message
Kristina Hoeppner (kris-hoeppner) wrote :

Thank you for the report, Marie-Eve. We'll review your suggestion and put it through our code review system.

Note for testing: This would be for LTI 1.1, using the 'External tool' option in Moodle.

summary: - LTI grading not working for some locales
+ LTI 1.1 grading not working for some locales
Revision history for this message
Gold (gold.catalyst) wrote :

Rather than the straight up str_replace() I would go for number_format() as it handles locales.

See this for it in action:
https://reviews.mahara.org/c/mahara/+/12478/6/htdocs/webservice/lib.php#b1489

Revision history for this message
Mahara Bot (dev-mahara) wrote : A patch has been submitted for review
Revision history for this message
Gold (gold.catalyst) wrote :

Hello Marie-Eve,

Could you give the patch at #4 a go please? I've added a PHPUnit test that looks to claim it is using an expected value, but there's nothing quite as good as testing in a full environment that it was found in.

Regards,
Gold

Revision history for this message
Marie-Eve Lévesque (marieeve83) wrote :

Hi Gold,

Yes, I just tried it in the same environment where I found the problem and the patch works!

Thanks!
Marie-Eve

Revision history for this message
Mahara Bot (dev-mahara) wrote : A change has been merged

Reviewed: https://reviews.mahara.org/c/mahara/+/13741
Committed: https://git.mahara.org/mahara/mahara/commit/511e22608a0f72b40ae0f764e6cfc0b8d1c92d1f
Submitter: "Robert Lyon <email address hidden>"
Branch: main

commit 511e22608a0f72b40ae0f764e6cfc0b8d1c92d1f
Author: Gold <email address hidden>
Date: Thu Feb 9 12:07:40 2023 +1300

Bug 2004852: LTI 1.1 grading vs some locales

Ensure the format of the grade uses a dot regardless of the system
locale.

Signed-off-by: Gold <email address hidden>
Change-Id: I4b669486c2f73eff73ce940300ba26db4586e914

Revision history for this message
Mahara Bot (dev-mahara) wrote : A patch has been submitted for review

Patch for "22.10_DEV" branch: https://reviews.mahara.org/c/mahara/+/13800

Revision history for this message
Mahara Bot (dev-mahara) wrote :

Patch for "22.04_DEV" branch: https://reviews.mahara.org/c/mahara/+/13801

Revision history for this message
Mahara Bot (dev-mahara) wrote :

Patch for "21.10_DEV" branch: https://reviews.mahara.org/c/mahara/+/13802

Revision history for this message
Mahara Bot (dev-mahara) wrote : A change has been merged

Reviewed: https://reviews.mahara.org/c/mahara/+/13800
Committed: https://git.mahara.org/mahara/mahara/commit/c52a159932df42e53a42dd36a947770a1ac92066
Submitter: "Robert Lyon <email address hidden>"
Branch: 22.10_DEV

commit c52a159932df42e53a42dd36a947770a1ac92066
Author: Gold <email address hidden>
Date: Thu Feb 9 12:07:40 2023 +1300

Bug 2004852: LTI 1.1 grading vs some locales

Ensure the format of the grade uses a dot regardless of the system
locale.

Signed-off-by: Gold <email address hidden>
Change-Id: I4b669486c2f73eff73ce940300ba26db4586e914
(cherry picked from commit 511e22608a0f72b40ae0f764e6cfc0b8d1c92d1f)

Revision history for this message
Mahara Bot (dev-mahara) wrote :

Reviewed: https://reviews.mahara.org/c/mahara/+/13801
Committed: https://git.mahara.org/mahara/mahara/commit/1deb137ca13d00a554f26c3657ec5c32361e41af
Submitter: "Robert Lyon <email address hidden>"
Branch: 22.04_DEV

commit 1deb137ca13d00a554f26c3657ec5c32361e41af
Author: Gold <email address hidden>
Date: Thu Feb 9 12:07:40 2023 +1300

Bug 2004852: LTI 1.1 grading vs some locales

Ensure the format of the grade uses a dot regardless of the system
locale.

Signed-off-by: Gold <email address hidden>
Change-Id: I4b669486c2f73eff73ce940300ba26db4586e914
(cherry picked from commit 511e22608a0f72b40ae0f764e6cfc0b8d1c92d1f)

Revision history for this message
Mahara Bot (dev-mahara) wrote :

Reviewed: https://reviews.mahara.org/c/mahara/+/13802
Committed: https://git.mahara.org/mahara/mahara/commit/eaadf5d106533064aec2e19d8e2a28483942363f
Submitter: "Robert Lyon <email address hidden>"
Branch: 21.10_DEV

commit eaadf5d106533064aec2e19d8e2a28483942363f
Author: Gold <email address hidden>
Date: Thu Feb 9 12:07:40 2023 +1300

Bug 2004852: LTI 1.1 grading vs some locales

Ensure the format of the grade uses a dot regardless of the system
locale.

Signed-off-by: Gold <email address hidden>
Change-Id: I4b669486c2f73eff73ce940300ba26db4586e914
(cherry picked from commit 511e22608a0f72b40ae0f764e6cfc0b8d1c92d1f)

Robert Lyon (robertl-9)
Changed in mahara:
milestone: 23.04.0 → none
Robert Lyon (robertl-9)
Changed in mahara:
status: Fix Committed → Fix Released
no longer affects: mahara
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.