exercise.page.ts 1.46 KB
Newer Older
1 2 3 4 5 6
/* tslint:disable:no-string-literal */
import {Component, OnInit} from '@angular/core';
import {HelperService} from '../helper.service';
import {NavController} from '@ionic/angular';
import {ActivatedRoute} from '@angular/router';
import {TranslateService} from '@ngx-translate/core';
7
import {ExerciseService} from 'src/app/exercise.service';
8 9 10 11 12 13 14 15 16 17 18 19

@Component({
    selector: 'app-exercise',
    templateUrl: './exercise.page.html',
    styleUrls: ['./exercise.page.scss'],
})
export class ExercisePage implements OnInit {

    HelperService = HelperService;

    constructor(public navCtrl: NavController,
                public activatedRoute: ActivatedRoute,
20 21
                public translateService: TranslateService,
                public exerciseService: ExerciseService) {
22 23
        this.activatedRoute.queryParams.subscribe((params: object) => {
            const exerciseType: string = params['type'];
24 25
            const exerciseTypePath: string = exerciseType === this.exerciseService.vocListString ?
                this.exerciseService.fillBlanksString : exerciseType;
26 27 28 29
            const file: string = params['file'];
            const lang: string = this.translateService.currentLang;
            window.localStorage.setItem(HelperService.config['localStorageKeyH5P'],
                HelperService.baseUrl + '/assets/h5p/' + exerciseType + '/content/' + file + '_' + lang + '.json');
30
            this.exerciseService.initH5P(exerciseTypePath);
31 32 33 34 35 36 37
        });
    }

    ngOnInit() {
    }

}