Skip to content

Commit

Permalink
MDL-82657 qbank_managecategories: Check "includesubcategories" on reload
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
marxjohnson committed Nov 26, 2024
1 parent 485130d commit 4913565
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 4 deletions.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,18 @@ export default class extends GenericFilter {
includeSubcategories: 'input[name=category-subcategories]',
};

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

async addSubcategoryCheckbox(checked = false) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,3 +107,6 @@ Feature: A teacher can put questions in categories in the question bank
When I set the field "Also show questions from subcategories" to "1"
And I click on "Apply filters" "button"
Then I should see "Question 1" in the "categoryquestions" "table"
When I reload the page
Then I should see "Question 1" in the "categoryquestions" "table"
And the field "Also show questions from subcategories" matches value "1"

0 comments on commit 4913565

Please sign in to comment.