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

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

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