MOBILE-3068 quiz: Close modals when time is up
parent
0a0d639ebf
commit
265f15f380
|
@ -25,6 +25,7 @@ import { CoreDomUtilsProvider } from '@providers/utils/dom';
|
|||
import { CoreTimeUtilsProvider } from '@providers/utils/time';
|
||||
import { CoreUrlUtilsProvider } from '@providers/utils/url';
|
||||
import { CoreUtilsProvider } from '@providers/utils/utils';
|
||||
import { MoodleMobileApp } from '../../../../../app/app.component';
|
||||
import { AddonModLessonProvider } from '../../providers/lesson';
|
||||
import { AddonModLessonOfflineProvider } from '../../providers/lesson-offline';
|
||||
import { AddonModLessonSyncProvider } from '../../providers/lesson-sync';
|
||||
|
@ -85,7 +86,8 @@ export class AddonModLessonPlayerPage implements OnInit, OnDestroy {
|
|||
protected lessonHelper: AddonModLessonHelperProvider, protected lessonSync: AddonModLessonSyncProvider,
|
||||
protected lessonOfflineProvider: AddonModLessonOfflineProvider, protected cdr: ChangeDetectorRef,
|
||||
modalCtrl: ModalController, protected navCtrl: NavController, protected appProvider: CoreAppProvider,
|
||||
protected utils: CoreUtilsProvider, protected urlUtils: CoreUrlUtilsProvider, protected fb: FormBuilder) {
|
||||
protected utils: CoreUtilsProvider, protected urlUtils: CoreUrlUtilsProvider, protected fb: FormBuilder,
|
||||
protected mmApp: MoodleMobileApp) {
|
||||
|
||||
this.lessonId = navParams.get('lessonId');
|
||||
this.courseId = navParams.get('courseId');
|
||||
|
@ -145,6 +147,13 @@ export class AddonModLessonPlayerPage implements OnInit, OnDestroy {
|
|||
return Promise.resolve();
|
||||
}
|
||||
|
||||
/**
|
||||
* Runs when the page is about to leave and no longer be the active page.
|
||||
*/
|
||||
ionViewWillLeave(): void {
|
||||
this.mmApp.closeModal();
|
||||
}
|
||||
|
||||
/**
|
||||
* A button was clicked.
|
||||
*
|
||||
|
|
|
@ -23,6 +23,7 @@ import { CoreDomUtilsProvider } from '@providers/utils/dom';
|
|||
import { CoreTimeUtilsProvider } from '@providers/utils/time';
|
||||
import { CoreQuestionHelperProvider } from '@core/question/providers/helper';
|
||||
import { CoreQuestionComponent } from '@core/question/components/question/question';
|
||||
import { MoodleMobileApp } from '../../../../../app/app.component';
|
||||
import { AddonModQuizProvider } from '../../providers/quiz';
|
||||
import { AddonModQuizSyncProvider } from '../../providers/quiz-sync';
|
||||
import { AddonModQuizHelperProvider } from '../../providers/helper';
|
||||
|
@ -80,7 +81,7 @@ export class AddonModQuizPlayerPage implements OnInit, OnDestroy {
|
|||
protected timeUtils: CoreTimeUtilsProvider, protected quizProvider: AddonModQuizProvider,
|
||||
protected quizHelper: AddonModQuizHelperProvider, protected quizSync: AddonModQuizSyncProvider,
|
||||
protected questionHelper: CoreQuestionHelperProvider, protected cdr: ChangeDetectorRef,
|
||||
modalCtrl: ModalController, protected navCtrl: NavController) {
|
||||
modalCtrl: ModalController, protected navCtrl: NavController, protected mmApp: MoodleMobileApp) {
|
||||
|
||||
this.quizId = navParams.get('quizId');
|
||||
this.courseId = navParams.get('courseId');
|
||||
|
@ -157,6 +158,13 @@ export class AddonModQuizPlayerPage implements OnInit, OnDestroy {
|
|||
return Promise.resolve();
|
||||
}
|
||||
|
||||
/**
|
||||
* Runs when the page is about to leave and no longer be the active page.
|
||||
*/
|
||||
ionViewWillLeave(): void {
|
||||
this.mmApp.closeModal();
|
||||
}
|
||||
|
||||
/**
|
||||
* Abort the quiz.
|
||||
*/
|
||||
|
|
|
@ -38,10 +38,10 @@ export class MoodleMobileApp implements OnInit {
|
|||
protected lastUrls = {};
|
||||
protected lastInAppUrl: string;
|
||||
|
||||
constructor(private platform: Platform, logger: CoreLoggerProvider, keyboard: Keyboard,
|
||||
constructor(private platform: Platform, logger: CoreLoggerProvider, keyboard: Keyboard, private app: IonicApp,
|
||||
private eventsProvider: CoreEventsProvider, private loginHelper: CoreLoginHelperProvider, private zone: NgZone,
|
||||
private appProvider: CoreAppProvider, private langProvider: CoreLangProvider, private sitesProvider: CoreSitesProvider,
|
||||
private screenOrientation: ScreenOrientation, app: IonicApp, private urlSchemesProvider: CoreCustomURLSchemesProvider,
|
||||
private screenOrientation: ScreenOrientation, private urlSchemesProvider: CoreCustomURLSchemesProvider,
|
||||
private utils: CoreUtilsProvider, private urlUtils: CoreUrlUtilsProvider) {
|
||||
this.logger = logger.getInstance('AppComponent');
|
||||
|
||||
|
@ -68,15 +68,7 @@ export class MoodleMobileApp implements OnInit {
|
|||
|
||||
// Register back button action to allow closing modals before anything else.
|
||||
this.appProvider.registerBackButtonAction(() => {
|
||||
// Following function is hidden in Ionic Code, however there's no solution for that.
|
||||
const portal = app._getActivePortal();
|
||||
if (portal) {
|
||||
portal.pop();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
return this.closeModal();
|
||||
}, 2000);
|
||||
});
|
||||
|
||||
|
@ -302,4 +294,21 @@ export class MoodleMobileApp implements OnInit {
|
|||
document.body.classList.remove(tempClass);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Close one modal if any.
|
||||
*
|
||||
* @return {boolean} True if one modal was present.
|
||||
*/
|
||||
closeModal(): boolean {
|
||||
// Following function is hidden in Ionic Code, however there's no solution for that.
|
||||
const portal = this.app._getActivePortal();
|
||||
if (portal) {
|
||||
portal.pop();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue