You can subscribe to this list here.
2004 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(58) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2005 |
Jan
(53) |
Feb
(56) |
Mar
|
Apr
|
May
(30) |
Jun
(78) |
Jul
(121) |
Aug
(155) |
Sep
(77) |
Oct
(61) |
Nov
(45) |
Dec
(94) |
2006 |
Jan
(116) |
Feb
(33) |
Mar
(11) |
Apr
(23) |
May
(60) |
Jun
(89) |
Jul
(130) |
Aug
(109) |
Sep
(124) |
Oct
(63) |
Nov
(82) |
Dec
(45) |
2007 |
Jan
(31) |
Feb
(35) |
Mar
(123) |
Apr
(36) |
May
(18) |
Jun
(134) |
Jul
(133) |
Aug
(241) |
Sep
(126) |
Oct
(31) |
Nov
(15) |
Dec
(5) |
2008 |
Jan
(11) |
Feb
(6) |
Mar
(16) |
Apr
(29) |
May
(43) |
Jun
(149) |
Jul
(27) |
Aug
(29) |
Sep
(37) |
Oct
(20) |
Nov
(4) |
Dec
(6) |
2009 |
Jan
(34) |
Feb
(30) |
Mar
(16) |
Apr
(6) |
May
(1) |
Jun
(32) |
Jul
(22) |
Aug
(7) |
Sep
(18) |
Oct
(50) |
Nov
(22) |
Dec
(8) |
2010 |
Jan
(17) |
Feb
(15) |
Mar
(10) |
Apr
(9) |
May
(67) |
Jun
(30) |
Jul
|
Aug
|
Sep
(2) |
Oct
|
Nov
(1) |
Dec
|
From: dpvc v. a. <we...@ma...> - 2007-08-19 20:44:10
|
Log Message: ----------- Move the context creation into the _init routine. Don't generate the error about implied multiplication, since that doesn't make sense here (produce the standard error instead). Modified Files: -------------- pg/macros: contextString.pl Revision Data ------------- Index: contextString.pl =================================================================== RCS file: /webwork/cvs/system/pg/macros/contextString.pl,v retrieving revision 1.9 retrieving revision 1.10 diff -Lmacros/contextString.pl -Lmacros/contextString.pl -u -r1.9 -r1.10 --- macros/contextString.pl +++ macros/contextString.pl @@ -1,6 +1,6 @@ loadMacros("MathObjects.pl"); -sub _contextString_init {}; # don't load it again +sub _contextString_init {context::String::Init()}; # don't load it again =head3 Context("String") @@ -21,7 +21,9 @@ =cut -package contextString::Variable; +################################################## + +package context::String::Variable; sub new { my $self = shift; my $equation = shift; @@ -32,37 +34,57 @@ $equation->Error(["Your answer should be one of %s",$strings]); } -package contextString::Formula; -our @ISA = qw(Value::Formula Parser Value); +################################################## + +package context::String::Formula; +our @ISA = qw(Value::Formula); sub parse { my $self = shift; foreach my $ref (@{$self->{tokens}}) { $self->{ref} = $ref; - contextString::Variable->new($self) if ($ref->[0] eq 'error'); # display the error + context::String::Variable->new($self->{equation}) if ($ref->[0] eq 'error'); # display the error } $self->SUPER::parse(@_); } -package main; +package context::String::BOP::mult; +our @ISA = qw(Parser::BOP); + +sub _check { + my $self = shift; + context::String::Variable->new($self->{equation}); # report an error +} + +################################################## + +package context::String; + +sub Init { + my $context = $main::context{String} = Parser::Context->getCopy("Numeric"); + $context->parens->clear(); + $context->variables->clear(); + $context->constants->clear(); + $context->operators->clear(); + $context->functions->clear(); + $context->strings->clear(); + $context->{parser}{Variable} = 'context::String::Variable'; + $context->{parser}{Formula} = 'context::String::Formula'; + $context->operators->add( + ' ' => {precedence => 3, associativity=>"left", type=>"bin", string => "*", class => 'context::String::BOP::mult'}, + '*' => {precedence => 3, associativity=>"left", type=>"bin", class => 'context::String::BOP::mult'} + ); + + main::PG_restricted_eval(<<' END_EVAL'); + sub string_cmp { + my $strings = shift; + $strings = [$strings,@_] if (scalar(@_)); + $strings = [$strings] unless ref($strings) eq 'ARRAY'; + return map {String($_)->cmp(showHints=>0,showLengthHints=>0)} @{$strings}; + } + END_EVAL -$context{String} = Parser::Context->getCopy("Numeric"); -$context{String}->parens->undefine('|','{','(','['); -$context{String}->variables->clear(); -$context{String}->constants->clear(); -$context{String}->operators->clear(); -$context{String}->functions->clear(); -$context{String}->strings->clear(); -$context{String}->{parser}{Variable} = 'contextString::Variable'; -$context{String}->{parser}{Formula} = 'contextString::Formula'; - -Context("String"); - -sub string_cmp { - my $strings = shift; - $strings = [$strings,@_] if (scalar(@_)); - $strings = [$strings] unless ref($strings) eq 'ARRAY'; - return map {String($_)->cmp(showHints=>0,showLengthHints=>0)} @{$strings}; + main::Context("String"); ### FIXME: probably should require author to set this explicitly } 1; |
From: dpvc v. a. <we...@ma...> - 2007-08-19 20:08:21
|
Log Message: ----------- Added context flags to more finely control the allowed entry format (e.g., force the use of commas, force the use of decimal places, and so on.) See the documentation at the top of the file for details. Modified Files: -------------- pg/macros: contextCurrency.pl Revision Data ------------- Index: contextCurrency.pl =================================================================== RCS file: /webwork/cvs/system/pg/macros/contextCurrency.pl,v retrieving revision 1.4 retrieving revision 1.5 diff -Lmacros/contextCurrency.pl -Lmacros/contextCurrency.pl -u -r1.4 -r1.5 --- macros/contextCurrency.pl +++ macros/contextCurrency.pl @@ -99,6 +99,27 @@ # # would allow the student to enter just 150 rather than $150. # + # By default, the students may omit the commas, but you can + # force them to supply the commas using forceCommas=>1 in + # your cmp() call. + # + # ANS(Compute('$10,000.00')->cmp(forceCommas=>1)); + # + # By default, students need not enter decimal digits, so could use + # $100 or $1,000. as valid entries. You can require that the cents + # be provided using the forceDecimals=>1 flag. + # + # ANS(Compute('$10.95')->cmp(forceDecimals=>1)); + # + # By default, if the monitary value includes decimals digits, it + # must have exactly two. You can weaken this requirement to all + # any number of decimals by using noExtraDecimals=>0. + # + # ANS(Compute('$10.23372')->cmp(noExtraDecimals=>0); + # + # If forceDecimals is set to 1 at the same time, then they must + # have 2 or more decimals, otherwise any number is OK. + # ###################################################################### =cut @@ -180,7 +201,14 @@ $symbol => {precedence => 10, associativity => $associativity, type => "unary", string => $symbol, TeX => Currency::quoteTeX($symbol), class => 'Currency::UOP::currency'}, ); - $context->flags->set(tolerance => .005, tolType => "absolute", promoteReals => 1); + $context->flags->set( + tolerance => .005, + tolType => "absolute", + promoteReals => 1, + forceCommas => 0, + forceDecimals => 0, + noExtraDecimals => 1, + ); $context->{_initialized} = 1; $context->update; $context->{error}{msg}{"Missing operand after '%s'"} = "There should be a number after '%s'"; @@ -316,7 +344,9 @@ sub new { my $self = shift; my $equation = shift; - my $pattern = $equation->{context}{pattern}; + my $context = $equation->{context}; + my $pattern = $context->{pattern}; + my $currency = $context->{currency}; my $value = shift; my $value_string; if (ref($value) eq "") { $value_string = "$value"; @@ -348,16 +378,19 @@ our @ISA = ('Parser::UOP'); sub _check { - my $self = shift; my $decimal = $self->context->{pattern}{currencyDecimal}; - my $op = $self->{op}; + my $self = shift; + my $context = $self->context; + my $decimal = $context->{pattern}{currencyDecimal}; + my $op = $self->{op}; my $value = $op->{value_string}; $self->Error("'%s' can only be used with numeric constants",$self->{uop}) unless $op->type eq 'Number' && $op->class eq 'Number'; - ### FIXME: these checks should be controlled by context flags - ### (e.g., force to have decimals, allow extra decimals, force commas, etc.) $self->{ref} = $op->{ref}; # highlight the number, not the operator + $self->Error("You should have a '%s' every 3 digits",$context->{currency}{comma}) + if $context->flag("forceCommas") && $value =~ m/\d\d\d\d/; $self->Error("Monetary values must have exactly two decimal places") - if $op->{value_string} && $op->{value_string} =~ m/$decimal\d/ && - $op->{value_string} !~ m/$decimal\d\d$/; + if $value && $value =~ m/$decimal\d/ && $value !~ m/$decimal\d\d$/ && $context->flag('noExtraDecimals'); + $self->Error("Monitary values require two decimal places",shift) + if $context->flag("forceDecimals") && $value !~ m/$decimal\d\d$/; $self->{type} = {%{$op->typeRef}}; $self->{isCurrency} = 1; } |
From: dpvc v. a. <we...@ma...> - 2007-08-19 19:23:58
|
Log Message: ----------- Allow objects to explicitly DENY being a given type, even if isa() says they are. Modified Files: -------------- pg/lib: Value.pm Revision Data ------------- Index: Value.pm =================================================================== RCS file: /webwork/cvs/system/pg/lib/Value.pm,v retrieving revision 1.86 retrieving revision 1.87 diff -Llib/Value.pm -Llib/Value.pm -u -r1.86 -r1.87 --- lib/Value.pm +++ lib/Value.pm @@ -350,10 +350,12 @@ my $isHash = ($ref && $ref ne 'ARRAY' && $ref ne 'CODE'); my $context = ($isHash ? $self->{context} || Value->context : Value->context); foreach my $name (@_) { + my $isName = "is".$name; return 1 if $class eq $name || $ref eq "Value::$name" || - ($isHash && $self->{"is".$name}) || + ($isHash && $self->{$isName}) || $ref eq $context->Package($name,1) || - isa($self,"Value::$name"); + (isa($self,"Value::$name") && + !($isHash && defined($self->{$isName}) && $self->{$isName} == 0)); } return 0; } |
From: dpvc v. a. <we...@ma...> - 2007-08-19 18:12:58
|
Log Message: ----------- The copy method was not copying all the values from the original (since it was making a new object from scratch). We now copy the complete hash and recursively copy the parse tree. Modified Files: -------------- pg/lib: Parser.pm Revision Data ------------- Index: Parser.pm =================================================================== RCS file: /webwork/cvs/system/pg/lib/Parser.pm,v retrieving revision 1.43 retrieving revision 1.44 diff -Llib/Parser.pm -Llib/Parser.pm -u -r1.43 -r1.44 --- lib/Parser.pm +++ lib/Parser.pm @@ -69,7 +69,12 @@ # # Make a copy of a formula # -sub copy {my $self = shift; $self->new($self)} +sub copy { + my $self = shift; + $self = bless {%{$self}}, ref($self); + $self->{tree} = $self->{tree}->copy($self); + return $self; +} ################################################## # |
From: dpvc v. a. <we...@ma...> - 2007-08-19 18:06:30
|
Log Message: ----------- The overridden with() method was not preserving all the settings in the Formula. This has been fixed. Modified Files: -------------- pg/lib/Value: Formula.pm Revision Data ------------- Index: Formula.pm =================================================================== RCS file: /webwork/cvs/system/pg/lib/Value/Formula.pm,v retrieving revision 1.57 retrieving revision 1.58 diff -Llib/Value/Formula.pm -Llib/Value/Formula.pm -u -r1.57 -r1.58 --- lib/Value/Formula.pm +++ lib/Value/Formula.pm @@ -32,11 +32,10 @@ # as the formula itself. # sub with { - my $self = (shift)->copy; my %hash = @_; - foreach my $id (keys(%hash)) { - $self->{tree}{$id} = $hash{$id}; - $self->{$id} = $hash{$id}; - } + my $self = shift; my %hash = @_; + $self = $self->SUPER::with(@_); + $self->{tree} = $self->{tree}->copy($self); # make a new copy pointing to the new equation. + foreach my $id (keys(%hash)) {$self->{tree}{$id} = $hash{$id}} return $self; } |
From: dpvc v. a. <we...@ma...> - 2007-08-19 15:44:18
|
Log Message: ----------- Correct the example so the answer given is actually a correct one. Modified Files: -------------- pg/macros: answerCustom.pl Revision Data ------------- Index: answerCustom.pl =================================================================== RCS file: /webwork/cvs/system/pg/macros/answerCustom.pl,v retrieving revision 1.11 retrieving revision 1.12 diff -Lmacros/answerCustom.pl -Lmacros/answerCustom.pl -u -r1.11 -r1.12 --- macros/answerCustom.pl +++ macros/answerCustom.pl @@ -52,7 +52,7 @@ # For example, the following checks if a student entered # a unit vector (any unit vector in R^3 will do): # - # custom_cmp("<1,2,3>",sub { + # custom_cmp("<1,0,0>",sub { # my ($correct,$student,$ans) = @_; # return norm($student) == 1; # }); |
From: dpvc v. a. <we...@ma...> - 2007-08-19 15:04:30
|
Log Message: ----------- Fixes to format POD documentation better. Modified Files: -------------- pg/macros: problemPreserveAnswers.pl Revision Data ------------- Index: problemPreserveAnswers.pl =================================================================== RCS file: /webwork/cvs/system/pg/macros/problemPreserveAnswers.pl,v retrieving revision 1.2 retrieving revision 1.3 diff -Lmacros/problemPreserveAnswers.pl -Lmacros/problemPreserveAnswers.pl -u -r1.2 -r1.3 --- macros/problemPreserveAnswers.pl +++ macros/problemPreserveAnswers.pl @@ -3,27 +3,28 @@ =head1 PreserveAnswers(); -###################################################################### -# -# This file implements a fragile hack to overcome a problem with -# PGbasicmacros.pl, which removes special characters from student -# answers (in order to prevent EV3 from mishandling them). -# -# Unfortunately, this means that "sticky" answers will lose -# those characters, which makes it very difficult to answer -# problems with more than one answer when the student wants -# to submit several times while working on later parts. -# -# The real fix to to rewrite PGbasicmacros.pl to handle -# this better, but this hack will handle the situation for -# now until that can be accomplished. -# -# To use this hack, simply load the file using -# -# loadMacros("problemPreserveAnswers.pl"); -# -# at the top of your PG file. -# + ###################################################################### + # + # This file implements a fragile hack to overcome a problem with + # PGbasicmacros.pl, which removes special characters from student + # answers (in order to prevent EV3 from mishandling them). + # + # Unfortunately, this means that "sticky" answers will lose + # those characters, which makes it very difficult to answer + # problems with more than one answer when the student wants + # to submit several times while working on later parts. + # + # The real fix to to rewrite PGbasicmacros.pl to handle + # this better, but this hack will handle the situation for + # now until that can be accomplished. + # + # To use this hack, simply load the file using + # + # loadMacros("problemPreserveAnswers.pl"); + # + # at the top of your PG file. + # + ###################################################################### =cut |
From: dpvc v. a. <we...@ma...> - 2007-08-19 15:00:14
|
Log Message: ----------- More fixes to POD sections. Modified Files: -------------- pg/macros: parserFunction.pl Revision Data ------------- Index: parserFunction.pl =================================================================== RCS file: /webwork/cvs/system/pg/macros/parserFunction.pl,v retrieving revision 1.7 retrieving revision 1.8 diff -Lmacros/parserFunction.pl -Lmacros/parserFunction.pl -u -r1.7 -r1.8 --- macros/parserFunction.pl +++ macros/parserFunction.pl @@ -1,7 +1,7 @@ loadMacros('MathObjects.pl'); -sub _parserFunction_init {}; # don't reload this file +sub _parserFunction_init {parserFunction::Init()}; # don't reload this file =head1 DESCRIPTION @@ -37,14 +37,16 @@ =cut -sub parserFunction {parserFunction->Create(@_)} - # # The package that will manage user-defined functions # package parserFunction; our @ISA = qw(Parser::Function); +sub Init { + main::PG_restricted_eval('sub parserFunction {parserFunction->Create(@_)}'); +} + sub Create { my $self = shift; my $name = shift; my $formula = shift; my $context = (Value::isContext($_[0]) ? shift : Value->context); @@ -126,10 +128,10 @@ =head3 ($Function)->D -# -# Compute the derivative of (single-variable) functions -# using the chain rule. -# + # + # Compute the derivative of (single-variable) functions + # using the chain rule. + # =cut @@ -143,14 +145,9 @@ return (($Df->substitute($x=>$g))*($g->D(@_)))->{tree}->reduce; } -=head3 NameForNumber($number) - # # Get the name for a number # - -=cut - sub NameForNumber { my $n = shift; my $name = ('zeroth','first','second','third','fourth','fifth', |
From: dpvc v. a. <we...@ma...> - 2007-08-19 14:50:34
|
Log Message: ----------- Now that parens->clear doesn't remove the 'start' paren, we can use clear as we can with the others. Modified Files: -------------- pg/macros: contextScientificNotation.pl Revision Data ------------- Index: contextScientificNotation.pl =================================================================== RCS file: /webwork/cvs/system/pg/macros/contextScientificNotation.pl,v retrieving revision 1.4 retrieving revision 1.5 diff -Lmacros/contextScientificNotation.pl -Lmacros/contextScientificNotation.pl -u -r1.4 -r1.5 --- macros/contextScientificNotation.pl +++ macros/contextScientificNotation.pl @@ -114,7 +114,7 @@ # $context->variables->clear; $context->constants->clear; - $context->parens->remove('(','[','{','|'); + $context->parens->clear; $context->operators->clear; $context->functions->clear; $context->strings->clear; |
From: dpvc v. a. <we...@ma...> - 2007-08-19 14:47:09
|
Log Message: ----------- Make sure clear doesn't remove the special 'start' paren that is required by the Parser class. Modified Files: -------------- pg/lib/Parser/Context: Parens.pm Revision Data ------------- Index: Parens.pm =================================================================== RCS file: /webwork/cvs/system/pg/lib/Parser/Context/Parens.pm,v retrieving revision 1.7 retrieving revision 1.8 diff -Llib/Parser/Context/Parens.pm -Llib/Parser/Context/Parens.pm -u -r1.7 -r1.8 --- lib/Parser/Context/Parens.pm +++ lib/Parser/Context/Parens.pm @@ -30,6 +30,15 @@ delete $self->{tokens}{$data->{close}} unless $data->{hidden} || $data->{close} eq $token; } +# +# Always retain 'start' since it si crucial to the parser +# +sub clear { + my $self = shift; + $self->SUPER::clear(); + $self->redefine('start'); +} + ######################################################################### 1; |
From: dpvc v. a. <we...@ma...> - 2007-08-19 03:47:24
|
Log Message: ----------- Allow formatted answers to include newlines, and convert them to <BR> so that we can try to improve the layout in the results table. (Piecewise functions will want this, since they can be very long otherwise. Raw matrix entries might want that, too.) Modified Files: -------------- pg/lib/Value: AnswerChecker.pm Revision Data ------------- Index: AnswerChecker.pm =================================================================== RCS file: /webwork/cvs/system/pg/lib/Value/AnswerChecker.pm,v retrieving revision 1.104 retrieving revision 1.105 diff -Llib/Value/AnswerChecker.pm -Llib/Value/AnswerChecker.pm -u -r1.104 -r1.105 --- lib/Value/AnswerChecker.pm +++ lib/Value/AnswerChecker.pm @@ -65,7 +65,7 @@ sub cmp { my $self = shift; my $ans = new AnswerEvaluator; - my $correct = protectHTML($self->{correct_ans}); + my $correct = preformat($self->{correct_ans}); $correct = $self->correct_ans unless defined($correct); $self->{context} = Value->context unless defined($self->{context}); $ans->ans_hash( @@ -87,7 +87,7 @@ return $ans; } -sub correct_ans {protectHTML(shift->string)} +sub correct_ans {preformat(shift->string)} sub cmp_diagnostics {} # @@ -129,16 +129,16 @@ unless Value::isValue($ans->{student_value}); $ans->{student_value}{isStudent} = 1; $ans->{preview_latex_string} = $ans->{student_formula}->TeX; - $ans->{preview_text_string} = protectHTML($ans->{student_formula}->string); + $ans->{preview_text_string} = preformat($ans->{student_formula}->string); # # Get the string for the student answer # - for ($ans->{formatStudentAnswer} || $context->flag('formatStudentAnswer')) { - /evaluated/i and do {$ans->{student_ans} = protectHTML($ans->{student_value}->string); last}; + for ($self->getFlag('formatStudentAnswer')) { + /evaluated/i and do {$ans->{student_ans} = preformat($ans->{student_value}->string); last}; /parsed/i and do {$ans->{student_ans} = $ans->{preview_text_string}; last}; /reduced/i and do { my $oldFlags = contextSet($context,reduceConstants=>1,reduceConstantFunctions=>0); - $ans->{student_ans} = protectHTML($ans->{student_formula}->substitute()->string); + $ans->{student_ans} = preformat($ans->{student_formula}->substitute()->string); contextSet($context,%{$oldFags}); last; }; warn "Unkown student answer format |$ans->{formatStudentAnswer}|"; @@ -593,13 +593,22 @@ # Quote HTML characters # sub protectHTML { - my $string = shift; - return unless defined($string); - return $string if eval ('$main::displayMode') eq 'TeX'; - $string =~ s/&/\&/g; - $string =~ s/</\</g; - $string =~ s/>/\>/g; - $string; + my $string = shift; + return unless defined($string); + return $string if eval ('$main::displayMode') eq 'TeX'; + $string =~ s/&/\&/g; + $string =~ s/</\</g; + $string =~ s/>/\>/g; + $string; +} + +# +# Convert newlines to <BR> +# +sub preformat { + my $string = protectHTML(shift); + $string =~ s!\n!<br />!g; + $string; } # |
From: dpvc v. a. <we...@ma...> - 2007-08-19 03:44:51
|
Log Message: ----------- Improved method of looking up the item class so that it will work with more deeply nested namespaces. Modified Files: -------------- pg/lib/Parser: Item.pm Revision Data ------------- Index: Item.pm =================================================================== RCS file: /webwork/cvs/system/pg/lib/Parser/Item.pm,v retrieving revision 1.13 retrieving revision 1.14 diff -Llib/Parser/Item.pm -Llib/Parser/Item.pm -u -r1.13 -r1.14 --- lib/Parser/Item.pm +++ lib/Parser/Item.pm @@ -10,9 +10,8 @@ # Return the class name of an item # sub class { - my $self = ref(shift); - $self =~ s/[^:]*:://; $self =~ s/::.*//; - return $self; + my @parts = split(/::/,ref(shift)); + return $parts[(scalar(@parts) > 2 ? -2 : -1)]; } # |
From: dpvc v. a. <we...@ma...> - 2007-08-19 02:58:18
|
Log Message: ----------- Macro files should return a non-zero value Modified Files: -------------- pg/macros: MathObjects.pl Revision Data ------------- Index: MathObjects.pl =================================================================== RCS file: /webwork/cvs/system/pg/macros/MathObjects.pl,v retrieving revision 1.6 retrieving revision 1.7 diff -Lmacros/MathObjects.pl -Lmacros/MathObjects.pl -u -r1.6 -r1.7 --- macros/MathObjects.pl +++ macros/MathObjects.pl @@ -11,6 +11,6 @@ =cut - loadMacros("Parser.pl"); +1; |
From: dpvc v. a. <we...@ma...> - 2007-08-19 02:07:38
|
Log Message: ----------- Normalized comments and headers to that they will format their POD documentation properly. (I know that the POD processing was supposed to strip off the initial #, but that doesn't seem to happen, so I've added a space throughout.) Modified Files: -------------- pg/macros: MathObjects.pl Parser.pl Value.pl answerComposition.pl answerHints.pl answerVariableList.pl contextABCD.pl contextCurrency.pl contextInequalities.pl contextIntegerFunctions.pl contextLimitedComplex.pl contextLimitedNumeric.pl contextLimitedPoint.pl contextLimitedPolynomial.pl contextLimitedPowers.pl contextLimitedVector.pl contextScientificNotation.pl contextString.pl contextTF.pl parserCustomization.pl parserDifferenceQuotient.pl parserFormulaWithUnits.pl parserFunction.pl parserImplicitEquation.pl parserImplicitPlane.pl parserMultiAnswer.pl parserMultiPart.pl parserNumberWithUnits.pl parserParametricLine.pl parserPopUp.pl parserRadioButtons.pl parserSolutionFor.pl parserVectorUtils.pl problemPreserveAnswers.pl problemRandomize.pl Revision Data ------------- Index: parserParametricLine.pl =================================================================== RCS file: /webwork/cvs/system/pg/macros/parserParametricLine.pl,v retrieving revision 1.9 retrieving revision 1.10 diff -Lmacros/parserParametricLine.pl -Lmacros/parserParametricLine.pl -u -r1.9 -r1.10 --- macros/parserParametricLine.pl +++ macros/parserParametricLine.pl @@ -4,40 +4,40 @@ =head1 DESCRIPTION -###################################################################### -# -# This is a Parser class that implements parametric lines as -# a subclass of the Formula class. The standard ->cmp routine -# will work for this, provided we define the compare() function -# needed by the overloaded ==. We assign the special precedence -# so that overloaded operations will be promoted to the ones below. -# -# Use ParametricLine(point,vector) or ParametricLine(formula) -# to create a ParametricLine object. You can pass an optional -# additional parameter that indicated the variable to use for the -# parameter for the line. -# -# Usage examples: -# -# $L = ParametricLine(Point(3,-1,2),Vector(1,1,3)); -# $L = ParametricLine([3,-1,2],[1,1,3]); -# $L = ParametricLine("<t,1-t,2t-3>"); -# -# $p = Point(3,-1,2); $v = Vector(1,1,3); -# $L = ParametricLine($p,$v); -# -# $t = Formula('t'); $p = Point(3,-1,2); $v = Vector(1,1,3); -# $L = ParametricLine($p+$t*$v); -# -# Context()->constants->are(a=>1+pi^2); # won't guess this value -# $L = ParametricLine("(a,2a,-1) + t <1,a,a^2>"); -# -# Then use -# -# ANS($L->cmp); -# -# to get the answer checker for $L. -# + ###################################################################### + # + # This is a Parser class that implements parametric lines as + # a subclass of the Formula class. The standard ->cmp routine + # will work for this, provided we define the compare() function + # needed by the overloaded ==. We assign the special precedence + # so that overloaded operations will be promoted to the ones below. + # + # Use ParametricLine(point,vector) or ParametricLine(formula) + # to create a ParametricLine object. You can pass an optional + # additional parameter that indicated the variable to use for the + # parameter for the line. + # + # Usage examples: + # + # $L = ParametricLine(Point(3,-1,2),Vector(1,1,3)); + # $L = ParametricLine([3,-1,2],[1,1,3]); + # $L = ParametricLine("<t,1-t,2t-3>"); + # + # $p = Point(3,-1,2); $v = Vector(1,1,3); + # $L = ParametricLine($p,$v); + # + # $t = Formula('t'); $p = Point(3,-1,2); $v = Vector(1,1,3); + # $L = ParametricLine($p+$t*$v); + # + # Context()->constants->are(a=>1+pi^2); # won't guess this value + # $L = ParametricLine("(a,2a,-1) + t <1,a,a^2>"); + # + # Then use + # + # ANS($L->cmp); + # + # to get the answer checker for $L. + # =cut Index: contextLimitedPoint.pl =================================================================== RCS file: /webwork/cvs/system/pg/macros/contextLimitedPoint.pl,v retrieving revision 1.6 retrieving revision 1.7 diff -Lmacros/contextLimitedPoint.pl -Lmacros/contextLimitedPoint.pl -u -r1.6 -r1.7 --- macros/contextLimitedPoint.pl +++ macros/contextLimitedPoint.pl @@ -5,13 +5,13 @@ =head3 Context("LimitedPoint") -########################################################## -# -# Implements a context in which points can be entered, -# but no operations are permitted between points. So -# students will be able to perform operations within the -# coordinates of the points, but not between points. -# + ########################################################## + # + # Implements a context in which points can be entered, + # but no operations are permitted between points. So + # students will be able to perform operations within the + # coordinates of the points, but not between points. + # =cut @@ -144,3 +144,5 @@ $context{LimitedPoint}->constants->remove('i','j','k'); Context("LimitedPoint"); + +1; Index: contextString.pl =================================================================== RCS file: /webwork/cvs/system/pg/macros/contextString.pl,v retrieving revision 1.8 retrieving revision 1.9 diff -Lmacros/contextString.pl -Lmacros/contextString.pl -u -r1.8 -r1.9 --- macros/contextString.pl +++ macros/contextString.pl @@ -4,21 +4,20 @@ =head3 Context("String") -########################################################## -# -# Implements contexts for string-valued answers. -# -# You can add new strings to the context as needed -# via the Context()->strings->add() method. E.g., -# -# Context("String")->strings->add(Foo=>{}, Bar=>{alias=>"Foo"}); -# -# Use string_cmp() to produce the answer checker(s) for your -# correct values. Eg. -# -# ANS(string_cmp("Foo")); -# -# + ########################################################## + # + # Implements contexts for string-valued answers. + # + # You can add new strings to the context as needed + # via the Context()->strings->add() method. E.g., + # + # Context("String")->strings->add(Foo=>{}, Bar=>{alias=>"Foo"}); + # + # Use string_cmp() to produce the answer checker(s) for your + # correct values. Eg. + # + # ANS(string_cmp("Foo")); + # =cut @@ -66,3 +65,5 @@ return map {String($_)->cmp(showHints=>0,showLengthHints=>0)} @{$strings}; } +1; + Index: parserImplicitPlane.pl =================================================================== RCS file: /webwork/cvs/system/pg/macros/parserImplicitPlane.pl,v retrieving revision 1.13 retrieving revision 1.14 diff -Lmacros/parserImplicitPlane.pl -Lmacros/parserImplicitPlane.pl -u -r1.13 -r1.14 --- macros/parserImplicitPlane.pl +++ macros/parserImplicitPlane.pl @@ -4,49 +4,49 @@ =head1 DESCRIPTION -###################################################################### -# -# This is a Parser class that implements implicit planes as -# a subclass of the Formula class. The standard ->cmp routine -# will work for this, provided we define the compare() function -# needed by the overloaded ==. We assign the special precedence -# so that overloaded operations will be promoted to the ones below. -# -# -# Use ImplicitPlane(point,vector), ImplicitPlane(point,number) or -# ImplicitPlane(formula) to create an ImplicitPlane object. -# The first form uses the point as a point on the plane and the -# vector as the normal for the plane. The second form uses the point -# as the coefficients of the variables and the number as the value -# that the formula must equal. The third form uses the formula -# directly. -# -# The number of variables in the Context determines the dimension of -# the "plane" being defined. If there are only two, the formula -# produces an implicit line, but if there are four variables, it will -# be a hyperplane in four-space. You can specify the variables you -# want to use by supplying an additional parameter, which is a -# reference to an array of variable names. -# -# -# Usage examples: -# -# $P = ImplicitPlane(Point(1,0,2),Vector(-1,1,3)); # -x+y+3z = 5 -# $P = ImplicitPlane([1,0,2],[-1,1,3]); # -x+y+3z = 5 -# $P = ImplicitPlane([1,0,2],4); # x+2z = 4 -# $P = ImplicitPlane("x+2y-z=5"); -# -# Context()->variables->are(x=>'Real',y=>'Real',z=>'Real',w=>'Real'); -# $P = ImplicitPlane([1,0,2,-1],10); # w+2y-z = 10 (alphabetical order) -# $P = ImplicitPlane([3,-1,2,4],5,['x','y','z','w']); # 3x-y+2z+4w = 5 -# $P = ImplicitPlane([3,-1,2],5,['y','z','w']); # 3y-z+2w = 5 -# -# Then use -# -# ANS($P->cmp); -# -# to get the answer checker for $P. -# + ###################################################################### + # + # This is a Parser class that implements implicit planes as + # a subclass of the Formula class. The standard ->cmp routine + # will work for this, provided we define the compare() function + # needed by the overloaded ==. We assign the special precedence + # so that overloaded operations will be promoted to the ones below. + # + # + # Use ImplicitPlane(point,vector), ImplicitPlane(point,number) or + # ImplicitPlane(formula) to create an ImplicitPlane object. + # The first form uses the point as a point on the plane and the + # vector as the normal for the plane. The second form uses the point + # as the coefficients of the variables and the number as the value + # that the formula must equal. The third form uses the formula + # directly. + # + # The number of variables in the Context determines the dimension of + # the "plane" being defined. If there are only two, the formula + # produces an implicit line, but if there are four variables, it will + # be a hyperplane in four-space. You can specify the variables you + # want to use by supplying an additional parameter, which is a + # reference to an array of variable names. + # + # + # Usage examples: + # + # $P = ImplicitPlane(Point(1,0,2),Vector(-1,1,3)); # -x+y+3z = 5 + # $P = ImplicitPlane([1,0,2],[-1,1,3]); # -x+y+3z = 5 + # $P = ImplicitPlane([1,0,2],4); # x+2z = 4 + # $P = ImplicitPlane("x+2y-z=5"); + # + # Context()->variables->are(x=>'Real',y=>'Real',z=>'Real',w=>'Real'); + # $P = ImplicitPlane([1,0,2,-1],10); # w+2y-z = 10 (alphabetical order) + # $P = ImplicitPlane([3,-1,2,4],5,['x','y','z','w']); # 3x-y+2z+4w = 5 + # $P = ImplicitPlane([3,-1,2],5,['y','z','w']); # 3y-z+2w = 5 + # + # Then use + # + # ANS($P->cmp); + # + # to get the answer checker for $P. + # =cut Index: contextLimitedVector.pl =================================================================== RCS file: /webwork/cvs/system/pg/macros/contextLimitedVector.pl,v retrieving revision 1.6 retrieving revision 1.7 diff -Lmacros/contextLimitedVector.pl -Lmacros/contextLimitedVector.pl -u -r1.6 -r1.7 --- macros/contextLimitedVector.pl +++ macros/contextLimitedVector.pl @@ -4,28 +4,28 @@ =head3 Context("LimitedVector") -########################################################## -# -# Implements a context in which vectors can be entered, -# but no vector operations are permitted. So students will -# be able to perform operations within the coordinates -# of the vectors, but not between vectors. -# -# Vectors can still be entered either in < , , > or ijk format. -# Most of the complication here is to handle ijk format -# properly. Each coordinate vector is allowed to appear -# only once, so we have to keep track of that, and allow -# SOME vector operations, but only when one term is -# one of the coordinate constants, or one of the formulas -# we've already OKed. -# -# You control which format to use by setting the context -# to one of the following: -# -# Context("LimitedVector-coordinate"); -# Context("LimitedVector-ijk"); -# Context("LimitedVector"); # either one -# + ########################################################## + # + # Implements a context in which vectors can be entered, + # but no vector operations are permitted. So students will + # be able to perform operations within the coordinates + # of the vectors, but not between vectors. + # + # Vectors can still be entered either in < , , > or ijk format. + # Most of the complication here is to handle ijk format + # properly. Each coordinate vector is allowed to appear + # only once, so we have to keep track of that, and allow + # SOME vector operations, but only when one term is + # one of the coordinate constants, or one of the formulas + # we've already OKed. + # + # You control which format to use by setting the context + # to one of the following: + # + # Context("LimitedVector-coordinate"); + # Context("LimitedVector-ijk"); + # Context("LimitedVector"); # either one + # =cut @@ -246,3 +246,5 @@ $context{'LimitedVector-coordinate'}->constants->undefine('i','j','k'); Context("LimitedVector"); + +1; Index: MathObjects.pl =================================================================== RCS file: /webwork/cvs/system/pg/macros/MathObjects.pl,v retrieving revision 1.5 retrieving revision 1.6 diff -Lmacros/MathObjects.pl -Lmacros/MathObjects.pl -u -r1.5 -r1.6 --- macros/MathObjects.pl +++ macros/MathObjects.pl @@ -2,12 +2,12 @@ =pod -# This file loads Parser.pl which in turn loads Value.pl -# The purpose of this file 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). +This file loads Parser.pl which in turn loads Value.pl +The purpose of this file 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. +It may later be used for other purposes as well. =cut Index: parserNumberWithUnits.pl =================================================================== RCS file: /webwork/cvs/system/pg/macros/parserNumberWithUnits.pl,v retrieving revision 1.4 retrieving revision 1.5 diff -Lmacros/parserNumberWithUnits.pl -Lmacros/parserNumberWithUnits.pl -u -r1.4 -r1.5 --- macros/parserNumberWithUnits.pl +++ macros/parserNumberWithUnits.pl @@ -4,27 +4,27 @@ =head1 DESCRIPTION -###################################################################### -# -# This is a Parser class that implements a number with units. -# It is a temporary version until the Parser can handle it -# directly. -# -# Use NumberWithUnits("num units") or NumberWithUnits(formula,"units") -# to generate a NumberWithUnits object, and then call its cmp method -# to get an answer checker for your number with units. -# -# Usage examples: -# -# ANS(NumberWithUnits("3 ft")->cmp); -# ANS(NumberWithUnits("$a*$b ft")->cmp); -# ANS(NumberWithUnits($a*$b,"ft")->cmp); -# + ###################################################################### + # + # This is a Parser class that implements a number with units. + # It is a temporary version until the Parser can handle it + # directly. + # + # Use NumberWithUnits("num units") or NumberWithUnits(formula,"units") + # to generate a NumberWithUnits object, and then call its cmp method + # to get an answer checker for your number with units. + # + # Usage examples: + # + # ANS(NumberWithUnits("3 ft")->cmp); + # ANS(NumberWithUnits("$a*$b ft")->cmp); + # ANS(NumberWithUnits($a*$b,"ft")->cmp); + # -# -# We now call on the Legacy version, which is used by -# num_cmp to handle numbers with units. -# + # + # We now call on the Legacy version, which is used by + # num_cmp to handle numbers with units. + # =cut Index: contextLimitedComplex.pl =================================================================== RCS file: /webwork/cvs/system/pg/macros/contextLimitedComplex.pl,v retrieving revision 1.6 retrieving revision 1.7 diff -Lmacros/contextLimitedComplex.pl -Lmacros/contextLimitedComplex.pl -u -r1.6 -r1.7 --- macros/contextLimitedComplex.pl +++ macros/contextLimitedComplex.pl @@ -276,3 +276,5 @@ $context{'LimitedComplex-strict'}->functions->disable('All'); Context("LimitedComplex"); + +1; Index: contextCurrency.pl =================================================================== RCS file: /webwork/cvs/system/pg/macros/contextCurrency.pl,v retrieving revision 1.3 retrieving revision 1.4 diff -Lmacros/contextCurrency.pl -Lmacros/contextCurrency.pl -u -r1.3 -r1.4 --- macros/contextCurrency.pl +++ macros/contextCurrency.pl @@ -1,111 +1,107 @@ - -=pod - -###################################################################### -# -# This file implements a context in which students can enter currency -# values that include a currency symbol and commas every three digits. -# You can specify what the currency symbol is, as well as what gets -# used for commas and decimals. -# -# To use the context, put -# -# loadMacros("contextCurrency.pl"); -# -# at the top of your problem file, and then issue the -# -# Context("Currency"); -# -# command to select the context. You can set the currency symbol -# and the comma or decimal values as in the following examples -# -# Context()->currency->set(symbol=>'#'); -# Context()->currency->set(symbol=>'euro'); # accepts '12 euro' -# Context()->currency->set(comma=>'.',decimal=>','); # accepts '10.000,00' -# -# You can add additional symbols (in case you want to allow -# more than one way to write the currency). For example: -# -# Context("Currency")->currency->addSymbol("dollars","dollar"); -# -# would accept '$12,345.67' or '12.50 dollars' or '1 dollar' as -# acceptable values. Note that if the symbol cantains any -# alphabetic characters, it is expected to come at the end of the -# number (as in the examples above) and if the symbol has only -# non-alphabetic characters, it comes before it. You can change -# this as in these examples: -# -# Context()->currency->setSymbol(euro=>{associativity=>"left"}); -# Context()->currency->setSymbol('#'=>{associativity=>"right"}); -# -# You can remove a symbol as follows: -# -# Context()->currency->removeSymbol('dollar'); -# -# To create a currency value, use -# -# $m = Currency(10.99); -# -# or -# -# $m1 = Compute('$10.99'); -# $m2 = Compute('$10,000.00'); -# -# and so on. Be careful, however, that you do not put dollar signs -# inside double quotes, as this refers to variable substitution. -# For example, -# -# $m = Compute("$10.99"); -# -# will most likely set $m to the Real value .99 rather than the -# monitary value of $10.99, since perl thinks $10 is the name of -# a variable, and will substitute that into the string before -# processing it. Since that variable is most likely empty, the -# result will be the same as $m = Compute(".99"); -# -# You can use monitary values within computations, as in -# -# $m1 = Compute('$10.00'); -# $m2 = 3*$m1; $m3 = $m2 + .5; -# $m4 = Compute('$10.00 + $2.59'); -# -# so that $m2 will be $30.00, $m3 will be $30.50, and $m4 will -# be $12.59. Students can perform computations within their -# answers unless you disable the operators and functions as well. -# -# The tolerance for this context is set initially to .005 and the -# tolType to 'absolute' so that monitary values will have to match -# to the nearest penny. You can change that on a global basis -# using -# -# Context()->flags->set(tolerance=>.0001,tolType=>"relative"); -# -# for example. You can also change the tolerance on an individual -# currency value as follows: -# -# $m = Compute('$1,250,000.00')-> -# with(tolerance=>.0001,tolType=>'relative'); -# -# By default, the answer checker for Currency values requires -# the student to enter the currency symbol, not just a real number. -# You can relax that condition by including the promoteReals=>1 -# option to the cmp() method of the Currency value. For example, -# -# ANS(Compute('$150')->cmp(promoteReals=>1)); -# -# would allow the student to enter just 150 rather than $150. -# -###################################################################### - -=cut - loadMacros("MathObjects.pl"); +loadMacros("problemPreserveAnswers.pl"); # needed to preserve $ in answers sub _contextCurrency_init {Currency::Init()} -###################################################################### +=head1 Context("Currency"); -loadMacros("problemPreserveAnswers.pl"); # needed to preserve $ in answers + ###################################################################### + # + # This file implements a context in which students can enter currency + # values that include a currency symbol and commas every three digits. + # You can specify what the currency symbol is, as well as what gets + # used for commas and decimals. + # + # To use the context, put + # + # loadMacros("contextCurrency.pl"); + # + # at the top of your problem file, and then issue the + # + # Context("Currency"); + # + # command to select the context. You can set the currency symbol + # and the comma or decimal values as in the following examples + # + # Context()->currency->set(symbol=>'#'); + # Context()->currency->set(symbol=>'euro'); # accepts '12 euro' + # Context()->currency->set(comma=>'.',decimal=>','); # accepts '10.000,00' + # + # You can add additional symbols (in case you want to allow + # more than one way to write the currency). For example: + # + # Context("Currency")->currency->addSymbol("dollars","dollar"); + # + # would accept '$12,345.67' or '12.50 dollars' or '1 dollar' as + # acceptable values. Note that if the symbol cantains any + # alphabetic characters, it is expected to come at the end of the + # number (as in the examples above) and if the symbol has only + # non-alphabetic characters, it comes before it. You can change + # this as in these examples: + # + # Context()->currency->setSymbol(euro=>{associativity=>"left"}); + # Context()->currency->setSymbol('#'=>{associativity=>"right"}); + # + # You can remove a symbol as follows: + # + # Context()->currency->removeSymbol('dollar'); + # + # To create a currency value, use + # + # $m = Currency(10.99); + # + # or + # + # $m1 = Compute('$10.99'); + # $m2 = Compute('$10,000.00'); + # + # and so on. Be careful, however, that you do not put dollar signs + # inside double quotes, as this refers to variable substitution. + # For example, + # + # $m = Compute("$10.99"); + # + # will most likely set $m to the Real value .99 rather than the + # monitary value of $10.99, since perl thinks $10 is the name of + # a variable, and will substitute that into the string before + # processing it. Since that variable is most likely empty, the + # result will be the same as $m = Compute(".99"); + # + # You can use monitary values within computations, as in + # + # $m1 = Compute('$10.00'); + # $m2 = 3*$m1; $m3 = $m2 + .5; + # $m4 = Compute('$10.00 + $2.59'); + # + # so that $m2 will be $30.00, $m3 will be $30.50, and $m4 will + # be $12.59. Students can perform computations within their + # answers unless you disable the operators and functions as well. + # + # The tolerance for this context is set initially to .005 and the + # tolType to 'absolute' so that monitary values will have to match + # to the nearest penny. You can change that on a global basis + # using + # + # Context()->flags->set(tolerance=>.0001,tolType=>"relative"); + # + # for example. You can also change the tolerance on an individual + # currency value as follows: + # + # $m = Compute('$1,250,000.00')-> + # with(tolerance=>.0001,tolType=>'relative'); + # + # By default, the answer checker for Currency values requires + # the student to enter the currency symbol, not just a real number. + # You can relax that condition by including the promoteReals=>1 + # option to the cmp() method of the Currency value. For example, + # + # ANS(Compute('$150')->cmp(promoteReals=>1)); + # + # would allow the student to enter just 150 rather than $150. + # + ###################################################################### + +=cut package Currency; Index: contextABCD.pl =================================================================== RCS file: /webwork/cvs/system/pg/macros/contextABCD.pl,v retrieving revision 1.7 retrieving revision 1.8 diff -Lmacros/contextABCD.pl -Lmacros/contextABCD.pl -u -r1.7 -r1.8 --- macros/contextABCD.pl +++ macros/contextABCD.pl @@ -4,33 +4,33 @@ =head1 DESCRIPTION -########################################################## -# -# Implements contexts for string-valued answers especially -# for matching problems (where you match against A, B, C, D, -# and so on). -# -# There are two contexts defined here, -# -# Context("ABCD"); -# Context("ABCD-List"); -# -# The second allows the students to enter lists of strings, -# while the first does not. -# -# You can add new strings to the context as needed (or remove old ones) -# via the Context()->strings->add() and Context()-strings->remove() -# methods, eg. -# -# Context("ABCD-List")->strings->add(E=>{},e=>{alias=>"E"}); -# -# Use string_cmp() to produce the answer checker(s) for your -# correct values. Eg. -# -# ANS(string_cmp("A","B")); -# -# when there are two answers, the first being "A" and the second being "B". -# + ########################################################## + # + # Implements contexts for string-valued answers especially + # for matching problems (where you match against A, B, C, D, + # and so on). + # + # There are two contexts defined here, + # + # Context("ABCD"); + # Context("ABCD-List"); + # + # The second allows the students to enter lists of strings, + # while the first does not. + # + # You can add new strings to the context as needed (or remove old ones) + # via the Context()->strings->add() and Context()-strings->remove() + # methods, eg. + # + # Context("ABCD-List")->strings->add(E=>{},e=>{alias=>"E"}); + # + # Use string_cmp() to produce the answer checker(s) for your + # correct values. Eg. + # + # ANS(string_cmp("A","B")); + # + # when there are two answers, the first being "A" and the second being "B". + # =cut @@ -49,3 +49,5 @@ $context{'ABCD-List'}->strings->add("NONE"=>{}); Context("ABCD"); + +1; Index: parserMultiPart.pl =================================================================== RCS file: /webwork/cvs/system/pg/macros/parserMultiPart.pl,v retrieving revision 1.9 retrieving revision 1.10 diff -Lmacros/parserMultiPart.pl -Lmacros/parserMultiPart.pl -u -r1.9 -r1.10 --- macros/parserMultiPart.pl +++ macros/parserMultiPart.pl @@ -2,13 +2,13 @@ =head3 MultiPart -###################################################################### -# -# This object has been renamed MultiAnswer and is now available in -# parserMultiAnswer.pl. Loading this file will produce a warning -# to that effect. -# -###################################################################### + ###################################################################### + # + # This object has been renamed MultiAnswer and is now available in + # parserMultiAnswer.pl. Using a MultiPart object will produce a + # warning to that effect. + # + ###################################################################### =cut Index: answerHints.pl =================================================================== RCS file: /webwork/cvs/system/pg/macros/answerHints.pl,v retrieving revision 1.2 retrieving revision 1.3 diff -Lmacros/answerHints.pl -Lmacros/answerHints.pl -u -r1.2 -r1.3 --- macros/answerHints.pl +++ macros/answerHints.pl @@ -1,77 +1,77 @@ sub _answerHints_init {} -=head1 AnswerHints +=head1 AnswerHints() -# This is an answer-checker post-filter that allows you to produce -# additional error messages for incorrect answers. You can trigger -# a message for a single answer, a collection of answers, or via a -# subroutine that determines the condition for the message. -# -# Note that this filter only works for MathObjects answer checkers. -# -# The answer hints are given as a pair using => with the right-hand -# side being the answer message and the left-hand side being one of -# three possibilities: 1) the value that triggers the message, -# 2) a reference to an array of values that trigger the message, or -# 3) a code reference to a subtroutine that accepts tthe correct -# answer, the student's answer, and the answer hash, and returns -# 1 or 0 depending on whether the message should or should not be -# displayed. (See the examples below.) -# -# The right-hand side can be either the message string itself, or -# a referrence to an array where the first element is the message -# string, and the remaining elements are name-value pairs that -# set options for the message. These can include: -# -# checkCorrect => 0 or 1 1 means check for messages even -# if the answer is correct. -# Default: 0 -# -# replaceMessage => 0 or 1 1 means it's OK to repalce any -# message that is already in place -# in the answer hash. -# Default: 0 -# -# checkTypes => 0 or 1 1 means only perform the test -# if the student answer is the -# same type as the correct one. -# Default: 1 -# -# score => number Specifies the score to use if -# the message is triggered (so that -# partial credit can be given). -# Default: keep original score -# -# cmp_options => [...] provides options for the cmp routine -# used to check if the student answer -# matches these answers. -# Default: [] -# -# If more than one message matches the student's answer, the first -# one in the list is used. -# -# Example: -# -# ANS(Vector(1,2,3)->cmp(showCoordinateHints=>0)->withPostFilter(AnswerHints( -# Vector(0,0,0) => "The zero vector is not a valid solution", -# "-<1,2,3>" => "Try the opposite direction", -# "<1,2,3>" => "Well done!", -# ["<1,1,1>","<2,2,2>","<3,3,3>"] => "Don't just guess!", -# sub { -# my ($correct,$student,$ans) = @_; -# return $correct . $student == 0; -# } => "Your answer is perpendicular to the correct one", -# Vector(1,2,3) => [ -# "You have the right direction, but not length", -# cmp_options => [parallel=>1], -# ], -# 0 => ["Careful, your answer should be a vector!", checkTypes => 0, replaceMessage => 1], -# sub { -# my ($correct,$student,$ans) = @_; -# return norm($correct-$student) < .1; -# } => ["Close! Keep trying.", score => .25], -# ))); -# + # This is an answer-checker post-filter that allows you to produce + # additional error messages for incorrect answers. You can trigger + # a message for a single answer, a collection of answers, or via a + # subroutine that determines the condition for the message. + # + # Note that this filter only works for MathObjects answer checkers. + # + # The answer hints are given as a pair using => with the right-hand + # side being the answer message and the left-hand side being one of + # three possibilities: 1) the value that triggers the message, + # 2) a reference to an array of values that trigger the message, or + # 3) a code reference to a subtroutine that accepts tthe correct + # answer, the student's answer, and the answer hash, and returns + # 1 or 0 depending on whether the message should or should not be + # displayed. (See the examples below.) + # + # The right-hand side can be either the message string itself, or + # a referrence to an array where the first element is the message + # string, and the remaining elements are name-value pairs that + # set options for the message. These can include: + # + # checkCorrect => 0 or 1 1 means check for messages even + # if the answer is correct. + # Default: 0 + # + # replaceMessage => 0 or 1 1 means it's OK to repalce any + # message that is already in place + # in the answer hash. + # Default: 0 + # + # checkTypes => 0 or 1 1 means only perform the test + # if the student answer is the + # same type as the correct one. + # Default: 1 + # + # score => number Specifies the score to use if + # the message is triggered (so that + # partial credit can be given). + # Default: keep original score + # + # cmp_options => [...] provides options for the cmp routine + # used to check if the student answer + # matches these answers. + # Default: [] + # + # If more than one message matches the student's answer, the first + # one in the list is used. + # + # Example: + # + # ANS(Vector(1,2,3)->cmp(showCoordinateHints=>0)->withPostFilter(AnswerHints( + # Vector(0,0,0) => "The zero vector is not a valid solution", + # "-<1,2,3>" => "Try the opposite direction", + # "<1,2,3>" => "Well done!", + # ["<1,1,1>","<2,2,2>","<3,3,3>"] => "Don't just guess!", + # sub { + # my ($correct,$student,$ans) = @_; + # return $correct . $student == 0; + # } => "Your answer is perpendicular to the correct one", + # Vector(1,2,3) => [ + # "You have the right direction, but not length", + # cmp_options => [parallel=>1], + # ], + # 0 => ["Careful, your answer should be a vector!", checkTypes => 0, replaceMessage => 1], + # sub { + # my ($correct,$student,$ans) = @_; + # return norm($correct-$student) < .1; + # } => ["Close! Keep trying.", score => .25], + # ))); + # =cut Index: contextLimitedPowers.pl =================================================================== RCS file: /webwork/cvs/system/pg/macros/contextLimitedPowers.pl,v retrieving revision 1.9 retrieving revision 1.10 diff -Lmacros/contextLimitedPowers.pl -Lmacros/contextLimitedPowers.pl -u -r1.9 -r1.10 --- macros/contextLimitedPowers.pl +++ macros/contextLimitedPowers.pl @@ -3,80 +3,84 @@ sub _contextLimitedPowers_init {}; # don't load it again =head3 LimitedPowers::NoBaseE(); + =head3 LimitedPowers::OnlyIntegers(); + =head3 LimitedPowers::OnlyNonNegativeIntegers(); + =head3 LimitedPowers::OnlyPositiveIntegers(); + =head3 LimitedPowers::OnlyNonTrivialPositiveIntegers(); -########################################################## -# -# Implements subclasses of the "^" operator that restrict -# the base or power that is allowed. There are four -# available restrictions: -# -# No raising e to a power -# Only allowing integer powers (positive or negative) -# Only allowing positive interger powers -# Only allowing positive interger powers (and 0) -# -# You install these via one of the commands: -# -# LimitedPowers::NoBaseE(); -# LimitedPowers::OnlyIntegers(); -# LimitedPowers::OnlyPositiveIntegers(); -# LimitedPowers::OnlyNonNegativeIntegers(); -# -# Only one of the three can be in effect at a time; setting -# a second one overrides the first. -# -# These function affect the current context, or you can pass -# a context reference, as in -# -# $context = Context("Numeric")->copy; -# LimitedPowers::OnlyIntegers($context); -# -# For the Interger power functions, you can pass additional -# parameters that control the range of values that are allowed -# for the powers. The oprtions include: -# -# minPower => m only integer powers bigger than or equal -# to m are allowed. (If m is undef, then -# there is no minimum power.) -# -# maxPower => M only integer powers less than or equal -# to M are allowed. (If M is undef, then -# there is no maximum power.) -# -# message => "text" a description of the type of power -# allowed (e.g., "positive integer constants"); -# -# checker => code a reference to a subroutine that will be -# used to check if the powers are acceptable. -# It should accept a reference to the BOP::power -# structure and return 1 or 0 depending on -# whether the power is OK or not. -# -# For example: -# -# LimitedPowers::OnlyIntegers( -# minPower => -5, maxPower => 5, -# message => "integer constants between -5 and 5", -# ); -# -# would accept only powers between -5 and 5, while -# -# LimitedPowers::OnlyIntegers( -# checker => sub { -# return 0 unless LimitedPowers::isInteger(@_); -# my $self = shift; my $p = shift; # the power as a constant -# return $p != 0 && $p != 1; -# }, -# message => "integer constants other than 0 or 1", -# ); -# -# would accept any integer power other than 0 and 1. -# -########################################################## + ########################################################## + # + # Implements subclasses of the "^" operator that restrict + # the base or power that is allowed. There are four + # available restrictions: + # + # No raising e to a power + # Only allowing integer powers (positive or negative) + # Only allowing positive interger powers + # Only allowing positive interger powers (and 0) + # + # You install these via one of the commands: + # + # LimitedPowers::NoBaseE(); + # LimitedPowers::OnlyIntegers(); + # LimitedPowers::OnlyPositiveIntegers(); + # LimitedPowers::OnlyNonNegativeIntegers(); + # + # Only one of the three can be in effect at a time; setting + # a second one overrides the first. + # + # These function affect the current context, or you can pass + # a context reference, as in + # + # $context = Context("Numeric")->copy; + # LimitedPowers::OnlyIntegers($context); + # + # For the Interger power functions, you can pass additional + # parameters that control the range of values that are allowed + # for the powers. The oprtions include: + # + # minPower => m only integer powers bigger than or equal + # to m are allowed. (If m is undef, then + # there is no minimum power.) + # + # maxPower => M only integer powers less than or equal + # to M are allowed. (If M is undef, then + # there is no maximum power.) + # + # message => "text" a description of the type of power + # allowed (e.g., "positive integer constants"); + # + # checker => code a reference to a subroutine that will be + # used to check if the powers are acceptable. + # It should accept a reference to the BOP::power + # structure and return 1 or 0 depending on + # whether the power is OK or not. + # + # For example: + # + # LimitedPowers::OnlyIntegers( + # minPower => -5, maxPower => 5, + # message => "integer constants between -5 and 5", + # ); + # + # would accept only powers between -5 and 5, while + # + # LimitedPowers::OnlyIntegers( + # checker => sub { + # return 0 unless LimitedPowers::isInteger(@_); + # my $self = shift; my $p = shift; # the power as a constant + # return $p != 0 && $p != 1; + # }, + # message => "integer constants other than 0 or 1", + # ); + # + # would accept any integer power other than 0 and 1. + # + ########################################################## =cut Index: contextTF.pl =================================================================== RCS file: /webwork/cvs/system/pg/macros/contextTF.pl,v retrieving revision 1.8 retrieving revision 1.9 diff -Lmacros/contextTF.pl -Lmacros/contextTF.pl -u -r1.8 -r1.9 --- macros/contextTF.pl +++ macros/contextTF.pl @@ -4,23 +4,23 @@ =head3 Context("TF") -########################################################## -# -# Implements contexts for string-valued answers especially -# for matching problems (where you match against T and F). -# -# Context("TF"); -# -# You can add new strings to the context as needed (or remove old ones) -# via the Context()->strings->add() and Context()-strings->remove() -# methods. -# -# Use: -# -# ANS(string_cmp("T","F")); -# -# when there are two answers, the first being "T" and the second being "F". -# + ########################################################## + # + # Implements contexts for string-valued answers especially + # for matching problems (where you match against T and F). + # + # Context("TF"); + # + # You can add new strings to the context as needed (or remove old ones) + # via the Context()->strings->add() and Context()-strings->remove() + # methods. + # + # Use: + # + # ANS(string_cmp("T","F")); + # + # when there are two answers, the first being "T" and the second being "F". + # =cut @@ -34,4 +34,4 @@ Context("TF"); - +1; Index: Parser.pl =================================================================== RCS file: /webwork/cvs/system/pg/macros/Parser.pl,v retrieving revision 1.11 retrieving revision 1.12 diff -Lmacros/Parser.pl -Lmacros/Parser.pl -u -r1.11 -r1.12 --- macros/Parser.pl +++ macros/Parser.pl @@ -2,10 +2,10 @@ =head1 DESCRIPTION -########################################################################### -## -## Set up the functions needed by the Parser. -## + ########################################################################### + ## + ## Set up the functions needed by the Parser. + ## =cut @@ -29,10 +29,10 @@ =head3 Formula("formula") -# -# The main way to get a MathObject Formula object (an equation -# that depends on one or more variables). -# + # + # The main way to get a MathObject Formula object (an equation + # that depends on one or more variables). + # =cut @@ -43,25 +43,25 @@ =head3 Compute("formula"[,var=>value,...]) -# -# Compute the value of a formula and return a MathObject appropriate -# to its value. Set the object so that the correct answer will be -# shown exatly as in the given string rather than by its usual -# stringification. If the value is a Formula and any var=>value -# pairs are specified, then the formula will be evaluated using -# the given variable values. E.g., -# -# $x = Compute("x+3",x=>2) -# -# will produce the equivalent of $x = Real(5). -# -# The original parsed formula will be saved in the object's -# original_formula field, and can be obtained by -# -# $x->{original_formula}; -# -# if needed later in the problem. -# + # + # Compute the value of a formula and return a MathObject appropriate + # to its value. Set the object so that the correct answer will be + # shown exatly as in the given string rather than by its usual + # stringification. If the value is a Formula and any var=>value + # pairs are specified, then the formula will be evaluated using + # the given variable values. E.g., + # + # $x = Compute("x+3",x=>2) + # + # will produce the equivalent of $x = Real(5). + # + # The original parsed formula will be saved in the object's + # original_formula field, and can be obtained by + # + # $x->{original_formula}; + # + # if needed later in the problem. + # =cut @@ -80,12 +80,12 @@ =head3 Context(), Context(name) or Context(context) -# -# Set or get the current context. When a name is given, the context -# with that name is selected as the current context. When a context -# reference is provided, that context is set as the current one. In -# all three cases, the current context (after setting) is returned. -# + # + # Set or get the current context. When a name is given, the context + # with that name is selected as the current context. When a context + # reference is provided, that context is set as the current one. In + # all three cases, the current context (after setting) is returned. + # =cut Index: parserImplicitEquation.pl =================================================================== RCS file: /webwork/cvs/system/pg/macros/parserImplicitEquation.pl,v retrieving revision 1.6 retrieving revision 1.7 diff -Lmacros/parserImplicitEquation.pl -Lmacros/parserImplicitEquation.pl -u -r1.6 -r1.7 --- macros/parserImplicitEquation.pl +++ macros/parserImplicitEquation.pl @@ -4,126 +4,126 @@ =head1 DESCRIPTION -###################################################################### -# -# This is a MathObject class that implements an answer checker for -# implicitly defined equations. The checker looks for the zeros of -# the equation and tests that the student and professor equations -# both have the same solutions. -# -# This type of check is very subtle, and there are important issues -# that you may have to take into account. The solutions to the -# equations are found numerically, and so they will not be exact; -# that means that there are tolerances that may need to be adjusted -# for your particular equation. Also, it is always possible for the -# student to represent the function in a form that will exceed those -# tolerances, and so be marked as incorrect. The answer checker -# attempts to set the parameters based on the values of the functions -# involved, but this may not work perfectly. -# -# The method used to locate the solutions of A=B is by finding zeros -# of A-B, and it requires this function to take on both positive and -# negative values (that is, it can only find transverse intersections -# of the surface A-B=0 and the plane at height 0). For example, even -# though the solutions of (x^2+y^1-1)^2=0 form a circle, the -# algorithm will fail to find any solutions for this equation. -# -# In order to locate the zeros, you may need to change the limits so -# that they include regions where the function is both positive and -# negative (see below). The algorithm will avoid discontinuities, so -# you can specify things like x-y=1/(x+y) rather than x^2-y^2=1. -# -# Because the solutions are found using a random search, it is -# possible the randomly chosen starting points don't locate enough -# zeros for the function, in which case the check will fail. This -# can happen for both the professor's function and the student's, -# since zeros are found for both. This means that a correct answer -# can sometimes be marked incorrect depending on the random points -# chosen initially. These points also affect the values selected for -# the tolerances used to determine when a function's value is zero, -# and so can affect whether the student's function is marked as -# correct or not. -# -# If an equation has several components or branches, it is possible -# that the random location of solutions will not find zeros on some -# of the branches, and so might incorrectly mark as correct an -# equation that only is zero on one of the components. For example, -# x^2-y^2=0 has solutions along the lines y=x and y=-x, so it is -# possible that x-y=0 or x+y=0 will be marked as correct if the -# random points are unluckily chosen. One way to reduce this problem -# is to increase the number of solutions that are required (by -# setting the ImplicitPoints flag in the Context). Another is to -# specify the solutions yourself, so that you are sure there are -# points on each component. -# -# These problems should be rare, and the values for the various -# parameters have been set in an attempt to minimize the possibility -# of these errors, but they can occur, and you should be aware of -# them, and their possible solutions. -# -# -# Usage examples: -# -# Context("ImplicitEquation"); -# $f = ImplicitEquation("x^2 = cos(y)"); -# $f = ImplicitEquation("x^2 - 2y^2 = 5",limits=>[[-3,3],[-2,2]]); -# $f = ImplicitEquation("x=1/y",tolerance=>.0001); -# -# Then use -# -# ANS($f->cmp); -# -# to get the answer checker for $f. -# -# There are a number of Context flags that control the answer checker. -# These include: -# -# ImplicitPoints => 7 (the number of solutions to test) -# ImplicitTolerance => 1E-6 (relative tolerance value for when -# the tested function is zero) -# ImplicitAbsoluteMinTolerance => 1E-3 (the minimum tolerance allowed) -# ImplicitAbsoluteMaxTolerance => 1E-3 (the maximum tolerance allowed) -# ImplicitPointTolerance => 1E-9 (relative tolerance for how close -# the solution point must be to an -# actual solution) -# BisectionTolerance => .01 (extra factor used for the tolerance -# when finding the solutions) -# BisectionCutoff => 40 (maximum number of bisections to -# perform when looking for a solution) -# -# You may set any of these using Context()->flags->set(...). -# -# In addition to the Context flags, you can set some values within -# the ImplicitEquation itself: -# -# tolerance (the absolute tolerance for zeros of the function) -# bisect_tolerance (the tolerance used when searching for zeros) -# point_tolerance (the absolute tolerance for how close to an -# actual solution the located solution must be) -# limits (the domain to use for the function; see the -# documentation for the Formula object) -# solutions (a reference to an array of references to arrays -# that contain the coordinates of the points -# that are the solutions of the equation) -# -# These can be set in the in the ImplicitEquation() call that creates -# the object, as in the examples below: -# -# For example: -# -# $f = ImplicitEquation("x^2-y^2=0", -# solutions => [[0,0],[1,1],[-1,1],[-1,-1],[1,-1]], -# tolerance => .001 -# ); -# -# -# $f = ImplicitEquation("xy=5",limits=>[-3,3]); -# -# The limits value can be set globally within the Context, if you wish, -# and the others can be controlled by the Context flags discussed -# above. -# -###################################################################### + ###################################################################### + # + # This is a MathObject class that implements an answer checker for + # implicitly defined equations. The checker looks for the zeros of + # the equation and tests that the student and professor equations + # both have the same solutions. + # + # This type of check is very subtle, and there are important issues + # that you may have to take into account. The solutions to the + # equations are found numerically, and so they will not be exact; + # that means that there are tolerances that may need to be adjusted + # for your particular equation. Also, it is always possible for the + # student to represent the function in a form that will exceed those + # tolerances, and so be marked as incorrect. The answer checker + # attempts to set the parameters based on the values of the functions + # involved, but this may not work perfectly. + # + # The method used to locate the solutions of A=B is by finding zeros + # of A-B, and it requires this function to take on both positive and + # negative values (that is, it can only find transverse intersections + # of the surface A-B=0 and the plane at height 0). For example, even + # though the solutions of (x^2+y^1-1)^2=0 form a circle, the + # algorithm will fail to find any solutions for this equation. + # + # In order to locate the zeros, you may need to change the limits so + # that they include regions where the function is both positive and + # negative (see below). The algorithm will avoid discontinuities, so + # you can specify things like x-y=1/(x+y) rather than x^2-y^2=1. + # + # Because the solutions are found using a random search, it is + # possible the randomly chosen starting points don't locate enough + # zeros for the function, in which case the check will fail. This + # can happen for both the professor's function and the student's, + # since zeros are found for both. This means that a correct answer + # can sometimes be marked incorrect depending on the random points + # chosen initially. These points also affect the values selected for + # the tolerances used to determine when a function's value is zero, + # and so can affect whether the student's function is marked as + # correct or not. + # + # If an equation has several components or branches, it is possible + # that the random location of solutions will not find zeros on some + # of the branches, and so might incorrectly mark as correct an + # equation that only is zero on one of the components. For example, + # x^2-y^2=0 has solutions along the lines y=x and y=-x, so it is + # possible that x-y=0 or x+y=0 will be marked as correct if the + # random points are unluckily chosen. One way to reduce this problem + # is to increase the number of solutions that are required (by + # setting the ImplicitPoints flag in the Context). Another is to + # specify the solutions yourself, so that you are sure there are + # points on each component. + # + # These problems should be rare, and the values for the various + # parameters have been set in an attempt to minimize the possibility + # of these errors, but they can occur, and you should be aware of + # them, and their possible solutions. + # + # + # Usage examples: + # + # Context("ImplicitEquation"); + # $f = ImplicitEquation("x^2 = cos(y)"); + # $f = ImplicitEquation("x^2 - 2y^2 = 5",limits=>[[-3,3],[-2,2]]); + # $f = ImplicitEquation("x=1/y",tolerance=>.0001); + # + # Then use + # + # ANS($f->cmp); + # + # to get the answer checker for $f. + # + # There are a number of Context flags that control the answer checker. + # These include: + # + # ImplicitPoints => 7 (the number of solutions to test) + # ImplicitTolerance => 1E-6 (relative tolerance value for when + # the tested function is zero) + # ImplicitAbsoluteMinTolerance => 1E-3 (the minimum tolerance allowed) + # ImplicitAbsoluteMaxTolerance => 1E-3 (the maximum tolerance allowed) + # ImplicitPointTolerance => 1E-9 (relative tolerance for how close + # the solution point must be to an + # actual solution) + # BisectionTolerance => .01 (extra factor used for the tolerance + # when finding the solutions) + # BisectionCutoff => 40 (maximum number of bisections to + # perform when looking for a solution) + # + # You may set any of these using Context()->flags->set(...). + # + # In addition to the Context flags, you can set some values within + # the ImplicitEquation itself: + # + # tolerance (the absolute tolerance for zeros of the function) + # bisect_tolerance (the tolerance used when searching for zeros) + # point_tolerance (the absolute tolerance for how close to an + # actual solution the located solution must be) + # limits (the domain to use for the function; see the + # documentation for the Formula object) + # solutions (a reference to an array of references to arrays + # that contain the coordinates of the points + # that are the solutions of the equation) + # + # These can be set in the in the ImplicitEquation() call that creates + # the object, as in the examples below: + # + # For example: + # + # $f = ImplicitEquation("x^2-y^2=0", + # solutions => [[0,0],[1,1],[-1,1],[-1,-1],[1,-1]], + # tolerance => .001 + # ); + # + # + # $f = ImplicitEquation("xy=5",limits=>[-3,3]); + # + # The limits value can be set globally within the Context, if you wish, + # and the others can be controlled by the Context flags discussed + # above. + # + ###################################################################### =cut Index: problemPreserveAnswers.pl =================================================================== RCS file: /webwork/cvs/system/pg/macros/problemPreserveAnswers.pl,v retrieving revision 1.1 retrieving revision 1.2 diff -Lmacros/problemPreserveAnswers.pl -Lmacros/problemPreserveAnswers.pl -u -r1.1 -r1.2 --- macros/problemPreserveAnswers.pl +++ macros/problemPreserveAnswers.pl @@ -1,5 +1,7 @@ -=pod +sub _problemPreserveAnswers_init {PreserveAnswers::Init()} + +=head1 PreserveAnswers(); ###################################################################### # @@ -25,8 +27,6 @@ =cut -sub _problemPreserveAnswers_init {PreserveAnswers::Init()} - package PreserveAnswers; # @@ -66,7 +66,7 @@ foreach my $id (keys %{$original}) {$inputs->{$id} = $original->{$id}} } -our $ENDDOCUMENT; +our $ENDDOCUMENT; # holds pointer to original ENDDOCUMENT ###################################################################### Index: contextLimitedNumeric.pl =================================================================== RCS file: /webwork/cvs/system/pg/macros/contextLimitedNumeric.pl,v retrieving revision 1.4 retrieving revision 1.5 diff -Lmacros/contextLimitedNumeric.pl -Lmacros/contextLimitedNumeric.pl -u -r1.4 -r1.5 --- macros/contextLimitedNumeric.pl +++ macros/contextLimitedNumeric.pl @@ -5,18 +5,18 @@ =head3 Context("LimitedNumeric") -########################################################## -# -# Implements a context in which numbers can be entered, -# but no operations are permitted between them. -# -# There are two versions: one for lists of numbers -# and one for a single number. Select them using -# one of the following commands: -# -# Context("LimitedNumeric-list"); -# Context("LimiteNumeric"); -# + ########################################################## + # + # Implements a context in which numbers can be entered, + # but no operations are permitted between them. + # + # There are two versions: one for lists of numbers + # and one for a single number. Select them using + # one of the following commands: + # + # Context("LimitedNumeric-list"); + # Context("LimiteNumeric"); + # =cut @@ -47,3 +47,5 @@ $context{LimitedNumeric}->operators->undefine(','); Context("LimitedNumeric"); + +1; Index: parserCustomization.pl =================================================================== RCS file: /webwork/cvs/system/pg/macros/parserCustomization.pl,v retrieving revision 1.4 retrieving revision 1.5 diff -Lmacros/parserCustomization.pl -Lmacros/parserCustomization.pl -u -r1.4 -r1.5 --- macros/parserCustomization.pl +++ macros/parserCustomization.pl @@ -30,5 +30,4 @@ =cut - 1; Index: parserDifferenceQuotient.pl =================================================================== RCS file: /webwork/cvs/system/pg/macros/parserDifferenceQuotient.pl,v retrieving revision 1.9 retrieving revision 1.10 diff -Lmacros/parserDifferenceQuotient.pl -Lmacros/p... [truncated message content] |
From: dpvc v. a. <we...@ma...> - 2007-08-19 01:11:39
|
Log Message: ----------- Parser needs UNIVERAL package in order to access the can() and isa() methods that are supposed to be part ofthe base class. Modified Files: -------------- webwork2/conf: global.conf.dist Revision Data ------------- Index: global.conf.dist =================================================================== RCS file: /webwork/cvs/system/webwork2/conf/global.conf.dist,v retrieving revision 1.198 retrieving revision 1.199 diff -Lconf/global.conf.dist -Lconf/global.conf.dist -u -r1.198 -r1.199 --- conf/global.conf.dist +++ conf/global.conf.dist @@ -42,7 +42,7 @@ # URL and path to courses directory. $webwork_courses_url = "/webwork2_course_files"; -$webwork_courses_dir = "/opt/webwork/courses"; +#$webwork_courses_dir = "/opt/webwork/courses"; ################################################################################ # Paths to external programs @@ -893,7 +893,7 @@ [qw(Select)], [qw(Units)], [qw(VectorField)], - [qw(Parser Value)], + [qw(Parser Value UNIVERSAL)], [qw(Parser::Legacy)], ]; |
From: dpvc v. a. <we...@ma...> - 2007-08-19 01:02:04
|
Log Message: ----------- Changed Parser.pl to MathObjects.pl Modified Files: -------------- pg/macros: PGinfo.pl answerCustom.pl answerVariableList.pl contextABCD.pl contextIntegerFunctions.pl contextLimitedComplex.pl contextLimitedNumeric.pl contextLimitedPoint.pl contextLimitedPolynomial.pl contextLimitedPowers.pl contextLimitedVector.pl contextString.pl contextTF.pl extraAnswerEvaluators.pl parserDifferenceQuotient.pl parserFormulaWithUnits.pl parserFunction.pl parserImplicitEquation.pl parserImplicitPlane.pl parserNumberWithUnits.pl parserParametricLine.pl parserPopUp.pl parserRadioButtons.pl parserSolutionFor.pl Revision Data ------------- Index: parserImplicitEquation.pl =================================================================== RCS file: /webwork/cvs/system/pg/macros/parserImplicitEquation.pl,v retrieving revision 1.5 retrieving revision 1.6 diff -Lmacros/parserImplicitEquation.pl -Lmacros/parserImplicitEquation.pl -u -r1.5 -r1.6 --- macros/parserImplicitEquation.pl +++ macros/parserImplicitEquation.pl @@ -1,4 +1,4 @@ -loadMacros("Parser.pl"); +loadMacros("MathObjects.pl"); sub _parserImplicitEquation_init {}; # don't reload this file Index: parserParametricLine.pl =================================================================== RCS file: /webwork/cvs/system/pg/macros/parserParametricLine.pl,v retrieving revision 1.8 retrieving revision 1.9 diff -Lmacros/parserParametricLine.pl -Lmacros/parserParametricLine.pl -u -r1.8 -r1.9 --- macros/parserParametricLine.pl +++ macros/parserParametricLine.pl @@ -1,4 +1,4 @@ -loadMacros('Parser.pl'); +loadMacros('MathObjects.pl'); sub _parserParametricLine_init {}; # don't reload this file Index: contextLimitedPoint.pl =================================================================== RCS file: /webwork/cvs/system/pg/macros/contextLimitedPoint.pl,v retrieving revision 1.5 retrieving revision 1.6 diff -Lmacros/contextLimitedPoint.pl -Lmacros/contextLimitedPoint.pl -u -r1.5 -r1.6 --- macros/contextLimitedPoint.pl +++ macros/contextLimitedPoint.pl @@ -1,5 +1,5 @@ -loadMacros("Parser.pl"); +loadMacros("MathObjects.pl"); sub _contextLimitedPoint_init {}; # don't load it again Index: contextString.pl =================================================================== RCS file: /webwork/cvs/system/pg/macros/contextString.pl,v retrieving revision 1.7 retrieving revision 1.8 diff -Lmacros/contextString.pl -Lmacros/contextString.pl -u -r1.7 -r1.8 --- macros/contextString.pl +++ macros/contextString.pl @@ -1,4 +1,4 @@ -loadMacros("Parser.pl"); +loadMacros("MathObjects.pl"); sub _contextString_init {}; # don't load it again Index: PGinfo.pl =================================================================== RCS file: /webwork/cvs/system/pg/macros/PGinfo.pl,v retrieving revision 1.2 retrieving revision 1.3 diff -Lmacros/PGinfo.pl -Lmacros/PGinfo.pl -u -r1.2 -r1.3 --- macros/PGinfo.pl +++ macros/PGinfo.pl @@ -6,21 +6,23 @@ =head1 NAME - PGinfo.pl - -Provides macros for determining the values of the current context in which the problem + PGinfo.pl + +=cut + +Provides macros for determining the values of the current context in which the problem is being written. -loadMacros("Parser.pl"); +loadMacros("MathObjects.pl"); =head3 listVariables Usage: listVariables(); -Prints all variables submitted in the problem form and all variables in the +Prints all variables submitted in the problem form and all variables in the the Problem environment and all of the flag variables in Context(). This is used for debugging and to determine the current -context for the problem. +context for the problem. =cut @@ -35,7 +37,7 @@ } =head4 listFormVariables() - + Called by listVariables to print out the input form variables. =cut @@ -48,7 +50,7 @@ } =head4 listEnvironmentVariables() - + Called by listVariables to print out the environment variables (in %envir). =cut @@ -60,8 +62,8 @@ } =head4 listContextFlags() - - Called by listVariables to print out context flags for Math Objects. + + Called by listVariables to print out context flags for Math Objects. =cut @@ -73,16 +75,16 @@ =head3 listContext() Usage: listContext(Context()) - + Prints out the contents of the current context hash -- includes flags and much more =cut -sub listContext { # include +sub listContext { # include my $context = shift; return TEXT("$PAR Error in listContext: usage: listContext(Context()); # must specify a context to list $BR") unless defined $context; foreach $key (keys %$context) { - next if $key =~/^_/; # skip if it begins with _ + next if $key =~/^_/; # skip if it begins with TEXT($HR, $key, $BR); TEXT( pretty_print($context->{$key}) ); } @@ -90,4 +92,4 @@ sub pp { my $hash = shift; "printing |". ref($hash)."|$BR". pretty_print($hash); -} \ No newline at end of file +} Index: contextLimitedNumeric.pl =================================================================== RCS file: /webwork/cvs/system/pg/macros/contextLimitedNumeric.pl,v retrieving revision 1.3 retrieving revision 1.4 diff -Lmacros/contextLimitedNumeric.pl -Lmacros/contextLimitedNumeric.pl -u -r1.3 -r1.4 --- macros/contextLimitedNumeric.pl +++ macros/contextLimitedNumeric.pl @@ -1,5 +1,5 @@ -loadMacros("Parser.pl"); +loadMacros("MathObjects.pl"); sub _contextLimitedNumeric_init {}; # don't load it again Index: parserDifferenceQuotient.pl =================================================================== RCS file: /webwork/cvs/system/pg/macros/parserDifferenceQuotient.pl,v retrieving revision 1.8 retrieving revision 1.9 diff -Lmacros/parserDifferenceQuotient.pl -Lmacros/parserDifferenceQuotient.pl -u -r1.8 -r1.9 --- macros/parserDifferenceQuotient.pl +++ macros/parserDifferenceQuotient.pl @@ -1,5 +1,5 @@ -loadMacros('Parser.pl'); +loadMacros('MathObjects.pl'); sub _parserDifferenceQuotient_init {}; # don't reload this file Index: parserImplicitPlane.pl =================================================================== RCS file: /webwork/cvs/system/pg/macros/parserImplicitPlane.pl,v retrieving revision 1.12 retrieving revision 1.13 diff -Lmacros/parserImplicitPlane.pl -Lmacros/parserImplicitPlane.pl -u -r1.12 -r1.13 --- macros/parserImplicitPlane.pl +++ macros/parserImplicitPlane.pl @@ -1,4 +1,4 @@ -loadMacros('Parser.pl'); +loadMacros('MathObjects.pl'); sub _parserImplicitPlane_init {}; # don't reload this file Index: contextLimitedVector.pl =================================================================== RCS file: /webwork/cvs/system/pg/macros/contextLimitedVector.pl,v retrieving revision 1.5 retrieving revision 1.6 diff -Lmacros/contextLimitedVector.pl -Lmacros/contextLimitedVector.pl -u -r1.5 -r1.6 --- macros/contextLimitedVector.pl +++ macros/contextLimitedVector.pl @@ -1,4 +1,4 @@ -loadMacros("Parser.pl"); +loadMacros("MathObjects.pl"); sub _contextLimitedVector_init {}; # don't load it again Index: parserFormulaWithUnits.pl =================================================================== RCS file: /webwork/cvs/system/pg/macros/parserFormulaWithUnits.pl,v retrieving revision 1.4 retrieving revision 1.5 diff -Lmacros/parserFormulaWithUnits.pl -Lmacros/parserFormulaWithUnits.pl -u -r1.4 -r1.5 --- macros/parserFormulaWithUnits.pl +++ macros/parserFormulaWithUnits.pl @@ -1,5 +1,5 @@ -loadMacros('Parser.pl'); +loadMacros('MathObjects.pl'); sub _parserFormulaWithUnits_init {}; # don't reload this file Index: parserNumberWithUnits.pl =================================================================== RCS file: /webwork/cvs/system/pg/macros/parserNumberWithUnits.pl,v retrieving revision 1.3 retrieving revision 1.4 diff -Lmacros/parserNumberWithUnits.pl -Lmacros/parserNumberWithUnits.pl -u -r1.3 -r1.4 --- macros/parserNumberWithUnits.pl +++ macros/parserNumberWithUnits.pl @@ -1,4 +1,4 @@ -loadMacros('Parser.pl'); +loadMacros('MathObjects.pl'); sub _parserNumberWithUnits_init {}; # don't reload this file Index: answerVariableList.pl =================================================================== RCS file: /webwork/cvs/system/pg/macros/answerVariableList.pl,v retrieving revision 1.5 retrieving revision 1.6 diff -Lmacros/answerVariableList.pl -Lmacros/answerVariableList.pl -u -r1.5 -r1.6 --- macros/answerVariableList.pl +++ macros/answerVariableList.pl @@ -1,4 +1,4 @@ -loadMacros('Parser.pl'); +loadMacros('MathObjects.pl'); sub _answerVariableList_init {}; # don't reload this file Index: contextLimitedComplex.pl =================================================================== RCS file: /webwork/cvs/system/pg/macros/contextLimitedComplex.pl,v retrieving revision 1.5 retrieving revision 1.6 diff -Lmacros/contextLimitedComplex.pl -Lmacros/contextLimitedComplex.pl -u -r1.5 -r1.6 --- macros/contextLimitedComplex.pl +++ macros/contextLimitedComplex.pl @@ -1,4 +1,4 @@ -loadMacros("Parser.pl"); +loadMacros("MathObjects.pl"); sub _contextLimitedComplex_init {}; # don't load it again Index: parserRadioButtons.pl =================================================================== RCS file: /webwork/cvs/system/pg/macros/parserRadioButtons.pl,v retrieving revision 1.5 retrieving revision 1.6 diff -Lmacros/parserRadioButtons.pl -Lmacros/parserRadioButtons.pl -u -r1.5 -r1.6 --- macros/parserRadioButtons.pl +++ macros/parserRadioButtons.pl @@ -1,4 +1,4 @@ -loadMacros('Parser.pl','contextString.pl'); +loadMacros('MathObjects.pl','contextString.pl'); sub _parserRadioButtons_init {}; # don't reload this file Index: contextABCD.pl =================================================================== RCS file: /webwork/cvs/system/pg/macros/contextABCD.pl,v retrieving revision 1.6 retrieving revision 1.7 diff -Lmacros/contextABCD.pl -Lmacros/contextABCD.pl -u -r1.6 -r1.7 --- macros/contextABCD.pl +++ macros/contextABCD.pl @@ -1,4 +1,4 @@ -loadMacros("Parser.pl","contextString.pl"); +loadMacros("MathObjects.pl","contextString.pl"); sub _contextABCD_init {}; # don't load it again Index: contextLimitedPowers.pl =================================================================== RCS file: /webwork/cvs/system/pg/macros/contextLimitedPowers.pl,v retrieving revision 1.8 retrieving revision 1.9 diff -Lmacros/contextLimitedPowers.pl -Lmacros/contextLimitedPowers.pl -u -r1.8 -r1.9 --- macros/contextLimitedPowers.pl +++ macros/contextLimitedPowers.pl @@ -1,4 +1,4 @@ -loadMacros("Parser.pl"); +loadMacros("MathObjects.pl"); sub _contextLimitedPowers_init {}; # don't load it again Index: contextTF.pl =================================================================== RCS file: /webwork/cvs/system/pg/macros/contextTF.pl,v retrieving revision 1.7 retrieving revision 1.8 diff -Lmacros/contextTF.pl -Lmacros/contextTF.pl -u -r1.7 -r1.8 --- macros/contextTF.pl +++ macros/contextTF.pl @@ -1,4 +1,4 @@ -loadMacros("Parser.pl","contextString.pl"); +loadMacros("MathObjects.pl","contextString.pl"); sub _contextTF_init {}; # don't load it again Index: parserFunction.pl =================================================================== RCS file: /webwork/cvs/system/pg/macros/parserFunction.pl,v retrieving revision 1.5 retrieving revision 1.6 diff -Lmacros/parserFunction.pl -Lmacros/parserFunction.pl -u -r1.5 -r1.6 --- macros/parserFunction.pl +++ macros/parserFunction.pl @@ -1,5 +1,5 @@ -loadMacros('Parser.pl'); +loadMacros('MathObjects.pl'); sub _parserFunction_init {}; # don't reload this file Index: contextIntegerFunctions.pl =================================================================== RCS file: /webwork/cvs/system/pg/macros/contextIntegerFunctions.pl,v retrieving revision 1.4 retrieving revision 1.5 diff -Lmacros/contextIntegerFunctions.pl -Lmacros/contextIntegerFunctions.pl -u -r1.4 -r1.5 --- macros/contextIntegerFunctions.pl +++ macros/contextIntegerFunctions.pl @@ -1,4 +1,4 @@ -loadMacros('Parser.pl'); +loadMacros('MathObjects.pl'); sub _contextIntegerFunctions_init {}; # don't reload this file Index: contextLimitedPolynomial.pl =================================================================== RCS file: /webwork/cvs/system/pg/macros/contextLimitedPolynomial.pl,v retrieving revision 1.8 retrieving revision 1.9 diff -Lmacros/contextLimitedPolynomial.pl -Lmacros/contextLimitedPolynomial.pl -u -r1.8 -r1.9 --- macros/contextLimitedPolynomial.pl +++ macros/contextLimitedPolynomial.pl @@ -1,5 +1,5 @@ -loadMacros("Parser.pl"); +loadMacros("MathObjects.pl"); sub _contextLimitedPolynomial_init {}; # don't load it again Index: parserPopUp.pl =================================================================== RCS file: /webwork/cvs/system/pg/macros/parserPopUp.pl,v retrieving revision 1.2 retrieving revision 1.3 diff -Lmacros/parserPopUp.pl -Lmacros/parserPopUp.pl -u -r1.2 -r1.3 --- macros/parserPopUp.pl +++ macros/parserPopUp.pl @@ -1,4 +1,4 @@ -loadMacros('Parser.pl','contextString.pl'); +loadMacros('MathObjects.pl','contextString.pl'); Context("Numeric"); Index: parserSolutionFor.pl =================================================================== RCS file: /webwork/cvs/system/pg/macros/parserSolutionFor.pl,v retrieving revision 1.4 retrieving revision 1.5 diff -Lmacros/parserSolutionFor.pl -Lmacros/parserSolutionFor.pl -u -r1.4 -r1.5 --- macros/parserSolutionFor.pl +++ macros/parserSolutionFor.pl @@ -1,4 +1,4 @@ -loadMacros("Parser.pl"); +loadMacros("MathObjects.pl"); sub _parserSolutionFor_init {}; # don't reload this file Index: extraAnswerEvaluators.pl =================================================================== RCS file: /webwork/cvs/system/pg/macros/extraAnswerEvaluators.pl,v retrieving revision 1.17 retrieving revision 1.18 diff -Lmacros/extraAnswerEvaluators.pl -Lmacros/extraAnswerEvaluators.pl -u -r1.17 -r1.18 --- macros/extraAnswerEvaluators.pl +++ macros/extraAnswerEvaluators.pl @@ -1,4 +1,4 @@ -loadMacros('Parser.pl'); +loadMacros('MathObjects.pl'); =head1 NAME Index: answerCustom.pl =================================================================== RCS file: /webwork/cvs/system/pg/macros/answerCustom.pl,v retrieving revision 1.10 retrieving revision 1.11 diff -Lmacros/answerCustom.pl -Lmacros/answerCustom.pl -u -r1.10 -r1.11 --- macros/answerCustom.pl +++ macros/answerCustom.pl @@ -1,4 +1,4 @@ -loadMacros('Parser.pl'); +loadMacros('MathObjects.pl'); sub _answerCustom_init {}; # don't reload this file |
From: dpvc v. a. <we...@ma...> - 2007-08-19 00:53:59
|
Log Message: ----------- Updated calls to Parser::Context->getCopy to remove unneeded undef argument. Modified Files: -------------- pg/macros: contextABCD.pl contextCurrency.pl contextInequalities.pl contextIntegerFunctions.pl contextLimitedComplex.pl contextLimitedPoint.pl contextLimitedPolynomial.pl contextLimitedVector.pl contextScientificNotation.pl contextString.pl contextTF.pl parserCustomization.pl parserImplicitEquation.pl parserImplicitPlane.pl parserParametricLine.pl parserRadioButtons.pl Revision Data ------------- Index: parserImplicitEquation.pl =================================================================== RCS file: /webwork/cvs/system/pg/macros/parserImplicitEquation.pl,v retrieving revision 1.4 retrieving revision 1.5 diff -Lmacros/parserImplicitEquation.pl -Lmacros/parserImplicitEquation.pl -u -r1.4 -r1.5 --- macros/parserImplicitEquation.pl +++ macros/parserImplicitEquation.pl @@ -130,7 +130,7 @@ # # Set up the context for ImplicitEquations and activate it # -$context{ImplicitEquation} = Parser::Context->getCopy(undef,"Numeric"); +$context{ImplicitEquation} = Parser::Context->getCopy("Numeric"); $context{ImplicitEquation}->variables->are(x=>'Real',y=>'Real'); $context{ImplicitEquation}{precedence}{ImplicitEquation} = Context()->{precedence}{special}; Parser::BOP::equality->Allow($context{ImplicitEquation}); Index: parserParametricLine.pl =================================================================== RCS file: /webwork/cvs/system/pg/macros/parserParametricLine.pl,v retrieving revision 1.7 retrieving revision 1.8 diff -Lmacros/parserParametricLine.pl -Lmacros/parserParametricLine.pl -u -r1.7 -r1.8 --- macros/parserParametricLine.pl +++ macros/parserParametricLine.pl @@ -44,7 +44,7 @@ # # Define a new context for lines # -$context{ParametricLine} = Parser::Context->getCopy(undef,"Vector"); +$context{ParametricLine} = Parser::Context->getCopy("Vector"); $context{ParametricLine}->variables->are(t=>'Real'); $context{ParametricLine}->{precedence}{ParametricLine} = $context{ParametricLine}->{precedence}{special}; Index: contextLimitedPoint.pl =================================================================== RCS file: /webwork/cvs/system/pg/macros/contextLimitedPoint.pl,v retrieving revision 1.4 retrieving revision 1.5 diff -Lmacros/contextLimitedPoint.pl -Lmacros/contextLimitedPoint.pl -u -r1.4 -r1.5 --- macros/contextLimitedPoint.pl +++ macros/contextLimitedPoint.pl @@ -113,7 +113,7 @@ # above classes rather than the usual ones # -$context{LimitedPoint} = Parser::Context->getCopy(undef,"Point"); +$context{LimitedPoint} = Parser::Context->getCopy("Point"); $context{LimitedPoint}->operators->set( '+' => {class => 'LimitedPoint::BOP::add'}, '-' => {class => 'LimitedPoint::BOP::subtract'}, Index: contextString.pl =================================================================== RCS file: /webwork/cvs/system/pg/macros/contextString.pl,v retrieving revision 1.6 retrieving revision 1.7 diff -Lmacros/contextString.pl -Lmacros/contextString.pl -u -r1.6 -r1.7 --- macros/contextString.pl +++ macros/contextString.pl @@ -47,7 +47,7 @@ package main; -$context{String} = Parser::Context->getCopy(undef,"Numeric"); +$context{String} = Parser::Context->getCopy("Numeric"); $context{String}->parens->undefine('|','{','(','['); $context{String}->variables->clear(); $context{String}->constants->clear(); Index: parserCustomization.pl =================================================================== RCS file: /webwork/cvs/system/pg/macros/parserCustomization.pl,v retrieving revision 1.3 retrieving revision 1.4 diff -Lmacros/parserCustomization.pl -Lmacros/parserCustomization.pl -u -r1.3 -r1.4 --- macros/parserCustomization.pl +++ macros/parserCustomization.pl @@ -9,14 +9,14 @@ # ijk notation (and force students to use it for entering # vectors) by uncommenting: # - # $context{Vector} = Parser::Context->getCopy(undef,"Vector"); + # $context{Vector} = Parser::Context->getCopy("Vector"); # $context{Vector}->flags->set(ijk=>1); # $context{Vector}->parens->remove('<'); # # To allow vectors to be entered with parens (and displayed with # parens) rather than angle-brakets, uncomment # - # $context{Vector} = Parser::Context->getCopy(undef,"Vector"); + # $context{Vector} = Parser::Context->getCopy("Vector"); # $context{Vector}->{cmpDefaults}{Vector} = {promotePoints => 1}; # $context{Vector}->lists->set(Vector=>{open=>'(', close=>')'}); # Index: parserImplicitPlane.pl =================================================================== RCS file: /webwork/cvs/system/pg/macros/parserImplicitPlane.pl,v retrieving revision 1.11 retrieving revision 1.12 diff -Lmacros/parserImplicitPlane.pl -Lmacros/parserImplicitPlane.pl -u -r1.11 -r1.12 --- macros/parserImplicitPlane.pl +++ macros/parserImplicitPlane.pl @@ -53,7 +53,7 @@ # # Create a context for implicit planes and activate it # -$context{ImplicitPlane} = Parser::Context->getCopy(undef,"Vector"); +$context{ImplicitPlane} = Parser::Context->getCopy("Vector"); $context{ImplicitPlane}->{precedence}{ImplicitPlane} = $context{ImplicitPlane}->{precedence}{special}; #$context{ImplicitPlane}->{value}{Equality} = "ImplicitPlane::equality"; # Index: contextLimitedVector.pl =================================================================== RCS file: /webwork/cvs/system/pg/macros/contextLimitedVector.pl,v retrieving revision 1.4 retrieving revision 1.5 diff -Lmacros/contextLimitedVector.pl -Lmacros/contextLimitedVector.pl -u -r1.4 -r1.5 --- macros/contextLimitedVector.pl +++ macros/contextLimitedVector.pl @@ -210,7 +210,7 @@ # above classes rather than the usual ones # -$context{LimitedVector} = Parser::Context->getCopy(undef,"Vector"); +$context{LimitedVector} = Parser::Context->getCopy("Vector"); $context{LimitedVector}->operators->set( '+' => {class => 'LimitedVector::BOP::add'}, '-' => {class => 'LimitedVector::BOP::subtract'}, Index: contextLimitedComplex.pl =================================================================== RCS file: /webwork/cvs/system/pg/macros/contextLimitedComplex.pl,v retrieving revision 1.4 retrieving revision 1.5 diff -Lmacros/contextLimitedComplex.pl -Lmacros/contextLimitedComplex.pl -u -r1.4 -r1.5 --- macros/contextLimitedComplex.pl +++ macros/contextLimitedComplex.pl @@ -226,7 +226,7 @@ # above classes rather than the usual ones # -$context{LimitedComplex} = Parser::Context->getCopy(undef,"Complex"); +$context{LimitedComplex} = Parser::Context->getCopy("Complex"); $context{LimitedComplex}->operators->set( '+' => {class => 'LimitedComplex::BOP::add'}, '-' => {class => 'LimitedComplex::BOP::subtract'}, Index: contextInequalities.pl =================================================================== RCS file: /webwork/cvs/system/pg/macros/contextInequalities.pl,v retrieving revision 1.3 retrieving revision 1.4 diff -Lmacros/contextInequalities.pl -Lmacros/contextInequalities.pl -u -r1.3 -r1.4 --- macros/contextInequalities.pl +++ macros/contextInequalities.pl @@ -44,6 +44,8 @@ =cut +loadMacros("MathObjects.pl"); + sub _contextInequalities_init {Inequalities::Init()} ################################################## @@ -54,7 +56,7 @@ # Sets up the two inequality contexts # sub Init { - my $context = $main::context{Inequalities} = Parser::Context->getCopy(undef,"Interval"); + my $context = $main::context{Inequalities} = Parser::Context->getCopy("Interval"); $context->operators->add( '<' => {precedence => .5, associativity => 'left', type => 'bin', string => ' < ', class => 'Inequalities::BOP::inequality', eval => 'evalLessThan', combine => 1}, Index: contextCurrency.pl =================================================================== RCS file: /webwork/cvs/system/pg/macros/contextCurrency.pl,v retrieving revision 1.2 retrieving revision 1.3 diff -Lmacros/contextCurrency.pl -Lmacros/contextCurrency.pl -u -r1.2 -r1.3 --- macros/contextCurrency.pl +++ macros/contextCurrency.pl @@ -99,6 +99,8 @@ =cut +loadMacros("MathObjects.pl"); + sub _contextCurrency_init {Currency::Init()} ###################################################################### @@ -168,7 +170,7 @@ associativity => "left", @_, ); - my $context = bless Parser::Context->getCopy(undef,"Numeric"), $class; + my $context = bless Parser::Context->getCopy("Numeric"), $class; $context->{_initialized} = 0; $context->{_currency} = new Currency::Context::currency($context,%data); my $symbol = $context->{currency}{symbol}; Index: contextScientificNotation.pl =================================================================== RCS file: /webwork/cvs/system/pg/macros/contextScientificNotation.pl,v retrieving revision 1.2 retrieving revision 1.3 diff -Lmacros/contextScientificNotation.pl -Lmacros/contextScientificNotation.pl -u -r1.2 -r1.3 --- macros/contextScientificNotation.pl +++ macros/contextScientificNotation.pl @@ -91,6 +91,8 @@ =cut +loadMacros("MathObjects.pl"); + sub _contextScientificNotation_init {ScientificNotation::Init()} ###################################################################### @@ -104,7 +106,7 @@ # # Create the Scientific Notation context # - my $context = $main::context{ScientificNotation} = Parser::Context->getCopy(undef,"Numeric"); + my $context = $main::context{ScientificNotation} = Parser::Context->getCopy("Numeric"); # # Make numbers include the leading + or - and not allow E notation Index: contextABCD.pl =================================================================== RCS file: /webwork/cvs/system/pg/macros/contextABCD.pl,v retrieving revision 1.5 retrieving revision 1.6 diff -Lmacros/contextABCD.pl -Lmacros/contextABCD.pl -u -r1.5 -r1.6 --- macros/contextABCD.pl +++ macros/contextABCD.pl @@ -34,7 +34,7 @@ =cut -$context{ABCD} = Parser::Context->getCopy(undef,"String"); +$context{ABCD} = Parser::Context->getCopy("String"); $context{ABCD}->strings->are( "A" => {}, "B" => {}, Index: parserRadioButtons.pl =================================================================== RCS file: /webwork/cvs/system/pg/macros/parserRadioButtons.pl,v retrieving revision 1.4 retrieving revision 1.5 diff -Lmacros/parserRadioButtons.pl -Lmacros/parserRadioButtons.pl -u -r1.4 -r1.5 --- macros/parserRadioButtons.pl +++ macros/parserRadioButtons.pl @@ -102,7 +102,7 @@ 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(undef,"String"); + my $context = Parser::Context->getCopy("String"); my %choiceHash = $self->choiceHash(1); $context->strings->add(map {$_=>{}} (keys %choiceHash)); $value = $self->correctChoice($value); Index: contextTF.pl =================================================================== RCS file: /webwork/cvs/system/pg/macros/contextTF.pl,v retrieving revision 1.6 retrieving revision 1.7 diff -Lmacros/contextTF.pl -Lmacros/contextTF.pl -u -r1.6 -r1.7 --- macros/contextTF.pl +++ macros/contextTF.pl @@ -24,7 +24,7 @@ =cut -$context{TF} = Parser::Context->getCopy(undef,"String"); +$context{TF} = Parser::Context->getCopy("String"); $context{TF}->strings->are( "T" => {value => 1}, "F" => {value => 0}, Index: contextIntegerFunctions.pl =================================================================== RCS file: /webwork/cvs/system/pg/macros/contextIntegerFunctions.pl,v retrieving revision 1.3 retrieving revision 1.4 diff -Lmacros/contextIntegerFunctions.pl -Lmacros/contextIntegerFunctions.pl -u -r1.3 -r1.4 --- macros/contextIntegerFunctions.pl +++ macros/contextIntegerFunctions.pl @@ -25,7 +25,7 @@ =cut -$context{IntegerFunctions} = Parser::Context->getCopy(undef,"Numeric"); +$context{IntegerFunctions} = Parser::Context->getCopy("Numeric"); package IntegerFunction2; our @ISA = qw(Parser::Function::numeric2); # checks for 2 numeric inputs Index: contextLimitedPolynomial.pl =================================================================== RCS file: /webwork/cvs/system/pg/macros/contextLimitedPolynomial.pl,v retrieving revision 1.7 retrieving revision 1.8 diff -Lmacros/contextLimitedPolynomial.pl -Lmacros/contextLimitedPolynomial.pl -u -r1.7 -r1.8 --- macros/contextLimitedPolynomial.pl +++ macros/contextLimitedPolynomial.pl @@ -317,7 +317,7 @@ # above classes rather than the usual ones # -$context{LimitedPolynomial} = Parser::Context->getCopy(undef,"Numeric"); +$context{LimitedPolynomial} = Parser::Context->getCopy("Numeric"); $context{LimitedPolynomial}->operators->set( '+' => {class => 'LimitedPolynomial::BOP::add'}, '-' => {class => 'LimitedPolynomial::BOP::subtract'}, |
From: dpvc v. a. <we...@ma...> - 2007-08-19 00:36:19
|
Log Message: ----------- The "undef" in Parser::Context->getCopy(undef,"NAME") is no longer needed, and will be ignored if provided, but you can now use Parser::Context->getCopy("NAME"); which is more reasonable to read. Modified Files: -------------- pg/lib/Parser: Context.pm Revision Data ------------- Index: Context.pm =================================================================== RCS file: /webwork/cvs/system/pg/lib/Parser/Context.pm,v retrieving revision 1.21 retrieving revision 1.22 diff -Llib/Parser/Context.pm -Llib/Parser/Context.pm -u -r1.21 -r1.22 --- lib/Parser/Context.pm +++ lib/Parser/Context.pm @@ -164,12 +164,14 @@ # # Get a copy of a named context -# (either from the main list or from the default list) +# (either from the (optional) list provided, the main user's list +# or from the default list) # sub getCopy { - my $self = shift; my $contextTable = shift; my $name = shift; + my $self = shift; my $contextTable; + $contextTable = shift if !defined $_[0] || ref($_[0]) eq 'HASH'; $contextTable = $userContext unless $contextTable; - my $context = $contextTable->{$name}; + my $name = shift; my $context = $contextTable->{$name}; $context = $Parser::Context::Default::context{$name} unless $context; return unless $context; return $context->copy; |
From: dpvc v. a. <we...@ma...> - 2007-08-19 00:27:24
|
Log Message: ----------- Make Compute() retain the original Formula as well as the correct answer string (for reference if you need it). Also provide a hook for subclasses of Parser::Item to force a Formula to be computed as a Formula-based Value object (e.g., this is needed for PiecewiseFunctions, which don't compute to constants, but don't want to be Formula's either). Modified Files: -------------- pg/macros: Parser.pl Revision Data ------------- Index: Parser.pl =================================================================== RCS file: /webwork/cvs/system/pg/macros/Parser.pl,v retrieving revision 1.10 retrieving revision 1.11 diff -Lmacros/Parser.pl -Lmacros/Parser.pl -u -r1.10 -r1.11 --- macros/Parser.pl +++ macros/Parser.pl @@ -55,13 +55,25 @@ # # will produce the equivalent of $x = Real(5). # +# The original parsed formula will be saved in the object's +# original_formula field, and can be obtained by +# +# $x->{original_formula}; +# +# if needed later in the problem. +# =cut sub Compute { my $string = shift; my $formula = Formula($string); - $formula = $formula->eval(@_) if scalar(@_) || $formula->isConstant; + $formula = $formula->{tree}->Compute if $formula->{tree}{canCompute}; + if (scalar(@_) || $formula->isConstant) { + my $f = $formula; + $formula = $formula->eval(@_); + $formula->{original_formula} = $f; + } $formula->{correct_ans} = $string; return $formula; } |
From: dpvc v. a. <we...@ma...> - 2007-08-18 23:51:41
|
Log Message: ----------- Include extra parens when they have been requested. Modified Files: -------------- pg/lib/Parser: Function.pm Revision Data ------------- Index: Function.pm =================================================================== RCS file: /webwork/cvs/system/pg/lib/Parser/Function.pm,v retrieving revision 1.23 retrieving revision 1.24 diff -Llib/Parser/Function.pm -Llib/Parser/Function.pm -u -r1.23 -r1.24 --- lib/Parser/Function.pm +++ lib/Parser/Function.pm @@ -255,7 +255,7 @@ foreach my $x (@{$self->{params}}) {push(@pstr,$x->string)} $string = ($self->{def}{string} || $self->{name})."$power".'('.join(',',@pstr).')'; $string = $self->addParens($string) - if (defined($precedence) and $precedence > $fn_precedence); + if (defined($precedence) and $precedence > $fn_precedence) || $showparens; return $string; } @@ -274,7 +274,7 @@ if ($fn->{braceTeX}) {$TeX = $name.'{'.join(',',@pstr).'}'} else {$TeX = $name."$power".'\!\left('.join(',',@pstr).'\right)'} $TeX = '\left('.$TeX.'\right)' - if (defined($precedence) and $precedence > $fn_precedence); + if (defined($precedence) and $precedence > $fn_precedence) or $showparens; return $TeX; } |
From: dpvc v. a. <we...@ma...> - 2007-08-18 23:49:28
|
Log Message: ----------- Miscellaneous improvements to TeX and string output. Fixed typo in propagation of equation pointer in one location. Propagate the varName field in "or" and "and" operations. Modified Files: -------------- pg/macros: contextInequalities.pl Revision Data ------------- Index: contextInequalities.pl =================================================================== RCS file: /webwork/cvs/system/pg/macros/contextInequalities.pl,v retrieving revision 1.2 retrieving revision 1.3 diff -Lmacros/contextInequalities.pl -Lmacros/contextInequalities.pl -u -r1.2 -r1.3 --- macros/contextInequalities.pl +++ macros/contextInequalities.pl @@ -135,7 +135,7 @@ if ($v->class eq 'Variable') { $self->{varName} = $v->{name}; delete $self->{equation}{variables}{$v->{name}} if $v->{isNew}; - $self->{$self->{varPos}} = Inequalities::DummyVariable->new($equation,$v->{name},$v->{ref}); + $self->{$self->{varPos}} = Inequalities::DummyVariable->new($self->{equation},$v->{name},$v->{ref}); return; } if ($self->{def}{combine} && $v->{isInequality}) { @@ -216,8 +216,19 @@ sub getVariables {{}} # -# Avoid unwanted parentheses from the standard TeX routine. +# Avoid unwanted parentheses from the standard routines. # +sub string { + my ($self,$precedence) = @_; + my $string; my $bop = $self->{def}; + + $string = $self->{lop}->string($bop->{precedence}). + $bop->{string}. + $self->{rop}->string($bop->{precedence}); + + return $string; +} + sub TeX { my ($self,$precedence) = @_; my $TeX; my $bop = $self->{def}; @@ -241,6 +252,7 @@ $self->Error("The operands of '%s' must be Intervals, Sets or Unions") unless $self->{lop}->isSetOfReals && $self->{rop}->isSetOfReals; $self->{type} = Value::Type("Interval",2); + $self->{varName} = $self->{lop}{varName} || $self->{rop}{varName}; } sub _eval {$_[1]->intersect($_[2])} @@ -257,6 +269,7 @@ $self->Error("The operands of '%s' must be Intervals, Sets or Unions") unless $self->{lop}->isSetOfReals && $self->{rop}->isSetOfReals; $self->{type} = Value::Type("Interval",2); + $self->{varName} = $self->{lop}{varName} || $self->{rop}{varName}; } sub _eval {$_[1] + $_[2]} @@ -294,19 +307,25 @@ sub new { my $self = shift; my $class = ref($self) || $self; my ($equation,$name,$ref) = @_; - bless {name => $name, ref => $ref, equation => $equation}, $class; + my $def = $equation->{context}{variables}{$name}; + bless {name => $name, ref => $ref, def => $def, equation => $equation}, $class; } sub eval {shift}; -sub string { - my $self = shift; - return $self->{name}; -} +sub string {(shift)->{name}} sub TeX { + my $self = shift; my $name = $self->{name}; + return $self->{def}{TeX} if defined $self->{def}{TeX}; + $name = $1.'_{'.$2.'}' if ($name =~ m/^([^_]+)_?(\d+)$/); + return $name; +} + +sub perl { my $self = shift; - return $self->{name}; + return $self->{def}{perl} if defined $self->{def}{perl}; + return '$'.$self->{name}; } ################################################## |
From: dpvc v. a. <we...@ma...> - 2007-08-18 23:45:34
|
Log Message: ----------- Use alternative method of testing if whether two objects are the same (without causing them to stringify first). [Technically, this should call Value::address, the renamed version of Value::Ref, but I didn't want the AIM participants to have to update to the latests version of MathObjects to be able to use this.] Modified Files: -------------- pg/macros: answerHints.pl Revision Data ------------- Index: answerHints.pl =================================================================== RCS file: /webwork/cvs/system/pg/macros/answerHints.pl,v retrieving revision 1.1 retrieving revision 1.2 diff -Lmacros/answerHints.pl -Lmacros/answerHints.pl -u -r1.1 -r1.2 --- macros/answerHints.pl +++ macros/answerHints.pl @@ -123,7 +123,6 @@ package AnswerHints; -my $noValueRef = ! defined &{\&{Value::Ref}}; # # Calls the answer checker on two values with a copy of the answer hash # and returns true if the two values match and false otherwise. @@ -132,12 +131,12 @@ my $self = shift; my $other = shift; my $ans = shift; $ans = bless {%{$ans},@_}, ref($ans); # make a copy $ans->{typeError} = 0; $ans->{ans_message} = $ans->{error_message} = ""; $ans->{score} = 0; - if ($noValueRef || Value::Ref($self) != Value::Ref($ans->{correct_value})) { + if (sprintf("%p",$self) ne sprintf("%p",$ans->{correct_value})) { $ans->{correct_ans} = $self->string; $ans->{correct_value} = $self; $ans->{correct_formula} = Value->Package("Formula")->new($self); } - if ($noValueRef || Value::Ref($other) != Value::Ref($ans->{student_value})) { + if (sprintf("%p",$other) ne sprintf("%p",$ans->{student_value})) { $ans->{student_ans} = $other->string; $ans->{student_value} = $other; $ans->{student_formula} = Value->Package("Formula")->new($other); |
From: dpvc v. a. <we...@ma...> - 2007-08-18 23:39:47
|
Log Message: ----------- Handle promotion of Parser::Items better when they have been subclassed, and be sure to initialize the {variables} field. Modified Files: -------------- pg/lib: Parser.pm Revision Data ------------- Index: Parser.pm =================================================================== RCS file: /webwork/cvs/system/pg/lib/Parser.pm,v retrieving revision 1.42 retrieving revision 1.43 diff -Llib/Parser.pm -Llib/Parser.pm -u -r1.42 -r1.43 --- lib/Parser.pm +++ lib/Parser.pm @@ -35,9 +35,10 @@ variables => {}, values => {}, context => $context, }, $class; - if (ref($string) =~ m/^Parser::/ || Value::isFormula($string)) { + if (Value::isParser($string) || Value::isFormula($string)) { my $tree = $string; $tree = $tree->{tree} if defined $tree->{tree}; $math->{tree} = $tree->copy($math); + $math->{variables} = $math->{tree}->getVariables; } elsif (Value::isValue($string)) { $math->{tree} = $math->Item("Value")->new($math,$string); } elsif ($string eq '' && $context->{flags}{allowEmptyStrings}) { @@ -56,8 +57,7 @@ # sub context { my $self = shift; - return $self->{context} - if ref($self) && ref($self) ne "ARRAY" && ref($self) ne "CODE" && $self->{context}; + return $self->{context} if Value::isHash($self) && $self->{context}; Parser::Context->current; } |
From: dpvc v. a. <we...@ma...> - 2007-08-18 23:38:48
|
Log Message: ----------- Added a number of methods to improve the ability to test unknown values for their types (e.g., isHash, isBlessed, etc), and modified several of the service routines to use them. Improved the isValue and related routines to use more sophisticated methods of determining whether a class is a MathObject. Made the UNIVERSAL isa() and can() methods available for use from within the safe compartment. Some miscellaneous cleanup. Modified Files: -------------- pg/lib: Value.pm Revision Data ------------- Index: Value.pm =================================================================== RCS file: /webwork/cvs/system/pg/lib/Value.pm,v retrieving revision 1.85 retrieving revision 1.86 diff -Llib/Value.pm -Llib/Value.pm -u -r1.85 -r1.86 --- lib/Value.pm +++ lib/Value.pm @@ -1,7 +1,7 @@ package Value; my $pkg = 'Value'; use vars qw($context $defaultContext %Type); -use Scalar::Util qw(refaddr); +use Scalar::Util; use strict; =head1 DESCRIPTION @@ -219,7 +219,7 @@ sub getFlag { my $self = shift; my $name = shift; - if (ref($self) && ref($self) ne 'ARRAY') { + if (Value::isHash($self)) { return $self->{$name} if defined($self->{$name}); if (defined $self->{equation}) { return $self->{equation}{$name} if defined($self->{equation}{$name}); @@ -239,11 +239,11 @@ # sub context { my $self = shift; my $context = shift; - if (ref($self) && ref($self) ne 'ARRAY') { + if (Value::isHash($self)) { if ($context && $self->{context} != $context) { $self->{context} = $context; if (defined $self->{data}) { - foreach my $x (@{$self->{data}}) {$x->context($context) if ref($x)} + foreach my $x (@{$self->{data}}) {$x->context($context) if Value::isBlessed($x)} } } return $self->{context} if $self->{context}; @@ -260,17 +260,29 @@ ############################################################# # -# Check if the object class matches one of a list of classes # -sub classMatch { - my $self = shift; my $class = class($self); - my $ref = ref($self); my $isHash = ($ref && $ref ne 'ARRAY' && $ref ne 'CODE'); - my $context = ($isHash ? $self->{context} || Value->context : Value->context); - foreach my $name (@_) { - return 1 if $class eq $name || $ref eq $context->Package($name,1) || - $ref eq "Value::$name" || ($isHash && $self->{"is".$name}); - } - return 0; +# The address of a Value object (actually ANY perl value). +# Use this to compare two objects to see of they are +# the same object (avoids automatic stringification). +# +sub address {oct(sprintf("0x%p",shift))} + +sub isBlessed {Scalar::Util::blessed(shift) ne ""} +sub blessedClass {Scalar::Util::blessed(shift)} +sub blessedType {Scalar::Util::reftype(shift)} + +sub isa {UNIVERSAL::isa(@_)} +sub can {UNIVERSAL::can(@_)} + +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); + return $code && $code ne $self->can($method); } # @@ -282,10 +294,10 @@ sub isComplex {classMatch(shift,'Complex')} 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::/ || - (ref($v) && ref($v) ne 'ARRAY' && ref($v) ne 'CODE' && $v->{isValue}); + return (ref($v) || $v) =~ m/^Value::/ || (isHash($v) && $v->{isValue}) || isa($v,'Value'); } sub isNumber { @@ -329,6 +341,23 @@ # sub Package {(shift)->context->Package(@_)} +# Check if the object class matches one of a list of classes +# +sub classMatch { + my $self = shift; + return $self->classMatch(@_) if Value->subclassed($self,"classMatch"); + my $class = class($self); my $ref = ref($self); + my $isHash = ($ref && $ref ne 'ARRAY' && $ref ne 'CODE'); + my $context = ($isHash ? $self->{context} || Value->context : Value->context); + foreach my $name (@_) { + return 1 if $class eq $name || $ref eq "Value::$name" || + ($isHash && $self->{"is".$name}) || + $ref eq $context->Package($name,1) || + isa($self,"Value::$name"); + } + return 0; +} + =head3 makeValue Usage: Value::makeValue(45); @@ -380,11 +409,12 @@ $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 = 'Word' if Value::classMatch($value,'String'); + $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; @@ -415,6 +445,7 @@ } } return 'an Infinity' if $type eq 'String' && $value->{isInfinite}; + return 'an Empty Value' if $type eq 'String' && $value eq ''; return 'a Word' if $type eq 'String'; return 'a Complex Number' if $value->isComplex; return 'an '.$type if $type =~ m/^[aeio]/i; @@ -426,6 +457,7 @@ # sub getType { my $equation = shift; my $value = shift; + return $value->getType($equation,@_) if Value->subclassed($value,"getType"); my $strings = $equation->{context}{strings}; if (ref($value) eq 'ARRAY') { return 'Interval' if ($value->[0] =~ m/^[(\[]$/ && $value->[-1] =~ m/^[)\]]$/); @@ -439,18 +471,18 @@ $ltype = $type if $ltype eq ''; return 'List' if $type ne $ltype; } - return 'Point' if $ltype eq 'Number'; + return 'Point' if $ltype eq 'Number'; return 'Matrix' if $ltype =~ m/Point|Matrix/; return 'List'; } - elsif (Value::isFormula($value)) {return 'Formula'} - elsif (Value::classMatch($value,'Infinity')) {return 'Infinity'} - elsif (Value::isReal($value)) {return 'Number'} - elsif (Value::isValue($value)) {return 'value'} - elsif (ref($value)) {return 'unknown'} - elsif (defined($strings->{$value})) {return 'String'} - elsif (Value::isNumber($value)) {return 'Number'} - elsif ($value eq '' && $equation->{context}{flags}{allowEmptyStrings}) {return 'String'} + return 'Formula' if Value::isFormula($value); + return 'Infinity' if Value::classMatch($value,'Infinity'); + return 'Number' if Value::isReal($value); + return 'value' if Value::isValue($value); + return 'unknown' if ref($value); + return 'String' if defined($strings->{$value}); + return 'Number' if Value::isNumber($value); + return 'String' if $value eq '' && $equation->{context}{flags}{allowEmptyStrings}; return 'unknown'; } @@ -460,6 +492,7 @@ # sub getValueType { my $equation = shift; my $value = shift; + return $value->getValueType($equation,@_) if Value->subclassed($value,"getValueType"); my $type = Value::getType($equation,$value); if ($type eq 'String') {$type = $Value::Type{string}} elsif ($type eq 'Number') {$type = $Value::Type{number}} @@ -578,14 +611,11 @@ # The Value.pm object class # sub class { - my $self = shift; my $class = ref($self) || $self; - $class =~ s/.*:://; + my $self = shift; + return $self->class(@_) if Value->subclassed($self,"class"); + my $class = ref($self) || $self; $class =~ s/.*:://; return $class; } -# -# The address of a Value object. -# -sub Ref {refaddr(shift) || 0} # # Get an element from a point, vector, matrix, or list @@ -765,7 +795,7 @@ my ($l,$r,$flag) = @_; my $tex = Value->context->flag('StringifyAsTeX'); if ($tex) {$l = $l->TeX} else {$l = $l->pdot} - if (ref($r)) {if ($tex) {$r = $r->TeX} else {$r = $r->pdot}} + if (Value::isBlessed($r)) {if ($tex) {$r = $r->TeX} else {$r = $r->pdot}} return ($flag)? ($r.$l): ($l.$r); } @@ -952,7 +982,7 @@ =cut sub Error { - my $self = (Value::isValue($_[0]) || (ref($_[0]) eq "" and $_[0] eq 'Value') ? shift : "Value"); + my $self = (UNIVERSAL::can($_[0],"getFlag") ? shift : "Value"); my $message = shift; my $context = $self->context; $message = [$message,@_] if scalar(@_) > 0; $context->setError($message,''); |
From: dpvc v. a. <we...@ma...> - 2007-08-18 21:52:43
|
Log Message: ----------- The changes in version 1.81 broke promotion of objects created by hand through the MathObject constructors since they don't have open and close explicitly like the parsed versions do. So check the context for the default parens for these. Modified Files: -------------- pg/lib: Value.pm Revision Data ------------- Index: Value.pm =================================================================== RCS file: /webwork/cvs/system/pg/lib/Value.pm,v retrieving revision 1.84 retrieving revision 1.85 diff -Llib/Value.pm -Llib/Value.pm -u -r1.84 -r1.85 --- lib/Value.pm +++ lib/Value.pm @@ -312,8 +312,11 @@ sub isSetOfReals {0} sub canBeInUnion { my $self = shift; + my $def = $self->context->lists->get($self->class); + my $open = $self->{open}; $open = $def->{open} unless defined $open; + my $close = $self->{close}; $close = $def->{close} unless defined $close; return $self->length == 2 && $self->typeRef->{entryType}{name} eq 'Number' && - $self->{open} =~ m/^[\(\[]$/ && $self->{close} =~ m/^[\)\]]$/; + $open =~ m/^[\(\[]$/ && $close =~ m/^[\)\]]$/; } ###################################################################### |