GithubHelp home page GithubHelp logo

Comments (6)

FlorianTolk avatar FlorianTolk commented on June 14, 2024

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:[email protected]"}, "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.

from xapiwrapper.

vbhayden avatar vbhayden commented on June 14, 2024

sendState() is what you want.

The documentation for the function itself is a bit slim, admittedly.

from xapiwrapper.

wzhonggo avatar wzhonggo commented on June 14, 2024

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.

  1. send state id questionstate is {"info":"1"}
  2. get state id questionstate , LRS server will return {"info":"1"}.
  3. I want to change questionstate, so i will send state id questionstate is {"info":"2"} and old state sha1 with {"info":"1"}.
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:[email protected]"}, 
                   "questionstate", null, stateval,oldstatevalHash);

from xapiwrapper.

vbhayden avatar vbhayden commented on June 14, 2024

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.

from xapiwrapper.

vbhayden avatar vbhayden commented on June 14, 2024

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:[email protected]"}, 
                   "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:[email protected]"}, 
                   "questionstate/" + oldStateVal["version"], null, oldstateval );
  

from xapiwrapper.

wzhonggo avatar wzhonggo commented on June 14, 2024

OK, I will customize the implementation of the old state of storage.

Thank you very much.

from xapiwrapper.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.