this.offsetLeftItemDragged = 0
this.offsetRightItemDragged = 0
+ this.createDraggable()
+ },
+
+ createDraggable: function() {
+ const $this = this
Draggable.create(this.item, {
type: "x,y",
edgeResistance: 0.2,
target.addClass("isValidated")
},
onComplete: function () {
- let html = target.html()
- $(zone).find(".slot:not(.active)").eq(0).addClass("active").html(html)
+ let html = target.html(),
+ id = "answer-"+target.data("id")
+
+ $(zone).find(".slot:not(.active)").eq(0).addClass("active").html(html).attr('data-order',target.data("id"))
+ $this.saveAnswer(zone,id)
target.remove()
}
})
- .to(".list .overlay", {
- y: -heightTarget,
- opacity: 0,
- onStart: function () {
- $(".list-item.isValidated").next().addClass("isNext")
- }
- }, "<")
- .to(".list .overlay", {
- y: 0,
- opacity: 1,
- duration: 0
- }, "+=1")
+ .to(".list .overlay", {
+ y: -heightTarget,
+ opacity: 0,
+ onStart: function () {
+ $(".list-item.isValidated").next().addClass("isNext")
+ }
+ }, "<")
+ .to(".list .overlay", {
+ y: 0,
+ opacity: 1,
+ duration: 0
+ }, "+=1")
}
},
})
}
});
-
},
rotateItem: function($this, direction) {
return {"x" : x, "y" : y, "w" : w, "h": h, "el": el}
},
+ reset: function() {
+ //this.activeScreen.find("input").prop("checked", false)
+ },
+
+ retreiveAnswer: function () {
+ let question = this.quiz.quiz.question.current(),
+ answers = question.answers
+
+ const $this = this
+
+ this.list.empty()
+ for(let k in answers) {
+ let content = answers[k].answer
+ $this.list.append("<li class='list-item'>"+content+"</li>")
+ }
+ this.item = this.activeScreen.find(".list-item")
+ this.createDraggable()
+ },
+ saveAnswer: function(zone,id) {
+ $(zone).find("input[id="+id+"]").prop("checked", true)
+ this.retreiveAnswer()
+ }
}
export default QuizDragAndDrop;
import QuizScreens from './quiz.screens';
import QuizProgressbar from "./quiz.progressbar";
import QuizL10n from "./quiz.l10n";
+import QuizDraganddrop from "./quiz.draganddrop";
window.cubeSCORM = new CubeSCORM();
window.$ = window.jQuery = $;
this.screens = new QuizScreens(this);
this.progressbar = new QuizProgressbar(this);
this.l10n = new QuizL10n(this);
+ this.draganddrop = new QuizDraganddrop(this);
console.log(this.data);
// ICI tout commence vraiment