Browse Source

Show warning if teacher using mark on close and no status available.

MOODLE_35_STABLE
Dan Marsden 7 years ago
parent
commit
95befa5143
  1. 14
      add_form.php
  2. 1
      lang/en/attendance.php
  3. 14
      update_form.php

14
add_form.php

@ -262,6 +262,7 @@ class mod_attendance_add_form extends moodleform {
* @param array $files * @param array $files
*/ */
public function validation($data, $files) { public function validation($data, $files) {
global $DB;
$errors = parent::validation($data, $files); $errors = parent::validation($data, $files);
$sesstarttime = $data['sestime']['starthour'] * HOURSECS + $data['sestime']['startminute'] * MINSECS; $sesstarttime = $data['sestime']['starthour'] * HOURSECS + $data['sestime']['startminute'] * MINSECS;
@ -299,6 +300,19 @@ class mod_attendance_add_form extends moodleform {
$this->_form->setConstant('previoussessiondate', $data['sessiondate']); $this->_form->setConstant('previoussessiondate', $data['sessiondate']);
} }
if ($data['automark'] == ATTENDANCE_AUTOMARK_CLOSE) {
$cm = $this->_customdata['cm'];
// Check that the selected statusset has a status to use when unmarked.
$sql = 'SELECT id
FROM {attendance_statuses}
WHERE deleted = 0 AND (attendanceid = 0 or attendanceid = ?)
AND setnumber = ? AND setunmarked = 1';
$params = array($cm->instance, $data['statusset']);
if (!$DB->record_exists_sql($sql, $params)) {
$errors['automark'] = get_string('noabsentstatusset', 'attendance');
}
}
return $errors; return $errors;
} }

1
lang/en/attendance.php

@ -272,6 +272,7 @@ $string['mustselectusers'] = 'Must select users to export';
$string['newdate'] = 'New date'; $string['newdate'] = 'New date';
$string['newduration'] = 'New duration'; $string['newduration'] = 'New duration';
$string['newstatusset'] = 'New set of statuses'; $string['newstatusset'] = 'New set of statuses';
$string['noabsentstatusset'] = 'The status set in use does not have a status to use when not marked.';
$string['noattendanceusers'] = 'It is not possible to export any data as there are no students enrolled in the course.'; $string['noattendanceusers'] = 'It is not possible to export any data as there are no students enrolled in the course.';
$string['noautomark'] = 'Disabled'; $string['noautomark'] = 'Disabled';
$string['noattforuser'] = 'No attendance records exist for the user'; $string['noattforuser'] = 'No attendance records exist for the user';

14
update_form.php

@ -177,6 +177,7 @@ class mod_attendance_update_form extends moodleform {
* @param array $files * @param array $files
*/ */
public function validation($data, $files) { public function validation($data, $files) {
global $DB;
$errors = parent::validation($data, $files); $errors = parent::validation($data, $files);
$sesstarttime = $data['sestime']['starthour'] * HOURSECS + $data['sestime']['startminute'] * MINSECS; $sesstarttime = $data['sestime']['starthour'] * HOURSECS + $data['sestime']['startminute'] * MINSECS;
@ -185,6 +186,19 @@ class mod_attendance_update_form extends moodleform {
$errors['sestime'] = get_string('invalidsessionendtime', 'attendance'); $errors['sestime'] = get_string('invalidsessionendtime', 'attendance');
} }
if ($data['automark'] == ATTENDANCE_AUTOMARK_CLOSE) {
$cm = $this->_customdata['cm'];
// Check that the selected statusset has a status to use when unmarked.
$sql = 'SELECT id
FROM {attendance_statuses}
WHERE deleted = 0 AND (attendanceid = 0 or attendanceid = ?)
AND setnumber = ? AND setunmarked = 1';
$params = array($cm->instance, $data['statusset']);
if (!$DB->record_exists_sql($sql, $params)) {
$errors['automark'] = get_string('noabsentstatusset', 'attendance');
}
}
return $errors; return $errors;
} }
} }

Loading…
Cancel
Save