Skip to content

Commit 2e81f53

Browse files
authored
Merge pull request #2322 from dpalou/MOBILE-3269
MOBILE-3269 quiz: Fix cannot read 'activerulenames' of undefined
2 parents c81e669 + c6393b4 commit 2e81f53

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

src/addon/mod/quiz/providers/helper.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -111,9 +111,10 @@ export class AddonModQuizHelperProvider {
111111
*/
112112
getPreflightData(quiz: any, accessInfo: any, attempt: any, prefetch?: boolean, title?: string, siteId?: string): Promise<any> {
113113
const notSupported: string[] = [];
114+
const rules = accessInfo && accessInfo.activerulenames;
114115

115116
// Check if there is any unsupported rule.
116-
accessInfo.activerulenames.forEach((rule) => {
117+
rules.forEach((rule) => {
117118
if (!this.accessRuleDelegate.isAccessRuleSupported(rule)) {
118119
notSupported.push(rule);
119120
}
@@ -131,7 +132,7 @@ export class AddonModQuizHelperProvider {
131132
attempt: attempt,
132133
prefetch: !!prefetch,
133134
siteId: siteId,
134-
rules: accessInfo.activerulenames
135+
rules: rules
135136
});
136137

137138
modal.present();
@@ -296,7 +297,7 @@ export class AddonModQuizHelperProvider {
296297
validatePreflightData(quiz: any, accessInfo: any, preflightData: any, attempt: any, offline?: boolean, prefetch?: boolean,
297298
siteId?: string): Promise<any> {
298299

299-
const rules = accessInfo.activerulenames;
300+
const rules = accessInfo && accessInfo.activerulenames;
300301
let promise;
301302

302303
if (attempt) {

src/addon/mod/quiz/providers/prefetch-handler.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ export class AddonModQuizPrefetchHandler extends CoreCourseActivityPrefetchHandl
160160
quiz, accessInfo, preflightData, attempt, false, true, title, siteId);
161161
} else {
162162
// Get some fixed preflight data from access rules (data that doesn't require user interaction).
163-
const rules = accessInfo.activerulenames;
163+
const rules = accessInfo && accessInfo.activerulenames;
164164

165165
promise = this.accessRuleDelegate.getFixedPreflightData(rules, quiz, preflightData, attempt, true, siteId).then(() => {
166166
if (!attempt) {

0 commit comments

Comments
 (0)