Miscellaneous

This bug is even more interesting than the last one!

This bug is even more interesting than the last one!

by joel robbin -
Number of replies: 7
The attached .pg file almost works, but the strings in the popup menu bear no relation to the strings in the code.
The code looks something like this:

$a1="\(A=A+0\) with \(A=b\)";
$a2="\(A+(-A)=0\) with \(A=a\)";
$a3="\(A+(B+C)=(A+B)+C\) with \(A=b\), \(B=a\), \(C=-a\)";
$a4="the hypothesis that \(b+a=0\)" ;
$a5=" \(0+A=A\) with \(A=-a\)" ;
$popupA1 = PopUp(["?", $a1,$a2,$a3,$a4,$a5, ],$a1);
.....

\{row("(1)", "$SP3\(b =b+0\)",$popupA1->menu() )\}

...


ANS( $popupA1->cmp() );

I recognize the strings in the popup menu.
They appeared in another problem I wrote.
I suppose that the problem has to do with the fact
that there is TeX code embedded in the strings;
perhaps the WeBWorK interpolations doesn't reach.
In reply to joel robbin

Re: This bug is even more interesting than the last one!(oops)

by joel robbin -
Oops -- The strings that appear in the popup menu are the strinf in the code. It's just that the interpolation didn't occur as I had expected.
In reply to joel robbin

Re: This bug (Apologies for the wasted electrons.)

by joel robbin -
I have since discovered that I can get the images into the popup menu with the code

$a1= EV3("\(A=A+0\) with \(A=b\)");
$popupA1 = PopUp(["?", $a3,$a2,$a5,$a1,$a4 ],$a1);

instead of

$a1= "\(A=A+0\) with \(A=b\)";
$popupA1 = PopUp(["?", $a3,$a2,$a5,$a1,$a4 ],$a1);

But of course the comparison code

ANS( $popupA1->cmp() );

does not work.
In reply to joel robbin

Re: This bug (Apologies for the wasted electrons.)

by Davide Cervone -
I'm surprised you were able to get images into the menu. That will be browser-dependent, and will not work on all browsers. The PopUp object will not be able to do what you require, and I doubt you would be able to get math into the menus without going to a JavaScript-based menu system (rather than the native browser menus used by PopUp).

Davide
In reply to Davide Cervone

Re: This bug is version dependent

by joel robbin -
The attached file does not work correctly on the system
on our computer but works correctly on

http://hosted2.webwork.rochester.edu/webwork2/wikiExamples/MathObjectsLabs2/2/?login_practice_user=true

I presume the two computers are running different versions of WeBWorK. How can I know which version is running on my computer?

(The bug occurs when you answer the 5 popup questions correctly.
On our computer the 5th question (and only the 5th question)
generates an error message.
In reply to joel robbin

Re: This bug is version dependent

by joel robbin -
I think I found the bug. If a string in an argument to PopUp()
contains a leading blank the error message is produced.
Thus

$A=" one";
$B="two";
$p=PopUp(['?',$A,$B],$A);

fails but


$A="one";
$B="two";
$p=PopUp(['?',$A,$B],$A);

works
In reply to joel robbin

Re: This bug is version dependent

by Davide Cervone -
Can you be more specific about the error message produced?

It's true that MathObject strings should not include leading spaces, since spaces are skipped in the parsing process. I'll have to modify PopUp to trim them, and Context()->strings->add to report the problem.

Davide
In reply to Davide Cervone

Re: This bug is version dependent

by joel robbin -
At the moment I got the PopUp s to work by using very bland strings. No leading blanks, nothing like a^{-1} or $SPACE or \( or \cdot. I guess it's good enough for my purposes. If the strings
in the call

$apop1=PopUp(['?',$arX1,$arX2,$arX3,$arX4,$arX5,$none],$arX1);

are not bland the messages column that appears when the "Check answers" button is clicked will contain something like

Your answer should be one of By A=A+0 with A=b, ?, By 0+A=A with A=-a, By A+(-A)=0 with A=a, By A+(B+C)=(A+B)+C with A=b , B=a , C=-a, By the hypothesis that b+a=0 or None of the above

The strings that appear in this message are the values of the variables $arX1 ... $arX5, $none. I got the message to appear by putting a leading blank in one of the strings.