Skip to content
Snippets Groups Projects
Commit c0265c28 authored by Eliott Sammier's avatar Eliott Sammier
Browse files

Replace default nav buttons

parent 2f8cbacc
Branches 3-qcu-features
No related tags found
No related merge requests found
#correct-indic { #correct-indic {
border-radius: 8px; border-radius: 8px;
padding: 16px; padding: 16px;
transition: opacity 0.1s ease-in-out;
&.hidden {
display: block;
opacity: 0;
}
p { p {
margin: 0; margin: 0;
...@@ -13,8 +19,7 @@ ...@@ -13,8 +19,7 @@
&.correct { &.correct {
background: #dfd; background: #dfd;
.label::before { .label {
content: "Correct";
color: var(--sd-rating-good-color); color: var(--sd-rating-good-color);
} }
} }
...@@ -23,12 +28,14 @@ ...@@ -23,12 +28,14 @@
background: #fdd; background: #fdd;
} }
.label::before { .label {
content: "Incorrect";
color: var(--sd-rating-bad-color); color: var(--sd-rating-bad-color);
} }
} }
#sv-nav-complete {
display: none;
}
p#gapfill-container { p#gapfill-container {
white-space: pre-wrap; white-space: pre-wrap;
......
...@@ -2,20 +2,33 @@ ...@@ -2,20 +2,33 @@
* Checks whether a question is correct, and update the correct indicator accordingly. * Checks whether a question is correct, and update the correct indicator accordingly.
*/ */
function checkQuestion(question) { function checkQuestion(question) {
let indicNode = document.getElementById("correct-indic");
let commentNode = indicNode.querySelector(".comment")
if (question.isAnswerCorrect()) { if (question.isAnswerCorrect()) {
indicNode.className = "correct"; correctIndic.node.className = "correct"
commentNode.innerText = question.getPropertyValue("correctComment", ""); correctIndic.labelNode.innerText = "Correct";
correctIndic.commentNode.innerText = question.getPropertyValue("correctComment", "");
} else { } else {
indicNode.className = "incorrect"; correctIndic.node.className = "incorrect";
commentNode.innerText = question.getPropertyValue("incorrectComment", ""); correctIndic.labelNode.innerText = "Incorrect";
correctIndic.commentNode.innerText = question.getPropertyValue("incorrectComment", "");
} }
console.log("question = ", question); console.log("question = ", question);
console.log(" correct = ", question.isAnswerCorrect()); console.log(" correct = ", question.isAnswerCorrect());
} }
function clearQuestion(question) {
question.value = undefined;
correctIndic.node.className = "hidden";
}
let correctIndic;
$(function () { $(function () {
correctIndic = {
node: document.getElementById("correct-indic"),
commentNode: document.querySelector("#correct-indic .comment"),
labelNode: document.querySelector("#correct-indic .label")
};
// Register our custom question types // Register our custom question types
Survey.CustomWidgetCollection.Instance.add(gapfillSelectWidget, gapfillSelectWidget.name); Survey.CustomWidgetCollection.Instance.add(gapfillSelectWidget, gapfillSelectWidget.name);
...@@ -34,12 +47,22 @@ $(function () { ...@@ -34,12 +47,22 @@ $(function () {
// Add "Check answers" button // Add "Check answers" button
survey.addNavigationItem({ survey.addNavigationItem({
id: "sv-nav-clear-page", id: "sv-nav-check",
title: "Check", title: "Vérifier",
action: () => { action: () => {
checkQuestion(survey.currentPage.questions[0]); checkQuestion(survey.currentPage.questions[0]);
}, },
css: "nav-button", css: "nav-button",
innerCss: "sd-btn sd-btn--action nav-input"
});
// Add "Clear answers" button
survey.addNavigationItem({
id: "sv-nav-clear",
title: "Effacer",
action: () => {
clearQuestion(survey.currentPage.questions[0]);
},
css: "nav-button",
innerCss: "sd-btn nav-input" innerCss: "sd-btn nav-input"
}); });
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment