Allow default subnet setting at activity level to be hidden.
authorDan Marsden <dan@danmarsden.com>
Tue, 20 Jun 2017 23:49:53 +0000 (11:49 +1200)
committerDan Marsden <dan@danmarsden.com>
Wed, 21 Jun 2017 02:18:18 +0000 (14:18 +1200)
add_form.php
lang/en/attendance.php
mod_form.php
settings.php

index 13819b2..fcc000f 100644 (file)
@@ -168,7 +168,12 @@ class mod_attendance_add_form extends moodleform {
             }
             $mgroup2 = array();
             $mgroup2[] = & $mform->createElement('text', 'subnet', get_string('requiresubnet', 'attendance'));
-            $mform->setDefault('subnet', $this->_customdata['att']->subnet);
+            if (empty(get_config('attendance', 'subnetactivitylevel'))) {
+                $mform->setDefault('subnet', get_config('attendance', 'subnet'));
+            } else {
+                $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);
index 050c289..7669c46 100644 (file)
@@ -367,6 +367,8 @@ $string['studentscanmarksessiontime_desc'] = 'If checked students can only recor
 $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['submitattendance'] = 'Submit attendance';
+$string['subnetactivitylevel'] = 'Allow subnet config at activity level';
+$string['subnetactivitylevel_desc'] = 'If enabled, teachers can override the default subnet at the activity level when creating an attendance. Otherwise the site default will be used when creating a session.';
 $string['subnetwrong'] = 'Attendance can only be recorded from certain locations, and this computer is not on the allowed list.';
 $string['summary'] = 'Summary';
 $string['tablerenamefailed'] = 'Rename of old attforblock table to attendance failed';
index 64bb8f6..6d6b78d 100644 (file)
@@ -59,12 +59,17 @@ class mod_attendance_mod_form extends moodleform_mod {
 
         $this->standard_coursemodule_elements(true);
 
-        $mform->addElement('header', 'security', get_string('extrarestrictions', 'attendance'));
         // IP address.
-        $mform->addElement('text', 'subnet', get_string('defaultsubnet', 'attendance'), array('size' => '164'));
-        $mform->setType('subnet', PARAM_TEXT);
-        $mform->addHelpButton('subnet', 'defaultsubnet', 'attendance');
-        $mform->setDefault('subnet', $attendanceconfig->subnet);
+        if (get_config('attendance', 'subnetactivitylevel')) {
+            $mform->addElement('header', 'security', get_string('extrarestrictions', 'attendance'));
+            $mform->addElement('text', 'subnet', get_string('defaultsubnet', 'attendance'), array('size' => '164'));
+            $mform->setType('subnet', PARAM_TEXT);
+            $mform->addHelpButton('subnet', 'defaultsubnet', 'attendance');
+            $mform->setDefault('subnet', $attendanceconfig->subnet);
+        } else {
+            $mform->addElement('hidden', 'subnet', '');
+            $mform->setType('subnet', PARAM_TEXT);
+        }
 
         $this->add_action_buttons();
     }
index 41131fd..120a32b 100644 (file)
@@ -57,6 +57,10 @@ if ($ADMIN->fulltree) {
         get_string('studentscanmarksessiontimeend', 'attendance'),
         get_string('studentscanmarksessiontimeend_desc', 'attendance'), '60', PARAM_INT));
 
+    $settings->add(new admin_setting_configcheckbox('attendance/subnetactivitylevel',
+        get_string('subnetactivitylevel', 'attendance'),
+        get_string('subnetactivitylevel_desc', 'attendance'), 1));
+
     $options = array(
         ATT_VIEW_ALL => get_string('all', 'attendance'),
         ATT_VIEW_ALLPAST => get_string('allpast', 'attendance'),