diff --git a/lib/classes/plugin_manager.php b/lib/classes/plugin_manager.php index 63dc85a4eae..8b75ead7947 100644 --- a/lib/classes/plugin_manager.php +++ b/lib/classes/plugin_manager.php @@ -1951,6 +1951,7 @@ class core_plugin_manager { 'qbank' => [ 'bulkmove', + 'columnsortorder', 'comment', 'customfields', 'deletequestion', diff --git a/question/bank/columnsortorder/amd/build/sort_columns.min.js.map b/question/bank/columnsortorder/amd/build/sort_columns.min.js.map index 92220218039..998848cbbc7 100644 --- a/question/bank/columnsortorder/amd/build/sort_columns.min.js.map +++ b/question/bank/columnsortorder/amd/build/sort_columns.min.js.map @@ -1 +1 @@ -{"version":3,"file":"sort_columns.min.js","sources":["../src/sort_columns.js"],"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 * Javascript for sorting columns in question bank view.\n *\n * @copyright 2021 Catalyst IT Australia Pty Ltd\n * @author Ghaly Marc-Alexandre \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\nimport {call as fetchMany} from 'core/ajax';\nimport {exception as displayException} from 'core/notification';\nimport SortableList from 'core/sortable_list';\nimport jQuery from 'jquery';\n\n/**\n * Sets up sortable list in the column sort order page.\n * @param {Element} listRoot\n */\nconst setupSortableLists = (listRoot) => {\n new SortableList(\n '.list',\n {\n moveHandlerSelector: '.item',\n }\n );\n\n jQuery('.item').on(SortableList.EVENTS.DROP, () => {\n const columns = getColumnOrder(listRoot);\n setOrder(columns).catch(displayException);\n listRoot.querySelectorAll('.item').forEach(item => item.classList.remove('active'));\n });\n\n jQuery('.item').on(SortableList.EVENTS.DRAGSTART, (event) => {\n event.currentTarget.classList.add('active');\n });\n};\n\n/**\n * Call external function set_order - inserts the updated column in the config_plugins table.\n *\n * @param {String} columns String that contains column order.\n * @returns {Promise}\n */\nconst setOrder = columns => fetchMany([{\n methodname: 'qbank_columnsortorder_set_columnbank_order',\n args: {columns: columns},\n }])[0];\n\n/**\n * Gets the newly reordered columns to display in the question bank view.\n * @param {Element} listRoot\n * @returns {Array}\n */\nconst getColumnOrder = (listRoot) => {\n const columns = Array.from(listRoot.querySelectorAll('[data-pluginname]')).map(column => column.dataset.pluginname);\n\n return columns.filter((value, index) => columns.indexOf(value) === index);\n};\n\n/**\n * Initialize module\n * @param {int} id unique id for columns.\n */\nexport const init = (id) => {\n const listRoot = document.querySelector(`#${id}`);\n setupSortableLists(listRoot);\n};\n"],"names":["setOrder","columns","methodname","args","getColumnOrder","listRoot","Array","from","querySelectorAll","map","column","dataset","pluginname","filter","value","index","indexOf","id","SortableList","moveHandlerSelector","on","EVENTS","DROP","catch","displayException","forEach","item","classList","remove","DRAGSTART","event","currentTarget","add","setupSortableLists","document","querySelector"],"mappings":";;;;;;;sLAyDMA,SAAWC,UAAW,cAAU,CAAC,CAC/BC,WAAY,6CACZC,KAAM,CAACF,QAASA,YAChB,GAOFG,eAAkBC,iBACdJ,QAAUK,MAAMC,KAAKF,SAASG,iBAAiB,sBAAsBC,KAAIC,QAAUA,OAAOC,QAAQC,oBAEjGX,QAAQY,QAAO,CAACC,MAAOC,QAAUd,QAAQe,QAAQF,SAAWC,uBAOlDE,KA7COZ,CAAAA,eACpBa,uBACA,QACA,CACIC,oBAAqB,8BAItB,SAASC,GAAGF,uBAAaG,OAAOC,MAAM,WACnCrB,QAAUG,eAAeC,UAC/BL,SAASC,SAASsB,MAAMC,yBACxBnB,SAASG,iBAAiB,SAASiB,SAAQC,MAAQA,KAAKC,UAAUC,OAAO,mCAGtE,SAASR,GAAGF,uBAAaG,OAAOQ,WAAYC,QAC/CA,MAAMC,cAAcJ,UAAUK,IAAI,cAgCtCC,CADiBC,SAASC,yBAAkBlB"} \ No newline at end of file +{"version":3,"file":"sort_columns.min.js","sources":["../src/sort_columns.js"],"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 * Javascript for sorting columns in question bank view.\n *\n * @copyright 2021 Catalyst IT Australia Pty Ltd\n * @author Ghaly Marc-Alexandre \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\nimport {call as fetchMany} from 'core/ajax';\nimport {exception as displayException} from 'core/notification';\nimport SortableList from 'core/sortable_list';\nimport jQuery from 'jquery';\n\n/**\n * Sets up sortable list in the column sort order page.\n * @param {Element} listRoot\n */\nconst setupSortableLists = (listRoot) => {\n new SortableList('.list', {\n moveHandlerSelector: '.item',\n });\n\n jQuery('.item').on(SortableList.EVENTS.DROP, () => {\n const columns = getColumnOrder(listRoot);\n setOrder(columns).catch(displayException);\n listRoot.querySelectorAll('.item').forEach(item => item.classList.remove('active'));\n });\n\n jQuery('.item').on(SortableList.EVENTS.DRAGSTART, (event) => {\n event.currentTarget.classList.add('active');\n });\n};\n\n/**\n * Call external function set_order - inserts the updated column in the config_plugins table.\n *\n * @param {String} columns String that contains column order.\n * @returns {Promise}\n */\nconst setOrder = columns => fetchMany([{\n methodname: 'qbank_columnsortorder_set_columnbank_order',\n args: {columns},\n}])[0];\n\n/**\n * Gets the newly reordered columns to display in the question bank view.\n * @param {Element} listRoot\n * @returns {Array}\n */\nconst getColumnOrder = listRoot => {\n const columns = Array.from(listRoot.querySelectorAll('[data-pluginname]'))\n .map(column => column.dataset.pluginname);\n\n return columns.filter((value, index) => columns.indexOf(value) === index);\n};\n\n/**\n * Initialize module\n * @param {String} id unique id for columns.\n */\nexport const init = id => {\n const listRoot = document.querySelector(`#${id}`);\n setupSortableLists(listRoot);\n};\n"],"names":["setOrder","columns","methodname","args","getColumnOrder","listRoot","Array","from","querySelectorAll","map","column","dataset","pluginname","filter","value","index","indexOf","id","SortableList","moveHandlerSelector","on","EVENTS","DROP","catch","displayException","forEach","item","classList","remove","DRAGSTART","event","currentTarget","add","setupSortableLists","document","querySelector"],"mappings":";;;;;;;sLAsDMA,SAAWC,UAAW,cAAU,CAAC,CACnCC,WAAY,6CACZC,KAAM,CAACF,QAAAA,YACP,GAOEG,eAAiBC,iBACbJ,QAAUK,MAAMC,KAAKF,SAASG,iBAAiB,sBAChDC,KAAIC,QAAUA,OAAOC,QAAQC,oBAE3BX,QAAQY,QAAO,CAACC,MAAOC,QAAUd,QAAQe,QAAQF,SAAWC,uBAOnDE,KA3CQZ,CAAAA,eACpBa,uBAAa,QAAS,CACtBC,oBAAqB,8BAGlB,SAASC,GAAGF,uBAAaG,OAAOC,MAAM,WACnCrB,QAAUG,eAAeC,UAC/BL,SAASC,SAASsB,MAAMC,yBACxBnB,SAASG,iBAAiB,SAASiB,SAAQC,MAAQA,KAAKC,UAAUC,OAAO,mCAGtE,SAASR,GAAGF,uBAAaG,OAAOQ,WAAYC,QAC/CA,MAAMC,cAAcJ,UAAUK,IAAI,cAiCtCC,CADiBC,SAASC,yBAAkBlB"} \ No newline at end of file diff --git a/question/bank/columnsortorder/amd/src/sort_columns.js b/question/bank/columnsortorder/amd/src/sort_columns.js index bb65ac8e53b..3e2859bef6f 100644 --- a/question/bank/columnsortorder/amd/src/sort_columns.js +++ b/question/bank/columnsortorder/amd/src/sort_columns.js @@ -31,12 +31,9 @@ import jQuery from 'jquery'; * @param {Element} listRoot */ const setupSortableLists = (listRoot) => { - new SortableList( - '.list', - { - moveHandlerSelector: '.item', - } - ); + new SortableList('.list', { + moveHandlerSelector: '.item', + }); jQuery('.item').on(SortableList.EVENTS.DROP, () => { const columns = getColumnOrder(listRoot); @@ -56,26 +53,27 @@ const setupSortableLists = (listRoot) => { * @returns {Promise} */ const setOrder = columns => fetchMany([{ - methodname: 'qbank_columnsortorder_set_columnbank_order', - args: {columns: columns}, - }])[0]; + methodname: 'qbank_columnsortorder_set_columnbank_order', + args: {columns}, +}])[0]; /** * Gets the newly reordered columns to display in the question bank view. * @param {Element} listRoot * @returns {Array} */ -const getColumnOrder = (listRoot) => { - const columns = Array.from(listRoot.querySelectorAll('[data-pluginname]')).map(column => column.dataset.pluginname); +const getColumnOrder = listRoot => { + const columns = Array.from(listRoot.querySelectorAll('[data-pluginname]')) + .map(column => column.dataset.pluginname); return columns.filter((value, index) => columns.indexOf(value) === index); }; /** * Initialize module - * @param {int} id unique id for columns. + * @param {String} id unique id for columns. */ -export const init = (id) => { +export const init = id => { const listRoot = document.querySelector(`#${id}`); setupSortableLists(listRoot); }; diff --git a/question/bank/columnsortorder/classes/external/set_columnbank_order.php b/question/bank/columnsortorder/classes/external/set_columnbank_order.php index 0eb87901236..cf2fcc2f73d 100644 --- a/question/bank/columnsortorder/classes/external/set_columnbank_order.php +++ b/question/bank/columnsortorder/classes/external/set_columnbank_order.php @@ -17,13 +17,11 @@ namespace qbank_columnsortorder\external; use context_system; -use Exception; use external_api; use external_function_parameters; use external_multiple_structure; use external_value; use qbank_columnsortorder\column_manager; -use stdClass; /** * External qbank_columnsortorder_set_columnbank_order API diff --git a/question/bank/columnsortorder/classes/output/renderer.php b/question/bank/columnsortorder/classes/output/renderer.php index c2b2cee0310..76354228944 100644 --- a/question/bank/columnsortorder/classes/output/renderer.php +++ b/question/bank/columnsortorder/classes/output/renderer.php @@ -16,10 +16,9 @@ namespace qbank_columnsortorder\output; -use qbank_columnsortorder\column_manager; -use html_writer; use moodle_url; use plugin_renderer_base; +use qbank_columnsortorder\column_manager; /** * Class renderer.