| … | |
… | |
| 647 | return ( |
647 | return ( |
| 648 | Value::Union::cmp_defaults($self,@_), |
648 | Value::Union::cmp_defaults($self,@_), |
| 649 | typeMatch => Value::Formula->new("(1,2]"), |
649 | typeMatch => Value::Formula->new("(1,2]"), |
| 650 | ) if $self->type eq 'Union'; |
650 | ) if $self->type eq 'Union'; |
| 651 | |
651 | |
| 652 | return Value::Real::cmp_defaults($self,@_) unless $self->type eq 'List'; |
652 | my $type = $self->type; |
|
|
653 | $type = ($self->isComplex)? 'Complex': 'Real' if $type eq 'Number'; |
|
|
654 | $type = 'Value::'.$type.'::'; |
|
|
655 | |
|
|
656 | return (&{$type.'cmp_defaults'}($self,@_)) |
|
|
657 | if defined(%$type) && $self->type ne 'List'; |
| 653 | |
658 | |
| 654 | return ( |
659 | return ( |
| 655 | Value::List::cmp_defaults($self,@_), |
660 | Value::List::cmp_defaults($self,@_), |
| 656 | removeParens => $self->{autoFormula}, |
661 | removeParens => $self->{autoFormula}, |
| 657 | typeMatch => Value::Formula->new(($self->createRandomPoints(1))[1]->[0]{data}[0]), |
662 | typeMatch => Value::Formula->new(($self->createRandomPoints(1))[1]->[0]{data}[0]), |
| … | |
… | |
| 702 | } else { |
707 | } else { |
| 703 | $self->SUPER::cmp_equal($ans); |
708 | $self->SUPER::cmp_equal($ans); |
| 704 | } |
709 | } |
| 705 | } |
710 | } |
| 706 | |
711 | |
| 707 | # |
712 | sub cmp_postprocess { |
| 708 | # Replace the ones in Value::Formula |
713 | my $self = shift; my $ans = shift; |
| 709 | # |
714 | return unless $ans->{score} == 0 && !$ans->{isPreview}; |
| 710 | sub PGseedRandom { |
715 | return if $ans->{ans_message} || !$ans->{showDimensionHints}; |
| 711 | my $self = shift; |
716 | my $other = $ans->{student_value}; |
| 712 | return if $self->{PGrandom}; |
717 | return unless $other->type =~ m/^(Point|Vector|Matrix)$/; |
| 713 | $self->{PGrandom} = new PGrandom($self->{context}->flag('random_seed')); |
718 | return unless $self->type =~ m/^(Point|Vector|Matrix)$/; |
|
|
719 | return if Parser::Item::typeMatch($self->typeRef,$other->typeRef); |
|
|
720 | $self->cmp_Error($ans,"The dimension is incorrect"); |
| 714 | } |
721 | } |
| 715 | sub PGgetRandom {shift->{PGrandom}->random(@_)} |
|
|
| 716 | |
722 | |
| 717 | ############################################################# |
723 | ############################################################# |
| 718 | |
724 | |
| 719 | 1; |
725 | 1; |