## WeBWorK Problems

### Problems not rendering after upgrade to 2.17

by Lukas Fredriksson -
Number of replies: 13

Hi,

After upgrading to version 2.17 some of our problems are no longer rendering properly. The error message isn't clear either (to me at least).

We are using includeRandomProblem to give different students different problems and some of the problems are working while some are not. I've tried comparing them but can't find why there is an issue. Here is the error message with code for the problem included in the error:

       Problem1
1. ERROR caught by Translator while processing problem file:Library/StockholmUni/DifferentialCalculusOneVar/Derivate/001.pg
****************
ERRORS from evaluating PG file:  ERROR in included file:
Library/StockholmUni/DifferentialCalculusOneVar/Derivate/DerivateEasy/enkelt5.pg
'require' trapped by operation mask at /usr/lib/x86_64-linux-gnu/perl/5.26/Encode.pm line 5
Died within Encode::Alias::find_alias called at line 114 of /usr/lib/x86_64-linux-gnu/perl/5.26/Encode.pm
from within Encode::getEncoding called at line 132 of /usr/lib/x86_64-linux-gnu/perl/5.26/Encode.pm
from within Encode::find_encoding called at line 166 of /usr/lib/x86_64-linux-gnu/perl/5.26/Encode.pm
from within Encode::encode called at line 82 of [WW]/lib/Apache/WeBWorK.pm
from within (eval) called at line 127 of [PG]/lib/WeBWorK/PG/IO.pm
from within WeBWorK::PG::IO::includePGtext called at line 33 of [TMPL]/macros/unionInclude.pl
from within main::includePGfile called at line 59 of [TMPL]/macros/unionInclude.pl
from within main::includeRandomProblem called at line 7 of (eval 1228)
Compilation failed in require at /usr/lib/x86_64-linux-gnu/perl/5.26/Encode/Alias.pm line 22

################################################################################
# WeBWorK Online Homework Delivery System
# $CVSHeader: webwork2/conf/snippets/blankProblem.pg,v 1.2 2005/02/06 15:20:51 gage Exp$
#
# This program is free software; you can redistribute it and/or modify it under
# Free Software Foundation; either version 2, or (at your option) any later
# version, or (b) the "Artistic License" which comes with this package.
#
# This program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE.  See either the GNU General Public License or the
# Artistic License for more details.
################################################################################
DOCUMENT();

# Load whatever macros you need for the problem
"MathObjects.pl",
);

## Do NOT show partial correct answers
$showPartialCorrectAnswers = 0; TEXT(beginproblem());$A = random(1,9,1);

BEGIN_TEXT

Bestäm derivatan till funktionen \$$f(x) = 1/(x+{A})^2 \$$
$PAR$PAR

\$$f'(x) = \$$ \\{ans_rule(20) \\}
$PAR END_TEXT$ans = Compute("-2/(x+${A})**3"); ANS($ans->cmp);

ENDDOCUMENT(); at [PG]/lib/WeBWorK/PG/IO.pm line 129

****************
1		DOCUMENT();
2
3		# Load whatever macros you need for the problem
5		);
6
7		includeRandomProblem(
8		"DerivateEasy/enkelt1.pg",
9		"DerivateEasy/enkelt3.pg",
10		"DerivateEasy/enkelt4.pg",
11		"DerivateEasy/enkelt5.pg",
12		);
13
14		ENDDOCUMENT();

### Re: Problems not rendering after upgrade to 2.17

by Danny Glin -

Did you restart apache after the upgrade?

Have you tried adding the individual problems directly to a homework set?

### Re: Problems not rendering after upgrade to 2.17

by Glenn Rice -

You should also note that the unionInclude.pg macro is deprecated, and will cease to function with the next version of webwork2 and pg.  Instead use includePGproblem.  The macro to load to use that method is PGstandard.pl.  To use that to obtain a random problem use

DOCUMENT();

@choices = ('DerivateEasy/enkelt1.pg', 'DerivateEasy/enkelt3.pg', 'DerivateEasy/enkelt4.pg', 'DerivateEasy/enkelt5.pg');
includePGproblem(list_random(@choices));

ENDDOCUMENT;

You should check the paths of those files though.  Are those relative to the courses templates directory?  If they are not that won't work for either the unionInclude.pg macro or with the includePGproblem method.

