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

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

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

Revision 998 Revision 999
264# [answer_evaluator, partial credit factor, comment] 264# [answer_evaluator, partial credit factor, comment]
265# it applies evaluators from the list until it hits one with positive credit, 265# it applies evaluators from the list until it hits one with positive credit,
266# weights it by the partial credit factor, and throws in its comment 266# weights it by the partial credit factor, and throws in its comment
267 267
268sub pc_evaluator { 268sub pc_evaluator {
269 my ($evaluator_list) = @_; 269 my @ev_list;
270 if(ref($_[0]) ne 'ARRAY') {
271 warn "Improper input to pc_evaluator";
272 }
273 if(ref($_[0]->[0]) ne 'ARRAY') {
274 @ev_list = @_;
275 } else {
276 @ev_list = @{$_[0]};
277 }
270 278
271 my $ans_evaluator = sub { 279 my $ans_evaluator = sub {
272 my $tried = shift; 280 my $tried = shift;
273 my $ans_hash; 281 my $ans_hash;
274 for($j=0;$j<scalar(@{$evaluator_list}); $j++) { 282 for($j=0;$j<scalar(@ev_list); $j++) {
275 my $old_evaluator = $evaluator_list->[$j][0]; 283 my $old_evaluator = $ev_list[$j][0];
276 my $cmt = $evaluator_list->[$j][2]; 284 my $cmt = $ev_list[$j][2];
277 my $weight = $evaluator_list->[$j][1]; 285 my $weight = $ev_list[$j][1];
286 $weight = 1 unless defined($weight);
278 287
279 if ( ref($old_evaluator) eq 'AnswerEvaluator' ) { # new style 288 if ( ref($old_evaluator) eq 'AnswerEvaluator' ) { # new style
280 $ans_hash = $old_evaluator->evaluate($tried); 289 $ans_hash = $old_evaluator->evaluate($tried);
281 } elsif (ref($old_evaluator) eq 'CODE' ) { #old style 290 } elsif (ref($old_evaluator) eq 'CODE' ) { #old style
282 $ans_hash = &$old_evaluator($tried); 291 $ans_hash = &$old_evaluator($tried);
283 } else { 292 } else {
284 warn "There is a problem using the answer evaluator"; 293 warn "There is a problem using the answer evaluator";
285 } 294 }
286 295
287 if($ans_hash->{score}>0) { 296 if($ans_hash->{score}>0) {
288 $ans_hash -> setKeys( 'ans_message' => $cmt); 297 $ans_hash -> setKeys( 'ans_message' => $cmt) if defined($cmt);
289 $ans_hash->{score} *= $weight; 298 $ans_hash->{score} *= $weight;
290 return $ans_hash; 299 return $ans_hash;
291 }; 300 };
292 }; 301 };
293 return $ans_hash; 302 return $ans_hash;

Legend:
Removed from v.998  
changed lines
  Added in v.999

aubreyja at gmail dot com
ViewVC Help
Powered by ViewVC 1.0.9