Skip to content
Snippets Groups Projects
Commit 05c8b697 authored by David Rouquet's avatar David Rouquet
Browse files

transcript image in quiz sumary

parent 330ffea4
No related branches found
No related tags found
No related merge requests found
Pipeline #2083 passed
...@@ -49,6 +49,8 @@ function toggleHelpComment(question, htmlElement) { ...@@ -49,6 +49,8 @@ function toggleHelpComment(question, htmlElement) {
let correctIndic; let correctIndic;
// The following allows to define complementary attributes in survey JSONS
$(function () { $(function () {
correctIndic = { correctIndic = {
node: document.getElementById("correct-indic"), node: document.getElementById("correct-indic"),
...@@ -80,7 +82,6 @@ $(function () { ...@@ -80,7 +82,6 @@ $(function () {
visibleIndex: 0, visibleIndex: 0,
}); });
// Add compComment to the metadata
Survey.JsonObject.metaData.addProperty("question", { Survey.JsonObject.metaData.addProperty("question", {
name: "compComment", name: "compComment",
type: "text", type: "text",
...@@ -89,6 +90,15 @@ $(function () { ...@@ -89,6 +90,15 @@ $(function () {
visibleIndex: 0, visibleIndex: 0,
}); });
Survey.JsonObject.metaData.addProperty("question", {
name: "transcript",
type: "text",
category: "general",
default: "",
visibleIndex: 0,
});
// Load survey model from JSON // Load survey model from JSON
const survey = new Survey.Model(jsonStatic); const survey = new Survey.Model(jsonStatic);
const questions = survey.getAllQuestions(); const questions = survey.getAllQuestions();
...@@ -175,7 +185,6 @@ $(function () { ...@@ -175,7 +185,6 @@ $(function () {
}); });
survey.onComplete.add(function (sender) { survey.onComplete.add(function (sender) {
if (sender.isSurveySummaryVisible) { if (sender.isSurveySummaryVisible) {
console.log("Survey summary is visible"); console.log("Survey summary is visible");
const userData = sender.data; const userData = sender.data;
...@@ -187,26 +196,32 @@ $(function () { ...@@ -187,26 +196,32 @@ $(function () {
const userAnswer = userData[q.name]; const userAnswer = userData[q.name];
const correctAnswer = q.correctAnswer; const correctAnswer = q.correctAnswer;
const isCorrect = userAnswer === correctAnswer; const isCorrect = userAnswer === correctAnswer;
html += `<li><b>${q.title}</b><br> html += `<li><b>${q.title}</b><br>
Your answer: ${userAnswer} <br> Your answer: ${userAnswer} <br>
Correct answer: ${correctAnswer} <br> Correct answer: ${correctAnswer} <br>
<span style="color:${isCorrect ? 'green' : 'red'};"> <span style="color:${isCorrect ? 'green' : 'red'};">
${isCorrect ? "Correct" : "Incorrect"} ${isCorrect ? "Correct" : "Incorrect"}
</span> </span>`;
</li><br>`;
// Check if the transcript property exists and add an image if it does
if (q.transcript) {
html += `<br><img src="${q.transcript}" alt="Transcript Image" class="inlineImage">`;
}
html += `</li><br>`;
}); });
html += "</ul>"; html += "</ul>";
summaryDiv.innerHTML = html; summaryDiv.innerHTML = html;
// Append the summary after the survey container // Append the summary after the survey container
document.getElementById("surveyContainer").appendChild(summaryDiv); document.getElementById("surveyContainer").appendChild(summaryDiv);
} }
}); });
// Ugly tricks to avoid creating a new theme // Ugly tricks to avoid creating a new theme
const customTheme = SurveyTheme.DefaultLightPanelless; const customTheme = SurveyTheme.DefaultLightPanelless;
const primColor = getComputedStyle(document.documentElement, null).getPropertyValue('--macao-primary-color'); const primColor = getComputedStyle(document.documentElement, null).getPropertyValue('--macao-primary-color');
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment