commit
62375690ff
13
card.js
13
card.js
|
@ -99,4 +99,17 @@
|
||||||
MemoryGame.Card.prototype = Object.create(EventDispatcher.prototype);
|
MemoryGame.Card.prototype = Object.create(EventDispatcher.prototype);
|
||||||
MemoryGame.Card.prototype.constructor = MemoryGame.Card;
|
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);
|
})(H5P.MemoryGame, H5P.EventDispatcher, H5P.jQuery);
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
"semantics": [
|
"semantics": [
|
||||||
{
|
{
|
||||||
"label": "Cartes",
|
"label": "Cartes",
|
||||||
"entity": "une carte",
|
"entity": "carte",
|
||||||
"field": {
|
"field": {
|
||||||
"label": "Carte",
|
"label": "Carte",
|
||||||
"fields": [
|
"fields": [
|
||||||
|
@ -17,19 +17,19 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"label": "Localisation",
|
"label": "Interface",
|
||||||
"fields": [
|
"fields": [
|
||||||
{
|
{
|
||||||
"label": "Texte pour une carte à retourner",
|
"label": "Texte pour le nombre de cartes retournées",
|
||||||
"default": "Retourner"
|
"default": "Cartes retournées :"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"label": "Texte pour le temps passé",
|
"label": "Texte pour le temps passé",
|
||||||
"default": "Durée écoulée"
|
"default": "Temps écoulé :"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"label": "Texte de feedback",
|
"label": "Texte de l'appréciation finale",
|
||||||
"default": "Bon travail!"
|
"default": "Bien joué !"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
|
@ -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!"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
|
@ -3,7 +3,7 @@
|
||||||
"description": "See how many cards you can remember!",
|
"description": "See how many cards you can remember!",
|
||||||
"majorVersion": 1,
|
"majorVersion": 1,
|
||||||
"minorVersion": 1,
|
"minorVersion": 1,
|
||||||
"patchVersion": 6,
|
"patchVersion": 10,
|
||||||
"runnable": 1,
|
"runnable": 1,
|
||||||
"author": "Amendor AS",
|
"author": "Amendor AS",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
|
|
|
@ -36,12 +36,15 @@ H5P.MemoryGame = (function (EventDispatcher, $) {
|
||||||
var finished = (removed === cards.length);
|
var finished = (removed === cards.length);
|
||||||
var desc = card.getDescription();
|
var desc = card.getDescription();
|
||||||
|
|
||||||
|
if (finished) {
|
||||||
|
self.triggerXAPIScored(1, 1, 'completed');
|
||||||
|
}
|
||||||
|
|
||||||
if (desc !== undefined) {
|
if (desc !== undefined) {
|
||||||
// Pause timer and show desciption.
|
// Pause timer and show desciption.
|
||||||
timer.stop();
|
timer.stop();
|
||||||
popup.show(desc, card.getImage(), function () {
|
popup.show(desc, card.getImage(), function () {
|
||||||
if (finished) {
|
if (finished) {
|
||||||
self.triggerXAPIScored(1, 1, 'completed');
|
|
||||||
// Game has finished
|
// Game has finished
|
||||||
$feedback.addClass('h5p-show');
|
$feedback.addClass('h5p-show');
|
||||||
}
|
}
|
||||||
|
@ -52,7 +55,6 @@ H5P.MemoryGame = (function (EventDispatcher, $) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
else if (finished) {
|
else if (finished) {
|
||||||
self.triggerXAPIScored(1, 1, 'completed');
|
|
||||||
// Game has finished
|
// Game has finished
|
||||||
timer.stop();
|
timer.stop();
|
||||||
$feedback.addClass('h5p-show');
|
$feedback.addClass('h5p-show');
|
||||||
|
@ -101,12 +103,14 @@ H5P.MemoryGame = (function (EventDispatcher, $) {
|
||||||
|
|
||||||
// Initialize cards.
|
// Initialize cards.
|
||||||
for (var i = 0; i < parameters.cards.length; i++) {
|
for (var i = 0; i < parameters.cards.length; i++) {
|
||||||
|
if (MemoryGame.Card.isValid(parameters.cards[i])) {
|
||||||
// Add two of each card
|
// Add two of each card
|
||||||
var cardOne = new MemoryGame.Card(parameters.cards[i], id);
|
var cardOne = new MemoryGame.Card(parameters.cards[i], id);
|
||||||
var cardTwo = new MemoryGame.Card(parameters.cards[i], id);
|
var cardTwo = new MemoryGame.Card(parameters.cards[i], id);
|
||||||
addCard(cardOne, cardTwo);
|
addCard(cardOne, cardTwo);
|
||||||
addCard(cardTwo, cardOne);
|
addCard(cardTwo, cardOne);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
H5P.shuffleArray(cards);
|
H5P.shuffleArray(cards);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue