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

课后作业接口调整

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