-
Notifications
You must be signed in to change notification settings - Fork 65
/
upgrades.js
67 lines (60 loc) · 2.04 KB
/
upgrades.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
var H5PUpgrades = H5PUpgrades || {};
H5PUpgrades['H5P.MarkTheWords'] = (function () {
return {
1: {
1: {
contentUpgrade: function (parameters, finished) {
// Moved all behavioural settings into "behaviour" group.
parameters.behaviour = {
enableRetry: parameters.enableRetry === undefined ? true: parameters.enableRetry,
enableSolutionsButton: parameters.enableShowSolution === undefined ? true : parameters.enableShowSolution
};
delete parameters.enableRetry;
delete parameters.enableShowSolution;
finished(null, parameters);
}
},
5: {
contentUpgrade: function (parameters, finished) {
if (parameters.textField !== undefined) {
parameters.textField = parameters.textField.replace(/\n/g, "<br />");
}
finished(null, parameters);
}
},
/**
* Asynchronous content upgrade hook.
* Upgrades content parameters to support Mark the Words 1.7
*
* Move old feedback message to the new overall feedback system.
* Do not show the new score points for old content being upgraded.
*
* @param {object} parameters
* @param {function} finished
*/
7: function (parameters, finished) {
if (parameters && parameters.score) {
parameters.overallFeedback = [
{
'from': 0,
'to': 100,
'feedback': parameters.score
}
];
delete parameters.score;
}
finished(null, parameters);
},
9: function (parameters, finished, extras) {
var title;
if (parameters) {
title = parameters.taskDescription;
}
extras = extras || {};
extras.metadata = extras.metadata || {};
extras.metadata.title = (title) ? title.replace(/<[^>]*>?/g, '') : ((extras.metadata.title) ? extras.metadata.title : 'Mark the Words');
finished(null, parameters, extras);
}
}
};
})();