let quiz = $("#quiz").get(0)
let x = (($(this).offset().left + $(this).width()) - quiz.getBoundingClientRect().x),
y = (($(this).offset().top - $(this).height()) - quiz.getBoundingClientRect().y) - $(this).height()
- let content = $(this).html()
+ let content = $(this).find(".content").html()
popup.html(content).css({
left: x,
content = neutral;
} else if (quiz.score.isPassed() === false) {
content = nok;
+ $(".score-answers-review .subtitle").text(this.quiz.l10n.__('Below are all your answers, the red crosses mark the questions to revisit, try again, and gain a digital badge'))
} else {
content = ok;
+ $(".score-answers-review .subtitle").text(this.quiz.l10n.__('Below are the correct answers. Red crosses mark the questions to revisit for improvement.'))
}
this.displayResultContent(content);
}
$(".score-answers-review_container").show();
let reviewList = this.quiz.question.getAll();
- let reviewList2 = this.quiz.question.getAll();
let status = this.quiz.score.questionStatus
let answersUser = this.quiz.score.answers;
let wrongIcon = getSpriteIcon("quiz-wrong");
- console.log("reviewList2",reviewList2)
-
reviewList = reviewList.map((c, i) => {
return {
'question': c['question'],
'type': c['type'],
'correctAnswers': c['answers'].filter((c__,k) => {
- let answers = answersUser[i][k]
- if(c['type'] === "match") {
- answers = c['answers'][answersUser[i][k]]
- }else if(c['type'] === "multiple") {
- console.log("index k",k,"index answersUser",answersUser[i][k])
- answers = answersUser[i].includes(k)
+ let status_ = c['answers']
+ if(c['type'] === "multiple") {
+ status_ = c['answers'][k].correct === 1;
}
- return answers
+ if(!quiz.score.isPassed()) {
+ status_ = status[i].answers[k] !== "missed" && status[i].answers[k] !== "neutral"
+ }
+ return status_
}).map((c_,k_) => {
- if(c['type'] === "draganddrop") {
+ c_ = { ...c_ }; //shallow copy
+ if(c['type'] === "draganddrop" && !quiz.score.isPassed()) {
c_['drop_area'] = answersUser[i][k_]
}
if(c['type'] === "match") {
- c_ = { ...c_ }; //shallow copy
c_['proposition'] = c['answers'][answersUser[i][k_]]['proposition']
}
+ c_['status'] = status[i].answers[k_]
return c_
}),
'status': status[i].ok,
for (var i in reviewList) {
i = parseInt(i);
let review = reviewList[i];
- let htmlSpan = null
-
- console.log("result",review)
+ let htmlSpan = ""
+ let statusByAnswer = status[i]
+ let nokClass = ""
let correctAnswers = review.correctAnswers.length > 0 ? review.correctAnswers : review.data.answers
titleType = ' - ' + this.quiz.l10n.__('Match the answers')
}
html += '<li class="item ' + review.status + '">';
- html += '<p class="position">' + this.quiz.l10n.__('Question :index', {index: i + 1}) + titleType + '</p>';
+ html += '<p class="position title-section">' + this.quiz.l10n.__('Question :index', {index: i + 1}) + titleType + '</p>';
if (review.type === "multiple") {
- html += '<p class="question">' + review.question + '</p>';
+ html += '<p class="question title-block">' + review.question + '</p>';
html += '<div class="multiple-wrapper">'
for (var j in correctAnswers) {
- if(!parseInt(correctAnswers[j].correct)) {
+ if(correctAnswers[j].status === "nok" || correctAnswers[j].status === "missed") {
htmlSpan = `<span class="access nok">${wrongIcon}</span>`
+ nokClass = "nok"
}
html += '<div class="card-holder">';
- html += '<p class="answer slot active">' + correctAnswers[j].answer + htmlSpan +'</p>';
+ html += '<p class="answer slot active '+nokClass+'">' + correctAnswers[j].answer+htmlSpan+'</p>';
html += '</div>';
}
html += '</div>'
}
if (review.type === "draganddrop") {
+ nokClass = ""
html += '<div class="area-title">'
- html += '<p>' + review.data.area_1.title + '</p><p>' + review.data.area_2.title + '</p>'
+ html += '<p class="title-block">' + review.data.area_1.title + '</p><p class="title-block">' + review.data.area_2.title + '</p>'
html += '</div>'
html += '<div class="area-container">'
+
for (let i = 1; i < 3; i++) {
let area = i === 1 ? review.data.area_1 : review.data.area_2
html += '<div class="area area"' + i + '>'
html += '<ul class="area-list card-holder">'
for (let k in correctAnswers) {
if (correctAnswers[k].drop_area === i) {
- html += '<li class="area-item slot active"><p>' + correctAnswers[k].answer + '</p></li>'
+ htmlSpan = ""
+ if(correctAnswers[k].status === "nok") {
+ htmlSpan = `<span class="access nok">${wrongIcon}</span>`
+ }
+ html += '<li class="area-item slot active '+correctAnswers[k].status+'"><p class="content">' + correctAnswers[k].answer+'</p>'
+ html += htmlSpan
+ html += '</li>'
}
}
html += '</ul>'
if (review.type === "match") {
html += '<div class="match-container">'
html += '<div class="match-title">'
- html += '<p>' + this.quiz.l10n.__('Question') + '</p><p>' + this.quiz.l10n.__('Answers') + '</p>'
+ html += '<p class="title-block">' + this.quiz.l10n.__('Question') + '</p><p class="title-block">' + this.quiz.l10n.__('Answers') + '</p>'
html += '</div>'
for (let k in correctAnswers) {
+ htmlSpan = ""
+ if(statusByAnswer.answers[k] === "nok") {
+ htmlSpan = `<span class="access nok">${wrongIcon}</span>`
+ }
html += '<div class="match-wrapper card-holder">'
- html += '<div class="match-item slot active"><p>' + correctAnswers[k].answer + '</p></div>'
- html += '<div class="separate"></div>'
- html += '<div class="match-item slot active"><p>' + correctAnswers[k].proposition + '</p></div>'
+ html += '<div class="match-item slot active '+statusByAnswer.answers[k]+'"><p>' + correctAnswers[k].answer + '</p></div>'
+ html += htmlSpan !== "" ? htmlSpan : '<div class="separate"></div>'
+ html += '<div class="match-item slot active '+statusByAnswer.answers[k]+'"><p>' + correctAnswers[k].proposition + '</p></div>'
html += '</div>'
}
html += '</div>'