diff --git a/README.md b/README.md index 348cda19..27031a83 100644 --- a/README.md +++ b/README.md @@ -128,6 +128,9 @@ Determines the 'exit state' (`cmi.core.exit` in SCORM 1.2, `cmi.exit` in SCORM 2 ##### \_exitStateIfComplete (string): Determines the 'exit state' (`cmi.core.exit` in SCORM 1.2, `cmi.exit` in SCORM 2004) to set when the course has been completed. The default behaviour will cause the exit state to be set to an empty string for SCORM 1.2 courses, or `"normal"` for SCORM 2004 courses. The default behaviour should be left in place unless you are confident you know what you are doing! Note: if you are using SCORM 2004, you can set this to `"suspend"` to prevent the LMS from clearing all progress tracking when a previously-completed course is re-launched by the learner. +#### \_showCookieLmsResetButton (boolean): +Determines whether a reset button will be available to relaunch the course and optionally clear tracking data (scorm_test_harness.html only). The default is `false`. +
Back to Top
## Notes diff --git a/example.json b/example.json index 304c1573..ab9491b2 100644 --- a/example.json +++ b/example.json @@ -27,7 +27,8 @@ "_commitOnVisibilityChangeHidden": true, "_exitStateIfIncomplete": "auto", "_exitStateIfComplete": "auto" - } + }, + "_showCookieLmsResetButton": false } // to be added to course/en/course.json (note: you only need to add the ones you want to change/translate) diff --git a/properties.schema b/properties.schema index 60fc3363..97d80c20 100644 --- a/properties.schema +++ b/properties.schema @@ -238,6 +238,15 @@ "help": "What exit status to use if the course is complete." } } + }, + "_showCookieLmsResetButton": { + "type": "boolean", + "required": false, + "default": false, + "title": "Show reset button (scorm_test_harness.html only)", + "inputType": "Checkbox", + "validators": [], + "help": "If enabled, a reset button will be available to relaunch the course and optionally clear tracking data (scorm_test_harness.html only)." } } } diff --git a/required/offline_API_wrapper.js b/required/offline_API_wrapper.js index b8e624d3..0572b240 100644 --- a/required/offline_API_wrapper.js +++ b/required/offline_API_wrapper.js @@ -43,12 +43,14 @@ var GenericAPI = { createResetButton: function() { $('body').append($('')); - var $button = $(''); + var $button = $(''); $('body').append($button); - $button.on('click', function() { - this.reset(); - alert('SCORM tracking cookie has been deleted!'); - window.location.reload(); + $button.on('click', function(e) { + if (!e.shiftKey) { + this.reset(); + alert('SCORM tracking cookie has been deleted! Tip: shift-click reset to preserve cookie.'); + } + window.location = window.location.pathname; }.bind(this)); }, @@ -72,7 +74,11 @@ var GenericAPI = { window.API = { LMSInitialize: function() { - // if (window.ISCOOKIELMS !== false) this.createResetButton(); + const Adapt = require('core/js/adapt'); + + if (window.ISCOOKIELMS !== false && Adapt?.config?.get('_spoor')?._showCookieLmsResetButton) { + this.createResetButton(); + } if (!this.fetch()) { this.data['cmi.core.lesson_status'] = 'not attempted'; this.data['cmi.suspend_data'] = ''; @@ -122,7 +128,11 @@ window.API = { window.API_1484_11 = { Initialize: function() { - // if (window.ISCOOKIELMS !== false) this.createResetButton(); + const Adapt = require('core/js/adapt'); + + if (window.ISCOOKIELMS !== false && Adapt?.config?.get('_spoor')?._showCookieLmsResetButton) { + this.createResetButton(); + } if (!this.fetch()) { this.data['cmi.completion_status'] = 'not attempted'; this.data['cmi.suspend_data'] = ''; diff --git a/schema/config.schema.json b/schema/config.schema.json index 0310ae90..96b782a3 100644 --- a/schema/config.schema.json +++ b/schema/config.schema.json @@ -169,6 +169,12 @@ "_backboneForms": "Select" } } + }, + "_showCookieLmsResetButton": { + "type": "boolean", + "title": "Show reset button (scorm_test_harness.html only)", + "description": "If enabled, a reset button will be available to relaunch the course and optionally clear tracking data (scorm_test_harness.html only).", + "default": false } } }