| … | |
… | |
| 746 | my $self = shift; |
746 | my $self = shift; |
| 747 | |
747 | |
| 748 | return ( |
748 | return ( |
| 749 | Value::Union::cmp_defaults($self,@_), |
749 | Value::Union::cmp_defaults($self,@_), |
| 750 | typeMatch => Value::Formula->new("(1,2]"), |
750 | typeMatch => Value::Formula->new("(1,2]"), |
|
|
751 | showDomainErrors => 1, |
| 751 | ) if $self->type eq 'Union'; |
752 | ) if $self->type eq 'Union'; |
| 752 | |
753 | |
| 753 | my $type = $self->type; |
754 | my $type = $self->type; |
| 754 | $type = ($self->isComplex)? 'Complex': 'Real' if $type eq 'Number'; |
755 | $type = ($self->isComplex)? 'Complex': 'Real' if $type eq 'Number'; |
| 755 | $type = 'Value::'.$type.'::'; |
756 | $type = 'Value::'.$type.'::'; |
| 756 | |
757 | |
| 757 | return (&{$type.'cmp_defaults'}($self,@_), upToConstant => 0) |
758 | return ( |
|
|
759 | &{$type.'cmp_defaults'}($self,@_), |
|
|
760 | upToConstant => 0, |
|
|
761 | showDomainErrors => 1, |
| 758 | if defined(%$type) && $self->type ne 'List'; |
762 | ) if defined(%$type) && $self->type ne 'List'; |
| 759 | |
763 | |
| 760 | return ( |
764 | return ( |
| 761 | Value::List::cmp_defaults($self,@_), |
765 | Value::List::cmp_defaults($self,@_), |
| 762 | removeParens => $self->{autoFormula}, |
766 | removeParens => $self->{autoFormula}, |
| 763 | typeMatch => Value::Formula->new(($self->createRandomPoints(1))[1]->[0]{data}[0]), |
767 | typeMatch => Value::Formula->new(($self->createRandomPoints(1))[1]->[0]{data}[0]), |
|
|
768 | showDomainErrors => 1, |
| 764 | ); |
769 | ); |
| 765 | } |
770 | } |
| 766 | |
771 | |
| 767 | # |
772 | # |
| 768 | # Get the types from the values of the formulas |
773 | # Get the types from the values of the formulas |
| … | |
… | |
| 798 | Parser::Context->current(undef,$context); |
803 | Parser::Context->current(undef,$context); |
| 799 | $context->{_variables}->{pattern} = $context->{_variables}->{namePattern} = |
804 | $context->{_variables}->{pattern} = $context->{_variables}->{namePattern} = |
| 800 | 'C0|' . $context->{_variables}->{pattern}; |
805 | 'C0|' . $context->{_variables}->{pattern}; |
| 801 | $context->update; $context->variables->add('C0' => 'Parameter'); |
806 | $context->update; $context->variables->add('C0' => 'Parameter'); |
| 802 | my $f = Value::Formula->new('C0')+$self; |
807 | my $f = Value::Formula->new('C0')+$self; |
| 803 | for ('limits','test_points','test_values','num_points','granularity','resolution') |
808 | for ('limits','test_points','test_values','num_points','granularity','resolution', |
|
|
809 | 'checkUndefinedPoints','max_undefined') |
| 804 | {$f->{$_} = $self->{$_} if defined($self->{$_})} |
810 | {$f->{$_} = $self->{$_} if defined($self->{$_})} |
| 805 | $cmp->ans_hash(correct_value => $f); |
811 | $cmp->ans_hash(correct_value => $f); |
| 806 | Parser::Context->current(undef,$current); |
812 | Parser::Context->current(undef,$current); |
| 807 | } |
813 | } |
| 808 | return $cmp; |
814 | return $cmp; |
| … | |
… | |
| 829 | } |
835 | } |
| 830 | |
836 | |
| 831 | sub cmp_postprocess { |
837 | sub cmp_postprocess { |
| 832 | my $self = shift; my $ans = shift; |
838 | my $self = shift; my $ans = shift; |
| 833 | return unless $ans->{score} == 0 && !$ans->{isPreview}; |
839 | return unless $ans->{score} == 0 && !$ans->{isPreview}; |
|
|
840 | return if $ans->{ans_message}; |
|
|
841 | if ($self->{domainMismatch} && $ans->{showDomainErrors}) { |
|
|
842 | $self->cmp_Error($ans,"The domain of your function doesn't match that of the correct answer"); |
|
|
843 | return; |
|
|
844 | } |
| 834 | return if $ans->{ans_message} || !$ans->{showDimensionHints}; |
845 | return if !$ans->{showDimensionHints}; |
| 835 | my $other = $ans->{student_value}; |
846 | my $other = $ans->{student_value}; |
| 836 | return if $ans->{ignoreStrings} && (!Value::isValue($other) || $other->type eq 'String'); |
847 | return if $ans->{ignoreStrings} && (!Value::isValue($other) || $other->type eq 'String'); |
| 837 | return unless $other->type =~ m/^(Point|Vector|Matrix)$/; |
848 | return unless $other->type =~ m/^(Point|Vector|Matrix)$/; |
| 838 | return unless $self->type =~ m/^(Point|Vector|Matrix)$/; |
849 | return unless $self->type =~ m/^(Point|Vector|Matrix)$/; |
| 839 | return if Parser::Item::typeMatch($self->typeRef,$other->typeRef); |
850 | return if Parser::Item::typeMatch($self->typeRef,$other->typeRef); |