diff --git a/runtime/scripts/jme.js b/runtime/scripts/jme.js index 470945258..191535ece 100644 --- a/runtime/scripts/jme.js +++ b/runtime/scripts/jme.js @@ -2201,10 +2201,13 @@ Scope.prototype = /** @lends Numbas.jme.Scope.prototype */ { * * @param {string} name */ - deleteVariable: function(name) { + deleteVariable: function(name, options) { + options = options || {}; name = jme.normaliseName(name, this); this.deleted.variables[name] = true; - this.deleted.constants[name] = true; + if(options.delete_constant !== false) { + this.deleted.constants[name] = true; + } }, /** Mark the given function name as deleted from the scope. * @@ -2544,7 +2547,7 @@ Scope.prototype = /** @lends Numbas.jme.Scope.prototype */ { var s = new Scope([this]); if(defs.variables) { defs.variables.forEach(function(v) { - s.deleteVariable(v); + s.deleteVariable(v, {delete_constant: false}); }); } if(defs.functions) { diff --git a/runtime/scripts/parts/jme.js b/runtime/scripts/parts/jme.js index 48021ecbe..9015dea1c 100644 --- a/runtime/scripts/parts/jme.js +++ b/runtime/scripts/parts/jme.js @@ -288,6 +288,7 @@ JMEPart.prototype = /** @lends Numbas.JMEPart.prototype */ if(!tree && this.marks>0) { this.error('part.jme.answer missing'); } + scope = scope.unset(this.question.local_definitions); var expr = jme.display.treeToJME(tree,{plaindecimal: true},scope); settings.correctVariables = jme.findvars(jme.compile(expr),[],scope); settings.correctAnswer = jme.display.simplifyExpression(