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

Commit 5d30f41

Browse files
Merge remote-tracking branch 'origin/master'
# Conflicts: # runestone/activecode/css/activecode.css # runestone/activecode/js/activecode.js
2 parents d9d8f9a + f300922 commit 5d30f41

File tree

9 files changed

+309
-143
lines changed

9 files changed

+309
-143
lines changed

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ license = "GPL"
3434
name = "runestone"
3535
readme = "README.rst"
3636
repository = "https://github.com/RunestoneInteractive/RunestoneComponents"
37-
version = "6.5.4"
37+
version = "6.6.0"
3838

3939
# See https://python-poetry.org/docs/pyproject/#include-and-exclude.
4040
include = [

runestone/__main__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,8 @@ def rs2ptx(course, sourcedir, outdir):
340340
"""
341341
os.chdir(findProjectRoot())
342342
sys.path.insert(0, os.getcwd())
343-
del os.environ["DBURL"]
343+
if "DBURL" in os.environ:
344+
del os.environ["DBURL"]
344345
try:
345346
import pavement
346347
except Exception as e:

runestone/activecode/css/activecode.css

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,6 @@
5757
clear: both;
5858
}
5959

60-
.ac_section .clearfix {
61-
position: initial;
62-
}
63-
6460
.unittest-results {
6561
margin-left: 20px;
6662
}
@@ -75,12 +71,6 @@
7571
background-color: lightgray;
7672
}
7773

78-
.python_check_results {
79-
margin-top: 20px;
80-
padding-top: 0px;
81-
padding-bottom: 0px;
82-
}
83-
8474
.python_check_results pre {
8575
background-color: #f5f5f5;
8676
}
@@ -160,4 +150,12 @@
160150

161151
.codelens {
162152
margin-bottom: 20px;
163-
}
153+
}
154+
155+
.codecoach {
156+
margin-top: 20px;
157+
}
158+
159+
.ac_section .alert h3:first-child {
160+
margin-top: 0px;
161+
}

runestone/activecode/js/activecode.js

Lines changed: 22 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -721,6 +721,19 @@ export class ActiveCode extends RunestoneBase {
721721
$(this.graphics).addClass("visible-ac-canvas");
722722
}.bind(this)
723723
);
724+
725+
//Anything that wants to add output to coachdiv can do so after the h3
726+
// all those elements will be cleared with each run and coach display will be
727+
// reset to none. Any component that adds content after a run should set display
728+
// to block to ensure visibility
729+
var coachDiv = document.createElement("div");
730+
coachDiv.classList.add("alert", "alert-warning", "codecoach");
731+
$(coachDiv).css("display", "none");
732+
let coachHead = coachDiv.appendChild(document.createElement("h3"));
733+
coachHead.textContent = "Code Coach";
734+
this.outerDiv.appendChild(coachDiv);
735+
this.codecoach = coachDiv;
736+
724737
outDiv.appendChild(this.output);
725738
outDiv.appendChild(this.graphics);
726739
this.outerDiv.appendChild(outDiv);
@@ -730,11 +743,6 @@ export class ActiveCode extends RunestoneBase {
730743
$(lensDiv).css("display", "none");
731744
this.codelens = lensDiv;
732745
this.outerDiv.appendChild(lensDiv);
733-
var coachDiv = document.createElement("div");
734-
coachDiv.classList.add("codecoach");
735-
$(coachDiv).css("display", "none");
736-
this.codecoach = coachDiv;
737-
this.outerDiv.appendChild(coachDiv);
738746
}
739747

740748
disableSaveLoad() {
@@ -903,38 +911,6 @@ export class ActiveCode extends RunestoneBase {
903911
div_id: this.divid,
904912
});
905913
}
906-
// <iframe id="%(divid)s_codelens" width="800" height="500" style="display:block"src="#">
907-
// </iframe>
908-
showCodeCoach() {
909-
var myIframe;
910-
var srcURL;
911-
var cl;
912-
var div_id = this.divid;
913-
if (this.codecoach === null) {
914-
this.codecoach = document.createElement("div");
915-
this.codecoach.style.display = "block";
916-
}
917-
cl = this.codecoach.firstChild;
918-
if (cl) {
919-
this.codecoach.removeChild(cl);
920-
}
921-
srcURL = eBookConfig.app + "/admin/diffviewer?divid=" + div_id;
922-
myIframe = document.createElement("iframe");
923-
myIframe.setAttribute("id", div_id + "_coach");
924-
myIframe.setAttribute("width", "100%");
925-
myIframe.setAttribute("height", "500px");
926-
myIframe.setAttribute("style", "display:block");
927-
myIframe.style.background = "#fff";
928-
myIframe.style.width = "100%";
929-
myIframe.src = srcURL;
930-
this.codecoach.appendChild(myIframe);
931-
$(this.codecoach).show();
932-
this.logBookEvent({
933-
event: "coach",
934-
act: "view",
935-
div_id: this.divid,
936-
});
937-
}
938914

939915
toggleEditorVisibility() {}
940916

@@ -1296,13 +1272,8 @@ Yet another is that there is an internal error. The internal error message is:
12961272
}
12971273

12981274
async checkPythonSyntax() {
1299-
let checkDiv = this.outerDiv.querySelector("div.python_check_results");
1300-
if( checkDiv != null )
1301-
checkDiv.remove();
1302-
13031275
let code = this.editor.getValue();
1304-
1305-
fetch('/ns/books/python_check', {
1276+
fetch('/ns/coach/python_check', {
13061277
method: 'POST',
13071278
body: code
13081279
})
@@ -1332,17 +1303,12 @@ Yet another is that there is an internal error. The internal error message is:
13321303
message = message.slice(0,-1); //remove trailing newline
13331304

13341305
//Render
1335-
checkDiv = document.createElement("div");
1336-
checkDiv.classList.add("python_check_results","alert", "alert-warning");
1337-
let checkHead = checkDiv.appendChild(document.createElement("h3"));
1338-
checkHead.textContent = "Syntax Tips";
1306+
let checkDiv = document.createElement("div");
1307+
checkDiv.classList.add("python_check_results");
13391308
let checkPre = checkDiv.appendChild(document.createElement("pre"));
1340-
//checkPre.classList.add("alert-warning");
13411309
checkPre.textContent = message;
1342-
1343-
//Squeeze check_results right before output pane
1344-
const outDiv = this.outDiv;
1345-
outDiv.parentNode.insertBefore(checkDiv, outDiv);
1310+
this.codecoach.append(checkDiv);
1311+
$(this.codecoach).css("display", "block");
13461312
}
13471313
})
13481314
.catch(err => {
@@ -1375,6 +1341,10 @@ Yet another is that there is an internal error. The internal error message is:
13751341
var prog = await this.buildProg(true);
13761342
this.saveCode = "True";
13771343
$(this.output).text("");
1344+
1345+
//clear anything after header in codecoach
1346+
$(this.codecoach).children().slice(1).remove();
1347+
13781348
while ($(`#${this.divid}_errinfo`).length > 0) {
13791349
$(`#${this.divid}_errinfo`).remove();
13801350
}

runestone/hparsons/hparsons.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,10 +102,16 @@ class HParsonsDirective(RunestoneIdDirective):
102102
Here is the problem description. It must ends with the tildes.
103103
Make sure you use the correct delimitier for each section below.
104104
~~~~
105+
--hiddenprefix--
106+
// code that is for scaffolding the execution (e.g. initializing database)
105107
--blocks--
106108
block 1
107109
block 2
108110
block 3
111+
--hiddensuffix--
112+
// code that is for scaffolding unittest/execution (e.g. adding query for database)
113+
// most of the time the hiddensuffix is just "select * from table" to
114+
// get all entries from the table to test the update or other operations.
109115
--unittest--
110116
assert 1,1 == world
111117
assert 0,1 == hello

0 commit comments

Comments
 (0)