Browse Source

Fixes #87 show a useful error when form submitted incorrectly.

MOODLE_28_STABLE
Dan Marsden 10 years ago
parent
commit
b0638c67bd
  1. 1
      lang/en/attendance.php
  2. 3
      renderer.php
  3. 7
      sessions.php

1
lang/en/attendance.php

@ -123,6 +123,7 @@ $string['includenottaken'] = 'Include not taken sessions';
$string['includeremarks'] = 'Include remarks'; $string['includeremarks'] = 'Include remarks';
$string['indetail'] = 'In detail...'; $string['indetail'] = 'In detail...';
$string['invalidsessionenddate'] = 'The session end date can not be earlier than the session start date'; $string['invalidsessionenddate'] = 'The session end date can not be earlier than the session start date';
$string['invalidaction'] = 'You must select an action';
$string['jumpto'] = 'Jump to'; $string['jumpto'] = 'Jump to';
$string['modulename'] = 'Attendance'; $string['modulename'] = 'Attendance';
$string['modulename_help'] = 'The attendance activity module enables a teacher to take attendance during class and students to view their own attendance record. $string['modulename_help'] = 'The attendance activity module enables a teacher to take attendance during class and students to view their own attendance record.

3
renderer.php

@ -294,6 +294,9 @@ class mod_attendance_renderer extends plugin_renderer_base {
$options = array( $options = array(
att_sessions_page_params::ACTION_DELETE_SELECTED => get_string('delete'), att_sessions_page_params::ACTION_DELETE_SELECTED => get_string('delete'),
att_sessions_page_params::ACTION_CHANGE_DURATION => get_string('changeduration', 'attendance')); att_sessions_page_params::ACTION_CHANGE_DURATION => get_string('changeduration', 'attendance'));
$controls = html_writer::select($options, 'action'); $controls = html_writer::select($options, 'action');
$attributes = array( $attributes = array(
'type' => 'submit', 'type' => 'submit',

7
sessions.php

@ -33,6 +33,13 @@ $pageparams = new att_sessions_page_params();
$id = required_param('id', PARAM_INT); $id = required_param('id', PARAM_INT);
$pageparams->action = required_param('action', PARAM_INT); $pageparams->action = required_param('action', PARAM_INT);
if (empty($pageparams->action)) {
// The form on manage.php can submit with the "choose" option - this should be fixed in the long term,
// but in the meantime show a useful error and redirect when it occurs.
$url = new moodle_url('/mod/attendance/view.php', array('id' => $id));
redirect($url, get_string('invalidaction', 'mod_attendance'), 2);
}
$cm = get_coursemodule_from_id('attendance', $id, 0, false, MUST_EXIST); $cm = get_coursemodule_from_id('attendance', $id, 0, false, MUST_EXIST);
$course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST); $course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST);
$att = $DB->get_record('attendance', array('id' => $cm->instance), '*', MUST_EXIST); $att = $DB->get_record('attendance', array('id' => $cm->instance), '*', MUST_EXIST);

Loading…
Cancel
Save