WeBWorK Problems

Units of Measure not Respected

Units of Measure not Respected

by Jason Appah -
Number of replies: 21
on several problems where the answer is reflected in ft or lb/ft or inches or any real units of measure webworks will not respect the UOM, even if I copy and paste the answer with the unit of measure it doesn't respect it.


here is an example of one of the problems:

Library/Michigan/Chap5Sec1/Q15.pg

A student is speeding down Route 11 in his fancy red Porsche when his radar system warns him of an obstacle 400 feet ahead. He immediately applies the brakes, starts to slow down, and spots a skunk in the road directly ahead of him. The "black box" in the Porsche records the car's speed every two seconds, producing the following table. The speed decreases throughout the 10 seconds it takes to stop, although not necessarily at a uniform rate.

Time since brakes applied (sec) 0 2 4 6 8 10
Speed (ft/sec) 120 70 50 20 15 0

A. What is your best estimate of the total distance the student's car traveled before coming to rest (note that the best estimate is probably not the over or under estimate that you can most easily find)?
distance = (include units)

B. Which one of the following statements can you justify from the information given?

A. The "black box" data is inconclusive. The skunk may or may not have been hit.
B. The car stopped before getting to the skunk.
C. The skunk was hit by the car.

the answer is 430 feet but webwork doesnt see the ft at the end no matter what I do...

whats up with that?
In reply to Jason Appah

Re: Units of Measure not Respected

by Davide Cervone -
It works fine for me. What version of PG are you using? I recall that there was a problem with units some time ago, but that was fixed at least a year ago. How long has it been since you did an update of PG?

When you enter "430 ft" is there an error message produced? If so, what is it?

Davde
In reply to Davide Cervone

Re: Units of Measure not Respected

by Jason Appah -
how do you update PG? how you know what version you are running? we upgraded from 2.3 to 2.4 does that involve updating pg?

the error message is that it marks them wrong and tells you you must provide units...
In reply to Jason Appah

Re: Units of Measure not Respected

by Davide Cervone -
The webwork2 and pg directories are separate components of WeBWorK, and so you might have updated webwork2 without updating PG.

You can use

    cvs status filename
to find out the version of a particular file. This should also list tags (such as rel-2-4-patches) which could tell you which version you are using.

It sounds to me like you have an old version of PG. You can update that without updating webwork itself. To do this, cd to the pg directory and use the command

    cvs update -d -r rel-2-4-patches
to get the latest update of pg. I think that should take care of your problem. Let me know if it doesn't.

Of course, it is always a good idea to make a backup of the pg directory before you do this, just in case you want to go back to the current setup of there is trouble.

Davide

In reply to Davide Cervone

Re: Units of Measure not Respected

by Jason Appah -
No dice, Updading broke pretty much every problem in the problem library, stating that there is no getcopy function?
In reply to Jason Appah

Re: Units of Measure not Respected

by Davide Cervone -
Did you restart the server after updating? You need to do that so that since part of WeBWorK is cached by the server processes, and that part would be using the old version if you didn't restart. The getCopy function is part of the updated version of pg, so I suspect that the old processes are still running with the old version.

Davide
In reply to Davide Cervone

Re: Units of Measure not Respected

by Jason Appah -
yes, multiple times I have rebooted and restarted apache
In reply to Jason Appah

Re: Units of Measure not Respected

by Jason Appah -
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

Can't locate object method "getCopy" via package "Parser::Context" at line 988 of [PG]/macros/PGnumericevaluators.pl Died within main::NUM_CMP called at line 411 of [PG]/macros/PGnumericevaluators.pl from within main::num_cmp called at line 62 of [TMPL]/Library/OSU/accelerated_calculus_and_analytic_geometry_i/hmwk9/prob11.pg

Error details