### Re: Problems not rendering after upgrade to 2.17

by Glenn Rice -
I just put in a pull request to fix the macro so it will continue to work with the next release of webwork and pg. However, it still should not be used. The macro is deprecated. Everything it does can be obtained using core functionality.

### Re: Problems not rendering after upgrade to 2.17

by Lukas Fredriksson -

Thank you both for your responses! I've restarted apache but have not tried to change the deprecated macro and yes, the path is correct.

The strange thing is that some of those random problems work while some doesn't. Will change the macro and come back if I still have issues!

### Re: Problems not rendering after upgrade to 2.17

by Glenn Rice -
I don't think this is an issue with the macro. On webwork version 2.17 the macro still works fine.

This looks like a module issue, based on your errors.

What do you get when you run check_modules.pl?

### Re: Problems not rendering after upgrade to 2.17

by Glenn Rice -
I just noticed the copyright symbol in your file. That may be the problem considering that Encode is having issues. Change that to © instead, and see if that helps.

By the way, what version of WeBWorK did you upgrade from?

### Re: Problems not rendering after upgrade to 2.17

by Lukas Fredriksson -
check_modules.pl says everything is found and loaded.

I included two different problems here, still being randomized using the code we had in my example above. This first one is NOT working:

DOCUMENT(); # Load whatever macros you need for the problem loadMacros("PGstandard.pl",            "MathObjects.pl",           ); ## Do NOT show partial correct answers $showPartialCorrectAnswers = 0; TEXT(beginproblem());$A = random(1,9,1); BEGIN_TEXT Bestäm derivatan till funktionen $$f(x) = \ln(x^2+{A})$$ $PAR$PAR $$f'(x) =$$ \{ans_rule(20) \} $PAR END_TEXT$ans = Compute("2*x/(x**2+${A})"); ANS($ans->cmp); ENDDOCUMENT(); 

And this second one is working just fine:

DOCUMENT();# Load whatever macros you need for the problemloadMacros("PGstandard.pl",           "MathObjects.pl",          );## Do NOT show partial correct answers$showPartialCorrectAnswers = 0;TEXT(beginproblem());$A = random(2,5,1);$B = random(1,5,1);BEGIN_TEXTBestäm derivatan till funktionen $$f(x) = \sin({A} x-{B})$$$PAR$PAR$$f'(x) =$$ \{ans_rule(20) \}$PAREND_TEXT$ans = Compute("${A}*cos(${A}*x-${B})");ANS(\$ans->cmp);ENDDOCUMENT();

### Re: Problems not rendering after upgrade to 2.17

by Glenn Rice -

Both problems seems to work fine for me.  Even if included via includeRandomProblem of unionInclude.pg.

I don't think it is the problems or the macro.  Except possible the copyright symbol.  Does one of those have the copyright symbol in the top part of the file and the other not?  Your first post included the following

# Copyright © 2000-2003 The WeBWorK Project, http://openwebwork.sf.net
If not there is something else going on with your setup here.

### Re: Problems not rendering after upgrade to 2.17

by Lukas Fredriksson -
Yes they both include the copyright symbol. I upgraded from 2.15 to 2.17, doing all the steps in the guide to upgrade from 2.15 to 2.16 as well.
The only issue encountered during our upgrade was that webwork complained about TikZImage.pg not being found, so I downloaded it from 2.16. We don't use TikZ though.

### Re: Problems not rendering after upgrade to 2.17

by Glenn Rice -

Did you try changing that copyright symbol to &copy; to see if that helps anyway?  I would be surprised if it didn't cause an issue.

### Re: Problems not rendering after upgrade to 2.17

by Lukas Fredriksson -
So I did some testing, both writing the problem directly without randomizing and copying one of the working files and changing the text so that it matched one of the non-working. Both of these methods worked.

That made me think that there had to be some problem with the encoding, and sure enough the problems that didn't work had CRLF line terminators while the working problems didn't.

So after changing encoding to just UTF-8 Unicode text the other problems also work!

Have to try this on our production server as well but it seems like this solves the issue.

Thank you for all the help!

### Re: Problems not rendering after upgrade to 2.17

by Lukas Fredriksson -
This problem with the line endings, is this a common issue as well? Should this even be an issue or could there be something else broken with my installation?