mirror of
https://codeup.aliyun.com/67762337eccfc218f6110e0e/vue/learning-system-mobile.git
synced 2025-12-07 01:46:44 +08:00
2022年5月29日 从svn移到git
This commit is contained in:
206
components/course-exam/course-exam.vue
Normal file
206
components/course-exam/course-exam.vue
Normal file
@@ -0,0 +1,206 @@
|
||||
<template>
|
||||
<view>
|
||||
<u-toast ref="messager"></u-toast>
|
||||
<view v-if="has" class="paperinfo">
|
||||
<view class="paperinfo-item">
|
||||
<u-cell-group>
|
||||
<u-cell title="考试时长" :value="info.testDuration+'分钟'"></u-cell>
|
||||
<u-cell title="及格线" :value="info.passLine"></u-cell>
|
||||
<u-cell v-if="studyItemId!=''" title="考试成绩" :value="lastScore"></u-cell>
|
||||
<!--应该再显示最终成绩,最高一次或最后一次得分-->
|
||||
</u-cell-group>
|
||||
</view>
|
||||
<view style="padding: 20px;">
|
||||
<u-button @click="startTest" type="primary" text="开始考试"></u-button>
|
||||
</view>
|
||||
<!--考试记录-->
|
||||
<view>
|
||||
<view class="endurance" v-for="(item,idx) in records" :key="idx" @click="toExamDetail(item)">
|
||||
<view class="exam">提交时间:{{item.lastTime}}</view>
|
||||
<view class="endurance-cen">
|
||||
<view>
|
||||
<view style="display: flex;margin-top: 9px;">
|
||||
<view class="schedule">考试成绩:</view>
|
||||
<view class="schscore">{{item.score}}分</view>
|
||||
</view>
|
||||
<view style="display: flex;margin-top: 6px;">
|
||||
<view class="patiently">考试用时</view>
|
||||
<view class="patientlys" style="">{{item.testDuration}}秒</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view v-else style="text-align: center;color: #ff0000;padding-top: 20px; ">
|
||||
此课程没有考试
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import apiStudy from '@/api/modules/courseStudy.js';
|
||||
import apiCourse from '@/api/modules/course.js';
|
||||
import {formatDate,getQuestionType,correctJudgment,numberToLetter} from '@/utils/tools.js';
|
||||
export default {
|
||||
props:{
|
||||
studyId: {
|
||||
type: String,
|
||||
},
|
||||
courseType:{
|
||||
type:Number,
|
||||
required:true
|
||||
},
|
||||
showRecord:{
|
||||
type:Boolean,
|
||||
default:true
|
||||
},
|
||||
showSubmit:{
|
||||
type:Boolean,
|
||||
default:true
|
||||
},
|
||||
content: {
|
||||
type: Object,
|
||||
default:()=>{}
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
correctJudgment:correctJudgment,
|
||||
show:0,
|
||||
toLetter:numberToLetter,
|
||||
testType:getQuestionType,
|
||||
has:true,
|
||||
startTime:null,
|
||||
testStart: false,
|
||||
info:{},
|
||||
paper:[],
|
||||
lastScore:0,//最终得分
|
||||
studyItemId:'',
|
||||
records:[] ,//考试记录
|
||||
allowSubmit:true,//是否允许考试,尝试次数达到后不能再考试
|
||||
};
|
||||
},
|
||||
mounted() {
|
||||
this.loadExamInfo();
|
||||
},
|
||||
watch:{
|
||||
studyId(newVal){
|
||||
this.loadRecord();
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
loadExamInfo(){
|
||||
apiCourse.getExam(this.content.id).then(res=>{
|
||||
if(res.status==200){
|
||||
this.info=res.result;
|
||||
|
||||
}else if(res.status==404){
|
||||
//没有找到考试信息
|
||||
}else{
|
||||
this.$refs.messager.show({message:res.message,type:'error'});
|
||||
}
|
||||
})
|
||||
},
|
||||
loadExamContent(){
|
||||
apiStudy.getStudyContentItem(this.studyId,this.content.id).then(rs=>{
|
||||
if(rs.status==200){
|
||||
this.lastScore=rs.result.score;
|
||||
this.studyItemId=rs.result.id;
|
||||
}
|
||||
});
|
||||
},
|
||||
loadRecord(){
|
||||
if(this.studyId==''){
|
||||
return;
|
||||
}
|
||||
this.loadExamContent();
|
||||
if(this.records.length==0){
|
||||
let params={
|
||||
studyId:this.studyId,
|
||||
contentId:this.content.id
|
||||
}
|
||||
apiStudy.myExamList2(params).then(examRs=>{
|
||||
if(examRs.status==200){
|
||||
this.records=examRs.result;
|
||||
let len=examRs.result.length;
|
||||
if(this.info.times>len){
|
||||
this.allowSubmit=true;
|
||||
}else{
|
||||
this.allowSubmit=false;
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
},
|
||||
startTest(){
|
||||
//转向详细页面
|
||||
uni.redirectTo({
|
||||
url:'/pages/study/exam?studyId='+this.studyId+'&ctype='+this.courseType+'&ccid='+this.content.id
|
||||
})
|
||||
},
|
||||
toExamDetail(item){
|
||||
uni.navigateTo({
|
||||
url:'/pages/study/examDetail?id='+item.id
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.paperinfo{
|
||||
padding-top: 10px;
|
||||
.paperinfo-title{
|
||||
text-align: center;
|
||||
font-size: 30upx;
|
||||
font-weight: 600;
|
||||
padding: 10px;
|
||||
}
|
||||
.paperinfo-item{
|
||||
background-color: #FFFFFF;
|
||||
}
|
||||
}
|
||||
.endurance{
|
||||
height: 90px;
|
||||
background: #FFFFFF;
|
||||
margin-top: 10px;
|
||||
padding-bottom: 10px;
|
||||
.exam{
|
||||
font-size: 15px;
|
||||
color: #5EB6A4;
|
||||
padding-top: 15px;
|
||||
margin-left: 15px;
|
||||
}
|
||||
|
||||
.endurance-cen{
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
margin-right: 11px;
|
||||
|
||||
.schedule{
|
||||
font-size: 14px;
|
||||
color: #868686;
|
||||
margin-left: 16px;
|
||||
}
|
||||
|
||||
.schscore{
|
||||
font-size: 14px;
|
||||
color: #000000;
|
||||
margin-left: 13px;
|
||||
}
|
||||
|
||||
.patiently{
|
||||
font-size: 14px;
|
||||
color: #868686;
|
||||
margin-left: 16px;
|
||||
}
|
||||
|
||||
.patientlys{
|
||||
font-size: 14px;
|
||||
color: #000000;
|
||||
margin-left: 13px;
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user