[system] / trunk / pg / lib / Value Repository:
ViewVC logotype

Log of /trunk/pg/lib/Value

View Directory Listing Directory Listing


Sticky Revision:

Revision 6899 - Directory Listing
Modified Sat Jun 25 20:51:08 2011 UTC (7 years ago) by dpvc
Initial attempt to link Matrix MathObject to CPAN Matrix library (added methods for the major ones in the CPAN library)

Revision 6898 - Directory Listing
Modified Sat Jun 25 20:36:58 2011 UTC (7 years ago) by dpvc
Fix HTML-based delimiters for Entered column for matrices

Revision 6534 - Directory Listing
Modified Tue Nov 16 02:22:05 2010 UTC (7 years, 8 months ago) by gage
second attempt to cure defined(%$type) without triggering the new perl compiler
warning that checking the existence of hashes is deprecated.   now just using %$type.



Revision 6504 - Directory Listing
Modified Thu Nov 11 15:34:47 2010 UTC (7 years, 8 months ago) by gage
removed use of defined(%hash)


Revision 6419 - Directory Listing
Modified Tue Sep 7 21:21:25 2010 UTC (7 years, 10 months ago) by apizer
Add MathJax display mode

Revision 6346 - Directory Listing
Modified Sat Jul 10 12:39:40 2010 UTC (8 years ago) by gage
Merging changes gage branch  gage_dev/pg

removed dependence on AUTOLOAD	which does not work well with newer versions of Safe.pm.  It wasn't needed 
in any case.  There remain other incompatibilies of WeBWorK with Safe.pm 2.27

Added more support for WARN_MESSAGE  and DEBUG_MESSAGE

Changed List.pm to ChoiceList.pm  to remove confusion with MathObjects List object

Additional support for geogebra applets



Revision 6319 - Directory Listing
Modified Tue Jul 6 21:49:52 2010 UTC (8 years ago) by gage
This version of the tooltip fix is still temporary but it works slightly 
better in practice than the fix just committed.

This method first attempts to calculate the latex string from {correct_ans} and if that fails
it attempts the mathObject->Tex, and finally it places an empty string in {correct_ans_latex_string} if 
all else fails.  With this method one gets the typeset version of pi  rather 
than the numerical result for the correct answer for Compute("pi").


Revision 6318 - Directory Listing
Modified Tue Jul 6 20:56:01 2010 UTC (8 years ago) by gage
Temporary fix to a bug which occurs when trying to calculate the latex preview
string for an Inequality mathobject.  Because the context has changed from the time 
the MathObject was created the parsing of the MathObject string during answer evaluation
may fail 

The temporary fix is to catch the error and simply place an empty string in the 
{correct_ans_latex_string} slot.  This is then properly handled in Problem.pm
which falls back to the {correct_ans}  string instead.



Revision 6294 - Directory Listing
Modified Fri Jun 18 01:38:07 2010 UTC (8 years, 1 month ago) by gage
Added  correct_ans_latex_string -> ...  element to the answer hash for displaying the TeX version of the correct answer

Revision 6248 - Directory Listing
Modified Fri May 14 01:17:21 2010 UTC (8 years, 2 months ago) by gage
major update which adds objective methods to the basic code of PG.
HEAD should be considered more beta than usual for a few days until minor glitches
are shaken out.
new modules needed:

PGcore PGalias PGresource PGloadfiles PGanswergroup PGresponsegroup  Tie::IxHash

Revision 6223 - Directory Listing
Modified Wed Apr 14 14:26:12 2010 UTC (8 years, 3 months ago) by dpvc
Make sure inherited formulas get the right variables

Revision 6222 - Directory Listing
Modified Thu Apr 8 10:49:05 2010 UTC (8 years, 3 months ago) by dpvc
Since $self->{tree} is not inherited, cache it beforehand so that we
can use it afterward.

Revision 6191 - Directory Listing
Modified Wed Jan 27 12:00:46 2010 UTC (8 years, 5 months ago) by dpvc
Allow error for correct answer but not student answer in getTypicalValue

Revision 6190 - Directory Listing
Modified Wed Jan 27 11:48:18 2010 UTC (8 years, 5 months ago) by dpvc
Allow creation of test points with no errors

Revision 6189 - Directory Listing
Modified Wed Jan 27 11:44:18 2010 UTC (8 years, 5 months ago) by dpvc
Make Formula typeMatch work with test_points, and not produce error messages

Revision 6119 - Directory Listing
Modified Thu Oct 1 14:12:06 2009 UTC (8 years, 9 months ago) by dpvc
Fix problem with processing lists where a constant answer produces a computation error

Revision 6118 - Directory Listing
Modified Thu Oct 1 14:10:02 2009 UTC (8 years, 9 months ago) by dpvc
Fix error message for powers of negatives

Revision 6058 - Directory Listing
Modified Thu Jun 25 23:28:44 2009 UTC (9 years ago) by gage
syncing pg HEAD with pg2.4.7 on 6/25/2009

Revision 6047 - Directory Listing
Modified Sun Jun 7 12:33:27 2009 UTC (9 years, 1 month ago) by dpvc
Don't do equivalence check if prefilters are erased

Revision 6014 - Directory Listing
Modified Tue Feb 24 23:58:13 2009 UTC (9 years, 4 months ago) by dpvc
Apply message conversion before adding position information

Revision 5990 - Directory Listing
Modified Thu Feb 5 14:57:48 2009 UTC (9 years, 5 months ago) by dpvc
Fix inheritance to copy the tree rather than just the pointer.  This
makes sure that the nodes point to the proper equation.

In the routine for adapting to parameters, check that the coefficient
matrix isn't singular, and try new random points if it is.

Revision 5989 - Directory Listing
Modified Thu Feb 5 14:55:26 2009 UTC (9 years, 5 months ago) by dpvc
Minor changes

Revision 5945 - Directory Listing
Modified Wed Nov 19 15:42:16 2008 UTC (9 years, 8 months ago) by dpvc
Fixed a bug where if the student answer has an evaluation error
in a problem with adaptive parameters, the error message could
incorrectly be displayed in the message area.  The correct behavior is
to mark the answer incorrect silently.

Also, properly report errors in correct answer under similar circumstances.

Revision 5943 - Directory Listing
Modified Fri Nov 14 04:08:37 2008 UTC (9 years, 8 months ago) by dpvc
Updated ans_array and TeX methods so that Matrix arrays don't have an
extra blank line at the bottom.  (There was an extra \cr that
shouldn't have been there.)

Revision 5941 - Directory Listing
Modified Tue Oct 21 17:52:43 2008 UTC (9 years, 9 months ago) by dpvc
Clear the error message before checking the student's answer for errors.

Revision 5929 - Directory Listing
Modified Tue Oct 7 23:12:06 2008 UTC (9 years, 9 months ago) by dpvc
Added a routine to trap errors in a function call.  I've needed this
for a long time, and got tired of working around the lack by hacks
involving PG_restricted_eval, which can't handle local variables from
the calling function.  This addition is still safe because it is
passed code (not a string) and the code is already compiled in the
safe compartment, so it can't include the disallowed commands.

Now I need to go back to remove the hacks from the various pg/macros
files where they currently exist.

Revision 5921 - Directory Listing
Modified Tue Sep 23 21:56:01 2008 UTC (9 years, 9 months ago) by dpvc
Fix the check for equivalent answers so that it uses the limits and
other settings from the answer checker and the original formula
object.

Revision 5920 - Directory Listing
Modified Tue Sep 23 21:54:27 2008 UTC (9 years, 9 months ago) by dpvc
Include a noinherit routine so that things like test_values and other
temporary items are not inheritted.  Only things like limits and so on.

Revision 5916 - Directory Listing
Modified Sun Sep 21 18:01:17 2008 UTC (9 years, 10 months ago) by dpvc
Report bad function calls in student Formulas (e.g., roots of
negatives), which used to be silently marked as incorrect.  This is
done during the post-processing phase by calling the formula's reduce
method, which will return an error if there are illegal function calls
(or other errors).

Revision 5888 - Directory Listing
Modified Mon Sep 1 11:45:50 2008 UTC (9 years, 10 months ago) by dpvc
Don't inherit the ColumnVector flag from Vector operands.  (This fixes
a problem with using the result of matrix-vector multiplication
together with the ->ans_array method.)

Revision 5828 - Directory Listing
Modified Sat Jun 28 20:29:14 2008 UTC (10 years ago) by gage
format spaces

Revision 5826 - Directory Listing
Modified Sat Jun 28 19:27:31 2008 UTC (10 years ago) by dpvc
Fixed problem with Union answer checker where incorrect error messages
could be given when intervals needed to be checked for syntax
errors.  Also fixed some comments.

Revision 5787 - Directory Listing
Modified Wed Jun 25 19:46:38 2008 UTC (10 years ago) by apizer
Added
no strict "refs"
to try to avoid new error checking in Perl 5.10.

Revision 5696 - Directory Listing
Modified Sat Jun 14 12:14:21 2008 UTC (10 years, 1 month ago) by dpvc
Added

	 no strict "refs"

to try to avoid new error checking in Perl 5.10.

Revision 5695 - Directory Listing
Modified Sat Jun 14 11:56:02 2008 UTC (10 years, 1 month ago) by dpvc
Fix typo in comments

Revision 5692 - Directory Listing
Modified Sat Jun 14 11:46:28 2008 UTC (10 years, 1 month ago) by dpvc
Make sure the previous answer is of the same MathObject class as the
object being checked (so the comparison is done by the right object).
This came up with the ImplicitEquation object).

Revision 5684 - Directory Listing
Modified Sat May 24 23:05:02 2008 UTC (10 years, 1 month ago) by dpvc
Moved previous_equivalence_message filter to Formula object directly,
so it is no longer needed in the FUNCTION_CMP macro itself.

Revision 5600 - Directory Listing
Modified Wed Jan 16 22:51:52 2008 UTC (10 years, 6 months ago) by dpvc
Make sure that real and complex values have their contexts changed if
one is specified in the call to new().

Revision 5592 - Directory Listing
Modified Sun Dec 2 14:19:50 2007 UTC (10 years, 7 months ago) by dpvc
Fixed a problem where intervals minus sets containing more than one
point were not being handled properly.

Revision 5589 - Directory Listing
Modified Thu Nov 15 12:31:50 2007 UTC (10 years, 8 months ago) by dpvc
When two sets are added, combine them rather than form a union.
(This allows Inequailities context to report errors better when
student answers are of the form x=a or x=b.)

Revision 5588 - Directory Listing
Modified Thu Nov 15 12:30:47 2007 UTC (10 years, 8 months ago) by dpvc
Do the reduction check on sets when they are compared (to see if there
are repeated values, for example).

Revision 5535 - Directory Listing
Modified Wed Sep 26 02:15:29 2007 UTC (10 years, 9 months ago) by dpvc
Localize the $ans variable (rather than incorrectly using a closure).

Revision 5520 - Directory Listing
Modified Mon Sep 24 22:33:16 2007 UTC (10 years, 9 months ago) by dpvc
Update the List() object to not add "(" and ")" around the list unless
they are explicitly entered by the author.  This prevents extraneous
parentheses from being introduced into the problem text that the
author hadn't expected.

Parentheses now are added only for nested lists, as in
List(1,List(2,3)), which will display as "1, (2, 3)", not "1, 2, 3".

Revision 5517 - Directory Listing
Modified Thu Sep 20 18:02:24 2007 UTC (10 years, 10 months ago) by dpvc
Make adaptive parameters try again if they fail to be found the first
time (Gavin has found cases where the random points cause the
coefficient matrix to be singular, so a second try should resolve the
problem).

Revision 5509 - Directory Listing
Modified Sat Sep 15 00:56:51 2007 UTC (10 years, 10 months ago) by dpvc
Formula objects and Context objects contain reference loops, which
prevent them from being freed properly by perl when they are no longer
needed.  This is a source of an important memory leak in WeBWorK.  The
problem has been fixed by using Scalar::Util::weaken for these
recursive references, so these objects can be freed properly when they
go out of scope.  This should cause an improvement in the memory usage
of the httpd child processes.

Revision 5475 - Directory Listing
Modified Sat Sep 8 22:54:17 2007 UTC (10 years, 10 months ago) by dpvc
Report error messages correctly when ijk notation is involved and
ijkAnyDimension is set.

Revision 5474 - Directory Listing
Modified Sat Sep 8 22:30:40 2007 UTC (10 years, 10 months ago) by dpvc
Use ijkAnyDimension in the check for parallel vectors as well.

Revision 5473 - Directory Listing
Modified Sat Sep 8 22:27:02 2007 UTC (10 years, 10 months ago) by dpvc
Had the inequality going the wrong way.  OOPS!

