let move = $(this).attr("aria-keyshortcuts"), zone = false;
if (move === "ARROWLEFT") {
- zone = $this.zone1
+ zone = 'zone-1';
} else {
- zone = $this.zone2
+ zone = 'zone-2';
}
$this.sendCurrentAnswerToArea(zone);
this.zone2 = this.activeScreen.find(".zone-2 .zone-content")
this.htmlZone1 = this.zone1.html()
this.htmlZone2 = this.zone2.html()
+ this.quiz.screens.currentQuestionAnswers = [];
this.offsetLeftItemDragged = 0
this.offsetRightItemDragged = 0
if (this.animating === true) {
return;
}
+ this.quiz.screens.currentQuestionAnswers.push(area === 'zone-1' ? 1 : 2);
+
this.animating = true;
const $this = this;
const current = this.activeScreen.find(".list-item:first-child");
let id = "answer-" + target.data("id");
if (!this.quiz.resize.isMobile()) {
- $(zone).find(".slot:not(.active)").eq(0).addClass("active").append("<h4>" + title + "</h4><p>" + text + "</p>").attr('data-order', target.data("id"))
+ this.getAreaElement(zone).find(".slot:not(.active)").eq(0).addClass("active").append("<h4>" + title + "</h4><p>" + text + "</p>").attr('data-order', target.data("id"))
}
-
- $this.saveAnswer(zone, id)
target.remove()
},
});
if ($(".zone-content.active").length > 0) {
- zone = "." + $(".zone-content.active").parent().data("zone")
+ zone = $(".zone-content.active").parent().data("zone")
}
return zone
},
getSlotInformations: function (zone) {
- let x = ($(zone).find(".slot:not(.active)").offset().left - this.list.offset().left),
- y = ($(zone).find(".slot:not(.active)").offset().top - this.list.offset().top),
- w = $(zone).find(".slot").innerWidth(), h = $(zone).find(".slot").innerHeight(), el = $(zone).find(".slot")
+
+ let a = this.getAreaElement(zone);
+ let freeSlot = $(a).find('.slot:not(.active)').eq(0);
+ let freeSlotOffset = $(freeSlot).offset();
+
+ let x = (freeSlotOffset.left - this.list.offset().left), y = (freeSlotOffset.top - this.list.offset().top),
+ w = $(a).find(".slot").innerWidth(), h = $(a).find(".slot").innerHeight(), el = $(a).find(".slot")
return {"x": x, "y": y, "w": w, "h": h, "el": el}
},
+ getAreaElement: function (area) {
+ return this.quiz.screens.getActiveScreen().find('[data-zone="' + area + '"]')
+ },
+
initQuestion: function () {
//
const htmlList = this.quiz.draganddrop.listHtml
let tl = gsap.timeline()
this.quiz.animations.animateDragAndDropCarrousel(tl)
},
-
- saveAnswer: function (zone, id) {
- $(zone).find("input[id=" + id + "]").prop("checked", true)
- this.quiz.screens.updateUserAnswers();
- }
}
export default QuizDragAndDrop;
}
ok = this_score >= min_score ? 'ok' : 'nok';
+ log.answer = a;
+ } else if (question.type === 'draganddrop') {
+ min_score = this.getMinScore(question);
+ this_score = 0;
+ for (let answerIndex in question.answers) {
+ const answer = question.answers[answerIndex];
+ this_score += ((answer.drop_area === userAnswers[answerIndex]) ? 1 : 0);
+ }
+ ok = this_score >= min_score ? 'ok' : 'nok';
+
log.answer = a;
} else {
log.answer = $(this).find('input,textarea,select').val();
min_score = 0;
for (const answerIndex in question.answers) {
const answer = question.answers[answerIndex];
- if (answer.correct === 1) {
+ if (answer.correct === 1 || question.type === 'draganddrop' || question.type === 'match') {
min_score += answer.score;
}
}