Open Alex-Jordan opened 3 years ago
It seems that the ans_array method modifies the object used for the answer itself. If you use a different object for the two answers this problem does not occur. So if you change your code to the following this is not a problem:
DOCUMENT();
loadMacros("PGstandard.pl", "MathObjects.pl", "PGML.pl");
Context("Vector");
$vector1 = Vector("<1,0,0>");
$vector2 = Vector("<1,0,0>");
Context("Matrix");
$matrix1 = Matrix("[[1,0],[0,1]]");
$matrix2 = Matrix("[[1,0],[0,1]]");
BEGIN_PGML
a. What vector in [`\mathbb{R}^3`] is the unit vector along the [`x`]-axis?
[_]{$vector1}{10}
a. What is the [`2\times2`] identity matrix?
[_]{$matrix1}{10}
a. What vector in [`\mathbb{R}^3`] is the unit vector along the [`x`]-axis?
[_]*{$vector2}{1}
a. What is the [`2\times2`] identity matrix?
[_]*{$matrix2}{1}
END_PGML
ENDDOCUMENT();
But should it be considered a bug that the ans_array method does that?
It seems highly unlikely that the same Matrix would be used as an answer multiple times in the same problem -- so I'd say we look into fixing it, but it seems low priority?
Yeah, I think it is a bug that should be fixed, but I agree that its priority is not high. For now, use a different answer object for this.
I ran across this in one of my problems and was going to file an issue when I found this. My test case is slightly different, so here it is in case it can help track down the cause.
DOCUMENT();
loadMacros(
"PGstandard.pl",
"PGML.pl",
);
TEXT(beginproblem());
$showPartialCorrectAnswers = 1;
Context('Matrix');
$v1 = Matrix([[1],[2]]);
BEGIN_PGML
Enter in the two vector [``\vec{\bf v}_1=[$v1]``].
a) First Answer:
[__]*{$v1}
b) Second Answer:
[__]*{$v1}
END_PGML
ENDDOCUMENT();
In this case, what is entered in the second part of the ans_array gets used in both answers, but the first part isn't changed.
Consider this problem code:
When I submit the answers:
Somehow the answers I submit to the first two answer fields are interpreted as first entries of the vector or matrix object instead of the entire vector or matrix.
If I remove the third and fourth questions that use an answer input array, then the first two answer blanks behave. Or if I just remove one of the last two questions, then the corresponding question from the first half behaves, but still not the other one.
It is as if using the answer input array is doing something to these mathobjects that persists longer than it should, and then later during an answer check, that breaks the answer checking.