diff --git a/card.js b/card.js index 0c0a608..dca1639 100644 --- a/card.js +++ b/card.js @@ -99,4 +99,17 @@ MemoryGame.Card.prototype = Object.create(EventDispatcher.prototype); MemoryGame.Card.prototype.constructor = MemoryGame.Card; + /** + * Check to see if the given object corresponds with the semantics for + * a memory game card. + * + * @param {object} params + * @returns {boolean} + */ + MemoryGame.Card.isValid = function (params) { + return (params !== undefined && + params.image !== undefined && + params.image.path !== undefined); + }; + })(H5P.MemoryGame, H5P.EventDispatcher, H5P.jQuery); diff --git a/language/fr.json b/language/fr.json index 96828bb..e00969e 100644 --- a/language/fr.json +++ b/language/fr.json @@ -2,7 +2,7 @@ "semantics": [ { "label": "Cartes", - "entity": "une carte", + "entity": "carte", "field": { "label": "Carte", "fields": [ @@ -17,19 +17,19 @@ } }, { - "label": "Localisation", + "label": "Interface", "fields": [ { - "label": "Texte pour une carte à retourner", - "default": "Retourner" + "label": "Texte pour le nombre de cartes retournées", + "default": "Cartes retournées :" }, { "label": "Texte pour le temps passé", - "default": "Durée écoulée" + "default": "Temps écoulé :" }, { - "label": "Texte de feedback", - "default": "Bon travail!" + "label": "Texte de l'appréciation finale", + "default": "Bien joué !" } ] } diff --git a/language/nb.json b/language/nb.json new file mode 100644 index 0000000..b56939a --- /dev/null +++ b/language/nb.json @@ -0,0 +1,50 @@ +{ + "semantics": [ + { + "englishLabel": "Cards", + "label": "Kort", + "englishEntity": "card", + "entity": "kort", + "field": { + "englishLabel": "Card", + "label": "Kort", + "fields": [ + { + "englishLabel": "Image", + "label": "Bilde" + }, + { + "englishLabel": "Description", + "label": "Beskrivelse", + "englishDescription": "A short text that is displayed once the two equal cards are found.", + "description": "En kort tekst som vises hver gang et kort-par er funnet." + } + ] + } + }, + { + "englishLabel": "Localization", + "label": "Oversettelser", + "fields": [ + { + "englishLabel": "Card turns text", + "label": "Etikett for antall vendte kort", + "englishDefault": "Card turns", + "default": "Kort vendt" + }, + { + "englishLabel": "Time spent text", + "label": "Etikett for tid brukt", + "englishDefault": "Time spent", + "default": "Tid brukt" + }, + { + "englishLabel": "Feedback text", + "label": "Tilbakemeldingstekst", + "englishDefault": "Good work!", + "default": "Godt jobbet!" + } + ] + } + ] +} diff --git a/library.json b/library.json index 158341f..e11093b 100644 --- a/library.json +++ b/library.json @@ -3,7 +3,7 @@ "description": "See how many cards you can remember!", "majorVersion": 1, "minorVersion": 1, - "patchVersion": 6, + "patchVersion": 10, "runnable": 1, "author": "Amendor AS", "license": "MIT", diff --git a/memory-game.js b/memory-game.js index 98166b8..845fe3b 100644 --- a/memory-game.js +++ b/memory-game.js @@ -36,12 +36,15 @@ H5P.MemoryGame = (function (EventDispatcher, $) { var finished = (removed === cards.length); var desc = card.getDescription(); + if (finished) { + self.triggerXAPIScored(1, 1, 'completed'); + } + if (desc !== undefined) { // Pause timer and show desciption. timer.stop(); popup.show(desc, card.getImage(), function () { if (finished) { - self.triggerXAPIScored(1, 1, 'completed'); // Game has finished $feedback.addClass('h5p-show'); } @@ -52,7 +55,6 @@ H5P.MemoryGame = (function (EventDispatcher, $) { }); } else if (finished) { - self.triggerXAPIScored(1, 1, 'completed'); // Game has finished timer.stop(); $feedback.addClass('h5p-show'); @@ -101,11 +103,13 @@ H5P.MemoryGame = (function (EventDispatcher, $) { // Initialize cards. for (var i = 0; i < parameters.cards.length; i++) { - // Add two of each card - var cardOne = new MemoryGame.Card(parameters.cards[i], id); - var cardTwo = new MemoryGame.Card(parameters.cards[i], id); - addCard(cardOne, cardTwo); - addCard(cardTwo, cardOne); + if (MemoryGame.Card.isValid(parameters.cards[i])) { + // Add two of each card + var cardOne = new MemoryGame.Card(parameters.cards[i], id); + var cardTwo = new MemoryGame.Card(parameters.cards[i], id); + addCard(cardOne, cardTwo); + addCard(cardTwo, cardOne); + } } H5P.shuffleArray(cards);