Skip to content

Commit

Permalink
Fixes #1990, update to onQuestionRecordInteraction() to call model fu…
Browse files Browse the repository at this point in the history
…nctions (#171)

As part of the rework in components to split model and view functions, with this code the model will be checked (when available) for the following functions:
- getResponseType()
- getResponse()
- isCorrect()
  • Loading branch information
brian-learningpool authored and moloko committed Mar 5, 2018
1 parent 2a31cda commit 69f6ff6
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions js/adapt-stateful-session.js
Original file line number Diff line number Diff line change
Expand Up @@ -148,14 +148,21 @@ define([
},

onQuestionRecordInteraction:function(questionView) {
var responseType = questionView.getResponseType();
var responseType = typeof questionView.model.getResponseType === 'function'
? questionView.model.getResponseType()
: questionView.getResponseType();

// if responseType doesn't contain any data, assume that the question component hasn't been set up for cmi.interaction tracking
if(_.isEmpty(responseType)) return;
// If responseType doesn't contain any data, assume that the question
// component hasn't been set up for cmi.interaction tracking
if (_.isEmpty(responseType)) return;

var id = questionView.model.get('_id');
var response = questionView.getResponse();
var result = questionView.isCorrect();
var response = typeof questionView.model.getResponse === 'function'
? questionView.model.getResponse()
: questionView.getResponse();
var result = typeof questionView.model.isCorrect === 'function'
? questionView.model.isCorrect()
: questionView.isCorrect();
var latency = questionView.getLatency();

Adapt.offlineStorage.set("interaction", id, response, result, latency, responseType);
Expand Down

0 comments on commit 69f6ff6

Please sign in to comment.