Hide completion date option if not applicable (#160)

This commit is contained in:
Mark Nelson 2018-12-17 16:28:16 +08:00
parent 97e44d3d1d
commit cf93b540d6

View file

@ -68,12 +68,15 @@ class element extends \mod_customcert\element {
* @param \mod_customcert\edit_element_form $mform the edit_form instance * @param \mod_customcert\edit_element_form $mform the edit_form instance
*/ */
public function render_form_elements($mform) { public function render_form_elements($mform) {
global $COURSE; global $CFG, $COURSE;
// Get the possible date options. // Get the possible date options.
$dateoptions = array(); $dateoptions = array();
$dateoptions[CUSTOMCERT_DATE_ISSUE] = get_string('issueddate', 'customcertelement_date'); $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_START] = get_string('coursestartdate', 'customcertelement_date');
$dateoptions[CUSTOMCERT_DATE_COURSE_END] = get_string('courseenddate', 'customcertelement_date'); $dateoptions[CUSTOMCERT_DATE_COURSE_END] = get_string('courseenddate', 'customcertelement_date');
$dateoptions[CUSTOMCERT_DATE_COURSE_GRADE] = get_string('coursegradedate', 'customcertelement_date'); $dateoptions[CUSTOMCERT_DATE_COURSE_GRADE] = get_string('coursegradedate', 'customcertelement_date');