Skip to content

Commit

Permalink
IOMAD: adding soem leeway on the final grade updates for IOMAD report…
Browse files Browse the repository at this point in the history
…ing tables in case of race conditions between that and course completion.
  • Loading branch information
turf212 committed Oct 17, 2023
1 parent 1685a43 commit 71680ef
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions local/iomad_track/classes/observer.php
Original file line number Diff line number Diff line change
Expand Up @@ -697,9 +697,15 @@ public static function user_graded($event) {
}

// Check if there is already an entry for this.
if ($entry = $DB->get_record('local_iomad_track', array('userid' => $userid,
'courseid' => $courseid,
'timecompleted' => null))) {
if ($entry = $DB->get_record_sql("SELECT * FROM {local_iomad_track}
WHERE userid = :userid
AND courseid = :courseid
AND
(timecompleted IS NULL OR
timecompleted + 5 > :eventtime)",
array('userid' => $userid,
'courseid' => $courseid,
'eventtime' => $event->timecreated))) {
// We already have an entry. Remove it.
$DB->set_field('local_iomad_track', 'finalscore', $graderec->finalgrade/$graderec->rawgrademax * 100, array('id' => $entry->id));
$DB->set_field('local_iomad_track', 'modifiedtime', $event->timecreated, array('id' => $entry->id));
Expand Down

0 comments on commit 71680ef

Please sign in to comment.