From 89ee56b65c72c88c5341c1333acc9aac90382bd1 Mon Sep 17 00:00:00 2001 From: moloko Date: Tue, 2 May 2017 13:41:02 +0100 Subject: [PATCH 1/5] amend adapt-stateful-session.js so that it replaces the hard-coded 'learner info' data with actual data from the LMS update offline_API_wrapper.js so that it has the student_name in "Lastname, Firstname" (as the SCORM spec requires) and also so that it has student_id/learner_id --- js/adapt-stateful-session.js | 5 +++++ required/offline_API_wrapper.js | 6 ++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/js/adapt-stateful-session.js b/js/adapt-stateful-session.js index 6db33422..3ae5467c 100644 --- a/js/adapt-stateful-session.js +++ b/js/adapt-stateful-session.js @@ -15,7 +15,12 @@ define([ //Session Begin initialize: function(callback) { this._onWindowUnload = _.bind(this.onWindowUnload, this); + this.getConfig(); + + // replace the hard-coded _learnerInfo data with the actual data from the LMS + _.extend(Adapt.course.get('_globals')._learnerInfo, Adapt.offlineStorage.get("learnerinfo")); + // restore state asynchronously to prevent IE8 freezes this.restoreSessionState(_.bind(function() { // still need to defer call because AdaptModel.check*Status functions are asynchronous diff --git a/required/offline_API_wrapper.js b/required/offline_API_wrapper.js index dc359ac1..20236f5b 100644 --- a/required/offline_API_wrapper.js +++ b/required/offline_API_wrapper.js @@ -20,7 +20,8 @@ var API = { if (!API.LMSFetch()) { this.data["cmi.core.lesson_status"] = "not attempted"; this.data["cmi.suspend_data"] = ""; - this.data["cmi.core.student_name"] = "Test Student"; + this.data["cmi.core.student_name"] = "Student, Sam"; + this.data["cmi.core.student_id"] = "sam.student@example.org"; this.data["cmi.interactions._count"] = 0; API.LMSStore(true); } @@ -97,7 +98,8 @@ var API_1484_11 = { if (!API_1484_11.LMSFetch()) { this.data["cmi.completion_status"] = "not attempted"; this.data["cmi.suspend_data"] = ""; - this.data["cmi.learner_name"] = "Test Student"; + this.data["cmi.learner_name"] = "Student, Sam"; + this.data["cmi.learner_id"] = "sam.student@example.org"; this.data["cmi.interactions._count"] = 0; API_1484_11.LMSStore(true); } From c2376e8166b4da7d38068d34864e1ea46e2be619 Mon Sep 17 00:00:00 2001 From: moloko Date: Tue, 2 May 2017 13:41:17 +0100 Subject: [PATCH 2/5] version bump --- README.md | 4 ++-- bower.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 17ba713c..5348931e 100644 --- a/README.md +++ b/README.md @@ -113,8 +113,8 @@ When **Spoor** is installed, *scorm_test_harness.html* can be used instead of *i Currently (officially) only supports SCORM 1.2 ---------------------------- -**Version number:** 2.0.15 adapt learning logo -**Framework versions:** 2.0.15 +**Version number:** 2.0.16 adapt learning logo +**Framework versions:** 2.0.16 **Author / maintainer:** Adapt Core Team with [contributors](https://github.com/adaptlearning/adapt-contrib-spoor/graphs/contributors) **Accessibility support:** n/a **RTL support:** n/a diff --git a/bower.json b/bower.json index f1a9081a..932014ba 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "adapt-contrib-spoor", - "version": "2.0.15", + "version": "2.0.16", "framework": "^2.0.16", "homepage": "https://github.com/adaptlearning/adapt-contrib-spoor", "issues": "https://github.com/adaptlearning/adapt_framework/issues/new?title=contrib-spoor%3A%20please%20enter%20a%20brief%20summary%20of%20the%20issue%20here&body=please%20provide%20a%20full%20description%20of%20the%20problem,%20including%20steps%20on%20how%20to%20replicate,%20what%20browser(s)/device(s)%20the%20problem%20occurs%20on%20and,%20where%20helpful,%20the%20contents%20of%20the%20SCORM%20debug%20window.", From dcf7d9ad295d1c65ed088ea638eeb44f71bdbc12 Mon Sep 17 00:00:00 2001 From: Matt Leathes Date: Tue, 2 May 2017 16:57:39 +0100 Subject: [PATCH 3/5] change default Student surname from 'Student' to 'Surname' following code review --- required/offline_API_wrapper.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/required/offline_API_wrapper.js b/required/offline_API_wrapper.js index 20236f5b..521260e3 100644 --- a/required/offline_API_wrapper.js +++ b/required/offline_API_wrapper.js @@ -20,7 +20,7 @@ var API = { if (!API.LMSFetch()) { this.data["cmi.core.lesson_status"] = "not attempted"; this.data["cmi.suspend_data"] = ""; - this.data["cmi.core.student_name"] = "Student, Sam"; + this.data["cmi.core.student_name"] = "Surname, Sam"; this.data["cmi.core.student_id"] = "sam.student@example.org"; this.data["cmi.interactions._count"] = 0; API.LMSStore(true); @@ -98,7 +98,7 @@ var API_1484_11 = { if (!API_1484_11.LMSFetch()) { this.data["cmi.completion_status"] = "not attempted"; this.data["cmi.suspend_data"] = ""; - this.data["cmi.learner_name"] = "Student, Sam"; + this.data["cmi.learner_name"] = "Surname, Sam"; this.data["cmi.learner_id"] = "sam.student@example.org"; this.data["cmi.interactions._count"] = 0; API_1484_11.LMSStore(true); From d284ebcf7ffa26de49a71f8dd28d023443ce40cc Mon Sep 17 00:00:00 2001 From: Matt Leathes Date: Tue, 2 May 2017 16:58:11 +0100 Subject: [PATCH 4/5] update student_id to match --- required/offline_API_wrapper.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/required/offline_API_wrapper.js b/required/offline_API_wrapper.js index 521260e3..5b6f51a3 100644 --- a/required/offline_API_wrapper.js +++ b/required/offline_API_wrapper.js @@ -21,7 +21,7 @@ var API = { this.data["cmi.core.lesson_status"] = "not attempted"; this.data["cmi.suspend_data"] = ""; this.data["cmi.core.student_name"] = "Surname, Sam"; - this.data["cmi.core.student_id"] = "sam.student@example.org"; + this.data["cmi.core.student_id"] = "sam.surname@example.org"; this.data["cmi.interactions._count"] = 0; API.LMSStore(true); } @@ -99,7 +99,7 @@ var API_1484_11 = { this.data["cmi.completion_status"] = "not attempted"; this.data["cmi.suspend_data"] = ""; this.data["cmi.learner_name"] = "Surname, Sam"; - this.data["cmi.learner_id"] = "sam.student@example.org"; + this.data["cmi.learner_id"] = "sam.surname@example.org"; this.data["cmi.interactions._count"] = 0; API_1484_11.LMSStore(true); } From c92f90d96308b5c9db688948eb07e0713ee8dc6a Mon Sep 17 00:00:00 2001 From: moloko Date: Thu, 25 May 2017 18:13:06 +0100 Subject: [PATCH 5/5] defensive programming to account for situations when the _learnerInfo object might not be present in _globals --- js/adapt-stateful-session.js | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/js/adapt-stateful-session.js b/js/adapt-stateful-session.js index 3ae5467c..e2495256 100644 --- a/js/adapt-stateful-session.js +++ b/js/adapt-stateful-session.js @@ -18,8 +18,7 @@ define([ this.getConfig(); - // replace the hard-coded _learnerInfo data with the actual data from the LMS - _.extend(Adapt.course.get('_globals')._learnerInfo, Adapt.offlineStorage.get("learnerinfo")); + this.getLearnerInfo(); // restore state asynchronously to prevent IE8 freezes this.restoreSessionState(_.bind(function() { @@ -40,6 +39,18 @@ define([ } }, + /** + * replace the hard-coded _learnerInfo data in _globals with the actual data from the LMS + * if the course has been published from the AT, the _learnerInfo object won't exist so we'll need to create it + */ + getLearnerInfo: function() { + var globals = Adapt.course.get('_globals'); + if (!globals._learnerInfo) { + globals._learnerInfo = {}; + } + _.extend(globals._learnerInfo, Adapt.offlineStorage.get("learnerinfo")); + }, + saveSessionState: function() { var sessionPairs = this.getSessionState(); Adapt.offlineStorage.set(sessionPairs);