## WeBWorK Problems

### Problems using parserMultiAnswer.pl in problem pieces loaded via includePGproblem into a single problem

by Nathan Wallach -
Number of replies: 4

Some locally developed problems are coded as "problem pieces" which are then loaded via a control PG file using includePGproblem(). The typical usage case is a set of several possible options for each part of a question, which are easy to maintain as single files (rather than inside one large file which selects each case from a long list).

This approach works well in some settings, but fails when multiple "problem pieces" need to use parserMultiAnswer.pl.

When 2 "problem pieces" both use MultiAnswer, trying to load the control file leads to Apache using huge amounts of CPU and RAM and failing to respond.

From this it seems that there is some problem using MultiAnswer in problems loaded via includePGproblem() from different files.

A set of sample file is attached which is just a trivial problem which uses MultiAnswer to grade 2 input boxes together, and given twice to trigger the error. When test2.pg is loaded after test1.pg by load_pair.pg the issue hits, and the server thrashes. Replacing test2.pg by test2b.pg which does not use MultiAnswer bypasses the problem, but fails to provide the intended behavior.

Hopefully there is some method to avoid the issue.

### Re: Problems using parserMultiAnswer.pl in problem pieces loaded via includePGproblem into a single problem

by Davide Cervone -

It turns out that the loading of parserMultiAnswer.pl twice in a single problem is the source of the issue, and the problem occurs during the _parserMultiAnswer_init. This is where the MultiAnswer() function is defined, and it seems that there is a conflict with making that definition if the MultiAnswer package is already in place. So one solution is to rename the MultiAnswer package to parser::MultiAnswer This requires two lines to be changed in parserMultiAnswer.pl: the MultiAnswer->new() call in the _parserMultiAnswer_init() function, and the package MultiAnswer a few lines later. Once these are changed, the two problems load successfully for me.

### Re: Problems using parserMultiAnswer.pl in problem pieces loaded via includePGproblem into a single problem

by Nathan Wallach -

Davide - Thanks.

This suggested patch certainly solves the problem.

I was stumped as to why it was failing.

Will you make a PR or would you like me to do so?

### Re: Problems using parserMultiAnswer.pl in problem pieces loaded via includePGproblem into a single problem

by Davide Cervone -
> I was stumped as to why it was failing.

I still don't know exactly why this is a problem, but that does seem to be the issue.

> Will you make a PR or would you like me to do so?

Would you be willing to do it? If you wait for me, it may be a while. I'm swamped trying to get things done before school begins and I start teaching remotely (all new for me).