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

fix: viewer 模块课后作业增加驳回功能

上级 e05c31be
...@@ -85,8 +85,8 @@ export default { ...@@ -85,8 +85,8 @@ export default {
] ]
} }
if (this.readOnly !== null) { if (this.disabled !== null) {
config.readOnly = this.readOnly config.readOnly = this.disabled
} }
const editor = (this.ckEditor = CKEDITOR.replace( const editor = (this.ckEditor = CKEDITOR.replace(
......
...@@ -57,21 +57,33 @@ export function updateChapterVideoProgress(params) { ...@@ -57,21 +57,33 @@ export function updateChapterVideoProgress(params) {
} }
/** /**
* 获取答题信息 * 获取章节作业
* @param {string} semesterId 学期ID * @param {string} semesterId 学期ID
* @param {string} courseId 课程ID * @param {string} courseId 课程ID
* @param {string} resourseId 章节的资源ID * @param {string} resourseId 章节的资源ID
*/ */
export function getChapterExam(semesterId, courseId, resourseId) { export function getChapterHomework(semesterId, courseId, resourseId) {
return httpRequest.get( return httpRequest.get(
`/v2/education/homeworks/${semesterId}/${courseId}/${resourseId}` `/v2/education/homeworks/${semesterId}/${courseId}/${resourseId}`
) )
} }
/**
* 获取提交作业截止时间
* @param {string} semesterId 学期ID
* @param {string} courseId 课程ID
* @param {string} chapterId 章节ID
*/
export function getChapterHomeworkDeadline(semesterId, courseId, chapterId) {
return httpRequest.get(
`/v2/education/homeworks/${semesterId}/${courseId}/${chapterId}/deadline`
)
}
/** /**
* 提交考试 * 提交考试
*/ */
export function sbumitChapterExam(params) { export function sbumitChapterHomework(params) {
return httpRequest.post('/v2/education/homeworks', params, { return httpRequest.post('/v2/education/homeworks', params, {
headers: { 'Content-Type': 'application/json' } headers: { 'Content-Type': 'application/json' }
}) })
......
...@@ -84,9 +84,8 @@ export default { ...@@ -84,9 +84,8 @@ export default {
{ name: 'insert', items: ['Image', 'Table', 'HorizontalRule'] } { name: 'insert', items: ['Image', 'Table', 'HorizontalRule'] }
] ]
} }
if (this.disabled !== null) {
if (this.readOnly !== null) { config.readOnly = this.disabled
config.readOnly = this.readOnly
} }
const editor = (this.ckEditor = CKEDITOR.replace( const editor = (this.ckEditor = CKEDITOR.replace(
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
<i class="el-icon-document"></i> <i class="el-icon-document"></i>
<div v-html="file.file_name"></div> <div v-html="file.file_name"></div>
</a> </a>
<span v-if="file.file_size">{{ file.file_size }}</span> <!-- <span v-if="file.file_size">{{ file.file_size }}</span> -->
<a :href="file.file_url" :download="file.file_name" target="_blank"> <a :href="file.file_url" :download="file.file_name" target="_blank">
<el-tooltip effect="dark" content="下载"> <el-tooltip effect="dark" content="下载">
<i class="el-icon-download"></i> <i class="el-icon-download"></i>
......
...@@ -102,7 +102,7 @@ export default { ...@@ -102,7 +102,7 @@ export default {
getDetail() { getDetail() {
this.loading = true this.loading = true
api api
.getChapterExam(this.sid, this.cid, this.resourceId) .getChapterHomework(this.sid, this.cid, this.resourceId)
.then(response => { .then(response => {
this.detail = Array.isArray(response) ? null : response this.detail = Array.isArray(response) ? null : response
if (this.detail) { if (this.detail) {
...@@ -248,7 +248,7 @@ export default { ...@@ -248,7 +248,7 @@ export default {
// 请求提交接口 // 请求提交接口
handleSubmitRequest(params) { handleSubmitRequest(params) {
api api
.sbumitChapterExam(params) .sbumitChapterHomework(params)
.then(response => { .then(response => {
if (response.status) { if (response.status) {
this.getDetail() this.getDetail()
......
...@@ -2,46 +2,75 @@ ...@@ -2,46 +2,75 @@
<template> <template>
<container :title="chapter.name" v-loading="loading"> <container :title="chapter.name" v-loading="loading">
<div class="exam-form"> <div class="exam-form">
<el-form :disabled="isRevised"> <el-form :disabled="disabled || !isWorkTime">
<exam-item <exam-item
v-for="(item, index) in questions" v-for="(item, index) in questions"
:index="index" :index="index"
:type="item.question_type" :type="item.question_type"
:data="item" :data="item"
:value="item.formModel" :value="item.formModel"
:disabled="isRevised" :disabled="disabled || !isWorkTime"
:key="item.id" :key="item.id"
></exam-item> ></exam-item>
</el-form> </el-form>
</div> </div>
<div class="work-bottom" v-if="detail"> <p style="color:red;" v-if="deadline">请于截止日期 {{deadline}} 前提交</p>
<div class="info"> <!-- 驳回状态 -->
<template v-if="isRevised"> <template v-if="detail && detail.status === 1">
<div class="work-bottom">
<div class="info">
<div class="paper-check"> <div class="paper-check">
<p>批改时间:{{detail.check_date}}</p> <h4>作业被驳回,点击“重新编辑”按钮重新编辑内容再次提交</h4>
<div class="paper-check-item"> <div class="paper-check-item">
<b>评分</b> <b>驳回时间</b>
{{detail.score}} {{detail.checker_time}}
</div> </div>
<div class="paper-check-item"> <div class="paper-check-item">
<b>评语</b> <b>驳回说明</b>
<div class="edit_html" v-html="detail.check_comments"></div> <div class="edit_html" v-html="detail.check_comments"></div>
</div> </div>
</div> </div>
</template> </div>
<template v-else-if="detail.created_time"> </div>
<p class="help">已于 {{detail.created_time}} 提交,等待老师批改中。</p> <div class="buttons">
<template v-if="detail.updated_time && detail.updated_time !== detail.created_time"> <el-button type="primary" @click="onReEdit" :disabled="!isWorkTime">重新编辑</el-button>
<p class="help">最近提交时间: {{detail.updated_time}}</p> </div>
</template>
<!-- 正常状态 -->
<template v-else>
<div class="work-bottom" v-if="detail">
<div class="info">
<template v-if="isRevised">
<div class="paper-check">
<p>批改时间:{{detail.checker_time}}</p>
<div class="paper-check-item">
<b>评分:</b>
{{detail.score}}
</div>
<div class="paper-check-item">
<b>评语:</b>
<div class="edit_html" v-html="detail.check_comments"></div>
</div>
</div>
</template> </template>
</template> <template v-else-if="detail.created_time">
<p class="help">已于 {{detail.created_time}} 提交,等待老师批改中。</p>
<template v-if="detail.updated_time && detail.updated_time !== detail.created_time">
<p class="help">最近提交时间: {{detail.updated_time}}</p>
</template>
</template>
</div>
</div> </div>
</div> <div class="buttons">
<div class="buttons"> <el-tooltip content="在获老师批改之前,可以多次提交,将以最后一次提交为准" placement="right">
<el-tooltip content="在获老师批改之前,可以多次提交,将以最后一次提交为准" placement="right"> <el-button
<el-button type="primary" @click="onSubmit" :disabled="isRevised">{{submitText}}</el-button> type="primary"
</el-tooltip> @click="onSubmit"
</div> :disabled="disabled || !isWorkTime"
>{{submitText}}</el-button>
</el-tooltip>
</div>
</template>
</container> </container>
</template> </template>
...@@ -80,7 +109,9 @@ export default { ...@@ -80,7 +109,9 @@ export default {
detail: null, detail: null,
questions: [], // 问题列表 questions: [], // 问题列表
startTime: new Date().getTime(), // 进入时间 startTime: new Date().getTime(), // 进入时间
messageInstance: null messageInstance: null,
deadline: '', // 截止时间
disabled: false
} }
}, },
watch: { watch: {
...@@ -112,22 +143,42 @@ export default { ...@@ -112,22 +143,42 @@ export default {
}, },
// 是否批改 // 是否批改
isRevised() { isRevised() {
return this.detail ? !!this.detail.check_date : false return this.detail ? this.detail.status === 0 : false
}, },
// 提交按钮文本 // 提交按钮文本
submitText() { submitText() {
return this.isRevised ? '已批改' : '提交' return this.isRevised ? '已批改' : '提交'
},
// 是否是提交作业时间
isWorkTime() {
if (!this.deadline) {
return true
}
// 大于开始时间,小于结束时间
const endTime = +new Date(this.deadline)
const currentTime = new Date().getTime()
return currentTime < endTime
} }
}, },
methods: { methods: {
// 获取作业截止时间
getDeadline() {
api
.getChapterHomeworkDeadline(this.sid, this.cid, this.pid)
.then(response => {
this.deadline = response.dead_line
})
},
// 获取详情 // 获取详情
getDetail() { getDetail() {
this.loading = true this.loading = true
api api
.getChapterExam(this.sid, this.cid, this.resourceId) .getChapterHomework(this.sid, this.cid, this.resourceId)
.then(response => { .then(response => {
this.detail = Array.isArray(response) ? null : response this.detail = Array.isArray(response) ? null : response
if (this.detail) { if (this.detail) {
// -1未处理 0已处理 1驳回
this.disabled = [0, 1].includes(this.detail.status)
const parseAnswers = JSON.parse(this.detail.work_contents) const parseAnswers = JSON.parse(this.detail.work_contents)
// 设置答案 // 设置答案
this.questions = this.questions.map(item => { this.questions = this.questions.map(item => {
...@@ -239,7 +290,7 @@ export default { ...@@ -239,7 +290,7 @@ export default {
// 请求提交接口 // 请求提交接口
handleSubmitRequest(params) { handleSubmitRequest(params) {
api api
.sbumitChapterExam(params) .sbumitChapterHomework(params)
.then(response => { .then(response => {
if (response.status) { if (response.status) {
this.$message.success('提交成功,等待批改') this.$message.success('提交成功,等待批改')
...@@ -251,10 +302,43 @@ export default { ...@@ -251,10 +302,43 @@ export default {
.catch(error => { .catch(error => {
this.$message.error(error.message) this.$message.error(error.message)
}) })
},
// 重新编辑
onReEdit() {
this.disabled = false
this.detail.status = -1
} }
}, },
beforeMount() { beforeMount() {
this.getDetail() this.getDetail()
this.getDeadline()
} }
} }
</script> </script>
<style lang="scss" scoped>
.work-bottom {
margin-top: 20px;
.info {
color: #999;
line-height: 28px;
}
}
.buttons {
padding: 20px 0;
::v-deep .el-button {
width: 120px;
}
}
.paper-check {
padding: 10px;
color: #000;
border: 1px solid #dedede;
h4 {
margin: 0 0 10px;
}
}
.paper-check-item {
display: flex;
}
</style>
...@@ -29,7 +29,7 @@ ...@@ -29,7 +29,7 @@
</div> </div>
<div class="q-item-ft" v-if="disabled"> <div class="q-item-ft" v-if="disabled">
<template v-if="type === 3"> <template v-if="type === 3">
<p> <p v-if="data.check_comment">
<span>评语:</span> <span>评语:</span>
<span>{{data.check_comment}}</span> <span>{{data.check_comment}}</span>
</p> </p>
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论