Browse Source

Add control flow for sc-question

pull/214/head
Sogari 3 years ago committed by Simon Christ
parent
commit
281df20492
  1. 29
      src/Literate.jl

29
src/Literate.jl

@ -953,8 +953,8 @@ function create_notebook(flavor::PlutoFlavor, chunks, config)
answer = string(answer) answer = string(answer)
push!(answers, answer) push!(answers, answer)
else else
if line != "" if line != "" && !startswith(line, "!!!")
write(qBuf, line, "\n\n") # why 2 \n write(qBuf, lstrip(line), "\n") # why 2 \n
end end
end end
end end
@ -962,24 +962,23 @@ function create_notebook(flavor::PlutoFlavor, chunks, config)
radioBind = writeBind(questionName, answers) radioBind = writeBind(questionName, answers)
logicBind = writeLogic(questionName, questionDict) logicBind = writeLogic(questionName, questionDict)
name = "$(questionName)Check"
#toWrite = " "*"\$("*"$name"*")"*"\n"
# toWrite = " " * "\$(eval(md\"\$(" * "$name" * ")\"))" * "\n" # for interactivity in the notebook (else it isn't reactive) # toWrite = " " * "\$(eval(md\"\$(" * "$name" * ")\"))" * "\n" # for interactivity in the notebook (else it isn't reactive)
toWrite = " " * "\\\$(eval(md\"\\\$(" * "$name" * ")\"))" * "\n" # for interactivity in the notebook (else it isn't reactive)
write(qBuf, toWrite) name = "$(questionName)Check"
seek(qBuf, 0) toWrite = "\$(" * "$name" * ")"
result = read(qBuf, String)
correctAdmo = Markdown.parse(result) seek(qBuf, 0)
correctAdmo[1].category = "correct" qStr = read(qBuf, String)
dangerAdmo = Markdown.parse(result) qStr = rstrip(qStr)
dangerAdmo[1].category = "danger"
result = """ result = """
$(correctAdmo) \$(
$(dangerAdmo) if $(questionName)Test($(questionName)Answer)
Markdown.MD(Markdown.Admonition("correct", "$(questionName)", [md"$(qStr)", md"$(toWrite)"]))
else
Markdown.MD(Markdown.Admonition("danger", "$(questionName)", [md"$(qStr)", md"$(toWrite)"]))
end
)
""" """

Loading…
Cancel
Save