Browse Source

Improve error handling when adding a new status fails.

MOODLE_34_STABLE
Dan Marsden 7 years ago
parent
commit
9ef0618b4a
  1. 1
      lang/en/attendance.php
  2. 7
      preferences.php

1
lang/en/attendance.php

@ -82,6 +82,7 @@ $string['calshow'] = 'Choose date';
$string['caltoday'] = 'Today';
$string['calweekdays'] = 'Su,Mo,Tu,We,Th,Fr,Sa';
$string['cannottakeforgroup'] = 'You can\'t take attendance for group "{$a}"';
$string['cantaddstatus'] = 'You must set an acronym and description when adding a new status.';
$string['categoryreport'] = 'Course category report';
$string['changeattendance'] = 'Change attendance';
$string['changeduration'] = 'Change duration';

7
preferences.php

@ -61,7 +61,7 @@ $errors = array();
if (!empty($att->pageparams->action)) {
require_sesskey();
}
$notification = '';
// TODO: combine this with the stuff in defaultstatus.php to avoid code duplication.
switch ($att->pageparams->action) {
case mod_attendance_preferences_page_params::ACTION_ADD:
@ -83,7 +83,7 @@ switch ($att->pageparams->action) {
$status = attendance_add_status($newstatus);
if (!$status) {
print_error('cantaddstatus', 'attendance', $this->url_preferences());
$notification = $OUTPUT->notification(get_string('cantaddstatus', 'attendance'), 'error');
}
if ($pageparams->statusset > $maxstatusset) {
@ -157,6 +157,9 @@ $setselector = new attendance_set_selector($att, $maxstatusset);
// Output starts here.
echo $output->header();
if (!empty($notification)) {
echo $notification;
}
echo $output->heading(get_string('attendanceforthecourse', 'attendance').' :: '. format_string($course->fullname));
echo $output->render($tabs);
echo $OUTPUT->box(get_string('preferences_desc', 'attendance'), 'generalbox attendancedesc', 'notice');

Loading…
Cancel
Save