');
-
- $conditionplugins = new \mod_pulse\plugininfo\pulsecondition();
- $plugins = $conditionplugins->get_plugins_base();
-
- $option = [];
- foreach ($plugins as $name => $plugin) {
- $plugin->include_condition($option);
- }
-
- $condition = $mform->addElement('autocomplete', 'triggerconditions', get_string('conditiontrigger', 'pulse'), $option);
- $condition->setMultiple(true);
- $mform->addHelpButton('triggerconditions', 'conditiontrigger', 'pulse');
-
- // Operator element.
- $operators = [
- \mod_pulse\automation\action_base::OPERATOR_ALL => get_string('all', 'pulse'),
- \mod_pulse\automation\action_base::OPERATOR_ANY => get_string('any', 'pulse'),
- ];
- $mform->addElement('select', 'triggeroperator', get_string('triggeroperator', 'pulse'), $operators);
- $mform->addHelpButton('triggeroperator', 'triggeroperator', 'pulse');
-
- $mform->addElement('html', html_writer::end_div()); // E.o of actions triggere tab.
- }
-
- /**
- * Include the manage instance table to the templates form.
- *
- * @param object $manageinstancetable Manage instance table
- * @return void
- */
- public function load_template_manageinstance($manageinstancetable) {
- global $OUTPUT, $PAGE, $DB, $CFG, $COURSE;
-
- require_once($CFG->dirroot. '/mod/pulse/automation/automationlib.php');
-
- // Get the template id.
- $templateid = optional_param('id', 0, PARAM_INT) ?? 0;
-
- echo html_writer::start_div('tab-pane fade', ['id' => 'manage-instance-tab']);
-
- echo helper::bulkaction_buttons($templateid);
-
- echo html_writer::start_div('manage-instance', ['id' => 'manage-instance-table']);
-
- // Instance management table added in the template form.
- $manageinstancetable->out(20, true);
-
- // E.o of instance manage table.
- echo html_writer::end_div();
-
- // Bulk reaction buttons.
- echo helper::bulkreaction_buttons();
-
- // E.o of manage instance tab.
- echo html_writer::end_div();
-
- $params = ['templateid' => $templateid];
- // Bulk actions.
- $PAGE->requires->js_call_amd('mod_pulse/bulkaction', 'init', $params);
-
- }
-
- /**
- * Load template actions.
- *
- * @return void
- */
- protected function load_template_actions() {
-
- $mform =& $this->_form;
- $actionplugins = new \mod_pulse\plugininfo\pulseaction();
- $plugins = $actionplugins->get_plugins_base();
-
- foreach ($plugins as $name => $plugin) {
- // Define the form elements inside the definition function.
- $mform->addElement('html', '
');
- $mform->addElement('html', '
'.get_string('pluginname', 'pulseaction_'.$name).'
');
- // Load the instance elements for this action.
- $plugin->load_global_form($mform, $this);
- $mform->addElement('html', html_writer::end_div()); // E.o of actions triggere tab.
- }
- }
-
- /**
- * Process the pulse module data before set the default.
- *
- * @param mixed $defaultvalues default values
- * @return void
- */
- public function data_preprocessing(&$defaultvalues) {
- $context = \context_system::instance();
- helper::prepare_editor_draftfiles($defaultvalues, $context);
- }
-
- /**
- * Get custom data associated with a specific key.
- *
- * @param string $key The key to retrieve custom data.
- * @return mixed The custom data if found, otherwise an empty string.
- */
- public function get_customdata($key) {
- return $this->_customdata[$key] ?? '';
- }
-
- /**
- * Load in existing data as form defaults. Usually new entry defaults are stored directly in
- * form definition (new entry form); this function is used to load in data where values
- * already exist and data is being edited (edit entry form).
- *
- * note: $slashed param removed
- *
- * @param stdClass|array $defaultvalues object or array of default values
- */
- public function set_data($defaultvalues) {
-
- $this->data_preprocessing($defaultvalues); // Include to store the files.
- if (is_object($defaultvalues)) {
- $defaultvalues = (array)$defaultvalues;
- }
- $this->_form->setDefaults($defaultvalues);
- }
-
- /**
- * Get list of all course and user context roles.
- *
- * @return void
- */
- public function course_roles() {
- global $DB;
-
- list($insql, $inparam) = $DB->get_in_or_equal([CONTEXT_COURSE, CONTEXT_USER]);
- $sql = "SELECT lvl.id, lvl.roleid, rle.name, rle.shortname FROM {role_context_levels} lvl
- JOIN {role} rle ON rle.id = lvl.roleid
- WHERE contextlevel $insql ";
-
- $result = $DB->get_records_sql($sql, $inparam);
- $result = role_fix_names($result);
- $roles = [];
- // Generate options list for select mform element.
- foreach ($result as $key => $role) {
- $roles[$role->roleid] = $role->localname; // Role fullname.
- }
- return $roles;
- }
-}
diff --git a/classes/helper.php b/classes/helper.php
index 170d0d5..04b55d7 100644
--- a/classes/helper.php
+++ b/classes/helper.php
@@ -39,9 +39,6 @@
*/
class helper {
-
-
-
/**
* Replace email template placeholders with dynamic datas.
*
@@ -51,18 +48,17 @@ class helper {
* @param mixed $user User data object.
* @param mixed $mod Pulse module data object.
* @param mixed $sender Sender user data object. - sender is the first enrolled teacher in the course of module.
- * @param array $conditionvars Condition variables.
* @return array Updated subject and message body content.
*/
- public static function update_emailvars($templatetext, $subject, $course, $user, $mod, $sender, $conditionvars=[]) {
- global $DB, $CFG, $USER;
+ public static function update_emailvars($templatetext, $subject, $course, $user, $mod, $sender) {
+ global $DB, $CFG;
// Include placholders handler and user profile library.
require_once($CFG->dirroot.'/mod/pulse/lib/vars.php');
require_once($CFG->dirroot.'/user/profile/lib.php');
// Load user profile field data.
- $newuser = (object) ['id' => !empty($user->id) ? $user->id : $USER->id];
+ $newuser = (object) ['id' => $user->id];
profile_load_data($newuser);
// Make the profile custom field data to separate element of the user object.
$newuserkeys = array_map(function($value) {
@@ -91,27 +87,7 @@ public static function update_emailvars($templatetext, $subject, $course, $user,
$course->category = is_number($course->category)
? core_course_category::get($course->category)->get_formatted_name() : $course->category;
- if (!empty($mod->id)) {
- if ($DB->record_exists('course_modules', ['id' => $mod->id])) {
- $module = $DB->get_record('course_modules', ['id' => $mod->id]);
- $name = $DB->get_field('modules', 'name', ['id' => $module->module]);
- $mod->url = new moodle_url("/mod/$name/view.php", ['id' => $mod->id]);
-
- if (\mod_pulse\automation\helper::create()->timemanagement_installed()) {
- $userenrolments = ltool_timemanagement_get_course_user_enrollment($course->id, $user->id);
- if (!empty($userenrolments)) {
- $record = $DB->get_record('ltool_timemanagement_modules', ['cmid' => $mod->id ?? 0]);
- if ($record) {
- $dates = ltool_timemanagement_cal_coursemodule_managedates($record, $userenrolments[0]['timestart']);
- $duedate = isset($dates['duedate']) ? userdate($dates['duedate']) : '';
- }
- }
- }
- $mod->duedate = $duedate ?? '';
- }
- }
-
- $vars = new pulse_email_vars($user, $course, $sender, $mod, $conditionvars);
+ $vars = new pulse_email_vars($user, $course, $sender, $mod);
foreach ($amethods as $varscat => $placeholders) {
foreach ($placeholders as $funcname) {
diff --git a/classes/plugininfo/pulseaction.php b/classes/plugininfo/pulseaction.php
deleted file mode 100644
index cfcd555..0000000
--- a/classes/plugininfo/pulseaction.php
+++ /dev/null
@@ -1,158 +0,0 @@
-.
-
-/**
- * Module pulse 2.0 - Plugin information for the pulse action class.
- *
- * @package mod_pulse
- * @copyright 2023, bdecent gmbh bdecent.de
- * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
- */
-
-namespace mod_pulse\plugininfo;
-
-use core\plugininfo\base, part_of_admin_tree, admin_settingpage;
-use moodle_exception;
-
-/**
- * Pulse action class extends base class providing access to the information about a pulse 2.0 plugin.
- */
-class pulseaction extends base {
-
-
- /**
- * Returns the information about plugin availability
- *
- * True means that the plugin is enabled. False means that the plugin is
- * disabled. Null means that the information is not available, or the
- * plugin does not support configurable availability or the availability
- * can not be changed.
- *
- * @return null|bool
- */
- public function is_enabled() {
- return true;
- }
-
- /**
- * Should there be a way to uninstall the plugin via the administration UI.
- *
- * By default uninstallation is not allowed, plugin developers must enable it explicitly!
- *
- * @return bool
- */
- public function is_uninstall_allowed() {
- return true;
- }
-
- /**
- * Loads plugin setting into the settings tree.
- *
- * @param \part_of_admin_tree $adminroot
- * @param string $parentnodename
- * @param bool $hassiteconfig whether the current user has moodle/site:config capability
- */
- public function load_settings(part_of_admin_tree $adminroot, $parentnodename, $hassiteconfig) {
-
- $ADMIN = $adminroot; // May be used in settings.php.
- if (!$this->is_installed_and_upgraded()) {
- return;
- }
-
- if (!$hassiteconfig || !file_exists($this->full_path('settings.php'))) {
- return;
- }
-
- $section = $this->get_settings_section_name();
- $page = new admin_settingpage($section, $this->displayname, 'moodle/site:config', $this->is_enabled() === false);
- include($this->full_path('settings.php')); // This may also set $settings to null.
-
- if ($page) {
- $ADMIN->add($parentnodename, $page);
- }
- }
-
- /**
- * Get a sub plugins in the ace tools plugin.
- *
- * @return array $subplugins.
- */
- public function get_plugins_list() {
- $actionplugins = \core_component::get_plugin_list('pulseaction');
- return $actionplugins;
- }
-
- /**
- * Get the list of action plugins woithj its base class.
- */
- public function get_plugins_base() {
- $plugins = $this->get_plugins_list();
-
- if (!empty($plugins)) {
- foreach ($plugins as $componentname => $pluginpath) {
- $instance = $this->get_plugin($componentname);
- $actions[$componentname] = $instance;
- }
- }
-
- return $actions ?? [];
- }
-
- /**
- * Get the action component actionform instance.
- *
- * @param string $componentname
- * @return \actionform
- */
- public function get_plugin($componentname) {
-
- $classname = "pulseaction_$componentname\actionform";
- if (!class_exists($classname)) {
- throw new moodle_exception('actioncomponentmissing', 'pulse');
- }
- $instance = new $classname();
- $instance->set_component($componentname);
-
- return $instance;
- }
-
- /**
- * Instance.
- *
- * @return \pulseaction
- */
- public static function instance() {
- static $instance;
- return $instance ?: new self();
- }
-
- /**
- * Get list of action plugins base class instance.
- *
- * @return stdclass
- */
- public static function get_list() {
- static $actionplugins = null;
-
- if (!$actionplugins) {
- $actionplugins = new self();
- }
-
- $plugins = $actionplugins->get_plugins_base();
- return $plugins;
- }
-
-}
diff --git a/classes/plugininfo/pulsecondition.php b/classes/plugininfo/pulsecondition.php
deleted file mode 100644
index 22573ac..0000000
--- a/classes/plugininfo/pulsecondition.php
+++ /dev/null
@@ -1,172 +0,0 @@
-.
-
-/**
- * Module pulse 2.0 - Plugin information for the pulse condition class.
- *
- * @package mod_pulse
- * @copyright 2023, bdecent gmbh bdecent.de
- * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
- */
-
-namespace mod_pulse\plugininfo;
-
-use core\plugininfo\base, part_of_admin_tree, admin_settingpage;
-
-/**
- * Pulse condition class extends base class providing access to the information about a pulse 2.0 plugin.
- */
-class pulsecondition extends base {
-
- /**
- * Returns the information about plugin availability
- *
- * True means that the plugin is enabled. False means that the plugin is
- * disabled. Null means that the information is not available, or the
- * plugin does not support configurable availability or the availability
- * can not be changed.
- *
- * @return null|bool
- */
- public function is_enabled() {
- return true;
- }
-
- /**
- * Should there be a way to uninstall the plugin via the administration UI.
- *
- * By default uninstallation is not allowed, plugin developers must enable it explicitly!
- *
- * @return bool
- */
- public function is_uninstall_allowed() {
- return true;
- }
-
- /**
- * Loads plugin setting into the settings tree.
- *
- * @param \part_of_admin_tree $adminroot
- * @param string $parentnodename
- * @param bool $hassiteconfig whether the current user has moodle/site:config capability
- */
- public function load_settings(part_of_admin_tree $adminroot, $parentnodename, $hassiteconfig) {
-
- $ADMIN = $adminroot; // May be used in settings.php.
- if (!$this->is_installed_and_upgraded()) {
- return;
- }
-
- if (!$hassiteconfig || !file_exists($this->full_path('settings.php'))) {
- return;
- }
-
- $section = $this->get_settings_section_name();
- $page = new admin_settingpage($section, $this->displayname, 'moodle/site:config', $this->is_enabled() === false);
- include($this->full_path('settings.php')); // This may also set $settings to null.
-
- if ($page) {
- $ADMIN->add($parentnodename, $page);
- }
- }
-
- /**
- * Get a sub plugins in the ace tools plugin.
- *
- * @return array $subplugins.
- */
- public function get_plugins_list() {
- $conditionplugins = \core_component::get_plugin_list('pulsecondition');
- return $conditionplugins;
- }
-
- /**
- * Get the list of condition plugins with its base class instance.
- */
- public function get_plugins_base() {
- $plugins = $this->get_plugins_list();
-
- if (!empty($plugins)) {
- foreach ($plugins as $componentname => $pluginpath) {
- $instance = $this->get_plugin($componentname);
- $conditions[$componentname] = $instance;
- }
- }
-
- return $conditions ?? [];
- }
-
- /**
- * Get the condtion component actionform instance.
- *
- * @param string $componentname
- * @return \conditionform
- */
- public function get_plugin($componentname) {
-
- $classname = "pulsecondition_$componentname\conditionform";
- if (!class_exists($classname)) {
- throw new \moodle_exception('actioncomponentmissing', 'pulse');
- }
- $instance = new $classname();
- $instance->set_component($componentname);
-
- return $instance;
- }
-
- /**
- * Instance.
- *
- * @return \pulsecondition
- */
- public static function instance() {
- static $instance;
- return $instance ?: new self();
- }
-
- /**
- * Get list of action plugins base class instance.
- *
- * @return stdclass
- */
- public static function get_list() {
- static $conditionplugins = null;
-
- if (!$conditionplugins) {
- $conditionplugins = new self();
- }
-
- $plugins = $conditionplugins->get_plugins_base();
- return $plugins;
- }
-
- /**
- * Delete the conditions instance overrides.
- *
- * @param int $instanceid
- * @return void
- */
- public static function delete_condition_instance_overrides(int $instanceid) {
- global $DB;
-
- if ($DB->delete_records('pulse_condition_overrides', ['instanceid' => $instanceid])) {
- return true;
- }
-
- return false;
- }
-
-}
diff --git a/classes/table/auto_instances.php b/classes/table/auto_instances.php
deleted file mode 100644
index 08b8b8b..0000000
--- a/classes/table/auto_instances.php
+++ /dev/null
@@ -1,282 +0,0 @@
-.
-
-/**
- * Automation instance - Table list for the automation instance in the pulse 2.0 plugin.
- *
- * @package mod_pulse
- * @copyright 2023, bdecent gmbh bdecent.de
- * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
- */
-
-namespace mod_pulse\table;
-
-defined('MOODLE_INTERNAL') || die();
-
-require_once($CFG->dirroot.'/lib/tablelib.php');
-
-use table_sql;
-use moodle_url;
-use html_writer;
-use core_reportbuilder\manager;
-use core_reportbuilder\permission;
-use mod_pulse\automation\instances;
-
-/**
- * Automation instances table handler.
- */
-class auto_instances extends table_sql {
-
- /**
- * Setup and Render the menus table.
- *
- * @param int $pagesize Size of page for paginated displayed table.
- * @param bool $useinitialsbar Whether to use the initials bar which will only be used if there is a fullname column defined.
- * @param string $downloadhelpbutton
- */
- public function out($pagesize, $useinitialsbar, $downloadhelpbutton = '') {
-
- // Define table headers and columns.
- $columns = ['title', 'idnumber', 'actions'];
- $headers = ["", "idnumber", ""];
-
- $this->define_columns($columns);
- $this->define_headers($headers);
-
- // Remove sorting for some fields.
- $this->sortable(true, 'sortorder', SORT_ASC);
-
- $this->no_sorting('title');
- $this->no_sorting('actions');
-
- $this->set_attribute('id', 'pulse_automation_template');
-
- $this->guess_base_url();
-
- parent::out($pagesize, $useinitialsbar, $downloadhelpbutton);
- }
-
- /**
- * Guess the base url for the automation table.
- */
- public function guess_base_url(): void {
- global $PAGE;
- $this->baseurl = $PAGE->url;
- }
-
- /**
- * Set the sql query to fetch smart menus list.
- *
- * @param int $pagesize Size of page for paginated displayed table.
- * @param bool $useinitialsbar Whether to use the initials bar which will only be used if there is a fullname column defined.
- * @return void
- */
- public function query_db($pagesize, $useinitialsbar = true) {
- global $PAGE, $DB;
-
- $courseid = $PAGE->course->id;
- // Fetch all automation instances in this course .
- $params = [];
- $condition = 'courseid=:courseid ';
- $params += ['courseid' => $courseid];
-
- // Filter the particular template instances in this course.
- if ($this->filterset->has_filter('templateid')) {
-
- $values = $this->filterset->get_filter('templateid')->get_filter_values();
- $templateid = isset($values[0]) ? current($values) : '';
- $condition .= 'AND templateid=:templateid';
- $params += ['templateid' => $templateid];
- }
-
- $this->set_sql(
- "ai.*, ati.*, ai.id as id, ati.insreference as idnumber",
- '{pulse_autoinstances} ai
- JOIN {pulse_autotemplates_ins} ati ON ati.instanceid=ai.id
- JOIN {pulse_autotemplates} pat ON pat.id=ai.templateid',
- $condition, $params
- );
-
- parent::query_db($pagesize, $useinitialsbar);
-
- $rawdata = $this->rawdata;
- // Collects all the templates id in a array.
- $templates = array_column($rawdata, 'templateid');
- // Fetch the templates data with its actions for all the instances.
- $templatedata = \mod_pulse\automation\templates::get_templates_record($templates);
- // Merge each instances with its templatedata, it will assign the template data for non overridden fields for instance.
- foreach ($rawdata as $key => $data) {
- $templateid = $data->templateid;
- if (isset($templatedata[$templateid])) {
- // Merge the override instance data with its related template data.
- $this->rawdata[$key] = \mod_pulse\automation\helper::merge_instance_overrides($data, $templatedata[$templateid]);
- }
- }
- // Filter the data.
- $this->rawdata = array_filter($this->rawdata);
-
- }
-
- /**
- * Show the menu title in the list, render the description based on the show description value "Above, below and help".
- * Default help_icon method only works with string identifiers, rendered the help icon from template directly.
- *
- * @param object $row
- * @return void
- */
- public function col_title($row) {
- global $OUTPUT;
-
- // TODO: Editable.
- $editable = $row->status != instances::STATUS_ORPHANED;
- $title = new \core\output\inplace_editable(
- 'mod_pulse', 'instancetitle', $row->id, $editable, format_string($row->title),
- $row->title, 'Edit template title', 'New value for ' . format_string($row->title)
- );
-
- $actions = \mod_pulse\plugininfo\pulseaction::instance()->get_plugins_base();
- array_walk($actions, function(&$value) {
- $classname = 'pulseaction_'.$value->get_component();
- $result['badge'] = html_writer::tag('span', get_string('formtab', 'pulseaction_'.$value->get_component()),
- ['class' => 'badge badge-primary '.$classname]);
- $result['icon'] = html_writer::span($value->get_action_icon(), 'action', ['class' => 'action-icon '. $classname]);
- $value = $result;
- });
-
- $collapseicon = ($row->notes) ? html_writer::tag('span', '
' , [
- 'data-target' => 'notes-collapse',
- 'data-notes' => html_writer::tag('p', format_string($row->notes)),
- 'data-collapse' => 1,
- 'data-instance' => $row->id,
- ]) : '';
-
- return $collapseicon . implode(' ', array_column($actions, 'icon')) . $OUTPUT->render($title) .
- implode(' ', array_column($actions, 'badge'));
- }
-
- /**
- * Generates the HTML content for the instance reference column in a row.
- *
- * @param object $row The row containing the data.
- * @return string The HTML content for the reference column.
- */
- public function col_idnumber($row) {
- $title = html_writer::tag('h5', format_string($row->reference . ($row->idnumber ?? '')),
- ['class' => 'template-reference']);
- return $title;
- }
-
- /**
- * Generates the actions links for the instance.
- *
- * @param object $row The row containing the data.
- * @return string
- */
- public function col_actions($row) {
- global $OUTPUT;
-
- $baseurl = new \moodle_url('/mod/pulse/automation/instances/edit.php', [
- 'instanceid' => $row->instanceid,
- 'sesskey' => \sesskey(),
- ]);
-
- $listurl = new \moodle_url('/mod/pulse/automation/instances/list.php', [
- 'instanceid' => $row->instanceid,
- 'sesskey' => \sesskey(),
- ]);
-
- $actions = [];
-
- if ($row->status == \mod_pulse\automation\templates::STATUS_ORPHANED) {
-
- $actions[] = html_writer::tag('span', get_string('templateorphaned', 'mod_pulse'), ['class' => 'badge badge-danger']);
-
- } else {
- // Edit.
- $actions[] = [
- 'url' => $baseurl,
- 'icon' => new \pix_icon('t/edit', \get_string('edit')),
- 'attributes' => ['class' => 'action-edit'],
- ];
-
- // Make the instance duplicate.
- $actions[] = [
- 'url' => new \moodle_url($listurl, ['action' => 'copy']),
- 'icon' => new \pix_icon('t/copy', \get_string('instancecopy', 'pulse')),
- 'attributes' => ['class' => 'action-copy'],
- ];
-
- // Instance reports builder view.
- if ($this->can_view_reports()) {
- $actions[] = [
- 'url' => new \moodle_url($listurl, ['action' => 'report']),
- 'icon' => new \pix_icon('i/calendar', \get_string('instancereport', 'pulse')),
- 'attributes' => ['class' => 'action-report', 'target' => '_blank'],
- ];
- }
-
- // Show/Hide.
- $checked = ($row->status) ? ['checked' => 'checked'] : [];
- $checkbox = html_writer::div(
- html_writer::empty_tag('input',
- ['type' => 'checkbox', 'class' => 'custom-control-input'] + $checked
- ) . html_writer::tag('span', '', ['class' => 'custom-control-label']),
- 'custom-control custom-switch'
- );
- $statusurl = new \moodle_url($listurl, ['action' => ($row->status) ? 'disable' : 'enable']);
- $statusclass = 'pulse-instance-status-switch ';
- $statusclass .= $row->status ? 'action-hide' : 'action-show';
- $actions[] = html_writer::link($statusurl->out(false), $checkbox, ['class' => $statusclass]);
- }
-
- // Delete.
- $actions[] = [
- 'url' => new \moodle_url($listurl, ['action' => 'delete']),
- 'icon' => new \pix_icon('t/delete', \get_string('delete')),
- 'attributes' => ['class' => 'action-delete'],
- 'action' => new \confirm_action(get_string('deleteinstance', 'pulse')),
- ];
-
- $actionshtml = [];
- foreach ($actions as $action) {
- if (!is_array($action)) {
- $actionshtml[] = $action;
- continue;
- }
- $action['attributes']['role'] = 'button';
- $actionshtml[] = $OUTPUT->action_icon(
- $action['url'],
- $action['icon'],
- ($action['action'] ?? null),
- $action['attributes']
- );
- }
- return html_writer::span(join('', $actionshtml), 'menu-item-actions item-actions mr-0');
- }
-
- /**
- * Verify the current user can able to view the reports.
- *
- * @return bool
- */
- public function can_view_reports() {
- // Create template instance. Actions are performed in template instance.
- $reportid = \mod_pulse\automation\instances::get_reportid();
- $report = manager::get_report_from_id($reportid);
- return permission::can_view_report($report->get_report_persistent());
- }
-
-}
diff --git a/classes/table/auto_templates.php b/classes/table/auto_templates.php
deleted file mode 100644
index 660f1af..0000000
--- a/classes/table/auto_templates.php
+++ /dev/null
@@ -1,249 +0,0 @@
-.
-
-/**
- * Automation template - Table list for the automation template in the pulse 2.0 plugin.
- *
- * @package mod_pulse
- * @copyright 2023, bdecent gmbh bdecent.de
- * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
- */
-
-namespace mod_pulse\table;
-
-defined('MOODLE_INTERNAL') || die();
-
-require_once($CFG->dirroot.'/lib/tablelib.php');
-
-use table_sql;
-use moodle_url;
-use html_writer;
-use mod_pulse\automation\helper;
-
-/**
- * Automation templates table handler.
- */
-class auto_templates extends table_sql {
-
- /**
- * Setup and Render the menus table.
- *
- * @param int $pagesize Size of page for paginated displayed table.
- * @param bool $useinitialsbar Whether to use the initials bar which will only be used if there is a fullname column defined.
- * @param string $downloadhelpbutton
- */
- public function out($pagesize, $useinitialsbar, $downloadhelpbutton = '') {
-
- // Define table headers and columns.
- $columns = ['title', 'reference', 'actions'];
- $headers = ["", "", ""];
-
- $this->define_columns($columns);
- $this->define_headers($headers);
-
- // Remove sorting for some fields.
- $this->sortable(true, 'sortorder', SORT_ASC);
-
- $this->no_sorting('title');
- $this->no_sorting('actions');
-
- $this->set_attribute('id', 'pulse_automation_template');
-
- $this->guess_base_url();
-
- parent::out($pagesize, $useinitialsbar, $downloadhelpbutton);
- }
-
- /**
- * Guess the base url for the automation table.
- */
- public function guess_base_url(): void {
- $this->baseurl = new moodle_url('/mod/pulse/automation/templates/list.php');
- }
-
- /**
- * Set the sql query to fetch smart menus list.
- *
- * @param int $pagesize Size of page for paginated displayed table.
- * @param bool $useinitialsbar Whether to use the initials bar which will only be used if there is a fullname column defined.
- * @return void
- */
- public function query_db($pagesize, $useinitialsbar = true) {
- global $DB;
- // Fetch all avialable records from smart menu table.
- $condition = '1=1';
- $params = [];
- if ($this->filterset->has_filter('category')) {
-
- $values = $this->filterset->get_filter('category')->get_filter_values();
- $category = isset($values[0]) ? current($values) : '';
- $condition = $DB->sql_like('categories', ':value');
- $params += ['value' => '%"'.$category.'"%'];
- }
- $this->set_sql('*', '{pulse_autotemplates}', $condition, $params);
- parent::query_db($pagesize, $useinitialsbar);
- }
-
- /**
- * Show the menu title in the list, render the description based on the show description value "Above, below and help".
- * Default help_icon method only works with string identifiers, rendered the help icon from template directly.
- *
- * @param object $row
- * @return void
- */
- public function col_title($row) {
- global $OUTPUT;
- // TODO: Editable.
- $editable = true;
- $title = new \core\output\inplace_editable(
- 'mod_pulse', 'templatetitle', $row->id, $editable, format_string($row->title),
- $row->title, 'Edit template title', 'New value for ' . format_string($row->title)
- );
-
- $actions = \mod_pulse\plugininfo\pulseaction::instance()->get_plugins_base();
- array_walk($actions, function(&$value) {
- $classname = 'pulseaction_'.$value->get_component();
- $result['badge'] = html_writer::tag('span', get_string('formtab', 'pulseaction_'.$value->get_component()),
- ['class' => 'badge badge-primary '.$classname]);
- $result['icon'] = html_writer::span($value->get_action_icon(), 'action', ['class' => 'action-icon '.$classname]);
- $value = $result;
- });
- return implode(' ', array_column($actions, 'icon')) . $OUTPUT->render($title) . implode(' ',
- array_column($actions, 'badge'));
- }
-
- /**
- * Generates the HTML content for the instance reference column in a row.
- *
- * @param object $row The row containing the data.
- * @return string The HTML content for the reference column.
- */
- public function col_reference($row) {
- $title = html_writer::tag('h5', format_string($row->reference), ['class' => 'template-reference']);
- return $title;
- }
-
- /**
- * Generates the actions links for the instance.
- *
- * @param object $row The row containing the data.
- * @return string
- */
- public function col_actions($row) {
- global $OUTPUT;
-
- $baseurl = new \moodle_url('/mod/pulse/automation/templates/edit.php', [
- 'id' => $row->id,
- 'sesskey' => \sesskey(),
- ]);
- $actions = [];
-
- // Edit.
- $actions[] = [
- 'url' => $baseurl,
- 'icon' => new \pix_icon('t/edit', \get_string('edit')),
- 'attributes' => ['class' => 'action-edit'],
- ];
-
- list($totalcount, $disabledcount) = $this->get_instance_count($row);
- $actions[] = html_writer::tag('label', $totalcount . "(" . $disabledcount . ")", [
- 'class' => 'overrides badge badge-secondary pl-10',
- ]);
- $listurl = new \moodle_url('/mod/pulse/automation/templates/list.php', [
- 'id' => $row->id,
- 'sesskey' => \sesskey(),
- ]);
-
- // Show/Hide.
- if ($row->visible) {
- $actions[] = [
- 'url' => new \moodle_url($listurl, ['action' => 'hidemenu']),
- 'icon' => new \pix_icon('t/hide', \get_string('hide')),
- 'attributes' => ['data-action' => 'hide', 'class' => 'action-hide'],
- ];
- } else {
- $actions[] = [
- 'url' => new \moodle_url($listurl, ['action' => 'showmenu']),
- 'icon' => new \pix_icon('t/show', \get_string('show')),
- 'attributes' => ['data-action' => 'show', 'class' => 'action-show'],
- ];
- }
-
- // List of items.
- $actions[] = $this->edit_switch($row);
-
- // Delete.
- $actions[] = [
- 'url' => new \moodle_url($listurl, ['action' => 'delete']),
- 'icon' => new \pix_icon('t/delete', \get_string('delete')),
- 'attributes' => ['class' => 'action-delete'],
- 'action' => new \confirm_action(get_string('confirmdeletetemplate', 'pulse')),
- ];
-
- $actionshtml = [];
- foreach ($actions as $action) {
- if (!is_array($action)) {
- $actionshtml[] = $action;
- continue;
- }
- $action['attributes']['role'] = 'button';
- $actionshtml[] = $OUTPUT->action_icon(
- $action['url'],
- $action['icon'],
- ($action['action'] ?? null),
- $action['attributes'],
- );
- }
- return html_writer::div(join('', $actionshtml), 'menu-item-actions item-actions mr-0');
- }
-
-
- /**
- * Create a navbar switch for toggling editing mode.
- * @param stdclass $row
- * @return string Html containing the edit switch
- */
- public function edit_switch($row) {
- global $PAGE, $OUTPUT;
-
- $temp = (object) [
- 'legacyseturl' => (new moodle_url('/mod/pulse/automation/templates/list.php', [
- 'id' => $row->id,
- 'sesskey' => sesskey(),
- ]))->out(false),
- 'pagecontextid' => $PAGE->context->id,
- 'pageurl' => $PAGE->url,
- 'sesskey' => sesskey(),
- 'checked' => $row->status,
- 'id' => $row->id,
- ];
- return $OUTPUT->render_from_template('pulse/status_switch', $temp);
- }
-
- /**
- * Gets the total count and disabled count of instances associated with a template.
- *
- * @param object $row The template row.
- * @return array An array containing the total count and disabled count.
- */
- protected function get_instance_count($row) {
- global $DB;
-
- $totalcount = $DB->count_records('pulse_autoinstances', ['templateid' => $row->id]);
- $disabledcount = $DB->count_records('pulse_autoinstances', ['templateid' => $row->id, 'status' => 0]);
- return [$totalcount, $disabledcount];
- }
-}
diff --git a/classes/table/automation_filterset.php b/classes/table/automation_filterset.php
deleted file mode 100644
index 0d7a66e..0000000
--- a/classes/table/automation_filterset.php
+++ /dev/null
@@ -1,66 +0,0 @@
-.
-
-/**
- * Automation filter set class.
- *
- * @package mod_pulse
- * @copyright 2023, bdecent gmbh bdecent.de
- * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
- */
-
-declare(strict_types=1);
-
-namespace mod_pulse\table;
-
-use core_table\local\filter\filterset;
-use core_table\local\filter\integer_filter;
-use core_table\local\filter\string_filter;
-
-/**
- * Automation table filterset.
- *
- * @package mod_pulse
- * @copyright 2023, bdecent gmbh bdecent.de
- * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
- */
-class automation_filterset extends filterset {
-
- /**
- * Get the required filters.
- *
- * The only required filter is the courseid filter.
- *
- * @return array.
- */
- public function get_required_filters(): array {
- return [];
- }
-
- /**
- * Get the optional filters.
- *
- * These are:
- * - category;
- *
- * @return array
- */
- public function get_optional_filters(): array {
- return [
- 'category' => integer_filter::class,
- ];
- }
-}
diff --git a/classes/table/automation_instance_filterset.php b/classes/table/automation_instance_filterset.php
deleted file mode 100644
index f88bfbe..0000000
--- a/classes/table/automation_instance_filterset.php
+++ /dev/null
@@ -1,66 +0,0 @@
-.
-
-/**
- * Automation instance filter set class.
- *
- * @package mod_pulse
- * @copyright 2023, bdecent gmbh bdecent.de
- * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
- */
-
-declare(strict_types=1);
-
-namespace mod_pulse\table;
-
-use core_table\local\filter\filterset;
-use core_table\local\filter\integer_filter;
-use core_table\local\filter\string_filter;
-
-/**
- * Automation Instance table filterset.
- *
- * @package mod_pulse
- * @copyright 2023, bdecent gmbh bdecent.de
- * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
- */
-class automation_instance_filterset extends filterset {
-
- /**
- * Get the required filters.
- *
- * The only required filter is the courseid filter.
- *
- * @return array.
- */
- public function get_required_filters(): array {
- return [];
- }
-
- /**
- * Get the optional filters.
- *
- * These are:
- * - category;
- *
- * @return array
- */
- public function get_optional_filters(): array {
- return [
- 'templateid' => integer_filter::class,
- ];
- }
-}
diff --git a/classes/table/manage_instance.php b/classes/table/manage_instance.php
deleted file mode 100644
index 9971c64..0000000
--- a/classes/table/manage_instance.php
+++ /dev/null
@@ -1,396 +0,0 @@
-.
-
-/**
- * Manage instance - Table list for the manage instance in the pulse 2.0 plugin.
- *
- * @package mod_pulse
- * @copyright 2023, bdecent gmbh bdecent.de
- * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
- */
-
-namespace mod_pulse\table;
-
-defined('MOODLE_INTERNAL') || die();
-
-require_once($CFG->dirroot.'/lib/tablelib.php');
-
-use table_sql;
-use moodle_url;
-use html_writer;
-use mod_pulse\automation\helper;
-use core_table\dynamic as dynamic_table;
-use stdClass;
-use core_course_category;
-
-/**
- * Manage instances table handler.
- */
-class manage_instance extends \table_sql implements dynamic_table {
-
- /**
- * Template id.
- *
- * @var int $templateid
- */
- public $templateid;
-
- /**
- * Fetch the template data.
- *
- * @var stdclass
- */
- public $template;
-
- /**
- * Fetch completions automation template list.
- *
- * @param mixed $templateid
- * @return void
- */
- public function __construct($templateid) {
- global $DB;
-
- parent::__construct($templateid);
-
- // Template ID.
- $this->templateid = $templateid;
-
- // Automation template data.
- $this->template = $DB->get_record('pulse_autotemplates', ['id' => $templateid]);
-
- }
-
- /**
- * Get the table context.
- *
- * @return void
- */
- public function get_context(): \context {
- return \context_system::instance();
- }
-
- /**
- * Setup and Render the manage instace table.
- *
- * @param int $pagesize Size of page for paginated displayed table.
- * @param bool $useinitialsbar Whether to use the initials bar which will only be used if there is a fullname column defined.
- * @param string $downloadhelpbutton
- */
- public function out($pagesize, $useinitialsbar, $downloadhelpbutton = '') {
- global $OUTPUT;
-
- // Define table headers and columns.
- $columns = ['checkbox', 'category', 'coursename', 'numberofinstance', 'actions'];
- $headers = [
- '',
- get_string('coursecategory', 'pulse'),
- get_string('coursename', 'pulse'),
- get_string('numberofinstance', 'pulse'),
- get_string('actions'),
- ];
-
- $this->define_columns($columns);
- $this->define_headers($headers);
-
- $this->no_sorting('select');
-
- // Remove sorting for some fields.
- $this->sortable(false);
-
- $this->set_attribute('id', 'pulse-manage-instance');
-
- $this->guess_base_url();
-
- parent::out($pagesize, $useinitialsbar, $downloadhelpbutton);
- }
-
- /**
- * Guess the base url for the manage instance table.
- */
- public function guess_base_url(): void {
- $this->baseurl = new moodle_url('/mod/pulse/automation/templates/edit.php', ['id' => $this->templateid]);
- }
-
- /**
- * Override the table show_hide_link to not show for select column.
- *
- * @param string $column the column name, index into various names.
- * @param int $index numerical index of the column.
- * @return string HTML fragment.
- */
- protected function show_hide_link($column, $index) {
- return '';
- }
-
- /**
- * Set the sql query to fetch manage instance list.
- *
- * @param int $pagesize Size of page for paginated displayed table.
- * @param bool $useinitialsbar Whether to use the initials bar which will only be used if there is a fullname column defined.
- * @return void
- */
- public function query_db($pagesize, $useinitialsbar = true) {
- global $DB;
-
- // Fetch available records from instance manage table.
- $from = "{course} c
- JOIN {course_categories} cat ON c.category = cat.id
- LEFT JOIN (
- SELECT courseid, count(*) AS numberofinstance FROM {pulse_autoinstances} WHERE
- templateid = ".$this->templateid." GROUP BY courseid
- ) pai ON pai.courseid = c.id
- LEFT JOIN (
- SELECT courseid, count(*) AS enabledinstance FROM {pulse_autoinstances} WHERE
- templateid =:templateid AND status <> 0 GROUP BY courseid
- ) pad ON pad.courseid = c.id
- ";
- $condition = "c.id <> 1 AND c.visible != 0";
- $inparams = ['templateid' => $this->templateid];
-
- // When prevent the categories in the automation template, then show only the selected category
- // courses in the instance management table.
- $categories = json_decode($DB->get_field('pulse_autotemplates', 'categories', ['id' => $this->templateid]));
- if (!empty($categories)) {
- list($categoryinsql, $categoryinparams) = $DB->get_in_or_equal($categories, SQL_PARAMS_NAMED, 'cate');
- $condition .= " AND c.category $categoryinsql";
- $inparams += $categoryinparams;
- }
-
- // Filter the category.
- if ($this->filterset->has_filter('category')) {
- $values = $this->filterset->get_filter('category')->get_filter_values();
- $category = isset($values[0]) ? current($values) : '';
-
- if (!empty($category)) {
- list($insql, $cateinparams) = $DB->get_in_or_equal($category, SQL_PARAMS_NAMED, 'cat');
- $condition .= " AND c.category $insql";
- $inparams += $cateinparams;
- }
- }
-
- // Filter the course.
- if ($this->filterset->has_filter('course')) {
- $values = $this->filterset->get_filter('course')->get_filter_values();
- $course = isset($values[0]) ? current($values) : '';
- if (!empty($course)) {
- list($insql, $courseinparams) = $DB->get_in_or_equal($course, SQL_PARAMS_NAMED, 'co');
- $condition .= " AND c.id $insql";
- $inparams += $courseinparams;
- }
- }
-
- // Filter the instance count.
- if ($this->filterset->has_filter('numberofinstance')) {
- $values = $this->filterset->get_filter('numberofinstance')->get_filter_values();
- $numofinstance = isset($values[0]) ? current($values) : '';
-
- if ($numofinstance !== null && ($numofinstance != '' || $numofinstance === 0)) {
- $condition .= $numofinstance ? " AND pai.numberofinstance = :numberofinstance " :
- " AND pai.numberofinstance IS NULL ";
- $inparams += ['numberofinstance' => $numofinstance ?: ''];
- }
- }
-
- $this->set_sql('c.*, cat.name AS categoryname, pai.numberofinstance, pad.enabledinstance', $from, $condition, $inparams);
-
- parent::query_db($pagesize, $useinitialsbar);
-
- // Filter the records by instance overrides count.
- if ($this->filterset->has_filter('numberofoverrides')) {
- $values = $this->filterset->get_filter('numberofoverrides')->get_filter_values();
- $numberofoverrides = isset($values[0]) ? current($values) : '';
-
- if ($numberofoverrides !== null && ($numberofoverrides != '' || $numberofoverrides === 0)) {
- // Fetch the list of instances for this template.
- $instances = $DB->get_records('pulse_autoinstances', ['templateid' => $this->templateid]);
- $overrides = [];
- if (!empty($instances)) {
- // Store the number of overrides for this instance. Store the overrides based on the course.
- foreach ($instances as $instanceid => $instance) {
- $insobj = new \mod_pulse\automation\instances($instance->id);
- $formdata = (object) $insobj->get_instance_formdata();
- $count = $formdata->overridecount;
- $overrides[$instance->courseid] = isset($overrides[$instance->courseid])
- ? $overrides[$instance->courseid] + $count : $count;
- }
- }
- // Filter the records by the number of overrides from the filter form.
- $this->rawdata = array_filter($this->rawdata, function($row) use ($overrides, $numberofoverrides) {
- return isset($overrides[$row->id]) && $overrides[$row->id] == $numberofoverrides;
- });
-
- // Reset the records count to resize the page size.
- $this->pagesize($pagesize, count($this->rawdata));
- }
- }
-
- }
-
- /**
- * Bulk action check box.
- *
- * @param stdClass $row
- * @return string
- */
- public function col_checkbox(stdClass $row) {
- global $DB;
- $html = '';
-
- // Count the number of instances in that course.
- $countcolorclass = $row->numberofinstance == 0 ? 'emptyinstance' : '';
-
- $bulkcourseinput = [
- 'id' => 'courselistitem' . $row->id,
- 'type' => 'checkbox',
- 'name' => 'bc[]',
- 'value' => $row->id,
- 'class' => 'bulk-action-checkbox custom-control-input '. $countcolorclass,
- 'data-action' => 'select',
- ];
- $html .= html_writer::start_div('custom-control custom-checkbox mr-1 ');
- $html .= html_writer::empty_tag('input', $bulkcourseinput);
- $labeltext = html_writer::span(get_string('bulkactionselect', 'moodle'), 'sr-only');
- $html .= html_writer::tag('label', $labeltext, [
- 'class' => 'custom-control-label',
- 'for' => 'courselistitem' . $row->id,
- ]);
- $html .= html_writer::end_div();
- return $html;
- }
-
- /**
- * Name of the course category.
- *
- * @param stdClass $row
- * @return string
- */
- public function col_category(stdClass $row) {
- global $DB;
- $categoryname = $row->categoryname;
- return $categoryname;
- }
-
- /**
- * Name of the course.
- *
- * @param stdClass $row
- * @return string
- */
- public function col_coursename(stdClass $row) : string {
- return format_string($row->fullname);;
- }
-
- /**
- * Get the number of instances count in the related course.
- *
- * @param stdClass $row
- * @return string
- */
- public function col_numberofinstance(stdClass $row) {
- global $DB;
-
- $countcolorclass = $row->numberofinstance == 0 ? 'emptycount' : '';
- $count = html_writer::tag('h6', $row->numberofinstance ?: 0, ['class' => 'numofinstance '.$countcolorclass]);
- return $count;
- }
-
- /**
- * Generates the actions links for the instance management.
- *
- * @param object $row The row containing the data.
- * @return string
- */
- public function col_actions($row) {
- global $OUTPUT, $DB;
-
- $baseurl = new \moodle_url('/mod/pulse/automation/templates/edit.php', [
- 'id' => $this->templateid,
- 'sesskey' => \sesskey(),
- ]);
- $actions = [];
-
- // Redirect to the related course automation page.
- $actions[] = [
- 'url' => new \moodle_url('/mod/pulse/automation/instances/list.php', ['courseid' => $row->id, 'sesskey' => sesskey()]),
- 'icon' => new \pix_icon('t/edit', \get_string('instanceslist', 'pulse')),
- 'attributes' => ['class' => 'action-edit', 'target' => '_blank'],
- ];
-
- // Add instance.
- $actions[] = [
- 'url' => new \moodle_url($baseurl, ['action' => 'add', 'courseid' => $row->id]),
- 'icon' => new \pix_icon('t/add', \get_string('addinstance', 'pulse')),
- 'attributes' => ['class' => 'action-add-instance'],
- ];
-
- // Enable / Disable course instance toggle option.
- $disabled = $row->numberofinstance - $row->enabledinstance; // Disable instances in the course.
- $status = $row->enabledinstance; // Find the most instances status enabled/disabled.
-
- $badge = '';
- $badge = ($row->numberofinstance && $row->enabledinstance && $disabled)
- ? html_writer::tag('span', get_string('mixed', 'pulse'), ['class' => 'badge badge-secondary']) : '';
-
- $checked = $row->enabledinstance ? ['checked' => 'checked'] : [];
-
- $checkbox = html_writer::div(
- html_writer::empty_tag('input',
- ['type' => 'checkbox', 'class' => 'custom-control-input'] + $checked
- ) . html_writer::tag('span', '', ['class' => 'custom-control-label']),
- 'custom-control custom-switch'
- );
- $statusurl = new \moodle_url($baseurl, ['action' => ($status) ? 'disable' : 'enable', 'courseid' => $row->id]);
- $statusclass = 'pulse-manage-instance-status-switch ';
- $statusclass .= $status ? 'action-hide' : 'action-show';
- $actions[] = html_writer::link($statusurl->out(false), $checkbox, ['class' => $statusclass]);
- $actions[] = $badge;
-
- // Instance reports for this course.
- $actions[] = [
- 'url' => new \moodle_url('/mod/pulse/automation/instances/list.php', [
- 'courseid' => $row->id, 'sesskey' => sesskey(), 'templateid' => $this->templateid,
- ]),
- 'icon' => new \pix_icon('i/calendar', \get_string('courseinsreport', 'pulse')),
- 'attributes' => ['class' => 'action-report', 'target' => '_blank'],
- ];
-
- // Delete all instance in the course.
- $actions[] = [
- 'url' => new \moodle_url($baseurl, ['action' => 'delete', 'courseid' => $row->id]),
- 'icon' => new \pix_icon('t/delete', \get_string('delete')),
- 'attributes' => ['class' => 'action-delete'],
- 'action' => new \confirm_action(get_string('confirmdeleteinstance', 'pulse')),
- ];
-
- $actionshtml = [];
- foreach ($actions as $action) {
- if (!is_array($action)) {
- $actionshtml[] = $action;
- continue;
- }
- $action['attributes']['role'] = 'button';
- $actionshtml[] = $OUTPUT->action_icon(
- $action['url'],
- $action['icon'],
- ($action['action'] ?? null),
- $action['attributes'],
- );
- }
- return html_writer::div(join('', $actionshtml), 'menu-item-actions item-actions mr-0');
- }
-
-}
diff --git a/classes/table/manage_instance_filterset.php b/classes/table/manage_instance_filterset.php
deleted file mode 100644
index 6f23a0a..0000000
--- a/classes/table/manage_instance_filterset.php
+++ /dev/null
@@ -1,69 +0,0 @@
-.
-
-/**
- * Manage instance filter set class.
- *
- * @package mod_pulse
- * @copyright 2023, bdecent gmbh bdecent.de
- * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
- */
-
-declare(strict_types=1);
-
-namespace mod_pulse\table;
-
-use core_table\local\filter\filterset;
-use core_table\local\filter\integer_filter;
-use core_table\local\filter\string_filter;
-
-/**
- * Manage instance table filterset.
- *
- * @package mod_pulse
- * @copyright 2023, bdecent gmbh bdecent.de
- * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
- */
-class manage_instance_filterset extends filterset {
-
- /**
- * Get the required filters.
- *
- * The only required filter is the courseid filter.
- *
- * @return array.
- */
- public function get_required_filters(): array {
- return [];
- }
-
- /**
- * Get the optional filters.
- *
- * These are:
- * - category;
- *
- * @return array
- */
- public function get_optional_filters(): array {
- return [
- 'category' => integer_filter::class,
- 'course' => integer_filter::class,
- 'numberofinstance' => integer_filter::class,
- 'numberofoverrides' => integer_filter::class,
- ];
- }
-}
diff --git a/conditions/activity/classes/conditionform.php b/conditions/activity/classes/conditionform.php
deleted file mode 100644
index 290ac20..0000000
--- a/conditions/activity/classes/conditionform.php
+++ /dev/null
@@ -1,180 +0,0 @@
-.
-
-/**
- * Conditions - Pulse condition class for the "Activity Completion".
- *
- * @package pulsecondition_activity
- * @copyright 2023, bdecent gmbh bdecent.de
- * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
- */
-
-namespace pulsecondition_activity;
-
-use mod_pulse\automation\condition_base;
-
-/**
- * Automation condition form for acitivty completion.
- */
-class conditionform extends \mod_pulse\automation\condition_base {
-
- /**
- * Include condition
- *
- * @param array $option
- * @return void
- */
- public function include_condition(&$option) {
- $option['activity'] = get_string('activitycompletion', 'pulsecondition_activity');
- }
-
- /**
- * Loads the form elements for activity condition.
- *
- * @param MoodleQuickForm $mform The form object.
- * @param object $forminstance The form instance.
- */
- public function load_instance_form(&$mform, $forminstance) {
-
- $completionstr = get_string('activitycompletion', 'pulsecondition_activity');
- $mform->addElement('select', 'condition[activity][status]', $completionstr, $this->get_options());
- $mform->addHelpButton('condition[activity][status]', 'activitycompletion', 'pulsecondition_activity');
- $courseid = $forminstance->get_customdata('courseid') ?? '';
- $modinfo = \course_modinfo::instance($courseid);
- // Include the suppress activity settings for the instance.
- $completion = new \completion_info(get_course($courseid));
- $activities = $completion->get_activities();
- array_walk($activities, function(&$value) {
- $value = format_string($value->name);
- });
-
- $modules = $mform->addElement('autocomplete', 'condition[activity][modules]',
- get_string('selectactivity', 'pulsecondition_activity'), $activities);
- $modules->setMultiple(true);
- $mform->hideIf('condition[activity][modules]', 'condition[activity][status]', 'eq', self::DISABLED);
- $mform->addHelpButton('condition[activity][modules]', 'selectactivity', 'pulsecondition_activity');
-
- // Enable the override by default to prevent adding overdide checkbox.
- $mform->addElement('hidden', 'override[condition_activity_modules]', 1);
- $mform->setType('override[condition_activity_modules]', PARAM_RAW);
- }
-
- /**
- * Checks if the user has completed the specified activities.
- *
- * @param object $instancedata The instance data.
- * @param int $userid The user ID.
- * @param \completion_info|null $completion The completion information.
- * @return bool True if completed, false otherwise.
- */
- public function is_user_completed($instancedata, $userid, \completion_info $completion=null) {
- // Get the notification suppres module ids.
- $additional = $instancedata->condition['activity'] ?? [];
- $modules = $additional['modules'] ?? [];
-
- if (!empty($modules)) {
- $result = [];
-
- if ($completion === null) {
- $completion = new \completion_info(get_course($instancedata->courseid));
- }
- // Find the completion status for all this suppress modules.
- foreach ($modules as $cmid) {
-
- if (method_exists($completion, 'get_completion_data')) {
- $modulecompletion = $completion->get_completion_data($cmid, $userid, []);
- } else {
- $cminfo = get_coursemodule_from_id('', $cmid);
- $modulecompletion = (array) $completion->get_data($cminfo, false, $userid);
- }
-
- if (isset($modulecompletion['completionstate']) && $modulecompletion['completionstate'] == COMPLETION_COMPLETE) {
- $result[] = true;
- }
- }
- // If suppress operator set as all, check all the configures modules are completed.
- // Remove the schedule only if all the activites are completed.
- if (count($result) == count($modules)) {
- return true;
- }
- return false;
- }
- return false;
- }
-
- /**
- * Module completed.
- *
- * @param stdclass $eventdata
- * @return bool
- */
- public static function module_completed($eventdata) {
- // Event data.
- $data = $eventdata->get_data();
-
- $cmid = $data['contextinstanceid'];
- $userid = $data['userid'];
- // Get the info for the context.
- list($context, $course, $cm) = get_context_info_array($data['contextid']);
- // Self condition instance.
- $condition = new self();
- // Course completion info.
- $completion = new \completion_info($course);
-
- // Get all the notification instance configures the suppress with this activity.
- $notifications = self::get_acitivty_notifications($cmid);
-
- foreach ($notifications as $notification) {
- // Get the notification suppres module ids.
- $additional = isset($notification->additional) ? json_decode($notification->additional, true) : '';
- $modules = $additional['modules'] ?? [];
- if (!empty($modules)) {
- // Remove the schedule only if all the activites are completed.
- $condition->trigger_instance($notification->instanceid, $userid);
- }
-
- }
- return true;
- }
-
-
- /**
- * Fetch the list of menus which is used the triggered ID in the access rules for the given method.
- *
- * Find the menus which contains the given ID in the access rule (Role or cohorts).
- *
- * @param int $id ID of the triggered method, Role or cohort id.
- * @return array
- */
- public static function get_acitivty_notifications($id) {
- global $DB;
-
- $like = $DB->sql_like('co.additional', ':value'); // Like query to fetch the instances assigned this module.
- $activitylike = $DB->sql_like('pat.triggerconditions', ':activity');
-
- $sql = "SELECT *, ai.id as id, ai.id as instanceid FROM {pulse_autoinstances} ai
- JOIN {pulse_autotemplates} pat ON pat.id = ai.templateid
- LEFT JOIN {pulse_condition_overrides} co ON co.instanceid = ai.id AND co.triggercondition = 'activity'
- WHERE $like AND (co.status > 0 OR $activitylike)";
-
- $params = ['activity' => '%"activity"%', 'value' => '%"'.$id.'"%'];
-
- $records = $DB->get_records_sql($sql, $params);
-
- return $records;
- }
-
-}
diff --git a/conditions/activity/db/events.php b/conditions/activity/db/events.php
deleted file mode 100644
index 949c175..0000000
--- a/conditions/activity/db/events.php
+++ /dev/null
@@ -1,32 +0,0 @@
-.
-
-/**
- * DB Events - Define event observers for "Activity condition".
- *
- * @package pulsecondition_activity
- * @copyright 2023, bdecent gmbh bdecent.de
- * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
- */
-defined('MOODLE_INTERNAL') || die();
-
-// Course module event observer for the "Activity completion" condition in the pulse 2.0.
-$observers = [
- [
- 'eventname' => 'core\event\course_module_completion_updated',
- 'callback' => '\pulsecondition_activity\conditionform::module_completed',
- ],
-];
diff --git a/conditions/activity/lang/en/pulsecondition_activity.php b/conditions/activity/lang/en/pulsecondition_activity.php
deleted file mode 100644
index e38026f..0000000
--- a/conditions/activity/lang/en/pulsecondition_activity.php
+++ /dev/null
@@ -1,35 +0,0 @@
-.
-
-/**
- * Strings for "Activity conditions", language 'en'.
- *
- * @package pulsecondition_activity
- * @copyright 2023, bdecent gmbh bdecent.de
- * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
- */
-defined('MOODLE_INTERNAL') || die();
-
-$string['pluginname'] = 'Activity completion';
-$string['activitycompletion'] = 'Activity completion';
-$string['activitycompletion_help'] = '
Activity Completion: This automation will be triggered when an activity within the
- course is marked as completed. You will need to specify the activity within the automation instance.The options for activity
- completion include:
Disabled: Activity completion condition is disabled.
All: Activity completion
- condition applies to all enrolled users.
Upcoming: Activity completion condition only applies to future enrolments.';
-$string['selectactivity'] = 'Select activities';
-$string['selectactivity_help'] = "The
Select Activities setting allows you to choose from all available activities within
- your course that have completion configured. This selection determines which specific activities will trigger the automation
- when their completion conditions are met.";
diff --git a/conditions/activity/tests/behat/trigger_pulsecondition_activity.feature b/conditions/activity/tests/behat/trigger_pulsecondition_activity.feature
deleted file mode 100644
index f4296e1..0000000
--- a/conditions/activity/tests/behat/trigger_pulsecondition_activity.feature
+++ /dev/null
@@ -1,62 +0,0 @@
-@mod @mod_pulse @pulse_triggercondition @pulsecondition_activity
-Feature: Activity trigger event.
- In To Verify Pulse Automation Template Conditions for Activity as a Teacher.
-
- Background:
- Given the following "course" exist:
- | fullname | shortname | category | enablecompletion |
- | Course 1 | C1 | 0 | 1 |
- And the following "activities" exist:
- | activity | name | course | idnumber | completion |
- | page | TestPage 01 | C1 | page1 | 1 |
- | page | TestPage 02 | C1 | page2 | 1 |
- And the following "users" exist:
- | 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 |
- | teacher1 | C1 | editingteacher |
- | student1 | C1 | student |
-
- @javascript
- Scenario: Check the pluse condition activity trigger workflow
- Given I log in as "admin"
- Then I create automation template with the following fields to these values:
- | Title | WELCOME MESSAGE 01 |
- | Reference | Welcomemessage |
- Then I create automation template with the following fields to these values:
- | Title | WELCOME MESSAGE 02 |
- | Reference | Welcomemessage02 |
- Then I create "Welcomemessage" template with the set the condition:
- | Triggers | Activity completion |
- | Trigger operator | All |
- And I am on "Course 1" course homepage
- And I follow "Automation"
- When I open the autocomplete suggestions list
- And I click on "WELCOME MESSAGE 01" item in the autocomplete list
- Then I press "Add automation instance"
- And I set the following fields to these values:
- | insreference | Welcomemessage |
- Then I follow "Condition"
- Then I should see "Activity completion"
- Then the field "Activity completion" matches value "All"
- And I should see "Select activities"
- Then I click on "#fitem_id_condition_activity_modules .form-autocomplete-downarrow" "css_element"
- Then I should see "TestPage 01" in the "#fitem_id_condition_activity_modules .form-autocomplete-suggestions" "css_element"
- Then I should see "TestPage 02" in the "#fitem_id_condition_activity_modules .form-autocomplete-suggestions" "css_element"
- And I press "Save changes"
- When I open the autocomplete suggestions list
- And I click on "WELCOME MESSAGE 02" item in the autocomplete list
- Then I press "Add automation instance"
- And I set the following fields to these values:
- | insreference | Welcomemessage2 |
- Then I follow "Condition"
- Then I should see "Activity completion"
- And I should not see "Select activities"
- Then the field "Activity completion" matches value "Disable"
- Then I wait "5" seconds
- Then I click on "input[name='override[condition_activity_status]'].checkboxgroupautomation" "css_element"
- And I set the field "Activity completion" to "All"
- And I should see "Select activities"
- And I press "Save changes"
diff --git a/conditions/activity/version.php b/conditions/activity/version.php
deleted file mode 100644
index 1f3719c..0000000
--- a/conditions/activity/version.php
+++ /dev/null
@@ -1,27 +0,0 @@
-.
-
-/**
- * Pulse conditions Version - Pulse module activity condition version and name defined.
- *
- * @package pulsecondition_activity
- * @copyright 2023, bdecent gmbh bdecent.de
- * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
- */
-defined('MOODLE_INTERNAL') || die();
-
-$plugin->component = 'pulsecondition_activity';
-$plugin->version = 2023080202;
diff --git a/conditions/cohort/classes/conditionform.php b/conditions/cohort/classes/conditionform.php
deleted file mode 100644
index aebd61d..0000000
--- a/conditions/cohort/classes/conditionform.php
+++ /dev/null
@@ -1,137 +0,0 @@
-.
-
-/**
- * Conditions - Pulse condition class for the "Cohort Completion".
- *
- * @package pulsecondition_cohort
- * @copyright 2023, bdecent gmbh bdecent.de
- * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
- */
-
-namespace pulsecondition_cohort;
-use mod_pulse\automation\condition_base;
-
-/**
- * Automation cohort completion condition form.
- */
-class conditionform extends \mod_pulse\automation\condition_base {
-
- /**
- * Include condition
- *
- * @param array $option
- * @return void
- */
- public function include_condition(&$option) {
- $option['cohort'] = get_string('condition', 'pulsecondition_cohort');
- }
-
- /**
- * Loads the form elements for cohort condition.
- *
- * @param MoodleQuickForm $mform The form object.
- * @param object $forminstance The form instance.
- */
- public function load_instance_form(&$mform, $forminstance) {
- global $CFG;
- require_once($CFG->dirroot.'/cohort/lib.php');
-
- $completionstr = get_string('condition', 'pulsecondition_cohort');
-
- $mform->addElement('select', 'condition[cohort][status]', $completionstr, $this->get_options());
- $mform->addHelpButton('condition[cohort][status]', 'condition', 'pulsecondition_cohort');
-
- $cohorts = cohort_get_all_cohorts(0, 0);
- $cohorts = $cohorts['cohorts'];
-
- array_walk($cohorts, function(&$value) {
- $value = format_string($value->name);
- });
-
- // TODO: double check all the config names and help icons.
- $cohorts = $mform->addElement('autocomplete', 'condition[cohort][cohorts]',
- get_string('cohorts', 'pulsecondition_cohort'), $cohorts);
- $cohorts->setMultiple(true);
- $mform->hideIf('condition[cohort][cohorts]', 'condition[cohort][status]', 'eq', self::DISABLED);
- $mform->addHelpButton('condition[cohort][cohorts]', 'cohorts', 'pulsecondition_cohort');
-
- $mform->addElement('hidden', 'override[condition_cohort_cohorts]', 1);
- $mform->setType('override[condition_cohort_cohorts]', PARAM_RAW);
- }
-
- /**
- * Checks if the user has assigned into the specified cohorts.
- *
- * @param object $instancedata The instance data.
- * @param int $userid The user ID.
- * @param \completion_info|null $completion The completion information.
- * @return bool True if completed, false otherwise.
- */
- public function is_user_completed($instancedata, $userid, \completion_info $completion=null) {
- global $CFG;
- require_once($CFG->dirroot.'/cohort/lib.php'); // Cohort library file inclusion.
-
- // Find the cohort conditions is enabled if not then make this condition true.
- if (!isset($instancedata->condition['cohort']['status']) || $instancedata->condition['cohort']['status'] == 0 ) {
- return true;
- }
-
- // Get the cohort ids.
- $cohorts = $instancedata->condition['cohort']['cohorts'] ?? [];
- foreach ($cohorts as $cohort) {
- if (cohort_is_member($cohort, $userid)) {
- return true;
- }
- }
- // Cohorts are configured but not completed.
- return !empty($cohorts) ? true : false;
- }
-
- /**
- * Member added event observer.
- *
- * @param stdclass $eventdata
- * @return bool
- */
- public static function member_added($eventdata) {
- global $DB;
-
- $data = $eventdata->get_data();
-
- $cohortid = $data['objectid'];
- $relateduserid = $data['relateduserid'];
-
- // Trigger the instances, this will trigger its related actions for this user.
- $patlike = $DB->sql_like('pat.triggerconditions', ':cohort');
- $overlike = $DB->sql_like('additional', ':value');
- $cohortlike = $DB->sql_like('co.triggercondition', ':cohort2');
-
- $sql = "SELECT * FROM {pulse_autoinstances} ai
- JOIN {pulse_autotemplates} pat ON pat.id = ai.templateid
- JOIN {pulse_condition_overrides} co ON co.instanceid = ai.id
- WHERE ($patlike OR ($cohortlike AND co.status > 0) ) AND $overlike";
-
- $params = ['cohort' => 'cohort', 'cohort2' => 'cohort', 'value' => '%"'.$cohortid.'"%'];
- $instances = $DB->get_records_sql($sql, $params);
- $condition = new self();
- foreach ($instances as $key => $instance) {
- // TODO: Condition status check.
- $condition->trigger_instance($instance->instanceid, $relateduserid);
- }
- return true;
- }
-}
diff --git a/conditions/cohort/db/events.php b/conditions/cohort/db/events.php
deleted file mode 100644
index 4361eb0..0000000
--- a/conditions/cohort/db/events.php
+++ /dev/null
@@ -1,36 +0,0 @@
-.
-
-/**
- * DB Events - Define event observers for "Cohort condition".
- *
- * @package pulsecondition_cohort
- * @copyright 2023, bdecent gmbh bdecent.de
- * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
- */
-defined('MOODLE_INTERNAL') || die();
-
-// Cohort member add and remove events observer for the "Cohort Membership Completion" condition in the pulse 2.0.
-$observers = [
- [
- 'eventname' => 'core\event\cohort_member_added',
- 'callback' => '\pulsecondition_cohort\conditionform::member_added',
- ],
- [
- 'eventname' => 'core\event\cohort_member_removed',
- 'callback' => '\pulsecondition_cohort\conditionform::member_added',
- ],
-];
diff --git a/conditions/cohort/lang/en/pulsecondition_cohort.php b/conditions/cohort/lang/en/pulsecondition_cohort.php
deleted file mode 100644
index 26ba07e..0000000
--- a/conditions/cohort/lang/en/pulsecondition_cohort.php
+++ /dev/null
@@ -1,33 +0,0 @@
-.
-
-/**
- * Strings for "Cohort conditions", language 'en'.
- *
- * @package pulsecondition_cohort
- * @copyright 2023, bdecent gmbh bdecent.de
- * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
- */
-defined('MOODLE_INTERNAL') || die();
-
-$string['pluginname'] = 'Cohort member';
-$string['cohorts'] = 'Cohorts';
-$string['cohorts_help'] = 'Select cohorts for this Cohort Membership conditions';
-$string['condition'] = 'Member in cohorts';
-$string['condition_help'] = '
Cohort Membership: This automation will be triggered if the user is a member of one of the
- selected cohorts.The options for cohort membership include:
Disabled: Cohort membership condition is disabled.
-
All: Cohort membership condition applies to all enrolled users.
Upcoming: Cohort membership condition only
- applies to future enrolments';
diff --git a/conditions/cohort/tests/behat/trigger_pulsecondition_cohort.feature b/conditions/cohort/tests/behat/trigger_pulsecondition_cohort.feature
deleted file mode 100644
index faebd86..0000000
--- a/conditions/cohort/tests/behat/trigger_pulsecondition_cohort.feature
+++ /dev/null
@@ -1,68 +0,0 @@
-@mod @mod_pulse @pulse_triggercondition @pulsecondition_cohort
-Feature: Cohort trigger event.
- In To Verify Pulse Automation Template Conditions for Cohort as a Teacher.
-
- Background:
- Given the following "course" exist:
- | fullname | shortname | category | enablecompletion |
- | Course 1 | C1 | 0 | 1 |
- And the following "users" exist:
- | username | firstname | lastname | email |
- | user1 | User | User 1 | user1@test.com |
- | user2 | User | User 2 | user2@test.com |
- | teacher1 | Teacher | User 1 | teacher1@test.com |
- And the following "course enrolments" exist:
- | user | course | role |
- | teacher1 | C1 | editingteacher |
- | user1 | C1 | student |
- | user2 | C1 | student |
- And the following "cohorts" exist:
- | name | idnumber |
- | Cohort 1 | CH1 |
- | Cohort 2 | CH2 |
- And the following "cohort members" exist:
- | user | cohort |
- | user1 | CH1 |
- | user2 | CH2 |
-
- @javascript
- Scenario: Check the pluse condition cohorts trigger workflow.
- Given I log in as "admin"
- Then I create automation template with the following fields to these values:
- | Title | WELCOME MESSAGE 01 |
- | Reference | Welcomemessage |
- Then I create automation template with the following fields to these values:
- | Title | WELCOME MESSAGE 02 |
- | Reference | Welcomemessage02 |
- Then I create "Welcomemessage" template with the set the condition:
- | Triggers | Member in cohorts |
- | Trigger operator | All |
- And I am on "Course 1" course homepage
- And I follow "Automation"
- When I open the autocomplete suggestions list
- And I click on "WELCOME MESSAGE 01" item in the autocomplete list
- Then I press "Add automation instance"
- And I set the following fields to these values:
- | insreference | Welcomemessage |
- Then I follow "Condition"
- Then I should see "Member in cohorts"
- Then the field "Member in cohorts" matches value "All"
- And I should see "Cohorts"
- Then I click on "#fitem_id_condition_cohort_cohorts .form-autocomplete-downarrow" "css_element"
- Then I should see "Cohort 1" in the "#fitem_id_condition_cohort_cohorts .form-autocomplete-suggestions" "css_element"
- Then I should see "Cohort 2" in the "#fitem_id_condition_cohort_cohorts .form-autocomplete-suggestions" "css_element"
- And I press "Save changes"
- When I open the autocomplete suggestions list
- And I click on "WELCOME MESSAGE 02" item in the autocomplete list
- Then I press "Add automation instance"
- And I set the following fields to these values:
- | insreference | Welcomemessage2 |
- Then I follow "Condition"
- Then I should see "Member in cohorts" in the "#id_cohort" "css_element"
- And I should not see "Cohorts" in the "#fitem_id_condition_cohort_cohorts" "css_element"
- Then the field "Member in cohorts" matches value "Disable"
- Then I wait "5" seconds
- Then I click on "input[name='override[condition_cohort_status]'].checkboxgroupautomation" "css_element"
- And I set the field "Member in cohorts" to "All"
- And I should see "Cohorts" in the "#fitem_id_condition_cohort_cohorts" "css_element"
- And I press "Save changes"
diff --git a/conditions/cohort/version.php b/conditions/cohort/version.php
deleted file mode 100644
index b0b1c7e..0000000
--- a/conditions/cohort/version.php
+++ /dev/null
@@ -1,27 +0,0 @@
-.
-
-/**
- * Pulse conditions Version - Pulse module Cohort condition version and name defined.
- *
- * @package pulsecondition_cohort
- * @copyright 2023, bdecent gmbh bdecent.de
- * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
- */
-defined('MOODLE_INTERNAL') || die();
-
-$plugin->component = 'pulsecondition_cohort';
-$plugin->version = 2023080202;
diff --git a/conditions/course/classes/conditionform.php b/conditions/course/classes/conditionform.php
deleted file mode 100644
index 03d196c..0000000
--- a/conditions/course/classes/conditionform.php
+++ /dev/null
@@ -1,109 +0,0 @@
-.
-
-/**
- * Conditions - Pulse condition class for the "Course Completion".
- *
- * @package pulsecondition_course
- * @copyright 2023, bdecent gmbh bdecent.de
- * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
- */
-
-namespace pulsecondition_course;
-
-use mod_pulse\automation\condition_base;
-
-/**
- * Automation course completion condition form.
- */
-class conditionform extends \mod_pulse\automation\condition_base {
-
- /**
- * Verify the user is completed the course which is configured in the conditions for the notification.
- *
- * @param object $instancedata The instance data.
- * @param int $userid The user ID.
- * @param \completion_info|null $completion The completion information.
- * @return bool True if completed, false otherwise.
- */
- public function is_user_completed($instancedata, int $userid, \completion_info $completion=null) {
- global $DB;
-
- $courseid = $instancedata->courseid;
- $course = get_course($courseid);
-
- $completion = ($completion !== null) ? $completion : new \completion_info($course);
- return $completion->is_course_complete($userid);
- }
-
- /**
- * Include condition
- *
- * @param array $option
- * @return void
- */
- public function include_condition(&$option) {
- $option['course'] = get_string('coursecompletion', 'pulsecondition_course');
- }
-
- /**
- * Loads the form elements for course completion condition.
- *
- * @param MoodleQuickForm $mform The form object.
- * @param object $forminstance The form instance.
- */
- public function load_instance_form(&$mform, $forminstance) {
-
- $completionstr = get_string('coursecompletion', 'pulsecondition_course');
-
- $mform->addElement('select', 'condition[course][status]', $completionstr, $this->get_options());
- $mform->addHelpButton('condition[course][status]', 'coursecompletion', 'pulsecondition_course');
- }
-
- /**
- * Course completed event observer. trigger the actions when the user completies the course.
- *
- * @param stdclass $eventdata
- * @return bool
- */
- public static function course_completed($eventdata) {
- global $DB;
-
- $data = $eventdata->get_data();
- $courseid = $data['courseid'];
- // Use the related user id, instead of userid.
- // When the course is completed via cron then the event uses the admin user as event user.
- $relateduserid = $data['relateduserid'];
-
- // Trigger the instances, this will trigger its related actions for this user.
- $like = $DB->sql_like('pat.triggerconditions', ':value');
- $sql = "SELECT *, ai.id as id, ai.id as instanceid FROM {pulse_autoinstances} ai
- JOIN {pulse_autotemplates} pat ON pat.id = ai.templateid
- LEFT JOIN {pulse_condition_overrides} co ON co.instanceid = ai.id AND co.triggercondition = 'course'
- WHERE ai.courseid=:courseid AND (co.status > 0 OR $like)";
-
- // Parameters.
- $params = ['courseid' => $courseid, 'value' => '%"course"%'];
- // Fetch the list of notifications.
- $instances = $DB->get_records_sql($sql, $params);
-
- foreach ($instances as $key => $instance) {
- $condition = (new self())->trigger_instance($instance->instanceid, $relateduserid);
- }
-
- return true;
- }
-}
diff --git a/conditions/course/db/events.php b/conditions/course/db/events.php
deleted file mode 100644
index a24e7db..0000000
--- a/conditions/course/db/events.php
+++ /dev/null
@@ -1,32 +0,0 @@
-.
-
-/**
- * DB Events - Define event observers for "Course Completion Condition".
- *
- * @package pulsecondition_course
- * @copyright 2023, bdecent gmbh bdecent.de
- * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
- */
-defined('MOODLE_INTERNAL') || die();
-
-// Course completed event observer for the "Course Completion" condition in the pulse 2.0.
-$observers = [
- [
- 'eventname' => 'core\event\course_completed',
- 'callback' => '\pulsecondition_course\conditionform::course_completed',
- ],
-];
diff --git a/conditions/course/lang/en/pulsecondition_course.php b/conditions/course/lang/en/pulsecondition_course.php
deleted file mode 100644
index 8911f77..0000000
--- a/conditions/course/lang/en/pulsecondition_course.php
+++ /dev/null
@@ -1,28 +0,0 @@
-.
-
-/**
- * Strings for "Course completion condition", language 'en'.
- *
- * @package pulsecondition_course
- * @copyright 2023, bdecent gmbh bdecent.de
- * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
- */
-defined('MOODLE_INTERNAL') || die();
-
-$string['pluginname'] = 'Course completion';
-$string['coursecompletion'] = 'Course completion';
-$string['coursecompletion_help'] = '
Course Completion: This automation will be triggered when the course is marked as completed, where this instance is used.
Disabled: Course completion condition is disabled.
All: Course completion condition applies to all enrolled users.
Upcoming: Course completion condition only applies to future enrolments.';
diff --git a/conditions/course/tests/behat/trigger_pulsecondition_course.feature b/conditions/course/tests/behat/trigger_pulsecondition_course.feature
deleted file mode 100644
index 257dccf..0000000
--- a/conditions/course/tests/behat/trigger_pulsecondition_course.feature
+++ /dev/null
@@ -1,54 +0,0 @@
-@mod @mod_pulse @pulse_triggercondition @pulsecondition_course
-Feature: Course Completion trigger event.
- In To Verify Pulse Automation Template Conditions for Course Completion as a Teacher.
-
- Background:
- Given the following "course" exist:
- | fullname | shortname | category | enablecompletion |
- | Course 1 | C1 | 0 | 1 |
- And the following "users" exist:
- | username | firstname | lastname | email |
- | user1 | User | User 1 | user1@test.com |
- | user2 | User | User 2 | user2@test.com |
- | teacher1 | Teacher | User 1 | teacher1@test.com |
- And the following "course enrolments" exist:
- | user | course | role |
- | teacher1 | C1 | editingteacher |
- | user1 | C1 | student |
- | user2 | C1 | student |
-
- @javascript
- Scenario: Check the pluse condition course trigger workflow.
- Given I log in as "admin"
- Then I create automation template with the following fields to these values:
- | Title | WELCOME MESSAGE 01 |
- | Reference | Welcomemessage |
- Then I create automation template with the following fields to these values:
- | Title | WELCOME MESSAGE 02 |
- | Reference | Welcomemessage02 |
- Then I create "Welcomemessage" template with the set the condition:
- | Triggers | Course completion |
- | Trigger operator | All |
- And I am on "Course 1" course homepage
- And I follow "Automation"
- When I open the autocomplete suggestions list
- And I click on "WELCOME MESSAGE 01" item in the autocomplete list
- Then I press "Add automation instance"
- And I set the following fields to these values:
- | insreference | Welcomemessage |
- Then I follow "Condition"
- Then I should see "Course completion"
- Then the field "Course completion" matches value "All"
- And I press "Save changes"
- When I open the autocomplete suggestions list
- And I click on "WELCOME MESSAGE 02" item in the autocomplete list
- Then I press "Add automation instance"
- And I set the following fields to these values:
- | insreference | Welcomemessage2 |
- Then I follow "Condition"
- Then I should see "Course completion" in the "#id_course" "css_element"
- Then the field "Course completion" matches value "Disable"
- Then I wait "5" seconds
- Then I click on "input[name='override[condition_course_status]'].checkboxgroupautomation" "css_element"
- And I set the field "Course completion" to "All"
- And I press "Save changes"
diff --git a/conditions/course/version.php b/conditions/course/version.php
deleted file mode 100644
index 4538f17..0000000
--- a/conditions/course/version.php
+++ /dev/null
@@ -1,27 +0,0 @@
-.
-
-/**
- * Pulse conditions Version - Pulse module course condition version and name defined.
- *
- * @package pulsecondition_course
- * @copyright 2023, bdecent gmbh bdecent.de
- * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
- */
-defined('MOODLE_INTERNAL') || die();
-
-$plugin->component = 'pulsecondition_course';
-$plugin->version = 2023080201;
diff --git a/conditions/enrolment/classes/conditionform.php b/conditions/enrolment/classes/conditionform.php
deleted file mode 100644
index bd20262..0000000
--- a/conditions/enrolment/classes/conditionform.php
+++ /dev/null
@@ -1,99 +0,0 @@
-.
-
-/**
- * Conditions - Pulse condition class for the "Enrolment Completion".
- *
- * @package pulsecondition_enrolment
- * @copyright 2023, bdecent gmbh bdecent.de
- * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
- */
-namespace pulsecondition_enrolment;
-
-use mod_pulse\automation\condition_base;
-
-/**
- * Pulse automation conditions form and basic details.
- */
-class conditionform extends \mod_pulse\automation\condition_base {
-
- /**
- * Verify the user is enroled in the course which is configured in the conditions for the notification.
- *
- * @param stdclass $instancedata
- * @param int $userid
- * @param \completion_info $completion
- * @return bool
- */
- public function is_user_completed($instancedata, int $userid, \completion_info $completion=null) {
- $courseid = $instancedata->courseid;
- $context = \context_course::instance($courseid);
-
- return is_enrolled($context, $userid);
- }
-
- /**
- * Include data to action.
- *
- * @param array $option
- * @return void
- */
- public function include_condition(&$option) {
- $option['enrolment'] = get_string('enrolment', 'pulsecondition_enrolment');
- }
-
- /**
- * Loads the form elements for enrolment condition.
- *
- * @param MoodleQuickForm $mform The form object.
- * @param object $forminstance The form instance.
- */
- public function load_instance_form(&$mform, $forminstance) {
-
- $completionstr = get_string('enrolment', 'pulsecondition_enrolment');
- $mform->addElement('select', 'condition[enrolment][status]', $completionstr, $this->get_options());
- $mform->addHelpButton('condition[enrolment][status]', 'enrolment', 'pulsecondition_enrolment');
- }
-
- /**
- * User enrolled event observer. Triggeres the instance actions when user enrolled in the course.
- *
- * @param stdclass $eventdata
- * @return void
- */
- public static function user_enrolled($eventdata) {
- global $DB;
-
- $data = $eventdata->get_data();
- $courseid = $data['courseid'];
- $relateduserid = $data['userid'];
-
- // Trigger the instances, this will trigger its related actions for this user.
- $like = $DB->sql_like('pat.triggerconditions', ':value');
- $sql = "SELECT * FROM {pulse_autoinstances} ai
- JOIN {pulse_autotemplates} pat ON pat.id = ai.templateid
- JOIN {pulse_condition_overrides} co ON co.instanceid = ai.id
- WHERE ai.courseid=:courseid AND ($like OR co.triggercondition = 'enrol')";
-
- $params = ['courseid' => $courseid, 'value' => '%"enrol"%'];
- $instances = $DB->get_records_sql($sql, $params);
- foreach ($instances as $key => $instance) {
- // TODO: Condition status check.
- $condition = (new self())->trigger_instance($instance->instanceid, $relateduserid);
- }
- return true;
- }
-}
diff --git a/conditions/enrolment/db/events.php b/conditions/enrolment/db/events.php
deleted file mode 100644
index 43eed32..0000000
--- a/conditions/enrolment/db/events.php
+++ /dev/null
@@ -1,41 +0,0 @@
-.
-
-/**
- * DB Events - Define event observers for "User Enrolment Condition".
- *
- * @package pulsecondition_enrolment
- * @copyright 2023, bdecent gmbh bdecent.de
- * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
- */
-defined('MOODLE_INTERNAL') || die();
-
-// User created, deleted and updated event observers for the "User Enrolment Completion" condition in the pulse 2.0.
-$observers = [
- [
- 'eventname' => 'core\event\user_enrolment_created',
- 'callback' => '\pulsecondition_enrolment\conditionform::user_enrolled',
- ],
- [
- 'eventname' => 'core\event\user_enrolment_deleted',
- 'callback' => '\pulsecondition_enrolment\conditionform::user_enrolled',
- ],
- [
- 'eventname' => 'core\event\user_enrolment_updated',
- 'callback' => '\pulsecondition_enrolment\conditionform::user_enrolled',
- ],
-];
-
diff --git a/conditions/enrolment/lang/en/pulsecondition_enrolment.php b/conditions/enrolment/lang/en/pulsecondition_enrolment.php
deleted file mode 100644
index a4df0f6..0000000
--- a/conditions/enrolment/lang/en/pulsecondition_enrolment.php
+++ /dev/null
@@ -1,28 +0,0 @@
-.
-
-/**
- * Strings for "Enrolment conditions", language 'en'.
- *
- * @package pulsecondition_enrolment
- * @copyright 2023, bdecent gmbh bdecent.de
- * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
- */
-defined('MOODLE_INTERNAL') || die();
-
-$string['pluginname'] = 'User enrolment';
-$string['enrolment'] = 'User enrolment';
-$string['enrolment_help'] = '
Enrolments: This automation will be triggered when a user is enrolled in the course where this instance is located.
Disabled: Enrolment condition is disabled.
All: Enrolment condition applies to all enrolments.
Upcoming: Enrolment condition only applies to future enrolments.';
diff --git a/conditions/enrolment/tests/behat/trigger_pulsecondition_enrolment.feature b/conditions/enrolment/tests/behat/trigger_pulsecondition_enrolment.feature
deleted file mode 100644
index a49eb44..0000000
--- a/conditions/enrolment/tests/behat/trigger_pulsecondition_enrolment.feature
+++ /dev/null
@@ -1,54 +0,0 @@
-@mod @mod_pulse @pulse_triggercondition @pulsecondition_enrolment
-Feature: Course Enrolment trigger event.
- In To Verify Pulse Automation Template Conditions for Course Enrolment as a Teacher.
-
- Background:
- Given the following "course" exist:
- | fullname | shortname | category | enablecompletion |
- | Course 1 | C1 | 0 | 1 |
- And the following "users" exist:
- | username | firstname | lastname | email |
- | user1 | User | User 1 | user1@test.com |
- | user2 | User | User 2 | user2@test.com |
- | teacher1 | Teacher | User 1 | teacher1@test.com |
- And the following "course enrolments" exist:
- | user | course | role |
- | teacher1 | C1 | editingteacher |
- | user1 | C1 | student |
- | user2 | C1 | student |
-
- @javascript
- Scenario: Check the pluse condition enrolment trigger workflow.
- Given I log in as "admin"
- Then I create automation template with the following fields to these values:
- | Title | WELCOME MESSAGE 01 |
- | Reference | Welcomemessage |
- Then I create automation template with the following fields to these values:
- | Title | WELCOME MESSAGE 02 |
- | Reference | Welcomemessage02 |
- Then I create "Welcomemessage" template with the set the condition:
- | Triggers | User enrolment |
- | Trigger operator | All |
- And I am on "Course 1" course homepage
- And I follow "Automation"
- When I open the autocomplete suggestions list
- And I click on "WELCOME MESSAGE 01" item in the autocomplete list
- Then I press "Add automation instance"
- And I set the following fields to these values:
- | insreference | Welcomemessage |
- Then I follow "Condition"
- Then I should see "User enrolment"
- Then the field "User enrolment" matches value "All"
- And I press "Save changes"
- When I open the autocomplete suggestions list
- And I click on "WELCOME MESSAGE 02" item in the autocomplete list
- Then I press "Add automation instance"
- And I set the following fields to these values:
- | insreference | Welcomemessage2 |
- Then I follow "Condition"
- Then I should see "User enrolment" in the "#id_enrolment" "css_element"
- Then the field "User enrolment" matches value "Disable"
- Then I wait "5" seconds
- Then I click on "input[name='override[condition_enrolment_status]'].checkboxgroupautomation" "css_element"
- And I set the field "User enrolment" to "All"
- And I press "Save changes"
diff --git a/conditions/enrolment/version.php b/conditions/enrolment/version.php
deleted file mode 100644
index 956240e..0000000
--- a/conditions/enrolment/version.php
+++ /dev/null
@@ -1,27 +0,0 @@
-.
-
-/**
- * Pulse conditions Version - Pulse module enrolment condition version and name defined.
- *
- * @package pulsecondition_enrolment
- * @copyright 2023, bdecent gmbh bdecent.de
- * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
- */
-defined('MOODLE_INTERNAL') || die();
-
-$plugin->component = 'pulsecondition_enrolment';
-$plugin->version = 2023080202;
diff --git a/conditions/events/backup/moodle2/backup_pulsecondition_events_subplugin.class.php b/conditions/events/backup/moodle2/backup_pulsecondition_events_subplugin.class.php
deleted file mode 100644
index 739e83b..0000000
--- a/conditions/events/backup/moodle2/backup_pulsecondition_events_subplugin.class.php
+++ /dev/null
@@ -1,59 +0,0 @@
-.
-
-/**
- * This file contains the class for backup of this submission plugin
- *
- * @package pulsecondition_events
- * @copyright 2023, bdecent gmbh bdecent.de
- * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
- */
-
-/**
- * Provides the information to backup submission files
- *
- * This just adds its filearea to the annotations and records the number of files
- *
- * @package pulsecondition_events
- * @copyright 2023, bdecent gmbh bdecent.de
- * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
- */
-class backup_pulsecondition_events_subplugin extends backup_subplugin {
-
- /**
- * Returns the subplugin information to attach to submission element
- * @return backup_subplugin_element
- */
- protected function define_pulse_autoinstances_subplugin_structure() {
-
- // Create XML elements.
- $subplugin = $this->get_subplugin_element();
-
- // Automation templates.
- $events = new \backup_nested_element('pulseconditionevents');
- $eventsfields = new \backup_nested_element('pulsecondition_events', ['id'], [
- "instanceid", "eventname", "notifyuser",
- ]);
-
- $subplugin->add_child($events);
- $events->add_child($eventsfields);
-
- $eventsfields->set_source_table('pulsecondition_events', ['instanceid' => \backup::VAR_PARENTID]);
-
- return $subplugin;
- }
-
-}
diff --git a/conditions/events/backup/moodle2/restore_pulsecondition_events_subplugin.class.php b/conditions/events/backup/moodle2/restore_pulsecondition_events_subplugin.class.php
deleted file mode 100644
index 0bc3546..0000000
--- a/conditions/events/backup/moodle2/restore_pulsecondition_events_subplugin.class.php
+++ /dev/null
@@ -1,64 +0,0 @@
-.
-
-/**
- * This file contains the class for restore of this pulse condition events plugin
- *
- * @package pulsecondition_events
- * @copyright 2023, bdecent gmbh bdecent.de
- * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
- */
-
-/**
- * Restore pulse action subplugin class.
- *
- */
-class restore_pulsecondition_events_subplugin extends restore_subplugin {
-
- /**
- * Returns the paths to be handled by the subplugin.
- * @return array
- */
- protected function define_pulse_autoinstances_subplugin_structure() {
-
- $paths = [];
-
- // We used get_recommended_name() so this works.
- $paths[] = new restore_path_element('pulsecondition_events',
- '/activity/pulse_autoinstances/notificationcondition/pulsecondition_events'
- );
-
- return $paths;
- }
-
- /**
- * Processes one pulsecondition_events element
- * @param mixed $data
- * @return void
- */
- public function process_pulsecondition_events($data) {
- global $DB;
-
- $data = (object) $data;
- // Get the new template id.
- $data->instanceid = $this->get_new_parentid('pulse_autoinstances');
-
- if (!$DB->record_exists('pulsecondition_events', ['instanceid' => $data->instanceid])) {
- $DB->insert_record('pulsecondition_events', $data);
- }
-
- }
-}
diff --git a/conditions/events/classes/conditionform.php b/conditions/events/classes/conditionform.php
deleted file mode 100644
index 2aecf24..0000000
--- a/conditions/events/classes/conditionform.php
+++ /dev/null
@@ -1,573 +0,0 @@
-.
-
-/**
- * Conditions - Pulse condition class for the "Course Completion".
- *
- * @package pulsecondition_events
- * @copyright 2023, bdecent gmbh bdecent.de
- * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
- */
-
-namespace pulsecondition_events;
-
-use core\context\user;
-use core\reportbuilder\local\entities\context;
-use mod_pulse\automation\condition_base;
-
-/**
- * Automation events completion condition form.
- */
-class conditionform extends \mod_pulse\automation\condition_base {
-
- /**
- * Repersents the affected user receive the notification.
- * @var int
- */
- const AFFECTED_USER = 1;
-
- /**
- * Repersents the related user receive the notification.
- * @var int
- */
- const RELATED_USER = 2;
-
-
- /**
- * Include condition
- *
- * @param array $option
- * @return void
- */
- public function include_condition(&$option) {
- $option['events'] = get_string('eventscompletion', 'pulsecondition_events');
- }
-
- /**
- * Status of the condition addon works based on the user enrolment.
- *
- * @return bool
- */
- public function is_user_enrolment_based() {
- return false;
- }
-
- /**
- * Gets available options. For events upcoming will be in top.
- *
- * @return array List of options.
- */
- public function get_options() {
- return [
- self::DISABLED => get_string('disable'),
- self::FUTURE => get_string('upcoming', 'pulse'),
- self::ALL => get_string('all'),
- ];
- }
-
- /**
- * Delete the records of condition for the custom instance.
- *
- * @param int $instanceid
- * @return void
- */
- public function delete_condition_instance(int $instanceid) {
- global $DB;
-
- if ($DB->delete_records('pulsecondition_events', ['instanceid' => $instanceid])) {
- purge_caches(['muc', 'other']);
- return true;
- }
-
- return false;
- }
-
- /**
- * Loads the form elements for events completion condition.
- *
- * @param MoodleQuickForm $mform The form object.
- * @param object $forminstance The form instance.
- */
- public function load_instance_form(&$mform, $forminstance) {
-
- $completionstr = get_string('eventscompletion', 'pulsecondition_events');
-
- $mform->addElement('select', 'condition[events][status]', $completionstr, $this->get_options());
- $mform->addHelpButton('condition[events][status]', 'eventscompletion', 'pulsecondition_events');
-
- // Events list.
- $eventlist = self::eventslist();
- $mform->addElement('autocomplete', 'condition[events][event]',
- get_string('selectevent', 'pulsecondition_events'), $eventlist);
- $mform->hideIf('condition[events][event]', 'condition[events][status]', 'eq', self::DISABLED);
- $mform->addHelpButton('condition[events][event]', 'selectevent', 'pulsecondition_events');
-
- // Select the which user has been recieve the notification.
- $option = [
- self::AFFECTED_USER => get_string('affecteduser', 'pulsecondition_events'),
- self::RELATED_USER => get_string('relateduser', 'pulsecondition_events'),
- ];
-
- $mform->addElement('select', 'condition[events][notifyuser]', get_string('notifyuser', 'pulsecondition_events'), $option);
- $mform->hideIf('condition[events][notifyuser]', 'condition[events][status]', 'eq', self::DISABLED);
- $mform->addHelpButton('condition[events][notifyuser]', 'notifyuser', 'pulsecondition_events');
-
- $mform->addElement('hidden', 'override[condition_events_event]', 1);
- $mform->setType('override[condition_events_event]', PARAM_INT);
-
- $mform->addElement('hidden', 'override[condition_events_notifyuser]', 1);
- $mform->setType('override[condition_events_notifyuser]', PARAM_INT);
-
- $courseid = $forminstance->get_customdata('courseid') ?? '';
- $modinfo = get_fast_modinfo($courseid);
- $cmlist = $modinfo->get_cms();
- $cmlist = array_map(fn($cm) => $cm->get_name(), $cmlist);
-
- $mform->addElement('autocomplete', 'condition[events][modules]',
- get_string('eventmodule', 'pulsecondition_events'), [0 => ''] + $cmlist);
- $mform->hideIf('condition[events][modules]', 'condition[events][status]', 'eq', self::DISABLED);
-
- $mform->addElement('hidden', 'override[condition_events_modules]', 1);
- $mform->setType('override[condition_events_modules]', PARAM_INT);
- }
-
- /**
- * Get the all event list form the moodle events list generator.
- *
- * @return array Events list.
- */
- public static function eventslist() {
-
- $completelist = \report_eventlist_list_generator::get_all_events_list();
-
- $list = [];
- foreach ($completelist as $key => $event) {
- $list[$key] = $event['raweventname'];
- }
- return $list;
- }
-
- /**
- * Verify the user is completed the events which is configured in the conditions for the notification.
- *
- * @param object $instancedata The instance data.
- * @param int $userid The user ID.
- * @param \completion_info|null $completion The completion information.
- * @return bool True if completed, false otherwise.
- */
- public function is_user_completed($instancedata, int $userid, \completion_info $completion=null) {
- global $DB;
-
- if (isset($instancedata->condition['events']) && $instancedata->condition['events']['status']) {
- $eventdata = $instancedata->condition['events'];
- list($sql, $params) = $this->generate_log_sql($eventdata, $userid, $instancedata);
- $status = $DB->record_exists_sql($sql, $params);
- return $status;
- }
-
- return false;
- }
-
- /**
- * Generate the log sql to fetch the event for the triggered event.
- *
- * @param array $eventdata
- * @param int $userid
- * @param stdClass $instancedata
- *
- * @return array
- */
- protected function generate_log_sql(array $eventdata, int $userid, $instancedata) {
-
- if (empty($eventdata)) {
- return [];
- }
-
- $sql = "SELECT *
- FROM {logstore_standard_log}
- WHERE eventname = :eventname ";
-
- $params['eventname'] = $eventdata['event'] ?? '';
- $params['userid'] = $userid;
-
- $notifyuser = $eventdata['notifyuser'] ?? 0;
-
- if ($notifyuser == self::AFFECTED_USER) {
- $sql .= " AND relateduserid = :userid ";
- } else if ($notifyuser == self::RELATED_USER) {
- $sql .= " AND userid = :userid ";
- }
-
- // Module configured.
- if (!empty($eventdata['modules'])) {
- $sql .= " AND contextinstanceid = :module";
- $params['module'] = $eventdata['modules'];
- }
-
- // Module not configured. then event should be core or the course id of the event is same as instance courseid.
- if (!empty($eventdata['modules'])) {
- $sql .= " AND (component = :core OR courseid = :courseid)";
- $params['courseid'] = $instancedata->courseid;
- $params['core'] = 'core';
- }
-
- // Upcoming condition check.
- if (!empty($eventdata['upcomingtime'])) {
- $sql .= 'AND timecreated >= :upcomingtime';
- $params['upcomingtime'] = $eventdata['upcomingtime'];
- }
-
- $sql .= ' ORDER BY id DESC ';
-
- return [$sql, $params];
- }
-
- /**
- * Pulse event condition trigger.
- *
- * @param stdclasss $eventdata event data.
- * @return bool
- */
- public static function pulse_event_condition_trigger($eventdata) {
- global $DB, $USER;
-
- $data = $eventdata->get_data();
-
- // Commit the database transaction.
- \core\event\manager::database_transaction_commited();
-
- // Events are stored in the log using the shutdown manager, it store the data end of the script.
- // Unfortuanlty the log will be stored to verify the event log to confirm the user is completed this conditions.
- // To store the data before, trigger the conditions check.
- // Fetch the log manager callback from shutdown handler and triggers the dispose method to store the event log data to DB.
- $obj = new \core_shutdown_manager();
- $reflection = new \ReflectionClass($obj);
- $property = $reflection->getProperty('callbacks');
- $property->setAccessible(true);
- $callbacks = $property->getValue($obj);
-
- // Get the log manager and trigger the dispose method.
- foreach ($callbacks as $lists) {
- foreach ($lists as $methods) {
- if (empty($methods)) {
- continue;
- }
- list($callback, $method) = $methods;
- if ($callback instanceof \tool_log\log\manager) {
- // Dispose the log manager to store the event entries.
- $callback->dispose();
- break;
- }
- }
- }
-
- $eventname = $eventdata->eventname ?? '';
-
- // Trigger the instances, this will trigger its related actions for this user.
- $instances = self::get_events_notifications($eventname);
-
- // Self condition instance.
- $condition = new self();
-
- foreach ($instances as $key => $instance) {
-
- $additional = $instance->additional ? json_decode($instance->additional) : (object)[];
-
- // Module configured for this instance event, and the event is not for this module, continue to next instance.
- if (property_exists($additional, 'modules') && $additional->modules &&
- $additional->modules !== $data['contextinstanceid']) {
- continue;
- }
-
- // Modules not configured, component of this event is not core, and the event course id is not this course.
- // Continue to next instance.
- if ((!property_exists($additional, 'modules') || !$additional->modules)
- && $data['component'] != 'core' && $data['courseid'] != $instance->courseid) {
- continue;
- }
-
- $notifyuser = $additional->notifyuser ?? 0;
-
- if ($notifyuser == self::AFFECTED_USER) {
- $userid = $data['relateduserid'] ?? $USER->id;
- } else if ($notifyuser == self::RELATED_USER) {
- $userid = $data['userid'] ?? $USER->id;
- }
-
- // TODO: Condition status check.
- $condition->trigger_instance($instance->instanceid, $userid);
- }
- return true;
-
- }
-
- /**
- * Fetch the list of instances which is used the triggered event in the access rules for the given method.
- *
- * Find the instance which contains the given event in the access rule (events).
- *
- * @param string $eventname name of the triggered event.
- * @return array
- */
- public static function get_events_notifications($eventname) {
- global $DB;
-
- $name = stripslashes($eventname);
-
- $like = $DB->sql_like('eve.eventname', ':value'); // Like query to fetch the instances assigned this event.
- $eventlike = $DB->sql_like('pat.triggerconditions', ':events');
-
- $sql = "SELECT *, ai.id as id, ai.id as instanceid FROM {pulse_autoinstances} ai
- JOIN {pulse_autotemplates} pat ON pat.id = ai.templateid
- LEFT JOIN {pulse_condition_overrides} co ON co.instanceid = ai.id AND co.triggercondition = 'events'
- LEFT JOIN {pulsecondition_events} eve ON eve.instanceid = ai.id
- WHERE $like AND (co.status > 0 OR $eventlike)";
-
- $params = ['events' => '%"events"%', 'value' => $name];
-
- $records = $DB->get_records_sql($sql, $params);
-
- return $records;
- }
-
- /**
- * Fetch the events data form the condition overrides table.
- *
- * @return array $list event list
- */
- public static function get_events() {
- global $DB;
-
- $list = [];
- $events = []; // Events added for observe.
-
- $eventscoditiondata = $DB->get_records('pulse_condition_overrides', ['triggercondition' => 'events']);
- foreach ($eventscoditiondata as $data) {
- $additional = json_decode($data->additional);
- if (!isset($additional->event) || $additional->event == '') {
- continue;
- }
-
- // Verify the event is already observed in the pulse event condition, to prevent multiple observe of single event.
- if (in_array($additional->event, $events)) {
- continue;
- }
-
- $list[] = [
- 'eventname' => $additional->event,
- 'callback' => '\pulsecondition_events\conditionform::pulse_event_condition_trigger',
- ];
-
- // Prevent multiple event observer for one event.
- $events[] = $additional->event;
- }
- return $list ?? [];
- }
-
- /**
- * Schedule override join.
- *
- * @return array
- */
- public function schedule_override_join() {
-
- return [
- 'event.status as event_status, event.additional as event_additional, event.isoverridden as event_isoverridden',
- "LEFT JOIN {pulse_condition_overrides} event ON event.instanceid = pati.instanceid AND
- event.triggercondition = 'events'",
- ];
- }
-
- /**
- * List of placeholders rendered form the events.
- *
- * @return array
- */
- public function get_email_placeholders() {
-
- $vars = [
- "Event_Name",
- "Event_Namelinked",
- "Event_Description",
- "Event_Time",
- "Event_Context",
- "Event_Contextlinked",
- "Event_Affecteduserfullname",
- "Event_Affecteduserfullnamelinked",
- "Event_Relateduserfullname",
- "Event_Relateduserfullnamelinked",
- ];
- return ['Event' => $vars];
- }
-
- /**
- * Update email custom vars.
- *
- * @param int $userid
- * @param stdClass $instancedata
- * @param stdClass $schedulerecord
- * @return void
- */
- public function update_email_customvars($userid, $instancedata, $schedulerecord) {
- global $DB, $OUTPUT;
- // Check the event condition are set for this notification. if its added then load the event data for placeholders.
- $eventin = in_array('events', (array) $instancedata->template->triggerconditions);
- $eventin = (property_exists($schedulerecord, 'event_isoverridden') && $schedulerecord->event_isoverridden == 1)
- ? $schedulerecord->event_status : $eventin;
-
- if ($eventin) {
-
- $eventdata = (array) json_decode($schedulerecord->event_additional);
-
- list($sql, $params) = $this->generate_log_sql($eventdata, $userid, $instancedata);
- $record = $DB->get_record_sql($sql, $params, IGNORE_MULTIPLE);
-
- if (empty($record)) {
- return [];
- }
-
- $logmanager = get_log_manager();
- $event = (new \logstore_database\log\store($logmanager))->get_log_event($record);
-
- if ($event == null) {
- return [];
- }
-
- $vars = [];
- $vars['name'] = $event->get_name();
-
- // Only encode as an action link if we're not downloading.
- if ($url = $event->get_url()) {
- $link = new \action_link($url, $vars['name'],
- new \popup_action('click', $url, 'action', ['height' => 440, 'width' => 700]));
- $vars['namelinked'] = $OUTPUT->render($link);
- }
-
- $vars['description'] = $event->get_description();
-
- // Event time.
- $dateformat = get_string('strftimedatetimeaccurate', 'core_langconfig');
- $vars['time'] = userdate($event->timecreated, $dateformat);
-
- // Event_Context.
- if ($event->contextid) {
- // If context name was fetched before then return, else get one.
- $context = \context::instance_by_id($event->contextid, IGNORE_MISSING);
- $vars['context'] = ($context) ? $context->get_context_name(true) : get_string('other');
-
- // Event_Contextlinked.
- if ($context instanceof \context) {
- if ($url = $context->get_url()) {
- $vars['contextlinked'] = \html_writer::link($url, $vars['context']);
- }
- }
- }
- // Event_Affecteduserfullname.
- if (!empty($event->relateduserid)) {
- $vars['affecteduserfullname'] = $this->get_user_fullname($event->relateduserid);
- $params = ['id' => $event->relateduserid];
- if ($event->courseid) {
- $params['course'] = $event->courseid;
- }
- // Event_Affecteduserfullnamelinked.
- $vars['affecteduserfullnamelinked'] = \html_writer::link(
- new \moodle_url('/user/view.php', $params), $vars['affecteduserfullname']);
- }
- // Event_Relateduserfullname.
- if (!empty($event->userid) && $vars['relateduserfullname'] = $this->get_user_fullname($event->userid)) {
- $params = ['id' => $event->userid];
- if ($event->courseid) {
- $params['course'] = $event->courseid;
- }
- $vars['relateduserfullnamelinked'] = \html_writer::link(
- new \moodle_url('/user/view.php', $params), $vars['relateduserfullname']);
- }
-
- return ['event' => $vars];
- }
-
- return [];
- }
-
- /**
- * Gets the user full name.
- *
- * This function is useful because, in the unlikely case that the user is
- * not already loaded in $this->userfullnames it will fetch it from db.
- *
- * @since Moodle 2.9
- * @param int $userid
- * @return string|false
- */
- protected function get_user_fullname($userid) {
- global $PAGE;
-
- if (empty($userid)) {
- return false;
- }
-
- // If we reach that point new users logs have been generated since the last users db query.
- $userfieldsapi = \core_user\fields::for_name();
- $fields = $userfieldsapi->get_sql('', false, '', '', false)->selects;
- if ($user = \core_user::get_user($userid, $fields)) {
- $userfullname = fullname($user, has_capability('moodle/site:viewfullnames', $PAGE->context));
- } else {
- $userfullname = false;
- }
-
- return $userfullname;
- }
-
- /**
- * Defined the strucure of tables for the backup.
- *
- * @param [type] $instances
- * @return void
- */
- public function backup_define_structure(&$instances) {
- global $DB;
-
- // Automation templates.
- $events = new \backup_nested_element('automationtemplates');
- $eventsfields = new \backup_nested_element('pulse_autotemplates', ['id'], [
- "instanceid", "eventname", "notifyuser",
- ]);
-
- $instances->add_child($events);
- $events->add_child($eventsfields);
-
- $eventsfields->set_source_table('pulsecondition_events', ['instanceid' => \backup::VAR_PARENTID]);
- }
-
- /**
- * After save the condition form, clear the observers from cache and recreated the list.
- *
- * @param int $instanceid
- * @param object $data
- * @return void
- */
- public function process_instance_save($instanceid, $data) {
- parent::process_instance_save($instanceid, $data);
-
- // Remove the event observers and recreate.
- $cache = \cache::make('core', 'observers');
- $cache->delete('all');
- // Build the observers again.
- $list = \core\event\manager::get_all_observers();
- $cache->set('all', $list);
- purge_caches(['muc', 'other']);
- }
-}
diff --git a/conditions/events/db/events.php b/conditions/events/db/events.php
deleted file mode 100644
index cb81e17..0000000
--- a/conditions/events/db/events.php
+++ /dev/null
@@ -1,31 +0,0 @@
-.
-
-/**
- * Define event observers.
- *
- * @package pulsecondition_events
- * @copyright 2023, bdecent gmbh bdecent.de
- * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
- */
-
-/**
- * Need to define list of events that plugin will go to observe.
- */
-
-defined('MOODLE_INTERNAL') || die();
-
-$observers = \pulsecondition_events\conditionform::get_events();
diff --git a/conditions/events/db/install.xml b/conditions/events/db/install.xml
deleted file mode 100644
index 87b0bcf..0000000
--- a/conditions/events/db/install.xml
+++ /dev/null
@@ -1,19 +0,0 @@
-
-
-
-
-
-
diff --git a/conditions/events/lang/en/pulsecondition_events.php b/conditions/events/lang/en/pulsecondition_events.php
deleted file mode 100644
index 18d0bcf..0000000
--- a/conditions/events/lang/en/pulsecondition_events.php
+++ /dev/null
@@ -1,37 +0,0 @@
-.
-
-/**
- * Strings for "events condition", language 'en'.
- *
- * @package pulsecondition_events
- * @copyright 2023, bdecent gmbh bdecent.de
- * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
- */
-defined('MOODLE_INTERNAL') || die();
-
-$string['pluginname'] = 'Events completion';
-$string['eventscompletion'] = 'Events completion';
-$string['eventscompletion_help'] = '
Events Completion: This automation will be triggered when the event extention has been granted, where this instance is used.
Disabled:Events completion condition is disabled.
All:Events completion condition applies to all enrolled users.
Upcoming:Events completion condition only applies to future enrolments.';
-$string['selectevent'] = 'Event';
-$string['selectevent_help'] = 'Select the event from the available events on the Moodle site.';
-$string['notifyuser'] = 'User';
-$string['notifyuser_help'] = 'Choose the user who will be monitored for the specified event and will receive the notification.
-
Affected User:This refers to the user who is directly impacted or affected by the event. For example, if a user submits an assignment, the affected user would be the one who submitted the assignment.
-
Related User:This refers to any other user who is related to or associated with the event in some way, but may not be directly affected by it. This could include users who are part of the same course, group, or organization, or users who have some connection to the event through their roles or permissions.';
-$string['relateduser'] = 'Related user';
-$string['affecteduser'] = 'Affected user';
-$string['eventmodule'] = 'Event module';
diff --git a/conditions/events/lib.php b/conditions/events/lib.php
deleted file mode 100644
index 36f497d..0000000
--- a/conditions/events/lib.php
+++ /dev/null
@@ -1,43 +0,0 @@
-.
-
-/**
- * Pulse events condition libarary file.
- *
- * @package pulsecondition_events
- * @copyright 2023, bdecent gmbh bdecent.de
- * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
- */
-
-/**
- * Fetch the events data form the condition overrides table.
- *
- * @return array $list event list
- */
-function get_events() {
- global $DB;
-
- $list = [];
- $eventscoditiondata = $DB->get_records('pulse_condition_overrides', ['triggercondition' => 'events']);
- foreach ($eventscoditiondata as $data) {
- $additional = json_decode($data->additional);
- $list[] = [
- 'eventname' => $additional->event,
- 'callback' => '\pulsecondition_course\eventobserver::pulse_event_condition_triggered',
- ];
- }
- return $list ?? [];
-}
diff --git a/conditions/events/version.php b/conditions/events/version.php
deleted file mode 100644
index c386e42..0000000
--- a/conditions/events/version.php
+++ /dev/null
@@ -1,27 +0,0 @@
-.
-
-/**
- * Pulse conditions Version - Pulse module events condition version and name defined.
- *
- * @package pulsecondition_events
- * @copyright 2023, bdecent gmbh bdecent.de
- * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
- */
-defined('MOODLE_INTERNAL') || die();
-
-$plugin->component = 'pulsecondition_events';
-$plugin->version = 2024033000;
diff --git a/conditions/session/classes/conditionform.php b/conditions/session/classes/conditionform.php
deleted file mode 100644
index 582f2a2..0000000
--- a/conditions/session/classes/conditionform.php
+++ /dev/null
@@ -1,360 +0,0 @@
-.
-
-/**
- * Conditions - Pulse condition class for the "Session Completion".
- *
- * @package pulsecondition_session
- * @copyright 2023, bdecent gmbh bdecent.de
- * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
- */
-namespace pulsecondition_session;
-
-defined('MOODLE_INTERNAL') || die();
-
-require_once($CFG->dirroot.'/mod/facetoface/lib.php');
-
-use mod_pulse\automation\condition_base;
-
-/**
- * Pulse automation session condition form and basic details.
- */
-class conditionform extends \mod_pulse\automation\condition_base {
-
- /**
- * Name of the session module.
- * @var string
- */
- const MODNAME = 'facetoface';
-
- /**
- * Include data to action.
- *
- * @param array $option
- * @return void
- */
- public function include_condition(&$option) {
- $option['session'] = get_string('sessionbooking', 'pulsecondition_session');
- }
-
- /**
- * Loads the form elements for session condition.
- *
- * @param MoodleQuickForm $mform The form object.
- * @param object $forminstance The form instance.
- */
- public function load_instance_form(&$mform, $forminstance) {
-
- $completionstr = get_string('sessionbooking', 'pulsecondition_session');
-
- $mform->addElement('select', 'condition[session][status]', $completionstr, $this->get_options());
- $mform->addHelpButton('condition[session][status]', 'sessionbooking', 'pulsecondition_session');
-
- $courseid = $forminstance->get_customdata('courseid') ?? '';
-
- // Include the suppress session settings for the instance.
- $list = [];
- $activities = get_all_instances_in_courses(static::MODNAME, [$courseid => $courseid]);
- array_map(function($value) use (&$list) {
- $list[$value->id] = format_string($value->name);
- }, $activities);
-
- $mform->addElement('autocomplete', 'condition[session][modules]',
- get_string('sessionmodule', 'pulsecondition_session'), $list);
- $mform->hideIf('condition[session][modules]', 'condition[session][status]', 'eq', self::DISABLED);
- $mform->addHelpButton('condition[session][modules]', 'sessionmodule', 'pulsecondition_session');
-
- // TODO: add this revention of override checkbox to dynamic instead of specific in each plugin.
- $mform->addElement('hidden', 'override[condition_session_modules]', 1);
- $mform->setType('override[condition_session_modules]', PARAM_RAW);
- }
-
- /**
- * Find the users is booked the session.
- *
- * @param stdclass $instancedata
- * @param int $userid
- * @param \completion_info $completion
- * @return bool
- */
- public function is_user_completed($instancedata, $userid, \completion_info $completion=null) {
- global $DB;
-
- // Get the notification suppres module ids.
- $additional = $instancedata->condition['session'] ?? [];
- $modules = $additional['modules'] ?? '';
- if (!empty($modules)) {
- $result = [];
-
- $sql = "SELECT count(*) FROM {facetoface_signups} f2f_su
- JOIN {facetoface_sessions} f2f_ss ON f2f_ss.id = f2f_su.sessionid
- JOIN {facetoface_signups_status} f2f_sts ON f2f_su.id = f2f_sts.signupid
- WHERE f2f_ss.facetoface = :f2fid AND f2f_su.userid = :userid
- AND f2f_sts.superceded != 1
- AND f2f_sts.statuscode >= :code AND f2f_sts.statuscode < :statuscode";
-
- $existingsignup = $DB->count_records_sql($sql, [
- 'f2fid' => $modules, 'userid' => $userid,
- 'code' => MDL_F2F_STATUS_REQUESTED, 'statuscode' => MDL_F2F_STATUS_NO_SHOW,
- ]);
-
- return ($existingsignup) ? true : false;
- }
- // Not configured any session modules.
- return false;
- }
-
- /**
- * Event observer to trigger actions when the user is signup to the session.
- *
- * @param stdclass $eventdata
- * @return bool
- */
- public static function signup_success($eventdata) {
- global $DB;
-
- // Event data.
- $data = $eventdata->get_data();
- $cmid = $data['contextinstanceid'];
- $userid = $data['userid'];
- $sessionid = $data['objectid'];
-
- // Get the info for the context.
- list($context, $course, $cm) = get_context_info_array($data['contextid']);
- // Self condition instance.
- $condition = new self();
- // Course completion info.
- $completion = new \completion_info($course);
-
- // Get all the notification instance configures the suppress with this session.
- $notifications = self::get_session_notifications($cm->instance);
-
- foreach ($notifications as $notification) {
- // Get the notification suppres module ids.
- $additional = $notification->additional ? json_decode($notification->additional, true) : '';
- $modules = $additional['modules'] ?? '';
-
- if (!empty($modules)) {
- $session = $DB->get_record('facetoface_sessions_dates', ['sessionid' => $sessionid]);
- // Trigger all the instance for notifications.
- $condition->trigger_instance($notification->instanceid, $userid, $session->timestart);
- }
- }
-
- return true;
- }
-
- /**
- * Fetch the list of menus which is used the triggered ID in the access rules for the given method.
- *
- * Find the menus which contains the given ID in the access rule (Role or cohorts).
- *
- * @param int $id ID of the triggered method, Role or cohort id.
- * @return array
- */
- public static function get_session_notifications($id) {
- global $DB;
-
- $like = $DB->sql_like('co.additional', ':value'); // Like query to fetch the instances assigned this module.
- $sessionlike = $DB->sql_like('pat.triggerconditions', ':session');
-
- $sql = "SELECT *, ai.id as id, ai.id as instanceid FROM {pulse_autoinstances} ai
- JOIN {pulse_autotemplates} pat ON pat.id = ai.templateid
- LEFT JOIN {pulse_condition_overrides} co ON co.instanceid = ai.id AND co.triggercondition = 'session'
- WHERE $like AND (co.status > 0 OR $sessionlike)";
- // Params.
- $params = ['session' => '%"session"%', 'value' => '%"'.$id.'"%'];
-
- $records = $DB->get_records_sql($sql, $params);
-
- return $records;
- }
-
- /**
- * Gets the session time for the notification.
- *
- * @param object $notification The notification data.
- * @param object $instancedata The instance data.
- * @return mixed The session start time or false if not found.
- */
- public static function get_session_time($notification, $instancedata) {
- global $DB;
-
- 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 : '';
- }
- return false;
- }
-
- /**
- * Get session data for a specific face-to-face ID and user ID.
- *
- * @param int $face2faceid The face-to-face ID.
- * @param int $userid The user ID.
- * @return array|null An array of session data or null if not found.
- */
- public static function get_session_data($face2faceid, $userid) {
- global $DB;
-
- $sql = "SELECT * FROM {facetoface_signups} f2f_su
- JOIN {facetoface_sessions_dates} f2f_sd ON f2f_sd.sessionid = f2f_su.sessionid
- JOIN {facetoface_sessions} f2f_ss ON f2f_ss.id = f2f_su.sessionid
- JOIN {facetoface_signups_status} f2f_sts ON f2f_su.id = f2f_sts.signupid
- WHERE f2f_ss.facetoface = :f2fid AND f2f_su.userid = :userid AND f2f_sd.timestart > :timestart
- AND f2f_sts.statuscode >= :code AND f2f_sts.statuscode < :statuscode";
-
- $existingsignup = $DB->get_records_sql($sql, [
- 'f2fid' => $face2faceid, 'userid' => $userid, 'timestart' => time(), 'code' => MDL_F2F_STATUS_REQUESTED,
- 'statuscode' => MDL_F2F_STATUS_NO_SHOW,
- ], 0, 1);
- return $existingsignup;
- }
-
- /**
- * Prepare the schedule for the user signup to the session.
- *
- * Gets the session from the param, and fetch the list of notification instance configured with this session.
- * Filters the users list selected to signup to the session with signup users and its status code.
- *
- * Then all the notification instances are triggered for the filtered users.
- *
- * @param int|null $instanceid Face to face instance id.
- * @return void
- */
- public static function prepare_session_signup_schedule(?int $instanceid=null) {
- global $PAGE, $DB;
-
- // Current session id.
- $sessionid = required_param('s', PARAM_INT);
-
- // Get the list of signup users.
- $session = facetoface_get_session($sessionid);
- $instanceid = $instanceid ?: $session->facetoface;
-
- $potentialuserselector = new \facetoface_candidate_selector('addselect', [
- 'sessionid' => $session->id, 'courseid' => $PAGE->course->id,
- ]);
- // Users to signup to the session.
- $addusers = optional_param_array($potentialuserselector->get_name(), [], PARAM_INT);
-
- list($insql, $inparams) = $DB->get_in_or_equal($addusers, SQL_PARAMS_NAMED, 'f2fu');
- $params = ['code' => MDL_F2F_STATUS_REQUESTED, 'statuscode' => MDL_F2F_STATUS_NO_SHOW, 'sessionid' => $sessionid];
-
- // Filter the users based on the signup status.
- $users = $DB->get_fieldset_sql("
- SELECT DISTINCT f2f_su.userid FROM {facetoface_signups} f2f_su
- JOIN {facetoface_signups_status} f2f_sts ON f2f_su.id = f2f_sts.signupid
- WHERE f2f_su.sessionid=:sessionid
- AND f2f_sts.statuscode >= :code AND f2f_sts.statuscode < :statuscode
- AND f2f_su.userid $insql
- GROUP BY f2f_su.userid
- ", $params + $inparams);
-
- // Self condition instance.
- $condition = new self();
-
- // Fetch the session notifications uses this session signup.
- $notifications = self::get_session_notifications($instanceid);
-
- foreach ($notifications as $notification) {
- // Get the notification suppres module ids.
- $additional = $notification->additional ? json_decode($notification->additional, true) : '';
- $modules = $additional['modules'] ?? '';
-
- if (!empty($modules)) {
-
- $session = $DB->get_record('facetoface_sessions_dates', ['sessionid' => $sessionid]);
- // Trigger all the instance for notifications.
- foreach ($users as $userid) {
- $condition->trigger_instance($notification->instanceid, $userid, $session->timestart);
- }
- }
-
- }
-
- }
-
- /**
- * Remove the schedule for the user removed from the session.
- *
- * Gets the session from the param, and fetch the list of notification instance configured with this session.
- * Filters the users list selected to remove signup from the session.
- *
- * Then all the notification instances are triggered for the filtered users. this will make the schedule on hold.
- *
- * @param int|null $instanceid Face to face instance id.
- * @return void
- */
- public static function remove_session_signup_schedule(?int $instanceid=null) {
- global $PAGE, $DB;
-
- // Current session id.
- $sessionid = required_param('s', PARAM_INT);
-
- // Get the list of signup users.
- $session = facetoface_get_session($sessionid);
- $instanceid = $instanceid ?: $session->facetoface;
-
- $potentialuserselector = new \facetoface_candidate_selector('removeselect', [
- 'sessionid' => $session->id, 'courseid' => $PAGE->course->id,
- ]);
- $removeusers = optional_param_array($potentialuserselector->get_name(), [], PARAM_INT);
-
- list($insql, $inparams) = $DB->get_in_or_equal($removeusers, SQL_PARAMS_NAMED, 'f2fu');
- $params = ['code' => MDL_F2F_STATUS_REQUESTED, 'statuscode' => MDL_F2F_STATUS_NO_SHOW, 'sessionid' => $sessionid];
-
- // Filter the users based on the signup status.
- $users = $DB->get_fieldset_sql("
- SELECT DISTINCT f2f_su.userid FROM {facetoface_signups} f2f_su
- JOIN {facetoface_signups_status} f2f_sts ON f2f_su.id = f2f_sts.signupid
- WHERE f2f_su.sessionid=:sessionid
- AND f2f_sts.statuscode >= :code AND f2f_sts.statuscode < :statuscode
- AND f2f_su.userid $insql
- GROUP BY f2f_su.userid
- ", $params + $inparams);
-
- // Self condition instance.
- $condition = new self();
-
- // Fetch the session notifications uses this session signup.
- $notifications = self::get_session_notifications($instanceid);
-
- foreach ($notifications as $notification) {
- // Get the notification suppres module ids.
- $additional = $notification->additional ? json_decode($notification->additional, true) : '';
- $modules = $additional['modules'] ?? '';
-
- if (!empty($modules)) {
-
- $session = $DB->get_record('facetoface_sessions_dates', ['sessionid' => $sessionid]);
- // Trigger all the instance for notifications.
- foreach ($removeusers as $userid) {
- if (isset($users[$userid])) {
- continue;
- }
- // Trigger the instance will verify the user compleiton status of session signup.
- // In this case user is cancelled from the session, so the schedule status will be updated to on-hold.
- $condition->trigger_instance($notification->instanceid, $userid, $session->timestart);
- }
- }
-
- }
-
- }
-}
diff --git a/conditions/session/db/events.php b/conditions/session/db/events.php
deleted file mode 100644
index 57536c4..0000000
--- a/conditions/session/db/events.php
+++ /dev/null
@@ -1,40 +0,0 @@
-.
-
-/**
- * DB Events - Define event observers for "Session module Condition".
- *
- * @package pulsecondition_session
- * @copyright 2023, bdecent gmbh bdecent.de
- * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
- */
-defined('MOODLE_INTERNAL') || die();
-
-// Signup success and signup failed event observers for the "Session module Completion" condition in the pulse 2.0.
-$observers = [
- [
- 'eventname' => '\mod_facetoface\event\signup_success',
- 'callback' => '\pulsecondition_session\conditionform::signup_success',
- ],
- [
- 'eventname' => '\mod_facetoface\event\signup_failed',
- 'callback' => '\pulsecondition_session\conditionform::signup_success',
- ],
- [
- 'eventname' => '\mod_facetoface\event\cancel_booking',
- 'callback' => '\pulsecondition_session\conditionform::signup_success',
- ],
-];
diff --git a/conditions/session/lang/en/pulsecondition_session.php b/conditions/session/lang/en/pulsecondition_session.php
deleted file mode 100644
index 28ab932..0000000
--- a/conditions/session/lang/en/pulsecondition_session.php
+++ /dev/null
@@ -1,30 +0,0 @@
-.
-
-/**
- * Strings for "Session module condition", language 'en'.
- *
- * @package pulsecondition_session
- * @copyright 2023, bdecent gmbh bdecent.de
- * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
- */
-defined('MOODLE_INTERNAL') || die();
-
-$string['pluginname'] = 'Session booking';
-$string['sessionbooking'] = 'Session booking';
-$string['sessionmodule'] = 'Session module';
-$string['sessionmodule_help'] = 'Select the session module for this session booking condition.';
-$string['sessionbooking_help'] = '
Session: This automation will be triggered when a session is booked within the course. This trigger is only available within the course and should be selected within the automation instance.The options for session triggers include:
Disabled: Session trigger is disabled.
All: Session trigger applies to all enrolled users.
Upcoming: Session trigger only applies to future enrolments.';
diff --git a/conditions/session/lib.php b/conditions/session/lib.php
deleted file mode 100644
index 0dbd9a6..0000000
--- a/conditions/session/lib.php
+++ /dev/null
@@ -1,83 +0,0 @@
-.
-
-/**
- * Pulse condition session common functions to observe moodle default hooks
- *
- * @package pulsecondition_session
- * @copyright 2023, bdecent gmbh bdecent.de
- * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
- */
-
- /**
- * Name of the session module.
- */
-define('PULSE_SESSION_MOD', 'facetoface');
-
-/**
- * Type of the edit attendees page.
- */
-define('PULSE_SESSION_MOD_EDITPAGEID', 'mod-facetoface-editattendees');
-
-/**
- * Extended the course navigation to observe the user add/remove from session from the backend by admin/managers.
- * Verify the add param and verifies the page is session edit attendees page. Then triggers the schedule preparation.
- *
- * @param navigation_node $navigation
- * @param stdClass $course Course info data.
- * @param \context $context
- * @return void
- */
-function pulsecondition_session_extend_navigation_course(navigation_node $navigation, stdClass $course, $context) {
- global $PAGE, $SCRIPT;
-
- // Verify the page is facetoface edit attendees page and the admin/teachers added user to signup from backend.
- // Trigger the pulse to get the list of new user signup in this session and create a schedule for those users.
- $addselect = optional_param_array('addselect', [], PARAM_INT);
- if (optional_param('add', false, PARAM_BOOL) && !empty($addselect)) {
-
- if ($PAGE->pagetype == PULSE_SESSION_MOD_EDITPAGEID && $PAGE->cm->modname == PULSE_SESSION_MOD) {
- \pulsecondition_session\conditionform::prepare_session_signup_schedule($PAGE->cm->instance);
- return true;
- }
-
- // When the error is raised during the signup, face to face throw exception,
- // This exception prevents the above schedule content to run.
- // Throw exception resets the PAGE urls, cm info, for the reason.
- // In this case the page is set as site index and the course is not frontpage but the current file path is facetoface.
- if ($PAGE->pagetype == 'site-index' && $PAGE->course->id != SITEID && $SCRIPT == '/mod/facetoface/editattendees.php') {
- \pulsecondition_session\conditionform::prepare_session_signup_schedule();
- return true;
- }
- }
-
- // Verify the page is facetoface edit attendees page and the admin/teachers added user to signup from backend.
- // Trigger the pulse to get the list of new user signup in this session and create a schedule for those users.
- $removeusers = optional_param_array('removeselect', [], PARAM_INT);
- if (optional_param('remove', false, PARAM_BOOL) && !empty($removeusers)) {
-
- if ($PAGE->pagetype == PULSE_SESSION_MOD_EDITPAGEID && $PAGE->cm->modname == PULSE_SESSION_MOD) {
- \pulsecondition_session\conditionform::remove_session_signup_schedule($PAGE->cm->instance);
- return true;
- }
-
- if ($PAGE->pagetype == 'site-index' && $PAGE->course->id != SITEID && $SCRIPT == '/mod/facetoface/editattendees.php') {
- \pulsecondition_session\conditionform::remove_session_signup_schedule();
- return true;
- }
-
- }
-}
diff --git a/conditions/session/tests/behat/trigger_pulsecondition_session.feature b/conditions/session/tests/behat/trigger_pulsecondition_session.feature
deleted file mode 100644
index 0d73640..0000000
--- a/conditions/session/tests/behat/trigger_pulsecondition_session.feature
+++ /dev/null
@@ -1,69 +0,0 @@
-@mod @mod_pulse @pulse_triggercondition @pulsecondition_session
-Feature: Session trigger event.
- In To Verify Pulse Automation Template Conditions for Session as a Teacher.
-
- Background:
- Given the following "course" exist:
- | fullname | shortname | category | enablecompletion |
- | Course 1 | C1 | 0 | 1 |
- And the following "users" exist:
- | username | firstname | lastname | email |
- | user1 | User | User 1 | user1@test.com |
- | user2 | User | User 2 | user2@test.com |
- | teacher1 | Teacher | User 1 | teacher1@test.com |
- And the following "course enrolments" exist:
- | user | course | role |
- | teacher1 | C1 | editingteacher |
- | user1 | C1 | student |
- | user2 | C1 | student |
-
- @javascript
- Scenario: Check the pluse condition sesion trigger workflow.
- Given I log in as "admin"
- And I am on "Course 1" course homepage with editing mode on
- And I press "Add an activity or resource"
- And I click on "Add a new Face-to-Face" "link" in the "Add an activity or resource" "dialogue"
- And I set the field "Name" to "FaceFace 01"
- And I press "Save and return to course"
- Then "FaceFace 01" activity should be visible
- And I press "Add an activity or resource"
- And I click on "Add a new Face-to-Face" "link" in the "Add an activity or resource" "dialogue"
- And I set the field "Name" to "FaceFace 02"
- And I press "Save and return to course"
- Then "FaceFace 02" activity should be visible
- Then I create automation template with the following fields to these values:
- | Title | WELCOME MESSAGE 01 |
- | Reference | Welcomemessage |
- Then I create automation template with the following fields to these values:
- | Title | WELCOME MESSAGE 02 |
- | Reference | Welcomemessage02 |
- Then I create "Welcomemessage" template with the set the condition:
- | Triggers | Session booking |
- | Trigger operator | All |
- And I am on "Course 1" course homepage
- And I follow "Automation"
- When I open the autocomplete suggestions list
- And I click on "WELCOME MESSAGE 01" item in the autocomplete list
- Then I press "Add automation instance"
- And I set the following fields to these values:
- | insreference | Welcomemessage |
- Then I follow "Condition"
- Then I should see "Session booking"
- Then the field "Session booking" matches value "All"
- And I should see "Session module"
- Then I should see "FaceFace 01" in the "#fitem_id_condition_session_modules" "css_element"
- And I press "Save changes"
- When I open the autocomplete suggestions list
- And I click on "WELCOME MESSAGE 02" item in the autocomplete list
- Then I press "Add automation instance"
- And I set the following fields to these values:
- | insreference | Welcomemessage2 |
- Then I follow "Condition"
- Then I should see "Session booking" in the "#id_session" "css_element"
- And I should not see "Session module" in the "#fitem_id_condition_session_modules" "css_element"
- Then the field "Session booking" matches value "Disable"
- Then I wait "5" seconds
- Then I click on "input[name='override[condition_session_status]'].checkboxgroupautomation" "css_element"
- And I set the field "Session booking" to "All"
- And I should see "Session module" in the "#fitem_id_condition_session_modules" "css_element"
- And I press "Save changes"
diff --git a/conditions/session/version.php b/conditions/session/version.php
deleted file mode 100644
index a6437b7..0000000
--- a/conditions/session/version.php
+++ /dev/null
@@ -1,28 +0,0 @@
-.
-
-/**
- * Pulse conditions Version - Pulse module session condition version and name defined.
- *
- * @package pulsecondition_session
- * @copyright 2023, bdecent gmbh bdecent.de
- * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
- */
-defined('MOODLE_INTERNAL') || die();
-
-$plugin->component = 'pulsecondition_session';
-$plugin->version = 2023080206;
-$plugin->dependencies = ['mod_facetoface' => 2021113000]; // Dependencies set for the session module "Face to Face".
diff --git a/db/access.php b/db/access.php
index 709120d..f76c71e 100644
--- a/db/access.php
+++ b/db/access.php
@@ -36,6 +36,7 @@
],
'clonepermissionsfrom' => 'moodle/course:manageactivities',
],
+
// Capability to view pulses.
'mod/pulse:view' => [
'captype' => 'read',
@@ -66,47 +67,4 @@
'clonepermissionsfrom' => 'mod/pulse:addinstance',
],
- 'mod/pulse:addtemplate' => [
- 'captype' => 'read',
- 'contextlevel' => CONTEXT_SYSTEM,
- 'archetypes' => [
- 'manager' => CAP_ALLOW,
- ],
- ],
-
- 'mod/pulse:viewtemplateslist' => [
- 'captype' => 'read',
- 'contextlevel' => CONTEXT_SYSTEM,
- 'archetypes' => [
- 'manager' => CAP_ALLOW,
- ],
- ],
-
- 'mod/pulse:addtemplateinstance' => [
- 'captype' => 'read',
- 'contextlevel' => CONTEXT_SYSTEM,
- 'archetypes' => [
- 'editingteacher' => CAP_ALLOW,
- 'manager' => CAP_ALLOW,
- ],
- ],
-
- 'mod/pulse:overridetemplateinstance' => [
- 'riskbitmask' => RISK_XSS,
- 'captype' => 'write',
- 'contextlevel' => CONTEXT_COURSE,
- 'archetypes' => [
- 'editingteacher' => CAP_ALLOW,
- 'manager' => CAP_ALLOW,
- ],
- ],
-
- 'mod/pulse:manageinstance' => [
- 'riskbitmask' => RISK_XSS,
- 'captype' => 'write',
- 'contextlevel' => CONTEXT_SYSTEM,
- 'archetypes' => [
- 'manager' => CAP_ALLOW,
- ],
- ],
];
diff --git a/db/events.php b/db/events.php
index a93327a..e67b5c8 100644
--- a/db/events.php
+++ b/db/events.php
@@ -35,10 +35,4 @@
'callback' => '\mod_pulse\eventobserver::user_enrolment_deleted',
],
- // To create a automation instance schedule for new user.
- [
- 'eventname' => 'core\event\user_enrolment_created',
- 'callback' => '\mod_pulse\eventobserver::user_enrolment_created',
- ],
-
];
diff --git a/db/install.xml b/db/install.xml
index 7637d43..efc6e36 100644
--- a/db/install.xml
+++ b/db/install.xml
@@ -80,70 +80,5 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/db/services.php b/db/services.php
index 4ec277b..0b746ed 100644
--- a/db/services.php
+++ b/db/services.php
@@ -34,13 +34,4 @@
'ajax' => true,
'loginrequired' => true,
],
-
- 'mod_pulse_manage_instances' => [
- 'classname' => 'mod_pulse\external',
- 'methodname' => 'manage_instances',
- 'description' => 'Bulk deleted the automation instances in the instance management table',
- 'type' => 'write',
- 'ajax' => true,
- 'loginrequired' => true,
- ],
];
diff --git a/db/subplugins.json b/db/subplugins.json
deleted file mode 100644
index c5b90ee..0000000
--- a/db/subplugins.json
+++ /dev/null
@@ -1,6 +0,0 @@
-{
- "plugintypes": {
- "pulseaction": "mod\/pulse\/actions",
- "pulsecondition": "mod\/pulse\/conditions"
- }
-}
diff --git a/db/upgrade.php b/db/upgrade.php
index ae1a730..34932f4 100644
--- a/db/upgrade.php
+++ b/db/upgrade.php
@@ -112,144 +112,5 @@ function xmldb_pulse_upgrade($oldversion) {
upgrade_mod_savepoint(true, 2021110200, 'pulse');
}
- if ($oldversion < 2023051802) {
-
- // Define table pulse_autoinstances to be created.
- $table = new xmldb_table('pulse_autoinstances');
- $table->add_field('id', XMLDB_TYPE_INTEGER, '9', null, XMLDB_NOTNULL, XMLDB_SEQUENCE, null, null);
- $table->add_field('templateid', XMLDB_TYPE_INTEGER, '9', null, XMLDB_NOTNULL, null, null, 'id');
- $table->add_field('courseid', XMLDB_TYPE_INTEGER, '9', null, XMLDB_NOTNULL, null, null, 'templateid');
- $table->add_field('status', XMLDB_TYPE_INTEGER, '9', null, null, null, '1', 'courseid');
- $table->add_field('timemodified', XMLDB_TYPE_INTEGER, '11', null, null, null, null, 'status');
- $table->add_key('primary', XMLDB_KEY_PRIMARY, ['id']);
-
- // Conditionally launch create table for pulse_autoinstaces.
- if (!$dbman->table_exists($table)) {
- $dbman->create_table($table);
- }
-
- // Define table pulse_autotemplates to be created.
- $table = new xmldb_table('pulse_autotemplates');
- $table->add_field('id', XMLDB_TYPE_INTEGER, '9', null, XMLDB_NOTNULL, XMLDB_SEQUENCE, null, null);
- $table->add_field('title', XMLDB_TYPE_CHAR, '255', null, XMLDB_NOTNULL, null, null, 'id');
- $table->add_field('reference', XMLDB_TYPE_CHAR, '100', null, XMLDB_NOTNULL, null, null, 'title');
- $table->add_field('visible', XMLDB_TYPE_INTEGER, '9', null, XMLDB_NOTNULL, null, '1', 'reference');
- $table->add_field('notes', XMLDB_TYPE_TEXT, null, null, null, null, null, 'visible');
- $table->add_field('status', XMLDB_TYPE_INTEGER, '9', null, XMLDB_NOTNULL, null, '1', 'notes');
- $table->add_field('tags', XMLDB_TYPE_TEXT, null, null, null, null, null, 'status');
- $table->add_field('tenants', XMLDB_TYPE_TEXT, null, null, null, null, null, 'tags');
- $table->add_field('categories', XMLDB_TYPE_TEXT, null, null, null, null, null, 'tenants');
- $table->add_field('triggerconditions', XMLDB_TYPE_TEXT, null, null, null, null, null, 'categories');
- $table->add_field('triggeroperator', XMLDB_TYPE_INTEGER, '9', null, null, null, '1', 'triggerconditions');
- $table->add_field('timemodified', XMLDB_TYPE_INTEGER, '11', null, null, null, null, 'triggeroperator');
- $table->add_key('primary', XMLDB_KEY_PRIMARY, ['id']);
-
- // Conditionally launch create table for pulse_autotemplates.
- if (!$dbman->table_exists($table)) {
- $dbman->create_table($table);
- }
-
- // Define table pulse_autotemplates_ins to be created.
- $table = new xmldb_table('pulse_autotemplates_ins');
- $table->add_field('id', XMLDB_TYPE_INTEGER, '9', null, XMLDB_NOTNULL, XMLDB_SEQUENCE, null, null);
- $table->add_field('instanceid', XMLDB_TYPE_INTEGER, '18', null, XMLDB_NOTNULL, null, null, 'id');
- $table->add_field('title', XMLDB_TYPE_CHAR, '255', null, null, null, null, 'instanceid');
- $table->add_field('insreference', XMLDB_TYPE_CHAR, '100', null, null, null, null, 'title');
- $table->add_field('notes', XMLDB_TYPE_TEXT, null, null, null, null, null, 'insreference');
- $table->add_field('tags', XMLDB_TYPE_TEXT, null, null, null, null, null, 'notes');
- $table->add_field('tenants', XMLDB_TYPE_TEXT, null, null, null, null, null, 'tags');
- $table->add_field('categories', XMLDB_TYPE_TEXT, null, null, null, null, null, 'tenants');
- $table->add_field('triggerconditions', XMLDB_TYPE_TEXT, null, null, null, null, null, 'categories');
- $table->add_field('triggeroperator', XMLDB_TYPE_INTEGER, '2', null, null, null, null, 'triggerconditions');
- $table->add_field('timemodified', XMLDB_TYPE_INTEGER, '11', null, null, null, null, 'triggeroperator');
- $table->add_key('primary', XMLDB_KEY_PRIMARY, ['id']);
- $table->add_key('unique', XMLDB_KEY_UNIQUE, ['instanceid']);
-
- // Conditionally launch create table for pulse_autotemplates_ins.
- if (!$dbman->table_exists($table)) {
- $dbman->create_table($table);
- }
-
- // Define table pulse_condition_overrides to be created.
- $table = new xmldb_table('pulse_condition_overrides');
- $table->add_field('id', XMLDB_TYPE_INTEGER, '18', null, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
- $table->add_field('instanceid', XMLDB_TYPE_INTEGER, '18', null, XMLDB_NOTNULL, null, null, 'id');
- $table->add_field('triggercondition', XMLDB_TYPE_CHAR, '200', null, XMLDB_NOTNULL, null, null, 'instanceid');
- $table->add_field('status', XMLDB_TYPE_INTEGER, '2', null, null, null, '0', 'triggercondition');
- $table->add_field('upcomingtime', XMLDB_TYPE_INTEGER, '18', null, null, null, null, 'status');
- $table->add_field('additional', XMLDB_TYPE_TEXT, null, null, null, null, null, 'status');
- $table->add_field('isoverridden', XMLDB_TYPE_INTEGER, '8', null, null, null, '1', 'additional');
- $table->add_key('primary', XMLDB_KEY_PRIMARY, ['id']);
- $table->add_key('unique', XMLDB_KEY_UNIQUE, ['instanceid', 'triggercondition']);
-
- // Conditionally launch create table for pulse_condition_overrides.
- if (!$dbman->table_exists($table)) {
- $dbman->create_table($table);
- }
-
- // Pulse savepoint reached.
- upgrade_mod_savepoint(true, 2023051802, 'pulse');
-
- }
-
- if ($oldversion < 2023051825) {
- // Auto templates instance.
- $instable = new xmldb_table('pulse_autotemplates_ins');
- $reference = new xmldb_field('reference', XMLDB_TYPE_CHAR, '100', null, null, null, null);
- // Verify field exists.
- if ($dbman->field_exists($instable, $reference)) {
- // Change the field.
- $dbman->rename_field($instable, $reference, 'insreference');
- }
-
- upgrade_mod_savepoint(true, 2023051825, 'pulse');
- }
-
- if ($oldversion < 2023051830) {
- // Auto templates instance.
- $instable = new xmldb_table('pulse_autotemplates_ins');
- $timemodified = new xmldb_field('timemodified', XMLDB_TYPE_INTEGER, '11', null, null, null, null);
- // Verify field exists.
- if ($dbman->field_exists($instable, $timemodified)) {
- // Change the field.
- $dbman->change_field_precision($instable, $timemodified);
- }
-
- // Update the templates table timemodified.
- $temptable = new xmldb_table('pulse_autotemplates');
- if ($dbman->field_exists($temptable, $timemodified)) {
- // Change the field.
- $dbman->change_field_precision($temptable, $timemodified);
- }
-
- // Update the pulse_autoinstances table timemodified.
- $autoinstable = new xmldb_table('pulse_autoinstances');
- if ($dbman->field_exists($autoinstable, $timemodified)) {
- // Change the field.
- $dbman->change_field_precision($autoinstable, $timemodified);
- }
-
- upgrade_mod_savepoint(true, 2023051830, 'pulse');
- }
-
- if ($oldversion < 2023100701) {
- // Auto templates instance.
- $instable = new xmldb_table('pulse_condition_overrides');
- $reference = new xmldb_field('isoverriden', XMLDB_TYPE_INTEGER, '8', null, null, null, '1');
- // Verify field exists.
- if ($dbman->field_exists($instable, $reference)) {
- // Change the field.
- $dbman->rename_field($instable, $reference, 'isoverridden');
- }
-
- // Upcoming time.
- $upcomingtime = new xmldb_field('upcomingtime', XMLDB_TYPE_INTEGER, '18', null, null, null, null, 'status');
- if (!$dbman->field_exists($instable, $upcomingtime)) {
- $dbman->add_field($instable, $upcomingtime);
- }
-
- upgrade_mod_savepoint(true, 2023100701, 'pulse');
- }
-
return true;
}
diff --git a/lang/en/pulse.php b/lang/en/pulse.php
index c9a560e..1ab556d 100644
--- a/lang/en/pulse.php
+++ b/lang/en/pulse.php
@@ -254,134 +254,13 @@
$string['enrolmentemptystartdate'] = '-';
$string['enrolmentemptyenddate'] = '-';
-// Strings for the pulse automation templates.
-// ...Template capabilities.
-$string['pulse:addtemplate'] = 'Add a new automation template';
-$string['pulse:viewtemplateslist'] = 'View the automation templates list';
-$string['pulse:addtemplateinstance'] = 'Add a new template instance';
-$string['pulse:sender'] = 'Notification sender user';
-
-// ...Templates list string.
-$string['autotemplates'] = 'Automation templates';
-$string['automation'] = 'Automation';
-$string['autotemplates_desc'] = 'Users with the appropriate permissions create automation templates globally, independent of specific courses. The template itself doesn\'t perform any actions, it serves as the foundation for creating the instances.';
-$string['autoinstance_desc'] = 'Users with the requisite permissions can generate automation instances by selecting an existing template. Within each automation instance, the initial values for settings are inherited from the template. However, should a user desire to deviate from the template\'s values, they have the option to locally override them by activating the "override" toggle and implementing local adjustments to the settings.';
-// ...create new template btn.
-$string['templatecreatenew'] = 'Create new template';
-// ...Edit templates page stirng.
-$string['templatessettings'] = 'Edit template';
-// ...Templates edit/create strings
-$string['reference'] = 'Reference';
-$string['show'] = 'Show';
-$string['hidden'] = 'Hidden';
-$string['visibility'] = 'Visibility';
-$string['internalnotes'] = 'Internal notes';
-$string['status'] = 'Status';
-$string['tags'] = 'Tags';
-$string['availablefortenants'] = 'Available for tenants';
-$string['availableincoursecategories'] = 'Available in course categories';
-$string['deleteinstance'] = 'Are you sure! do you want to delete the instance';
-// ...Auto templates user notifications strings.
-$string['templateupdatesuccess'] = 'Template updated successfully';
-$string['templateinsertsuccess'] = 'Template inserted successfully';
-$string['templatedeleted'] = 'Automation template instance deleted successfully.';
// ...Admin settings.
$string['generalsettings'] = 'General settings';
-$string['conditiontrigger'] = 'Triggers';
-$string['triggeroperator'] = 'Trigger operator';
-$string['all'] = 'All';
-$string['any'] = 'Any';
-// ...Add template in instance.
-$string['addtemplatebtn'] = 'Add automation instance';
-$string['managetemplate'] = 'Manage templates';
-$string['upcoming'] = 'Upcoming';
-// ...Form tabs
-$string['tabgeneral'] = 'General';
-$string['tabcondition'] = 'Condition';
-$string['autoinstances'] = 'Auto instances';
-$string['editinstance'] = 'Edit instance';
-// ...Update status modal
-$string['templatestatusudpate'] = 'Are you sure that you want to change the status of the template?
-
-- Choose Update Template if you only want to update the status of the template, but leave the instances untouched
.
-- Choose Update Template & Instances if you want to update the status of the template and also all of its instances.
';
-$string['instancecopy'] = 'Duplicate Instance';
-
-$string['instancereport'] = 'Instance automation schedules';
-$string['automationreportname'] = 'Automation schedule instances';
-$string['overrides'] = 'Overrides';
-$string['updateinstance'] = 'Update Template & Instance';
-$string['updatetemplate'] = 'Update Template';
-
-
-$string['instancename'] = 'Instance Name';
-$string['view'] = 'View';
-// ... Instance override modal title.
-$string['instanceoverrides'] = 'Overridden instances';
-
-// Help Texts.
-// Title.
-$string['title_help'] = 'Enter a
Title for this automation template. This title is for administrative purposes and helps identify the template.';
-// Reference.
-$string['reference_help'] = 'Provide a
Reference for this automation template. This identifier is also for administrative purposes and helps uniquely identify the template.';
-// Visibility.
-$string['visibility_help'] = 'Choose whether you want this template to be visible or hidden.
-
Note: If hidden, users won\'t be able to create new instances based on this template, but existing instances will still be available.';
-// Internal notes.
-$string['internalnotes_help'] = 'Add any internal notes or information related to this automation template.';
-// Status.
-$string['status_help'] = 'Select the status for this automation template:
Enabled: Allows instances of this template to be created. Enabling the template may also prompt the user to decide whether to enable all existing instances based on the template.
Disabled: Turns off the automation template and its instances. Users can still enable instances individually if needed. Disabling the template may prompt the user to decide whether to disable all existing instances based on the template.';
-// Tags.
-$string['tags_help'] = 'Add
Tags to this template for administrative purposes. Tags can help categorize and organize templates.';
-// Available for tenants.
-$string['availablefortenants_help'] = 'Specify for which Moodle Workplace
Tenants this template should be available. Select one or more tenants to make the template accessible to specific groups.';
-// Available in course categories.
-$string['availableincoursecategories_help'] = 'Choose the
Course categories where this template should be available. Select one or more categories to determine where users can create instances based on this template.';
-// Trigger operator.
-$string['triggeroperator_help'] = 'Choose the operator that determines how the selected triggers are evaluated:
Any: At least one of the selected triggers must occur to activate the automation.
All: All of the selected triggers must occur simultaneously to activate the automation.';
-// Condition trigger.
-$string['conditiontrigger_help'] = 'Choose the trigger events that will activate this automation. You can select one or more of the following trigger options:
Activity Completion: This automation will be triggered when an activity within the course is marked as completed. You will need to specify the activity within the automation instance.
Course Completion: This automation will be triggered when the entire course is marked as completed, where this instance is used.
Enrolments: This automation will be triggered when a user is enrolled in the course where this instance is located.
Session: This automation will be triggered when a session is booked within the course. This trigger is only available within the course and should be selected within the automation instance.
Cohort Membership: This automation will be triggered if the user is a member of one of the selected cohorts.';
// Number of schedules notification.
$string['schedulecount'] = 'Number of schedule count';
$string['schedulecountdesc'] = 'This setting allows you to control how many scheduled task notifications are sent during each cron run. By specifying a numerical value, you can regulate the rate at which system administrators receive notifications regarding the completion or status of scheduled tasks.';
-// ...Automation templates table instruction help texts.
-$string['instruction'] = 'Instructions';
-$string['automation_title'] = '
Template title ';
-$string['automation_reference'] = 'TEMPLATE_REFERENCE';
-$string['automationreferencedemo'] = 'WELCOME_MESSAGE';
-$string['automationtemplate_help1'] = 'The icon represents the enabled action(s) in the automation (template). the following actions are available: "Notification", "Assignment". "Membership", "Skills",';
-$string['automationtemplate_help2'] = 'The title of the automation
template. This should be a generic explanation about what the template is for. It can be changed inline by clicking on the pencil icon.';
-$string['automationtemplate_help3'] = 'The pills provide additional improtant information about the automation template. In this case, it explains that it\'s a notification.';
-$string['automationtemplate_help4'] = 'This is the reference of the template, and is providing a unique identifier for the template. it will be part of the unique identifier of the automation instance.';
-$string['automationtemplate_help5'] = 'Click on this icon to edit the template.';
-$string['automationtemplate_help6'] = 'Click on this icon to toggle the visibility of a template. A template which is not visible is hidden in courses. Existing automation instances will still be available, but new ones cannot be added anymore.';
-$string['automationtemplate_help7'] = 'Use this toggle to turn on or off a template. A template which is turned off also disabled all automation instances, unless they are locally enabled using an override';
-$string['automationtemplate_help8'] = 'How many automation instances are using the template? The number in brackets indicates the number of disabled instances.';
-
-// ...Automation instance table instruction help texts.
-$string['automationinstance_title'] = '
Instance title ';
-$string['automationinstance_reference'] = 'INSTANCE_REFERENCE';
-$string['automationinstance_help1'] = 'The icon represents the enabled action(s) in the automation (template). the following actions are available: "Notification", "Assignment". "Membership", "Skills",';
-$string['automationinstance_help2'] = 'The title of the automation
instance. This should be a generic explanation about what the template is for. It can be changed inline by clicking on the pencil icon.';
-$string['automationinstance_help3'] = 'The pills provide additional improtant information about the automation instance. In this case, it explains that it\'s a notification.';
-$string['automationinstance_help4'] = 'This is the reference of the instance, and acts as a unique identifier. It is (Usually) a combination of the template\'s reference combined with the course.';
-$string['automationinstance_help5'] = 'Click on this icon to edit the automation.';
-$string['automationinstance_help6'] = 'Duplicate the automation';
-$string['automationinstance_help7'] = 'Open the automation queue (in the report builder), which provides information about all the automations that ran.';
-$string['automationinstance_help8'] = 'Use this toggle to turn on or off the automation instance locally. This will override the status of the template, i.e. even if the template is turned off, it can be enabled.';
-$string['automationinstance_help9'] = 'Click on this icon to delete the automation instance.';
-
-// Pulse automation template profile navigation link.
-$string['pulsetemplink'] = "Pulse Automation Template";
-$string['completionenrolled'] = 'enrolled';
-// ...Automation template error.
-$string['errortemplatenotavailable'] = 'This automation template is not available for this course';
-
-// Override instance capability.
-$string['pulse:overridetemplateinstance'] = 'Override the automation instance';
-
// Email placeholders category.
$string['User_vars'] = 'User Profile';
$string['Course_vars'] = 'Course Information';
@@ -391,7 +270,9 @@
$string['Site_vars'] = 'Site';
$string['Mod_vars'] = 'Course activities';
$string['Mod_session_vars'] = 'Face to Face';
-$string['Assignment_vars'] = "Assignments";
+$string['Training_vars'] = "Training";
+$string['Mod_Metadata_vars'] = "Metedata";
+$string['Reaction_vars'] = 'Reaction';
// Email placeholders category help text.
$string['User_vars_help'] = 'User Profile placeholders';
@@ -402,60 +283,12 @@
$string['Site_vars_help'] = 'Site information placeholders';
$string['Mod_vars_help'] = 'Course activities information placeholders';
$string['Mod_session_vars_help'] = 'Face to Face module placeholders';
-$string['Assignment_vars_help'] = "Email placeholder for the assignment extension";
-
-// Manage Instance tab.
-$string['tabmanageinstance'] = 'Instance Management';
-$string['manageinstance'] = 'Manage Instance';
-$string['numberofinstance'] = 'Number of instance';
-$string['numberofoverrides'] = 'Number of overrides';
-$string['coursename'] = 'Course name';
-$string['coursecategory'] = 'Course category';
-$string['suspended'] = 'Suspended';
-$string['addinstance'] = 'Add Instance';
-$string['courseinsreport'] = 'Instances for this template';
-$string['selectall'] = 'Select all';
-$string['deselectall'] = 'De-select all';
-$string['selectwithoutins'] = 'Select all without instances';
-$string['filterlang'] = 'Filter';
-$string['bulkaction:deleteinstance'] = 'Delete instances ';
-$string['bulkaction:addinstance'] = 'Add instances ';
-$string['bulkaction:disableinstance'] = "Disable instances ";
-$string['bulkaction:enableinstance'] = "Enable instances ";
-$string['withselect'] = 'With selection:';
-$string['instancedataempty'] = 'Instance data empty';
-$string['confirmation'] = 'Confirmation';
-$string['confirmdeleteinstance'] = 'Are you sure! do you want to delete all instance for this selected courses.';
-$string['confirmaddinstance'] = 'Are you sure! do you want to add a instances for this selected courses.';
-$string['confirmenableinstance'] = 'Are you sure! do you want to enable the instances for this selected courses.';
-$string['confirmdisableinstance'] = 'Are you sure! do you want to disable the instances for this selected courses.';
-$string['templatedisablesuccess'] = 'Automation template instances disabled successfully';
-$string['templateenablesuccess'] = 'Automation template instances enabled successfully';
-$string['mixed'] = 'Mixed';
-$string['instanceslist'] = 'Course Instances List';
-
-// Manage Instance capability.
-$string['pulse:manageinstance'] = 'Access to the instance management';
-
-// Assignment Extension.
-$string['previously'] = 'Previously';
-$string['noextensiongranted'] = 'No extensions have been granted for upcoming assignments.';
-
-// Event Condition vars.
-$string['Event_vars'] = 'Logs';
-$string['Event_vars_help'] = 'Events conditions vars';
+$string['Training_vars_help'] = "Training information vars";
+$string['Mod_Metadata_vars_help'] = 'Metadata information vars';
+$string['Reaction_vars_help'] = 'pulse reaction vars';
$string['showmore'] = "Show more";
$string['showless'] = "Show less";
$string['vardocstr'] = "The full list of available placeholders can be found in the ";
$string['placeholder'] = "Placeholders";
$string['documentation'] = "documentation";
-$string['templatesorphanederror'] = 'Instance is orphaned';
-$string['templateorphaned'] = 'Orphaned';
-$string['Training_vars'] = "Training";
-$string['Training_vars_help'] = "Training information vars";
-$string['Mod_Metadata_vars'] = "Metedata";
-$string['Mod_Metadata_vars_help'] = 'Metadata information vars';
-$string['Reaction_vars'] = 'Reaction';
-$string['Reaction_vars_help'] = 'pulse reaction vars';
-$string['includepulseautomationinfo'] = 'Include pulse automation';
diff --git a/lib.php b/lib.php
index bd34f9b..d47654f 100644
--- a/lib.php
+++ b/lib.php
@@ -32,7 +32,6 @@
require_once($CFG->libdir."/completionlib.php");
require_once($CFG->dirroot.'/lib/filelib.php');
require_once($CFG->dirroot.'/mod/pulse/lib/vars.php');
-require_once($CFG->dirroot.'/mod/pulse/classes/table/manage_instance.php');
/**
* Add pulse instance.
@@ -595,124 +594,16 @@ function mod_pulse_output_fragment_completionbuttons($args) {
return json_encode($html);
}
-/**
- * Update the automation templates and instance title during edited directly on table using inplace editable.
- *
- * @param string $itemtype Template or Instance which is edited.
- * @param int $itemid ID of the edited template or instance
- * @param string $newvalue New value to updated
- * @return string Updated title of template or instance.
- */
-function mod_pulse_inplace_editable($itemtype, $itemid, $newvalue) {
- global $DB, $PAGE;
- $context = \context_system::instance();
- $PAGE->set_context($context);
- require_login();
-
- if ($itemtype === 'templatetitle') {
-
- $record = $DB->get_record('pulse_autotemplates', ['id' => $itemid], '*', MUST_EXIST);
- // Check permission of the user to update this item.
- require_capability('mod/pulse:addtemplate', context_system::instance());
- // Clean input and update the record.
- $newvalue = clean_param($newvalue, PARAM_NOTAGS);
- $DB->update_record('pulse_autotemplates', ['id' => $itemid, 'title' => $newvalue]);
- // Prepare the element for the output.
- $record->title = $newvalue;
- return new \core\output\inplace_editable('mod_pulse', 'title', $record->id, true,
- format_string($record->title), $record->title, 'Edit template title',
- 'New value for ' . format_string($record->title));
-
- } else if ($itemtype === 'instancetitle') {
-
- $record = $DB->get_record('pulse_autotemplates_ins', ['instanceid' => $itemid], '*', MUST_EXIST);
- // Check permission of the user to update this item.
- require_capability('mod/pulse:addtemplateinstance', context_system::instance());
- // Clean input and update the record.
- $newvalue = clean_param($newvalue, PARAM_NOTAGS);
- $DB->update_record('pulse_autotemplates_ins', ['id' => $record->id, 'title' => $newvalue]);
- // Prepare the element for the output.
- $record->title = $newvalue;
- return new \core\output\inplace_editable('mod_pulse', 'title', $record->id, true,
- format_string($record->title), $record->title, 'Edit template title',
- 'New value for ' . format_string($record->title));
- }
-}
-
-/**
- * Add the link in course secondary navigation menu to open the automation instance list page.
- *
- * @param navigation_node $navigation
- * @param stdClass $course
- * @param context_course $context
- * @return void
- */
-function mod_pulse_extend_navigation_course(navigation_node $navigation, stdClass $course, $context) {
- global $PAGE;
-
- $addnode = $context->contextlevel === CONTEXT_COURSE;
- $addnode = $addnode && has_capability('mod/pulse:addtemplateinstance', $context); // TODO: Custom capability.
- if ($addnode) {
- $id = $context->instanceid;
- $url = new moodle_url('/mod/pulse/automation/instances/list.php', [
- 'courseid' => $id,
- ]);
- $node = $navigation->create(get_string('automation', 'pulse'), $url, navigation_node::TYPE_SETTING, null, null);
- $node->add_class('automation-templates');
- $node->set_force_into_more_menu(false);
- $node->set_show_in_secondary_navigation(true);
- $node->key = 'automation-templates';
- $navigation->add_node($node, 'gradebooksetup');
- $PAGE->requires->js_call_amd('mod_pulse/automation', 'instanceMenuLink', []);
- }
-}
-
-/**
- * Defines pulse automation template list nodes for my profile navigation tree.
- *
- * @param \core_user\output\myprofile\tree $tree Tree object
- * @param stdClass $user user object
- * @param bool $iscurrentuser is the user viewing profile, current user ?
- * @param stdClass $course course object
- *
- * @return bool
- */
-function mod_pulse_myprofile_navigation(tree $tree, $user, $iscurrentuser, $course) {
- global $USER;
-
- // Get the pulse category.
- if (!array_key_exists('pulse', $tree->__get('categories'))) {
- // Create the category.
- $categoryname = get_string('pluginname', 'mod_pulse');
- $category = new core_user\output\myprofile\category('pulse', $categoryname, 'privacyandpolicies');
- $tree->add_category($category);
- } else {
- // Get the existing category.
- $category = $tree->__get('categories')['pulse'];
- }
-
- if ($iscurrentuser) {
- $systemcontext = \context_system::instance();
- if (has_capability('mod/pulse:viewtemplateslist', $systemcontext)) {
- $automationtemplate = new moodle_url('/mod/pulse/automation/templates/list.php');
- $pulsenode = new core_user\output\myprofile\node('pulse', 'pulse',
- get_string('pulsetemplink', 'mod_pulse'), null, $automationtemplate);
- $tree->add_node($pulsenode);
- }
- }
-}
-
/**
* Add email placeholder fields in form fields.
*
* @param string $editor
- * @param bool $automation
* @return void
*/
-function pulse_email_placeholders($editor, $automation=true) {
+function pulse_email_placeholders($editor) {
global $OUTPUT;
- $vars = \pulse_email_vars::vars($automation);
+ $vars = \pulse_email_vars::vars();
$i = 0;
foreach ($vars as $key => $var) {
@@ -744,22 +635,3 @@ function pulse_email_placeholders($editor, $automation=true) {
return $OUTPUT->render_from_template('mod_pulse/vars', $templatecontext);
}
-
-/**
- * Get the management instance table form the manageinstable table and return to the fragment.
- *
- * @param array $params
- * @return void
- */
-function mod_pulse_output_fragment_get_manageinstance_table(array $params) {
- global $OUTPUT;
-
- $templateid = $params['templateid'];
- ob_start();
- $table = new \mod_pulse\table\manage_instance($templateid);
- $table->out(20, true);
- $tablehtml = ob_get_contents();
- ob_end_clean();
-
- return $OUTPUT->render_from_template('mod_pulse/manageinstance_table', ['tablehtml' => $tablehtml]);
-}
diff --git a/lib/vars.php b/lib/vars.php
index 1e8ddfa..cb52238 100644
--- a/lib/vars.php
+++ b/lib/vars.php
@@ -23,7 +23,6 @@
*/
defined('MOODLE_INTERNAL') || die('No direct access');
-use mod_pulse\automation\helper;
use mod_pulse\helper as pulsehelper;
/**
* Filter for notification content placeholders.
@@ -108,41 +107,6 @@ class pulse_email_vars {
*/
protected $orgcourse = null;
- /**
- * Calendar data.
- *
- * @var object
- */
- public $calendar = null;
-
- /**
- * Assignment Extension data.
- *
- * @var object
- */
- public $assignment = null;
-
- /**
- * Conditions vars data.
- *
- * @var mixed
- */
- public $condition = null;
-
- /**
- * Event data.
- *
- * @var object
- */
- public $event = null;
-
- /**
- * Traning data.
- *
- * @var object
- */
- public $training = null;
-
/**
* Reaction Data
*
@@ -157,15 +121,13 @@ class pulse_email_vars {
* @param mixed $course Course data object
* @param mixed $sender Sender user record data.
* @param mixed $pulse Pulse instance record data.
- * @param mixed $condition Conditions data
* @return void
*/
- public function __construct($user, $course, $sender, $pulse, $condition=null) {
- global $CFG, $USER;
+ public function __construct($user, $course, $sender, $pulse) {
+ global $CFG;
- $newuser = !empty($user->id) ? $user : $USER;
self::convert_varstime_format($user);
- $this->user =& $newuser;
+ $this->user =& $user;
$this->sender =& $sender;
$wwwroot = $CFG->wwwroot;
@@ -190,21 +152,10 @@ public function __construct($user, $course, $sender, $pulse, $condition=null) {
$this->enrolment = $this->get_user_enrolment();
- $this->calendar = $this->get_calendar();
-
- $this->training = $this->training_data();
-
- $actionplugins = new \mod_pulse\plugininfo\pulseaction();
- $plugins = $actionplugins->get_plugins_base();
- foreach ($plugins as $component => $pluginbase) {
- $this->assignment = $pluginbase->get_assignment_extension($this->course->id, $this->user->id);
- }
-
if (pulsehelper::pulse_has_pro() && $this->pulse) {
$this->reaction = $this->reaction_data();
}
- $this->condition = $condition;
}
/**
@@ -252,11 +203,10 @@ private static function convert_varstime_format(&$var) {
/**
* Set up all the methods that can be called and used for substitution var in email templates.
*
- * @param bool $automation Display the vars related to the automation actions and conditions.
* @return array
*
**/
- public static function vars($automation=false) {
+ public static function vars() {
global $DB, $SITE;
$reflection = new ReflectionClass("pulse_email_vars");
@@ -272,37 +222,15 @@ public static function vars($automation=false) {
'Sender' => self::sender_data_fields(),
// Enrolment data fields.
'Enrolment' => self::enrolement_data_fields(),
- // Calendar data fields.
- 'Calendar' => self::calendar_data_fields(),
// Site data fields.
'Site' => self::site_data_fields(),
// Course activities data fields.
'Mod' => self::course_activities_data_fields(),
// Meta fields.
'Mod_Metadata' => self::module_meta_fields(),
- // Training fields.
- "Training" => self::training_data_fields(),
];
- if ($automation) {
- $actionplugins = new \mod_pulse\plugininfo\pulseaction();
- $plugins = $actionplugins->get_plugins_base();
- foreach ($plugins as $component => $pluginbase) {
- $result += $pluginbase->get_email_placeholders();
- }
-
- $plugins = \mod_pulse\plugininfo\pulsecondition::instance()->get_plugins_base();
- foreach ($plugins as $component => $pluginbase) {
- $result += $pluginbase->get_email_placeholders();
- }
-
- // Session data fields.
- $result += ['Mod_session' => self::session_fields()];
- }
-
- if (!$automation || $automation == 'all') {
- $result += \mod_pulse\extendpro::pulse_extend_reaction_placholder();
- }
+ $result += \mod_pulse\extendpro::pulse_extend_reaction_placholder();
// Remove empty vars.
$result = array_filter($result);
@@ -327,8 +255,6 @@ public function __get($name) {
if (method_exists($this, $object)) {
return $this->$object($property); // Call the method.
- } else if (array_key_exists($object, $this->condition)) {
- return $this->condition[$object][$property] ?? $this->blank;
} else if ($this->$object == null) {
return $this->blank;
}
@@ -431,12 +357,9 @@ public function get_user_enrolment() {
$firstinstance = current($enrolments);
$percentage = \core_completion\progress::get_course_progress_percentage($this->orgcourse, $this->user->id);
$progress = !empty($percentage) ? $percentage : 0;
- $courseduedate = helper::create()->timemanagement_details(
- 'coursedue', $this->orgcourse, $this->user->id, $this->coursecontext, $this->pulse);
return (object) [
'progress' => round($progress) .'%',
- 'courseduedate' => $courseduedate,
'status' => ($firstinstance->status == 1) ? get_string('suspended', 'mod_pulse') : get_string('active'),
'startdate' => $firstinstance->timestart
? userdate($firstinstance->timestart, get_string('strftimedatetimeshort', 'langconfig')) : $emptystartdate,
@@ -447,33 +370,6 @@ public function get_user_enrolment() {
return (object) ['startdate' => $emptystartdate, 'enddate' => $emptyenddate];
}
- /**
- * Fetch the traning data.
- *
- * @return array
- */
- public function training_data() {
- // Course user progress in percentage.
- $percentage = \core_completion\progress::get_course_progress_percentage($this->orgcourse, $this->user->id);
- $progress = !empty($percentage) ? $percentage : 0;
- $eventdates = helper::create()->timemanagement_details(
- 'eventdates', $this->orgcourse, $this->user->id, $this->coursecontext, $this->pulse);
- $upcomingmods = helper::create()->timemanagement_details(
- 'upcomingmods', $this->orgcourse, $this->user->id, $this->coursecontext, $this->pulse);
- $courseduedate = helper::create()->timemanagement_details(
- 'coursedue', $this->orgcourse, $this->user->id, $this->coursecontext, $this->pulse);
- $activityduedate = helper::create()->timemanagement_details(
- 'activityduedate', $this->orgcourse, $this->user->id, $this->coursecontext, $this->pulse);
-
- return (object) [
- 'upcomingmods' => $upcomingmods,
- 'courseprogress' => $progress ? round($progress) .'%' : '',
- 'eventdates' => $eventdates,
- 'coursedue' => $courseduedate,
- 'activityduedate' => $activityduedate,
- ];
- }
-
/**
* Include user profile fields with custom profile fields.
*
@@ -539,11 +435,7 @@ public static function course_fields() {
'groupmode', 'groupmodeforce', 'defaultgroupingid', 'lang', 'calendartype', 'theme', 'timecreated',
'timemodified', 'enablecompletion',
];
-
- $sql = "SELECT cf.shortname FROM {customfield_field} cf
- JOIN {customfield_category} cc ON cc.id = cf.categoryid
- WHERE cc.component = :component";
- $records = $DB->get_records_sql($sql, ['component' => 'core_course']);
+ $records = $DB->get_records('customfield_field', [], '', 'shortname');
$customfields = array_map(function($value) {
return 'customfield_'.$value;
@@ -632,18 +524,6 @@ public static function sender_data_fields() {
];
}
- /**
- * Calendar information list.
- *
- * @return array
- */
- public static function calendar_data_fields() {
- return [
- // Calendar information fields.
- 'Calendar_UpcomingActivitiesList', 'Calendar_EventDatesList',
- ];
- }
-
/**
* Enrolment information fields.
*
@@ -652,7 +532,7 @@ public static function calendar_data_fields() {
public static function enrolement_data_fields() {
return [
// Sender information fields .
- 'Enrolment_Status', 'Enrolment_Progress', 'Enrolment_Startdate', 'Enrolment_Enddate', 'Enrolment_Courseduedate',
+ 'Enrolment_Status', 'Enrolment_Progress', 'Enrolment_Startdate', 'Enrolment_Enddate',
];
}
@@ -680,36 +560,6 @@ public static function course_activities_data_fields() {
];
}
- /**
- * Training fields. Timemanagement ltools support.
- *
- * @return array
- */
- public static function training_data_fields() {
- return [
- 'Training_Upcomingmods', 'Training_Courseprogress', 'Training_Eventdates',
- 'Training_Coursedue', 'Training_Activityduedate',
- ];
- }
-
- /**
- * Get the Calendar data.
- *
- * @return array
- */
- public function get_calendar() {
-
- $eventdates = helper::create()->timemanagement_details(
- 'eventdates', $this->orgcourse, $this->user->id, $this->coursecontext, $this->pulse);
- $upcomingactivities = helper::create()->timemanagement_details(
- 'upcomingmods', $this->orgcourse, $this->user->id, $this->coursecontext, $this->pulse);
-
- return (object) [
- 'upcomingactivitieslist' => $upcomingactivities,
- 'eventdateslist' => $eventdates,
- ];
- }
-
/**
* Get the site data.
*
@@ -742,10 +592,9 @@ class EmailVars extends pulse_email_vars {
* Set up all the methods that can be called and used for substitution var in email templates.
* There is not use for this function, FIX for CI.
*
- * @param bool $automation
* @return array
**/
- public static function vars($automation=false) {
+ public static function vars() {
$test = ''; // FIX for Moodle CI codechecker.
return parent::vars();
}
diff --git a/mod_form.php b/mod_form.php
index 4e5fcb5..4dca6e2 100644
--- a/mod_form.php
+++ b/mod_form.php
@@ -111,7 +111,7 @@ public function definition() {
$section = optional_param('section', 0, PARAM_INT);
$PAGE->requires->js_call_amd('mod_pulse/preset', 'init', [$this->context->id, $PAGE->course->id, $section]);
- $placeholders = pulse_email_placeholders('content', false);
+ $placeholders = pulse_email_placeholders('content');
$mform->addElement('html', $placeholders);
// Show intro on course page always.
$mform->addElement('hidden', 'showdescription', 1);
diff --git a/settings.php b/settings.php
index 9768091..c03b05c 100644
--- a/settings.php
+++ b/settings.php
@@ -39,8 +39,3 @@
}
$ADMIN->add('modpulse', $settings);
$settings = null; // Reset the settings.
-
-// Include the external page automation settings.
-$automation = new admin_externalpage('pulseautomation', get_string('autotemplates', 'pulse', null, true),
- new moodle_url('/mod/pulse/automation/templates/list.php'), 'mod/pulse:viewtemplateslist');
-$ADMIN->add('modpulse', $automation);
diff --git a/styles.css b/styles.css
index 236c00e..238f95f 100644
--- a/styles.css
+++ b/styles.css
@@ -133,260 +133,12 @@
font-size: 1.5rem;
}
-.mod-pulse-automation-table .template-add-form .btn {
- margin-left: 10px;
-}
-
-/* Auto templates styles */
-#pulse_automation_template thead {
- display: none;
-}
-.mod-pulse-automation-table .updatestatus-switch-form .custom-control-input {
- width: 100%;
- z-index: 1;
-}
-
-/* Automation templates table */
-.mod-pulse-automation-table .template-add-form .form-group {
- margin: 0;
- display: inline-block;
- vertical-align: top;
-}
-.mod-pulse-automation-table .template-add-form .form-group .col-md-3 {
- width: 0;
- max-width: none;
- flex: 0;
- padding: 0;
- margin: 0;
-}
-.mod-pulse-automation-table .template-add-form .form-group .col-md-9 {
- max-width: none;
- padding: 0;
- margin-top: 1rem;
-}
-/* .mod-pulse-automation-table .template-add-form {
- display: flex;
- align-items: center;
-} */
-.mod-pulse-automation-table .template-add-form > * {
- display: inline-block;
- vertical-align: top;
-}
-.mod-pulse-automation-table .template-add-form > a.btn {
- margin-top: 1rem;
- margin-bottom: 1rem;
-}
-.mod-pulse-automation-table table.generaltable {
- border-spacing: 0 10px;
- border-collapse: separate;
- padding: 0 10px;
- margin-top: 20px;
-}
-.mod-pulse-automation-table table.generaltable thead {
- display: none;
-}
-.mod-pulse-automation-table table.generaltable thead tr th {
- border: 0;
-}
-.mod-pulse-automation-table table.generaltable tbody tr {
- border: 1px solid #eee;
- border-radius: 5px;
- background: none;
- box-shadow: 2px 5px 5px rgba(0, 0, 0, 0.1);
-}
-.mod-pulse-automation-table table.generaltable tbody tr:nth-of-type(odd) {
- background: none;
-}
-.mod-pulse-automation-table table.generaltable tbody td {
- border-top: 1px solid #eee;
- border-bottom: 1px solid #eee;
- border-collapse: collapse;
- vertical-align: middle;
-}
-.mod-pulse-automation-table div:not(.automation-instruction) > div > table.generaltable tbody td:not([colspan]):first-child {
- border-left: 1px solid #eee;
- border-top-left-radius: 5px;
- border-bottom-left-radius: 5px;
- display: flex;
- align-items: center;
-}
-.mod-pulse-automation-table table.generaltable tbody td:last-child {
- border-right: 1px solid #eee;
- border-top-right-radius: 5px;
- border-bottom-right-radius: 5px;
-}
-.mod-pulse-automation-table table.generaltable tbody td:last-child .menu-item-actions {
- display: flex;
- justify-content: center;
-}
-.mod-pulse-automation-table table.generaltable tbody td p {
- text-align: left;
- margin: 10px;
-}
-.mod-pulse-automation-table table.generaltable tbody td .action-icon i {
- width: 40px;
- height: 40px;
- font-size: 18px;
- line-height: 40px;
- border-radius: 50%;
- color: #fff;
-}
-.mod-pulse-automation-table table.generaltable tbody td .action-icon.pulseaction_notification i,
-.mod-pulse-automation-table .badge.pulseaction_notification {
- background-color: #7b61ff;
-}
-.mod-pulse-automation-table table.generaltable tbody td span.inplaceeditable {
- font-size: 16px;
- font-weight: bold;
-}
-.mod-pulse-automation-table table.generaltable tbody td .template-reference {
- color: #999;
- font-style: italic;
- font-weight: normal;
- line-height: 30px;
- text-align: right;
- margin-bottom: 0;
-}
-.mod-pulse-automation-table table.generaltable tbody td .menu-item-actions.item-actions > * {
- font-size: 16px;
- color: #000;
- display: inline-block;
- margin-right: 10px;
-}
-.mod-pulse-automation-table table.generaltable tbody td .menu-item-actions.item-actions
-.pulse-instance-status-switch .custom-control-label {
- display: block;
-}
-.mod-pulse-automation-table .automation-instruction {
- margin-top: 70px;
-}
-.path-admin-mod-pulse-automation-templates form.mform .tab-content .tab-pane .form-group .form-inline span.override-count-element {
- font-size: 14px;
- color: #000;
- display: inline-block;
- margin-left: 10px;
- background-color: #ced4da;
- cursor: pointer;
-}
-.mod-pulse-automation-table .table-responsive table.generaltable tbody tr {
- border: 0;
- box-shadow: none;
-}
-.mod-pulse-automation-table .table-responsive table.generaltable tbody td {
- border: 0;
-}
-.mod-pulse-automation-table .table-responsive table.generaltable tbody td:first-child {
- text-align: right;
-}
-.mod-pulse-automation-table .table-responsive table.generaltable tbody td:last-child {
- text-align: left;
-}
-.mod-pulse-automation-table table.generaltable tbody td .badge.pulseaction_notification {
- background-color: #7b61ff;
-}
-.mod-pulse-automation-filter .box.generalbox {
- position: relative;
-}
-.mod-pulse-automation-filter .filter-form-container {
- float: right;
-}
-.mod-pulse-automation-filter .filter-form-container #pulse-automation-filter i.icon {
- margin-right: 0;
-}
-.mod-pulse-automation-filter .filter-form-container #pulse-automation-filterform {
- background-color: #fff;
- border: 1px solid #ccc;
- box-shadow: 0 0 0 0.1px;
- padding: 15px;
- position: absolute;
- top: 80%;
- right: 0;
- z-index: 2;
-}
-.mod-pulse-automation-filter .filter-form-container #pulse-automation-filterform form .form-group {
- margin-left: 0;
-}
-.mod-pulse-automation-filter .filter-form-container #pulse-automation-filterform form .form-group .col-form-label {
- padding-left: 0;
-}
-
-/* Templates Instance style */
-.path-mod-pulse-automation form.mform .tab-content .tab-pane .form-group .form-inline .custom-switch {
- width: auto;
- padding-left: 0;
- margin-top: 8px;
- display: inline-block;
- vertical-align: top;
-}
-.path-mod-pulse-automation form.mform .tab-content .tab-pane .form-group .form-inline .custom-switch .form-check {
- align-items: normal;
-}
-.path-mod-pulse-automation form.mform .tab-content .tab-pane .form-group .form-inline .custom-switch .checkboxgroupautomation {
- width: 2.5rem;
- margin: 0;
- z-index: 1;
-}
-.reportbuilder-report table tbody td a.pulse-automation-info-block i {
- width: 18px;
- height: 18px;
- font-size: 13px;
- color: #fff;
- line-height: 18px;
- text-align: center;
- margin-left: 5px;
- background: #0f6cbf;
- border-radius: 50%;
-}
-.mod-pulse-automation-table .generalbox .sort-autotemplates {
- float: right;
-}
-.mod-pulse-automation-table .generalbox .sort-autotemplates i {
- margin-right: 5px;
- vertical-align: middle;
-}
-.path-mod-pulse-automation #fitem_id_insreference #pulse-template-reference {
- margin-right: 10px;
-}
-/* Warning message info */
-#page-mod-pulse-automation-instances-edit .pulse-warnings li span {
- color: initial;
-}
-
-/* Behat issue fix for auto instance */
-body.behat-site .pulse-instance-status-switch input.custom-control-input {
- position: relative;
- z-index: -1;
-}
-
-/* Pulse 2.1 */
+/* Pulse 2.1 email placeholders style */
.mod-pulse-emailvars-toggle .emailvars-content .pulse-email-placeholders .placeholder-body .placeholders.less {
width: 400px;
height: 25px;
overflow: hidden;
}
-.manage-instance h6.numofinstance.emptycount {
- color: red;
-}
-#manage-instance-tab .filter-form-container {
- float: right;
-}
-#manage-instance-tab #manage-instance-table input.custom-control-input:not(:checked) ~ .badge {
- display: none;
-}
-#manage-instance-tab .generalbox .bulkdisableinstance-btn .custom-control,
-#manage-instance-tab .generalbox .bulkenableinstance-btn .custom-control {
- display: inline-block;
- vertical-align: middle;
-}
-#manage-instance-table .table-dynamic .generaltable .menu-item-actions a {
- color: #000;
- display: inline-block;
- vertical-align: middle;
-}
-#manage-instance-table .table-dynamic .generaltable .menu-item-actions a .custom-control .badge {
- margin-right: 5px;
-}
-
.mod-pulse-emailvars-toggle .emailvars-content .pulse-email-placeholders li {
margin-bottom: 10px;
}
@@ -455,11 +207,6 @@ body.behat-site .pulse-instance-status-switch input.custom-control-input {
font-weight: normal;
}
-#manage-instance-tab.show + .femptylabel,
-#manage-instance-tab.show ~ .required {
- display: none;
-}
-
div#pulsetemplates-tab-content .tab-pane.active {
display: block;
}
diff --git a/templates/automation_tabs.mustache b/templates/automation_tabs.mustache
deleted file mode 100644
index 20b499b..0000000
--- a/templates/automation_tabs.mustache
+++ /dev/null
@@ -1,45 +0,0 @@
-{{!
- This file is part of Moodle - http://moodle.org/
-
- Moodle is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- Moodle is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with Moodle. If not, see
.
-}}
-{{!
-
- @template mod_pulse/automation_tabs
-
- This template renders the tabs in the pulse automation instance / templates pages
-
- Example context (json):
- {
- "tabs": [{
- "name": "pulse-general",
- "title": "General",
- "active": "active"
- },
- {
- "name": "pulse-general",
- "title": "General"
- }
- ]
- }
-}}
-
diff --git a/templates/manageinstance_table.mustache b/templates/manageinstance_table.mustache
deleted file mode 100644
index cccc0c5..0000000
--- a/templates/manageinstance_table.mustache
+++ /dev/null
@@ -1,30 +0,0 @@
-{{!
- This file is part of Moodle - http://moodle.org/
-
- Moodle is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- Moodle is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with Moodle. If not, see
.
-}}
-{{!
- @template mod_pulse/manageinstance_table
-
- Manage instance table.
-
- Example context (json):
- {
- "tablehtml": "TableSQL format HTML for the table"
- }
-}}
-
-
- {{{tablehtml}}}
-
diff --git a/templates/overrides.mustache b/templates/overrides.mustache
deleted file mode 100644
index fa27c9e..0000000
--- a/templates/overrides.mustache
+++ /dev/null
@@ -1,14 +0,0 @@
-
-
-
- {{#str}} instancename, pulse {{/str}} | {{#str}} view, pulse {{/str}} |
-
- {{#instances}}
-
- {{{name}}} |
- {{#str}} view, pulse {{/str}} |
-
- {{/instances}}
-
-
-
diff --git a/templates/status_switch.mustache b/templates/status_switch.mustache
deleted file mode 100644
index d4244b6..0000000
--- a/templates/status_switch.mustache
+++ /dev/null
@@ -1,58 +0,0 @@
-{{!
- This file is part of Moodle - http://moodle.org/
-
- Moodle is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- Moodle is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with Moodle. If not, see
.
-}}
-{{!
-
- @template theme_boost/editswitch
-
- This template renders the top navbar.
-
- Example context (json):
- {
- "url": "http://localhost/",
- "sesskey": "sesskey",
- "edit": 1,
- "adminedit": true,
- "checked": "",
- "string": "Edit on",
- "legacyseturl": "/editmode.php"
- }
-}}
-
-
diff --git a/tests/behat/behat_pulse.php b/tests/behat/behat_pulse.php
index 87c6c8f..adbf9af 100644
--- a/tests/behat/behat_pulse.php
+++ b/tests/behat/behat_pulse.php
@@ -121,82 +121,6 @@ public function i_create_demo_presets(): void {
\mod_pulse\preset::pulse_create_presets();
}
-
- /**
- * Open the automation templates listing page.
- *
- * @Given /^I navigate to automation templates$/
- */
- public function i_navigate_to_automation_templates() {
- $this->execute('behat_navigation::i_navigate_to_in_site_administration',
- ['Plugins > Activity modules > Pulse > Automation templates']);
- }
-
- /**
- * Open the automation instance listing page for the course.
- *
- * @Given /^I navigate to course "(?P
(?:[^"]|\\")*)" automation instances$/
- * @param string $coursename Coursename.
- */
- public function i_navigate_to_course_automation_instances($coursename) {
- $this->execute('behat_navigation::i_am_on_course_homepage', [$coursename]);
- $this->execute('behat_navigation::i_select_from_secondary_navigation', get_string('automation', 'pulse'));
- }
-
- /**
- * Fills a automation template create form with field/value data.
- *
- * @Given /^I create automation template with the following fields to these values:$/
- * @throws ElementNotFoundException Thrown by behat_base::find
- * @param TableNode $data
- */
- public function i_create_automation_template_with_the_following_fields_to_these_values(TableNode $data) {
-
- $this->execute('behat_navigation::i_navigate_to_in_site_administration',
- ["Plugins > Activity modules > Pulse > Automation templates"]);
- $this->execute("behat_general::i_click_on", ["Create new template", "button"]);
- $this->execute('behat_forms::i_set_the_following_fields_to_these_values', [$data]);
- $this->execute("behat_general::i_click_on", ["Save changes", "button"]);
- }
-
-
- /**
- * Fills a automation template condition form with field/value data.
- *
- * @Given /^I create "([^"]*)" template with the set the condition:$/
- * @throws ElementNotFoundException Thrown by behat_base::find
- * @param string $reference
- * @param TableNode $data
- */
- public function i_create_autoation_template_condition_to_these_values($reference, TableNode $data) {
-
- $this->execute('behat_navigation::i_navigate_to_in_site_administration',
- ["Plugins > Activity modules > Pulse > Automation templates"]);
- $this->execute("behat_general::i_click_on_in_the", [".action-edit", "css_element", $reference, "table_row"]);
- $this->execute("behat_general::click_link", ["Condition"]);
- $this->execute('behat_forms::i_set_the_following_fields_to_these_values', [$data]);
- $this->execute("behat_general::i_click_on", ["Save changes", "button"]);
- }
-
-
- /**
- * Fills a automation template notification form with field/value data.
- *
- * @Given /^I create "([^"]*)" template with the set the notification:$/
- * @throws ElementNotFoundException Thrown by behat_base::find
- * @param string $reference
- * @param TableNode $data
- */
- public function i_create_automation_template_notification_to_these_values($reference, TableNode $data) {
-
- $this->execute('behat_navigation::i_navigate_to_in_site_administration',
- ["Plugins > Activity modules > Pulse > Automation templates"]);
- $this->execute("behat_general::i_click_on_in_the", [".action-edit", "css_element", $reference, "table_row"]);
- $this->execute("behat_general::i_click_on", ["#automation-tabs .nav-item:nth-child(3) a", "css_element"]);
- $this->execute('behat_forms::i_set_the_following_fields_to_these_values', [$data]);
- $this->execute("behat_general::i_click_on", ["Save changes", "button"]);
- }
-
/**
* Select the conditions are met option on the activity completion tracking .
*
@@ -212,36 +136,4 @@ public function i_set_the_activity_completion_tracking() {
['Completion tracking', 'Show activity as complete when conditions are met']);
}
}
-
-
- /**
- * Switches to a pulse new window.
- *
- * @Given /^I switch to a pulse open window$/
- * @throws DriverException If there aren't exactly 2 windows open.
- */
- public function switch_to_open_window() {
- $names = $this->getSession()->getWindowNames();
- $this->getSession()->switchToWindow(end($names));
- }
-
- /**
- * Switches to a pulse new window.
- *
- * @Given /^I click on pulse "([^"]*)" editor$/
- *
- * @param string $editor
- * @throws DriverException If there aren't exactly 2 windows open.
- */
- public function i_click_on_pulse_editor($editor) {
- global $CFG;
-
- if ($CFG->branch >= 402) {
- $this->execute('behat_general::i_click_on_in_the',
- ['#'.$editor . '_ifr', 'css_element', '#fitem_'.$editor, 'css_element']);
- } else {
- $this->execute('behat_general::i_click_on_in_the',
- ['#'.$editor . 'editable', 'css_element', '#fitem_'.$editor, 'css_element']);
- }
- }
}
diff --git a/tests/behat/pulse_automation_instance.feature b/tests/behat/pulse_automation_instance.feature
deleted file mode 100644
index c9914e0..0000000
--- a/tests/behat/pulse_automation_instance.feature
+++ /dev/null
@@ -1,167 +0,0 @@
-@mod @mod_pulse @pulse_automation_instance
-Feature: Pulse automation instances
- In order to check the the pulse automation template works
- As a teacher.
-
- Background:
- Given the following "categories" exist:
- | name | category | idnumber |
- | Cat 1 | 0 | CAT1 |
- | Cat 2 | 0 | CAT2 |
- | Cat 3 | CAT1 | CAT3 |
- And the following "course" exist:
- | fullname | shortname | category |
- | Course 1 | C1 | 0 |
- | Course 2 | C2 | CAT1 |
- | Course 3 | C3 | CAT2 |
- | Course 4 | C4 | CAT3 |
- And the following "users" exist:
- | 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 |
- | teacher1 | C1 | editingteacher |
- | student1 | C1 | student |
-
- @javascript
- Scenario: Create the automation template instance.
- Given I log in as "admin"
- Then I create automation template with the following fields to these values:
- | Title | WELCOME MESSAGE |
- | Reference | Welcomemessage |
- | Visibility | Show |
- And I should see "WELCOME MESSAGE" in the "#pulse_automation_template" "css_element"
- And I am on "Course 1" course homepage
- And I follow "Automation"
- When I open the autocomplete suggestions list
- And I click on "WELCOME MESSAGE" item in the autocomplete list
- Then I click on "Add automation instance" "button"
- And I set the following fields to these values:
- | override[title] | 1 |
- | Title | WELCOME MESSAGE Instance |
- | insreference | Welcomemessageinstance |
- And I press "Save changes"
- Then I should see "Template inserted successfully"
- And I should see "WELCOME MESSAGE" in the "#pulse_automation_template" "css_element"
- And I should see "Welcomemessageinstance" in the "#pulse_automation_template .template-reference" "css_element"
-
- @javascript
- Scenario: Edit the automation template instance.
- Given I log in as "admin"
- Then I create automation template with the following fields to these values:
- | Title | WELCOME MESSAGE |
- | Reference | Welcomemessage |
- | Visibility | Show |
- And I should see "WELCOME MESSAGE" in the "#pulse_automation_template" "css_element"
- And I am on "Course 1" course homepage
- And I follow "Automation"
- When I open the autocomplete suggestions list
- And I click on "WELCOME MESSAGE" item in the autocomplete list
- Then I click on "Add automation instance" "button"
- And I set the following fields to these values:
- | insreference | Welcomemessage |
- And I press "Save changes"
- Then I should see "Template inserted successfully"
- And I should see "WELCOME MESSAGE" in the "#pulse_automation_template" "css_element"
- And I should see "Welcomemessage" in the "#pulse_automation_template .template-reference" "css_element"
- And "#pulse_automation_template .menu-item-actions .action-edit" "css_element" should exist
- Then I click on ".action-edit" "css_element" in the "WELCOME MESSAGE" "table_row"
- Then I should see "Edit instance"
- And I set the following fields to these values:
- | override[title] | 1 |
- | Title | DEMO MESSAGE |
- | insreference | demomessageinstance |
- Then I press "Save changes"
- And I should see "DEMO MESSAGE" in the "#pulse_automation_template" "css_element"
- And I should not see "WELCOME MESSAGE" in the "#pulse_automation_template" "css_element"
- And I should see "demomessage" in the "#pulse_automation_template .template-reference" "css_element"
- And I should not see "Welcomemessageinstance" in the "#pulse_automation_template .template-reference" "css_element"
-
- @javascript
- Scenario: Dupilcate the automation template instance.
- Given I log in as "admin"
- Then I create automation template with the following fields to these values:
- | Title | WELCOME MESSAGE |
- | Reference | Welcomemessage |
- | Visibility | Show |
- And I am on "Course 1" course homepage
- And I follow "Automation"
- When I open the autocomplete suggestions list
- And I click on "WELCOME MESSAGE" item in the autocomplete list
- Then I click on "Add automation instance" "button"
- And I set the following fields to these values:
- | override[title] | 1 |
- | Title | WELCOME MESSAGE Instance |
- | insreference | Welcomemessageinstance |
- And I press "Save changes"
- And I should see "WELCOME MESSAGE" in the "#pulse_automation_template tbody tr:nth-child(1)" "css_element"
- And I should not see "WELCOME MESSAGE" in the "#pulse_automation_template tbody tr:nth-child(2)" "css_element"
- Then I click on "#pulse_automation_template tbody tr:nth-child(1) .action-copy" "css_element"
- And I should see "WELCOME MESSAGE" in the "#pulse_automation_template tbody tr:nth-child(1)" "css_element"
- And I should see "WELCOME MESSAGE" in the "#pulse_automation_template tbody tr:nth-child(2)" "css_element"
-
- @javascript
- Scenario: Delete the automation template instance.
- Given I log in as "admin"
- Then I create automation template with the following fields to these values:
- | Title | WELCOME MESSAGE |
- | Reference | Welcomemessage |
- | Visibility | Show |
- And I am on "Course 1" course homepage
- And I follow "Automation"
- When I open the autocomplete suggestions list
- And I click on "WELCOME MESSAGE" item in the autocomplete list
- Then I click on "Add automation instance" "button"
- And I set the following fields to these values:
- | insreference | Welcomemessage |
- And I press "Save changes"
- And I should see "WELCOME MESSAGE" in the "#pulse_automation_template" "css_element"
- Then I click on "#pulse_automation_template .action-delete" "css_element"
- And I click on "Cancel" "button" in the "Confirmation" "dialogue"
- And I should see "WELCOME MESSAGE" in the "#pulse_automation_template" "css_element"
- Then I click on "#pulse_automation_template .action-delete" "css_element"
- And I click on "Yes" "button" in the "Confirmation" "dialogue"
- Then I should see "Nothing to display"
- And "#pulse_automation_template" "css_element" should not exist
-
- @javascript
- Scenario: Check the multiple automation template instance
- Given I log in as "admin"
- Then I create automation template with the following fields to these values:
- | Title | WELCOME MESSAGE |
- | Reference | Welcomemessage |
- Then I create automation template with the following fields to these values:
- | Title | Notification |
- | Reference | notification |
- And I am on "Course 1" course homepage
- And I follow "Automation"
- When I open the autocomplete suggestions list
- Then I should see "WELCOME MESSAGE" in the ".template-add-form .form-autocomplete-suggestions" "css_element"
- Then I should see "Notification" in the ".template-add-form .form-autocomplete-suggestions" "css_element"
- When I open the autocomplete suggestions list
- And I click on "WELCOME MESSAGE" item in the autocomplete list
- Then I click on "Add automation instance" "button"
- Then the field "Title" matches value "WELCOME MESSAGE"
- And I set the following fields to these values:
- | insreference | Welcomemessageinstance |
- And I press "Save changes"
- And I should see "WELCOME MESSAGE" in the "#pulse_automation_template tbody tr:nth-child(1)" "css_element"
- When I open the autocomplete suggestions list
- And I click on "Notification" item in the autocomplete list
- Then I click on "Add automation instance" "button"
- Then the field "Title" matches value "Notification"
- And I set the following fields to these values:
- | insreference | notificationinstance |
- And I press "Save changes"
- And I should see "Notification" in the "#pulse_automation_template tbody tr:nth-child(2)" "css_element"
- When I open the autocomplete suggestions list
- And I click on "WELCOME MESSAGE" item in the autocomplete list
- Then I click on "Add automation instance" "button"
- Then the field "Title" matches value "WELCOME MESSAGE"
- And I set the following fields to these values:
- | override[title] | 1 |
- | insreference | Welcomemessageinstance2 |
- | Title | WELCOME CONTENT |
- And I press "Save changes"
- And I should see "WELCOME CONTENT"
diff --git a/tests/behat/pulse_automation_instance_management.feature b/tests/behat/pulse_automation_instance_management.feature
deleted file mode 100644
index 807005d..0000000
--- a/tests/behat/pulse_automation_instance_management.feature
+++ /dev/null
@@ -1,688 +0,0 @@
-@mod @mod_pulse @pulse_automation_instance @_switch_window
-Feature: Pulse automation instances management
- In order to check the the pulse automation template works
- As a teacher.
-
- Background:
- Given the following "categories" exist:
- | name | category | idnumber |
- | Cat 1 | 0 | CAT1 |
- | Cat 2 | 0 | CAT2 |
- | Cat 3 | CAT1 | CAT3 |
- And the following "course" exist:
- | fullname | shortname | category | enablecompletion |
- | Course 1 | C1 | 0 | 1 |
- | Course 2 | C2 | CAT1 | 1 |
- | Course 3 | C3 | CAT2 | 1 |
- | Course 4 | C4 | CAT3 | 1 |
- And the following "activities" exist:
- | activity | name | course | idnumber | intro | section | completion |
- | assign | Assign1 | C1 | assign1 | Page description | 1 | 1 |
- | assign | Assign2 | C1 | assign2 | Page description | 2 | 1 |
- | assign | Assign3 | C1 | assign3 | Page description | 3 | 1 |
- And the following "users" exist:
- | 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 |
- | teacher1 | C1 | editingteacher |
- | student1 | C1 | student |
-
- And I log in as "admin"
- And I am on "Course 1" course homepage
- And I navigate to "Settings" in current page administration
- And I expand all fieldsets
- And I set the field "Enable completion tracking" to "Yes"
- And I press "Save and display"
- And I click on "More" "link" in the ".secondary-navigation" "css_element"
- And I click on "Course completion" "link" in the ".secondary-navigation" "css_element"
- And I expand all fieldsets
- And I set the field "Assign1" to "1"
- And I press "Save changes"
-
- Then I create automation template with the following fields to these values:
- | Title | Template1 |
- | Reference | temp1 |
- And I click on "Create new template" "button"
- Then I set the following fields to these values:
- | Title | Notification1 |
- | Reference | notification1 |
- And I press "Save changes"
- And I click on ".action-edit" "css_element" in the "Template1" "table_row"
- And I click on "Instance Management" "link"
- And I should see "Course 1" in the "Category 1" "table_row"
- And I should see "0" in the "Course 1" "table_row"
-
- And I click on "Automation templates" "link" in the ".breadcrumb" "css_element"
- And I should see "0(0)" in the "notification1" "table_row"
- And I click on ".action-edit" "css_element" in the "Notification1" "table_row"
- And I click on "Instance Management" "link"
- And I should see "0" in the "Course 1" "table_row"
- And I click on ".action-add-instance" "css_element" in the "Course 1" "table_row"
- And I click on "Instance Management" "link"
- And I should see "1" in the "Course 1" "table_row"
- And I click on "Automation templates" "link" in the ".breadcrumb" "css_element"
- And I should see "1(0)" in the "notification1" "table_row"
-
- And I click on ".action-edit" "css_element" in the "Template1" "table_row"
- And I click on "Instance Management" "link"
- And I should see "0" in the "Course 1" "table_row"
- And I click on "Select all" "link" in the "#manage-instance-tab" "css_element"
- And I click on "#bulkadd-btn" "css_element" in the ".bulkaction-group" "css_element"
- And I click on "Yes" "button" in the "Confirmation" "dialogue"
- And I click on "Automation templates" "link" in the ".breadcrumb" "css_element"
- And I should see "4(0)" in the "temp1" "table_row"
- And I click on ".action-edit" "css_element" in the "Template1" "table_row"
- And I click on "Instance Management" "link"
- And I should see "1" in the "Course 1" "table_row"
- And I should see "1" in the "Course 2" "table_row"
- And I should see "1" in the "Course 3" "table_row"
- And I should see "1" in the "Course 4" "table_row"
- And I log out
-
- @javascript
- Scenario: Add instances in the Instance Management
- Given I log in as "admin"
- And I navigate to "Plugins > Activity modules > Automation templates" in site administration
- And I click on ".action-edit" "css_element" in the "Template1" "table_row"
- And I click on "Instance Management" "link"
- And I click on "Select all" "link" in the "#manage-instance-tab" "css_element"
- And I click on "#bulkdelete-btn" "css_element" in the ".bulkaction-group" "css_element"
- And I click on "Yes" "button" in the "Confirmation" "dialogue"
-
- And I should see "0" in the "Course 1" "table_row"
- And I click on ".action-add-instance" "css_element" in the "Course 1" "table_row"
- And I click on "Automation templates" "link" in the ".breadcrumb" "css_element"
- And I should see "1(0)" in the "temp1" "table_row"
- And I click on ".action-edit" "css_element" in the "Template1" "table_row"
- And I click on "Instance Management" "link"
- And I should see "1" in the "Course 1" "table_row"
-
- And I set the field with xpath "//tr[contains(normalize-space(.), 'Course 1')]//input[@type='checkbox']" to "bc[]"
- And I click on "#bulkadd-btn" "css_element" in the ".bulkaction-group" "css_element"
- And I click on "Yes" "button" in the "Confirmation" "dialogue"
- And I click on "Automation templates" "link" in the ".breadcrumb" "css_element"
- And I should see "2(0)" in the "temp1" "table_row"
- And I click on ".action-edit" "css_element" in the "Template1" "table_row"
- And I click on "Instance Management" "link"
- And I should see "2" in the "Course 1" "table_row"
-
- And I click on ".action-add-instance" "css_element" in the "Course 2" "table_row"
- And I click on "Automation templates" "link" in the ".breadcrumb" "css_element"
- And I should see "3(0)" in the "temp1" "table_row"
- And I click on ".action-edit" "css_element" in the "Template1" "table_row"
- And I click on "Instance Management" "link"
- And I should see "1" in the "Course 2" "table_row"
-
- And I click on "Select all without instances" "link" in the "#manage-instance-tab" "css_element"
- And I click on "#bulkadd-btn" "css_element" in the ".bulkaction-group" "css_element"
- And I click on "Yes" "button" in the "Confirmation" "dialogue"
- And I click on "Automation templates" "link" in the ".breadcrumb" "css_element"
- And I should see "5(0)" in the "temp1" "table_row"
- And I click on ".action-edit" "css_element" in the "Template1" "table_row"
- And I click on "Instance Management" "link"
- And I should see "1" in the "Course 3" "table_row"
- And I should see "1" in the "Course 4" "table_row"
-
- And I click on ".fa-calendar" "css_element" in the "Course 1" "table_row"
- And I switch to a second window
- Then I should see "Template1" in the "temp1C1" "table_row"
-
- @javascript
- Scenario: Modify the instances with bulk action group
- Given I log in as "admin"
- And I navigate to "Plugins > Activity modules > Automation templates" in site administration
- And I click on ".action-edit" "css_element" in the "Template1" "table_row"
- And I click on "Instance Management" "link"
- And I should see "1" in the "Course 1" "table_row"
-
- # Delete the instances for the Course
- And I click on ".action-delete" "css_element" in the "Course 2" "table_row"
- And I click on "Yes" "button" in the "Confirmation" "dialogue"
- And I click on "Automation templates" "link" in the ".breadcrumb" "css_element"
- And I should see "3(0)" in the "temp1" "table_row"
- And I click on ".action-edit" "css_element" in the "Template1" "table_row"
- And I click on "Instance Management" "link"
- And I should see "0" in the "Course 2" "table_row"
-
- # Bulk delete the instances for the course
- And I set the field with xpath "//tr[contains(normalize-space(.), 'Course 1')]//input[@type='checkbox']" to "bc[]"
- And I click on "#bulkdelete-btn" "css_element" in the ".bulkaction-group" "css_element"
- And I click on "Yes" "button" in the "Confirmation" "dialogue"
- And I click on "Automation templates" "link" in the ".breadcrumb" "css_element"
- And I should see "2(0)" in the "temp1" "table_row"
- And I click on ".action-edit" "css_element" in the "Template1" "table_row"
- And I click on "Instance Management" "link"
- And I should see "0" in the "Course 1" "table_row"
-
- # Enable / Disable the instances with bulk option
- And I set the field with xpath "//tr[contains(normalize-space(.), 'Course 3')]//input[@type='checkbox']" to "bc[]"
- And I set the field with xpath "//tr[contains(normalize-space(.), 'Course 4')]//input[@type='checkbox']" to "bc[]"
- And I click on "#bulkdisable-btn" "css_element" in the ".bulkaction-group" "css_element"
- And I click on "Yes" "button" in the "Confirmation" "dialogue"
- And ".pulse-manage-instance-status-switch .custom-control-input:checked" "css_element" should not exist in the "Course 3" "table_row"
- And ".pulse-manage-instance-status-switch .custom-control-input:checked" "css_element" should not exist in the "Course 4" "table_row"
- And I set the field with xpath "//tr[contains(normalize-space(.), 'Course 1')]//input[@type='checkbox']" to "bc[]"
- And I set the field with xpath "//tr[contains(normalize-space(.), 'Course 2')]//input[@type='checkbox']" to "bc[]"
- And I click on "#bulkadd-btn" "css_element" in the ".bulkaction-group" "css_element"
- And I click on "Yes" "button" in the "Confirmation" "dialogue"
- And I should see "1" in the "Course 1" "table_row"
- And I should see "1" in the "Course 2" "table_row"
- And I click on "Select all" "link" in the "#manage-instance-tab" "css_element"
- And I click on "#bulkenable-btn" "css_element" in the ".bulkaction-group" "css_element"
- And I click on "Yes" "button" in the "Confirmation" "dialogue"
- And ".pulse-manage-instance-status-switch .custom-control-input:checked" "css_element" should exist in the "Course 1" "table_row"
- And ".pulse-manage-instance-status-switch .custom-control-input:checked" "css_element" should exist in the "Course 3" "table_row"
-
- And I click on "Automation templates" "link" in the ".breadcrumb" "css_element"
- And I click on ".action-edit" "css_element" in the "Notification1" "table_row"
- And I click on "Instance Management" "link"
- And I should see "1" in the "Course 1" "table_row"
- And I click on "Select all" "link" in the "#manage-instance-tab" "css_element"
- And I click on "#bulkadd-btn" "css_element" in the ".bulkaction-group" "css_element"
- And I click on "Yes" "button" in the "Confirmation" "dialogue"
- And I click on "Automation templates" "link" in the ".breadcrumb" "css_element"
-
- And I should see "5(0)" in the "notification1" "table_row"
- And I click on ".action-edit" "css_element" in the "Notification1" "table_row"
- And I click on "Instance Management" "link"
- And I should see "2" in the "Course 1" "table_row"
-
- And I click on ".action-edit" "css_element" in the "Course 1" "table_row"
- And I switch to a second window
- And I should see "Template1" in the "temp1C1" "table_row"
- And I should see "Notification1" in the "notification1C1" "table_row"
- And I close all opened windows
- And I click on ".action-report" "css_element" in the "Course 1" "table_row"
- And I switch to a second window
- Then "Template1" "table_row" should not exist
- And I should see "Notification1" in the "notification1C1" "table_row"
- And I close all opened windows
-
- # Filter the available course categories
- And I click on "#tool-details-tab" "css_element"
- And I wait "2" seconds
- And I set the following fields to these values:
- | Available in course categories | Category 1, Cat 1 |
- And I press "Save changes"
- And I click on ".action-edit" "css_element" in the "Notification1" "table_row"
- And I click on "Instance Management" "link"
- And I should see "Course 1" in the "Category 1" "table_row"
- And I should see "Course 2" in the "Cat 1" "table_row"
- And "Course 3" "table_row" should not exist
- And I click on "#tool-details-tab" "css_element"
- And I click on "span.badge" "css_element" in the "#fitem_id_categories .form-autocomplete-selection" "css_element"
- And I wait "1" seconds
- And I click on "span.badge" "css_element" in the "#fitem_id_categories .form-autocomplete-selection" "css_element"
- And I press "Save changes"
- And I click on ".action-edit" "css_element" in the "Notification1" "table_row"
- And I click on "Instance Management" "link"
- And I should see "Course 1" in the "Category 1" "table_row"
- And I should see "Course 3" in the "Cat 2" "table_row"
- And I wait "5" seconds
-
- @javascript
- Scenario: Instance mixed status check
- Given I log in as "admin"
- # Enable / Disable Instance Mixed option
- And I navigate to "Plugins > Activity modules > Automation templates" in site administration
- And I click on ".action-edit" "css_element" in the "Notification1" "table_row"
- And I click on "Instance Management" "link"
- And I should see "1" in the "Course 1" "table_row"
- And I click on ".action-add-instance" "css_element" in the "Course 1" "table_row"
- And I click on "Instance Management" "link"
- And I click on ".action-add-instance" "css_element" in the "Course 1" "table_row"
- And I click on "Instance Management" "link"
- And I should see "3" in the "Course 1" "table_row"
- And ".menu-item-actions .badge" "css_element" should not exist in the "Course 1" "table_row"
- And I click on ".action-report" "css_element" in the "Course 1" "table_row"
- And I switch to a second window
- And I click on ".pulse-instance-status-switch" "css_element" in the ".menu-item-actions" "css_element"
- And I switch to the main window
- And I navigate to "Plugins > Activity modules > Automation templates" in site administration
- And I click on ".action-edit" "css_element" in the "Notification1" "table_row"
- And I click on "Instance Management" "link"
- And I should see "Mixed" in the "Course 1" "table_row"
- And I should see "3" in the "Course 1" "table_row"
-
- @javascript
- Scenario: Utilizing the filter option in instance management
- Given I log in as "admin"
- And I navigate to "Plugins > Activity modules > Automation templates" in site administration
- And I click on ".action-edit" "css_element" in the "Template1" "table_row"
- And I click on "Instance Management" "link"
- And I should see "1" in the "Course 1" "table_row"
-
- # Filtering "Category"
- And I click on "#pulse-manageinstance-filter" "css_element" in the "#manage-instance-tab" "css_element"
- And I set the following fields to these values:
- | Category | Category 1 |
- And I click on "Filter" "button" in the "#fitem_id_submitbutton" "css_element"
- And I should see "Course 1" in the "Category 1" "table_row"
- And "Cat 1" "table_row" should not exist
- And I click on "#pulse-manageinstance-filter" "css_element" in the "#manage-instance-tab" "css_element"
- And I set the following fields to these values:
- | Category | All |
- And I click on "Filter" "button" in the "#fitem_id_submitbutton" "css_element"
- And I should see "Course 1" in the "Category 1" "table_row"
- And I should see "Course 2" in the "Cat 1" "table_row"
- And I wait "5" seconds
-
- # Filtering "Course"
- And I click on "#pulse-manageinstance-filter" "css_element" in the "#manage-instance-tab" "css_element"
- And I set the following fields to these values:
- | Course name | Course 1 |
- And I click on "Filter" "button" in the "#fitem_id_submitbutton" "css_element"
- And I should see "Course 1" in the "Category 1" "table_row"
- And "Cat 2" "table_row" should not exist
- And I click on "#pulse-manageinstance-filter" "css_element" in the "#manage-instance-tab" "css_element"
- And I set the following fields to these values:
- | Course name | All |
- And I click on "Filter" "button" in the "#fitem_id_submitbutton" "css_element"
- And I should see "Course 1" in the "Category 1" "table_row"
- And I should see "Course 2" in the "Cat 1" "table_row"
-
- # Filtering "Number of instances"
- And I click on ".action-add-instance" "css_element" in the "Course 1" "table_row"
- And I click on "Instance Management" "link"
- And I should see "2" in the "Course 1" "table_row"
- And I click on "#pulse-manageinstance-filter" "css_element" in the "#manage-instance-tab" "css_element"
- And I set the following fields to these values:
- | Number of instance | 2 |
- And I click on "Filter" "button" in the "#fitem_id_submitbutton" "css_element"
- And I should see "2" in the "Category 1" "table_row"
- And "Cat 1" "table_row" should not exist
- And I click on "#pulse-manageinstance-filter" "css_element" in the "#manage-instance-tab" "css_element"
- And I set the following fields to these values:
- | Number of instance | |
- And I click on "Filter" "button" in the "#fitem_id_submitbutton" "css_element"
- And I should see "2" in the "Category 1" "table_row"
- And I should see "1" in the "Cat 1" "table_row"
-
- # Filtering "Number of overrides"
- @javascript
- Scenario: Utilizing the number of overrides filter option in instance management
- Given I log in as "admin"
- And I navigate to "Plugins > Activity modules > Automation templates" in site administration
- And I click on ".action-edit" "css_element" in the "Template1" "table_row"
- And I click on "Instance Management" "link"
- And I should see "1" in the "Course 1" "table_row"
-
- # Number of override: 1
- And I click on ".action-report" "css_element" in the "Category 1" "table_row"
- And I switch to a second window
- And I should see "Template1" in the "temp1C1" "table_row"
- And I click on ".action-edit" "css_element" in the "Template1" "table_row"
- And I click on ".checkboxgroupautomation" "css_element" in the "#fitem_id_title" "css_element"
- And I set the following fields to these values:
- | Title | Template01 |
- | Reference | C2 |
- And I wait "2" seconds
- And I press "Save changes"
- And I should see "Template01" in the "temp1C2" "table_row"
- And I navigate to "Plugins > Activity modules > Automation templates" in site administration
- And I click on ".action-edit" "css_element" in the "Template1" "table_row"
- And I click on "Instance Management" "link"
-
- And I click on "#pulse-manageinstance-filter" "css_element" in the "#manage-instance-tab" "css_element"
- And I set the following fields to these values:
- | Number of overrides | 1 |
- And I click on "Filter" "button" in the "#fitem_id_submitbutton" "css_element"
- And I should see "Course 1" in the "Category 1" "table_row"
- And "Cat 1" "table_row" should not exist
-
- And I click on "#pulse-manageinstance-filter" "css_element" in the "#manage-instance-tab" "css_element"
- And I set the following fields to these values:
- | Number of overrides | 0 |
- And I click on "Filter" "button" in the "#fitem_id_submitbutton" "css_element"
- And I should see "Course 2" in the "Cat 1" "table_row"
- And I should see "Course 3" in the "Cat 2" "table_row"
- And I should see "Course 4" in the "Cat 3" "table_row"
- And "Category 1" "table_row" should not exist
-
- And I click on "#pulse-manageinstance-filter" "css_element" in the "#manage-instance-tab" "css_element"
- And I set the following fields to these values:
- | Number of overrides | |
- And I click on "Filter" "button" in the "#fitem_id_submitbutton" "css_element"
- And I should see "Course 1" in the "Category 1" "table_row"
- And I should see "Course 2" in the "Cat 1" "table_row"
-
- And I click on ".action-edit" "css_element" in the "Course 2" "table_row"
- And I switch to a pulse open window
- And I should see "Template1" in the "temp1C2" "table_row"
- And I click on ".action-edit" "css_element" in the "Template1" "table_row"
- And I click on ".checkboxgroupautomation" "css_element" in the "#fitem_id_title" "css_element"
- And I set the following fields to these values:
- | Title | Template02 |
- And I press "Save changes"
- And I should see "Template02" in the "temp1C2" "table_row"
- And I navigate to "Plugins > Activity modules > Automation templates" in site administration
- And I click on ".action-edit" "css_element" in the "Template1" "table_row"
- And I click on "Instance Management" "link"
-
- And I click on "#pulse-manageinstance-filter" "css_element" in the "#manage-instance-tab" "css_element"
- And I set the following fields to these values:
- | Number of overrides | 1 |
- And I click on "Filter" "button" in the "#fitem_id_submitbutton" "css_element"
- And I should see "Course 1" in the "Category 1" "table_row"
- And I should see "Course 2" in the "Cat 1" "table_row"
- And "Cat 2" "table_row" should not exist
-
- # Number of override: 2
- And I click on ".action-edit" "css_element" in the "Course 1" "table_row"
- And I switch to a pulse open window
- And I click on ".action-edit" "css_element" in the "Template01" "table_row"
- And I click on ".checkboxgroupautomation" "css_element" in the "#fitem_id_notes" "css_element"
- And I set the following fields to these values:
- | Internal notes | Demo Template01 |
- And I press "Save changes"
- And I navigate to "Plugins > Activity modules > Automation templates" in site administration
- And I click on ".action-edit" "css_element" in the "Template1" "table_row"
- And I click on "Instance Management" "link"
-
- And I click on "#pulse-manageinstance-filter" "css_element" in the "#manage-instance-tab" "css_element"
- And I set the following fields to these values:
- | Number of overrides | 2 |
- And I click on "Filter" "button" in the "#fitem_id_submitbutton" "css_element"
- And I should see "Course 1" in the "Category 1" "table_row"
- And "Cat 1" "table_row" should not exist
-
- And I click on ".action-edit" "css_element" in the "Course 1" "table_row"
- And I switch to a pulse open window
- And I click on ".action-edit" "css_element" in the "Template01" "table_row"
- And I click on ".checkboxgroupautomation" "css_element" in the "#fitem_id_notes" "css_element"
- And I press "Save changes"
- And I navigate to "Plugins > Activity modules > Automation templates" in site administration
- And I click on ".action-edit" "css_element" in the "Template1" "table_row"
- And I click on "Instance Management" "link"
-
- And I click on "#pulse-manageinstance-filter" "css_element" in the "#manage-instance-tab" "css_element"
- And I set the following fields to these values:
- | Number of overrides | 2 |
- And I click on "Filter" "button" in the "#fitem_id_submitbutton" "css_element"
- And I should see "Nothing to display" in the "#manage-instance-table" "css_element"
-
- And I click on "#pulse-manageinstance-filter" "css_element" in the "#manage-instance-tab" "css_element"
- And I set the following fields to these values:
- | Number of overrides | 1 |
- And I click on "Filter" "button" in the "#fitem_id_submitbutton" "css_element"
- And I should see "Course 1" in the "Category 1" "table_row"
- And I wait "2" seconds
-
- @javascript
- Scenario: Delete action for the template
- Given I log in as "admin"
- And I navigate to "Plugins > Activity modules > Automation templates" in site administration
- And I click on ".action-edit" "css_element" in the "Notification1" "table_row"
- And I click on "Instance Management" "link"
- And I click on ".action-edit" "css_element" in the "Course 1" "table_row"
- And I switch to a second window
- And I should see "Notification1" in the "notification1C1" "table_row"
- And I should see "Template1" in the "temp1C1" "table_row"
- And I click on ".form-autocomplete-downarrow" "css_element" in the "#fitem_id_templateid .align-items-start" "css_element"
- And "Template1" "text" in the "#fitem_id_templateid .form-autocomplete-suggestions" "css_element" should be visible
- And "Notification1" "text" in the "#fitem_id_templateid .form-autocomplete-suggestions" "css_element" should be visible
- And I close all opened windows
- And I click on "Automation templates" "link" in the ".breadcrumb" "css_element"
- And I click on ".action-delete" "css_element" in the "notification1" "table_row"
- And I click on "Yes" "button" in the "Confirmation" "dialogue"
- And "Notification1" "table_row" should not exist
- And I click on ".action-edit" "css_element" in the "Template1" "table_row"
- And I click on "Instance Management" "link"
- And I should see "1" in the "Course 1" "table_row"
- And I click on ".action-edit" "css_element" in the "Course 1" "table_row"
- And I switch to a second window
- And I should see "Template1" in the "temp1C1" "table_row"
- And "notification1C1" "table_row" should not exist
- And I click on ".form-autocomplete-downarrow" "css_element" in the "#fitem_id_templateid .align-items-start" "css_element"
- And "Template1" "text" in the "#fitem_id_templateid .form-autocomplete-suggestions" "css_element" should be visible
- And "Notification1" "text" in the "#fitem_id_templateid .form-autocomplete-suggestions" "css_element" should not be visible
- And I wait "2" seconds
-
- @javascript
- Scenario: Additional column added for the report source
- Given I log in as "student1"
- And I am on "Course 1" course homepage
- And I am on the "Assign1" "assign activity" page
- And I press "Mark as done"
- And I log out
-
- And I log in as "admin"
- And I navigate to course "Course 1" automation instances
- And I should see "Template1" in the "temp1C1" "table_row"
- And I click on ".action-edit" "css_element" in the "Template1" "table_row"
- And I click on "#id_override_title" "css_element" in the "#fitem_id_title" "css_element"
- And I set the field "Title" to "Template01"
- And I click on "Condition" "link" in the "#automation-tabs" "css_element"
- And I click on "#id_override_triggeroperator" "css_element" in the "#fitem_id_triggeroperator" "css_element"
- And I set the field "Trigger operator" to "Any"
- And I click on "#id_override_condition_activity_status" "css_element" in the "#fitem_id_condition_activity_status" "css_element"
- And I set the field "Activity completion" to "All"
- And I wait "2" seconds
- And I set the field "Select activities" to "Assign1"
- And I click on "Notification" "link" in the "#automation-tabs" "css_element"
- And I click on "#id_override_pulsenotification_recipients" "css_element" in the "#fitem_id_pulsenotification_recipients" "css_element"
- And I set the field "Recipients" to "Student"
- And I click on "#id_override_pulsenotification_cc" "css_element" in the "#fitem_id_pulsenotification_cc" "css_element"
- And I set the field "Cc" to "Teacher"
- And I press "Save changes"
-
- And I wait "3" seconds
- And I click on ".action-report" "css_element" in the "Template01" "table_row"
- And I switch to a second window
- And I should see "student User 1" in the "Course 1" "table_row"
- And I log out
-
- And I log in as "admin"
- And I navigate to "Reports > Report builder > Custom reports" in site administration
- And I click on "New report" "button"
- And I set the following fields in the "New report" "dialogue" to these values:
- | Name | My report |
- | Report source | Notification |
- | Include default setup | 0 |
- And I click on "Save" "button" in the "New report" "dialogue"
- And I wait until the page is ready
- Then I should see "My report"
- And I click on "Template title" "link" in the ".reportbuilder-sidebar-menu-cards .card-body" "css_element"
- And I should see "Template1" in the ".reportbuilder-table tbody tr td" "css_element"
- And I click on "Template reference" "link" in the ".reportbuilder-sidebar-menu-cards .card-body" "css_element"
- And I should see "temp1" in the "Template1" "table_row"
- And I click on "Instance title" "link" in the ".reportbuilder-sidebar-menu-cards .card-body" "css_element"
- And I wait "2" seconds
- And I should see "Template01" in the "temp1" "table_row"
- And I click on "Instance reference" "link" in the ".reportbuilder-sidebar-menu-cards .card-body" "css_element"
- And I wait "2" seconds
- And I should see "C1" in the "temp1" "table_row"
-
- @javascript
- Scenario: A instance override capabiltiy check
- Given I log in as "admin"
- And I navigate to "Plugins > Activity modules > Automation templates" in site administration
- And I click on ".action-edit" "css_element" in the "Template1" "table_row"
- And I click on "Instance Management" "link"
- And I should see "1" in the "Course 1" "table_row"
- And I log out
-
- # Allow the instance override
- And I log in as "teacher1"
- And I navigate to course "Course 1" automation instances
- And I click on ".action-edit" "css_element" in the "Notification1" "table_row"
- And I click on ".checkboxgroupautomation" "css_element" in the "#fitem_id_title" "css_element"
- And I set the following fields to these values:
- | Title | Template01 |
- And I wait "2" seconds
- And I press "Save changes"
- And I wait "10" seconds
- And I should see "Template01" in the "notification1C1" "table_row"
- And I close all opened windows
- And I log out
-
- # Allow the instance override
- And I log in as "admin"
- And I navigate to "Users > Permissions > Define roles" in site administration
- And I click on ".fa-cog" "css_element" in the "teacher" "table_row"
- And I set the field "mod/pulse:overridetemplateinstance" to "0"
- And I press "Save changes"
- And I log out
-
- And I log in as "teacher1"
- And I navigate to course "Course 1" automation instances
- And I click on ".action-edit" "css_element" in the "Template01" "table_row"
- And ".form-control[disabled='disabled']" "css_element" should exist in the "#fitem_id_title" "css_element"
- And I press "Save changes"
- And I should see "Notification1" in the "notification1C1" "table_row"
- And I close all opened windows
-
- @javascript
- Scenario: Placeholder for extending assignment submission deadlines
- Given I log in as "admin"
- And I am on "Course 1" course homepage
- And I am on the "Assign1" "assign activity" page
- And I click on "Settings" "link" in the ".secondary-navigation" "css_element"
- And I set the following fields to these values:
- | Due date | ##1 March 2024## |
- And I press "Save and display"
-
- And I am on the "Assign2" "assign activity" page
- And I click on "Settings" "link" in the ".secondary-navigation" "css_element"
- And I set the following fields to these values:
- | Due date | ##31 March 2024## |
- And I press "Save and display"
-
- And I am on the "Assign3" "assign activity" page
- And I click on "Settings" "link" in the ".secondary-navigation" "css_element"
- And I set the following fields to these values:
- | Due date | ##1 April 2024## |
- And I press "Save and display"
-
- And I navigate to course "Course 1" automation instances
- And I click on ".action-edit" "css_element" in the "Template1" "table_row"
- And I click on "Notification" "link" in the "#automation-tabs" "css_element"
- And I click on "#id_override_pulsenotification_headercontent_editor" "css_element" in the "#fitem_id_pulsenotification_headercontent_editor" "css_element"
- And I wait "2" seconds
- And I click on ".fa-angle-double-down" "css_element" in the "#header-email-vars-button" "css_element"
- And I click on "Show more" "link" in the ".User_field-placeholders" "css_element"
- And I click on "Show less" "link" in the ".User_field-placeholders" "css_element"
- And I click on pulse "id_pulsenotification_headercontent_editor" editor
- And I click on "Extensions" "link" in the ".Assignment_field-placeholders .placeholders" "css_element"
- And I click on "Preview" "button" in the "#fitem_id_pulsenotification_preview" "css_element"
- And I should see "No extensions have been granted for upcoming assignments." in the "Preview" "dialogue"
- And I click on ".close" "css_element" in the "Preview" "dialogue"
- And I press "Save changes"
- And I log out
-
- And I log in as "student1"
- And I am on "Course 1" course homepage
- And I am on the "Assign1" "assign activity" page
- And I should see "The due date for this assignment has now passed" in the "Time remaining" "table_row"
- And I am on the "Assign3" "assign activity" page
- And I should see "The due date for this assignment has now passed" in the "Time remaining" "table_row"
- And I log out
-
- # Due date extension in assign1 activity
- And I log in as "admin"
- And I am on "Course 1" course homepage
- And I am on the "Assign1" "assign activity" page
- And I click on "View all submissions" "link" in the ".tertiary-navigation" "css_element"
- And I click on "Edit" "link" in the "student User 1" "table_row"
- And I choose "Grant extension" in the open action menu
- And I set the following fields to these values:
- | Extension due date | ##1 July 2024## |
- And I press "Save changes"
- And I should see "Extension granted until: Monday, 1 July 2024, 12:00 AM" in the "student User 1" "table_row"
-
- # Due date extension in assign3 activity
- And I am on the "Assign3" "assign activity" page
- And I click on "View all submissions" "link" in the ".tertiary-navigation" "css_element"
- And I click on "Edit" "link" in the "student User 1" "table_row"
- And I choose "Grant extension" in the open action menu
- And I set the following fields to these values:
- | Extension due date | ##2 August 2024 14:27## |
- And I press "Save changes"
- And I should see "Extension granted until: Friday, 2 August 2024, 2:27 PM" in the "student User 1" "table_row"
-
- And I navigate to course "Course 1" automation instances
- And I click on ".action-edit" "css_element" in the "Template1" "table_row"
- And I click on "Notification" "link" in the "#automation-tabs" "css_element"
- And I click on "Preview" "button" in the "#fitem_id_pulsenotification_preview" "css_element"
- And I wait "10" seconds
- And I should see "Assign1: Monday, 1 July 2024, 12:00 AM(Previously: Friday, 1 March 2024, 12:00 AM)" in the "Preview" "dialogue"
- And I should see "Assign3: Friday, 2 August 2024, 2:27 PM(Previously: Monday, 1 April 2024, 12:00 AM)" in the "Preview" "dialogue"
- And I click on ".close" "css_element" in the "Preview" "dialogue"
- And I press "Save changes"
- And I log out
-
- And I log in as "student1"
- And I am on "Course 1" course homepage
- And I am on the "Assign1" "assign activity" page
- And I should see "Monday, 1 July 2024, 12:00 AM" in the "Extension due date" "table_row"
- And I press "Mark as done"
-
- And I am on the "Assign3" "assign activity" page
- And I should see "Friday, 2 August 2024, 2:27 PM" in the "Extension due date" "table_row"
- And I press "Mark as done"
- And I log out
-
- And I log in as "admin"
- And I navigate to course "Course 1" automation instances
- And I click on ".action-edit" "css_element" in the "Template1" "table_row"
- And I click on "Notification" "link" in the "#automation-tabs" "css_element"
- And I click on "Preview" "button" in the "#fitem_id_pulsenotification_preview" "css_element"
- And I should see "No extensions have been granted for upcoming assignments." in the "Preview" "dialogue"
- And I click on ".close" "css_element" in the "Preview" "dialogue"
- And I press "Save changes"
-
- @javascript
- Scenario: Notification of events condition for extending assignment submission deadlines
- Given I log in as "admin"
- And I am on "Course 1" course homepage
- And I am on the "Assign1" "assign activity" page
- And I click on "Settings" "link" in the ".secondary-navigation" "css_element"
- And I set the following fields to these values:
- | Due date | ##1 March 2024## |
- And I press "Save and display"
- And I log out
-
- And I log in as "student1"
- And I am on "Course 1" course homepage
- And I am on the "Assign1" "assign activity" page
- And I should see "The due date for this assignment has now passed" in the "Time remaining" "table_row"
- And I log out
-
- And I log in as "admin"
- And I navigate to course "Course 1" automation instances
- And I should see "Template1" in the "temp1C1" "table_row"
- And I click on ".action-edit" "css_element" in the "Template1" "table_row"
- And I click on "Condition" "link" in the "#automation-tabs" "css_element"
- And I click on "#id_override_triggeroperator" "css_element" in the "#fitem_id_triggeroperator" "css_element"
- And I set the field "Trigger operator" to "Any"
- And I click on "#id_override_condition_events_status" "css_element" in the "#fitem_id_condition_events_status" "css_element"
- And I set the field "Events completion" to "All"
- And I open the autocomplete suggestions list in the "Event" "fieldset"
- And I click on "An extension has been granted. \mod_assign\event\extension_granted" item in the autocomplete list
- And I set the field "User" to "1"
- And I set the field "Event module" to "Assign1"
- And I click on "Notification" "link" in the "#automation-tabs" "css_element"
- And I click on "#id_override_pulsenotification_recipients" "css_element" in the "#fitem_id_pulsenotification_recipients" "css_element"
- And I set the field "Recipients" to "Student"
- And I click on "#id_override_pulsenotification_cc" "css_element" in the "#fitem_id_pulsenotification_cc" "css_element"
- And I set the field "Cc" to "Teacher"
- And I press "Save changes"
-
- And I am on "Course 1" course homepage
- And I am on the "Assign1" "assign activity" page
- And I click on "View all submissions" "link" in the ".tertiary-navigation" "css_element"
- And I click on "Edit" "link" in the "student User 1" "table_row"
- And I choose "Grant extension" in the open action menu
- And I set the following fields to these values:
- | Extension due date | ##1 July 2024## |
- And I press "Save changes"
- And I should see "Extension granted until: Monday, 1 July 2024, 12:00 AM" in the "student User 1" "table_row"
- And I navigate to course "Course 1" automation instances
- And I trigger cron
- And I navigate to course "Course 1" automation instances
- And I should see "Template1" in the "temp1C1" "table_row"
- And I click on ".action-report" "css_element" in the "temp1C1" "table_row"
- And I switch to a second window
- And I should see "sent" in the "Template1" "table_row"
diff --git a/tests/behat/pulse_automation_template.feature b/tests/behat/pulse_automation_template.feature
deleted file mode 100644
index 10236b0..0000000
--- a/tests/behat/pulse_automation_template.feature
+++ /dev/null
@@ -1,290 +0,0 @@
-@mod @mod_pulse @pulse_automation_template
-Feature: Pulse automation templates
- In order to check the the pulse automation template works
- As a teacher.
-
- Background:
- Given the following "categories" exist:
- | name | category | idnumber |
- | Cat 1 | 0 | CAT1 |
- | Cat 2 | 0 | CAT2 |
- And the following "course" exist:
- | fullname | shortname | category |
- | Course 1 | C1 | 0 |
- | Course 2 | C2 | CAT1 |
- | Course 3 | C3 | CAT2 |
- And the following "users" exist:
- | 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 |
- | teacher1 | C1 | editingteacher |
- | student1 | C1 | student |
-
- @javascript
- Scenario: Check the automation template.
- Given I log in as "admin"
- And I navigate to "Plugins > Activity modules > Pulse > Automation templates" in site administration
- Then I should see "Automation templates" in the "#region-main h2" "css_element"
- And I should see "Create new template"
- Then I click on "Create new template" "button"
- And I set the following fields to these values:
- | Title | WELCOME MESSAGE |
- | Reference | Welcomemessage |
- | Visibility | Show |
- | Status | Enabled |
- Then I press "Save changes"
- Then I should see "Template inserted successfully"
- Then I should see "Automation templates"
- Then "#region-main-box .flexible#pulse_automation_template" "css_element" should exist
- And I should see "WELCOME MESSAGE" in the "#pulse_automation_template" "css_element"
- And I should see "Welcomemessage" in the "#pulse_automation_template .template-reference" "css_element"
- And "#pulse_automation_template .menu-item-actions .action-edit" "css_element" should exist
- Then I create automation template with the following fields to these values:
- | Title | Triggers |
- | Reference | Conditiontriggers |
- Then I should see "Template inserted successfully"
- And I should see "WELCOME MESSAGE" in the "#pulse_automation_template tbody tr:nth-child(1)" "css_element"
- And I should see "Welcomemessage" in the "#pulse_automation_template tbody tr:nth-child(1) .template-reference" "css_element"
- And I should see "Triggers" in the "#pulse_automation_template tbody tr:nth-child(2)" "css_element"
- And I should see "Conditiontriggers" in the "#pulse_automation_template tbody tr:nth-child(2) .template-reference" "css_element"
-
- @javascript
- Scenario: Edit the automation template
- Given I log in as "admin"
- Then I create automation template with the following fields to these values:
- | Title | WELCOME MESSAGE |
- | Reference | Welcomemessage |
- Then I should see "Template inserted successfully"
- And I should see "WELCOME MESSAGE" in the "#pulse_automation_template tbody tr:nth-child(1)" "css_element"
- And I should see "Welcomemessage" in the "#pulse_automation_template tbody tr:nth-child(1) .template-reference" "css_element"
- And "#pulse_automation_template .menu-item-actions .action-edit" "css_element" should exist
- Then I click on ".action-edit" "css_element" in the "WELCOME MESSAGE" "table_row"
- Then I should see "Edit template"
- And I set the following fields to these values:
- | Title | Triggers |
- | Reference | Conditiontriggers |
- Then I press "Save changes"
- Then I should see "Template updated successfully"
- And I should see "Triggers" in the "#pulse_automation_template tbody tr:nth-child(1)" "css_element"
- And I should see "Conditiontriggers" in the "#pulse_automation_template tbody tr:nth-child(1) .template-reference" "css_element"
-
- @javascript
- Scenario: Check Visibility of automation template
- Given I log in as "admin"
- Then I create automation template with the following fields to these values:
- | Title | WELCOME MESSAGE |
- | Reference | Welcomemessage |
- | Visibility | Show |
- And I should see "WELCOME MESSAGE" in the "#pulse_automation_template" "css_element"
- And I am on "Course 1" course homepage
- Then I should see "Automation"
- And I follow "Automation"
- Then I should see "Automation" in the "#region-main h2" "css_element"
- And ".template-add-form .custom-select#id_templateid" "css_element" should exist
- When I open the autocomplete suggestions list
- Then I should see "WELCOME MESSAGE" in the ".template-add-form .form-autocomplete-suggestions" "css_element"
- And I navigate to "Plugins > Activity modules > Pulse > Automation templates" in site administration
- Then I click on ".action-edit" "css_element" in the "WELCOME MESSAGE" "table_row"
- And I set the field "Visibility" to "Hidden"
- Then I press "Save changes"
- And I am on "Course 1" course homepage
- And I follow "Automation"
- And ".template-add-form .custom-select#id_templateid" "css_element" should not exist
- Then I should not see "WELCOME MESSAGE" in the ".template-add-form" "css_element"
- And I navigate to "Plugins > Activity modules > Pulse > Automation templates" in site administration
- Then I click on ".action-show" "css_element" in the "WELCOME MESSAGE" "table_row"
- And I am on "Course 1" course homepage
- And I follow "Automation"
- And ".template-add-form .custom-select#id_templateid" "css_element" should exist
- When I open the autocomplete suggestions list
- Then I should see "WELCOME MESSAGE" in the ".template-add-form" "css_element"
-
- @javascript
- Scenario: Check Status of automation template
- Given I log in as "admin"
- Then I create automation template with the following fields to these values:
- | Title | WELCOME MESSAGE |
- | Reference | Welcomemessage |
- | Visibility | Show |
- | Status | Enable |
- And I should see "WELCOME MESSAGE" in the "#pulse_automation_template" "css_element"
- And I am on "Course 1" course homepage
- Then I should see "Automation"
- And I follow "Automation"
- Then I should see "Automation" in the "#region-main h2" "css_element"
- And ".template-add-form .custom-select#id_templateid" "css_element" should exist
- When I open the autocomplete suggestions list
- Then I should see "WELCOME MESSAGE" in the ".template-add-form .form-autocomplete-suggestions" "css_element"
- And I navigate to "Plugins > Activity modules > Pulse > Automation templates" in site administration
- Then I click on ".action-edit" "css_element" in the "WELCOME MESSAGE" "table_row"
- And I set the field "Visibility" to "Hidden"
- Then I press "Save changes"
- And I am on "Course 1" course homepage
- And I follow "Automation"
- And ".template-add-form .custom-select#id_templateid" "css_element" should not exist
- Then I should not see "WELCOME MESSAGE" in the ".template-add-form" "css_element"
- And I navigate to "Plugins > Activity modules > Pulse > Automation templates" in site administration
- Then I click on ".action-show" "css_element" in the "WELCOME MESSAGE" "table_row"
- And I am on "Course 1" course homepage
- And I follow "Automation"
- And ".template-add-form .custom-select#id_templateid" "css_element" should exist
- When I open the autocomplete suggestions list
- Then I should see "WELCOME MESSAGE" in the ".template-add-form" "css_element"
-
- @javascript
- Scenario: Check Available in course categories for automation template
- Given I log in as "admin"
- Then I create automation template with the following fields to these values:
- | Title | WELCOME MESSAGE |
- | Reference | Welcomemessage |
- | Available in course categories | Category 1 |
- And I am on "Course 1" course homepage
- Then I should see "Automation"
- And I follow "Automation"
- And ".template-add-form .custom-select#id_templateid" "css_element" should exist
- When I open the autocomplete suggestions list
- Then I should see "WELCOME MESSAGE" in the ".template-add-form .form-autocomplete-suggestions" "css_element"
- # Course 2
- And I am on "Course 2" course homepage
- Then I should see "Automation"
- And I follow "Automation"
- And ".template-add-form .custom-select#id_templateid" "css_element" should not exist
- Then I should not see "WELCOME MESSAGE" in the ".template-add-form" "css_element"
- # Course 3
- And I am on "Course 2" course homepage
- Then I should see "Automation"
- And I follow "Automation"
- And ".template-add-form .custom-select#id_templateid" "css_element" should not exist
- Then I should not see "WELCOME MESSAGE" in the ".template-add-form" "css_element"
- # Update the template
- And I navigate to "Plugins > Activity modules > Pulse > Automation templates" in site administration
- Then I click on ".action-edit" "css_element" in the "WELCOME MESSAGE" "table_row"
- And I set the field "Available in course categories" to "Category 1, Cat 1"
- Then I press "Save changes"
- And I am on "Course 1" course homepage
- Then I should see "Automation"
- And I follow "Automation"
- And ".template-add-form .custom-select#id_templateid" "css_element" should exist
- When I open the autocomplete suggestions list
- Then I should see "WELCOME MESSAGE" in the ".template-add-form .form-autocomplete-suggestions" "css_element"
- # Course 2
- And I am on "Course 2" course homepage
- Then I should see "Automation"
- And I follow "Automation"
- And ".template-add-form .custom-select#id_templateid" "css_element" should exist
- When I open the autocomplete suggestions list
- Then I should see "WELCOME MESSAGE" in the ".template-add-form .form-autocomplete-suggestions" "css_element"
- # Course 3
- And I am on "Course 3" course homepage
- Then I should see "Automation"
- And I follow "Automation"
- And ".template-add-form .custom-select#id_templateid" "css_element" should not exist
- Then I should not see "WELCOME MESSAGE" in the ".template-add-form" "css_element"
-
- @javascript
- Scenario: Check condition for automation template
- Given I log in as "admin"
- Then I create automation template with the following fields to these values:
- | Title | WELCOME MESSAGE |
- | Reference | Welcomemessage |
- | Available in course categories | Category 1 |
- Then I create "Welcomemessage" template with the set the condition:
- | Triggers | Activity completion, Member in cohorts |
- | Trigger operator | All |
- And I am on "Course 1" course homepage
- And I follow "Automation"
- When I open the autocomplete suggestions list
- And I click on "WELCOME MESSAGE" item in the autocomplete list
- Then I press "Add automation instance"
- Then I follow "Condition"
- Then I should see "Activity completion"
- Then I should see "Member in cohorts"
- Then the field "Activity completion" matches value "All"
- Then the field "Select activities" matches value ""
- Then the field "Member in cohorts" matches value "All"
- Then the field "Cohorts" matches value ""
-
- @javascript
- Scenario: Check Notification for automation template
- Given I log in as "admin"
- And I navigate to "Plugins > Activity modules > Pulse > Automation templates" in site administration
- Then I create automation template with the following fields to these values:
- | Title | WELCOME MESSAGE |
- | Reference | Welcomemessage |
- | Available in course categories | Category 1 |
- Then I create "Welcomemessage" template with the set the condition:
- | Triggers | Activity completion, Member in cohorts |
- | Trigger operator | All |
- Then I create "Welcomemessage" template with the set the notification:
- | Sender | Group teacher |
- | Interval | Once |
- | Cc | Teacher |
- | Bcc | Manager |
- | Subject | Demo MESSAGE |
- | Header content | Lorem Ipsum is therefore always free from repetition, injected humour |
- | Static content | There are many variations of passages of Lorem Ipsum available, but the majority have suffered alteration in some form |
- Then I should see "Template updated successfully"
- And I am on "Course 1" course homepage
- And I follow "Automation"
- When I open the autocomplete suggestions list
- And I click on "WELCOME MESSAGE" item in the autocomplete list
- Then I press "Add automation instance"
- Then I click on "#automation-tabs .nav-item:nth-child(3) a" "css_element"
- Then I wait "10" seconds
- Then the field "Sender" matches value "Group teacher"
- Then the field "Interval" matches value "Once"
- Then the field "Subject" matches value "Demo MESSAGE"
-
- @javascript
- Scenario: Check Notification for automation overrides badge
- Given I log in as "admin"
- Then I create automation template with the following fields to these values:
- | Title | WELCOME MESSAGE |
- | Reference | Welcomemessage |
- Then I create automation template with the following fields to these values:
- | Title | Notification |
- | Reference | notification |
- And I am on "Course 1" course homepage
- And I follow "Automation"
- When I open the autocomplete suggestions list
- And I click on "WELCOME MESSAGE" item in the autocomplete list
- Then I click on "Add automation instance" "button"
- And I set the following fields to these values:
- | insreference | Welcomemessageinstance |
- And I press "Save changes"
- When I open the autocomplete suggestions list
- And I click on "WELCOME MESSAGE" item in the autocomplete list
- Then I click on "Add automation instance" "button"
- And I set the following fields to these values:
- | insreference | Welcomemessageinstance2 |
- And I press "Save changes"
- When I open the autocomplete suggestions list
- And I click on "WELCOME MESSAGE" item in the autocomplete list
- Then I click on "Add automation instance" "button"
- And I set the following fields to these values:
- | insreference | Welcomemessageinstance3 |
- And I press "Save changes"
- When I open the autocomplete suggestions list
- And I click on "Notification" item in the autocomplete list
- Then I click on "Add automation instance" "button"
- And I set the following fields to these values:
- | insreference | notificationinstance |
- And I press "Save changes"
- And I navigate to "Plugins > Activity modules > Pulse > Automation templates" in site administration
- And I should see "3(0)" in the "WELCOME MESSAGE" "table_row"
- And I should see "1(0)" in the "notification" "table_row"
- And I am on "Course 1" course homepage
- And I follow "Automation"
- Then I click on ".pulse-instance-status-switch" "css_element" in the "Welcomemessageinstance" "table_row"
- And I navigate to "Plugins > Activity modules > Pulse > Automation templates" in site administration
- And I should see "3(1)" in the "WELCOME MESSAGE" "table_row"
- And I should see "1(0)" in the "notification" "table_row"
- And I am on "Course 1" course homepage
- And I follow "Automation"
- Then I click on ".action-hide" "css_element" in the "Welcomemessageinstance2" "table_row"
- Then I click on ".action-hide" "css_element" in the "notificationinstance" "table_row"
- And I navigate to "Plugins > Activity modules > Pulse > Automation templates" in site administration
- And I should see "3(2)" in the "WELCOME MESSAGE" "table_row"
- And I should see "1(1)" in the "notification" "table_row"
diff --git a/version.php b/version.php
index a7c2ef0..1da694f 100644
--- a/version.php
+++ b/version.php
@@ -25,7 +25,7 @@
defined('MOODLE_INTERNAL') || die();
$plugin->component = 'mod_pulse';
-$plugin->version = 2024033003;
+$plugin->version = 2024033004;
$plugin->requires = 2022112800; // Requires Moodle 4.1.
$plugin->release = 'v2.1';
$plugin->maturity = MATURITY_STABLE;