[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 4967 Revision 4968
95# 95#
96@custom_cmp_defaults = (); 96@custom_cmp_defaults = ();
97 97
98=head3 another example 98=head3 another example
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
104# custom_cmp. 104 # custom_cmp.
105# 105 #
106# You pass the correct answer (as a string or as a List or Union 106 # You pass the correct answer (as a string or as a List or Union
107# object) as the first argument, and the custom list checker as 107 # object) as the first argument, and the custom list checker as
108# the second argument. You can pass any additional parameters 108 # the second argument. You can pass any additional parameters
109# that should be included in the answer checker following those 109 # that should be included in the answer checker following those
110# two required ones. 110 # two required ones.
111# 111 #
112# The checker will be passed a reference to the array of correct 112 # The checker will be passed a reference to the array of correct
113# answers, a reference to the array of student answers, and 113 # answers, a reference to the array of student answers, and
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# For example, the following checks for any list of the same length 119 # 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.) 120 # as the instructor's list. (A stupid checker, but just an example.)
121# 121 #
122# custom_list_cmp("1,2,3",sub { 122 # custom_list_cmp("1,2,3",sub {
123# my ($correct,$student,$ans) = @_; 123 # my ($correct,$student,$ans) = @_;
124# scalar(@{$correct}) == scalar(@{$student}); 124 # scalar(@{$correct}) == scalar(@{$student});
125# }); 125 # });
126# 126 #
127# The checker subroutine can call Value::Error(message) to generate 127 # 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 128 # 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., 129 # the page. If the checker generates a fatal runtime error (e.g.,
130# calls the "die" function), then the message is reported with the 130 # calls the "die" function), then the message is reported with the
131# "pink screen of death", and includes a request for the student to 131 # "pink screen of death", and includes a request for the student to
132# inform the instructor. 132 # inform the instructor.
133# 133 #
134 134
135=cut 135=cut
136 136
137sub custom_list_cmp { 137sub custom_list_cmp {
138 my $correct = shift; my $checker = shift; 138 my $correct = shift; my $checker = shift;

Legend:
Removed from v.4967  
changed lines
  Added in v.4968

aubreyja at gmail dot com
ViewVC Help
Powered by ViewVC 1.0.9