@@ -165,7 +165,7 @@ angular.module('mm.addons.mod_quiz')
165165 // User just finished an attempt in offline and it seems it's been synced, since it's finished in online.
166166 // Go to the review of this attempt if the user hasn't left this view.
167167 if ( ! $scope . $$destroyed && $state . current . name == 'site.mod_quiz' ) {
168- goToAutoReview ( ) ;
168+ promises . push ( goToAutoReview ( ) ) ;
169169 }
170170 autoReview = undefined ;
171171 }
@@ -332,7 +332,16 @@ angular.module('mm.addons.mod_quiz')
332332
333333 // Go to review an attempt that has just been finished.
334334 function goToAutoReview ( ) {
335- $state . go ( 'site.mod_quiz-review' , { courseid : courseId , quizid : quiz . id , attemptid : autoReview . attemptId } ) ;
335+ // Verify that user can see the review.
336+ var attemptId = autoReview . attemptId ;
337+ if ( quizAccessInfo . canreviewmyattempts ) {
338+ return $mmaModQuiz . getAttemptReview ( attemptId , - 1 ) . then ( function ( ) {
339+ return $state . go ( 'site.mod_quiz-review' , { courseid : courseId , quizid : quiz . id , attemptid : attemptId } ) ;
340+ } ) . catch ( function ( ) {
341+ // Ignore errors.
342+ } ) ;
343+ }
344+ return $q . when ( ) ;
336345 }
337346
338347 // Open a quiz to attempt it.
@@ -450,18 +459,23 @@ angular.module('mm.addons.mod_quiz')
450459 return ;
451460 }
452461
453- var forwardView = $ionicHistory . forwardView ( ) ;
462+ var forwardView = $ionicHistory . forwardView ( ) ,
463+ promise ;
454464 if ( forwardView && forwardView . stateName === 'site.mod_quiz-player' ) {
455465 if ( autoReview && autoReview . synced ) {
456- goToAutoReview ( ) ;
466+ promise = goToAutoReview ( ) ;
457467 autoReview = undefined ;
468+ } else {
469+ promise = $q . when ( ) ;
458470 }
459471
460472 // Refresh data.
461473 $scope . quizLoaded = false ;
462474 scrollView . scrollTop ( ) ;
463- refreshData ( ) . finally ( function ( ) {
464- $scope . quizLoaded = true ;
475+ promise . then ( function ( ) {
476+ refreshData ( ) . finally ( function ( ) {
477+ $scope . quizLoaded = true ;
478+ } ) ;
465479 } ) ;
466480 } else {
467481 autoReview = undefined ;
0 commit comments