LTI grade sync and scales

LTI grade sync and scales

by Kirk Martinson -
Number of replies: 3

After realizing that we were unable to translate LTI-reported grades (e.g. from Google Assignments) correctly to a scaled grade in the gradebook, I went digging about and discovered that the scaling from the LTI-reported percentage (0 to 1 value) was being multiplied by the 'grade' column in the lti table - which is not the max grade for scaled activities, but rather the negative of its scale id number.

I was able to rectify this with a bit of code in the servicelib.php file of the lti module, in the lti_update_grade function, catching any negative value for the $ltiinstance->grade value, and in those cases multiplying by the 'grademax' value from the grade_item table instead (pulled using the courseid, iteminstance values from $ltiinstance, and setting 'itemmodule' to lti). So far, this seems to work for me, but I'm almost certain it's not the best fix, and I'm wondering a) why this hasn't already been addressed in the core code, and b) if this needs to be reported as a bug to be implemented, or if my setup is somehow not catching and converting these values in a way that is already implemented.

Thanks,

kirk

Code change to servicelib.php:

        $gradeval = $gradeval * floatval($ltiinstance->grade);

changed to:

    if ($ltiinstance->grade < 0) {

        $gradeitem = $DB->get_record('grade_items', array(

             'iteminstance' => $ltiinstance->id,

     'courseid' => $ltiinstance->course,

     'itemmodule' => LTI_ITEM_MODULE));

$maxgrade = $gradeitem->grademax;

        $gradeval = $gradeval * $maxgrade;

    } else {

        $gradeval = $gradeval * floatval($ltiinstance->grade);

    }

Average of ratings: -
In reply to Kirk Martinson

Re: LTI grade sync and scales

by Jake Dallimore -
Picture of Core developers Picture of Moodle HQ Picture of Peer reviewers Picture of Plugin developers Picture of Testers
Hi Kirk

Thanks for the report. Firstly, I'm just going to ask that this post be moved over to the LTI forum. Hopefully Howard sees this.

I'm pretty flat out with the release work at present, but as soon as I have a spare minute or two, I'll run through this code and see what's going on.

Cheers,
In reply to Jake Dallimore

Re: LTI grade sync and scales

by Ian Stuart -
Can I ask where this "LTI Forum" is - I can't find it.... cheers