提交 d4bb63c3 authored 作者: 王鹏飞's avatar 王鹏飞

bug fixes

上级 14dd1232
......@@ -25,6 +25,7 @@
</div>
<div class="right">
<question-numbers
:status="status"
:page="currentGroupPage"
:data="currentQuestionGroup"
:list="numberGroups.length ? numberGroups : questionGroups"
......@@ -66,6 +67,7 @@ import questionNumbers from '@/components/exam/questionNumbers'
export default {
components: { questionList, questionNumbers },
props: {
status: { type: Number, default: 1 }, // 1:答题;2:查看;3:批阅
title: { type: String },
hasMark: { type: Boolean, default: true }, // 标记
hasCollect: { type: Boolean, default: true }, // 收藏
......@@ -259,7 +261,7 @@ export default {
},
// 组装试题数据
genQuestions(data) {
const { questions, answers = {} } = data
const { questions, answers = {}, score_items: scores = {} } = data
if (!questions) return []
this.questionGroups = questions.question_items.reduce((result, question) => {
if (question.question_list.length) {
......@@ -267,17 +269,27 @@ export default {
list = list.map(item => {
let userAnswers = []
let sign = false
let scoreItem = {}
if (answers) {
// 大题答案包含所有小题答案
const bigQuestionAnswer = answers[question.question_item_id]
const bigQuestionScore = scores[question.question_item_id]
if (bigQuestionAnswer) {
// 小题答案
const questionAnswer = bigQuestionAnswer[item.id] || {}
// 小题分数
scoreItem = bigQuestionScore[item.id] || {}
userAnswers = questionAnswer.answer || []
sign = questionAnswer.sign || false
if (userAnswers.length) {
scoreItem.answer = scoreItem.is_right ? 1 : 2
} else {
scoreItem.answer = 0
}
}
}
return { ...item, user_answer: userAnswers, sign }
return { ...item, user_answer: userAnswers, sign, ...scoreItem }
})
result.push(Object.assign({}, question, { question_list: list }))
})
......
......@@ -52,10 +52,10 @@
</div>
</template>
<template v-else>
<!-- <div class="answer-item">
<div class="answer-item" v-if="data.comment">
<div class="answer-item-label">老师点评:</div>
<div class="answer-item-content">{{ correctAnswerText }}</div>
</div> -->
<div class="answer-item-content">{{ data.comment }}</div>
</div>
</template>
<div class="answer-item" v-if="data.question_analysis">
<div class="answer-item-label">解析:</div>
......
<template>
<exam-card
title="课后练习"
:hasMark="hasMark"
:status="status"
:data="data"
:hasCountdown="false"
@submit="handleSubmit"
......@@ -15,6 +17,8 @@ export default {
components: { ExamCard },
data() {
return {
status: 1, // 考试状态
hasMark: true,
data: {}
}
},
......@@ -35,6 +39,12 @@ export default {
}
api.getCourseQuestion(param).then(response => {
this.data = JSON.parse(response.data).sheet
// 已提交
const isSubmited = ['1', '2'].includes(this.data.status)
if (isSubmited) {
this.status = 2
this.hasMark = false
}
})
},
// 返回
......@@ -59,9 +69,9 @@ export default {
answers[group.question_item_id] = {}
}
group.question_list.forEach(item => {
answers[item.question_item_id][item.id] = {
answers[group.question_item_id][item.id] = {
sign: item.sign ? item.sign : false,
answers: item.user_answer
answer: item.user_answer
}
})
})
......
......@@ -57,8 +57,7 @@ export default {
return `width: ${this.accuracy}%`
}
},
mounted() {
},
mounted() {},
methods: {
goPage(param) {
const urlParam = this.$route.query
......@@ -76,24 +75,20 @@ export default {
course_id: this.$route.query.course_id,
chapter_id: this.$route.query.chapter_id
}
api
.getCourseQuestion(param)
.then(response => {
const data = JSON.parse(response.data)
this.data = data
this.accuracy = parseInt(data.sheet.score) / parseInt(data.sheet.questions.total_score) * 100
})
.finally(() => {
})
api.getCourseQuestion(param).then(response => {
const data = JSON.parse(response.data)
this.data = data
this.accuracy = (parseInt(data.sheet.score) / parseInt(data.sheet.questions.total_score)) * 100
})
}
}
}
</script>
<style lang="scss" scoped>
.result-box{
.result-box {
width: 100%;
display: flex;
.card-left{
.card-left {
position: relative;
box-sizing: border-box;
padding: 10px 30px 20px;
......@@ -102,13 +97,13 @@ export default {
margin-right: 10px;
height: 560px;
border-radius: 8px;
.title{
.title {
font-size: 18px;
color: #222222;
line-height: 45px;
border-bottom: 1px solid #ccc;
}
.chart-box{
.chart-box {
position: absolute;
top: 50%;
left: 50%;
......@@ -116,63 +111,63 @@ export default {
width: 148px;
// margin: 26px auto 0;
}
.assess{
.assess {
font-size: 18px;
color: #222222;
line-height: 45px;
border-bottom: 1px solid #ccc;
}
.assess-box{
.assess-box {
padding-top: 27px;
.prog{
.prog {
width: 350px;
margin: 0 auto;
display: flex;
align-items: center;
justify-content: space-between;
.line-box{
.line-box {
width: 300px;
width: 300px;
height: 10px;
background: #F9F9F9;
background: #f9f9f9;
border-radius: 5px;
.line{
.line {
width: 80%;
height: 10px;
background: linear-gradient(90deg, #F47C46 0%, #F22F48 100%);
background: linear-gradient(90deg, #f47c46 0%, #f22f48 100%);
border-radius: 5px;
}
}
.icon{
.icon {
width: 41px;
height: 38px;
background: url(@/assets/images/res-icon.png);
background-size: 100% 100%;
}
}
.text{
.text {
font-size: 14px;
color: #222222;
line-height: 20px;
text-align: center;
margin: 50px 0 68px 0;
}
.btn{
.btn {
cursor: pointer;
text-align: center;
line-height: 40px;
width: 144px;
height: 40px;
background: #C01540;
background: #c01540;
border-radius: 4px;
font-size: 14px;
font-weight: bold;
color: #FFFFFF;
color: #ffffff;
margin: 0 auto;
}
}
}
.card-right{
.card-right {
box-sizing: border-box;
flex: 1;
background: #fff;
......
<template>
<exam-card
:title="title"
:status="2"
:groups="questionGroups"
:numberGroups="numberGroups"
:hasMark="false"
......
......@@ -2,6 +2,8 @@
<div>
<exam-card
title="模拟考试"
:hasMark="hasMark"
:status="status"
:hasSubmitBtn="!!!this.$route.query.id"
:hasCountdown="!!!this.$route.query.id"
:data="data"
......@@ -19,9 +21,10 @@ export default {
components: { ExamCard },
data() {
return {
data: {
cacheAnswerTime: null // 缓存题计时器
}
status: 1, // 考试状态
hasMark: true,
data: {},
cacheAnswerTime: null // 缓存题计时器
}
},
computed: {
......@@ -56,6 +59,9 @@ export default {
this.cacheAnswerTime = setInterval(() => {
this.submitExam(0)
}, 3000)
} else {
this.status = 2
this.hasMark = false
}
})
},
......
......@@ -2,6 +2,7 @@
<div>
<exam-card
title="批阅考卷"
:status="3"
:hasSubmitBtn="false"
:hasCountdown="false"
:hasCollect="false"
......
......@@ -2,6 +2,7 @@
<div>
<exam-card
title="批阅考卷"
:status="3"
:hasSubmitBtn="false"
:hasCountdown="false"
:hasCollect="false"
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论