Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
import {Component, EventEmitter, ViewChild} from '@angular/core';
import {IonicPage, Nav, Navbar, NavController, NavParams} from 'ionic-angular';
import {ReviewLearnPage} from "../review-learn/review-learn";
import {LearnService} from "../learn.service";
import {EmitService} from "../../../../provide/emit.service";
@IonicPage()
@Component({
selector: 'page-learning-result',
templateUrl: 'learning-result.html',
})
export class LearningResultPage {
@ViewChild(Navbar) navbar: Navbar;
testId; //测试id
title; //测试标题
result; //测试结果
isRepeat; // 是否能够重复测试
starList = [
{class: 'star-yellow'},
{class: 'star-yellow'},
{class: 'star-yellow'},
];
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.title = this.navParams.get('title');
this.isRepeat = this.navParams.get('isRepeat');
const data = {
testId: this.testId
};
this.learnSer.viewTestResult(data).subscribe(
(res) => {
this.result = res.data;
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,
title: this.title,
})
}
//重新测试
resetTest() {
this.navCtrl.push('LearningDoPage', {
testId: this.testId,
title: this.title,
type: 'reset'
});
}
}