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

Commit 5c28142

Browse files
committed
✨ Update grading for hparsons
1 parent bd6e411 commit 5c28142

File tree

3 files changed

+28
-26
lines changed

3 files changed

+28
-26
lines changed

runestone/hparsons/js/BlockFeedback.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,25 @@ export default class BlockFeedback extends HParsonsFeedback {
3030
// Called when check button clicked (block-based Feedback)
3131
async runButtonHandler() {
3232
this.checkCurrentAnswer();
33+
this.logCurrentAnswer();
3334
this.renderFeedback();
3435
}
3536

37+
async logCurrentAnswer() {
38+
let act = {
39+
scheme: "block",
40+
correct: this.grader.graderState == 'correct' ? "T" : "F",
41+
answer: this.hparsons.hparsonsInput.getParsonsTextArray(),
42+
percent: this.grader.percent
43+
}
44+
let logData = {
45+
event: "hparsonsAnswer",
46+
div_id: this.hparsons.divid,
47+
act: act
48+
}
49+
await this.hparsons.logBookEvent(logData);
50+
}
51+
3652
// Used for block-based feedback
3753
checkCurrentAnswer() {
3854
if (!this.solved) {

runestone/hparsons/js/SQLFeedback.js

Lines changed: 12 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -272,34 +272,20 @@ export default class SQLFeedback extends HParsonsFeedback {
272272
}
273273

274274
// copied from activecode-sql
275-
async logCurrentAnswer(sid) {
276-
// commenting these out for now
277-
// Not sure if we need to log run event in horizontal parsons
278-
// let data = {
279-
// div_id: this.hparsons.divid,
280-
// code: this.hparsons.hparsonsInput.getParsonsTextArray(),
281-
// language: "sql",
282-
// // errinfo: this.results[this.results.length - 1].status,
283-
// to_save: this.hparsons.saveCode,
284-
// prefix: this.hparsons.pretext,
285-
// suffix: this.hparsons.suffix,
286-
// }; // Log the run event
287-
// if (typeof sid !== "undefined") {
288-
// data.sid = sid;
289-
// }
290-
// await this.hparsons.logRunEvent(data);
291-
275+
async logCurrentAnswer() {
292276
if (this.unit_results) {
293-
let unitData = {
294-
event: "unittest",
277+
let act = {
278+
scheme: "execution",
279+
correct: (this.failed === 0 && this.percent != null) ? "T" : "F",
280+
answer: this.hparsons.hparsonsInput.getParsonsTextArray(),
281+
percent: this.percent // percent is null if there is execution error
282+
}
283+
let logData = {
284+
event: "hparsonsAnswer",
295285
div_id: this.hparsons.divid,
296-
course: eBookConfig.course,
297-
act: this.unit_results,
298-
};
299-
if (typeof sid !== "undefined") {
300-
unitData.sid = sid;
286+
act: act
301287
}
302-
await this.hparsons.logBookEvent(unitData);
288+
await this.hparsons.logBookEvent(logData);
303289
}
304290
}
305291

@@ -332,6 +318,7 @@ export default class SQLFeedback extends HParsonsFeedback {
332318
result += "\n";
333319
}
334320
let pct = (100 * this.passed) / (this.passed + this.failed);
321+
this.percent = pct;
335322
pct = pct.toLocaleString(undefined, { maximumFractionDigits: 2 });
336323
result += `You passed ${this.passed} out of ${this.passed + this.failed
337324
} tests for ${pct}%`;

runestone/hparsons/js/hparsons-sql.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,6 @@ export default class SQLHParsons extends RunestoneBase {
7575

7676
// copied from activecode, already modified to add parsons
7777
createEditor() {
78-
console.log('test create editor hparsons')
7978
this.outerDiv = document.createElement("div");
8079
$(this.origElem).replaceWith(this.outerDiv);
8180
let parsonsHTML = `<horizontal-parsons id='${this.divid}-hparsons'`;

0 commit comments

Comments
 (0)