|
|
@@ -2,16 +2,38 @@
|
|
|
<div class="tab complex-tab">
|
|
|
<div class="left">
|
|
|
<h1 class="title">课程测验 <c-tag theme="green">学生</c-tag></h1>
|
|
|
- <div class="sub-title">待完成的测验</div>
|
|
|
- <quiz-card
|
|
|
- :key="quiz.id" v-for="quiz in ongoingQuizzes"
|
|
|
- :nav-path="{ name: 'student-quiz-detail', params: { quizId: quiz.id } }"
|
|
|
- :quiz="quiz" hide-quiz-state hide-quiz-time />
|
|
|
- <div class="sub-title">已完成的测验 & 结果</div>
|
|
|
- <quiz-card
|
|
|
- :key="quiz.id" v-for="quiz in closedQuizzes"
|
|
|
- :nav-path="{ name: 'student-quiz-detail', params: { quizId: quiz.id } }"
|
|
|
- :quiz="quiz" hide-quiz-state hide-quiz-time />
|
|
|
+ <div class="show-quiz-type-bar mb-24">
|
|
|
+ <c-button block :right="6" @click="showOngoing = true" :theme="showOngoing ? 'green' : 'normal'">进行中</c-button>
|
|
|
+ <c-button block :left="6" @click="showOngoing = false" :theme="showOngoing ? 'normal' : 'green'">已结束</c-button>
|
|
|
+ </div>
|
|
|
+ <div v-if="showOngoing">
|
|
|
+ <div class="sub-title">
|
|
|
+ 待完成测验
|
|
|
+ <c-button text :left="4" theme="blue" :icon="showMore ? 'unfold_less' : 'unfold_more'" @click="showMore = !showMore">
|
|
|
+ {{showMore ? '收起' : '展开'}}详情
|
|
|
+ </c-button>
|
|
|
+ </div>
|
|
|
+ <quiz-card
|
|
|
+ :hide-slide-name="!showMore"
|
|
|
+ :hide-course-name="!showMore"
|
|
|
+ :key="quiz.id" v-for="quiz in ongoingQuizzes"
|
|
|
+ :nav-path="{ name: 'student-quiz-detail', params: { quizId: quiz.id } }"
|
|
|
+ :quiz="quiz" hide-quiz-state hide-quiz-time />
|
|
|
+ </div>
|
|
|
+ <div v-else>
|
|
|
+ <div class="sub-title">
|
|
|
+ 已结束测验
|
|
|
+ <c-button text :left="4" theme="blue" :icon="showMore ? 'unfold_less' : 'unfold_more'" @click="showMore = !showMore">
|
|
|
+ {{showMore ? '收起' : '展开'}}详情
|
|
|
+ </c-button>
|
|
|
+ </div>
|
|
|
+ <quiz-card
|
|
|
+ :hide-slide-name="!showMore"
|
|
|
+ :hide-course-name="!showMore"
|
|
|
+ :key="quiz.id" v-for="quiz in closedQuizzes"
|
|
|
+ :nav-path="{ name: 'student-quiz-detail', params: { quizId: quiz.id } }"
|
|
|
+ :quiz="quiz" hide-quiz-state hide-quiz-time />
|
|
|
+ </div>
|
|
|
</div>
|
|
|
<router-view />
|
|
|
</div>
|
|
|
@@ -22,18 +44,33 @@ import { getQuizList } from '@/server/quiz'
|
|
|
import { QuizState } from '@/server/enums/quiz-state'
|
|
|
import CTag from '@/components/Basic/CTag'
|
|
|
import QuizCard from '@/components/Cards/QuizCard'
|
|
|
+import CButton from '@/components/Basic/CButton'
|
|
|
|
|
|
export default {
|
|
|
- components: { QuizCard, CTag },
|
|
|
+ components: { CButton, QuizCard, CTag },
|
|
|
data() {
|
|
|
return {
|
|
|
ongoingQuizzes: [],
|
|
|
- closedQuizzes: []
|
|
|
+ closedQuizzes: [],
|
|
|
+ showOngoing: true,
|
|
|
+ showMore: false
|
|
|
+ }
|
|
|
+ },
|
|
|
+ watch: {
|
|
|
+ showOngoing (newValue) {
|
|
|
+ if (newValue) {
|
|
|
+ this.showMore = this.ongoingQuizzes.length < 5
|
|
|
+ } else {
|
|
|
+ this.showMore = this.closedQuizzes.length < 5
|
|
|
+ }
|
|
|
}
|
|
|
},
|
|
|
mounted() {
|
|
|
getQuizList({ state: QuizState.ongoing })
|
|
|
- .then(res => (this.ongoingQuizzes = res.quizzes))
|
|
|
+ .then(res => {
|
|
|
+ this.ongoingQuizzes = res.quizzes
|
|
|
+ this.showMore = res.quizzes.length < 5
|
|
|
+ })
|
|
|
.catch(err => this.$setErrorMessage(err.response.data.msg))
|
|
|
getQuizList({ state: QuizState.closed })
|
|
|
.then(res => (this.closedQuizzes = res.quizzes))
|
|
|
@@ -45,4 +82,13 @@ export default {
|
|
|
<style lang="scss" scoped>
|
|
|
@import "~@/style/theme.scss";
|
|
|
@import "~@/views/shared/tab-common";
|
|
|
+
|
|
|
+.show-quiz-type-bar {
|
|
|
+ display: flex;
|
|
|
+}
|
|
|
+
|
|
|
+.sub-title {
|
|
|
+ display: flex;
|
|
|
+ align-items: center;
|
|
|
+}
|
|
|
</style>
|