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