Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 14 additions & 13 deletions lib/Value/AnswerChecker.pm
Original file line number Diff line number Diff line change
Expand Up @@ -194,9 +194,9 @@ sub cmp_collect {
return 1 unless $self->{ans_name};
$ans->{preview_latex_string} = $ans->{preview_text_string} = "";
my $OK = $self->ans_collect($ans);
$ans->{student_ans} = $self->format_matrix($ans->{student_formula}, @{ $self->{format_options} }, tth_delims => 1);
$ans->{student_ans} = $self->format_matrix($ans->{student_array}, @{ $self->{format_options} }, tth_delims => 1);
return 0 unless $OK;
my $array = $ans->{student_formula};
my $array = $ans->{student_array};

if ($self->{ColumnVector}) {
my @V = ();
Expand Down Expand Up @@ -295,7 +295,7 @@ sub cmp_list_compare { Value::List::cmp_list_compare(@_) }
sub typeMatch {
my $self = shift;
my $other = shift;
return 1 unless ref($other);
return 1 unless Value::isValue($other);
$self->type eq $other->type && !$other->isFormula;
}

Expand Down Expand Up @@ -728,8 +728,9 @@ sub ans_collect {
}
push(@array, [@row]);
}
$ans->{student_formula} = [@array];
$ans->{ans_message} = $ans->{error_message} = "";
delete $ans->{student_formula};
$ans->{student_array} = [@array];
$ans->{ans_message} = $ans->{error_message} = '';
if (scalar(@{$errors})) {
$ans->{ans_message} = $ans->{error_message} =
'<TABLE BORDER="0" CELLSPACING="0" CELLPADDING="0" CLASS="ArrayLayout">'
Expand Down Expand Up @@ -851,7 +852,7 @@ sub typeMatch {
my $self = shift;
my $other = shift;
my $ans = shift;
return 1 unless ref($other);
return 1 unless Value::isValue($other);
return 0 if Value::isFormula($other);
return 1 if $other->type eq 'Infinity' && $ans->{ignoreInfinity};
$self->type eq $other->type;
Expand All @@ -867,7 +868,7 @@ sub typeMatch {
my $self = shift;
my $other = shift;
my $ans = shift;
return 1 unless ref($other);
return 1 unless Value::isValue($other);
return 0 if Value::isFormula($other);
return 1 if $other->type eq 'Number';
$self->type eq $other->type;
Expand Down Expand Up @@ -995,7 +996,7 @@ sub typeMatch {
my $self = shift;
my $other = shift;
my $ans = shift;
return ref($other) && $other->type eq 'Point' && !$other->isFormula;
return Value::isValue($other) && $other->type eq 'Point' && !$other->isFormula;
}

#
Expand Down Expand Up @@ -1085,7 +1086,7 @@ sub typeMatch {
my $self = shift;
my $other = shift;
my $ans = shift;
return 0 unless ref($other) && !$other->isFormula;
return 0 unless Value::isValue($other) && !$other->isFormula;
return $other->type eq 'Vector'
|| ($ans->{promotePoints} && $other->type eq 'Point');
}
Expand Down Expand Up @@ -1213,7 +1214,7 @@ sub typeMatch {
my $self = shift;
my $other = shift;
my $ans = shift;
return 0 unless ref($other) && !$other->isFormula;
return 0 unless Value::isValue($other) && !$other->isFormula;
return $other->type eq 'Matrix'
|| ($other->type =~ m/^(Point|List)$/
&& $other->{open} . $other->{close} eq $self->{open} . $self->{close});
Expand Down Expand Up @@ -1439,7 +1440,7 @@ package Value::Union;
sub typeMatch {
my $self = shift;
my $other = shift;
return 0 unless ref($other) && !$other->isFormula;
return 0 unless Value::isValue($other) && !$other->isFormula;
return
$other->length == 2
&& ($other->{open} eq '(' || $other->{open} eq '[')
Expand Down Expand Up @@ -1549,7 +1550,7 @@ sub cmp_defaults {
#
# Match anything but formulas
#
sub typeMatch { return !ref($other) || !$other->isFormula }
sub typeMatch { return !Value::isValue($other) || !$other->isFormula }

#
# Handle removal of outermost parens in correct answer.
Expand Down Expand Up @@ -1901,7 +1902,7 @@ sub typeMatch {
my $self = shift;
my $other = shift;
my $ans = shift;
return 1 if $self->type eq $other->type;
return 1 if !Value::isValue($other) || $self->type eq $other->type;
my $typeMatch = $self->getTypicalValue($self);
$other = $self->getTypicalValue($other, 1) if Value::isFormula($other);
return 1 unless defined($other); # can't really tell, so don't report type mismatch
Expand Down
Loading