Skip to content

Commit

Permalink
Instance override capability improved.
Browse files Browse the repository at this point in the history
- PLS-729
  • Loading branch information
raja-lmsace committed Apr 11, 2024
1 parent 70adc8b commit a33b233
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 12 deletions.
6 changes: 4 additions & 2 deletions actions/notification/classes/schedule.php
Original file line number Diff line number Diff line change
Expand Up @@ -177,8 +177,10 @@ public function send_scheduled_notification($userid=null) {
// Check the session condition are set for this notification. if its added then load the session data for placeholders.
$sessionin = in_array('session', (array) $this->instancedata->template->triggerconditions);
$sessionin = ($this->schedulerecord->con_isoverridden == 1) ? $this->schedulerecord->con_status : $sessionin;
if ($sessionin) {
$sessionconditiondata = (object) ['modules' => json_decode($this->schedulerecord->con_additional)->modules];
if ($sessionin && $this->schedulerecord->con_additional) {
$sessionaddional = json_decode($this->schedulerecord->con_additional);
$sessionmodules = !empty($sessionaddional->modules) ? $sessionaddional->modules : [];
$sessionconditiondata = (object) ['modules' => $sessionmodules];
$this->include_session_data($mod, $sessionconditiondata, $this->user->id);
}

Expand Down
2 changes: 1 addition & 1 deletion amd/build/automation.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/automation.min.js.map

Large diffs are not rendered by default.

15 changes: 13 additions & 2 deletions amd/src/automation.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,16 @@ define("mod_pulse/automation", ['jquery', 'core/modal_factory', 'core/templates'
var group = "checkboxgroupautomation";

if (document.querySelectorAll('input[type=checkbox].' + group)
=== null || document.querySelectorAll('[data-fieldtype="autocomplete"]') === null) {
=== null || document.querySelectorAll('[data-fieldtype="autocomplete"], [data-fieldtype="tags"]') === null) {
return true;
}

document.querySelectorAll('[data-fieldtype="autocomplete"]').forEach((element) => {

var capinput = document.querySelector('input[name="hasinstanceeditcapability"]');
var hasCapability = (capinput && capinput.value) || capinput === null;

// Observer the autocomplete.
document.querySelectorAll('[data-fieldtype="autocomplete"], [data-fieldtype="tags"]').forEach((element) => {

if (element === null) {
return true;
Expand All @@ -66,6 +71,12 @@ define("mod_pulse/automation", ['jquery', 'core/modal_factory', 'core/templates'
var observer = new MutationObserver(function(mutations) {
mutations.forEach((mutation) => {
var target = mutation.target;

// Not has capability to edit instance, then hide the autocomplete input text.
if (!hasCapability && target.querySelector('input[data-fieldtype="autocomplete"]')) {
target.querySelector('input[data-fieldtype="autocomplete"]').disabled = true;
}

var overrideElement = target.querySelector('.custom-switch');
if (overrideElement === null) {
return;
Expand Down
2 changes: 1 addition & 1 deletion conditions/activity/classes/conditionform.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ public function is_user_completed($instancedata, $userid, \completion_info $comp
}
return false;
}
return true;
return false;
}

/**
Expand Down
4 changes: 2 additions & 2 deletions conditions/cohort/classes/conditionform.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public function load_instance_form(&$mform, $forminstance) {
$mform->addElement('select', 'condition[cohort][status]', $completionstr, $this->get_options());
$mform->addHelpButton('condition[cohort][status]', 'condition', 'pulsecondition_cohort');

$cohorts = cohort_get_all_cohorts();
$cohorts = cohort_get_all_cohorts(0, 0);
$cohorts = $cohorts['cohorts'];

array_walk($cohorts, function(&$value) {
Expand Down Expand Up @@ -98,7 +98,7 @@ public function is_user_completed($instancedata, $userid, \completion_info $comp
}
}
// Cohorts are configured but not completed.
return !empty($cohorts) ? false : true;
return !empty($cohorts) ? true : false;
}

/**
Expand Down
6 changes: 4 additions & 2 deletions conditions/events/classes/conditionform.php
Original file line number Diff line number Diff line change
Expand Up @@ -400,8 +400,10 @@ public function update_email_customvars($userid, $instancedata, $schedulerecord)
$vars['context'] = ($context) ? $context->get_context_name(true) : get_string('other');

// Event_Contextlinked.
if ($url = $context->get_url()) {
$vars['contextlinked'] = \html_writer::link($url, $vars['context']);
if ($context instanceof \context) {
if ($url = $context->get_url()) {
$vars['contextlinked'] = \html_writer::link($url, $vars['context']);
}
}
}
// Event_Affecteduserfullname.
Expand Down
2 changes: 1 addition & 1 deletion conditions/session/classes/conditionform.php
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ public function is_user_completed($instancedata, $userid, \completion_info $comp
return ($existingsignup) ? true : false;
}
// Not configured any session modules.
return true;
return false;
}

/**
Expand Down

0 comments on commit a33b233

Please sign in to comment.