Skip to content

Commit

Permalink
Merge branch 'master' into json-schema
Browse files Browse the repository at this point in the history
  • Loading branch information
tomgreenfield committed Jan 8, 2021
2 parents c895a9a + bd1b425 commit bb6d1c7
Show file tree
Hide file tree
Showing 8 changed files with 370 additions and 309 deletions.
99 changes: 66 additions & 33 deletions README.md

Large diffs are not rendered by default.

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": "3.6.0-alpha.1",
"version": "3.7.0",
"framework": ">=5.5",
"homepage": "https://github.com/adaptlearning/adapt-contrib-spoor",
"issues": "https://github.com/adaptlearning/adapt_framework/issues/new",
Expand Down
1 change: 1 addition & 0 deletions js/adapt-offlineStorage-scorm.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ define([

save() {
this.statefulSession.saveSessionState();
this.scorm.commit();
}

serialize(...args) {
Expand Down
4 changes: 2 additions & 2 deletions js/adapt-stateful-session.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ define([
const config = Adapt.spoor.config;
if (!config) return;
const tracking = config._tracking;
this._shouldStoreResponses = (tracking && tracking._shouldStoreResponses);
this._shouldStoreAttempts = (tracking && tracking._shouldStoreAttempts);
this._shouldStoreResponses = (tracking && tracking._shouldStoreResponses) || false;
this._shouldStoreAttempts = (tracking && tracking._shouldStoreAttempts) || false;
// Default should be to record interactions, so only avoid doing that if
// _shouldRecordInteractions is set to false
if (tracking && tracking._shouldRecordInteractions === false) {
Expand Down
3 changes: 2 additions & 1 deletion js/scorm/wrapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,7 @@ define([
if (this.scorm.save()) {
this.commitRetries = 0;
this.lastCommitSuccessTime = new Date();
Adapt.trigger('spoor:commit', this);
return;
}

Expand Down Expand Up @@ -461,7 +462,7 @@ define([

this.scorm.get(property);

return (this.scorm.debug.getCode() === 401);
return (this.scorm.debug.getCode() !== 401); // 401 is the 'not implemented' error code
}

initTimedCommit() {
Expand Down
163 changes: 163 additions & 0 deletions libraries/js-cookie.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,163 @@
/*!
* JavaScript Cookie v2.2.1
* https://github.com/js-cookie/js-cookie
*
* Copyright 2006, 2015 Klaus Hartl & Fagner Brack
* Released under the MIT license
*/
;(function (factory) {
var registeredInModuleLoader;
if (typeof define === 'function' && define.amd) {
define(factory);
registeredInModuleLoader = true;
}
if (typeof exports === 'object') {
module.exports = factory();
registeredInModuleLoader = true;
}
if (!registeredInModuleLoader) {
var OldCookies = window.Cookies;
var api = window.Cookies = factory();
api.noConflict = function () {
window.Cookies = OldCookies;
return api;
};
}
}(function () {
function extend () {
var i = 0;
var result = {};
for (; i < arguments.length; i++) {
var attributes = arguments[ i ];
for (var key in attributes) {
result[key] = attributes[key];
}
}
return result;
}

function decode (s) {
return s.replace(/(%[0-9A-Z]{2})+/g, decodeURIComponent);
}

function init (converter) {
function api() {}

function set (key, value, attributes) {
if (typeof document === 'undefined') {
return;
}

attributes = extend({
path: '/'
}, api.defaults, attributes);

if (typeof attributes.expires === 'number') {
attributes.expires = new Date(new Date() * 1 + attributes.expires * 864e+5);
}

// We're using "expires" because "max-age" is not supported by IE
attributes.expires = attributes.expires ? attributes.expires.toUTCString() : '';

try {
var result = JSON.stringify(value);
if (/^[\{\[]/.test(result)) {
value = result;
}
} catch (e) {}

value = converter.write ?
converter.write(value, key) :
encodeURIComponent(String(value))
.replace(/%(23|24|26|2B|3A|3C|3E|3D|2F|3F|40|5B|5D|5E|60|7B|7D|7C)/g, decodeURIComponent);

key = encodeURIComponent(String(key))
.replace(/%(23|24|26|2B|5E|60|7C)/g, decodeURIComponent)
.replace(/[\(\)]/g, escape);

var stringifiedAttributes = '';
for (var attributeName in attributes) {
if (!attributes[attributeName]) {
continue;
}
stringifiedAttributes += '; ' + attributeName;
if (attributes[attributeName] === true) {
continue;
}

// Considers RFC 6265 section 5.2:
// ...
// 3. If the remaining unparsed-attributes contains a %x3B (";")
// character:
// Consume the characters of the unparsed-attributes up to,
// not including, the first %x3B (";") character.
// ...
stringifiedAttributes += '=' + attributes[attributeName].split(';')[0];
}

return (document.cookie = key + '=' + value + stringifiedAttributes);
}

function get (key, json) {
if (typeof document === 'undefined') {
return;
}

var jar = {};
// To prevent the for loop in the first place assign an empty array
// in case there are no cookies at all.
var cookies = document.cookie ? document.cookie.split('; ') : [];
var i = 0;

for (; i < cookies.length; i++) {
var parts = cookies[i].split('=');
var cookie = parts.slice(1).join('=');

if (!json && cookie.charAt(0) === '"') {
cookie = cookie.slice(1, -1);
}

try {
var name = decode(parts[0]);
cookie = (converter.read || converter)(cookie, name) ||
decode(cookie);

if (json) {
try {
cookie = JSON.parse(cookie);
} catch (e) {}
}

jar[name] = cookie;

if (key === name) {
break;
}
} catch (e) {}
}

return key ? jar[key] : jar;
}

api.set = set;
api.get = function (key) {
return get(key, false /* read as raw */);
};
api.getJSON = function (key) {
return get(key, true /* read as json */);
};
api.remove = function (key, attributes) {
set(key, '', extend(attributes, {
expires: -1
}));
};

api.defaults = {};

api.withConverter = init;

return api;
}

return init(function () {});
}));
Loading

0 comments on commit bb6d1c7

Please sign in to comment.