Browse Source

Add setting to force self-marking during session.

MOODLE_32_STABLE
Dan Marsden 8 years ago
parent
commit
d73402bf7a
  1. 3
      attendance.php
  2. 4
      lang/en/attendance.php
  3. 25
      locallib.php
  4. 3
      renderer.php
  5. 9
      settings.php
  6. 4
      version.php

3
attendance.php

@ -39,7 +39,8 @@ $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)) { if (!attendance_can_student_mark($attforsession)) {
// TODO: should we add a log message here? - student has got to submit page but cannot save attendance (time ran out?)
redirect(new moodle_url('/mod/attendance/view.php', array('id' => $cm->id))); redirect(new moodle_url('/mod/attendance/view.php', array('id' => $cm->id)));
exit; exit;
} }

4
lang/en/attendance.php

@ -324,6 +324,10 @@ $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_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['studentscanmarksessiontime'] = 'Students record attendance during session time';
$string['studentscanmarksessiontime_desc'] = 'If checked students can only record their attendance during the session.';
$string['studentscanmarksessiontimeend'] = 'Session end (minutes)';
$string['studentscanmarksessiontimeend_desc'] = 'If the session does not have an end time, how many minutes should the session be available for students to record their attendance.';
$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.';
$string['lowgrade'] = 'Low grade'; $string['lowgrade'] = 'Low grade';

25
locallib.php

@ -375,3 +375,28 @@ function attendance_random_string($length=6) {
} }
return $string; return $string;
} }
/**
* Check to see if this session is open for student marking.
*
* @param stdclass $sess the session record from attendance_sessions.
* @return boolean
*/
function attendance_can_student_mark($sess) {
$canmark = false;
$attconfig = get_config('attendance');
if (!empty($attconfig->studentscanmark) && !empty($sess->studentscanmark)) {
if (empty($attconfig->studentscanmarksessiontime)) {
$canmark = true;
} else {
$duration = $sess->duration;
if (empty($duration)) {
$duration = $attconfig->studentscanmarksessiontimeend * 60;
}
if ($sess->sessdate < time() && time() < ($sess->sessdate + $duration)) {
$canmark = true;
}
}
}
return $canmark;
}

3
renderer.php

@ -847,9 +847,10 @@ class mod_attendance_renderer extends plugin_renderer_base {
$cell->colspan = 2; $cell->colspan = 2;
$row->cells[] = $cell; $row->cells[] = $cell;
} else { } else {
if (!empty(get_config('attendance', 'studentscanmark')) && !empty($sess->studentscanmark)) { if (attendance_can_student_mark($sess)) {
// Student can mark their own attendance. // 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()));
$cell = new html_table_cell(html_writer::link($url, get_string('submitattendance', 'attendance'))); $cell = new html_table_cell(html_writer::link($url, get_string('submitattendance', 'attendance')));

9
settings.php

@ -48,6 +48,15 @@ if ($ADMIN->fulltree) {
$settings->add(new admin_setting_configcheckbox('attendance/studentscanmark', $settings->add(new admin_setting_configcheckbox('attendance/studentscanmark',
get_string('studentscanmark', 'attendance'), get_string('studentscanmark_desc', 'attendance'), 1)); get_string('studentscanmark', 'attendance'), get_string('studentscanmark_desc', 'attendance'), 1));
$settings->add(new admin_setting_configcheckbox('attendance/studentscanmarksessiontime',
get_string('studentscanmarksessiontime', 'attendance'),
get_string('studentscanmarksessiontime_desc', 'attendance'), 1));
$settings->add(new admin_setting_configtext('attendance/studentscanmarksessiontimeend',
get_string('studentscanmarksessiontimeend', 'attendance'),
get_string('studentscanmarksessiontimeend_desc', 'attendance'), '60', PARAM_INT));
$name = new lang_string('defaultsettings', 'mod_attendance'); $name = new lang_string('defaultsettings', 'mod_attendance');
$description = new lang_string('defaultsettings_help', 'mod_attendance'); $description = new lang_string('defaultsettings_help', 'mod_attendance');
$settings->add(new admin_setting_heading('defaultsettings', $name, $description)); $settings->add(new admin_setting_heading('defaultsettings', $name, $description));

4
version.php

@ -23,9 +23,9 @@
*/ */
defined('MOODLE_INTERNAL') || die(); defined('MOODLE_INTERNAL') || die();
$plugin->version = 2016121306; $plugin->version = 2016121307;
$plugin->requires = 2016111800; $plugin->requires = 2016111800;
$plugin->release = '3.2.6'; $plugin->release = '3.2.7';
$plugin->maturity = MATURITY_STABLE; $plugin->maturity = MATURITY_STABLE;
$plugin->cron = 0; $plugin->cron = 0;
$plugin->component = 'mod_attendance'; $plugin->component = 'mod_attendance';

Loading…
Cancel
Save