Skip to content

Commit ec9f0b8

Browse files
committed
Merge pull request #381 from adaptlearning/hotfix/v1.1.1
Hotfix/v1.1.1
2 parents b650564 + 46c8d21 commit ec9f0b8

6 files changed

Lines changed: 64 additions & 40 deletions

File tree

adapt.json

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,24 @@
11
{
22
"dependencies": {
3-
"adapt-contrib-vanilla": "0.0.0",
4-
"adapt-contrib-text": "0.0.0",
5-
"adapt-contrib-narrative": "0.0.0",
6-
"adapt-contrib-media": "0.0.0",
7-
"adapt-contrib-hotgraphic": "0.0.0",
8-
"adapt-contrib-blank": "0.0.0",
9-
"adapt-contrib-accordion": "0.0.0",
10-
"adapt-contrib-graphic": "0.0.0",
11-
"adapt-contrib-matching": "0.0.0",
12-
"adapt-contrib-textInput": "0.0.0",
13-
"adapt-contrib-mcq": "0.0.0",
14-
"adapt-contrib-gmcq": "0.0.0",
15-
"adapt-contrib-assessment": "0.0.0",
16-
"adapt-contrib-trickle": "0.0.0",
17-
"adapt-contrib-tutor": "0.0.0",
18-
"adapt-contrib-boxMenu": "0.0.0",
19-
"adapt-contrib-spoor": "0.0.0",
20-
"adapt-contrib-pageLevelProgress": "0.0.0",
21-
"adapt-contrib-resources": "0.0.0",
22-
"adapt-contrib-slider": "0.0.0"
3+
"adapt-contrib-vanilla": "*",
4+
"adapt-contrib-text": "*",
5+
"adapt-contrib-narrative": "*",
6+
"adapt-contrib-media": "*",
7+
"adapt-contrib-hotgraphic": "*",
8+
"adapt-contrib-blank": "*",
9+
"adapt-contrib-accordion": "*",
10+
"adapt-contrib-graphic": "*",
11+
"adapt-contrib-matching": "*",
12+
"adapt-contrib-textInput": "*",
13+
"adapt-contrib-mcq": "*",
14+
"adapt-contrib-gmcq": "*",
15+
"adapt-contrib-assessment": "*",
16+
"adapt-contrib-trickle": "*",
17+
"adapt-contrib-tutor": "*",
18+
"adapt-contrib-boxMenu": "*",
19+
"adapt-contrib-spoor": "*",
20+
"adapt-contrib-pageLevelProgress": "*",
21+
"adapt-contrib-resources": "*",
22+
"adapt-contrib-slider": "*"
2323
}
2424
}

src/core/js/app.js

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,10 @@ require([
4646
&& Adapt.articles.models.length > 0
4747
&& Adapt.blocks.models.length > 0
4848
&& Adapt.components.models.length > 0
49-
&& Adapt.course.hasChanged()) {
49+
&& Adapt.course.get('_id')) {
5050
Adapt.trigger('app:dataReady');
5151
Adapt.initialize();
52-
Adapt.off('adaptCollection:dataLoaded courseModel:dataLoaded configModel:dataLoaded');
52+
Adapt.off('adaptCollection:dataLoaded courseModel:dataLoaded');
5353
}
5454
}
5555

@@ -84,12 +84,8 @@ require([
8484
}
8585

8686
// Events that are triggered by the main Adapt content collections and models
87-
Adapt.on('configModel:loadCourseData', loadCourseData);
87+
Adapt.once('configModel:loadCourseData', loadCourseData);
8888

8989
Adapt.on('adaptCollection:dataLoaded courseModel:dataLoaded', checkDataIsLoaded);
9090

91-
92-
93-
94-
9591
});

src/core/js/models/adaptModel.js

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,12 @@ define(function (require) {
4040
_isTrackable: {},
4141
_isVisible: {}
4242
};
43+
// Wait until data is ready before setting up model
44+
Adapt.once('app:dataReady', this.setupModel, this);
45+
46+
},
47+
48+
setupModel: function() {
4349
if (this.get('_type') === 'page') {
4450
this._children = 'articles';
4551
}
@@ -52,20 +58,23 @@ define(function (require) {
5258
"change:_isComplete": this.checkCompletionStatus
5359
}, this);
5460
}
55-
this.init();
56-
},
57-
58-
init: function() {
59-
6061
},
6162

