Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Does not work on Pluto :( #35

Closed
fonsp opened this issue Jul 16, 2023 · 3 comments
Closed

Does not work on Pluto :( #35

fonsp opened this issue Jul 16, 2023 · 3 comments

Comments

@fonsp
Copy link

fonsp commented Jul 16, 2023

Hallo!

I tried to use QuizQuestions.jl on Pluto but it does not seem to work

image
@fonsp
Copy link
Author

fonsp commented Jul 16, 2023

For globals, you could use window.quizquestions_scorecard instead of just quizquestions_scorecard.

Also check out:

@fonsp
Copy link
Author

fonsp commented Jul 16, 2023

An alternative approach to managing the global state of the scorecard:

Make the score an HTML attribute of the question element. Whenever a score changes, fire a new CustomEvent("quizquestions score changed") on window.
Then the scorecard can just have an event listener on window. The listener function uses document.querySelectorAll to find all questions currently displayed on the page, and map and reduce to get their total scores.

This way, you don't need the ID, and you don't need to worry about questions being removed/changed and leaving global state.

Hope this is useful! If any of this is unclear, I really recommend the crowd-sourced resource javascript.info for learning more about browser API :)

@jverzani
Copy link
Owner

Thanks for the comment and especially the suggested alternative! Will try to address ASAP.

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

No branches or pull requests

2 participants