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

Commit 0d7777a

Browse files
authored
Merge branch 'master' into selenium_fixse
2 parents 54c3d11 + 5d4e53a commit 0d7777a

7 files changed

Lines changed: 68 additions & 61 deletions

File tree

runestone/activecode/js/activecode.js

Lines changed: 44 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -241,9 +241,14 @@ export class ActiveCode extends RunestoneBase {
241241
$(butt).addClass("btn btn-success run-button");
242242
ctrlDiv.appendChild(butt);
243243
this.runButton = butt;
244+
console.log("adding click function for run");
244245
$(butt).click(
245246
async function () {
246-
await this.runProg();
247+
try {
248+
await this.runProg();
249+
} catch (e) {
250+
console.log(`there was an error ${e} running the code`);
251+
}
247252
if (this.logResults) {
248253
this.logCurrentAnswer();
249254
}
@@ -1136,42 +1141,46 @@ Yet another is that there is an internal error. The internal error message is:
11361141
}
11371142

11381143
async manage_scrubber(saveCode) {
1139-
let scrubber_dfd = false;
11401144
if (this.historyScrubber === null && !this.autorun) {
1141-
scrubber_dfd = await this.addHistoryScrubber();
1142-
}
1143-
if (scrubber_dfd && scrubber_dfd.ok) {
1144-
if (
1145-
this.historyScrubber &&
1146-
this.history[$(this.historyScrubber).slider("value")] !=
1147-
this.editor.getValue()
1148-
) {
1149-
saveCode = "True";
1150-
this.history.push(this.editor.getValue());
1151-
this.timestamps.push(new Date().toLocaleString());
1152-
$(this.historyScrubber).slider(
1153-
"option",
1154-
"max",
1155-
this.history.length - 1
1156-
);
1157-
$(this.historyScrubber).slider(
1158-
"option",
1159-
"value",
1160-
this.history.length - 1
1161-
);
1162-
this.slideit();
1163-
} else {
1164-
saveCode = "False";
1165-
}
1166-
if (this.historyScrubber == null) {
1167-
saveCode = "False";
1145+
let response = await this.addHistoryScrubber();
1146+
if (!response.ok) {
1147+
console.log("Failed to load history -- this should not fail.");
11681148
}
11691149
}
1150+
if (
1151+
this.historyScrubber &&
1152+
this.history[$(this.historyScrubber).slider("value")] !=
1153+
this.editor.getValue()
1154+
) {
1155+
saveCode = "True";
1156+
this.history.push(this.editor.getValue());
1157+
this.timestamps.push(new Date().toLocaleString());
1158+
$(this.historyScrubber).slider(
1159+
"option",
1160+
"max",
1161+
this.history.length - 1
1162+
);
1163+
$(this.historyScrubber).slider(
1164+
"option",
1165+
"value",
1166+
this.history.length - 1
1167+
);
1168+
this.slideit();
1169+
} else {
1170+
saveCode = "False";
1171+
}
1172+
if (this.historyScrubber == null) {
1173+
saveCode = "False";
1174+
}
11701175
return Promise.resolve(saveCode);
11711176
}
11721177

11731178
async checkCurrentAnswer() {
1174-
this.run_promise = this.runProg();
1179+
try {
1180+
await this.runProg();
1181+
} catch (e) {
1182+
console.log(`error running code ${e}`);
1183+
}
11751184
}
11761185

11771186
logCurrentAnswer() {
@@ -1229,6 +1238,7 @@ Yet another is that there is an internal error. The internal error message is:
12291238
*
12301239
*/
12311240
async runProg(noUI, logResults) {
1241+
console.log("starting runProg");
12321242
if (typeof logResults === "undefined") {
12331243
this.logResults = true;
12341244
} else {
@@ -1241,7 +1251,10 @@ Yet another is that there is an internal error. The internal error message is:
12411251
var prog = await this.buildProg(true);
12421252
this.saveCode = "True";
12431253
$(this.output).text("");
1244-
$(this.eContainer).remove();
1254+
while ($(`#${this.divid}_errinfo`).length > 0) {
1255+
$(`#${this.divid}_errinfo`).remove();
1256+
}
1257+
//$(this.eContainer).remove();
12451258
if (this.codelens) {
12461259
this.codelens.style.display = "none";
12471260
}

runestone/activecode/js/timed_activecode.js

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -71,21 +71,10 @@ var TimedActiveCodeMixin = {
7171
},
7272

7373
reinitializeListeners: function (taken) {
74-
// re-attach the run button listener
75-
$(this.runButton).click(this.runProg.bind(this));
7674
$(this.codeDiv).show();
7775
this.runButton.disabled = false;
7876
$(this.codeDiv).removeClass("ac-disabled");
7977
this.editor.refresh();
80-
$(this.histButton).click(this.addHistoryScrubber.bind(this));
81-
if (this.historyScrubber !== null) {
82-
$(this.historyScrubber).slider({
83-
max: this.history.length - 1,
84-
value: this.history.length - 1,
85-
slide: this.slideit.bind(this),
86-
change: this.slideit.bind(this),
87-
});
88-
}
8978
if (taken) {
9079
$(`#${this.divid}_unit_results`).show();
9180
}

runestone/common/js/runestonebase.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,10 @@ export default class RunestoneBase {
6161
});
6262
}
6363

64-
// .. _logBookEvent:
65-
//
66-
// logBookEvent
67-
// ------------
64+
// .. _logBookEvent:
65+
//
66+
// logBookEvent
67+
// ------------
6868
// This function sends the provided ``eventInfo`` to the `hsblog endpoint` of the server. Awaiting this function returns either ``undefined`` (if Runestone services are not available) or the data returned by the server as a JavaScript object (already JSON-decoded).
6969
async logBookEvent(eventInfo) {
7070
if (this.graderactive) {
@@ -100,10 +100,10 @@ export default class RunestoneBase {
100100
return post_return;
101101
}
102102

103-
// .. _logRunEvent:
104-
//
105-
// logRunEvent
106-
// -----------
103+
// .. _logRunEvent:
104+
//
105+
// logRunEvent
106+
// -----------
107107
// This function sends the provided ``eventInfo`` to the `runlog endpoint`. When awaited, this function returns the data (decoded from JSON) the server sent back.
108108
async logRunEvent(eventInfo) {
109109
let post_promise = "done";
@@ -122,8 +122,8 @@ export default class RunestoneBase {
122122
headers: this.jsonHeaders,
123123
body: JSON.stringify(eventInfo),
124124
});
125-
post_promise = await fetch(request);
126-
if (!post_promise.ok) {
125+
let response = await fetch(request);
126+
if (!response.ok) {
127127
throw new Error("Failed to log the run");
128128
}
129129
post_promise = await response.json();

runestone/mchoice/test/test_assess.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,10 @@ def test_mc2(self):
169169

170170
fb = t1.find_element_by_id("question2_feedback")
171171
self.assertIsNotNone(fb)
172+
self.wait.until(
173+
EC.text_to_be_present_in_element((By.ID, "question2_feedback"), "Red"),
174+
message="Did not find expected text",
175+
)
172176
cnamestr = fb.get_attribute("class")
173177
self.assertIn("alert-info", cnamestr)
174178

runestone/parsons/js/parsons.js

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,7 @@ export default class Parsons extends RunestoneBase {
278278
this.parsonsControlDiv.appendChild(this.messageDiv);
279279
$(this.messageDiv).hide();
280280
$(this.origElem).replaceWith(this.containerDiv);
281+
$(this.containerDiv).closest(".sqcontainer").css("max-width", "none");
281282
}
282283
// Initialize lines and solution properties
283284
initializeLines(text) {
@@ -296,13 +297,13 @@ export default class Parsons extends RunestoneBase {
296297
// Remove the options from the code
297298
// only options are #paired or #distractor
298299
var options = {};
299-
textBlock = textBlock.replace(/#(paired|distractor)/, function (
300-
mystring,
301-
arg1
302-
) {
303-
options[arg1] = true;
304-
return "";
305-
});
300+
textBlock = textBlock.replace(
301+
/#(paired|distractor)/,
302+
function (mystring, arg1) {
303+
options[arg1] = true;
304+
return "";
305+
}
306+
);
306307
// Create lines
307308
var lines = [];
308309
var split = textBlock.split("\n");

runestone/selectquestion/selectone.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747

4848

4949
TEMPLATE = """
50-
<div class="runestone alert alert-warning">
50+
<div class="runestone alert alert-warning sqcontainer">
5151
<div data-component="selectquestion" id={component_id} {selector} {points} {proficiency} {min_difficulty} {max_difficulty} {autogradable} {not_seen_ever} {primary} {AB}>
5252
<p>Loading ...</p>
5353
</div>

runestone/timed/js/timed.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -817,7 +817,7 @@ export default class Timed extends RunestoneBase {
817817
currentQuestion.renderFeedback();
818818

819819
for (var i = 0; i < this.renderedQuestionArray.length; i++) {
820-
var currentQuestion = this.renderedQuestionArray[i];
820+
let currentQuestion = this.renderedQuestionArray[i];
821821
// set the state to forreview so we know that feedback may be appropriate
822822
currentQuestion.state = "forreview";
823823
}

0 commit comments

Comments
 (0)