SDK Initialization and Data Storage (Key-Value)
1. Methods
init (SDK Initialization)
⚠️ All functions provided by the SDK can only be used after the initialization is completed through the init method. Please make sure to use SDK features after the execution of this function is completed.
Vanilla JS example
React example
Initialize the SDK using the init()
function provided by the installed SDK.
By default, this function parses the query string included in the URL through
window.location.search
to extract thematerialId
andextToken
information necessary to integrate with the Elice platform.If it is difficult to provide information for integration from
window.location.search
, you can directly provide the information through thesearch
parameter in theinit()
function.By default,
baseUrl
is set to the Elice platform's production environment. If you want to use it in a test environment, please set thebaseUrl
as an argument.
sendScore (Send Score to the Elice Platform)
Configure to send the score to the Elice platform when the user completes the content.
Call the
sendScore()
function provided by@eliceio/content-sdk
when the content is completed. The function requires thescore
argument, and typically, a score of100
is sent when the content is completed.If the content is set as Elice class material, check if the score of the material becomes 100 as shown in the figure.
postKeyValue (Save Practice Changes to the Elice Platform)
To save a student's content changes on the Elice platform, use the postKeyValue()
function provided by @eliceio/content-sdk
. This function saves the key
and value
.
⚠️ Practice changes are stored separately for each user and material and do not affect other users or materials.
⚠️ Key and value writing rules
The key must always be written in camelCase and consist of alphanumeric characters ([a-zA-Z0-9]+]).
The possible types for the value are string, number, boolean, object, array. The keys of an object must always be written in camelCase.
getKeyValue (Retrieve Practice Changes from the Elice Platform)
To retrieve a student's content changes, use the getKeyValue()
function provided by @eliceio/content-sdk
. This function retrieves the value
corresponding to the key
.
delete (Delete key-value)
This method is used to delete a key-value pair from the Key-Value store.
Parameters
Name | Type | Description |
---|---|---|
|
| The unique key of the data to be deleted from kvstore. |
JavaScript Example
React Example
2. Properties
account (Account Information)
⚠️ The
account.accountId
property will be deprecated starting from version v1.0.0. Please useaccount.uid
instead.
You can retrieve the information of the account currently logged into the Elice platform. The account information can be retrieved through the account
property, which includes accountId (Account ID)
, fullname (Name)
, and uid (Unified ID)
.
metadata (Learning Material Metadata)
You can retrieve the metadata of the learning material registered on the Elice platform. The information is retrieved through the metadata
property, which includes the materialId (Material ID)
.
Last updated