Skip to content

Commit

Permalink
Event condition and placeholders improved.
Browse files Browse the repository at this point in the history
- PLS-731
- PLS-735
  • Loading branch information
raja-lmsace committed Apr 12, 2024
1 parent b9173ff commit 030b539
Show file tree
Hide file tree
Showing 10 changed files with 148 additions and 14 deletions.
4 changes: 4 additions & 0 deletions actions/notification/classes/actionform.php
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,10 @@ public function delete_template_action($templateid) {
*/
public function trigger_action($instancedata, $userid, $expectedtime=null, $newuser=false) {

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

$notification = notification::instance($instancedata->pulsenotification_id);
$notificationinstance = (object) helper::filter_record_byprefix($instancedata, $this->config_shortname());

Expand Down
2 changes: 1 addition & 1 deletion amd/build/module.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion amd/build/module.min.js.map

Large diffs are not rendered by default.

5 changes: 2 additions & 3 deletions amd/src/module.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,16 +145,15 @@ define(['core_editor/events'], function() {
return false;
}
iframes.forEach((iframe) => {
iframe.contentDocument.addEventListener('click', function(e) {
var currentFrame = e.target;
iframe.contentDocument.addEventListener('click', function() {
iframes.forEach((frame) => {
var frameElem = frame.contentDocument.querySelector(".insertatcaretactive");
if (frameElem !== null) {
frameElem.classList.remove("insertatcaretactive");
}
});

var contentBody = currentFrame.querySelector('body');
var contentBody = iframe.contentDocument.querySelector('body');
if (contentBody !== null) {
contentBody.classList.add("insertatcaretactive");
}
Expand Down
24 changes: 22 additions & 2 deletions classes/automation/condition_base.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,10 +120,11 @@ public function get_options() {
* @param int $instanceid The instance ID.
* @param int $userid The user ID.
* @param mixed $expectedtime The expected time for triggering.
* @param bool $newuser Is the trigger instance for new user.
*/
public function trigger_instance(int $instanceid, int $userid, $expectedtime=null) {
public function trigger_instance(int $instanceid, int $userid, $expectedtime=null, $newuser=false) {

\mod_pulse\automation\instances::create($instanceid)->trigger_action($userid, $expectedtime);
\mod_pulse\automation\instances::create($instanceid)->trigger_action($userid, $expectedtime, $newuser);
}

/**
Expand All @@ -138,6 +139,15 @@ public function is_user_completed($notification, int $userid) {
return true;
}

/**
* Status of the condition addon works based on the user enrolment.
*
* @return bool
*/
public function is_user_enrolment_based() {
return true;
}

/**
* Processes the saving of an instance.
*
Expand Down Expand Up @@ -283,4 +293,14 @@ public function schedule_override_join() {
*/
public function backup_define_structure(&$instances) {
}

/**
* Delete the records of condition for the custom instance.
*
* @param int $instanceid
* @return void
*/
public function delete_condition_instance(int $instanceid) {
return false;
}
}
Loading

0 comments on commit 030b539

Please sign in to comment.