openwebwork/webwork2 — pull request #460 by dpvc (2014-08-05 23:58:11+00:00)
Title: Patch for input colors (correct/incorrect)

This rewrites the color.js file that adds colors to the input fields for correct/incorrect colors. It requires the corresponding pull request from pg in order to work.

Prior to this patch, the colors for MathObject `ans_array` calls (for Matrix, Vector, Point) only colored the first entry. This should resolve that.

Also, MultiAnswer objects with `singleResults=>1` only colored the first blank. This should resolve that as well. Mixing MultiAnswer with Matrix Arrays should color properly as well.

Test cases are of the form:

```
loadMacros("parserMultiAnswer.pl");
loadMacros("parserRadioButtons.pl");

Context("Matrix");
$M = Matrix([1,2],[3,4]);
$V = Vector(1,2,3);

$ma = MultiAnswer($M,$P)->with(
singleResult => 1,
checker => sub {
my ($correct,$student) = @_;
my ($c1,$c2) = @$correct;
my ($s1,$s2) = @$student;
return (1,1) if $c1 == $s1 && $c2 == $s2;
return (1,0) if $c1 == $s1;
return (0,1) if $c2 == $s2;
return (0,0);
}
);

BEGIN_TEXT
\{$ma->ans_array\} and \{$ma->ans_array\}
END_TEXT

ANS($ma->cmp);
```

One should also use `singleResult=>0`, and try with PopUp and RadioButton objects as well.