Merge branch 'MDL-76508-401' of https://github.com/meirzamoodle/moodle into MOODLE_401_STABLE

This commit is contained in:
Andrew Nicols 2023-01-05 21:30:22 +08:00
commit b24414554f
3 changed files with 17 additions and 4 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -556,9 +556,22 @@ function(
// Allow variable expansion in the param part only.
param = helper(param, context);
}
// Allow json formatted $a arguments.
if ((param.indexOf('{') === 0) && (param.indexOf('{{') !== 0)) {
param = JSON.parse(param);
// Added double quote after left curly bracket to differentiate between string and JSON string.
if (param.indexOf('{"') === 0) {
// If it can't be parsed then the string is not a JSON format.
try {
const parsedParam = JSON.parse(param);
// Handle non-exception-throwing cases, e.g. null, integer, boolean.
if (parsedParam && typeof parsedParam === "object") {
param = parsedParam;
}
} catch (err) {
// This was probably not JSON.
// Keep the error message visible.
window.console.warn(err.message);
}
}
var index = this.requiredStrings.length;