Skip to content

Commit 092447b

Browse files
authored
Merge pull request #1333 from gajennings/main
OPL problems from PR#1280. All work and all but one successfully produce hardcopies. The one that throws hardcopy errors is CollegeOfIdaho/setStatistics_Ch01PicturingDistributionsWithGraphs/01Stats_08_PictDistnsWGraphs/01Stats_08_PictDistnsWGraphs.pg but I wasn't able to find the cause of the hardcopy error.
2 parents c11528d + 52b631f commit 092447b

File tree

148 files changed

+5565
-7877
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

148 files changed

+5565
-7877
lines changed

OpenProblemLibrary/270/setzKim/p6.pg

Lines changed: 14 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -11,46 +11,27 @@
1111
## Level(2)
1212
## KEYWORDS('Average','Averages')
1313

14-
DOCUMENT(); # This should be the first executable line in the problem.
14+
DOCUMENT(); # This should be the first executable line in the problem.
1515

16-
loadMacros(
17-
"PGstandard.pl",
18-
"PGchoicemacros.pl",
19-
"PGasu.pl",
20-
"PGcourse.pl"
21-
);
16+
loadMacros('PGstandard.pl', 'PGML.pl', 'PGcourse.pl');
2217

23-
TEXT(beginproblem());
24-
25-
#
2618
# Now we do the randomization of variables, and other computations
2719
# as needed for this problem. Sometimes we compute the answers here.
28-
#
29-
30-
$a = random(1,9);
31-
$b = random(-3,2);
32-
33-
$ans1 = ($a+$b)/2;
3420

35-
#
36-
# Now the problem text itself, with ans_rule's to indicate where the
37-
# answers go. You can stop entering text, do more computations, and then
38-
# start up again if you want.
39-
#
21+
$a = random( 1, 9);
22+
$b = random(-3, 2);
4023

41-
BEGIN_TEXT
42-
What is the average of $a and $b?
43-
$PAR
44-
Average = \{ans_rule(40)\}
45-
END_TEXT
24+
$avg = ($a + $b) / 2;
4625

47-
#
48-
# Tell WeBWork how to test if answers are right. These should come in the
49-
# same order as the answer blanks above. You tell WeBWork both the type of
50-
# "answer evaluator" to use, and the correct answer.
51-
#
26+
BEGIN_PGML
27+
What is the average of [$a] and [$b] ?
5228

53-
ANS(num_cmp($ans1));
29+
Average = [_]{Real($avg)}{10}
30+
END_PGML
5431

55-
ENDDOCUMENT(); # This should be the last executable line in the problem.
32+
BEGIN_PGML_SOLUTION
33+
The average of two values is the sum divided by 2. In this case
34+
[``` \frac{[$a]+[$b]}{2} = [$avg] ```]
35+
END_PGML_SOLUTION
5636

37+
ENDDOCUMENT(); # This should be the last executable line in the problem.

OpenProblemLibrary/ASU-topics/setFinance/ch5revp1.pg

Lines changed: 25 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -11,50 +11,38 @@
1111
## Level(3)
1212
## KEYWORDS('percent', 'mathematics for business', 'algebraic expression')
1313

14-
DOCUMENT(); # This should be the first executable line in the problem.
14+
## Updated 2025.02 by Peter Staab, switch to PGML
1515

16-
loadMacros(
17-
"PGstandard.pl",
18-
"PGchoicemacros.pl",
19-
"PGasu.pl",
20-
"PGcourse.pl"
21-
);
16+
DOCUMENT();
2217

23-
TEXT(beginproblem());
18+
loadMacros('PGstandard.pl', 'PGML.pl', 'PGcourse.pl');
2419

25-
$A = random(4,20,1)*100;
26-
$b = random(2,9,1);
20+
Context('LimitedNumeric')
21+
->flags->set(tolType => 'digits', tolerance => 2, tolTruncation => 1);
2722

28-
$c = random(4,15,1);
29-
$r=$c/100;
23+
$A = random(4, 20) * 100;
24+
$b = random(2, 9);
3025

31-
$n=12*$b;
32-
$i=$r/12;
26+
$c = random(4, 15);
27+
$r = $c / 100;
3328

34-
TEXT(EV2(<<EOT));
35-
Find the principal needed to get $DOLLAR$A in $b years at $c$PERCENT
36-
compounded monthly.
37-
$BR
38-
Principal = $DOLLAR \{ans_rule(20)\}
39-
$BR
40-
EOT
29+
$n = 12 * $b;
30+
$i = $r / 12;
31+
$P = Real($A / ((1 + $i)**$n));
4132

42-
HINT(EV2(<<EOT));
43-
$BBOLD HINT: $EBOLD Use the compound interest formula \(A = P(1+i)^n \)
44-
to find \(P\).
45-
$BR
46-
$BR
47-
EOT
33+
BEGIN_PGML
34+
Find the principal needed to get $[$A] in [$b] years at [$c]% compounded monthly.
4835

