From f833624090b5035d63bed1f747c41108c08e5f90 Mon Sep 17 00:00:00 2001 From: Dan Marsden Date: Thu, 11 Jul 2024 19:56:02 +1200 Subject: [PATCH] Fix #80 - add suffix to compeltion field names. --- mod_form.php | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/mod_form.php b/mod_form.php index f669f74..a15524d 100644 --- a/mod_form.php +++ b/mod_form.php @@ -171,14 +171,14 @@ public function definition() { * @return array List of added element names, or names of wrapping group elements. */ public function add_completion_rules() { - $mform = $this->_form; + $completionfieldname = 'completioncourse' . $this->get_suffix(); - $mform->addElement('advcheckbox', 'completioncourse', get_string('completioncourse', 'mod_subcourse'), + $mform->addElement('advcheckbox', $completionfieldname, get_string('completioncourse', 'mod_subcourse'), get_string('completioncourse_text', 'mod_subcourse')); - $mform->addHelpButton('completioncourse', 'completioncourse', 'mod_subcourse'); + $mform->addHelpButton($completionfieldname, 'completioncourse', 'mod_subcourse'); - return ['completioncourse']; + return [$completionfieldname]; } /** @@ -188,6 +188,7 @@ public function add_completion_rules() { * @return bool True if one or more rules is enabled, false if none are. */ public function completion_rule_enabled($data) { - return (!empty($data['completioncourse'])); + $completionfieldname = 'completioncourse' . $this->get_suffix(); + return (!empty($data[$completionfieldname])); } }