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

Commit 1595b1c

Browse files
author
Xinying329
committed
Updated log book event in Toggle feature
1 parent a5d65a8 commit 1595b1c

File tree

3 files changed

+36
-11
lines changed

3 files changed

+36
-11
lines changed

runestone/activecode/js/activecode.js

Lines changed: 17 additions & 5 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

@@ -649,7 +648,7 @@ export class ActiveCode extends RunestoneBase {
649648
$(this.timestampP).text(`${curVal} - ${pos + 1} of ${outOf}`);
650649
this.logBookEvent({
651650
event: "activecode",
652-
act: "slide:" + curVal,
651+
act: "save&run:" + curVal,
653652
div_id: this.divid,
654653
});
655654
};
@@ -1272,6 +1271,19 @@ Yet another is that there is an internal error. The internal error message is:
12721271
}
12731272
}
12741273

1274+
async 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/parsons/js/parsons.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2042,8 +2042,10 @@ export default class Parsons extends RunestoneBase {
20422042
//this.helpButton.disabled = true;
20432043
//}
20442044
// if less than 3 attempts
2045+
console.log("msg_parson_atleast_three_attempts")
20452046
if (this.numDistinct < 3) {
20462047
alert($.i18n("msg_parson_atleast_three_attempts"));
2048+
console.log("msg_parson_atleast_three_attempts")
20472049
}
20482050
// otherwise give help
20492051
else {

runestone/selectquestion/js/selectone.js

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -307,13 +307,24 @@ 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-
);
310+
$(closeButton).click(
311+
async function () {
312+
$("#toggle-preview").html("");
313+
toggleQuestionSelect.value = $("#" + parentID).data(
314+
"toggle_current"
315+
);
315316
$("#component-preview").hide();
316-
});
317+
}
318+
);
319+
closeButton.addEventListener("click",
320+
async function () {
321+
this.logBookEvent({
322+
event: "close_toggle",
323+
act: toggleQuestionSelect.value,
324+
div_id: toggleQuestionSelect.parentElement.id
325+
});
326+
}.bind(this)
327+
);
317328
$("#toggle-buttons").append(closeButton);
318329

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

0 commit comments

Comments
 (0)