overhangio / openedx-scorm-xblock

SCORM XBlock for Open edX
GNU Affero General Public License v3.0
37 stars 46 forks source link

fix: Scorm iframe and API loading race condition #78

Open talhaaslam01 opened 1 month ago

talhaaslam01 commented 1 month ago

Description

Load the Scorm iframe's 'src' attribute after initializing the Scorm API instead of directly in the 'scormxblock.html' file because it can lead to a race condition where the Scorm content may load faster and try to access the Scorm API before it is loaded, thus giving an error.

talhaaslam01 commented 1 month ago

@ziafazal When the Scorm course is loaded in an iframe, it searches for the Scorm API in the global window variable which is initialized in initScorm function. If the Scorm xblock's page takes longer to load than the Scorm course in an iframe then, the Scorm course will look for the Scorm API in the window variable which is not available in the window variable at the moment and thus, resulting in an error, "Unable to acquire LMS API, content may not play properly and results may not be recorded".