Skip to content

Commit 1124d4f

Browse files
authored
Merge pull request #1271 from Alex-Jordan/restructure-pod-macros-contexts
Restructire the POD of macros (contexts)
2 parents 743b763 + b637ef5 commit 1124d4f

35 files changed

+228
-218
lines changed

macros/contexts/contextABCD.pl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ =head1 DESCRIPTION
99
for matching problems (where you match against A, B, C, D,
1010
and so on).
1111
12+
=head1 SYNOPSIS
13+
1214
There are two contexts defined here,
1315
1416
Context("ABCD");

macros/contexts/contextAlternateDecimal.pl

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
=head1 NAME
33
4-
C<Context("AlternateDecimal")> - Provides a context that allows the
4+
contextAlternateDecimal.pl - Provides a context that allows the
55
entry of decimal numbers using a comma for the decimal indicator
66
rather than a dot (e.g., C<3,14159> rather than C<3.14159>).
77
@@ -13,11 +13,7 @@ =head1 DESCRIPTION
1313
the other form produces an error message when used. You can also
1414
force the display of numbers to use one or the other form.
1515
16-
=head1 USAGE
17-
18-
To use this file, first load it into your problem, then select the
19-
context that you wish to use. There are three pre-defined contexts,
20-
C<AlternateDecimal>, C<AlternateDecimal-Only>, and
16+
There are three pre-defined contexts, C<AlternateDecimal>, C<AlternateDecimal-Only>, and
2117
C<AlternateDecimal-Warning>. The first allows both the standard and
2218
alternate forms to be used, the second allows only the alternate form,
2319
and the third allows only the standard form, but recognizes the
@@ -82,7 +78,7 @@ =head1 USAGE
8278
numebrs would be displayed in standard form.
8379
8480
85-
=head1 LISTS IN ALTERNATE FORMAT
81+
=head2 LISTS IN ALTERNATE FORMAT
8682
8783
Because the alternate format allows numbers to be entered using commas
8884
rather than periods, this makes the formation of lists harder. For
@@ -107,16 +103,16 @@ =head1 LISTS IN ALTERNATE FORMAT
107103
must be a list separator.
108104
109105
110-
=head1 SETTING THE ALTERNATE FORM AS THE DEFAULT
106+
=head2 SETTING THE ALTERNATE FORM AS THE DEFAULT
111107
112108
If you want to force existing problems to allow (or force, or warn about)
113109
the alternate format instead, then create a file named
114110
C<parserCustomization.pl> in your course's C<templates/macros>
115111
directory, and enter the following in it:
116112
117113
loadMacros("contextAlternateDecimal.pl");
118-
context::AlternateDecimal->Default("either","either");
119-
Context("Numeric");
114+
context::AlternateDecimal->Default("either","either");
115+
Context("Numeric");
120116
121117
This will alter all the standard contexts to allow students to enter
122118
numbers in either format, and will display them using the form that
@@ -125,17 +121,17 @@ =head1 SETTING THE ALTERNATE FORM AS THE DEFAULT
125121
You could also do
126122
127123
loadMacros("contextAlternateDecimal.pl");
128-
context::AlternateDecimal->Default(".",".");
129-
Context("Numeric");
124+
context::AlternateDecimal->Default(".",".");
125+
Context("Numeric");
130126
131127
to cause a warning message to appear when students enter the alternate
132128
format.
133129
134130
If you want to force students to enter the alternate format, use
135131
136132
loadMacros("contextAlternateDecimal.pl");
137-
context::AlternateDecimal->Default(",",",");
138-
Context("Numeric");
133+
context::AlternateDecimal->Default(",",",");
134+
Context("Numeric");
139135
140136
This will force the display of all numbers into the alternate form (so
141137
even the ones created in the problem using standard form will show

macros/contexts/contextAlternateIntervals.pl

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11

22
=head1 NAME
33
4-
C<Context("AlternateIntervals")> - Provides a context that allows the
4+
contextAlternateIntervals.pl - Provides a context that allows the
55
entry of intervals using reversed bracket notation for open endpoints
66
(e.g., C<]a,b[> rather than C<(a,b)> for an open interval).
77
8-
98
=head1 DESCRIPTION
109
1110
This macro file defines contexts in which open intervals can be
@@ -14,9 +13,6 @@ =head1 DESCRIPTION
1413
form produces an error message when used. You can also force the
1514
display of intervals to use one or the other form.
1615
17-
18-
=head1 USAGE
19-
2016
To use this file, first load it into your problem, then select the
2117
context that you wish to use. There are three pre-defined contexts,
2218
C<AlternateIntervals>, C<AlternateIntervals-Only>, and
@@ -83,7 +79,7 @@ =head1 USAGE
8379
would allow students to enter intervals in either format, but all
8480
intervals would be displayed in standard form.
8581
86-
=head1 Setting the alternate form as the default
82+
=head2 Setting the alternate form as the default
8783
8884
If you want to force existing problems that use the Interval context
8985
to use one of the alternate contexts instead, then create a file named

macros/contexts/contextArbitraryString.pl

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,7 @@ =head1 NAME
44
contextArbitraryString.pl - Implements a context in which the student's answer is treated as a
55
literal string, and not parsed further.
66
7-
=head1 DESCRIPTION
8-
9-
Implements a context in which the student's answer is treated as a
10-
literal string, and not parsed further. The real answer checking
11-
should be performed in a custom checker passed to the answer
12-
string's C<cmp()> method. E.g.,
7+
=head1 SYNOPSIS
138
149
loadMacros("contextArbitraryString.pl");
1510
Context("ArbitraryString");
@@ -26,6 +21,13 @@ =head1 DESCRIPTION
2621
return $score;
2722
}));
2823
24+
=head1 DESCRIPTION
25+
26+
Implements a context in which the student's answer is treated as a
27+
literal string, and not parsed further. The real answer checking
28+
should be performed in a custom checker passed to the answer
29+
string's C<cmp()> method.
30+
2931
The default checker is essentially that given above, so if you want
3032
the student answer to match the correct one exactly (spacing and
3133
case are significant), then you don't have to use a custom checker.
@@ -131,8 +133,7 @@ sub quoteHTML {
131133
}
132134

