Skip to content

Commit cc2ee88

Browse files
committed
MOBILE-4690 quiz: Wait the questions to load before validating
1 parent f9d3f47 commit cc2ee88

File tree

17 files changed

+160
-47
lines changed

17 files changed

+160
-47
lines changed

src/addons/qtype/ddimageortext/component/ddimageortext.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,18 +45,23 @@ export class AddonQtypeDdImageOrTextComponent
4545
*/
4646
init(): void {
4747
if (!this.question) {
48+
this.onReadyPromise.resolve();
49+
4850
return;
4951
}
5052

5153
const questionElement = this.initComponent();
5254
if (!questionElement) {
55+
this.onReadyPromise.resolve();
56+
5357
return;
5458
}
5559

5660
// Get D&D area and question text.
5761
const ddArea = questionElement.querySelector('.ddarea');
5862
if (!ddArea) {
5963
this.logger.warn('Aborting because of an error parsing question.', this.question.slot);
64+
this.onReadyPromise.resolve();
6065

6166
return CoreQuestionHelper.showComponentError(this.onAbort);
6267
}
@@ -84,6 +89,7 @@ export class AddonQtypeDdImageOrTextComponent
8489
}
8590

8691
this.question.loaded = false;
92+
this.onReadyPromise.resolve();
8793
}
8894

8995
/**

src/addons/qtype/ddmarker/component/ddmarker.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,15 @@ export class AddonQtypeDdMarkerComponent
5151
*/
5252
init(): void {
5353
if (!this.question) {
54+
this.onReadyPromise.resolve();
55+
5456
return;
5557
}
5658

5759
const questionElement = this.initComponent();
5860
if (!questionElement) {
61+
this.onReadyPromise.resolve();
62+
5963
return;
6064
}
6165

@@ -65,6 +69,7 @@ export class AddonQtypeDdMarkerComponent
6569

6670
if (!ddArea || !ddForm) {
6771
this.logger.warn('Aborting because of an error parsing question.', this.question.slot);
72+
this.onReadyPromise.resolve();
6873

6974
return CoreQuestionHelper.showComponentError(this.onAbort);
7075
}
@@ -107,6 +112,7 @@ export class AddonQtypeDdMarkerComponent
107112
}
108113

109114
this.question.loaded = false;
115+
this.onReadyPromise.resolve();
110116
}
111117

112118
/**

src/addons/qtype/ddwtos/component/ddwtos.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,15 @@ export class AddonQtypeDdwtosComponent extends CoreQuestionBaseComponent<AddonMo
4747
*/
4848
init(): void {
4949
if (!this.question) {
50+
this.onReadyPromise.resolve();
51+
5052
return;
5153
}
5254

5355
const questionElement = this.initComponent();
5456
if (!questionElement) {
57+
this.onReadyPromise.resolve();
58+
5559
return;
5660
}
5761

@@ -65,6 +69,7 @@ export class AddonQtypeDdwtosComponent extends CoreQuestionBaseComponent<AddonMo
6569
const answerContainer = questionElement.querySelector('.answercontainer');
6670
if (!answerContainer) {
6771
this.logger.warn('Aborting because of an error parsing question.', this.question.slot);
72+
this.onReadyPromise.resolve();
6873

6974
return CoreQuestionHelper.showComponentError(this.onAbort);
7075
}
@@ -98,6 +103,7 @@ export class AddonQtypeDdwtosComponent extends CoreQuestionBaseComponent<AddonMo
98103
this.question.text = questionText;
99104

100105
this.question.loaded = false;
106+
this.onReadyPromise.resolve();
101107
}
102108

103109
/**

src/addons/qtype/description/component/description.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,16 @@ export class AddonQtypeDescriptionComponent extends CoreQuestionBaseComponent {
3636
init(): void {
3737
const questionEl = this.initComponent();
3838
if (!questionEl) {
39+
this.onReadyPromise.resolve();
40+
3941
return;
4042
}
4143

4244
// Get the "seen" hidden input.
4345
const input = questionEl.querySelector<HTMLInputElement>('input[type="hidden"][name*=seen]');
4446
if (!input) {
47+
this.onReadyPromise.resolve();
48+
4549
return;
4650
}
4751

src/addons/qtype/essay/component/essay.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ export class AddonQtypeEssayComponent extends CoreQuestionBaseComponent<AddonMod
4545
*/
4646
init(): void {
4747
if (!this.question) {
48+
this.onReadyPromise.resolve();
49+
4850
return;
4951
}
5052

@@ -57,6 +59,7 @@ export class AddonQtypeEssayComponent extends CoreQuestionBaseComponent<AddonMod
5759
if (this.question?.allowsAttachments && this.uploadFilesSupported && !this.review) {
5860
this.loadAttachments();
5961
}
62+
this.onReadyPromise.resolve();
6063
}
6164

6265
/**

src/addons/qtype/gapselect/component/gapselect.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ export class AddonQtypeGapSelectComponent extends CoreQuestionBaseComponent {
3636
*/
3737
init(): void {
3838
this.initOriginalTextComponent('.qtext');
39+
this.onReadyPromise.resolve();
3940
}
4041

4142
/**

src/addons/qtype/match/component/match.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ export class AddonQtypeMatchComponent extends CoreQuestionBaseComponent<AddonMod
3535
*/
3636
init(): void {
3737
this.initMatchComponent();
38+
this.onReadyPromise.resolve();
3839
}
3940

4041
}

src/addons/qtype/multianswer/component/multianswer.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ export class AddonQtypeMultiAnswerComponent extends CoreQuestionBaseComponent {
3535
*/
3636
init(): void {
3737
this.initOriginalTextComponent('.formulation');
38+
this.onReadyPromise.resolve();
3839
}
3940

4041
/**

src/addons/qtype/multichoice/component/multichoice.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ export class AddonQtypeMultichoiceComponent extends CoreQuestionBaseComponent<Ad
3535
*/
3636
init(): void {
3737
this.initMultichoiceComponent();
38+
this.onReadyPromise.resolve();
3839
}
3940

4041
/**

src/addons/qtype/numerical/component/numerical.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ export class AddonQtypeNumericalComponent extends CoreQuestionBaseComponent<Addo
3535
*/
3636
init(): void {
3737
this.initCalculatedComponent();
38+
this.onReadyPromise.resolve();
3839
}
3940

4041
}

0 commit comments

Comments
 (0)