diff --git a/tutorial/sample-problems/Algebra/EquationDefiningFunction.pg b/tutorial/sample-problems/Algebra/EquationDefiningFunction.pg index 865244c51..1a168ee31 100644 --- a/tutorial/sample-problems/Algebra/EquationDefiningFunction.pg +++ b/tutorial/sample-problems/Algebra/EquationDefiningFunction.pg @@ -26,7 +26,7 @@ loadMacros('PGstandard.pl', 'PGML.pl', 'parserAssignment.pl', 'PGcourse.pl'); #:% section = setup #: To allow assignments in the current context call `parser::Assignment->Allow`. #: To allow students to enter an assignment in which the left side is a function -#: declaration call `parser::Assignment->Function('f')`. For more details, see +#: use `parser::Assignment->Function('f')`. For more details, see #: PODLINK('parserAssignment.pl'). Context()->variables->are(x => 'Real', y => 'Real'); parser::Assignment->Allow; diff --git a/tutorial/sample-problems/Algebra/GraphToolCircle.pg b/tutorial/sample-problems/Algebra/GraphToolCircle.pg index cf4051d39..e7b1ba10a 100644 --- a/tutorial/sample-problems/Algebra/GraphToolCircle.pg +++ b/tutorial/sample-problems/Algebra/GraphToolCircle.pg @@ -12,8 +12,8 @@ #:% name = Graph Tool, plotting a circle #:% type = [Sample, technique] -#:% subject = [algebra, precalculus] -#:% categories = [graph] +#:% subject = [algebra, precalculus, geometry] +#:% categories = [graph, graphtool] #:% section = preamble #: This example shows how to get student input in the form of a graph (a circle) diff --git a/tutorial/sample-problems/Algebra/GraphToolCubic.pg b/tutorial/sample-problems/Algebra/GraphToolCubic.pg index d36a5a8f4..e46d42966 100644 --- a/tutorial/sample-problems/Algebra/GraphToolCubic.pg +++ b/tutorial/sample-problems/Algebra/GraphToolCubic.pg @@ -13,7 +13,7 @@ #:% name = Graph Tool, plotting a cubic #:% type = [Sample, technique] #:% subject = [algebra, precalculus] -#:% categories = [graph] +#:% categories = [graph, graphtool] #:% section = preamble #: This example shows how to get student input in the form of a graph (a cubic) diff --git a/tutorial/sample-problems/Algebra/GraphToolCustomChecker.pg b/tutorial/sample-problems/Algebra/GraphToolCustomChecker.pg index 8e3d10fe5..a5c1d4cbb 100644 --- a/tutorial/sample-problems/Algebra/GraphToolCustomChecker.pg +++ b/tutorial/sample-problems/Algebra/GraphToolCustomChecker.pg @@ -13,7 +13,7 @@ #:% name = Graph Tool, custom checker #:% type = [Sample, technique] #:% subject = [algebra, precalculus] -#:% categories = [graph] +#:% categories = [graph, graphtool] #:% section = preamble #: This example shows how to get student input in the form of a graph (a circle) diff --git a/tutorial/sample-problems/Algebra/GraphToolLine.pg b/tutorial/sample-problems/Algebra/GraphToolLine.pg index 4538d4459..bf5154a39 100644 --- a/tutorial/sample-problems/Algebra/GraphToolLine.pg +++ b/tutorial/sample-problems/Algebra/GraphToolLine.pg @@ -12,8 +12,8 @@ #:% name = Graph Tool, plotting a line #:% type = [Sample, technique] -#:% subject = [algebra, precalculus] -#:% categories = [graph] +#:% subject = [algebra, precalculus, geometry] +#:% categories = [graph, graphtool] #:% section = preamble #: This example shows how to get student input in the form of a graph (a line) diff --git a/tutorial/sample-problems/Algebra/GraphToolNumberLine.pg b/tutorial/sample-problems/Algebra/GraphToolNumberLine.pg index 0e98ea9b4..7b4d5fac2 100644 --- a/tutorial/sample-problems/Algebra/GraphToolNumberLine.pg +++ b/tutorial/sample-problems/Algebra/GraphToolNumberLine.pg @@ -13,7 +13,7 @@ #:% name = Graph Tool, number line #:% type = [Sample, technique] #:% subject = [algebra, precalculus] -#:% categories = [graph] +#:% categories = [graph, graphtool] #:% section = preamble #: This example shows how to get student input in the form of a graph @@ -40,8 +40,8 @@ loadMacros('PGstandard.pl', 'PGML.pl', 'parserGraphTool.pl', 'PGcourse.pl'); #: #: * `numberLine` is set to 1 (true) to indicate this is a one-dimensional #: graph. -#: * `bBox`: For a number line the bounding box is an array reference [xmin, xmax] -#: containing the left and right limits of the visible graph. +#: * `bBox`: For a number line the bounding box is an array reference +#: [xmin, xmax] containing the left and right limits of the visible graph. #: * `availableTools`: This determines which tools will be available for the #: student to use. #: * `ticksDistanceX`: The distance between tick marks in the x direction. diff --git a/tutorial/sample-problems/Algebra/GraphToolPoints.pg b/tutorial/sample-problems/Algebra/GraphToolPoints.pg index 6838d0fae..e57505c86 100644 --- a/tutorial/sample-problems/Algebra/GraphToolPoints.pg +++ b/tutorial/sample-problems/Algebra/GraphToolPoints.pg @@ -13,7 +13,7 @@ #:% name = Graph Tool, plotting points #:% type = [Sample, technique] #:% subject = [algebra, precalculus] -#:% categories = [graph] +#:% categories = [graph, graphtool] #:% see_also = [GraphToolCircle.pg, GraphToolCubic.pg, GraphToolLine.pg, GraphToolNumberLine.pg] #:% section = preamble diff --git a/tutorial/sample-problems/Arithmetic/UnitConversion.pg b/tutorial/sample-problems/Arithmetic/UnitConversion.pg new file mode 100644 index 000000000..1d598376e --- /dev/null +++ b/tutorial/sample-problems/Arithmetic/UnitConversion.pg @@ -0,0 +1,87 @@ +## DESCRIPTION +## Answer is a number or formula with units +## ENDDESCRIPTION + +## DBsubject(WeBWorK) +## DBchapter(WeBWorK tutorial) +## DBsection(PGML tutorial 2015) +## Date(02/15/2025) +## Institution(Fitchburg State University) +## Author(Peter Staab) +## Static(1) +## MO(1) +## KEYWORDS('differential calculus', 'units') + +# Update 2025.02 to use the contextUnits.pl macro. + +#:% name = Unit Conversion +#:% type = Sample +#:% subject = arithmetic +#:% categories = [units] + +#:% section = preamble +#: We load `contextUnits.pl` in order to use the Units context. +DOCUMENT(); + +loadMacros('PGstandard.pl', 'PGML.pl', 'contextUnits.pl', 'PGcourse.pl'); + +#:% section = setup +#: The Units context is from the PODLINK('contextUnits.pl') macro. +#: This is related to the 'Numeric' context with the ability to handle units. +#: The first question involves volume units so we set that. +#: +#: The `->toUnits` method converts the given number with units to the +#: requested unit. +#: +#: The second part below is a different conversion question, so the line +#: `Context('Units')->withUnitsFor('length', 'time');` resets the contxt with +#: a new set of units. +Context('Units')->withUnitsFor('volume'); + +$v = random(25, 200, 25); +$vol = Compute("$v ml"); +$vol_cups = $vol->toUnits('cup'); + +Context('Units')->withUnitsFor('length', 'time'); + +$s = random(22, 110, 11); +$speed = Compute("$s ft/s"); +$speed_mph = $speed->toUnits('mi/h'); + +#:% section = statement +#: The `with(sameUnits =>1)` requires the student answer to be in the same +#: units. Use `helpLink('units')` for students to have access to the complete +#: list of units that WeBWorK understands. +BEGIN_PGML +Perform the following unit conversions: + +a) Convert [$vol] to cups. You may use [`1\;\text{l} = 1000\;\text{ml}`], +[`1\;\text{qt} = 0.9464\;\text{l}`] and [`1\;\text{qt}=4\;\text{cups}`]. + + Answer: [_]{$vol_cups->with(sameUnits => 1)} + +b) Convert [$speed] to miles per hour. Recall that +[`1\;\text{mile}=5280\;\text{feet}`]. + + Answer: [_]{$speed_mph->with(sameUnits => 1)} + +Note: use units in all answers. [@ helpLink('units') @]* +END_PGML + +#:% section = solution +BEGIN_PGML_SOLUTION +Using dimensional analysis: + +a) [``` +[$vol] \cdot \frac{1\;\text{l}}{1000\;\text{ml}} +\cdot \frac{1\;\text{qt}}{0.9464\;\text{l}} +\cdot \frac{4\;\text{cups}}{1\;\text{qt}} = [$vol_cups] +```] + +b) [``` +[$speed] \cdot \frac{1\;\text{mile}}{5280\;\text{ft}} +\cdot \frac{3600\;\text{sec}}{1\;\text{hr}} = [$speed_mph] +```] +END_PGML_SOLUTION + +ENDDOCUMENT(); diff --git a/tutorial/sample-problems/DiffCalc/AnswerWithUnits.pg b/tutorial/sample-problems/DiffCalc/AnswerWithUnits.pg index 64c5ee7c0..230b69785 100644 --- a/tutorial/sample-problems/DiffCalc/AnswerWithUnits.pg +++ b/tutorial/sample-problems/DiffCalc/AnswerWithUnits.pg @@ -12,6 +12,8 @@ ## MO(1) ## KEYWORDS('differential calculus', 'units') +# Updated 2025.02 to use the contextUnits.pl macro. + #:% name = Answer with Units #:% type = Sample #:% subject = differential calculus @@ -22,26 +24,25 @@ #: PODLINK('parserFormulaWithUnits.pl') macros. DOCUMENT(); -loadMacros( - 'PGstandard.pl', 'PGML.pl', - 'parserNumberWithUnits.pl', 'parserFormulaWithUnits.pl', - 'PGcourse.pl' -); +loadMacros('PGstandard.pl', 'PGML.pl', 'contextUnits.pl', 'PGcourse.pl'); #:% section = setup +#: First, set the variable for the functions in the problem to be t, +#: and assign the units "seconds" to it. +#: #: Use the differentiation operator `->D('t')` to compute the derivated, and the -#: evaluation method `->eval()` to evaluate it as a function. +#: evaluation method `->eval()` to evaluate it as a function. All of these will +#: now have the expect units. Context()->variables->are(t => 'Real'); +Context()->assignUnits(t => 's'); + +$v0 = random(16, 96, 16); -$h = Formula('-16 t^2 + 16'); +$h = Formula("(-16 t^2 + $v0 t) ft"); $v = $h->D('t'); -$v1 = $v->eval(t => 1); +$v1 = $v->eval(t => $v0 / 16); $a = $v->D('t'); -$ans1 = FormulaWithUnits($v, 'ft/s'); -$ans2 = NumberWithUnits($v1, 'ft/s'); -$ans3 = FormulaWithUnits($a, 'ft/s^2'); - #:% section = statement #: Give students access to help on entering units and the complete list of units #: that WeBWorK understands by inserting the result of calling @@ -52,16 +53,16 @@ by [`h(t) = [$h]`] for [`t \geq 0`], where time is measured in seconds. a. What is the velocity of the object? Include units in your answer. - [_]{$ans1}{15} + [_]{$v}{15} b. What is the velocity of the object when it hits the ground? Include units in your answer. - [_]{$ans2}{15} + [_]{$v1}{15} c. What is the acceleration of the object? Include units in your answer. - [_]{$ans3}{15} + [_]{$a}{15} Note: Use units in all answers. [@ helpLink('units') @]* END_PGML diff --git a/tutorial/sample-problems/Geometry/LineSegmentGraphTool.pg b/tutorial/sample-problems/Geometry/LineSegmentGraphTool.pg new file mode 100644 index 000000000..2f35a9196 --- /dev/null +++ b/tutorial/sample-problems/Geometry/LineSegmentGraphTool.pg @@ -0,0 +1,62 @@ +## DESCRIPTION +## Shows a triangle tool within the GraphTool. +## ENDDESCRIPTION + +## DBsubject(WeBWorK) +## DBchapter(Sample Problems) +## DBsection(Graph Tool) +## Date(02/25/2025) +## Institution(Missouri Western) +## Author(Glenn Rice) +## MO(1) +## KEYWORDS('graph tool', 'vectors') + +#:% name = Line Segment Graph Tool +#:% type = Sample +#:% subject = [geometry] +#:% categories = [graph, graphtool] +#:% see_also = [VectorGraphTool.pg, TriangleGraphTool.pg, QuadrilateralGraphTool.pg] + +#:% section = preamble +#: Load the PODLINK('parserGraphTool.pl') macro to be able to use the GraphTool. +DOCUMENT(); + +loadMacros('PGstandard.pl', 'PGML.pl', 'parserGraphTool.pl', 'PGcourse.pl'); + +#:% section = setup +#: The graph tool is created with the correct answer +#: `{ segment, solid, ($sx1, $sy1), ($sx2, $sy2) }`, with unique points +#: `($sx1, $sy1)` and `($sx2, $sy2)`. For a correct answer, the line segment +#: must have the given the endpoints and be solid. +#: +#: Mulitple line segments can be added to the graph tool, however, if a +#: triangle or quadrilateral is desired, see PROBLINK('TriangleGraphTool.pg') +#: and PROBLINK('QuadrilateralGraphTool.pg') for more appropriate tools. +$sx1 = random(-8, 8); +$sy1 = random(-8, 8); +do { $sx2 = random(-8, 8); $sy2 = random(-8, 8); } + until $sx2 != $sx1 || $sy2 != $sy1; + +$gt = GraphTool("{segment, solid, ($sx1, $sy1), ($sx2, $sy2)}",) + ->with(availableTools => [ 'SegmentTool', 'FillTool', 'SolidDashTool' ]); + +#:% section = statement +#: This asks the student to graph the line segment with the given endpoints. +#: The code `[_]{$gt}` inserts the graph tool. +BEGIN_PGML +Graph the line segment between the points [`([$sx1], [$sy1])`] and +[`([$sx2], [$sy2])`]. + +[_]{$gt} +END_PGML + +#:% section = solution +#: To show the graph with alternate text we use the PGML image construct +#: `[! !]{$gt}`, where the alternate text is placed within the `[! !]`. +BEGIN_PGML_SOLUTION +The correct answer is + +[!A graph of the line segment from ([$sx1], [$sy1]) to ([$sx2],[$sy2])!]{$gt} +END_PGML_SOLUTION + +ENDDOCUMENT(); diff --git a/tutorial/sample-problems/Geometry/QuadrilateralGraphTool.pg b/tutorial/sample-problems/Geometry/QuadrilateralGraphTool.pg new file mode 100644 index 000000000..09e2dc188 --- /dev/null +++ b/tutorial/sample-problems/Geometry/QuadrilateralGraphTool.pg @@ -0,0 +1,64 @@ +## DESCRIPTION +## Shows a quadrilateral tool within the GraphTool. +## ENDDESCRIPTION + +## DBsubject(WeBWorK) +## DBchapter(Sample Problems) +## DBsection(Graph Tool) +## Date(02/25/2025) +## Institution(Missouri Western) +## Author(Glenn Rice) +## MO(1) +## KEYWORDS('graph tool', 'quadrilateral') + +#:% name = Quadrilateral Graph Tool +#:% type = Sample +#:% subject = [geometry] +#:% categories = [graph, graphtool] + +#:% section = preamble +#: Load the PODLINK('parserGraphTool.pl') macro to be able to use the GraphTool. +DOCUMENT(); + +loadMacros('PGstandard.pl', 'PGML.pl', 'parserGraphTool.pl', 'PGcourse.pl'); + +#:% section = setup +#: This finds four unique random points and sets up the GraphTool. The line +#: `{ quadrilateral, solid, ($x1, $y1), ($x2, $y2), ($x3, $y3), ($x4, y4) }` +#: creates a quadrilateral with solid line edges and the given four points. +$x1 = random(-8, 8); +$y1 = random(-8, 8); +do { $x2 = random(-8, 8); $y2 = random(-8, 8) } until $x2 != $x1 || $y2 != $y1; +do { $x3 = random(-8, 8); $y3 = random(-8, 8) } + until ($y3 - $y1) * ($x2 - $x1) != ($y2 - $y1) * ($x3 - $x1); +do { $x4 = random(-8, 8); $y4 = random(-8, 8) } + until ($y4 - $y1) * ($x2 - $x1) != ($y2 - $y1) * ($x4 - $x1) + && ($y4 - $y1) * ($x3 - $x1) != ($y3 - $y1) * ($x4 - $x1) + && ($y4 - $y1) * ($x3 - $x2) != ($y3 - $y2) * ($x4 - $x2); + +$gt = GraphTool( + "{quadrilateral, solid, ($x1, $y1), ($x2, $y2), ($x3, $y3), ($x4, $y4)}") + ->with( + availableTools => [ 'QuadrilateralTool', 'FillTool', 'SolidDashTool' ]); +#:% section = statement +#: This asks the student to graph a quadrilateral with the given vertices. +#: The code `[_]{$gt}` inserts the graph tool. +BEGIN_PGML +Graph the quadrilateral with vertices [`([$x1], [$y1])`], [`([$x2], [$y2])`], +[`([$x3], [$y3])`], and [`([$x4], [$y4])`] in that order. + +[_]{$gt} +END_PGML + +#:% section = solution +#: To show the graph with alternate text we use the PGML image construct +#: `[! !]{$gt}`, where the alternate text is placed within the `[! !]`. +$alt_text = "A graph of the quadrilateral with vertices ($x1, $y1), ($x2,$y2), " + . "($x3, $y3),and ($x4, $y4)"; +BEGIN_PGML_SOLUTION +The correct answer is + +[![$alt_text]!]{$gt} +END_PGML_SOLUTION + +ENDDOCUMENT(); diff --git a/tutorial/sample-problems/Geometry/TriangleGraphTool.pg b/tutorial/sample-problems/Geometry/TriangleGraphTool.pg new file mode 100644 index 000000000..0ac0e57dd --- /dev/null +++ b/tutorial/sample-problems/Geometry/TriangleGraphTool.pg @@ -0,0 +1,58 @@ +## DESCRIPTION +## Shows a triangle tool within the GraphTool. +## ENDDESCRIPTION + +## DBsubject(WeBWorK) +## DBchapter(Sample Problems) +## DBsection(Graph Tool) +## Date(02/25/2025) +## Institution(Missouri Western) +## Author(Glenn Rice) +## MO(1) +## KEYWORDS('graph tool', 'triangle') + +#:% name = Triangle Graph Tool +#:% type = Sample +#:% subject = [geometry] +#:% categories = [graph, graphtool] + +#:% section = preamble +#: Load the PODLINK('parserGraphTool.pl') macro to be able to use the GraphTool. +DOCUMENT(); + +loadMacros('PGstandard.pl', 'PGML.pl', 'parserGraphTool.pl', 'PGcourse.pl'); + +#:% section = setup +#: This finds three unique random points and sets up the GraphTool. The line +#: `{ triangle, solid, ($x1, $y1), ($x2, $y2), ($x3, $y3) }` creates a triangle +#: with solid line edges and the given three points. +$x1 = random(-8, 8); +$y1 = random(-8, 8); +do { $x2 = random(-8, 8); $y2 = random(-8, 8) } until $x2 != $x1 || $y2 != $y1; +do { $x3 = random(-8, 8); $y3 = random(-8, 8) } + until ($y3 - $y1) * ($x2 - $x1) != ($y2 - $y1) * ($x3 - $x1); + +$gt = GraphTool("{ triangle, solid, ($x1, $y1), ($x2, $y2), ($x3, $y3) }") + ->with(availableTools => [ 'TriangleTool', 'FillTool', 'SolidDashTool' ]); + +#:% section = statement +#: This asks the student to graph a triangle with the given vertices. +#: The code `[_]{$gt}` inserts the graph tool. +BEGIN_PGML +Graph the triangle with vertices [`([$x1], [$y1])`], [`([$x2], [$y2])`], and +[`([$x3], [$y3])`]. + +[_]{$gt} +END_PGML + +#:% section = solution +#: To show the graph with alternate text we use the PGML image construct +#: `[! !]{$gt}`, where the alternate text is placed within the `[! !]`. +BEGIN_PGML_SOLUTION +The correct answer is + +[!A graph of the triangle with vertices ([$x1], [$y1]), ([$x2],[$y2]) and +([$x3],[$y3])!]{$gt} +END_PGML_SOLUTION + +ENDDOCUMENT(); diff --git a/tutorial/sample-problems/IntegralCalc/GraphShading.pg b/tutorial/sample-problems/IntegralCalc/GraphShading.pg index 79b9f4f6d..420ecf6b0 100644 --- a/tutorial/sample-problems/IntegralCalc/GraphShading.pg +++ b/tutorial/sample-problems/IntegralCalc/GraphShading.pg @@ -32,11 +32,11 @@ loadMacros('PGstandard.pl', 'PGML.pl', 'PGtikz.pl', 'PGcourse.pl'); #: The shading in done with the `\filldraw` command with the #: `fill opacity = 0.5`. Also note that one of the sides of the filled area is #: the square root function. -$a = random(-4, 2); -$b = random(1, 4); -$g = Compute("$b + sqrt(x - $a)"); -$gtex = "$b + \sqrt{" . nicestring([ 1, -$a ]) . '}'; -$ans = Compute("3*$b + 14/3"); + +$a = random(-4, 2); +$b = random( 1, 4); +$g = Compute("$b + sqrt(x - $a)")->reduce; +$ans = Compute("3*$b + 14/3"); $graph = createTikZImage(); $graph->tikzLibraries('arrows.meta'); @@ -77,7 +77,7 @@ $altText = #:% section = statement BEGIN_PGML -Use the graph to find the area of the shaded region under [`f(x) = [$gtex]`]. +Use the graph to find the area of the shaded region under [`f(x) = [$g]`]. >>[![$altText]!]{$graph}{400}<< diff --git a/tutorial/sample-problems/Misc/DynamicGraphPolygon.pg b/tutorial/sample-problems/Misc/DynamicGraphPolygon.pg index 0a82a8089..560f0a7ee 100644 --- a/tutorial/sample-problems/Misc/DynamicGraphPolygon.pg +++ b/tutorial/sample-problems/Misc/DynamicGraphPolygon.pg @@ -60,9 +60,9 @@ $plot_setup = qq/ # The vertices of the triangle chosen randomly will be ($x0, $y0), ($x1, $y0) # and ($x0, $y1). $x0 = random(-3, -1); -$x1 = random(1, 3); +$x1 = random( 1, 3); $y0 = random(-3, -1); -$y1 = random(1, 3); +$y1 = random( 1, 3); $graph1 = createTikZImage(); $graph1->tikzLibraries('arrows.meta'); diff --git a/tutorial/sample-problems/Misc/RandomPerson.pg b/tutorial/sample-problems/Misc/RandomPerson.pg index 377b67776..4b5d18fff 100644 --- a/tutorial/sample-problems/Misc/RandomPerson.pg +++ b/tutorial/sample-problems/Misc/RandomPerson.pg @@ -39,19 +39,32 @@ $c = random(4, 8, 2); #: The objects `$p1`, `$p2` and `$p3` are `Person` objects. A `Person` object's #: `name` method can be called to obtain the person's name. A `Person` object is #: "stringified" to the name as well. So `[$p1]` can be used in `PGML` to obtain -#: the name. The `subject`, `possessive`, `possession`, and `object` methods can -#: be called to obtain pronouns referring to the person in various parts of +#: the name. +#: +#: There are a couple of ways to determine pronouns. One method is to call the +#: `subject`, `possessive`, `possession`, and `object` methods of a Person +#: to obtain pronouns referring to the person in various parts of #: speech. There are also capitalized versions of those methods to obtain -#: capitalized pronouns. In addition, there is a `verb` method to conjugate most +#: capitalized pronouns. +#: +#: Alternatively, a more-natural set of methods, `they, them, their` and `theirs` +#: will generate the correct subject, object, possession, possesive forms of the +#: pronoun. +#: +#: In addition, there is a `verb` method to conjugate most #: verbs as well as some irregular ones, like `do` which returns the correct #: conjugation of "to do". +#: +#: Note: when writing problems using randomPerson in the Problem Editor, use the +#: "Randomize Seed" button to ensure that the proper pronouns are used for all +#: pronouns. BEGIN_PGML -[$p1] has a ribbon of length [$n] cm. [$p1->Subject] [$p1->verb('cut')] -[$c] cm off the ribbon and [$p1->verb('give')] the piece to [$p1->possessive] +[$p1] has a ribbon of length [$n] cm. [$p1->They] [$p1->verb('cut')] +[$c] cm off the ribbon and [$p1->verb('give')] the piece to [$p1->their] friend [$p2]. [$p1] then [$p1->verb('divide')] the rest in half and [$p1->verb('give')] -half to [$p1->possessive] friend [$p3]. +half to [$p1->their] friend [$p3]. How much ribbon [$p1->do] [$p1] have left? [___]{Real(($n-$c)/2)} END_PGML diff --git a/tutorial/sample-problems/Parametric/PolarGraph.pg b/tutorial/sample-problems/Parametric/PolarGraph.pg index dd69cc979..ed57dced8 100644 --- a/tutorial/sample-problems/Parametric/PolarGraph.pg +++ b/tutorial/sample-problems/Parametric/PolarGraph.pg @@ -13,7 +13,7 @@ #:% name = Polar Graph #:% type = [sample, technique] -#:% subject = parametric +#:% subject = [parametric] #:% section = preamble #: The PODLINK('PGtikz.pl') macro is used to generate the graph. diff --git a/tutorial/sample-problems/Parametric/SpaceCurveGraph.pg b/tutorial/sample-problems/Parametric/SpaceCurveGraph.pg index 94df29c89..5ee0e15da 100644 --- a/tutorial/sample-problems/Parametric/SpaceCurveGraph.pg +++ b/tutorial/sample-problems/Parametric/SpaceCurveGraph.pg @@ -13,7 +13,8 @@ #:% name = Space Curve Graph #:% type = Sample -#:% subject = [parametric, graph] +#:% category = [graph] +#:% subject = [parametric, vector calculus] #:% section = preamble #: The macro PODLINK('plotly3D.pl') is used to produce the graph. diff --git a/tutorial/sample-problems/Parametric/VectorParametricDerivative.pg b/tutorial/sample-problems/Parametric/VectorParametricDerivative.pg index c287157f8..968c3900d 100644 --- a/tutorial/sample-problems/Parametric/VectorParametricDerivative.pg +++ b/tutorial/sample-problems/Parametric/VectorParametricDerivative.pg @@ -14,6 +14,7 @@ #:% name = Parametric Vector Function with Derivative #:% type = Sample #:% subject = parametric +#:% see_also = [VectorParametricFunction.pg, VectorParametricLines.pg] #:% section = preamble #: Although not necessary for the code demonstrated in this example, you might diff --git a/tutorial/sample-problems/Parametric/VectorParametricFunction.pg b/tutorial/sample-problems/Parametric/VectorParametricFunction.pg index 3bc37e8e2..53847356a 100644 --- a/tutorial/sample-problems/Parametric/VectorParametricFunction.pg +++ b/tutorial/sample-problems/Parametric/VectorParametricFunction.pg @@ -14,6 +14,7 @@ #:% name = Vector Parametric Function #:% type = Sample #:% subject = parametric +#:% see_also = [VectorParametricLines.pg,VectorParametricDerivative.pg] #:% section = preamble #: Although not necessary for the code demonstrated in this example, you might diff --git a/tutorial/sample-problems/Parametric/VectorParametricLines.pg b/tutorial/sample-problems/Parametric/VectorParametricLines.pg index 5c2514415..b83835cc2 100644 --- a/tutorial/sample-problems/Parametric/VectorParametricLines.pg +++ b/tutorial/sample-problems/Parametric/VectorParametricLines.pg @@ -14,6 +14,7 @@ #:% name = Parametric Lines #:% type = Sample #:% subject = parametric +#:% see_also = [VectorParametricFunction.pg,VectorParametricDerivative.pg] #:% section = preamble #: The PODLINK('parserVectorUtils.pl') macro is used which provides the diff --git a/tutorial/sample-problems/ProblemTechniques/CalculatingWithPoints.pg b/tutorial/sample-problems/ProblemTechniques/CalculatingWithPoints.pg index 625d370fc..e2dd2936a 100644 --- a/tutorial/sample-problems/ProblemTechniques/CalculatingWithPoints.pg +++ b/tutorial/sample-problems/ProblemTechniques/CalculatingWithPoints.pg @@ -44,7 +44,7 @@ loadMacros('PGstandard.pl', 'PGML.pl', 'PGcourse.pl'); #: `sqrt(36 + 1)` as desired. Context('Point'); $point1 = Point(random(1, 5, 1), random(-5, -1, 1)); -$point2 = Point(random(5, 10, 1), random(6, 11, 1)); +$point2 = Point(random(5, 10, 1), random( 6, 11, 1)); # If $point1 = (x1,y1) and $point2 = (x2,y2), # then the following makes $d1 = x1 - x2, $d2 = y1 - y2 diff --git a/tutorial/sample-problems/ProblemTechniques/EquationEvaluators.pg b/tutorial/sample-problems/ProblemTechniques/EquationEvaluators.pg index 1f126ff91..8889c8686 100644 --- a/tutorial/sample-problems/ProblemTechniques/EquationEvaluators.pg +++ b/tutorial/sample-problems/ProblemTechniques/EquationEvaluators.pg @@ -82,7 +82,7 @@ loadMacros( Context('ImplicitEquation'); Context()->variables->set( x => { limits => [ -2, 2 ] }, - y => { limits => [ 0, 4 ] } + y => { limits => [ 0, 4 ] } ); $ans = ImplicitEquation('y = (x-1)^2'); diff --git a/tutorial/sample-problems/ProblemTechniques/ExtractingCoordinatesFromPoint.pg b/tutorial/sample-problems/ProblemTechniques/ExtractingCoordinatesFromPoint.pg index 84c82d332..49295e5b8 100644 --- a/tutorial/sample-problems/ProblemTechniques/ExtractingCoordinatesFromPoint.pg +++ b/tutorial/sample-problems/ProblemTechniques/ExtractingCoordinatesFromPoint.pg @@ -55,8 +55,8 @@ loadMacros('PGstandard.pl', 'PGML.pl', 'PGcourse.pl'); #: `((2 + (-7)) / 2, (-3 + 8) / 2)` from being accepted. Context('Point'); -$point1 = Point(random(1, 5), random(-5, -1)); -$point2 = Point(random(-10, -6), random(6, 10)); +$point1 = Point(random(1, 5), random(-5, -1)); +$point2 = Point(random(-10, -6), random( 6, 10)); ($d1, $d2) = ($point1 - $point2)->value; diff --git a/tutorial/sample-problems/ProblemTechniques/RestrictAnswerToFraction.pg b/tutorial/sample-problems/ProblemTechniques/RestrictAnswerToFraction.pg index e7d893a79..1d02c310e 100644 --- a/tutorial/sample-problems/ProblemTechniques/RestrictAnswerToFraction.pg +++ b/tutorial/sample-problems/ProblemTechniques/RestrictAnswerToFraction.pg @@ -13,7 +13,8 @@ #:% name = Restrict Answers to a Fraction #:% type = [technique, sample] -#:% subject = [answer] +#:% category = [answer] +#:% subject = [algebra, precalculus] #:% see_also = [RestrictingFunctions.pg] #:% section = preamble diff --git a/tutorial/sample-problems/ProblemTechniques/RestrictingFunctions.pg b/tutorial/sample-problems/ProblemTechniques/RestrictingFunctions.pg index cab2cbf11..d7fa1b039 100644 --- a/tutorial/sample-problems/ProblemTechniques/RestrictingFunctions.pg +++ b/tutorial/sample-problems/ProblemTechniques/RestrictingFunctions.pg @@ -13,7 +13,8 @@ #:% name = Restrict Answers to a Constant #:% type = [technique, sample] -#:% subject = [answer] +#:% category = [answer] +#:% subject = [trigonometry] #:% see_also = [RestrictAnswerToFraction.pg] #:% section = preamble @@ -34,7 +35,7 @@ $deriv = Compute(0)->cmp(showTypeWarnings => 0); BEGIN_PGML Find and completely simplify: -[``\frac{d}{dx}\bigl(\sin^2 x + \cos^2 x\bigr) = ``] [__]{$deriv} +[`` \frac{d}{dx}\bigl(\sin^2 x +\cos^2 x \bigr)= ``] [__]{$deriv} END_PGML #:% section = solution diff --git a/tutorial/sample-problems/Statistics/BarGraph.pg b/tutorial/sample-problems/Statistics/BarGraph.pg new file mode 100644 index 000000000..91377f0d5 --- /dev/null +++ b/tutorial/sample-problems/Statistics/BarGraph.pg @@ -0,0 +1,102 @@ +## DESCRIPTION +## Find the mean and standard deviation of a list of numbers. +## ENDDESCRIPTION +## DBsubject(WeBWorK) +## DBchapter(WeBWorK tutorial) +## DBsection(WeBWorK tutorial) +## Institution(Fitchburg State University) +## Author(Peter Staab) +## Date(02/25/2025) +## KEYWORDS('statistics', 'bar graph') + +#:% name = Bar Graph +#:% subject = [statistics] +#:% type = sample + +#:% section = preamble +#: The PODLINK('PGtikz.pl') macro provides the graphing methods we will use +#: in this problem and PODLINK('contextPercent.pl') will be to provide the +#: Percent context. +DOCUMENT(); + +loadMacros( + "PGstandard.pl", "PGML.pl", + 'PGtikz.pl', 'contextPercent.pl', + "PGcourse.pl" +); + +#:% section = setup +#: The 'Percent' context allow students to enter percents. + +#: The graph is created dynamically. The axes are created with the given labels. +#: Extending the number of bars or the height of the bars should be similar to +#: this code. The heights of the bars are the grades which are generated +#: randomly with the perl `map` function. If you want a non uniform +#: distribution, you can create a different range of random numbers for each +#: grade level. +#: +#: Make sure that an alternate text is added to all graphs for accessibility. Be +#: detailed. + +Context('Percent'); + +@grades = map { random(1, 5) } (0 .. 3); + +$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 +] (-1, -1) rectangle (11, 7); +\draw[->, thick] (-1, 0) -- (10, 0); + +\foreach \x/\label in {2/A,4/B,6/C,8/D} + \draw(\x,0.25)--(\x,-0.25) node [below] {\label}; +\draw[-, thick] (0, -1) -- (0, 6); +\foreach \y in {1, ..., 5} + \draw (5pt, \y) -- (-5pt, \y) node[left] {\(\y\)}; + +\filldraw[fill=LightBlue, draw=black] (1.2,0) rectangle (2.8,$grades[0]); +\filldraw[fill=LightSalmon, draw=black] (3.2,0) rectangle (4.8,$grades[1]); +\filldraw[fill=LightYellow, draw=black] (5.2,0) rectangle (6.8,$grades[2]); +\filldraw[fill=LightGreen, draw=black] (7.2,0) rectangle (8.8,$grades[3]); + +END_TIKZ + +$alt_text = + "A bar graph with vertical bars. The height of the bar labelled A " + . "is $grades[0]. The height of the bar labelled B is $grades[1]. " + . " The height of the bar labelled C is $grades[2] and finally the " + . "bar labelled D is $grades[3]."; + +# This code adds up all the numbers in the @grades array. +$num_students = 0; +$num_students += $_ for @grades; + +$perA = Real($grades[0] / $num_students); + +#:% section = statement +#: In this case, we plot the bar graph and ask a question. +#: Since the context is 'Percent', the students can +#: answer the question with either a fraction, decimal or percent. +#: If only percent answers is desired, see the flags for the Percent context +#: in the macro. +BEGIN_PGML +The following is a distribution of grades on a Statistics quiz. +>>[! [$alt_text] !]{$graph}{400}<< + +What percentage of students earned an A? [_]{$perA} +END_PGML + +#:% section = solution +BEGIN_PGML_SOLUTION +The total number of students that took the quiz is [$total] so the percentage is +the number of A students or [`[$grades[0]]/[$num_students] = [$perA] `] +END_PGML_SOLUTION + +ENDDOCUMENT(); diff --git a/tutorial/sample-problems/Trig/TrigDegrees.pg b/tutorial/sample-problems/Trig/TrigDegrees.pg index b76667205..9e795acb0 100644 --- a/tutorial/sample-problems/Trig/TrigDegrees.pg +++ b/tutorial/sample-problems/Trig/TrigDegrees.pg @@ -18,13 +18,13 @@ #:% section = preamble #: Load the PODLINK('contextTrigDegrees.pl') macro for the `TrigDegrees` -#: context. Also load the PODLINK('parserNumberWithUnits.pl') so that answers -#: can be asked for with the degree symbol. +#: context. Also load the PODLINK('contextUnits.pl') which will require that the +#: answer has units of degrees. DOCUMENT(); loadMacros( 'PGstandard.pl', 'PGML.pl', - 'contextTrigDegrees.pl', 'parserNumberWithUnits.pl', + 'contextTrigDegrees.pl', 'contextUnits.pl', 'PGcourse.pl' ); @@ -32,21 +32,24 @@ loadMacros( #: Select the `TrigDegrees` context to which evaluates trig functions in #: degrees. This applies to any formulas or student answers in this context. #: -#: The second answers is constructed with the `NumberWithUnits` method and the +#: The second answer is constructed with the `NumberWithUnits` method and the #: degree symbol is specified as the unit. Degree measures should always be #: given with the degree symbol. Context('TrigDegrees'); -$ans1 = Compute('sin(30)'); -$ans2 = NumberWithUnits('arcsin(1 / 2)', 'degrees'); +$y = Compute('sin(30)'); + +Context('Units')->withUnitsFor('angles'); + +$ang = Compute('30 degrees'); #:% section = statement #: Inform the students to give angle measurements in degrees. BEGIN_PGML Evaluate the following. Give angles in degrees. -1. [`\sin(30^{\circ}) =`] [_]{$ans1}{5} -2. [`\arcsin(1 / 2) =`] [_]{$ans2}{5} +1. [`\sin(30^{\circ}) =`] [_]{$y} +2. [``\sin^{-1}\left(\frac{1}{2}\right) =``] [_]{$ang->with(sameUnits => 1)} END_PGML #:% section = solution diff --git a/tutorial/sample-problems/VectorCalc/GraphToolVectors.pg b/tutorial/sample-problems/VectorCalc/GraphToolVectors.pg new file mode 100644 index 000000000..3268fca3e --- /dev/null +++ b/tutorial/sample-problems/VectorCalc/GraphToolVectors.pg @@ -0,0 +1,59 @@ +## DESCRIPTION +## Shows a triangle tool within the GraphTool. +## ENDDESCRIPTION + +## DBsubject(WeBWorK) +## DBchapter(Sample Problems) +## DBsection(Graph Tool) +## Date(02/25/2025) +## Institution(Missouri Western) +## Author(Glenn Rice) +## MO(1) +## KEYWORDS('graph tool', 'vectors') + +#:% name = Vector Graph Tool +#:% type = Sample +#:% subject = [geometry] +#:% categories = [graph, graphtool] + +#:% section = preamble +#: Load the PODLINK('parserGraphTool.pl') macro to be able to use the GraphTool. +DOCUMENT(); + +loadMacros('PGstandard.pl', 'PGML.pl', 'parserGraphTool.pl', 'PGcourse.pl'); + +#:% section = setup +#: This problem asks the student to graph the random vector <$vx1, $vy1>. Set +#: this as the correct answer by passing `{ vector, solid (0,0), ($vx1, $vx2) }` +#: to the `GraphTool` method. +#: +#: The checker will give credit for any vector that is graphed with the same +#: length and direction. The graphed vector's initial point does not need to be +#: the origin. +$vx1 = random(-8, 8); +$vy1 = random(-8, 8); + +$gt = GraphTool("{vector, solid, (0, 0), ($vx1, $vy1)}") + ->with(availableTools => [ 'VectorTool', 'FillTool', 'SolidDashTool' ]); + +#:% section = statement +#: The question asks the student to graph the given vector. +#: The code `[_]{$gt}` inserts the graph tool. +BEGIN_PGML +Graph the vector [`\langle[$vx1], [$vy1]\rangle`]. + +[_]{$gt} +END_PGML + +#:% section = solution +#: To show the graph with alternate text we use the PGML image construct +#: `[! !]{$gt}`, where the alternate text is placed within the `[! !]`. +BEGIN_PGML_SOLUTION +A correct answer is + +[!A graph of the vector from (0,0) to ([$vx1],[$vy1])!]{$gt} + +But any vector with the same length and in the same direction would be correct as well. +END_PGML_SOLUTION + +ENDDOCUMENT(); diff --git a/tutorial/sample-problems/VectorCalc/VectorFieldGraph3D/VectorFieldGraph3D1.pg b/tutorial/sample-problems/VectorCalc/VectorFieldGraph3D/VectorFieldGraph3D1.pg index b8d686935..458c69a7f 100644 --- a/tutorial/sample-problems/VectorCalc/VectorFieldGraph3D/VectorFieldGraph3D1.pg +++ b/tutorial/sample-problems/VectorCalc/VectorFieldGraph3D/VectorFieldGraph3D1.pg @@ -50,15 +50,15 @@ $plot = VectorField3D( yvar => 'y', zvar => 'z', xmin => -1, - xmax => 1, + xmax => 1, ymin => -1, - ymax => 1, + ymax => 1, zmin => -1, - zmax => 1, - xsamples => 4, - ysamples => 4, - zsamples => 4, - axesframed => 1, + zmax => 1, + xsamples => 4, + ysamples => 4, + zsamples => 4, + axesframed => 1, xaxislabel => 'X', yaxislabel => 'Y', zaxislabel => 'Z', diff --git a/tutorial/sample-problems/VectorCalc/VectorLineSegment1.pg b/tutorial/sample-problems/VectorCalc/VectorLineSegment1.pg index 996b4bf5b..7feeae4a8 100644 --- a/tutorial/sample-problems/VectorCalc/VectorLineSegment1.pg +++ b/tutorial/sample-problems/VectorCalc/VectorLineSegment1.pg @@ -17,6 +17,7 @@ #:% type = [technique, sample] #:% categories = vector #:% subject = Vector Calculus +#:% see_also = [VectorParametricLine.pg, VectorLineSegment2.pg] #:% section = preamble #: The PODLINK('parseParametricLine.pl') macro provides the `ParametricLine` @@ -83,10 +84,11 @@ $multians = MultiAnswer($line, Real(0), Real(1))->with( #:% section = statement #: Use `$multians` for each answer. BEGIN_PGML -Find a vector equation for the line segment from the point [`P = [$P]`] to -[`Q = [$Q]`]. +Find a vector equation for the line segment from the point +[`P = [$P]`] to [`Q = [$Q]`] . [`\vec{r}(t) =`] [__]{$multians}{15} + for [_]{$multians}{4} [` \leq t \leq `] [_]{$multians}{4} END_PGML diff --git a/tutorial/sample-problems/VectorCalc/VectorLineSegment2.pg b/tutorial/sample-problems/VectorCalc/VectorLineSegment2.pg index 51f18ed6e..2460987b4 100644 --- a/tutorial/sample-problems/VectorCalc/VectorLineSegment2.pg +++ b/tutorial/sample-problems/VectorCalc/VectorLineSegment2.pg @@ -17,6 +17,7 @@ #:% type = [technique, sample] #:% categories = vector #:% subject = Vector Calculus +#:% see_also = [VectorParametricLine.pg, VectorLineSegment1.pg] #:% section = preamble #: The PODLINK('parseVectorUtils.pl') macro is loaded for the @@ -48,7 +49,7 @@ centimeters. Find a vector equation for the position of the object. -[` \vec{r}(t) = `] [____]{$ans} +[` \vec{r}(t) = `] [_]{$ans}{10} _Do not include units in your answer._ END_PGML diff --git a/tutorial/sample-problems/VectorCalc/VectorParametricLine.pg b/tutorial/sample-problems/VectorCalc/VectorParametricLine.pg index 2e1cce899..e8b3598a0 100644 --- a/tutorial/sample-problems/VectorCalc/VectorParametricLine.pg +++ b/tutorial/sample-problems/VectorCalc/VectorParametricLine.pg @@ -17,6 +17,7 @@ #:% type = [technique, sample] #:% categories = vector #:% subject = Vector Calculus +#:% see_also = [VectorLineSegment1.pg, VectorLineSegment2.pg] #:% section = preamble #: The PODLINK('parseVectorUtils.pl') macro provides the `non_zero_point3D` and diff --git a/tutorial/templates/general-main.mt b/tutorial/templates/general-main.mt index 8a46ce2eb..e4d1e29f0 100644 --- a/tutorial/templates/general-main.mt +++ b/tutorial/templates/general-main.mt @@ -12,7 +12,7 @@ % } % } else { % for (sort(keys %$list)) { - % my %topics = (categories => 'Catetory', subjects => 'Subject', macros => 'Macro'); + % my %topics = (categories => 'Category', subjects => 'Subject', macros => 'Macro'); % my $id = $_ =~ s/\s/_/gr;