Forum

PCI: setSerializedState & getSerializedState

edited May 14 in Developers

The behavior regarding state serialization isn't very well defined.

First of all jsdoc headers don't match the function header in any examples supplied:

     * @param {Object} interaction
     * @param {Object} serializedState - json format

VS. reality in the samples:
setSerializedState : function(state){}

Secondly, in samples supplied getSerializedState return value is described as follows:
* @param {Object} serializedState - json format

So should I return a string? A serializable JS object? A specific object schema?

When I implement these functions, it seems like setSerializedState always gets the mangled response from getResponse, In other words I get something like {response:{base:{string:'foobar'}}}, except the string is mangled and escape characters (backslash) are removed, so a newline becomes an n.

Can someone tell me, what is the correct way to implement the 'preview' functionality on results for custom PCIs?

Comments

  • Those methods are used to save and restore "anything", as soon as it's JSON.
    By default the response goes in (to restore the response), but the state can contain more info/data.
    For example, if you have shuffled some questions but want the order to be kept while navigating back and forward, you'll use the serializedState to keep the order. it can be anything, it's the reason why the documented format is open.

    This may change with QTI 3.1.

    Thanks,

    Amy

  • edited May 19

    My problem is that I have defined both setSerializedState and getSerializedState. If I navigate back to the PCI by using the 'Previous' button, the state from getSerializedState is indeed used in setSerializedState... HOWEVER, when setSerializedState is called in the taoOutcomeUi "preview", it gets the response from setResponse instead. Is this a bug? Or is the behavior just not defined in spec?

    I ask again, more precisely: "What is the correct way to implement "preview" functionality in the TaoOutcomeUi?"

    Tao version is 3.2.0-RC2 btw.

  • edited May 19

    You keep using the term JSON, does it refer to a serializable javascript object? Or is this a JSON string? As I said, documentation is vague. (I of course know the answer, its an object, any object that can be serialized with JSON.stringify, but you insist on using vague or misleading terminology.)

  • What is the version of TAO you have implemented?

  • Im using Tao 3.2 and 3.3, same behavior in both. OutcomeUi initializes PCIs with response and not the serialized state...

  • I have read this document yes, but the flow diagram sadly isn't complete I assume? It also doesn't really say anything about what happens in TaoOutcomeUI...

  • edited May 21

    I guess my solution will have to be to put the state in the response. This isn't exactly great from a UX perspective as reviewers will have to deal with the extra non human readable data in the response fields. Unless this isn't the expected behavior when reviewing in outcomeui?

  • This is the current state as per the standard. As always any contributions to improve TAO are welcome.

    Thanks,

    Amy

  • Amy, are you 100% sure about this? I find it wierd that the state gets POSTed and presumably stored somewhere along with the response?

    Anyways, it works now. While I have you here, do you have any guides on working on TAO? Im working on a module. The scaffolding for extensions in 3.3 is a good start so far, but any developer guides, raw documentation etc. would be appreciated :)

  • That’s what I was finding in the older version as QTI 3 isn’t out yet. As far as documentation we are working on new docs, including a developer guide, as we prepare for our TAO 3.3 release.

Sign In or Register to comment.

We use cookies on our website to support technical features that enhance your user experience. Cookie Policy Privacy Policy

×