From 65a24ed30170f690ba8ba2d5cf69afe72d177cd7 Mon Sep 17 00:00:00 2001 From: Dani Palou Date: Tue, 25 Feb 2020 08:51:21 +0100 Subject: [PATCH] MOBILE-3323 quiz: Fix nativeElement error when submit quiz --- src/addon/mod/quiz/pages/player/player.ts | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/addon/mod/quiz/pages/player/player.ts b/src/addon/mod/quiz/pages/player/player.ts index 92d9a04ac..a7ebca6af 100644 --- a/src/addon/mod/quiz/pages/player/player.ts +++ b/src/addon/mod/quiz/pages/player/player.ts @@ -154,7 +154,9 @@ export class AddonModQuizPlayerPage implements OnInit, OnDestroy { await this.domUtils.showConfirm(this.translate.instant('addon.mod_quiz.confirmleavequizonerror')); - this.domUtils.triggerFormCancelledEvent(this.formElement.nativeElement, this.sitesProvider.getCurrentSiteId()); + if (this.formElement) { + this.domUtils.triggerFormCancelledEvent(this.formElement.nativeElement, this.sitesProvider.getCurrentSiteId()); + } } finally { modal.dismiss(); } @@ -589,8 +591,10 @@ export class AddonModQuizPlayerPage implements OnInit, OnDestroy { this.autoSave.cancelAutoSave(); this.autoSave.hideAutoSaveError(); - this.domUtils.triggerFormSubmittedEvent(this.formElement.nativeElement, !this.offline, - this.sitesProvider.getCurrentSiteId()); + if (this.formElement) { + this.domUtils.triggerFormSubmittedEvent(this.formElement.nativeElement, !this.offline, + this.sitesProvider.getCurrentSiteId()); + } }); }