',
f'
{number}'
f'{path}
',
f'
{text_html(question.get("question", ""))}
',
]
q_image = media.image_html(question.get("picture_question"))
if q_image:
front_parts.append(
f'
{q_image}
'
)
front_parts.append('
')
for choice in choices:
choice_image = media.image_html(choice.get("picture"))
image_html_part = (
f'{choice_image}
' if choice_image else ""
)
front_parts.append(
"- "
f'
{text_html(choice["text"])}
'
f"{image_html_part}"
" "
)
front_parts.append("
")
correct_image = media.image_html(correct.get("picture"))
back_parts = [
'',
f'
Richtige Antwort: {correct_label}
',
f'
{text_html(correct["text"])}
',
]
if correct_image:
back_parts.append(
f'
{correct_image}
'
)
explanation = explanations.get(str(question.get("number", "")))
if explanation:
back_parts.append(render_explanation(explanation))
back_parts.append("
")
return "".join(front_parts), "".join(back_parts), correct_label
def render_explanation(explanation):
"""Render one explanation entry as an HTML block for the card back.
Inline `$...$` LaTeX in the body is rewritten to MathJax via
`text_html()`, same as the rest of the card. Sources that look
like an HTTP(S) URL become a clickable link; anything else (a
citation like "AFuV §16(2)") is rendered as plain text. The
`revision` number stays editorial-only and is never displayed;
`confidence` is also normally hidden, but surfaces as a small
"low confidence" badge in the header when it falls below
`LOW_CONFIDENCE_THRESHOLD` — a hint to the learner that this
explanation needs more work and to a reviewer that it's a
candidate for §8.3 in EXPLANATIONS.md.
"""
body = text_html(explanation["explanation"])
source_html = _source_html(explanation["source"])
badge = ""
if explanation["confidence"] < LOW_CONFIDENCE_THRESHOLD:
badge = (
'