diff --git a/actions/notification/tests/behat/behat_pulseaction_notification.php b/actions/notification/tests/behat/behat_pulseaction_notification.php index ffff130..edcfac2 100644 --- a/actions/notification/tests/behat/behat_pulseaction_notification.php +++ b/actions/notification/tests/behat/behat_pulseaction_notification.php @@ -133,21 +133,4 @@ public function i_set_previous_template_notification($notificationdata) { $this->execute('behat_forms::i_set_the_following_fields_to_these_values', [$notificationdata]); } - - - /** - * Switches to a third window. - * - * @Given /^I switch to a third window$/ - * @throws DriverException If there aren't exactly 3 windows open. - */ - public function switch_to_third_window() { - $names = $this->getSession()->getWindowNames(); - - if (count($names) !== 3) { - throw new DriverException('Expected to see 3 windows open, found ' . count($names)); - } - - $this->getSession()->switchToWindow($names[2]); - } } diff --git a/actions/notification/tests/behat/pulse_notification_template.feature b/actions/notification/tests/behat/pulse_notification_template.feature index ee5f4ab..e2a1d12 100644 --- a/actions/notification/tests/behat/pulse_notification_template.feature +++ b/actions/notification/tests/behat/pulse_notification_template.feature @@ -9,69 +9,69 @@ Feature: Configuring the pulseaction_notification plugin on the "Automation temp | name | category | idnumber | | Cat 1 | 0 | CAT1 | And the following "course" exist: - | fullname | shortname | category | - | Course 1 | C1 | 0 | + | fullname | shortname | category | + | Course 1 | C1 | 0 | And the following "activities" exist: - | activity | name | intro | course | idnumber | - | book | Test book name | Test book description | C1 | book1 | + | activity | name | intro | course | idnumber | + | book | Test book name | Test book description | C1 | book1 | And the following "users" exist: - | username | firstname | lastname | email | - | student1 | student | User 1 | student1@test.com | - | teacher1 | teacher | User 1 | teacher1@test.com | + | username | firstname | lastname | email | + | student1 | student | User 1 | student1@test.com | + | teacher1 | teacher | User 1 | teacher1@test.com | And the following "course enrolments" exist: - | user | course | role | + | user | course | role | | student1 | C1 | student | | teacher1 | C1 | teacher | And the following "permission overrides" exist: - | capability | permission | role | contextlevel | reference | - | pulseaction/notification:receivenotification | Allow | teacher | System | | + | capability | permission | role | contextlevel | reference | + | pulseaction/notification:receivenotification | Allow | teacher | System | | @javascript Scenario: Create notification template and instance Given I log in as "admin" And I navigate to automation templates And I create pulse notification template "WELCOME MESSAGE" "WELCOMEMESSAGE_" to these values: - | Sender | Course teacher | - | Recipients | Student | - | Subject | Welcome to {Site_FullName} | + | Sender | Course teacher | + | Recipients | Student | + | Subject | Welcome to {Site_FullName} | | Header content | Hi {User_firstname} {User_lastname},
Welcome to learning portal of {Site_FullName} | - | Footer content | Copyright @ 2023 {Site_FullName} | + | Footer content | Copyright @ 2023 {Site_FullName} | Then I should see "Automation templates" And I should see "WELCOME MESSAGE" in the "pulse_automation_template" "table" And I navigate to course "Course 1" automation instances And I create pulse notification instance "WELCOME MESSAGE" "COURSE_1" to these values: - | Recipients | Student | + | Recipients | Student | And I should see "WELCOMEMESSAGE_COURSE_1" in the "pulse_automation_template" "table" And I click on ".action-report" "css_element" in the "WELCOMEMESSAGE_COURSE_1" "table_row" And I switch to a second window Then ".reportbuilder-report" "css_element" should exist And the following should exist in the "reportbuilder-table" table: - | Full name | Subject | Status | - | student User 1 | Welcome to Acceptance test site | Queued | + | Full name | Subject | Status | + | student User 1 | Welcome to Acceptance test site | Queued | @javascript Scenario: Override notification template Given I log in as "admin" And I navigate to automation templates And I create pulse notification template "WELCOME MESSAGE" "WELCOMEMESSAGE_" to these values: - | Sender | Course teacher | - | Recipients | Student | - | Subject | Welcome to {Site_FullName} | + | Sender | Course teacher | + | Recipients | Student | + | Subject | Welcome to {Site_FullName} | | Header content | Hi {User_firstname} {User_lastname},
Welcome to learning portal of {Site_FullName} | - | Footer content | Copyright @ 2023 {Site_FullName} | + | Footer content | Copyright @ 2023 {Site_FullName} | Then I should see "Automation templates" And I should see "WELCOME MESSAGE" in the "pulse_automation_template" "table" And I navigate to course "Course 1" automation instances And I create pulse notification instance "WELCOME MESSAGE" "COURSE_1" to these values: - | override[pulsenotification_subject] | 1 | - | Subject | Welcome to learning portal {Site_FullName} | + | override[pulsenotification_subject] | 1 | + | Subject | Welcome to learning portal {Site_FullName} | And I should see "WELCOMEMESSAGE_COURSE_1" in the "pulse_automation_template" "table" And I click on ".action-report" "css_element" in the "WELCOMEMESSAGE_COURSE_1" "table_row" And I switch to a second window Then ".reportbuilder-report" "css_element" should exist And the following should exist in the "reportbuilder-table" table: - | Full name | Subject | Status | - | student User 1 | Welcome to learning portal Acceptance test site | Queued | + | Full name | Subject | Status | + | student User 1 | Welcome to learning portal Acceptance test site | Queued | @javascript Scenario: Preview the notification content @@ -80,11 +80,11 @@ Feature: Configuring the pulseaction_notification plugin on the "Automation temp | Title | WELCOME MESSAGE | | Reference | WELCOMEMESSAGE_ | And I set previous automation template notification to these values: - | Sender | Course teacher | - | Recipients | Student | - | Subject | Welcome to {Site_FullName} | + | Sender | Course teacher | + | Recipients | Student | + | Subject | Welcome to {Site_FullName} | | Header content | Hi {User_firstname} {User_lastname},
Welcome to {Site_FullName} | - | Footer content |

Copyright @ 2023 {Site_FullName}

| + | Footer content |

Copyright @ 2023 {Site_FullName}