Problem1
ERROR caught by Translator while processing problem file:Library/OSU/accelerated_calculus_and_analytic_geometry_i/hmwk9/prob11.pg
****************
Can't locate object method "getCopy" via package "Parser::Context" at line 988 of [PG]/macros/PGnumericevaluators.pl
Died within main::NUM_CMP called at line 411 of [PG]/macros/PGnumericevaluators.pl
from within main::num_cmp called at line 62 of [TMPL]/Library/OSU/accelerated_calculus_and_analytic_geometry_i/hmwk9/prob11.pg

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

------Input Read
1 ## DESCRIPTION
2 ## Integration: Arc Length
3 ## ENDDESCRIPTION
4
5 ## KEYWORDS('Integration', 'Arc Length', 'Application')
6 ## Tagged by nhamblet
7
8 ## DBsubject('Calculus')
9 ## DBchapter('Applications of Integration')
10 ## DBsection('Arc Length')
11 ## Date('5/20/2000')
12 ## Author('Zig Fiedorowicz')
13 ## Institution('Ohio State')
14 ## TitleText1('Calculus: Early Transcendentals')
15 ## EditionText1('5')
16 ## AuthorText1('Stewart')
17 ## Section1('8.1')
18 ## Problem1('')
19
20 ## TitleText2('Calculus: Early Transcendentals')
21 ## EditionText2('6')
22 ## AuthorText2('Stewart')
23 ## Section2('8.1')
24 ## Problem2('')
25
26 DOCUMENT(); # This should be the first executable line in the problem.
27
28 loadMacros(
29 "PG.pl",
30 "PGbasicmacros.pl",
31 "PGchoicemacros.pl",
32 "PGanswermacros.pl",
33 "PGauxiliaryFunctions.pl"
34 );
35
36 $showPartialCorrectAnswers = 1;
37 if (!($studentName =~ /PRACTICE/)) {
38 $seed = random(1,4,1);
39 if ($studentName =~ /VINCE VERSION1/) {$seed = 1;}
40 if ($studentName =~ /VINCE VERSION2/) {$seed = 2;}
41 if ($studentName =~ /VINCE VERSION3/) {$seed = 3;}
42 if ($studentName =~ /VINCE VERSION4/) {$seed = 4;}
43 SRAND($seed);}
44
45
46 $a = random(2,5,1);
47 $c = $a + random(1,5,1);
48 $d = $c + random(1,3,1);
49 $answer = $d - $c + $a*log( ($d-$a)/($c-$a) ) - $a* log( ($d + $a)/ ($c + $a) );
50
51 TEXT(beginproblem());
52 BEGIN_TEXT
53 Find the length of the curve defined by
54 \[ y=${a}\ln( (x/$a) ^2 - 1 ) \]
55 from \(x=$c\) to \(x = $d \).
56 $BR
57
58 \{ ans_rule(40) \}
59
60 $PAR
61
62
63 END_TEXT
64
65 ANS(num_cmp($answer));
66
67 ENDDOCUMENT()

that is the text of the error message...


can someone please help me?
In reply to Jason Appah

Re: Units of Measure not Respected

by Jason Appah -
ok, this is the list of errors when trying to display items on WEBWORKS, interestingly its not consistent, some display fine, but others generate errors....

