Coloring fractionInput boxes

As far as I can tell, the boxes for fractionInput are never colored when they are inside an answer. Can you make that happen?

Green when fraction is correct would help. Red when both parts are incorrect, or when the credit is awarded for a single fraction, seems noncontroversial to me.

In my ideal world, I would want to color each input separately if I have defined the answer to award based on the numerator and denominator separately, because right now, I’m using fractionInput as a visual device and to enforce doing a problem in steps, like in part a of this work-in-progress.

But even if that behavior tricky or not universally desired, I think turning both boxes green when it’s correct would be good.

+1

Oops, I missed adding coloring support to fractionInput.

I’m not sure what to do about coloring pieces individually. That would extend beyond fractionInput and should involve any input boxes.

It would hard to get individual coloring to work from

<answer>
  <fractionInput name="fi" />
  <award matchPartial><when>
    $fi.numerator=2 and $fi.denominator=3
  </when></award>
</answer>

or more generally from

<mathInput name="mi1" forAnswer="$ans" />
<mathInput name="mi2" forAnswer="$ans" />
<answer name="ans">
  <award matchPartial><when>
    $mi1 = 1 and $mi2 = 2
  </when></award>
</answer>

as we don’t have a way to map back which part of the logic inside the <when> contributed to the fraction correct.

It would probably be easier to support differentiated coloring with markup where the link between the credit and input box is explicitly spelled out. For example using multiple awards such as this

<answer numAwardsCredited="2">
  <fractionInput name="fi" />
  <award credit="0.5"><when>
    $fi.numerator=2
  </when></award>
  <award credit="0.5"><when>
    $fi.denominator=3
  </when></award>
</answer>

Would that be too much to ask authors to use that more complicated syntax?

I created a bug report for the lack of coloring of a fractionInput. I created a feature request for coloring inputs separately.

The bug for coloring fraction inputs was fixed earlier on the dev version, though I neglected to mention it.

Now, I have released a dev version with the new attribute colorInputSeparately. (For consistency, I have renamed the attribute forceIndividualAnswerColoring to colorAnswersSeparately, though the old attribute it still accepted with a warning.)

The colorInputsSeparately attribute is designed to work when you have multiple awards with numAwardsCredited equal to the number of inputs and you have one award per input with credits that add up to 1. If you don’t follow that specific structure, you may get unexpected results. I didn’t get it to work generally with compound statements inside a <when>.

Here are two examples that now work on “0.7dev”:

<answer colorInputsSeparately numAwardsCredited="2">
  <fractionInput name="fi">
    <label>Enter 2/3</label>
  </fractionInput>
  <award credit="0.5"><when>$fi.numerator=2</when></award>
  <award credit="0.5"><when>$fi.denominator=3</when></award>
</answer>
<p><mathInput name="mi1" forAnswer="$ans"><label>Enter 2:</label></mathInput></p>
<p><mathInput name="mi2" forAnswer="$ans"><label>Enter 3:</label></mathInput></p>
<answer name="ans" colorInputsSeparately numAwardsCredited="2">
  <award credit="0.5"><when>$mi1=2</when></award>
  <award credit="0.5"><when>$mi2=3</when></award>
</answer>

The second one could arguably be more easily implemented with two answers and a sectionWideCheckWork in a <div> with colorAnswersSeparately. But, colorInputsSeparately in a single answer is the only way that works to separately color the numerator and denominator of a fraction input.

Awesome, thank you!

I might have been one of the only users of forceIndividualAnswerColoring, but I used it extensively in dozens of problems, so please keep allowing it for a while at least!

Except for limited exceptions (such as when we released an attribute for only a few days and then thought better of it), we won’t remove any attributes until our next major release 0.8. (We don’t currently have a roadmap for 0.8 yet, so I don’t know when that is.)