Revision 5472 - Directory Listing
Modified Sat Sep 8 22:24:06 2007 UTC (10 years, 10 months ago) by dpvc
Make vectors that are creates using ijk notation remain in ijk
notation when displayed.  (This is easy now that objects produced by
combining others inherit the parent objects' flags.)

Added another context flag (ijkAnyDimension) that controls whether
vectors in ijk notation will conform to whatever dimension is used by
the vector they are being compared to.  When set, i+2*j will equal
<1,2> even though i and j are vectors in 3-space.  The value of
ijkAnyDimension is 1 by default.

This eliminates the need for the Vector2D context.

Revision 5469 - Directory Listing
Modified Sat Sep 8 21:35:21 2007 UTC (10 years, 10 months ago) by dpvc
Removed an experiment that I accidentally left in during the last commit.

Revision 5468 - Directory Listing
Modified Sat Sep 8 21:33:53 2007 UTC (10 years, 10 months ago) by dpvc
The make() method now inherits all the settings of the parent object,
so that flags set by the user (e.g., tolerances, periods, and so on)
will be passed on as new objects are created.  For example, in

     $x = Real(1)=>with(tolerance=>.0001);
     $y = sin($x);

$y will also have tolerance set to .0001.

This also applies to binary operations, where the result will now
inherit all the values of either operand, with the left-hand operand
taking precedence when they both have a flag set but to different
values.

This is a significant change, and there may be unforeseen side effects
that I'll have to take care of as they appear.  It passes my test
suite, however, so I'm hoping they will be limited.

Revision 5467 - Directory Listing
Modified Sat Sep 8 21:25:06 2007 UTC (10 years, 10 months ago) by dpvc
Allow interval data to be given in more forms (eg, (a,b,"(",")") in
addition to ("(",a,b,")"), since that is the order that the value()
method returns the data.)

Revision 5462 - Directory Listing
Modified Thu Sep 6 10:36:15 2007 UTC (10 years, 10 months ago) by dpvc
Only try to reduce intervals, sets and unions.  (Don't call isReduced
on objects that don't support it).

Revision 5455 - Directory Listing
Modified Thu Aug 30 02:45:18 2007 UTC (10 years, 10 months ago) by dpvc
Make sure Formula's value() method doesn't produce an error when it
can't extact the separate entries of the formula.

Revision 5442 - Directory Listing
Modified Tue Aug 28 23:08:44 2007 UTC (10 years, 10 months ago) by gage
Backporting changes from HEAD to rel-2-4-dev

Revision 5439 - Directory Listing
Modified Tue Aug 28 21:53:42 2007 UTC (10 years, 10 months ago) by dpvc
Updated contexts to include a "name" field that at least tracks what
context you started with (though it can be modified and no longer be
the same as the original context).

Remove the individual named variables in the Default.pm file; they are
now available only through the %Parser::Context::Default::context
hash.

Remove the >< and . operators, the <...> parentheses, the norm and
unit functions, and the i, j, and k constants from the Point context.
So the Point context no longer includes vectors and vector
operaterations.

Revision 5436 - Directory Listing
Modified Tue Aug 28 01:30:25 2007 UTC (10 years, 10 months ago) by dpvc
Had the wrong inequality (but since answers won't usually contain
newlines, this won't have affected anyone).

Revision 5433 - Directory Listing
Modified Sun Aug 26 19:05:18 2007 UTC (10 years, 10 months ago) by dpvc
Improve error messages for unreduced unions.

Revision 5430 - Directory Listing
Modified Sun Aug 26 12:13:12 2007 UTC (10 years, 10 months ago) by dpvc
Had the test reversed in isReduced when returning a boolean rather
than an array (Argh!)

Revision 5429 - Directory Listing
Modified Sun Aug 26 11:56:24 2007 UTC (10 years, 10 months ago) by dpvc
Make sure the constructor creates the interval in the correct context.

Revision 5428 - Directory Listing
Modified Sun Aug 26 03:03:29 2007 UTC (10 years, 10 months ago) by dpvc
Allow Interval constructor to handle more situations.

Revision 5427 - Directory Listing
Modified Sun Aug 26 03:02:06 2007 UTC (10 years, 10 months ago) by dpvc
Minor change (don't need to check for isValue since we are already
assuming that in the previous line).

Revision 5408 - Directory Listing
Modified Fri Aug 24 03:02:54 2007 UTC (10 years, 11 months ago) by dpvc
Load the UNIVERSAL package and make it available to Parser Items and Contexts.

Revision 5405 - Directory Listing
Modified Wed Aug 22 23:38:13 2007 UTC (10 years, 11 months ago) by dpvc
Revamp the isReduced() method for Unions and Sets so that it produces
error indicators in addition to the T/F result.  The answer checker
now uses that to produce more meaningful error messages for students
(in the past it always said "Your union can be produced without
overlaps" even when that was not the actual reason why the union is
not reduced).

Revision 5403 - Directory Listing
Modified Wed Aug 22 23:31:10 2007 UTC (10 years, 11 months ago) by dpvc
Make sure Context's cmpDefaults hash is copied when duplicated.  (Now
that isHash() and so on can be used, this can be improved.)

Revision 5401 - Directory Listing
Modified Wed Aug 22 20:16:26 2007 UTC (10 years, 11 months ago) by dpvc
Allow conversion of error messages after the value substitution has
been performed.  Also provide a subroutine to do more complex
conversion of error messages:

    Context()->{error}{convert} = sub {
      my $message = shift;
      ... manipulate message ...
      return $message;
    }

Revision 5399 - Directory Listing
Modified Wed Aug 22 19:49:36 2007 UTC (10 years, 11 months ago) by dpvc
Allow contexts to override the MathObject constructors separately from
the ones generated by the parser.  That way, you can define Real(),
for example, to produce ScientificNotation, without screwing up the
reals used in the parser itself.

Revision 5389 - Directory Listing
Modified Sun Aug 19 21:43:37 2007 UTC (10 years, 11 months ago) by dpvc
Only do this translation when not in hardcopy mode (but the answer
checkers aren't called then anyway, so that is probably not ever going
to occur).

Revision 5382 - Directory Listing
Modified Sun Aug 19 18:00:48 2007 UTC (10 years, 11 months ago) by dpvc
The overridden with() method was not preserving all the settings in
the Formula.  This has been fixed.

Revision 5376 - Directory Listing
Modified Sun Aug 19 03:41:45 2007 UTC (10 years, 11 months ago) by dpvc
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.)

Revision 5356 - Directory Listing
Modified Sat Aug 18 02:47:09 2007 UTC (10 years, 11 months ago) by dpvc
The MultiAnswer object calls cmp_compare() in a non-standard way (in
order to get its checker routine to run inside an eval call, which it
can't do itself since it is not a .pm file, and so is in the safe
compartment).  Recent changes to this routine to take advantage of
MathObjects storing their contexts broke this non-standard usage.  (It
should really be changed so that this hack isn't necessary in the
MultiAnswer object.)

Revision 5345 - Directory Listing
Modified Fri Aug 17 16:24:40 2007 UTC (10 years, 11 months ago) by dpvc
Fixed a typo that prevented the flags from the cmp() method from being
accessible to the getFlag() method.  OOPS!

Revision 5253 - Directory Listing
Modified Thu Aug 9 06:30:52 2007 UTC (10 years, 11 months ago) by dpvc
Copy the error message translation array when a Context is duplicated.

Revision 5240 - Directory Listing
Modified Tue Aug 7 04:33:31 2007 UTC (10 years, 11 months ago) by dpvc
Use cached value of context rather than looking it up each time.

Revision 5239 - Directory Listing
Modified Tue Aug 7 04:32:33 2007 UTC (10 years, 11 months ago) by dpvc
Use corret indices for the left and right endpoints.  (The paren types
are not stared in the data, only the endpoints, so use entries 0
and 1, not 1 and 2).

Revision 5214 - Directory Listing
Modified Mon Jul 23 12:11:14 2007 UTC (11 years ago) by dpvc
Allow Parser::Formula to accept context parameter.

Revision 5181 - Directory Listing
Modified Sun Jul 15 13:03:43 2007 UTC (11 years ago) by dpvc
Removed promote() from calls to funcitons where the operand will
already be a Complex; overloaded operations guarantee this, unless the
funciton is called explicitly through the package name.  It is
more direct to do something like sin(Complex($a,$b)) than
Value::Complex::sin($a,$b) anyway.  Although I was trying to allow
both forms, it is not worth the overhead to allow the second form, and
it is nor really "best practice" anyway.

Revision 5180 - Directory Listing
Modified Sun Jul 15 12:11:07 2007 UTC (11 years ago) by dpvc
Accidental typo due to global search and replace.

Revision 5178 - Directory Listing
Modified Fri Jul 13 21:59:34 2007 UTC (11 years ago) by dpvc
Make periodic comparisons have their tolerances based on the correct
answer point rather than just the period.  (This avoids zeroLevel
checks on one coordiante when period is pure imaginary or pure real.)

Also fixed promote() calls since it has been moved to Value.pm.

Revision 5170 - Directory Listing
Modified Fri Jul 13 20:50:45 2007 UTC (11 years ago) by dpvc
Make Real and Complex objects promote their period fields so that they
can be specified as strings rather than actual objects.

Also make the default promote() routine be the more sophisticated one
used by Real and Complex (and so remove the reoutine from those objects).

Revision 5132 - Directory Listing
Modified Mon Jul 9 19:54:21 2007 UTC (11 years ago) by dpvc
Better control over when extra parentheses are added.

Revision 5127 - Directory Listing
Modified Fri Jul 6 15:21:12 2007 UTC (11 years ago) by dpvc
Record the equation of the separate components of the list so that
getFlag will be able to obtain the values from the original list or
formula.

Revision 5126 - Directory Listing
Modified Fri Jul 6 15:19:37 2007 UTC (11 years ago) by dpvc
The value computed by modulo() is already a Complex, so no need to
cast it to be one (in fact, it screwed up the value, since make()
expects the real and imagniary parts separately).

Revision 5125 - Directory Listing
Modified Wed Jul 4 20:26:24 2007 UTC (11 years ago) by dpvc
Use precompiled patterns for efficiency.

Revision 5116 - Directory Listing
Modified Tue Jul 3 10:44:30 2007 UTC (11 years ago) by dpvc
Modified the method used to tokenize a formula to use one large
pattern that includes all the token types rather than individual
patterns for variables, strings, operators, and so on.  This allows
the Parser to handle the situation where a token of one type is a
prefix of a token of another type (e.g., < as a parenthesis but <- as
an operator) without worrying about which one is checked first.  The
new mtheod is also more flexible about having additional patterns
(like quoted strings, or arbitrary variable names) and about
specifying the order in which they are applied.

Revision 5115 - Directory Listing
Modified Mon Jul 2 23:48:00 2007 UTC (11 years ago) by dpvc
Get the period and logperiodic values using getFlags rather than only
looking in the object itself (this allows it to inherit the values
from a Formula, for example).

Revision 5113 - Directory Listing
Modified Mon Jul 2 16:27:13 2007 UTC (11 years ago) by dpvc
Improve some error messages.
In comparisons, mark the values created by the formulas so that they
will use the formula's tolerances.

Revision 5112 - Directory Listing
Modified Mon Jul 2 16:18:49 2007 UTC (11 years ago) by dpvc
Make getFlag() look for an {equation} field and add that into the
search path for the flag.  This lets Formula object tag their results
so that printing and comparisons will use the flags from the Formula
for formats and tolerances.

Revision 5111 - Directory Listing
Modified Mon Jul 2 00:50:14 2007 UTC (11 years ago) by dpvc
Changed with() to make a copy (as suggested last week).  This one is a
deep copy, however, since the tree is modified and we don't want to
change the original, we need to make a deep copy.

Adjust bop() to remove dependency on hard-coded Parser package name.

Remove stringify, which is now identical to parent version

Move usesOneOf to near isConstant (cosmetic change only).

Revision 5108 - Directory Listing
Modified Sun Jul 1 18:34:13 2007 UTC (11 years ago) by dpvc
Remove unneeded parens and do better type coersion in new() method.
Preserve contexts in more situations.
Handle errors in powers better.
Promote more types of objects (specifically, parse string values) in several places.
Handle dimensions more carefully in comparison.
Handle dimensions more carefully in column extraction.
Allow identity matrix dimension to come from the object creating it, when applicable.
Don't override stringify or string methods.  (This used to be needed
  to force the display to use proper open and close symbols, but
  we now coerce the rows to be of matrix type, so that is no longer needed.)

Revision 5104 - Directory Listing
Modified Sun Jul 1 11:17:31 2007 UTC (11 years ago) by dpvc
Remove unneeded parens, and don't use $isMatrix (scalar(@d) being
non-zero can be used instead).
Make sure ColumnVector status is retained in make() (so that adding
column vectors produces a column vector, for example).
Convert more values in promote (e.g., strings).
Fix a number of error messages and comments, and some formatting.
Handle contexts better.
Arrange for method inheritence in abs and areParallel.
Don't need stringify since it is now the same as the parent version.

Revision 5103 - Directory Listing
Modified Sun Jul 1 11:11:01 2007 UTC (11 years ago) by dpvc
Promote more possible values (e.g., strings).

Revision 5101 - Directory Listing
Modified Sun Jul 1 01:50:21 2007 UTC (11 years ago) by dpvc
Remove unneeded paretheses.
Don't need $isMatrix (since scalar(@d) non-zero tells us that).
Fix up some error messages.

Revision 5100 - Directory Listing
Modified Sat Jun 30 15:07:45 2007 UTC (11 years ago) by dpvc
Maintain context in a number of places where it was being lost.
Properly create Intervals from List and Point objects, when apropriate.
Properly create Formulas from non-constant Unions.
Properly report whether Unions of single items are reduced.
Only add parentheses when needed in stringify.

Revision 5097 - Directory Listing
Modified Sat Jun 30 02:39:10 2007 UTC (11 years ago) by dpvc
Promote arguments to Union operations.
Fix a typo.
Remove stringify since it is now the same as the parent class.

Revision 5096 - Directory Listing
Modified Sat Jun 30 02:37:34 2007 UTC (11 years ago) by dpvc
Remove unneeded parens in if statements.
Don't need $isMatrix (since scalar(@d) > 0 only in that case).
Promote arguements to Set operations.
Use Union routine to handle subtraction, since promotion may return an
interval or union under some circumstances.

