## WeBWorK Problems

### Randomization button fails: "434 setmaker.js: /webwork2/instructorXMLHandler: Forbidden"

by Keir Lockridge -
Number of replies: 9

Hello,

I'm writing my first WW problem (a work in progress; see below) and it seems to work ok, but for some reason when I try to click on the "Randomize" link when viewing the problem in the library browser I get an error:

"434 setmaker.js: /webwork2/instructorXMLHandler: Forbidden"

I can use the "Randomize" link for other problems in the library, but not for this one. I can get WW to generate various randomizations of the problem by editing the problem and using the view option (where you can specify a seed).

Does anyone know why I'm earning the warning above? Thanks!

--Keir

(I'm also happy to hear from anyone who wants to tell me how to better construct this problem.)

#########

DOCUMENT();
"PGstandard.pl",
"MathObjects.pl",
"PGML.pl",
"PGcourse.pl",
"contextFraction.pl",
"parserPopUp.pl",
);

$showPartialCorrectAnswers = 1; TEXT(beginproblem()); Context("Fraction-NoDecimals");$b = non_zero_random(-6,6);
$d = non_zero_random(-6,6); do {$a = non_zero_random(-6,6);
$c = non_zero_random(-6,6); } until$c != $a; Context()->variables->add(k=>"Real"); Context()->variables->add(h=>"Real"); Context()->variables->add(y=>"Real");$k_cutoff = Formula("$a *$d / ($c *$b)")->reduce();
$h_cutoff = Formula("$k_cutoff / (1 - $c /$a)")->reduce();

$popEQ = PopUp(["select","=","≠"], "=");$popNEQ = PopUp(["select","=","≠"], "≠");

$LHS1 = Formula("$a * x + $b *k* y")->reduce();$LHS2 = Formula("$c * x +$d * y")->reduce();

BEGIN_PGML

Consider the linear system [\begin{array}{rl}[$LHS1] &= h \\[$LHS2] &= h -k \\\end{array}] In the parts below, if you think that [h] can be any real number, then input [h = ] ANY.

(a) Find all values of [k] and [h] so that the system has no solution.

[k] [@ $popEQ->menu() @]* [_____] and [h] [@$popNEQ->menu() @]* [_____]

(b) Find all values of [k] and [h] so that the system has a unique solution.

[k] [@ $popNEQ->menu() @]* [_____] and [h] [@$popEQ->menu() @]* [_____]

(c) Find all values of [k] and [h] so that the system has infinitely many solutions.

[k] [@ $popEQ->menu() @]* [_____] and [h] [@$popEQ->menu() @]* [_____]

END_PGML

ANS($popEQ->cmp()); ANS($k_cutoff->cmp());
ANS($popNEQ->cmp()); ANS($h_cutoff->cmp());

ANS($popNEQ->cmp()); ANS($k_cutoff->cmp());
ANS($popEQ->cmp()); Context()->strings->add(ANY=>{}); ANS(String("ANY")->cmp()); ANS($popEQ->cmp());
ANS($k_cutoff->cmp()); ANS($popEQ->cmp());
ANS($h_cutoff->cmp()); # For the solution.$b2 = Formula("($b/$a)*k")->reduce();
$d2 = Formula("$d - ($c *$b/$a)*k")->reduce();$aug1 = Formula("h/$a")->reduce();$aug2 = Formula("(1 - [$c]/[$a])*h - k")->reduce();
$sf = Formula("1/[$a]")->reduce();

BEGIN_PGML_SOLUTION

The augmented matrix for the given linear system is [\left[ \begin{array}{rrr} [$a] & [$b]k & h \\ [$c] & [$d] & h - k \end{array}\right].]

We may row reduce the matrix to obtain (e.g., scale the top row [R_1] by [[$sf]], then replace the second row [R_2] with [R_2 - ([$c])R_1]): [\left[ \begin{array}{rrr} 1 & [$b2] & [$aug1] \\ 0 & [$d2] & [$aug2] \end{array}\right].]

If [[$d2] \neq 0] ([k \neq [$k_cutoff]]), then the system will be consistent for any value of [h]. If [[$d2] = 0] ([k = [$k_cutoff]]), then the system  has infinitely many solutions if [[$aug2] = 0] ([h = [$h_cutoff]]) and has no solutions (is inconsistent) if [[$aug2] \neq 0] ([h \neq [$h_cutoff]]).

END_PGML_SOLUTION

ENDDOCUMENT();

### Re: Randomization button fails: "434 setmaker.js: /webwork2/instructorXMLHandler: Forbidden"

by Danny Glin -

I have come across this issue with other problems (e.g. Library/TCNJ/TCNJ_MatrixInverse/problem1.pg).  It also occurs if you try to render the problem in the Homework Sets Editor.  I haven't had the time to try to hunt down the cause, as the workaround you mention is available.  The reason that the error only shows up in these scenarios is that in these cases there is javascript dynamically rendering a problem within a page, as opposed to the problem being rendered in advance of the page being served.

I suspect that it has something to do with an extended character appearing somewhere in the problem, but that could be way off.

I realize that this doesn't solve your issue, but I'm posting it in the hope that it helps someone properly narrow down the cause of the issue.

### Re: Randomization button fails: "434 setmaker.js: /webwork2/instructorXMLHandler: Forbidden"

by Keir Lockridge -

Thank you for the reply! So: as long as it correctly randomizes when I edit the problem and use the view option (where you specify a seed), then I can assume it will correctly randomize the problem for students. Is that correct?

### Re: Randomization button fails: "434 setmaker.js: /webwork2/instructorXMLHandler: Forbidden"

by Nathan Wallach -
Yes. If changing the seed gets the randomization to work, then it works fine.

