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

Commit b4efe96

Browse files
Move python_check output to old codecoach div
Purge old codecoach cruft
1 parent aa19d42 commit b4efe96

File tree

2 files changed

+30
-62
lines changed

2 files changed

+30
-62
lines changed

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: 21 additions & 51 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,12 +1272,7 @@ 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-
13051276
fetch('/ns/coach/python_check', {
13061277
method: 'POST',
13071278
body: code
@@ -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
}

0 commit comments

Comments
 (0)