提交 189ecee7 authored 作者: lihuihui's avatar lihuihui
...@@ -34,6 +34,8 @@ ...@@ -34,6 +34,8 @@
:autosize="{ minRows: 4, maxRows: 6 }" :autosize="{ minRows: 4, maxRows: 6 }"
:disabled="disabled" :disabled="disabled"
@blur="handleChange" @blur="handleChange"
:maxlength="100"
:show-word-limit="true"
></el-input> ></el-input>
</template> </template>
<template v-if="questionType === 3"> <template v-if="questionType === 3">
......
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
:hasCountdown="false" :hasCountdown="false"
@submit="handleSubmit" @submit="handleSubmit"
@back="handleBack" @back="handleBack"
ref="exam"
v-if="Object.keys(data).length" v-if="Object.keys(data).length"
></exam-card> ></exam-card>
</template> </template>
...@@ -19,13 +20,17 @@ export default { ...@@ -19,13 +20,17 @@ export default {
return { return {
status: 1, // 考试状态 status: 1, // 考试状态
hasMark: true, hasMark: true,
data: {} data: {},
cacheAnswerTime: null
} }
}, },
beforeMount() { beforeMount() {
// 获取考卷 // 获取考卷
this.getTopic() this.getTopic()
}, },
beforeDestroy() {
this.cacheAnswerTime && clearInterval(this.cacheAnswerTime) // 停止缓存
},
methods: { methods: {
// 获取考卷 // 获取考卷
getTopic() { getTopic() {
...@@ -41,9 +46,13 @@ export default { ...@@ -41,9 +46,13 @@ export default {
this.data = JSON.parse(response.data).sheet this.data = JSON.parse(response.data).sheet
// 已提交 // 已提交
const isSubmited = ['1', '2'].includes(this.data.status) const isSubmited = ['1', '2'].includes(this.data.status)
// 缓存答题
if (isSubmited) { if (isSubmited) {
this.status = 2 this.status = 2
this.hasMark = false this.hasMark = false
} else {
clearInterval(this.cacheAnswerTime)
this.cacheAnswerTime = setInterval(this.handleCache, 3000)
} }
}) })
}, },
...@@ -55,6 +64,7 @@ export default { ...@@ -55,6 +64,7 @@ export default {
handleSubmit(data) { handleSubmit(data) {
const params = this.genSubmitData(data).params const params = this.genSubmitData(data).params
const answerNum = this.genSubmitData(data).answerNum const answerNum = this.genSubmitData(data).answerNum
params.status = 1
if (answerNum !== 0) { if (answerNum !== 0) {
this.$confirm(`您还有${answerNum}道题没有作答`, '请确认', { this.$confirm(`您还有${answerNum}道题没有作答`, '请确认', {
confirmButtonText: '确认提交', confirmButtonText: '确认提交',
...@@ -70,13 +80,21 @@ export default { ...@@ -70,13 +80,21 @@ export default {
} }
}, },
submitApi(params) { submitApi(params) {
api.setCourseCache(Object.assign(params, { status: 1 })).then(res => { this.cacheAnswerTime && clearInterval(this.cacheAnswerTime) // 停止缓存
api.setCourseCache(params).then(res => {
this.$router.replace({ this.$router.replace({
path: '/course/chapter/result', path: '/course/chapter/result',
query: Object.assign({}, this.$route.query, { type: 2 }) query: Object.assign({}, this.$route.query, { type: 2 })
}) })
}) })
}, },
// 缓存答案
handleCache() {
const refData = this.$refs.exam
const params = this.genSubmitData(refData.questionGroups).params
params.status = 0
api.setCourseCache(params)
},
// 组装提交数据 // 组装提交数据
genSubmitData(questionGroups) { genSubmitData(questionGroups) {
const answers = {} const answers = {}
......
...@@ -30,6 +30,7 @@ ...@@ -30,6 +30,7 @@
placeholder="请输入分数" placeholder="请输入分数"
size="mini" size="mini"
style="width:80px" style="width:80px"
@input="handleScoreInput(item)"
></el-input> ></el-input>
</div> </div>
</div> </div>
...@@ -42,6 +43,8 @@ ...@@ -42,6 +43,8 @@
max="2" max="2"
resize="none" resize="none"
v-model="item.comment" v-model="item.comment"
:maxlength="100"
:show-word-limit="true"
> >
</el-input> </el-input>
</div> </div>
...@@ -115,6 +118,12 @@ export default { ...@@ -115,6 +118,12 @@ export default {
this.studentList = JSON.parse(window.localStorage.examStudentsList) this.studentList = JSON.parse(window.localStorage.examStudentsList)
}, },
methods: { methods: {
handleScoreInput(item) {
item.user_score = parseInt(item.user_score.replace(/[^\d]+/g, ''))
if (item.user_score > item.score) {
item.user_score = item.score
}
},
selectStudent(item) { selectStudent(item) {
this.sheetId = item.sheet_id this.sheetId = item.sheet_id
this.getTopic() this.getTopic()
......
...@@ -26,10 +26,12 @@ ...@@ -26,10 +26,12 @@
<el-input <el-input
type="number" type="number"
:disabled="item.checked_flag" :disabled="item.checked_flag"
:max="item.score"
v-model="item.user_score" v-model="item.user_score"
placeholder="请输入分数" placeholder="请输入分数"
size="mini" size="mini"
style="width:80px" style="width:80px"
@input="handleScoreInput(item)"
></el-input> ></el-input>
</div> </div>
</div> </div>
...@@ -42,6 +44,8 @@ ...@@ -42,6 +44,8 @@
max="2" max="2"
resize="none" resize="none"
v-model="item.comment" v-model="item.comment"
:maxlength="100"
:show-word-limit="true"
> >
</el-input> </el-input>
</div> </div>
...@@ -115,6 +119,12 @@ export default { ...@@ -115,6 +119,12 @@ export default {
this.studentList = JSON.parse(window.localStorage.testStudentsList) this.studentList = JSON.parse(window.localStorage.testStudentsList)
}, },
methods: { methods: {
handleScoreInput(item) {
item.user_score = parseInt(item.user_score.replace(/[^\d]+/g, ''))
if (item.user_score > item.score) {
item.user_score = item.score
}
},
selectStudent(item) { selectStudent(item) {
this.sheetId = item.sheet_id this.sheetId = item.sheet_id
this.getTopic() this.getTopic()
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论