Skip to main content

Settings Reference

The APIs include several settings to customize the functionality of each API. Settings are passed when creating a new API instance.

Basic Usage

const settings = {
autocommit: true,
lmsCommitUrl: 'https://your-lms.com/api/scorm/commit',
logLevel: 'DEBUG'
};

// SCORM 1.2
window.API = new Scorm12API(settings);

// SCORM 2004
window.API_1484_11 = new Scorm2004API(settings);

Settings Table

General Settings

SettingDefaultTypeDescription
autocommitfalsebooleanDetermines whether the API schedules an autocommit to the LMS after setting a value.
autocommitSeconds10numberNumber of seconds to wait before autocommitting. Timer is restarted if another value is set.
sendFullCommittruebooleanDetermines whether the API sends the full CMI object as part of the commit, or if it only sends the fields that actually contain values.
renderCommonCommitFieldsfalsebooleanEmits a structured commit object with summary fields and runtimeData. SCORM 2004 structured commits also include the sequencing globalObjectives snapshot.
selfReportSessionTimefalsebooleanMeasures elapsed time from Initialize() and uses it instead of relying on SCO-reported session_time.
alwaysSendTotalTimefalsebooleanShould the API always send total_time when committing to the LMS.

HTTP/Network Settings

SettingDefaultTypeDescription
lmsCommitUrlfalsestring | falseThe URL endpoint of the LMS where data should be sent upon commit. If no value is provided, modules will run as usual, but all method calls will be logged to the console.
throttleCommitsfalsebooleanWhen enabled, throttles commit requests by delaying them 500ms, allowing rapid changes to be batched into a single commit. Only works when useAsynchronousCommits=true. Cannot be used with synchronous commits.
useAsynchronousCommitsfalsebooleanUse async HTTP requests (legacy behavior). Not SCORM compliant. May cause data loss. Only use for specific legacy use cases.
commitRequestDataType'application/json;charset=UTF-8'stringThis setting is provided in case your LMS expects a different content type or character set.
fetchMode'cors'stringThe fetch mode to use when sending requests to the LMS. Options: 'cors', 'no-cors', 'same-origin', 'navigate'.
asyncModeBeaconBehavior'never'stringIn asynchronous mode, controls when to use Beacon instead of fetch: 'always', 'on-terminate', or 'never'. Synchronous mode always uses Beacon for termination commits.
xhrWithCredentialsfalsebooleanSets the withCredentials flag on the request to the LMS.
xhrHeaders{}objectThis allows setting of additional headers on the request to the LMS where the key should be the header name and the value is the value of the header you want to send.
httpServicenullIHttpService | nullAdvanced: Inject custom HTTP service implementation. Overrides useAsynchronousCommits.
terminateCommitParamundefinedstringWhen set, the terminate-time commit's URL gets ?<name>=true appended (or &=true if lmsCommitUrl already has a query string), letting the server distinguish the final commit from heartbeat commits. Applies to normal terminate commits, sendBeacon terminate commits, and offline replays of a terminate commit.
terminateCommitPayloadFieldundefinedstringWhen set, the terminate-time commit's payload gets <name>: true added (object formats) or <name>=true appended (params format). Independent of terminateCommitParam; either or both may be used.
terminationCommitContentType'text/plain;charset=UTF-8'stringContent type for Beacon termination commits. Use asynchronous fetch with asyncModeBeaconBehavior: 'never' for cross-origin JSON or custom authorization headers.
includeCommitSequencefalsebooleanWhen enabled, every commit payload includes a commitSequence field with a monotonically increasing number assigned when the commit is captured. Offline-replayed commits keep their original sequence, so servers can reject stale, out-of-order commits.

Data Format Settings

SettingDefaultTypeDescription
dataCommitFormat'json'stringFormat for sending data to the LMS. Options: 'json', 'flattened', 'params'. See Data Formats for details.
requestHandlerfunctionfunctionA function to transform the commit object before sending it to lmsCommitUrl. Receives an optional second CommitMetadata argument ({ isTerminateCommit, trigger, sequence }); existing one-argument handlers keep working unchanged. By default it's the identity function (no transformation).
responseHandlerfunctionasync functionCustom response handler for async fetch Response objects. Called when useAsynchronousCommits=true. The APIs expect the result from the LMS to be in the format: { "result": true, "errorCode": 0 } (errorCode is optional).
xhrResponseHandlerfunctionfunctionCustom response handler for synchronous XMLHttpRequest responses. Called when useAsynchronousCommits=false.

