Skip to content

feat: ChoiceAnswer and Quiz#270

Open
lebalz wants to merge 92 commits intomainfrom
feature/choice-answer
Open

feat: ChoiceAnswer and Quiz#270
lebalz wants to merge 92 commits intomainfrom
feature/choice-answer

Conversation

@lebalz
Copy link
Contributor

@lebalz lebalz commented Jan 27, 2026

This PR introduces a new <ChoiceAnswer> component for creating single-choice and multiple choice questions, such as

  <ChoiceAnswer correct={[5]} scoring={points(2)}>
      > In welchem Jahr war 2024?
      
      1. 1965
      2. 1983
      3. 1991
      4. 2000
      5. 2024
  </ChoiceAnswer>

ChoiceAnswers support automatic assessment and points scoring. In addition, there is a Quiz component which groups several ChoiceAnswers into a single quiz, where question orders can be randomized and global scoring rules can be defined.

Preview and documentation: https://deploy-preview-270--teaching-dev.netlify.app/docs/gallery/persistable-documents/answer/choice-answer/.

@netlify
Copy link

netlify bot commented Jan 27, 2026

Deploy Preview for teaching-dev ready!

Name Link
🔨 Latest commit 787992b
🔍 Latest deploy log https://app.netlify.com/projects/teaching-dev/deploys/69c3e442351f1300087b0820
😎 Deploy Preview https://deploy-preview-270--teaching-dev.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

Comment on lines +16 to +26
```html
<ChoiceAnswer id="9c86f782-39bc-4a2d-bdb5-53a6dad884aa">
Wir gilt als Erfinder des World Wide Web (WWW)?

<ChoiceAnswer.Option id="1">Steve Jobs</ChoiceAnswer.Option>
<ChoiceAnswer.Option id="2" correct>Tim Berners-Lee</ChoiceAnswer.Option>
<ChoiceAnswer.Option id="3">Ada Lovelace</ChoiceAnswer.Option>
<ChoiceAnswer.Option id="4">Alain Berset</ChoiceAnswer.Option>
<ChoiceAnswer.Option id="5">Charles Bartowski</ChoiceAnswer.Option>
</ChoiceAnswer>
```
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Coole Idee 👍 Würde ich gerne brauchen :)
Zum Verfassen und zur Darstellung als "normales" Markdown: wie wäre eine Syntax vergleichbar zum Step bzw. ProgressState? Die id würde obsolet, da die Reihenfolge dann bereits gegeben ist, randomisieren wäre immernoch möglich. Einzig die korrekten Antworten müssten noch speziell markiert werden, bspw. so

Wir gilt als Erfinder des World Wide Web (WWW)?
<ChoiceAnswer correct={[2]} id="9c86f782-39bc-4a2d-bdb5-53a6dad884aa">
    1. Steve Jobs
    2. Tim Berners-Lee
    3. Ada Lovelace
    4. Alain Berset
    5. Charles Bartowski
</ChoiceAnswer>

Copy link
Contributor

@SilasBerger SilasBerger Jan 27, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like it! One thing I would change though: The question should IMO be inside the ChoiceAnswer block (I know, it's not part of the answer…). This makes it easier to e.g. automatically add an aufgabe admonition and a checkbox to a ChoiceAnswer, select the individual ChoiceAnswers in a group to arrange them into a carroussel, etc.

<ChoiceAnswer correct={[2]} id="9c86f782-39bc-4a2d-bdb5-53a6dad884aa">
    Wir gilt als Erfinder des World Wide Web (WWW)?

    1. Steve Jobs
    2. Tim Berners-Lee
    3. Ada Lovelace
    4. Alain Berset
    5. Charles Bartowski
</ChoiceAnswer>

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, this would be really cool - but it's not that easy to create a robust behavior...

The approach of ProgressState is to expect a <ul> as a child and process it (https://github.com/GBSL-Informatik/teaching-dev/blob/main/src/components/documents/ProgressState/index.tsx) - with additional content that could be pre- or post <ul>, it could be hard to do it robust.

Maybe you'd need to add a remark plugin could help? not sure what's the best approach...

@SilasBerger SilasBerger self-assigned this Mar 25, 2026
@SilasBerger SilasBerger changed the title WIP: Feature/choice answer feat: ChoiceAnswer and Quiz Mar 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants