-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9fe0983
commit 5cb00e1
Showing
6 changed files
with
63 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
book | ||
src/mdbook-quiz |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
[book] | ||
authors = ["Will Crichton"] | ||
language = "en" | ||
multilingual = false | ||
src = "src" | ||
title = "example" | ||
|
||
[preprocessor.quiz] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Summary | ||
|
||
- [Chapter 1](./chapter_1.md) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# Chapter 1 | ||
|
||
Here's a *quiz!* | ||
|
||
{{#quiz ./quiz.toml}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
[[questions]] | ||
type = "MultipleChoice" | ||
prompt.prompt = "What does it mean if a variable `x` is immutable?" | ||
prompt.choices = [ | ||
"`x` is stored in the immutable region of memory.", | ||
"After being defined, `x` can be changed at most once.", | ||
"`x` cannot be changed after being assigned to a value.", | ||
"You cannot create a reference to `x`." | ||
] | ||
answer.answer = 2 | ||
context = """ | ||
Immutable means "not mutable", or not changeable. | ||
""" | ||
|
||
[[questions]] | ||
type = "ShortAnswer" | ||
prompt.prompt = "What is the keyword used after `let` to indicate that a variable can be mutated?" | ||
answer.answer = "mut" | ||
context = """ | ||
For example, you can make a mutable variable `x` by writing: `let mut x = 1`. | ||
""" | ||
|
||
[[questions]] | ||
type = "Tracing" | ||
prompt.program = """ | ||
fn main() { | ||
let x = 1; | ||
println!("{x}"); | ||
x += 1; | ||
println!("{x}"); | ||
} | ||
""" | ||
answer.doesCompile = false | ||
answer.lineNumber = 4 | ||
context = """ | ||
This is a compiler error because line 4 tries to mutate `x` when `x` is not marked as `mut`. | ||
""" |