Skip to content
Snippets Groups Projects
Commit 4126d47d authored by Matti Harjula's avatar Matti Harjula
Browse files

Fix the stackjson_stringify() function to not escape strings and to deal with

the unexpected behaviour of simplode() when the list is empty. This fix will
break those very few questions that use this feature. But better do this now
than latter.
parent da45b293
No related branches found
No related tags found
No related merge requests found
......@@ -807,6 +807,10 @@ function xmldb_qtype_stack_upgrade($oldversion) {
upgrade_plugin_savepoint(true, 2018120500, 'qtype', 'stack');
}
if ($oldversion < 2019041600) {
upgrade_plugin_savepoint(true, 2019041600, 'qtype', 'stack');
}
// Add new upgrade blocks just above here.
// Check the version of the Maxima library code that comes with this version
......
......@@ -2920,4 +2920,4 @@ load(linearalgebra);
/* Stack expects some output with the version number the output happens at */
/* maximalocal.mac after additional library loading */
stackmaximaversion:2018080600$
stackmaximaversion:2019041600$
......@@ -223,12 +223,13 @@ stackjson_stringify(obj) := block([tmp,r,l],
tmp:ssubst("\\n",ascii(10),tmp),
tmp:ssubst("\\f",ascii(12),tmp),
tmp:ssubst("\\r",ascii(13),tmp),
r:sconcat("\\\"",tmp,"\\\"")
r:sconcat("\"",tmp,"\"")
) else if is_stackmap(obj) then (
l:[],
for tmp in stackmap_keys(obj) do l:append(l,[sconcat(stackjson_stringify(tmp),":",stackjson_stringify(stackmap_get(obj,tmp)))]),
r:sconcat("{",simplode(l,","),"}")
) else if listp(obj) then r:sconcat("[",simplode(makelist(stackjson_stringify(x),x,obj),","),"]")
) else if listp(obj) and length(obj) > 0 then r:sconcat("[",simplode(makelist(stackjson_stringify(x),x,obj),","),"]")
else if listp(obj) then r:"[]"
else if integerp(obj) then r:string(obj)
else if numberp(obj) then r:string(float(obj))
else r:stackjson_stringify(string(obj)),
......
......@@ -24,7 +24,7 @@
defined('MOODLE_INTERNAL') || die();
$plugin->version = 2018120500;
$plugin->version = 2019041600;
$plugin->requires = 2015111600;
$plugin->cron = 0;
$plugin->component = 'qtype_stack';
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment