WeBWorK Main Forum

ERRORS in rendering problem

ERRORS in rendering problem

by Andrew Mathas -
Number of replies: 6
I am using questions from
Library/NAU/setLinearAlgebra/P3span.pg
in one of my webwork quizzes and some of my students are getting the error:
ERRORS from evaluating PG file:
Undefined subroutine &context::Fraction::Real::cmp_defaults called at
[PG]/lib/Value/AnswerChecker.pm line 1620
The page displays properly for me when I look at it. The error does not always appear but it is appearing enough to cause problems.

Can anyone see what the problem might be? Clearly a subroutine is missing but I don't know where to find this. The quiz file starts with

loadMacros(
"PGstandard.pl",
"MathObjects.pl",
"parserMultiAnswer.pl",
"AnswerFormatHelp.pl",
"MatrixReduce.pl",
"PGcourse.pl",
"contextFraction.pl"
);

and I have not taken anything out of this list so I am somewhat confused as to why a standard question from the library would cause errors.

Andrew
In reply to Andrew Mathas

Re: ERRORS in rendering problem

by Davide Cervone -
This was due to an error in the contextFraction.pl file, which was corrected in this patch back in the summer of 2017. Updating your copy of WeBWorK would fix that, but probably isn't something that should be done in the middle of a semester. You could, however, download the patches contextFraction.pl and place it in the templates/macros folder of your course in order to get the updated version.
In reply to Andrew Mathas

Re: ERRORS in rendering problem

by Nandor Sieben -
My version of this problem loads these macros:

loadMacros(
"PGstandard.pl",
"MathObjects.pl",
"parserMultiAnswer.pl",
"AnswerFormatHelp.pl",
"MatrixReduce.pl",
"rank.pl",
"PGcourse.pl"
);

Chances are that your OPL is not completely up to date.
In reply to Nandor Sieben

Re: ERRORS in rendering problem

by Andrew Mathas -
Dear Nandor and Davide,

Thanks for the reply. Looking at this again I think that my problem is probably that I do not have the rank.pl module. When I add it to the list of modules to be loaded I get the error/warning message:

Warning messages

  • Can't locate macro file |rank.pl| via path: |.|,
    |[TMPL]/macros|,
    |[PG]/macros/|,
    |[TMPL]/Library/macros/Union|,
    |[TMPL]/Library/macros/Michigan|,
    |[TMPL]/Library/macros/CollegeOfIdaho|,
    |[TMPL]/Library/macros/FortLewis|,
    |[TMPL]/Library/macros/TCNJ|,
    |[TMPL]/Library/macros/NAU|,
    |[TMPL]/Library/macros/Dartmouth|,
    |[TMPL]/Library/macros/WHFreeman|,
    |[TMPL]/Library/macros/UMass-Amherst|,
    |[TMPL]/Library/macros/PCC|,
    |[TMPL]/Library/macros/Alfred|,
    |[TMPL]/Library/macros/Wiley|,
    |[TMPL]/Library/macros/UBC|,
    |[TMPL]/Library/macros/Hope|
As far as I can see rank.pl is not on my system but via google I found what I think is the relevant code at:

https://github.com/openwebwork/webwork-open-problem-library/blob/master/OpenProblemLibrary/NAU/setLinearAlgebra/rank.pl

so I added the following code:
# returns the rank of a matrix
# original code by Christopher Heckman modified by Nandor

sub rank {
Context('Fraction');
my $R = rref(apply_fraction_to_matrix_entries(shift));
my ($row,$col) = $R->dimensions;
my ($r,$c) = (1,1);
while (($r <= $row) && ($c <= $col)) {
$r++ if ($R->element($r,$c) > 0.5);
$c ++;
}
$r - 1;
}

directly to the top of this question (and a few others in fact) but problems still persist.

Given that I have problems anyway is there any reason not to pull the latest updates from the git repository?

Andrew
In reply to Andrew Mathas

Re: ERRORS in rendering problem

by Davide Cervone -
The error message states that the problem is with context::Fraction::Real::cmp_defaults, and that this function is undefined. This is the bug that I referenced in my previous message, and that is fixed in contextFraction.pl. No other changes will resolve that problem. The error message is **not** due to a missing rank() function, and the rank.pl file is not a standard one (though it seems to be referenced from several NAU problems). It may be something local to Nandor's installation.

I still think the easiest solution is to download the patched contextFraction.pl and put it in your templates/macros folder. You can open the link I just gave and save that to a text file and then upload that to your templates/macros folder.

I would not recommend updating your entire PG and webwork2 installation in the middle of the term, as such changes require testing and may include changes to the interface and other features that could confuse your students (and faculty) who are used to doing things the way they are now. Also, you should not update just PG alone, as there are often changes that are required in both components. You could cherry-pick (git cherry-pick) the one commit the I linked to above in order to get the changed contextFraction.pl, but that might make complicate updating PG later.
In reply to Andrew Mathas

Re: ERRORS in rendering problem

by Nandor Sieben -
It seems that both the webwork system and the OPL library need updating. Updating webwork and pg in the middle of the semester is dangerous. I would not try that unless there is no other choice. Updating the OPL is usually pretty safe. I do it quite often.

Loading rank.pl in the pg file is not going to resolve the issue since the old version of the pg file does not use rank.pl. Davide's suggestion should work with the old version of the pg file. If that does not work for some reason, then I recommend you do a "git pull" in the OPL directory followed by OPL-update. That should get the new version of the pg file and this will also get rank.pl. If neither of these suggestions work, then you might want to try updating everything but expect some difficulties.
In reply to Andrew Mathas

Re: ERRORS in rendering problem

by Nathan Wallach -
I realize this is long after the original discussion, but I found that the rank.pl in the OPL is not that reliable for matrices whose entries need not be fractions.

An alternate rank function for MathObject matrices is available in the following GitHub issue, as well as revised basis grading code which uses it:


I've been using the new code in production courses, but more help in testing it would be nice, so it can be debugged/stabilized for addition to the main WeBWorK pg repository for a future release.