Skip to main content

The PreTeXt Guide

Subsection 7.1.6 Reusing a <webwork> by @xml:id

If a <webwork> has an @xml:id, then another <webwork> can “copy” the first one simply by using a @copy attribute whose value is the first <webwork>’s @xml:id. The @seed of the first <webwork> is ignored, and the second <webwork> may set its own @seed. For example:
<exercise>
  <webwork xml:id="foo" seed="1">
    <pg-code>
      $a = random(1,9,1);
      $answer = $a+1;
    </pg-code>
    <statement>
      <p>
        Enter <m><var name="$a"/>+1</m>.  <var name="$answer" width="10"/>
      </p>
    </statement>
  </webwork>
</exercise>

<exercise>
  <webwork copy="foo" seed="2"/>
</exercise>
The @copy attribute should point to a <webwork> that has PreTeXt-authored source, not to a <webwork> with a @source attribute. (If you want to copy one with a @source attribute, just reuse the same @source value.)