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

Commit 7b4969a

Browse files
authored
Merge pull request #1174 from bjones1/more-tests
Improved testing 13
2 parents c32b413 + 951a1a8 commit 7b4969a

5 files changed

Lines changed: 139 additions & 161 deletions

File tree

runestone/dragndrop/README.md

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,17 @@
22

33
```html
44
<ul data-component="dragndrop" id="dd1">
5-
<span data-component="question">The Question goes here.</span>
6-
<span data-component="feedback">This is feedback that is displayed when this is answered incorrectly.</span>
5+
<span data-subcomponent="question">The Question goes here.</span>
6+
<span data-subcomponent="feedback">This is feedback that is displayed when this is answered incorrectly.</span>
77

8-
<li data-component="draggable" id="dd1_drag1">Drag to Answer A</li>
9-
<li data-component="dropzone" for="dd1_drag1">Answer A</li>
8+
<li data-subcomponent="draggable" id="dd1_drag1">Drag to Answer A</li>
9+
<li data-subcomponent="dropzone" for="dd1_drag1">Answer A</li>
1010

11-
<li data-component="draggable" id="dd1_drag2">Drag to Answer B</li>
12-
<li data-component="dropzone" for="dd1_drag2">Answer B</li>
11+
<li data-subcomponent="draggable" id="dd1_drag2">Drag to Answer B</li>
12+
<li data-subcomponent="dropzone" for="dd1_drag2">Answer B</li>
1313

14-
<li data-component="draggable" id="dd1_drag3">Drag to Answer C</li>
15-
<li data-component="dropzone" for="dd1_drag3">Answer C</li>
14+
<li data-subcomponent="draggable" id="dd1_drag3">Drag to Answer C</li>
15+
<li data-subcomponent="dropzone" for="dd1_drag3">Answer C</li>
1616

1717

1818
</ul>
@@ -28,15 +28,15 @@ Option spec:
2828
<ul>
2929
<li><code>data-component="dragndrop"</code> Identifies this as a drag n drop component</li>
3030
<li><code>id</code> Must be unique in the document</li>
31-
<li><code>data-component="question"</code> Optional--Identifies a <code>span</code> that contains the question</li>
32-
<li><code>data-component="feedback"</code> Optional--Identifies a <code>span</code> that contains the feedback for incorrect answers</li>
31+
<li><code>data-subcomponent="question"</code> Optional--Identifies a <code>span</code> that contains the question</li>
32+
<li><code>data-subcomponent="feedback"</code> Optional--Identifies a <code>span</code> that contains the feedback for incorrect answers</li>
3333
</ul>
3434

3535
Option spec for the <code>li</code> tags:
3636

3737
<ul>
38-
<li><code>data-component="draggable"</code> Identifies a draggable element that will be dropped into a dropzone block</li>
38+
<li><code>data-subcomponent="draggable"</code> Identifies a draggable element that will be dropped into a dropzone block</li>
3939
<li><code>id</code> For the draggable elements--must be unique in the component
40-
<li><code>data-component="dropzone"</code> Identifies a dropzone component that will receive a draggable element</li>
40+
<li><code>data-subcomponent="dropzone"</code> Identifies a dropzone component that will receive a draggable element</li>
4141
<li><code>for</code> For the dropzone components--identifies the correct draggable element (via <code>id</code>) that when dropped into this dropzone, will be registered as correct</li>
4242
</ul>

runestone/dragndrop/dragndrop.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818

1919
from docutils import nodes
2020
from docutils.parsers.rst import directives
21-
from docutils.parsers.rst import Directive
2221
from runestone.server.componentdb import (
2322
addQuestionToDB,
2423
addHTMLToDB,
@@ -27,7 +26,6 @@
2726
from runestone.common.runestonedirective import (
2827
RunestoneIdDirective,
2928
RunestoneIdNode,
30-
add_i18n_js,
3129
)
3230

3331

@@ -42,13 +40,13 @@ def setup(app):
4240
TEMPLATE_START = """
4341
<div class="%(divclass)s">
4442
<ul data-component="dragndrop" data-question_label="%(question_label)s" id="%(divid)s" %(optional)s style="visibility: hidden;">
45-
<span data-component="question">%(qnumber)s: %(question)s</span>
43+
<span data-subcomponent="question">%(qnumber)s: %(question)s</span>
4644
%(feedback)s
4745
"""
4846

4947
TEMPLATE_OPTION = """
50-
<li data-component="draggable" id="%(divid)s_drag%(dnd_label)s">%(dragText)s</li>
51-
<li data-component="dropzone" for="%(divid)s_drag%(dnd_label)s">%(dropText)s</li>
48+
<li data-subcomponent="draggable" id="%(divid)s_drag%(dnd_label)s">%(dragText)s</li>
49+
<li data-subcomponent="dropzone" for="%(divid)s_drag%(dnd_label)s">%(dropText)s</li>
5250
"""
5351
TEMPLATE_END = """</ul></div>"""
5452

@@ -75,7 +73,7 @@ def visit_dnd_node(self, node):
7573

7674
if "feedback" in node.runestone_options:
7775
node.runestone_options["feedback"] = (
78-
"<span data-component=feedback>"
76+
"<span data-subcomponent=feedback>"
7977
+ node.runestone_options["feedback"]
8078
+ "</span>"
8179
)

runestone/dragndrop/js/dragndrop.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ export default class DragNDrop extends RunestoneBase {
4444
populate() {
4545
for (var i = 0; i < this.origElem.childNodes.length; i++) {
4646
if (
47-
$(this.origElem.childNodes[i]).data("component") === "dropzone"
47+
$(this.origElem.childNodes[i]).data("subcomponent") === "dropzone"
4848
) {
4949
var tmp = $(this.origElem).find(
5050
`#${$(this.origElem.childNodes[i]).attr("for")}`
@@ -65,11 +65,11 @@ export default class DragNDrop extends RunestoneBase {
6565
tmpArr.push(otherReplaceSpan);
6666
this.dragPairArray.push(tmpArr);
6767
} else if (
68-
$(this.origElem.childNodes[i]).data("component") === "question"
68+
$(this.origElem.childNodes[i]).data("subcomponent") === "question"
6969
) {
7070
this.question = this.origElem.childNodes[i].innerHTML;
7171
} else if (
72-
$(this.origElem.childNodes[i]).data("component") === "feedback"
72+
$(this.origElem.childNodes[i]).data("subcomponent") === "feedback"
7373
) {
7474
this.feedback = this.origElem.childNodes[i].innerHTML;
7575
}
@@ -81,6 +81,7 @@ export default class DragNDrop extends RunestoneBase {
8181
========================================*/
8282
createNewElements() {
8383
this.containerDiv = document.createElement("div");
84+
this.containerDiv.id = this.divid;
8485
$(this.containerDiv).addClass(
8586
"alert alert-warning draggable-container"
8687
);
@@ -97,7 +98,7 @@ export default class DragNDrop extends RunestoneBase {
9798
this.dragDropWrapDiv.appendChild(this.draggableDiv);
9899
this.dragDropWrapDiv.appendChild(this.dropZoneDiv);
99100
this.createButtons();
100-
this.checkServer("dragNdrop");
101+
this.checkServer("dragNdrop", true);
101102
}
102103
finishSettingUp() {
103104
this.appendReplacementSpans();

runestone/dragndrop/test/_sources/index.rst

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,10 @@ Testing: Drag and Drop Questions
1818
Drag and Drop
1919
-------------
2020

21-
.. dragndrop:: question3
21+
.. dragndrop:: test_dnd_1
2222
:feedback: Review your choice
2323
:match_1: C++|||cpp
2424
:match_2: Java|||java
2525
:match_3: Python|||py
2626

2727
Match the language and the file extension.
28-

0 commit comments

Comments
 (0)