Skip to content

Commit b0b4c2f

Browse files
committed
MOBILE-1543 quiz: Ask preflight in prefetch
1 parent 803fb4f commit b0b4c2f

File tree

15 files changed

+314
-192
lines changed

15 files changed

+314
-192
lines changed

www/addons/mod_quiz/accessrules/delaybetweenattempts/handlers.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,10 @@ angular.module('mm.addons.mod_quiz')
3838
* Check if a preflight check is required.
3939
*
4040
* @param {Object} [attempt] Attempt to continue. Not defined if starting a new attempt.
41+
* @param {Boolean} prefetch True if prefetching, false if attempting the quiz.
4142
* @return {Boolean} True if preflight check required.
4243
*/
43-
self.isPreflightCheckRequired = function(attempt) {
44+
self.isPreflightCheckRequired = function(attempt, prefetch) {
4445
return false;
4546
};
4647

www/addons/mod_quiz/accessrules/ipaddress/handlers.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,10 @@ angular.module('mm.addons.mod_quiz')
3838
* Check if a preflight check is required.
3939
*
4040
* @param {Object} [attempt] Attempt to continue. Not defined if starting a new attempt.
41+
* @param {Boolean} prefetch True if prefetching, false if attempting the quiz.
4142
* @return {Boolean} True if preflight check required.
4243
*/
43-
self.isPreflightCheckRequired = function(attempt) {
44+
self.isPreflightCheckRequired = function(attempt, prefetch) {
4445
return false;
4546
};
4647

www/addons/mod_quiz/accessrules/numattempts/handlers.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,10 @@ angular.module('mm.addons.mod_quiz')
3838
* Check if a preflight check is required.
3939
*
4040
* @param {Object} [attempt] Attempt to continue. Not defined if starting a new attempt.
41+
* @param {Boolean} prefetch True if prefetching, false if attempting the quiz.
4142
* @return {Boolean} True if preflight check required.
4243
*/
43-
self.isPreflightCheckRequired = function(attempt) {
44+
self.isPreflightCheckRequired = function(attempt, prefetch) {
4445
return false;
4546
};
4647

www/addons/mod_quiz/accessrules/offlineattempts/handlers.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,14 @@ angular.module('mm.addons.mod_quiz')
3838
* Check if a preflight check is required.
3939
*
4040
* @param {Object} [attempt] Attempt to continue. Not defined if starting a new attempt.
41+
* @param {Boolean} prefetch True if prefetching, false if attempting the quiz.
4142
* @return {Boolean} True if preflight check required.
4243
*/
43-
self.isPreflightCheckRequired = function(attempt) {
44+
self.isPreflightCheckRequired = function(attempt, prefetch) {
45+
if (prefetch) {
46+
return false;
47+
}
48+
4449
if (!attempt) {
4550
return true;
4651
}
@@ -57,9 +62,10 @@ angular.module('mm.addons.mod_quiz')
5762
* @name $mmaModQuizAccessRulesDelegate#getFixedPreflightData
5863
* @param {Object} attempt Attempt.
5964
* @param {Object} preflightData Object where to store the preflight data.
65+
* @param {Boolean} prefetch True if prefetching, false if attempting the quiz.
6066
* @return {Void}
6167
*/
62-
self.getFixedPreflightData = function(attempt, preflightData) {
68+
self.getFixedPreflightData = function(attempt, preflightData, prefetch) {
6369
preflightData.confirmdatasaved = 1;
6470
};
6571

www/addons/mod_quiz/accessrules/openclosedate/handlers.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,10 @@ angular.module('mm.addons.mod_quiz')
3838
* Check if a preflight check is required.
3939
*
4040
* @param {Object} [attempt] Attempt to continue. Not defined if starting a new attempt.
41+
* @param {Boolean} prefetch True if prefetching, false if attempting the quiz.
4142
* @return {Boolean} True if preflight check required.
4243
*/
43-
self.isPreflightCheckRequired = function(attempt) {
44+
self.isPreflightCheckRequired = function(attempt, prefetch) {
4445
return false;
4546
};
4647

www/addons/mod_quiz/accessrules/password/handlers.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,10 @@ angular.module('mm.addons.mod_quiz')
4747
* Check if a preflight check is required.
4848
*
4949
* @param {Object} [attempt] Attempt to continue. Not defined if starting a new attempt.
50+
* @param {Boolean} prefetch True if prefetching, false if attempting the quiz.
5051
* @return {Boolean} True if preflight check required.
5152
*/
52-
self.isPreflightCheckRequired = function(attempt) {
53+
self.isPreflightCheckRequired = function(attempt, prefetch) {
5354
// If the password rule is active in a quiz we always require to input the password.
5455
return true;
5556
};

www/addons/mod_quiz/accessrules/safebrowser/handlers.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,10 @@ angular.module('mm.addons.mod_quiz')
3838
* Check if a preflight check is required.
3939
*
4040
* @param {Object} [attempt] Attempt to continue. Not defined if starting a new attempt.
41+
* @param {Boolean} prefetch True if prefetching, false if attempting the quiz.
4142
* @return {Boolean} True if preflight check required.
4243
*/
43-
self.isPreflightCheckRequired = function(attempt) {
44+
self.isPreflightCheckRequired = function(attempt, prefetch) {
4445
return false;
4546
};
4647

www/addons/mod_quiz/accessrules/securewindow/handlers.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,10 @@ angular.module('mm.addons.mod_quiz')
3838
* Check if a preflight check is required.
3939
*
4040
* @param {Object} [attempt] Attempt to continue. Not defined if starting a new attempt.
41+
* @param {Boolean} prefetch True if prefetching, false if attempting the quiz.
4142
* @return {Boolean} True if preflight check required.
4243
*/
43-
self.isPreflightCheckRequired = function(attempt) {
44+
self.isPreflightCheckRequired = function(attempt, prefetch) {
4445
return false;
4546
};
4647

www/addons/mod_quiz/accessrules/timelimit/handlers.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,12 @@ angular.module('mm.addons.mod_quiz')
3838
* Check if a preflight check is required.
3939
*
4040
* @param {Object} [attempt] Attempt to continue. Not defined if starting a new attempt.
41+
* @param {Boolean} prefetch True if prefetching, false if attempting the quiz.
4142
* @return {Boolean} True if preflight check required.
4243
*/
43-
self.isPreflightCheckRequired = function(attempt) {
44+
self.isPreflightCheckRequired = function(attempt, prefetch) {
4445
// Warning only required if the attempt is not already started.
46+
// prefetch should always be false since offline isn't compatible with timed quizzes.
4547
return !attempt;
4648
};
4749

www/addons/mod_quiz/controllers/player.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ angular.module('mm.addons.mod_quiz')
132132
function startOrContinueAttempt(fromModal) {
133133
// Check preflight data and start attempt if needed.
134134
var att = newAttempt ? undefined : attempt;
135-
return $mmaModQuizHelper.checkPreflightData($scope, quiz, quizAccessInfo, att, offline, fromModal).then(function(att) {
135+
return $mmaModQuiz.checkPreflightData($scope, quiz, quizAccessInfo, att, offline, fromModal).then(function(att) {
136136

137137
// Re-fetch attempt access information with the right attempt (might have changed because a new attempt was created).
138138
return $mmaModQuiz.getAttemptAccessInformation(quiz.id, att.id, offline, true).then(function(info) {
@@ -156,6 +156,10 @@ angular.module('mm.addons.mod_quiz')
156156
return loadSummary();
157157
}
158158
});
159+
}).catch(function(error) {
160+
if (error) {
161+
return $mmaModQuizHelper.showError(error, 'mm.core.error');
162+
}
159163
});
160164
}
161165

0 commit comments

Comments
 (0)