6263
checkReadyStatus: function () {
63-
if (this.getChildren().findWhere({_isReady: false})) return;
64+
// Filter children based upon whether they are available
65+
var availableChildren = new Backbone.Collection(this.getChildren().where({_isAvailable: true}));
66+
// Check if any return _isReady:false
67+
// If not - set this model to _isReady: true
68+
if (availableChildren.findWhere({_isReady: false})) return;
6469
this.set({_isReady: true});
6570
},
6671

6772
checkCompletionStatus: function () {
68-
if (this.getChildren().findWhere({_isComplete: false})) return;
73+
// Filter children based upon whether they are available
74+
var availableChildren = new Backbone.Collection(this.getChildren().where({_isAvailable: true}));
75+
// Check if any return _isComplete:false
76+
// If not - set this model to _isComplete: true
77+
if (availableChildren.findWhere({_isComplete: false})) return;
6978
this.set({_isComplete: true});
7079
},
7180

src/core/js/router.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,9 +141,14 @@ define(function(require) {
141141

142142
Adapt.location._currentLocation = currentLocation;
143143

144+
var classes = (Adapt.location._currentId) ? 'location-'
145+
+ Adapt.location._contentType
146+
+ ' location-id-'
147+
+ Adapt.location._currentId :
148+
'location-' + Adapt.location._currentLocation;
144149
this.$wrapper
145150
.removeClass()
146-
.addClass('location-' + Adapt.location._currentLocation)
151+
.addClass(classes)
147152
.attr('data-location', Adapt.location._currentLocation);
148153

149154
// Trigger event when location changes

src/core/js/views/questionView.js

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ define(function(require) {
139139

140140
showMarking: function() {
141141
_.each(this.model.get('_items'), function(item, i) {
142-
var $item = this.$('.item').eq(i);
142+
var $item = this.$('.component-item').eq(i);
143143
$item.addClass(item.correct ? 'correct' : 'incorrect');
144144
}, this);
145145
},
@@ -181,15 +181,27 @@ define(function(require) {
181181
onQuestionIncorrect: function() {
182182
if (this.isPartlyCorrect()) {
183183
if (this.model.get('_attemptsLeft') === 0 || !this.model.get('_feedback')._partlyCorrect.notFinal) {
184-
this.model.set("feedbackMessage", this.model.get('_feedback')._partlyCorrect.final);
184+
this.model.set({
185+
"feedbackTitle": this.model.get('title'),
186+
"feedbackMessage": this.model.get('_feedback')._partlyCorrect.final
187+
});
185188
} else {
186-
this.model.set("feedbackMessage", this.model.get('_feedback')._partlyCorrect.notFinal);
189+
this.model.set({
190+
"feedbackTitle": this.model.get('title'),
191+
"feedbackMessage": this.model.get('_feedback')._partlyCorrect.notFinal
192+
});
187193
}
188194
} else {
189195
if (this.model.get('_attemptsLeft') === 0 || !this.model.get('_feedback')._incorrect.notFinal) {
190-
this.model.set("feedbackMessage", this.model.get('_feedback')._incorrect.final);
196+
this.model.set({
197+
"feedbackTitle": this.model.get('title'),
198+
"feedbackMessage": this.model.get('_feedback')._incorrect.final
199+
});
191200
} else {
192-
this.model.set("feedbackMessage", this.model.get('_feedback')._incorrect.notFinal);
201+
this.model.set({
202+
"feedbackTitle": this.model.get('title'),
203+
"feedbackMessage": this.model.get('_feedback')._incorrect.notFinal
204+
});
193205
}
194206
}
195207

test/spec/adaptModels.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,8 @@ define(function (require) {
160160
}
161161
], {model: ComponentModel, reset:true});
162162

163+
Adapt.trigger('app:dataReady');
164+
163165
describe('AdaptModel', function () {
164166

165167
it("should allow me to get my children if I'm a contentObject", function () {

0 commit comments

Comments
 (0)