[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 4830 Revision 4831
1loadMacros('Parser.pl'); 1loadMacros('Parser.pl');
2 2
3sub _answerCustom_init {}; # don't reload this file 3sub _answerCustom_init {}; # don't reload this file
4 4
5=head custom response evaluator 5=head3 custom response evaluator
6 6
7###################################################################### 7 ######################################################################
8# 8 #
9# This answer checker provides an easy method for creating an answer 9 # This answer checker provides an easy method for creating an answer
10# checker with a custom subroutine that performs the check for 10 # checker with a custom subroutine that performs the check for
11# correctness. 11 # correctness.
12# 12 #
13# Pass the correct answer (either as a string or as a Parser object) 13 # Pass the correct answer (either as a string or as a Parser object)
14# as the first argument, and a reference to the checker subroutine 14 # as the first argument, and a reference to the checker subroutine
15# as the second argument. Additional parameters can follow. These 15 # as the second argument. Additional parameters can follow. These
16# include any of the parameters for the usual answer checker of the 16 # include any of the parameters for the usual answer checker of the
17# of the type of the correct answer (e.g., showCoordinateHints), plus 17 # of the type of the correct answer (e.g., showCoordinateHints), plus
18# the following: 18 # the following:
19# 19 #
20# sameClass => 0 or 1 If 1 (the default), only call the 20 # sameClass => 0 or 1 If 1 (the default), only call the
21# custom checker if the student answer 21 # custom checker if the student answer
22# is the same object class as the correct 22 # is the same object class as the correct
23# answer (e.g., both are points). 23 # answer (e.g., both are points).
24# If 0, the checker will be called 24 # If 0, the checker will be called
25# whenever the student answer passes 25 # whenever the student answer passes
26# the typeMatch check for the correct 26 # the typeMatch check for the correct
27# answer. For example, if the correct 27 # answer. For example, if the correct
28# answer is a vector, and promotePoints 28 # answer is a vector, and promotePoints
29# has been set to 1, then the checker 29 # has been set to 1, then the checker
30# will be called when the student answer 30 # will be called when the student answer
31# is a vector OR a point. 31 # is a vector OR a point.
32# 32 #
33# sameLength => 0 or 1 If 1 (the default), only call the 33 # sameLength => 0 or 1 If 1 (the default), only call the
34# custom checker if the student answer 34 # custom checker if the student answer
35# has the same number of coordinates as 35 # has the same number of coordinates as
36# the correct answer. 36 # the correct answer.
37# 37 #
38# If the correct answer is a list, the custom checker will be called 38 # If the correct answer is a list, the custom checker will be called
39# on the individual entries of the list, not on the list as a whole. 39 # on the individual entries of the list, not on the list as a whole.
40# If the list is an unordered list, the routine may be called 40 # If the list is an unordered list, the routine may be called
41# multiple times with various combinations of student and professor's 41 # multiple times with various combinations of student and professor's
42# answers in order to find a correct match. 42 # answers in order to find a correct match.
43# 43 #
44# The checker routine will be passed the correct answer, the 44 # The checker routine will be passed the correct answer, the
45# student's answer, and the answer evaluator object, in that order. 45 # student's answer, and the answer evaluator object, in that order.
46# 46 #
47# For example, the following checks if a student entered 47 # For example, the following checks if a student entered
48# a unit vector (any unit vector in R^3 will do): 48 # a unit vector (any unit vector in R^3 will do):
49# 49 #
50# custom_cmp("<1,2,3>",sub { 50 # custom_cmp("<1,2,3>",sub {
51# my ($correct,$student,$ans) = @_; 51 # my ($correct,$student,$ans) = @_;
52# return norm($student) == 1; 52 # return norm($student) == 1;
53# }); 53 # });
54# 54 #
55# The checker subroutine can call Value::Error(message) to generate 55 # The checker subroutine can call Value::Error(message) to generate
56# an error message that will be reported in the table at the top of 56 # an error message that will be reported in the table at the top of
57# the page. If the checker generates a fatal runtime error (e.g., 57 # the page. If the checker generates a fatal runtime error (e.g.,
58# calls the "die" function), then the message is reported with the 58 # calls the "die" function), then the message is reported with the
59# "pink screen of death", and includes a request for the student to 59 # "pink screen of death", and includes a request for the student to
60# inform the instructor. 60 # inform the instructor.
61# 61 #
62 62
63=cut 63=cut
64 64
65sub custom_cmp { 65sub custom_cmp {
66 my $correct = shift; my $checker = shift; 66 my $correct = shift; my $checker = shift;

Legend:
Removed from v.4830  
changed lines
  Added in v.4831

aubreyja at gmail dot com
ViewVC Help
Powered by ViewVC 1.0.9