import {Component} from '@angular/core';
import {IonicPage, NavController, NavParams} from 'ionic-angular';
import {ReadLearnPage} from "../read-learn/read-learn";
import {LearnManageService} from "../learnManage.service";
import {CommonService} from "../../../../provide/common.service";
import {RankListPage} from "../rank-list/rank-list";


@IonicPage()
@Component({
    selector: 'page-learn-detail',
    templateUrl: 'learn-detail.html',
})
export class LearnDetailPage {

    testId;
    test;
    constructor(public navCtrl: NavController, public navParams: NavParams,
                public learnManageSer:LearnManageService,public commonSer:CommonService) {
    }

    ionViewDidLoad() {
        this.testId = this.navParams.get('testId');
        const data = {
            testId:this.testId
        }
        this.learnManageSer.getDetail(data).subscribe(
            (res)=>{
                this.test = res.data;
            }
        )
    }

    //批阅试卷
    gotoRead() {
        if(this.test.markNumber > 0){
            this.navCtrl.push('ReadLearnPage')
        }else{
            this.commonSer.toast("当前试卷无问答题");
        }
    }

    //查看排行榜
    goToRank(){
        this.navCtrl.push('RankListPage',{
            testId:this.testId
        })
    }

}
