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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
import {Component, ViewChild} from '@angular/core';
import {IonicPage, NavController, NavParams, Slides, ToastController} from 'ionic-angular';
import {AppService} from "../../../../service/http.service";
import {message} from "../../../../app/main";
import {LearnService} from "../learn.service";
import {CommonService} from "../../../../provide/common.service";
@IonicPage()
@Component({
selector: 'page-review-learn',
templateUrl: 'review-learn.html',
})
export class ReviewLearnPage {
@ViewChild(Slides) slides: Slides;
title; //测试标题
list = [];
index = 0; //当前题目的序号
score; //得分
error;
errorContent;
constructor(public navCtrl: NavController, public navParams: NavParams,public learnSer:LearnService,
public toastCtrl:ToastController,public appService:AppService,public commonSer:CommonService) {
}
ionViewDidLoad() {
const recordId = this.navParams.get('recordId');
this.score = this.navParams.get('score');
this.title = this.navParams.get('title');
const data = {
recordId:recordId,
}
this.learnSer.viewAnswerDetail(data).subscribe(
(res)=>{
this.list = res.data;
this.list.forEach(e=>{
if(e.questionType == 4){
e.options = [
{option:'A', comment:'是'},
{option:'B', comment:'否'},
];
e.myAnswer = e.myAnswer == '1'?'A':'B';
e.correctAnswer = e.correctAnswer == '1'?'A':'B';
}
if(e.questionType == 1 || e.questionType == 2 || e.questionType == 4){
e.options.forEach(s=>{
if(e.correctAnswer.includes(s.option)){
s.answer = 'right';
}else if(!e.correctAnswer.includes(s.option) && e.myAnswer.includes(s.option)){
s.answer = 'error'
}else{
s.answer = 'normal'
}
})
}
})
console.log(this.list)
}
)
}
slideChanged(){
this.index = this.slides.realIndex;
}
//上一题
prev() {
if (this.index == 0) {
const toast = this.toastCtrl.create(message);
toast.setMessage('已经是第一题哦');
toast.present();
} else {
this.index -= 1;
this.slides.slideTo(this.index)
}
}
//下一题
next() {
if (this.index == this.list.length -1) {
const toast = this.toastCtrl.create(message);
toast.setMessage('已经是最后一题了哦');
toast.present();
} else {
this.index += 1;
this.slides.slideTo(this.index)
}
}
//只看错题
lookError(){
this.index = 1;
this.slides.slideTo(this.index-1)
let arr = [];
this.list.map(e=>{
if(e.result == 0){
arr.push(e);
}
});
if(arr.length == 0){
this.commonSer.toast("恭喜您获得满分,无错题!")
}else{
this.list = arr;
}
}
//纠错
sure(){
const data = {
questionId:this.list[this.index].questionId,
questionType:this.list[this.index].questionType,
content:this.errorContent
};
this.commonSer.log(data);
this.learnSer.questionCorrecting(data).subscribe(
(res)=>{
this.commonSer.toast("提交成功!");
this.error = false;
}
)
}
cancel(){
this.error = false;
this.errorContent = "";
}
}