Getting started with the Node.js client for the SCORM Cloud API
Updated on
If you’re using Rustici Software’s SCORM Cloud service to deliver and manage e-learning content, the SCORM Cloud API provides an interface to build custom integrations and reporting tools. To get you started, I’ve put together some examples using the Node.js client library.
Installation
To get started, first install the module using the npm install
command:
Usage
If you have not already, sign up for a SCORM Cloud account. You are required to provide API credentials in the form of an Application ID (App ID) and a secret key. You can access this information from the Apps / API page:
- Click the Details link to view the secret key for an existing application. The App ID is also listed at the top of this page.
- Click the Add Application button to create a new application for testing purposes.
You’ll need to import the module and construct an instance of the API client with your Application ID and secret key. You can do this from the Node REPL by running the node
command without a filename.
Use the authPing
method to verify that your credentials are valid and that the web service is reachable. Note that asynchronous functions use error-first callbacks. The first argument is reserved for an error object, and the second for response data.
If true
was printed to your console, you’re ready to continue to the next section.
Importing a course
Use the importCourse
method to add a course to your library in SCORM Cloud. You’ll need to provide a unique identifier and file path for the course, and a callback function. If the course identifier refers to an existing course, a new version of the course will be created.
The import results will be printed to your console. If your import was successful, you should see output similar to the following:
Creating registrations
One way that you can connect learners to your content in SCORM Cloud is through registrations – you provide the learner and course information to create a unique registration that can be launched from your system. When an integrating system “assigns” a course to a learner, if will often create a registration in SCORM Cloud.
Use the createRegistration
method to create a new registration. You’ll need to provide the unique identifier for the course, a unique identifier for the registration, learner information, and a callback function.
In the examples below, I’m using the uuid module to generate unique identifiers for registrations. Use the npm install uuid
command to install the module before continuing.
If true
was printed to your console, the registration was created successfully.
Launching a registration
Registrations are launched using an API url that will respond with a 302 Redirect that provides the learner access to the registration and course content.
Use the getLaunchUrl
method to generate a launch url for a registration. This API url is valid for approximately 15 minutes – you should generate this immediately before launching a registration for a learner.
Creating invitations
Another way that you can connect learners to your content in SCORM Cloud is through invitations. Invitations can be used to create a public link to your course, or a private link that is emailed directly to each learner. Use the createInvitation
method to create either type of invitation.
Public invitations require that learners enter a name and email address in order to create the registration and launch the training. To create a public invitation:
The web service responds with a unique identifier for the invitation. Use the getInvitationInfo
method to retrieve details about an invitation.
Details about the invitation should be printed to your console if you’re following along in the Node REPL.
Retrieving registration results
The getRegistrationListResults
method allows you to retrieve a list of registration results limited to a specific course or learner. Registration results include the completion status, success status, total time spent, and the overall score.
The registration results will be printed to your console. You should expect to see output similar to the following:
If you found this article helpful, visit the GitHub project page and star the project. Use the Issues to request new features or report bugs. Stay tuned for additional examples!