Revision 5095 - Directory Listing
Modified Sat Jun 30 02:33:11 2007 UTC (11 years ago) by dpvc
Need to use flag() not getFlag() for context objects.

Revision 5093 - Directory Listing
Modified Sat Jun 30 00:35:17 2007 UTC (11 years ago) by dpvc
Produce a set when the endpoints of the interval are the same.
Fixed an error with the length method.
Make transferFlags only operate on the endpoints, no the parens.
Allow subtraction between intervals and non-intervals.
Promote non-intervals in the set operations.

Revision 5092 - Directory Listing
Modified Sat Jun 30 00:29:52 2007 UTC (11 years ago) by dpvc
Vectors can't be in Unions, even when of length two and with no parens.

Revision 5091 - Directory Listing
Modified Sat Jun 30 00:28:32 2007 UTC (11 years ago) by dpvc
Handle canBeInUnion properly (it must come AFTER isSetOfReals, and
needs to deal with empty parens).

Revision 5089 - Directory Listing
Modified Fri Jun 29 22:07:10 2007 UTC (11 years ago) by dpvc
Transfer flags from parent objects to their children for comparisons
and printing purposes.  Also touch up a few type-coersion issues.  (It
may be possible to not to need Value::isValue() if these can all be
taken care of.)

Revision 5088 - Directory Listing
Modified Fri Jun 29 20:05:15 2007 UTC (11 years ago) by dpvc
Improved an error message, fixed comparison of infinity to real
numbers, and aded a missing space in TeX output.

Revision 5085 - Directory Listing
Modified Fri Jun 29 19:13:37 2007 UTC (11 years ago) by dpvc
Fixed some type checking.  Removed some unwantedd fuzzy checks (use
exact checks instead).  Preserve context flags from complex object to
real and imaginary parts.  Preserve context during function evaluations.

Revision 5084 - Directory Listing
Modified Fri Jun 29 19:11:05 2007 UTC (11 years ago) by dpvc
Adjusted some of the type checking to use more appropriate tests.

Revision 5072 - Directory Listing
Modified Thu Jun 28 23:40:46 2007 UTC (11 years ago) by dpvc
Fixed a typo in the compare method.

Revision 5060 - Directory Listing
Modified Thu Jun 28 20:42:53 2007 UTC (11 years ago) by dpvc
Use Value->context rather than $$Value::context.

Revision 5056 - Directory Listing
Modified Thu Jun 28 11:32:10 2007 UTC (11 years ago) by dpvc
Make List() preserve the correct_ans field when it is used to coerce a
single element to a singleton list.

Revision 5042 - Directory Listing
Modified Thu Jun 28 01:31:09 2007 UTC (11 years ago) by dpvc
Recent changes to automatically do promotion in the Value methods was
a mistake.  I put it back into the subclass methods again.

Revision 5039 - Directory Listing
Modified Wed Jun 27 20:22:20 2007 UTC (11 years ago) by dpvc
OOPS, the example in the previous message is wrong.  You need to use

      $a = Context()->variables->get("a")->{value};
      $b = Context()->variables->get("b")->{value};

(brtaces around the "value").

Revision 5038 - Directory Listing
Modified Wed Jun 27 20:20:12 2007 UTC (11 years ago) by dpvc
Adaptive-parameter values are now stored in the Context so that they
can be retreived if needed.  E.g.,

    Formula("a x + b") == Formula("5 x - 3");
    $a = Context()->variables->get("a")->value;
    $b = Context()->variables->get("b")->value;

will have $a equal to 5 and $b equal to -3.

Revision 5027 - Directory Listing
Modified Sat Jun 23 20:20:09 2007 UTC (11 years, 1 month ago) by dpvc
Forgot to handle context in the make() method.

Revision 5026 - Directory Listing
Modified Sat Jun 23 20:08:07 2007 UTC (11 years, 1 month ago) by dpvc
Make the Package method really be a method of the context rather than
the Value objects, and make the Value method call the context one.
This means it is not necessary to pass the context as a parameter any
longer.

Revision 5025 - Directory Listing
Modified Sat Jun 23 20:05:49 2007 UTC (11 years, 1 month ago) by dpvc
Was taking the context form the wrong position in the parameter list.

Revision 5016 - Directory Listing
Modified Fri Jun 22 02:39:24 2007 UTC (11 years, 1 month ago) by dpvc
Handle ans_array() correctly again (context issues, and allow parser
to create a formula from an existing subtree).

Revision 5012 - Directory Listing
Modified Thu Jun 21 23:10:13 2007 UTC (11 years, 1 month ago) by dpvc
Added Package method to the Context object to replace the
Value->Package() calls and simplify the $self->Package calls (don't
have to look up the context again).

Revision 5006 - Directory Listing
Modified Sat Jun 16 02:08:02 2007 UTC (11 years, 1 month ago) by dpvc
Fixed an error with the modulo method, and adjusted formatting.

Revision 5001 - Directory Listing
Modified Tue Jun 12 04:05:56 2007 UTC (11 years, 1 month ago) by dpvc
More fixes for creating items in the corret context.  Also added a
method for looking up the package associated with a particular Parser
class (for consistency with the Value->Package call).

Revision 4996 - Directory Listing
Modified Sun Jun 10 11:34:27 2007 UTC (11 years, 1 month ago) by dpvc
Allow promote() to accept a context as the first argument so that the
promoted object can be forced into the given context.

Revision 4993 - Directory Listing
Modified Fri Jun 8 12:09:53 2007 UTC (11 years, 1 month ago) by dpvc
Added more flexible type checking for MathObject classes.  This makes
it possible to correctly match types even when the context has
specified a different package to handle a given type, for example.

Revision 4992 - Directory Listing
Modified Fri Jun 8 11:05:48 2007 UTC (11 years, 1 month ago) by dpvc
Fixed typo.

Revision 4991 - Directory Listing
Modified Fri Jun 8 02:09:21 2007 UTC (11 years, 1 month ago) by dpvc
Update new() and make() methods to accept a context as the first
parameter (making it easier to create objects in a given context
without having to resort to a separate call to coerce them to the
given context after the fact).

Revision 4990 - Directory Listing
Modified Thu Jun 7 23:48:20 2007 UTC (11 years, 1 month ago) by dpvc
More updates to use the new Value->Package() call.  This will make the
standard object-creation functions like Real() and Complex() use the
new lookup method.

Revision 4989 - Directory Listing
Modified Thu Jun 7 23:47:14 2007 UTC (11 years, 1 month ago) by dpvc
can't use inContext() with the "fake" make that produces perl reals,
so remove it for now.  (Perhaps we should just go with the Reals() and
not try to be fancy about it, since it will often get converted to a
Real anyway).  This will need more work.

Revision 4988 - Directory Listing
Modified Thu Jun 7 23:43:42 2007 UTC (11 years, 1 month ago) by dpvc
Give the MathObjects answer checker a _filter_name so it is easier to recognize.

Revision 4987 - Directory Listing
Modified Thu Jun 7 21:54:46 2007 UTC (11 years, 1 month ago) by dpvc
Added Value->Package(name[,context]) to look up what package is
currently set to handle the named type.  E.g.,
Value->Package("Complex") usually returns "Value::Complex".  These can
be overridden in the Context so that modified vesions of the
MathObjects can be made to replace the existing ones more easily.  In
particular, the Parser classes should call these (not yet implemented)
when they create objects, so that you can override the object they
create.

Also cleaned up some more context issues (with still more to come).

Revision 4979 - Directory Listing
Modified Thu Jun 7 11:59:05 2007 UTC (11 years, 1 month ago) by dpvc
More updates for marking MathObjects with the context in which they
were created, so they should now work like the Formula objects in that
respect.  As they are combined via overloaded operators, they should
pass on their contexts correctly.

Also normalized the use of getFlag() to obtain flags from the
MathObject's context rather than looking in the context directly.
This allows the math object to override the flag by setting the flag
value in the object's hash (e.g., $f->{tolerance} = .001).  I've also
added the ability to override context flags via the answerHash (e.g.,
$f->cmp(tolerance => .001)), though some filtering may need to be
added to this at some point.  Note that ONLY the context flags can be
overridden, not other parts of the context.

Revision 4976 - Directory Listing
Modified Wed Jun 6 23:00:14 2007 UTC (11 years, 1 month ago) by dpvc
Added comparisons for periodic reals and complex numbers (numbers that
match up to reduction module some number).  This makes
contextPeriodic.pl obsolete, but the problems that use it should not
need to change.  (It would be good to remove the loadMacros() call,
however.)

Reals and Complex numbers now overload the % operator for the modulo
operation.

Revision 4975 - Directory Listing
Modified Wed Jun 6 21:44:05 2007 UTC (11 years, 1 month ago) by dpvc
This begins some major updates to the Parser and Value libraries.
This may make the MathObjects unstable as things shake down, but I'll
try to keep that to a minimum.

This update reorganizes how the overloading of operations are
implemented.  The base Value class is now overloaded rather than the
individual Value classes.  This makes it easier to make subclasses
that take advantage of the overloading.

The code that handles promoting one MathObject to another has been
updated as a part of this.  This should also make subclassing the
existing MathObjects more flexible.

In the past, Formula objects included a pointer to the Context in
which the object was created, but other MathObject did not.  This
update is the first round of updates to include the context in the
other MathObjects, but more work needs to be done.

The changes here should not affect existing problems; it is possible
that some macro files will need to be updated, but none of the
standard ones in pg/macros seem to need it at the moment.

Revision 4964 - Directory Listing
Modified Tue May 22 18:02:40 2007 UTC (11 years, 2 months ago) by dpvc
Fixed an error with List answer checking when one of the elements was
the constant 0 (a check for whether a value was defined was not
properly handling the case when the answer is zero (which counts as
false in a boolean check)).

Revision 4962 - Directory Listing
Modified Wed May 16 00:36:37 2007 UTC (11 years, 2 months ago) by dpvc
Allow Real object to override the context's number format by setting
its format field.  E.g.:

    Real(1.2345)->with(format=>"%.2f")

Revision 4930 - Directory Listing
Modified Wed Apr 18 22:37:59 2007 UTC (11 years, 3 months ago) by dpvc
Clear the error message in Context before it is used in an answer
checker (prevents bleading of one error into a later answer).

Revision 4844 - Directory Listing
Modified Tue Mar 6 01:51:12 2007 UTC (11 years, 4 months ago) by gage
Format fix

Revision 4834 - Directory Listing
Modified Sun Mar 4 23:39:20 2007 UTC (11 years, 4 months ago) by gage
Formatting changes in documentation

Revision 4833 - Directory Listing
Modified Sun Mar 4 23:26:12 2007 UTC (11 years, 4 months ago) by gage
More format changes to documentation

Revision 4829 - Directory Listing
Modified Sun Mar 4 22:10:40 2007 UTC (11 years, 4 months ago) by gage
 Updated documentation in response to comments from Davide.
 More comments welcome. :-)

 --Mike

Revision 4827 - Directory Listing
Modified Sun Mar 4 20:58:26 2007 UTC (11 years, 4 months ago) by gage
Added pod documentation for these files

Revision 4824 - Directory Listing
Modified Sat Mar 3 00:31:14 2007 UTC (11 years, 4 months ago) by dpvc
Only show the adaptive parameters where there actually ARE some, and
fix a typo when looking up the adaptive points when there aren't any.

Revision 4823 - Directory Listing
Modified Sat Mar 3 00:17:12 2007 UTC (11 years, 4 months ago) by dpvc
Improved Formula diagonstics when adaptive parameters are used.  They
now allow you to graph the functions (they are no longer considered
multi-variable functions), and the values reported are the adapted
values rather then the unadapted correct answers.  This now correctly
reflects the tests that are being performed.

Revision 4822 - Directory Listing
Modified Sat Mar 3 00:11:28 2007 UTC (11 years, 4 months ago) by dpvc
Use zeroLevelTol values when checking answers that have adaptive parameters.

Revision 4795 - Directory Listing
Modified Sun Feb 25 20:59:09 2007 UTC (11 years, 4 months ago) by dpvc
Avoid an infinite loop when string-values formulas are used in a List.
Allow diagonstics to work for complex-valued functions.

Revision 4728 - Directory Listing
Modified Sat Dec 16 14:07:58 2006 UTC (11 years, 7 months ago) by dpvc
Use Perl reals rather than Parser Reals in matrix for adaptive
parameters.

Revision 4663 - Directory Listing
Modified Sun Nov 26 20:30:17 2006 UTC (11 years, 7 months ago) by dpvc
Added ability to have additional information given when not enough
test points can be generated for a function comparison.  By default,
this information is NOT shown (since it could give students additional
information about what answer is expectd).  Professors can request it
by setting the 'showTestPointErrors' flag in the Context().

Revision 4662 - Directory Listing
Modified Sun Nov 26 20:11:03 2006 UTC (11 years, 7 months ago) by dpvc
Allow overridden Parser classes to generate error messages that the
student will see.  (For formulas, error messages are trapped silently
by the overridden == and will not be seen.  This lets Parser objects
force a message to be seen.)

Revision 4625 - Directory Listing
Modified Fri Nov 3 23:05:37 2006 UTC (11 years, 8 months ago) by dpvc
Fixed problem with checking Matrices of dimension 1 x n.
(Fixes bug 1122.)

