Skip to content

Commit

Permalink
Fix #80 - add suffix to compeltion field names.
Browse files Browse the repository at this point in the history
  • Loading branch information
danmarsden committed Jul 11, 2024
1 parent 298b45b commit 2a7a191
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions mod_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -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];
}

/**
Expand All @@ -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]));
}
}

0 comments on commit 2a7a191

Please sign in to comment.