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

Merge branch 'master' into demo

...@@ -40,7 +40,7 @@ export default class CourseAction extends BaseACTION { ...@@ -40,7 +40,7 @@ export default class CourseAction extends BaseACTION {
const cur = data[i] const cur = data[i]
const _cur = data[i].curriculum const _cur = data[i].curriculum
/* 课程类型 */ /* 课程类型 */
const _type = cur.course_type const _type = parseInt(cur.course_type)
const str1 = _type === 1 ? _vIn.$t('action.courseAction.mustLearn') const str1 = _type === 1 ? _vIn.$t('action.courseAction.mustLearn')
: (_type === 2 ? _vIn.$t('action.courseAction.changeLearn') : (_type === 2 ? _vIn.$t('action.courseAction.changeLearn')
: (_type === 3 ? _vIn.$t('action.courseAction.repeatLearn') : '')) : (_type === 3 ? _vIn.$t('action.courseAction.repeatLearn') : ''))
......
...@@ -8,7 +8,7 @@ const httpRequest = new BaseAPI(webConf) ...@@ -8,7 +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(`/api/lms/v2/education/courses/${semesterId}/${courseId}`) return httpRequest.get(`/api/lms/v3/education/courses/${semesterId}/${courseId}`)
} }
/** /**
......
...@@ -10,7 +10,7 @@ export default class CourseAPI extends BaseAPI { ...@@ -10,7 +10,7 @@ export default class CourseAPI extends BaseAPI {
* @param {[string]} isMy * @param {[string]} isMy
* @param {[object]} param * @param {[object]} param
*/ */
getCourseList = (isMy, param) => this.get('/api/lms/v2/education/courses' + (isMy ? '/my' : ''), param) getCourseList = (isMy, param) => this.get('/api/lms/v3/education/courses' + (isMy ? '/my' : ''), param)
/** /**
* 获取某个课程详细信息 - 课程考核 和 课程讨论单独获取 * 获取某个课程详细信息 - 课程考核 和 课程讨论单独获取
* @param {[string]} id * @param {[string]} id
......
...@@ -8,7 +8,7 @@ const httpRequest = new BaseAPI(webConf) ...@@ -8,7 +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(`/api/lms/v2/education/courses/${semesterId}/${courseId}`) return httpRequest.get(`/api/lms/v3/education/courses/${semesterId}/${courseId}`)
} }
/** /**
...@@ -53,6 +53,14 @@ export function updateChapterVideoProgress(params) { ...@@ -53,6 +53,14 @@ export function updateChapterVideoProgress(params) {
return httpRequest.get('/api/lms/v2/analytics/upload-video', params) return httpRequest.get('/api/lms/v2/analytics/upload-video', params)
} }
/**
* 获取章节阅读资料
* @param {string} resourseId 章节的资源ID
*/
export function getChapterReading(resourseId) {
return httpRequest.get(`/api/lms/v3/education/reading/${resourseId}`)
}
/** /**
* 获取章节作业 * 获取章节作业
* @param {string} semesterId 学期ID * @param {string} semesterId 学期ID
...@@ -60,7 +68,7 @@ export function updateChapterVideoProgress(params) { ...@@ -60,7 +68,7 @@ export function updateChapterVideoProgress(params) {
* @param {string} resourseId 章节的资源ID * @param {string} resourseId 章节的资源ID
*/ */
export function getChapterHomework(semesterId, courseId, resourseId) { export function getChapterHomework(semesterId, courseId, resourseId) {
return httpRequest.get(`/api/lms/v2/education/homeworks/${semesterId}/${courseId}/${resourseId}`) return httpRequest.get(`/api/lms/v3/education/homeworks/${semesterId}/${courseId}/${resourseId}`)
} }
/** /**
......
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
// components // components
import Container from '../common/container.vue' import Container from '../common/container.vue'
import FileList from './fileList.vue' import FileList from './fileList.vue'
import * as api from '../../api'
// 章节阅读资料 // 章节阅读资料
export default { export default {
...@@ -30,15 +31,30 @@ export default { ...@@ -30,15 +31,30 @@ export default {
} }
} }
}, },
data() {
return {
files: []
}
},
computed: { computed: {
files() { // 资源ID
const reading = this.chapter.reading resourceId() {
const file = { return this.chapter.resource_id
file_name: reading.reading_content,
file_url: reading.reading_attachment
}
return [file]
} }
},
methods: {
getChapterReading() {
api.getChapterReading(this.resourceId).then(response => {
const file = {
file_name: response.reading_content,
file_url: response.reading_attachment
}
this.files = [file]
})
}
},
beforeMount() {
this.getChapterReading()
} }
} }
</script> </script>
...@@ -39,12 +39,8 @@ export default { ...@@ -39,12 +39,8 @@ export default {
components: { Container, ExamItem }, components: { Container, ExamItem },
props: { props: {
// 当前选中的章节 // 当前选中的章节
chapter: { chapter: { type: Object, default: () => ({}) },
type: Object, homework: { type: Object, default: () => ({}) }
default() {
return {}
}
}
}, },
data() { data() {
return { return {
...@@ -57,11 +53,16 @@ export default { ...@@ -57,11 +53,16 @@ export default {
} }
}, },
watch: { watch: {
chapter: { homework: {
immediate: true, immediate: true,
handler(data) { handler(data) {
if (!this.questions.length) { const { questions = [], answer = {} } = data
this.questions = data.homework ? this.genQuestions(data.homework.questions) : [] this.detail = answer
this.questions = this.genQuestions(questions)
// 答案处理
const parseAnswers = answer.work_contents ? JSON.parse(answer.work_contents) : []
if (parseAnswers && parseAnswers.length) {
this.setAnswers(parseAnswers)
} }
} }
} }
...@@ -99,34 +100,6 @@ export default { ...@@ -99,34 +100,6 @@ export default {
} }
}, },
methods: { methods: {
// 获取测试答题详情
getDetail() {
this.loading = true
api
.getChapterHomework(this.sid, this.cid, this.resourceId)
.then(response => {
this.detail = Array.isArray(response) ? null : response
if (this.detail) {
const parseAnswers = JSON.parse(this.detail.work_contents)
// 设置答案
this.questions = this.questions.map(item => {
const found = parseAnswers.find(answer => answer.question_id === item.id)
if (found) {
const selectedIds = found.options.reduce((result, item) => {
item.selected && result.push(item.id)
return result
}, [])
item.user_answer = item.question_type === 2 ? selectedIds : selectedIds[0]
}
return item
})
this.questions = this.genQuestions(this.questions)
}
})
.finally(() => {
this.loading = false
})
},
// 组装问题数据 // 组装问题数据
genQuestions(list) { genQuestions(list) {
if (!list) { if (!list) {
...@@ -165,6 +138,22 @@ export default { ...@@ -165,6 +138,22 @@ export default {
) )
}) })
}, },
// 设置答案
setAnswers(parseAnswers) {
this.questions = this.questions.map(item => {
const found = parseAnswers.find(answer => answer.question_id === item.id)
if (found) {
const selectedIds = found.options.reduce((result, item) => {
item.selected && result.push(item.id)
return result
}, [])
item.user_answer = item.question_type === 2 ? selectedIds : selectedIds[0]
}
return item
})
// 重新组装
this.questions = this.genQuestions(this.questions)
},
// 提交校验 // 提交校验
checkSubmit() { checkSubmit() {
const questions = this.questions const questions = this.questions
...@@ -245,7 +234,7 @@ export default { ...@@ -245,7 +234,7 @@ export default {
.sbumitChapterHomework(params) .sbumitChapterHomework(params)
.then(response => { .then(response => {
if (response.status) { if (response.status) {
this.getDetail() this.$emit('updateHomework')
} else { } else {
this.$message.error(response.data.error) this.$message.error(response.data.error)
} }
...@@ -257,9 +246,6 @@ export default { ...@@ -257,9 +246,6 @@ export default {
this.submitLoading = false this.submitLoading = false
}) })
} }
},
beforeMount() {
this.getDetail()
} }
} }
</script> </script>
......
...@@ -20,32 +20,11 @@ ...@@ -20,32 +20,11 @@
</el-form> </el-form>
</template> </template>
</div> </div>
<p style="color: red" v-if="deadline && detail.status !== 1"> <!-- 有互评的,批改后不显示 -->
{{ $t('viewerWork.deadline', { date: deadline }) }} <template v-if="!(hasComment && isRevised)">
</p> <p style="color: red" v-if="deadline && detail.status !== 1">
<!-- 驳回状态 --> {{ $t('viewerWork.deadline', { date: deadline }) }}
<template v-if="detail.status === 8"> </p>
<div class="work-bottom">
<div class="info">
<div class="paper-check">
<h4>{{ $t('viewerWork.rejectTips') }}</h4>
<div class="paper-check-item">
<b>{{ $t('viewerWork.rejectTime') }}</b>
{{ detail.checker_time }}
</div>
<div class="paper-check-item">
<b>{{ $t('viewerWork.rejectContent') }}</b>
<div class="edit_html" v-html="detail.check_comments"></div>
</div>
</div>
</div>
</div>
<div class="buttons">
<el-button type="primary" @click="onReEdit">{{ $t('viewerWork.reEdit') }}</el-button>
</div>
</template>
<!-- 正常状态 -->
<template v-else>
<div class="work-bottom" v-if="detail.status !== 1"> <div class="work-bottom" v-if="detail.status !== 1">
<div class="info"> <div class="info">
<template v-if="isRevised"> <template v-if="isRevised">
...@@ -80,19 +59,41 @@ ...@@ -80,19 +59,41 @@
<span>提交后不可修改,请检查好作业内容再做提交。</span> <span>提交后不可修改,请检查好作业内容再做提交。</span>
</template> </template>
<template v-else> <template v-else>
<span v-if="hasComment">{{ $t('viewerWork.commentTips') }}</span> <span v-if="hasComment && !isRevised">{{ $t('viewerWork.commentTips') }}</span>
</template> </template>
</div> </div>
</template> </template>
</container> </container>
<chapter-work-comment <chapter-work-comment
id="comment"
:endDate="commentEndDate" :endDate="commentEndDate"
:status="detail.status2" :status="detail.status2"
@update="getDetail" @update="$emit('updateHomework')"
v-if="showComment" v-if="showComment"
id="comment" >
/> <!-- 已批改 -->
<template v-if="isRevised">
<div class="work-bottom">
<div class="info">
<div class="paper-check">
<p>{{ $t('viewerWork.correctionTime') }}{{ detail.checker_time }}</p>
<div class="paper-check-item" v-if="hasScore">
<b>{{ $t('viewerWork.score') }}</b>
{{ detail.score }}
</div>
<div class="paper-check-item">
<b>{{ $t('viewerWork.comments') }}</b>
<div class="edit_html" v-html="detail.check_comments"></div>
</div>
</div>
</div>
</div>
<div class="buttons">
<el-button type="primary" :disabled="disabled">{{ submitText }}</el-button>
</div>
</template>
</chapter-work-comment>
<el-dialog :title="dialogTitle" :visible.sync="dialogVisible" width="500px"> <el-dialog :title="dialogTitle" :visible.sync="dialogVisible" width="500px">
<div class="paper-check-item"> <div class="paper-check-item">
...@@ -132,19 +133,10 @@ export default { ...@@ -132,19 +133,10 @@ export default {
components: { Container, ExamItem, ChapterWorkComment }, components: { Container, ExamItem, ChapterWorkComment },
props: { props: {
// 当前选中的 // 当前选中的
chapter: { chapter: { type: Object, default: () => ({}) },
type: Object,
default() {
return {}
}
},
// 课程详情接口返回的数据 // 课程详情接口返回的数据
data: { data: { type: Object, default: () => ({}) },
type: Object, homework: { type: Object, default: () => ({}) }
default() {
return {}
}
}
}, },
data() { data() {
return { return {
...@@ -167,11 +159,22 @@ export default { ...@@ -167,11 +159,22 @@ export default {
} }
}, },
watch: { watch: {
chapter: { homework: {
immediate: true, immediate: true,
handler(data) { handler(data) {
if (!this.questions.length) { const { questions = [], answer = {} } = data
this.questions = data.homework ? this.genQuestions(data.homework.questions) : [] this.questions = this.genQuestions(questions)
this.detail = Array.isArray(answer) ? {} : answer
if (
(this.detail.status === 1 || this.detail.status2 === 1) &&
!([-1, -2].includes(this.detail.status) || [-1, -2].includes(this.detail.status2))
) {
this.dialogVisible = true
}
// 答案处理
const parseAnswers = answer.work_contents ? JSON.parse(answer.work_contents) : []
if (parseAnswers && parseAnswers.length) {
this.setAnswers(parseAnswers)
} }
} }
} }
...@@ -219,7 +222,7 @@ export default { ...@@ -219,7 +222,7 @@ export default {
showComment() { showComment() {
const currentTime = new Date().getTime() const currentTime = new Date().getTime()
const endTime = +new Date(this.deadline) const endTime = +new Date(this.deadline)
return this.hasComment && currentTime > endTime return this.hasComment && currentTime > endTime && this.detail.status !== 1
}, },
disabled() { disabled() {
if (this.detail.status === 1) { if (this.detail.status === 1) {
...@@ -245,43 +248,12 @@ export default { ...@@ -245,43 +248,12 @@ export default {
getDeadline() { 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 this.deadline = response.dead_line
this.hasUpload = !!response.pdf this.hasUpload = response.pdf !== 0
this.isAnonymous = !!response.anonymous this.isAnonymous = !!response.anonymous
this.hasComment = !!response.comment this.hasComment = !!response.comment
this.commentEndDate = response.comment_end this.commentEndDate = response.comment_end
}) })
}, },
// 获取详情
getDetail() {
this.loading = true
api
.getChapterHomework(this.sid, this.cid, this.resourceId)
.then(response => {
this.detail = Array.isArray(response) ? {} : response
if (
(this.detail.status === 1 || this.detail.status2 === 1) &&
!([-1, -2].includes(this.detail.status) || [-1, -2].includes(this.detail.status2))
) {
this.dialogVisible = true
}
if (this.detail.id) {
const parseAnswers = JSON.parse(this.detail.work_contents)
// 设置答案
this.questions = this.questions.map(item => {
const found = parseAnswers.find(answer => answer.question_id === item.id)
if (found) {
item.user_answer = found.descreption
item.attachments = found.file_url
}
return item
})
this.questions = this.genQuestions(this.questions)
}
})
.finally(() => {
this.loading = false
})
},
// 组装问题数据 // 组装问题数据
genQuestions(list) { genQuestions(list) {
if (!list) { if (!list) {
...@@ -320,6 +292,19 @@ export default { ...@@ -320,6 +292,19 @@ export default {
) )
}) })
}, },
// 设置答案
setAnswers(parseAnswers) {
this.questions = this.questions.map(item => {
const found = parseAnswers.find(answer => answer.question_id === item.id)
if (found) {
item.user_answer = found.descreption
item.attachments = found.file_url
}
return item
})
// 重新组装数据
this.questions = this.genQuestions(this.questions)
},
// 提交校验 // 提交校验
checkSubmit() { checkSubmit() {
let result = true let result = true
...@@ -385,7 +370,7 @@ export default { ...@@ -385,7 +370,7 @@ export default {
.then(response => { .then(response => {
if (response.status) { if (response.status) {
this.$message.success(this.$t('viewerWork.examSubmitSuccess')) this.$message.success(this.$t('viewerWork.examSubmitSuccess'))
this.getDetail() this.$emit('updateHomework')
} else { } else {
this.$message.error(response.data.error) this.$message.error(response.data.error)
} }
...@@ -410,7 +395,6 @@ export default { ...@@ -410,7 +395,6 @@ export default {
} }
}, },
beforeMount() { beforeMount() {
this.getDetail()
this.getDeadline() this.getDeadline()
} }
} }
......
...@@ -20,14 +20,14 @@ ...@@ -20,14 +20,14 @@
/> </el-form-item /> </el-form-item
></el-form> ></el-form>
</template> </template>
<div class="button"> <div class="button" v-if="status !== 0">
<el-button type="primary" :disabled="disabled" @click="handleSubmit">{{ <el-button type="primary" :disabled="disabled" @click="handleSubmit">{{
$t('viewerWork.commentSubmitText') $t('viewerWork.commentSubmitText')
}}</el-button> }}</el-button>
<p v-if="status === 1">注:重新提交后不可修改,请检查好作业内容再做提交。</p> <p v-if="status === 1">注:重新提交后不可修改,请检查好作业内容再做提交。</p>
<p v-else>{{ $t('viewerWork.commentSubmitTips', { date: endDate }) }}</p> <p v-else>{{ $t('viewerWork.commentSubmitTips', { date: endDate }) }}</p>
</div> </div>
<slot></slot>
<div class="more"> <div class="more">
<router-link :to="`${$route.path}/answers`" target="_blank"> <router-link :to="`${$route.path}/answers`" target="_blank">
<el-button round>{{ $t('viewerWork.answerMoreButtonText') }}</el-button> <el-button round>{{ $t('viewerWork.answerMoreButtonText') }}</el-button>
......
<template> <template>
<component :is="currentCompoent" :chapter="chapter" :data="data" v-bind="$attrs" v-on="$listeners" v-if="chapter" /> <component
:is="currentCompoent"
:chapter="chapter"
:data="data"
:homework="homework"
@updateHomework="getHomework"
v-bind="$attrs"
v-on="$listeners"
v-if="chapter"
v-loading="loading"
/>
</template> </template>
<script> <script>
// componets // componets
import ChapterWork from './chapterWork.vue' import ChapterWork from './chapterWork.vue'
import ChapterTest from './chapterTest.vue' import ChapterTest from './chapterTest.vue'
import * as api from '../../api'
export default { export default {
name: 'ViewerWork', name: 'ViewerWork',
...@@ -26,15 +37,54 @@ export default { ...@@ -26,15 +37,54 @@ export default {
} }
} }
}, },
data() {
return {
loading: false,
homework: {}
}
},
computed: { computed: {
currentCompoent() { currentCompoent() {
const componentNames = { const componentNames = {
1: 'ChapterTest', // 课后测验 1: 'ChapterTest', // 课后测验
2: 'ChapterWork' // 作业 2: 'ChapterWork' // 作业
} }
const homework = this.chapter.homework const homework = this.homework
return homework ? componentNames[homework.work_type] : '' return homework ? componentNames[homework.work_type] : ''
},
// 学期ID
sid() {
return this.$route.params.sid
},
// 课程ID
cid() {
return this.$route.params.cid
},
// 当前页面的ID
pid() {
return this.$route.params.id
},
// 资源ID
resourceId() {
return this.chapter.resource_id
}
},
methods: {
getHomework() {
this.loading = true
api
.getChapterHomework(this.sid, this.cid, this.resourceId)
.then(response => {
const { answer, question } = response
this.homework = { answer, ...question }
})
.finally(() => {
this.loading = false
})
} }
},
beforeMount() {
this.getHomework()
} }
} }
</script> </script>
<!--课程考核--> <!--课程考核-->
<template> <template>
<div class="course-assess-standard"> <div class="course-assess-standard" v-if="checkList.length">
<div class="subtitle"> <div class="subtitle">
<span>{{ $t('pages.learn.courseDetail.Courseassessmentstandard') }}</span> <span>{{ $t('pages.learn.courseDetail.Courseassessmentstandard') }}</span>
</div> </div>
......
...@@ -33,7 +33,7 @@ ...@@ -33,7 +33,7 @@
<el-tab-pane lazy :label="$t('pages.learn.courseDetail.Courseassessment')"> <el-tab-pane lazy :label="$t('pages.learn.courseDetail.Courseassessment')">
<course-assessment :course="detail"></course-assessment> <course-assessment :course="detail"></course-assessment>
</el-tab-pane> </el-tab-pane>
<el-tab-pane lazy label="课程直播"> <el-tab-pane lazy label="课程直播" v-if="detail.meetings && detail.meetings.length">
<course-live :course="detail"></course-live> <course-live :course="detail"></course-live>
</el-tab-pane> </el-tab-pane>
</el-tabs> </el-tabs>
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论