-
-
Notifications
You must be signed in to change notification settings - Fork 77
/
Copy pathGraphToolCircle.pg
104 lines (89 loc) · 3.7 KB
/
GraphToolCircle.pg
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
## DESCRIPTION
## Interactive graphing tool problem that asks the student to plot a circle.
## ENDDESCRIPTION
## DBsubject(WeBWorK)
## DBchapter(WeBWorK tutorial)
## DBsection(WeBWorK tutorial)
## Date(05/28/2023)
## Institution(Missouri Western State University)
## Author(Glenn Rice)
## KEYWORDS('graphs', 'circles')
#:% name = Graph Tool, plotting a circle
#:% type = [Sample, technique]
#:% 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)
#: by using interactive graphing tools. Load the PODLINK('parserGraphTool.pl')
#: macro for this.
DOCUMENT();
loadMacros('PGstandard.pl', 'PGML.pl', 'parserGraphTool.pl', 'PGcourse.pl');
#:% section = setup
#: The variables `$h`, `$k` and `$r` randomly pick a center and radius of the
#: circle.
#:
#: The lines
#:
#: ```{#equation .perl}
#: Context()->variables->add(y => 'Real');
#: $circle_eq_lhs = Formula("(x - $h)^2 + (y - $k)^2")->reduce;
#: ```
#:
#: define the equation of the circle that is shown in the problem and solution.
#:
#: The `GraphTool` method creates the graph tool object. The only argument is
#: the correct answer. This is a string that contains a list of objects that
#: the student will be expected to graph. Each object is a brace delimited list
#: of the attributes of the object. The first attribute in each list is the
#: type of object to be graphed, `circle` in this case. What the remaining
#: attributes are depend on the type. For a circle the second attribute is
#: whether the object is to be `solid` or `dashed`, the third attribute is the
#: center of the circle, and the fourth attribute is a point on the circle.
#:
#: The `->with` method is then used to set options for the `GraphTool` object.
#: In this case the options that are set are:
#:
#: * `bBox`: This is an array reference of four values xmin, ymax, xmax, ymin
#: indicating the upper left and lower right corners of the visible graph.
#:
#: There is a default checker for the GraphTool that will mark correct a
#: student answer that 'looks' like the correct one. This means that if
#: a student adds two circles that are equivalent with one solid and one
#: dashed, that if the solid one is plotted second, credit will be given.
#: For simple graphs, the default should be sufficient. See
#: PROBLINK('GraphToolCustomChecker.pg') for an example of how to use a custom
#: checker.
#:
#: For more details, see PODLINK('parserGraphTool.pl').
$h = non_zero_random(-5, 5);
$k = non_zero_random(-5, 5);
$r = random(1, 4);
Context()->variables->add('y' => 'Real');
$circle_eq_lhs = Formula("(x-$h)^2 + (y-$k)^2")->reduce;
$gt = GraphTool("{circle, solid, ($h, $k), ($h + $r, $k)}")
->with(bBox => [ -11, 11, 11, -11 ]);
#:% section = statement
#: This asks the student to graph the circle given by the equation. The code
#: `[_]{$gt}` inserts the GraphTool.
BEGIN_PGML
Graph the circle given by the following equation.
[`[$circle_eq_lhs] = [$r ** 2]`]
[_]{$gt}
END_PGML
#:% section = solution
#: The solution describes how to obtain the graph of the circle from the
#: equation.
#:
#: The line `[! the graph of a circle centered at ([$h], [$k]) of radius [$r] !]{$gt}`
#: inserts the correct answer graph.
BEGIN_PGML_SOLUTION
The equation of the circle of the form:
[`[$circle_eq_lhs] = [$r ** 2]`]
has a center at [`([$h],[$k])`] and radius [$r]. To enter the graph, click the
circle tool, then click the center at [`([$h],[$k])`] and then click a second
point that is [$r] units from the center. This is easiest going left, right, up
or down from the center.
The solution is
[! the graph of a circle centered at ([$h], [$k]) of radius [$r] !]{$gt}
END_PGML_SOLUTION
ENDDOCUMENT();