Header

Gadfly.weave

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 results
  • commands=false hide commands
  • results=false hide results
  • output=false suppress printed output
  • asis=true include output as is, without code blocks

Graphics 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 styles

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 here

That was all in HTML which we want to avoid. There will be a well function.

  • styles:

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")
This is only a test

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")
Embedded Image

Inline images allow inclusion of local images without having to have a url, nice to make the pages self-contained.

Questions

There are some simple ways to incude self-grading questions:

Question 1

what is 3?

Weave.numericq(3, .001; hint="answer is *three*")

Question 2

What is false?

Weave.booleanq(true, hint="answer is true")

Question 3

what is one?

Weave.radioq(["one *einz* **ichi** _uno_ ~un~",
 "two", 
"three"], 1, hint="one is `1`, of course")

Question 4

What is two?

Weave.choiceq(["one", "two", "three"], 2, hint="two is *two*, of course")

Question 5

Spell "cat"

Weave.textq("^cat\$", hint="It is not *kat*")