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

Merge branch 'master' into kelley

......@@ -40,7 +40,7 @@ export default class CourseAction extends BaseACTION {
const cur = data[i]
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')
: (_type === 2 ? _vIn.$t('action.courseAction.changeLearn')
: (_type === 3 ? _vIn.$t('action.courseAction.repeatLearn') : ''))
......
......@@ -8,7 +8,7 @@ const httpRequest = new BaseAPI(webConf)
* @param {string} courseId 课程ID
*/
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 {
* @param {[string]} isMy
* @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
......
......@@ -8,7 +8,7 @@ const httpRequest = new BaseAPI(webConf)
* @param {string} courseId 课程ID
*/
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) {
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
......@@ -60,7 +68,7 @@ export function updateChapterVideoProgress(params) {
* @param {string} resourseId 章节的资源ID
*/
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 @@
// components
import Container from '../common/container.vue'
import FileList from './fileList.vue'
import * as api from '../../api'
// 章节阅读资料
export default {
......@@ -30,15 +31,30 @@ export default {
}
}
},
data() {
return {
files: []
}
},
computed: {
files() {
const reading = this.chapter.reading
// 资源ID
resourceId() {
return this.chapter.resource_id
}
},
methods: {
getChapterReading() {
api.getChapterReading(this.resourceId).then(response => {
const file = {
file_name: reading.reading_content,
file_url: reading.reading_attachment
file_name: response.reading_content,
file_url: response.reading_attachment
}
return [file]
this.files = [file]
})
}
},
beforeMount() {
this.getChapterReading()
}
}
</script>
......@@ -39,12 +39,8 @@ export default {
components: { Container, ExamItem },
props: {
// 当前选中的章节
chapter: {
type: Object,
default() {
return {}
}
}
chapter: { type: Object, default: () => ({}) },
homework: { type: Object, default: () => ({}) }
},
data() {
return {
......@@ -57,11 +53,16 @@ export default {
}
},
watch: {
chapter: {
homework: {
immediate: true,
handler(data) {
if (!this.questions.length) {
this.questions = data.homework ? this.genQuestions(data.homework.questions) : []
const { questions = [], answer = {} } = data
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 {
}
},
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) {
if (!list) {
......@@ -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() {
const questions = this.questions
......@@ -245,7 +234,7 @@ export default {
.sbumitChapterHomework(params)
.then(response => {
if (response.status) {
this.getDetail()
this.$emit('updateHomework')
} else {
this.$message.error(response.data.error)
}
......@@ -257,9 +246,6 @@ export default {
this.submitLoading = false
})
}
},
beforeMount() {
this.getDetail()
}
}
</script>
......
......@@ -20,32 +20,11 @@
</el-form>
</template>
</div>
<!-- 有互评的,批改后不显示 -->
<template v-if="!(hasComment && isRevised)">
<p style="color: red" v-if="deadline && detail.status !== 1">
{{ $t('viewerWork.deadline', { date: deadline }) }}
</p>
<!-- 驳回状态 -->
<template v-if="detail.status === 8">
<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="info">
<template v-if="isRevised">
......@@ -80,19 +59,41 @@
<span>提交后不可修改,请检查好作业内容再做提交。</span>
</template>
<template v-else>
<span v-if="hasComment">{{ $t('viewerWork.commentTips') }}</span>
<span v-if="hasComment && !isRevised">{{ $t('viewerWork.commentTips') }}</span>
</template>
</div>
</template>
</container>
<chapter-work-comment
id="comment"
:endDate="commentEndDate"
:status="detail.status2"
@update="getDetail"
@update="$emit('updateHomework')"
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">
<div class="paper-check-item">
......@@ -132,19 +133,10 @@ export default {
components: { Container, ExamItem, ChapterWorkComment },
props: {
// 当前选中的
chapter: {
type: Object,
default() {
return {}
}
},
chapter: { type: Object, default: () => ({}) },
// 课程详情接口返回的数据
data: {
type: Object,
default() {
return {}
}
}
data: { type: Object, default: () => ({}) },
homework: { type: Object, default: () => ({}) }
},
data() {
return {
......@@ -167,11 +159,22 @@ export default {
}
},
watch: {
chapter: {
homework: {
immediate: true,
handler(data) {
if (!this.questions.length) {
this.questions = data.homework ? this.genQuestions(data.homework.questions) : []
const { questions = [], answer = {} } = data
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 {
showComment() {
const currentTime = new Date().getTime()
const endTime = +new Date(this.deadline)
return this.hasComment && currentTime > endTime
return this.hasComment && currentTime > endTime && this.detail.status !== 1
},
disabled() {
if (this.detail.status === 1) {
......@@ -245,43 +248,12 @@ export default {
getDeadline() {
api.getChapterHomeworkDeadline(this.sid, this.cid, this.pid).then(response => {
this.deadline = response.dead_line
this.hasUpload = !!response.pdf
this.hasUpload = response.pdf !== 0
this.isAnonymous = !!response.anonymous
this.hasComment = !!response.comment
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) {
if (!list) {
......@@ -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() {
let result = true
......@@ -385,7 +370,7 @@ export default {
.then(response => {
if (response.status) {
this.$message.success(this.$t('viewerWork.examSubmitSuccess'))
this.getDetail()
this.$emit('updateHomework')
} else {
this.$message.error(response.data.error)
}
......@@ -410,7 +395,6 @@ export default {
}
},
beforeMount() {
this.getDetail()
this.getDeadline()
}
}
......
......@@ -20,14 +20,14 @@
/> </el-form-item
></el-form>
</template>
<div class="button">
<div class="button" v-if="status !== 0">
<el-button type="primary" :disabled="disabled" @click="handleSubmit">{{
$t('viewerWork.commentSubmitText')
}}</el-button>
<p v-if="status === 1">注:重新提交后不可修改,请检查好作业内容再做提交。</p>
<p v-else>{{ $t('viewerWork.commentSubmitTips', { date: endDate }) }}</p>
</div>
<slot></slot>
<div class="more">
<router-link :to="`${$route.path}/answers`" target="_blank">
<el-button round>{{ $t('viewerWork.answerMoreButtonText') }}</el-button>
......
<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>
<script>
// componets
import ChapterWork from './chapterWork.vue'
import ChapterTest from './chapterTest.vue'
import * as api from '../../api'
export default {
name: 'ViewerWork',
......@@ -26,15 +37,54 @@ export default {
}
}
},
data() {
return {
loading: false,
homework: {}
}
},
computed: {
currentCompoent() {
const componentNames = {
1: 'ChapterTest', // 课后测验
2: 'ChapterWork' // 作业
}
const homework = this.chapter.homework
const homework = this.homework
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>
<!--课程考核-->
<template>
<div class="course-assess-standard">
<div class="course-assess-standard" v-if="checkList.length">
<div class="subtitle">
<span>{{ $t('pages.learn.courseDetail.Courseassessmentstandard') }}</span>
</div>
......
......@@ -33,7 +33,7 @@
<el-tab-pane lazy :label="$t('pages.learn.courseDetail.Courseassessment')" v-if="false">
<course-assessment :course="detail"></course-assessment>
</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>
</el-tab-pane>
</el-tabs>
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论