ines / course-starter-python

👩‍🏫🐍 Starter repo for building interactive Python courses
https://course-starter-python.netlify.com
MIT License
504 stars 118 forks source link

Options for multiple choice questions #3

Closed sammous closed 5 years ago

sammous commented 5 years ago

Hello,

I have an issue when I stack multiple choice questions in the same exercise. When I try to select for the second question an option, it's not clickable and it updates the options of the first question, like if they are linked. Code :

<exercise id="4" title="Wrapping up">
Let's ask some questions about the slides before wrapping up.

<choice>

<opt text="True">

Wrong

</opt>

<opt id=4 text="False" correct="true">

Good job!

</opt>

</choice>

Question 2
<choice>

<opt text="True">

Wrong

</opt>

<opt text="False" correct="true">

Good job!

</opt>

</choice>

</exercise>

In the picture, when I click for the second question on the option False, it selects the second option of the first question. image

A fix for now is only to put one question per exercise (or maybe it's intended ?)

Overall, everything works like a charm, I only had an issue with Netlify/Binder where you need to properly delete the cache of Netlify or it won't take any updates from Binder.

Thanks!

ines commented 5 years ago

Thanks!

And I think I know what the problem is: The radio inputs are only assigned a generic name "choice", so all visible inputs are part of the same "group". This is not an issue if there's only one multiple choice question, because only one exercise is ever visible at a time.

Should be easy to fix – I'll add an optional id attribute to <choice> which lets you create unique names per question.