HtmlWeave facilitates the writing of self-grading quizzes with markdown and embedded julia code and graphs. The bulk of the work is done by Gadfly.weave, this package provides the question writing interface and some other markup.
Basic content is handled with markdown. Simple command are executed and printed with comments to separate them from the input:
2 + 2
## 4
There are ways to control what is printed:
hide=true hide commands and resultscommands=false hide commandsresults=false hide resultsoutput=false suppress printed outputasis=true include output as is, without code blocksGraphics can be include via googlecharts:
using GoogleCharts
plot(sin, 0, pi)
(This needs asis=true to work.)
using Gadfly
p = Gadfly.plot(sin, 0, 2pi);
draw(D3(6inch, 6inch), p)
Gadfly graphics should work too, but for now they don't. They would be as simple as this (where the Gadfly prefix is included only because GoogleCharts.plot is loaded):
import Gadfly.gadfly_format
function gadfly_format(p::Gadfly.Plot)
f = tempname() * ".js"
draw(D3(f, 6inch, 6inch), p)
io = open(f)
x = readlines(io) |> join
close(io); rm(f)
id = randstring(10)
x = "<div id='$id'></div><script>" * x * ";draw('$id');</script>"
x
end
p = Gadfly.plot(sin, 0, pi)
Bootstrap is used to style the pages. The navigation is provided by a tabbable function. It's use is fairly straightforward.
To set text off, on can use a well:
Title
setoff text hereThat was all in HTML which we want to avoid. There will be a well function.
Examples:
example("Many parts")
Example: Many parts
Make an example
note("A note")
A note
A basic note
alert("This is only a test", title="Warning", class="error")
That should have been an alert
msg = "
**Yo!** This a message from somewhere.
";
blockquote(msg, author="John")
Yo! This a message from somewhere.
John
There is a block quote above
Weave.inline_img("composition.png")
Inline images allow inclusion of local images without having to have a url, nice to make the pages self-contained.
There are some simple ways to incude self-grading questions:
what is 3?
Weave.numericq(3, .001; hint="answer is *three*")
What is false?
Weave.booleanq(true, hint="answer is true")
what is one?
Weave.radioq(["one *einz* **ichi** _uno_ ~un~",
"two",
"three"], 1, hint="one is `1`, of course")
What is two?
Weave.choiceq(["one", "two", "three"], 2, hint="two is *two*, of course")
Spell "cat"
Weave.textq("^cat\$", hint="It is not *kat*")