Hide option to automark if standard log store disabled.
authorDan Marsden <dan@danmarsden.com>
Thu, 25 Jan 2018 22:16:20 +0000 (11:16 +1300)
committerDan Marsden <dan@danmarsden.com>
Thu, 25 Jan 2018 22:16:20 +0000 (11:16 +1300)
add_form.php
locallib.php
settings.php
update_form.php

index a1a6e97..b2b9c17 100644 (file)
@@ -186,10 +186,7 @@ class mod_attendance_add_form extends moodleform {
             $mform->addElement('checkbox', 'studentscanmark', '', get_string('studentscanmark', 'attendance'));
             $mform->addHelpButton('studentscanmark', 'studentscanmark', 'attendance');
 
-            $options = array(
-                ATTENDANCE_AUTOMARK_DISABLED => get_string('noautomark', 'attendance'),
-                ATTENDANCE_AUTOMARK_ALL => get_string('automarkall', 'attendance'),
-                ATTENDANCE_AUTOMARK_CLOSE => get_string('automarkclose', 'attendance'));
+            $options = attendance_get_automarkoptions();
 
             $mform->addElement('select', 'automark', get_string('automark', 'attendance'), $options);
             $mform->setType('automark', PARAM_INT);
index efa2405..4794dec 100644 (file)
@@ -869,4 +869,19 @@ function attendance_session_get_highest_status(mod_attendance_structure $att, $a
         return false;
     }
     return $highestavailablestatus->id;
+}
+
+/**
+ * Get available automark options.
+ *
+ * @return array
+ */
+function attendance_get_automarkoptions() {
+    $options = array();
+    $options[ATTENDANCE_AUTOMARK_DISABLED] = get_string('noautomark', 'attendance');
+    if (strpos(get_config('tool_log', 'enabled_stores'), 'logstore_standard') !== false) {
+        $options[ATTENDANCE_AUTOMARK_ALL] = get_string('automarkall', 'attendance');
+    }
+    $options[ATTENDANCE_AUTOMARK_CLOSE] = get_string('automarkclose', 'attendance');
+    return $options;
 }
\ No newline at end of file
index e169122..1c6a14e 100644 (file)
@@ -107,10 +107,7 @@ if ($ADMIN->fulltree) {
     $settings->add(new admin_setting_configcheckbox('attendance/studentscanmark_default',
         get_string('studentscanmark', 'attendance'), '', 0));
 
-    $options = array(
-        ATTENDANCE_AUTOMARK_DISABLED => get_string('noautomark', 'attendance'),
-        ATTENDANCE_AUTOMARK_ALL => get_string('automarkall', 'attendance'),
-        ATTENDANCE_AUTOMARK_CLOSE => get_string('automarkclose', 'attendance'));
+    $options = attendance_get_automarkoptions();
 
     $settings->add(new admin_setting_configselect('attendance/automark_default',
         get_string('automark', 'attendance'), '', 0, $options));
index bf5e58c..3e2ced0 100644 (file)
@@ -112,10 +112,7 @@ class mod_attendance_update_form extends moodleform {
             $mform->addElement('checkbox', 'studentscanmark', '', get_string('studentscanmark', 'attendance'));
             $mform->addHelpButton('studentscanmark', 'studentscanmark', 'attendance');
 
-            $options2 = array(
-                ATTENDANCE_AUTOMARK_DISABLED => get_string('noautomark', 'attendance'),
-                ATTENDANCE_AUTOMARK_ALL => get_string('automarkall', 'attendance'),
-                ATTENDANCE_AUTOMARK_CLOSE => get_string('automarkclose', 'attendance'));
+            $options2 = attendance_get_automarkoptions();
 
             $mform->addElement('select', 'automark', get_string('automark', 'attendance'), $options2);
             $mform->setType('automark', PARAM_INT);