Skip to content
This repository was archived by the owner on Jun 7, 2023. It is now read-only.

Commit 9abc5bc

Browse files
committed
Merge pull request #44 from riknos314/dragncss
Add css feed back on submission of dragndrop component
2 parents dd43078 + 1f6fb85 commit 9abc5bc

File tree

3 files changed

+61
-0
lines changed

3 files changed

+61
-0
lines changed

runestone/dragndrop/css/dragndrop.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@
2525
background-color: black;
2626
color: white;
2727
}
28+
.drop-incorrect {
29+
border: 1px solid red !important;
30+
background-color: #f2dede !important;
31+
}
2832
.drag-reset:enabled {
2933
background-color: #474949;
3034
color: white;

runestone/dragndrop/js/dragndrop.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,10 @@ DragNDrop.prototype.dragEval = function () {
316316
for (var i = 0; i < this.dragPairArray.length; i++) {
317317
if (!$(this.dragPairArray[i][1]).has(this.dragPairArray[i][0]).length) {
318318
this.correct = false;
319+
$(this.dragPairArray[i][1]).addClass("drop-incorrect");
319320
this.incorrectNum++;
321+
} else {
322+
$(this.dragPairArray[i][1]).removeClass("drop-incorrect");
320323
}
321324
if (this.hasNoDragChild(this.dragPairArray[i][1])) {
322325
this.unansweredNum++;

runestone/dragndrop/js/timeddnd.js

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
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

Comments
 (0)