From e41cd40d8bdb1282b98ef60cfe8c1caed20ce107 Mon Sep 17 00:00:00 2001 From: Jonathan Putney <42720634+jcputney@users.noreply.github.com> Date: Tue, 26 May 2020 08:41:04 -0400 Subject: [PATCH] Documenting new features Adding responseHandler setting and wildcard listener examples --- README.md | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/README.md b/README.md index 8a74c20..c8c5ce2 100644 --- a/README.md +++ b/README.md @@ -52,6 +52,7 @@ The APIs include several settings to customize the functionality of each API: | `autoProgress` | false | true/false | In case Sequencing is being used, you can tell the API to automatically throw the `SequenceNext` event.| | `logLevel` | 4 | int

1 => DEBUG
2 => INFO
3 => WARN
4 => ERROR
5 => NONE | By default, the APIs only log error messages. | | `mastery_override` | false | true/false | (SCORM 1.2) Used 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. | +| `responseHandler` | function | | A function to properly tranform the response from the LMS to the correct format. The APIs expect the result from the LMS to be in the following format (errorCode is optional):
{
"result": true,
"errorCode": 0
} | ## Initial Values @@ -166,6 +167,14 @@ window.API.on("LMSSetValue.cmi.core.student_id", function(CMIElement, value) { }); ``` +Finally, you can listen for events using a wildcard: + +```javascript +window.API.on("LMSSetValue.cmi.*", function(CMIElement, value) { + [...] +}); +``` + ### SCORM 2004 Listeners For convenience, hooks are available for all the SCORM API Signature functions: @@ -201,6 +210,14 @@ window.API_1484_11.on("SetValue.cmi.learner_id ", function(CMIElement, value) { }); ``` +Finally, you can listen for events using a wildcard: + +```javascript +window.API_1484_11.on("SetValue.cmi.* ", function(CMIElement, value) { + [...] +}); +``` + ### Total Time Calculation The APIs provide a convenience method `getCurrentTotalTime()` that can be used for calculating the current `total_time` value, based on the current `session_time` and the `total_time` supplied when the module was launched. This works for both ISO 8601 duration time formats in SCORM 2004 as well as the HH:MM:SS format in SCORM 1.2 and AICC, and outputs the correct format based on the version used.