Skip to content

Quarto mod8 mod9 #81

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

Merged
merged 11 commits into from
Jun 27, 2025
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
update quiz correctAnswers logic
  • Loading branch information
zmx721 committed Jun 4, 2025
commit 33131c16b72db2c4cc55c13cdc5714ed7ee9ac50
9 changes: 8 additions & 1 deletion src/quiz.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,14 @@ function generateQuiz(containerId, title, question, options, correctAnswers) {
messageElement.style.display = 'none';
messageElement.style.opacity = 0;

if (correctAnswers === option) {
isCorrect = false
if (Array.isArray(correctAnswers)) {
isCorrect = correctAnswers.some(ans => ans === option);
} else {
isCorrect = correctAnswers === option
}

if (isCorrect) {
const emojis = ["🍀", "🎉", "🌈", "🚀", "🌟", "✨", "💯"];
const emoji = emojis[~~(Math.random() * emojis.length)];
messageBody.innerHTML = `<strong style="color: #0E76BC !important; font-size: 16px">Correct! &nbsp;${emoji}</strong><br>${explanation}`;
Expand Down