Logging Settings

SettingDefaultTypeDescription
logLevel4number | stringBy default, the APIs only log error messages. Options: 1 or 'DEBUG', 2 or 'INFO', 3 or 'WARN', 4 or 'ERROR', 5 or 'NONE'.
onLogMessagefunctionfunctionA function to be called whenever a message is logged. Defaults to console.{error,warn,info,debug,log}.

SCORM 1.2 Specific Settings

SettingDefaultTypeDescription
mastery_overridefalsebooleanUsed to override a module's cmi.core.lesson_status so that a pass/fail is determined based on a mastery score and the user's raw score, rather than using whatever status is provided by the module. An example of this would be if a module is published using a Complete/Incomplete final status, but the LMS always wants to receive a Passed/Failed for quizzes, then we can use this setting to override the given final status.
autoCompleteLessonStatusfalsebooleanControls termination behaviour for SCOs that never set cmi.core.lesson_status. When false (default), the API leaves the status as incomplete; when true, it restores the legacy behaviour of auto-upgrading to completed.

SCORM 2004 Specific Settings

SettingDefaultTypeDescription
autoProgressfalsebooleanIn case Sequencing is being used, you can tell the API to automatically throw the SequenceNext event.
scoItemIds[]string[]A list of valid SCO IDs to be used for choice/jump sequence validation. If a sequencing configuration is provided with an activity tree, this list will be automatically populated with all activity IDs from the tree.
scoItemIdValidatorfalsefalse | functionA function to be called during choice/jump sequence checks to determine if a SCO ID is valid. Could be used to call an API to check validity.
globalObjectiveIds[]string[]Host-defined objective IDs exposed directly as global CMI rows. Manifest <imsss:mapInfo> targets are discovered from the activity tree and should not be duplicated here.
sequencingnullSequencingSettings | nullConfiguration for SCORM 2004 sequencing, including activity tree, sequencing rules, sequencing controls, and rollup rules. This data must be extracted by the LMS from the package's imsmanifest.xml file. See the Sequencing Configuration documentation for details on the required format and LMS integration requirements.
sequencingStatePersistenceundefinedSequencingStatePersistenceConfigCallbacks and options for activity tracking state. Set autoLoadOnInitialize: false when the LMS explicitly awaits a preload before initial delivery.

Offline Support Settings

SettingDefaultTypeDescription
enableOfflineSupportfalsebooleanEnable offline support for storing and syncing data when offline.
courseIdundefinedstringUnique identifier for the course (required when offline support is enabled).
syncOnInitializetruebooleanAttempt to sync data when initializing API.
syncOnTerminatetruebooleanAttempt to sync data when terminating API.
maxSyncAttempts5numberMaximum number of attempts to sync an item.

Setting Examples

TypeScript Usage

import { Scorm2004API, Settings } from 'scorm-again';

// Create an instance with typed settings
const settings: Settings = {
autocommit: true,
logLevel: 'DEBUG',
lmsCommitUrl: 'https://your-lms.com/api/commit'
};

const api = new Scorm2004API(settings);

Minimal Configuration

// Run without LMS - all calls logged to console
const api = new Scorm12API({
logLevel: 'DEBUG'
});

Production Configuration

const api = new Scorm2004API({
lmsCommitUrl: 'https://your-lms.com/api/scorm/commit',
autocommit: true,
autocommitSeconds: 30,
sendFullCommit: false,
logLevel: 'ERROR',
xhrHeaders: {
'Authorization': 'Bearer YOUR_TOKEN'
}
});

Offline Support Configuration

const api = new Scorm12API({
lmsCommitUrl: 'https://your-lms.com/api/scorm/commit',
autocommit: true,
enableOfflineSupport: true,
courseId: 'COURSE-12345',
syncOnInitialize: true,
syncOnTerminate: true,
maxSyncAttempts: 5
});

SCORM 2004 with Sequencing

const api = new Scorm2004API({
lmsCommitUrl: 'https://your-lms.com/api/scorm/commit',
autoProgress: true,
selfReportSessionTime: true,
renderCommonCommitFields: true,
sequencing: {
autoRollupOnCMIChange: false,
activityTree: {
id: 'root',
title: 'Course',
children: [
{
id: 'module1',
title: 'Module 1',
children: [
{ id: 'lesson1', title: 'Lesson 1' },
{ id: 'lesson2', title: 'Lesson 2' }
]
}
]
}
}
});