Skip to content

[v4.1.1] [Moodle 4.4.6] [PHP 8.1] course/defaultcompletion.php - Form validation error when checking and saving with custom completion rule "submit" #626

@danowar2k

Description

@danowar2k

Moodle 4.4 requires custom completion rules to have a suffix "_$modname".

When Moodle checks if automatic completion is enabled here: https://github.com/moodle/moodle/blob/b132ff1ed83dbe243909b8b121304ab20c0f069c/completion/classes/form/form_trait.php#L403

mod_questionnaire checks the given $data object only for the rule name without the suffix:

public function completion_rule_enabled($data) {
return !empty($data['completionsubmit']);
}

while earlier it did create the form elements with the suffix:

$mform =& $this->_form;
$mform->addElement('checkbox', 'completionsubmit' . $suffix, '',
get_string('completionsubmit', 'questionnaire'));
return ['completionsubmit' . $suffix];

This leads to the bug that the custom completion rule can't be activated and therefore not be used (at least as a default)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions