[system] / trunk / webwork / system / courseScripts / PG_CAPAmacros.pl Repository:
ViewVC logotype

Diff of /trunk/webwork/system/courseScripts/PG_CAPAmacros.pl

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

Revision 193 Revision 194
12 12
13 #TEXT("answerCounter =". ++$problemCounter,"$BR"); # checking whether values are reinitialized 13 #TEXT("answerCounter =". ++$problemCounter,"$BR"); # checking whether values are reinitialized
14 if (defined($options{'reltol'}) or defined($options{'tol'}) or defined($options{'unit'}) ) { 14 if (defined($options{'reltol'}) or defined($options{'tol'}) or defined($options{'unit'}) ) {
15 15
16 if (defined( $options{'unit'} ) ) { 16 if (defined( $options{'unit'} ) ) {
17 $ans = "$ans $options{'unit'}"; 17 #$ans = "$ans $options{'unit'}";
18 $answer_evaluator = numerical_compare_with_units($ans, %options); 18 $answer_evaluator = num_cmp($ans, 'format' => $options{format},
19 reltol => ( defined($options{reltol}) ) ? $options{reltol} :undef,
20 tol => ( defined($options{tol}) ) ? $options{tol} : undef ,
21 unit => $options{unit},
22 );
19 } else { # numerical compare: 23 } else { # numerical compare:
20 if (defined($options{'reltol'}) ) { #relative tolerance is given with a percent sign 24 if (defined($options{'reltol'}) ) { #relative tolerance is given with a percent sign
21 my $reltol = $options{ 'reltol' }; 25 my $reltol = $options{ 'reltol' };
22 my $format = $options{'format'} if defined($options{'format'}); 26 my $format = $options{'format'} if defined($options{'format'});
23 $answer_evaluator = std_num_cmp($ans,$reltol,$format); 27 $answer_evaluator = num_cmp($ans,reltol=>$reltol,'format' => $format);
24 } elsif (defined($options{'tol'}) ) { 28 } elsif (defined($options{'tol'}) ) {
25 my $format = $options{'format'} if defined($options{'format'}); 29 my $format = $options{'format'} if defined($options{'format'});
26 $answer_evaluator = std_num_cmp_abs($ans,$options{'tol'},$format); 30 $answer_evaluator = num_cmp($ans,tol => $options{'tol'}, 'format' => $format);
27 } else { 31 } else {
28 my $tol = $ans*$main::numRelPercentTolDefault; 32 my $tol = $ans*$main::numRelPercentTolDefault;
29 my $format = $options{'format'} if defined($options{'format'}); 33 my $format = $options{'format'} if defined($options{'format'});
30 $answer_evaluator = std_num_cmp_abs($ans,$tol,$format); 34 $answer_evaluator = num_cmp($ans,reltol=> $tol,'format'=> $format);
31 } 35 }
32 } 36 }
33 } else { 37 } else {
34 # string comparisons 38 # string comparisons
35 if ( defined($options{'str'}) and $options{'str'} =~/CS/i ) { 39 if ( defined($options{'str'}) and $options{'str'} =~/CS/i ) {
36 $answer_evaluator =std_cs_str_cmp($ans); 40 $answer_evaluator =str_cmp($ans,filters=>['compress_whitespace']);
37 } elsif ( defined($options{'str'}) and $options{'str'} =~/MC/i ) { 41 } elsif ( defined($options{'str'}) and $options{'str'} =~/MC/i ) {
38 $answer_evaluator = unordered_str_cmp($ans); 42 $answer_evaluator = str_cmp($ans,filters=>[qw( compress_whitespace ignore_case ignore_order )]);
39 } else { 43 } else {
40 $answer_evaluator = std_str_cmp($ans); 44 $answer_evaluator = str_cmp($ans,filters=>[qw( compress_whitespace ignore_case )]);
41 } 45 }
42 } 46 }
43 47
44 $answer_evaluator; 48 $answer_evaluator;
45} 49}

Legend:
Removed from v.193  
changed lines
  Added in v.194

aubreyja at gmail dot com
ViewVC Help
Powered by ViewVC 1.0.9