Don't use student_formula to collect matrix array and update typeMatch methods.#1407
Don't use student_formula to collect matrix array and update typeMatch methods.#1407somiaj wants to merge 2 commits into
Conversation
|
The It was probably a mistake to use diff --git a/lib/Value/AnswerChecker.pm b/lib/Value/AnswerChecker.pm
index ec6a6b9b..1d4eba90 100644
--- a/lib/Value/AnswerChecker.pm
+++ b/lib/Value/AnswerChecker.pm
@@ -201,9 +201,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 = ();
@@ -735,7 +735,8 @@ sub ans_collect {
}
push(@array, [@row]);
}
- $ans->{student_formula} = [@array];
+ delete $ans->{student_formula};
+ $ans->{student_array} = [@array];
$ans->{ans_message} = $ans->{error_message} = "";
if (scalar(@{$errors})) {
$ans->{ans_message} = $ans->{error_message} =This resolve the problem at the source, and potentially prevents future problems. On the other hand, the Note, however, that the other I would recommend using |
When collecting a matrix array answer use `student_array` instead of `student_formula` as `student_formula` should always be a formula, and this could fail to convert to a formula if an answer blank is left empty, causing a future `typeMatch` error. Fixes openwebwork#1406.
When checking if `$other` is an object, check that it is actually a `Value` object instead just that it is a reference in the various `typeMatch` methods. This is done by using `Value::isValue($other)` instead of `ref($other)`. In addition add a test for `Value::isValue($other)` in the `Value::Formula::typeMatch` method to be consistent with the other methods. This was suggested by @dpvc.
7466222 to
b214dab
Compare
|
I updated the fix as suggested by @dpvc to collect the matrix array into a new key, I also added a second commit suggested by @dpvc to update the |
When collecting a matrix array answer use
student_arrayinstead ofstudent_formulaasstudent_formulashould always be a formula, and this could fail to convert to a formula if an answer blank is left empty, causing a futuretypeMatcherror.Fixes #1406.
In addition update the
typeMatchmethods as suggested by @dpvc. When checking if$otheris an object, check that it is actually aValueobject instead just that it is a reference in the varioustypeMatchmethods. This is done by usingValue::isValue($other)instead ofref($other).