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: .. code-block:: xml EXERCISE_NAME var1 = value1; var2 = value2; ... TEXT EXPLAINING THE EXERCISE TEXT EXPLAINING THE QUESTION A MATHEMATICAL EXPRESSION THAT IS THE CORRECT ANSWER TO THE QUESTION 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 ```` 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 ``radian`` must never be used in an expression. - Avoid special angles unless specifically requested. Mathematical Notation in Text ----------------------------- Mathematical expressions inside ```` tags must be wrapped in dollar signs to ensure MathJax rendering. Example: .. code-block:: xml The vector has length $ \sqrt{x^2 + y^2} $. Consistency of Variables ------------------------ All variables appearing inside: .. code-block:: xml ... must: 1. Be defined inside the ```` tag. 2. Have reasonable numerical values. 3. 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: .. code-block:: xml REGEX COMMENT The ``ATTRIBUTE`` can be one of: - ``required`` - ``forbidden`` - ``necessary`` - ``allowed`` - ``encouraged`` - ``discouraged`` Hints may be placed inside the ```` tag or inside an individual ```` tag. Use cases include: - ``forbidden`` – prohibit certain answer forms - ``required`` – demand that a specific structure appears - ``necessary`` – enforce a mandatory component - ``allowed`` – whitelist forms - ``encouraged`` / ``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 ```` element per variable. - Each question must have a unique ``key`` attribute. - Each question must include its own ```` and ````. The ```` tag contains only the target expression and must not contain an equal sign. The ```` tag inside the question explains which variable the student is expected to compute.