You can actually decide how to initialize the state yourself - completely blank, empty data structure, some starting data, whatever you want.
If you want to give a particular piece of feedback within one problem, that’s easier - you can use Write-Your-Own-Grader problems and return all kinds of custom stuff.
Sharing data between problems is very difficult if they’re not on the same page. That’s one of the things I had hoped to make easier with this project - providing variables that are keyed to a particular student and letting problems interact with them via javascript. Hopefully I’ll be able to fix this project eventually, but I’m awful busy these days.
If you want some examples of JSInput problems, check out https://github.com/HarvardX/js-input-samples , where there a bunch of problems that I wrote and that some folks at Stanford wrote. The text_logger problem is probably the easiest one to start with.
So looking at the “Write Your Own grader” & JSProblemState usage in those examples it seems that they all seem useful enough but its not clear to me how to learn & use the leaners data e.g. first name from any of the documentation I’ve read thus far.
Is there any documentation about the context within which this JSInput code or the Python code in an OLX script executes? I read about the CodeJail. But what objects are accessible during execution that might contain the user’s info or an id to do a lookup somewhere to find it?
I’m interested in doing some personalization of the questions/content. Thanks so much for making time to help me understand better.
You are correct - there’s no easy access to user data from within a problem. There’s no access to it at all from the problem’s python; instead you have to pull it via javascript.
You can get the username via javascript from analytics._user._getTraits(), but only once the page loads completely. Then you have to somehow pass it to the python if you want it in the feedback message. If you have a JSInput problem, you can pass it back to the grading python as part of the state I mentioned before. Otherwise, you need to use Stupid JQuery Tricks™ to insert it after the message appears.
Practically none of this is documented. My colleagues and I had to hunt around to find the analytics object, and there’s no guarantee it will be unchanged in the future. I keep a wiki called edX Undocumented that attempts to track some of these things.