Skip to content

Commit

Permalink
Merge pull request #44 from mebis-lp/MBS-8801-Add-suffix-for-default-…
Browse files Browse the repository at this point in the history
…completion

MBS-8801: Add suffix for default completion
  • Loading branch information
PhMemmel authored Feb 16, 2024
2 parents 3a975bb + e1ceccf commit bed326a
Showing 1 changed file with 25 additions and 6 deletions.
31 changes: 25 additions & 6 deletions mod_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,10 @@ public function definition(): void {
* @return bool
*/
public function completion_rule_enabled($data): bool {
return (!empty($data['completioncreate']) || !empty($data['completioncomplete']));
return (
!empty($data['completioncreate' . $this->get_suffix()]) ||
!empty($data['completioncomplete' . $this->get_suffix()])
);
}

/**
Expand All @@ -82,22 +85,38 @@ public function completion_rule_enabled($data): bool {
public function add_completion_rules(): array {
$mform = $this->_form;

$completioncreate = 'completioncreate' . $this->get_suffix();
$completioncomplete = 'completioncomplete' . $this->get_suffix();

$mform->addElement(
'text',
'completioncreate',
$completioncreate,
get_string('completioncreate', 'kanban'),
['size' => 3]
);
$mform->setType('completioncreate', PARAM_INT);
$mform->setType($completioncreate, PARAM_INT);

$mform->addElement(
'text',
'completioncomplete',
$completioncomplete,
get_string('completioncomplete', 'kanban'),
['size' => 3]
);
$mform->setType('completioncomplete', PARAM_INT);
$mform->setType($completioncomplete, PARAM_INT);

return ([$completioncreate, $completioncomplete]);
}

return (['completioncreate', 'completioncomplete']);
/**
* Get the suffix to be added to the completion elements when creating them.
* This acts as a spare for compatibility with Moodle 4.1 and 4.2.
*
* @return string The suffix
*/
public function get_suffix(): string {
if (method_exists(get_parent_class($this), 'get_suffix')) {
return parent::get_suffix();
}
return '';
}
}

0 comments on commit bed326a

Please sign in to comment.