Skip to content

Commit ea9d812

Browse files
committed
Restructure the POD of macros
For consistency the POD of macros have been updated so that there is a `=HEAD1 NAME` with the following structure: ``` macroName.pl - short description. ``` u
1 parent 601750b commit ea9d812

File tree

136 files changed

+1800
-2605
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

136 files changed

+1800
-2605
lines changed

macros/answers/ConditionalHint.pl

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

2-
=head1 ConditionalHint.pl
2+
=head1 NAME
33
4-
=head2 NAME
5-
6-
C<ConditionalHint.pl> - Allows a hint to be revealed after a student
4+
ConditionalHint.pl - Allows a hint to be revealed after a student
75
has entered an answer correctly.
86
9-
=head2 DESCRIPTION
7+
=head1 DESCRIPTION
108
119
The subroutine C<ConditionalHint()> allows a hint to be revealed
1210
after a student has entered an answer correctly. It is useful
@@ -17,9 +15,9 @@ =head2 DESCRIPTION
1715
A subroutine C<IsAnswerCorrect()> that returns 0 or 1 is also
1816
provided.
1917
20-
=head2 USAGE
18+
=head1 MACROS
2119
22-
=head3 Synopsis of ConditionalHint
20+
=head2 ConditionalHint
2321
2422
loadMacros("ConditionalHint.pl");
2523
@@ -102,10 +100,6 @@ =head3 Complete Working Example of ConditionalHint
102100
103101
ENDDOCUMENT();
104102
105-
=head2 AUTHOR
106-
107-
Paul Pearson
108-
109103
=cut
110104

111105
sub _ConditionalHint_init { }; # don't reload this file
@@ -142,14 +136,8 @@ sub IsAnswerCorrect {
142136
@_
143137
);
144138

145-
# my $name_of_correct_answer = shift;
146-
# my $answer_rule_number = shift;
147-
148-
# return $name_of_correct_answer->cmp()->evaluate($inputs_ref->{ANS_NUM_TO_NAME($answer_rule_number)})->{score};
149-
150139
return $options{ans_name}->cmp()->evaluate($inputs_ref->{ ANS_NUM_TO_NAME($options{ans_number}) })->{score};
151140

152141
}
153142

154143
1;
155-

macros/answers/Generic.pl

Lines changed: 45 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,28 @@
1-
#R. Byerly, Texas Tech University, 2005
21

3-
sub _Generic { } #Don't reload this file.
2+
=head1 NAME
43
5-
#Documentation:
4+
Generic.pl - provide some generic answer checkers.
65
7-
=head1 Generic Answer Checker
6+
=head1 DESCRIPTION
87
9-
(Based on David Cervone's vector_cmp. See
10-
doc/parser/extensions/8-answer.pg under the webwork2 directory.)
11-
Place in macros directory and load this file (Generic.pl) using the
12-
loadMacros command. (To just copy it into a pg file, replace
13-
occurences of "\&" by "~~&".)
8+
This macro provides a set of functions that provide a generic answer checker.
149
15-
Usage:
10+
Usage:
11+
12+
ANS( generic_cmp(<prof_answer>, <optional and mandatory arguments>) );
1613
17-
ANS( generic_cmp(<prof_answer>, <optional and mandatory arguments>) );
1814
where <prof_answer> is a parser object or syntactically correct string
1915
for a parser object.
2016
2117
Mandatory arguments:
2218
23-
type => <type>
19+
type => <type>
20+
2421
where <type> is a recognized parser type (e.g., Number, Point, Vector,
2522
Matrix, etc.)
2623
27-
checker => <checker>
24+
checker => <checker>
25+
2826
where <checker> is a reference to a subroutine that will be passed (in
2927
order) the parsed (and, if possible, evaluated) student answer, the
3028
parsed professor's answer, and a reference to the answer hash. (The
@@ -33,63 +31,54 @@ =head1 Generic Answer Checker
3331
3432
Optional arguments:
3533
36-
correct_ans => <answer_string>
34+
correct_ans => <answer_string>
35+
3736
where <answer_string> is a string that will show up as the correct
3837
answer when solutions are available.
3938
40-
variables_allowed => 0 or 1
39+
variables_allowed => 0 or 1
40+
4141
(default 0 (false). Determines whether student's answer is allowed to
4242
contain variables. In this case the checker must take care of
4343
evaluating it.)
4444
45-
length => n
45+
length => n
46+
4647
where n is the number of elements in an expected answer of type list,
4748
vector, or points. Returns error message to student if answer of wrong
4849
length is entered.
4950
51+
=head1 SYNOPSIS
5052
51-
####################Example:##########################
52-
DOCUMENT(); # This should be the first executable line in the problem.
53-
54-
loadMacros(
55-
"PG.pl",
56-
"PGbasicmacros.pl",
57-
"PGanswermacros.pl",
58-
"Parser.pl",
59-
"Generic.pl",
60-
);
61-
62-
TEXT(&beginproblem);
53+
DOCUMENT();
6354
64-
Context("Vector");
65-
$A=Vector(1,2,1);
66-
$B=Vector(1,3,1);
67-
$C=Vector(1,4,1);
55+
loadMacros("PG.pl", "PGbasicmacros.pl", "PGanswermacros.pl", "Parser.pl", "Generic.pl");
6856
69-
BEGIN_TEXT
70-
Show that the vectors \(\{$A->TeX\}, \{$B->TeX\}, \{$C->TeX\}\) do
71-
not span \(R^3\) by giving a vector not in their span:
72-
\{ans_rule()\}
73-
END_TEXT
57+
Context("Vector");
58+
$A=Vector(1,2,1);
59+
$B=Vector(1,3,1);
60+
$C=Vector(1,4,1);
7461
75-
#Easy to get by guessing!
62+
BEGIN_TEXT
63+
Show that the vectors \(\{$A->TeX\}, \{$B->TeX\}, \{$C->TeX\}\) do
64+
not span \(R^3\) by giving a vector not in their span:
65+
\{ans_rule()\}
66+
END_TEXT
7667
77-
sub check{
78-
my $stu=shift();
79-
$x1=$stu->extract(1); $x3=$stu->extract(3);
80-
$x1 != $x3; #any vectors with different 1st and 3rd coordinates
81-
}
68+
sub check {
69+
my $stu=shift;
70+
$x1=$stu->extract(1); $x3=$stu->extract(3);
71+
$x1 != $x3; #any vectors with different 1st and 3rd coordinates
72+
}
8273
83-
ANS(generic_cmp("23",type => 'Vector', length => 3, checker => ~~&check));
74+
ANS(generic_cmp("23",type => 'Vector', length => 3, checker => ~~&check));
8475
85-
ENDDOCUMENT(); # This should be the last executable line in the problem.
76+
ENDDOCUMENT();
8677
87-
####################End of Example########################
78+
=head1 MACROS
8879
8980
=cut
9081

91-
#End of Documentation
92-
9382
#From parserUtils.pl:
9483
sub protectHTML {
9584
my $string = shift;
@@ -100,6 +89,10 @@ sub protectHTML {
10089

10190
}
10291

92+
=head2 generic_cmp
93+
94+
=cut
95+
10396
sub generic_cmp {
10497
my $v = shift;
10598
my %opts = @_;
@@ -120,6 +113,10 @@ sub generic_cmp {
120113
return $ans;
121114
}
122115

116+
=head2 generic_cmp_check
117+
118+
=cut
119+
123120
sub generic_cmp_check {
124121
my $ans = shift;
125122
my $type = $ans->{type};

0 commit comments

Comments
 (0)