forked from h5p/h5p-branching-scenario
-
Notifications
You must be signed in to change notification settings - Fork 0
/
upgrades.js
46 lines (40 loc) · 1.63 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
var H5PUpgrades = H5PUpgrades || {};
H5PUpgrades['H5P.BranchingScenario'] = (function () {
return {
1: {
/**
* Asynchronous content upgrade hook.
*
* Add new default parameters.
*
* @param {Object} parameters
* @param {function} finished
*/
2: function (parameters, finished, extras) {
// Sanitization
parameters.branchingScenario = parameters.branchingScenario || {};
parameters.branchingScenario.content = parameters.branchingScenario.content || [];
// Individual require finished override value
parameters.branchingScenario.content.forEach( function (contentNode) {
// No setting required for Branching Question
if (!contentNode.type || !contentNode.type.library || contentNode.type.library.split(' ')[0] === 'H5P.BranchingQuestion') {
return;
}
// Mind the one-item behavior of semantics groups
if (typeof contentNode.contentBehaviour === 'undefined') {
contentNode.contentBehaviour = false;
}
});
// Global backwards navigation default value, mind the one-item behavior of semantics groups
// Global require finished override select default value, mind the one-item behavior of semantics groups
if (typeof parameters.branchingScenario.behaviour === 'undefined') {
parameters.branchingScenario.behaviour = 'individual';
}
if (parameters.branchingScenario.l10n) {
parameters.branchingScenario.l10n.backButtonText = 'Back';
}
finished(null, parameters, extras);
}
}
};
})();