Skip to content

Not sending correct grade because the last-grade is seen as the current-grade #51

@SAHellauer

Description

@SAHellauer

Please review the following line:

if ( intval($grade) == $user->lastgrade ) {

Should the above code be an exact check and then we store the exact grade being sent in the db?

Use Case

  1. A quiz is worth 10 points.
  2. Student gets a 9.2 on their first attempt.
  3. Cron script runs, sends the float value and then sets the last-grade to 9 in the db.
  4. Student gets a 9.8 on their second attempt.
  5. Cron script runs and does not send the float value, because the check in the code referenced above considers 9.2 and 9.8 as the same.

Or at the very least could we round the grade and check that way?

$roundedGrade = round($grade);

if (intval($roundedGrade) == $user->lastgrade) {
    continue;
}

And then store the rounded grade instead.

$DB->set_field('local_ltiprovider_user', 'lastgrade', intval($roundedGrade), array('id' => $user->id));

This solution still does not provide an exact check. 9.2 and 9.3 would still be see as 9. But I believe it would be a little more accurate.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions