Commit cf0b4e52 authored by wangqinghua's avatar wangqinghua

结果页面

parent ad6e761b
...@@ -32,6 +32,7 @@ ...@@ -32,6 +32,7 @@
1、node版本装8.9.0 的 不然跑不起来 1、node版本装8.9.0 的 不然跑不起来
2、http文件里面的请求改成本地请求的方式 本地跑 2、http文件里面的请求改成本地请求的方式 本地跑
3、这个项目的接口基本都是用form表单提交的 3、这个项目的接口基本都是用form表单提交的
4.ionic.config.json 文件是本地配置跨域问题的nginx文件 service 里面的domain参数要设置
******常见问题****** ******常见问题******
如果build android 报错了请在platforms/build.gradle里面的最后添加如下代码: 如果build android 报错了请在platforms/build.gradle里面的最后添加如下代码:
......
...@@ -23,4 +23,14 @@ export class LearnService{ ...@@ -23,4 +23,14 @@ export class LearnService{
submitPaper(data): Observable<any>{ submitPaper(data): Observable<any>{
return this.http.post(AppGlobal.domain+'/wisdomgroup/modules/learnTest/submitPaper',data) return this.http.post(AppGlobal.domain+'/wisdomgroup/modules/learnTest/submitPaper',data)
} }
//查看测试页面
viewTestResult(data): Observable<any>{
return this.http.post(AppGlobal.domain+'/wisdomgroup/modules/learnTest/viewTestResult',this.commonSer.toFormData(data));
}
//查看题目页面
viewAnswerDetail(data): Observable<any>{
return this.http.post(AppGlobal.domain+'/wisdomgroup/modules/learnTest/viewAnswerDetail',this.commonSer.toFormData(data));
}
} }
\ No newline at end of file
...@@ -124,7 +124,9 @@ page-learning-do { ...@@ -124,7 +124,9 @@ page-learning-do {
margin-right: 5px; margin-right: 5px;
color: #666; color: #666;
font-size: 1.5rem; font-size: 1.5rem;
position: relative;
} }
input:checked +.selectIndex{ input:checked +.selectIndex{
background-color: #ec1826; background-color: #ec1826;
color: #ffffff; color: #ffffff;
......
...@@ -16,8 +16,10 @@ export class LearningDoPage { ...@@ -16,8 +16,10 @@ export class LearningDoPage {
@ViewChild(Slides) slides: Slides; @ViewChild(Slides) slides: Slides;
@ViewChild(Navbar) navbar: Navbar @ViewChild(Navbar) navbar: Navbar
type; //是否重做
title; // 问卷标题 title; // 问卷标题
recordId; recordId; //试卷记录ID
testId; //试卷ID
clock; //倒计时的定时器 clock; //倒计时的定时器
list = []; list = [];
timeText = '00:00:00'; timeText = '00:00:00';
...@@ -29,10 +31,11 @@ export class LearningDoPage { ...@@ -29,10 +31,11 @@ export class LearningDoPage {
} }
ionViewDidEnter() { ionViewDidEnter() {
const testId = this.navParams.get('testId'); this.testId = this.navParams.get('testId');
this.title = this.navParams.get('title'); this.title = this.navParams.get('title');
this.type = this.navParams.get('type');
const data = { const data = {
testId: testId testId: this.testId
}; };
this.learnSer.startTest(data).subscribe( this.learnSer.startTest(data).subscribe(
(res) => { (res) => {
...@@ -60,7 +63,6 @@ export class LearningDoPage { ...@@ -60,7 +63,6 @@ export class LearningDoPage {
//倒计时 //倒计时
countTime() { countTime() {
let totalTime = this.totalTime; let totalTime = this.totalTime;
this.useTime = this.totalTime;
this.clock = window.setInterval(() => { this.clock = window.setInterval(() => {
totalTime--; totalTime--;
this.useTime ++; this.useTime ++;
...@@ -106,11 +108,10 @@ export class LearningDoPage { ...@@ -106,11 +108,10 @@ export class LearningDoPage {
//多选 //多选
mutiSelect(i, option) { mutiSelect(i, option) {
console.log(option);
if (this.list[i].answer.includes(option)) { if (this.list[i].answer.includes(option)) {
this.list[i].answer = this.list[i].answer.replace(option, ''); this.list[i].answer = this.list[i].answer.replace(option, '');
} else { } else {
this.list[i].answer += option + ","; this.list[i].answer += option + ";";
} }
} }
...@@ -141,30 +142,38 @@ export class LearningDoPage { ...@@ -141,30 +142,38 @@ export class LearningDoPage {
} }
submit(){ submit(){
const data = { if(this.type == 'reset'){
listMap: this.list.map(e => { this.navCtrl.push("LearningResultPage",{
if (e.answer.length > 1) { testId:this.testId,
e.answer = e.answer.substr(0, e.answer.length - 1); title:this.title
});
}else{
const data = {
listMap: this.list.map(e => {
if (e.answer.length > 1) {
e.answer = e.answer.substr(0, e.answer.length - 1);
}
const d = {
questionId: e.questionId,
questionType: e.questionType,
answer: e.answer
};
return d;
}),
recordId: this.recordId,
answerTime: this.useTime,
};
this.learnSer.submitPaper(data).subscribe(
(res) => {
this.commonSer.toast("提交成功");
this.navCtrl.push("LearningResultPage",{
testId:this.testId,
title:this.title
})
} }
const d = { )
questionId: e.questionId, }
questionType: e.questionType,
answer: e.answer
};
return d;
}),
recordId: this.recordId,
answerTime: this.useTime,
};
this.learnSer.submitPaper(data).subscribe(
(res) => {
this.commonSer.toast("提交成功");
this.navCtrl.push("LearningResultPage",{
result:res.data,
title:this.title
})
}
)
} }
} }
...@@ -10,6 +10,6 @@ ...@@ -10,6 +10,6 @@
<ion-content> <ion-content>
<p class="explain margin-top-100">本次答题共计{{item?.questionCount}}题,满分{{item?.fullMarks}}分</p> <p class="explain margin-top-100">本次答题共计{{item?.questionCount}}题,满分{{item?.fullMarks}}分</p>
<p class="explain margin-top-20">时间:{{item?.timeLimit | formatTime}}</p> <p class="explain margin-top-20">时间:{{item?.timeLimit | formatTime}}</p>
<p class="explain margin-top-20">分数超过{{item?.fullMarks *0.6}}分合格</p> <p class="explain margin-top-20">分数超过{{item?.fullMarks}}分合格</p>
<button class="submit-btn submit" (click)="goToDO()">开始答题</button> <button class="submit-btn submit" (click)="goToDO()">开始答题</button>
</ion-content> </ion-content>
...@@ -16,7 +16,7 @@ export class LearningExplainPage { ...@@ -16,7 +16,7 @@ export class LearningExplainPage {
title; title;
item = { item = {
questionCount: 0, questionCount: 0,
fullMarks: '0', fullMarks: 0,
timeLimit: 0, timeLimit: 0,
testId:null testId:null
}; //测试对象 }; //测试对象
...@@ -34,6 +34,7 @@ export class LearningExplainPage { ...@@ -34,6 +34,7 @@ export class LearningExplainPage {
this.learnSer.startTest(data).subscribe( this.learnSer.startTest(data).subscribe(
(res) => { (res) => {
this.item = res.data; this.item = res.data;
this.item.fullMarks = Math.floor(this.item.fullMarks *0.6);
} }
) )
} }
......
...@@ -28,14 +28,14 @@ export class LearningListPage { ...@@ -28,14 +28,14 @@ export class LearningListPage {
public learnSer: LearnService, public datePipe: DatePipe) { public learnSer: LearnService, public datePipe: DatePipe) {
} }
ionViewDidLoad() { ionViewDidEnter() {
let itemWidth = window.screen.width / 3; let itemWidth = window.screen.width / 3;
this.tips.nativeElement.style.left = itemWidth / 2 - this.tips.nativeElement.offsetWidth / 2 + 'px'; this.tips.nativeElement.style.left = itemWidth / 2 - this.tips.nativeElement.offsetWidth / 2 + 'px';
this.getList(); this.getList();
} }
getList() { getList() {
const nowDate = this.datePipe.transform(new Date(), 'yyyy/MM/dd HH:hh:ss') const nowDate = this.datePipe.transform(new Date(), 'yyyy/MM/dd HH:mm:ss')
const data = { const data = {
pageNumber:this.pageNumber, pageNumber:this.pageNumber,
pageSize:this.pageSize, pageSize:this.pageSize,
...@@ -114,7 +114,8 @@ export class LearningListPage { ...@@ -114,7 +114,8 @@ export class LearningListPage {
}) })
}else{ }else{
this.navCtrl.push("LearningResultPage", { this.navCtrl.push("LearningResultPage", {
item: item testId: item.testId,
title:item.title
}) })
} }
......
import {Component, ViewChild} from '@angular/core'; import {Component, ViewChild} from '@angular/core';
import {IonicPage, Navbar, NavController, NavParams} from 'ionic-angular'; import {IonicPage, Navbar, NavController, NavParams} from 'ionic-angular';
import {ReviewLearnPage} from "../review-learn/review-learn"; import {ReviewLearnPage} from "../review-learn/review-learn";
import {LearnService} from "../learn.service";
@IonicPage() @IonicPage()
@Component({ @Component({
...@@ -9,22 +10,48 @@ import {ReviewLearnPage} from "../review-learn/review-learn"; ...@@ -9,22 +10,48 @@ import {ReviewLearnPage} from "../review-learn/review-learn";
}) })
export class LearningResultPage { export class LearningResultPage {
@ViewChild(Navbar) navbar:Navbar; @ViewChild(Navbar) navbar:Navbar;
result; testId;
title; title;
result;
starList = [ starList = [
{class: 'star-yellow'}, {class: 'star-yellow'},
{class: 'star-yellow'}, {class: 'star-yellow'},
{class: 'star-gray'}, {class: 'star-yellow'},
] ];
constructor(public navCtrl: NavController, public navParams: NavParams) { constructor(public navCtrl: NavController, public navParams: NavParams,
public learnSer:LearnService) {
} }
ionViewDidLoad() { ionViewDidLoad() {
this.result = this.navParams.get('result'); this.testId = this.navParams.get('testId');
this.title = this.navParams.get('title'); this.title = this.navParams.get('title');
console.log(this.result); const data = {
testId:this.testId
};
this.learnSer.viewTestResult(data).subscribe(
(res)=>{
this.result = res.data;
let c = this.result.score/this.result.fullmarks;
console.log(c)
if(this.result.score == 0){
this.starList = [{class: 'star-gray'}, {class: 'star-gray'}, {class: 'star-gray'},];
}
if( 0.6 > c && c > 0.3){
this.starList = [{class: 'star-yellow'}, {class: 'star-gray'}, {class: 'star-gray'},];
}
if( 0.3 > c && c > 0){
this.starList = [{class: 'star-yellow'}, {class: 'star-gray'}, {class: 'star-gray'},];
}
if( 1 > c && c > 0.6){
this.starList = [{class: 'star-yellow'}, {class: 'star-yellow'}, {class: 'star-gray'},];
}
if( this.result.score == this.result.fullmarks){
this.starList = [{class: 'star-yellow'}, {class: 'star-yellow'}, {class: 'star-yellow'},];
}
}
)
this.navbar.backButtonClick = (event)=>{ this.navbar.backButtonClick = (event)=>{
let index = this.navCtrl.length() -2; let index = this.navCtrl.length() -2;
this.navCtrl.remove(2,index) this.navCtrl.remove(2,index)
...@@ -33,11 +60,18 @@ export class LearningResultPage { ...@@ -33,11 +60,18 @@ export class LearningResultPage {
//测试回顾 //测试回顾
reviewTest() { reviewTest() {
this.navCtrl.push("ReviewLearnPage") this.navCtrl.push("ReviewLearnPage",{
recordId:this.result.recordId,
score:this.result.score
})
} }
//重新测试 //重新测试
resetTest() { resetTest() {
this.navCtrl.pop() this.navCtrl.push('LearningDoPage',{
testId: this.testId,
title:this.title,
type:'reset'
});
} }
} }
...@@ -17,64 +17,71 @@ ...@@ -17,64 +17,71 @@
<!--判断题目类型--> <!--判断题目类型-->
<p> <p>
<span class="color-red" *ngIf="item.isAns == 1">*</span>{{index}}、 <span class="color-red" *ngIf="item.isAns == 1">*</span>{{index}}、
<span *ngIf="item.quesType == 1">(判断)</span> <span *ngIf="item.questionType == 1">(单选)</span>
<span *ngIf="item.quesType == 2">(单选)</span> <span *ngIf="item.questionType == 2">(多选)</span>
<span *ngIf="item.quesType == 3">(多选)</span> <span *ngIf="item.questionType == 3">(填空)</span>
<span *ngIf="item.quesType == 4">(填空)</span> <span *ngIf="item.questionType == 4">(判断)</span>
<span *ngIf="item.quesType == 5">(问答)</span> <span *ngIf="item.questionType == 5">(问答)</span>
{{item.title}} {{item.questionContent}}
</p> </p>
</div> </div>
<div class="ans-tips"> <div class="ans-tips">
<span class="ans-green">回答正确</span> <span *ngIf="item.result == 1" class="ans-green">回答正确</span>
<span class="ans-red">回答错误</span> <span *ngIf="item.result == 0" class="ans-red">回答错误</span>
<span class="margin-left-20">您的答案:{{item.myAnswer}}</span>
</div> </div>
<div class="item-content"> <div class="item-content">
<div class="padding-0-30"> <div class="padding-0-30">
<!--单选题--> <!--单选题-->
<ng-container *ngIf="item.quesType == 1"> <ng-container *ngIf="item.questionType == 1">
<p> <ng-container *ngFor=" let option1 of item.options;let optIndex = index;">
<label>
<input [(ngModel)]="item.answerdesc" name="{{item.questionQueId}}" value="0" type="radio">
<span class="input-radio"></span>
</label>
</p>
<p>
<label>
<input [(ngModel)]="item.answerdesc" name="{{item.questionQueId}}" value="1" type="radio">
<span class="input-radio"></span>
</label>
</p>
</ng-container>
<!--多选题-->
<ng-container *ngIf="item.quesType == 2">
<ng-container *ngFor=" let option1 of item.quesDesc;let optIndex = index;">
<p> <p>
<label> <label>
<input [(ngModel)]="item.answerdesc" type="radio" value="{{optIndex}}" name="{{item.questionQueId}}">{{option1.option_title}} <input [(ngModel)]="item.answer" disabled type="radio" [value]="option1.option" [name]="item.questionId">
<span class="input-radio"></span> <span class="selectIndex" [ngClass]="{'select-right' : option1.answer == 'right',
'select-error':option1.answer == 'error'}">{{option1.option}}</span>&nbsp;&nbsp;
{{option1.comment}}
</label> </label>
</p> </p>
</ng-container> </ng-container>
</ng-container> </ng-container>
<!--判断题--> <!--多选题-->
<ng-container *ngIf="item.quesType == 3"> <ng-container *ngIf="item.questionType == 2">
<ng-container *ngFor=" let option2 of item.quesDesc;let quesIndex = index;"> <ng-container *ngFor=" let option2 of item.options;let quesIndex = index;">
<p> <p>
<label> <label>
<input type="checkbox" (change)="mutiSelect(i,quesIndex)" value="{{quesIndex}}">{{option2.option_title}} <input type="checkbox" (change)="mutiSelect(i,option2.option)" [value]="quesIndex" [name]="item.questionId">
<span class="input-check"></span> <span class="selectIndex" [ngClass]="{'select-right' : option2.answer == 'right',
'select-error':option2.answer == 'error'}">{{option2.option}}</span>&nbsp;&nbsp;
{{option2.comment}}
</label> </label>
</p> </p>
</ng-container> </ng-container>
</ng-container> </ng-container>
<!--填空--> <!--填空-->
<ng-container *ngIf="item.quesType == 4"> <ng-container *ngIf="item.questionType == 3">
<textarea [(ngModel)]="item.answerdesc" class="content-textarea"></textarea> <textarea disabled [(ngModel)]="item.myAnswer" class="content-textarea"></textarea>
</ng-container>
<!--判断题-->
<ng-container *ngIf="item.questionType == 4">
<p>
<label>
<input [(ngModel)]="item.answer" [name]="item.questionQueId" value="A type="radio">
<span class=" selectIndex">A</span>&nbsp;&nbsp;
</label>
</p>
<p>
<label>
<input [(ngModel)]="item.answer" [name]="item.questionQueId" value="B" type="radio">
<span class=" selectIndex">B</span>&nbsp;&nbsp;
</label>
</p>
</ng-container> </ng-container>
<!--问答--> <!--问答-->
<ng-container *ngIf="item.quesType == 5"> <ng-container *ngIf="item.questionType == 5">
<textarea [(ngModel)]="item.answerdesc" class="content-textarea"></textarea> <textarea [(ngModel)]="item.answer" class="content-textarea"></textarea>
</ng-container> </ng-container>
</div> </div>
</div> </div>
...@@ -89,8 +96,8 @@ ...@@ -89,8 +96,8 @@
<div (click)="next()" class="next">下一题</div> <div (click)="next()" class="next">下一题</div>
</div> </div>
<div class="footer-submit"> <div class="footer-submit">
<div class="time">答题得分&nbsp;&nbsp;80</div> <div class="time">答题得分&nbsp;&nbsp;{{score}}</div>
<div class="submit" (click)="submit()"> <div class="submit" (click)="lookError()">
<span>只看错题</span> <span>只看错题</span>
</div> </div>
</div> </div>
......
import { NgModule } from '@angular/core'; import {NgModule} from '@angular/core';
import { IonicPageModule } from 'ionic-angular'; import {IonicPageModule} from 'ionic-angular';
import { ReviewLearnPage } from './review-learn'; import {ReviewLearnPage} from './review-learn';
import {PipesModule} from "../../../../pipes/pipes.module";
@NgModule({ @NgModule({
declarations: [ declarations: [
ReviewLearnPage, ReviewLearnPage,
], ],
imports: [ imports: [
IonicPageModule.forChild(ReviewLearnPage), PipesModule,
], IonicPageModule.forChild(ReviewLearnPage),
],
}) })
export class ReviewLearnPageModule {} export class ReviewLearnPageModule {
}
...@@ -37,6 +37,9 @@ page-review-learn { ...@@ -37,6 +37,9 @@ page-review-learn {
} }
.item-content { .item-content {
padding: 1rem; padding: 1rem;
p{
margin: 1rem 0;
}
} }
.footer-subject { .footer-subject {
padding: 0 1rem; padding: 0 1rem;
...@@ -100,6 +103,26 @@ page-review-learn { ...@@ -100,6 +103,26 @@ page-review-learn {
margin-left: 2rem; margin-left: 2rem;
border-radius: 4px; border-radius: 4px;
} }
.selectIndex{
position: relative;
}
.select-right::before{
content: '\2713';
position: absolute;
left: -24px;
top: -4px;
transform: rotate(7deg);
color: #50b632;
font-size: 2.5rem;
}
.select-error::before{
content: '\2718';
position: absolute;
left: -20px;
top: 0;
color: #ec1826;
font-size: 2rem;
}
.item-ios p { .item-ios p {
margin: 15px 0; margin: 15px 0;
white-space: normal; white-space: normal;
...@@ -123,7 +146,7 @@ page-review-learn { ...@@ -123,7 +146,7 @@ page-review-learn {
} }
} }
input:checked + .input-radio::after { input:checked + .input-radio::after {
content: '2713'; content: '\2713';
position: absolute; position: absolute;
width: 10px; width: 10px;
top: 2px; top: 2px;
......
...@@ -2,6 +2,7 @@ import {Component, ViewChild} from '@angular/core'; ...@@ -2,6 +2,7 @@ import {Component, ViewChild} from '@angular/core';
import {IonicPage, NavController, NavParams, Slides, ToastController} from 'ionic-angular'; import {IonicPage, NavController, NavParams, Slides, ToastController} from 'ionic-angular';
import {AppService} from "../../../../service/appHttpService"; import {AppService} from "../../../../service/appHttpService";
import {message} from "../../../../app/main"; import {message} from "../../../../app/main";
import {LearnService} from "../learn.service";
@IonicPage() @IonicPage()
...@@ -12,20 +13,38 @@ import {message} from "../../../../app/main"; ...@@ -12,20 +13,38 @@ import {message} from "../../../../app/main";
export class ReviewLearnPage { export class ReviewLearnPage {
@ViewChild(Slides) slides: Slides; @ViewChild(Slides) slides: Slides;
list = [ list = [];
{title:"你最喜欢玩的游戏是什么?",quesType:'1',option:[{ans:"苹果",index:1},{ans:"香蕉",index:2},{ans:"梨",index:3},]}, //单选题
{title:"你最喜欢吃的水果是什么",quesType:'2',option:[{ans:"苹果",index:1},{ans:"香蕉",index:2},{ans:"梨",index:3},]}, //多选题
{title:"你最喜欢玩的地方是什么?",quesType:'3'}, //判断题
{title:"你最喜欢什么手机?",quesType:'4'}, //填空题
{title:"你最喜欢什么耳机?",quesType:'5'} //问答题
];
index = 1; //当前题目的序号 index = 1; //当前题目的序号
constructor(public navCtrl: NavController, public navParams: NavParams, score; //得分
constructor(public navCtrl: NavController, public navParams: NavParams,public learnSer:LearnService,
public toastCtrl:ToastController,public appService:AppService) { public toastCtrl:ToastController,public appService:AppService) {
} }
ionViewDidLoad() { ionViewDidLoad() {
console.log('ionViewDidLoad LearningDoPage'); const recordId = this.navParams.get('recordId');
this.score = this.navParams.get('score');
const data = {
recordId:recordId,
}
this.learnSer.viewAnswerDetail(data).subscribe(
(res)=>{
this.list = res.data;
this.list.forEach(e=>{
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);
}
)
} }
//上一题 //上一题
...@@ -53,10 +72,16 @@ export class ReviewLearnPage { ...@@ -53,10 +72,16 @@ export class ReviewLearnPage {
} }
//只看错题 //只看错题
submit(){ lookError(){
this.appService.alert("确定提交问卷",()=>{ this.index = 1;
this.navCtrl.push("LearningResultPage") this.slides.slideTo(this.index-1)
}) let arr = [];
this.list.map(e=>{
if(e.result == 0){
arr.push(e);
}
});
this.list = arr;
} }
} }
...@@ -80,15 +80,6 @@ export class LoginPage { ...@@ -80,15 +80,6 @@ export class LoginPage {
enableBackdropDismiss: true //点击页面其他地方则关闭 正在登录 enableBackdropDismiss: true //点击页面其他地方则关闭 正在登录
}); });
loading.present(); loading.present();
let formData = new FormData()
formData.append('mobile',this.user.mobile);
formData.append('password',this.user.password);
// formData.append('remember',true);
this.loginSer.loginpost(formData).subscribe(
(res)=>{
}
)
this.appService.ObserverHttpPost("/wisdomgroup/app/loginpost", this.user) this.appService.ObserverHttpPost("/wisdomgroup/app/loginpost", this.user)
.subscribe((res: Response) => { .subscribe((res: Response) => {
loading.dismiss(); loading.dismiss();
......
...@@ -14,7 +14,7 @@ export class AppGlobal { ...@@ -14,7 +14,7 @@ export class AppGlobal {
//接口基地址 //接口基地址
// static domain = "http://101.89.112.92:80"; //正式环境 // static domain = "http://101.89.112.92:80"; //正式环境
//测试环境 通过nginx配置 // static domain = "http://180.168.156.212:2931"; //测试环境
static domain = ""; //本地环境 static domain = ""; //本地环境
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment