Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file.
35 changes: 35 additions & 0 deletions packages/preview/quiztime/0.1.0/README.md
Original file line number Diff line number Diff line change
@@ -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:

![](./output.png)
71 changes: 71 additions & 0 deletions packages/preview/quiztime/0.1.0/lib.typ
Original file line number Diff line number Diff line change
@@ -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: <question>
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
}
}
Binary file added packages/preview/quiztime/0.1.0/output.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 9 additions & 0 deletions packages/preview/quiztime/0.1.0/typst.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[package]
name = "quiztime"
version = "0.1.0"
entrypoint = "lib.typ"
authors = ["Robert Richter <https://github.com/judgeNotFound>"]
license = "MIT"
categories = ["utility"]
description = "Create little quizzes."
keywords = ["Quiz", "Teaching", "Grading"]