Wrap expected text in code block when no answer provided

This commit is contained in:
Damien Elmes 2023-02-02 18:01:23 +10:00
parent de86d6b40f
commit 2c952cf3af
2 changed files with 4 additions and 7 deletions

View file

@ -607,14 +607,9 @@ class Reviewer:
origSize = len(buf)
buf = buf.replace("<hr id=answer>", "")
hadHR = len(buf) != origSize
# munge correct value
expected = self.typeCorrect
provided = self.typedAnswer
if not provided:
output = expected
else:
# compare with typed answer
output = self.mw.col.compare_answer(expected, provided)
output = self.mw.col.compare_answer(expected, provided)
# and update the type answer area
def repl(match: Match) -> str:
# can't pass a string in directly, and can't use re.escape as it

View file

@ -90,7 +90,9 @@ impl DiffContext {
let expected = render_tokens(&output.expected);
format!(
"<code id=typeans>{}</code>",
if no_mistakes(&output.expected) {
if self.provided.is_empty() {
self.expected.iter().collect()
} else if no_mistakes(&output.expected) {
provided
} else {
format!("{provided}<br><span id=typearrow>&darr;</span><br>{expected}")