[system] / trunk / pg / macros / parserFormulaUpToConstant.pl Repository:
ViewVC logotype

Diff of /trunk/pg/macros/parserFormulaUpToConstant.pl

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 5904 Revision 5905
1################################################################################ 1################################################################################
2# WeBWorK Online Homework Delivery System 2# WeBWorK Online Homework Delivery System
3# Copyright 2000-2007 The WeBWorK Project, http://openwebwork.sf.net/ 3# Copyright 2000-2007 The WeBWorK Project, http://openwebwork.sf.net/
4# $CVSHeader: pg/macros/parserFormulaUpToConstant.pl,v 1.11.2.1 2008/06/24 00:44:54 gage Exp $ 4# $CVSHeader: pg/macros/parserFormulaUpToConstant.pl,v 1.13 2008/09/11 17:26:57 dpvc Exp $
5# 5#
6# This program is free software; you can redistribute it and/or modify it under 6# This program is free software; you can redistribute it and/or modify it under
7# the terms of either: (a) the GNU General Public License as published by the 7# the terms of either: (a) the GNU General Public License as published by the
8# Free Software Foundation; either version 2, or (at your option) any later 8# Free Software Foundation; either version 2, or (at your option) any later
9# version, or (b) the "Artistic License" which comes with this package. 9# version, or (b) the "Artistic License" which comes with this package.
212 $self->cmp_Error($ans,"Note: there is always more than one posibility") if $result == 2 || $result == 3; 212 $self->cmp_Error($ans,"Note: there is always more than one posibility") if $result == 2 || $result == 3;
213 if ($result == 3) { 213 if ($result == 3) {
214 my $context = $self->context; 214 my $context = $self->context;
215 $context->flags->set(no_parameters=>0); 215 $context->flags->set(no_parameters=>0);
216 $context->variables->add(x00=>'Real'); 216 $context->variables->add(x00=>'Real');
217 $result = 1 if $self->removeConstant+"n01+n00x00" == $student+"x00"; # must use both parameters 217 my $correct = $self->removeConstant+"n01+n00x00"; # must use both parameters
218 $main::{_cmp_} = sub {return $correct == $student+"x00"}; # a closure to access local variables
219 $result = 1 if main::PG_restricted_eval('&{$main::{_cmp_}}'); # prevents domain errors (and other errors)
220 delete $main::{_cmp_}; # remove temprary function
218 $context->variables->remove('x00'); 221 $context->variables->remove('x00');
219 $context->flags->set(no_parameters=>1); 222 $context->flags->set(no_parameters=>1);
220 } 223 }
221 $self->cmp_Error($ans,"Your answer is not the most general solution") if $result == 1; 224 $self->cmp_Error($ans,"Your answer is not the most general solution") if $result == 1;
222 $self->cmp_Error($ans,"Your formula should be linear in the constant '$student->{constant}'") 225 $self->cmp_Error($ans,"Your formula should be linear in the constant '$student->{constant}'")

Legend:
Removed from v.5904  
changed lines
  Added in v.5905

aubreyja at gmail dot com
ViewVC Help
Powered by ViewVC 1.0.9