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

Commit 5924848

Browse files
authored
Merge pull request #1344 from Xinying329/master
Updated log book event in the toggle feature
2 parents 4d88d78 + 7ee65b9 commit 5924848

File tree

2 files changed

+30
-11
lines changed

2 files changed

+30
-11
lines changed

runestone/activecode/js/activecode.js

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,7 @@ export class ActiveCode extends RunestoneBase {
217217
"2px solid #b43232"
218218
);
219219
this.isAnswered = true;
220+
// the first time the student types in the write-code box
220221
this.logBookEvent({
221222
event: "activecode",
222223
act: "edit",
@@ -265,9 +266,7 @@ export class ActiveCode extends RunestoneBase {
265266
// The run is finished; re-enable the button.
266267
this.runButton.disabled = false;
267268
this.runCount += 1;
268-
if (this.is_toggle && this.runCount == 3) {
269-
alert("Help is Available Using the Toggle Question Selector");
270-
}
269+
this.toggleAlert();
271270
}
272271

273272
createControls() {
@@ -281,7 +280,7 @@ export class ActiveCode extends RunestoneBase {
281280
$(butt).addClass("btn btn-success run-button");
282281
ctrlDiv.appendChild(butt);
283282
this.runButton = butt;
284-
console.log("adding click function for run");
283+
// console.log("adding click function for run");
285284
this.runButton.onclick = this.runButtonHandler.bind(this);
286285
$(butt).attr("type", "button");
287286

@@ -1272,6 +1271,19 @@ Yet another is that there is an internal error. The internal error message is:
12721271
}
12731272
}
12741273

1274+
toggleAlert(){
1275+
if (this.is_toggle && this.runCount == 3) {
1276+
if (this.errinfo != "success" || this.unit_results.substring(8,11)!=100.0){
1277+
setTimeout(function() {alert("Help is Available Using the Toggle Question Selector! You can try the Mixed-up Question first."); }, 500);
1278+
this.logBookEvent({
1279+
event: "togglealert",
1280+
act: "Help is Available Using the Toggle Question Selector",
1281+
div_id: this.divid,
1282+
})
1283+
}
1284+
}
1285+
}
1286+
12751287
/* runProg has several async elements to it.
12761288
* 1. Skulpt runs the python program asynchronously
12771289
* 2. The history is restored asynchronously

runestone/selectquestion/js/selectone.js

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -307,13 +307,20 @@ export default class SelectOne extends RunestoneBase {
307307
let closeButton = document.createElement("button");
308308
$(closeButton).text("Close Preview");
309309
$(closeButton).addClass("btn btn-default");
310-
$(closeButton).click(function (event) {
311-
$("#toggle-preview").html("");
312-
toggleQuestionSelect.value = $("#" + parentID).data(
313-
"toggle_current"
314-
);
315-
$("#component-preview").hide();
316-
});
310+
closeButton.addEventListener("click",
311+
function () {
312+
$("#toggle-preview").html("");
313+
toggleQuestionSelect.value = $("#" + parentID).data(
314+
"toggle_current"
315+
);
316+
$("#component-preview").hide();
317+
this.logBookEvent({
318+
event: "close_toggle",
319+
act: toggleQuestionSelect.value,
320+
div_id: toggleQuestionSelect.parentElement.id
321+
});
322+
}.bind(this)
323+
);
317324
$("#toggle-buttons").append(closeButton);
318325

319326
// if "lock" is not in toggle options, then allow adding more buttons to the preview panel

0 commit comments

Comments
 (0)