From cf93b540d6ff848dc3634b79de6abf033aee8188 Mon Sep 17 00:00:00 2001 From: Mark Nelson Date: Mon, 17 Dec 2018 16:28:16 +0800 Subject: [PATCH] Hide completion date option if not applicable (#160) --- element/date/classes/element.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/element/date/classes/element.php b/element/date/classes/element.php index e03e655..c91662e 100644 --- a/element/date/classes/element.php +++ b/element/date/classes/element.php @@ -68,12 +68,15 @@ class element extends \mod_customcert\element { * @param \mod_customcert\edit_element_form $mform the edit_form instance */ public function render_form_elements($mform) { - global $COURSE; + global $CFG, $COURSE; // Get the possible date options. $dateoptions = array(); $dateoptions[CUSTOMCERT_DATE_ISSUE] = get_string('issueddate', 'customcertelement_date'); - $dateoptions[CUSTOMCERT_DATE_COMPLETION] = get_string('completiondate', 'customcertelement_date'); + $completionenabled = $CFG->enablecompletion && $COURSE->enablecompletion; + if ($completionenabled) { + $dateoptions[CUSTOMCERT_DATE_COMPLETION] = get_string('completiondate', 'customcertelement_date'); + } $dateoptions[CUSTOMCERT_DATE_COURSE_START] = get_string('coursestartdate', 'customcertelement_date'); $dateoptions[CUSTOMCERT_DATE_COURSE_END] = get_string('courseenddate', 'customcertelement_date'); $dateoptions[CUSTOMCERT_DATE_COURSE_GRADE] = get_string('coursegradedate', 'customcertelement_date');