-
Notifications
You must be signed in to change notification settings - Fork 249
SCORM, closing windows, LMSFinish and synchronous XHR dismissals
Upon closing a SCORM course, the LMS doesn't do [something expected] when using a modern browser.
The LMS makes a series of standardised, named functions, an API called SCORM, available in JavaScript with which the content JavaScript can interact. The content does not directly communicate with the LMS except through this SCORM API. The back end of the SCORM API, implemented by the LMS, communicates with the LMS on the course's behalf using http requests.
When the course is closed, the course calls the LMS's SCORM function LMSFinish
. In this case, the LMSFinish
function uses a synchronous, or blocking, http request. Modern browsers prevent blocking https requests in order that whilst a request is being performed, the browser window does not hang. Instead, asynchronous or non-blocking http requests are performed so that the browser window stays performant whilst in use.
- [the user clicks the window close button]
- Window triggers beforeunload event
a) LMSFinish starts a blocking request, causing the browser to hang
b) LMSFinish finishes a blocking request - Window triggers unload event
- Browser closes
- [the user clicks the window close button]
- Window triggers beforeunload event
a) LMSFinish starts a non-blocking request (which never finishes) - Window triggers unload event
- Browser closes
Call LMSFinish and wait for it to complete before closing the window
We could change the way Adapt works to do an asynchronous (non-blocking) http request first, before any call to window.close
but... window.close
is only one way of closing the window. We aren't able trap or prevent or stop or delay other methods of closing a window in order to call a non-blocking LMSFinish
first.
For example, when a user clicks the window's close button, the JavaScript function window.close
is never called, but the window triggers its unload events - which can't be stopped - Adapt calls LMSFinish
from a window unload event handler, and then the browser closes. LMSFinish
in modern browsers (remember that LMSFinish
is implemented by the LMS) is now not allowed to make a blocking http request, so when it does (in the case of this bug), the browser closes before the course's finishing http request is complete.
You could add an additional close button to your course, which calls LMSFinish
when clicked (see adapt-close). This won't stop users clicking the window close button and losing their stuff, as this isn't an LMS fix for the LMSFinish
function, but it may buy you time until you can fix your LMS.
Fix the LMS's LMSFinish
function.
beforeunload, unload, sendBeacon, fun reading, more fun reading, and more, fetch#stayin-alive
- Framework in Five Minutes
- Setting up Your Development Environment
- Manual Installation of the Adapt Framework
- Adapt Command Line Interface
- Common Issues
- Reporting Bugs
- Requesting Features
- Creating Your First Course
- Styling Your Course
- Configuring Your Project with config.json
- Content starts with course.json
- Course Localisation
- Compiling, testing and deploying your Adapt course
- Core Plugins in the Adapt Learning Framework
- Converting a Course from Framework Version 1 to Version 2
- Contributing to the Adapt Project
- Git Flow
- Adapt API
- Adapt Command Line Interface
- Core Events
- Core Model Attributes
- Core Modules
- Web Security Audit
- Peer Code Review
- Plugins
- Developing Plugins
- Developer's Guide: Components
- Developer's Guide: Theme
- Making a theme editable
- Developer's Guide: Menu
- Registering a Plugin
- Semantic Version Numbers
- Core Model Attributes
- Adapt Command Line Interface
- Accessibility v3
- Adapt Framework Right to Left (RTL) Support