Browse Source

Fixes #223 allow student attendance to be disabled at site-level

MOODLE_27_STABLE
Dan Marsden 8 years ago
parent
commit
3b9f928ed5
  1. 9
      add_form.php
  2. 4
      attendance.php
  3. 1
      lang/en/attendance.php
  4. 3
      renderer.php
  5. 4
      sessions.php
  6. 3
      settings.php

9
add_form.php

@ -106,8 +106,13 @@ class mod_attendance_add_form extends moodleform {
$mform->addHelpButton('addmultiply', 'createmultiplesessions', 'attendance'); $mform->addHelpButton('addmultiply', 'createmultiplesessions', 'attendance');
// Students can mark own attendance. // Students can mark own attendance.
$mform->addElement('checkbox', 'studentscanmark', '', get_string('studentscanmark','attendance')); if (!empty(get_config('attendance', 'studentscanmark'))) {
$mform->addHelpButton('studentscanmark', 'studentscanmark', 'attendance'); $mform->addElement('checkbox', 'studentscanmark', '', get_string('studentscanmark', 'attendance'));
$mform->addHelpButton('studentscanmark', 'studentscanmark', 'attendance');
} else {
$mform->addElement('hidden', 'studentscanmark', '0');
$mform->settype('studentscanmark', PARAM_INT);
}
$mform->addElement('date_time_selector', 'sessiondate', get_string('sessiondate', 'attendance')); $mform->addElement('date_time_selector', 'sessiondate', get_string('sessiondate', 'attendance'));

4
attendance.php

@ -41,6 +41,10 @@ $course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST)
// Require the user is logged in. // Require the user is logged in.
require_login($course, true, $cm); require_login($course, true, $cm);
if (empty(get_config('attendance', 'studentscanmark')) || empty($attforsession->studentscanmark)) {
redirect(new moodle_url('/mod/attendance/view.php', array('id' => $cm->id)));
exit;
}
$pageparams->sessionid = $id; $pageparams->sessionid = $id;
$att = new attendance($attendance, $cm, $course, $PAGE->context, $pageparams); $att = new attendance($attendance, $cm, $course, $PAGE->context, $pageparams);

1
lang/en/attendance.php

@ -231,6 +231,7 @@ $string['eventstatusupdated'] = 'Status updated';
$string['eventstatusadded'] = 'Status added'; $string['eventstatusadded'] = 'Status added';
$string['studentscanmark'] = 'Allow students to record own attendance'; $string['studentscanmark'] = 'Allow students to record own attendance';
$string['studentscanmark_desc'] = 'If checked, teachers will be able to allow students to mark their own attendance.';
$string['studentscanmark_help'] = 'If checked students will be able to change their own attendance status for the session.'; $string['studentscanmark_help'] = 'If checked students will be able to change their own attendance status for the session.';
$string['set_by_student'] = 'Self-recorded'; $string['set_by_student'] = 'Self-recorded';
$string['attendance_already_submitted'] = 'You may not self register attendance that has already been set.'; $string['attendance_already_submitted'] = 'You may not self register attendance that has already been set.';

3
renderer.php

@ -748,7 +748,8 @@ class mod_attendance_renderer extends plugin_renderer_base {
$cell->colspan = 2; $cell->colspan = 2;
$row->cells[] = $cell; $row->cells[] = $cell;
} else { } else {
if (!empty($sess->studentscanmark)) { // Student can mark their own attendance. if (!empty(get_config('attendance', 'studentscanmark')) && !empty($sess->studentscanmark)) {
// Student can mark their own attendance.
// URL to the page that lets the student modify their attendance. // URL to the page that lets the student modify their attendance.
$url = new moodle_url('/mod/attendance/attendance.php', $url = new moodle_url('/mod/attendance/attendance.php',
array('sessid' => $sess->id, 'sesskey' => sesskey())); array('sessid' => $sess->id, 'sesskey' => sesskey()));

4
sessions.php

@ -194,6 +194,10 @@ function construct_sessions_data_for_add($formdata) {
$duration = $formdata->durtime['hours']*HOURSECS + $formdata->durtime['minutes']*MINSECS; $duration = $formdata->durtime['hours']*HOURSECS + $formdata->durtime['minutes']*MINSECS;
$now = time(); $now = time();
if (empty(get_config('attendance', 'studentscanmark'))) {
$formdata->studentscanmark = 0;
}
$sessions = array(); $sessions = array();
if (isset($formdata->addmultiply)) { if (isset($formdata->addmultiply)) {
$startdate = $formdata->sessiondate; $startdate = $formdata->sessiondate;

3
settings.php

@ -41,4 +41,7 @@ if ($ADMIN->fulltree) {
$settings->add(new admin_setting_configselect('attendance/resultsperpage', $settings->add(new admin_setting_configselect('attendance/resultsperpage',
get_string('resultsperpage', 'attendance'), get_string('resultsperpage_desc', 'attendance'), 25, $options)); get_string('resultsperpage', 'attendance'), get_string('resultsperpage_desc', 'attendance'), 25, $options));
$settings->add(new admin_setting_configcheckbox('attendance/studentscanmark',
get_string('studentscanmark', 'attendance'), get_string('studentscanmark_desc', 'attendance'), 1));
} }

Loading…
Cancel
Save