-
Notifications
You must be signed in to change notification settings - Fork 55
/
upgrades.js
55 lines (49 loc) · 2.15 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
var H5PUpgrades = H5PUpgrades || {};
H5PUpgrades['H5P.BranchingScenario'] = (function () {
return {
1: {
/**
* Asynchronous content upgrade hook.
*
* Add new default parameters.
*
* @param {Object} parameters
* @param {function} finished
*/
4: function (parameters, finished, extras) {
// Sanitization
parameters.branchingScenario = parameters.branchingScenario || {};
parameters.branchingScenario.content = parameters.branchingScenario.content || [];
parameters.branchingScenario.behaviour = parameters.branchingScenario.behaviour || {};
// Set behvaior paramter for each content
parameters.branchingScenario.content.forEach( function (contentNode) {
if (!contentNode.contentBehaviour) {
contentNode.contentBehaviour = "useBehavioural";
}
if (!contentNode.forceContentFinished) {
contentNode.forceContentFinished = "useBehavioural";
}
});
// Global backwards navigation default value
if (!parameters.branchingScenario.behaviour.enableBackwardsNavigation) {
parameters.branchingScenario.behaviour.enableBackwardsNavigation = false;
}
if (!parameters.branchingScenario.behaviour.forceContentFinished) {
parameters.branchingScenario.behaviour.forceContentFinished = false;
}
finished(null, parameters, extras);
},
5: function (parameters, finished, extras) {
// Sanitization
parameters.branchingScenario = parameters.branchingScenario || {};
parameters.branchingScenario.scoringOptionGroup = parameters.branchingScenario.scoringOptionGroup || {};
// Change from scoringOption to scoringGroup
parameters.branchingScenario.scoringOptionGroup.scoringOption = parameters.branchingScenario.scoringOption || "no-score";
delete parameters.branchingScenario.scoringOption;
// Don't want to change behaviour of old content
parameters.branchingScenario.scoringOptionGroup.includeInteractionsScores = false;
finished(null, parameters, extras);
},
}
};
})();