| And I press "Preview" And I should see "Preview" in the ".modal-header .modal-title" "css_element" Then I set the field "userselector" to "student User 1" @@ -97,9 +97,9 @@ Feature: Configuring the pulseaction_notification plugin on the "Automation temp And I should see "WELCOME MESSAGE" in the "pulse_automation_template" "table" And I navigate to course "Course 1" automation instances And I initiate new automation instance of template "WELCOME MESSAGE" to these values: - | Reference | COURSE_1 | + | Reference | COURSE_1 | And I set previous automation template notification to these values: - | Recipients | Student | + | Recipients | Student | And I press "Preview" And I should see "Preview" in the ".modal-header .modal-title" "css_element" Then I set the field "userselector" to "student User 1" @@ -117,53 +117,53 @@ Feature: Configuring the pulseaction_notification plugin on the "Automation temp Given I log in as "admin" And I navigate to automation templates And I create pulse notification template "WELCOME MESSAGE" "WELCOMEMESSAGE_" to these values: - | Sender | Course teacher | - | Recipients | Student | - | Subject | Welcome to {Site_FullName} | - | Header content | Hi {User_firstname} {User_lastname},
Welcome to learning portal of {Site_FullName} | - | Footer content | Copyright @ 2023 {Site_FullName} | - | Delay | After | - | pulsenotification_delayduration[number] | 10 | + | Sender | Course teacher | + | Recipients | Student | + | Subject | Welcome to {Site_FullName} | + | Header content | Hi {User_firstname} {User_lastname},
Welcome to learning portal of {Site_FullName} | + | Footer content | Copyright @ 2023 {Site_FullName} | + | Delay | After | + | pulsenotification_delayduration[number] | 10 | Then I should see "Automation templates" And I should see "WELCOME MESSAGE" in the "pulse_automation_template" "table" And I navigate to course "Course 1" automation instances And I create pulse notification instance "WELCOME MESSAGE" "COURSE_1" to these values: - | override[pulsenotification_subject] | 1 | - | Subject | Welcome to learning portal {Site_FullName} | + | override[pulsenotification_subject] | 1 | + | Subject | Welcome to learning portal {Site_FullName} | And I should see "WELCOMEMESSAGE_COURSE_1" in the "pulse_automation_template" "table" And I click on ".action-report" "css_element" in the "WELCOMEMESSAGE_COURSE_1" "table_row" And I switch to a second window Then ".reportbuilder-report" "css_element" should exist And the following should exist in the "reportbuilder-table" table: - | Full name | Subject | Status | Time created | Scheduled time | - | student User 1 | Welcome to learning portal Acceptance test site | Queued | ##now##%A, %d %B %Y, %I:%M %p## | ##+10 minutes##%A, %d %B %Y, %I:%M %p## | + | Full name | Subject | Status | Time created | Scheduled time | + | student User 1 | Welcome to learning portal Acceptance test site | Queued | ##now##%A, %d %B %Y, %I:%M %p## | ##+10 minutes##%A, %d %B %Y, %I:%M %p## | @javascript Scenario Outline: Pulse action Notification: Send notification for different role users Given I log in as "admin" And I navigate to automation templates And I create pulse notification template "WELCOME MESSAGE" "WELCOMEMESSAGE_" to these values: - | Sender | Custom | - | Sender email | test@test.com | - | Recipients | | - | Subject | Welcome to {Site_FullName} | + | Sender | Custom | + | Sender email | test@test.com | + | Recipients | | + | Subject | Welcome to {Site_FullName} | | Header content | Hi {User_firstname} {User_lastname},
Welcome to learning portal of {Site_FullName} | Then I should see "Automation templates" And I should see "WELCOME MESSAGE" in the "pulse_automation_template" "table" And I navigate to course "Course 1" automation instances # Demo content. And I create pulse notification instance "WELCOME MESSAGE" "COURSE_1" to these values: - | Recipients | Student | + | Recipients | Student | And I should see "WELCOMEMESSAGE_COURSE_1" in the "pulse_automation_template" "table" And I click on ".action-report" "css_element" in the "WELCOMEMESSAGE_COURSE_1" "table_row" And I switch to a second window Then ".reportbuilder-report" "css_element" should exist And the following exist in the "reportbuilder-table" table: - | Full name | Status | - | student User 1 | Queued | + | Full name | Status | + | student User 1 | Queued | And the following exist in the "reportbuilder-table" table: - | Full name | Status | - | teacher User 1 | Queued | + | Full name | Status | + | teacher User 1 | Queued | Examples: | recipient | studentshouldorshouldnot | teachershouldorshouldnot | diff --git a/amd/build/preset.min.js b/amd/build/preset.min.js index 59fc9f6..6b1dc58 100644 --- a/amd/build/preset.min.js +++ b/amd/build/preset.min.js @@ -1,3 +1,3 @@ -define("mod_pulse/preset",["jquery","core/modal_factory","mod_pulse/modal_preset","mod_pulse/events","core/str","core/fragment","core/ajax","core/templates","core/loadingicon","core/notification","core/modal_events","mod_pulse/presetmodal"],(function($,Modal,ModalPreset,PresetEvents,Str,Fragment,AJAX,Templates,Loadingicon,Notification,ModalEvents,PresetModal){var SELECTOR_presetAvailability=".preset-config-params .availability-field",Preset=function(contextId,courseid,section){this.contextId=contextId,this.courseid=courseid,this.section=section,this.loadPresetsList()};return Preset.prototype.listElement={selector:"pulse-presets-data",loaded:"data-listloaded"},Preset.prototype.contextId=0,Preset.prototype.courseid=0,Preset.prototype.section=0,Preset.prototype.pageparams=[],Preset.prototype.loadIconElement=".modal-footer #loader-icon",Preset.prototype.actionbuttons=".modal-footer button",Preset.prototype.setupmodal=function(){var THIS=this,triggerelement=document.querySelectorAll(".pulse-usepreset"),attachmentPoint=document.createElement("div");attachmentPoint.classList.add("modal-preset"),triggerelement.forEach((element=>element.addEventListener("click",(()=>{var presetid=element.getAttribute("data-presetid"),presettitle=element.getAttribute("data-presettitle"),params={presetid:presetid,courseid:THIS.courseid,section:THIS.section};document.body.prepend(attachmentPoint),(void 0===PresetModal.registerModalType?Modal.create({type:ModalPreset.TYPE,title:Str.get_string("presetmodaltitle","pulse",{title:presettitle}),body:Fragment.loadFragment("mod_pulse","get_preset_preview",THIS.contextId,params),large:!0}):PresetModal.create({title:Str.get_string("presetmodaltitle","pulse",{title:presettitle}),body:Fragment.loadFragment("mod_pulse","get_preset_preview",THIS.contextId,params),large:!0})).then((modal=>(modal.attachmentPoint=attachmentPoint,modal.show(),modal.getRoot().on(ModalEvents.bodyRendered,(function(){THIS.reinitAvailability(SELECTOR_presetAvailability),THIS.fieldChangedEvent()})),modal.getRoot().on(ModalEvents.hidden,(function(){modal.getRoot().get(0).querySelectorAll("form textarea").forEach((target=>{"undefined"!=tinyMCE&&tinyMCE.EditorManager.get(target.id).remove()})),modal.destroy.bind(modal)})),modal.getRoot().on(PresetEvents.customize,(()=>{var modform=document.querySelector("#mod-pulse-form"),modformdata=new FormData(modform);modal.getRoot().get(0).querySelectorAll("form").forEach((form=>{var formdata=new FormData(form);formdata=new URLSearchParams(formdata).toString();var pageparams=new URLSearchParams(modformdata).toString();params={formdata:formdata,pageparams:pageparams},Loadingicon.addIconToContainer(this.loadIconElement),THIS.disableButtons(),THIS.applyCustomize(params,THIS.contextId,modal)}))})),modal.getRoot().on(PresetEvents.save,(e=>{e.preventDefault(),Loadingicon.addIconToContainer(this.loadIconElement),THIS.disableButtons();var formdata={};modal.getRoot().get(0).querySelectorAll("form").forEach((form=>{formdata=new FormData(form),this.restorePreset(formdata,THIS.contextId)}))})),!0))).catch(Notification.exception)}))))},Preset.prototype.fieldChangedEvent=()=>{var fieldName,changeinput,id,changeName,split,confParam=document.getElementById("preset-configurable-params"),methods=["fixed","relative"];confParam.querySelectorAll("input, select, textarea").forEach((field=>{field.addEventListener("change",(event=>{fieldName=event.target.getAttribute("name"),null!==confParam.querySelector('input[name="'+fieldName+'_changed"]')&&(confParam.querySelector('input[name="'+fieldName+'_changed"]').value=!0)}))})),["first","second","recurring"].forEach((reminder=>{confParam.querySelectorAll('[name="'+reminder+'_schedule"').forEach((schedule=>{schedule.addEventListener("change",(e=>{changeName=e.target.getAttribute("name"),changeinput='input[name="'+changeName+'_arr_changed"]',confParam.querySelector(changeinput).value=!0}))})),methods.forEach((method=>{id=reminder+"_"+method+"date",confParam.querySelectorAll('[name*="'+id+'"]').forEach((opt=>{opt.addEventListener("change",(e=>{split=e.target.getAttribute("name").split("["),changeName=split.hasOwnProperty(1)?split[0]:split,changeinput='input[name="'+changeName+'_changed"]',confParam.querySelector(changeinput).value=!0}))}))}))}))},Preset.prototype.reinitAvailability=function(){let selector=arguments.length>0&&void 0!==arguments[0]?arguments[0]:".availability-field";void 0!==M.core_availability.form&&null!==document.getElementById("id_availabilityconditionsjson")&&(this.resetRestrictPlugins(),document.querySelectorAll(selector).forEach((field=>field.parentNode.removeChild(field))),M.core_availability.form.init())},Preset.prototype.resetRestrictPlugins=function(){if(void 0!==M.core_availability.form&&null!==document.getElementById("id_availabilityconditionsjson")){M.core_availability.form.restrictByGroup=null;var availabilityPlugins=void 0!==M.core_availability.form.plugins?M.core_availability.form.plugins:{},plugin="";for(var i in availabilityPlugins)plugin="availability_"+i,M.hasOwnProperty(plugin)&&(M[plugin].form.addedEvents=!1)}},Preset.prototype.applyCustomize=function(params,contextID,modal){Fragment.loadFragment("mod_pulse","apply_preset",contextID,params).done(((html,js)=>{modal.destroy(),this.resetRestrictPlugins(),this.handleFormSubmissionResponse(html,js)}))},Preset.prototype.disableButtons=function(){var buttons=document.querySelectorAll(this.actionbuttons);for(let $i in buttons)buttons[$i].disabled=!0},Preset.prototype.handleFormSubmissionResponse=(data,js)=>{document.createElement("div").innerHTML=data,Templates.replaceNode('[action="modedit.php"]',data,js)},Preset.prototype.restorePreset=(formdata,contextid)=>{var formdatastr=new URLSearchParams(formdata).toString();AJAX.call([{methodname:"mod_pulse_apply_presets",args:{contextid:contextid,formdata:formdatastr}}])[0].done((response=>{void 0!==(response=JSON.parse(response)).url&&(window.location.href=response.url)}))},Preset.prototype.loadPresetsList=function(){var listParent=document.getElementById(this.listElement.selector);null!==listParent&&"false"==listParent.getAttribute(this.listElement.loaded)&&Fragment.loadFragment("mod_pulse","get_presetslist",this.contextId,{courseid:this.courseid}).done(((html,js)=>{Templates.replaceNodeContents(listParent,html,js),listParent.setAttribute(this.listElement.loaded,"true"),this.setupmodal()}))},{init:(contextId,courseid,section)=>{new Preset(contextId,courseid,section)}}})); +define("mod_pulse/preset",["jquery","core/modal_factory","mod_pulse/modal_preset","mod_pulse/events","core/str","core/fragment","core/ajax","core/templates","core/loadingicon","core/notification","core/modal_events","mod_pulse/presetmodal"],(function($,Modal,ModalPreset,PresetEvents,Str,Fragment,AJAX,Templates,Loadingicon,Notification,ModalEvents,PresetModal){var SELECTOR_presetAvailability=".preset-config-params .availability-field",Preset=function(contextId,courseid,section){this.contextId=contextId,this.courseid=courseid,this.section=section,this.loadPresetsList()};return Preset.prototype.listElement={selector:"pulse-presets-data",loaded:"data-listloaded"},Preset.prototype.contextId=0,Preset.prototype.courseid=0,Preset.prototype.section=0,Preset.prototype.pageparams=[],Preset.prototype.loadIconElement=".modal-footer #loader-icon",Preset.prototype.actionbuttons=".modal-footer button",Preset.prototype.setupmodal=function(){var THIS=this,triggerelement=document.querySelectorAll(".pulse-usepreset"),attachmentPoint=document.createElement("div");attachmentPoint.classList.add("modal-preset"),triggerelement.forEach((element=>element.addEventListener("click",(()=>{var presetid=element.getAttribute("data-presetid"),presettitle=element.getAttribute("data-presettitle"),params={presetid:presetid,courseid:THIS.courseid,section:THIS.section};document.body.prepend(attachmentPoint),(void 0===PresetModal.registerModalType?Modal.create({type:ModalPreset.TYPE,title:Str.get_string("presetmodaltitle","pulse",{title:presettitle}),body:Fragment.loadFragment("mod_pulse","get_preset_preview",THIS.contextId,params),large:!0}):PresetModal.create({title:Str.get_string("presetmodaltitle","pulse",{title:presettitle}),body:Fragment.loadFragment("mod_pulse","get_preset_preview",THIS.contextId,params),large:!0})).then((modal=>(modal.attachmentPoint=attachmentPoint,modal.show(),modal.getRoot().on(ModalEvents.bodyRendered,(function(){THIS.reinitAvailability(SELECTOR_presetAvailability),THIS.fieldChangedEvent()})),modal.getRoot().on(ModalEvents.hidden,(function(){modal.getRoot().get(0).querySelectorAll("form textarea").forEach((target=>{"undefined"!=typeof tinyMCE&&tinyMCE.EditorManager.get(target.id).remove()})),modal.destroy.bind(modal)})),modal.getRoot().on(PresetEvents.customize,(()=>{var modform=document.querySelector("#mod-pulse-form"),modformdata=new FormData(modform);modal.getRoot().get(0).querySelectorAll("form").forEach((form=>{var formdata=new FormData(form);formdata=new URLSearchParams(formdata).toString();var pageparams=new URLSearchParams(modformdata).toString();params={formdata:formdata,pageparams:pageparams},Loadingicon.addIconToContainer(this.loadIconElement),THIS.disableButtons(),THIS.applyCustomize(params,THIS.contextId,modal)}))})),modal.getRoot().on(PresetEvents.save,(e=>{e.preventDefault(),Loadingicon.addIconToContainer(this.loadIconElement),THIS.disableButtons();var formdata={};modal.getRoot().get(0).querySelectorAll("form").forEach((form=>{formdata=new FormData(form),this.restorePreset(formdata,THIS.contextId)}))})),!0))).catch(Notification.exception)}))))},Preset.prototype.fieldChangedEvent=()=>{var fieldName,changeinput,id,changeName,split,confParam=document.getElementById("preset-configurable-params"),methods=["fixed","relative"];confParam.querySelectorAll("input, select, textarea").forEach((field=>{field.addEventListener("change",(event=>{fieldName=event.target.getAttribute("name"),null!==confParam.querySelector('input[name="'+fieldName+'_changed"]')&&(confParam.querySelector('input[name="'+fieldName+'_changed"]').value=!0)}))})),["first","second","recurring"].forEach((reminder=>{confParam.querySelectorAll('[name="'+reminder+'_schedule"').forEach((schedule=>{schedule.addEventListener("change",(e=>{changeName=e.target.getAttribute("name"),changeinput='input[name="'+changeName+'_arr_changed"]',confParam.querySelector(changeinput).value=!0}))})),methods.forEach((method=>{id=reminder+"_"+method+"date",confParam.querySelectorAll('[name*="'+id+'"]').forEach((opt=>{opt.addEventListener("change",(e=>{split=e.target.getAttribute("name").split("["),changeName=split.hasOwnProperty(1)?split[0]:split,changeinput='input[name="'+changeName+'_changed"]',confParam.querySelector(changeinput).value=!0}))}))}))}))},Preset.prototype.reinitAvailability=function(){let selector=arguments.length>0&&void 0!==arguments[0]?arguments[0]:".availability-field";void 0!==M.core_availability.form&&null!==document.getElementById("id_availabilityconditionsjson")&&(this.resetRestrictPlugins(),document.querySelectorAll(selector).forEach((field=>field.parentNode.removeChild(field))),M.core_availability.form.init())},Preset.prototype.resetRestrictPlugins=function(){if(void 0!==M.core_availability.form&&null!==document.getElementById("id_availabilityconditionsjson")){M.core_availability.form.restrictByGroup=null;var availabilityPlugins=void 0!==M.core_availability.form.plugins?M.core_availability.form.plugins:{},plugin="";for(var i in availabilityPlugins)plugin="availability_"+i,M.hasOwnProperty(plugin)&&(M[plugin].form.addedEvents=!1)}},Preset.prototype.applyCustomize=function(params,contextID,modal){Fragment.loadFragment("mod_pulse","apply_preset",contextID,params).done(((html,js)=>{modal.destroy(),this.resetRestrictPlugins(),this.handleFormSubmissionResponse(html,js)}))},Preset.prototype.disableButtons=function(){var buttons=document.querySelectorAll(this.actionbuttons);for(let $i in buttons)buttons[$i].disabled=!0},Preset.prototype.handleFormSubmissionResponse=(data,js)=>{document.createElement("div").innerHTML=data,Templates.replaceNode('[action="modedit.php"]',data,js)},Preset.prototype.restorePreset=(formdata,contextid)=>{var formdatastr=new URLSearchParams(formdata).toString();AJAX.call([{methodname:"mod_pulse_apply_presets",args:{contextid:contextid,formdata:formdatastr}}])[0].done((response=>{void 0!==(response=JSON.parse(response)).url&&(window.location.href=response.url)}))},Preset.prototype.loadPresetsList=function(){var listParent=document.getElementById(this.listElement.selector);null!==listParent&&"false"==listParent.getAttribute(this.listElement.loaded)&&Fragment.loadFragment("mod_pulse","get_presetslist",this.contextId,{courseid:this.courseid}).done(((html,js)=>{Templates.replaceNodeContents(listParent,html,js),listParent.setAttribute(this.listElement.loaded,"true"),this.setupmodal()}))},{init:(contextId,courseid,section)=>{new Preset(contextId,courseid,section)}}})); //# sourceMappingURL=preset.min.js.map \ No newline at end of file diff --git a/amd/build/preset.min.js.map b/amd/build/preset.min.js.map index a636070..f8080d3 100644 --- a/amd/build/preset.min.js.map +++ b/amd/build/preset.min.js.map @@ -1 +1 @@ -{"version":3,"file":"preset.min.js","sources":["../src/preset.js"],"sourcesContent":["define(['jquery', 'core/modal_factory', 'mod_pulse/modal_preset', 'mod_pulse/events', 'core/str', 'core/fragment', 'core/ajax',\n 'core/templates', 'core/loadingicon', 'core/notification', 'core/modal_events', 'mod_pulse/presetmodal'],\n function($, Modal, ModalPreset, PresetEvents, Str, Fragment, AJAX, Templates, Loadingicon,\n Notification, ModalEvents, PresetModal) {\n\n var SELECTOR = {\n presetAvailability: '.preset-config-params .availability-field'\n };\n\n /**\n * Preset module declaration. Setup the global values.\n * @param {int} contextId\n * @param {int} courseid\n * @param {int} section\n */\n var Preset = function(contextId, courseid, section) {\n this.contextId = contextId;\n this.courseid = courseid;\n this.section = section;\n this.loadPresetsList();\n };\n\n Preset.prototype.listElement = {'selector': 'pulse-presets-data', \"loaded\": \"data-listloaded\"};\n\n Preset.prototype.contextId = 0;\n\n Preset.prototype.courseid = 0;\n\n Preset.prototype.section = 0;\n\n Preset.prototype.pageparams = [];\n\n Preset.prototype.loadIconElement = '.modal-footer #loader-icon';\n\n Preset.prototype.actionbuttons = '.modal-footer button';\n\n /**\n * Setup the presets modal event listeners.\n */\n Preset.prototype.setupmodal = function() {\n\n var THIS = this;\n\n var triggerelement = document.querySelectorAll('.pulse-usepreset');\n // Modal attachment point.\n var attachmentPoint = document.createElement('div');\n attachmentPoint.classList.add('modal-preset');\n triggerelement.forEach((element) => element.addEventListener('click', () => {\n var presetid = element.getAttribute('data-presetid');\n var presettitle = element.getAttribute('data-presettitle');\n var params = {'presetid': presetid, 'courseid': THIS.courseid, 'section': THIS.section};\n\n document.body.prepend(attachmentPoint);\n\n var modalFn;\n if (typeof PresetModal.registerModalType == 'undefined') {\n modalFn = Modal.create({\n type: ModalPreset.TYPE,\n title: Str.get_string('presetmodaltitle', 'pulse', {'title': presettitle}),\n body: Fragment.loadFragment('mod_pulse', 'get_preset_preview', THIS.contextId, params),\n large: true,\n });\n } else {\n modalFn = PresetModal.create({\n title: Str.get_string('presetmodaltitle', 'pulse', {'title': presettitle}),\n body: Fragment.loadFragment('mod_pulse', 'get_preset_preview', THIS.contextId, params),\n large: true,\n });\n }\n\n modalFn.then(modal => {\n // Make the modal attachment point to overcome the restriction access condition.\n modal.attachmentPoint = attachmentPoint;\n modal.show();\n modal.getRoot().on(ModalEvents.bodyRendered, function() {\n THIS.reinitAvailability(SELECTOR.presetAvailability);\n THIS.fieldChangedEvent();\n });\n // Destroy the modal on hidden to reload the editors.\n modal.getRoot().on(ModalEvents.hidden, function() {\n modal.getRoot().get(0).querySelectorAll('form textarea').forEach(target => {\n if (tinyMCE != 'undefined') { // eslint-disable-line\n tinyMCE.EditorManager.get(target.id).remove(); // eslint-disable-line\n }\n });\n modal.destroy.bind(modal);\n // THIS.reinitAvailability();\n });\n\n // Apply and customize method.\n modal.getRoot().on(PresetEvents.customize, () => {\n var modform = document.querySelector('#mod-pulse-form');\n var modformdata = new FormData(modform);\n modal.getRoot().get(0).querySelectorAll('form').forEach(form => {\n var formdata = new FormData(form);\n formdata = new URLSearchParams(formdata).toString();\n var pageparams = new URLSearchParams(modformdata).toString();\n params = {formdata: formdata, pageparams: pageparams};\n\n Loadingicon.addIconToContainer(this.loadIconElement);\n THIS.disableButtons();\n THIS.applyCustomize(params, THIS.contextId, modal);\n });\n });\n // Apply and save method.\n modal.getRoot().on(PresetEvents.save, (e) => {\n e.preventDefault();\n Loadingicon.addIconToContainer(this.loadIconElement);\n THIS.disableButtons();\n var formdata = {};\n modal.getRoot().get(0).querySelectorAll('form').forEach(form => {\n formdata = new FormData(form);\n this.restorePreset(formdata, THIS.contextId);\n });\n });\n return true;\n }).catch(Notification.exception);\n }));\n };\n\n\n Preset.prototype.fieldChangedEvent = () => {\n var confParam = document.getElementById(\"preset-configurable-params\");\n var reminders = ['first', 'second', 'recurring'];\n var methods = ['fixed', 'relative'];\n var fieldName, changeinput, id, changeName, split;\n confParam.querySelectorAll('input, select, textarea').forEach(field => {\n field.addEventListener('change', (event) => {\n fieldName = event.target.getAttribute('name');\n if (confParam.querySelector('input[name=\"' + fieldName + '_changed\"]') !== null) {\n confParam.querySelector('input[name=\"' + fieldName + '_changed\"]').value = true;\n }\n });\n });\n\n reminders.forEach(reminder => {\n confParam.querySelectorAll('[name=\"' + reminder + '_schedule\"').forEach(schedule => {\n schedule.addEventListener('change', (e) => {\n changeName = e.target.getAttribute('name');\n changeinput = 'input[name=\"' + changeName + '_arr_changed\"]';\n confParam.querySelector(changeinput).value = true;\n });\n });\n methods.forEach(method => {\n id = reminder + \"_\" + method + \"date\";\n confParam.querySelectorAll('[name*=\"' + id + '\"]').forEach(opt => {\n opt.addEventListener('change', (e) => {\n split = e.target.getAttribute('name').split('[');\n changeName = (split.hasOwnProperty(1)) ? split[0] : split;\n changeinput = 'input[name=\"' + changeName + '_changed\"]';\n confParam.querySelector(changeinput).value = true;\n });\n });\n });\n });\n };\n\n /**\n * Reinitialize the availability javascript.\n * @param {string} selector\n */\n Preset.prototype.reinitAvailability = function(selector = '.availability-field') {\n if (typeof M.core_availability.form !== \"undefined\" &&\n document.getElementById('id_availabilityconditionsjson') !== null) {\n this.resetRestrictPlugins();\n document.querySelectorAll(selector).forEach((field) => field.parentNode.removeChild(field));\n M.core_availability.form.init();\n }\n };\n\n Preset.prototype.resetRestrictPlugins = function() {\n if (typeof M.core_availability.form !== \"undefined\" &&\n document.getElementById('id_availabilityconditionsjson') !== null) {\n M.core_availability.form.restrictByGroup = null;\n var availabilityPlugins = (typeof M.core_availability.form.plugins !== 'undefined')\n ? M.core_availability.form.plugins : {};\n var plugin = '';\n for (var i in availabilityPlugins) {\n plugin = \"availability_\" + i;\n if (M.hasOwnProperty(plugin)) {\n M[plugin].form.addedEvents = false;\n }\n }\n }\n };\n\n /**\n * Apply and customize triggered using fragment. Response will replaced with current mod form.\n * @param {string} params\n * @param {int} contextID\n * @param {object} modal\n */\n Preset.prototype.applyCustomize = function(params, contextID, modal) {\n Fragment.loadFragment('mod_pulse', 'apply_preset', contextID, params).done((html, js) => {\n modal.destroy();\n // Reset the availability to work for upcoming response html.\n this.resetRestrictPlugins();\n this.handleFormSubmissionResponse(html, js);\n });\n };\n\n /**\n * Disable the modal save and customize buttons to prevent reinit.\n */\n Preset.prototype.disableButtons = function() {\n var buttons = document.querySelectorAll(this.actionbuttons);\n for (let $i in buttons) {\n buttons[$i].disabled = true;\n }\n };\n\n /**\n * Handle the loaded fragment output of customize method pulse mod.\n * @param {html} data\n * @param {string} js\n */\n Preset.prototype.handleFormSubmissionResponse = (data, js) => {\n var newform = document.createElement('div');\n newform.innerHTML = data;\n Templates.replaceNode('[action=\"modedit.php\"]', data, js);\n\n };\n\n /**\n * Initiate the apply and save method to create the pulse module with custom daa.\n * @param {FormData} formdata\n * @param {int} contextid\n */\n Preset.prototype.restorePreset = (formdata, contextid) => {\n var formdatastr = new URLSearchParams(formdata).toString();\n var promises = AJAX.call([{\n methodname: 'mod_pulse_apply_presets',\n args: {contextid: contextid, formdata: formdatastr}\n }]);\n\n promises[0].done((response) => {\n response = JSON.parse(response);\n if (typeof response.url != 'undefined') {\n window.location.href = response.url;\n }\n });\n };\n\n /**\n * Load list of available presets.\n */\n Preset.prototype.loadPresetsList = function() {\n var listParent = document.getElementById(this.listElement.selector);\n\n if (listParent !== null) {\n if (listParent.getAttribute(this.listElement.loaded) == 'false') {\n Fragment.loadFragment('mod_pulse', 'get_presetslist', this.contextId, {'courseid': this.courseid})\n .done((html, js) => {\n Templates.replaceNodeContents(listParent, html, js);\n listParent.setAttribute(this.listElement.loaded, 'true');\n this.setupmodal();\n });\n }\n }\n };\n\n return {\n init: (contextId, courseid, section) => {\n new Preset(contextId, courseid, section);\n }\n };\n });\n"],"names":["define","$","Modal","ModalPreset","PresetEvents","Str","Fragment","AJAX","Templates","Loadingicon","Notification","ModalEvents","PresetModal","SELECTOR","Preset","contextId","courseid","section","loadPresetsList","prototype","listElement","pageparams","loadIconElement","actionbuttons","setupmodal","THIS","this","triggerelement","document","querySelectorAll","attachmentPoint","createElement","classList","add","forEach","element","addEventListener","presetid","getAttribute","presettitle","params","body","prepend","registerModalType","create","type","TYPE","title","get_string","loadFragment","large","then","modal","show","getRoot","on","bodyRendered","reinitAvailability","fieldChangedEvent","hidden","get","target","tinyMCE","EditorManager","id","remove","destroy","bind","customize","modform","querySelector","modformdata","FormData","form","formdata","URLSearchParams","toString","addIconToContainer","disableButtons","applyCustomize","save","e","preventDefault","restorePreset","catch","exception","fieldName","changeinput","changeName","split","confParam","getElementById","methods","field","event","value","reminder","schedule","method","opt","hasOwnProperty","selector","M","core_availability","resetRestrictPlugins","parentNode","removeChild","init","restrictByGroup","availabilityPlugins","plugins","plugin","i","addedEvents","contextID","done","html","js","handleFormSubmissionResponse","buttons","$i","disabled","data","innerHTML","replaceNode","contextid","formdatastr","call","methodname","args","response","JSON","parse","url","window","location","href","listParent","loaded","replaceNodeContents","setAttribute"],"mappings":"AAAAA,0BAAO,CAAC,SAAU,qBAAsB,yBAA0B,mBAAoB,WAAY,gBAAiB,YAC/G,iBAAkB,mBAAoB,oBAAqB,oBAAqB,0BAChF,SAASC,EAAGC,MAAOC,YAAaC,aAAcC,IAAKC,SAAUC,KAAMC,UAAWC,YAC1EC,aAAcC,YAAaC,iBAEvBC,4BACoB,4CASpBC,OAAS,SAASC,UAAWC,SAAUC,cAClCF,UAAYA,eACZC,SAAWA,cACXC,QAAUA,aACVC,0BAGTJ,OAAOK,UAAUC,YAAc,UAAa,4BAAgC,mBAE5EN,OAAOK,UAAUJ,UAAY,EAE7BD,OAAOK,UAAUH,SAAW,EAE5BF,OAAOK,UAAUF,QAAU,EAE3BH,OAAOK,UAAUE,WAAa,GAE9BP,OAAOK,UAAUG,gBAAkB,6BAEnCR,OAAOK,UAAUI,cAAgB,uBAKjCT,OAAOK,UAAUK,WAAa,eAEtBC,KAAOC,KAEPC,eAAiBC,SAASC,iBAAiB,oBAE3CC,gBAAk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,SAAUoD,gBAGlC,GAAGX,MAAMe,gBAEa,KAD3BA,SAAWC,KAAKC,MAAMF,WACFG,MAChBC,OAAOC,SAASC,KAAON,SAASG,SAQ5CvH,OAAOK,UAAUD,gBAAkB,eAC3BuH,WAAa7G,SAAS+D,eAAejE,KAAKN,YAAYiF,UAEvC,OAAfoC,YACwD,SAApDA,WAAWnG,aAAaZ,KAAKN,YAAYsH,SACzCpI,SAAS2C,aAAa,YAAa,kBAAmBvB,KAAKX,UAAW,UAAaW,KAAKV,WACnFmG,MAAK,CAACC,KAAMC,MACT7G,UAAUmI,oBAAoBF,WAAYrB,KAAMC,IAChDoB,WAAWG,aAAalH,KAAKN,YAAYsH,OAAQ,aAC5ClH,iBAMlB,CACHmF,KAAM,CAAC5F,UAAWC,SAAUC,eACpBH,OAAOC,UAAWC,SAAUC"} \ No newline at end of file +{"version":3,"file":"preset.min.js","sources":["../src/preset.js"],"sourcesContent":["define(['jquery', 'core/modal_factory', 'mod_pulse/modal_preset', 'mod_pulse/events', 'core/str', 'core/fragment', 'core/ajax',\n 'core/templates', 'core/loadingicon', 'core/notification', 'core/modal_events', 'mod_pulse/presetmodal'],\n function($, Modal, ModalPreset, PresetEvents, Str, Fragment, AJAX, Templates, Loadingicon,\n Notification, ModalEvents, PresetModal) {\n\n var SELECTOR = {\n presetAvailability: '.preset-config-params .availability-field'\n };\n\n /**\n * Preset module declaration. Setup the global values.\n * @param {int} contextId\n * @param {int} courseid\n * @param {int} section\n */\n var Preset = function(contextId, courseid, section) {\n this.contextId = contextId;\n this.courseid = courseid;\n this.section = section;\n this.loadPresetsList();\n };\n\n Preset.prototype.listElement = {'selector': 'pulse-presets-data', \"loaded\": \"data-listloaded\"};\n\n Preset.prototype.contextId = 0;\n\n Preset.prototype.courseid = 0;\n\n Preset.prototype.section = 0;\n\n Preset.prototype.pageparams = [];\n\n Preset.prototype.loadIconElement = '.modal-footer #loader-icon';\n\n Preset.prototype.actionbuttons = '.modal-footer button';\n\n /**\n * Setup the presets modal event listeners.\n */\n Preset.prototype.setupmodal = function() {\n\n var THIS = this;\n\n var triggerelement = document.querySelectorAll('.pulse-usepreset');\n // Modal attachment point.\n var attachmentPoint = document.createElement('div');\n attachmentPoint.classList.add('modal-preset');\n triggerelement.forEach((element) => element.addEventListener('click', () => {\n var presetid = element.getAttribute('data-presetid');\n var presettitle = element.getAttribute('data-presettitle');\n var params = {'presetid': presetid, 'courseid': THIS.courseid, 'section': THIS.section};\n\n document.body.prepend(attachmentPoint);\n\n var modalFn;\n if (typeof PresetModal.registerModalType == 'undefined') {\n modalFn = Modal.create({\n type: ModalPreset.TYPE,\n title: Str.get_string('presetmodaltitle', 'pulse', {'title': presettitle}),\n body: Fragment.loadFragment('mod_pulse', 'get_preset_preview', THIS.contextId, params),\n large: true,\n });\n } else {\n modalFn = PresetModal.create({\n title: Str.get_string('presetmodaltitle', 'pulse', {'title': presettitle}),\n body: Fragment.loadFragment('mod_pulse', 'get_preset_preview', THIS.contextId, params),\n large: true,\n });\n }\n\n modalFn.then(modal => {\n // Make the modal attachment point to overcome the restriction access condition.\n modal.attachmentPoint = attachmentPoint;\n modal.show();\n modal.getRoot().on(ModalEvents.bodyRendered, function() {\n THIS.reinitAvailability(SELECTOR.presetAvailability);\n THIS.fieldChangedEvent();\n });\n // Destroy the modal on hidden to reload the editors.\n modal.getRoot().on(ModalEvents.hidden, function() {\n modal.getRoot().get(0).querySelectorAll('form textarea').forEach(target => {\n if (typeof tinyMCE !== 'undefined') {\n tinyMCE.EditorManager.get(target.id).remove(); // eslint-disable-line\n }\n });\n modal.destroy.bind(modal);\n // THIS.reinitAvailability();\n });\n\n // Apply and customize method.\n modal.getRoot().on(PresetEvents.customize, () => {\n var modform = document.querySelector('#mod-pulse-form');\n var modformdata = new FormData(modform);\n modal.getRoot().get(0).querySelectorAll('form').forEach(form => {\n var formdata = new FormData(form);\n formdata = new URLSearchParams(formdata).toString();\n var pageparams = new URLSearchParams(modformdata).toString();\n params = {formdata: formdata, pageparams: pageparams};\n\n Loadingicon.addIconToContainer(this.loadIconElement);\n THIS.disableButtons();\n THIS.applyCustomize(params, THIS.contextId, modal);\n });\n });\n // Apply and save method.\n modal.getRoot().on(PresetEvents.save, (e) => {\n e.preventDefault();\n Loadingicon.addIconToContainer(this.loadIconElement);\n THIS.disableButtons();\n var formdata = {};\n modal.getRoot().get(0).querySelectorAll('form').forEach(form => {\n formdata = new FormData(form);\n this.restorePreset(formdata, THIS.contextId);\n });\n });\n return true;\n }).catch(Notification.exception);\n }));\n };\n\n\n Preset.prototype.fieldChangedEvent = () => {\n var confParam = document.getElementById(\"preset-configurable-params\");\n var reminders = ['first', 'second', 'recurring'];\n var methods = ['fixed', 'relative'];\n var fieldName, changeinput, id, changeName, split;\n confParam.querySelectorAll('input, select, textarea').forEach(field => {\n field.addEventListener('change', (event) => {\n fieldName = event.target.getAttribute('name');\n if (confParam.querySelector('input[name=\"' + fieldName + '_changed\"]') !== null) {\n confParam.querySelector('input[name=\"' + fieldName + '_changed\"]').value = true;\n }\n });\n });\n\n reminders.forEach(reminder => {\n confParam.querySelectorAll('[name=\"' + reminder + '_schedule\"').forEach(schedule => {\n schedule.addEventListener('change', (e) => {\n changeName = e.target.getAttribute('name');\n changeinput = 'input[name=\"' + changeName + '_arr_changed\"]';\n confParam.querySelector(changeinput).value = true;\n });\n });\n methods.forEach(method => {\n id = reminder + \"_\" + method + \"date\";\n confParam.querySelectorAll('[name*=\"' + id + '\"]').forEach(opt => {\n opt.addEventListener('change', (e) => {\n split = e.target.getAttribute('name').split('[');\n changeName = (split.hasOwnProperty(1)) ? split[0] : split;\n changeinput = 'input[name=\"' + changeName + '_changed\"]';\n confParam.querySelector(changeinput).value = true;\n });\n });\n });\n });\n };\n\n /**\n * Reinitialize the availability javascript.\n * @param {string} selector\n */\n Preset.prototype.reinitAvailability = function(selector = '.availability-field') {\n if (typeof M.core_availability.form !== \"undefined\" &&\n document.getElementById('id_availabilityconditionsjson') !== null) {\n this.resetRestrictPlugins();\n document.querySelectorAll(selector).forEach((field) => field.parentNode.removeChild(field));\n M.core_availability.form.init();\n }\n };\n\n Preset.prototype.resetRestrictPlugins = function() {\n if (typeof M.core_availability.form !== \"undefined\" &&\n document.getElementById('id_availabilityconditionsjson') !== null) {\n M.core_availability.form.restrictByGroup = null;\n var availabilityPlugins = (typeof M.core_availability.form.plugins !== 'undefined')\n ? M.core_availability.form.plugins : {};\n var plugin = '';\n for (var i in availabilityPlugins) {\n plugin = \"availability_\" + i;\n if (M.hasOwnProperty(plugin)) {\n M[plugin].form.addedEvents = false;\n }\n }\n }\n };\n\n /**\n * Apply and customize triggered using fragment. Response will replaced with current mod form.\n * @param {string} params\n * @param {int} contextID\n * @param {object} modal\n */\n Preset.prototype.applyCustomize = function(params, contextID, modal) {\n Fragment.loadFragment('mod_pulse', 'apply_preset', contextID, params).done((html, js) => {\n modal.destroy();\n // Reset the availability to work for upcoming response html.\n this.resetRestrictPlugins();\n this.handleFormSubmissionResponse(html, js);\n });\n };\n\n /**\n * Disable the modal save and customize buttons to prevent reinit.\n */\n Preset.prototype.disableButtons = function() {\n var buttons = document.querySelectorAll(this.actionbuttons);\n for (let $i in buttons) {\n buttons[$i].disabled = true;\n }\n };\n\n /**\n * Handle the loaded fragment output of customize method pulse mod.\n * @param {html} data\n * @param {string} js\n */\n Preset.prototype.handleFormSubmissionResponse = (data, js) => {\n var newform = document.createElement('div');\n newform.innerHTML = data;\n Templates.replaceNode('[action=\"modedit.php\"]', data, js);\n\n };\n\n /**\n * Initiate the apply and save method to create the pulse module with custom daa.\n * @param {FormData} formdata\n * @param {int} contextid\n */\n Preset.prototype.restorePreset = (formdata, contextid) => {\n var formdatastr = new URLSearchParams(formdata).toString();\n var promises = AJAX.call([{\n methodname: 'mod_pulse_apply_presets',\n args: {contextid: contextid, formdata: formdatastr}\n }]);\n\n promises[0].done((response) => {\n response = JSON.parse(response);\n if (typeof response.url != 'undefined') {\n window.location.href = response.url;\n }\n });\n };\n\n /**\n * Load list of available presets.\n */\n Preset.prototype.loadPresetsList = function() {\n var listParent = document.getElementById(this.listElement.selector);\n\n if (listParent !== null) {\n if (listParent.getAttribute(this.listElement.loaded) == 'false') {\n Fragment.loadFragment('mod_pulse', 'get_presetslist', this.contextId, {'courseid': this.courseid})\n .done((html, js) => {\n Templates.replaceNodeContents(listParent, html, js);\n listParent.setAttribute(this.listElement.loaded, 'true');\n this.setupmodal();\n });\n }\n }\n };\n\n return {\n init: (contextId, courseid, section) => {\n new Preset(contextId, courseid, section);\n }\n };\n });\n"],"names":["define","$","Modal","ModalPreset","PresetEvents","Str","Fragment","AJAX","Templates","Loadingicon","Notification","ModalEvents","PresetModal","SELECTOR","Preset","contextId","courseid","section","loadPresetsList","prototype","listElement","pageparams","loadIconElement","actionbuttons","setupmodal","THIS","this","triggerelement","document","querySelectorAll","attachmentPoint","createElement","classList","add","forEach","element","addEventListener","presetid","getAttribute","presettitle","params","body","prepend","registerModalType","create","type","TYPE","title","get_string","loadFragment","large","then","modal","show","getRoot","on","bodyRendered","reinitAvailability","fieldChangedEvent","hidden","get","target","tinyMCE","EditorManager","id","remove","destroy","bind","customize","modform","querySelector","modformdata","FormData","form","formdata","URLSearchParams","toString","addIconToContainer","disableButtons","applyCustomize","save","e","preventDefault","restorePreset","catch","exception","fieldName","changeinput","changeName","split","confParam","getElementById","methods","field","event","value","reminder","schedule","method","opt","hasOwnProperty","selector","M","core_availability","resetRestrictPlugins","parentNode","removeChild","init","restrictByGroup","availabilityPlugins","plugins","plugin","i","addedEvents","contextID","done","html","js","handleFormSubmissionResponse","buttons","$i","disabled","data","innerHTML","replaceNode","contextid","formdatastr","call","methodname","args","response","JSON","parse","url","window","location","href","listParent","loaded","replaceNodeContents","setAttribute"],"mappings":"AAAAA,0BAAO,CAAC,SAAU,qBAAsB,yBAA0B,mBAAoB,WAAY,gBAAiB,YAC/G,iBAAkB,mBAAoB,oBAAqB,oBAAqB,0BAChF,SAASC,EAAGC,MAAOC,YAAaC,aAAcC,IAAKC,SAAU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AC9EjE,MAAMc,eAEDsC,4BACAc,6BAA6BF,KAAMC,QAOhDvG,OAAOK,UAAU2D,eAAiB,eAC1ByC,QAAU3F,SAASC,iBAAiBH,KAAKH,mBACxC,IAAIiG,MAAMD,QACXA,QAAQC,IAAIC,UAAW,GAS/B3G,OAAOK,UAAUmG,6BAA+B,CAACI,KAAML,MACrCzF,SAASG,cAAc,OAC7B4F,UAAYD,KACpBlH,UAAUoH,YAAY,yBAA0BF,KAAML,KAS1DvG,OAAOK,UAAUgE,cAAgB,CAACT,SAAUmD,iBACpCC,YAAc,IAAInD,gBAAgBD,UAAUE,WACjCrE,KAAKwH,KAAK,CAAC,CACtBC,WAAY,0BACZC,KAAM,CAACJ,UAAWA,UAAWnD,SAAUoD,gBAGlC,GAAGX,MAAMe,gBAEa,KAD3BA,SAAWC,KAAKC,MAAMF,WACFG,MAChBC,OAAOC,SAASC,KAAON,SAASG,SAQ5CvH,OAAOK,UAAUD,gBAAkB,eAC3BuH,WAAa7G,SAAS+D,eAAejE,KAAKN,YAAYiF,UAEvC,OAAfoC,YACwD,SAApDA,WAAWnG,aAAaZ,KAAKN,YAAYsH,SACzCpI,SAAS2C,aAAa,YAAa,kBAAmBvB,KAAKX,UAAW,UAAaW,KAAKV,WACnFmG,MAAK,CAACC,KAAMC,MACT7G,UAAUmI,oBAAoBF,WAAYrB,KAAMC,IAChDoB,WAAWG,aAAalH,KAAKN,YAAYsH,OAAQ,aAC5ClH,iBAMlB,CACHmF,KAAM,CAAC5F,UAAWC,SAAUC,eACpBH,OAAOC,UAAWC,SAAUC"} \ No newline at end of file diff --git a/amd/build/presetmodal.min.js b/amd/build/presetmodal.min.js index d41dd4c..bc51315 100644 --- a/amd/build/presetmodal.min.js +++ b/amd/build/presetmodal.min.js @@ -1,3 +1,3 @@ -define("mod_pulse/presetmodal",["exports","core/modal","core/custom_interaction_events","mod_pulse/events","jquery"],(function(_exports,_modal,CustomEvents,PresetEvents,_jquery){function _getRequireWildcardCache(nodeInterop){if("function"!=typeof WeakMap)return null;var cacheBabelInterop=new WeakMap,cacheNodeInterop=new WeakMap;return(_getRequireWildcardCache=function(nodeInterop){return nodeInterop?cacheNodeInterop:cacheBabelInterop})(nodeInterop)}function _interopRequireWildcard(obj,nodeInterop){if(!nodeInterop&&obj&&obj.__esModule)return obj;if(null===obj||"object"!=typeof obj&&"function"!=typeof obj)return{default:obj};var cache=_getRequireWildcardCache(nodeInterop);if(cache&&cache.has(obj))return cache.get(obj);var newObj={},hasPropertyDescriptor=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var key in obj)if("default"!==key&&Object.prototype.hasOwnProperty.call(obj,key)){var desc=hasPropertyDescriptor?Object.getOwnPropertyDescriptor(obj,key):null;desc&&(desc.get||desc.set)?Object.defineProperty(newObj,key,desc):newObj[key]=obj[key]}return newObj.default=obj,cache&&cache.set(obj,newObj),newObj}function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}function _defineProperty(obj,key,value){return key in obj?Object.defineProperty(obj,key,{value:value,enumerable:!0,configurable:!0,writable:!0}):obj[key]=value,obj}Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.default=void 0,_modal=_interopRequireDefault(_modal),CustomEvents=_interopRequireWildcard(CustomEvents),PresetEvents=_interopRequireWildcard(PresetEvents),_jquery=_interopRequireDefault(_jquery);const SELECTORS_SAVE_BUTTON='[data-action="save"]',SELECTORS_CUSTOMIZE_BUTTON='[data-action="customize"]',SELECTORS_CANCEL_BUTTON='[data-action="cancel"]';class PresetModal extends _modal.default{registerEventListeners(){super.registerEventListeners(this),this.getModal().on(CustomEvents.events.activate,SELECTORS_SAVE_BUTTON,function(event,data){document.querySelectorAll(".preset-config-params form.mform").forEach((form=>{form.importmethod.value="save",form.addEventListener("submit",(function(e){e.preventDefault()}))})),0!=document.querySelectorAll('.preset-config-params [data-fieldtype="submit"] input').length&&document.querySelectorAll('.preset-config-params [data-fieldtype="submit"] input')[0].click();var approveEvent=_jquery.default.Event(PresetEvents.save);this.getRoot().trigger(approveEvent,this),approveEvent.isDefaultPrevented()||(this.destroy(),data.originalEvent.preventDefault()),event.preventDefault()}.bind(this)),this.getModal().on(CustomEvents.events.activate,SELECTORS_CUSTOMIZE_BUTTON,function(event,data){document.querySelectorAll(".preset-config-params form.mform").forEach((form=>{form.importmethod.value="customize"}));var customizeEvent=_jquery.default.Event(PresetEvents.customize);this.getRoot().trigger(customizeEvent,this),customizeEvent.isDefaultPrevented()||data.originalEvent.preventDefault(),event.preventDefault()}.bind(this)),this.getModal().on(CustomEvents.events.activate,SELECTORS_CANCEL_BUTTON,function(){this.destroy()}.bind(this))}}return _exports.default=PresetModal,_defineProperty(PresetModal,"TYPE","PulsePresetModal"),_defineProperty(PresetModal,"TEMPLATE","mod_pulse/modal_preset"),"undefined"!==PresetModal.registerModalType&&PresetModal.registerModalType(),_exports.default})); +define("mod_pulse/presetmodal",["exports","core/modal","core/custom_interaction_events","mod_pulse/events","jquery"],(function(_exports,_modal,CustomEvents,PresetEvents,_jquery){function _getRequireWildcardCache(nodeInterop){if("function"!=typeof WeakMap)return null;var cacheBabelInterop=new WeakMap,cacheNodeInterop=new WeakMap;return(_getRequireWildcardCache=function(nodeInterop){return nodeInterop?cacheNodeInterop:cacheBabelInterop})(nodeInterop)}function _interopRequireWildcard(obj,nodeInterop){if(!nodeInterop&&obj&&obj.__esModule)return obj;if(null===obj||"object"!=typeof obj&&"function"!=typeof obj)return{default:obj};var cache=_getRequireWildcardCache(nodeInterop);if(cache&&cache.has(obj))return cache.get(obj);var newObj={},hasPropertyDescriptor=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var key in obj)if("default"!==key&&Object.prototype.hasOwnProperty.call(obj,key)){var desc=hasPropertyDescriptor?Object.getOwnPropertyDescriptor(obj,key):null;desc&&(desc.get||desc.set)?Object.defineProperty(newObj,key,desc):newObj[key]=obj[key]}return newObj.default=obj,cache&&cache.set(obj,newObj),newObj}function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}function _defineProperty(obj,key,value){return key in obj?Object.defineProperty(obj,key,{value:value,enumerable:!0,configurable:!0,writable:!0}):obj[key]=value,obj}Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.default=void 0,_modal=_interopRequireDefault(_modal),CustomEvents=_interopRequireWildcard(CustomEvents),PresetEvents=_interopRequireWildcard(PresetEvents),_jquery=_interopRequireDefault(_jquery);const SELECTORS_SAVE_BUTTON='[data-action="save"]',SELECTORS_CUSTOMIZE_BUTTON='[data-action="customize"]',SELECTORS_CANCEL_BUTTON='[data-action="cancel"]';class PresetModal extends _modal.default{registerEventListeners(){super.registerEventListeners(this),this.getModal().on(CustomEvents.events.activate,SELECTORS_SAVE_BUTTON,function(event,data){document.querySelectorAll(".preset-config-params form.mform").forEach((form=>{form.importmethod.value="save",form.addEventListener("submit",(function(e){e.preventDefault()}))})),0!=document.querySelectorAll('.preset-config-params [data-fieldtype="submit"] input').length&&document.querySelectorAll('.preset-config-params [data-fieldtype="submit"] input')[0].click();var approveEvent=_jquery.default.Event(PresetEvents.save);this.getRoot().trigger(approveEvent,this),approveEvent.isDefaultPrevented()||(this.destroy(),data.originalEvent.preventDefault()),event.preventDefault()}.bind(this)),this.getModal().on(CustomEvents.events.activate,SELECTORS_CUSTOMIZE_BUTTON,function(event,data){document.querySelectorAll(".preset-config-params form.mform").forEach((form=>{form.importmethod.value="customize"}));var customizeEvent=_jquery.default.Event(PresetEvents.customize);this.getRoot().trigger(customizeEvent,this),customizeEvent.isDefaultPrevented()||data.originalEvent.preventDefault(),event.preventDefault()}.bind(this)),this.getModal().on(CustomEvents.events.activate,SELECTORS_CANCEL_BUTTON,function(){this.destroy()}.bind(this))}}return _exports.default=PresetModal,_defineProperty(PresetModal,"TYPE","PulsePresetModal"),_defineProperty(PresetModal,"TEMPLATE","mod_pulse/modal_preset"),void 0!==PresetModal.registerModalType&&PresetModal.registerModalType(),_exports.default})); //# sourceMappingURL=presetmodal.min.js.map \ No newline at end of file diff --git a/amd/build/presetmodal.min.js.map b/amd/build/presetmodal.min.js.map index 19ac211..cde6f23 100644 --- a/amd/build/presetmodal.min.js.map +++ b/amd/build/presetmodal.min.js.map @@ -1 +1 @@ -{"version":3,"file":"presetmodal.min.js","sources":["../src/presetmodal.js"],"sourcesContent":["import Modal from 'core/modal';\r\nimport * as CustomEvents from 'core/custom_interaction_events';\r\nimport * as PresetEvents from 'mod_pulse/events';\r\nimport $ from 'jquery';\r\n\r\nconst SELECTORS = {\r\n SAVE_BUTTON: '[data-action=\"save\"]',\r\n CUSTOMIZE_BUTTON: '[data-action=\"customize\"]',\r\n CANCEL_BUTTON: '[data-action=\"cancel\"]',\r\n};\r\n\r\nexport default class PresetModal extends Modal {\r\n\r\n static TYPE = 'PulsePresetModal';\r\n static TEMPLATE = 'mod_pulse/modal_preset';\r\n\r\n registerEventListeners() {\r\n // Apply parent event listeners.\r\n super.registerEventListeners(this);\r\n\r\n this.getModal().on(CustomEvents.events.activate, SELECTORS.SAVE_BUTTON, function(event, data) {\r\n // Load the backupfile.\r\n document.querySelectorAll('.preset-config-params form.mform').forEach(form => {\r\n form.importmethod.value = 'save';\r\n form.addEventListener('submit', function(e) {\r\n e.preventDefault();\r\n });\r\n });\r\n\r\n if (document.querySelectorAll('.preset-config-params [data-fieldtype=\"submit\"] input').length != 0) {\r\n document.querySelectorAll('.preset-config-params [data-fieldtype=\"submit\"] input')[0].click();\r\n }\r\n\r\n var approveEvent = $.Event(PresetEvents.save);\r\n this.getRoot().trigger(approveEvent, this);\r\n\r\n if (!approveEvent.isDefaultPrevented()) {\r\n this.destroy();\r\n data.originalEvent.preventDefault();\r\n }\r\n event.preventDefault();\r\n }.bind(this));\r\n\r\n\r\n this.getModal().on(CustomEvents.events.activate, SELECTORS.CUSTOMIZE_BUTTON, function(event, data) {\r\n // Add your logic for when the login button is clicked. This could include the form validation,\r\n document.querySelectorAll('.preset-config-params form.mform').forEach(form => {\r\n form.importmethod.value = 'customize';\r\n });\r\n\r\n var customizeEvent = $.Event(PresetEvents.customize);\r\n this.getRoot().trigger(customizeEvent, this);\r\n\r\n if (!customizeEvent.isDefaultPrevented()) {\r\n data.originalEvent.preventDefault();\r\n }\r\n event.preventDefault();\r\n\r\n }.bind(this));\r\n\r\n this.getModal().on(CustomEvents.events.activate, SELECTORS.CANCEL_BUTTON, function() {\r\n this.destroy();\r\n }.bind(this));\r\n }\r\n}\r\n\r\nif (PresetModal.registerModalType !== 'undefined') {\r\n PresetModal.registerModalType();\r\n}\r\n"],"names":["SELECTORS","PresetModal","Modal","registerEventListeners","this","getModal","on","CustomEvents","events","activate","event","data","document","querySelectorAll","forEach","form","importmethod","value","addEventListener","e","preventDefault","length","click","approveEvent","$","Event","PresetEvents","save","getRoot","trigger","isDefaultPrevented","destroy","originalEvent","bind","customizeEvent","customize","registerModalType"],"mappings":"ymDAKMA,sBACW,uBADXA,2BAEgB,4BAFhBA,wBAGa,+BAGEC,oBAAoBC,eAKrCC,+BAEUA,uBAAuBC,WAExBC,WAAWC,GAAGC,aAAaC,OAAOC,SAAUT,sBAAuB,SAASU,MAAOC,MAEpFC,SAASC,iBAAiB,oCAAoCC,SAAQC,OAClEA,KAAKC,aAAaC,MAAQ,OAC1BF,KAAKG,iBAAiB,UAAU,SAASC,GACrCA,EAAEC,uBAIuF,GAA7FR,SAASC,iBAAiB,yDAAyDQ,QACnFT,SAASC,iBAAiB,yDAAyD,GAAGS,YAGtFC,aAAeC,gBAAEC,MAAMC,aAAaC,WACnCC,UAAUC,QAAQN,aAAcnB,MAEhCmB,aAAaO,4BACTC,UACLpB,KAAKqB,cAAcZ,kBAEvBV,MAAMU,kBACRa,KAAK7B,YAGFC,WAAWC,GAAGC,aAAaC,OAAOC,SAAUT,2BAA4B,SAASU,MAAOC,MAEzFC,SAASC,iBAAiB,oCAAoCC,SAAQC,OAClEA,KAAKC,aAAaC,MAAQ,mBAG1BiB,eAAiBV,gBAAEC,MAAMC,aAAaS,gBACrCP,UAAUC,QAAQK,eAAgB9B,MAElC8B,eAAeJ,sBAChBnB,KAAKqB,cAAcZ,iBAEvBV,MAAMU,kBAERa,KAAK7B,YAEFC,WAAWC,GAAGC,aAAaC,OAAOC,SAAUT,wBAAyB,gBACjE+B,WACPE,KAAK7B,4DAnDMH,mBAEH,oCAFGA,uBAGC,0BAoDgB,cAAlCA,YAAYmC,mBACZnC,YAAYmC"} \ No newline at end of file +{"version":3,"file":"presetmodal.min.js","sources":["../src/presetmodal.js"],"sourcesContent":["import Modal from 'core/modal';\nimport * as CustomEvents from 'core/custom_interaction_events';\nimport * as PresetEvents from 'mod_pulse/events';\nimport $ from 'jquery';\n\nconst SELECTORS = {\n SAVE_BUTTON: '[data-action=\"save\"]',\n CUSTOMIZE_BUTTON: '[data-action=\"customize\"]',\n CANCEL_BUTTON: '[data-action=\"cancel\"]',\n};\n\nexport default class PresetModal extends Modal {\n\n static TYPE = 'PulsePresetModal';\n static TEMPLATE = 'mod_pulse/modal_preset';\n\n registerEventListeners() {\n // Apply parent event listeners.\n super.registerEventListeners(this);\n\n this.getModal().on(CustomEvents.events.activate, SELECTORS.SAVE_BUTTON, function(event, data) {\n // Load the backupfile.\n document.querySelectorAll('.preset-config-params form.mform').forEach(form => {\n form.importmethod.value = 'save';\n form.addEventListener('submit', function(e) {\n e.preventDefault();\n });\n });\n\n if (document.querySelectorAll('.preset-config-params [data-fieldtype=\"submit\"] input').length != 0) {\n document.querySelectorAll('.preset-config-params [data-fieldtype=\"submit\"] input')[0].click();\n }\n\n var approveEvent = $.Event(PresetEvents.save);\n this.getRoot().trigger(approveEvent, this);\n\n if (!approveEvent.isDefaultPrevented()) {\n this.destroy();\n data.originalEvent.preventDefault();\n }\n event.preventDefault();\n }.bind(this));\n\n\n this.getModal().on(CustomEvents.events.activate, SELECTORS.CUSTOMIZE_BUTTON, function(event, data) {\n // Add your logic for when the login button is clicked. This could include the form validation,\n document.querySelectorAll('.preset-config-params form.mform').forEach(form => {\n form.importmethod.value = 'customize';\n });\n\n var customizeEvent = $.Event(PresetEvents.customize);\n this.getRoot().trigger(customizeEvent, this);\n\n if (!customizeEvent.isDefaultPrevented()) {\n data.originalEvent.preventDefault();\n }\n event.preventDefault();\n\n }.bind(this));\n\n this.getModal().on(CustomEvents.events.activate, SELECTORS.CANCEL_BUTTON, function() {\n this.destroy();\n }.bind(this));\n }\n}\n\nif (typeof PresetModal.registerModalType !== 'undefined') {\n PresetModal.registerModalType();\n}\n"],"names":["SELECTORS","PresetModal","Modal","registerEventListeners","this","getModal","on","CustomEvents","events","activate","event","data","document","querySelectorAll","forEach","form","importmethod","value","addEventListener","e","preventDefault","length","click","approveEvent","$","Event","PresetEvents","save","getRoot","trigger","isDefaultPrevented","destroy","originalEvent","bind","customizeEvent","customize","registerModalType"],"mappings":"ymDAKMA,sBACW,uBADXA,2BAEgB,4BAFhBA,wBAGa,+BAGEC,oBAAoBC,eAKrCC,+BAEUA,uBAAuBC,WAExBC,WAAWC,GAAGC,aAAaC,OAAOC,SAAUT,sBAAuB,SAASU,MAAOC,MAEpFC,SAASC,iBAAiB,oCAAoCC,SAAQC,OAClEA,KAAKC,aAAaC,MAAQ,OAC1BF,KAAKG,iBAAiB,UAAU,SAASC,GACrCA,EAAEC,uBAIuF,GAA7FR,SAASC,iBAAiB,yDAAyDQ,QACnFT,SAASC,iBAAiB,yDAAyD,GAAGS,YAGtFC,aAAeC,gBAAEC,MAAMC,aAAaC,WACnCC,UAAUC,QAAQN,aAAcnB,MAEhCmB,aAAaO,4BACTC,UACLpB,KAAKqB,cAAcZ,kBAEvBV,MAAMU,kBACRa,KAAK7B,YAGFC,WAAWC,GAAGC,aAAaC,OAAOC,SAAUT,2BAA4B,SAASU,MAAOC,MAEzFC,SAASC,iBAAiB,oCAAoCC,SAAQC,OAClEA,KAAKC,aAAaC,MAAQ,mBAG1BiB,eAAiBV,gBAAEC,MAAMC,aAAaS,gBACrCP,UAAUC,QAAQK,eAAgB9B,MAElC8B,eAAeJ,sBAChBnB,KAAKqB,cAAcZ,iBAEvBV,MAAMU,kBAERa,KAAK7B,YAEFC,WAAWC,GAAGC,aAAaC,OAAOC,SAAUT,wBAAyB,gBACjE+B,WACPE,KAAK7B,4DAnDMH,mBAEH,oCAFGA,uBAGC,+BAoDuB,IAAlCA,YAAYmC,mBACnBnC,YAAYmC"} \ No newline at end of file diff --git a/amd/src/preset.js b/amd/src/preset.js index 8ab37c5..6f85cae 100644 --- a/amd/src/preset.js +++ b/amd/src/preset.js @@ -79,7 +79,7 @@ define(['jquery', 'core/modal_factory', 'mod_pulse/modal_preset', 'mod_pulse/eve // Destroy the modal on hidden to reload the editors. modal.getRoot().on(ModalEvents.hidden, function() { modal.getRoot().get(0).querySelectorAll('form textarea').forEach(target => { - if (tinyMCE != 'undefined') { // eslint-disable-line + if (typeof tinyMCE !== 'undefined') { tinyMCE.EditorManager.get(target.id).remove(); // eslint-disable-line } }); diff --git a/amd/src/presetmodal.js b/amd/src/presetmodal.js index f0c3176..f78aa9b 100644 --- a/amd/src/presetmodal.js +++ b/amd/src/presetmodal.js @@ -64,6 +64,6 @@ export default class PresetModal extends Modal { } } -if (PresetModal.registerModalType !== 'undefined') { +if (typeof PresetModal.registerModalType !== 'undefined') { PresetModal.registerModalType(); } diff --git a/classes/forms/automation_instance_form.php b/classes/forms/automation_instance_form.php index 7e9a2fd..8da04cf 100644 --- a/classes/forms/automation_instance_form.php +++ b/classes/forms/automation_instance_form.php @@ -267,7 +267,6 @@ protected function load_template_conditions() { $mform->addElement('html', html_writer::end_div()); // E.o of actions triggere tab. } - /** * Load instance form elments for pulse action plugins. * diff --git a/conditions/activity/tests/behat/trigger_pulsecondition_activity.feature b/conditions/activity/tests/behat/trigger_pulsecondition_activity.feature index 7aa83b2..f4296e1 100644 --- a/conditions/activity/tests/behat/trigger_pulsecondition_activity.feature +++ b/conditions/activity/tests/behat/trigger_pulsecondition_activity.feature @@ -4,30 +4,30 @@ Feature: Activity trigger event. Background: Given the following "course" exist: - | fullname | shortname | category | enablecompletion | - | Course 1 | C1 | 0 | 1 | + | 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 | + | 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 | + | 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 | + | user | course | role | | teacher1 | C1 | editingteacher | - | student1 | C1 | student | + | 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 | + | Reference | Welcomemessage | Then I create automation template with the following fields to these values: | Title | WELCOME MESSAGE 02 | - | Reference | Welcomemessage02 | + | Reference | Welcomemessage02 | Then I create "Welcomemessage" template with the set the condition: | Triggers | Activity completion | | Trigger operator | All | @@ -37,7 +37,7 @@ Feature: Activity trigger event. 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 | + | insreference | Welcomemessage | Then I follow "Condition" Then I should see "Activity completion" Then the field "Activity completion" matches value "All" @@ -50,7 +50,7 @@ Feature: Activity trigger event. 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 | + | insreference | Welcomemessage2 | Then I follow "Condition" Then I should see "Activity completion" And I should not see "Select activities" diff --git a/conditions/cohort/tests/behat/trigger_pulsecondition_cohort.feature b/conditions/cohort/tests/behat/trigger_pulsecondition_cohort.feature index 85de96c..faebd86 100644 --- a/conditions/cohort/tests/behat/trigger_pulsecondition_cohort.feature +++ b/conditions/cohort/tests/behat/trigger_pulsecondition_cohort.feature @@ -4,22 +4,22 @@ Feature: Cohort trigger event. Background: Given the following "course" exist: - | fullname | shortname | category | enablecompletion | - | Course 1 | C1 | 0 | 1 | + | 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 | + | 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 | + | user | course | role | | teacher1 | C1 | editingteacher | - | user1 | C1 | student | - | user2 | C1 | student | + | user1 | C1 | student | + | user2 | C1 | student | And the following "cohorts" exist: - | name | idnumber | - | Cohort 1 | CH1 | - | Cohort 2 | CH2 | + | name | idnumber | + | Cohort 1 | CH1 | + | Cohort 2 | CH2 | And the following "cohort members" exist: | user | cohort | | user1 | CH1 | @@ -30,20 +30,20 @@ Feature: Cohort trigger event. Given I log in as "admin" Then I create automation template with the following fields to these values: | Title | WELCOME MESSAGE 01 | - | Reference | Welcomemessage | + | Reference | Welcomemessage | Then I create automation template with the following fields to these values: | Title | WELCOME MESSAGE 02 | - | Reference | Welcomemessage02 | + | Reference | Welcomemessage02 | Then I create "Welcomemessage" template with the set the condition: - | Triggers | Member in cohorts | - | Trigger operator | All | + | 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 | + | insreference | Welcomemessage | Then I follow "Condition" Then I should see "Member in cohorts" Then the field "Member in cohorts" matches value "All" @@ -56,7 +56,7 @@ Feature: Cohort trigger event. 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 | + | 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" diff --git a/conditions/course/tests/behat/trigger_pulsecondition_course.feature b/conditions/course/tests/behat/trigger_pulsecondition_course.feature index 12457be..257dccf 100644 --- a/conditions/course/tests/behat/trigger_pulsecondition_course.feature +++ b/conditions/course/tests/behat/trigger_pulsecondition_course.feature @@ -4,38 +4,38 @@ Feature: Course Completion trigger event. Background: Given the following "course" exist: - | fullname | shortname | category | enablecompletion | - | Course 1 | C1 | 0 | 1 | + | 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 | + | 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 | + | user | course | role | | teacher1 | C1 | editingteacher | - | user1 | C1 | student | - | user2 | C1 | student | + | 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 | + | Reference | Welcomemessage | Then I create automation template with the following fields to these values: | Title | WELCOME MESSAGE 02 | - | Reference | Welcomemessage02 | + | Reference | Welcomemessage02 | Then I create "Welcomemessage" template with the set the condition: - | Triggers | Course completion | - | Trigger operator | All | + | 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 | + | insreference | Welcomemessage | Then I follow "Condition" Then I should see "Course completion" Then the field "Course completion" matches value "All" @@ -44,7 +44,7 @@ Feature: Course Completion trigger event. 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 | + | 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" diff --git a/conditions/enrolment/tests/behat/trigger_pulsecondition_enrolment.feature b/conditions/enrolment/tests/behat/trigger_pulsecondition_enrolment.feature index 1c8db7b..a49eb44 100644 --- a/conditions/enrolment/tests/behat/trigger_pulsecondition_enrolment.feature +++ b/conditions/enrolment/tests/behat/trigger_pulsecondition_enrolment.feature @@ -4,38 +4,38 @@ Feature: Course Enrolment trigger event. Background: Given the following "course" exist: - | fullname | shortname | category | enablecompletion | - | Course 1 | C1 | 0 | 1 | + | 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 | + | 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 | + | user | course | role | | teacher1 | C1 | editingteacher | - | user1 | C1 | student | - | user2 | C1 | student | + | 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 | + | Reference | Welcomemessage | Then I create automation template with the following fields to these values: | Title | WELCOME MESSAGE 02 | - | Reference | Welcomemessage02 | + | Reference | Welcomemessage02 | Then I create "Welcomemessage" template with the set the condition: - | Triggers | User enrolment | - | Trigger operator | All | + | 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 | + | insreference | Welcomemessage | Then I follow "Condition" Then I should see "User enrolment" Then the field "User enrolment" matches value "All" @@ -44,7 +44,7 @@ Feature: Course Enrolment trigger event. 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 | + | 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" diff --git a/conditions/session/tests/behat/trigger_pulsecondition_session.feature b/conditions/session/tests/behat/trigger_pulsecondition_session.feature index 27bb6b8..0d73640 100644 --- a/conditions/session/tests/behat/trigger_pulsecondition_session.feature +++ b/conditions/session/tests/behat/trigger_pulsecondition_session.feature @@ -4,18 +4,18 @@ Feature: Session trigger event. Background: Given the following "course" exist: - | fullname | shortname | category | enablecompletion | - | Course 1 | C1 | 0 | 1 | + | 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 | + | 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 | + | user | course | role | | teacher1 | C1 | editingteacher | - | user1 | C1 | student | - | user2 | C1 | student | + | user1 | C1 | student | + | user2 | C1 | student | @javascript Scenario: Check the pluse condition sesion trigger workflow. @@ -33,20 +33,20 @@ Feature: Session trigger event. 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 | + | Reference | Welcomemessage | Then I create automation template with the following fields to these values: | Title | WELCOME MESSAGE 02 | - | Reference | Welcomemessage02 | + | Reference | Welcomemessage02 | Then I create "Welcomemessage" template with the set the condition: - | Triggers | Session booking | - | Trigger operator | All | + | 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 | + | insreference | Welcomemessage | Then I follow "Condition" Then I should see "Session booking" Then the field "Session booking" matches value "All" @@ -57,7 +57,7 @@ Feature: Session trigger event. 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 | + | 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" diff --git a/tests/behat/behat_pulse.php b/tests/behat/behat_pulse.php index fb1e99d..5e571e3 100644 --- a/tests/behat/behat_pulse.php +++ b/tests/behat/behat_pulse.php @@ -224,4 +224,20 @@ 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$/ + * @throws DriverException If there aren't exactly 2 windows open. + */ + public function i_click_on_pulse_editor($editor) { + global $CFG; + + if ($CFG->branch == "403") { + $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_management.feature b/tests/behat/pulse_automation_instance_management.feature index a395ce2..0f659e0 100644 --- a/tests/behat/pulse_automation_instance_management.feature +++ b/tests/behat/pulse_automation_instance_management.feature @@ -564,7 +564,7 @@ Feature: Pulse automation instances management 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 "#id_pulsenotification_headercontent_editor_ifr" "css_element" in the "#fitem_id_pulsenotification_headercontent_editor" "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" @@ -684,5 +684,3 @@ Feature: Pulse automation instances management 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_preset.feature b/tests/behat/pulse_preset.feature index fba3cbe..6c15632 100644 --- a/tests/behat/pulse_preset.feature +++ b/tests/behat/pulse_preset.feature @@ -56,11 +56,10 @@ Feature: Preset create pulse with custom params. When I click on ".pulse-usepreset" "css_element" And I should see "Welcome Message" in the ".modal-header .modal-title" "css_element" And I set the field with xpath "//div[@class='preset-config-params']//input[@id='id_name']" to "Customize preset" - And I set the field "id_preseteditor_introeditor" to "Pulse created using apply and customize - custom value" And I press "Apply and Customize" And I wait "3" seconds Then ".modal-body" "css_element" should not be visible Then the field "id_name" matches value "Customize preset" - And the field "id_introeditor" matches value "Pulse created using apply and customize - custom value" + And I set the field "id_introeditor" to "Pulse created using apply and customize - custom value" And I press "Save and return to course" Then I should see "Pulse created using apply and customize - custom value"