49-
SOLUTION(EV3(<<'EOT'));
50-
$BBOLD SOLUTION: $EBOLD
51-
Use the compound interest formula \(A = P(1+i)^n \)
52-
with \( A= $A\), \(i = \frac{$r}{12}\), \(n=$n \)
53-
to find \(P\).
54-
EOT
36+
Principal = $[_]{$P}
37+
END_PGML
5538

56-
$ans = $A/((1+$i)**$n);
39+
BEGIN_PGML_HINT
40+
Use the compound interest formula [`A = P(1+i)^n `] to find [`P`].
41+
END_PGML_HINT
5742

58-
ANS(num_cmp($ans));
59-
60-
ENDDOCUMENT(); # This should be the last executable line in the problem.
43+
BEGIN_PGML_SOLUTION
44+
Use the compound interest formula [`A = P(1+i)^n `]
45+
with [` A= [$A]`], [`i = \frac{[$r]}{12}`], [`n=[$n] `]
46+
to find [`P`]. The result is $[@sprintf("%.2f", $P)@].
47+
END_PGML_SOLUTION
48+
ENDDOCUMENT(); # This should be the last executable line in the problem.

OpenProblemLibrary/ASU-topics/setFinance/p3st.pg

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -12,34 +12,34 @@
1212
## Level(3)
1313
## KEYWORDS('percent', 'mathematics for business', 'algebraic expression')
1414

15-
DOCUMENT(); # This should be the first executable line in the problem.
15+
## Updated 2025.02 by Peter Staab, switch to PGML and added a solution.
1616

17-
loadMacros(
18-
"PGstandard.pl",
19-
"PGchoicemacros.pl",
20-
"PGasu.pl",
21-
"PGcourse.pl"
22-
);
17+
DOCUMENT();
2318

24-
TEXT(beginproblem());
19+
loadMacros('PGstandard.pl', 'PGML.pl', 'PGcourse.pl');
20+
Context('LimitedNumeric')
21+
->flags->set(tolType => 'digits', tolerance => 3, tolTruncation => 1);
2522

26-
$P = random(1,10,1)*100;
27-
$b = random(2,18,1);
28-
if($b==12) {
29-
$b=8;
30-
}
23+
$P = random(1, 10) * 100;
24+
$b = random(2, 18);
25+
$b = 8 if ($b == 12);
3126

32-
$c = random(3,18,1);
33-
$r=$c/100;
27+
$c = random(3, 18);
28+
$r = $c / 100;
29+
$A = Real($P * (1 + $r / 12)**$b);
3430

35-
TEXT(EV2(<<EOT));
36-
Find the amount if $DOLLAR$P is invested at $c$PERCENT compounded monthly
37-
for $b months.
38-
$BR
39-
Amount = $DOLLAR \{ans_rule(20)\}
40-
EOT
41-
$ans = $P*(1+$r/12)**$b;
31+
BEGIN_PGML
32+
Find the amount if $[$P] is invested at an annual rate of [$c]% compounded monthly
33+
for [$b] months.
4234

43-
ANS(num_cmp($ans));
35+
Amount = $[_]{$A}
36+
END_PGML
4437

