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

Commit 5ac48b5

Browse files
committed
🎉 A working version of the tool!
1 parent b160087 commit 5ac48b5

5 files changed

Lines changed: 24 additions & 23 deletions

File tree

runestone/hparsons/hparsons.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,10 +91,10 @@ class HParsonsDirective(Assessment):
9191
9292
"""
9393

94-
required_arguments = 0 # the div id
95-
optional_arguments = 0
94+
required_arguments = 1 # the div id
95+
optional_arguments = 0
9696
final_argument_whitespace = True
97-
has_content = False
97+
has_content = True
9898
option_spec = Assessment.option_spec.copy()
9999
# seem to be defining the type of the options
100100
# option_spec.update({"mathjax": directives.flag})

runestone/hparsons/js/hparsons.js

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -22,34 +22,26 @@ if (hpList === undefined) hpList = {};
2222
export default class HParsons extends RunestoneBase {
2323
constructor(opts) {
2424
super(opts);
25-
console.log('hparsons')
2625
if (opts) {
2726
// TODO: what is orig?
2827
var orig = opts.orig; // entire <pre> element that will be replaced by new HTML
2928
this.containerDiv = orig;
30-
this.origElem = $(orig).find("pre.parsonsblocks")[0];
29+
this.origElem = $(orig).find(".hparsons")[0];
30+
console.log('hparsons')
3131
console.log(orig)
32+
console.log(this.origElem)
3233
this.useRunestoneServices =
3334
opts.useRunestoneServices || eBookConfig.useRunestoneServices;
3435
this.divid = orig.id;
3536

3637
// The element that is going to be replaced
37-
// this.elem = $(orig).find(".hparsons")[0];
3838
// Find the question text and store it in .question
3939
this.question = $(orig).find(`.hparsons_question`)[0];
4040
// TODO: idk what this is with shortanswer
41-
// this.question = this.origElem.innerHTML;
42-
// this.optional = false;
43-
// if ($(this.origElem).is("[data-optional]")) {
44-
// this.optional = true;
45-
// }
46-
// if ($(this.origElem).is("[data-mathjax]")) {
47-
// this.mathjax = true;
48-
// }
4941
this.renderHTML();
5042
this.caption = "hparsons";
51-
// this.addCaption("runestone");
52-
// this.checkServer("hparsons", true);
43+
this.addCaption("runestone");
44+
this.checkServer("hparsons", true);
5345

5446
// Set the storageId (key for storing data)
5547
var storageId = super.localStorageKey();
@@ -63,13 +55,15 @@ export default class HParsons extends RunestoneBase {
6355

6456
renderHTML() {
6557
console.log('renderhtml');
66-
const div = document.createElement('regex-element');
67-
div.setAttribute('input-type', 'parsons')
68-
div.id = 'abcd';
69-
$(this.origElem).replaceWith(div);
58+
// const div = document.createElement('regex-element');
59+
// div.setAttribute('input-type', 'parsons')
60+
// div.id = 'abcd';
61+
// console.log(this.origElem)
62+
$(this.origElem).html('<regex-element id="tool-area"></regex-element>');
63+
// console.log(this.origElem)
7064
// $(this.origElem).replaceWith(document.createElement('regex-element'));
7165
// $(this.elem).innerHTML = `<regex-element input-type='parsons' id="abcd"></regex-element>`;
72-
console.log(div)
66+
// console.log(div)
7367
}
7468

7569
checkCurrentAnswer() { }

runestone/hparsons/test/_sources/index.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ ActiveCode
5050

5151
.. hparsons:: codeexample1
5252

53-
content content content
53+
content content content
5454

5555

5656

runestone/mchoice/js/mchoice.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,10 @@ window.mcList = {}; // Multiple Choice dictionary
2121
export default class MultipleChoice extends RunestoneBase {
2222
constructor(opts) {
2323
super(opts);
24-
console.log('mchoice')
2524
opts = opts || {};
2625
var orig = opts.orig; // entire <ul> element
26+
console.log('mchoice')
27+
console.log(orig)
2728
this.origElem = orig;
2829
this.useRunestoneServices = opts.useRunestoneServices;
2930
this.multipleanswers = false;

test.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/bin/bash
2+
npm run build
3+
pip install .
4+
cd runestone/hparsons/test
5+
runestone build
6+
runestone serve

0 commit comments

Comments
 (0)