Compare commits

...

4 Commits

Author SHA1 Message Date
Marty Gilbert 58f93889d4 https://github.com/danmarsden/moodle-mod_attendance/issues/234 (#235) 8 years ago
Dan Marsden 7aa0143d3a Fixes #223 allow student attendance to be disabled at site-level 8 years ago
Dan Marsden 8b5f41b1eb make sure php 7 tests pass on 3.0 branch 9 years ago
Dan Marsden 5f5e87842a update travis check with correct branches 9 years ago
  1. 6
      .travis.yml
  2. 10
      add_form.php
  3. 4
      attendance.php
  4. 1
      lang/en/attendance.php
  5. 4
      renderer.php
  6. 5
      sessions.php
  7. 3
      settings.php

6
.travis.yml

@ -10,15 +10,9 @@ php:
- 5.6 - 5.6
- 7.0 - 7.0
matrix:
allow_failures:
- php: 7.0
env: env:
matrix: matrix:
- DB=pgsql MOODLE_BRANCH=MOODLE_29_STABLE
- DB=pgsql MOODLE_BRANCH=MOODLE_30_STABLE - DB=pgsql MOODLE_BRANCH=MOODLE_30_STABLE
- DB=mysqli MOODLE_BRANCH=MOODLE_29_STABLE
- DB=mysqli MOODLE_BRANCH=MOODLE_30_STABLE - DB=mysqli MOODLE_BRANCH=MOODLE_30_STABLE
before_install: before_install:

10
add_form.php

@ -118,8 +118,14 @@ class mod_attendance_add_form extends moodleform {
} }
// Students can mark own attendance. // Students can mark own attendance.
$mform->addElement('checkbox', 'studentscanmark', '', get_string('studentscanmark', 'attendance')); $configcanmark = get_config('attendance', 'studentscanmark');
$mform->addHelpButton('studentscanmark', 'studentscanmark', 'attendance'); if (!empty($configcanmark)) {
$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('editor', 'sdescription', get_string('description', 'attendance'), array('rows' => 1, 'columns' => 80), $mform->addElement('editor', 'sdescription', get_string('description', 'attendance'), array('rows' => 1, 'columns' => 80),
array('maxfiles' => EDITOR_UNLIMITED_FILES, 'noclean' => true, 'context' => $modcontext)); array('maxfiles' => EDITOR_UNLIMITED_FILES, 'noclean' => true, 'context' => $modcontext));

4
attendance.php

@ -39,6 +39,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 mod_attendance_structure($attendance, $cm, $course, $PAGE->context, $pageparams); $att = new mod_attendance_structure($attendance, $cm, $course, $PAGE->context, $pageparams);

1
lang/en/attendance.php

@ -293,6 +293,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.';

4
renderer.php

@ -806,7 +806,9 @@ 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. $configjs = get_config('attendance', 'studentscanmark');
if (!empty($configjs) && !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()));

5
sessions.php

@ -237,6 +237,11 @@ function construct_sessions_data_for_add($formdata) {
$duration = $sesendtime - $sesstarttime; $duration = $sesendtime - $sesstarttime;
$now = time(); $now = time();
$configcanmark = get_config('attendance', 'studentscanmark');
if (empty($configcanmark)) {
$formdata->studentscanmark = 0;
}
$sessions = array(); $sessions = array();
if (isset($formdata->addmultiply)) { if (isset($formdata->addmultiply)) {
$startdate = $sessiondate; $startdate = $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