Skip to content

Commit

Permalink
Blog/Completion Conditions: Required posts/comments reverting to 1 #8…
Browse files Browse the repository at this point in the history
…13610
  • Loading branch information
Jason.Platts authored and sammarshallou committed Sep 9, 2024
1 parent a796664 commit 783c4bb
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions mod_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -221,24 +221,24 @@ public function add_completion_rules() {
$completionpostsenabledel,
' ',
get_string('completionposts', 'oublog'));
$completionpostsel = $this->get_suffixed_name('completionpostsenabled');
$completionpostsel = $this->get_suffixed_name('completionposts');
$group[] =& $mform->createElement('text', $completionpostsel, ' ', ['size' => 3]);
$mform->setType($completionpostsel, PARAM_INT);
$completionpostsgroupel = $this->get_suffixed_name('completionpostsenabled');
$completionpostsgroupel = $this->get_suffixed_name('completionpostsgroup');
$mform->addGroup($group, $completionpostsgroupel, get_string('completionpostsgroup', 'oublog'), [' '], false);
$mform->addHelpButton($completionpostsgroupel, 'completionpostsgroup', 'oublog');
$mform->disabledIf($completionpostsel, $completionpostsenabledel, 'notchecked');

$group = [];
$completioncommentsenabled = $this->get_suffixed_name('completionpostsenabled');
$completioncommentsenabled = $this->get_suffixed_name('completioncommentsenabled');
$group[] =& $mform->createElement('checkbox',
$completioncommentsenabled,
' ',
get_string('completioncomments', 'oublog'));
$completioncommentsel = $this->get_suffixed_name('completionpostsenabled');
$completioncommentsel = $this->get_suffixed_name('completioncomments');
$group[] =& $mform->createElement('text', $completioncommentsel, ' ', ['size' => 3]);
$mform->setType($completioncommentsel, PARAM_INT);
$completioncommentsgroupel = $this->get_suffixed_name('completionpostsenabled');
$completioncommentsgroupel = $this->get_suffixed_name('completioncommentsgroup');
$mform->addGroup($group,
$completioncommentsgroupel,
get_string('completioncommentsgroup', 'oublog'),
Expand All @@ -256,7 +256,7 @@ public function add_completion_rules() {
public function completion_rule_enabled($data) {
return ((!empty($data[$this->get_suffixed_name('completionpostsenabled')]) &&
$data[$this->get_suffixed_name('completionposts')]!=0)) ||
((!empty($data[$this->get_suffixed_name('completionposts')]) &&
((!empty($data[$this->get_suffixed_name('completioncommentsenabled')]) &&
$data[$this->get_suffixed_name('completioncomments')]!=0));
}

Expand All @@ -272,8 +272,8 @@ public function get_data() {
if (empty($data->{$this->get_suffixed_name('completionpostsenabled')}) || !$autocompletion) {
$data->{$this->get_suffixed_name('completionposts')} = 0;
}
if (empty($data->{$this->get_suffixed_name('completionpostsenabled')}) || !$autocompletion) {
$data->{$this->get_suffixed_name('completionpostsenabled')} = 0;
if (empty($data->{$this->get_suffixed_name('completioncommentsenabled')}) || !$autocompletion) {
$data->{$this->get_suffixed_name('completioncomments')} = 0;
}
}
// If maxvisibility is disabled by individual mode, ensure it's limited to course.
Expand Down Expand Up @@ -328,14 +328,14 @@ public function data_preprocessing(&$default_values) {
// We also make the default value (if you turn on the checkbox) for those
// numbers to be 1, this will not apply unless checkbox is ticked.
$completionpostsenabledel = $this->get_suffixed_name('completionpostsenabled');
$completionpostsel = $this->get_suffixed_name('completionpostsenabled');
$completionpostsel = $this->get_suffixed_name('completionposts');
$default_values[$completionpostsenabledel] =
!empty($default_values[$completionpostsel]) ? 1 : 0;
if (empty($default_values[$completionpostsel])) {
$default_values[$completionpostsel] = 1;
}
$completioncommentsenabled = $this->get_suffixed_name('completionpostsenabled');
$completioncommentsel = $this->get_suffixed_name('completionpostsenabled');
$completioncommentsenabled = $this->get_suffixed_name('completioncommentsenabled');
$completioncommentsel = $this->get_suffixed_name('completioncomments');
$default_values[$completioncommentsenabled] =
!empty($default_values[$completioncommentsel]) ? 1 : 0;
if (empty($default_values[$completioncommentsel])) {
Expand Down

0 comments on commit 783c4bb

Please sign in to comment.