Skip to content

False schema warning for <choices> inside <exercise> in valid multiple-choice PreTeXt markup #172

@geoff-cox

Description

@geoff-cox

These are common exercise interactives, so I am sure you are aware of these warnings by now (unless I am doing something wrong).

I am seeing a validation warning in VS Code from pretext-tools for markup that appears to be valid and builds correctly.

Warning

element "choices" not allowed here; 
expected the element end-tag or element "answer", "hint", 
or "solution"
  • The project builds successfully.
  • The output renders correctly.
  • The warning appears only when the PreTeXt-tools extension is enabled in VS Code.
  • If I disable PreTeXt-tools, the warning goes away.

Minimal Example

<exercise xml:id="ex-product-rule-mc">
  <title>Spot the derivative</title>

  <statement>
    <p>
      Which of the following is the derivative of 
      <m>h(x) = x^2 \sin(x)</m>?
    </p>
  </statement>

  <choices randomize="yes">
    <choice>
      <statement>
        <p>
          <m>h'(x) = 2x \cos(x)</m>
        </p>
      </statement>
      <feedback>
        <p>
          It is tempting to take the derivative directly 
          like this, but the correct approach is
          <md>(fg)' = f'g + fg'</md>.
        </p>
      </feedback>
    </choice>

    <choice correct="yes">
      <statement>
        <p>
          <m>h'(x) = 2x\sin(x) + x^2\cos(x)</m>
        </p>
      </statement>
      <feedback>
        <p>
          With <m>f = x^2</m> and <m>g = \sin(x)</m>, 
          the product rule gives
          <md>f'g + fg' = 2x\sin(x) + x^2\cos(x)</md>.
        </p>
      </feedback>
    </choice>

    <choice>
      <statement>
        <p>
          <m>h'(x) = 2x\sin(x) - x^2\cos(x)</m>
        </p>
      </statement>
      <feedback>
        <p>
          Close, but the product rule adds the two terms, 
          not subtracts them.
        </p>
      </feedback>
    </choice>

    <choice>
      <statement>
        <p>
          <m>h'(x) = x^2\cos(x)</m>
        </p>
      </statement>
      <feedback>
        <p>
          This differentiates only the <m>\sin(x)</m> factor, 
          leaving <m>x^2</m> alone. The product rule 
          requires differentiating each factor in turn: 
          <m>f'g + fg'</m>.
        </p>
      </feedback>
    </choice>
  </choices>
</exercise>

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions