-
Bug
-
Resolution: Fixed
-
Minor
-
3.3.4, 3.4.1, 3.5
-
MOODLE_33_STABLE, MOODLE_34_STABLE, MOODLE_35_STABLE
-
MOODLE_33_STABLE, MOODLE_34_STABLE
-
MDL-61324_lti_sync -
When invoking moodle lti grade sync, unchanged grades are repeatedly sent on subsequent syncs to the consumer system regardless of whether they have changed, if the `grade` variable is a float.
The sync grades function checks whether the grade has changed by comparing the current `grade` with the `lastgrade` field in the `enrol_lti_users` database table. If it has changed, it will send the grade to the consumer system.
However the comparison will fail when `grade` is a float, because `lastgrade` is cast to an int when saved to the `enrol_lti_users` database table [on line 177](https://github.com/moodle/moodle/blob/8ed2bbcfed79b8224876364ca428049563128145/enrol/lti/classes/task/sync_grades.php#L177).
Steps to reproduce:
- Set up two moodle systems, one as an LTI provider and one as a consumer. On the provider site set up a quiz with a single multiple choice question with one answer having the grade 100%, and one answer having the grade 33.3%. Share the quiz with the consumer system using Published as LTI Tools, and adding as an External Tool on the consumer system.
- Log into the consumer system as a student user, complete the quiz you just created answering with the option you gave the grade of 33.3%.
- From the moodle root of the provider system, run the command `php admin/tool/task/cli/schedule_task.php --execute=\enrol_lti\task\sync_grades`
- Look at the web server logs for the consumer system. You should see an entry something like `xx.xxx.xxx.xxx - - [31/Jan/2018:11:17:12 +0000] "POST /mod/lti/service.php HTTP/1.1" 200 554 "-" "MoodleBot/1.0"`
- Re run the sync grades task on the provider system, and again check the web server logs. You will see each time you run sync grades, it will re-send the grade.
I have also inspected the LTI xml data that is sent in the above example and confirmed that it is sending the exact same grade each time.