Skip to content

Commit

Permalink
Allow specifying a custom delimiter for multiple choice quizzes (#1226)
Browse files Browse the repository at this point in the history
I'm writing quizzes on shell pipelines, and I need to include |s in my
answers.
  • Loading branch information
illicitonion authored Dec 5, 2024
1 parent 4504c42 commit 0663f07
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ menu=["shortcodes"]

This is a simple "check understanding" block that allows you to create a multiple choice question with options and feedback. Short assessments like this are a pedagogically sound strategy to boost retention and understanding.

If you need to use `|` characters in your answers/feedback, you can specify the `delimiter` key to use a different delimiter between them.

### Invoke

```go
Expand Down
6 changes: 4 additions & 2 deletions common-theme/layouts/shortcodes/multiple-choice.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@
>}}

*/}}

{{ $delimiter := .Get "delimiter" | default "|" }}
{{ $question := .Get "question" }}
{{ $answers := split (.Get "answers") "|" }}
{{ $feedback := split (.Get "feedback" | default "") "|" }}
{{ $answers := split (.Get "answers") $delimiter }}
{{ $feedback := split (.Get "feedback" | default "") $delimiter }}
{{ $correct := (.Get "correct") }}

{{ partial "multiple-choice" (dict "question" $question "answers" $answers "feedback" $feedback "correct" $correct) }}

0 comments on commit 0663f07

Please sign in to comment.