mirror of
https://github.com/moodle/moodle.git
synced 2025-01-19 06:18:28 +01:00
MDL-82401 quiz: editing modals must be removed on close
This commit is contained in:
parent
7d7a871edd
commit
48eec50590
2
mod/quiz/amd/build/add_question_modal.min.js
vendored
2
mod/quiz/amd/build/add_question_modal.min.js
vendored
@ -5,6 +5,6 @@ define("mod_quiz/add_question_modal",["exports","core/modal"],(function(_exports
|
||||
* @module mod_quiz/add_question_modal
|
||||
* @copyright 2023 Andrew Lyons <andrew@nicols.co.uk>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.default=void 0,_modal=(obj=_modal)&&obj.__esModule?obj:{default:obj};class AddQuestionModal extends _modal.default{configure(modalConfig){modalConfig.large=!0,modalConfig.show=!0,this.setContextId(modalConfig.contextId),this.setAddOnPageId(modalConfig.addOnPage),super.configure(modalConfig)}constructor(root){super(root),this.contextId=null,this.addOnPageId=null}setContextId(id){this.contextId=id}getContextId(){return this.contextId}setAddOnPageId(id){this.addOnPageId=id}getAddOnPageId(){return this.addOnPageId}}return _exports.default=AddQuestionModal,_exports.default}));
|
||||
*/Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.default=void 0,_modal=(obj=_modal)&&obj.__esModule?obj:{default:obj};class AddQuestionModal extends _modal.default{configure(modalConfig){modalConfig.large=!0,modalConfig.show=!0,modalConfig.removeOnClose=!0,this.setContextId(modalConfig.contextId),this.setAddOnPageId(modalConfig.addOnPage),super.configure(modalConfig)}constructor(root){super(root),this.contextId=null,this.addOnPageId=null}setContextId(id){this.contextId=id}getContextId(){return this.contextId}setAddOnPageId(id){this.addOnPageId=id}getAddOnPageId(){return this.addOnPageId}}return _exports.default=AddQuestionModal,_exports.default}));
|
||||
|
||||
//# sourceMappingURL=add_question_modal.min.js.map
|
@ -1 +1 @@
|
||||
{"version":3,"file":"add_question_modal.min.js","sources":["../src/add_question_modal.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 <http://www.gnu.org/licenses/>.\n\n/**\n * Contain the logic for the add random question modal.\n *\n * @module mod_quiz/add_question_modal\n * @copyright 2023 Andrew Lyons <andrew@nicols.co.uk>\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\nimport Modal from 'core/modal';\n\nexport default class AddQuestionModal extends Modal {\n configure(modalConfig) {\n // Add question modals are always large.\n modalConfig.large = true;\n\n // Always show on creation.\n modalConfig.show = true;\n\n // Apply question modal configuration.\n this.setContextId(modalConfig.contextId);\n this.setAddOnPageId(modalConfig.addOnPage);\n\n // Apply standard configuration.\n super.configure(modalConfig);\n }\n\n constructor(root) {\n super(root);\n\n this.contextId = null;\n this.addOnPageId = null;\n }\n\n /**\n * Save the Moodle context id that the question bank is being\n * rendered in.\n *\n * @method setContextId\n * @param {Number} id\n */\n setContextId(id) {\n this.contextId = id;\n }\n\n /**\n * Retrieve the saved Moodle context id.\n *\n * @method getContextId\n * @return {Number}\n */\n getContextId() {\n return this.contextId;\n }\n\n /**\n * Set the id of the page that the question should be added to\n * when the user clicks the add to quiz link.\n *\n * @method setAddOnPageId\n * @param {Number} id\n */\n setAddOnPageId(id) {\n this.addOnPageId = id;\n }\n\n /**\n * Returns the saved page id for the question to be added to.\n *\n * @method getAddOnPageId\n * @return {Number}\n */\n getAddOnPageId() {\n return this.addOnPageId;\n }\n\n}\n"],"names":["AddQuestionModal","Modal","configure","modalConfig","large","show","setContextId","contextId","setAddOnPageId","addOnPage","constructor","root","addOnPageId","id","getContextId","this","getAddOnPageId"],"mappings":";;;;;;;iJAyBqBA,yBAAyBC,eAC1CC,UAAUC,aAENA,YAAYC,OAAQ,EAGpBD,YAAYE,MAAO,OAGdC,aAAaH,YAAYI,gBACzBC,eAAeL,YAAYM,iBAG1BP,UAAUC,aAGpBO,YAAYC,YACFA,WAEDJ,UAAY,UACZK,YAAc,KAUvBN,aAAaO,SACJN,UAAYM,GASrBC,sBACWC,KAAKR,UAUhBC,eAAeK,SACND,YAAcC,GASvBG,wBACWD,KAAKH"}
|
||||
{"version":3,"file":"add_question_modal.min.js","sources":["../src/add_question_modal.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 <http://www.gnu.org/licenses/>.\n\n/**\n * Contain the logic for the add random question modal.\n *\n * @module mod_quiz/add_question_modal\n * @copyright 2023 Andrew Lyons <andrew@nicols.co.uk>\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\nimport Modal from 'core/modal';\n\nexport default class AddQuestionModal extends Modal {\n configure(modalConfig) {\n // Add question modals are always large.\n modalConfig.large = true;\n\n // Always show on creation.\n modalConfig.show = true;\n modalConfig.removeOnClose = true;\n\n // Apply question modal configuration.\n this.setContextId(modalConfig.contextId);\n this.setAddOnPageId(modalConfig.addOnPage);\n\n // Apply standard configuration.\n super.configure(modalConfig);\n }\n\n constructor(root) {\n super(root);\n\n this.contextId = null;\n this.addOnPageId = null;\n }\n\n /**\n * Save the Moodle context id that the question bank is being\n * rendered in.\n *\n * @method setContextId\n * @param {Number} id\n */\n setContextId(id) {\n this.contextId = id;\n }\n\n /**\n * Retrieve the saved Moodle context id.\n *\n * @method getContextId\n * @return {Number}\n */\n getContextId() {\n return this.contextId;\n }\n\n /**\n * Set the id of the page that the question should be added to\n * when the user clicks the add to quiz link.\n *\n * @method setAddOnPageId\n * @param {Number} id\n */\n setAddOnPageId(id) {\n this.addOnPageId = id;\n }\n\n /**\n * Returns the saved page id for the question to be added to.\n *\n * @method getAddOnPageId\n * @return {Number}\n */\n getAddOnPageId() {\n return this.addOnPageId;\n }\n\n}\n"],"names":["AddQuestionModal","Modal","configure","modalConfig","large","show","removeOnClose","setContextId","contextId","setAddOnPageId","addOnPage","constructor","root","addOnPageId","id","getContextId","this","getAddOnPageId"],"mappings":";;;;;;;iJAyBqBA,yBAAyBC,eAC1CC,UAAUC,aAENA,YAAYC,OAAQ,EAGpBD,YAAYE,MAAO,EACnBF,YAAYG,eAAgB,OAGvBC,aAAaJ,YAAYK,gBACzBC,eAAeN,YAAYO,iBAG1BR,UAAUC,aAGpBQ,YAAYC,YACFA,WAEDJ,UAAY,UACZK,YAAc,KAUvBN,aAAaO,SACJN,UAAYM,GASrBC,sBACWC,KAAKR,UAUhBC,eAAeK,SACND,YAAcC,GASvBG,wBACWD,KAAKH"}
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -30,6 +30,7 @@ export default class AddQuestionModal extends Modal {
|
||||
|
||||
// Always show on creation.
|
||||
modalConfig.show = true;
|
||||
modalConfig.removeOnClose = true;
|
||||
|
||||
// Apply question modal configuration.
|
||||
this.setContextId(modalConfig.contextId);
|
||||
|
@ -101,6 +101,8 @@ export default class ModalAddRandomQuestion extends Modal {
|
||||
}
|
||||
|
||||
configure(modalConfig) {
|
||||
modalConfig.removeOnClose = true;
|
||||
|
||||
this.setCategory(modalConfig.category);
|
||||
this.setReturnUrl(modalConfig.returnUrl);
|
||||
this.setCMID(modalConfig.cmid);
|
||||
|
@ -81,6 +81,26 @@ Feature: Adding questions to a quiz from the question bank
|
||||
And I should see "Feature question 5"
|
||||
And I should see "Feature question 9"
|
||||
|
||||
Scenario: After closing and reopening the modal, it still works
|
||||
Given the following "question categories" exist:
|
||||
| contextlevel | reference | name |
|
||||
| Course | C1 | My collection |
|
||||
And the following "question" exists:
|
||||
| questioncategory | My collection |
|
||||
| qtype | essay |
|
||||
| name | Feature question |
|
||||
| questiontext | Write about topic |
|
||||
| user | teacher1 |
|
||||
When I am on the "Quiz 1" "mod_quiz > Edit" page logged in as teacher1
|
||||
And I open the "last" add to quiz menu
|
||||
And I follow "from question bank"
|
||||
And I click on "Close" "button" in the "Add from the question bank at the end" "dialogue"
|
||||
And I open the "last" add to quiz menu
|
||||
And I follow "from question bank"
|
||||
And I set the field "Category" to "My collection"
|
||||
And I press "Apply filters"
|
||||
Then I should see "Feature question"
|
||||
|
||||
Scenario: Questions are added in the right place with multiple sections
|
||||
Given the following "questions" exist:
|
||||
| questioncategory | qtype | name | questiontext |
|
||||
|
@ -84,6 +84,18 @@ Feature: Adding random questions to a quiz based on category and tags
|
||||
And I should see "question 1 name"
|
||||
And I should see "\"listen\" & \"answer\""
|
||||
|
||||
Scenario: After closing and reopening the modal, it still works
|
||||
When I am on the "Quiz 1" "mod_quiz > Edit" page logged in as teacher1
|
||||
And I open the "last" add to quiz menu
|
||||
And I follow "a random question"
|
||||
And I click on "Close" "button" in the "Add a random question at the end" "dialogue"
|
||||
And I open the "last" add to quiz menu
|
||||
And I follow "a random question"
|
||||
And I should not see "question 3 name"
|
||||
And I set the field "Category" to "Subcategory"
|
||||
And I press "Apply filters"
|
||||
Then I should see "question 3 name"
|
||||
|
||||
Scenario: Teacher without moodle/question:useall should not see the add a random question menu item
|
||||
Given the following "permission overrides" exist:
|
||||
| capability | permission | role | contextlevel | reference |
|
||||
|
Loading…
x
Reference in New Issue
Block a user