Online Submission Versus Local Only - Using local_practice and submit_practice

This article outlines the interactions available when initialising activities of type: "local_practice" or "submit_practice".
 

"local_practice" is mainly used to do normal practice without saving responses. However, when working with Activities in "local_practice", Items API still provides a way to obtain and provide a saved user's responses when initialising in different states:

  • User's responses can be obtained by calling getResponses() method on the ItemsApp object obtained from the LearnosityApp.init() call.
  • User's saved responses can be provided as a response attribute within the activity JSON when initialising the Items API in either "resume" or "review" states.

Note "submit_practice" is the default value of activity type attribute.


Obtaining User Responses

To obtain the user's responses, Items API provides the getResponses public method. To access it, the host environment must assign the returned App object from the LearnosityApp.init() call to a local variable.

Method Arguments Return Description
getResponses()   Object Obtains an object containing responses for each Question that has been attempted.

getResponses() JSON example

{
    "classification_1_question_1": {
        "value": "Dublin",
        "characterCount": 6,
        "type": "string",
        "apiVersion": "latest"
    },
    "multiple_choice_1_question_1": {
        "value": ["sydney", "brisbane"],
        "type": "array",
        "apiVersion": "latest"
    }
}

Restoring User Responses

The object obtained from the getResponses() call can be provided back when initialising the Items API in "review" or "resume" state inside the Initialization Options in a responses attribute.

request JSON attribute

Key Type Default Description
responses Object   Object consisting of all questions that have been attempted, with response_ids as keys, and the response as value. This object can be obtained by calling getResponses()

Important Audio questions do not support retrieving a response from the responses Object. Local Practice Activities do not store content in Learnosity's servers, but audio questions require the response to be captured by Learnosity in order to support "resume" and "review" states.


request JSON Example

var initOptions = {
    "request": {
        "rendering_type": "assess",
        "user_id": "12345678",
        "session_id": "0df55215-90de-407a-b077-7017924556d3",
        "type": "local_practice",
        "state": "resume",
        "items": [
            "classification_1",
            "multiple_choice_1"
        ],
        "responses": {
            "classification_1_question_1": {
                "value": "Dublin",
                "characterCount": 6,
                "type": "string",
                "apiVersion": "latest"
            },
            "multiple_choice_1_question_1": {
                "value": ["sydney", "brisbane"],
                "type": "array",
                "apiVersion": "latest"
            }
        }
    },
    "security": {
        "consumer_key": "INSERT_CONSUMER_KEY_HERE",
        "domain": "docs.learnosity.com",
        "timestamp": "20131119-2026",
        "signature": "INSERT_GENERATED_SIGNATURE_HERE"
    }
};

When an activity is being initialized in "submit_practice" mode, Items API exposes two methods save() and submit(), which capture and store users progress into Learnosity's database.

The user's responses can be reloaded by initializing the activity session in "resume" or "review" mode. Submitted responses will be graded.

The responses can be retrieved via the Data API, and various statistics can be obtained through the Reports API.


Save And Submit

Method Argument Returns Description
save() [settings] (Object) - Save the user responses into Learnosity Database.
submit() [settings] (Object) - Save the user responses into Learnosity Database, and flags them for grading. This will make them available via the Reports API and Data API.

Activity JSON example

var initOptions = {
    "request": {
        "rendering_type": "assess",
        "user_id": "12345678",
        "session_id": "0df55215-90de-407a-b077-7017924556d3",
        "type": "submit_practice",
        "state": "resume",
        "items": [
            "classification_1",
            "multiple_choice_1"
        ]
    },
    "security": {
        "consumer_key": "INSERT_CONSUMER_KEY_HERE",
        "domain": "www.example.com",
        "timestamp": "20131119-2026",
        "signature": "INSERT_GENERATED_SIGNATURE_HERE"
    }
};
Was this article helpful?

Did you arrive here by accident? If so, learn more about Learnosity.