Revision 4513 - Directory Listing
Modified Fri Sep 22 16:36:57 2006 UTC (11 years, 10 months ago) by dpvc
Make ijk mode use the TeX definitions from the i, j and k constants as
defined in the context, if they exist, otherwise fall back on the
defaults.

Revision 4512 - Directory Listing
Modified Thu Sep 21 22:08:49 2006 UTC (11 years, 10 months ago) by dpvc
Fix problem with formula comparisons involving vector-valued formulas.
The coordinates for the vectors used in checking equality were plain
Perl reals rather than Parser-based reals, and so the comparisons were
being done using exact rather than fuzzy comparisons.

Revision 4464 - Directory Listing
Modified Sat Sep 9 00:22:13 2006 UTC (11 years, 10 months ago) by dpvc
Add parenthesis around ijk vectors for string concatenation.

Revision 4423 - Directory Listing
Modified Tue Aug 29 11:12:56 2006 UTC (11 years, 10 months ago) by dpvc
Allow cmp_compare to return an array of answers, if requested (needed
by parserMultiPart.pl).

Revision 4384 - Directory Listing
Modified Wed Aug 16 01:41:02 2006 UTC (11 years, 11 months ago) by dpvc
Fixed spelling errors in error messages.

Revision 4383 - Directory Listing
Modified Wed Aug 16 01:40:06 2006 UTC (11 years, 11 months ago) by dpvc
Fixed a problem where Set objects could incorrectly complain about the
parentheses (braces) used to declare the set.

Revision 4301 - Directory Listing
Modified Wed Jul 26 13:23:09 2006 UTC (11 years, 11 months ago) by dpvc
Allow matrices to be created from lists of vectors or points, or from
formulas returning vectors or points.

Revision 4144 - Directory Listing
Modified Fri Jun 23 22:07:44 2006 UTC (12 years, 1 month ago) by dpvc
Use tolerance flags from the Real object itself, if available, before
looking at the context.

Revision 4143 - Directory Listing
Modified Fri Jun 23 22:06:47 2006 UTC (12 years, 1 month ago) by dpvc
Fix some problems with the Diagonstics output for Formula objects.
(The tolerances using in the diagnostics didn't always match the ones
used in the actual testing, and the wrong values were sometimes
displayed when a multi-variable function was displayed as a graph.)

Revision 4093 - Directory Listing
Modified Tue May 23 11:51:55 2006 UTC (12 years, 2 months ago) by dpvc
Fixed a problem where a pick screen error was produced if a student
entered a vector-valued formula rather than a constant vector when
parallel answers are being checked and the student used the Preview
button to submit the answer.

Revision 3992 - Directory Listing
Modified Mon Jan 30 16:20:09 2006 UTC (12 years, 5 months ago) by dpvc
When checking for division by zero, don't do fuzzy check.

Revision 3872 - Directory Listing
Modified Sat Dec 31 16:31:48 2005 UTC (12 years, 6 months ago) by dpvc
Added ability to supply a code reference (rather than a Value object)
for the typeMatch and extra fields for the List answer checker (and
the String answer checker).  This makes these more useful in
overriding the match for specific problems that want better error
messages, for example.

Revision 3869 - Directory Listing
Modified Sat Dec 31 14:57:39 2005 UTC (12 years, 6 months ago) by dpvc
Added a new flag that controls how a list with a single entry that is
a list is handled.  In the past, the student could not specify such an
item, but now the default is to form a list with a single entry that
is a list, provided the student has used parens explicitly around his
list.  So "1,2" will be a list with two items and "(1,2)" will be a
list with one item (a list).  This improves the ability to use the
list checker for lists of arbitrary pairs (like "(1,max)") especially
when you want to check for lists of these (e.g., "(1,max),(2,min)"),
since otherwise a single pair "(1,max)" entered by the student would
become the list "1,max" rather than the list containing the single
pair.

If you really want "(1,max)" to become the list "1,max", use

   List("1,max")->cmp(implicitList=>0);

to prevent single lists from forming a list of a single item.

Revision 3868 - Directory Listing
Modified Sat Dec 31 02:42:46 2005 UTC (12 years, 6 months ago) by dpvc
Now that the Parser allows multi-letter variable names, there is no
need to handle C0 specially.

Revision 3754 - Directory Listing
Modified Sat Nov 12 00:30:31 2005 UTC (12 years, 8 months ago) by dpvc
Roll back Mike's change, since this can cause unwanted error messages
in list comparisons and other situations where the equality check
could compare different types of objects (for example) or where the
comparison could legitimately fail.  We only want to report errors
here when the user-supplied checker code fails.

This change would cause errors to be reported, for example, when the
user (incorrectly) entered a vector one time and then a formula
(correctly) the next time.  When the previous answer is checked against
the current one, this change would report an error rather than
silently ignoring the error, as it should.

Revision 3752 - Directory Listing
Modified Sat Nov 12 00:12:54 2005 UTC (12 years, 8 months ago) by gage
Changes to code checking whether the previous answer is equivalent to the current answer.
In this module additional code was answer to check for errors in the overloaded ==
in case the two Values can't be compared.

In PGanswermacros.pl the filter which handles "parse_previous_answer"
was modified to make sure the context is the same in the previous answer and the current answer.

Revision 3716 - Directory Listing
Modified Sun Oct 16 03:37:17 2005 UTC (12 years, 9 months ago) by dpvc
In the past, when Value objects were inserted into strings, they would
automatically include parentheses so that if you had $f equal to 1+x
and $g equal to 1-x, then Formula("$f/$g") would mean (1+x)/(1-x)
rather than 1+(x/1)-x, which is what would happen as a straing string
substitution.

The problem is that this would also happen for real numbers, vectors,
and everything else, even when it wasn't necessary.  So if $x=Real(3),
then "Let x = $x" would be "Let x = (3)".

I have changed the behavior of the string concatenation for Value
objects so that parentheses are only added in a few cases: for
Formulas, Complex numbers, and Unions.  This makes the other Value
objects work more like regular variables in strings, but might cause
some problems with strings that are used as formulas.  For example, if
$a = Real(-3), then "x + 2 $a" will become "x + 2 -3", or "x-1" rather
than the expected "x - 6".  (The old approach would have made it "x +
2 (-3)" which would have worked properly).  For the most part, it is
easier to use something like "x + 2*$a" or even "x" + 2*$a in this
case, so the extra trouble of having to avoid parentheses when you
really meant to substitute the value into a string didn't seem worth
it.

Revision 3715 - Directory Listing
Modified Sun Oct 16 03:27:35 2005 UTC (12 years, 9 months ago) by dpvc
Added a new experimental diagonstic function for the function answer
checker.  When enabled, it will produce graphs of the correct answer,
the student answer, and the absolute and relative errors, and will
list the data points used in the comparison, plus the numerical values
of the results and errors.

To enable the diagnostic, use

   ANS(fun_cmp($f,diagnostics=>1));

Note that only single-variable functions can be graphed at the moment,
so if you are using a multi-variable check, you need to disable the
graphing.  To do this use

   ANS(fun_cmp($f,vars=>['x','y'],diagnostics=>[showGraphs=>0]));

The diagnostic mode is only available for the Parser-based versions of
the function checker, and (of course) with the native Parser objects
as well:

   ANS(Formula($f)->cmp(diagnostics=>1));

There are now Context settings to control the diagnostics, which can
be set through Context()->diagnostics->set().  For example

   Context()->diagnostics->set(formulas=>{showGraphs=>0});

would turn off graphs for all functions comparisons.  Some of the
other values you can set are:

   formulas => {
     showTestPoints => 1,        # show the test points and function values
     showRelativeErrors => 1,    # show the relative errors for the student answer
     showAbsoluteErrors => 1,    # show the absolute errors for the student answer
     showGraphs => 1,            # show the various graphs
     graphRelativeErrors => 1,   #  show the relative error graph
     graphAbsoluteErrors => 1,   #  show the absolute error graph
     clipRelativeError => 5,     #  don't show relative errors above 5
     clipAbsoluteError => 5,     #  don't show absolute errors above 5
     plotTestPoints => 1,        #  include dots at the test points
     combineGraphs => 1,         #  show correct and student graphs in one image
   },
   graphs => {
     divisions => 75,       # the number of data points to plot
     limits => [-2,2],      # the lower and upper limit of the plot
                            #  (taken from the function limits if not provided)
     size => 250,           # pixel size of the image (could be [width,height])
     grid => [10,10],       # number of grid lines in each direction
     axes => [0,0],         # where to put axes relative to origin
   }

Any of these can be set in the Context(), or in the answer checker
itself.  If you set diagnostics to an array reference, the entries in
the array refer to element of the formulas hash.  If you set
diagonstics to a hash reference, then you can set values in either the
formulas or graphs hashes, as in:

   ANS(Formula($f)->cmp(diagnostics=>{
     formulas => {showAbsoluteErrors=>0},
     graphs => {size=>300, divisions=>100},
   }));

If you want all function checkers to show diagnostics, use

   Context()->diagonstics->set(formulas=>{show=>1});

The image file names are modified to include the current time so that
the names will be unique.  This avoids problems with the browser cache
showing a old image when a new one has been generated.  But this also
means that the temporary image directory will fill up fast, so you may
need to empty it if you use the diagnostic images frequently.

This is just a first attempt at a diagnostic feature.  I think it will
help when you are not sure if the tolerances are set properly, or if
you think a student answer should be markes correct but isn't, as it
will point out which point(s) are not being accepted.

Revision 3714 - Directory Listing
Modified Sun Oct 16 02:44:34 2005 UTC (12 years, 9 months ago) by dpvc
Modified context data objects to provide a copy method so that the
various types of data can copy themselves (and can provide a more
comprehensive copy if necessary).

Revision 3713 - Directory Listing
Modified Fri Oct 14 23:33:58 2005 UTC (12 years, 9 months ago) by dpvc
Let Parser object's cmp(debug=>1) option set the debug feature of the
answer evaluator.

Revision 3703 - Directory Listing
Modified Mon Oct 10 23:47:26 2005 UTC (12 years, 9 months ago) by dpvc
Add a new context flag that controls how the student answer should be
displayed.  The formatStudentAnswer flag can be set to 'evaluated'
(the default), which shows the final numeric answer; 'parsed', which
shows the fully parsed version (including extra parentheses for
clarity); or 'reduced', which performs constant operations, but
doesn't perform function evaluations or named-constant substitutions.

For example, if the student answers 1+2+sqrt(3), then 'evaluated' will
produce  4.73205, 'reduced' will show 3+sqrt(3), and 'parsed' will
show 1+2+sqrt(3).

Revision 3696 - Directory Listing
Modified Mon Oct 10 12:37:13 2005 UTC (12 years, 9 months ago) by dpvc
Fixed a bug where correct_ans could not be overridden in the cmp()
method for Lists.

Revision 3678 - Directory Listing
Modified Sat Oct 1 01:13:27 2005 UTC (12 years, 9 months ago) by dpvc
Handle the names of entries in Lists and Formulas returning lists
better.  Also do better typechecking on these lists.  Finally, allow
better typechecking for String objects that are being used when a
Formula answer is allowed.

Revision 3677 - Directory Listing
Modified Sat Oct 1 01:10:27 2005 UTC (12 years, 9 months ago) by dpvc
Allow context to override object class used to create formula objects
(so that things like ImplicitPlane can create instances of themselves
automatically when needed).

This mechanism needs to be enlarged to encompass the other Value
object classes as well (like the Context()->{parser}{...} hash).

The real problem is that the List object probably shouldn't create a
formula returning a list when it is passed formulas, since there
really isn't much need for a formula returning a list to be
autogenerated (you can create one by hand using Formula if needed).

Right now, ALL the Value objects make themselves into Formulas when
one of their entries is a formula.  For example, Point(1,"x") produces
the same thing as Formula("(1,x)"), and List(1,"x") is the same as
Formula("1,x").  This is good for points, but not so good for lists.
And it might sometimes be nice to have a Vector of Formulas, or a
Matrix with Formula entries (rather than Formulas returning Vectors or
Matrices).  But this would require some serious changes internally in
the Value objects, which make assumptions about their values being
constant.  Changing that will be for another day...

Revision 3676 - Directory Listing
Modified Sat Oct 1 00:59:06 2005 UTC (12 years, 9 months ago) by dpvc
Correctly create Formula returning List when a list has formula
entries.

Revision 3652 - Directory Listing
Modified Sat Sep 24 00:47:30 2005 UTC (12 years, 10 months ago) by dpvc
Added ability to have answers that are empty strings.  String("") now
will produce a valid string object regardless of the Context's defined
string values.  (You can prevent this using

       Context()->flags->set(allowEmptyStrings=>0);

if you wish).  String("")->cmp will produce an answer checker for an
empty string (it removes the blank checker that WW installs).

Revision 3633 - Directory Listing
Modified Sat Sep 17 13:22:52 2005 UTC (12 years, 10 months ago) by dpvc
Don't allow wrapping in label for ans_array errors.

Revision 3631 - Directory Listing
Modified Sat Sep 17 13:02:24 2005 UTC (12 years, 10 months ago) by dpvc
The Parser answer checkers used to give the student answer as the
parsed but unevaluated answer.  This has been changed so that the
student answer is now the computed result, no the parsed answer.
The answer preview still shows the parsed equation.  This is more
consistent with the traditional answer checkers, and probably is more
valuable to the students.

Revision 3630 - Directory Listing
Modified Sat Sep 17 12:39:09 2005 UTC (12 years, 10 months ago) by dpvc
Better error messages for unreduced unions.

Revision 3629 - Directory Listing
Modified Sat Sep 17 12:25:38 2005 UTC (12 years, 10 months ago) by dpvc
Improved error message layout and labeling for when ans_array is used.

Revision 3613 - Directory Listing
Modified Mon Sep 12 23:28:37 2005 UTC (12 years, 10 months ago) by dpvc
Fixed an error where scalar() was used on a hash ref.
Fixed a misfeature where operations on formulas could return Value
objects of other classes; they should always return formulas, even
when the formula is constant.

Revision 3596 - Directory Listing
Modified Fri Sep 2 22:29:59 2005 UTC (12 years, 10 months ago) by dpvc
Fixed error in atan2 where second argument was not promoted to a Real.

Revision 3589 - Directory Listing
Modified Tue Aug 30 00:44:53 2005 UTC (12 years, 10 months ago) by dpvc
Added the ability to put class-specific answer-checker defaults into
the Context object.  For example,

    Context("Vector")->{cmpDefaults}{Vector}{promotePoints} = 1;

would make all Vector answer checkers include promotePoints=>1
automatically.  (Note however that if a subclass of Vector is used, it
will not get this defaults, since its class name would be different.
Perhaps something more sophisticated will be needed in the future.)

Revision 3569 - Directory Listing
Modified Thu Aug 25 03:40:44 2005 UTC (12 years, 11 months ago) by dpvc
Fixed problem with Context's not properly initializing themselves with
the WW environment parameters (like zeroLevelTol and useBaseTenLog).
The copy method and the method that did an initialized copy used to be
separate routines, but that turned out to be unnecessary, so they have
now been merged (copy always tries to initialize the WW values when it
can, and when the copied context doesn't already have them).

The reason this is complicated is that a number contexts are set up
before the global.conf data is available, so these can't be
initialized with the WW values.  Also, these default contexts are
stored in the persistant processes, and we don't want to leave
possibly course-specific values lying around in them, so whenever a
context is selected, it is copied from the standard version and the
WW parameters are inserted into it.  The problem author can only
modify the copy, not the original, so this is OK with mod_perl.

The context's copy method now always tries to initialize (we used to
have to call initCoopy to get a copy that has the WW parameters
inserted).  That turned out to cause trouble with code that handled
contexts without the usual Context() command.

Revision 3562 - Directory Listing
Modified Wed Aug 24 19:07:10 2005 UTC (12 years, 11 months ago) by dpvc
Changed stringify to check for an answer that is zero by using the
zeroLevelTol value directly (rather than use the fuzzy equality check
for zero, which depends on the tolType in a bad way).

Revision 3525 - Directory Listing
Modified Sun Aug 14 00:23:10 2005 UTC (12 years, 11 months ago) by dpvc
Added methods for testing containment of one set in another, and so
on.  These include:

     $A->contains($B)        Test if $B is a subset of $A (or an
                             element of $A if $B$ is a real number).

     $A->isSubsetOf($B)      Test if $A is a subset of $B.

     $A->isEmpty             True if $A is the empty set.

     $A->intersects($B)      True if $A and $B have numbers in common.

     $A->intersect($B)       The set of numbers common to both $A and $B.

Be careful of the difference between "intersect" and "intersects".
One is a set the other a true/false value.

Revision 3523 - Directory Listing
Modified Sat Aug 13 22:38:39 2005 UTC (12 years, 11 months ago) by dpvc
Added canBeInUnion and isSetOfReals methods to the Parser package
(similar to the ones in the Value package), replacing the
canBeInterval flag and other ad hoc checks.

Removed ability to form interval like [a] now that we have sets.

Revision 3518 - Directory Listing
Modified Sat Aug 13 21:34:50 2005 UTC (12 years, 11 months ago) by dpvc
Allow a list of numbers to be converted to a set.

Revision 3517 - Directory Listing
Modified Sat Aug 13 21:31:46 2005 UTC (12 years, 11 months ago) by dpvc
Pass the canBeInUnion call on to the Formula's root node

Revision 3516 - Directory Listing
Modified Sat Aug 13 20:59:28 2005 UTC (12 years, 11 months ago) by dpvc
Added isSetOfReals and canBeInUnion methods to the Value objects, and
replaced the ad hoc tests for these conditions to call these
routines.

Cleaned up the make() methods for Intervals, Sets and Unions, and
improved the new() methods to handle more cases better.

Fixed Value::makeValue() to handle an array reference correctly.

I don't THINK any of this will break anything.  :-)

Revision 3515 - Directory Listing
Modified Sat Aug 13 20:55:35 2005 UTC (12 years, 11 months ago) by dpvc
Make formulas that produce lists get default open and close parens,
and have them retained in Formula() results.

Revision 3514 - Directory Listing
Modified Sat Aug 13 19:10:41 2005 UTC (12 years, 11 months ago) by dpvc
Make sure the singletons are sorted before comparing them to the
intervals (and each other).

Revision 3512 - Directory Listing
Modified Sat Aug 13 18:19:01 2005 UTC (12 years, 11 months ago) by dpvc
Can't use the length check when reducing unions, since it could
contain a single set that is not reduced, and we need to check that,
too.

Revision 3511 - Directory Listing
Modified Sat Aug 13 17:50:11 2005 UTC (12 years, 11 months ago) by dpvc
Fixed reduction warnings for individual sets, intervals and unions (in
making it work for lists, I broke it for the single items).

Revision 3510 - Directory Listing
Modified Sat Aug 13 17:32:58 2005 UTC (12 years, 11 months ago) by dpvc
Fixed a problem with redefine when used with classes that store their
data in a on-standard form (i.e., by overridding the create()
method).  Now they can define uncreate() to get the original data back
for use with redefine().

Revision 3508 - Directory Listing
Modified Sat Aug 13 16:58:56 2005 UTC (12 years, 11 months ago) by dpvc
Added isReduced method to tell if a Union, Set or Interval is already
reduced.  Fixed up sort to use CORE::sort, and added sort and reduce
to Intervals, which do nothing, but are there for consistency.

Revision 3507 - Directory Listing
Modified Sat Aug 13 16:57:14 2005 UTC (12 years, 11 months ago) by dpvc
Fixed error in testing is a union is reduced (didn't test if sets
within a union were reduced properly).

Revision 3505 - Directory Listing
Modified Sat Aug 13 16:33:50 2005 UTC (12 years, 11 months ago) by dpvc
Added sort methods to Union and Set that return objects with their
data sorted.

Revision 3504 - Directory Listing
Modified Sat Aug 13 15:57:17 2005 UTC (12 years, 11 months ago) by dpvc
Moved the union and set reduction checks from cmp_equal to cmp_compare
so that the messages can be produced even in lists of unions.

Improved the message facilities for the list comparison so that
cmp_compare can make errors that refer to the number of the entry in
the student's answer (otherwise an extra "There was a problem with
your nth value" message needs to be prepended, which looks bad if it
can be avoided).

