Browse Source

Fix up auto-marking code.

40-behatfixes
Dan Marsden 3 years ago
parent
commit
967633cdc1
  1. 19
      classes/task/auto_mark.php

19
classes/task/auto_mark.php

@ -144,8 +144,6 @@ class auto_mark extends \core\task\scheduled_task {
$logusers->close();
} else if ($session->automark == 3) {
$completedusers = array();
$newlog = new \stdClass();
$newlog->timetaken = $now;
$newlog->takenby = 0;
@ -154,25 +152,22 @@ class auto_mark extends \core\task\scheduled_task {
$newlog->statusset = implode(',', array_keys( (array)$att->get_statuses()));
// Get users who have completed the course in this session.
$completedusers[] = $DB->get_record('course_modules_completion', array(
'coursemoduleid' => $session->automarkcmid,
'completionstate' => 1
));
if (!empty($completedusers)) {
$completedusers = $DB->get_records_select('course_modules_completion',
'coursemoduleid = ? AND completionstate > 0', [$session->automarkcmid]);
// Get automark status the users and update the attendance log.
foreach ($completedusers as $completionuser) {
if (empty($completionuser->timemodified) || (empty($completionuser->userid))) {
// Time modified or userid not set - we can't calculate for this record.
continue;
}
$newlog->studentid = $completionuser->userid;
$newlog->statusid = $att->get_automark_status($completionuser->timemodified, $session->id);
if (!empty($newlog->statusid)) {
$newlog->studentid = $completionuser->userid;
$DB->insert_record('attendance_log', $newlog);
}
}
}
}
// Get all unmarked students.
$users = $att->get_users($session->groupid, 0);

Loading…
Cancel
Save