| | |
| | | import axios from "axios"; |
| | | import { useRoute } from "vue-router"; |
| | | |
| | | const route = useRoute(); |
| | | |
| | | axios.defaults.headers["Content-Type"] = "application/json;charset=utf-8"; |
| | | |
| | | const service = axios.create({ |
| | |
| | | import { ref,computed } from 'vue'; |
| | | import { ref, computed } from 'vue'; |
| | | import { defineStore } from 'pinia'; |
| | | export const useExamStore = defineStore('exam', () => { |
| | | const examInfo = ref({ |
| | |
| | | } |
| | | ], |
| | | "analyze": "问小朋友", |
| | | "correct": "B", |
| | | "correct": "", |
| | | "score": "", |
| | | "difficult": 5 |
| | | }, |
| | |
| | | } |
| | | ], |
| | | "analyze": "问小朋友", |
| | | "correct": "B", |
| | | "correct": "", |
| | | "score": "", |
| | | "difficult": 5 |
| | | } |
| | |
| | | } |
| | | ], |
| | | "analyze": "问小朋友", |
| | | "correct": "B", |
| | | "correct": "", |
| | | "score": "", |
| | | "difficult": 5 |
| | | }, |
| | |
| | | } |
| | | ], |
| | | "analyze": "问小朋友", |
| | | "correct": "B", |
| | | "correct": "", |
| | | "score": "", |
| | | "difficult": 5 |
| | | } |
| | |
| | | ]); |
| | | |
| | | const activeQuestion = ref(null); |
| | | |
| | | |
| | | const getActiveQuestion = computed(() => { |
| | | const temp = examDetail.value.find(item => item.questionType === currentType.value); |
| | | if(temp) { |
| | | return temp.questionList[currentIndex.value]; |
| | | } |
| | | }) |
| | | |
| | | const setExamInfo = (info) => { |
| | | examInfo.value = info; |
| | |
| | | activeQuestion.value = detail; |
| | | }; |
| | | |
| | | const setQuestionAnswer = (type, index, answer) => { |
| | | const temp = examDetail.value.find(item => item.questionType === type); |
| | | if(temp) { |
| | | temp.questionList[index].correct = answer; |
| | | } |
| | | }; |
| | | |
| | | |
| | | return { |
| | | examInfo, |
| | | examDetail, |
| | |
| | | activeQuestion, |
| | | currentType, |
| | | currentIndex, |
| | | getActiveQuestion, |
| | | setExamInfo, |
| | | setExamDetail, |
| | | setActiveQuestion |
| | | setActiveQuestion, |
| | | setQuestionAnswer |
| | | }; |
| | | }); |
| | |
| | | |
| | | const examStore = useExamStore(); |
| | | |
| | | const {currentIndex,activeQuestion} = storeToRefs(examStore); |
| | | const {currentIndex} = storeToRefs(examStore); |
| | | |
| | | const activeQuestion = ref(examStore.getActiveQuestion); |
| | | |
| | | const answerClick = (item) => { |
| | | if(item) { |
| | | // resetAnswer(); |
| | |
| | | </template> |
| | | |
| | | <script setup> |
| | | import { ref } from 'vue'; |
| | | import { ref, onMounted } from 'vue'; |
| | | import {storeToRefs} from 'pinia'; |
| | | import ExamInfo from '@/components/ExamInfo/index.vue'; |
| | | import {useExamStore} from '@/store/index.js'; |
| | | const examStore = useExamStore(); |
| | | |
| | | const {currentType,currentIndex,activeQuestion,examDetail} = storeToRefs(examStore); |
| | | const {currentType,currentIndex,examDetail} = storeToRefs(examStore); |
| | | |
| | | const activeQuestion = ref(examStore.getActiveQuestion); |
| | | |
| | | const answerClick = (item) => { |
| | | if(item) { |
| | | resetAnswer(); |
| | | item.isActive = true; |
| | | |
| | | examStore.setQuestionAnswer(currentType.value, currentIndex.value, item.prefix); |
| | | } |
| | | }; |
| | | |
| | |
| | | activeQuestion.value.items.forEach(item => item.isActive = false); |
| | | } |
| | | |
| | | const filterExam = () => { |
| | | |
| | | } |
| | | |
| | | </script> |
| | | |
| | |
| | | <template v-for="item in examDetail"> |
| | | <el-collapse-item :title="examType[item.questionType]" :name="item.questionType"> |
| | | <div class="sheet-list grid grid-cols-5 gap-4 justify-items-center"> |
| | | <div class="sheet-item cursor-pointer flex justify-center items-center" v-for="question,index in item.questionList" @click="sheetClick(item.questionType,index,question)" :class="itemClass(item,item.questionType, index)"> |
| | | <div class="sheet-item cursor-pointer flex justify-center items-center" v-for="question,index in item.questionList" @click="sheetClick(item.questionType,index)" :class="itemClass(item,item.questionType, index)"> |
| | | {{ index + 1 }} |
| | | </div> |
| | | </div> |
| | |
| | | |
| | | const activeNames = ref(examDetail.value.map(item => item.questionType)); |
| | | |
| | | const sheetClick = (type,index,question) => { |
| | | const sheetClick = (type,index) => { |
| | | currentType.value = type; |
| | | currentIndex.value = index; |
| | | examStore.setActiveQuestion(question); |
| | | } |
| | | </script> |
| | | |
| | |
| | | .active { |
| | | border-color: #3680fa; |
| | | } |
| | | .answer { |
| | | border-color: #3680fa !important; |
| | | background-color: #3680fa !important; |
| | | color: #fff !important; |
| | | } |
| | | </style> |
| | |
| | | <el-dialog v-model="dialogVisible" title="注意" width="500"> |
| | | <div class="dialog-container"> |
| | | <p>请确认是否退出当前考试</p> |
| | | <p>当前考试试卷会自动提交,后续无法继续作答</p> |
| | | <p>当前考试试卷会自动提交,后续将无法继续作答</p> |
| | | </div> |
| | | <template #footer> |
| | | <div class="dialog-footer"> |
| | |
| | | const router = useRouter(); |
| | | |
| | | const examStore = useExamStore(); |
| | | const { currentType, currentIndex, activeQuestion, examDetail } = storeToRefs(examStore); |
| | | const { currentType, currentIndex, examDetail } = storeToRefs(examStore); |
| | | |
| | | const typeComponent = { |
| | | 1: AnswerSingle, |
| | | 2: AnswerMultiple, |
| | | }; |
| | | examStore.setActiveQuestion(examDetail.value[0].questionList[0]); |
| | | |
| | | const dialogVisible = ref(false); |
| | | |
| | |
| | | currentIndex.value = 0; |
| | | } |
| | | } |
| | | findQuestion(currentType.value, currentIndex.value); |
| | | // findQuestion(currentType.value, currentIndex.value); |
| | | } |
| | | |
| | | }; |