2015-04-08 15:04:29 +02:00
|
|
|
var H5PUpgrades = H5PUpgrades || {};
|
|
|
|
|
|
|
|
H5PUpgrades['H5P.QuestionSet'] = (function ($) {
|
|
|
|
return {
|
|
|
|
1: {
|
2015-04-14 13:56:32 +02:00
|
|
|
3: function (parameters, finished) {
|
2015-04-08 15:04:29 +02:00
|
|
|
for (var i = 0; i < parameters.questions.length; i++) {
|
|
|
|
if (parameters.questions[i].subContentId === undefined) {
|
|
|
|
// NOTE: We avoid using H5P.createUUID since this is an upgrade script and H5P function may change in the
|
|
|
|
// future
|
|
|
|
parameters.questions[i].subContentId = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(char) {
|
|
|
|
var random = Math.random()*16|0, newChar = char === 'x' ? random : (random&0x3|0x8);
|
|
|
|
return newChar.toString(16);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
2016-03-17 14:09:13 +01:00
|
|
|
finished(null, parameters);
|
|
|
|
},
|
2016-04-04 15:50:41 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Asynchronous content upgrade hook.
|
|
|
|
* Upgrades content parameters to support IV 1.7.
|
|
|
|
*
|
|
|
|
* Groups all UI text strings to make them eaiser to translate and handle.
|
|
|
|
*
|
|
|
|
* @params {Object} parameters
|
|
|
|
* @params {function} finished
|
|
|
|
*/
|
2016-03-17 14:09:13 +01:00
|
|
|
8: function (parameters, finished) {
|
|
|
|
|
2016-05-02 11:05:59 +02:00
|
|
|
if (parameters.override) {
|
|
|
|
if (parameters.override.overrideButtons) {
|
|
|
|
// Set new variables
|
|
|
|
parameters.override.showSolutionButton =
|
|
|
|
(parameters.override.overrideShowSolutionButton ? 'on' : 'off');
|
|
|
|
parameters.override.retryButton =
|
|
|
|
(parameters.override.overrideRetry ? 'on' : 'off');
|
|
|
|
}
|
2016-04-04 15:50:41 +02:00
|
|
|
|
2016-05-02 11:05:59 +02:00
|
|
|
// Remove old field variables
|
|
|
|
delete parameters.override.overrideButtons;
|
|
|
|
delete parameters.override.overrideShowSolutionButton;
|
|
|
|
delete parameters.override.overrideRetry;
|
|
|
|
}
|
2016-04-04 15:50:41 +02:00
|
|
|
|
2016-04-15 12:49:09 +02:00
|
|
|
// Move copyright dialog question label
|
2016-03-17 14:09:13 +01:00
|
|
|
if (parameters.questionLabel) {
|
2016-04-15 12:49:09 +02:00
|
|
|
parameters.texts = parameters.texts || {};
|
2016-03-17 14:09:13 +01:00
|
|
|
parameters.texts.questionLabel = parameters.questionLabel;
|
|
|
|
}
|
|
|
|
|
2016-04-15 12:49:09 +02:00
|
|
|
// Remove old copyright dialog question label
|
|
|
|
delete parameters.questionLabel;
|
|
|
|
|
2017-07-03 15:09:49 +02:00
|
|
|
finished(null, parameters);
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Asynchronous content upgrade hook.
|
|
|
|
*
|
|
|
|
* Upgrade params to support overall feedback
|
|
|
|
*
|
|
|
|
* @param {Object} parameters
|
|
|
|
* @param {function} finished
|
|
|
|
*/
|
|
|
|
13: function (parameters, finished) {
|
|
|
|
|
|
|
|
parameters.endGame = parameters.endGame || {};
|
|
|
|
parameters.endGame.overallFeedback = [];
|
|
|
|
|
|
|
|
if (parameters.endGame.scoreString) {
|
|
|
|
parameters.endGame.overallFeedback.push({
|
|
|
|
from: 0,
|
|
|
|
to: 100,
|
|
|
|
feedback: parameters.endGame.scoreString
|
|
|
|
});
|
|
|
|
|
|
|
|
delete parameters.endGame.scoreString;
|
|
|
|
}
|
|
|
|
|
2017-07-13 15:51:24 +02:00
|
|
|
// Group old feedback fields
|
|
|
|
if (parameters.endGame.successGreeting ||
|
|
|
|
parameters.endGame.successComment ||
|
|
|
|
parameters.endGame.failGreeting ||
|
|
|
|
parameters.endGame.failComment) {
|
|
|
|
parameters.endGame.oldFeedback = {};
|
|
|
|
if (parameters.endGame.successGreeting) {
|
|
|
|
parameters.endGame.oldFeedback.successGreeting = parameters.endGame.successGreeting;
|
|
|
|
}
|
|
|
|
if (parameters.endGame.successComment) {
|
|
|
|
parameters.endGame.oldFeedback.successComment = parameters.endGame.successComment;
|
|
|
|
}
|
|
|
|
if (parameters.endGame.failGreeting) {
|
|
|
|
parameters.endGame.oldFeedback.failGreeting = parameters.endGame.failGreeting;
|
|
|
|
}
|
|
|
|
if (parameters.endGame.failComment) {
|
|
|
|
parameters.endGame.oldFeedback.failComment = parameters.endGame.failComment;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-04-08 15:04:29 +02:00
|
|
|
finished(null, parameters);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
})(H5P.jQuery);
|