Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-78599

Syntax error in LTI Advantage grade sync SQL




      Kindly reported by Onno here: https://moodle.org/mod/forum/discuss.php?d=448092

      The code:

      ON {c.id} = e.courseid 

      should be:

      ON c.id = e.courseid 

      Note: This SQL will be in the sync_tool_grades task in 4.2 and newer. In 4.1, it'll be in the main sync_grades task.

      This only impacts the case where we're creating the grade item for a published course having a decoupled grade item. I.e. the launch has included an AGS claim, but hasn't included a 'lineitem' endpoint, meaning the tool is free to manage its own line items in the gradebook. This won't impact shared activities, nor any shared items with coupled line items (those which include a 'lineitem' property in the AGS claim).

      Replication instructions:

      1. Setup two sites using LTI Advantage; one platform, one tool
      2. In the tool site, create a course with an assignment in it.
      3. Publish the entire course as an LTI tool (course context is important)
      4. In the platform site, create the external tool instance such that you're able to launch into the published course (use deep linking)
      5. Edit the settings of that activity and set:
        • Privacy > Accept grades from the tool = Yes
        • Grade type: None
          (This results in the ags claim ONLY sending 2 items: the 'scope' property and the 'lineitems' property (importantly, NOT the 'lineitem' property for the specific grade item, since the grade is set to None)
      6. Launch
      7. Log in to the platform as a student user s1
      8. Launch into the tool (we don't need a submission here, just a launch)
      9. Log out
      10. Log in to the platform as the admin
      11. Go to the course
      12. Launch the tool and go to the assignment
      13. Click "View all submissions"
      14. Click the "Quick grading" checkbox
      15. Set a grade for the student s1, say '55'
      16. Now, in the root of the tool site, run:

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

      On 4.2+, this will schedule the adhocs that sync grades

      1. Then run:

      php admin/cli/adhoc_task.php --execute 

      This will process the adhoc tasks for grade syncing

      1. Inspect the terminal output
        Expected: You see "The grade 'xx' was sent" (xx will be whatever the expected course grade was)
        Actual: You see (ignore the letter placeholders here, yours will be different):

      Failed - The grade 'xx' for the user 'yy', for the resource 'zz' and the course 'a' failed to send.
      Error reading from database (ERROR:  syntax error at or near "{"
      LINE 6:                                   ON {c.id} = e.courseid 
      SELECT c.fullname
                                      FROM mdl_enrol_lti_tools t
                                      JOIN mdl_enrol e
                                        ON (e.id = t.enrolid)
                                      JOIN mdl_course c
                                        ON {c.id} = e.courseid
                                     WHERE t.id = $1
      [array (
        0 => '14',




            jaked Jake Dallimore
            jaked Jake Dallimore
            Paul Holden Paul Holden
            Andrew Lyons Andrew Lyons
            CiBoT CiBoT
            0 Vote for this issue
            4 Start watching this issue



              Time Tracking

                Original Estimate - Not Specified
                Not Specified
                Remaining Estimate - 0 minutes
                Time Spent - 1 hour, 22 minutes
                1h 22m


                  Error rendering 'clockify-timesheets-time-tracking-reports:timer-sidebar'. Please contact your Jira administrators.