From c25dd07940e0efd2ed99aaf55355f4981dc01d3a Mon Sep 17 00:00:00 2001 From: jverzani Date: Sun, 24 Jul 2022 18:53:43 -0400 Subject: [PATCH] adjust for use with quarto --- Project.toml | 2 +- README.md | 2 +- docs/src/index.md | 9 +-- examples/quarto.qmd | 147 ++++++++++++++++++++++++++++++++++++++++++ src/html_templates.jl | 50 ++++++++------ src/question_types.jl | 4 +- src/show_methods.jl | 2 + 7 files changed, 187 insertions(+), 29 deletions(-) create mode 100644 examples/quarto.qmd diff --git a/Project.toml b/Project.toml index 1db4b0d..244b89b 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "QuizQuestions" uuid = "612c44de-1021-4a21-84fb-7261cf5eb2d4" authors = ["jverzani and contributors"] -version = "0.3.13" +version = "0.3.14" [deps] Base64 = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f" diff --git a/README.md b/README.md index 70b80ee..0921300 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ [![](https://img.shields.io/badge/docs-dev-blue.svg)](https://jverzani.github.io/QuizQuestions.jl/dev/) -A simple means to make basic web pages using Markdown with self-grading quiz questions. Question types are for numeric response, text response (graded with a regular expression), matching, a selection of one from many, or one or more from many. Can be used with Weave, Documenter, or Pluto. +A simple means to make basic web pages using Markdown with self-grading quiz questions. Question types are for numeric response, text response (graded with a regular expression), matching, a selection of one from many, or one or more from many. Can be used with Weave, Documenter, [quarto](https://quarto.org), or Pluto. The package creates `show` methods for mime type `text/html` for a few objects that produce HTML showing an input widget with attached javascript code to grade the input once the widget loses focus. diff --git a/docs/src/index.md b/docs/src/index.md index 8899534..6073f23 100644 --- a/docs/src/index.md +++ b/docs/src/index.md @@ -1,6 +1,6 @@ # QuizQuestions -[QuizQuestions](https://github.com/jverzani/QuizQuestions.jl) allows the inclusion of self-grading quiz questions within a `Documenter`, `Weave`, or `Pluto` HTML page. +[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. ## Basics @@ -26,9 +26,10 @@ radioq(choices, answer; label=question, hint="A hint") The quizzes are written in markdown with the questions in `Julia` blocks. The above code cells would be enclosed in triple-backtick -blocks and would typically have their contents hidden from the user. How this is -done varies between `Documenter`, `Weave`, and `Pluto`. The `examples` -directory shows examples of each. +blocks and would typically have their contents hidden from the +user. How this is done varies between `Documenter`, `Weave`, +[quarto](https://quarto.org), and `Pluto`. The `examples` directory +shows examples of each. ---- diff --git a/examples/quarto.qmd b/examples/quarto.qmd new file mode 100644 index 0000000..97ffbf3 --- /dev/null +++ b/examples/quarto.qmd @@ -0,0 +1,147 @@ +# A simple self-grading quiz + + +```{julia} +using QuizQuestions +``` + +Match `abc` + + +```{julia} +#| echo: false +re = Regex("abc") +stringq(re) +``` + +```{julia} +#| echo: false +a = 1 +numericq(a, label= raw"What is ``\sin(\frac{\pi}{2})``?") +``` + +What is $100$ centimeters in meters? + + +```{julia} +#| echo: false +a = 1 +numericq(a, units="meter(s)", hint="It is 1") +``` + +What is $\sqrt{2}$? + + +```{julia} +#| echo: false +a = sqrt(2) +Δ = 1e-2 +numericq(a, Δ, hint="use 3 digits") +``` + +What is "one"? + + +```{julia} +#| echo: false +choices = ("``1``", "``2``", "``3``") +answer = 1 +radioq(choices, answer, hint="select the number matching the word", keep_order=true) +``` + +```{julia} +#| echo: false +choices = ["beta", raw"``\beta``", "`beta`"] +answer = 2 +radioq(choices, answer; label="Which is the letter?", hint="Which is the Greek symbol?") +``` + +Matching question + + +```{julia} +#| echo: false +questions = ("Select a Volvo", "Select a Mercedes", "Select an Audi") +choices = ("XC90", "A4", "GLE 350", "X1") # may be more than questions +answer = (1,3,2) # indices of correct +matchq(questions, choices, answer) +``` + +Button choice + + +```{julia} +#| echo: false +choices = ["beta", raw"``\beta``", "`beta`"] +answer = 2 +buttonq(choices, answer; label="choose the letter", hint="Which is the Greek symbol?") +``` + +Hotspot + + +```{julia} +#| hold: true +#| 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="What best matches the graph of ``f(x) = -x^4``?") +``` + + +yesnoq + +```{julia} +#| echo: false +yesnoq("yes"; label="Having fun?", hint="It isn't so hard", explanation="We want you to be having fun") +``` + +booleanq + +```{julia} +#| echo: false +booleanq(true; label="Having fun?", hint="It isn't so hard", explanation="We want you to be having fun") +``` + +multiq + +```{julia} +#| echo: false +choices = ["pear", "tomato", "banana"] +answers = [1,3] +multiq(choices, answers; label="yellow foods", hint="not the red one!") +``` + +multibuttonq + +```{julia} +#| echo: false +choices = ["pear", "tomato", "banana"] +answers = [1,3] +multibuttonq(choices, answers; label="yellow foods", hint="not the red one!") +``` + +fillblankq + +```{julia} +#| echo: false +question = "The quick brown fox jumped over the ____ dog" +fillblankq(question, r"lazy") +``` + +```{julia} +#| echo: false +fillblankq(question, ("lazy", "brown", "sleeping"), 1) +``` + +```{julia} +#| echo: false +fillblankq("____ ``+ 2 = 4``", 2) +``` diff --git a/src/html_templates.jl b/src/html_templates.jl index c450149..85b7b6c 100644 --- a/src/html_templates.jl +++ b/src/html_templates.jl @@ -26,14 +26,14 @@ html_templates["question_tpl"] = mt"""
-
{{#:LABEL}} -