Memory Card Game - xAPI Completed (Improvement)

Excellent job on adding xAPI, however I'm sure you are aware that the score is currently hard coded here is a quick fix.

Counter.js

Adding this below the increment function. Simply return current score.

self.count = function(){ return current; };

Timer.js

Adding this below the stop function. Simply return total time.

self.totalTime = function(){

var currentTime = (new Date().getTime() - started);

return humanizeTime(Math.floor((totalTime + currentTime) / 1000));

};

Memory-game.js

Find the line self.triggerXPIScore(1, 1, 'completed');

Replace it with self.triggerXAPIScored(counter.count(), 1, 'completed');

Now we have a the proper score returned.

However in my case I wanted both time and score. Without hacking the triggerXPIScored function I passed a data object back in place of score including both bits of data, like so:

self.triggerXAPIScored({ 'score': counter.count(), 'time': timer.totalTime() }, 1, 'completed');

This isn't ideal passing the time in like this, but it was a quick solution.

EDIT:: Created GitHub Fork

 

 

 

 

 

icc's picture

Hi! I guess that the xAPI support which was added was more of a quick fix. The original plans were to simply report the time that it took to complete since it would be difficult to calculate a real score. I think there have been some discussions on how the score reporting should behave earlier and that the conclusion was some sort of exponential function starting at 1(full score) and going towards 0 would be they way to go since you can have an infinite number of card turns. However, it may be somewhat misleading since time often is the primary means of measurement for such tasks. 

What does your solution do in terms of max score? I'm afraid that some LRS solutions might get confused if you can't measure the score in percentage between 0 and 100.

I'm glad to see the xAPI support regardless, it streamlines my code slightly. Max score in my case is completely ignored I had never intended on using it, I was more interested in knowing how many card turns it took the player along with the time it took them to complete the puzzle. I store this information on wordpress then return it as a Leaderboard.  A single score value sounds interesting would perhaps work out slightly more unique than my scoring system.

icc's picture

I will keep this in mind for the next work session on Memory Game, when we're improving the events. A leader board for certain content types is a really great idea, I will note that down as well. Thank you for your feedback!