133135
#
134-
# Adjust preview and strings so they display
135-
# multiline answers properly.
136+
# Adjust preview and strings so they display multiline answers properly.
136137
#
137138
sub cmp_preprocess {
138139
my $self = shift;

macros/contexts/contextBaseN.pl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,9 @@ =head1 DESCRIPTION
1010
greater than or equal to 2. The numbers will be stored internally in decimal, though parsed
1111
and shown in the chosen base.
1212
13-
In addition, basic integer arithemetic (+,-,*,/,%,^) are available for these numbers.
14-
Division is defined in an integer sense.
15-
1613
The original purpose for this is simple conversion and operations in another base, however
17-
it is not limited to this.
14+
it is not limited to this. In addition, basic integer arithemetic (+,-,*,/,%,^) are available for these numbers.
15+
Division is defined in an integer sense.
1816
1917
To use a non-decimal base MathObject, first load the contextBaseN.pl file:
2018
@@ -114,12 +112,14 @@ sub Init {
114112
$context->parens->undefine('|', '{', '[');
115113
}
116114

115+
=head1 FUNCTIONS
116+
117117
=head2 convertBase
118118
119119
The function C<convertBase(value, opts)> converts the value from or to other bases depending on the options
120120
in C<opts>. The input C<value> is a positive number or string version of a positive number in some base.
121121
122-
=head3 options
122+
=head3 Options
123123
124124
=over
125125

macros/contexts/contextBoolean.pl

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ =head1 NAME
55
66
=head1 DESCRIPTION
77
8+
This macro provides functionality for handling boolean expressions.
9+
10+
=head1 SYNOPSIS
11+
812
Load this file:
913
1014
loadMacros('contextBoolean.pl');
@@ -13,7 +17,7 @@ =head1 DESCRIPTION
1317
1418
Context('Boolean');
1519
16-
=head2 CONSTANTS
20+
=head1 CONSTANTS
1721
1822
This constant recognizes two constants by default, C<T> and C<F>. The following are all equivalent:
1923
@@ -22,22 +26,22 @@ =head2 CONSTANTS
2226
$T = Context()->T;
2327
$T = context::Boolean->T;
2428
25-
=head2 VARIABLES
29+
=head1 VARIABLES
2630
2731
By default, this context has two variables, C<p> and C<q>. More variables can be added through the usual
2832
means of modifying context:
2933
3034
Context->variables->add( r => 'Boolean' );
3135
32-
=head2 OPERATORS
36+
=head1 OPERATORS
3337
3438
Changing the LaTeX representations of the boolean operators is handled through the operators C<or>, C<and>,
3539
C<xor>, and C<not>. Note the extra space following the LaTeX command.
3640
3741
Context->operators->set( not => { TeX => '\neg ' } );
3842
3943
40-
=head3 Aliases and Alternatives
44+
=head2 Aliases and Alternatives
4145
4246
Modifications to the operators should be applied to the string versions of each operator: 'or', 'xor', 'and',
4347
and 'not'; rather than to any of the following aliases or alternatives.
@@ -66,7 +70,7 @@ =head3 Aliases and Alternatives
6670
6771
=back
6872
69-
=head2 OPERATOR PRECEDENCE
73+
=head1 OPERATOR PRECEDENCE
7074
7175
=over
7276
@@ -86,7 +90,7 @@ =head2 OPERATOR PRECEDENCE
8690
8791
=back
8892
89-
=head2 REDUCTION
93+
=head1 REDUCTION RULES
9094
9195
The context also handles C<reduceConstants> with the following reduction rules:
9296
@@ -114,7 +118,7 @@ =head2 REDUCTION
114118
115119
=back
116120
117-
=head2 COMPARISON
121+
=head1 COMPARISON
118122
119123
Boolean Formula objects are considered equal whenever the two expressions generate the same truth table.
120124

macros/contexts/contextComplexExtras.pl

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
=head1 NAME
33
4-
F<contextCopmlesExtras.pl> - Add conjugation to Complex contexts, and
4+
contextComplexExtras.pl - Add conjugation to Complex contexts, and
55
transpose, conjugate transpose, trace, and determinant to Complex-Matrix context.
66
77
=head1 DESCRIPTION
@@ -11,6 +11,8 @@ =head1 DESCRIPTION
1111
answers in the Complex-Matrix context, and adds conjugation to all
1212
Complex contexts.
1313
14+
=head1 SYNOPSIS
15+
1416
Conjugation is represented by C<~>, as in C<~z> or C<~M> to conjugate
1517
a complex number or complex matrix. This can be used in both PG code
1618
as well as student answers. The transpose is represented by C<^T>, as
@@ -180,10 +182,8 @@ sub _eval {
180182
}
181183

182184
#
183-
# Check for a single Matrix-valued argument
184-
# Then promote it to a Matrix (does error checking)
185-
# and call the routine from Value package (after
186-
# converting "tr" to "trace")
185+
# Check for a single Matrix-valued argument. Then promote it to a Matrix (does error checking)
186+
# and call the routine from Value package (after converting "tr" to "trace")
187187
#
188188
sub _call {
189189
my $self = shift;
@@ -195,3 +195,5 @@ sub _call {
195195
$name = "trace" if $name eq "tr"; # method of Matrix is trace not tr
196196
$self->Package("Matrix")->promote($context, $M)->$name;
197197
}
198+
199+
1;

macros/contexts/contextComplexJ.pl

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
=head1 NAME
33
4-
C<contextComplexJ.pl> - Alters the Complex context to allow the
4+
contextComplexJ.pl - Alters the Complex context to allow the
55
use of j-notation in addition to (or in place of) i-notation for
66
complex numbers.
77
@@ -14,9 +14,6 @@ =head1 DESCRIPTION
1414
type), and how complex numbers should be displayed (you can force
1515
either form to be used regardless of how they were entered).
1616
17-
18-
=head1 USAGE
19-
2017
To use this file, first load it into your problem, then use the
2118
Complex context as usual. Both i and j notation will be allowed,
2219
and numbers will display in whichever format they were originally
@@ -68,7 +65,7 @@ =head1 USAGE
6865
all numebrs would be displayed in standard form.
6966
7067
71-
=head1 SETTING THE ALTERNATE FORM AS THE DEFAULT
68+
=head2 SETTING THE ALTERNATE FORM AS THE DEFAULT
7269
7370
If you want to force existing problems to allow (or force, or warn
7471
about) the j notation, then create a file named

macros/contexts/contextCongruence.pl

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11

2-
=encoding UTF-8
3-
=head1 NAME
2+
=encoding utf8
43
4+
=head1 NAME
55
6-
C<Context("Congruence")> - Provides contexts that allow the
7-
entry of congruence solutions
6+
contextCongruence.pl - Provides contexts that allow the entry of congruence solutions
87
98
=head1 DESCRIPTION
109
@@ -19,9 +18,6 @@ =head1 DESCRIPTION
1918
2019
Congruences must be created with three paramters (a, b, m) from ax ≡ b (mod m).
2120
22-
=head1 USAGE
23-
24-
2521
loadMacros("contextCongruence.pl");
2622
2723
Context("Congruence");

macros/contexts/contextCurrency.pl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,6 @@ =head1 DESCRIPTION
153153
=cut
154154

155155
loadMacros("MathObjects.pl");
156-
#loadMacros("problemPreserveAnswers.pl"); # obsolete
157156

158157
sub _contextCurrency_init { Currency::Init() }
159158

0 commit comments

Comments
 (0)