|
| 1 | +function TimedDragNDrop (opts) { |
| 2 | + if (opts) { |
| 3 | + this.timedInit(opts); |
| 4 | + } |
| 5 | +} |
| 6 | +TimedDragNDrop.prototype = new DragNDrop(); |
| 7 | + |
| 8 | +TimedDragNDrop.prototype.timedInit = function (opts) { |
| 9 | + this.init(opts); |
| 10 | + this.renderTimedIcon(this.containerDiv); |
| 11 | + this.hideButtons(); |
| 12 | +}; |
| 13 | + |
| 14 | + |
| 15 | +TimedDragNDrop.prototype.hideButtons = function () { |
| 16 | + $(this.submitButton).hide(); |
| 17 | +}; |
| 18 | + |
| 19 | +TimedDragNDrop.prototype.renderTimedIcon = function (component) { |
| 20 | + // renders the clock icon on timed components. The component parameter |
| 21 | + // is the element that the icon should be appended to. |
| 22 | + var timeIconDiv = document.createElement("div"); |
| 23 | + var timeIcon = document.createElement("img"); |
| 24 | + $(timeIcon).attr({ |
| 25 | + "src": "../_static/clock.png", |
| 26 | + "style": "width:15px;height:15px" |
| 27 | + }); |
| 28 | + timeIconDiv.className = "timeTip"; |
| 29 | + timeIconDiv.title = ""; |
| 30 | + timeIconDiv.appendChild(timeIcon); |
| 31 | + $(component).prepend(timeIconDiv); |
| 32 | +}; |
| 33 | + |
| 34 | +TimedDragNDrop.prototype.checkCorrectTimed = function () { |
| 35 | + // Returns if the question was correct. Used for timed assessment grading. |
| 36 | + if (this.unansweredNum === this.dragPairArray.length) { |
| 37 | + this.correct = null; |
| 38 | + } |
| 39 | + |
| 40 | + return this.correct; |
| 41 | +}; |
| 42 | + |
| 43 | +TimedDragNDrop.prototype.hideFeedback = function () { |
| 44 | + $(this.feedBackDiv).hide(); |
| 45 | +}; |
| 46 | + |
| 47 | +TimedDragNDrop.prototype.processTimedSubmission = function () { |
| 48 | + $(this.resetButton).hide(); |
| 49 | + this.dragEval(); |
| 50 | + for (var i = 0; i < this.dragPairArray.length; i++) { // No more dragging |
| 51 | + $(this.dragPairArray[i][0]).attr("draggable", "false"); |
| 52 | + $(this.dragPairArray[i][0]).css("cursor", "initial"); |
| 53 | + } |
| 54 | +}; |
0 commit comments