Skip to content

Commit

Permalink
Added placeholder content type, completion status lang string
Browse files Browse the repository at this point in the history
  • Loading branch information
prasanna-lmsace committed Sep 26, 2023
1 parent 5265f62 commit 898150f
Show file tree
Hide file tree
Showing 9 changed files with 72 additions and 20 deletions.
5 changes: 3 additions & 2 deletions actions/notification/classes/actionform.php
Original file line number Diff line number Diff line change
Expand Up @@ -515,8 +515,9 @@ public function load_instance_form(&$mform, $forminstance) {

// Add 'content_type' element with the following options.
$contenttypeoptions = array(
notification::DYNAMIC_DESCRIPTION => get_string('description', 'pulseaction_notification'),
notification::DYNAMIC_CONTENT => get_string('content', 'pulseaction_notification'),
notification::DYNAMIC_PLACEHOLDER => get_string('dynamicplacholder', 'pulseaction_notification'),
notification::DYNAMIC_DESCRIPTION => get_string('dynamicdescription', 'pulseaction_notification'),
notification::DYNAMIC_CONTENT => get_string('dynamiccontent', 'pulseaction_notification'),
);
$dynamic2 = $mform->createElement('select', 'pulsenotification_contenttype',
get_string('contenttype', 'pulseaction_notification'), $contenttypeoptions);
Expand Down
15 changes: 13 additions & 2 deletions actions/notification/classes/notification.php
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,12 @@ class notification {
*/
const LENGTH_NOTLINKED = 3;

/**
* Represents the content of the dynamic module is only for placeholder.
* @var int
*/
const DYNAMIC_PLACEHOLDER = 0;

/**
* Represents the description of the dynamic module is included in the notification.
* @var int
Expand Down Expand Up @@ -771,16 +777,21 @@ public function build_notification_content(?stdClass $cm=null, $context=null, $o
* @param \context $context
* @param stdclass $cm
*
* @return void
* @return string
*/
public static function generate_dynamic_content($contenttype, $contentlength, $chapterid, $context, $cm) {

global $CFG, $DB;

// Include module libarary files.
require_once($CFG->dirroot.'/lib/modinfolib.php');
require_once($CFG->dirroot.'/mod/book/lib.php');
require_once($CFG->libdir.'/filelib.php');

// Content type is placholder, no need to include the content.
if ($contenttype == self::DYNAMIC_PLACEHOLDER) {
return '';
}

if ($contenttype == self::DYNAMIC_CONTENT) {

if ($cm->modname == 'book') {
Expand Down
6 changes: 4 additions & 2 deletions actions/notification/lang/en/pulseaction_notification.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,10 @@
$string['after'] = 'After';

$string['suppressnotification'] = 'Suppress notification';
$string['description'] = 'Description';
$string['content'] = 'Content';
$string['dynamicplacholder'] = 'Placeholder';
$string['dynamicdescription'] = 'Description';
$string['dynamiccontent'] = 'Content';

$string['teaser'] = 'Teaser';
$string['full_linked'] = 'Full linked';
$string['full_not_linked'] = 'Full not linked';
Expand Down
3 changes: 1 addition & 2 deletions actions/notification/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ function pulseaction_notification_output_fragment_preview_content($args) {
$user = (object) ($args['userid'] != null ? core_user::get_user($args['userid']) : current($users));

$dynamiccontent = '';
$mod = new stdclass;
if (isset($args['contentdynamic']) && !empty($args['contentdynamic'])) {

$module = get_coursemodule_from_id('', $args['contentdynamic']);
Expand All @@ -156,7 +157,6 @@ function pulseaction_notification_output_fragment_preview_content($args) {
$context,
$moddata
);
$mod = new stdclass;
// TODO: Inlcude the vars update from condition plugins.
if ($args['contentdynamic']) {
// Prepare the module data. based on dynamic content and includ the session data.
Expand All @@ -166,7 +166,6 @@ function pulseaction_notification_output_fragment_preview_content($args) {
$mod = current($modules[$modname]);
}
// Check the session condition are set for this notification. if its added then load the session data for placeholders.

$sessionincondition = in_array('session', (array) array_keys($formdata['condition']));
if ($sessionincondition && $formdata['condition']['session']['status']) {
$sessionconditiondata = (object) ['modules' => $formdata['condition']['session']['modules']];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,22 @@ Feature: Configuring the pulseaction_notification plugin on the "Automation temp

Background:
Given the following "categories" exist:
| name | category | idnumber |
| Cat 1 | 0 | CAT1 |
| name | category | idnumber |
| Cat 1 | 0 | CAT1 |
And the following "course" exist:
| fullname | shortname | category |
| Course 1 | C1 | 0 |
| fullname | shortname | category |
| Course 1 | C1 | 0 |
And the following "users" exist:
| username | firstname | lastname | email |
| student1 | student | User 1 | student1@test.com |
| username | firstname | lastname | email |
| student1 | student | User 1 | student1@test.com |
| teacher1 | teacher | User 1 | teacher1@test.com |
And the following "course enrolments" exist:
| user | course | role |
| student1 | C1 | student |
| user | course | role |
| student1 | C1 | student |
| teacher1 | C1 | teacher |
And the following "permission overrides" exist:
| capability | permission | role | contextlevel | reference |
| pulseaction/notification:receivenotification | Allow | teacher | System | |

@javascript
Scenario: Create notification template and instance
Expand Down Expand Up @@ -88,5 +93,37 @@ Feature: Configuring the pulseaction_notification plugin on the "Automation temp
And I switch to a second window
Then ".reportbuilder-report" "css_element" should exist
And the following should exist in the "reportbuilder-table" table:
| Full name | Subject | Status | Time created | Scheduled time |
| Full name | Subject | Status | Time created | Scheduled time |
| student User 1 | Welcome to learning portal Acceptance test site | Queued | ##now##%A, %d %B %Y, %I:%M %p## | ##+10 minutes##%A, %d %B %Y, %I:%M %p## |

@javascript
Scenario Outline: Pulse action Notification: Send notification for different role users
Given I log in as "admin"
And I navigate to automation templates
And I create pulse notification template "WELCOME MESSAGE" "WELCOMEMESSAGE_" to these values:
| Sender | Custom |
| Sender email | test@test.com |
| Recipients | <recipient> |
| Subject | Welcome to {Site_FullName} |
| Header content | Hi {User_firstname} {User_lastname}, <br> Welcome to learning portal of {Site_FullName} |
Then I should see "Automation templates"
And I should see "WELCOME MESSAGE" in the "pulse_automation_template" "table"
And I navigate to course "Course 1" automation instances
# Demo content.
And I create pulse notification instance "WELCOME MESSAGE" "COURSE_1" to these values:
| Recipients | Student |
And I should see "WELCOMEMESSAGE_COURSE_1" in the "pulse_automation_template" "table"
And I click on ".action-report" "css_element" in the "WELCOMEMESSAGE_COURSE_1" "table_row"
And I switch to a second window
Then ".reportbuilder-report" "css_element" should exist
And the following <studentshouldorshouldnot> exist in the "reportbuilder-table" table:
| Full name | Status |
| student User 1 | Queued |
And the following <teachershouldorshouldnot> exist in the "reportbuilder-table" table:
| Full name | Status |
| teacher User 1 | Queued |

Examples:
| recipient | studentshouldorshouldnot | teachershouldorshouldnot |
| Student | should | should not |
| Teacher | should not | should |
3 changes: 2 additions & 1 deletion conditions/session/classes/conditionform.php
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,8 @@ public static function get_acitivty_notifications($id) {
public static function get_session_time($notification, $instancedata) {
global $DB;

if (isset($instancedata->condition['session']) && $instancedata->condition['session']['status']) {
if (isset($instancedata->condition['session']) && $instancedata->condition['session']['status']
&& isset($instancedata->condition['session']['modules'])) {
$module = $instancedata->condition['session']['modules'];
$existingsignup = self::get_session_data($module, $notification->userid);
return !empty($existingsignup) ? current($existingsignup)->timestart : '';
Expand Down
1 change: 1 addition & 0 deletions lang/en/pulse.php
Original file line number Diff line number Diff line change
Expand Up @@ -370,3 +370,4 @@

// Pulse automation template profile navigation link.
$string['pulsetemplink'] = "Pulse Automation Template";
$string['completionenrolled'] = 'enrolled';
2 changes: 1 addition & 1 deletion lib/vars.php
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ public function completionstatus() {
} else if ($DB->record_exists('course_completions', ['course' => $this->course->id, 'userid' => $this->user->id])) {
return get_string('inprogress');
} else if (is_enrolled($coursecontext, $this->user->id)) {
return get_string('enroled');
return get_string('completionenrolled', 'pulse');
}
return '';
}
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 = 2023051832;
$plugin->version = 2023051833;
$plugin->requires = 2020061500; // Requires Moodle 3.90.
$plugin->release = 'v2.0';
$plugin->maturity = MATURITY_STABLE;
Expand Down

0 comments on commit 898150f

Please sign in to comment.