Skip to content

Add placement test problems #1261

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 69 additions & 0 deletions Contrib/Piedmont/MathPlacementTest/mpt.1.2.pg
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
#DESCRIPTION
## Algebra problem: simplifying fraction
##ENDDESCRIPTION

## hcao tagged and PAID on 12-12-2003

## slightly modified for Piedmont placement test
## (smaller numbers) by Doug Torrance (2025-05-08)

## DBsubject(Arithmetic)
## DBchapter(Fractions/rational numbers)
## DBsection(Multiple operations)
## MLT(DivFollowedBySubtract)
## MLTleader(1)
## Date(6/3/2002)
## Level(2)
## TitleText1('College Algebra')
## AuthorText1('Stewart, Redlin, Watson')
## EditionText1('3')
## Section1('1.2')
## Problem1('15')
## KEYWORDS('algebra', 'fraction')
DOCUMENT(); # This should be the first executable line in the problem.

loadMacros(
"PGstandard.pl",
"PGchoicemacros.pl",
"PGcourse.pl"
);
TEXT(beginproblem());
$showCorrectPartialAnswers = 1;

$n1 = random(2,5,1);
$n2 = random(1,5,1);
do {$d2 = random(2,5,1)} until (gcd($n2, $d2) == 1);

BEGIN_TEXT
Combine the fractions, and reduce your answer.
\[ \left($n1\div\frac{$n2}{$d2}\right)-\frac{$n2}{$d2} \]
The reduced answer is \{ans_rule(5)\} / \{ans_rule(5)\}
END_TEXT
@factors = ();
@commonfactors = ();
$fac = $d2*$n2;
for($i=2; $i<=($d2*$n2)/2; $i++){
if($fac % $i == 0){
$fac =$fac/$i;
push @factors,$i;
$i = $i-1;
};
};
$fac = $n1*$d2*$d2-$n2*$n2;
foreach $i (@factors){
if($fac % $i == 0){
$fac = $fac / $i;
push @commonfactors,$i;
};
};
$den = $d2*$n2;
$num = $n1*$d2*$d2-$n2*$n2;
foreach $i (@commonfactors){
$num = $num / $i;
$den = $den / $i;
};

ANS(num_cmp($num, mode=>"strict"));
ANS(num_cmp($den, mode=>"strict"));

ENDDOCUMENT(); # This should be the last executable line in the problem.
54 changes: 54 additions & 0 deletions Contrib/Piedmont/MathPlacementTest/mpt.1.6.pg
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
## DESCRIPTION
## Solve a linear inequality
## ENDDESCRIPTION

## KEYWORDS('linear inequality')

## DBsubject('Algebra')
## DBchapter('Algebra of real numbers and simplifying expressions')
## DBsection('Inequalities and intervals')
## Date('2025-05-06')
## Author('Doug Torrance')
## Institution('Piedmont University')

DOCUMENT();

loadMacros(
"PGstandard.pl", # Standard macros for PG language
"PGML.pl", # PGML markup and Math Objects
"PGcourse.pl", # Customization file for the course
);

$endpoint = random(-5, 5);
$oper = random(0, 3);
$opertex = ("<", "\leq", ">", "\geq")[$oper];
$b = random(1, 10);
$c = random(2, 10);
$d = random(1, $endpoint + 10);
$e = $b - $c*($endpoint - $d);

Context()->variables->add(a => 'Real');
$f = Formula("$b - $c(a - $d)");

if ($oper == 0) {
$ans = Interval("($endpoint, inf)");
} elsif ($oper == 1) {
$ans = Interval("[$endpoint, inf)");
} elsif ($oper == 2) {
$ans = Interval("(-inf, $endpoint)");
} else {
$ans = Interval("(-inf, $endpoint]");
}

BEGIN_PGML

Solve this inequality.

[``[$f] [$opertex] [$e]``]

Enter your answer using interval notation. See [@helpLink('interval notation')@]*.

[_]{$ans}
END_PGML

