Add option to shown approximate answer#22
Merged
Conversation
4a032d8 to
07cb83c
Compare
84458a4 to
07cb83c
Compare
7ae427a to
20f970f
Compare
afb4644 to
c522785
Compare
Clarify in README that E-modes must include a trailing `;<digits>` and provide an example showing how shown answers are formatted with the specified significant digits. Change _extract_evalf_from_answer to enforce this: it now raises a ValueError (including lineno and docname) when no valid trailing digits are provided instead of falling back to a default. This makes the formatting behavior explicit and fails fast on malformed answers.
Normalize math markup in examples: replace plain fractions with \frac/\dfrac, escape π as \pi, and wrap numeric significant-digit values in math mode ($5$, $6$). These changes update the displayed answers and input examples for clearer and more consistent LaTeX rendering (applied to two repeated examples).
Improve the ValueError message in QuestionDirective parsing: replace a vague "Invalid at ..." message with a more explicit "Invalid formatted digits at line ..." so the error more clearly identifies the issue and its location in the document.
Remove the DEFAULT_EVALF_SIG_DIGITS class attribute from QuestionDirective in src/teachbooks_questions/__init__.py. This cleans up an unused configuration constant; no functional changes are expected.
douden
approved these changes
May 1, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds approximate answer to math questions. Example shown here: https://oit.tudelft.nl/CTB1310/test-evalf/sympy/lesoefening2.html