why does this always happen to me :(


WeBWorK Warnings
WeBWorK has encountered warnings while processing your request. If this occured when viewing a problem, it was likely caused by an error or ambiguity in that problem. Otherwise, it may indicate a problem with the WeBWorK system itself. If you are a student, report these warnings to your professor to have them corrected. If you are a professor, please consult the warning output below for more information.

Warning messages




Failed to evaluate module Parser: Undefined subroutine &Scalar::Util::weaken called at /opt/webwork/pg/lib/Value/Context/Data.pm line 62.
BEGIN failed--compilation aborted at /opt/webwork/pg/lib/Value.pm line 132.
Compilation failed in require at /opt/webwork/pg/lib/Parser.pm line 791.
BEGIN failed--compilation aborted at /opt/webwork/pg/lib/Parser.pm line 791.
Compilation failed in require at (eval 590) line 1.
Failed to evaluate module Value: Undefined subroutine &Scalar::Util::weaken called at /opt/webwork/pg/lib/Value/Context/Data.pm line 62.
BEGIN failed--compilation aborted at /opt/webwork/pg/lib/Value.pm line 132.
Compilation failed in require at /opt/webwork/pg/lib/Parser.pm line 791.
BEGIN failed--compilation aborted at /opt/webwork/pg/lib/Parser.pm line 791.
Compilation failed in require at (eval 590) line 1.
Failed to evaluate module Parser::Legacy: Can't call method "copy" on an undefined value at /opt/webwork/pg/lib/Parser/Legacy/LimitedNumeric.pm line 81.
Compilation failed in require at /opt/webwork/pg/lib/Parser/Legacy.pm line 6.
BEGIN failed--compilation aborted at /opt/webwork/pg/lib/Parser/Legacy.pm line 6.
Compilation failed in require at (eval 591) line 1.
In reply to Jason Appah

Re: Units of Measure not Respected

by Jason Appah -
so I found at least part of the problem here:
http://wwrk.maa.org/moodle/mod/forum/discuss.php?d=530

adding the line : pecialPGEnvironmentVars}{useOldAnswerMacros} = 1; to my global.conf fixed at least the lion share of the problems...
In reply to Jason Appah

Re: Units of Measure not Respected

by Davide Cervone -
This doesn't actually "fix" anything, it just avoids the issue by calling the older versions of the traditional answer checkers that don't use MathObjects internally. The problem still exists, and any newer PG files that use MathObjects (the new standard for writing WeBWorK problems) will continue to cause the errors you are seeing.

Davide
In reply to Jason Appah

Re: Units of Measure not Respected

by Davide Cervone -
Your error messages suggest that you have not updated all of PG, but perhaps just pg/macros? The Context getCopy method is in lib/Parser/Context.pm; what version of that file do you have. You can cd to the pg/lib/Parser directory and use

cvs status Context.pm

to find out.

If you only updated pg/macros and not all of the PG directory tree, you will likely get lots of errors like the ones you are seeing. Make sure that you have updated everything to the rel-2-4-patches (or even HEAD) versions.

The only reason I can see for getting this error is if you have an old version of pg/lib/Parser/Context.pm, so that is your first place to look.

Davide
In reply to Davide Cervone

Re: Units of Measure not Respected

by Jason Appah -
I did as you asked and this is the result:jason@TANGENT:/opt/webwork/pg/lib/Parser$ cvs status Context.pm
===================================================================
File: Context.pm Status: Up-to-date

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

jason@TANGENT:/opt/webwork/pg/lib/Parser$


it looks like its right?
In reply to Jason Appah

Re: Units of Measure not Respected

by Davide Cervone -
Yes, that is the right version. You should not be getting any errors about getCopy with that version (the getCopy method is defined in that file).

What is the current set of messages? Is it the getCopy one, or the Scalar::Util::weaken one?

If it is the latter, check that you have Scalar::Util installed in your perl include path. For example

    perl -MScalar::Util -e 'print "You got it!\n"'
should print "You got it!" if you do and give an error message if you don't. (The webwork2/bin/check_modules.pl file should check for that; did you run it? Scalar::Util was added four months ago, so perhaps that was after you ran it.) If you don't have it, you can get it from www.CPAN.org or one of the other distribution methods.

Hope that will clear up your problems.

Davide

PS, have you looked at the server error log to see if there are any other messages there? Sometimes there are message that don't show up on the webwork screen that can help you track down missing files, etc.

In reply to Davide Cervone

Re: Units of Measure not Respected

by Jason Appah -
the perl worked. but we still get the "pink screen errors about finding scalar::util" as well as some of the newer problems still produce errors:
In reply to Jason Appah

Re: Units of Measure not Respected

by Jason Appah -
here's an example of a problem that no longer works?

any ideas?

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