ENDDOCUMENT();
191 changes: 191 additions & 0 deletions Contrib/Piedmont/MathPlacementTest/mpt.1.7.pg
Original file line number Diff line number Diff line change
@@ -0,0 +1,191 @@
# WeBWorK problem written by Chris Hughes, 2013
# Portland Community College
#
# Template:
# Solve the following quadratic equation
#
# ac x^2 = - (ad + bc) x - bd
#
# This equation factors nicely
#
# (ax + b)(cx + d) = 0
#
# If you need to use the square root symbol,
# as in x=sqrt{17}, type it like: *sqrt(17)*
#
# a is integer on [2,5], c = 1
#
# b = d are both positive.
#
# Last updated: Hughes 8/20/13
#
# ENDDESCRIPTION

# Modified for Piedmont placement test
# (smaller numbers, no sqrt note)
# by Doug Torrance (2025-05-08)

## DBCCSS('A-REI.4.b')
## DBsubject('Algebra')
## DBchapter('Basic Algebra')
## DBsection('equations', 'Simplification')
## KEYWORDS('solve','quadratic','equation','factor','zero product principle','fraction')
## Author('Alex Jordan, Carl Yao, Chris Hughes')
## Institution('PCC')


##############################################
DOCUMENT();
loadMacros(
"PGstandard.pl",
"MathObjects.pl",
"parserAssignment.pl",
"answerHints.pl",
"PGML.pl",
"contextFraction.pl",
"PCCmacros.pl",
"PGcourse.pl",
);

##############################################

Context("Numeric");
# globally set the reductions one time
# # so that we can then merely call ->reduce;
Context()->noreduce('(-x)-y','(-x)+y');

$var = "x";
$a=10;
$b=$a;
$c=$a;
$d=$a;

while(gcd($a,$b)!=1 or gcd($c,$d)!=1 or (abs($a*$d+$b*$d)>20) or abs($b * $d) > 20)
{
$a = random(2,5,1);
$b = random(1,12,1);
$c = 1;
$d = random(2,10,1);
}

$lhs = Formula("$a*$c*$var^2")->reduce->reduce;
$rhs = Formula("-($b*$c+$a*$d)*$var-($b*$d)")->reduce->reduce;
$questionFormula = Formula("$a*$c*$var^2+($b*$c+$a*$d)*$var+($b*$d)")->reduce->reduce;
$questionFormula1 = Formula("($a*$var+$b)($c*$var+$d)")->reduce;

Context("LimitedFraction")->flags->set(
reduceFractions => 0,
showMixedNumbers=>0,
showExtraParens=>0 );
parser::Assignment->Allow;
Context()->operators->redefine(',',using=>',',from=>'Numeric');
Context()->operators->redefine('or',using=>',',from=>'Numeric');
Context()->operators->set(
','=>{string=>' or ',TeX=>'\hbox{ or }'},
'or'=>{string=>' or ',TeX=>'\hbox{ or }'}
);
Context()->lists->set(List => {separator => " or "});
Context()->{error}{msg}{"Function 'sqrt' is not allowed in this context"}
= "Please simplify your answer further";
Context()->{error}{msg}{"Can't use '*' in this context"}
= "Please simplify your answer further";
Context()->{error}{msg}{"Can't use '+' in this context"}
= "Please simplify your answer further";
Context()->{error}{msg}{"Can't use '-' in this context"}
= "Please simplify your answer further";

# add solution strings to context- this means that if
# students enter these (and they are not correct), then
# WW will not give a Context warning
Context()->strings->add("no real solutions"=>{},
"no real solution"=>{alias=>'no real solutions'},
"none"=>{alias=>'no real solutions'},
);

$soln1 = Fraction(-$b,$a);
$soln2 = Fraction(-$d,$c);
$ans = Compute("$var = $soln1, $var = $soln2");

##############################################

TEXT(beginproblem());
BEGIN_PGML
Solve the equation.

[` [$lhs]=[$rhs]`]

[__________________________]

[@KeyboardInstructions("Enter multiple answers separated by commas, as in [|x=1, x=-1|]*.")@]**
END_PGML

