提交 f71d6411 authored 作者: GOD_ZYX's avatar GOD_ZYX

完成全部 考试开发

上级 e32c2cad
......@@ -47,7 +47,7 @@
<div class="edit_html" v-html="item.content || ''"></div>
<textarea :id="('editor-exam' + index)" v-model="item.user_answer"></textarea>
<div style="height: 10px;"></div>
<component :is="item.upload.type" v-bind:key="item.upload.model" :item="item.upload" :formData="item"></component>
<component :is="item.upload.type" v-bind:key="item.upload.model" :item="item.upload" :formData="item" :isUpload="!exam.type"></component>
</div>
</template>
</template>
......@@ -117,6 +117,7 @@ export default {
},
data () {
return {
_time: null, // 定时器,自动化提交
exam: {
// id: '1',
// title: '标题',
......@@ -246,6 +247,26 @@ export default {
},
mounted () {
this.loadAjax()
if (this._time) {
clearInterval(this._time)
this._time = null
}
this._time = setInterval(() => {
if (!this.exam.type) {
this.submitExam({ submitType: true }) // 暂存, submitType: true 暂存;其他或不填为提交
} else {
clearInterval(this._time)
this._time = null
}
}, 30000)
},
destroyed () {
if (this._time) {
console.log(11)
clearInterval(this._time)
this._time = null
}
},
methods: {
isCheckboxRight: (val, arr) => {
......@@ -274,7 +295,10 @@ export default {
initckeditor () {
if (!this.exam.shortAnswerList) { return }
for (let i = 0; i < this.exam.shortAnswerList.length; i++) {
let tmpEditor = CKEDITOR.replace('editor-exam' + i, {
let instances = CKEDITOR.instances
let tmpEditor = null
if (!instances['editor-exam' + i]) {
tmpEditor = CKEDITOR.replace('editor-exam' + i, {
height: 300,
uiColor: '#eeeeee',
filebrowserImageUploadUrl: '/api/ckeditor/img/upload',
......@@ -294,7 +318,8 @@ export default {
{ name: 'insert', items: [ 'Image', 'Table', 'HorizontalRule' ] }
]
})
this.exam.shortAnswerList[i].ckeditor = tmpEditor
}
this.exam.shortAnswerList[i].ckeditor = tmpEditor || instances['editor-exam' + i]
}
},
/**
......@@ -340,15 +365,15 @@ export default {
* 提交试题
*/
submitExam (e) {
if (e.currentTarget.dataset.submit) {
if (!e.submitType && e.currentTarget.dataset.submit) {
this.$message.error('已做过,不能再提交')
return
}
let body = { answers: {}, type: 0 } // type: 0 缓存;type: 1 提交
let body = { answers: {}, type: !e.submitType ? 1 : 0 } // type: 0 缓存;type: 1 提交
body.answers.radioList = []
for (let i = 0; i < this.exam.radioList.length; i++) {
let tmp = this.exam.radioList[i]
if (!tmp.user_answer) {
if (!tmp.user_answer && !e.submitType) {
this.$message.error('还有单选题未做,不能提交')
return
}
......@@ -360,7 +385,7 @@ export default {
body.answers.checkboxList = []
for (let i = 0; i < this.exam.checkboxList.length; i++) {
let tmp = this.exam.checkboxList[i]
if (!tmp.user_answer.length) {
if (!tmp.user_answer.length && !e.submitType) {
this.$message.error('还有多选题未做,不能提交')
return
}
......@@ -373,7 +398,7 @@ export default {
for (let i = 0; i < this.exam.shortAnswerList.length; i++) {
let tmp = this.exam.shortAnswerList[i]
tmp.user_answer = tmp.ckeditor.getData()
if (!tmp.user_answer) {
if (!tmp.user_answer && !e.submitType) {
this.$message.error('还有简答题未做,不能提交')
return
}
......@@ -386,6 +411,10 @@ export default {
body.answers = JSON.stringify(body.answers)
const loading = this.$loading({ lock: true, text: '', spinner: '', background: 'rgba(255, 255, 255, 0.9)' })
cAction.examAction.submitExam(this.cid, this.sid, this.exam.id, body).then(_res => {
if (e.submitType) {
this.$message.success('暂存成功')
return
}
if (_res.code === 200) {
this.loadAjax()
} else {
......
......@@ -8,9 +8,10 @@
:on-success="onSuccessFile"
:with-credentials="true"
:show-file-list="false"
:disabled="item.disabled || false"
v-bind="item.attrs || {}">
<el-button type="primary" size="small">点击上传</el-button>
:disabled="(item.disabled || false) || !isUpload"
v-bind="item.attrs || {}"
>
<el-button type="primary" size="small" :disabled="!isUpload">点击上传</el-button>
<template v-if="formData[item.model] !== null && formData[item.model] !== '' && formData[item.model] !== undefined">
<div class="self-icon el-icon-circle-check" style="color: #237f00;"></div>
</template>
......@@ -22,7 +23,7 @@
<template v-for="(item, index) in filesArr">
<template v-if="/(jpeg)|(jpg)|(png)|(gif)/gi.test(item.url)">
<div v-bind:key="item.id" class="show-file">
<template v-if="!(item.disabled || false)">
<template v-if="!(item.disabled || false) && isUpload">
<div class="close" @click="deleteFiles(index)">X</div>
</template>
<el-avatar shape="square" :size="100" fit="contain" :src="item.url"></el-avatar>
......@@ -34,7 +35,7 @@
</template>
<template v-else>
<div v-bind:key="item.id" class="show-file">
<template v-if="!(item.disabled || false)">
<template v-if="!(item.disabled || false) && isUpload">
<div class="close" @click="deleteFiles(index)">X</div>
</template>
<el-avatar shape="square" :size="100" fit="contain" :src="item.url"></el-avatar>
......@@ -69,6 +70,12 @@ export default {
default () {
return {}
}
},
isUpload: {
type: Boolean,
default () {
return true
}
}
},
data () {
......
......@@ -6,8 +6,8 @@ if (state === 'test') {
// conf.agentApiUrl = 'http://10.1.1.5:8024/'
// conf.agentApiUrl = 'http://192.168.3.254:8081'
} else if (state === 'production') {
conf.agentApiUrl = 'https://zapi.ezijing.com/'
// conf.agentApiUrl = 'https://api2.ezijing.com/'
// conf.agentApiUrl = 'https://zapi.ezijing.com/'
conf.agentApiUrl = 'https://api2.ezijing.com/'
}
global.app = null
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论