diff --git a/docs/make.jl b/docs/make.jl index 0840c38..92ea758 100644 --- a/docs/make.jl +++ b/docs/make.jl @@ -4,7 +4,7 @@ using QuizQuestions ENV["QQ_LaTeX_dollar_delimiters"] = true makedocs(sitename="QuizQuestions documentation", - format = Documenter.HTML(ansicolor=true) + format = Documenter.HTML(ansicolor=true), ) # Documenter can also automatically deploy documentation to gh-pages. # See "Hosting Documentation" and deploydocs() in the Documenter manual diff --git a/docs/src/index.md b/docs/src/index.md index 6ad90c5..473f6d7 100644 --- a/docs/src/index.md +++ b/docs/src/index.md @@ -2,6 +2,13 @@ [QuizQuestions](https://github.com/jverzani/QuizQuestions.jl) allows the inclusion of self-grading quiz questions within a `Documenter`, `Weave`, [quarto](https://quarto.org), or `Pluto` HTML page. +A few examples: + +* [Quarto example](./quarto-example.html) +* [Weave example](./weave-example.html) + + + ## Basics The basic idea is: @@ -24,6 +31,7 @@ radioq(choices, answer; label=question, hint="A hint") * repeat as desired. +---- The quizzes are written in markdown with the questions in `Julia` blocks. The above code cells would be enclosed in triple-backtick @@ -32,7 +40,6 @@ user. How this is done varies between `Documenter`, `Weave`, [quarto](https://quarto.org), and `Pluto`. The `examples` directory shows examples of each. ----- For each question: diff --git a/docs/src/quarto-example.html b/docs/src/quarto-example.html new file mode 100644 index 0000000..51d3aa5 --- /dev/null +++ b/docs/src/quarto-example.html @@ -0,0 +1,3192 @@ + + + + + + + + + +Quarto example + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+ +
+
+

Quarto example

+
+ + + +
+ + + + +
+ + +
+ +

\[ %% <<--- for some reason a little latex rendering helps render latex in forms elements +\]

+
+
+ +
+
+
+
+

Which adds to \(2\)? + + +

+
+ + + +
+ + + +
+
+
+ +
+
+
+ + + +
+
+
+
+ +
+
+
+
+

Select the sentences with numbers (one or more) + + +

+
+ +
+
+ +
+
+ +
+
+ +
+ + +
+
+
+
+
+
+ + + +
+
+
+
+ +
+
+
+
+

Select the sentences with numbers (one or more) + + +

+
+ + + + +
+ +
+
+ + + +
+
+
+
+
+
+ + + +
+
+
+
+ +
+
+
+
+ \(1 + 1?\) + +  🎁 +
+
+
+ +
+ + +
+
+
+
+
+
+ + + +
+
+
+
+ +
+
+
+
+

What best matches the graph of \(f(x) = -x^4\)? + + +

+
+Image for hotspot selection +
+ + +
+
+
+
+
+
+ + + +
+
+ +
+ + +
+ + + + \ No newline at end of file diff --git a/docs/src/quarto-example.qmd b/docs/src/quarto-example.qmd new file mode 100644 index 0000000..871b793 --- /dev/null +++ b/docs/src/quarto-example.qmd @@ -0,0 +1,75 @@ +--- +title: "Quarto example" +format: + html: + embed-resources: true +jupyter: julia-1.9 +--- + + +```{julia} +#| echo: false +using QuizQuestions +using LaTeXStrings +using Plots +``` + +$$ %% <<--- for some reason a little latex rendering helps render latex in forms elements +$$ + +```{julia} +#| echo: false +buttonq([L"1 + 1", L"2+2", L"-1 + -1"], 1; + label = L"Which adds to $2$?", + explanation="Add 'em up") +``` + +```{julia} +#| echo: false +choices =[ + "Four score and seven years ago", + "Lorum ipsum", + "The quick brown fox jumped over the lazy dog", + "One and one and one makes three" +] +answer = (1, 4) +multiq(choices, answer, + label="Select the sentences with numbers (one or more)") +``` + +```{julia} +#| echo: false +choices =[ + "Four score and seven years ago", + "Lorum ipsum", + "The quick brown fox jumped over the lazy dog", + "One and one and one makes three" +] +answer = (1, 4) +multibuttonq(choices, answer, + label="Select the sentences with numbers (one or more)") +``` + + +```{julia} +#| echo: false +answer = 1 + 1 +numericq(answer; + label=L"1 + 1?", + hint="Do the math") +``` + + +```{julia} +#| echo: false +p1 = plot(x -> x^2, axis=nothing, legend=false) +p2 = plot(x -> x^3, axis=nothing, legend=false) +p3 = plot(x -> -x^2, axis=nothing, legend=false) +p4 = plot(x -> -x^3, axis=nothing, legend=false) +l = @layout [a b; c d] +p = plot(p1, p2, p3, p4, layout=l) +imgfile = tempname() * ".png" +savefig(p, imgfile) +hotspotq(imgfile, (0,1/2), (0, 1/2), + label=L"What best matches the graph of $f(x) = -x^4$?") +``` diff --git a/docs/src/weave-example.html b/docs/src/weave-example.html new file mode 100644 index 0000000..254eb89 --- /dev/null +++ b/docs/src/weave-example.html @@ -0,0 +1,1226 @@ + + + + + + + + + + + + + + + + + + + + + +
+
+
+
+ + + +
+ +

