Browse Source

Modify subnet field to hopefully improve usability with teachers.

MOODLE_32_STABLE
Dan Marsden 8 years ago
parent
commit
8fdf17d30f
  1. 17
      add_form.php
  2. 7
      classes/structure.php
  3. 7
      lang/en/attendance.php
  4. 16
      locallib.php
  5. 2
      sessions.php
  6. 22
      update_form.php

17
add_form.php

@ -159,13 +159,20 @@ class mod_attendance_add_form extends moodleform {
if (isset($pluginconfig->automark_default)) {
$mform->setDefault('automark', $pluginconfig->automark_default);
}
$mform->addElement('text', 'subnet', get_string('requiresubnet', 'attendance'));
$mform->setType('subnet', PARAM_TEXT);
$mform->addHelpButton('subnet', 'requiresubnet', 'attendance');
$mform->disabledif('subnet', 'studentscanmark', 'notchecked');
$mgroup2 = array();
$mgroup2[] = & $mform->createElement('text', 'subnet', get_string('requiresubnet', 'attendance'));
$mform->setDefault('subnet', $this->_customdata['att']->subnet);
$mform->setAdvanced('subnet');
$mgroup2[] = & $mform->createElement('checkbox', 'usedefaultsubnet', get_string('usedefaultsubnet', 'attendance'));
$mform->setDefault('usedefaultsubnet', 1);
$mform->setType('subnet', PARAM_TEXT);
$mform->addGroup($mgroup2, 'subnetgrp', get_string('requiresubnet', 'attendance'), array(' '), false);
$mform->setAdvanced('subnetgrp');
$mform->addHelpButton('subnetgrp', 'requiresubnet', 'attendance');
$mform->disabledif('usedefaultsubnet', 'studentscanmark', 'notchecked');
$mform->disabledif('subnet', 'studentscanmark', 'notchecked');
$mform->disabledif('subnet', 'usedefaultsubnet', 'checked');
} else {
$mform->addElement('hidden', 'studentscanmark', '0');
$mform->settype('studentscanmark', PARAM_INT);

7
classes/structure.php

@ -500,7 +500,12 @@ class mod_attendance_structure {
!empty($formdata->studentscanmark)) {
$sess->studentscanmark = $formdata->studentscanmark;
$sess->studentpassword = $formdata->studentpassword;
$sess->subnet = $formdata->subnet;
if (!empty($formdata->usedefaultsubnet)) {
$sess->subnet = $this->subnet;
} else {
$sess->subnet = $formdata->subnet;
}
if (!empty($formdata->automark)) {
$sess->automark = $formdata->automark;
}

7
lang/en/attendance.php

@ -372,10 +372,10 @@ $string['repeaton'] = 'Repeat on';
$string['invalidsessionendtime'] = 'The end time must be greater than start time';
$string['deletedgroup'] = 'The group associated with this session has been deleted';
$string['extrarestrictions'] = 'Extra restrictions';
$string['requiresubnet'] = 'Students can only record own attendance from these computers.';
$string['requiresubnet'] = 'Require network address';
$string['subnetwrong'] = 'Attendance can only be recorded from certain locations, and this computer is not on the allowed list.';
$string['requiresubnet_help'] = 'Attendance recording may be restricted to particular subnets by specifying a comma-separated list of partial or full IP addresses.';
$string['defaultsubnet'] = 'Default subnet range';
$string['defaultsubnet'] = 'Default network address';
$string['defaultsubnet_help'] = 'Attendance recording may be restricted to particular subnets by specifying a comma-separated list of partial or full IP addresses. This is the default value used when creating new sessions.';
$string['defaultsettings'] = 'Default attendance settings';
$string['defaultsettings_help'] = 'These settings define the defaults for all new attendances';
@ -398,4 +398,5 @@ $string['studentmarking'] = 'Student recording';
$string['automarktask'] = 'Check for closed attendance sessions that require auto marking';
$string['autorecorded'] = 'system auto recorded';
$string['coursesummary'] = 'Course summary report';
$string['averageattendance'] = 'Average attendance';
$string['averageattendance'] = 'Average attendance';
$string['usedefaultsubnet'] = 'Use default';

16
locallib.php

@ -520,9 +520,10 @@ function attendance_exporttocsv($data, $filename) {
/**
* Get session data for form.
* @param stdClass $formdata moodleform - attendance form.
* $param mod_attendance_structure $att - used to get attendance level subnet.
* @return array.
*/
function attendance_construct_sessions_data_for_add($formdata) {
function attendance_construct_sessions_data_for_add($formdata, mod_attendance_structure $att) {
global $CFG;
$sesstarttime = $formdata->sestime['starthour'] * HOURSECS + $formdata->sestime['startminute'] * MINSECS;
@ -570,7 +571,11 @@ function attendance_construct_sessions_data_for_add($formdata) {
$sess->timemodified = $now;
if (isset($formdata->studentscanmark)) { // Students will be able to mark their own attendance.
$sess->studentscanmark = 1;
$sess->subnet = $formdata->subnet;
if (!empty($formdata->usedefaultsubnet)) {
$sess->subnet = $att->subnet;
} else {
$sess->subnet = $formdata->subnet;
}
$sess->automark = $formdata->automark;
$sess->automarkcompleted = 0;
if (!empty($formdata->randompassword)) {
@ -616,7 +621,12 @@ function attendance_construct_sessions_data_for_add($formdata) {
} else {
$sess->studentpassword = $formdata->studentpassword;
}
$sess->subnet = $formdata->subnet;
if (!empty($formdata->usedefaultsubnet)) {
$sess->subnet = $att->subnet;
} else {
$sess->subnet = $formdata->subnet;
}
if (!empty($formdata->automark)) {
$sess->automark = $formdata->automark;
}

2
sessions.php

@ -73,7 +73,7 @@ switch ($att->pageparams->action) {
}
if ($formdata = $mform->get_data()) {
$sessions = attendance_construct_sessions_data_for_add($formdata);
$sessions = attendance_construct_sessions_data_for_add($formdata, $att);
$att->add_sessions($sessions);
if (count($sessions) == 1) {
$message = get_string('sessiongenerated', 'attendance');

22
update_form.php

@ -49,6 +49,7 @@ class mod_attendance_update_form extends moodleform {
if (!$sess = $DB->get_record('attendance_sessions', array('id' => $sessionid) )) {
error('No such session in this course');
}
$attendancesubnet = $DB->get_field('attendance', 'subnet', array('id' => $sess->attendanceid));
$defopts = array('maxfiles' => EDITOR_UNLIMITED_FILES, 'noclean' => true, 'context' => $modcontext);
$sess = file_prepare_standard_editor($sess, 'description', $defopts, $modcontext, 'mod_attendance', 'session', $sess->id);
@ -70,6 +71,11 @@ class mod_attendance_update_form extends moodleform {
'subnet' => $sess->subnet,
'automark' => $sess->automark,
'automarkcompleted' => 0);
if ($sess->subnet == $attendancesubnet) {
$data['usedefaultsubnet'] = 1;
} else {
$data['usedefaultsubnet'] = 0;
}
$mform->addElement('header', 'general', get_string('changesession', 'attendance'));
@ -115,11 +121,21 @@ class mod_attendance_update_form extends moodleform {
$mform->addHelpButton('studentpassword', 'passwordgrp', 'attendance');
$mform->disabledif('studentpassword', 'studentscanmark', 'notchecked');
$mform->addElement('text', 'subnet', get_string('requiresubnet', 'attendance'));
$mgroup2 = array();
$mgroup2[] = & $mform->createElement('text', 'subnet', get_string('requiresubnet', 'attendance'));
$mform->setDefault('subnet', $this->_customdata['att']->subnet);
$mgroup2[] = & $mform->createElement('checkbox', 'usedefaultsubnet', get_string('usedefaultsubnet', 'attendance'));
$mform->setDefault('usedefaultsubnet', 1);
$mform->setType('subnet', PARAM_TEXT);
$mform->addHelpButton('subnet', 'requiresubnet', 'attendance');
$mform->addGroup($mgroup2, 'subnetgrp', get_string('requiresubnet', 'attendance'), array(' '), false);
$mform->setAdvanced('subnetgrp');
$mform->addHelpButton('subnetgrp', 'requiresubnet', 'attendance');
$mform->disabledif('usedefaultsubnet', 'studentscanmark', 'notchecked');
$mform->disabledif('subnet', 'studentscanmark', 'notchecked');
$mform->setAdvanced('subnet');
$mform->disabledif('subnet', 'usedefaultsubnet', 'checked');
$mform->addElement('hidden', 'automarkcompleted', '0');
$mform->settype('automarkcompleted', PARAM_INT);

Loading…
Cancel
Save