diff --git a/report/participation/amd/build/participants.min.js b/report/participation/amd/build/participants.min.js index fa9364b470d..551b48d50d7 100644 --- a/report/participation/amd/build/participants.min.js +++ b/report/participation/amd/build/participants.min.js @@ -1,2 +1,2 @@ -define ("report_participation/participants",["exports","jquery","core/custom_interaction_events","core/modal_events","core/notification","core_user/local/participants/bulkactions"],function(a,b,c,d,e,f){"use strict";Object.defineProperty(a,"__esModule",{value:!0});a.init=void 0;b=g(b);c=g(c);d=g(d);e=g(e);function g(a){return a&&a.__esModule?a:{default:a}}var h={bulkActionSelect:"#formactionid",bulkUserSelectedCheckBoxes:"input[data-togglegroup^='participants-table']:checked",participantsForm:"#participantsform"};a.init=function init(){var a=document.querySelector(h.participantsForm),g=function(){c.default.define(h.bulkActionSelect,[c.default.events.accessibleChange]);(0,b.default)(h.bulkActionSelect).on(c.default.events.accessibleChange,function(b){var c=b.target.value,g=a.querySelectorAll(h.bulkUserSelectedCheckBoxes);if(-1!==c.indexOf("#")){b.preventDefault();var j=[];g.forEach(function(a){j.push(a.getAttribute("name").replace("user",""))});if("#messageselect"===c){(0,f.showSendMessage)(j).then(function(b){b.getRoot().on(d.default.hidden,function(){var b=a.querySelector(h.bulkActionSelect);i(b);b.focus()});return b}).catch(e.default.exception)}}else if(""!==c&&g.length){b.target.form().submit()}i(b.target)})},i=function(a){a.value=""};g()}}); +define ("report_participation/participants",["exports","jquery","core/custom_interaction_events","core/modal_events","core/notification","core_user/local/participants/bulkactions"],function(a,b,c,d,e,f){"use strict";Object.defineProperty(a,"__esModule",{value:!0});a.init=void 0;b=g(b);c=g(c);d=g(d);e=g(e);function g(a){return a&&a.__esModule?a:{default:a}}var h={bulkActionSelect:"#formactionid",bulkUserSelectedCheckBoxes:"input[data-togglegroup^='participants-table'][data-toggle='slave']:checked",participantsForm:"#participantsform"};a.init=function init(){var a=document.querySelector(h.participantsForm),g=function(){c.default.define(h.bulkActionSelect,[c.default.events.accessibleChange]);(0,b.default)(h.bulkActionSelect).on(c.default.events.accessibleChange,function(b){var c=b.target.value,g=a.querySelectorAll(h.bulkUserSelectedCheckBoxes);if(-1!==c.indexOf("#")){b.preventDefault();var j=[];g.forEach(function(a){j.push(a.getAttribute("name").replace("user",""))});if("#messageselect"===c){(0,f.showSendMessage)(j).then(function(b){b.getRoot().on(d.default.hidden,function(){var b=a.querySelector(h.bulkActionSelect);i(b);b.focus()});return b}).catch(e.default.exception)}}else if(""!==c&&g.length){b.target.form().submit()}i(b.target)})},i=function(a){a.value=""};g()}}); //# sourceMappingURL=participants.min.js.map diff --git a/report/participation/amd/build/participants.min.js.map b/report/participation/amd/build/participants.min.js.map index 23f6cb6b2df..293895b3555 100644 --- a/report/participation/amd/build/participants.min.js.map +++ b/report/participation/amd/build/participants.min.js.map @@ -1 +1 @@ -{"version":3,"sources":["../src/participants.js"],"names":["Selectors","bulkActionSelect","bulkUserSelectedCheckBoxes","participantsForm","init","root","document","querySelector","registerEventListeners","CustomEvents","define","events","accessibleChange","on","e","action","target","value","checkboxes","querySelectorAll","indexOf","preventDefault","ids","forEach","checkbox","push","getAttribute","replace","then","modal","getRoot","ModalEvents","hidden","bulkActionSelector","resetBulkAction","focus","catch","Notification","exception","length","form","submit"],"mappings":"uRAyBA,OACA,OACA,OACA,O,sDAGMA,CAAAA,CAAS,CAAG,CACdC,gBAAgB,CAAE,eADJ,CAEdC,0BAA0B,CAAE,uDAFd,CAGdC,gBAAgB,CAAE,mBAHJ,C,QAME,QAAPC,CAAAA,IAAO,EAAM,IAChBC,CAAAA,CAAI,CAAGC,QAAQ,CAACC,aAAT,CAAuBP,CAAS,CAACG,gBAAjC,CADS,CAShBK,CAAsB,CAAG,UAAM,CACjCC,UAAaC,MAAb,CAAoBV,CAAS,CAACC,gBAA9B,CAAgD,CAACQ,UAAaE,MAAb,CAAoBC,gBAArB,CAAhD,EACA,cAAOZ,CAAS,CAACC,gBAAjB,EAAmCY,EAAnC,CAAsCJ,UAAaE,MAAb,CAAoBC,gBAA1D,CAA4E,SAAAE,CAA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odle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/**\n * Some UI stuff for participants page.\n * This is also used by the report/participants/index.php because it has the same functionality.\n *\n * @module core_user/participants\n * @package core_user\n * @copyright 2017 Damyon Wiese\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\nimport jQuery from 'jquery';\nimport CustomEvents from 'core/custom_interaction_events';\nimport ModalEvents from 'core/modal_events';\nimport Notification from 'core/notification';\nimport {showSendMessage} from 'core_user/local/participants/bulkactions';\n\nconst Selectors = {\n bulkActionSelect: \"#formactionid\",\n bulkUserSelectedCheckBoxes: \"input[data-togglegroup^='participants-table']:checked\",\n participantsForm: '#participantsform',\n};\n\nexport const init = () => {\n const root = document.querySelector(Selectors.participantsForm);\n\n /**\n * Private method.\n *\n * @method registerEventListeners\n * @private\n */\n const registerEventListeners = () => {\n CustomEvents.define(Selectors.bulkActionSelect, [CustomEvents.events.accessibleChange]);\n jQuery(Selectors.bulkActionSelect).on(CustomEvents.events.accessibleChange, e => {\n const action = e.target.value;\n const checkboxes = root.querySelectorAll(Selectors.bulkUserSelectedCheckBoxes);\n\n if (action.indexOf('#') !== -1) {\n e.preventDefault();\n\n const ids = [];\n checkboxes.forEach(checkbox => {\n ids.push(checkbox.getAttribute('name').replace('user', ''));\n });\n\n if (action === '#messageselect') {\n showSendMessage(ids)\n .then(modal => {\n modal.getRoot().on(ModalEvents.hidden, () => {\n // Focus on the action select when the dialog is closed.\n const bulkActionSelector = root.querySelector(Selectors.bulkActionSelect);\n resetBulkAction(bulkActionSelector);\n bulkActionSelector.focus();\n });\n\n return modal;\n })\n .catch(Notification.exception);\n }\n } else if (action !== '' && checkboxes.length) {\n e.target.form().submit();\n }\n\n resetBulkAction(e.target);\n });\n };\n\n const resetBulkAction = bulkActionSelect => {\n bulkActionSelect.value = '';\n };\n\n registerEventListeners();\n};\n"],"file":"participants.min.js"} \ No newline at end of file +{"version":3,"sources":["../src/participants.js"],"names":["Selectors","bulkActionSelect","bulkUserSelectedCheckBoxes","participantsForm","init","root","document","querySelector","registerEventListeners","CustomEvents","define","events","accessibleChange","on","e","action","target","value","checkboxes","querySelectorAll","indexOf","preventDefault","ids","forEach","checkbox","push","getAttribute","replace","then","modal","getRoot","ModalEvents","hidden","bulkActionSelector","resetBulkAction","focus","catch","Notification","exception","length","form","submit"],"mappings":"uRAyBA,OACA,OACA,OACA,O,sDAGMA,CAAAA,CAAS,CAAG,CACdC,gBAAgB,CAAE,eADJ,CAEdC,0BAA0B,CAAE,4EAFd,CAGdC,gBAAgB,CAAE,mBAHJ,C,QAME,QAAPC,CAAAA,IAAO,EAAM,IAChBC,CAAAA,CAAI,CAAGC,QAAQ,CAACC,aAAT,CAAuBP,CAAS,CAACG,gBAAjC,CADS,CAShBK,CAAsB,CAAG,UAAM,CACjCC,UAAaC,MAAb,CAAoBV,CAAS,CAACC,gBAA9B,CAAgD,CAACQ,UAAaE,MAAb,CAAoBC,gBAArB,CAAhD,EACA,cAAOZ,CAAS,CAACC,gBAAjB,EAAmCY,EAAnC,CAAsCJ,UAAaE,MAAb,CAAoBC,gBAA1D,CAA4E,SAAAE,CAAC,CAAI,IACvEC,CAAAA,CAAM,CAAGD,CAAC,CAACE,MAAF,CAASC,KADqD,CAEvEC,CAAU,CAAGb,CAAI,CAACc,gBAAL,CAAsBnB,CAAS,CAACE,0BAAhC,CAF0D,CAI7E,GAA4B,CAAC,CAAzB,GAAAa,CAAM,CAACK,OAAP,CAAe,GAAf,CAAJ,CAAgC,CAC5BN,CAAC,CAACO,cAAF,GAEA,GAAMC,CAAAA,CAAG,CAAG,EAAZ,CACAJ,CAAU,CAACK,OAAX,CAAmB,SAAAC,CAAQ,CAAI,CAC3BF,CAAG,CAACG,IAAJ,CAASD,CAAQ,CAACE,YAAT,CAAsB,MAAtB,EAA8BC,OAA9B,CAAsC,MAAtC,CAA8C,EAA9C,CAAT,CACH,CAFD,EAIA,GAAe,gBAAX,GAAAZ,CAAJ,CAAiC,CAC7B,sBAAgBO,CAAhB,EACCM,IADD,CACM,SAAAC,CAAK,CAAI,CACXA,CAAK,CAACC,OAAN,GAAgBjB,EAAhB,CAAmBkB,UAAYC,MAA/B,CAAuC,UAAM,CAEzC,GAAMC,CAAAA,CAAkB,CAAG5B,CAAI,CAACE,aAAL,CAAmBP,CAAS,CAACC,gBAA7B,CAA3B,CACAiC,CAAe,CAACD,CAAD,CAAf,CACAA,CAAkB,CAACE,KAAnB,EACH,CALD,EAOA,MAAON,CAAAA,CACV,CAVD,EAWCO,KAXD,CAWOC,UAAaC,SAXpB,CAYH,CACJ,CAtBD,IAsBO,IAAe,EAAX,GAAAvB,CAAM,EAAWG,CAAU,CAACqB,MAAhC,CAAwC,CAC3CzB,CAAC,CAACE,MAAF,CAASwB,IAAT,GAAgBC,MAAhB,EACH,CAEDP,CAAe,CAACpB,CAAC,CAACE,MAAH,CAClB,CA/BD,CAgCH,CA3CqB,CA6ChBkB,CAAe,CAAG,SAAAjC,CAAgB,CAAI,CACxCA,CAAgB,CAACgB,KAAjB,CAAyB,EAC5B,CA/CqB,CAiDtBT,CAAsB,EACzB,C","sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/**\n * Some UI stuff for participants page.\n * This is also used by the report/participants/index.php because it has the same functionality.\n *\n * @module core_user/participants\n * @package core_user\n * @copyright 2017 Damyon Wiese\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\nimport jQuery from 'jquery';\nimport CustomEvents from 'core/custom_interaction_events';\nimport ModalEvents from 'core/modal_events';\nimport Notification from 'core/notification';\nimport {showSendMessage} from 'core_user/local/participants/bulkactions';\n\nconst Selectors = {\n bulkActionSelect: \"#formactionid\",\n bulkUserSelectedCheckBoxes: \"input[data-togglegroup^='participants-table'][data-toggle='slave']:checked\",\n participantsForm: '#participantsform',\n};\n\nexport const init = () => {\n const root = document.querySelector(Selectors.participantsForm);\n\n /**\n * Private method.\n *\n * @method registerEventListeners\n * @private\n */\n const registerEventListeners = () => {\n CustomEvents.define(Selectors.bulkActionSelect, [CustomEvents.events.accessibleChange]);\n jQuery(Selectors.bulkActionSelect).on(CustomEvents.events.accessibleChange, e => {\n const action = e.target.value;\n const checkboxes = root.querySelectorAll(Selectors.bulkUserSelectedCheckBoxes);\n\n if (action.indexOf('#') !== -1) {\n e.preventDefault();\n\n const ids = [];\n checkboxes.forEach(checkbox => {\n ids.push(checkbox.getAttribute('name').replace('user', ''));\n });\n\n if (action === '#messageselect') {\n showSendMessage(ids)\n .then(modal => {\n modal.getRoot().on(ModalEvents.hidden, () => {\n // Focus on the action select when the dialog is closed.\n const bulkActionSelector = root.querySelector(Selectors.bulkActionSelect);\n resetBulkAction(bulkActionSelector);\n bulkActionSelector.focus();\n });\n\n return modal;\n })\n .catch(Notification.exception);\n }\n } else if (action !== '' && checkboxes.length) {\n e.target.form().submit();\n }\n\n resetBulkAction(e.target);\n });\n };\n\n const resetBulkAction = bulkActionSelect => {\n bulkActionSelect.value = '';\n };\n\n registerEventListeners();\n};\n"],"file":"participants.min.js"} \ No newline at end of file diff --git a/report/participation/amd/src/participants.js b/report/participation/amd/src/participants.js index 7af7b60b847..81dfdc85534 100644 --- a/report/participation/amd/src/participants.js +++ b/report/participation/amd/src/participants.js @@ -31,7 +31,7 @@ import {showSendMessage} from 'core_user/local/participants/bulkactions'; const Selectors = { bulkActionSelect: "#formactionid", - bulkUserSelectedCheckBoxes: "input[data-togglegroup^='participants-table']:checked", + bulkUserSelectedCheckBoxes: "input[data-togglegroup^='participants-table'][data-toggle='slave']:checked", participantsForm: '#participantsform', }; diff --git a/report/participation/tests/behat/message_participants.feature b/report/participation/tests/behat/message_participants.feature index df6fa46b9d7..3ed310cc399 100644 --- a/report/participation/tests/behat/message_participants.feature +++ b/report/participation/tests/behat/message_participants.feature @@ -20,21 +20,31 @@ Feature: Use the particiaption report to message groups of students | student1 | C1 | student | | student2 | C1 | student | | student3 | C1 | student | - And I log in as "teacher1" - And I am on "Course 1" course homepage with editing mode on - And I add a "Book" to section "1" and I fill the form with: - | Name | Test book name | - | Description | Test book | - And I follow "Test book name" - And I set the following fields to these values: - | Chapter title | Test chapter | - | Content | Test chapter content | - And I log out + And the following "activity" exists: + | course | C1 | + | activity | book | + | name | Test book name | + | description | Test book | + | idnumber | book1 | And I log in as "student1" And I am on "Course 1" course homepage And I follow "Test book name" And I log out + Scenario: Message all students from the participation report + Given I log in as "teacher1" + And I am on "Course 1" course homepage + And I navigate to "Reports > Course participation" in current page administration + And I set the field "instanceid" to "Test book name" + And I set the field "roleid" to "Student" + And I press "Go" + When I click on "select-all-participants" "checkbox" + And I choose "Send a message" from the participants page bulk action menu + Then "Send message to 3 people" "dialogue" should exist + And I set the field "Message" to "Hi there" + And I press "Send message to 3 people" + And I should see "Message sent to 3 people" + Scenario: Message students who have not participated in book Given I log in as "teacher1" And I am on "Course 1" course homepage @@ -47,13 +57,14 @@ Feature: Use the particiaption report to message groups of students And I should see "No" in the "Student 3" "table_row" When I press "Select all 'No'" And I choose "Send a message" from the participants page bulk action menu - Then I should see "Send message to 2 people" + Then "Send message to 2 people" "dialogue" should exist + And I set the field "Message" to "Hi there" + And I press "Send message to 2 people" + And I should see "Message sent to 2 people" Scenario: Ensure no message options when messaging is disabled - Given I log in as "admin" - And I set the following administration settings values: + Given the following config values are set as admin: | messaging | 0 | - And I log out And I log in as "teacher1" And I am on "Course 1" course homepage And I navigate to "Reports > Course participation" in current page administration @@ -61,4 +72,4 @@ Feature: Use the particiaption report to message groups of students And I set the field "roleid" to "Student" And I press "Go" Then I should not see "With selected users..." - And I should not see "Select all" + And "select-all-participants" "checkbox" should not exist