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

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

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

Revision 3867 Revision 3971
47 # add a variable for 'dx' 47 # add a variable for 'dx'
48 # 48 #
49 my $context = main::Context($current->copy); 49 my $context = main::Context($current->copy);
50 $context->variables->add($dx=>'Real') unless ($context->variables->get($dx)); 50 $context->variables->add($dx=>'Real') unless ($context->variables->get($dx));
51 $q = bless $self->SUPER::new($formula), $class; 51 $q = bless $self->SUPER::new($formula), $class;
52 $q->{isValue} = 1; $q->{isFormula} = 1; $q->{dx} = $dx; 52 $q->{isValue} = 1; $q->{isFormula} = 1; $q->{'dx'} = $dx;
53 main::Context($current); # put back the original context; 53 main::Context($current); # put back the original context;
54 return $q; 54 return $q;
55} 55}
56 56
57sub cmp_class {'a Difference Quotient'} 57sub cmp_class {'a Difference Quotient'}
60 shift->SUPER::cmp_defaults, 60 shift->SUPER::cmp_defaults,
61 ignoreInfinity => 0, 61 ignoreInfinity => 0,
62)} 62)}
63 63
64sub cmp_postprocess { 64sub cmp_postprocess {
65 my $self = shift; my $ans = shift; my $dx = $self->{dx}; 65 my $self = shift; my $ans = shift; my $dx = $self->{'dx'};
66 return if $ans->{score} == 0 || $ans->{isPreview}; 66 return if $ans->{score} == 0 || $ans->{isPreview};
67 $main::__student_value__ = $ans->{student_value}; 67 $main::__student_value__ = $ans->{student_value};
68 my ($value,$err) = main::PG_restricted_eval('$__student_value__->substitute('.$dx.'=>0)->reduce'); 68 my ($value,$err) = main::PG_restricted_eval('$__student_value__->substitute(\''.$dx.'\'=>0)->reduce');
69 $self->cmp_Error($ans,"It looks like you didn't finish simplifying your answer") 69 $self->cmp_Error($ans,"It looks like you didn't finish simplifying your answer")
70 if $err && $err =~ m/division by zero/i; 70 if $err && $err =~ m/division by zero/i;
71} 71}
72 72

Legend:
Removed from v.3867  
changed lines
  Added in v.3971

aubreyja at gmail dot com
ViewVC Help
Powered by ViewVC 1.0.9