-
-
Notifications
You must be signed in to change notification settings - Fork 76
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding more sample problems and cleanup
- Loading branch information
Showing
18 changed files
with
748 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
## DESCRIPTION | ||
## Factored polynomial | ||
## ENDDESCRIPTION | ||
|
||
## DBsubject(WeBWorK) | ||
## DBchapter(WeBWorK tutorial) | ||
## DBsection(PGML tutorial 2015) | ||
## Date(06/01/2015) | ||
## Institution(Hope College) | ||
## Author(Paul Pearson) | ||
## Static(1) | ||
## MO(1) | ||
## KEYWORDS('algebra', 'factored polynomial') | ||
|
||
#:% name = Simple factoring | ||
#:% type = Sample | ||
#:% subject = [algebra, precalculus] | ||
#:% categories = [polynomial] | ||
#:% see_also = [FactoredPolynomial.pg, ExpandedPolynomial.pg, FactoringAndExpanding.pg] | ||
|
||
#:% section = preamble | ||
DOCUMENT(); | ||
|
||
loadMacros('PGstandard.pl', 'PGML.pl', 'PGcourse.pl'); | ||
#:% section = setup | ||
#: First, we create two random roots and then create the factors. Note: | ||
#: the `->reduce` will help make `x-(-3)` into `x+3`. In addition, we | ||
#: create the expanded form of the quadratic. | ||
#: | ||
#: Note that the argument of the List call are the objects in the list, | ||
#: which can be any MathObjects. Here we create a list of Formulas and a list | ||
#: of Reals (the numbers that we use in the second list will be promoted to | ||
#: Real MathObjects when the List is created). | ||
#: | ||
#: If, for example, there were no real roots, we should set | ||
#: `$roots = List("NONE");` so that students who enter a list of roots will not | ||
#: receive an error message about entering the wrong type of answer. If we were | ||
#: to use `$roots = String("NONE");` instead, students who enter anything | ||
#: other than a string (e.g., a list of numbers) will receive an error message. | ||
#: | ||
#: Similarly, if there were only one root at x=4, we would use | ||
#: `$roots = List(4);` instead of $roots = Real(4); to avoid sending error | ||
#: messages to students who enter multiple answers or NONE. | ||
($x0, $x1) = (non_zero_random(-6, 6), non_zero_random(-6, 6)); | ||
$factor1 = Compute("x-$x0")->reduce; | ||
$factor2 = Compute("x-$x1")->reduce; | ||
$f = Compute("x^2-($x0+$x1)x+$x0*$x1")->reduce; | ||
$factors = List($factor1, $factor2); | ||
$roots = List($x0, $x1); | ||
|
||
# If there were only one solution | ||
# $roots = List(4); | ||
|
||
# If there were no solutions | ||
# $roots = List("NONE"); | ||
|
||
#:% section = statement | ||
BEGIN_PGML | ||
a) What are the factors of [`[$f]`]? | ||
|
||
Factors = [__]{$factors} | ||
|
||
|
||
b) What are the roots of this equation? | ||
|
||
Roots = [__]{$roots} | ||
|
||
_(Enter both answers as a comma-separated list.)_ | ||
|
||
END_PGML | ||
|
||
#:% section = solution | ||
BEGIN_PGML_SOLUTION | ||
Solution explanation goes here. | ||
END_PGML_SOLUTION | ||
|
||
ENDDOCUMENT(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,173 @@ | ||
## DESCRIPTION | ||
## Matching problem with graphs | ||
## ENDDESCRIPTION | ||
|
||
## DBsubject(WeBWorK) | ||
## DBchapter(WeBWorK tutorial) | ||
## DBsection(PGML tutorial 2015) | ||
## Date(07/15/2023) | ||
## Institution(Fitchburg State University) | ||
## Author(Peter Staab) | ||
## MO(1) | ||
## KEYWORDS('matching', 'dynamic graph') | ||
|
||
#:% name = Matching Problem with Graphs | ||
#:% type = Sample | ||
#:% subject = [algebra, precalculus] | ||
#:% categories = [graph] | ||
|
||
#:% section = preamble | ||
#: The dynamic graph is generated with `PGtikz.pl`, so this is needed. | ||
#: The matching is done with popups, so `parserPopUp.pl` is need and lastly | ||
#: a `LayoutTable` is used from `niceTables.pl`. | ||
DOCUMENT(); | ||
|
||
loadMacros( | ||
'PGstandard.pl', 'PGML.pl', 'PGtikz.pl', 'parserPopUp.pl', | ||
'niceTables.pl', 'PGcourse.pl' | ||
); | ||
|
||
#:% section = setup | ||
#: The array `@all_plots` contains the display form (f) of the function, | ||
#: the functional form (form) of the function needed in tikz format, | ||
#: the domain of the function and the alterative text. | ||
#: | ||
#: The graphs of all plots and then created by calling commands from `PGtikz.pl`. | ||
#: See PROBLINK('DynamicGraph.pg') for a simpler example using tikz. Note | ||
#: that alternate text is provided to the `image` command and for accessibility | ||
#: should always be considered and this should be provided. | ||
#: | ||
#: The dropdowns are created in the `@dropdown` array which pulls all | ||
#: options. | ||
#: | ||
#: The `LayoutTable` is used to make an accessible table that is nicely | ||
#: laid out. | ||
#: | ||
#: Although this matching problem creates graphs dynamically, these can use | ||
#: static images by changing the call to `image` to just pass in the | ||
#: image names. | ||
@all_plots = ( | ||
{ | ||
f => 'x^2', | ||
form => '\x*\x', | ||
domain => '-3:3', | ||
alt => | ||
'A graph of a curve with a minimum at the origin and opening ' | ||
. 'upward.' | ||
}, | ||
{ | ||
f => 'e^x', | ||
form => 'exp(\x)', | ||
domain => '-6:3', | ||
alt => 'A graph of a curve starting near the negative x axis and ' | ||
. 'rising steeply toward the first quadrant.' | ||
}, | ||
{ | ||
f => 'x^3', | ||
form => '\x*\x*\x', | ||
domain => '-2:2', | ||
alt => 'A graph of a curve from the third quadrant (where is it ' | ||
. 'concave down) to the first quadrant (where it is concave up).' | ||
}, | ||
{ | ||
f => 'ln(x)', | ||
form => 'ln(\x)', | ||
domain => '0.1:6', | ||
alt => 'A graph of a curve that approaches the negative y-axis ' | ||
. 'and rises to the first quadrant and everywhere it is concave' | ||
. 'down.' | ||
}, | ||
{ | ||
f => '3x+2', | ||
form => '3*\x+2', | ||
domain => '-6:6', | ||
alt => | ||
'The graph of a line from the 3rd quadrant to the first quadrant' | ||
}, | ||
{ | ||
f => 'sin(x)', | ||
form => 'sin(\x r)', | ||
domain => '-6:6', | ||
alt => 'A graph of a curve that osciallates and passes through the ' | ||
. 'origin' | ||
}, | ||
); | ||
|
||
for $i (0 .. $#all_plots) { | ||
my $graph = createTikZImage(); | ||
$graph->tikzLibraries('arrows.meta'); | ||
$graph->BEGIN_TIKZ | ||
\tikzset{>={Stealth[scale=1.5]}} | ||
\filldraw[ | ||
draw=LightBlue, | ||
fill=white, | ||
rounded corners=10pt, | ||
thick,use as bounding box | ||
] (-7,-7) rectangle (7,7); | ||
\draw[->,thick] (-6,0) -- (6,0) node[above left,outer sep=3pt] {\(x\)}; | ||
\foreach \x in {-5,...,-1,1,2,...,5} | ||
\draw(\x,5pt) -- (\x,-5pt) node [below] {\(\x\)}; | ||
\draw[->,thick] (0,-6) -- (0,6) node[below right,outer sep=3pt] {\(y\)}; | ||
\foreach \y in {-5,...,-1,1,2,...,5} | ||
\draw (5pt,\y) -- (-5pt,\y) node[left] {\(\y\)}; | ||
\draw[blue,ultra thick] plot[domain=$all_plots[$i]->{domain},smooth] (\x,{$all_plots[$i]->{form}}); | ||
END_TIKZ | ||
$all_plots[$i]->{graph} = $graph; | ||
} | ||
|
||
@plots = random_subset(4, @all_plots); | ||
|
||
# sorted list of possible answers | ||
$list = [ lex_sort(map {"$_->{f}"} @all_plots) ]; | ||
|
||
@dropdowns = map { DropDown($list, "$_->{f}") } @plots; | ||
|
||
$tab = LayoutTable( | ||
[ | ||
[ | ||
map { | ||
image( | ||
$plots[$_]->{graph}, | ||
width => 300, | ||
tex_size => 400, | ||
extra_html_tags => "alt = '$plots[$_]->{alt}'" | ||
) | ||
} (0 .. 1) | ||
], | ||
[ map { $dropdowns[$_]->menu } (0 .. 1) ], | ||
[ | ||
map { | ||
image( | ||
$plots[$_]->{graph}, | ||
width => 300, | ||
tex_size => 400, | ||
extra_html_tags => "alt = '$plots[$_]->{alt}'" | ||
) | ||
} (2 .. 3) | ||
], | ||
[ map { $dropdowns[$_]->menu } (2 .. 3) ] | ||
|
||
], | ||
align => 'cc' | ||
); | ||
|
||
$showPartialCorrectAnswers = 0; | ||
|
||
#:% section = statement | ||
BEGIN_PGML | ||
Match the graph with the formula for the graph (Click on image for a larger view.) | ||
|
||
[$tab]* | ||
END_PGML | ||
|
||
#:% section = answer | ||
#: Because the dropdowns are created in the older fashion, we use the `ANS` form | ||
#: to check the answer | ||
ANS($dropdowns[$_]->cmp) for (0 .. 3); | ||
|
||
#:% section = solution | ||
BEGIN_PGML_SOLUTION | ||
Solution explanation goes here. | ||
END_PGML_SOLUTION | ||
|
||
ENDDOCUMENT(); |
111 changes: 111 additions & 0 deletions
111
tutorial/sample-problems/Parametric/ParametricEquationAnswers.pg
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
## DESCRIPTION | ||
## Check student answers that are parametric equations | ||
## ENDDESCRIPTION | ||
|
||
## DBsubject(WeBWorK) | ||
## DBchapter(WeBWorK tutorial) | ||
## DBsection(PGML tutorial 2015) | ||
## Date(06/01/2015) | ||
## Institution(Hope College) | ||
## Author(Paul Pearson) | ||
## Static(1) | ||
## MO(1) | ||
## KEYWORDS('parametric equation', 'answer checker') | ||
|
||
#:% name = Parametric Equation Answer Checker | ||
#:% type = [Sample, technique] | ||
#:% subject = [differential calculus] | ||
#:% categories = [parametric, answer] | ||
|
||
#:% section = preamble | ||
#: Since there are multiple ways to parameterize, we use the `parserMultiAnswer.pl` | ||
#: macro. | ||
DOCUMENT(); | ||
|
||
loadMacros('PGstandard.pl', 'PGML.pl', 'parserMultiAnswer.pl', 'PGcourse.pl'); | ||
|
||
#:% section = setup | ||
#: We use a `MultiAnswer()` answer checker that will verify that the students | ||
#: answers satisfy the equation for the circle and have the required starting | ||
#: and ending points. This answer checker will allow students to enter any | ||
#: correct parametrization. For example, both | ||
#: x = \cos(t), y = sin(t), 0 ≤ t ≤ pi/3 and x = cos(2t), y = sin(2t), | ||
#: 0 ≤ t ≤ pi/6 will be marked correct. | ||
#: | ||
#: When evaluating student's answers, it is important not to use quotes. For | ||
#: example, if the code were `$xstu->eval(t=>"$t1stu")` with quotes, then if a | ||
#: student enters pi the answer checker will interpret it as the string "pi" | ||
#: which will need to be converted to a MathObject Real and numerical error | ||
#: will be introduced in the conversion. The correct code to use is | ||
#: `$xstu->eval(t=>$t1stu)` without quotes so that the answer is interpreted | ||
#: without a conversion that may introduce error. | ||
#: | ||
#: The first if statement is fully correct, that is the parametric functions | ||
#: are on the unit circle and the initial and final points are correct. | ||
#: The other three ifelse in the answer checker has either the second point, | ||
#: first point or both points wrong. | ||
Context("Numeric")->variables->are(t => "Real"); | ||
Context()->variables->set(t => { limits => [ -5, 5 ] }); | ||
|
||
$x = Formula("cos(t)"); | ||
$y = Formula("sin(t)"); | ||
$t0 = Compute("0"); | ||
$t1 = Compute("pi/3"); | ||
|
||
($x0, $y0) = (1, 0); | ||
($x1, $y1) = (1 / 2, sqrt(3) / 2); | ||
|
||
$multians = MultiAnswer($x, $y, $t0, $t1)->with( | ||
singleResult => 0, | ||
checker => sub { | ||
my ($correct, $student, $self) = @_; | ||
my ($xstu, $ystu, $t0stu, $t1stu) = @{$student}; | ||
if ((($xstu**2 + $ystu**2) == 1) | ||
&& (($xstu->eval(t => $t0stu)) == $x0) | ||
&& (($ystu->eval(t => $t0stu)) == $y0) | ||
&& (($xstu->eval(t => $t1stu)) == $x1) | ||
&& (($ystu->eval(t => $t1stu)) == $y1)) | ||
{ | ||
return [ 1, 1, 1, 1 ]; | ||
|
||
} elsif ((($xstu**2 + $ystu**2) == 1) | ||
&& (($xstu->eval(t => $t0stu)) == $x0) | ||
&& (($ystu->eval(t => $t0stu)) == $y0)) | ||
{ | ||
return [ 1, 1, 1, 0 ]; | ||
|
||
} elsif ((($xstu**2 + $ystu**2) == 1) | ||
&& (($xstu->eval(t => $t1stu)) == $x1) | ||
&& (($ystu->eval(t => $t1stu)) == $y1)) | ||
{ | ||
return [ 1, 1, 0, 1 ]; | ||
|
||
} elsif ((($xstu**2 + $ystu**2) == 1)) { | ||
return [ 1, 1, 0, 0 ]; | ||
|
||
} else { | ||
return [ 0, 0, 0, 0 ]; | ||
} | ||
} | ||
); | ||
#:% section = statement | ||
#: Since the correct answer depends on all answer blanks, the MathObject | ||
#: `$multians` is input into all answer blanks. | ||
BEGIN_PGML | ||
Find a parametrization of the unit circle from the point | ||
[` \big(1,0\big) `] to [` \big(\frac{1}{2},\frac{\sqrt{3}}{2}\big) `]. | ||
Use [` t `] as the parameter for your answers. | ||
|
||
[` x(t) = `] [__]{$multians} | ||
|
||
[` y(t) = `] [__]{$multians} | ||
|
||
for [__]{$multians} to [__]{$multians}. | ||
END_PGML | ||
|
||
#:% section = solution | ||
BEGIN_PGML_SOLUTION | ||
Solution explanation goes here. | ||
END_PGML_SOLUTION | ||
|
||
ENDDOCUMENT(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.