RunestoneInteractive / RunestoneComponents

Packaging of the Runestone tools for publishing educational materials using github pages
http://runestoneinteractive.org
Other
101 stars 225 forks source link

Add restoring local student answer for hparsons directive #1386

Closed amy21206 closed 1 year ago

amy21206 commented 1 year ago

Implemented checkLocalStorage(), setLocalStorage(), and restoreAnswers() for hparsons directive.

Server implementation might be needed for restoring server-side answers. Documentation included in restoreAnswers().

bnmnetp commented 1 year ago

Working with localStorage but not with data from the server.

Here is the object that the server returns, but

serverData
{id: 5, timestamp: '2023-02-23T01:55:22.625929', div_id: 'test_hparsons_block_1', sid: 'testuser1', correct: true, …}
answer: blocks: (4) ['SELECT', '*', 'FROM', 'test']
[[Prototype]]: Object
correct: true
course_name: "overview"
div_id: "test_hparsons_block_1"
id: 5
percent: 1
sid: "testuser1"
timestamp: "2023-02-23T01:55:22.625929"

Also, there is no reason to log the fact that we restored the answer. None of the other components log that action.

bnmnetp commented 1 year ago

@amy21206 I changed my code so that it now calls

this.hparsonsInput.restoreAnswer(serverData.answer.blocks);

But I'm still not getting a restore to work with server data.

Its hard to debug because I only have the minified version of the microparsons. How do you have your development environment set up so that you can make changes to microparsons and then incorporate them into runestone without doing a release and npm update on the runestone side?

bnmnetp commented 1 year ago

OK, I figured out a workflow....

I changed the imports in hparsons and copied everything from bin/ to the hparsons/js folder.

Now I am able to step through everything with the debugger. And it appears that it is working....

I also re-updated the micro-parsons package with npm and with my small change it now appears to work either way.... So I don't think you need to do anything at the moment, but I would suggest eliminating the log message about restoring.

amy21206 commented 1 year ago

Sorry I just saw the message! I just changed my settings for github email notification so I can get the messages in time in the future. I will remove the log message about restoring, and let me know if there's anything else!