Skip to content

Commit 0dcfe1c

Browse files
authored
Merge pull request #1261 from d-torrance/placement-test
Add placement test problems
2 parents 983a829 + 6497ddc commit 0dcfe1c

25 files changed

+1575
-0
lines changed
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
#DESCRIPTION
2+
## Algebra problem: simplifying fraction
3+
##ENDDESCRIPTION
4+
5+
## hcao tagged and PAID on 12-12-2003
6+
7+
## slightly modified for Piedmont placement test
8+
## (smaller numbers) by Doug Torrance (2025-05-08)
9+
10+
## DBsubject(Arithmetic)
11+
## DBchapter(Fractions/rational numbers)
12+
## DBsection(Multiple operations)
13+
## MLT(DivFollowedBySubtract)
14+
## MLTleader(1)
15+
## Date(6/3/2002)
16+
## Level(2)
17+
## TitleText1('College Algebra')
18+
## AuthorText1('Stewart, Redlin, Watson')
19+
## EditionText1('3')
20+
## Section1('1.2')
21+
## Problem1('15')
22+
## KEYWORDS('algebra', 'fraction')
23+
DOCUMENT(); # This should be the first executable line in the problem.
24+
25+
loadMacros(
26+
"PGstandard.pl",
27+
"PGchoicemacros.pl",
28+
"PGcourse.pl"
29+
);
30+
TEXT(beginproblem());
31+
$showCorrectPartialAnswers = 1;
32+
33+
$n1 = random(2,5,1);
34+
$n2 = random(1,5,1);
35+
do {$d2 = random(2,5,1)} until (gcd($n2, $d2) == 1);
36+
37+
BEGIN_TEXT
38+
Combine the fractions, and reduce your answer.
39+
\[ \left($n1\div\frac{$n2}{$d2}\right)-\frac{$n2}{$d2} \]
40+
The reduced answer is \{ans_rule(5)\} / \{ans_rule(5)\}
41+
END_TEXT
42+
@factors = ();
43+
@commonfactors = ();
44+
$fac = $d2*$n2;
45+
for($i=2; $i<=($d2*$n2)/2; $i++){
46+
if($fac % $i == 0){
47+
$fac =$fac/$i;
48+
push @factors,$i;
49+
$i = $i-1;
50+
};
51+
};
52+
$fac = $n1*$d2*$d2-$n2*$n2;
53+
foreach $i (@factors){
54+
if($fac % $i == 0){
55+
$fac = $fac / $i;
56+
push @commonfactors,$i;
57+
};
58+
};
59+
$den = $d2*$n2;
60+
$num = $n1*$d2*$d2-$n2*$n2;
61+
foreach $i (@commonfactors){
62+
$num = $num / $i;
63+
$den = $den / $i;
64+
};
65+
66+
ANS(num_cmp($num, mode=>"strict"));
67+
ANS(num_cmp($den, mode=>"strict"));
68+
69+
ENDDOCUMENT(); # This should be the last executable line in the problem.
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
## DESCRIPTION
2+
## Solve a linear inequality
3+
## ENDDESCRIPTION
4+
5+
## KEYWORDS('linear inequality')
6+
7+
## DBsubject('Algebra')
8+
## DBchapter('Algebra of real numbers and simplifying expressions')
9+
## DBsection('Inequalities and intervals')
10+
## Date('2025-05-06')
11+
## Author('Doug Torrance')
12+
## Institution('Piedmont University')
13+
14+
DOCUMENT();
15+
16+
loadMacros(
17+
"PGstandard.pl", # Standard macros for PG language
18+
"PGML.pl", # PGML markup and Math Objects
19+
"PGcourse.pl", # Customization file for the course
20+
);
21+
22+
$endpoint = random(-5, 5);
23+
$oper = random(0, 3);
24+
$opertex = ("<", "\leq", ">", "\geq")[$oper];
25+
$b = random(1, 10);
26+
$c = random(2, 10);
27+
$d = random(1, $endpoint + 10);
28+
$e = $b - $c*($endpoint - $d);
29+
30+
Context()->variables->add(a => 'Real');
31+
$f = Formula("$b - $c(a - $d)");
32+
33+
if ($oper == 0) {
34+
$ans = Interval("($endpoint, inf)");
35+
} elsif ($oper == 1) {
36+
$ans = Interval("[$endpoint, inf)");
37+
} elsif ($oper == 2) {
38+
$ans = Interval("(-inf, $endpoint)");
39+
} else {
40+
$ans = Interval("(-inf, $endpoint]");
41+
}
42+
43+
BEGIN_PGML
44+
45+
Solve this inequality.
46+
47+
[``[$f] [$opertex] [$e]``]
48+
49+
Enter your answer using interval notation. See [@helpLink('interval notation')@]*.
50+
51+
[_]{$ans}
52+
END_PGML
53+
54+
ENDDOCUMENT();
Lines changed: 191 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,191 @@
1+
# WeBWorK problem written by Chris Hughes, 2013
2+
# Portland Community College
3+
#
4+
# Template:
5+
# Solve the following quadratic equation
6+
#
7+
# ac x^2 = - (ad + bc) x - bd
8+
#
9+
# This equation factors nicely
10+
#
11+
# (ax + b)(cx + d) = 0
12+
#
13+
# If you need to use the square root symbol,
14+
# as in x=sqrt{17}, type it like: *sqrt(17)*
15+
#
16+
# a is integer on [2,5], c = 1
17+
#
18+
# b = d are both positive.
19+
#
20+
# Last updated: Hughes 8/20/13
21+
#
22+
# ENDDESCRIPTION
23+
24+
# Modified for Piedmont placement test
25+
# (smaller numbers, no sqrt note)
26+
# by Doug Torrance (2025-05-08)
27+
28+
## DBCCSS('A-REI.4.b')
29+
## DBsubject('Algebra')
30+
## DBchapter('Basic Algebra')
31+
## DBsection('equations', 'Simplification')
32+
## KEYWORDS('solve','quadratic','equation','factor','zero product principle','fraction')
33+
## Author('Alex Jordan, Carl Yao, Chris Hughes')
34+
## Institution('PCC')
35+
36+
37+
##############################################
38+
DOCUMENT();
39+
loadMacros(
40+
"PGstandard.pl",
41+
"MathObjects.pl",
42+
"parserAssignment.pl",
43+
"answerHints.pl",
44+
"PGML.pl",
45+
"contextFraction.pl",
46+
"PCCmacros.pl",
47+
"PGcourse.pl",
48+
);
49+
50+
##############################################
51+
52+
Context("Numeric");
53+
# globally set the reductions one time
54+
# # so that we can then merely call ->reduce;
55+
Context()->noreduce('(-x)-y','(-x)+y');
56+
57+
$var = "x";
58+
$a=10;
59+
$b=$a;
60+
$c=$a;
61+
$d=$a;
62+
63+
while(gcd($a,$b)!=1 or gcd($c,$d)!=1 or (abs($a*$d+$b*$d)>20) or abs($b * $d) > 20)
64+
{
65+
$a = random(2,5,1);
66+
$b = random(1,12,1);
67+
$c = 1;
68+
$d = random(2,10,1);
69+
}
70+
71+
$lhs = Formula("$a*$c*$var^2")->reduce->reduce;
72+
$rhs = Formula("-($b*$c+$a*$d)*$var-($b*$d)")->reduce->reduce;
73+
$questionFormula = Formula("$a*$c*$var^2+($b*$c+$a*$d)*$var+($b*$d)")->reduce->reduce;
74+
$questionFormula1 = Formula("($a*$var+$b)($c*$var+$d)")->reduce;
75+
76+
Context("LimitedFraction")->flags->set(
77+
reduceFractions => 0,
78+
showMixedNumbers=>0,
79+
showExtraParens=>0 );
80+
parser::Assignment->Allow;
81+
Context()->operators->redefine(',',using=>',',from=>'Numeric');
82+
Context()->operators->redefine('or',using=>',',from=>'Numeric');
83+
Context()->operators->set(
84+
','=>{string=>' or ',TeX=>'\hbox{ or }'},
85+
'or'=>{string=>' or ',TeX=>'\hbox{ or }'}
86+
);
87+
Context()->lists->set(List => {separator => " or "});
88+
Context()->{error}{msg}{"Function 'sqrt' is not allowed in this context"}
89+
= "Please simplify your answer further";
90+
Context()->{error}{msg}{"Can't use '*' in this context"}
91+
= "Please simplify your answer further";
92+
Context()->{error}{msg}{"Can't use '+' in this context"}
93+
= "Please simplify your answer further";
94+
Context()->{error}{msg}{"Can't use '-' in this context"}
95+
= "Please simplify your answer further";
96+
97+
# add solution strings to context- this means that if
98+
# students enter these (and they are not correct), then
99+
# WW will not give a Context warning
100+
Context()->strings->add("no real solutions"=>{},
101+
"no real solution"=>{alias=>'no real solutions'},
102+
"none"=>{alias=>'no real solutions'},
103+
);
104+
105+
$soln1 = Fraction(-$b,$a);
106+
$soln2 = Fraction(-$d,$c);
107+
$ans = Compute("$var = $soln1, $var = $soln2");
108+
109+
##############################################
110+
111+
TEXT(beginproblem());
112+
BEGIN_PGML
113+
Solve the equation.
114+
115+
[` [$lhs]=[$rhs]`]
116+
117+
[__________________________]
118+
119+
[@KeyboardInstructions("Enter multiple answers separated by commas, as in [|x=1, x=-1|]*.")@]**
120+
END_PGML
121+
122+
##############################################
123+
$showPartialCorrectAnswers = 1;
124+
ANS($ans->cmp(
125+
entry_type => "a solution",
126+
checker => sub {
127+
my ($correct,$student,$ans,$nth,$value) = @_;
128+
if ($correct->type eq "Assignment") {
129+
my ($svar,$sfrac) = $student->value; # get the variable and fraction
130+
#return 0 unless Value::classMatch($sfrac,'Fraction') && $sfrac->isReduced;
131+
if(Value::classMatch($sfrac,'Fraction'))
132+
{
133+
return 0 unless $sfrac->isReduced;
134+
}
135+
}
136+
return $correct == $student;
137+
},
138+
extra => sub {
139+
my ($student,$ansHash,$nth,$value) = @_;
140+
if($student eq "no real solutions")
141+
{
142+
$student->context->setError("This equation does have some solutions- try using the square root method","",undef,undef,$Value::CMP_WARNING)
143+
unless $ans->{isPreview};
144+
return;
145+
}
146+
if ($student->type ne "Assignment" && $ansHash->{student_formula}->type ne "Assignment") {
147+
$student->context->setError("Your $nth solution should be written $var = $US$US$US","",undef,undef,$Value::CMP_WARNING)
148+
unless $ans->{isPreview};
149+
return;
150+
}
151+
my ($svar,$sfrac) = $student->value; # get the variable and fraction
152+
if (Value::classMatch($sfrac,'Fraction') && !$sfrac->isReduced) {
153+
$student->context->setError("Your $nth $value is not reduced","",undef,undef,$Value::CMP_WARNING)
154+
unless $ans->{isPreview};
155+
return;
156+
}
157+
return Value::Real->typeMatch($student);
158+
}
159+
)->withPostFilter(AnswerHints(
160+
["$var=$soln1","$var=$soln2"] => "Are you sure you have all the solutions?",
161+
[$soln1,$soln2] => ["Your solution is a correct one, but you should write $var = $US$US$US<br>Are you sure you have all the solutions?",replaceMessage=>1],
162+
["$soln1,$soln2","$soln2,$soln1"] => ["Your solutions are correct, but you should write $var = $US$US$US",replaceMessage=>1],
163+
)));
164+
165+
##############################################
166+
167+
$A = $a*$c;
168+
$B = $b*$c+$a*$d;
169+
$C = $b*$d;
170+
171+
BEGIN_PGML_SOLUTION
172+
There are a few ways to solve quadratic equations- the easiest way to solve this particular
173+
type of problem is to use the _zero product principle_.
174+
175+
[`
176+
\begin{aligned}
177+
[$lhs]=[$rhs] &\Rightarrow [$questionFormula]=0 \\
178+
&\Rightarrow [$questionFormula1]=0 \\
179+
& \Rightarrow [$ans]
180+
\end{aligned}
181+
`]
182+
183+
This quadratic equation has two distinct, real solutions.
184+
185+
The solutions can be checked by substituting them into the original equation- this is left as an exercise.
186+
END_PGML_SOLUTION
187+
188+
##############################################
189+
190+
ENDDOCUMENT();
191+
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
## DESCRIPTION
2+
## Simplify radical expression
3+
## ENDDESCRIPTION
4+
5+
## KEYWORDS('radical expression')
6+
7+
## DBsubject('Algebra')
8+
## DBchapter('Properties of exponents, rational exponents and radicals')
9+
## DBsection('Properties of rational exponents and radicals')
10+
## Date('2025-05-07')
11+
## Author('Doug Torrance')
12+
## Institution('Piedmont University')
13+
14+
DOCUMENT();
15+
16+
loadMacros(
17+
"PGstandard.pl", # Standard macros for PG language
18+
"PGML.pl", # PGML markup and Math Objects
19+
"PGcourse.pl", # Customization file for the course
20+
"contextLimitedRadical.pl",
21+
);
22+
23+
# constant term = a^2 * b, where a and b are chosen from 2, 3, 5
24+
$a = list_random(2, 3, 5);
25+
do {$b = list_random(2, 3, 5);} until ($a != $b);
26+
$coeff = $a**2 * $b;
27+
28+
$var_with_exp = random(0, 1);
29+
$a_exp = random(2, 4);
30+
$q_exp = 2 * $a_exp + 1;
31+
32+
Context('LimitedRadical');
33+
Context()->variables->add(y => 'Real');
34+
35+
if ($var_with_exp == 0) {
36+
$q = Formula("sqrt($coeff x^$q_exp y)");
37+
$ans = Formula("$a x^$a_exp sqrt($b x y)");
38+
} else {
39+
$q = Formula("sqrt($coeff x y^$q_exp)");
40+
$ans = Formula("$a y^$a_exp sqrt($b x y)");
41+
}
42+
43+
BEGIN_PGML
44+
Simplify this expression. Assume all variables represent positive real numbers.
45+
46+
[``[$q]``].
47+
48+
[_]{$ans}
49+
END_PGML
50+
51+
ENDDOCUMENT();

0 commit comments

Comments
 (0)