Use the "extra" answer checker to report syntax error messages in unordered
lists.

Revision 3498 - Directory Listing
Modified Sat Aug 13 00:35:11 2005 UTC (12 years, 11 months ago) by dpvc
Fixed a typo in an error message.

Revision 3497 - Directory Listing
Modified Sat Aug 13 00:25:27 2005 UTC (12 years, 11 months ago) by dpvc
Added ability for Unions and Sets to simplify themselves
(automatically or on demand), and added flags to the Context and
answer checkers to control these features.  The new Context flags
are

    reduceUnions                tells whether unions are automatically
                                reduced when they are created.

    reduceUnionsForComparison   tells whether unions are reduced
                                before comparing them for equality
                                or inequality (etc) if they aren't
                                reduced already.

    reduceSets                  tells whether redundent elements are
                                removed from sets as they are created.

    reduceSetsForComparison     tells whether sets are reduced before
                                comparing them.

All of these default to true.

The Interval, Set, Union, and List answer checkers not have two new
flags for controlling these values:

    studentsMustReduceUnions    tells whether unions and sets will be
                                counted as incorrect when they are not
                                reduced to non-overlapping intervals
                                and at most one set with no repeated
                                entries.

    showUnionReduceWarnings     tells whether an error message will
                                be produced for non-reduced unions and
                                sets, or if they will be marked wrong
                                silently.  (Not available in Lists.)

Both of these are true by default, since most professors probably want
their students to write intervals in reduced form.  (Is this true?)
This corresponds the the current behavior of the interval checkers,
which require the student's answer to be the same set of intervals as
in the professor's, but with the addition of an error message when the
student answer is not reduced.

Revision 3493 - Directory Listing
Modified Fri Aug 12 22:56:04 2005 UTC (12 years, 11 months ago) by dpvc
Detect preview mode correctly for either WW1 or WW2.

Revision 3492 - Directory Listing
Modified Fri Aug 12 22:55:19 2005 UTC (12 years, 11 months ago) by dpvc
Adjust spacing.

Revision 3488 - Directory Listing
Modified Fri Aug 12 17:40:07 2005 UTC (12 years, 11 months ago) by dpvc
Avoid problem with undefined value being passed to protectHTML.

Revision 3487 - Directory Listing
Modified Fri Aug 12 17:09:42 2005 UTC (12 years, 11 months ago) by dpvc
Changed how Intervals implement the requireParenMatch flag for the
interval and union answer checker.  (Use a Context flag rather than a
flag on the interval itself.)  Moved the getFlag method from
Formula.pm to Value.pm so it can be used by any object class.  New
feature where classes can add more context flags to set (and reset
after the answer checker runs).

Revision 3484 - Directory Listing
Modified Fri Aug 12 01:26:11 2005 UTC (12 years, 11 months ago) by dpvc
Removed erroneous dollar sign.

Revision 3483 - Directory Listing
Modified Fri Aug 12 01:21:48 2005 UTC (12 years, 11 months ago) by dpvc
Added redefine() function to complement undefine() for various
Context() values.  For example

      Context()->operators->undefine('+');

makes '+' undefined, but

      Context()->operators->redefine('+');

will put it back.  You can specify a context from which to take the
redefinition, and a name in that context, as in

      Context()->operators->redefine('U',from=>"Interval");
      Context()->operators->redefine('u',from=>"Interval",using=>"U");
      Context()->operators->redefine('U',from=>$content);

where $content is a reference to a Context object.

The undefine() function lets you undefine several items at once, as in

      Context()->operators->undefine('+','-');

For redefine, you must put multiple names in square brackets because
of the optional parmeters:

      Context()->operators->redefine(['+','-']);

Revision 3477 - Directory Listing
Modified Thu Aug 11 20:57:18 2005 UTC (12 years, 11 months ago) by dpvc
Added ability to subtract intervals, sets and unions.  Adjusted the
precedence of the union 'U' to be above _ and + so that things like
(1,5) U (7,10) - {8} U (2,3) will do ((1,5) U (7,10)) - ({8} U (2,3))
rather than the previous (1,5) U ((7,10) - {8}) U (2,3).  Finally,
added a constant 'R' to the Interval context that is equivalent to
(-inf,inf), so you can do things like R-{0} now.

Still need to work out reducing unions so that things like (1,3)U(2,4)
can become (1,4).

Revision 3472 - Directory Listing
Modified Thu Aug 11 14:33:09 2005 UTC (12 years, 11 months ago) by dpvc
Changes needed to Set object.  Also, use Parser to handle unions
defined as strings rather than doing it by hand (that's the whole
point, isn't it?).  Added object promotion from lower-precedence
classes (for better error messages), and fixed up the comparison
routine.

Revision 3471 - Directory Listing
Modified Thu Aug 11 14:28:07 2005 UTC (12 years, 11 months ago) by dpvc
Changes needed for Set object, better handling of an interval given as
a string, and a few misc. fixes.

Revision 3470 - Directory Listing
Modified Thu Aug 11 14:25:53 2005 UTC (12 years, 11 months ago) by dpvc
Changes needed for new Set object, and moving of string, TeX and perl
methods to Value.pm

Revision 3469 - Directory Listing
Modified Thu Aug 11 14:23:16 2005 UTC (12 years, 11 months ago) by dpvc
Added changes needed for the new Set object.

Revision 3466 - Directory Listing
Modified Thu Aug 11 14:19:26 2005 UTC (12 years, 11 months ago) by dpvc
Added new Set object class to the Parser.  It implements a finite set
of real numbers, for use with unions and intervals.  E.g., (1,2) U {3}
or (1,2) U {3,4,5}.  You can created Set objects in your perl code via
the Set() command, e.g, Set(3,4,5) or Set("{1,2,3}").  You should set
the Context to Context("Interval") if you plan to use Set objects, as
this defined the braces to form sets (rather than using them as
parentheses, which is the default WW behavior).  Note that in Interval
context, you can NOT use braces as parentheses.

Current, Set objects are only allowed to be sets of numbers.  It would
be possible to extend that in the future.

Revision 3460 - Directory Listing
Modified Wed Aug 10 15:07:12 2005 UTC (12 years, 11 months ago) by dpvc
Interval (and Union) checker now accepts requireParenMatch flag for
deciding whether the interval type must match.  Setting
requireParenMatch to 0 will let (1,2) match (1,2] or [1,2], etc.

Revision 3444 - Directory Listing
Modified Mon Aug 1 13:10:52 2005 UTC (12 years, 11 months ago) by dpvc
Make List("1,2,3") work like List("1","2","3") rather than produce a
list with one element that is a list.

Revision 3442 - Directory Listing
Modified Mon Aug 1 12:37:35 2005 UTC (12 years, 11 months ago) by dpvc
Fixed typo that caused hilighting of the position of errors to be lost.

Revision 3384 - Directory Listing
Modified Sat Jul 16 19:24:31 2005 UTC (13 years ago) by jj
Fixed typo related to useBaseTenLog.

Revision 3370 - Directory Listing
Modified Tue Jul 12 22:29:53 2005 UTC (13 years ago) by dpvc
A first pass at making parser error messages localizable.  The
Context()->{error}{msg} hash can be used to specify translations of
the standard messages.  For example,

    Context()->{error}{msg}{'Division by zero'} = "Don't divide by zero, dude!";
    Context()->{error}{msg}{'Function '%s' has too many inputs'} =
        "You passed too many arguments to '%s'";

(I didn't translate into another language, here, but you could do
that, too.)

The msg hash could also be used within answer checkers to make certain
answer messages more appropriate for the given type of expected answer.

Revision 3369 - Directory Listing
Modified Tue Jul 12 21:05:37 2005 UTC (13 years ago) by dpvc
Fixed various perl compiler warnings (due to extra "my", and so on).

Revision 3342 - Directory Listing
Modified Mon Jul 4 15:53:26 2005 UTC (13 years ago) by dpvc
Better messages when adaptive parameters are too big.

Revision 3341 - Directory Listing
Modified Mon Jul 4 15:43:53 2005 UTC (13 years ago) by dpvc
Implement "remove trailing zeros" format, like in prfmt().  I still
think '%g' works better in most cases ('%f#' will print larger values
without using scientific notation, which is nice, but will print small
numbers like .000000005 as 0, even though the fuzzy comparison of this
to zero will not be true.)

Revision 3339 - Directory Listing
Modified Mon Jul 4 15:22:22 2005 UTC (13 years ago) by dpvc
Don't use the overloaded Real class for doing adaptive parameter
checks (use non-fuzzy checks, since we are checking the fuzziness by hand).

Revision 3336 - Directory Listing
Modified Mon Jul 4 13:15:57 2005 UTC (13 years ago) by dpvc
Change so as not to use raw HTML in the error messages.

Revision 3334 - Directory Listing
Modified Sun Jul 3 20:10:37 2005 UTC (13 years ago) by dpvc
Updates to allow string matches to be case-insensitive.  This is now
the default, and can be overridden in the Context by setting the
string's "caseSensitive" attribute.  e.g.:

	 Context()->strings->add("FooBar"=>{caseSensitive=>1});

would rewuire "FooBar" to be entered exactly as typed.

Revision 3333 - Directory Listing
Modified Sun Jul 3 20:06:33 2005 UTC (13 years ago) by dpvc
Adjusted some spacing

Revision 3298 - Directory Listing
Modified Thu Jun 16 15:32:02 2005 UTC (13 years, 1 month ago) by dpvc
New flag showAllErrors for when a custom checker is supplied.  This
will cause all errors generated in the user's code to be reported
(normally, messages from the Value and Parser packages are ignored).

Revision 3296 - Directory Listing
Modified Thu Jun 16 04:03:40 2005 UTC (13 years, 1 month ago) by dpvc
Fixed a problem with auto-generated functions getting an incomplete
variable list.

Revision 3273 - Directory Listing
Modified Mon Jun 6 02:32:20 2005 UTC (13 years, 1 month ago) by dpvc
Forgot to check hardcopy mode.  Fixed some problems with that.  The
answer array items have to turn off verbatim mode that is used when
answer are included in the hardcopy.  This causes paragraph breaks
between entries in a singleResult MultiPart that includes ans_arrays,
which make the output less pretty, but at least they show up.

Revision 3269 - Directory Listing
Modified Sun Jun 5 23:52:11 2005 UTC (13 years, 1 month ago) by dpvc
Added ability to have Matrix, Vector and Point objects produce input
arrays similar to the ones available in PGmatrixmacros.pg.  This
provides some substantial new functionality, and it may still have
some shaking down to do, but it should not affect the existing
functionality of the answer checkers.

To create an answer array for a matrix, vector or point, use the new
ans_array() or named_ans_array() methods of these objects.  For
example:

	Context("Matrix");
	$M = Matrix([1,2],[3,4]);

	BEGIN_TEXT
	\{$M->TeX\} = \{$M->ans_array\}
	END_TEXT

	ANS($M->cmp);

This creates a matrix, then prints it ans creates an answer array of
the appropriate size for the matrix.  The answer checker will
automatically know to handle the multiple entry blanks.

To used a named answer rule, use:

	Context("Matrix");
	$M = Matrix([1,2],[3,4]);

	BEGIN_TEXT
	\{$M->TeX\} = \{$M->named_ans_array('fred')\}
	END_TEXT

	NAMED_ANS(fred => $M->cmp);

Both methods also take an optional argument that specifies the width
of the answer rules.  The default is 5.

You can get a multi-input point or vector array as well, and you can
make column vectors as follows:

        Context("Vector");
	$V = ColumnVector("1+x","3x","1-x");

	BEGIN_TEXT
	\{$V->TeX\} = \{$V->ans_array\}
	END_TEXT

	ANS($V->cmp);

Note that you can make answer arrays for matrices and vectors of
formulas as well as constants, provided the formula is an explicit
matrix or vector of formulas, and is not obtained by matrix
arithmatic.

For concistencey, all objets now have ans_rule and named_ans_rule
methods as well.  The default width is 20 for these.

Revision 3266 - Directory Listing
Modified Sun Jun 5 23:24:29 2005 UTC (13 years, 1 month ago) by dpvc
Better handling of delimiters that are explicitly set byt he user.
Fixed an incorrect call during object class promotion.
Added ability to sepcify that a vector is a Column Vector.

Revision 3265 - Directory Listing
Modified Sun Jun 5 23:22:20 2005 UTC (13 years, 1 month ago) by dpvc
Better handling of open and close delimiters that are explicitly set.

Revision 3264 - Directory Listing
Modified Sun Jun 5 23:18:01 2005 UTC (13 years, 1 month ago) by dpvc
Fix some incorrect calls when the promoting types to higher precedence
object types.

Revision 3261 - Directory Listing
Modified Sat Jun 4 13:50:41 2005 UTC (13 years, 1 month ago) by dpvc
Avoid possible infinite loop with length and typeref calls.

Revision 3260 - Directory Listing
Modified Sat Jun 4 13:50:01 2005 UTC (13 years, 1 month ago) by dpvc
Remove unneeded comment.

Revision 3258 - Directory Listing
Modified Fri Jun 3 19:14:00 2005 UTC (13 years, 1 month ago) by dpvc
Better control over number of points that can be undefined, and
new ability to specify required test points plus additional random
ones.  (Previously, if you set the test points, no random points were
generated.)  For example:

     $f = Formula("(x^2-1)/(x-1)");
     $f->{test_at} = [[1]];  # test at x=1 plus random points

as opposed to

     $f->{test_points} = [[-1],[0],[1]];

which tests only the points x = -1, x = 0 and x = 1.

Revision 3257 - Directory Listing
Modified Thu Jun 2 22:50:24 2005 UTC (13 years, 1 month ago) by dpvc
Modified the Formula answer checker to allow checking of points where
the functions are undefined (i.e., attempt to check that the domains
agree).  This can be enabled by setting the checkundefinedPoints flag
in the Context(), or in the formula itself.  Test points where the
function is undefined will be retained and the student's answer will
have to be undefined at the same points.  If the points are selected
at random, the points where the function is undefined are kept in
addition to the ones where it is defined, so the required number of
test points where the function IS defined will still need to be
found.  The number of undefined points can be up to the number of
defined points.  This number can be reduced by setting the
max_undefined flag.  If you want to guarantee that a specific
undefined point be tested, you can provide that point using the
test_points field of the formula.  For example:

     Context()->flags->set(checkUndefinedPoints=>1);
     $f = Formula("(x^2-1)/(x-1)");
     $f->{test_points} = [[-1],[0],[1],[2]];
     ANS($f->cmp);

will guarantee that the singularity at x=1 is tested, so the answer
x+1 will not be marked as correct.

If an answer matches at all the test points where the functions are
both defined, but some of the undefind points differ between the two
functions, the answer checker will generate an error message
indicating that the domains of the functions don't agree.  (This is
ONLY generated with the functions match except for that.)  This can be
controlled by setting the showDomainErrors flag in the formula's cmp()
call:

     ANS($f->cmp(showDomainErrors=>0));

The default is to show these errors.

Revision 3256 - Directory Listing
Modified Thu Jun 2 19:53:06 2005 UTC (13 years, 1 month ago) by dpvc
Fixed an accidental hard-coded operation from always being "add" to
being the correct operation when promoting the operations to an object
of higher precedence.  (But since formulas are normally the highest
precedence, this will never have occurred.)

Revision 3218 - Directory Listing
Modified Fri Apr 29 02:37:13 2005 UTC (13 years, 2 months ago) by dpvc
Fixed a bug with adaptive parameters where the relative tolerance
was not being properly computed.  This allowed large constants to be
treated as correct when they shouldn't be.

Revision 3217 - Directory Listing
Modified Wed Apr 27 21:30:13 2005 UTC (13 years, 2 months ago) by dpvc
Copy parameters like limits, etc, to the newly created formula when
'C0' is added by the "upToConstant=>1" option in formula cmp().

Revision 3216 - Directory Listing
Modified Wed Apr 27 21:29:10 2005 UTC (13 years, 2 months ago) by dpvc
Use correct form of "x" with lists (rather than hack using split()).

Revision 3207 - Directory Listing
Modified Tue Mar 29 13:14:17 2005 UTC (13 years, 3 months ago) by dpvc
Handle error messages in the list checker better.  In particular, make
the error messages generated by custom checkers called on elements in
the list look better.  Also, in an ordered list, if the student enters
extra values, call an answer checker to do a syntax check.  (By
default, use the first element again, but the user can supply a
separate object to use for the checker using the extra=>object
option.)

Revision 3206 - Directory Listing
Modified Tue Mar 29 03:25:29 2005 UTC (13 years, 3 months ago) by dpvc
Compartmentalize the equality check one step further.  The cmp_equal
method now calls a new cmp_compare method to perform the actual
comparison (rather than use == directly).  The cmp_compare method
either calls a user-supplied checker routine, or defaults to using the
== operator.  The list checker also uses cmp_compare to check the
individual items in the list.  The list checker also calls a new
cmp_list_checker method to perform the list check.  This can be
overridden by a user-supplied list-checking routine.

To supply an alternate checking routine, use the "checker" option to
the cmp() method of the correct answer object.  For example:

    sub check {
      my ($correct,$student,$ans) = @_;
      return 0 unless $correct->length == $student->length;
      my ($x,$y) = $student->value;  # break up a point;
      return $x**2 - $y**2 = 1;      # check if it is on a hyperbola
    }
    Point(1,0)->cmp(checker=>~~&check);

This will check if the student's point lies on the given hyperbola.  All
the usual error messages will be issued if the student's answer is not
a point, or is of the wrong dimension, etc.

You can use

    sub list_check {
      my ($correct,$student,$ans) = @_;
      my @correct = @{$correct}; my @student = @{$student};
      ...
      return ($score,@errors);
    }
    List(...)->cmp(list_checker=>~~&list_check);

to replace the list-checking routine with your own custom one.  The
$correct and $student values are array references to the elements in
the lists provided by the professor and student.  (Note that you do
NOT get a List() object; this allows you to handle lists of formulas,
since a List of formulas becomes a formula returning a list).  The
checker routine should return the number of correct elements in the
student's list ($score), and a list of error messages produced while
checking the two lists (@errors).  (This is a list of messages, since
you might want to include an error for each entry in the list, for
example).

If your checker or list_checker routine wants to die with an error
message, use Value::Error(message).  This will put the message in the
WeBWorK display area at the top of the page.  If you use die(message),
or if the code fails due to a runtime error, then "pink screen of
death" will be produced indicating the error and asking the student to
report the error to the professor.

Revision 3205 - Directory Listing
Modified Tue Mar 29 02:55:10 2005 UTC (13 years, 3 months ago) by dpvc
Properly handle string values in postprocessing of vectors and other
related lists.  (It used to report a dimension error for things like 'NONE').

Revision 3192 - Directory Listing
Modified Wed Mar 16 13:30:28 2005 UTC (13 years, 4 months ago) by dpvc
Update the overloaded operators so that they can be overridden by
subclasses of the predefined object classes.  This involves calling
the objects method rather than using a hard reference to the routine
in the parent class.

Also, change the name of the string comparison routine to
compare_string to avoid conflicts with cmp that is used to produce the
answer checker for the class.

Finally, in Value.pm, promotePrecedence no longer has to do fancy
footwork to get "special" precedence to work (this was a hack to get
around the misfeature of the overloaded operators -- now that that is
being handled correctly, there is no need for it).

Revision 3177 - Directory Listing
Modified Fri Feb 18 00:04:09 2005 UTC (13 years, 5 months ago) by dpvc
Missed one situation when making the previous update.  Fixed it.

Revision 3174 - Directory Listing
Modified Thu Feb 17 16:12:45 2005 UTC (13 years, 5 months ago) by dpvc
Fixed it so that direct calls to the add, sub, mult, etc functions
would work as expected (even though there is no need to call them directly).

Revision 3172 - Directory Listing
Modified Tue Feb 15 21:58:54 2005 UTC (13 years, 5 months ago) by dpvc
Updated the answer checkers so that you can more easily specify how
the correct answer shoudl be displayed.  In the past, you could use
something like Real(sqrt(2))->cmp(correct_ans=>"sqrt(2)") to do this,
but that is awkward.  Now the Compute() function (which parses and
then evaluates a string) sets things up so that the original string
will be what is used as the correct answer.  That means
Compute("sqrt(2)")->cmp will have the same result as the example
above.

