I made a version of your problem, pasted below). Overall, we (the WeBWorK community) have a problem in that so much of the OPL and even the wiki demonstrates old (or in some cases bad) coding techniques. And then these things propagate when people naturally use them for templates.
The main things I changed are:
- eliminated stuff from your preamble that is not used
- switched from the TEXT method of problem statement to PGML
- condensed the code for your multians
I also made some cosmetic changes.
I did not have the image file that this uses, so I'm not sure what that looks like. But one more thing I might have changed would be to draw that image directly using tikz. As of WW 2.16 it is possible to do that. It's nice to not have to manage separate image files that pair with a problem file.
Either way, you should write some alt text for the image. As of WW 2.16, you can add alt text in a straightforward way as I put in the code below.
Lastly, I think that in your setup with the definitions of $F1 through $MRz, you may have some unnecessary things in there. But I didn't want to think too hard about what I could cut.
DOCUMENT();
loadMacros(
"PGstandard.pl", # Standard macros for PG language
"MathObjects.pl",
"parserMultiAnswer.pl",
"PGML.pl",
"PGcourse.pl",
);
Context("Numeric");
Context()->flags->set(
tolerance => .01, # the relative or absolute tolerance
);
##############################################################
# Setup
#
$F1 = random(150, 450, 75);
$F2x = random(-100, -300, 50);
$F2y = random(200, 500, 100);
$F2z = random(-200, -500, 100);
$F3 = random(350, 600, 50);
$d1 = random(4, 6, .5);
$d2 = random(2, 3, .5);
$d3 = random(2, 3, .5);
$FRx = Compute("($F2x)");
$FRy = Compute("$F3+$F2y");
$FRz = Compute("$F2z-$F1");
$MRox = Compute("(-($d1*$F1)+($d1*$F2z))");
$MRx = -$MRox;
$MRoy = Compute("-($d2*$F2z)");
$MRy = -$MRoy;
$MRoz = Compute("((-$d1*$F2x+$d2*$F2y)+$d2*$F3)");
$MRz = -$MRoz;
$multians = MultiAnswer($MRox, $MRoy, $MRoz)->with(
singleResult => 0,
checker => sub {
my ( $correct, $student, $self ) = @_;
# Figure out which ones are correct
$return = [
$correct->[0] == $student->[0],
$correct->[1] == $student->[1],
$correct->[2] == $student->[2]
];
# Special feedback
if (-$correct->[0] == $student->[0] &&
-$correct->[1] == $student->[1] &&
-$correct->[2] == $student->[2])
{
for my $i (1,2,3) {$self->setMessage($i,"Your frame of reference was backwards, the components of your moment have the wrong sign");}
} else {
for my $i (1,2,3) {$self->setMessage($i,"Check the sign of your answer") if (-$correct->[$i-1] == $student->[$i-1]);}
}
# Return results
return $return;
}
);
##############################################################
# Statement
#
BEGIN_PGML
Replace the force system by an equivalent resultant force and moment at point [`O`]
where [`F_1`] is [`[$F1]\,\text{lbs}`], [`F_2`] is
[`\left([$F2x]\hat{\imath} + [$F2y]\hat{\jmath} + [$F2z]\hat{k}\right)\,\text{lbs}`],
[`F_3`] is [`[$F3]\,\text{lbs}`], and
[`d_1`] is [`[$d1]\,\text{ft}`],
[`d_2`] is [`[$d2]\,\text{ft}`], and
[`d_3`] is [`[$d3]\,\text{ft}`].
>> [@image( "Q4.jpg", width => 500, height => 500, tex_size => 700, alt => 'some alt text here')@]* <<
The moment about point [`O`] is
[`\Big(`][_]{$multians}{10}[`\hat{\imath}+{}`]
[_]{$multians}{10}[`\hat{\jmath}+{}`]
[_]{$multians}{10}[`\hat{k}\Big)\,\text{lbs}\cdot\text{ft}`].
END_PGML
ENDDOCUMENT();