Skip to content

Commit

Permalink
Merge pull request #116 from adaptlearning/hotfix/at-saverestore
Browse files Browse the repository at this point in the history
hotfix/at-saverestore
  • Loading branch information
Himanshu Rajotia committed Dec 9, 2015
2 parents 4858cfc + d61bd08 commit 6709e55
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 50 deletions.
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.7",
"version": "2.0.8",
"framework": "^2.0.0",
"homepage": "https://github.com/adaptlearning/adapt-contrib-spoor",
"issues": "https://adaptlearning.atlassian.net/secure/CreateIssueDetails!init.jspa?pid=10100&issuetype=1&priority=6&components=10520",
Expand Down
99 changes: 50 additions & 49 deletions js/serializers/questions.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,76 +37,77 @@ define([
captureData: function() {
var data = [];

var components = Adapt.components.toJSON();

components = _.where(components, includes);

var trackingIds = Adapt.blocks.pluck("_trackingId");
var blocks = {};
var countInBlock = {};

for (var i = 0, l = components.length; i < l; i++) {
var component = components[i];
var blockId = component._parentId;
for (var i = 0, l = trackingIds.length; i < l; i++) {

if (!blocks[blockId]) {
blocks[blockId] = Adapt.findById(blockId).toJSON();
}
var trackingId = trackingIds[i];
var blockModel = Adapt.blocks.findWhere({_trackingId: trackingId });
var componentModels = blockModel.getChildren().where(includes);

var block = blocks[blockId];
if (countInBlock[blockId] === undefined) countInBlock[blockId] = -1;
countInBlock[blockId]++;
for (var c = 0, cl = componentModels.length; c < cl; c++) {

var blockLocation = countInBlock[blockId];
var component = componentModels[c].toJSON();
var blockId = component._parentId;

if (component['_isInteractionComplete'] === false || component['_isComplete'] === false) {
//if component is not currently complete skip it
continue;
}
if (!blocks[blockId]) {
blocks[blockId] = blockModel.toJSON();
}

if (block['_trackingId'] === undefined) {
//if block has no tracking id, skip it
continue;
}
var block = blocks[blockId];
if (countInBlock[blockId] === undefined) countInBlock[blockId] = -1;
countInBlock[blockId]++;

var blockLocation = countInBlock[blockId];

if (component['_isInteractionComplete'] === false || component['_isComplete'] === false) {
//if component is not currently complete skip it
continue;
}

var hasUserAnswer = (component['_userAnswer'] !== undefined);
var isUserAnswerArray = (component['_userAnswer'] instanceof Array);
var hasUserAnswer = (component['_userAnswer'] !== undefined);
var isUserAnswerArray = (component['_userAnswer'] instanceof Array);


var numericParameters = [
blockLocation,
block['_trackingId'],
component['_score'] || 0
];
var numericParameters = [
blockLocation,
block['_trackingId'],
component['_score'] || 0
];

var booleanParameters = [
hasUserAnswer,
isUserAnswerArray,
component['_isInteractionComplete'],
component['_isSubmitted'],
component['_isCorrect'] || false
];

var booleanParameters = [
hasUserAnswer,
isUserAnswerArray,
component['_isInteractionComplete'],
component['_isSubmitted'],
component['_isCorrect'] || false
var dataItem = [
numericParameters,
booleanParameters
];

var dataItem = [
numericParameters,
booleanParameters
];

if (hasUserAnswer) {
var userAnswer = isUserAnswerArray ? component['_userAnswer'] : [component['_userAnswer']];

if (hasUserAnswer) {
var userAnswer = isUserAnswerArray ? component['_userAnswer'] : [component['_userAnswer']];
var arrayType = SCORMSuspendData.DataType.getArrayType(userAnswer);

var arrayType = SCORMSuspendData.DataType.getArrayType(userAnswer);
switch(arrayType.name) {
case "string": case "variable":
console.log("Cannot store _userAnswers from component " + component._id + " as array is of variable or string type.");
continue;
}

switch(arrayType.name) {
case "string": case "variable":
console.log("Cannot store _userAnswers from component " + component._id + " as array is of variable or string type.");
continue;
dataItem.push(userAnswer);
}

dataItem.push(userAnswer);
}
data.push(dataItem);

data.push(dataItem);
}

}

Expand Down

0 comments on commit 6709e55

Please sign in to comment.