Can't locate object method "current" via package "Parser::Context" at line 325 of [PG]/macros/PGgraphmacros.pl Died within main::plot_functions called at line 296 of [PG]/macros/PGgraphmacros.pl from within main::add_functions called at line 94 of [TMPL]/Library/Michigan/Chap5Sec1/Q01.pg

Error details

Problem21
ERROR caught by Translator while processing problem file:Library/Michigan/Chap5Sec1/Q01.pg
****************
Can't locate object method "current" via package "Parser::Context" at line 325 of [PG]/macros/PGgraphmacros.pl
Died within main::plot_functions called at line 296 of [PG]/macros/PGgraphmacros.pl
from within main::add_functions called at line 94 of [TMPL]/Library/Michigan/Chap5Sec1/Q01.pg



here is another one from setmaker:

WeBWorK error

An error occured while processing your request. For help, please send mail to this site's webmaster (webmaster@localhost), including all of the following information as well as what what you were doing when the error occured.

Mon Jan 12 15:26:03 2009

Warning messages

Error messages

No display module found for path '/admin/Undefined_Set/1/'. at /opt/webwork/webwork2/lib/WeBWorK.pm line 152.
Call stack

The information below can help locate the source of the problem.

Request information


So what do you think?
In reply to Jason Appah

Re: Units of Measure not Respected

by Davide Cervone -
Well, the first message is pretty strange, because the context() method is defined in the same file as the Parser::Context package, so what it looks like is that that file is not being loaded at all. The loading of the Parser (i.e., MathObjects) files is controlled by the ${pg}{modules} array at the bottom of webwork2/config/global.conf. There should be two entries near the bottom of that list: [qw(Parser Value)] and [qw(Parser::Legacy)]. Are they there and not commented out?

If they are there, then I don't see why you would be getting this message. You might want to try putting a warning message into pg/lib/Parser/Context.pm to see if it is actually being loaded. (The message may not appear on screen, but should be in the error log, at last.) For example:

    warn "In Parser::Context";
If not, try putting a die statement rather than a warn just to be sure. Of course, remember to restart the server after you edit the file.

