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

Commit 5318905

Browse files
committed
Fix a few small hparsons errors
1 parent a933b8d commit 5318905

File tree

2 files changed

+16
-7
lines changed

2 files changed

+16
-7
lines changed

runestone/hparsons/js/SQLFeedback.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ export default class SQLFeedback extends HParsonsFeedback {
261261
// adapted from activecode
262262
async buildProg() {
263263
// assemble code from prefix, suffix, and editor for running.
264-
// TODO: automatically joins the text array with space.
264+
// TODO: automatically joins the text array with space.
265265
// Should be joining without space when implementing regex.
266266
var prog;
267267
prog = this.hparsons.hparsonsInput.getParsonsTextArray().join(' ') + "\n";
@@ -280,7 +280,10 @@ export default class SQLFeedback extends HParsonsFeedback {
280280
let logData = {
281281
event: "hparsonsAnswer",
282282
div_id: this.hparsons.divid,
283-
act: act
283+
act: JSON.stringify(act),
284+
percent: this.percent || 0,
285+
correct: act.correct,
286+
answer: JSON.stringify({"blocks": act.answer}),
284287
}
285288
await this.hparsons.logBookEvent(logData);
286289
}

runestone/hparsons/js/hparsons.js

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@ import BlockFeedback from "./BlockFeedback.js";
55
import SQLFeedback from "./SQLFeedback.js";
66
import {InitMicroParsons} from 'micro-parsons/micro-parsons/micro-parsons.js';
77
import 'micro-parsons/micro-parsons/micro-parsons.css';
8+
// If you need to debug something in the micro-parsons library then
9+
// gh repo clone amy21206/micro-parsons-element
10+
// run npm install and npm build
11+
// copy everything from bin into the hparsons/js folder and build the components.
12+
/*import {InitMicroParsons} from './micro-parsons.js';
13+
import './micro-parsons.css';*/
814

915
export var hpList;
1016
// Dictionary that contains all instances of horizontal Parsons problem objects
@@ -32,7 +38,7 @@ export default class HParsons extends RunestoneBase {
3238
// Set the storageId (key for storing data)
3339
var storageId = super.localStorageKey();
3440
this.storageId = storageId;
35-
41+
3642
this.origElem = orig;
3743
this.origText = this.origElem.textContent;
3844
this.code = $(orig).text() || "\n\n\n\n\n";
@@ -76,7 +82,7 @@ export default class HParsons extends RunestoneBase {
7682

7783
// initializing functionalities for different feedback
7884
this.feedbackController.init();
79-
this.checkServer('hparsons', true);
85+
this.checkServer('hparsonsAnswer', true);
8086
}
8187

8288
// copied from activecode, already modified to add parsons
@@ -152,7 +158,7 @@ export default class HParsons extends RunestoneBase {
152158
}
153159

154160
// Return previous answers in local storage
155-
//
161+
//
156162
localData() {
157163
var data = localStorage.getItem(this.storageId);
158164
if (data !== null) {
@@ -168,7 +174,7 @@ export default class HParsons extends RunestoneBase {
168174
}
169175
// RunestoneBase: Sent when the server has data
170176
restoreAnswers(serverData) {
171-
// TODO: not tested with server data yet.
177+
// TODO: not tested with server data yet.
172178
// Server side data should be:
173179
/*
174180
{
@@ -177,7 +183,7 @@ export default class HParsons extends RunestoneBase {
177183
}
178184
*/
179185
if (serverData.answer){
180-
this.hparsonsInput.restoreAnswer(serverData.answer);
186+
this.hparsonsInput.restoreAnswer(serverData.answer.blocks);
181187
}
182188
if (serverData.count) {
183189
this.feedbackController.checkCount = serverData.count;

0 commit comments

Comments
 (0)