OPENTA XML Generation Rules
This section describes the rules for generating OPENTA-compatible XML exercises.
General XML Structure
When generating an exercise, the XML must follow the structure below:
<exercise>
<exercisename>EXERCISE_NAME</exercisename>
<global>var1 = value1; var2 = value2; ...</global>
<text>TEXT EXPLAINING THE EXERCISE</text>
<question key="RANDOMKEY1">
<text>TEXT EXPLAINING THE QUESTION</text>
<expression>A MATHEMATICAL EXPRESSION THAT IS THE CORRECT ANSWER TO THE QUESTION</expression>
</question>
</exercise>
The values value1, value2 etc. may include units when relevant.
Units must be written out in full, for example: meter, second, kg.
Example:
g = 9.800 meter / second^2
Since units are already included in the global variable definitions, student answers must not contain units.
Expressions inside <expression> must refer only to variables.
Numerical Rules
Use at least four significant figures when assigning numerical values.
Avoid whole numbers and simple fractions.
Angles must always be expressed in radians.
The word
radianmust never be used in an expression.Avoid special angles unless specifically requested.
Mathematical Notation in Text
Mathematical expressions inside <text> tags must be wrapped in dollar signs to ensure MathJax rendering.
Example:
<text>The vector has length $ \sqrt{x^2 + y^2} $.</text>
Consistency of Variables
All variables appearing inside:
<expression> ... </expression>
must:
Be defined inside the
<global>tag.Have reasonable numerical values.
Include units when appropriate.
Hints and Regular Expressions
Hints may be added to enforce restrictions or requirements on student answers.
A hint block has the form:
<hint>
<regex present="ATTRIBUTE">REGEX</regex>
<comment>COMMENT</comment>
</hint>
The ATTRIBUTE can be one of:
requiredforbiddennecessaryallowedencourageddiscouraged
Hints may be placed inside the <global> tag or inside an individual <question> tag.
Use cases include:
forbidden– prohibit certain answer formsrequired– demand that a specific structure appearsnecessary– enforce a mandatory componentallowed– whitelist formsencouraged/discouraged– guide style without strict enforcement
When including a regex, the system should remind the user that the above attributes are available.
Multiple Questions
If an exercise requires solving for multiple different variables:
Create one
<question>element per variable.Each question must have a unique
keyattribute.Each question must include its own
<text>and<expression>.
The <expression> tag contains only the target expression and must not contain an equal sign.
The <text> tag inside the question explains which variable the student is expected to compute.