You can also set the {correct_ans} properly of any Parser object to
have that value used as the correct answer.  For example

     $x = Real(sqrt(2));
     $x->{correct_ans} = "sqrt(2)";
     ANS($x->cmp)

would also produce the same answer checker as the two previous
examples.  All three methods should work.  Use the one that is most
convenient for you.

Revision 3171 - Directory Listing
Modified Tue Feb 15 21:53:23 2005 UTC (13 years, 5 months ago) by dpvc
Improved the Real(), Complex(), Point(), Vector(), Matrix() and
String() constructors so that they will process formulas passed to
them as strings rather than requiring perl objects for these.

For example, you can use Real("2/3") rather than Real(2/3) if you
want.  Also, Real("1+x") will return a formula returning a real
(essentially the same as Formula("1+x") in this case).

Revision 3166 - Directory Listing
Modified Tue Feb 15 02:20:52 2005 UTC (13 years, 5 months ago) by dpvc
Fixed an error with Matrix() that could cause it to loop infinitely
when bad data is passed to it.

Also, allow Matrix(), Point(), Vector(), and Real() to accept string
values that are evaluated to produce the value returned.

(Sorry, accidentally committed with a blank message.)

Revision 3165 - Directory Listing
Modified Tue Feb 15 02:16:10 2005 UTC (13 years, 5 months ago) by dpvc
*** empty log message ***

Revision 3074 - Directory Listing
Modified Tue Jan 4 17:56:33 2005 UTC (13 years, 6 months ago) by dpvc
Fixed index problem with matrix multiplciation.  (It was returning the
transpose!)

Revision 2937 - Directory Listing
Modified Tue Oct 19 00:23:01 2004 UTC (13 years, 9 months ago) by dpvc
Added "areParallel" method as a synonym for "isParallel".

Revision 2916 - Directory Listing
Modified Wed Oct 13 18:41:07 2004 UTC (13 years, 9 months ago) by dpvc
Clear error messages before doing the answer check (this clears old
messages left over inclass this checker is called by another one,
e.g. when using UNORDERD_ANS()).

Revision 2914 - Directory Listing
Modified Wed Oct 13 02:41:33 2004 UTC (13 years, 9 months ago) by dpvc
Added support for useBaseTenLogs to make log() work like ln() or
log10() depending on the value in the course.conf file.

Also fixed a bug that caused the WeBWorK parameters not to be
copied into contexts by initCopy().

Revision 2908 - Directory Listing
Modified Tue Oct 12 20:46:43 2004 UTC (13 years, 9 months ago) by dpvc
Report errors for powers of negative numbers rather than return 'nan'.
Don't allow 'nan' to be made into a Real object.

Revision 2900 - Directory Listing
Modified Tue Oct 12 00:52:47 2004 UTC (13 years, 9 months ago) by dpvc
Don't give coordinate hints during parallel vector checks.  Also fixed
a typo.

Revision 2800 - Directory Listing
Modified Sun Sep 19 14:27:39 2004 UTC (13 years, 10 months ago) by dpvc
Added isZero and isOne checks for Parser::Value objects (i.e., for
constants within formulas).  These now correctly handle vector and
matrices, in particular.  The isOne and isZero checks are used in the
reduce() method to simplify formulas.

Revision 2799 - Directory Listing
Modified Sun Sep 19 11:49:32 2004 UTC (13 years, 10 months ago) by dpvc
Added a new flag to the Formula()->cmp answer checker that allows a
constant-valued formula to be evaluated and then use the checker for
the resulting type.  This is useful when you want the correct answer
for a numeric check to be shown in a symbolic form (like "pi/4")
rather than as a decimal number.  To do this, use

       Formula("pi/4")->cmp(eval=>1);

rather than Real(pi/4)->cmp, which would show the correct answer as
0.785398.  Note that Formula("pi/4")->cmp would also match against
pi/4, but it does it as a function rather than a number, so error
messages might be issued indicating that the checker is expecting a
formula that returns a number, rather than just a number; this might
be confusing to a student.  It would also accept answers like
"pi/4-x+x" as correct, whereas with eval=>1 this would produce an
error message saying that the answer was supposed to be a number not a
formula returning a number.

Similarly, if you want to show sqrt(2)/2 as the correct answer, use

     Context()->flags->set(reduceConstants=>0, reduceConstantFunctions=>0);
     Formula("sqrt(2)/2")->cmp(eval=>1);

The first line tells the parser not to automatically reduce
expressions that only involve constants, so that the value of the
formula in the second line will not be reduced to a decimal before
the cmp method is called.

Revision 2791 - Directory Listing
Modified Thu Sep 16 23:43:54 2004 UTC (13 years, 10 months ago) by dpvc
Don't reduce constants in the display of student answers (so they can
tell how the parser interprets their answer).  The drawback is that
the final number is not displayed.  (We may need to add more columns
to the results display.)

Revision 2790 - Directory Listing
Modified Thu Sep 16 23:03:03 2004 UTC (13 years, 10 months ago) by dpvc
Use extra parens in the string version of the student's answer, but
not in the professor's (unless the problem sets the showExtraParens
flag).

Revision 2772 - Directory Listing
Modified Sun Sep 12 11:11:47 2004 UTC (13 years, 10 months ago) by dpvc
Make partial credit in list answer checkers be the default (now that
WeBWorK can handle this).

Revision 2771 - Directory Listing
Modified Sat Sep 11 17:11:29 2004 UTC (13 years, 10 months ago) by dpvc
Fixed a bug with constants where the values were being cached so that
changes in the context were not being reflected in the formulas that
use them.

Revision 2757 - Directory Listing
Modified Fri Sep 10 14:50:14 2004 UTC (13 years, 10 months ago) by dpvc
No longer produces the message that there are too many answers if
hints are being shown about individual entries in a list.  (This gave
away the answer about which ones to remove.)

Revision 2692 - Directory Listing
Modified Fri Aug 27 21:49:36 2004 UTC (13 years, 10 months ago) by dpvc
Use the current context if the answer doesn't have one itself (like
with Value objects).

Revision 2688 - Directory Listing
Modified Fri Aug 27 19:42:59 2004 UTC (13 years, 10 months ago) by dpvc
Added in functMaxConstantOfIntegration support in the adaptive
parameter answer checking.  Also added a flag to the formula answer
checker that allows checking a formula up to a constant (for
integration problems).  This really just adds a new parameter to the
context and adds that to the formula, so there is nothing deep about
this.

	ANS(Formula("2x")->cmp(upToConstant=>1));

Finally, don't look for adaptive parameters if they aren't actually
used in the professor's formula (even if they are defined).

Revision 2687 - Directory Listing
Modified Fri Aug 27 00:28:27 2004 UTC (13 years, 10 months ago) by dpvc
Added ability to have linear adaptive parameters in the function
answer checker.  It only works for real-valued functions, though.
To use a parameter, use

       Context()->variables->add(a=>'Parameter');

and then use 'a' as a variable within your answer.  The student will
not be allowed to enter the parameter, but the professor will.

Note that the correct answer will show the full professor's answer,
including the parameters, even though the student can't type it.  Is
this the right behaviour?

Revision 2678 - Directory Listing
Modified Mon Aug 23 23:55:37 2004 UTC (13 years, 11 months ago) by dpvc
Modified the parser so that the classes for the various object
constructors are stored in the context table rather than hard-coded
into the parser.  That way, you can override the default classes with
your own.  This gives you even more complete control to modify the
parser.  (You had been able to replace the definitions of operators,
functions and list-like objects, but could not override the behaviour
of numbers, strings, variables, and so on.  Now you can.)

This effects most of the files, but only by changing the name of the
calls that create the various objects.

There are also a couple of other minor fixes.

Revision 2674 - Directory Listing
Modified Mon Aug 23 04:58:00 2004 UTC (13 years, 11 months ago) by dpvc
Remove more lines in error messages produced while evaluation student
answers.

Revision 2673 - Directory Listing
Modified Mon Aug 23 01:21:27 2004 UTC (13 years, 11 months ago) by dpvc
Moved WW-specific routines from Parser.pm to WeBWorK.pm.
Changed error reporting when the error message was not generated by
the parser directly.  (The stack trace and line number references are
removed before the error is reported.)

Revision 2671 - Directory Listing
Modified Sun Aug 22 21:18:06 2004 UTC (13 years, 11 months ago) by dpvc
Fixed some inconsistencies between handing of matrices within the
parser and Value packages.  Added a predefined Matrix context.

Revision 2669 - Directory Listing
Modified Sun Aug 22 15:42:50 2004 UTC (13 years, 11 months ago) by dpvc
Made the granularity of the test-point intervals be a parameter that
can be set on a global or variable-by-variable basis, so this is now
controlable from the .pg file.  For example:

            Context("Numeric")->variables->are(
              k=>{limits=>[1,10], resolution=>1},
              x=>{limits=>[-2,2], granularity=>1000},
            );

will make k be a variable that will only take on integer values
between 1 and 10, and x a variable that will take on one of 1000
different values evenly spaced between -2 and 2 (so resolution is
4/1000 in this case).

These parameters can also be set for an individual formula:

           $f = Formula("k^2-1");
           $f->{resolution} = 1;
           $f->{limits} = [0,10];

Revision 2668 - Directory Listing
Modified Sun Aug 22 02:55:38 2004 UTC (13 years, 11 months ago) by dpvc
Fixed TeX output of Matrices to use \array rather than \matrix for
matrices with formulas as entries (this had already been fixed for
constant matrices).  Made intervals produce formulas when of of the
endpoints is a formula.  Removed unneeded comment.

Revision 2667 - Directory Listing
Modified Sun Aug 22 02:51:53 2004 UTC (13 years, 11 months ago) by dpvc
Added support for dimension warnings in the answer checker for
formulas that return points, vectors or matrices.

Revision 2666 - Directory Listing
Modified Sun Aug 22 00:56:32 2004 UTC (13 years, 11 months ago) by dpvc
Formulas can now be compared even if their variables are complex
numbers, or even points or vectors!  This makes it possible to ask
students for complex functions like z^2+i and so on.

You can specify limits for variables either via
Context()->variables->set(x=>{limits=>[0,1]})  (for reals) or
Context()->variables->set(z=>{limits=>[[-2,2],[0,1]]}) (for complexes).
Similarly for points and vectors (where the number of sub arrays
depends on the dimension).  You can also give the limits for a
specific formula by assigning to its ->{limits} field:

    $f = Formula("sqrt(x-10)");
    $f->{limits} = [10,12];

There are now named variable types for 'Point2D', 'Point3D',
'Vector2D' and 'Vector3D', in addition to 'Real' and 'Complex'.
You can also specify a variable type by giving an explicit instance of
a value of the given type.  E.g.

    Context()->variables->add(x=>'Real',y=>0);     # two real variables
    Context()->variables->add(z=>'Complex',w=>i);  # two complexes
    Context()->variables->add(r=>Vector(0,0,0));   # a vector in R^3
    Context()->variables->add(X=>'Vector3D');      # a vector in R^3

There still needs to be more error checking in processing
user-supplied limits, but I'm not sure how much overhead is worth it.

Revision 2664 - Directory Listing
Modified Sat Aug 21 22:02:14 2004 UTC (13 years, 11 months ago) by dpvc
Added a file to perform WeBWorK-specific modifications to the
Parser/Value packages.  (I've tried to make these independent of
WeBWorK, so you can use them in other perl code if you want to.)

The parameters for fuzzy reals and some of the other parameters now
are taken from the pg->{ansEvalDefaults} values (as defined in
global.conf or course.conf).  More still needs to be done with this,
however.

Revision 2661 - Directory Listing
Modified Fri Aug 20 15:56:56 2004 UTC (13 years, 11 months ago) by dpvc
A number of fixes to make handing lists work better.  In particular,
you can now specify checks for whether the right kinds of parentheses
(or none at all) are used on the student's answer.  Some of the flags
for the list checker have been changed to accommodate this.

Revision 2660 - Directory Listing
Modified Fri Aug 20 15:52:32 2004 UTC (13 years, 11 months ago) by dpvc
A number of adjustments to get negative infinities to work better.
They used to be stored as separate Parser strings, but now they are
flagged versions of a single string.

All of the problems are really due to the fact that there is no
Infinity class in the Parser (only a Value version).  That should be
changed, but will require some work, and can be put off for now.

It would be best if the classes within the two packages would match up
nearly 1-to-1, but for historical reasons, they don't.  Since the
introduction of Real, String and Infinity classes to the Value
package, The Infinity class is the one main difference between the
two, and once that is fixed, everything needs to be looked over to
check for unnecessary complications due to the historical lack of classes
in one or the other package.

Revision 2658 - Directory Listing
Modified Fri Aug 20 11:17:06 2004 UTC (13 years, 11 months ago) by dpvc
Make blank patterns be ^$ (which should never match) rather than empty
(which always matches).  this fixes a problem where if a context has
no functions, for example, the parser would attempt to create function
calls to a function named ''.

Revision 2656 - Directory Listing
Modified Fri Aug 20 02:13:38 2004 UTC (13 years, 11 months ago) by dpvc
We need to protect the HTML in the professor's answer so that if it
contains <, for example, it won't disappear.

