initEvents: function () {
const $this = this;
let popup = $("#resume")
+ let quiz = $("#quiz").get(0)
$(document).on("click", ".toggle-answers-review", function () {
$(".score-answers-review_container").toggleClass("active")
$(document).on('click', '.btn.restart', function () {
$this.quiz.restart();
});
- $(document).on("mouseover", ".area-item", function () {
- 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).find(".content").html()
- popup.html(content).css({
+ $(document).on("mousemove", function(e) {
+ let x = e.clientX - quiz.getBoundingClientRect().left
+ let y = e.clientY - quiz.getBoundingClientRect().top
+
+ popup.css({
left: x,
top: y,
})
- gsap.to(popup, {autoAlpha: 1})
+ });
+
+ $(document).on("mouseover", ".area-item, .match-item, .multiple-item", function (e) {
+ let content = $(this).find(".content").html()
+
+ if(content) {
+ popup.html(content)
+ gsap.to(popup, {autoAlpha: 1})
+ }
}).on("mouseout", function () {
gsap.to(popup, {autoAlpha: 0})
})
}
},
+ returnContentClass: function(str = "") {
+ return str.length >= 83 ? "content" : ""
+ },
+
displayReviewList: function () {
let $ul = $("#answers-list");
if ($ul.length === 0 || this.quiz.data.review === 'never' || (this.quiz.data.review === 'passed' && !this.quiz.score.isPassed())) {
}
$(".score-answers-review_container").show();
let reviewList = this.quiz.question.getAll();
+ let reviewList_2 = this.quiz.question.getAll();
let status = this.quiz.score.questionStatus
let answersUser = this.quiz.score.answers;
let wrongIcon = getSpriteIcon("quiz-wrong");
- console.log("score",this.quiz.score)
-
reviewList = reviewList.map((c, i) => {
return {
'question': c['question'],
'type': c['type'],
- 'correctAnswers': c['answers'].filter((c__,k) => {
- let status_ = c['answers']
+ 'correctAnswers': c['answers'].filter((c__,k) => { //on filtre les réponses
+ let status_ = answersUser[i]
if(c['type'] === "multiple") {
status_ = parseInt(c['answers'][k].correct) === 1;
}
status_ = status[i].answers[k] !== "missed" && status[i].answers[k] !== "neutral"
}
return status_
- }).map((c_,k_) => {
+ }).map((c_,k_) => { //on modifie les valeurs
+ c_ = { ...c_ }; //shallow copy
if(c['type'] === "draganddrop" && !quiz.score.isPassed()) {
- c_ = { ...c_ }; //shallow copy
c_['drop_area'] = answersUser[i][k_]
}
- if(c['type'] === "match" && !quiz.score.isPassed()) {
- c_ = { ...c_ }; //shallow copy
+ if(c['type'] === "match" && !quiz.score.isPassed() && c['answers'][answersUser[i][k_]] > 0) {
c_['proposition'] = c['answers'][answersUser[i][k_]]['proposition']
}
- console.log(status[i].answers[k_])
- c_['status'] = status[i].answers[k_]
+ c_['status'] = status[i].answers[[answersUser[i][k_]]]
return c_
}),
'status': status[i].ok,
}
})
+ console.log("score",this.quiz.score)
+ console.log("reviewList",reviewList)
+
let html = '';
for (var i in reviewList) {
i = parseInt(i);
let statusByAnswer = status[i]
let nokClass = ""
- console.log(review)
-
let correctAnswers = review.correctAnswers.length > 0 ? review.correctAnswers : review.data.answers
let titleType = '';
if (review.type === "multiple") {
html += '<p class="question title-block">' + review.question + '</p>';
html += '<div class="multiple-wrapper">'
- for (var j in correctAnswers) {
- nokClass = ""
- if(correctAnswers[j].status === "nok" || correctAnswers[j].status === "missed") {
- htmlSpan = `<span class="access nok">${wrongIcon}</span>`
- nokClass = "nok"
+ console.log("review",review)
+ console.log("correctAnswers",correctAnswers)
+ if(correctAnswers.length > 0) {
+ for (var j in correctAnswers) {
+ nokClass = ""
+ if (correctAnswers[j].status === "nok" || correctAnswers[j].status === "missed") {
+ htmlSpan = `<span class="access nok">${wrongIcon}</span>`
+ nokClass = "nok"
+ }
+ html += '<div class="card-holder multiple-item">';
+ html += '<p class="answer slot ' + nokClass + " " + this.returnContentClass(correctAnswers[j].answer)+'">' + correctAnswers[j].answer + htmlSpan + '</p>';
+ html += '</div>';
}
- html += '<div class="card-holder">';
- html += '<p class="answer slot '+nokClass+'">' + correctAnswers[j].answer+htmlSpan+'</p>';
- html += '</div>';
}
html += '</div>'
}
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) {
- htmlSpan = ""
- if(correctAnswers[k].status === "nok") {
- htmlSpan = `<span class="access nok">${wrongIcon}</span>`
+ if(correctAnswers.length > 0) {
+ for (let k in correctAnswers) {
+ if (correctAnswers[k].drop_area === i) {
+ 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="'+this.returnContentClass(correctAnswers[k].answer)+'">' + correctAnswers[k].answer + '</p>'
+ html += htmlSpan
+ html += '</li>'
}
- html += '<li class="area-item slot active '+correctAnswers[k].status+'"><p class="content">' + correctAnswers[k].answer+'</p>'
- html += htmlSpan
- html += '</li>'
}
}
html += '</ul>'
html += '<div class="match-title">'
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>`
+ if(correctAnswers.length > 0) {
+ 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 ' + statusByAnswer.answers[k] + '"><p class="'+this.returnContentClass(correctAnswers[k].answer)+'">' + correctAnswers[k].answer + '</p></div>'
+ html += htmlSpan !== "" ? htmlSpan : '<div class="separate"></div>'
+ html += '<div class="match-item slot active ' + statusByAnswer.answers[k] + '"><p class="'+this.returnContentClass(correctAnswers[k].proposition)+'">' + correctAnswers[k].proposition + '</p></div>'
+ html += '</div>'
}
- html += '<div class="match-wrapper card-holder">'
- 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>'
}