Closed wzhonggo closed 6 years ago
Hello! Just making sure, you have seen the documentation in the js file, right?
Get activity state from the LRS
@param {string} activityid the id of the Activity this state is about
@param {object} agent the agent this Activity state is related to
@param {string} [stateid] the id of the state, if not included, the response will be a list of stateids
associated with the activity and agent)
@param {string} [registration] the registraton id associated with this state
@param {object} [since] date object or date string telling the LRS to return objects newer than the date supplied
@param {function} [callback] function to be called after the LRS responds
to this request (makes the call asynchronous)
the function will be passed the XMLHttpRequest object
@return {object} xhr response object or null if 404
@example
ADL.XAPIWrapper.getState("http://adlnet.gov/expapi/activities/question",
{"mbox":"mailto:tom@example.com"}, "questionstate");
>> {info: "the state info"}
You should just need to include the stateid in the call if I am not mistaken.
Also, if you are trying to save the sate info, you should be using sendState which sends the information to your LRS.
sendState() is what you want.
The documentation for the function itself is a bit slim, admittedly.
Hi FlorianTolk
I've read document with xAPIWrapper before i create this issue and I know how to send state with sendState. But i am not know how to store the state when use getState. Does it need to be store old state in localStorage by myself.
Example : I want to change old state if old state is {"info":"1"}, but not a simple way to store old state etag.
var stateval = {"info":"2"};
var oldstateval = {"info":"1"};
var oldstatevalHash = ADL.XAPIWrapper.hash(JSON.stringify(oldstateval));
ADL.XAPIWrapper.sendState("http://adlnet.gov/expapi/activities/question",
{"mbox":"mailto:tom@example.com"},
"questionstate", null, stateval,oldstatevalHash);
You can store something locally or keep everything on the LRS -- it's up to you, really.
If you need assistance storing values on a local machine, then there are plenty of resources online for how to do that. :-)
I'll be closing this issue at the end of the week if there aren't any issues related to functionality.
After reading your question again: No there isn't any out-of-the-box functionality to save a history of state values.
But, there's nothing stopping you from saving your prior state as another state itself, or just attaching the history to your object itself (not recommended for performance reasons).
// The objects you pass can be anything serializable
//
var stateval = {"info":"2", "version": 1};
var oldstateval = {"info":"1", "version": 0};
var oldstatevalHash = ADL.XAPIWrapper.hash(JSON.stringify(oldstateval));
// Send the most recent one, which has its version number
//
ADL.XAPIWrapper.sendState("http://adlnet.gov/expapi/activities/question",
{"mbox":"mailto:tom@example.com"},
"questionstate", null, stateval);
// Send the previous one, which also has its version number, but send it to a unique
// IRL based on that version and the state ID
//
ADL.XAPIWrapper.sendState("http://adlnet.gov/expapi/activities/question",
{"mbox":"mailto:tom@example.com"},
"questionstate/" + oldStateVal["version"], null, oldstateval );
OK, I will customize the implementation of the old state of storage.
Thank you very much.
Hi
GetState function not store state value or etag. It there a simple way to store state value or etag?