|
|
@@ -0,0 +1,154 @@
|
|
|
+<template>
|
|
|
+ <div class="student-question-table">
|
|
|
+ <div v-if="questionsList === null" class="no-content-warning">加载中...</div>
|
|
|
+ <div v-else-if="questionsList.length === 0" class="no-content-warning">无内容</div>
|
|
|
+ <template v-else>
|
|
|
+ <div class="left">
|
|
|
+ <template v-for="question of questionsList">
|
|
|
+ <question-card
|
|
|
+ @click.native="onShowQuestion === question ? onShowQuestion = null : onShowQuestion = question"
|
|
|
+ v-if="question !== null"
|
|
|
+ :style="onShowQuestion === question ? 'box-shadow: 0 4px 6px rgba(0, 0, 0, .1);' : ''"
|
|
|
+ :key="question.id"
|
|
|
+ :type="question.type"
|
|
|
+ :stem="question.stem"
|
|
|
+ :question-id="question.id"
|
|
|
+ student-mode
|
|
|
+ />
|
|
|
+ </template>
|
|
|
+ </div>
|
|
|
+ <div class="right">
|
|
|
+ <div v-if="onShowQuestion">
|
|
|
+ <question-detail-factory :question="onShowQuestion"></question-detail-factory>
|
|
|
+ <mark-action-bar v-if="interactiveMap" :marked-prop="interactiveMap[onShowQuestion.id].marked"
|
|
|
+ :rate-prop="interactiveMap[onShowQuestion.id].rate"
|
|
|
+ :question-id="onShowQuestion.id"></mark-action-bar>
|
|
|
+ </div>
|
|
|
+ <div v-else-if="questionsList && questionsList.length > 0" class="no-content-warning">未选中具体题目</div>
|
|
|
+ <pagination @change="handlePageChange" v-show="questionsList && questionsList.length > 0" :page="page"
|
|
|
+ :size="size"
|
|
|
+ :total-elements="totalElements"></pagination>
|
|
|
+ </div>
|
|
|
+ </template>
|
|
|
+ </div>
|
|
|
+</template>
|
|
|
+
|
|
|
+<script>
|
|
|
+import Pagination from '@/components/Pagination'
|
|
|
+import QuestionDetailFactory from '@/views/quiz/components/QuestionDetailFactory'
|
|
|
+import QuestionCard from '@/views/quiz/components/QuestionCard'
|
|
|
+import MarkActionBar from '@/views/quiz/components/MarkActionBar'
|
|
|
+import { getInteractiveList } from '@/server/question'
|
|
|
+
|
|
|
+export default {
|
|
|
+ name: 'StudentQuestionTable',
|
|
|
+ components: { MarkActionBar, QuestionCard, QuestionDetailFactory, Pagination },
|
|
|
+ props: {
|
|
|
+ getListFunction: Function
|
|
|
+ },
|
|
|
+ data () {
|
|
|
+ return {
|
|
|
+ questionsList: null,
|
|
|
+ onShowQuestion: null,
|
|
|
+ page: 1,
|
|
|
+ size: 6,
|
|
|
+ totalElements: 0,
|
|
|
+ interactiveMap: null
|
|
|
+ }
|
|
|
+ },
|
|
|
+ watch: {
|
|
|
+ getListFunction: {
|
|
|
+ handler () {
|
|
|
+ this.fetchQuestions()
|
|
|
+ this.onShowQuestion = null
|
|
|
+ },
|
|
|
+ immediate: true
|
|
|
+ }
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ fetchQuestions () {
|
|
|
+ this.questionsList = null
|
|
|
+ this.interactiveMap = null
|
|
|
+ this.getListFunction && this.getListFunction({ page: this.page, size: this.size })
|
|
|
+ .then(res => {
|
|
|
+ this.totalElements = res.page.totalElements
|
|
|
+ this.questionsList = res.data
|
|
|
+ if (this.page > res.page.totalPages) {
|
|
|
+ this.page = res.page.totalPages
|
|
|
+ this.fetchQuestions()
|
|
|
+ }
|
|
|
+ getInteractiveList({ questionIdJoinByComma: res.data.map(_ => _.id).join(',') }).then(res => {
|
|
|
+ const tempMap = {}
|
|
|
+ res.forEach(item => {
|
|
|
+ tempMap[item.questionId] = { marked: item.collection, rate: item.rate }
|
|
|
+ })
|
|
|
+ this.interactiveMap = tempMap
|
|
|
+ }).catch(err => this.$setErrorMessage(err.response.data.msg))
|
|
|
+ })
|
|
|
+ .catch(err => this.$setErrorMessage(err))
|
|
|
+ },
|
|
|
+ handlePageChange ({ page }) {
|
|
|
+ this.page = page
|
|
|
+ this.onShowQuestion = null
|
|
|
+ this.fetchQuestions()
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+</script>
|
|
|
+
|
|
|
+<style lang="scss" scoped>
|
|
|
+@import "~@/style/theme.scss";
|
|
|
+
|
|
|
+@media (min-width: 720px) {
|
|
|
+ .student-question-table {
|
|
|
+ display: flex;
|
|
|
+ box-sizing: border-box;
|
|
|
+ background-color: #f8f8f8;
|
|
|
+ justify-content: center;
|
|
|
+ min-height: 350px;
|
|
|
+ }
|
|
|
+
|
|
|
+ .left {
|
|
|
+ padding: 24px;
|
|
|
+ width: 1px;
|
|
|
+ max-width: 350px;
|
|
|
+ flex: 1;
|
|
|
+ }
|
|
|
+
|
|
|
+ .right {
|
|
|
+ width: 1px;
|
|
|
+ flex: 1;
|
|
|
+ display: flex;
|
|
|
+ flex-direction: column;
|
|
|
+ justify-content: space-between;
|
|
|
+ min-height: 200px;
|
|
|
+
|
|
|
+ .no-content-warning {
|
|
|
+ height: unset;
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+.right {
|
|
|
+ margin-top: 16px;
|
|
|
+ padding: 24px;
|
|
|
+}
|
|
|
+
|
|
|
+.question-card {
|
|
|
+ cursor: pointer;
|
|
|
+ margin-top: 12px;
|
|
|
+ break-inside: avoid;
|
|
|
+ border-radius: 12px;
|
|
|
+ background-color: white;
|
|
|
+ transition: .2s;
|
|
|
+ box-shadow: 0 1px 3px rgba(0, 0, 0, .05);
|
|
|
+
|
|
|
+ &:hover {
|
|
|
+ box-shadow: 2px 4px 6px rgba(0, 0, 0, .05);
|
|
|
+ }
|
|
|
+
|
|
|
+ &:last-child {
|
|
|
+ margin-bottom: 12px;
|
|
|
+ }
|
|
|
+}
|
|
|
+</style>
|