Skip to content

Commit 4913565

Browse files
committed
MDL-82657 qbank_managecategories: Check "includesubcategories" on reload
The "includesubcategories" parameter is passed in the URL as lowercase, but the Javascript was looking for "includeSubcategories" in camel case. This meant it was always being set as false (unchecked) even when the URL said it was true. This fixes the casing in the Javascript, and adds a behat test to confirm the fix.
1 parent 485130d commit 4913565

File tree

4 files changed

+16
-4
lines changed

4 files changed

+16
-4
lines changed

question/bank/managecategories/amd/build/datafilter/filtertypes/categories.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

question/bank/managecategories/amd/build/datafilter/filtertypes/categories.min.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

question/bank/managecategories/amd/src/datafilter/filtertypes/categories.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,18 @@ export default class extends GenericFilter {
3131
includeSubcategories: 'input[name=category-subcategories]',
3232
};
3333

34-
constructor(filterType, rootNode, initialValues, filterOptions = {includeSubcategories: false}) {
34+
/**
35+
* Construct a new categoires filter
36+
*
37+
* @param {String} filterType The type of filter that this relates to (categories)
38+
* @param {HTMLElement} rootNode The root node for the participants filterset
39+
* @param {Array} initialValues The currently selected category IDs.
40+
* @param {Object} filterOptions An object containing the additional options for the filter, currently "includesubcategories"
41+
* is supported, which if true will display the "Also show questions from subcategories" checkbox as checked.
42+
*/
43+
constructor(filterType, rootNode, initialValues, filterOptions = {includesubcategories: false}) {
3544
super(filterType, rootNode, initialValues);
36-
this.addSubcategoryCheckbox(filterOptions.includeSubcategories);
45+
this.addSubcategoryCheckbox(filterOptions.includesubcategories);
3746
}
3847

3948
async addSubcategoryCheckbox(checked = false) {

question/bank/managecategories/tests/behat/question_categories.feature

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,3 +107,6 @@ Feature: A teacher can put questions in categories in the question bank
107107
When I set the field "Also show questions from subcategories" to "1"
108108
And I click on "Apply filters" "button"
109109
Then I should see "Question 1" in the "categoryquestions" "table"
110+
When I reload the page
111+
Then I should see "Question 1" in the "categoryquestions" "table"
112+
And the field "Also show questions from subcategories" matches value "1"

0 commit comments

Comments
 (0)