Activity Save/Submit UI Buttons
The Items API exposes Public Methods to perform save and submit operations, which provides freedom to handle these operations and render custom UI as appropriate.
However, it also provides the ability to render a predefined UI for these operations, in case the client did not have a need for customizing the UI for them. To do so, a client needs to simply assign an attribute in the Activity JSON and insert a HTML hook where it wants the button to be rendered.
The save() and submit() operations are only valid when the Items API is initialized in Submit Practice Activities. If the Items API is initialized in local_practice mode, then calling these methods will raise error 10004 instead. To implement these operations in local_practice, see Local Practice Activities for more information.
Save Button
Attribute
Key | Type | Default | Description |
---|---|---|---|
renderSaveButton | boolean | false | If true, the API will render a Save Button |
Example
var initOptions = {
...
"config": {
"questions_api_init_options": {
"renderSaveButton": true
}
}
};
HTML Hook
A HTML node with class "learnosity-save-button" is required for the button to be rendered. The node acts as a placeholder and can be positioned anywhere within the DOM. If the attribute is true and the node is not found, nothing is rendered in the UI and an error event is triggered.
<span class="learnosity-save-button"></span>
UI Example
Submit Button
Attribute
Key | Type | Default | Description |
---|---|---|---|
renderSubmitButton | boolean | false | If true, the API will render a Submit Button |
Example
var initOptions = {
...
"config": {
"questions_api_init_options": {
"renderSubmitButton": true
}
}
};
HTML Hook
An HTML node with class "learnosity-submit-button" is required for the button to be rendered. The node acts as a placeholder and can be positioned anywhere within the DOM. If the attribute is true and the node is not found, nothing is rendered in the UI and an error event is triggered.
<span class="learnosity-submit-button"></span>