diff --git a/packages/preview/quiztime/0.1.0/LICENSE b/packages/preview/quiztime/0.1.0/LICENSE new file mode 100644 index 0000000000..a02059b3ac --- /dev/null +++ b/packages/preview/quiztime/0.1.0/LICENSE @@ -0,0 +1,7 @@ +Copyright © 2025 Robert Richter + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/packages/preview/quiztime/0.1.0/README.md b/packages/preview/quiztime/0.1.0/README.md new file mode 100644 index 0000000000..e6a9b973b1 --- /dev/null +++ b/packages/preview/quiztime/0.1.0/README.md @@ -0,0 +1,35 @@ +# Quiztime + +Typst package to create quizzes. + +```typst +#import "@preview/quiztime:0.1.0": question, quiz + +#let q1 = question( + text: "What color is the sky?", + kind: "multiple-choice", + answers: ("Blue", "Red", "Yellow", "Gray"), +) + +#let q2 = question( + text: "Why do you think is the world where it is?", + kind: "text", + answers: ("Because no one took proper care of it.",), + show-solutions: true, + answer-space: 50pt, +) + +#let q3 = question( + text: "What color is the sea?", + kind: "multiple-choice", + answers: ("Blue", "Red", "Yellow", "Gray"), + true-answers: (1,), + show-solutions: true +) + +#quiz(questions: (q1,q2,q3), pre-numbering: "Question ") +``` + +Gives a list of quiz questions that are multiple-choice or text-based (i.e., space for writing freely). Solutions may be enabled per question. + +![Three quiz questions. First a multiple-choice question, followed by a text question, and finally a multiple-choice question, where the solution is shown.](./output.png) diff --git a/packages/preview/quiztime/0.1.0/lib.typ b/packages/preview/quiztime/0.1.0/lib.typ new file mode 100644 index 0000000000..bf329f8dca --- /dev/null +++ b/packages/preview/quiztime/0.1.0/lib.typ @@ -0,0 +1,71 @@ +#let checkbox = text("◯", size: 8pt) +#let checkbox-true = text("⬤", size: 8pt) + +#let question( + // Actual question to be asked + text: "", + + // Possible values: multiple-choice, text + kind: "", + + // Answers for a multiple choice question + // Only used if kind = "multiple-choice" + answers: (), + + // The space that should be given for writing an answer + // Only used for kind = "text" + answer-space: 100pt, + + // The index (1-based) of the answers that are true + true-answers: (), + + // Whether or not to show solutions + show-solutions: false, +) = { + text + "\n" + v(5pt) + + if kind == "multiple-choice" { + let idx = 0 + while idx < answers.len() { + let a = answers.at(idx) + + h(20pt) + if show-solutions and true-answers.contains(idx + 1) { + checkbox-true + } else { + checkbox + } + h(10pt) + + a + "\n" + idx += 1 + } + } else { + if show-solutions and answers.len() > 0 { + h(20pt) + answers.at(0) + } else { + v(answer-space) + } + } +} + +#let quiz( + // Questions + questions: (), + + // The text before 1: + pre-numbering: "", +) = { + let idx = 0 + while idx < questions.len() { + let q = questions.at(idx) + + text(pre-numbering + str(idx + 1) + ": ", weight: "bold") + q + v(20pt) + + idx += 1 + } +} \ No newline at end of file diff --git a/packages/preview/quiztime/0.1.0/output.png b/packages/preview/quiztime/0.1.0/output.png new file mode 100644 index 0000000000..f2825a0e57 Binary files /dev/null and b/packages/preview/quiztime/0.1.0/output.png differ diff --git a/packages/preview/quiztime/0.1.0/typst.toml b/packages/preview/quiztime/0.1.0/typst.toml new file mode 100644 index 0000000000..a1ee34947f --- /dev/null +++ b/packages/preview/quiztime/0.1.0/typst.toml @@ -0,0 +1,9 @@ +[package] +name = "quiztime" +version = "0.1.0" +entrypoint = "lib.typ" +authors = ["Robert Richter "] +license = "MIT" +categories = ["utility"] +description = "Create little quizzes." +keywords = ["Quiz", "Teaching", "Grading"]