diff --git a/README.md b/README.md index 8b77c6e..02050ab 100644 --- a/README.md +++ b/README.md @@ -51,6 +51,8 @@ format: allowNumberKeys: true disableOnCheck: false shuffleOptions: true + defaultCorrect: "Correct!" + defaultIncorrect: "Incorrect!" revealjs-plugins: - quiz ``` @@ -63,6 +65,8 @@ The `disableOnCheck` option will disable the quiz question after it has been che The `shuffleOptions` option will shuffle the order of the options when the question is displayed. This is true by default. You can refresh your browser to reshuffle the options. +The `defaultCorrect` and `defaultIncorrect` options allow you to set the default text for the correct and incorrect explanations. By default, they are set to "Correct!" and "Incorrect!" if you don't define them. + ### Custom explanations for each option Within a slide, you can use the `data-explanation` attribute to provide an explanation for the each option including the correct answer. It is a [data attribute](https://developer.mozilla.org/en-US/docs/Learn/HTML/Howto/Use_data_attributes), in case you are wondering why it has a "data-*" prefix. This will be displayed when the user checks their answer. For example, here's what a math quiz question might look like: diff --git a/_extensions/quiz/_extension.yml b/_extensions/quiz/_extension.yml index 9a5c52a..9b0c9cb 100644 --- a/_extensions/quiz/_extension.yml +++ b/_extensions/quiz/_extension.yml @@ -16,4 +16,6 @@ contributes: shuffleKey: "t" allowNumberKeys: true disableOnCheck: false - shuffleOptions: true \ No newline at end of file + shuffleOptions: true + defaultCorrect: "" + defaultIncorrect: "" \ No newline at end of file diff --git a/_extensions/quiz/quiz.js b/_extensions/quiz/quiz.js index ecab631..582e2b4 100644 --- a/_extensions/quiz/quiz.js +++ b/_extensions/quiz/quiz.js @@ -89,6 +89,9 @@ window.RevealQuiz = function () { settings.shuffleOptions = options.shuffleOptions || false; + settings.defaultCorrect = options.defaultCorrect || "Correct!"; + settings.defaultIncorrect = options.defaultIncorrect || "Incorrect!"; + console.log(settings); deck.getSlides().forEach((slide, index) => { @@ -172,11 +175,11 @@ window.RevealQuiz = function () { } if (isCorrect) { selectedOption.classList.add('correct'); - cloneFeedbackElement.textContent = explanation || 'Correct!'; // Use explanation if available + cloneFeedbackElement.textContent = explanation || settings.defaultCorrect; // Use explanation if available cloneFeedbackElement.style.color = '#27ae60'; } else { selectedOption.classList.add('incorrect'); - cloneFeedbackElement.textContent = explanation || 'Incorrect!'; // Use explanation if available + cloneFeedbackElement.textContent = explanation || settings.defaultIncorrect; // Use explanation if available cloneFeedbackElement.style.color = '#c0392b'; }