WeBWorK Main Forum

new_multiple_choice: can't generate hardcopy with student answer

new_multiple_choice: can't generate hardcopy with student answer

by Andras Balogh -
Number of replies: 8

When I use new_multiple_choice, for example from https://webwork.maa.org/wiki/MultipleChoiceProblems, PDF hard copy generation with students answer results in error message

Package inputenc Error: Invalid UTF-8 byte "80.
...
l.416 $\displaystyle \verb
                            B$
Without student answer there is no problem with PDF generation.

This is in v. 2.17, but as I remember I had the same problem with v. 2.16.

In reply to Andras Balogh

Re: new_multiple_choice: can't generate hardcopy with student answer

by Glenn Rice -

First, it needs to be noted that using the PGchoicemacros.pl with anything other than new_checkbox_multiple_choice is not something that you should do anymore.  The only reason for the allowance for usage of new_checkbox_multiple_choice is because there isn't a proper alternative for that with new answer checkers.  For radio answer type problems use parserRadioButtons.pl as noted on the page that you referenced.

In any case, to fix the issue on line 597 of PGstringevaluators change "my $c = chr(128);" to "my $c = MODES(HTML => chr(0x1F), TeX => chr(0xD));"

In reply to Glenn Rice

Re: new_multiple_choice: can't generate hardcopy with student answer

by Andras Balogh -

Thanks for the fix!

For the record, I was not going to write a problem myself with new_multiple_choice(). It came from the library problem MontanaState/FL/2.2B83Nested2.pg
It looks superfluous to me to have A,B,C... listed next to the options, like A. True, B. False.

 

In reply to Andras Balogh

Re: new_multiple_choice: can't generate hardcopy with student answer

by Glenn Rice -
Yeah, at some point we need to update all of the OPL problems. That is a huge project though.
In reply to Glenn Rice

Re: new_multiple_choice: can't generate hardcopy with student answer

by Cindy Loten -
I've been using PGchoicemacros.pl for the function NchooseK. Is there a comparable function that I should be using instead of NchooseK?

Thanks!
In reply to Cindy Loten

Re: new_multiple_choice: can't generate hardcopy with student answer

by Glenn Rice -

Unfortunately, there isn't a replacement for NchooseK even though it has been marked as deprecated since 2007.

In reply to Glenn Rice

Re: new_multiple_choice: can't generate hardcopy with student answer

by Cindy Loten -
Okay, I see where NchooseK is marked as deprecated in https://webwork.maa.org/pod/pg/macros/PGchoicemacros.html. Thanks for pointing this out.

Unfortunately, I was looking at info about NchooseK at https://webwork.maa.org/wiki/NchooseK


Any style hints as to what's better:
(1) keep using NchooseK
or
(2) use my own perl program to shuffle the array (0.. n-1) and then keep the first k elements of the array.
In reply to Cindy Loten

Re: new_multiple_choice: can't generate hardcopy with student answer

by Glenn Rice -
I use my own perl sub to do this when needed. However, it is okay to use NchooseK at this point. At least until there is an alternate.
In reply to Glenn Rice

Re: new_multiple_choice: can't generate hardcopy with student answer

by Alex Jordan -

It's such a useful tool that I think it should be added to PGbasicmacros.pl. If PGchoicemacros.pl is not already loading that, then it could load PGbasicmacros.pl and remove its definition of NchooseK to avoid redefinitions.