##############################################
$showPartialCorrectAnswers = 1;
ANS($ans->cmp(
entry_type => "a solution",
checker => sub {
my ($correct,$student,$ans,$nth,$value) = @_;
if ($correct->type eq "Assignment") {
my ($svar,$sfrac) = $student->value; # get the variable and fraction
#return 0 unless Value::classMatch($sfrac,'Fraction') && $sfrac->isReduced;
if(Value::classMatch($sfrac,'Fraction'))
{
return 0 unless $sfrac->isReduced;
}
}
return $correct == $student;
},
extra => sub {
my ($student,$ansHash,$nth,$value) = @_;
if($student eq "no real solutions")
{
$student->context->setError("This equation does have some solutions- try using the square root method","",undef,undef,$Value::CMP_WARNING)
unless $ans->{isPreview};
return;
}
if ($student->type ne "Assignment" && $ansHash->{student_formula}->type ne "Assignment") {
$student->context->setError("Your $nth solution should be written $var = $US$US$US","",undef,undef,$Value::CMP_WARNING)
unless $ans->{isPreview};
return;
}
my ($svar,$sfrac) = $student->value; # get the variable and fraction
if (Value::classMatch($sfrac,'Fraction') && !$sfrac->isReduced) {
$student->context->setError("Your $nth $value is not reduced","",undef,undef,$Value::CMP_WARNING)
unless $ans->{isPreview};
return;
}
return Value::Real->typeMatch($student);
}
)->withPostFilter(AnswerHints(
["$var=$soln1","$var=$soln2"] => "Are you sure you have all the solutions?",
[$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],
["$soln1,$soln2","$soln2,$soln1"] => ["Your solutions are correct, but you should write $var = $US$US$US",replaceMessage=>1],
)));

##############################################

$A = $a*$c;
$B = $b*$c+$a*$d;
$C = $b*$d;

BEGIN_PGML_SOLUTION
There are a few ways to solve quadratic equations- the easiest way to solve this particular
type of problem is to use the _zero product principle_.

[`
\begin{aligned}
[$lhs]=[$rhs] &\Rightarrow [$questionFormula]=0 \\
&\Rightarrow [$questionFormula1]=0 \\
& \Rightarrow [$ans]
\end{aligned}
`]

This quadratic equation has two distinct, real solutions.

The solutions can be checked by substituting them into the original equation- this is left as an exercise.
END_PGML_SOLUTION

##############################################

ENDDOCUMENT();

51 changes: 51 additions & 0 deletions Contrib/Piedmont/MathPlacementTest/mpt.1.8.pg
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
## DESCRIPTION
## Simplify radical expression
## ENDDESCRIPTION

## KEYWORDS('radical expression')

## DBsubject('Algebra')
## DBchapter('Properties of exponents, rational exponents and radicals')
## DBsection('Properties of rational exponents and radicals')
## Date('2025-05-07')
## Author('Doug Torrance')
## Institution('Piedmont University')

DOCUMENT();

loadMacros(
"PGstandard.pl", # Standard macros for PG language
"PGML.pl", # PGML markup and Math Objects
"PGcourse.pl", # Customization file for the course
"contextLimitedRadical.pl",
);

# constant term = a^2 * b, where a and b are chosen from 2, 3, 5
$a = list_random(2, 3, 5);
do {$b = list_random(2, 3, 5);} until ($a != $b);
$coeff = $a**2 * $b;

$var_with_exp = random(0, 1);
$a_exp = random(2, 4);
$q_exp = 2 * $a_exp + 1;

Context('LimitedRadical');
Context()->variables->add(y => 'Real');

if ($var_with_exp == 0) {
$q = Formula("sqrt($coeff x^$q_exp y)");
$ans = Formula("$a x^$a_exp sqrt($b x y)");
} else {
$q = Formula("sqrt($coeff x y^$q_exp)");
$ans = Formula("$a y^$a_exp sqrt($b x y)");
}

BEGIN_PGML
Simplify this expression. Assume all variables represent positive real numbers.

[``[$q]``].

[_]{$ans}
END_PGML

ENDDOCUMENT();
Loading