Browse Source

Add helper functions at the end of the pluto-nb

pull/214/head
Sogari 3 years ago committed by Simon Christ
parent
commit
2948d69759
  1. 31
      src/Literate.jl

31
src/Literate.jl

@ -868,8 +868,7 @@ function writeLogic(questionName, questionDict)
""" """
function $(questionName)Test($(questionName)Answer) function $(questionName)Test($(questionName)Answer)
return $(questionName)Answer == "$(questionDict["correct"])" return $(questionName)Answer == "$(questionDict["correct"])"
end; end;"""
"""
return logic return logic
end end
@ -887,6 +886,9 @@ function create_notebook(flavor::PlutoFlavor, chunks, config)
# Print cells # Print cells
uuids = Base.UUID[] uuids = Base.UUID[]
singleChoiceUuids = Base.UUID[]
singleChoiceFolds = Bool[]
singleChoiceContent = String[]
folds = Bool[] folds = Bool[]
default_fold = Dict{String,Bool}("markdown"=>true, "code"=>false) # toggleable ??? default_fold = Dict{String,Bool}("markdown"=>true, "code"=>false) # toggleable ???
cellCounter = 1 cellCounter = 1
@ -1036,23 +1038,19 @@ function create_notebook(flavor::PlutoFlavor, chunks, config)
content = String(take!(io)) content = String(take!(io))
uuid = uuid4(content, cellCounter) uuid = uuid4(content, cellCounter)
cellCounter += 1 cellCounter += 1
push!(uuids, uuid) push!(singleChoiceUuids, uuid)
push!(folds, fold) push!(singleChoiceFolds, fold)
print(ionb, "# ╔═╡ ", uuid, '\n') push!(singleChoiceContent, content)
write(ionb, content, '\n')
write(io, logicBind, '\n') write(io, logicBind, '\n')
write(io, '\n') write(io, '\n')
content = String(take!(io)) content = String(take!(io))
uuid = uuid4(content, cellCounter) uuid = uuid4(content, cellCounter)
cellCounter += 1 cellCounter += 1
push!(uuids, uuid) push!(singleChoiceUuids, uuid)
push!(folds, fold) push!(singleChoiceFolds, fold)
print(ionb, "# ╔═╡ ", uuid, '\n') push!(singleChoiceContent, content)
write(ionb, content, '\n')
end end
write(io, '\n')
end end
content = String(take!(io)) content = String(take!(io))
@ -1084,6 +1082,15 @@ function create_notebook(flavor::PlutoFlavor, chunks, config)
write(ionb, content, '\n') write(ionb, content, '\n')
end end
for (i, uuid) in enumerate(singleChoiceUuids)
content = singleChoiceContent[i]
print(ionb, "# ╔═╡ ", uuid, '\n')
write(ionb, content, '\n')
end
uuids = vcat(uuids, singleChoiceUuids)
folds = vcat(folds, singleChoiceFolds)
# Print cell order # Print cell order
print(ionb, "# ╔═╡ Cell order:\n# ╟─a0000000-0000-0000-0000-000000000000\n") print(ionb, "# ╔═╡ Cell order:\n# ╟─a0000000-0000-0000-0000-000000000000\n")
foreach(((x, f),) -> print(ionb, "# $(f ? "╟─" : "╠═")", x, '\n'), zip(uuids, folds)) foreach(((x, f),) -> print(ionb, "# $(f ? "╟─" : "╠═")", x, '\n'), zip(uuids, folds))

Loading…
Cancel
Save