Installation

problem with math objects

problem with math objects

by Darwyn Cook -
Number of replies: 8
Problems that use math objects, like the Formula command produce the following error:
No such package 'Value::Formula()' in Value::Context::Package at line 326 of [PG]/lib/Value.pm in Value::Package at line 64 of [PG]/macros/Parser.p...
I just recently upgraded to 2.4.5, which may be when the problem began. From what I can tell this only affects objects which are "defined" in the pg/lib/Value subdirectory, for example Formula.pm can be found there.
In reply to Darwyn Cook

Re: problem with math objects

by Davide Cervone -
It looks like you might have an outdated version of the MathObjects libraries. Can you tell me what version of pg/lib/Value/Context.pm you have? (Use cvs status to determine the version.) I'm not sure what went into the 2-4-5 release, but this message should not occur in the current version of Context.pm. You might try updating to the HEAD version of pg, which is pretty stable at the moment.

Davide
In reply to Davide Cervone

Re: problem with math objects

by Darwyn Cook -
cvs status gives:
File: Context.pm Status: Up-to-date

Working revision: 1.10.6.2.2.2
Repository revision: 1.10.6.2.2.2 /webwork/cvs/system/pg/lib/Value/Context.pm,v
Sticky Tag: rel-2-4-patches (branch: 1.10.6.2.2)
Sticky Date: (none)
Sticky Options: (none)

I used cvs -q up -dP HEAD, is that the right command to update to HEAD? When I did this no files where changed (or at least none were reported)
In reply to Darwyn Cook

Re: problem with math objects

by Davide Cervone -
Well, that is the version that you should have had, but I don't see how that message could have been produced, since the trailing parentheses shoud have been removed before the message was issued. Hmmm.

In any case, I don't think the cvs command is quite right. It looks to me that this would try to get the current version of the file named HEAD. Try 'cvs update -A' in the pg directory. This should remove sticky tags and get you the most current version of everything.

Davide
In reply to Davide Cervone

Re: problem with math objects

by Darwyn Cook -
Well after updating the file HEAD blush I tried the cvs update -A. Lot's of files updated, but no success on the fix.
In reply to Darwyn Cook

Re: problem with math objects

by Davide Cervone -
OK, try this. Edit the pg/lib/Value/Context.pm file to change
    sub Package {
      my $context = shift; my $class = shift;
      return $context->{value}{$class} if defined $context->{value}{$class};
      $class =~ s/\(\)$//;
      return $context->{value}{$class} if defined $context->{value}{$class};
      return "Value::$class" if defined @{"Value::${class}::ISA"};
      Value::Error("No such package 'Value::%s'",$class) unless $_[0];
    }
to
    sub Package {
      my $context = shift; my $class = shift;
      return $context->{value}{$class} if defined $context->{value}{$class};
      $class =~ s/\(\)$//;
      warn $class;
      return $context->{value}{$class} if defined $context->{value}{$class};
      return "Value::$class" if defined @{"Value::${class}::ISA"};
      Value::Error("No such package 'Value::%s'",$class) unless $_[0];
    }
That is, add the "warn" line at around line 104 of the file. (Also, check that the line just above the warn command is exactly as it appears here.)

Restart the server.

Now view ONE problem file using the Library Browser or in a problem set. (If you use the browser, set the display mode to "none" when you list the problems, and click the "Try it" button on one of the problems.) This should generate 20 or 30 lines of warnings. Copy and past them into a message, here, and we'll see what we can see.

Davide

In reply to Davide Cervone

Re: problem with math objects

by Darwyn Cook -

WeBWorK Error

WeBWorK has encountered a software error while attempting to process this problem. It is likely that there is an error in the problem itself. If you are a student, report this error message to your professor to have it corrected. If you are a professor, please consult the error output below for more information.

Error messages

No such package 'Value::Formula()' in Value::Context::Package at line 326 of [PG]/lib/Value.pm in Value::Package at line 64 of [PG]/macros/Parser.pl in main::Formula at line 50 of [PG]/macros/Parser.pl in (eval) at line 1 of [PG]/macros/Parser.pl in main::__ANON__ at line 236 of /usr/lib/perl5/5.8.8/i386-linux-thread-multi/Safe.pm in (eval) at line 236 of /usr/lib/perl5/5.8.8/i386-linux-thread-multi/Safe.pm in Safe::reval at line 904 of [PG]/lib/WeBWorK/PG/Translator.pm in WeBWorK::PG::Translator::translate at line 344 of [WW]/lib/WeBWorK/PG/Local.pm in WeBWorK::PG::Local::new_helper at line 65 of [WW]/lib/WeBWorK/PG/Local.pm in (eval) at line 65 of [WW]/lib/WeBWorK/PG/Local.pm in WeBWorK::PG::Local::new at line 52 of [WW]/lib/WeBWorK/PG.pm in WeBWorK::PG::new at line 597 of [WW]/lib/WeBWorK/ContentGenerator/Problem.pm in WeBWorK::ContentGenerator::Problem::pre_header_initialize at line 175 of [WW]/lib/WeBWorK/ContentGenerator.pm in WeBWorK::ContentGenerator::go at line 353 of [WW]/lib/WeBWorK.pm in WeBWorK::dispatch at line 115 of [WW]/lib/Apache/WeBWorK.pm in (eval) at line 115 of [WW]/lib/Apache/WeBWorK.pm in Apache::WeBWorK::handler at line 0 of [PG]/macros/Parser.pl in (eval) at line 0 of [PG]/macros/Parser.pl Died within main::Formula called at line 50 of [TMPL]/alfredLibrary/anton8e/chapter3/3.3/prob1.pg

