From: Mike G. v. a. <we...@ma...> - 2008-06-24 02:25:05
|
Log Message: ----------- Formatting changes Tags: ---- rel-2-4-patches Modified Files: -------------- pg: README pg/lib: AnswerHash.pm Parser.pm Value.pm pg/lib/Parser: BOP.pm Complex.pm Constant.pm Context.pm Differentiation.pm Function.pm Item.pm List.pm Number.pm String.pm UOP.pm Value.pm Variable.pm pg/lib/Parser/Context: Default.pm Parens.pm pg/lib/Parser/Legacy: NumberWithUnits.pm Numeric.pm PGcomplexmacros.pl pg/lib/Value: AnswerChecker.pm Complex.pm Context.pm Formula.pm Infinity.pm Interval.pm List.pm Matrix.pm Point.pm Real.pm Set.pm pg/lib/Value/Context: Data.pm pg/lib/WeBWorK/PG: Translator.pm pg/macros: IO.pl MathObjects.pl PG.pl PGanswermacros.pl PGauxiliaryFunctions.pl PGbasicmacros.pl PGinfo.pl Parser.pl Value.pl answerComposition.pl answerCustom.pl answerVariableList.pl contextABCD.pl contextIntegerFunctions.pl contextLimitedComplex.pl contextLimitedNumeric.pl contextLimitedPoint.pl contextLimitedPolynomial.pl contextLimitedPowers.pl contextLimitedVector.pl contextPeriodic.pl contextString.pl contextTF.pl dangerousMacros.pl displayMacros.pl parserCustomization.pl parserDifferenceQuotient.pl parserFormulaWithUnits.pl parserFunction.pl parserImplicitEquation.pl parserParametricLine.pl parserPopUp.pl parserRadioButtons.pl parserSolutionFor.pl parserVectorUtils.pl Revision Data ------------- Index: README =================================================================== RCS file: /webwork/cvs/system/pg/README,v retrieving revision 1.2.4.2 retrieving revision 1.2.4.2.2.1 diff -LREADME -LREADME -u -r1.2.4.2 -r1.2.4.2.2.1 --- README +++ README @@ -1,6 +1,6 @@ WeBWorK Program Generation Language - Version 2.4.0 + Version 2.4.5 Copyright 2000-2007, The WeBWorK Project All rights reserved. Index: AnswerHash.pm =================================================================== RCS file: /webwork/cvs/system/pg/lib/AnswerHash.pm,v retrieving revision 1.14.2.2 retrieving revision 1.14.2.2.2.1 diff -Llib/AnswerHash.pm -Llib/AnswerHash.pm -u -r1.14.2.2 -r1.14.2.2.2.1 --- lib/AnswerHash.pm +++ lib/AnswerHash.pm @@ -7,10 +7,8 @@ # Copyright @ 1995-2002 WeBWorK Team # All Rights Reserved #################################################################### - #$Id$ - =head1 NAME AnswerHash.pm -- located in the courseScripts directory Index: Value.pm =================================================================== RCS file: /webwork/cvs/system/pg/lib/Value.pm,v retrieving revision 1.53.2.3 retrieving revision 1.53.2.3.2.1 diff -Llib/Value.pm -Llib/Value.pm -u -r1.53.2.3 -r1.53.2.3.2.1 --- lib/Value.pm +++ lib/Value.pm @@ -1,7 +1,6 @@ package Value; my $pkg = 'Value'; use vars qw($context $defaultContext %Type); - use Scalar::Util; use strict; no strict "refs"; @@ -16,7 +15,6 @@ like equality are "fuzzy", meaning that two items are equal when they are "close enough" (by tolerances that are set in the current Context). - =cut @@ -196,7 +194,6 @@ push(@{$$context->{data}{values}},'method','precedence'); - # # Copy an item and its data # @@ -222,7 +219,6 @@ sub getFlag { my $self = shift; my $name = shift; - if (Value::isHash($self)) { return $self->{$name} if defined($self->{$name}); if (defined $self->{equation}) { @@ -235,11 +231,9 @@ return $context->{answerHash}{$name} if defined($context->{answerHash}) && defined($context->{answerHash}{$name}); # use WW answerHash flags first return $context->{flags}{$name} if defined($context->{flags}{$name}); - return shift; } - # # Get or set the context of an object # @@ -283,10 +277,8 @@ sub isHash { my $self = shift; return ref($self) eq 'HASH' || blessedType($self) eq 'HASH'; - } - sub subclassed { my $self = shift; my $obj = shift; my $method = shift; my $code = UNIVERSAL::can($obj,$method); @@ -311,7 +303,6 @@ # # Check if a value is a number, complex, etc. # - sub matchNumber {my $n = shift; $n =~ m/^$$Value::context->{pattern}{signedNumber}$/i} sub matchInfinite {my $n = shift; $n =~ m/^$$Value::context->{pattern}{infinite}$/i} sub isReal {classMatch(shift,'Real')} @@ -319,7 +310,6 @@ sub isContext {class(shift) eq 'Context'} sub isFormula {classMatch(shift,'Formula')} sub isParser {my $v = shift; isBlessed($v) && $v->isa('Parser::Item')} - sub isValue { my $v = shift; return (ref($v) || $v) =~ m/^Value::/ || (isHash($v) && $v->{isValue}) || isa($v,'Value'); @@ -441,22 +431,18 @@ =cut sub showClass { - my $value = shift; if (ref($value) || $value !~ m/::/) { $value = Value::makeValue($value,makeFormula=>0); return "'".$value."'" unless Value::isValue($value); } return $value->showClass(@_) if Value->subclassed($value,"showClass"); - my $class = class($value); - return showType($value) if Value::classMatch($value,'List'); $class .= ' Number' if Value::classMatch($value,'Real','Complex'); $class .= ' of Intervals' if Value::classMatch($value,'Union'); $class = ($value eq '' ? 'Empty Value' : 'Word') if Value::classMatch($value,'String'); return 'a Formula that returns '.showType($value->{tree}) if Value::isFormula($value); - return 'an '.$class if $class =~ m/^[aeio]/i; return 'a '.$class; } @@ -516,7 +502,6 @@ return 'Matrix' if $ltype =~ m/Point|Matrix/; return 'List'; } - return 'Formula' if Value::isFormula($value); return 'Infinity' if Value::classMatch($value,'Infinity'); return 'Number' if Value::isReal($value); @@ -596,10 +581,8 @@ # sub make { my $self = shift; my $class = ref($self) || $self; - my $context = (Value::isContext($_[0]) ? shift : $self->context); bless {$self->hash, data => [@_], context => $context}, $class; - } # @@ -608,7 +591,6 @@ # is not a deep copy.) # sub with { - my $self = shift; bless {%{$self},@_}, ref($self); } @@ -621,7 +603,6 @@ $self = bless {%{$self}}, ref($self); foreach my $id (@_) {delete $self->{$id} if defined $self->{$id}} return $self; - } ###################################################################### @@ -756,13 +737,10 @@ sub promotePrecedence { my $self = shift; my $other = shift; my $context = $self->context; return 0 unless Value::isValue($other); - my $sprec = $self->precedence; my $oprec = $other->precedence; - return (defined($sprec) && defined($oprec) && $sprec < $oprec); } - sub precedence {my $self = shift; return $self->context->{precedence}{$self->class}} sub promote { @@ -825,7 +803,6 @@ sub _sin {(shift)->sin} sub _cos {(shift)->cos} - # # Default stub to call when no function is defined for an operation # @@ -914,9 +891,7 @@ # sub compare_string { my ($l,$r,$flag) = @_; - $l = $l->string; $r = $r->string if Value::isValue($r); - if ($flag) {my $tmp = $l; $l = $r; $r = $tmp} return $l cmp $r; } @@ -1067,11 +1042,9 @@ =head3 Error - Usage: Value->Error("We're sorry..."); or $mathObject->Error("We're still sorry..."); - # # Report an error and die. This can be used within custom answer checkers # to report errors during the check, or when sub-classing a MathObject to @@ -1081,16 +1054,12 @@ =cut sub Error { - my $self = (UNIVERSAL::can($_[0],"getFlag") ? shift : "Value"); my $message = shift; my $context = $self->context; - $message = [$message,@_] if scalar(@_) > 0; - $context->setError($message,''); $message = $context->{error}{message}; die $message . traceback() if $self->getFlag('showTraceback'); - die $message . getCaller(); } Index: Parser.pm =================================================================== RCS file: /webwork/cvs/system/pg/lib/Parser.pm,v retrieving revision 1.32.2.2 retrieving revision 1.32.2.2.2.1 diff -Llib/Parser.pm -Llib/Parser.pm -u -r1.32.2.2 -r1.32.2.2.2.1 --- lib/Parser.pm +++ lib/Parser.pm @@ -35,7 +35,6 @@ variables => {}, values => {}, context => $context, }, $class; - if (Value::isParser($string) || Value::isFormula($string)) { my $tree = $string; $tree = $tree->{tree} if defined $tree->{tree}; $math->{tree} = $tree->copy($math); @@ -53,7 +52,6 @@ return $math; } - # # Get the object's context, or the default one # @@ -734,7 +732,6 @@ # Sets the values of variables for evaluation purposes # sub setValues { - my $self = shift; my ($xref,$value,$type); my $context = $self->context; my $variables = $context->{variables}; @@ -759,7 +756,6 @@ $v->inContext($self->context) if $v->context != $self->context; $self->{values}{$x} = $v; } - } } Index: Number.pm =================================================================== RCS file: /webwork/cvs/system/pg/lib/Parser/Number.pm,v retrieving revision 1.13.4.2 retrieving revision 1.13.4.2.2.1 diff -Llib/Parser/Number.pm -Llib/Parser/Number.pm -u -r1.13.4.2 -r1.13.4.2.2.1 --- lib/Parser/Number.pm +++ lib/Parser/Number.pm @@ -3,16 +3,13 @@ # Implements the Number class # package Parser::Number; - use strict; no strict "refs"; our @ISA = qw(Parser::Item); - $Parser::class->{Number} = 'Parser::Number'; sub new { my $self = shift; my $class = ref($self) || $self; - my $equation = shift; my $context = $equation->{context}; my ($value,$ref) = @_; return $self->Item("Complex",$context)->new($equation,$value,$ref) @@ -24,7 +21,6 @@ type => $Value::Type{number}, isConstant => 1, ref => $ref, equation => $equation, }, $class; - $num->weaken; my $x = $num->Package("Real")->make($context,$value); $num->{isOne} = 1 if $x eq 1; Index: Complex.pm =================================================================== RCS file: /webwork/cvs/system/pg/lib/Parser/Complex.pm,v retrieving revision 1.8.2.2 retrieving revision 1.8.2.2.2.1 diff -Llib/Parser/Complex.pm -Llib/Parser/Complex.pm -u -r1.8.2.2 -r1.8.2.2.2.1 --- lib/Parser/Complex.pm +++ lib/Parser/Complex.pm @@ -3,11 +3,9 @@ # Implements the Complex class # package Parser::Complex; - use strict; no strict "refs"; our @ISA = qw(Parser::Item); - $Parser::class->{Complex} = 'Parser::Complex'; sub new { @@ -22,10 +20,8 @@ value => $value, type => $Value::Type{complex}, isConstant => 1, ref => $ref, equation => $equation, }, $class; - $num->weaken; my $z = $self->Package("Complex",$context)->make($context,@{$value}); - $num->{isOne} = 1 if ($z cmp 1) == 0; $num->{isZero} = 1 if $z == 0; return $num; Index: Value.pm =================================================================== RCS file: /webwork/cvs/system/pg/lib/Parser/Value.pm,v retrieving revision 1.17.6.2 retrieving revision 1.17.6.2.2.1 diff -Llib/Parser/Value.pm -Llib/Parser/Value.pm -u -r1.17.6.2 -r1.17.6.2.2.1 --- lib/Parser/Value.pm +++ lib/Parser/Value.pm @@ -4,11 +4,9 @@ # (used to store constant Vector values, etc.) # package Parser::Value; - use strict; no strict "refs"; our @ISA = qw(Parser::Item); - $Parser::class->{Value} = 'Parser::Value'; # Index: List.pm =================================================================== RCS file: /webwork/cvs/system/pg/lib/Parser/List.pm,v retrieving revision 1.17.6.2 retrieving revision 1.17.6.2.2.1 diff -Llib/Parser/List.pm -Llib/Parser/List.pm -u -r1.17.6.2 -r1.17.6.2.2.1 --- lib/Parser/List.pm +++ lib/Parser/List.pm @@ -3,11 +3,9 @@ # Implements base List class. # package Parser::List; - use strict; no strict "refs"; our @ISA = qw(Parser::Item); - $Parser::class->{List} = 'Parser::List'; # Index: Context.pm =================================================================== RCS file: /webwork/cvs/system/pg/lib/Parser/Context.pm,v retrieving revision 1.16.2.2 retrieving revision 1.16.2.2.2.1 diff -Llib/Parser/Context.pm -Llib/Parser/Context.pm -u -r1.16.2.2 -r1.16.2.2.2.1 --- lib/Parser/Context.pm +++ lib/Parser/Context.pm @@ -2,11 +2,9 @@ package Parser::Context; my $pkg = "Parser::Context"; - use strict; no strict "refs"; our @ISA = ("Value::Context"); - # # Create a new Context object and initialize its data lists # @@ -123,8 +121,6 @@ - - # # Access to the data lists # @@ -167,17 +163,14 @@ } # - # Get a copy of a named context # (either from the (optional) list provided, the main user's list # or from the default list) # - sub getCopy { my $self = shift; my $contextTable; $contextTable = shift if !defined $_[0] || ref($_[0]) eq 'HASH'; $contextTable = $userContext unless $contextTable; - my $name = shift; my $context = $contextTable->{$name}; $context = $Parser::Context::Default::context{$name} unless $context; return unless $context; Index: Constant.pm =================================================================== RCS file: /webwork/cvs/system/pg/lib/Parser/Constant.pm,v retrieving revision 1.9.6.2 retrieving revision 1.9.6.2.2.1 diff -Llib/Parser/Constant.pm -Llib/Parser/Constant.pm -u -r1.9.6.2 -r1.9.6.2.2.1 --- lib/Parser/Constant.pm +++ lib/Parser/Constant.pm @@ -3,11 +3,9 @@ # Implements named constants (e, pi, etc.) # package Parser::Constant; - use strict; no strict "refs"; our @ISA = qw(Parser::Item); - $Parser::class->{Constant} = 'Parser::Constant'; # @@ -41,7 +39,6 @@ if (Value::isFormula($data)) { $data = $data->copy; $data->{values} = $self->{equation}{values}; - $data = $data->{tree}->eval->inContext($context); return $data; } elsif (ref($data) eq 'ARRAY') { Index: String.pm =================================================================== RCS file: /webwork/cvs/system/pg/lib/Parser/String.pm,v retrieving revision 1.11.6.2 retrieving revision 1.11.6.2.2.1 diff -Llib/Parser/String.pm -Llib/Parser/String.pm -u -r1.11.6.2 -r1.11.6.2.2.1 --- lib/Parser/String.pm +++ lib/Parser/String.pm @@ -4,11 +4,9 @@ # (Used for things like INFINITY, and so on) # package Parser::String; - use strict; no strict "refs"; our @ISA = qw(Parser::Item); - $Parser::class->{String} = 'Parser::String'; # Index: Differentiation.pm =================================================================== RCS file: /webwork/cvs/system/pg/lib/Parser/Differentiation.pm,v retrieving revision 1.9.4.2 retrieving revision 1.9.4.2.2.1 diff -Llib/Parser/Differentiation.pm -Llib/Parser/Differentiation.pm -u -r1.9.4.2 -r1.9.4.2.2.1 --- lib/Parser/Differentiation.pm +++ lib/Parser/Differentiation.pm @@ -602,7 +602,6 @@ sub Parser::List::AbsoluteValue::D { my $self = shift; my $x = $self->{coords}[0]->copy; my $equation = $self->{equation}; - my $BOP = $self->Item("BOP"); return $BOP->new($equation,"*", Index: BOP.pm =================================================================== RCS file: /webwork/cvs/system/pg/lib/Parser/BOP.pm,v retrieving revision 1.16.2.2 retrieving revision 1.16.2.2.2.1 diff -Llib/Parser/BOP.pm -Llib/Parser/BOP.pm -u -r1.16.2.2 -r1.16.2.2.2.1 --- lib/Parser/BOP.pm +++ lib/Parser/BOP.pm @@ -4,11 +4,9 @@ # package Parser::BOP; - use strict; no strict "refs"; our @ISA = qw(Parser::Item); - $Parser::class->{BOP} = 'Parser::BOP'; # Index: Variable.pm =================================================================== RCS file: /webwork/cvs/system/pg/lib/Parser/Variable.pm,v retrieving revision 1.9.2.2 retrieving revision 1.9.2.2.2.1 diff -Llib/Parser/Variable.pm -Llib/Parser/Variable.pm -u -r1.9.2.2 -r1.9.2.2.2.1 --- lib/Parser/Variable.pm +++ lib/Parser/Variable.pm @@ -3,11 +3,9 @@ # Implements named variables # package Parser::Variable; - use strict; no strict "refs"; our @ISA = qw(Parser::Item); - $Parser::class->{Variable} = 'Parser::Variable'; # @@ -29,7 +27,6 @@ $equation->Error(["Variable '%s' is not defined in this context",$name],$ref) if $variables-> {$name}{parameter} && $equation->{context}{flags}{no_parameters}; $equation->{variables}{$name} = 1; - my $def = $variables->{$name}; my $v = bless { name => $name, def => $def, type => $def->{type}, Index: Function.pm =================================================================== RCS file: /webwork/cvs/system/pg/lib/Parser/Function.pm,v retrieving revision 1.18.6.2 retrieving revision 1.18.6.2.2.1 diff -Llib/Parser/Function.pm -Llib/Parser/Function.pm -u -r1.18.6.2 -r1.18.6.2.2.1 --- lib/Parser/Function.pm +++ lib/Parser/Function.pm @@ -4,7 +4,6 @@ # package Parser::Function; - use strict; no strict "refs"; our @ISA = qw(Parser::Item); Index: Item.pm =================================================================== RCS file: /webwork/cvs/system/pg/lib/Parser/Item.pm,v retrieving revision 1.8.6.2 retrieving revision 1.8.6.2.2.1 diff -Llib/Parser/Item.pm -Llib/Parser/Item.pm -u -r1.8.6.2 -r1.8.6.2.2.1 --- lib/Parser/Item.pm +++ lib/Parser/Item.pm @@ -53,34 +53,6 @@ } # -# Get the equation context -# -sub context { - my $self = shift; - return (ref($self) ? $self->{equation}{context} : Value->context); -} - -# -# Get the package for a given Parser class -# -sub Item { - my $self = shift; my $class = shift; - my $context = (Value::isContext($_[0]) ? shift : $self->context); - return $context->{parser}{$class} if defined $context->{parser}{$class}; - return "Parser::$class" if defined @{"Parser::${class}::ISA"}; - Value::Error("No such package 'Parser::%s'",$class); -} - -# -# Same but for Value classes -# -sub Package { - my $self = shift; my $class = shift; - my $context = (Value::isContext($_[0]) ? shift : $self->context); - $context->Package($class); -} - -# # Get various type information # sub type {my $self = shift; return $self->{type}{name}} Index: UOP.pm =================================================================== RCS file: /webwork/cvs/system/pg/lib/Parser/UOP.pm,v retrieving revision 1.16.2.2 retrieving revision 1.16.2.2.2.1 diff -Llib/Parser/UOP.pm -Llib/Parser/UOP.pm -u -r1.16.2.2 -r1.16.2.2.2.1 --- lib/Parser/UOP.pm +++ lib/Parser/UOP.pm @@ -3,11 +3,9 @@ # Implements the base Unary Operator class # package Parser::UOP; - use strict; no strict "refs"; our @ISA = qw(Parser::Item); - $Parser::class->{UOP} = 'Parser::UOP'; sub new { Index: Parens.pm =================================================================== RCS file: /webwork/cvs/system/pg/lib/Parser/Context/Parens.pm,v retrieving revision 1.4.6.2 retrieving revision 1.4.6.2.2.1 diff -Llib/Parser/Context/Parens.pm -Llib/Parser/Context/Parens.pm -u -r1.4.6.2 -r1.4.6.2.2.1 --- lib/Parser/Context/Parens.pm +++ lib/Parser/Context/Parens.pm @@ -11,7 +11,6 @@ $self->{dataName} = 'parens'; $self->{name} = 'parenthesis'; $self->{Name} = 'Parenthesis'; - $self->{namePattern} = qr/\S+/; } @@ -31,7 +30,6 @@ delete $self->{tokens}{$data->{close}} unless $data->{hidden} || $data->{close} eq $token; } - # # Always retain 'start' since it si crucial to the parser # Index: Default.pm =================================================================== RCS file: /webwork/cvs/system/pg/lib/Parser/Context/Default.pm,v retrieving revision 1.37.2.2 retrieving revision 1.37.2.2.2.1 diff -Llib/Parser/Context/Default.pm -Llib/Parser/Context/Default.pm -u -r1.37.2.2 -r1.37.2.2.2.1 --- lib/Parser/Context/Default.pm +++ lib/Parser/Context/Default.pm @@ -132,7 +132,6 @@ 'e' => exp(1), 'pi' => 4*atan2(1,1), 'i' => Value::Complex->new(0,1), - 'j' => Value::Vector->new(0,1,0)->with(ijk=>1), 'k' => Value::Vector->new(0,0,1)->with(ijk=>1), '_blank_' => {value => 0, hidden => 1, string => "", TeX => ""}, Index: NumberWithUnits.pm =================================================================== RCS file: /webwork/cvs/system/pg/lib/Parser/Legacy/NumberWithUnits.pm,v retrieving revision 1.8.2.2 retrieving revision 1.8.2.2.2.1 diff -Llib/Parser/Legacy/NumberWithUnits.pm -Llib/Parser/Legacy/NumberWithUnits.pm -u -r1.8.2.2 -r1.8.2.2.2.1 --- lib/Parser/Legacy/NumberWithUnits.pm +++ lib/Parser/Legacy/NumberWithUnits.pm @@ -157,8 +157,6 @@ sub cmp_reparse {Value::cmp_parse(@_)} -sub _compare {Value::binOp(@_,'compare')} - ###################################################################### # Index: PGcomplexmacros.pl =================================================================== RCS file: /webwork/cvs/system/pg/lib/Parser/Legacy/PGcomplexmacros.pl,v retrieving revision 1.3.2.2 retrieving revision 1.3.2.2.2.1 diff -Llib/Parser/Legacy/PGcomplexmacros.pl -Llib/Parser/Legacy/PGcomplexmacros.pl -u -r1.3.2.2 -r1.3.2.2.2.1 --- lib/Parser/Legacy/PGcomplexmacros.pl +++ lib/Parser/Legacy/PGcomplexmacros.pl @@ -5,11 +5,9 @@ # Copyright @ 1995-2002 The WeBWorK Team # All Rights Reserved #################################################################### - #$Id$ - =head1 NAME Macros for complex numbers for the PG language Index: Numeric.pm =================================================================== RCS file: /webwork/cvs/system/pg/lib/Parser/Legacy/Numeric.pm,v retrieving revision 1.2.6.2 retrieving revision 1.2.6.2.2.1 diff -Llib/Parser/Legacy/Numeric.pm -Llib/Parser/Legacy/Numeric.pm -u -r1.2.6.2 -r1.2.6.2.2.1 --- lib/Parser/Legacy/Numeric.pm +++ lib/Parser/Legacy/Numeric.pm @@ -25,8 +25,6 @@ step => {class => 'Parser::Legacy::Numeric', perl => 'Parser::Legacy::Numeric::do_step'}, fact => {class => 'Parser::Legacy::Numeric', perl => 'Parser::Legacy::Numeric::do_fact'}, ); - $context->{name} = "LegacyNumeric"; 1; - Index: Real.pm =================================================================== RCS file: /webwork/cvs/system/pg/lib/Value/Real.pm,v retrieving revision 1.24.2.2 retrieving revision 1.24.2.2.2.1 diff -Llib/Value/Real.pm -Llib/Value/Real.pm -u -r1.24.2.2 -r1.24.2.2.2.1 --- lib/Value/Real.pm +++ lib/Value/Real.pm @@ -18,7 +18,6 @@ my $context = (Value::isContext($_[0]) ? shift : $self->context); my $x = shift; $x = [$x,@_] if scalar(@_) > 0; return $x->inContext($context) if Value::isReal($x); - $x = [$x] unless ref($x) eq 'ARRAY'; Value::Error("Can't convert ARRAY of length %d to %s",scalar(@{$x}),Value::showClass($self)) unless (scalar(@{$x}) == 1); Index: Complex.pm =================================================================== RCS file: /webwork/cvs/system/pg/lib/Value/Complex.pm,v retrieving revision 1.18.6.2 retrieving revision 1.18.6.2.2.1 diff -Llib/Value/Complex.pm -Llib/Value/Complex.pm -u -r1.18.6.2 -r1.18.6.2.2.1 --- lib/Value/Complex.pm +++ lib/Value/Complex.pm @@ -3,12 +3,10 @@ package Value::Complex; my $pkg = 'Value::Complex'; - use strict; no strict "refs"; our @ISA = qw(Value); our $i; our $pi; - # # Check that the inputs are: # one or two real numbers, or @@ -104,7 +102,6 @@ } sub div { - my ($self,$l,$r,$other) = Value::checkOpOrderWithPromote(@_); my ($a,$b) = $l->value; my ($c,$d) = $r->value; my $x = $c*$c + $d*$d; @@ -120,7 +117,6 @@ return exp($r * log($l)) } - sub modulo { my ($self,$l,$r,$other) = Value::checkOpOrderWithPromote(@_); return $self->inherit($other)->make(0) if abs($r)->value == 0; # non-fuzzy check Index: List.pm =================================================================== RCS file: /webwork/cvs/system/pg/lib/Value/List.pm,v retrieving revision 1.19.6.2 retrieving revision 1.19.6.2.2.1 diff -Llib/Value/List.pm -Llib/Value/List.pm -u -r1.19.6.2 -r1.19.6.2.2.1 --- lib/Value/List.pm +++ lib/Value/List.pm @@ -5,7 +5,6 @@ package Value::List; my $pkg = 'Value::List'; - use strict; no strict "refs"; our @ISA = qw(Value); @@ -15,7 +14,6 @@ # sub new { my $self = shift; my $class = ref($self) || $self; - my $context = (Value::isContext($_[0]) ? shift : $self->context); my $def = $context->lists->get("List"); my $p = shift; my $isFormula = 0; Index: Context.pm =================================================================== RCS file: /webwork/cvs/system/pg/lib/Value/Context.pm,v retrieving revision 1.10.6.2 retrieving revision 1.10.6.2.2.1 diff -Llib/Value/Context.pm -Llib/Value/Context.pm -u -r1.10.6.2 -r1.10.6.2.2.1 --- lib/Value/Context.pm +++ lib/Value/Context.pm @@ -85,7 +85,6 @@ foreach my $data (@{$context->{data}{values}}) { $context->{$data} = {%{$self->{$data}}}; } - $context->{error}{msg} = {%{$self->{error}{msg}}}; $context->{error}{convert} = $self->{error}{convert} if defined $self->{error}{convert}; @@ -94,7 +93,6 @@ return $context; } - # # Returns the package name for the specificied Value object class # (as specified by the context's {value} hash, or "Value::name"). Index: Infinity.pm =================================================================== RCS file: /webwork/cvs/system/pg/lib/Value/Infinity.pm,v retrieving revision 1.9.6.2 retrieving revision 1.9.6.2.2.1 diff -Llib/Value/Infinity.pm -Llib/Value/Infinity.pm -u -r1.9.6.2 -r1.9.6.2.2.1 --- lib/Value/Infinity.pm +++ lib/Value/Infinity.pm @@ -3,7 +3,6 @@ package Value::Infinity; my $pkg = 'Value::Infinity'; - use strict; no strict "refs"; our @ISA = qw(Value); Index: Set.pm =================================================================== RCS file: /webwork/cvs/system/pg/lib/Value/Set.pm,v retrieving revision 1.10.6.2 retrieving revision 1.10.6.2.2.1 diff -Llib/Value/Set.pm -Llib/Value/Set.pm -u -r1.10.6.2 -r1.10.6.2.2.1 --- lib/Value/Set.pm +++ lib/Value/Set.pm @@ -3,7 +3,6 @@ package Value::Set; my $pkg = 'Value::Set'; - use strict; no strict "refs"; our @ISA = qw(Value); Index: AnswerChecker.pm =================================================================== RCS file: /webwork/cvs/system/pg/lib/Value/AnswerChecker.pm,v retrieving revision 1.91.2.2 retrieving revision 1.91.2.2.2.1 diff -Llib/Value/AnswerChecker.pm -Llib/Value/AnswerChecker.pm -u -r1.91.2.2 -r1.91.2.2.2.1 --- lib/Value/AnswerChecker.pm +++ lib/Value/AnswerChecker.pm @@ -90,7 +90,6 @@ @_, ); $ans->{debug} = $ans->{rh_ans}{debug}; - $ans->install_evaluator(sub { my $ans = shift; $ans->{_filter_name} = "MathObjects answer checker"; @@ -126,9 +125,6 @@ $context->clearError(); $context->{answerHash} = $ans; # values here can override context flags - $context->{answerHash} = $ans; # values here can override context flags - - # # Parse and evaluate the student answer # @@ -244,10 +240,8 @@ my $context = (Value::isValue($self) ? $self->context : Value->context); return eval {$self == $other} unless ref($ans->{checker}) eq 'CODE'; my @equal = eval {&{$ans->{checker}}($self,$other,$ans,$nth,@_)}; - if (!defined($equal) && $@ ne '' && (!$context->{error}{flag} || $ans->{showAllErrors})) { $context->setError(["<I>An error occurred while checking your$nth answer:</I>\n". - '<DIV STYLE="margin-left:1em">%s</DIV>',$@],'',undef,undef,$CMP_ERROR); warn "Please inform your instructor that an error occurred while checking your answer"; } @@ -2056,10 +2050,8 @@ # sub value { my $self = shift; - return $self unless defined $self->{tree}{coords}; my $context = $self->context; - my @array = (); if ($self->{tree}->type eq 'Matrix') { foreach my $row (@{$self->{tree}->coords}) { Index: Formula.pm =================================================================== RCS file: /webwork/cvs/system/pg/lib/Value/Formula.pm,v retrieving revision 1.43.2.2 retrieving revision 1.43.2.2.2.1 diff -Llib/Value/Formula.pm -Llib/Value/Formula.pm -u -r1.43.2.2 -r1.43.2.2.2.1 --- lib/Value/Formula.pm +++ lib/Value/Formula.pm @@ -8,14 +8,11 @@ use strict; no strict "refs"; our @ISA = qw(Parser Value); - - my $UNDEF = bless {}, "UNDEF"; # used for undefined points # # Call Parser to make the new Formula - # sub new { my $self = shift; @@ -35,7 +32,6 @@ # as the formula itself. # sub with { - my $self = shift; my %hash = @_; $self = $self->SUPER::with(@_); $self->{tree} = $self->{tree}->copy($self); # make a new copy pointing to the new equation. @@ -84,7 +80,6 @@ if (ref($l) eq $class || ref($l) eq $pkg) { $formula->{context} = $l->{context}; $l = $l->{tree}->copy($formula); - } else { $l = $self->new($l)->{tree}->copy($formula); } @@ -446,7 +441,6 @@ } push @A, [@a]; push @b, [(&$F(@p,@P)-$v->[$i])->value]; } - # # Use MatrixReal1.pm to solve system of linear equations # Index: Interval.pm =================================================================== RCS file: /webwork/cvs/system/pg/lib/Value/Interval.pm,v retrieving revision 1.28.6.2 retrieving revision 1.28.6.2.2.1 diff -Llib/Value/Interval.pm -Llib/Value/Interval.pm -u -r1.28.6.2 -r1.28.6.2.2.1 --- lib/Value/Interval.pm +++ lib/Value/Interval.pm @@ -8,7 +8,6 @@ use strict; no strict "refs"; our @ISA = qw(Value); - # # Convert a value to an interval. The value consists of # an open paren string, one or two real numbers or infinities, @@ -16,7 +15,6 @@ # sub new { my $self = shift; my $class = ref($self) || $self; - my $context = (Value::isContext($_[0]) ? shift : $self->context); if (scalar(@_) == 1) { my $x = Value::makeValue($_[0],context=>$context); Index: Matrix.pm =================================================================== RCS file: /webwork/cvs/system/pg/lib/Value/Matrix.pm,v retrieving revision 1.22.4.2 retrieving revision 1.22.4.2.2.1 diff -Llib/Value/Matrix.pm -Llib/Value/Matrix.pm -u -r1.22.4.2 -r1.22.4.2.2.1 --- lib/Value/Matrix.pm +++ lib/Value/Matrix.pm @@ -10,7 +10,6 @@ use strict; no strict "refs"; our @ISA = qw(Value); - # # Convert a value to a matrix. The value can be: # a list of numbers or list of (nested) references to arrays of numbers, @@ -191,7 +190,6 @@ Value::Error("Can't subtract Matrices with different dimensions") unless scalar(@l) == scalar(@r); my @s = (); - foreach my $i (0..scalar(@l)-1) {push(@s,$l[$i] - $r[$i])} return $self->inherit($other)->make(@s); } Index: Point.pm =================================================================== RCS file: /webwork/cvs/system/pg/lib/Value/Point.pm,v retrieving revision 1.18.6.2 retrieving revision 1.18.6.2.2.1 diff -Llib/Value/Point.pm -Llib/Value/Point.pm -u -r1.18.6.2 -r1.18.6.2.2.1 --- lib/Value/Point.pm +++ lib/Value/Point.pm @@ -8,7 +8,6 @@ use strict; no strict "refs"; our @ISA = qw(Value); - # # Convert a value to a point. The value can be # a list of numbers, or an reference to an array of numbers @@ -61,7 +60,6 @@ # sub add { - my ($self,$l,$r,$other) = Value::checkOpOrderWithPromote(@_); my @l = $l->value; my @r = $r->value; Value::Error("Can't add Points with different numbers of coordinates") @@ -72,7 +70,6 @@ } sub sub { - my ($self,$l,$r,$other) = Value::checkOpOrderWithPromote(@_); my @l = $l->value; my @r = $r->value; Value::Error("Can't subtract Points with different numbers of coordinates") @@ -80,7 +77,6 @@ my @s = (); foreach my $i (0..scalar(@l)-1) {push(@s,$l[$i] - $r[$i])} return $self->inherit($other)->make(@s); - } sub mult { Index: Data.pm =================================================================== RCS file: /webwork/cvs/system/pg/lib/Value/Context/Data.pm,v retrieving revision 1.9.6.2 retrieving revision 1.9.6.2.2.1 diff -Llib/Value/Context/Data.pm -Llib/Value/Context/Data.pm -u -r1.9.6.2 -r1.9.6.2.2.1 --- lib/Value/Context/Data.pm +++ lib/Value/Context/Data.pm @@ -49,7 +49,6 @@ $copy->{$name} = $data->{$name}; } } - $self->{tokens} = {%{$orig->{tokens}}}; foreach my $p (keys %{$orig->{patterns}}) { $self->{patterns}{$p} = Index: Translator.pm =================================================================== RCS file: /webwork/cvs/system/pg/lib/WeBWorK/PG/Translator.pm,v retrieving revision 1.18.2.2 retrieving revision 1.18.2.2.2.1 diff -Llib/WeBWorK/PG/Translator.pm -Llib/WeBWorK/PG/Translator.pm -u -r1.18.2.2 -r1.18.2.2.2.1 --- lib/WeBWorK/PG/Translator.pm +++ lib/WeBWorK/PG/Translator.pm @@ -154,6 +154,8 @@ my $class = shift; my $safe_cmpt = new Safe; #('PG_priv'); my $self = { + preprocess_code => \&default_preprocess_code, + postprocess_code => \&default_postprocess_code, envir => undef, PG_PROBLEM_TEXT_ARRAY_REF => [], PG_PROBLEM_TEXT_REF => 0, @@ -882,13 +884,19 @@ ########################################## ###### PG preprocessing code ############# ########################################## - # BEGIN_TEXT and END_TEXT must occur on a line by themselves. - $evalString =~ s/\n\s*END_TEXT[\s;]*\n/\nEND_TEXT\n/g; - $evalString =~ s/\n\s*BEGIN_TEXT[\s;]*\n/\nTEXT\(EV3\(<<'END_TEXT'\)\);\n/g; - $evalString =~ s/ENDDOCUMENT.*/ENDDOCUMENT();/s; # remove text after ENDDOCUMENT + + $evalString = &{$self->{preprocess_code}}($evalString); + + +# # default_preprocess_code +# # BEGIN_TEXT and END_TEXT must occur on a line by themselves. +# $evalString =~ s/\n\s*END_TEXT[\s;]*\n/\nEND_TEXT\n/g; +# $evalString =~ s/\n\s*BEGIN_TEXT[\s;]*\n/\nTEXT\(EV3\(<<'END_TEXT'\)\);\n/g; +# $evalString =~ s/ENDDOCUMENT.*/ENDDOCUMENT();/s; # remove text after ENDDOCUMENT +# +# $evalString =~ s/\\/\\\\/g; # \ can't be used for escapes because of TeX conflict +# $evalString =~ s/~~/\\/g; # use ~~ as escape instead, use # for comments - $evalString =~ s/\\/\\\\/g; # \ can't be used for escapes because of TeX conflict - $evalString =~ s/~~/\\/g; # use ~~ as escape instead, use # for comments =pod @@ -922,6 +930,12 @@ ########## end EVALUATION code ########### ############################################################################# + ########################################## + ###### PG postprocessing code ############# + ########################################## + $PG_PROBLEM_TEXT_REF = &{$self->{postprocess_code}}($PG_PROBLEM_TEXT_REF); + + =pod (5) B<Process errors> @@ -960,7 +974,7 @@ $self -> {errors}."\r\n" . "****************<BR>\n"); - push(@PROBLEM_TEXT_OUTPUT , "------Input Read\r\n"); + push(@PROBLEM_TEXT_OUTPUT , "------Input Read\r\n"); $self->{source} =~ s/</</g; @input=split("\n", $self->{source}); $lineNumber = 1; @@ -1607,6 +1621,37 @@ } +sub original_preprocess_code { + my $evalString = shift; + # BEGIN_TEXT and END_TEXT must occur on a line by themselves. + $evalString =~ s/\n\s*END_TEXT[\s;]*\n/\nEND_TEXT\n/g; + $evalString =~ s/\n\s*BEGIN_TEXT[\s;]*\n/\nTEXT\(EV3\(<<'END_TEXT'\)\);\n/g; + $evalString =~ s/ENDDOCUMENT.*/ENDDOCUMENT();/s; # remove text after ENDDOCUMENT + + $evalString =~ s/\\/\\\\/g; # \ can't be used for escapes because of TeX conflict + $evalString =~ s/~~/\\/g; # use ~~ as escape instead, use # for comments + $evalString; +} +sub default_preprocess_code { + my $evalString = shift; + # BEGIN_TEXT and END_TEXT must occur on a line by themselves. + $evalString =~ s/\n\s*END_TEXT[\s;]*\n/\nEND_TEXT\n/g; + $evalString =~ s/\n\s*END_SOLUTION[\s;]*\n/\nEND_TEXT\n/g; + $evalString =~ s/\n\s*END_HINT[\s;]*\n/\nEND_TEXT\n/g; + $evalString =~ s/\n\s*BEGIN_TEXT[\s;]*\n/\nTEXT\(EV3\(<<'END_TEXT'\)\);\n/g; + $evalString =~ s/\n\s*BEGIN_SOLUTION[\s;]*\n/\nTEXT\(EV3\(<<'END_SOLUTION'\)\);\n/g; + $evalString =~ s/\n\s*BEGIN_HINT[\s;]*\n/\nTEXT\(EV3\(<<'END_HINT'\)\);\n/g; + $evalString =~ s/ENDDOCUMENT.*/ENDDOCUMENT();/s; # remove text after ENDDOCUMENT + + $evalString =~ s/\\/\\\\/g; # \ can't be used for escapes because of TeX conflict + $evalString =~ s/~~/\\/g; # use ~~ as escape instead, use # for comments + $evalString; +} +sub default_postprocess_code { + my $evalString_ref = shift; + $evalString_ref; +} + sub dumpvar { my ($packageName) = @_; Index: parserParametricLine.pl =================================================================== RCS file: /webwork/cvs/system/pg/macros/parserParametricLine.pl,v retrieving revision 1.5.2.2 retrieving revision 1.5.2.2.2.1 diff -Lmacros/parserParametricLine.pl -Lmacros/parserParametricLine.pl -u -r1.5.2.2 -r1.5.2.2.2.1 --- macros/parserParametricLine.pl +++ macros/parserParametricLine.pl @@ -16,7 +16,6 @@ =head1 NAME - parserParametricLine.pl - Implements Formulas that represent parametric lines. =head1 DESCRIPTION @@ -107,7 +106,6 @@ return bless $line, $class; } - =head2 $lhs == $rhs # Index: contextLimitedPoint.pl =================================================================== RCS file: /webwork/cvs/system/pg/macros/contextLimitedPoint.pl,v retrieving revision 1.2.6.2 retrieving revision 1.2.6.2.2.1 diff -Lmacros/contextLimitedPoint.pl -Lmacros/contextLimitedPoint.pl -u -r1.2.6.2 -r1.2.6.2.2.1 --- macros/contextLimitedPoint.pl +++ macros/contextLimitedPoint.pl @@ -1,4 +1,3 @@ - ################################################################################ # WeBWorK Online Homework Delivery System # Copyright © 2000-2007 The WeBWorK Project, http://openwebwork.sf.net/ @@ -30,12 +29,10 @@ =cut - loadMacros("MathObjects.pl"); sub _contextLimitedPoint_init {LimitedPoint::Init()}; # don't load it again - ################################################## # # Handle common checking for BOPs @@ -169,5 +166,4 @@ main::Context("LimitedPoint"); ### FIXME: probably should require author to set this explicitly } - 1; Index: IO.pl =================================================================== RCS file: /webwork/cvs/system/pg/macros/IO.pl,v retrieving revision 1.3.6.2 retrieving revision 1.3.6.2.2.1 diff -Lmacros/IO.pl -Lmacros/IO.pl -u -r1.3.6.2 -r1.3.6.2.2.1 --- macros/IO.pl +++ macros/IO.pl @@ -1,6 +1,4 @@ - ################################################################################ - # WeBWorK Online Homework Delivery System # Copyright © 2000-2007 The WeBWorK Project, http://openwebwork.sf.net/ # $CVSHeader$ Index: contextString.pl =================================================================== RCS file: /webwork/cvs/system/pg/macros/contextString.pl,v retrieving revision 1.4.2.2 retrieving revision 1.4.2.2.2.1 diff -Lmacros/contextString.pl -Lmacros/contextString.pl -u -r1.4.2.2 -r1.4.2.2.2.1 --- macros/contextString.pl +++ macros/contextString.pl @@ -18,7 +18,6 @@ contextString.pl - Allow string-valued answers. - =head1 DESCRIPTION Implements contexts for string-valued answers. Index: PGinfo.pl =================================================================== RCS file: /webwork/cvs/system/pg/macros/PGinfo.pl,v retrieving revision 1.1.2.2 retrieving revision 1.1.2.2.2.1 diff -Lmacros/PGinfo.pl -Lmacros/PGinfo.pl -u -r1.1.2.2 -r1.1.2.2.2.1 --- macros/PGinfo.pl +++ macros/PGinfo.pl @@ -4,7 +4,6 @@ # All Rights Reserved #################################################################### - =head1 NAME PGinfo.pl Index: contextLimitedVector.pl =================================================================== RCS file: /webwork/cvs/system/pg/macros/contextLimitedVector.pl,v retrieving revision 1.2.6.2 retrieving revision 1.2.6.2.2.1 diff -Lmacros/contextLimitedVector.pl -Lmacros/contextLimitedVector.pl -u -r1.2.6.2 -r1.2.6.2.2.1 --- macros/contextLimitedVector.pl +++ macros/contextLimitedVector.pl @@ -42,12 +42,10 @@ =cut - loadMacros("MathObjects.pl"); sub _contextLimitedVector_init {LimitedVector::Init()}; # don't load it again - ################################################## # # Handle common checking for BOPs @@ -271,6 +269,8 @@ $context->flags->set(vector_format => 'coordinate'); $context->constants->undefine('i','j','k'); + ######################### + main::Context("LimitedVector"); ### FIXME: probably should require author to set this explicitly } Index: MathObjects.pl =================================================================== RCS file: /webwork/cvs/system/pg/macros/MathObjects.pl,v retrieving revision 1.2.2.4 retrieving revision 1.2.2.4.2.1 diff -Lmacros/MathObjects.pl -Lmacros/MathObjects.pl -u -r1.2.2.4 -r1.2.2.4.2.1 --- macros/MathObjects.pl +++ macros/MathObjects.pl @@ -1,4 +1,3 @@ - ################################################################################ # WeBWorK Online Homework Delivery System # Copyright © 2000-2007 The WeBWorK Project, http://openwebwork.sf.net/ @@ -25,10 +24,8 @@ is to encourage the use of the name MathObjects instead of Parser (which is not as intuitive for those who don't know the history). - It may later be used for other purposes as well. - =head1 SEE ALSO L<Parser.pl>. Index: contextLimitedComplex.pl =================================================================== RCS file: /webwork/cvs/system/pg/macros/contextLimitedComplex.pl,v retrieving revision 1.3.2.2 retrieving revision 1.3.2.2.2.1 diff -Lmacros/contextLimitedComplex.pl -Lmacros/contextLimitedComplex.pl -u -r1.3.2.2 -r1.3.2.2.2.1 --- macros/contextLimitedComplex.pl +++ macros/contextLimitedComplex.pl @@ -62,16 +62,12 @@ loadMacros("MathObjects.pl"); - sub _contextLimitedComplex_init {LimitedComplex::Init()}; # don't load it again - - ################################################## # # Handle common checking for BOPs # - package LimitedComplex::BOP; # Index: dangerousMacros.pl =================================================================== RCS file: /webwork/cvs/system/pg/macros/dangerousMacros.pl,v retrieving revision 1.41.2.3 retrieving revision 1.41.2.3.2.1 diff -Lmacros/dangerousMacros.pl -Lmacros/dangerousMacros.pl -u -r1.41.2.3 -r1.41.2.3.2.1 --- macros/dangerousMacros.pl +++ macros/dangerousMacros.pl @@ -1285,7 +1285,6 @@ =head2 sourceAlias - sourceAlias($path_to_PG_file); Returns a relative URL to the F<source.pl> script, which may be installed in a @@ -1349,7 +1348,6 @@ Value->Package("Formula")->new('k')->eval; } - # ^function pi # ^uses &Value::Package sub pi () {Value->Package("Formula")->new('pi')->eval} Index: contextABCD.pl =================================================================== RCS file: /webwork/cvs/system/pg/macros/contextABCD.pl,v retrieving revision 1.3.6.2 retrieving revision 1.3.6.2.2.1 diff -Lmacros/contextABCD.pl -Lmacros/contextABCD.pl -u -r1.3.6.2 -r1.3.6.2.2.1 --- macros/contextABCD.pl +++ macros/contextABCD.pl @@ -16,10 +16,8 @@ =head1 NAME - contextABCD.pl - Contexts for matching problems. - =head1 DESCRIPTION Implements contexts for string-valued answers especially Index: contextLimitedPowers.pl =================================================================== RCS file: /webwork/cvs/system/pg/macros/contextLimitedPowers.pl,v retrieving revision 1.2.4.2 retrieving revision 1.2.4.2.2.1 diff -Lmacros/contextLimitedPowers.pl -Lmacros/contextLimitedPowers.pl -u -r1.2.4.2 -r1.2.4.2.2.1 --- macros/contextLimitedPowers.pl +++ macros/contextLimitedPowers.pl @@ -1,4 +1,3 @@ - ################################################################################ # WeBWorK Online Homework Delivery System # Copyright © 2000-2007 The WeBWorK Project, http://openwebwork.sf.net/ @@ -103,7 +102,6 @@ loadMacros("MathObjects.pl"); - sub _contextLimitedPowers_init {}; # don't load it again package LimitedPowers; @@ -153,7 +151,6 @@ # # Legacy code to accommodate older approach to setting the operators # - our @NoBaseE = ( '^' => {class => 'LimitedPowers::NoBaseE', isCommand=>1, perl=>'LimitedPowers::NoBaseE->_eval'}, '**' => {class => 'LimitedPowers::NoBaseE', isCommand=>1, perl=>'LimitedPowers::NoBaseE->_eval'}, Index: contextTF.pl =================================================================== RCS file: /webwork/cvs/system/pg/macros/contextTF.pl,v retrieving revision 1.4.6.2 retrieving revision 1.4.6.2.2.1 diff -Lmacros/contextTF.pl -Lmacros/contextTF.pl -u -r1.4.6.2 -r1.4.6.2.2.1 --- macros/contextTF.pl +++ macros/contextTF.pl @@ -16,7 +16,6 @@ =head1 NAME - contextTF.pl - Imlements contexts for true/false problems. =head1 DESCRIPTION Index: Parser.pl =================================================================== RCS file: /webwork/cvs/system/pg/macros/Parser.pl,v retrieving revision 1.6.6.2 retrieving revision 1.6.6.2.2.1 diff -Lmacros/Parser.pl -Lmacros/Parser.pl -u -r1.6.6.2 -r1.6.6.2.2.1 --- macros/Parser.pl +++ macros/Parser.pl @@ -1,4 +1,3 @@ - ################################################################################ # WeBWorK Online Homework Delivery System # Copyright © 2000-2007 The WeBWorK Project, http://openwebwork.sf.net/ @@ -26,10 +25,8 @@ ## Set up the functions needed by the Parser. ## - # ^uses $Parser::installed # ^uses $Value::installed - if (!$Parser::installed) { die "\n************************************************************\n" . "* This problem requires the Parser.pm package, which doesn't\n". @@ -87,13 +84,10 @@ =cut - # ^function Compute # ^uses Formula - sub Compute { my $string = shift; - my $formula = Formula($string); $formula = $formula->{tree}->Compute if $formula->{tree}{canCompute}; if (scalar(@_) || $formula->isConstant) { @@ -105,7 +99,6 @@ return $formula; } - =head2 Context Context(); @@ -122,15 +115,12 @@ # ^function Context # ^uses Parser::Context::current # ^uses %context - sub Context {Parser::Context->current(\%context,@_)} - # ^variable our %context %context = (); # Locally defined contexts, including 'current' context # ^uses Context Context(); # Initialize context (for persistent mod_perl) - ########################################################################### # # stubs for trigonometric functions Index: parserImplicitEquation.pl =================================================================== RCS file: /webwork/cvs/system/pg/macros/parserImplicitEquation.pl,v retrieving revision 1.2.2.2 retrieving revision 1.2.2.2.2.1 diff -Lmacros/parserImplicitEquation.pl -Lmacros/parserImplicitEquation.pl -u -r1.2.2.2 -r1.2.2.2.2.1 --- macros/parserImplicitEquation.pl +++ macros/parserImplicitEquation.pl @@ -181,7 +181,6 @@ loadMacros("MathObjects.pl"); - sub _parserImplicitEquation_init {ImplicitEquation::Init()}; # don't reload this file # Index: contextLimitedNumeric.pl =================================================================== RCS file: /webwork/cvs/system/pg/macros/contextLimitedNumeric.pl,v retrieving revision 1.2.6.2 retrieving revision 1.2.6.2.2.1 diff -Lmacros/contextLimitedNumeric.pl -Lmacros/contextLimitedNumeric.pl -u -r1.2.6.2 -r1.2.6.2.2.1 --- macros/contextLimitedNumeric.pl +++ macros/contextLimitedNumeric.pl @@ -1,4 +1,3 @@ - ################################################################################ # WeBWorK Online Homework Delivery System # Copyright © 2000-2007 The WeBWorK Project, http://openwebwork.sf.net/ @@ -15,10 +14,8 @@ # Artistic License for more details. ################################################################################ - =head1 NAME - contextLimitedNumeric.pl - Allows numeric entry but no operations. =head1 DESCRIPTION @@ -38,7 +35,6 @@ =cut - loadMacros("MathObjects.pl"); sub _contextLimitedNumeric_init { Index: parserCustomization.pl =================================================================== RCS file: /webwork/cvs/system/pg/macros/parserCustomization.pl,v retrieving revision 1.2.2.2 retrieving revision 1.2.2.2.2.1 diff -Lmacros/parserCustomization.pl -Lmacros/parserCustomization.pl -u -r1.2.2.2 -r1.2.2.2.2.1 --- macros/parserCustomization.pl +++ macros/parserCustomization.pl @@ -37,7 +37,6 @@ $context{Vector}->{cmpDefaults}{Vector} = {promotePoints => 1}; $context{Vector}->lists->set(Vector=>{open=>'(', close=>')'}); - (This actually just turns points into vectors in the answer checker for vectors, and displays vectors using parens rather than angle brakets. The student is really still entering what the Parser @@ -45,7 +44,6 @@ in the Value package, that should work. But if a problem checks if a student's value is actually a Vector, that will not be true.) - =cut sub _parserCustomization_init {} Index: parserVectorUtils.pl =================================================================== RCS file: /webwork/cvs/system/pg/macros/parserVectorUtils.pl,v retrieving revision 1.2.8.2 retrieving revision 1.2.8.2.2.1 diff -Lmacros/parserVectorUtils.pl -Lmacros/parserVectorUtils.pl -u -r1.2.8.2 -r1.2.8.2.2.1 --- macros/parserVectorUtils.pl +++ macros/parserVectorUtils.pl @@ -24,11 +24,8 @@ =cut -=cut - sub _parserVectorUtils_init {}; # don't reload this file - =head1 MACROS =head2 Overline @@ -55,7 +52,6 @@ ); } - =head2 BoldMath BoldMath($vectorName) @@ -120,7 +116,6 @@ sub non_zero_point2D {non_zero_point(2,@_)} sub non_zero_point3D {non_zero_point(3,@_)} - =head2 non_zero_vector, non_zero_vector2D, non_zero_vector3D non_zero_vector($Dim,$L_bound,$U_bound,$step) @@ -138,7 +133,6 @@ sub non_zero_vector2D {non_zero_vector(2,@_)} sub non_zero_vector3D {non_zero_vector(3,@_)} - =head2 Line $P = Point(@coords1); @@ -161,7 +155,6 @@ =cut - sub Line { my @p = Point(shift)->value; my @v = Vector(shift)->value; my $t = shift; $t = 't' unless $t; $t = Formula($t); Index: parserDifferenceQuotient.pl =================================================================== RCS file: /webwork/cvs/system/pg/macros/parserDifferenceQuotient.pl,v retrieving revision 1.6.4.2 retrieving revision 1.6.4.2.2.1 diff -Lmacros/parserDifferenceQuotient.pl -Lmacros/parserDifferenceQuotient.pl -u -r1.6.4.2 -r1.6.4.2.2.1 --- macros/parserDifferenceQuotient.pl +++ macros/parserDifferenceQuotient.pl @@ -46,10 +46,8 @@ Context()->variables->are(t=>'Real',a=>'Real'); ANS(DifferenceQuotient("-a/[t(t+dt)]","dt")->cmp); - =cut - loadMacros('MathObjects.pl'); sub _parserDifferenceQuotient_init {DifferenceQuotient::Init()}; # don't reload this file Index: parserFormulaWithUnits.pl =================================================================== RCS file: /webwork/cvs/system/pg/macros/parserFormulaWithUnits.pl,v retrieving revision 1.3.4.2 retrieving revision 1.3.4.2.2.1 diff -Lmacros/parserFormulaWithUnits.pl -Lmacros/parserFormulaWithUnits.pl -u -r1.3.4.2 -r1.3.4.2.2.1 --- macros/parserFormulaWithUnits.pl +++ macros/parserFormulaWithUnits.pl @@ -20,7 +20,6 @@ =head1 DESCRIPTION - This is a Parser class that implements a formula with units. It is a temporary version until the Parser can handle it directly. Index: answerComposition.pl =================================================================== RCS file: /webwork/cvs/system/pg/macros/answerComposition.pl,v retrieving revision 1.1.8.2 retrieving revision 1.1.8.2.2.1 diff -Lmacros/answerComposition.pl -Lmacros/answerComposition.pl -u -r1.1.8.2 -r1.1.8.2.2.1 --- macros/answerComposition.pl +++ macros/answerComposition.pl @@ -1,4 +1,3 @@ - ################################################################################ # WeBWorK Online Homework Delivery System # Copyright © 2000-2007 The WeBWorK Project, http://openwebwork.sf.net/ @@ -29,12 +28,8 @@ =cut - -=cut - sub _answerComposition_init {}; # don't reload this file - =head1 MACROS =head2 COMPOSITION_ANS @@ -63,7 +58,6 @@ =cut - sub COMPOSITION_ANS { my $f = shift; my $g = shift; my $fID = ANS_NUM_TO_NAME($main::ans_rule_count-1); @@ -72,7 +66,6 @@ ANS($ans{$fID},$ans{$gID}); } - =head2 NAMED_COMPOSITION_ANS NAMED_COMPOSITION_ANS($fID=>$f, $gID=>$g, %options) @@ -95,11 +88,8 @@ =cut - - sub NAMED_COMPOSITION_ANS {NAMED_ANS(composition_ans_list(@_))} - =head2 composition_ans_list composition_ans_list($fID=>$f, $gID=>$g, %options) @@ -130,8 +120,6 @@ =cut -=cut - sub composition_ans_list { my ($fID,$f,$gID,$g,%params) = @_; my @IDs = ($fID,$gID); # Index: answerVariableList.pl =================================================================== RCS file: /webwork/cvs/system/pg/macros/answerVariableList.pl,v retrieving revision 1.4.2.2 retrieving revision 1.4.2.2.2.1 diff -Lmacros/answerVariableList.pl -Lmacros/answerVariableList.pl -u -r1.4.2.2 -r1.4.2.2.2.1 --- macros/answerVariableList.pl +++ macros/answerVariableList.pl @@ -46,7 +46,6 @@ addVariables('x','y','z','s','t,); ANS(variable_cmp("s,t")); - addVariables('x','y','z'); ANS(variable_cmp("(x)",showHints=>0,showLengthHints=>0)); Index: contextPeriodic.pl =================================================================== RCS file: /webwork/cvs/system/pg/macros/contextPeriodic.pl,v retrieving revision 1.3.2.2 retrieving revision 1.3.2.2.2.1 diff -Lmacros/contextPeriodic.pl -Lmacros/contextPeriodic.pl -u -r1.3.2.2 -r1.3.2.2.2.1 --- macros/contextPeriodic.pl +++ macros/contextPeriodic.pl @@ -1,4 +1,3 @@ - ################################################################################ # WeBWorK Online Homework Delivery System # Copyright © 2000-2007 The WeBWorK Project, http://openwebwork.sf.net/ Index: PG.pl =================================================================== RCS file: /webwork/cvs/system/pg/macros/PG.pl,v retrieving revision 1.29.2.2 retrieving revision 1.29.2.2.2.1 diff -Lmacros/PG.pl -Lmacros/PG.pl -u -r1.29.2.2 -r1.29.2.2.2.1 --- macros/PG.pl +++ macros/PG.pl @@ -22,7 +22,6 @@ In a PG problem: - DOCUMENT(); # should be the first statment in the problem loadMacros(.....); # (optional) load other macro files if needed. @@ -126,7 +125,6 @@ # there could be conflicts. As I understand the behavior of the Apache child # this cannot occur -- a child finishes with one request before obtaining the next - ################################################################################ =head1 MACROS @@ -135,7 +133,6 @@ =over - =item DOCUMENT() DOCUMENT() should be the first statement in each problem template. It can @@ -340,7 +337,6 @@ $STRINGforOUTPUT .= join(" ",@in); } - =item ANS() TEXT(ans_rule(), ans_rule(), ans_rule()); @@ -392,10 +388,8 @@ =item NAMED_ANS() - Old name for LABELED_ANS(). DEPRECATED. - =cut # ^function NAMED_ANS @@ -421,7 +415,6 @@ Temporarily suspends accumulation of problem text and storing of answer blanks and answer evaluators until RESUME_RENDERING() is called. - =cut # ^function STOP_RENDERING @@ -447,18 +440,15 @@ ""; } - =item ENDDOCUMENT() ENDDOCUMENT(); - When PG problems are evaluated, the result of evaluating the entire problem is interpreted as the return value of ENDDOCUMENT(). Therefore, ENDDOCUMENT() must be the last executable statement of every problem. It can only appear once. It returns a list consisting of: - =over =item * @@ -544,7 +534,6 @@ =back - =cut # ^function ENDDOCUMENT @@ -649,7 +638,6 @@ eval(q!++$main::ans_rule_count!); # evalute at runtime to get correct main:: } - =item RECORD_ANS_NAME() RECORD_ANS_NAME("label"); @@ -669,7 +657,6 @@ $label; } - =item NEW_ANS_NAME() NEW_ANS_NAME($num); @@ -718,7 +705,6 @@ my $vecnum; - =item RECORD_FROM_LABEL() RECORD_FORM_LABEL("label"); @@ -739,7 +725,6 @@ $label; } - =item NEW_ANS_ARRAY_NAME() NEW_ANS_ARRAY_NAME($num, $row, $col); @@ -795,12 +780,13 @@ $label; } - =item get_PG_ANSWERS_HASH() get_PG_ANSWERS_HASH(); get_PG_ANSWERS_HASH($key); + + =cut # ^function get_PG_ANSWERS_HASH @@ -834,7 +820,6 @@ } } - =item includePGproblem($filePath) includePGproblem($filePath); @@ -843,8 +828,7 @@ a path relative to the top of the templates directory. The output of that problem appears in the given problem. -=head1 SEE ALSO - +=cut # ^function includePGproblem # ^uses %envir @@ -881,6 +865,4 @@ =cut - 1; - Index: PGauxiliaryFunctions.pl =================================================================== RCS file: /webwork/cvs/system/pg/macros/PGauxiliaryFunctions.pl,v retrieving revision 1.9.6.2 retrieving revision 1.9.6.2.2.1 diff -Lmacros/PGauxiliaryFunctions.pl -Lmacros/PGauxiliaryFunctions.pl -u -r1.9.6.2 -r1.9.6.2.2.1 --- macros/PGauxiliaryFunctions.pl +++ macros/PGauxiliaryFunctions.pl @@ -12,10 +12,8 @@ =cut # ^uses loadMacros - loadMacros("PGcommonFunctions.pl"); - =head3 # @@ -33,6 +31,7 @@ # isPrime($number) # reduce($numerator,$denominator) # preformat($scalar, "QuotedString") +# =cut Index: parserRadioButtons.pl =================================================================== RCS file: /webwork/cvs/system/pg/macros/parserRadioButtons.pl,v retrieving revision 1.2.2.2 retrieving revision 1.2.2.2.2.1 diff -Lmacros/parserRadioButtons.pl -Lmacros/parserRadioButtons.pl -u -r1.2.2.2 -r1.2.2.2.2.1 --- macros/parserRadioButtons.pl +++ macros/parserRadioButtons.pl @@ -157,7 +157,6 @@ unless ref($choices) eq 'ARRAY'; Value::Error("A RadioButton's second argument should be the correct button choice") unless defined($value) && $value ne ""; - my $context = Parser::Context->getCopy("String"); my %choiceHash = $self->choiceHash(1); $context->strings->add(map {$_=>{}} (keys %choiceHash)); Index: Value.pl =================================================================== RCS file: /webwork/cvs/system/pg/macros/Value.pl,v retrieving revision 1.7.6.2 retrieving revision 1.7.6.2.2.1 diff -Lmacros/Value.pl -Lmacros/Value.pl -u -r1.7.6.2 -r1.7.6.2.2.1 --- macros/Value.pl +++ macros/Value.pl @@ -1,4 +1,5 @@ + =head1 DESCRIPTION # @@ -91,7 +92,6 @@ return $x; } - =head3 NOTE: ########################################################################### Index: PGbasicmacros.pl =================================================================== RCS file: /webwork/cvs/system/pg/macros/PGbasicmacros.pl,v retrieving revision 1.47.2.2 retrieving revision 1.47.2.2.2.1 diff -Lmacros/PGbasicmacros.pl -Lmacros/PGbasicmacros.pl -u -r1.47.2.2 -r1.47.2.2.2.1 --- macros/PGbasicmacros.pl +++ macros/PGbasicmacros.pl @@ -1620,6 +1620,113 @@ } } +=head3 EV3P + + ###################################################################### + # + # New version of EV3 that allows `...` and ``...`` to insert TeX produced + # by the new Parser (in math and display modes). + # + # Format: EV3P(string,...); + # EV3P({options},string,...); + # + # `x^2/5` will become \(\frac{x^2}{5}\) and then rendered for hardcopy or screen output + # + # where options can include: + # + # processCommands => 0 or 1 Indicates if the student's answer will + # be allowed to process \{...\}. + # Default: 1 + # + # processVariables => 0 1 Indicates whether variable substitution + # should be performed on the student's + # answer. + # Default: 1 + # + # processMath => 0 or 1 Indicates whether \(...\), \[...\], + # `...` and ``...`` will be processed + # in the student's answer. + # Default: 1 + # + # processParser => 0 or 1 Indicates if `...` and ``...`` should + # be processed when math is being + # processed. + # Default: 1 + # + # fixDollars => 0 or 1 Specifies whether dollar signs not followed + # by a letter should be replaced by ${DOLLAR} + # prior to variable substitution (to prevent + # accidental substitution of strange Perl + # values). + # Default: 1 + # + +=cut + +sub EV3P { + my $option_ref = {}; $option_ref = shift if ref($_[0]) eq 'HASH'; + my %options = ( + processCommands =... [truncated message content] |