MDL-84146 question: Improve handling of JS parameters

This commit is contained in:
Mark Johnson
2025-02-04 02:34:28 +00:00
committed by Jenkins
parent 595db30261
commit c968ab77be
5 changed files with 22 additions and 11 deletions
+1 -1
View File
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+4 -5
View File
@@ -40,8 +40,8 @@ import Fragment from 'core/fragment';
* @param {string} callback Name of the callback for the fragment API (e.g question_data)
* @param {string} view The class name of the question bank view class used for this page.
* @param {Number} cmid If we are in an activitiy, the course module ID.
* @param {string} pagevars JSON-encoded parameters from passed from the view, including filters and jointype.
* @param {string} extraparams JSON-encoded additional parameters specific to this view class, used for re-rendering the view.
* @param {Object} pagevars JSON-encoded parameters from passed from the view, including filters and jointype.
* @param {Object} extraparams JSON-encoded additional parameters specific to this view class, used for re-rendering the view.
*/
export const init = (
filterRegionId,
@@ -55,7 +55,7 @@ export const init = (
view,
cmid,
pagevars,
extraparams
extraparams,
) => {
const SELECTORS = {
@@ -73,7 +73,7 @@ export const init = (
const filterSet = document.querySelector(`#${filterRegionId}`);
const viewData = {
extraparams,
extraparams: JSON.stringify(extraparams),
cmid,
view,
cat: defaultcategoryid,
@@ -215,7 +215,6 @@ export const init = (
});
// Run apply filter at page load.
pagevars = JSON.parse(pagevars);
let initialFilters;
let jointype = null;
if (pagevars.filter) {
@@ -134,7 +134,7 @@ class question_bank_filter_ui extends datafilter {
'quizcmid' => $this->extraparams['quizcmid'] ?? $this->cmid,
'component' => $this->component,
'callback' => $this->callback,
'view' => str_replace('\\', '\\\\', $this->view),
'view' => $this->view,
'cmid' => $this->cmid ?? 0,
'pagevars' => json_encode($this->pagevars),
'extraparams' => json_encode($this->extraparams),
@@ -29,7 +29,7 @@
"quizcmid": "4",
"component": "core_quiz",
"callback": "get_question_data",
"view": "\\\\core\\\\question\\\\local\\\\bank\\\\view",
"view": "\\core\\question\\local\\bank\\view",
"cmid": "4",
"pagevars": "[]",
"extraparams": "[]"
@@ -42,7 +42,19 @@
{{#js}}
require(['core_question/filter'], function(Filter) {
Filter.init('core-filter-{{uniqid}}', {{courseid}}, {{categoryid}}, {{perpage}}, {{contextid}}, {{quizcmid}},
'{{component}}', '{{callback}}', '{{view}}', {{cmid}}, '{{{pagevars}}}', '{{{extraparams}}}');
Filter.init(
{{#quote}}core-filter-{{uniqid}}{{/quote}},
{{courseid}},
{{categoryid}},
{{perpage}},
{{contextid}},
{{quizcmid}},
{{#quote}}{{component}}{{/quote}},
{{#quote}}{{callback}}{{/quote}},
{{#quote}}{{view}}{{/quote}},
{{cmid}},
{{{pagevars}}},
{{{extraparams}}},
);
});
{{/js}}