Skip to content

Commit

Permalink
have spoor overwrite the hard-coded 'learner info' data with real data (
Browse files Browse the repository at this point in the history
#155)

* 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

* version bump

* change default Student surname

from 'Student' to 'Surname' following code review

* update student_id to match

* defensive programming to account for situations when the _learnerInfo object might not be present in _globals
  • Loading branch information
moloko authored and tomgreenfield committed May 26, 2017
1 parent 9ea0093 commit 4461c53
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 5 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 <a href="https://community.adaptlearning.org/" target="_blank"><img src="https://github.com/adaptlearning/documentation/blob/master/04_wiki_assets/plug-ins/images/adapt-logo-mrgn-lft.jpg" alt="adapt learning logo" align="right"></a>
**Framework versions:** 2.0.15
**Version number:** 2.0.16 <a href="https://community.adaptlearning.org/" target="_blank"><img src="https://github.com/adaptlearning/documentation/blob/master/04_wiki_assets/plug-ins/images/adapt-logo-mrgn-lft.jpg" alt="adapt learning logo" align="right"></a>
**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
Expand Down
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -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.",
Expand Down
16 changes: 16 additions & 0 deletions js/adapt-stateful-session.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,11 @@ define([
//Session Begin
initialize: function(callback) {
this._onWindowUnload = _.bind(this.onWindowUnload, this);

this.getConfig();

this.getLearnerInfo();

// restore state asynchronously to prevent IE8 freezes
this.restoreSessionState(_.bind(function() {
// still need to defer call because AdaptModel.check*Status functions are asynchronous
Expand All @@ -35,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);
Expand Down
6 changes: 4 additions & 2 deletions required/offline_API_wrapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -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"] = "Surname, Sam";
this.data["cmi.core.student_id"] = "[email protected]";
this.data["cmi.interactions._count"] = 0;
API.LMSStore(true);
}
Expand Down Expand Up @@ -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"] = "Surname, Sam";
this.data["cmi.learner_id"] = "[email protected]";
this.data["cmi.interactions._count"] = 0;
API_1484_11.LMSStore(true);
}
Expand Down

0 comments on commit 4461c53

Please sign in to comment.