| … | |
… | |
| 433 | # messages. |
433 | # messages. |
| 434 | # |
434 | # |
| 435 | sub cmp_defaults {( |
435 | sub cmp_defaults {( |
| 436 | Value::List::cmp_defaults(@_), |
436 | Value::List::cmp_defaults(@_), |
| 437 | typeMatch => 'Value::Interval', |
437 | typeMatch => 'Value::Interval', |
| 438 | list_type => 'union', |
438 | list_type => 'a union', |
| 439 | entry_type => 'an interval', |
439 | entry_type => 'an interval', |
| 440 | )} |
440 | )} |
| 441 | |
441 | |
| 442 | sub cmp_equal {Value::List::cmp_equal(@_)} |
442 | sub cmp_equal {Value::List::cmp_equal(@_)} |
| 443 | |
443 | |
| … | |
… | |
| 453 | showLengthHints => undef, |
453 | showLengthHints => undef, |
| 454 | # partialCredit => undef, |
454 | # partialCredit => undef, |
| 455 | partialCredit => 0, # only allow this once WW can deal with partial credit |
455 | partialCredit => 0, # only allow this once WW can deal with partial credit |
| 456 | ordered => 0, |
456 | ordered => 0, |
| 457 | entry_type => undef, |
457 | entry_type => undef, |
| 458 | list_type => lc($self->type), |
458 | list_type => undef, |
| 459 | typeMatch => Value::makeValue($self->{data}[0]), |
459 | typeMatch => Value::makeValue($self->{data}[0]), |
| 460 | allowParens => 0, |
460 | allowParens => 0, |
| 461 | showParens => 0, |
461 | showParens => 0, |
| 462 | ); |
462 | ); |
| 463 | } |
463 | } |
| … | |
… | |
| 492 | my $showLengthHints = getOption($ans,'showLengthHints'); |
492 | my $showLengthHints = getOption($ans,'showLengthHints'); |
| 493 | my $partialCredit = getOption($ans,'partialCredit'); |
493 | my $partialCredit = getOption($ans,'partialCredit'); |
| 494 | my $ordered = $ans->{ordered}; my $allowParens = $ans->{allowParens}; |
494 | my $ordered = $ans->{ordered}; my $allowParens = $ans->{allowParens}; |
| 495 | my $typeMatch = $ans->{typeMatch}; |
495 | my $typeMatch = $ans->{typeMatch}; |
| 496 | my $value = $ans->{entry_type}; |
496 | my $value = $ans->{entry_type}; |
| 497 | my $ltype = $ans->{list_type}; |
497 | my $ltype = $ans->{list_type} || lc($self->type); |
| 498 | |
498 | |
| 499 | $value = (Value::isValue($typeMatch)? lc($typeMatch->cmp_class): 'value') |
499 | $value = (Value::isValue($typeMatch)? lc($typeMatch->cmp_class): 'value') |
| 500 | unless defined($value); |
500 | unless defined($value); |
| 501 | $value =~ s/(real|complex) //; $ans->{cmp_class} = $value; |
501 | $value =~ s/(real|complex) //; $ans->{cmp_class} = $value; |
| 502 | $value =~ s/^an? //; $value = 'formula' if $value =~ m/formula/; |
502 | $value =~ s/^an? //; $value = 'formula' if $value =~ m/formula/; |
|
|
503 | $ltype =~ s/^an? //; |
| 503 | $showTypeWarnings = $showHints = $showLengthHints = 0 if $ans->{isPreview}; |
504 | $showTypeWarnings = $showHints = $showLengthHints = 0 if $ans->{isPreview}; |
| 504 | |
505 | |
| 505 | # |
506 | # |
| 506 | # Get the lists of correct and student answers |
507 | # Get the lists of correct and student answers |
| 507 | # (split formulas that return lists or unions) |
508 | # (split formulas that return lists or unions) |
| … | |
… | |
| 511 | else {@correct = Value::List->splitFormula($self,$ans)} |
512 | else {@correct = Value::List->splitFormula($self,$ans)} |
| 512 | my $student = $ans->{student_value}; |
513 | my $student = $ans->{student_value}; |
| 513 | my @student = ($student); |
514 | my @student = ($student); |
| 514 | if ($student->class eq 'Formula' && $student->type eq $self->type) { |
515 | if ($student->class eq 'Formula' && $student->type eq $self->type) { |
| 515 | @student = Value::List->splitFormula($student,$ans); |
516 | @student = Value::List->splitFormula($student,$ans); |
| 516 | } elsif ($student->class ne 'Formula' && $student->class eq $self->class && |
517 | } elsif ($student->class ne 'Formula' && $student->class eq $self->type && |
| 517 | ($allowParens || (!$student->{open} && !$student->{close}))) { |
518 | ($allowParens || (!$student->{open} && !$student->{close}))) { |
| 518 | @student = @{$student->{data}}; |
519 | @student = @{$student->{data}}; |
| 519 | } |
520 | } |
| 520 | return if $ans->{split_error}; |
521 | return if $ans->{split_error}; |
| 521 | if (scalar(@correct) == 0 && scalar(@student) == 0) {$ans->score(1); return} |
522 | if (scalar(@correct) == 0 && scalar(@student) == 0) {$ans->score(1); return} |
| … | |
… | |
| 546 | } |
547 | } |
| 547 | } |
548 | } |
| 548 | # |
549 | # |
| 549 | # Give messages about incorrect answers |
550 | # Give messages about incorrect answers |
| 550 | # |
551 | # |
| 551 | my $nth = ''; my $answer = 'answer'; my $class = $self->cmp_class; |
552 | my $nth = ''; my $answer = 'answer'; |
|
|
553 | my $class = $ans->{list_type} || $self->cmp_class; |
| 552 | if (scalar(@student) > 1) { |
554 | if (scalar(@student) > 1) { |
| 553 | $nth = ' '.$self->NameForNumber($i); |
555 | $nth = ' '.$self->NameForNumber($i); |
| 554 | $class = $ans->{cmp_class}; |
556 | $class = $ans->{cmp_class}; |
| 555 | $answer = 'value'; |
557 | $answer = 'value'; |
| 556 | } |
558 | } |
| … | |
… | |
| 650 | $other = eval {($other->createRandomPoints(1))[1]->[0]} if ($other->class eq 'Formula'); |
652 | $other = eval {($other->createRandomPoints(1))[1]->[0]} if ($other->class eq 'Formula'); |
| 651 | return 1 unless defined($other); # can't really tell, so don't report type mismatch |
653 | return 1 unless defined($other); # can't really tell, so don't report type mismatch |
| 652 | $typeMatch->typeMatch($other,$ans); |
654 | $typeMatch->typeMatch($other,$ans); |
| 653 | } |
655 | } |
| 654 | |
656 | |
|
|
657 | # |
|
|
658 | # Handle removal of outermost parens in a list. |
|
|
659 | # |
|
|
660 | sub cmp { |
|
|
661 | my $self = shift; |
|
|
662 | my $cmp = $self->SUPER::cmp(@_); |
|
|
663 | if (!$cmp->{rh_ans}{showParens} && $self->type eq 'List') { |
|
|
664 | $self->{tree}{open} = $self->{tree}{close} = ''; |
|
|
665 | $cmp->ans_hash(correct_ans => $self->stringify); |
|
|
666 | } |
|
|
667 | return $cmp; |
|
|
668 | } |
|
|
669 | |
| 655 | sub cmp_equal { |
670 | sub cmp_equal { |
| 656 | my $self = shift; my $ans = shift; |
671 | my $self = shift; my $ans = shift; |
| 657 | # |
672 | # |
| 658 | # Get the problem's seed |
673 | # Get the problem's seed |
| 659 | # |
674 | # |