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

Commit b58cd79

Browse files
committed
💡 Adding todo for fixing text entry
1 parent 62a6adc commit b58cd79

File tree

3 files changed

+34
-5
lines changed

3 files changed

+34
-5
lines changed

runestone/hparsons/hparsons.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ class HParsonsDirective(RunestoneIdDirective):
9696
.. hparsons:: uniqueid
9797
:language: sql, regex
9898
:dburl: only for sql -- url to load database
99-
99+
TODO: fix textentry
100100
:textentry: if you will use text entry instead of horizontal parsons
101101
102102
Here is the problem description. It must ends with the tildes.

runestone/hparsons/js/hparsons-sql.js

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ export default class SQLHParons extends RunestoneBase {
1919
// copied from activecode
2020
var suffStart;
2121
var orig = $(opts.orig).find("textarea")[0];
22+
this.textentry = $(orig).data('textentry') ? true : false;
2223
this.divid = opts.orig.id;
2324
this.containerDiv = opts.orig;
2425
this.useRunestoneServices = opts.useRunestoneServices;
@@ -140,8 +141,11 @@ export default class SQLHParons extends RunestoneBase {
140141
createEditor() {
141142
this.outerDiv = document.createElement("div");
142143
$(this.origElem).replaceWith(this.outerDiv);
143-
this.outerDiv.innerHTML = `<horizontal-parsons input-type='parsons' id='${this.divid}-hparsons'>`;
144-
console.log(this.code);
144+
if (this.textentry) {
145+
this.outerDiv.innerHTML = `<horizontal-parsons input-type='text' id='${this.divid}-hparsons'>`;
146+
} else {
147+
this.outerDiv.innerHTML = `<horizontal-parsons input-type='parsons' id='${this.divid}-hparsons'>`;
148+
}
145149
let blocks = [];
146150
let blockIndex = this.code.indexOf('--blocks--');
147151
if (blockIndex > -1) {
@@ -345,8 +349,12 @@ export default class SQLHParons extends RunestoneBase {
345349
// changed to getting parsons
346350
async buildProg(useSuffix) {
347351
// assemble code from prefix, suffix, and editor for running.
348-
var pretext;
349-
var prog = this.hparsons.getParsonsTextArray().join(' ') + "\n";
352+
var prog;
353+
if (this.textentry) {
354+
prog = this.hparsons.getCurrentInput();
355+
} else {
356+
prog = this.hparsons.getParsonsTextArray().join(' ') + "\n";
357+
}
350358
this.pretext = "";
351359
this.pretextLines = 0;
352360
this.progLines = prog.match(/\n/g).length + 1;

runestone/hparsons/test/_sources/index.rst

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,27 @@ Horizontal Parsons + SQL
2525

2626
.. :dburl: http://localhost:8000/_static/test.db
2727
28+
29+
.. hparsons:: teasfasfas
30+
:language: sql
31+
:dburl: /_static/test.db
32+
33+
34+
this is a cute horizontal parsons problem!
35+
~~~~
36+
--blocks--
37+
select
38+
*
39+
from
40+
test
41+
--unittest--
42+
assert 1,1 == world
43+
assert 0,1 == hello
44+
assert 2,1 == 42
45+
46+
.. :dburl: http://localhost:8000/_static/test.db
47+
48+
2849
.. activecode:: abcde
2950
:language: sql
3051
:autograde: unittest

0 commit comments

Comments
 (0)