Skip to content
learning-explain.ts 1.52 KiB
Newer Older
wangqinghua's avatar
wangqinghua committed
import {Component} from '@angular/core';
import {IonicPage, NavController, NavParams} from 'ionic-angular';
import {LearningDoPage} from "../learning-do/learning-do";
import {LearnService} from "../learn.service";
import {AppGlobal, AppService} from "../../../../service/http.service";
import {CommonService} from "../../../../provide/common.service";

@IonicPage()
@Component({
    selector: 'page-learning-explain',
    templateUrl: 'learning-explain.html',
})
export class LearningExplainPage {

    testId;
    title;
    item = {
        questionCount: 0,
        fullMarks: 0,
        timeLimit: 0,
        testId:null,
        score:0,
    };  //测试对象
    constructor(public navCtrl: NavController, public navParams: NavParams,
                public learnSer: LearnService,public commonSer:CommonService) {
    }

    ionViewDidLoad() {
        const item = this.navParams.get('item');
        this.title = item.title;
        this.testId = item.testId;
        const data = {
            testId: this.testId
        };
        this.learnSer.startTest(data).subscribe(
            (res) => {
                this.item = res.data;
                this.item.score = Math.floor(this.item.fullMarks *0.6);
            }
        )
    }

    //跳转答题页面
    goToDO() {
        if(this.item.questionCount > 0){
            this.navCtrl.push("LearningDoPage", {
                testId: this.testId,
                title:this.title
            });
        }else{
            this.commonSer.toast('当前试卷试题为空');
        }
    }

}