diff --git a/user/amd/build/participants.min.js b/user/amd/build/participants.min.js index 071682ec3a7..0a8e5cdb191 100644 --- a/user/amd/build/participants.min.js +++ b/user/amd/build/participants.min.js @@ -1,2 +1,2 @@ -function _typeof(a){"@babel/helpers - typeof";if("function"==typeof Symbol&&"symbol"==typeof Symbol.iterator){_typeof=function(a){return typeof a}}else{_typeof=function(a){return a&&"function"==typeof Symbol&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a}}return _typeof(a)}define ("core_user/participants",["exports","core_table/dynamic","core/str","core/checkbox-toggleall","core/custom_interaction_events","core_table/local/dynamic/selectors","core/modal_events","core/notification","core/pending","jquery","core_user/local/participants/bulkactions"],function(a,b,c,d,e,f,g,h,i,j,k){"use strict";Object.defineProperty(a,"__esModule",{value:!0});a.init=void 0;b=n(b);c=n(c);d=l(d);e=l(e);f=l(f);g=l(g);h=l(h);i=l(i);j=l(j);function l(a){return a&&a.__esModule?a:{default:a}}function m(){if("function"!=typeof WeakMap)return null;var a=new WeakMap;m=function(){return a};return a}function n(a){if(a&&a.__esModule){return a}if(null===a||"object"!==_typeof(a)&&"function"!=typeof a){return{default:a}}var b=m();if(b&&b.has(a)){return b.get(a)}var c={},d=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var e in a){if(Object.prototype.hasOwnProperty.call(a,e)){var f=d?Object.getOwnPropertyDescriptor(a,e):null;if(f&&(f.get||f.set)){Object.defineProperty(c,e,f)}else{c[e]=a[e]}}}c.default=a;if(b){b.set(a,c)}return c}function o(a,b){return t(a)||s(a,b)||q(a,b)||p()}function p(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function q(a,b){if(!a)return;if("string"==typeof a)return r(a,b);var c=Object.prototype.toString.call(a).slice(8,-1);if("Object"===c&&a.constructor)c=a.constructor.name;if("Map"===c||"Set"===c)return Array.from(c);if("Arguments"===c||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(c))return r(a,b)}function r(a,b){if(null==b||b>a.length)b=a.length;for(var c=0,d=Array(b);ca.length)b=a.length;for(var c=0,d=Array(b);c.\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 * as DynamicTable from 'core_table/dynamic';\nimport * as Str from 'core/str';\nimport CheckboxToggleAll from 'core/checkbox-toggleall';\nimport CustomEvents from 'core/custom_interaction_events';\nimport DynamicTableSelectors from 'core_table/local/dynamic/selectors';\nimport ModalEvents from 'core/modal_events';\nimport Notification from 'core/notification';\nimport Pending from 'core/pending';\nimport jQuery from 'jquery';\nimport {showAddNote, 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 checkCountButton: \"#checkall\",\n showCountText: '[data-region=\"participant-count\"]',\n showCountToggle: '[data-action=\"showcount\"]',\n stateHelpIcon: '[data-region=\"state-help-icon\"]',\n tableForm: uniqueId => `form[data-table-unique-id=\"${uniqueId}\"]`,\n};\n\nexport const init = ({\n uniqueid,\n noteStateNames = {},\n}) => {\n const root = document.querySelector(Selectors.tableForm(uniqueid));\n const getTableFromUniqueId = uniqueId => root.querySelector(DynamicTableSelectors.main.fromRegionId(uniqueId));\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 bulkActionSelect = e.target.closest('select');\n const action = bulkActionSelect.value;\n const tableRoot = getTableFromUniqueId(uniqueid);\n const checkboxes = tableRoot.querySelectorAll(Selectors.bulkUserSelectedCheckBoxes);\n const pendingPromise = new Pending('core_user/participants:bulkActionSelect');\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 let bulkAction;\n if (action === '#messageselect') {\n bulkAction = showSendMessage(ids);\n } else if (action === '#addgroupnote') {\n bulkAction = showAddNote(\n root.dataset.courseId,\n ids,\n noteStateNames,\n root.querySelector(Selectors.stateHelpIcon)\n );\n }\n\n if (bulkAction) {\n const pendingBulkAction = new Pending('core_user/participants:bulkActionSelected');\n bulkAction\n .then(modal => {\n modal.getRoot().on(ModalEvents.hidden, () => {\n // Focus on the action select when the dialog is closed.\n bulkActionSelect.focus();\n });\n\n pendingBulkAction.resolve();\n return modal;\n })\n .catch(Notification.exception);\n }\n } else if (action !== '' && checkboxes.length) {\n bulkActionSelect.form.submit();\n }\n\n resetBulkAction(bulkActionSelect);\n pendingPromise.resolve();\n });\n\n root.addEventListener('click', e => {\n // Handle clicking of the \"Show [all|count]\" and \"Select all\" actions.\n const showCountLink = root.querySelector(Selectors.showCountToggle);\n const checkCountButton = root.querySelector(Selectors.checkCountButton);\n\n const showCountLinkClicked = showCountLink && showCountLink.contains(e.target);\n const checkCountButtonClicked = checkCountButton && checkCountButton.contains(e.target);\n\n if (showCountLinkClicked || checkCountButtonClicked) {\n e.preventDefault();\n\n const tableRoot = getTableFromUniqueId(uniqueid);\n\n DynamicTable.setPageSize(tableRoot, showCountLink.dataset.targetPageSize)\n .then(tableRoot => {\n // Always update the toggle state.\n // This ensures that the bulk actions are disabled after changing the page size.\n CheckboxToggleAll.setGroupState(root, 'participants-table', checkCountButtonClicked);\n\n return tableRoot;\n })\n .catch(Notification.exception);\n }\n });\n\n // When the content is refreshed, update the row counts in various places.\n root.addEventListener(DynamicTable.Events.tableContentRefreshed, e => {\n const showCountLink = root.querySelector(Selectors.showCountToggle);\n const checkCountButton = root.querySelector(Selectors.checkCountButton);\n\n const tableRoot = e.target;\n\n const defaultPageSize = parseInt(root.dataset.tableDefaultPerPage, 10);\n const currentPageSize = parseInt(tableRoot.dataset.tablePageSize, 10);\n const totalRowCount = parseInt(tableRoot.dataset.tableTotalRows, 10);\n\n CheckboxToggleAll.updateSlavesFromMasterState(root, 'participants-table');\n\n const pageCountStrings = [\n {\n key: 'countparticipantsfound',\n component: 'core_user',\n param: totalRowCount,\n },\n ];\n\n\n if (totalRowCount <= defaultPageSize) {\n // There are fewer than the default page count numbers of rows.\n showCountLink.classList.add('hidden');\n\n if (checkCountButton) {\n checkCountButton.classList.add('hidden');\n }\n } else if (totalRowCount <= currentPageSize) {\n // The are fewer than the current page size.\n pageCountStrings.push({\n key: 'showperpage',\n component: 'core',\n param: defaultPageSize,\n });\n\n pageCountStrings.push({\n key: 'selectalluserswithcount',\n component: 'core',\n param: defaultPageSize,\n });\n\n // Show the 'Show [x]' link.\n showCountLink.classList.remove('hidden');\n showCountLink.dataset.targetPageSize = defaultPageSize;\n\n if (checkCountButton) {\n // The 'Check all [x]' button is only visible when there are values to set.\n checkCountButton.classList.add('hidden');\n }\n } else {\n pageCountStrings.push({\n key: 'showall',\n component: 'core',\n param: totalRowCount,\n });\n\n pageCountStrings.push({\n key: 'selectalluserswithcount',\n component: 'core',\n param: totalRowCount,\n });\n\n // Show both the 'Show [x]' link, and the 'Check all [x]' button.\n showCountLink.classList.remove('hidden');\n showCountLink.dataset.targetPageSize = totalRowCount;\n\n if (checkCountButton) {\n checkCountButton.classList.remove('hidden');\n }\n }\n\n Str.get_strings(pageCountStrings)\n .then(([showingParticipantCountString, showCountString, selectCountString]) => {\n const showingParticipantCount = root.querySelector(Selectors.showCountText);\n showingParticipantCount.innerHTML = showingParticipantCountString;\n\n if (showCountString) {\n showCountLink.innerHTML = showCountString;\n }\n\n if (selectCountString && checkCountButton) {\n checkCountButton.value = selectCountString;\n }\n\n return;\n })\n .catch(Notification.exception);\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","checkCountButton","showCountText","showCountToggle","stateHelpIcon","tableForm","uniqueId","init","uniqueid","noteStateNames","root","document","querySelector","getTableFromUniqueId","DynamicTableSelectors","main","fromRegionId","registerEventListeners","CustomEvents","define","events","accessibleChange","on","e","target","closest","action","value","tableRoot","checkboxes","querySelectorAll","pendingPromise","Pending","indexOf","preventDefault","ids","forEach","checkbox","push","getAttribute","replace","bulkAction","dataset","courseId","pendingBulkAction","then","modal","getRoot","ModalEvents","hidden","focus","resolve","catch","Notification","exception","length","form","submit","resetBulkAction","addEventListener","checkCountButtonClicked","contains","DynamicTable","setPageSize","targetPageSize","CheckboxToggleAll","setGroupState","Events","tableContentRefreshed","defaultPageSize","parseInt","tableDefaultPerPage","currentPageSize","tablePageSize","totalRowCount","tableTotalRows","updateSlavesFromMasterState","pageCountStrings","key","component","param","classList","add","remove","Str","get_strings","showingParticipantCountString","selectCountString","showingParticipantCount","innerHTML"],"mappings":"uqBAyBA,OACA,OACA,OACA,OACA,OACA,OACA,OACA,OACA,O,wjDAGMA,CAAAA,CAAS,CAAG,CACdC,gBAAgB,CAAE,eADJ,CAEdC,0BAA0B,CAAE,2EAFd,CAGdC,gBAAgB,CAAE,WAHJ,CAIdC,aAAa,CAAE,qCAJD,CAKdC,eAAe,CAAE,6BALH,CAMdC,aAAa,CAAE,mCAND,CAOdC,SAAS,CAAE,mBAAAC,CAAQ,8CAAkCA,CAAlC,QAPL,C,QAUE,QAAPC,CAAAA,IAAO,GAGd,IAFFC,CAAAA,CAEE,GAFFA,QAEE,KADFC,cACE,CADFA,CACE,YADe,EACf,GACIC,CAAI,CAAGC,QAAQ,CAACC,aAAT,CAAuBd,CAAS,CAACO,SAAV,CAAoBG,CAApB,CAAvB,CADX,CAEIK,CAAoB,CAAG,SAAAP,CAAQ,QAAII,CAAAA,CAAI,CAACE,aAAL,CAAm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AHW,CAAtB,EAMA,GAAIzE,CAAJ,CAAsB,CAClBA,CAAgB,CAACgF,SAAjB,CAA2BE,MAA3B,CAAkC,QAAlC,CACH,CACJ,CAEDC,CAAG,CAACC,WAAJ,CAAgBR,CAAhB,EACChC,IADD,CACM,WAAwD,cAAtDyC,CAAsD,MAAvBC,CAAuB,MACpDC,CAAuB,CAAG9E,CAAI,CAACE,aAAL,CAAmBd,CAAS,CAACI,aAA7B,CAD0B,CAE1DsF,CAAuB,CAACC,SAAxB,CAAoCH,CAApC,CAEA,GAAIC,CAAiB,EAAItF,CAAzB,CAA2C,CACvCA,CAAgB,CAAC0B,KAAjB,CAAyB4D,CAC5B,CAGJ,CAVD,EAWCnC,KAXD,CAWOC,UAAaC,SAXpB,CAYH,CA3DD,CA4DH,CA/IC,CAiJII,CAAe,CAAG,SAAA3D,CAAgB,CAAI,CACxCA,CAAgB,CAAC4B,KAAjB,CAAyB,EAC5B,CAnJC,CAqJFV,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 * as DynamicTable from 'core_table/dynamic';\nimport * as Str from 'core/str';\nimport CheckboxToggleAll from 'core/checkbox-toggleall';\nimport CustomEvents from 'core/custom_interaction_events';\nimport DynamicTableSelectors from 'core_table/local/dynamic/selectors';\nimport ModalEvents from 'core/modal_events';\nimport Notification from 'core/notification';\nimport Pending from 'core/pending';\nimport jQuery from 'jquery';\nimport {showAddNote, 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 checkCountButton: \"#checkall\",\n showCountText: '[data-region=\"participant-count\"]',\n showCountToggle: '[data-action=\"showcount\"]',\n stateHelpIcon: '[data-region=\"state-help-icon\"]',\n tableForm: uniqueId => `form[data-table-unique-id=\"${uniqueId}\"]`,\n};\n\nexport const init = ({\n uniqueid,\n noteStateNames = {},\n}) => {\n const root = document.querySelector(Selectors.tableForm(uniqueid));\n const getTableFromUniqueId = uniqueId => root.querySelector(DynamicTableSelectors.main.fromRegionId(uniqueId));\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 bulkActionSelect = e.target.closest('select');\n const action = bulkActionSelect.value;\n const tableRoot = getTableFromUniqueId(uniqueid);\n const checkboxes = tableRoot.querySelectorAll(Selectors.bulkUserSelectedCheckBoxes);\n const pendingPromise = new Pending('core_user/participants:bulkActionSelect');\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 let bulkAction;\n if (action === '#messageselect') {\n bulkAction = showSendMessage(ids);\n } else if (action === '#addgroupnote') {\n bulkAction = showAddNote(\n root.dataset.courseId,\n ids,\n noteStateNames,\n root.querySelector(Selectors.stateHelpIcon)\n );\n }\n\n if (bulkAction) {\n const pendingBulkAction = new Pending('core_user/participants:bulkActionSelected');\n bulkAction\n .then(modal => {\n modal.getRoot().on(ModalEvents.hidden, () => {\n // Focus on the action select when the dialog is closed.\n bulkActionSelect.focus();\n });\n\n pendingBulkAction.resolve();\n return modal;\n })\n .catch(Notification.exception);\n }\n } else if (action !== '' && checkboxes.length) {\n bulkActionSelect.form.submit();\n }\n\n resetBulkAction(bulkActionSelect);\n pendingPromise.resolve();\n });\n\n root.addEventListener('click', e => {\n // Handle clicking of the \"Select all\" actions.\n const checkCountButton = root.querySelector(Selectors.checkCountButton);\n const checkCountButtonClicked = checkCountButton && checkCountButton.contains(e.target);\n\n if (checkCountButtonClicked) {\n e.preventDefault();\n\n const tableRoot = getTableFromUniqueId(uniqueid);\n\n DynamicTable.setPageSize(tableRoot, checkCountButton.dataset.targetPageSize)\n .then(tableRoot => {\n // Update the toggle state.\n CheckboxToggleAll.setGroupState(root, 'participants-table', true);\n\n return tableRoot;\n })\n .catch(Notification.exception);\n }\n });\n\n // When the content is refreshed, update the row counts in various places.\n root.addEventListener(DynamicTable.Events.tableContentRefreshed, e => {\n const checkCountButton = root.querySelector(Selectors.checkCountButton);\n\n const tableRoot = e.target;\n\n const defaultPageSize = parseInt(tableRoot.dataset.tableDefaultPerPage, 10);\n const currentPageSize = parseInt(tableRoot.dataset.tablePageSize, 10);\n const totalRowCount = parseInt(tableRoot.dataset.tableTotalRows, 10);\n\n CheckboxToggleAll.updateSlavesFromMasterState(root, 'participants-table');\n\n const pageCountStrings = [\n {\n key: 'countparticipantsfound',\n component: 'core_user',\n param: totalRowCount,\n },\n ];\n\n if (totalRowCount <= defaultPageSize) {\n if (checkCountButton) {\n checkCountButton.classList.add('hidden');\n }\n } else if (totalRowCount <= currentPageSize) {\n // The are fewer than the current page size.\n pageCountStrings.push({\n key: 'selectalluserswithcount',\n component: 'core',\n param: defaultPageSize,\n });\n\n if (checkCountButton) {\n // The 'Check all [x]' button is only visible when there are values to set.\n checkCountButton.classList.add('hidden');\n }\n } else {\n pageCountStrings.push({\n key: 'selectalluserswithcount',\n component: 'core',\n param: totalRowCount,\n });\n\n if (checkCountButton) {\n checkCountButton.classList.remove('hidden');\n }\n }\n\n Str.get_strings(pageCountStrings)\n .then(([showingParticipantCountString, selectCountString]) => {\n const showingParticipantCount = root.querySelector(Selectors.showCountText);\n showingParticipantCount.innerHTML = showingParticipantCountString;\n\n if (selectCountString && checkCountButton) {\n checkCountButton.value = selectCountString;\n }\n\n return;\n })\n .catch(Notification.exception);\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/user/amd/src/participants.js b/user/amd/src/participants.js index 63c8e0a5d9b..7e4eb24da42 100644 --- a/user/amd/src/participants.js +++ b/user/amd/src/participants.js @@ -109,23 +109,19 @@ export const init = ({ }); root.addEventListener('click', e => { - // Handle clicking of the "Show [all|count]" and "Select all" actions. - const showCountLink = root.querySelector(Selectors.showCountToggle); + // Handle clicking of the "Select all" actions. const checkCountButton = root.querySelector(Selectors.checkCountButton); - - const showCountLinkClicked = showCountLink && showCountLink.contains(e.target); const checkCountButtonClicked = checkCountButton && checkCountButton.contains(e.target); - if (showCountLinkClicked || checkCountButtonClicked) { + if (checkCountButtonClicked) { e.preventDefault(); const tableRoot = getTableFromUniqueId(uniqueid); - DynamicTable.setPageSize(tableRoot, showCountLink.dataset.targetPageSize) + DynamicTable.setPageSize(tableRoot, checkCountButton.dataset.targetPageSize) .then(tableRoot => { - // Always update the toggle state. - // This ensures that the bulk actions are disabled after changing the page size. - CheckboxToggleAll.setGroupState(root, 'participants-table', checkCountButtonClicked); + // Update the toggle state. + CheckboxToggleAll.setGroupState(root, 'participants-table', true); return tableRoot; }) @@ -135,12 +131,11 @@ export const init = ({ // When the content is refreshed, update the row counts in various places. root.addEventListener(DynamicTable.Events.tableContentRefreshed, e => { - const showCountLink = root.querySelector(Selectors.showCountToggle); const checkCountButton = root.querySelector(Selectors.checkCountButton); const tableRoot = e.target; - const defaultPageSize = parseInt(root.dataset.tableDefaultPerPage, 10); + const defaultPageSize = parseInt(tableRoot.dataset.tableDefaultPerPage, 10); const currentPageSize = parseInt(tableRoot.dataset.tablePageSize, 10); const totalRowCount = parseInt(tableRoot.dataset.tableTotalRows, 10); @@ -154,67 +149,39 @@ export const init = ({ }, ]; - if (totalRowCount <= defaultPageSize) { - // There are fewer than the default page count numbers of rows. - showCountLink.classList.add('hidden'); - if (checkCountButton) { checkCountButton.classList.add('hidden'); } } else if (totalRowCount <= currentPageSize) { // The are fewer than the current page size. - pageCountStrings.push({ - key: 'showperpage', - component: 'core', - param: defaultPageSize, - }); - pageCountStrings.push({ key: 'selectalluserswithcount', component: 'core', param: defaultPageSize, }); - // Show the 'Show [x]' link. - showCountLink.classList.remove('hidden'); - showCountLink.dataset.targetPageSize = defaultPageSize; - if (checkCountButton) { // The 'Check all [x]' button is only visible when there are values to set. checkCountButton.classList.add('hidden'); } } else { - pageCountStrings.push({ - key: 'showall', - component: 'core', - param: totalRowCount, - }); - pageCountStrings.push({ key: 'selectalluserswithcount', component: 'core', param: totalRowCount, }); - // Show both the 'Show [x]' link, and the 'Check all [x]' button. - showCountLink.classList.remove('hidden'); - showCountLink.dataset.targetPageSize = totalRowCount; - if (checkCountButton) { checkCountButton.classList.remove('hidden'); } } Str.get_strings(pageCountStrings) - .then(([showingParticipantCountString, showCountString, selectCountString]) => { + .then(([showingParticipantCountString, selectCountString]) => { const showingParticipantCount = root.querySelector(Selectors.showCountText); showingParticipantCount.innerHTML = showingParticipantCountString; - if (showCountString) { - showCountLink.innerHTML = showCountString; - } - if (selectCountString && checkCountButton) { checkCountButton.value = selectCountString; } diff --git a/user/classes/table/participants.php b/user/classes/table/participants.php index 09823d73a59..ecbaff21526 100644 --- a/user/classes/table/participants.php +++ b/user/classes/table/participants.php @@ -195,6 +195,8 @@ class participants extends \table_sql implements dynamic_table { $this->no_sorting('groups'); } + $this->set_default_per_page(20); + $this->set_attribute('id', 'participants'); $this->countries = get_string_manager()->get_list_of_countries(true); diff --git a/user/index.php b/user/index.php index 7bf05da3eb9..a4f9648228f 100644 --- a/user/index.php +++ b/user/index.php @@ -35,7 +35,6 @@ use core_table\local\filter\integer_filter; use core_table\local\filter\string_filter; define('DEFAULT_PAGE_SIZE', 20); -define('SHOW_ALL_PAGE_SIZE', 5000); $page = optional_param('page', 0, PARAM_INT); // Which page to show. $perpage = optional_param('perpage', DEFAULT_PAGE_SIZE, PARAM_INT); // How many per page. @@ -189,7 +188,6 @@ echo html_writer::start_tag('form', [ 'id' => 'participantsform', 'data-course-id' => $course->id, 'data-table-unique-id' => $participanttable->uniqueid, - 'data-table-default-per-page' => ($perpage < DEFAULT_PAGE_SIZE) ? $perpage : DEFAULT_PAGE_SIZE, ]); echo '
'; echo ''; @@ -205,40 +203,6 @@ echo html_writer::tag( echo $participanttablehtml; -$perpageurl = new moodle_url('/user/index.php', [ - 'contextid' => $context->id, - 'id' => $course->id, -]); -$perpagesize = DEFAULT_PAGE_SIZE; -$perpagevisible = false; -$perpagestring = ''; - -if ($perpage == SHOW_ALL_PAGE_SIZE && $participanttable->totalrows > DEFAULT_PAGE_SIZE) { - $perpageurl->param('perpage', $participanttable->totalrows); - $perpagesize = SHOW_ALL_PAGE_SIZE; - $perpagevisible = true; - $perpagestring = get_string('showperpage', '', DEFAULT_PAGE_SIZE); -} else if ($participanttable->get_page_size() < $participanttable->totalrows) { - $perpageurl->param('perpage', SHOW_ALL_PAGE_SIZE); - $perpagesize = SHOW_ALL_PAGE_SIZE; - $perpagevisible = true; - $perpagestring = get_string('showall', '', $participanttable->totalrows); -} - -$perpageclasses = ''; -if (!$perpagevisible) { - $perpageclasses = 'hidden'; -} -echo $OUTPUT->container(html_writer::link( - $perpageurl, - $perpagestring, - [ - 'data-action' => 'showcount', - 'data-target-page-size' => $perpagesize, - 'class' => $perpageclasses, - ] -), [], 'showall'); - $bulkoptions = (object) [ 'uniqueid' => $participanttable->uniqueid, ]; @@ -256,7 +220,7 @@ if ($bulkoperations) { 'id' => 'checkall', 'class' => 'btn btn-secondary', 'value' => $label, - 'data-target-page-size' => $participanttable->totalrows, + 'data-target-page-size' => TABLE_SHOW_ALL_PAGE_SIZE, ]); } echo html_writer::end_tag('div');