File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -2201,10 +2201,13 @@ Scope.prototype = /** @lends Numbas.jme.Scope.prototype */ {
22012201 *
22022202 * @param {string } name
22032203 */
2204- deleteVariable : function ( name ) {
2204+ deleteVariable : function ( name , options ) {
2205+ options = options || { } ;
22052206 name = jme . normaliseName ( name , this ) ;
22062207 this . deleted . variables [ name ] = true ;
2207- this . deleted . constants [ name ] = true ;
2208+ if ( options . delete_constant !== false ) {
2209+ this . deleted . constants [ name ] = true ;
2210+ }
22082211 } ,
22092212 /** Mark the given function name as deleted from the scope.
22102213 *
@@ -2544,7 +2547,7 @@ Scope.prototype = /** @lends Numbas.jme.Scope.prototype */ {
25442547 var s = new Scope ( [ this ] ) ;
25452548 if ( defs . variables ) {
25462549 defs . variables . forEach ( function ( v ) {
2547- s . deleteVariable ( v ) ;
2550+ s . deleteVariable ( v , { delete_constant : false } ) ;
25482551 } ) ;
25492552 }
25502553 if ( defs . functions ) {
Original file line number Diff line number Diff line change @@ -288,6 +288,7 @@ JMEPart.prototype = /** @lends Numbas.JMEPart.prototype */
288288 if ( ! tree && this . marks > 0 ) {
289289 this . error ( 'part.jme.answer missing' ) ;
290290 }
291+ scope = scope . unset ( this . question . local_definitions ) ;
291292 var expr = jme . display . treeToJME ( tree , { plaindecimal : true } , scope ) ;
292293 settings . correctVariables = jme . findvars ( jme . compile ( expr ) , [ ] , scope ) ;
293294 settings . correctAnswer = jme . display . simplifyExpression (
You can’t perform that action at this time.
0 commit comments