Error details

 Problem1
ERROR caught by Translator while processing problem file:alfredLibrary/anton8e/chapter3/3.3/prob1.pg
****************
No such package 'Value::Formula()' in Value::Context::Package at line 326 of [PG]/lib/Value.pm
 in Value::Package at line 64 of [PG]/macros/Parser.pl
 in main::Formula at line 50 of [PG]/macros/Parser.pl
 in (eval) at line 1 of [PG]/macros/Parser.pl
 in main::__ANON__ at line 236 of /usr/lib/perl5/5.8.8/i386-linux-thread-multi/Safe.pm
 in (eval) at line 236 of /usr/lib/perl5/5.8.8/i386-linux-thread-multi/Safe.pm
 in Safe::reval at line 904 of [PG]/lib/WeBWorK/PG/Translator.pm
 in WeBWorK::PG::Translator::translate at line 344 of [WW]/lib/WeBWorK/PG/Local.pm
 in WeBWorK::PG::Local::new_helper at line 65 of [WW]/lib/WeBWorK/PG/Local.pm
 in (eval) at line 65 of [WW]/lib/WeBWorK/PG/Local.pm
 in WeBWorK::PG::Local::new at line 52 of [WW]/lib/WeBWorK/PG.pm
 in WeBWorK::PG::new at line 597 of [WW]/lib/WeBWorK/ContentGenerator/Problem.pm
 in WeBWorK::ContentGenerator::Problem::pre_header_initialize at line 175 of [WW]/lib/WeBWorK/ContentGenerator.pm
 in WeBWorK::ContentGenerator::go at line 353 of [WW]/lib/WeBWorK.pm
 in WeBWorK::dispatch at line 115 of [WW]/lib/Apache/WeBWorK.pm
 in (eval) at line 115 of [WW]/lib/Apache/WeBWorK.pm
 in Apache::WeBWorK::handler at line 0 of [PG]/macros/Parser.pl
 in (eval) at line 0 of [PG]/macros/Parser.pl
 Died within main::Formula called at line 50 of [TMPL]/alfredLibrary/anton8e/chapter3/3.3/prob1.pg

****************

------Input Read
1 ##DESCRIPTION
2 #
3 # File Created: 5/29/2008
4 # Last Modified: 5/29/2008
5 # Problem Author: Addison Frey
6 # WeBWorK Entry: Victoria Sweetser
7 # Location: Alfred University
8 #
9 ##ENDDESCRIPTION
10
11 ##KEYWORDS('Derivative','Polynomial')
12 ##
13
14 ## DBsubject('Calculus')
15 ## DBchapter('Differentiation')
16 ## DBsection('Derivatives of Polynomials and Exponential Functions')
17 ## Date('5/29/2008')
18 ## Author('Addison Frey')
19 ## Institution('Alfred University')
20 ## TitleText1('Calculus: with Early Transcendentals')
21 ## EditionText1('8')
22 ## AuthorText1('Anton')
23 ## Section1('3.3')
24 ## Problem1('1')
25
26 DOCUMENT();
27
28 # Load whatever macros you need for the problem
29 loadMacros("PG.pl",
30 "PGbasicmacros.pl",
31 "PGchoicemacros.pl",
32 "PGanswermacros.pl",
33 "PGauxiliaryFunctions.pl",
34 "PGgraphmacros.pl",
35 "MathObjects.pl");
36
37 ## Show partial correct answers
38 $showPartialCorrectAnswers = 1;
39 ## Display the problem information
40 TEXT(beginproblem());
41
42 ## Declare Variables
43 Context()->variables->are(x=>'Real',y=>'Real');
44
45 ## Function Definition
46 $a0 = non_zero_random(-10,10);
47 $a1 = random(2,9);
48
49
50 $f = Formula("$a0*x^$a1")->reduce;
51 $df = $f->D('x');
52
53 Context()->texStrings;
54 BEGIN_TEXT
55
56 Find \(\>dy/dx\>\) if \(\>y = $f\).
57 $BR
58 $BR
59 Answer: \{ans_rule(20)\}
60
61 END_TEXT
62 Context()->normalStrings;
63 ANS($df->cmp);
64
65
66 ENDDOCUMENT();

I also am including a listing of the relevant directories:
pg/lib

