Show a mathInput if a choice is selected

I’d like for the following behavior to occur but neither of my approaches seems to be working.

The user is shown a multiple choice question where part of the choice is only displayed if the user selects that choice. Below, I want to present the user with a math input box only if the user selects the particular choice but I am running into a circular dependency.

<problem>
  <p>Which of the following is true of <m>x^2-1</m>? Select all that apply.</p>
  <choiceInput>
    <choice name="choice4">
      The expression can be factored by using the difference of squares formula
      <conditionalContent>
        <case condition="$choice4.selected=true">
          and it factors to <mathInput name="userInput1" />
        </case>
        <else>.</else>
      </conditionalContent>
    </choice>
  </choiceInput>
</problem>

I’ve also tried the following but ran into a circular dependency again.

<setup>
  <boolean name="c4selected">$choice4.selected</boolean>
</setup>

<problem>
  <p>Which of the following is true of <m>x^2-1</m>? Select all that apply.</p>
  <choiceInput>
    <choice name="choice4">
      The expression can be factored by using the difference of squares formula
      <conditionalContent>
        <case condition="$c4selected=true">
          and it factors to <mathInput name="userInput1" />
        </case>
        <else>.</else>
      </conditionalContent>
    </choice>
  </choiceInput>
</problem>

Can you use a hide instead of conditionalContent? That has gotten around circular dependencies for me before.

I don’t know if this is the best method or not, but what I’ve sometimes done for text and math mixed is wrap the content in a <span> and put the hide condition on the span.

This now works with the latest dev version of DoenetML. (You’ll probably need to clear your browser cache.)