WeBWorK Problems

Error that only sometimes appears with contextInequalities

Error that only sometimes appears with contextInequalities

by Robin Cruz -
Number of replies: 15

I'm using a slightly modified version of contextInequalities.  I've used this version for 3 terms now and it seems to be working OK. 

However, I updated the pg directory at the end of Dec or so and this term I'm getting an error.  The error that is being produced seems to happen when a student accidently enters something that WeBWorK isn't expecting -- like a "?" or if they enter a variable which is not defined for the problem.  Sometimes the "correct" error warning is given to the student and sometimes the page goes into "error" mode.  Sometimes after one of these errors, the next problem the student moves to has the page in "error" mode.  We can sometimes get the problem to reset by reloading the page, but sometimes the student has to shut down the window and then relogin in.  However, the problem works just fine after this.

I am sending a copy of the "error" page with this note (it's kind of long).  Note that I also tried this using the plain old version of contextInequalities and got similar results.

Thanks for your help -- rac

----------------Error follows------------------------------

18 DOCUMENT(); # This should be the first executable line in the problem.

19

20 loadMacros(

21 "PGstandard.pl",

22 "MathObjects.pl",

23 "contextInequalitiesAllowStrings.pl"

24 );

25

26 TEXT(&beginproblem);

27

28 ######################################

29 # Setup

30

31 @alphabet = ("a","m","n","r","t","x","y","z");

32 $choose = random(0,7,1);

33 $var = $alphabet[ $choose ];

34

35 $c2 = non_zero_random(2,4,1);

36 do {$m = list_random(-2,2,-3,3,-4,4,-5,5);} while ($c2**2==$m**2);

37 $a = $m/$c2;

38 do {$b = non_zero_random(-5,5,1);} while ($b>=$a || $b==-1*$a);

39 $c1 = $m + $c2*$b; #(c2x+m)(x+b)

40 $c0 = $m * $b;

41 $n = random(0,1,1);

42 $poly = nicestring([$c2,$c1,$c0],["$var^2","$var",""]);

43 @display = ("$poly < 0","$poly \le 0");

44 $na = -1*$a;

45 $nb = -1*$b;

46 @interval = ("($na,$nb)","[$na,$nb]");

47

48 ######################################

49 # Main text

50

51 BEGIN_TEXT

52 Solve the quadratic inequality:

53 \[ $display[$n] \]

54 $BR $BR

55 Answer: \{ans_rule(35) \}

56 END_TEXT

57

58 ######################################

59 # Answers

60

61 Context("Inequalities-AllowStrings");

62 Context()->strings->add("No solution"=>{});

63 Context()->variables->are($var=>'Real');

64

65 $answer = "$interval[$n]";

66 ANS(Compute($answer)->cmp);

67

68 $showPartialCorrectAnswers = 1;

69

70 ######################################

71

72 ENDDOCUMENT(); # This should be the last executable line in the problem.;

In reply to Robin Cruz

Re: Error that only sometimes appears with contextInequalities

by Davide Cervone -
It doesn't look like the full error was included (I only see the code listing, and only part of that, since it starts at line 18). Also, can you attach the modified contextInequalities.pl?

I assume you restarted the server after updating pg. I only ask because errors like this that seem intermittent or happen and then go away often are caused by not restarting the server, and you sometimes get a child process with the old code and sometimes one with the new.

Davide
In reply to Davide Cervone

Re: Error that only sometimes appears with contextInequalities

by Robin Cruz -

Davide,

I was going to send you the complete error message but a new error is occuring (I don't think it has anything to do with contextInequalities) and I can't get any of the problems to show up.  The new error message follows.  I restarted the server -- just in case I forgot earlier, but this error was happening before I did that and is still happening after the restart.

Thanks -- rac

---------------------New error---------------------------------------

Warning messages

Error messages


Failed to create directory /opt/webwork/webwork2/tmp/ImageGenerator.H8JV9Uis:
No space left on device at /opt/webwork/pg/lib/WeBWorK/PG/ImageGenerator.pm line 73.

Call stack

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

  • in WeBWorK::PG::Local::new called at line 52 of /opt/webwork/webwork2/lib/WeBWorK/PG.pm
  • in WeBWorK::PG::new called at line 598 of /opt/webwork/webwork2/lib/WeBWorK/ContentGenerator/Problem.pm
  • in WeBWorK::ContentGenerator::Problem::pre_header_initialize called at line 175 of /opt/webwork/webwork2/lib/WeBWorK/ContentGenerator.pm
  • in WeBWorK::ContentGenerator::go called at line 353 of /opt/webwork/webwork2/lib/WeBWorK.pm
In reply to Robin Cruz

Re: Error that only sometimes appears with contextInequalities

by Davide Cervone -
"No space left on device" is Unix-speak for "the disk is full". You will need to free up some space on the disk. Since the tmp directories are on that disk, they are an obvious place to start. You should be able to delete virtually anything that is in a course's tmp directory to free some space. If there are old classes that are not being used and they still have directories in /opt/webwork/webwork2/tmp, then those could certainly be emptied without problems. The image cache is another place that you could save space, by deleting old images that haven't been accessed in a while. There is a command for doing that in /opt/webwork/webwork2/bin, but I don't remember it off hand. Searching these archives for "stale image" or "remove old images" should turn up the command to use.

In the meantime, switch to jsMath mode, which doesn't need to generate images.

Davide
In reply to Davide Cervone

Re: Error that only sometimes appears with contextInequalities

by Robin Cruz -

OK.  I cleaned out the tmp folders and things seem to be working better on that end.  I also switched the courses to jsMath thinking that perhaps it would be better in the long run to not have so many images generated.  Thoughts on which is better to use: "images" or "jsMath".

One reason I have not used jsMath for the default display method is that there are LaTeX commands which do not work with it.  For example, the "\hline" command causes the array not to display.  Instead, a small box appears in the problem where the array should be and says "Unknown control sequence \hline".  Is there a way to get a horizontal line for a table in jsMath?  Here's an example:

\[ \begin{array}{c|cccccccc}
x  & $x[0] & $x[1] & $x[2] & $x[3] & $x[4] & $x[5] & $x[6] & $x[7] \cr
\hline
y  & $y[0] & $y[1] & $y[2] & $y[3] & $y[4] & $y[5] & $y[6] & $y[7] \cr
\end{array} \]

Note when I take out the \hline command, the values in the array display as they should, but the vertical line which is supposed to appear after the first column does not display.

OK, back to the original problem.  Here is a copy of the full error message. 

Thanks -- rac

-------------------------Error------------------------------------

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

Missing close parenthesis for '('; see position 1 of formula at line 687 of [PG]/macros/contextInequalities.pl Died within Inequalities::Inequality::new called at line 37 of [PG]/lib/Parser/List/Interval.pm from within Parser::List::Interval::_eval called at line 88 of [PG]/lib/Parser/List.pm from within Parser::List::eval called at line 63 of [PG]/lib/Parser/List.pm from within Parser::List::new called at line 388 of [PG]/lib/Parser.pm from within Parser::Close called at line 134 of [PG]/lib/Parser.pm from within Parser::parse called at line 50 of [PG]/lib/Parser.pm from within Parser::new called at line 19 of [PG]/lib/Value/Formula.pm from within Value::Formula::new called at line 64 of [PG]/macros/Parser.pl from within main::Formula called at line 93 of [PG]/macros/Parser.pl from within main::Compute called at line 64 of [TMPL]/Problems/setAppliedMath_02_05_PolyRatIneq/AppMath_04_PolyRatIneq.pg

Error details


Problem4 ERROR caught by Translator while processing problem file:Problems/setAppliedMath_02_05_PolyRatIneq/AppMath_04_PolyRatIneq.pg
**************** Missing close parenthesis for '('; see position 1 of formula at line 687 of [PG]/macros/contextInequalities.pl
Died within Inequalities::Inequality::new called at line 37 of [PG]/lib/Parser/List/Interval.pm
from within Parser::List::Interval::_eval called at line 88 of [PG]/lib/Parser/List.pm
from within Parser::List::eval called at line 63 of [PG]/lib/Parser/List.pm
from within Parser::List::new called at line 388 of [PG]/lib/Parser.pm
from within Parser::Close called at line 134 of [PG]/lib/Parser.pm
from within Parser::parse called at line 50 of [PG]/lib/Parser.pm
from within Parser::new called at line 19 of [PG]/lib/Value/Formula.pm
from within Value::Formula::new called at line 64 of [PG]/macros/Parser.pl
from within main::Formula called at line 93 of [PG]/macros/Parser.pl
from within main::Compute called at line 64 of [TMPL]/Problems/setAppliedMath_02_05_PolyRatIneq/AppMath_04_PolyRatIneq.pg
****************
 ------Input Read
1 #DESCRIPTION
2 ## Inequalities
3 ##
4 ##ENDDESCRIPTION
5 ## DBsubject('Applied Mathematics')
6 ## DBchapter('Ch 02: Graphs, Lines, and Inequalities')
7 ## DBsection('Polynomial and Rational Inequalities')
8 ## KEYWORDS('inequalities')
9 ## TitleText1('Finite Mathematics with Applications')
10 ## EditionText1('1')
11 ## AuthorText1('Lial, Hungerford, Holcomb')
12 ## Section1('2.5')
13 ## Problem1('')
14 ## Author('RA Cruz')
15 ## Institution('The College of Idaho')
16 ## Date: 2007/12
17
18 DOCUMENT(); # This should be the first executable line in the problem.
19
20 loadMacros(
21 "PGstandard.pl",
22 "MathObjects.pl",
23 "contextInequalitiesAllowStrings.pl"
24 );
25
26 TEXT(&beginproblem);
27
28 ######################################
29 # Setup
30
31 @alphabet = ("a","m","n","r","t","x","y","z");
32 $choose = random(0,7,1);
33 $var = $alphabet[ $choose ];
34
35 $c2 = non_zero_random(2,4,1);
36 do {$m = list_random(-2,2,-3,3,-4,4,-5,5);} while ($c2**2==$m**2);
37 $a = $m/$c2;
38 do {$b = non_zero_random(-5,5,1);} while ($b>=$a || $b==-1*$a);
39 $c1 = $m + $c2*$b; #(c2x+m)(x+b)
40 $c0 = $m * $b;
41 $n = random(0,1,1);
42 $poly = nicestring([$c2,$c1,$c0],["$var^2","$var",""]);
43 @display = ("$poly < 0","$poly \le 0");
44 $na = -1*$a;
45 $nb = -1*$b;
46 @interval = ("($na,$nb)","[$na,$nb]");
47
48 ######################################
49 # Main text
50
51 BEGIN_TEXT
52 Solve the quadratic inequality:
53 \[ $display[$n] \]
54 $BR $BR
55 Answer: \{ans_rule(35) \}
56 END_TEXT
57
58 ######################################
59 # Answers
60
61 Context("Inequalities-AllowStrings");
62 Context()->strings->add("No solution"=>{});
63 Context()->variables->are($var=>'Real');
64
65 $answer = "$interval[$n]";
66 ANS(Compute($answer)->cmp);
67
68 $showPartialCorrectAnswers = 1;
69
70 ######################################
71
72 ENDDOCUMENT(); # This should be the last executable line in the problem.;
-----

Request information

Time Thu Jan 22 16:38:49 2009
Method GET
URI /webwork2/MAT123_03_W09/Ch2_5_Polynomial_and_Rational_Inequalities/4/
HTTP Headers
User-Agent Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; GTB5; .NET CLR 1.0.3705; .NET CLR 1.1.4322; IEMB3; IEMB3)
Accept image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/msword, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/x-shockwave-flash, */*
Connection Keep-Alive
Referer http://docralph.collegeofidaho.edu/webwork2/MAT123_03_W09/Ch2_5_Polynomial_and_Rational_Inequalities/3/?user=rcruz&effectiveUser=rcruz&key=wPAtZsjhQCr5qFKhgsLb2hhcXA5VMjBF&displayMode=jsMath&showOldAnswers=1
UA-CPU x86
Accept-Encoding gzip, deflate
Accept-Language en-us
Cookie __utma=33027372.1440341229.1198802297.1232583576.1232667340.513; __utmz=33027372.1230672260.479.1.utmccn=(direct)|utmcsr=(direct)|utmcmd=(none); __utmb=33027372; __utmc=33027372; jsMath=font%3Asymbol%2Cwarn%3A0
Host docralph.collegeofidaho.edu

(Edited by Davide Cervone - original submission Thursday, 22 January 2009, 06:27 PM)

In reply to Robin Cruz

Re: Error that only sometimes appears with contextInequalities

by Davide Cervone -
You are right that jsMath doesn't do the full LaTeX array environment. That certainly needs work, and there is not "correct" way to do the \hline that you request (there are hacks for it).

Personally, I think it is better to use PG's table macros when you need this type of thing rather than raw TeX tables, but that is neither here nor there.

As for your error, you will need to send along your modified contextInequatilies.pl before I can determine the problem.

Davide
In reply to Davide Cervone

Re: Error that only sometimes appears with contextInequalities

by Robin Cruz -

I've been checking to see what causes the error and it seems if an answer is entered like "0<x,x>1" where the comma should have been "or" then the error occurs and it causes the next few problems to have the same error -- even if nothing has been submitted for an answer on the next problems.  If I shut down the window (or sometimes reloading the page works) the offending problem will display again, but I can't change the answer to one without the comma, I've typed in the answer in the correct format, but when I submit the problem the same error occurs and when I reload the page, the wrong answer is still in the answer box.

--rac

In reply to Robin Cruz

Re: Error that only sometimes appears with contextInequalities

by Davide Cervone -
I am not able to reproduce the error. What version of WW and PG are you using?

The experience you are reporting is strange, and it sounds more like some kind of browser caching issue rather than a WeBWorK one. Can you try reloading the page with a forced reload (for example, some browsers do this when holding down control while doing the reload)?

Davide
In reply to Davide Cervone

Re: Error that only sometimes appears with contextInequalities

by Robin Cruz -

For the version number, I updated from cvs using rel-2-4-patches on Jan 21.  I updated all of pg, but only updated the lib folder in the webwork folder.  Ever since I did the upgrade, we've had these problems.  Other errors have appeared now.  Here's a problem that has worked for 4 years and now produces an error:

---------------------------New error----------------------------------

When the string answer is checked (which is done correctly) a yellow box appears in the Answer Preview box that says : Unknown control sequence '\verb'.

------------------Code from the problem---------------------------

##DESCRIPTION
##  Hypothesis testing:  One mean, unknown standard deviation
##ENDDESCRIPTION

##KEYWORDS('Inference')

DOCUMENT();        # This should be the first executable line in the problem.

loadMacros(
"PG.pl",
"PGbasicmacros.pl",
"PGchoicemacros.pl",
"PGanswermacros.pl",
"PGauxiliaryFunctions.pl"
);
TEXT(&beginproblem);
$showPartialCorrectAnswers = 0;

$mu = random(10,20,2);
$n = random(8,23,1);

$p = random(0.055,0.085,0.001);

BEGIN_TEXT
NOTE:  You only have 3 chances on this problem.  Your score will
not be updated after the third submission.
$PAR
END_TEXT
BEGIN_TEXT
The P-value for a two sided test of the null hypothesis \(H_0: \mu = $mu\)
is $p.
END_TEXT

BEGIN_TEXT
$PAR
(a)   Does the 95$PERCENT confidence interval include the value of \($mu\)
(Type Yes or No):  \{ ans_rule(5)\}

$PAR
(b)   Does the 90$PERCENT confidence interval include the value of \($mu\)
(Type Yes or No):  \{ ans_rule(5)\}

END_TEXT

$ans1 = "Yes";
if ($p < .05) {$ans1 = "No";}
ANS(std_str_cmp($ans1));

$ans1 = "Yes";
if ($p < .10) {$ans1 = "No";}
ANS(std_str_cmp($ans1));


ENDDOCUMENT();        # This should be the last executable line in the problem.

------------End of code from new error-----------------------------

I know from looking over past forum questions that I will need to upgrade dvipng in order to get "images" display to work with the new version of pg, but I'm afraid at this point to try and do too much in the middle of the term.  I would like to "reset" everything so that it had the version in pg and lib that I had before the upgrade.  Everything was working then.  I could then do the upgrades to everything after the term is over and we don't have students getting frustrated with the problems we are having now.

So, is there a way I can turn the system back to the older version?  If so how? 

The inequality context worked fine in the older version as well, but here is the file I'm using in case I should make adjustments to it.

-------------------contextInequalitiesAllowStrings.pl-----------------------

###

=head1 NAME

    extra macros for Intermediate Algebra problems at CofI

=head1 Synposis
    macros by R Cruz -- The College of Idaho
=cut

=head3 Allows string answers for the set of real numbers and the empty set
      
=pod
      Adds the string "All real numbers" to the Inequalities context
 NOT WORKING: Adds the string "No solution" to the Inequalities context

=cut

loadMacros("contextInequalities.pl");

sub _contextInequalitiesAllowStrings_init {
    my $context = $main::context{"Inequalities-AllowStrings"} =
                Parser::Context->getCopy("Inequalities");

    $context->constants->{namePattern} = qr/.*/;

#----Add variations of "All real numbers"

    $context->constants->redefine("All real numbers",from=>"Interval",using=>"R");
    $context->constants->set("All real numbers"=>{TeX=>"\\mbox{All real numbers}"});

    $context->constants->redefine("all real numbers",from=>"Interval",using=>"R");
    $context->constants->set("all real numbers"=>{TeX=>"\\mbox{all real numbers}"});

    $context->constants->redefine("All Real numbers",from=>"Interval",using=>"R");
    $context->constants->set("All Real numbers"=>{TeX=>"\\mbox{All Real numbers}"});

    $context->constants->redefine("ALL REAL NUMBERS",from=>"Interval",using=>"R");
    $context->constants->set("ALL REAL NUMBERS"=>{TeX=>"\\mbox{ALL REAL NUMBERS}"});

#-----Add variations of "No solution" = NONE
#************This part does not work. Can't get it to "take" the empty set
# Tried Set(), NONE and DNE
#
#    $context->constants->redefine("No solution"",from=>"Interval",using=>"{}");
#    $context->constants->set("No solution"=>{TeX=>"\\mbox{No solution}"});
#
#    $context->constants->redefine("no solution"",from=>"Interval",using=>"{}");
#    $context->constants->set("no solution"=>{TeX=>"\\mbox{no solution}"});
#
#    $context->constants->redefine("NO SOLUTION"",from=>"Interval",using=>"{}");
#    $context->constants->set("NO SOLUTION"=>{TeX=>"\\mbox{NO SOLUTION}"});

        }
1;
-------------------End of contextInequalitiesAllowStrints.pl----------------

Thanks for you help on this. -- rac

In reply to Robin Cruz

Re: Yellow box with error message

by Davide Cervone -
Robin:

You have asked questions on several issues, so I'm going to reply to them each in a separate message.

The first one concerns the yellow box with the error message about \verb. This is because you are using an older version of jsMath and need to update that (it is in webwork2/htdocs/jsMath) and the newest copy of the string answer checker uses \verb to display the string rather than just {\rm ...} as it used to, since the latter doesn't treat spaces right or other special characters. This was added to jsMath some time ago, but I don't remember which version it was.

This is a consequence of your only updating webwork2/lib and not all of webwork2 (since that missed the webwork2/htdocs directory). It is not generally a good idea to only update part of webwork, as there may be required changes in other areas. In particular, I'm concerned about changes in webwork2/config/globcal.conf.dist that you may be missing and that are required by changes in the rest of the system. If I were you, I'd try bringing the whole webwork2 directory up to the same version, and making sure you have updated your copy of global.conf. Unfortunately, that is not always a simple job, as sometimes there are new Perl modules that you will need to get, and so on. It is not easy to make this sort of change during the term.

In any case, updating jsMath should fix the yellow box problem, or going back to image mode, either one.

Davide
In reply to Robin Cruz

Re: Going back to an older version of WeBWorK

by Davide Cervone -
Robin:

You ask:

I would like to "reset" everything so that it had the version in pg and lib that I had before the upgrade. Everything was working then. I could then do the upgrades to everything after the term is over and we don't have students getting frustrated with the problems we are having now.

So, is there a way I can turn the system back to the older version? If so how?

One way would be to reload the pg and webwork2/lib directories from backups that were made before you updated to rel-2-4-patches (you DO make backups before updating, don't you?)

Alternatively, you can use CVS to go back to earlier versions, if you know what version you want to go back to. Just use

   cvs -r rel-2-3-2
in the directory you want to revert (and use whatever version you want in place of rel-2-3-2 if that was not the version you were running; perhaps you were using rel-2-4-0 or some other version). That should do it for you.

Davide

In reply to Robin Cruz

Re: inequalities with strings

by Davide Cervone -
Robin:

Your version of contextInequalitiesAllowStrings.pl has an implied question about how to get the empty set.

The reason you could not get the redefine commands to work is that the name for the empty set in the Interval context is NONE, not {} (you can certainly enter {} to obtain the empty set, but it is not a named constant, as NONE is, and as R is for the whole real line in your earlier commands). The valu eof the using flag must be a named constant in the Interval context that you are going to make a copy of as your new constant.

For example:

    $context->constants->redefine("No solution", from=>"Interval", using=>"NONE");
    $context->constants->set("No solution"=>{TeX=>"\\mbox{No solution}"});
should work.

In the case where there didn't happen to be a constant with the required value already, you could set up one simply have using the value you want:

    $context->constants->add("No solution"=>main::Set());
    $context->constants->set("No solution"=>{TeX=>"\\mbox{No solution}"});

Hope that clears it up.

Davide

In reply to Robin Cruz

Re: Error that only sometimes appears with contextInequalities

by Davide Cervone -
I'm still not able to reproduce the problem, and because you have only updated part of the webwork2 directory, I'm going to assume it has to do with the inconsistency within the system. See if either going to a full 2.4.5 version works, or going back to the old version helps.

Davide
In reply to Davide Cervone

Re: Error that only sometimes appears with contextInequalities

by Robin Cruz -

Davide,

I've been meaning to get back to you.  When I sent out my last note I was sort of in panic mode.  So, thanks for reminding me that I can "go back".  I reset our WeBWorK to what it was before the partial upgrade problem and we are OK again.  The inequalities context is working again as it should.  I will do a full more careful upgrade after Winter term is over -- before Spring term starts and that should take care of the other difficulties.

Thanks for the help on my version of contextInequalitiesAllowStrings.pl.  Your suggestion makes it do what I wanted. 

Thanks so much. --rac

In reply to Robin Cruz

Re: Error that only sometimes appears with contextInequalities

by Robin Cruz -
Davide,
Thought I should let you know about this. When I changed my version of contextInequalitiesAllowStrings.pl to allow for answers like "No solution" for the empty set, I could not get it to work by "redefining" the constants. I got this error message:

ERROR in included file: Problems/setAlgebra_04_02_CompoundIneq/42IntAlg_03_CompoundIneq.pg No definition for constant 'NONE' in the given context at line 51 of [TMPL]/macros/contextInequalitiesAllowStrings.pl Died within main::_contextInequalitiesAllowStrings_init called at line 332 of (eval 232) from within main::loadMacros called at line 20 of [TMPL]/Problems/setAlgebra_04_02_CompoundIneq/42IntAlg_03_CompoundIneq.pg from within (eval) called at line 86 of [PG]/lib/WeBWorK/PG/IO.pm from within WeBWorK::PG::IO::includePGtext called at line 32 of [TMPL]/macros/unionInclude.pl from within main::includePGfile called at line 56 of [TMPL]/macros/unionInclude.pl from within main::includeRandomProblem called at line 15 of [TMPL]/Problems/setAlgebra_04_02_CompoundIneq/42aRandomizer_Problems_03_to_07.pg

However, when I used the second of your suggestions -- where the constant was added -- it worked as desired.

I was wondering why the error happened when I used the "redefine" method.
--rac
In reply to Robin Cruz

Re: Error that only sometimes appears with contextInequalities

by Davide Cervone -
Sorry, it should be
    from => $context
not
    from => "Interval"
My mistake. You want to take the "NONE" from the Inequalities context, not the Interval context. But due to a bug in the redefine() method, you can't do it by giving its name, but must give a pointer to the context object instead.

Davide