[root@webwork lib]# ls -l
total 524
-rw-r--r-- 1 root root 19746 Aug 9 2006 AlgParser.pm
-rw-r--r-- 1 root root 25482 Aug 13 09:39 AnswerHash.pm
-rw-r--r-- 1 root root 1309 Sep 11 2007 AnswerIO.pm
-rw-r--r-- 1 root root 23395 Aug 13 09:39 Applet.pm
-rw-r--r-- 1 root root 4102 Jun 9 2003 Circle.pm
-rw-r--r-- 1 root root 40202 Jun 6 2003 Complex1.pm
-rw-r--r-- 1 root root 195 Jul 1 2003 Complex.pm
drwxr-xr-x 2 root root 4096 Aug 13 09:39 CVS
-rw-r--r-- 1 root root 11736 Jun 6 2003 Distributions.pm
-rw-r--r-- 1 root root 10768 Aug 13 09:39 Fraction.pm
-rw-r--r-- 1 root root 9363 Jun 7 2004 Fun.pm
-rw-r--r-- 1 root root 11526 Jun 9 2003 Hermite.pm
-rw-r--r-- 1 root root 2860 Jun 6 2003 Label.pm
-rw-r--r-- 1 root root 20474 Aug 13 09:39 List.pm
-rw-r--r-- 1 root root 6735 Jun 9 2003 Match.pm
-rw-r--r-- 1 root root 13382 Jul 12 2005 Matrix.pm
-rw-r--r-- 1 root root 106890 Jul 12 2005 MatrixReal1.pm
-rw-r--r-- 1 root root 7834 Jun 9 2003 Multiple.pm
drwxr-xr-x 9 root root 4096 Aug 13 09:39 Parser
-rw-r--r-- 1 root root 26545 Aug 13 09:39 Parser.pm
-rw-r--r-- 1 root root 1698 Aug 12 2003 PGrandom.pm
-rw-r--r-- 1 root root 8532 Jul 28 2004 Polynomial.pm
-rw-r--r-- 1 root root 13463 Jul 28 2004 PowerPolynomial.pm
-rw-r--r-- 1 root root 12823 Jun 9 2003 Regression.pm
-rw-r--r-- 1 root root 7122 Jun 9 2003 Select.pm
-rw-r--r-- 1 root root 18411 Aug 13 09:39 Units.pm
drwxr-xr-x 4 root root 4096 Aug 13 16:19 Value
-rw-r--r-- 1 root root 30601 Aug 13 09:39 Value.pm
-rw-r--r-- 1 root root 8029 Aug 13 09:39 VectorField.pm
drwxr-xr-x 4 root root 4096 Aug 13 09:39 WeBWorK
-rw-r--r-- 1 root root 14641 Jun 15 2005 WWPlot.pm
-rw-r--r-- 1 root root 2736 Jun 17 2004 ww_strict.pm

pg/lib/Value
[root@webwork Value]# ls -l
total 220
-rw-r--r-- 1 root root 69924 Aug 13 09:39 AnswerChecker.pm
-rw-r--r-- 1 root root 10238 Aug 13 09:39 Complex.pm
drwxr-xr-x 3 root root 4096 Aug 13 09:39 Context
-rw-r--r-- 1 root root 4509 Aug 13 16:18 Context.pm
-rw-r--r-- 1 root root 4494 Aug 13 16:17 Context.pm.bak
drwxr-xr-x 2 root root 4096 Aug 13 09:39 CVS
-rw-r--r-- 1 root root 16531 Aug 13 09:39 Formula.pm
-rw-r--r-- 1 root root 2045 Aug 13 09:39 Infinity.pm
-rw-r--r-- 1 root root 8402 Aug 13 09:39 Interval.pm
-rw-r--r-- 1 root root 3239 Aug 13 09:39 List.pm
-rw-r--r-- 1 root root 11905 Aug 13 09:39 Matrix.pm
-rw-r--r-- 1 root root 4632 Aug 13 09:39 Point.pm
-rw-r--r-- 1 root root 5870 Aug 13 09:39 Real.pm
-rw-r--r-- 1 root root 7334 Aug 13 09:39 Set.pm
-rw-r--r-- 1 root root 2010 Aug 13 09:39 String.pm
-rw-r--r-- 1 root root 10600 Aug 13 09:39 Union.pm
-rw-r--r-- 1 root root 9961 Aug 13 09:39 Vector.pm
-rw-r--r-- 1 root root 3248 Aug 13 09:39 WeBWorK.pm

In reply to Darwyn Cook

Re: problem with math objects

by Darwyn Cook -
I did a reboot for the them question I posted, and all is right with the world again. Sorry for the trouble, should have tried that first.
In reply to Darwyn Cook

Re: problem with math objects

by Davide Cervone -
Certainly the restart was necessary to get the new versions of the files to be used. I should have reminded you about that more clearly (it was in my instructions for the warning message I asked you to add in the message above, but I didn't stress the point).

I'm glad that everything is working for you now.

Davide

P.S., be sure to remove the warning I asked you to include above. :-)