Sorry if this problem is better suited for the WeBWorK forum, but I can only produce this issue once the question is in PreTeXt.
One of the users of APEX Calculus reported that this question is not being graded correctly:
https://opentext.uleth.ca/apex-calculus/sec_limits_one_sided.html#ex-limit-onesided-use-graph-4
I can confirm that sometimes it works, but clicking the randomize button produces versions where the answers to parts (a) and (b) are swapped, or parts (b) and (d), etc.
In other words, between parts (a), (b), and (d), the answers that are marked correct come from some permutation of the correct answers.
Below is both the PreTeXt source, and the WeBWorK code that PreTeXt generates for this problem. I've put the WeBWorK code on the server being used for this problem, and I've tried about 30 different random seeds, and they all worked correctly.
In summary: I can't reproduce the bug by running the generated .pg file on WeBWorK. But when I activate the problem in PreTeXt, the answers are mixed up about 80% of the time.
This makes me think it's a PreTeXt problem and not a WeBWorK problem.
PreTeXt souce:
<exercise label="ex-limit-onesided-use-graph-4">
<webwork xml:id="webwork-ex-limit-onesided-use-graph-4">
<pg-code>
Context()->strings->add('does not exist'=>{alias=>'DNE'});
@x=num_sort((0,random_subset(2,1..5)));
@y=random_subset(3,1..5);
($w,$z)=random_subset(2,1..$y[1]-1,$y[1]+1..5);
if($envir{problemSeed}==1){@x=(0,1,2);@y=(1,0,2);$z=2;$w=1;};
$a=$x[1];
$f=Formula("($z-$y[0])/($x[1]-$x[0])*(x-$x[0])+$y[0]");
$g=Formula("($y[2]-$y[1])/($x[2]-$x[1])^2*(x-$x[1])^2+$y[1]");
$xmin=min(0,@x)-1;$xmax=max(0,@x)+1;$ymin=min(0,@y,$z,$w)-1;$ymax=max(0,@y,$z,$w)+1;
@L=($z,$y[1],Compute("DNE"),$w);
</pg-code>
<introduction>
<image>
<description>
<p>
Graph that shows the domain <m><var name="$x[0]]"/></m> to <m><var name="$x[2]"/></m>. There
are two lines on the graph. The first is defined by the solid
point <m>(<var name="$x[0]"/>, <var name="$y[0]"/>)</m> and hollow
point <m>(<var name="$x[1]"/>, <var name="$y[1]"/>)</m>. The second
is defined by the hollow point <m>(<var name="$x[1]"/>, <var name="$z"/>)</m>
and solid point <m>(<var name="$x[2]"/>, <var name="$y[2]"/>)</m>. There
is also a solid point at <m>(<var name="$x[1]"/>, <var name="$w"/>)</m>.
The first line is straight while the seconds line is curved.
</p>
</description>
<shortdescription>
Graph for exercise problem 8.
</shortdescription>
<latex-image>
\begin{tikzpicture}
\begin{axis}[
xmin = $xmin,
xmax = $xmax,
ymin = $ymin,
ymax = $ymax,
]
\addplot[firstcurvestyle, domain=$x[0]:$x[1]] {$f};
\addplot[firstcurvestyle, domain=$x[1]:$x[2]] {$g};
\addplot[soliddot] coordinates {($x[0],$y[0]) ($x[1],$w) ($x[2],$y[2])};
\addplot[hollowdot] coordinates {($x[1],$y[1]) ($x[1],$z)};
\end{axis}
\end{tikzpicture}
</latex-image>
</image>
<instruction>
If you need to enter <m>\infty</m>, you may type <c>infinity</c>, or just <c>INF</c>.
If the limit does not exist, you may type <c>does not exist</c>, or just <c>DNE</c>.
</instruction>
</introduction>
<task label="ex-limit-onesided-use-graph-4a">
<statement>
<p>
<m>\lim\limits_{x\to <var name="$a"/>^-} f(x)</m>
</p>
<p>
<var name="$L[0]" width="10"/>
</p>
</statement>
</task>
<task label="ex-limit-onesided-use-graph-4b">
<statement>
<p>
<m>\lim\limits_{x\to <var name="$a"/>^+} f(x)</m>
</p>
<p>
<var name="$L[1]" width="10"/>
</p>
</statement>
</task>
<task label="ex-limit-onesided-use-graph-4c">
<statement>
<p>
<m>\lim\limits_{x\to <var name="$a"/>} f(x)</m>
</p>
<p>
<var name="$L[2]" width="10"/>
</p>
</statement>
</task>
<task label="ex-limit-onesided-use-graph-4d">
<statement>
<p>
<m>f(<var name="$a"/>)</m>
</p>
<p>
<var name="$L[3]" width="10"/>
</p>
</statement>
</task>
</webwork>
</exercise>
WeBWorK source:
#############################################
### Generated from PreTeXt source
### on 2025-12-12T19:03:05Z
### A recent stable commit (2022-07-01):
### 6c761d3dba23af92cba35001c852aac04ae99a5f
###
### https://pretextbook.org
###
#############################################
## DBsubject()
## DBchapter()
## DBsection()
## Level()
## KEYWORDS()
## TitleText1()
## EditionText1()
## AuthorText1()
## Section1(not reported)
## Problem1(1.4.8)
## Author()
## Institution()
## Language(en-US)
DOCUMENT();
############################################################
# Load Macros
############################################################
loadMacros(
"PGstandard.pl",
"PGML.pl",
"scaffold.pl",
"AnswerFormatHelp.pl",
"PGlateximage.pl",
"PCCmacros.pl",
"contextForm.pl",
"APEX.pl",
"PGcourse.pl",
);
COMMENT('Authored in PreTeXt');
COMMENT('This problem is scaffolded with multiple parts');
############################################################
# Header
############################################################
TEXT(beginproblem());
############################################################
# PG Setup Code
############################################################
Context()->strings->add('does not exist'=>{alias=>'DNE'});
@x=num_sort((0,random_subset(2,1..5)));
@y=random_subset(3,1..5);
($w,$z)=random_subset(2,1..$y[1]-1,$y[1]+1..5);
if($envir{problemSeed}==1){@x=(0,1,2);@y=(1,0,2);$z=2;$w=1;};
$a=$x[1];
$f=Formula("($z-$y[0])/($x[1]-$x[0])*(x-$x[0])+$y[0]");
$g=Formula("($y[2]-$y[1])/($x[2]-$x[1])^2*(x-$x[1])^2+$y[1]");
$xmin=min(0,@x)-1;$xmax=max(0,@x)+1;$ymin=min(0,@y,$z,$w)-1;$ymax=max(0,@y,$z,$w)+1;
@L=($z,$y[1],Compute("DNE"),$w);
$image_1 = createLaTeXImage();
$image_1->addToPreamble(latexImagePreamble());
$image_1->BEGIN_LATEX_IMAGE
\begin{tikzpicture}
\begin{axis}[
xmin = $xmin,
xmax = $xmax,
ymin = $ymin,
ymax = $ymax,
]
\addplot[firstcurvestyle, domain=$x[0]:$x[1]] {$f};
\addplot[firstcurvestyle, domain=$x[1]:$x[2]] {$g};
\addplot[soliddot] coordinates {($x[0],$y[0]) ($x[1],$w) ($x[2],$y[2])};
\addplot[hollowdot] coordinates {($x[1],$y[1]) ($x[1],$z)};
\end{axis}
\end{tikzpicture}
END_LATEX_IMAGE
############################################################
# Body
############################################################
BEGIN_PGML
Evaluate each expression using the given graph of [`f\text{.}`]
>> [@image(insertGraph($image_1), width=>600, alt=>qq"Graph for exercise problem 8.")@]* <<
[@KeyboardInstructions('If you need to enter [`\infty\text{,}`] you may type [|infinity|]*, or just [|INF|]*. If the limit does not exist, you may type [|does not exist|]*, or just [|DNE|]*.')@]**
END_PGML
############################################################
# Scaffold
############################################################
Scaffold::Begin(numbered => 1,is_open => "correct_or_first_incorrect",can_open => always,);
############################################################
# Section
############################################################
Section::Begin("");
BEGIN_PGML
[`\lim\limits_{x\to [$a]^-} f(x)`]
[_]{$L[0]}{10}
END_PGML
Section::End();
############################################################
# Section
############################################################
Section::Begin("");
BEGIN_PGML
[`\lim\limits_{x\to [$a]^+} f(x)`]
[_]{$L[1]}{10}
END_PGML
Section::End();
############################################################
# Section
############################################################
Section::Begin("");
BEGIN_PGML
[`\lim\limits_{x\to [$a]} f(x)`]
[_]{$L[2]}{10}
END_PGML
Section::End();
############################################################
# Section
############################################################
Section::Begin("");
BEGIN_PGML
[`f([$a])`]
[_]{$L[3]}{10}
END_PGML
Section::End();
Scaffold::End();
############################################################
# End Problem
############################################################
ENDDOCUMENT();
--
You received this message because you are subscribed to the Google Groups "PreTeXt support" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pretext-suppo...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/pretext-support/5afb77c2-fd95-445f-a958-fae138580d91n%40googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/pretext-support/62813078-5c05-4fab-a6c4-3f3b28316726n%40googlegroups.com.


To view this discussion visit https://groups.google.com/d/msgid/pretext-support/9679a143-54c4-4b1c-af08-2a58e8ae8ee2n%40googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/pretext-support/e990c68d-3b97-4f61-95e9-b7a8808875c6n%40googlegroups.com.