If you don't see the message, then the file isn't being loaded. Check the $pg_dir variable in webwork2/conf/global.dist so that you are sure you are using the correct PG directory. Also, make sure you go over the changes you made to global.conf.dist carefully (you did make a new global.conf file from the global.conf.dist file and edited it to suit your local configuration, right? You can't just use your old one from an earlier version of WeBWorK.) Make sure the changes you have made are all correct.

If you do see the message, then check to be sure the file is complete (perhaps it didn't transfer correctly when you downloaded it, or it got corrupted on your disk somehow). I know I'm grasping at straws, here, but if that file is getting loaded, I don't see how it could be producing the error you are reporting.

Are you running Apache2 or Apache1.3? Also, what version of Perl are you using? What OS?

As for the error about no path module found, that is probably because you are trying to run the library browser from the admin course. That course is a very specialized one, and is really just for administrative work. You should not run the Library Browser there. Make an actual course (even just a test one) to run the Library Browser. I think you will find that you don't get that message then.

Davide

In reply to Davide Cervone

Re: Units of Measure not Respected

by Jason Appah -
##### PG modules to load

# The first item of each list is the module to load. The remaining items are
# additional packages to import.

${pg}{modules} = [
[qw(DynaLoader)],
[qw(Exporter)],
[qw(GD)],

[qw(AlgParser AlgParserWithImplicitExpand Expr ExprWithImplicitExpand utf8)],
[qw(AnswerHash AnswerEvaluator)],
[qw(WWPlot)], # required by Circle (and others)
[qw(Circle)],
[qw(Complex)],
[qw(Complex1)],
[qw(Distributions)],
[qw(Fraction)],
[qw(Fun)],
[qw(Hermite)],
[qw(Label)],
[qw(List)],
[qw(Match)],
[qw(MatrixReal1)], # required by Matrix
[qw(Matrix)],
[qw(Multiple)],
[qw(PGrandom)],
[qw(Regression)],
[qw(Select)],
[qw(Units)],
[qw(VectorField)],
[qw(Parser Value)],
[qw(Parser::Legacy)],
];


here is the excerpt of my global.conf. I'm not certain if the commenting on the matrix line continues or not, but I suspsect not.

we are using apache2 , and yes I did make a copy of global.conf.dist

Perl is 5.8.8

Os is Debian etch 4.0 with all current updates

I will make the changes and restart the server during lunch when people are less likely to be using it.
In reply to Jason Appah

Re: Units of Measure not Respected

by Davide Cervone -
The list of modules looks good. Did you check the $pg_dir variable to make sure it is right? (It probably is.) If you have verified that pg/lib/Parser/Context.pm is actually loading, then I don't see how you can be getting the message you are seeing (unless that file is truncated or damaged in some way).

I haven't used Apache2, but I know there were some problems with it when it first came out. It may be that your mod_perl isn't working properly, but that is taking me out of my field of expertise.

Here's another thing to try. Make a problem file containing

    DOCUMENT();
    loadMacros("PGstandard.pl");
    TEXT(beginproblem);
    TEXT(join("<BR>",lex_sort(grep {/::/} (keys %main:: ))));
    ENDDOCUMENT();
and run it using the Library Browser. It should output a list like the following:
    AlgParser::
    AlgParserWithImplicitExpand::
    AnswerEvaluator::
    AnswerHash::
    Apache::
    Applet::
    Carp::
    Circle::
    CommonFunction::
    Complex1::
    Complex::
    Distributions::
    DynaLoader::
    Exporter::
    Expr::
    ExprWithImplicitExpand::
    FlashApplet::
    Fraction::
    Fun::
    GD::
    Hermite::
    IO::
    JavaApplet::
    Label::
    List::
    Match::
    Matrix::
    MatrixReal1::
    Multiple::
    PGrandom::
    Parser::
    Regression::
    Safe::
    Select::
    Units::
    Value::
    VectorField::
    WWPlot::
    WeBWorK::
    main::
    strict::
    utf8::
    ww_strict::
Check to make sure Parser:: and Value:: appear on this list. Then if they do, try
    DOCUMENT();
    loadMacros("PGstandard.pl");
    TEXT(beginproblem);
    TEXT(join("<BR>",lex_sort(keys %main::Parser:: )));
    ENDDOCUMENT();
and then
    DOCUMENT();
    loadMacros("PGstandard.pl");
    TEXT(beginproblem);
    TEXT(join("<BR>",lex_sort(keys %main::Parser::Context:: )));
    ENDDOCUMENT();
Both of these should produce longish lists of variable/function/package names. The last one should include current (the method that perl is complaining about).

See what this turns up, if anything.

Davide

In reply to Davide Cervone

Re: Units of Measure not Respected

by Jason Appah -
davide,

where would I see the "warn" in the logs? in the webwork2/logs section? or in the var/logs/apache2? I grep'd both and I'm not seeing my "loaded" warn or die

I am seeing lots of warns from other things but to be honest I dont really know what I am looking for.
In reply to Jason Appah

Re: Units of Measure not Respected

by Davide Cervone -
I meant to look in the apache logs. If you did a
    warn "Loaded";
at the top of pg/lib/Parser/Context.pm, then you should see something like:
[Thu Jan 15 18:00:31 2009] [warn] [client 127.0.0.1] [/webwork2/DPVC-test/Undefined_Set/1/] Loaded at /usr/local/WeBWorK/pg/lib/Parser/Context.pm line 3.
in the error log. But it turns out that you should also get the pick screen and the warning on the actual WeBWorK page itself. You need to load a problem that tries to use MathObjects, and because Context.pm is one of the files that is cached by mod_perl, you will only see the message the first time that any Apache child process loads the file (i.e., you may not see it if you reload the page, unless you get a different child process).

Remember to restart the server after making the change.

Davide