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

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

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

Revision 5381 Revision 5390
50 # student's answer, and the answer evaluator object, in that order. 50 # student's answer, and the answer evaluator object, in that order.
51 # 51 #
52 # For example, the following checks if a student entered 52 # For example, the following checks if a student entered
53 # a unit vector (any unit vector in R^3 will do): 53 # a unit vector (any unit vector in R^3 will do):
54 # 54 #
55 # custom_cmp("<1,0,0>",sub { 55 # ANS(custom_cmp("<1,0,0>",sub {
56 # my ($correct,$student,$ans) = @_; 56 # my ($correct,$student,$ans) = @_;
57 # return norm($student) == 1; 57 # return norm($student) == 1;
58 # }); 58 # },showCoordinateHints => 0));
59 # 59 #
60 # The checker subroutine can call Value::Error(message) to generate 60 # The checker subroutine can call Value::Error(message) to generate
61 # an error message that will be reported in the table at the top of 61 # an error message that will be reported in the table at the top of
62 # the page. If the checker generates a fatal runtime error (e.g., 62 # the page. If the checker generates a fatal runtime error (e.g.,
63 # calls the "die" function), then the message is reported with the 63 # calls the "die" function), then the message is reported with the
93# Set this to include any default parameters you want 93# Set this to include any default parameters you want
94# to include in the custom answer checkers 94# to include in the custom answer checkers
95# 95#
96@custom_cmp_defaults = (); 96@custom_cmp_defaults = ();
97 97
98=head3 another example 98=head3 a custom list evaluator
99 99
100 # 100 #
101 # This one installs a custom list-based answer checker (for the 101 # This one installs a custom list-based answer checker (for the
102 # List and Union classes). Basically it is just a shell that makes 102 # List and Union classes). Basically it is just a shell that makes
103 # it a little easier to do, and provides an interface similar to 103 # it a little easier to do, and provides an interface similar to
114 # the answer evaluator object. Note that the correct and student 114 # the answer evaluator object. Note that the correct and student
115 # answers are array references, not List structures (this is because 115 # answers are array references, not List structures (this is because
116 # a list of formulas becomes a formula returning a list, so in order 116 # a list of formulas becomes a formula returning a list, so in order
117 # to keep the formulas separate, they are passed in an array). 117 # to keep the formulas separate, they are passed in an array).
118 # 118 #
119 # The checker should return the number of list entries that were
120 # matched by the students answers. (I.e., a number between 0
121 # and the length of the list.)
122 #
119 # For example, the following checks for any list of the same length 123 # For example, the following checks for any list of the same length
120 # as the instructor's list. (A stupid checker, but just an example.) 124 # as the instructor's list. (A stupid checker, but just an example.)
121 # 125 #
122 # custom_list_cmp("1,2,3",sub { 126 # ANS(custom_list_cmp("1,2,3",sub {
123 # my ($correct,$student,$ans) = @_; 127 # my ($correct,$student,$ans) = @_;
124 # scalar(@{$correct}) == scalar(@{$student}); 128 # (scalar(@{$correct}) == scalar(@{$student}) ? 3 : 0);
125 # }); 129 # }));
126 # 130 #
127 # The checker subroutine can call Value::Error(message) to generate 131 # The checker subroutine can call Value::Error(message) to generate
128 # an error message that will be reported in the table at the top of 132 # an error message that will be reported in the table at the top of
129 # the page. If the checker generates a fatal runtime error (e.g., 133 # the page. If the checker generates a fatal runtime error (e.g.,
130 # calls the "die" function), then the message is reported with the 134 # calls the "die" function), then the message is reported with the

Legend:
Removed from v.5381  
changed lines
  Added in v.5390

aubreyja at gmail dot com
ViewVC Help
Powered by ViewVC 1.0.9