45-
ENDDOCUMENT(); # This should be the last executable line in the problem.
38+
BEGIN_PGML_SOLUTION
39+
For this, we will use the formula:
40+
[``` A = P (1+i)^n ```]
41+
where [`P`] is the principal (original amount), [`i`] is the compound interest rate (in this case [`[$c]/12`] and [`n`] is the number of compounding periods or [`[$b]`] in this case. The result is
42+
43+
[``` A = [$P] (1 + [$r]/12)^[$b] = [@sprintf("%.2f", $A) @] ```]
44+
END_PGML_SOLUTION
45+
ENDDOCUMENT();

OpenProblemLibrary/ASU-topics/setGraphEquations/sw2_2_18.pg

Lines changed: 90 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -11,51 +11,97 @@
1111
## Level(2)
1212
## KEYWORDS('algebra', 'coordinate', 'graph', 'intercepts')
1313

14-
DOCUMENT(); # This should be the first executable line in the problem.
14+
## Updated 2025.02 by Peter Staab, switch to PGML and add a solution
15+
16+
DOCUMENT();
1517

1618
loadMacros(
17-
"PGstandard.pl",
18-
"PGchoicemacros.pl",
19-
"PGcourse.pl"
19+
'PGstandard.pl', 'PGML.pl', 'contextFraction.pl', 'PGtikz.pl',
20+
'parserPopUp.pl', 'PGcourse.pl'
2021
);
2122

22-
TEXT(beginproblem());
23-
24-
$showPartialCorrectAnswers = 1;
25-
install_problem_grader(~~&std_problem_grader);
26-
27-
$a = random(2,20,1);
28-
$b = random(1,9,1);
29-
30-
BEGIN_TEXT
31-
For the graph of the equation \[y=$a x+$b\] draw a sketch of the graph on
32-
a piece of paper. Then answer the following questions:
33-
$BR $BR
34-
The \(x\)-intercept is : \( x = \) \{ans_rule(10)\}
35-
$BR
36-
The \(y\)-intercept is : \( y = \) \{ans_rule(10)\}
37-
$BR
38-
Is the graph symmetric with respect to the \(x\)-axis?
39-
Input $BITALIC yes $EITALIC or $BITALIC no $EITALIC here : \{ans_rule(10)\}
40-
$BR
41-
Is the graph symmetric with respect to the \(y\)-axis?
42-
Input $BITALIC yes $EITALIC or $BITALIC no $EITALIC here : \{ans_rule(10)\}
43-
$BR
44-
Is the graph symmetric with respect to the origin?
45-
Input $BITALIC yes $EITALIC or $BITALIC no $EITALIC here : \{ans_rule(10)\}
46-
$BR
47-
END_TEXT
48-
49-
$ans1 = "-$b/$a";
50-
$ans2 = $b;
51-
$ans3 = "no";
52-
$ans4 = "no";
53-
$ans5 = "no";
54-
55-
ANS(num_cmp($ans1));
56-
ANS(num_cmp($ans2));
57-
ANS(str_cmp($ans3));
58-
ANS(str_cmp($ans4));
59-
ANS(str_cmp($ans5));
60-
61-
ENDDOCUMENT(); # This should be the last executable line in the problem.
23+
Context('Fraction');
24+
25+
$a = random(2, 20);
26+
$b = random(1, 9);
27+
28+
$x = Fraction(-$b, $a);
29+
30+
$dd1 = DropDown([ 'Yes', 'No' ], 1);
31+
$dd2 = DropDown([ 'Yes', 'No' ], 1);
32+
$dd3 = DropDown([ 'Yes', 'No' ], 1);
33+
34+
BEGIN_PGML
35+
For the graph of the equation [```y=[$a] x+[$b]```] draw a sketch of the graph on a piece of paper. Then answer the following questions:
36+
37+
38+
a) The [`x`]-intercept is : [` x = `] [_]{$x}
39+
40+
b) The [`y`]-intercept is : [` y = `] [_]{Real($b)}
41+
42+
c) Is the graph symmetric with respect to the [`x`]-axis? [_]{$dd1}
43+
44+
d) Is the graph symmetric with respect to the [`y`]-axis? [_]{$dd2}
45+
46+
e) Is the graph symmetric with respect to the origin? [_]{$dd3}
47+
48+
END_PGML
49+
50+
# determine the bounds of the lines for nicer plotting
51+
52+
$xmax =
53+
$m * 10.5 + $b > 10.5 ? (10.5 - $b) / $m
54+
: $m * 10.5 + $b < -10.5 ? (-10.5 - $b) / $m
55+
: 10.5;
56+
57+
$xmin =
58+
$m * -10.5 + $b > 10.5 ? (10.5 - $b) / $m
59+
: $m * -10.5 + $b < -10.5 ? (-10.5 - $b) / $m
60+
: -10.5;
61+
62+
$graph = createTikZImage();
63+
$graph->tikzLibraries('arrows.meta');
64+
$graph->BEGIN_TIKZ
65+
\tikzset{>={Stealth[scale=1.5]}}
66+
\filldraw[
67+
draw=LightBlue,
68+
fill=white,
69+
rounded corners=10pt,
70+
thick,use as bounding box
71+
] (-11,-11) rectangle (11,11);
72+
\draw[gray] (-10,-10) grid (10,10);
73+
\draw[->,thick] (-10.5,0) -- (10.5,0) node[above left,outer sep=3pt] {\(x\)};
74+
\foreach \x in {-10,-8,...,-2,2,4,...,10}
75+
\draw(\x,5pt) -- (\x,-5pt) node [below] {\(\x\)};
76+
\draw[->,thick] (0,-10.5) -- (0,10.5) node[below right,outer sep=3pt] {\(y\)};
77+
\foreach \y in {-10,-8,...,-2,2,4,...,10}
78+
\draw (5pt,\y) -- (-5pt,\y) node[left] {\(\y\)};
79+
\draw[blue,ultra thick,<->] plot[domain=$xmin:$xmax] (\x,{$a*\x+$b});
80+
END_TIKZ
81+
82+
$alt_text = "Graph of the line y=$a x + $b.";
83+
84+
BEGIN_PGML_SOLUTION
85+
A graph of the line is
86+
87+
>> [![$alt_text]!]{$graph}{400} <<
88+
89+
a) The [`x`]-intercept is found by solving
90+
[```
91+
\begin{aligned}
92+
0 & = [$a] x + [$b] \\
93+
-[$b] & = [$a] x \\
94+
-\frac{[$b]}{[$a]} & = x
95+
\end{aligned}
96+
```]
97+
98+
b) The [`y`]-intercept is the constant term or [$b].
99+
100+
c) The graph is not symmetric with respect to the [`x`]-axis.
101+
102+
d) The graph is not symmetric with respect to the [`y`]-axis.
103+
104+
e) The graph is not symmetric with respect to the origin.
105+
END_PGML_SOLUTION
106+
107+
ENDDOCUMENT(); # This should be the last executable line in the problem.

0 commit comments

Comments
 (0)