Revision 2649 - Directory Listing
Modified Thu Aug 19 14:19:32 2004 UTC (13 years, 11 months ago) by dpvc
Fixed an error in the generation of regexp patterns for the various
data types.

Revision 2648 - Directory Listing
Modified Thu Aug 19 12:38:47 2004 UTC (13 years, 11 months ago) by dpvc
The answer checkers now work with subclasses of Formulas that are not
part of the Value:: package tree itself (we call Value::isFormula()
rather than checking the class directly).

I also removed the various cmp_* flags that stored method names as
they ended up not needing to be used (they were intended as a means of
overriding the default method names, but subclassing turned out to be
a better approach).

I moved some initialization of the answer checker out of the anonymous
subroutine that is installed in the checker and just have that
subroutine call the correct answer's main checker (which I renamed).

Finally, I changed the student_ans value to be an HTMLized version of
the student answer, since the student could include things like < in
his answer (e.g., for vectors), in which case his whole answer might
disappear.  I wonder if this couldn't be handled better at a higher
level, as it seems wrong to make the student_ans be HTML rather than
the parsed string.  I originally thought Problem.pm could do the
protecting of HTML special characters, but this won't work without
additional changes, since some answer checkers put HTML into
student_ans to mark sytanx errors in the student answer, and you DON'T
want to protect those HTML characters.  The student_ans field is
probably being misused in this, and there might want to be another
field that gets used by Problem.pm in place of student_ans (which can
be HTML protected) when it is non-empty; say student_HTML or something
like that.  The answer checkers could use that field if it wants to
add HTML to the student answer, and student_ans otherwise, with the
assurance that it's HTML characters will be protected.  That way, if a
second answer checker calls the first (like some list checkers do),
then the second checker doesn't have to worry about removing HTML from
the student ans, and doesn't ahve to wonder whether the student_ans
actually contains an error message or syntax markings rather than the
actual student answer.

Revision 2634 - Directory Listing
Modified Tue Aug 17 15:21:58 2004 UTC (13 years, 11 months ago) by dpvc
Changed the string used for the student answer to be taken from the
unevaluated formula rather than the fully-evaluated one.  This leaves
constants unreplaced, for one thing.

Currently the parser combines constants automatically during the parse
[which should be controllable by a flag], so student answers that
produce numbers are fully evaluated at this point already, except for
constant substitution.  This could be changed so that even for
numberic results, the student sees the parsed expression (rather than
the numeric result), which might help them identify where they and the
parser differ in their interpretation.  It is still nice to see the
final computed result, however, but there is no place to show the
parsed input as well as the final result.  One solution would be to
add another column (wasting space).  Another would be to make the
value shown be "parsed-value = computed-value" when they are not the
same thing.  A bit ugly, but works within the current framework.

Revision 2632 - Directory Listing
Modified Tue Aug 17 12:05:18 2004 UTC (13 years, 11 months ago) by dpvc
Fixed typo in name of random generator.

Revision 2629 - Directory Listing
Modified Tue Aug 17 02:01:27 2004 UTC (13 years, 11 months ago) by dpvc
Fixed a number of minor problems with creating perl functions from
formulas (this is done automatically as part of the function answer
checker, so is showing up now that I have that checker in place).

Also improved error messages in the function answer checker, and fixed
a bug when students enter a constant list or union when the answer
checker expects formulas.

Revision 2627 - Directory Listing
Modified Mon Aug 16 20:22:16 2004 UTC (13 years, 11 months ago) by dpvc
Removed unwanted side-effects of some type-match checks, and moved the
ignoreStrings flag so that it is available for the checkers of ANY type.

Revision 2626 - Directory Listing
Modified Mon Aug 16 19:44:26 2004 UTC (13 years, 11 months ago) by dpvc
One more fix for handling intervals properly (I think it's really
right this time).  Also, named constants that end in numbers will
produce TeX output with the number as a subscript (this was already
true for variable names).

Revision 2625 - Directory Listing
Modified Mon Aug 16 18:35:12 2004 UTC (13 years, 11 months ago) by dpvc
Added string comparison to all Value object classes (to compare the
string value of an object to another string).

Overloaded perl '.' operator to do dot product when the operands are
formulas returning vectors.  (Part of the auto-generation of
formulas).

A few improvements to real and complex class output results.

Made Union class slightly more robust and removed need for makeUnion
method other than in the Union itself.

Revision 2624 - Directory Listing
Modified Mon Aug 16 13:44:45 2004 UTC (13 years, 11 months ago) by dpvc
Added support for unorderd list or formulas with partial credit.
Fixed type mismatch reporting in formula answer checker.
Fixed an error with Unions producing incorrect perl versions under
some circumstances.

Revision 2622 - Directory Listing
Modified Sun Aug 15 22:46:57 2004 UTC (13 years, 11 months ago) by dpvc
Created the first draft of the Parser's function answer checker.  Some
work still needs to be done, in particular, type mismatches are not
being reported, and lists are being processed only as ordered lists
with no partial credit.

This doesn't implement everything from fun_cmp.  In particular, there
is no support for parameter matching at the moment.  This will have to
be added, but I'm not quite sure how to do it when the function's
return value is not a real number (e.g., an interval).

On the other hand, this checker is more forgiving about domain errors:
if tries a point where the professor's function is not defined, it
ignores that one and looks for another (until it decides it can't find
one).  Once it has these points, it tries them on the student's
answer, and if the student's function is undefined, then the student
answer is wrong (since it is not defined somewhere that the
professor's funciton is).  This avoids the "Error evaluating student
function at ..." messages, which just confused most students anyway.

Revision 2621 - Directory Listing
Modified Sun Aug 15 17:05:41 2004 UTC (13 years, 11 months ago) by dpvc
Improved error messages, particularly when the student enters a
formula in an answer that should be constant, and also for incorrect
answers in lists of answers.  There are a few other miscellaneous output
improvements as well.

Revision 2617 - Directory Listing
Modified Sun Aug 15 00:13:38 2004 UTC (13 years, 11 months ago) by dpvc
The Union answer checker now uses the generic List checker, so that it
will be able to produce partial credit and hints about which Intervals
are correct.

Revision 2615 - Directory Listing
Modified Sat Aug 14 21:27:45 2004 UTC (13 years, 11 months ago) by dpvc
*** empty log message ***

Revision 2612 - Directory Listing
Modified Sat Aug 14 19:29:42 2004 UTC (13 years, 11 months ago) by dpvc
Fixed some bugs in the handle of the context in ->string and ->TeX
methods of Value objects.

Revision 2611 - Directory Listing
Modified Sat Aug 14 15:59:35 2004 UTC (13 years, 11 months ago) by dpvc
Fixed a typo in one of the parser answer checkers.  Added a line that
was incorrecctly removed in the parser.

Revision 2610 - Directory Listing
Modified Sat Aug 14 13:55:54 2004 UTC (13 years, 11 months ago) by dpvc
The class file for the Value::String object.  (Forgot to add it before
the last commit.  Sorry!)

Revision 2609 - Directory Listing
Modified Sat Aug 14 13:54:52 2004 UTC (13 years, 11 months ago) by dpvc
Added a String type to the Value package.  Mostly this is to make it
possible to generate an answer checker for it that uses the parser.
It also makes it more consistent for handling things like stringify,
especially when they are recursively called internally.

Added new default strings "NONE" and "DNE", since these get used a
lot.

Modified how the default parameters are set up for the answer
checkers, and how the answer checker reports the expected answer type
in type mismatch error messages.

Revision 2606 - Directory Listing
Modified Sat Aug 14 11:25:47 2004 UTC (13 years, 11 months ago) by dpvc
Can now specify that the objects stringify themselfs in their TeX
forms rather than their answer-string forms.  This makes it easier to
use the objects in the text of a problem (without having to call ->TeX
explicitly each reference).

Use

       Context()->texStrings

to start outputting TeX strings, and

      Context()->normalStrings

to switch back.

Revision 2605 - Directory Listing
Modified Sat Aug 14 02:50:18 2004 UTC (13 years, 11 months ago) by dpvc
Incorporated infinities into Parser package better.  They have been
stored as String objects (with extra data) in the parser, and I've
left it that way, but now they convert to/from Vallue::Infinity
objects correctly, and these are used for generating the output.

Also added the Infinity answer checker, and adjusted the error
messages produces by type mismatches in the answer checkers and
elsewhere.

Revision 2604 - Directory Listing
Modified Fri Aug 13 23:49:16 2004 UTC (13 years, 11 months ago) by dpvc
Fixed some output issues with intervals and unions.

Revision 2603 - Directory Listing
Modified Fri Aug 13 23:01:07 2004 UTC (13 years, 11 months ago) by dpvc
Added an Infinite object class for the Value package.  Still need to
add it to the Parser package.

Revision 2601 - Directory Listing
Modified Fri Aug 13 19:06:09 2004 UTC (13 years, 11 months ago) by dpvc
Added ability to report incorrect coordinates in point and vector
answers, and incorrect endpoints and endpoint types in intervals.
Separated these kinds of checks from the typeMatch check, where they
didn't really belong.

Added ability to specify intervals and unions as strings in Interval()
and Union(), which makes it easier to make constants of these types.

There are still problems comparing intervals that contain infinities;
I really need to make the infinity object to solve this, so have put
off trying to fix that for now.

Revision 2600 - Directory Listing
Modified Fri Aug 13 14:39:16 2004 UTC (13 years, 11 months ago) by dpvc
Handle list entries that are not Value objects better.

Revision 2599 - Directory Listing
Modified Fri Aug 13 14:19:23 2004 UTC (13 years, 11 months ago) by dpvc
The List object's answer checker is now considerably improved.  It
will allow you to specify an unorderd or ordered check, and whether to
print various kinds of hints for wrong answers.

The checker can return partial credit, but WW doesn't deal well with
this at the moment (some small changes to Problem.pm can take care of
that).  Partial credit should be based on $showPartialCorrectAnswers,
but it is disabled for now.

The list answer checker probably still needs some work, especially
with non-numeric lists.

Revision 2597 - Directory Listing
Modified Fri Aug 13 11:38:22 2004 UTC (13 years, 11 months ago) by dpvc
Added answer checker for parallel vectors.
Added option to number checker to have it not report type mismatches
for the known strings (like 'infinity').  (Really need a class for
infinities, and a Value.pm class for strings.)

Revision 2596 - Directory Listing
Modified Thu Aug 12 23:11:32 2004 UTC (13 years, 11 months ago) by dpvc
Have parser handle infinities better.

Revision 2594 - Directory Listing
Modified Thu Aug 12 20:17:18 2004 UTC (13 years, 11 months ago) by dpvc
Fixes for handling intervals better.  In particular, deal better with
ambiguous situations, like (1,2) that could be a point.

You can use [a,a] to specify the single point a.  I'd like to make {a}
represent this (and maybe even {a,b,c} to form finite sets), but this
would interfere with the use of { and } as alternative parentheses.
(Does anyone really use these?)

Do we need a cross product for intervals (and sets) as a means of
representing regions in R^2 (or higher)?

Revision 2593 - Directory Listing
Modified Thu Aug 12 16:48:52 2004 UTC (13 years, 11 months ago) by dpvc
This is a preliminary attempt at adding answer checkers that use the
parser.  If you have a parser object (like a formula or a vector), you
can use the ->cmp method to get an answer checker appropriate for the
object.  For example:

	 Context('Vector');
	 $v = Vector(1,2,3);
	 #  print text of problem
	 ANS($v->cmp);

would produce an answer checker that matched against the vector <1,2,3>.
Most of the parameters are set in the Context, but additional ones can
be passed to the checker (this still needs work).

See the sample problems for more examples.

The checkers for Reals, Complexes, Points, Vectors, Matrices and
Intervals work pretty well.  The ones for List and Union objects need
more work, as they only do an ORDERED check at the moment (the student
answers must be in the same order).  This needs to be fixed.
The checker for Formula objects (which corresponds to fun_cmp) still
needs to be written.

Revision 2592 - Directory Listing
Modified Thu Aug 12 16:40:47 2004 UTC (13 years, 11 months ago) by dpvc
A number of small fixes.  Most were to fix minor bugs in string and
TeX output, particulary for the various list-based objects (like
vectors, intervals, etc.).  There were also some bug fixes in the
comparison routines.  Some additional checks were added for valid
intervals when the coordinates are formulas.

Revision 2580 - Directory Listing
Modified Mon Aug 9 21:38:58 2004 UTC (13 years, 11 months ago) by dpvc
Forgot to add this file.  It implements the "fuzzy real" class.

Revision 2579 - Directory Listing
Modified Mon Aug 9 21:38:01 2004 UTC (13 years, 11 months ago) by dpvc
Significant update to new parser.

New features include:

  Better control over format of vector output (you can now
    specify ijk-format rather than <...> format)

  "Fuzzy" reals, where the relations like == return true when the
    two values are "close enough".  (This is controlable using
    parameters similar to those used in NUM_CMP).

  The fuzzy reals are now used in vectors/points/matrices/complexes/intervals
    and so on so that their relations will also be fuzzy.  E.g.,
    (1E-13,2) == (0,3) will be true, and norm(Vector(0,1E-13)) will
    equal 0.

  The two main portions of the parser (the Parser and Value packages)
    now share a common context object for configuration purposes.

Revision 2558 - Directory Listing
Added Wed Jul 28 20:32:33 2004 UTC (13 years, 11 months ago) by sh002i
merged changes from rel-2-1-a1 -- stop using that branch.

Sort log by:

aubreyja at gmail dot com
ViewVC Help
Powered by ViewVC 1.0.9