Skip to content

Commit

Permalink
Improved the schedule based on conditions
Browse files Browse the repository at this point in the history
  • Loading branch information
prasanna-lmsace committed Sep 25, 2023
1 parent cc20294 commit ec6cf1d
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
24 changes: 23 additions & 1 deletion actions/notification/classes/notification.php
Original file line number Diff line number Diff line change
Expand Up @@ -499,6 +499,27 @@ public function create_schedule_forinstance($newenrolment=false) {
return true;
}

/**
* Verfiy the current instance configured any conditions.
*
* @return bool if configured any conditions return true otherwise returns flase.
*/
protected function verfiy_instance_contains_condition() {

if (!isset($this->instancedata->condition)) {
return false;
}

// Verify the instance contains any enabled conditions.
foreach ($this->instancedata->condition as $condition => $values) {
if ($values['status']) {
return true;
}
}

return false;
}

/**
* Create schedule for the user.
*
Expand All @@ -517,8 +538,9 @@ public function create_schedule_foruser($userid, $lastrun='', $notifycount=0, $e
$this->create_instance_data();
}

// Instance should be configured with any of conditions. Otherwise stop creating instance (PLS-637).
// Verify the user passed the instance condition.
if (!instances::create($this->notificationdata->instanceid)
if (!$this->verfiy_instance_contains_condition() || !instances::create($this->notificationdata->instanceid)
->find_user_completion_conditions($this->instancedata->condition, $this->instancedata, $userid, $isnewuser)) {
// Remove the user condition.
$this->disable_user_schedule($userid);
Expand Down
2 changes: 1 addition & 1 deletion version.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
defined('MOODLE_INTERNAL') || die();

$plugin->component = 'mod_pulse';
$plugin->version = 2023051830;
$plugin->version = 2023051831;
$plugin->requires = 2020061500; // Requires Moodle 3.90.
$plugin->release = 'v2.0';
$plugin->maturity = MATURITY_STABLE;
Expand Down

0 comments on commit ec6cf1d

Please sign in to comment.