[system] / trunk / pg / lib / Value / AnswerChecker.pm Repository:
ViewVC logotype

Diff of /trunk/pg/lib/Value/AnswerChecker.pm

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

Revision 3204 Revision 3205
287# Check for dimension mismatch and incorrect coordinates 287# Check for dimension mismatch and incorrect coordinates
288# 288#
289sub cmp_postprocess { 289sub cmp_postprocess {
290 my $self = shift; my $ans = shift; 290 my $self = shift; my $ans = shift;
291 return unless $ans->{score} == 0 && !$ans->{isPreview}; 291 return unless $ans->{score} == 0 && !$ans->{isPreview};
292 if ($ans->{showDimensionHints} && 292 my $student = $ans->{student_value};
293 $self->length != $ans->{student_value}->length) { 293 return if $ans->{ignoreStrings} && (!Value::isValue($student) || $student->type eq 'String');
294 if ($ans->{showDimensionHints} && $self->length != $student->length) {
294 $self->cmp_Error($ans,"The dimension of your result is incorrect"); return; 295 $self->cmp_Error($ans,"The dimension of your result is incorrect"); return;
295 } 296 }
296 if ($ans->{showCoordinateHints}) { 297 if ($ans->{showCoordinateHints}) {
297 my @errors; 298 my @errors;
298 foreach my $i (1..$self->length) { 299 foreach my $i (1..$self->length) {
299 push(@errors,"The ".$self->NameForNumber($i)." coordinate is incorrect") 300 push(@errors,"The ".$self->NameForNumber($i)." coordinate is incorrect")
300 if ($self->{data}[$i-1] != $ans->{student_value}{data}[$i-1]); 301 if ($self->{data}[$i-1] != $student->{data}[$i-1]);
301 } 302 }
302 $self->cmp_Error($ans,@errors); return; 303 $self->cmp_Error($ans,@errors); return;
303 } 304 }
304} 305}
305 306
329# for incorrect coordinates 330# for incorrect coordinates
330# 331#
331sub cmp_postprocess { 332sub cmp_postprocess {
332 my $self = shift; my $ans = shift; 333 my $self = shift; my $ans = shift;
333 return unless $ans->{score} == 0; 334 return unless $ans->{score} == 0;
335 my $student = $ans->{student_value};
336 return if $ans->{ignoreStrings} && (!Value::isValue($student) || $student->type eq 'String');
334 if (!$ans->{isPreview} && $ans->{showDimensionHints} && 337 if (!$ans->{isPreview} && $ans->{showDimensionHints} &&
335 $self->length != $ans->{student_value}->length) { 338 $self->length != $student->length) {
336 $self->cmp_Error($ans,"The dimension of your result is incorrect"); return; 339 $self->cmp_Error($ans,"The dimension of your result is incorrect"); return;
337 } 340 }
338 if ($ans->{parallel} && 341 if ($ans->{parallel} &&
339 $self->isParallel($ans->{student_value},$ans->{sameDirection})) { 342 $self->isParallel($student,$ans->{sameDirection})) {
340 $ans->score(1); return; 343 $ans->score(1); return;
341 } 344 }
342 if (!$ans->{isPreview} && $ans->{showCoordinateHints} && !$ans->{parallel}) { 345 if (!$ans->{isPreview} && $ans->{showCoordinateHints} && !$ans->{parallel}) {
343 my @errors; 346 my @errors;
344 foreach my $i (1..$self->length) { 347 foreach my $i (1..$self->length) {
345 push(@errors,"The ".$self->NameForNumber($i)." coordinate is incorrect") 348 push(@errors,"The ".$self->NameForNumber($i)." coordinate is incorrect")
346 if ($self->{data}[$i-1] != $ans->{student_value}{data}[$i-1]); 349 if ($self->{data}[$i-1] != $student->{data}[$i-1]);
347 } 350 }
348 $self->cmp_Error($ans,@errors); return; 351 $self->cmp_Error($ans,@errors); return;
349 } 352 }
350} 353}
351 354
371 374
372sub cmp_postprocess { 375sub cmp_postprocess {
373 my $self = shift; my $ans = shift; 376 my $self = shift; my $ans = shift;
374 return unless $ans->{score} == 0 && 377 return unless $ans->{score} == 0 &&
375 !$ans->{isPreview} && $ans->{showDimensionHints}; 378 !$ans->{isPreview} && $ans->{showDimensionHints};
379 my $student = $ans->{student_value};
380 return if $ans->{ignoreStrings} && (!Value::isValue($student) || $student->type eq 'String');
376 my @d1 = $self->dimensions; my @d2 = $ans->{student_value}->dimensions; 381 my @d1 = $self->dimensions; my @d2 = $student->dimensions;
377 if (scalar(@d1) != scalar(@d2)) { 382 if (scalar(@d1) != scalar(@d2)) {
378 $self->cmp_Error($ans,"Matrix dimension is not correct"); 383 $self->cmp_Error($ans,"Matrix dimension is not correct");
379 return; 384 return;
380 } else { 385 } else {
381 foreach my $i (0..scalar(@d1)-1) { 386 foreach my $i (0..scalar(@d1)-1) {
412# 417#
413sub cmp_postprocess { 418sub cmp_postprocess {
414 my $self = shift; my $ans = shift; 419 my $self = shift; my $ans = shift;
415 return unless $ans->{score} == 0 && !$ans->{isPreview}; 420 return unless $ans->{score} == 0 && !$ans->{isPreview};
416 my $other = $ans->{student_value}; 421 my $other = $ans->{student_value};
422 return if $ans->{ignoreStrings} && (!Value::isValue($other) || $other->type eq 'String');
417 return unless $other->class eq 'Interval'; 423 return unless $other->class eq 'Interval';
418 my @errors; 424 my @errors;
419 if ($ans->{showEndpointHints}) { 425 if ($ans->{showEndpointHints}) {
420 push(@errors,"Your left endpoint is incorrect") 426 push(@errors,"Your left endpoint is incorrect")
421 if ($self->{data}[0] != $other->{data}[0]); 427 if ($self->{data}[0] != $other->{data}[0]);
507 my $showTypeWarnings = $ans->{showTypeWarnings}; 513 my $showTypeWarnings = $ans->{showTypeWarnings};
508 my $showHints = getOption($ans,'showHints'); 514 my $showHints = getOption($ans,'showHints');
509 my $showLengthHints = getOption($ans,'showLengthHints'); 515 my $showLengthHints = getOption($ans,'showLengthHints');
510 my $showParenHints = getOption($ans,'showLengthHints'); 516 my $showParenHints = getOption($ans,'showLengthHints');
511 my $partialCredit = getOption($ans,'partialCredit'); 517 my $partialCredit = getOption($ans,'partialCredit');
512 my $ordered = $ans->{ordered}; 518 my $ordered = $ans->{ordered};
513 my $requireParenMatch = $ans->{requireParenMatch}; 519 my $requireParenMatch = $ans->{requireParenMatch};
514 my $typeMatch = $ans->{typeMatch}; 520 my $typeMatch = $ans->{typeMatch};
515 my $value = $ans->{entry_type}; 521 my $value = $ans->{entry_type};
516 my $ltype = $ans->{list_type} || lc($self->type); 522 my $ltype = $ans->{list_type} || lc($self->type);
517 523
749sub cmp_postprocess { 755sub cmp_postprocess {
750 my $self = shift; my $ans = shift; 756 my $self = shift; my $ans = shift;
751 return unless $ans->{score} == 0 && !$ans->{isPreview}; 757 return unless $ans->{score} == 0 && !$ans->{isPreview};
752 return if $ans->{ans_message} || !$ans->{showDimensionHints}; 758 return if $ans->{ans_message} || !$ans->{showDimensionHints};
753 my $other = $ans->{student_value}; 759 my $other = $ans->{student_value};
760 return if $ans->{ignoreStrings} && (!Value::isValue($other) || $other->type eq 'String');
754 return unless $other->type =~ m/^(Point|Vector|Matrix)$/; 761 return unless $other->type =~ m/^(Point|Vector|Matrix)$/;
755 return unless $self->type =~ m/^(Point|Vector|Matrix)$/; 762 return unless $self->type =~ m/^(Point|Vector|Matrix)$/;
756 return if Parser::Item::typeMatch($self->typeRef,$other->typeRef); 763 return if Parser::Item::typeMatch($self->typeRef,$other->typeRef);
757 $self->cmp_Error($ans,"The dimension of your result is incorrect"); 764 $self->cmp_Error($ans,"The dimension of your result is incorrect");
758} 765}

Legend:
Removed from v.3204  
changed lines
  Added in v.3205

aubreyja at gmail dot com
ViewVC Help
Powered by ViewVC 1.0.9