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

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

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

Revision 3601 Revision 4761
293 my $ra_answer_evaluators = shift; # array of evaluators 293 my $ra_answer_evaluators = shift; # array of evaluators
294 my %options = @_; 294 my %options = @_;
295 my @answer_evaluators = @{$ra_answer_evaluators}; 295 my @answer_evaluators = @{$ra_answer_evaluators};
296 my $backup_ans_eval = $answer_evaluators[0]; 296 my $backup_ans_eval = $answer_evaluators[0];
297 my $multi_ans_evaluator = new AnswerEvaluator; 297 my $multi_ans_evaluator = new AnswerEvaluator;
298 $multi_ans_evaluator->{debug}=$options{debug} if defined($options{debug});
298 $multi_ans_evaluator->install_evaluator( sub { 299 $multi_ans_evaluator->install_evaluator( sub {
299 my $rh_ans = shift; 300 my $rh_ans = shift;
301
300 my @student_answers = split/\s*,\s*/,$rh_ans->{student_ans}; 302 my @student_answers = split/\s*,\s*/,$rh_ans->{student_ans};
301 my @evaluated_ans_hashes = (); 303 my @evaluated_ans_hashes = ();
302 for ( my $j=0; $j<@student_answers; $j++ ) { 304 for ( my $j=0; $j<@student_answers; $j++ ) {
303 # find an answer evaluator which marks this answer correct. 305 # find an answer evaluator which marks this answer correct.
304 my $student_ans = $student_answers[$j]; 306 my $student_ans = $student_answers[$j];
332 } 334 }
333 335
334 336
335 } 337 }
336 # construct the final answer hash 338 # construct the final answer hash
339 my @saved_evaluated_ans_hashes = @evaluated_ans_hashes;
337 my $rh_ans_out = shift @evaluated_ans_hashes; 340 my $rh_ans_out = shift @evaluated_ans_hashes;
338 while (@evaluated_ans_hashes) { 341 while (@evaluated_ans_hashes) {
339 my $temp_hash = shift @evaluated_ans_hashes; 342 my $temp_hash = shift @evaluated_ans_hashes;
340 $rh_ans_out =$rh_ans_out->AND($temp_hash); 343 $rh_ans_out =$rh_ans_out->AND($temp_hash);
341 } 344 }
345 $rh_ans_out->{original_student_ans} = $rh_ans->{student_ans};
342 $rh_ans_out->{student_ans} = $rh_ans->{student_ans}; 346 $rh_ans_out->{student_ans} = $rh_ans->{student_ans};
343 $rh_ans_out->{score}=0 unless @{$ra_answer_evaluators} == @student_answers; # require the correct number of answers 347 $rh_ans_out->{score}=0 unless @{$ra_answer_evaluators} == @student_answers; # require the correct number of answers
348 $rh_ans_out->{_filter_name} = 'multi_cmp';
349 $rh_ans_out->{intermediate_response_evaluations} = [@saved_evaluated_ans_hashes];
344 $rh_ans_out; 350 $rh_ans_out;
345 }); 351 });
346 $multi_ans_evaluator; 352 $multi_ans_evaluator;
347} 353}
348# sub multi_cmp_old{ 354# sub multi_cmp_old{

Legend:
Removed from v.3601  
changed lines
  Added in v.4761

aubreyja at gmail dot com
ViewVC Help
Powered by ViewVC 1.0.9