WeBWorK Problems

Answer boxes for limits of integration / fractions / etc

by Ryan Maccombs -
Number of replies: 2
I recently have been playing around with modifying the css in WW problems to make answer boxes appear smaller or as limits of integration and as part of fractions. Perhaps this is old news but I couldn't find it on the forums anywhere so I thought I would share.

This seems to work in all major browsers and looks decent even in hard copies. I have posted the PGML code below:

DOCUMENT();

"PGstandard.pl",
"MathObjects.pl",
"PGML.pl",);

Context("Numeric")->flags->set(
reduceConstants => 0,
reduceConstantFunctions => 0,);
Context()->variables->set(t => {limits => [0,1]});

Parser::Number::NoDecimals;

$a = Formula("0");$b = Formula("pi/3");
$soln = Formula("1/2*((9*cos(t))**2 - (1+cos(t))**2)"); BEGIN_PGML [@ MODES(HTML=>"<style> a.btn.codeshard-btn {display:none; } .codeshard {border-radius:4px !important;}</style>", TeX=>"") @]* [@ MODES(HTML=>"<style> #AnSwEr0001 {padding:0px; padding-top:-5px; padding-left: 2px; margin-bottom:-10px; margin-top:35px; margin-left:-11px; max-width:24px !important; font-size:8pt; height:16px !important;}</style>", TeX=>"") @]* [@ MODES(HTML=>"<style> #AnSwEr0002 {padding:0px; padding-top:-5px; padding-left: 2px; margin-bottom:35px; margin-left:-23px; max-width:24px !important; font-size:8pt; height:16px !important;}</style>", TeX=>"") @]* On a piece of paper sketch the cardioid [r_1 = 1+\cos\theta] and the circle [r_2=3\cos\theta]. Set up an integral that represents the area of the region in the *_first quadrant_* that is inside the circle but outside the cardioid. [\text{Area} = \int] [_]{$a}{1} [_]{$b}{1} [_]{$soln}{30} [\; dt]

*Notes:* Use [t] in place of [\theta]. You do not have to evaluate this integral!
END_PGML
ENDDOCUMENT();

In reply to Ryan Maccombs

Re: Answer boxes for limits of integration / fractions / etc

by Sean Fitzpatrick -
That first line after BEGIN_PGML works perfectly to hide MathView in cases where it shouldn't be there. Thanks for this.
Any thoughts on how to get it to work with older problems written in PG?

I experimented with adding the same line after BEGIN_TEXT in a true/false problem written in PG. It disables the button, but it also leaves an artifact in the text of the problem. (Part of the code remains visible.)

Probably the right answer is to use PGML exclusively. But there are some good matrix problems in the OPL that would take some work to convert.
In reply to Ryan Maccombs

Re: Answer boxes for limits of integration / fractions / etc

by Nathan Wallach -
I really liked this approach, but once we started using MathQuill for live rendering of answers (a feature added in WW 2.15), I had problems as the layout did not work when MathQuill is enabled.

I found an approach which seems to work well both with MathQuill on and off. See:  https://webwork.maa.org/moodle/mod/forum/discuss.php?d=4767#p14157

My problems are not using PGML, but the technique should hopefully work, or just use BEGIN_TEXT and END_TEXT to handle the blocks which use the "old" PG syntax.

Nathan