From 94494a69c9fabc4f0f5935c151e36f5c682af37e Mon Sep 17 00:00:00 2001 From: Springcode Date: Fri, 5 Jul 2019 10:49:05 +0100 Subject: [PATCH 1/2] Added getCourseMetaData which returns information contained in the iManifest.xml file. --- src/scormcloud.js | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/scormcloud.js b/src/scormcloud.js index c992d52..b23f2f6 100644 --- a/src/scormcloud.js +++ b/src/scormcloud.js @@ -44,6 +44,23 @@ SCORMCloud.prototype.authPing = function (callback) { // Course Service // +SCORMCloud.prototype.getCourseMetaData = function (courseid, callback) { + + var url = new URL('api?method=rustici.course.getMetadata', this.serviceUrl); + + // The id used to identify this course. + if (courseid) url.searchParams.set('courseid', courseid); + + this._request(url, function (error, json) { + + if (error) return callback(error, json); + + let data = json.rsp.package; + + return callback(error, data); + }); +} + SCORMCloud.prototype.getCoursePreviewUrl = function (courseid, versionid, redirecturl) { var url = new URL('api?method=rustici.course.preview', this.serviceUrl); From 2b2574468518d48b5c841a8ace172929bbc46374 Mon Sep 17 00:00:00 2001 From: Springcode Date: Fri, 5 Jul 2019 11:13:22 +0100 Subject: [PATCH 2/2] Fixed bug in setCourseAttributes see comments. --- src/scormcloud.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/scormcloud.js b/src/scormcloud.js index b23f2f6..22810c2 100644 --- a/src/scormcloud.js +++ b/src/scormcloud.js @@ -161,6 +161,12 @@ SCORMCloud.prototype.setCourseAttributes = function (courseid, attributes, callb if (error) return callback(error, json); + // From SCORM Cloud documentation: + // (If an attribute is set to it’s existing value, it will not appear in the returned list. Only changed values will appear.) + + // check for any returned attributes, if there are no changes attributes will be an empty string + if (json.rsp.attributes === "") return callback(error, {}); + let data = {}; let attributes = json.rsp.attributes.attribute;