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

课后作业接口调整

上级 7a46c699
......@@ -8,9 +8,7 @@ const httpRequest = new BaseAPI(webConf)
* @param {string} courseId 课程ID
*/
export function getCourse(semesterId, courseId) {
return httpRequest.get(
`/api/lms/v2/education/courses/${courseId}`
)
return httpRequest.get(`/api/lms/v2/education/courses/${courseId}`)
}
/**
......@@ -44,10 +42,7 @@ export function getChapterVideoAliyun(vid) {
* @param {Object} params
*/
export function getChapterVideoProgress(semesterId, resourseId, params) {
return httpRequest.get(
`/api/lms/v2/education/video/${resourseId}/device`,
params
)
return httpRequest.get(`/api/lms/v2/education/video/${resourseId}/device`, params)
}
/**
......@@ -62,12 +57,11 @@ export function updateChapterVideoProgress(params) {
* 获取章节作业
* @param {string} semesterId 学期ID
* @param {string} courseId 课程ID
* @param {string} chapterId 章节ID
* @param {string} resourseId 章节的资源ID
*/
export function getChapterHomework(semesterId, courseId, resourseId) {
return httpRequest.get(
`/api/lms/v2/education/homeworks/${courseId}/${resourseId}`
)
export function getChapterHomework(semesterId, courseId, chapterId, resourseId) {
return httpRequest.get(`/api/lms/v2/education/homeworks/${courseId}/${chapterId}/${resourseId}`)
}
/**
......@@ -77,9 +71,7 @@ export function getChapterHomework(semesterId, courseId, resourseId) {
* @param {string} chapterId 章节ID
*/
export function getChapterHomeworkDeadline(semesterId, courseId, chapterId) {
return httpRequest.get(
`/api/lms/v2/education/homeworks/${courseId}/${chapterId}/deadline`
)
return httpRequest.get(`/api/lms/v2/education/homeworks/${courseId}/${chapterId}/deadline`)
}
/**
......@@ -106,9 +98,7 @@ export function uploadFile(data) {
* @param {string} courseId 课程ID
*/
export function getCourseWork(semesterId, courseId) {
return httpRequest.get(
`/api/lms/v2/education/courses/${courseId}/essay`
)
return httpRequest.get(`/api/lms/v2/education/courses/${courseId}/essay`)
}
/**
......@@ -117,11 +107,9 @@ export function getCourseWork(semesterId, courseId) {
* @param {string} courseId 课程ID
*/
export function updateCourseWork(semesterId, courseId, data) {
return httpRequest.post(
`/api/lms/v2/education/courses/${courseId}/essay`,
data,
{ headers: { 'Content-Type': 'multipart/form-data' } }
)
return httpRequest.post(`/api/lms/v2/education/courses/${courseId}/essay`, data, {
headers: { 'Content-Type': 'multipart/form-data' }
})
}
/**
......@@ -130,9 +118,7 @@ export function updateCourseWork(semesterId, courseId, data) {
* @param {string} courseId 课程ID
*/
export function getCourseExam(semesterId, courseId) {
return httpRequest.get(
`/api/lms/v2/education/${courseId}/examination`
)
return httpRequest.get(`/api/lms/v2/education/${courseId}/examination`)
}
/**
......@@ -142,9 +128,7 @@ export function getCourseExam(semesterId, courseId) {
* @param {string} examId 试题ID
*/
export function getCourseExamStatus(semesterId, courseId, examId) {
return httpRequest.get(
`/api/lms/v2/education/${courseId}/examination/${examId}/status`
)
return httpRequest.get(`/api/lms/v2/education/${courseId}/examination/${examId}/status`)
}
/**
......@@ -154,11 +138,9 @@ export function getCourseExamStatus(semesterId, courseId, examId) {
* @param {string} examId 试题ID
*/
export function submitCourseExam(semesterId, courseId, examId, data) {
return httpRequest.post(
`/api/lms/v2/education/${courseId}/examination/${examId}/sheet`,
data,
{ headers: { 'Content-Type': 'application/x-www-form-urlencoded' } }
)
return httpRequest.post(`/api/lms/v2/education/${courseId}/examination/${examId}/sheet`, data, {
headers: { 'Content-Type': 'application/x-www-form-urlencoded' }
})
}
/**
......@@ -168,8 +150,5 @@ export function submitCourseExam(semesterId, courseId, examId, data) {
* @param {string} examId 试题ID
*/
export function getCourseExamResult(semesterId, courseId, examId, params) {
return httpRequest.get(
`/api/lms/v2/education/${courseId}/examination/${examId}/sheet`,
params
)
return httpRequest.get(`/api/lms/v2/education/${courseId}/examination/${examId}/sheet`, params)
}
......@@ -101,7 +101,7 @@ export default {
getDetail() {
this.loading = true
api
.getChapterHomework(this.sid, this.cid, this.resourceId)
.getChapterHomework(this.sid, this.cid, this.pid, this.resourceId)
.then(response => {
this.detail = Array.isArray(response) ? null : response
if (this.detail) {
......
......@@ -13,7 +13,7 @@
></exam-item>
</el-form>
</div>
<p style="color:red;" v-if="deadline">请于截止日期 {{ deadline }} 前提交</p>
<p style="color: red" v-if="deadline">请于截止日期 {{ deadline }} 前提交</p>
<!-- 驳回状态 -->
<template v-if="detail && detail.status === 1">
<div class="work-bottom">
......@@ -54,12 +54,7 @@
</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
"
>
<template v-if="detail.updated_time && detail.updated_time !== detail.created_time">
<p class="help">最近提交时间: {{ detail.updated_time }}</p>
</template>
</template>
......@@ -67,12 +62,9 @@
</div>
<div class="buttons">
<el-tooltip content="在获老师批改之前,可以多次提交,将以最后一次提交为准" placement="right">
<el-button
type="primary"
:disabled="disabled || !isWorkTime"
:loading="submitLoading"
@click="onSubmit"
>{{ submitText }}</el-button>
<el-button type="primary" :disabled="disabled || !isWorkTime" :loading="submitLoading" @click="onSubmit">{{
submitText
}}</el-button>
</el-tooltip>
</div>
</template>
......@@ -124,9 +116,7 @@ export default {
chapter: {
immediate: true,
handler(data) {
this.questions = data.homework
? this.genQuenstions(data.homework.questions)
: []
this.questions = data.homework ? this.genQuenstions(data.homework.questions) : []
}
}
},
......@@ -169,9 +159,7 @@ export default {
methods: {
// 获取作业截止时间
getDeadline() {
api
.getChapterHomeworkDeadline(this.sid, this.cid, this.pid)
.then(response => {
api.getChapterHomeworkDeadline(this.sid, this.cid, this.pid).then(response => {
this.deadline = response.dead_line
})
},
......@@ -179,7 +167,7 @@ export default {
getDetail() {
this.loading = true
api
.getChapterHomework(this.sid, this.cid, this.resourceId)
.getChapterHomework(this.sid, this.cid, this.pid, this.resourceId)
.then(response => {
this.detail = Array.isArray(response) ? null : response
if (this.detail) {
......@@ -188,9 +176,7 @@ export default {
const parseAnswers = JSON.parse(this.detail.work_contents)
// 设置答案
this.questions = this.questions.map(item => {
const found = parseAnswers.find(
answer => answer.question_id === item.id
)
const found = parseAnswers.find(answer => answer.question_id === item.id)
if (found) {
item.user_answer = found.descreption
item.attachments = found.file_url
......@@ -226,9 +212,7 @@ export default {
temp = {
formModel: {
id: item.id,
user_answer: item.user_answer
? Base64.decode(item.user_answer)
: '',
user_answer: item.user_answer ? Base64.decode(item.user_answer) : '',
attachments: item.attachments || ''
}
}
......@@ -238,9 +222,7 @@ export default {
item,
{
content: item.question_content,
options: item.question_options
? JSON.parse(item.question_options)
: []
options: item.question_options ? JSON.parse(item.question_options) : []
},
temp
)
......@@ -262,23 +244,17 @@ export default {
// 校验
if (!this.checkSubmit()) {
this.messageInstance && this.messageInstance.close()
this.messageInstance = this.$message.error(
'答题内容不能为空,请检查并输入内容'
)
this.messageInstance = this.$message.error('答题内容不能为空,请检查并输入内容')
return
}
// 计算答题时间
const duration = Math.floor(
(new Date().getTime() - this.startTime) / 1000
)
const duration = Math.floor((new Date().getTime() - this.startTime) / 1000)
// 提交的答案数据
const answers = this.questions.map(item => {
return {
question_id: item.id,
descreption:
item.question_type === 3
? Base64.encode(item.formModel.user_answer)
: item.formModel.user_answer,
item.question_type === 3 ? Base64.encode(item.formModel.user_answer) : item.formModel.user_answer,
file_url: item.formModel.attachments,
is_encoded: 1
}
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论