### Re: Randomization button fails: "434 setmaker.js: /webwork2/instructorXMLHandler: Forbidden"

by Nathan Wallach -

This sounds like to issue with UTF-8 and XMLRPC which can be fixed by patching /usr/share/perl5/XMLRPC/Lite.pm to support UTF-8 text. AFAIK the "not equals" symbol (used in the PopUp) requires UTF-8 which is the apparent trigger.

 The patch replaces line 55 of /usr/share/perl5/XMLRPC/Lite.pm which originally was: base64 => [10, sub {$_[0] =~ /[^\x09\x0a\x0d\x20-\x7f]/}, 'as_base64'], with the following replacement line: base64 => [10, sub {$_[0] =~ /[^\x09\x0a\x0d\x20-\x7f]/ && !utf8::is_utf8(\$_[0])}, 'as_base64'], 

### Re: Randomization button fails: "434 setmaker.js: /webwork2/instructorXMLHandler: Forbidden"

by Keir Lockridge -
I did the patch and restarted my webservers. Now when I hit the randomize button I get ... quite an error message (see below). Perhaps I can try to avoid the not equals sign.

--Keir

WebworkClient Errors
Errors:
------The current problem set number setNumber is not defined
------The current problem number probNum is not definedinternal_debug_messagescourseIDmath212f2012WARNINGSV0FSTklOR1MKCjxici8+TW9yZTxici8+Cg== at /opt/webwork/webwork2/lib/WebworkClient.pm line 302.

End Errors
WeBWorK error
An error occured while processing your request. For help, please send mail to this site's webmaster (webmaster@localhost), including all of the following information as well as what what you were doing when the error occured.

Thu Jun 11 14:17:02 2020

Warning messages
Error messages
xmlrpcCall to renderProblem returned no result for
Call stack
The information below can help locate the source of the problem.

in WeBWorK::ContentGenerator::instructorXMLHandler::content called at line 233 of /opt/webwork/webwork2/lib/WeBWorK/ContentGenerator.pm
in WeBWorK::ContentGenerator::go called at line 386 of /opt/webwork/webwork2/lib/WeBWorK.pm
Request information
Method POST
URI /webwork2/instructorXMLHandler
Sec-Fetch-Dest empty
X-Requested-With XMLHttpRequest
Accept-Language en-US,en;q=0.9
Connection keep-alive
Accept */*
Content-Type application/x-www-form-urlencoded; charset=UTF-8
Accept-Encoding gzip, deflate, br
Content-Length 390

### Re: Randomization button fails: "434 setmaker.js: /webwork2/instructorXMLHandler: Forbidden"

by Nathan Wallach -
We are making progress - as the error is now occurring somewhere else, and the message jogged my memory.

You can probably avoid the issue by not using "not equals" or any other UTF-8 as part of an answer... but PopUp will not allow you to use "math" inside the options.

I hope we can instead find the "fixes" you need to solve the problem - and that it will help make sure that the future WW 2.16 (if not 2.15) is really ready for UTF-8 without all these bugs. (It will still probably require the manual patch to Lite.pm as part of the installation procedure.)

UTF-8 support in WW was only added in WW 2.15, and there were issues none of us found during the testing before WW 2.15 was released. For a good while, I was aware that some problems could not be loaded in the library browser or via html2xml in general, but discovering why and finding a fix was quite challenging. We also told students not to use images mode due to one of the issues (see below). I hope that the patches discussed below also fixed the issue you are encountering now.

The "not well-formed (invalid token)" issue seems to have been related to problems where the correct/student answers could contain UTF-8 strings, as the "XMLRPC" system was not properly encoding strings deep inside the data it was passing, in particular for "answer" strings which contained UTF-8 characters. The "not equals" sign would almost certainly trigger that problem (in html2xml and apparently for the "randomization" button).

If my analysis is correct, then I hope that the changes made in the pull request https://github.com/openwebwork/webwork2/pull/1089 which had been merged into the develop branch will solve the problem you are having. I have been using that patched code for a good while, and it seems to solve the issues I had before with some problems in the library browser and with the same problems embedded via html2xml which I ran into before the changes.

Also there was a second issue with UTF-8 answers discussed in https://github.com/openwebwork/pg/issues/443 and likely to effect your problems. The second  issue was a failure to generating the answer table in "images" mode for cases like this. Students would only get an error page and not the feedback, etc. Davide Cervone proposed a fix, and Mike made the fix in https://github.com/openwebwork/pg/pull/466 which is also only in "develop" and not WW 2.15. Since that issue will effect such problems when used by students, if they change to using "images" mode for equation display - it is also something you probably want to consider patching on your system.

Sorry, I should have recalled both these issues when I posted my first response. Hopefully, we will not discover another problem later on.

Nathan

### Re: Randomization button fails: "434 setmaker.js: /webwork2/instructorXMLHandler: Forbidden"

by Keir Lockridge -

Would you advise me to avoid not equals for now and wait for 2.16, or try to install these patches? (I'm content with something like "!=" for now.)

Thanks to you and all the others who are doing the development work!

### Re: Randomization button fails: "434 setmaker.js: /webwork2/instructorXMLHandler: Forbidden"

by Nathan Wallach -
If you have time - help testing patches/development code is always a contribution which helps the project and the community.

I tested the Library browser randomize button with your problem on my laptop which is running some version of the development code, and it worked for me. That is a pretty good indication that the patch mentioned above should solve your problem, so it is likely to just work once WW 2.16 gets released. However, there are plenty of other changes in the develop branch, so it could be some other commit/PR was also part of what fixed the issue. Testing with just the PR 1089 changes would narrow down what the issue and fix is.