From 6d53ae24a6a6181773655b2846fa9ef7acc69f65 Mon Sep 17 00:00:00 2001 From: Dan Marsden Date: Fri, 26 Jan 2018 11:16:20 +1300 Subject: [PATCH] Hide option to automark if standard log store disabled. --- add_form.php | 5 +---- locallib.php | 15 +++++++++++++++ settings.php | 5 +---- update_form.php | 5 +---- 4 files changed, 18 insertions(+), 12 deletions(-) diff --git a/add_form.php b/add_form.php index 08815a1..31255c6 100644 --- a/add_form.php +++ b/add_form.php @@ -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); diff --git a/locallib.php b/locallib.php index efa2405..4794dec 100644 --- a/locallib.php +++ b/locallib.php @@ -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 diff --git a/settings.php b/settings.php index e169122..1c6a14e 100644 --- a/settings.php +++ b/settings.php @@ -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)); diff --git a/update_form.php b/update_form.php index a2ab016..ed6e115 100644 --- a/update_form.php +++ b/update_form.php @@ -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);