[system] / trunk / pg / macros / answerHints.pl Repository:
ViewVC logotype

Diff of /trunk/pg/macros/answerHints.pl

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 5373 Revision 5554
1sub _answerHints_init {} 1sub _answerHints_init {}
2 2
3=head1 AnswerHints() 3=head1 AnswerHints()
4 4
5 # This is an answer-checker post-filter that allows you to produce 5This is an answer-checker post-filter that allows you to produce
6 # additional error messages for incorrect answers. You can trigger 6additional error messages for incorrect answers. You can trigger
7 # a message for a single answer, a collection of answers, or via a 7a message for a single answer, a collection of answers, or via a
8 # subroutine that determines the condition for the message. 8subroutine that determines the condition for the message.
9 # 9
10 # Note that this filter only works for MathObjects answer checkers. 10Note that this filter only works for MathObjects answer checkers.
11 # 11
12 # The answer hints are given as a pair using => with the right-hand 12The answer hints are given as a pair using => with the right-hand
13 # side being the answer message and the left-hand side being one of 13side being the answer message and the left-hand side being one of
14 # three possibilities: 1) the value that triggers the message, 14three possibilities: 1) the value that triggers the message,
15 # 2) a reference to an array of values that trigger the message, or 152) a reference to an array of values that trigger the message, or
16 # 3) a code reference to a subtroutine that accepts tthe correct 163) a code reference to a subtroutine that accepts tthe correct
17 # answer, the student's answer, and the answer hash, and returns 17answer, the student's answer, and the answer hash, and returns
18 # 1 or 0 depending on whether the message should or should not be 181 or 0 depending on whether the message should or should not be
19 # displayed. (See the examples below.) 19displayed. (See the examples below.)
20 # 20
21 # The right-hand side can be either the message string itself, or 21The right-hand side can be either the message string itself, or
22 # a referrence to an array where the first element is the message 22a referrence to an array where the first element is the message
23 # string, and the remaining elements are name-value pairs that 23string, and the remaining elements are name-value pairs that
24 # set options for the message. These can include: 24set options for the message. These can include:
25 # 25
26 # checkCorrect => 0 or 1 1 means check for messages even 26=over
27 # if the answer is correct. 27
28 # Default: 0 28=item C<S<< checkCorrect => 0 or 1 >>>
29 # 29
30 # replaceMessage => 0 or 1 1 means it's OK to repalce any 301 means check for messages even
31 # message that is already in place 31if the answer is correct.
32 # in the answer hash. 32Default: 0
33 # Default: 0 33
34 # 34=item C<S<< replaceMessage => 0 or 1 >>>
35 # checkTypes => 0 or 1 1 means only perform the test 35
36 # if the student answer is the 361 means it's OK to repalce any
37 # same type as the correct one. 37message that is already in place
38 # Default: 1 38in the answer hash.
39 # 39Default: 0
40 # score => number Specifies the score to use if 40
41 # the message is triggered (so that 41=item C<S<< checkTypes => 0 or 1 >>>
42 # partial credit can be given). 42
43 # Default: keep original score 431 means only perform the test
44 # 44if the student answer is the
45 # cmp_options => [...] provides options for the cmp routine 45same type as the correct one.
46 # used to check if the student answer 46Default: 1
47 # matches these answers. 47
48 # Default: [] 48=item C<S<< score => number >>>
49 # 49
50Specifies the score to use if
51the message is triggered (so that
52partial credit can be given).
53Default: keep original score
54
55=item C<S<< cmp_options => [...] >>>
56
57provides options for the cmp routine
58used to check if the student answer
59matches these answers.
60Default: []
61
62=back
63
50 # If more than one message matches the student's answer, the first 64If more than one message matches the student's answer, the first
51 # one in the list is used. 65one in the list is used.
52 # 66
53 # Example: 67Example:
54 # 68
55 # ANS(Vector(1,2,3)->cmp(showCoordinateHints=>0)->withPostFilter(AnswerHints( 69 ANS(Vector(1,2,3)->cmp(showCoordinateHints=>0)->withPostFilter(AnswerHints(
56 # Vector(0,0,0) => "The zero vector is not a valid solution", 70 Vector(0,0,0) => "The zero vector is not a valid solution",
57 # "-<1,2,3>" => "Try the opposite direction", 71 "-<1,2,3>" => "Try the opposite direction",
58 # "<1,2,3>" => "Well done!", 72 "<1,2,3>" => "Well done!",
59 # ["<1,1,1>","<2,2,2>","<3,3,3>"] => "Don't just guess!", 73 ["<1,1,1>","<2,2,2>","<3,3,3>"] => "Don't just guess!",
60 # sub { 74 sub {
61 # my ($correct,$student,$ans) = @_; 75 my ($correct,$student,$ans) = @_;
62 # return $correct . $student == 0; 76 return $correct . $student == 0;
63 # } => "Your answer is perpendicular to the correct one", 77 } => "Your answer is perpendicular to the correct one",
64 # Vector(1,2,3) => [ 78 Vector(1,2,3) => [
65 # "You have the right direction, but not length", 79 "You have the right direction, but not length",
66 # cmp_options => [parallel=>1], 80 cmp_options => [parallel=>1],
67 # ], 81 ],
68 # 0 => ["Careful, your answer should be a vector!", checkTypes => 0, replaceMessage => 1], 82 0 => ["Careful, your answer should be a vector!", checkTypes => 0, replaceMessage => 1],
69 # sub { 83 sub {
70 # my ($correct,$student,$ans) = @_; 84 my ($correct,$student,$ans) = @_;
71 # return norm($correct-$student) < .1; 85 return norm($correct-$student) < .1;
72 # } => ["Close! Keep trying.", score => .25], 86 } => ["Close! Keep trying.", score => .25],
73 # ))); 87 )));
74 #
75 88
76=cut 89=cut
77 90
78sub AnswerHints { 91sub AnswerHints {
79 return (sub { 92 return (sub {

Legend:
Removed from v.5373  
changed lines
  Added in v.5554

aubreyja at gmail dot com
ViewVC Help
Powered by ViewVC 1.0.9