Weave examples

+ + + + +
+
+
+
+

Which adds to \(2\)? + + +

+
+ + + +
+ + + +
+
+
+ +
+
+
+ + + + + + + +
+
+
+
+

Select the sentences with numbers (one or more) + + +

+
+ +
+
+ +
+
+ +
+
+ +
+ + +
+
+
+
+
+
+ + + + + + + +
+
+
+
+

Select the sentences with numbers (one or more) + + +

+
+ + + + +
+ +
+
+ + + +
+
+
+
+
+
+ + + + + + + +
+
+
+
+ \(1 + 1?\) + +  🎁 +
+
+
+ +
+ + +
+
+
+
+
+
+ + + + + + + +
+
+
+
+

What best matches the graph of \(f(x) = -x^4\)? + + +

+
+Image for hotspot selection +
+ + +
+
+
+
+
+
+ + + + + +

The plotlylightq type works with Weave:

+ + + +
+
+
+
+

Click a value with \(x>3\) + + +

+ +
+ +
+
+
+
+
+
+ + + + + + +
+ +
+
+
+ + + diff --git a/docs/src/weave-example.jmd b/docs/src/weave-example.jmd new file mode 100644 index 0000000..a021463 --- /dev/null +++ b/docs/src/weave-example.jmd @@ -0,0 +1,70 @@ +# Weave examples + +```{julia, echo=false} +using QuizQuestions +using LaTeXStrings +``` + + +```{julia, echo=false} +buttonq([L"1 + 1", L"2+2", L"-1 + -1"], 1; + label = L"Which adds to $2$?", + explanation="Add 'em up") +``` + +```{julia, echo=false} +choices =[ + "Four score and seven years ago", + "Lorum ipsum", + "The quick brown fox jumped over the lazy dog", + "One and one and one makes three" +] +answer = (1, 4) +multiq(choices, answer, + label="Select the sentences with numbers (one or more)") +``` + +```{julia, echo=false} +choices =[ + "Four score and seven years ago", + "Lorum ipsum", + "The quick brown fox jumped over the lazy dog", + "One and one and one makes three" +] +answer = (1, 4) +multibuttonq(choices, answer, + label="Select the sentences with numbers (one or more)") +``` + + + +```{julia, echo=false} +answer = 1 + 1 +numericq(answer; + label=L"1 + 1?", + hint="Do the math") +``` + +```{julia, echo=false} +using Plots +p1 = plot(x -> x^2, axis=nothing, legend=false) +p2 = plot(x -> x^3, axis=nothing, legend=false) +p3 = plot(x -> -x^2, axis=nothing, legend=false) +p4 = plot(x -> -x^3, axis=nothing, legend=false) +l = @layout [a b; c d] +p = plot(p1, p2, p3, p4, layout=l) +imgfile = tempname() * ".png" +savefig(p, imgfile) +hotspotq(imgfile, (0,1/2), (0, 1/2), + label=L"What best matches the graph of $f(x) = -x^4$?") +``` + +The `plotlylightq` type works with Weave: + +```{julia, echo=false} +using PlotlyLight +xs = range(0, 2pi, length=100) +ys = sin.(xs) +p = Plot(;x=xs, y=ys, layout=Config(width=800, height=600)) +plotlylightq(p, (3,Inf); label="Click a value with ``x>3``") +```