From 11f8666b7396f43efadb0c921c508d4d6340a1d7 Mon Sep 17 00:00:00 2001 From: tom creighton Date: Mon, 2 Oct 2017 15:55:41 -0400 Subject: [PATCH] adding profile act type to statements --- SCORMToXAPIFunctions.js | 97 +++++++++++++++++++++-------------------- 1 file changed, 50 insertions(+), 47 deletions(-) diff --git a/SCORMToXAPIFunctions.js b/SCORMToXAPIFunctions.js index 9582ce3..e7d0f20 100644 --- a/SCORMToXAPIFunctions.js +++ b/SCORMToXAPIFunctions.js @@ -101,20 +101,23 @@ xapi = function () { definition: { type: "http://adlnet.gov/expapi/activities/attempt" } - }, + }, { id: config.courseId, objectType: "Activity", definition: { type: "http://adlnet.gov/expapi/activities/course" } - } - ], + } + ], category: [ { - id: "https://w3id.org/xapi/scorm" - } - ] + id: "https://w3id.org/xapi/scorm", + definition: { + type: "http://adlnet.gov/expapi/activities/profile" + } + } + ] } } }; @@ -160,8 +163,8 @@ xapi = function () { definition: { type: "http://adlnet.gov/expapi/activities/lesson" } - } - ], + } + ], grouping: [ { id: "", @@ -169,20 +172,23 @@ xapi = function () { definition: { type: "http://adlnet.gov/expapi/activities/attempt" } - }, + }, { id: config.courseId, objectType: "Activity", definition: { type: "http://adlnet.gov/expapi/activities/course" } - } - ], + } + ], category: [ { - id: "https://w3id.org/xapi/scorm" - } - ] + id: "https://w3id.org/xapi/scorm", + definition: { + type: "http://adlnet.gov/expapi/activities/profile" + } + } + ] } }, result: { @@ -314,10 +320,7 @@ xapi = function () { // send a suspended statement to replace the (voided) terminated statement suspendAttempt(terminateStmt.timestamp); - - } - } @@ -643,8 +646,6 @@ xapi = function () { if (cmi_total_time != "") state.total_time = cmi_total_time; - - // see if the profile is already set var as = ADL.XAPIWrapper.getState(attemptIri, agent, constants.attemptStateIri); @@ -665,35 +666,37 @@ xapi = function () { ** *******************************************************************************/ var saveDataValue = function (name, value) { - var isInteraction = name.indexOf("cmi.interactions") > -1; + var isInteraction = name.indexOf("cmi.interactions") > -1; - if (isInteraction) { - setInteraction(name, value); - } else { - // Handle only non-array scorm data model elements - switch (name) { - case scormVersionConfig.scoreScaledElement: - setScore(value); - break; - case scormVersionConfig.completionElement: - setComplete(value); - break; - case scormVersionConfig.successElement: - setSuccess(value); - break; - case scormVersionConfig.exitElement: - exitSetToSuspend = (value == "suspend"); - break; - default: - break; - } + if (isInteraction) { + setInteraction(name, value); + } else { + // Handle only non-array scorm data model elements + switch (name) { + case scormVersionConfig.scoreScaledElement: + setScore(value); + break; + case scormVersionConfig.completionElement: + setComplete(value); + break; + case scormVersionConfig.successElement: + setSuccess(value); + break; + case scormVersionConfig.exitElement: + exitSetToSuspend = (value == "suspend"); + break; + default: + break; } } - /******************************************************************************* - ** - ** This function/vars is used to handle the interaction type - ** - *******************************************************************************/ + } + + + /******************************************************************************* + ** + ** This function/vars is used to handle the interaction type + ** + *******************************************************************************/ var setInteraction = function (name, value) { // key for interactions in local storage is scoped to an attempt var interactionsKey = window.localStorage[config.activityId] + "_interactions"; @@ -822,9 +825,9 @@ xapi = function () { } } } - } + /******************************************************************************* ** ** This function is used to get an interaction iri @@ -834,6 +837,7 @@ xapi = function () { return config.activityId + "/interactions/" + encodeURIComponent(interactionId); } + /******************************************************************************* ** ** This function is used to set a scaled score @@ -975,7 +979,6 @@ xapi = function () { suspendDataElement: "cmi.suspend_data", totalTimeElement: (config.isScorm2004) ? "cmi.total_time" : "cmi.core.total_time" } - } /*******************************************************************************