WeBWorK Main Forum

Issues when creating hardcopy

Issues when creating hardcopy

by Robert Mařík -
Number of replies: 1

Hello all, my students found two issues when converting homeworks with filled answers to PDF

1. When using PGchoicemacros.pl the student answers are converted into argument of LaTeX verb macro and the begin and end is separated by char 128. However, this char makes troubles in UTF-8. See for example https://perldoc.perl.org/functions/chr which states "Note that characters from 128 to 255 (inclusive) are by default internally not encoded as UTF-8 for backward compatibility reasons." I resolved the issue by changing in pg/macros/PGstringevaluators.pl line

my $rh_hash = shift; my $c = chr(128); ## something that won't be typed 

to

my $rh_hash = shift; my $c = '|'; ## something that won't be typed

having in mind that the character | will not be used in my problems.

2. The answer to essay question is formatted as math formula. I resolved the issue by wrapping with minipage. I changed

'preview_latex_string'=>$answer_value,

in pg/macros/PGessaymacros.pl

to

'preview_latex_string'=>'\begin{minipage}{0.7\hsize}'.$answer_value.'\end{minipage}',

Just a fast solutions. I am sure that there are better fixes .

Thank you for working on  webwork. Robert Marik

In reply to Robert Mařík

Re: Issues when creating hardcopy

by Glenn Rice -

For 1, I have a branch I should submit that has a better fix for that I think.  Instead change that line to

my $c = MODES(HTML => chr(0x1F), TeX => chr(0xD), PTX => chr(0xD));

(note that in the develop branch that part is on its own line without the "my $rh_hash = shift" part).

Thanks for pointing out the issue with essay questions.  I will look into that.