Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 15 additions & 6 deletions mod_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -195,10 +195,12 @@ public function validation($data, $files) {
}

/**
* Add any completion rules for the form.
* @return string[]
* Returns the suffixed name for custom completion elements.
*
* @param string $fieldname
* @return string
*/
public function add_completion_rules() {
protected function get_suffixed_name(string $fieldname): string {
global $CFG;

// Changes for Moodle 4.3 - MDL-78516.
Expand All @@ -207,11 +209,18 @@ public function add_completion_rules() {
} else {
$suffix = $this->get_suffix();
}
return $fieldname . $suffix;
}

/**
* Add any completion rules for the form.
* @return string[]
*/
public function add_completion_rules() {
$mform =& $this->_form;
$mform->addElement('checkbox', 'completionsubmit' . $suffix, '',
$mform->addElement('checkbox', $this->get_suffixed_name('completionsubmit'), '',
get_string('completionsubmit', 'questionnaire'));
return ['completionsubmit' . $suffix];
return [$this->get_suffixed_name('completionsubmit')];
}

/**
Expand All @@ -220,7 +229,7 @@ public function add_completion_rules() {
* @return bool
*/
public function completion_rule_enabled($data) {
return !empty($data['completionsubmit']);
return !empty($data[$this->get_suffixed_name('completionsubmit')]);
}

}