Skip to content
review-result.ts 2.43 KiB
Newer Older
wangqinghua's avatar
wangqinghua committed
import {Component, ViewChild} from '@angular/core';
import {IonicPage, Navbar, NavController, NavParams, Slides, ToastController} from 'ionic-angular';
import {message} from "../../../../app/main";
import {LearnService} from "../learn.service";
import {AppService} from "../../../../service/http.service";
import {EmitService} from "../../../../provide/emit.service";

@IonicPage()
@Component({
    selector: 'page-review-result',
    templateUrl: 'review-result.html',
})
export class ReviewResultPage {
    @ViewChild(Navbar) navbar: Navbar;

    testId;
    title;
    result;

    starList = [];

    constructor(public navCtrl: NavController, public navParams: NavParams,
                public learnSer: LearnService, public eventEmitSer: EmitService) {
    }

    ionViewDidEnter() {
        //发射物理键返回 返回列表的信息
        this.eventEmitSer.eventEmit.emit('result');
    }

    ionViewDidLoad() {
        this.testId = this.navParams.get('testId');
        this.result = this.navParams.get('result');
        this.title = this.navParams.get('title');
        let c = this.result.score / this.result.fullmarks;
        //一颗星代表80%以下,两颗星80%-90%(不含90%),三颗星90%-100%以上
        if (this.result.score == 0) {
            this.starList = [{class: 'star-gray'}, {class: 'star-gray'}, {class: 'star-gray'},];
        }
        if (0 < c && c < 0.8 ) {
            this.starList = [{class: 'star-yellow'}, {class: 'star-gray'}, {class: 'star-gray'},];
        }
        if ( c == 0.8 ) {
            this.starList = [{class: 'star-yellow'}, {class: 'star-gray'}, {class: 'star-gray'},];
        }
        if (0.8 < c && c < 0.9) {
            this.starList = [{class: 'star-yellow'}, {class: 'star-yellow'}, {class: 'star-gray'},];
        }
        if (0.9 < c || c == 0.9) {
            this.starList = [{class: 'star-yellow'}, {class: 'star-yellow'}, {class: 'star-yellow'},];
        }
        this.navbar.backButtonClick = (event) => {
            let index = this.navCtrl.length() - 2;
            this.navCtrl.remove(2, index)
        }
    }

    //测试回顾
    reviewTest() {
        this.navCtrl.push("ReviewLearnPage", {
            recordId: this.result.recordId,
            score: this.result.score
        })
    }

    //重新测试
    resetTest() {
        this.navCtrl.push('LearningDoPage', {
            testId: this.testId,
            title: this.title,
            type: 'reset'
        });
    }
}