Skip to content

Commit 95d28f0

Browse files
authored
Merge pull request #527 from dpalou/MOBILE-1650
MOBILE-1650 completion: Fix scorm and quiz completion check
2 parents 8c0a714 + 20fac49 commit 95d28f0

File tree

2 files changed

+13
-19
lines changed

2 files changed

+13
-19
lines changed

www/addons/mod/quiz/controllers/index.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -339,6 +339,9 @@ angular.module('mm.addons.mod_quiz')
339339

340340
// Go to review an attempt that has just been finished.
341341
function goToAutoReview() {
342+
// If we go to auto review it means an attempt was finished. Check completion status.
343+
$mmCourse.checkModuleCompletion(courseId, module.completionstatus);
344+
342345
// Verify that user can see the review.
343346
var attemptId = autoReview.attemptId;
344347
if (quizAccessInfo.canreviewmyattempts) {
@@ -349,9 +352,6 @@ angular.module('mm.addons.mod_quiz')
349352
});
350353
}
351354

352-
// If we go to auto review it means an attempt was finished. Check completion status.
353-
$mmCourse.checkModuleCompletion(courseId, module.completionstatus);
354-
355355
return $q.when();
356356
}
357357

www/addons/mod/scorm/controllers/index.js

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ angular.module('mm.addons.mod_scorm')
4848
$scope.modebrowse = $mmaModScorm.MODEBROWSE;
4949

5050
// Convenience function to get SCORM data.
51-
function fetchScormData(refresh) {
51+
function fetchScormData(refresh, checkCompletion) {
5252
return $mmaModScorm.getScorm(courseid, module.id, module.url).then(function(scormData) {
5353
scorm = scormData;
5454

@@ -76,6 +76,10 @@ angular.module('mm.addons.mod_scorm')
7676
$scope.syncTime = syncTime;
7777
});
7878

79+
if (checkCompletion) {
80+
$mmCourse.checkModuleCompletion(courseid, module.completionstatus);
81+
}
82+
7983
// Get the number of attempts and check if SCORM is incomplete.
8084
return $mmaModScorm.getAttemptCount(scorm.id).then(function(attemptsData) {
8185
attempts = attemptsData;
@@ -279,15 +283,15 @@ angular.module('mm.addons.mod_scorm')
279283
}
280284

281285
// Refreshes data.
282-
function refreshData(dontForceSync) {
286+
function refreshData(dontForceSync, checkCompletion) {
283287
var promises = [];
284288
promises.push($mmaModScorm.invalidateScormData(courseid));
285289
if (scorm) {
286290
promises.push($mmaModScorm.invalidateAllScormData(scorm.id));
287291
}
288292

289293
return $q.all(promises).finally(function() {
290-
return fetchScormData(!dontForceSync);
294+
return fetchScormData(!dontForceSync, checkCompletion);
291295
});
292296
}
293297

@@ -339,11 +343,6 @@ angular.module('mm.addons.mod_scorm')
339343
if (message) {
340344
$mmUtil.showErrorModal(message);
341345
}
342-
343-
if (data.attemptFinished) {
344-
// An attempt was finished, check completion status.
345-
$mmCourse.checkModuleCompletion(courseid, module.completionstatus);
346-
}
347346
}
348347
}).catch(function(err) {
349348
if (showErrors) {
@@ -416,7 +415,7 @@ angular.module('mm.addons.mod_scorm')
416415
// Refresh the data.
417416
$scope.scormLoaded = false;
418417
scrollView.scrollTop();
419-
refreshData(true).finally(function() {
418+
refreshData(true, true).finally(function() {
420419
$scope.scormLoaded = true;
421420
});
422421
}).finally(function() {
@@ -441,7 +440,7 @@ angular.module('mm.addons.mod_scorm')
441440
scrollView.scrollTop();
442441
// Add a delay to make sure the player has started the last writing calls so we can detect conflicts.
443442
$timeout(function() {
444-
refreshData().finally(function() {
443+
refreshData(false, true).finally(function() {
445444
$scope.scormLoaded = true;
446445
});
447446
}, 500);
@@ -453,14 +452,9 @@ angular.module('mm.addons.mod_scorm')
453452
if (data && data.siteid == $mmSite.getId() && data.scormid == scorm.id) {
454453
$scope.scormLoaded = false;
455454
scrollView.scrollTop();
456-
fetchScormData().finally(function() {
455+
fetchScormData(false, true).finally(function() {
457456
$scope.scormLoaded = true;
458457
});
459-
460-
if (data.attemptFinished) {
461-
// An attempt was finished, check completion status.
462-
$mmCourse.checkModuleCompletion(courseid, module.completionstatus);
463-
}
464458
}
465459
});
466460

0 commit comments

Comments
 (0)