提交 10c4fab5 authored 作者: lihuihui's avatar lihuihui
...@@ -80,7 +80,7 @@ export default { ...@@ -80,7 +80,7 @@ export default {
const path = type === 3 ? '/course/chapter/result' : '/course/exam/chapter' const path = type === 3 ? '/course/chapter/result' : '/course/exam/chapter'
this.$router.push({ this.$router.push({
path: path, path: path,
query: { course_id: this.courseId, chapter_id: data.id, type } query: { course_id: this.courseId, chapter_id: data.id, type, exam_id: data.resource_id }
}) })
}, },
handleDownload(item) { handleDownload(item) {
......
...@@ -25,13 +25,23 @@ ...@@ -25,13 +25,23 @@
<el-tab-pane lazy label="课程内容"> <el-tab-pane lazy label="课程内容">
<course-chapter :courseId="courseId" :showProgress="true" :data="detail.chapters"></course-chapter> <course-chapter :courseId="courseId" :showProgress="true" :data="detail.chapters"></course-chapter>
</el-tab-pane> </el-tab-pane>
<el-tab-pane v-if="examList.length" lazy label="课后习题"> <el-tab-pane v-if="examList.length" lazy label="全部习题">
<ul class="exam-list"> <ul class="exam-list">
<li v-for="item in examList" :key="item.id"> <li v-for="item in examList" :key="item.id">
<router-link <div class="name">
:to="{ path: '/course/exam/chapter', query: { course_id: courseId, chapter_id: item.id,exam_id: item.resource_id } }" {{ item.name }}
>{{ item.name }}</router-link </div>
> <div class="buttons">
<el-button round size="mini" v-if="item.status === 100" @click="toExamPage(item, 1)">
测试
</el-button>
<el-button round size="mini" v-if="[0, 3].includes(item.status)" @click="toExamPage(item, 2)">
继续测试
</el-button>
<template v-if="[1, 2].includes(item.status)">
<el-button round size="mini" @click="toExamPage(item, 3)">报告</el-button>
</template>
</div>
</li> </li>
</ul> </ul>
</el-tab-pane> </el-tab-pane>
...@@ -68,8 +78,7 @@ export default { ...@@ -68,8 +78,7 @@ export default {
return { return {
tabActive: 0, tabActive: 0,
loaded: false, loaded: false,
detail: {}, detail: {}
examList: []
} }
}, },
computed: { computed: {
...@@ -81,9 +90,13 @@ export default { ...@@ -81,9 +90,13 @@ export default {
}, },
// 扁平化章节数据 // 扁平化章节数据
flatChapters() { flatChapters() {
if (this.detail.chapters && this.detail.chapters.length) {
return this.detail.chapters.reduce((result, item) => { return this.detail.chapters.reduce((result, item) => {
return result.concat(item.children) return result.concat(item.children)
}, []) }, [])
} else {
return []
}
}, },
// 最新的视频 // 最新的视频
latestVideo() { latestVideo() {
...@@ -92,6 +105,9 @@ export default { ...@@ -92,6 +105,9 @@ export default {
} else { } else {
return this.flatChapters.length ? this.flatChapters[0] : null return this.flatChapters.length ? this.flatChapters[0] : null
} }
},
examList() {
return this.flatChapters.filter(item => item.type === 9)
} }
}, },
methods: { methods: {
...@@ -101,18 +117,6 @@ export default { ...@@ -101,18 +117,6 @@ export default {
api api
.getCourse(this.courseId) .getCourse(this.courseId)
.then(response => { .then(response => {
if (response.chapters.length) {
const examList = []
response.chapters.forEach(item => {
item.children.forEach((it, index) => {
if (it.type === 9) {
examList.push(it)
item.children.splice(index, 1)
}
})
})
this.examList = examList
}
if (response.files && response.files.length) { if (response.files && response.files.length) {
response.chapters.push({ response.chapters.push({
id: '1', id: '1',
...@@ -120,7 +124,6 @@ export default { ...@@ -120,7 +124,6 @@ export default {
children: response.files children: response.files
}) })
} }
console.log(response)
this.detail = response this.detail = response
}) })
.finally(() => { .finally(() => {
...@@ -133,6 +136,13 @@ export default { ...@@ -133,6 +136,13 @@ export default {
}, },
onChapterClick(data) { onChapterClick(data) {
this.$router.push({ name: 'viewerCourseChapter', params: { cid: this.courseId, id: data.id } }) this.$router.push({ name: 'viewerCourseChapter', params: { cid: this.courseId, id: data.id } })
},
toExamPage(data, type) {
const path = type === 3 ? '/course/chapter/result' : '/course/exam/chapter'
this.$router.push({
path: path,
query: { course_id: this.courseId, chapter_id: data.id, type, exam_id: data.resource_id }
})
} }
}, },
beforeMount() { beforeMount() {
...@@ -204,12 +214,19 @@ export default { ...@@ -204,12 +214,19 @@ export default {
margin-left: 20px; margin-left: 20px;
width: 300px; width: 300px;
} }
.exam-list li { .exam-list {
li {
display: flex;
padding: 5px 0; padding: 5px 0;
line-height: 22px;
cursor: pointer; cursor: pointer;
color: #666;
&:hover { &:hover {
color: #c01540; color: #c01540;
} }
.name {
flex: 1;
overflow: hidden;
}
}
} }
</style> </style>
<template> <template>
<app-container title="模拟考试"> <app-container title="模拟考试">
<template #header-right>
<el-select v-model="courseId" @change="getExamList" placeholder="请选择课程" clearable style="width:300px">
<el-option v-for="item in courses" :key="item.id" :label="item.course_name" :value="item.id"></el-option>
</el-select>
</template>
<div class="exam-list"> <div class="exam-list">
<template v-for="item in examList"> <template v-for="item in examList">
<el-card shadow="hover" class="exam-item" :key="item.id" @click.native="startExam(item)"> <el-card shadow="hover" class="exam-item" :key="item.id" @click.native="startExam(item)">
...@@ -23,6 +28,8 @@ export default { ...@@ -23,6 +28,8 @@ export default {
components: { AppContainer }, components: { AppContainer },
data() { data() {
return { return {
courseId: '',
courses: [],
examList: [] examList: []
} }
}, },
...@@ -31,9 +38,10 @@ export default { ...@@ -31,9 +38,10 @@ export default {
}, },
methods: { methods: {
getExamList() { getExamList() {
api.getExamList().then(response => { api.getExamList({ course_id: this.courseId }).then(response => {
// 考试状态(0,3:已缓存,1:已提交,2:已评阅,100:未做) // 考试状态(0,3:已缓存,1:已提交,2:已评阅,100:未做)
this.examList = response.papers this.examList = response.papers
this.courses = response.courses
}) })
}, },
startExam(item) { startExam(item) {
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论