ZhangXianQiang
2024-06-19 706fc58eea8b31ecd2e5003615a4874bf0200d76
src/views/exam/index.vue
@@ -78,7 +78,7 @@
    </div>
    <!-- 提示弹窗 -->
    <!-- 退出考试提示弹窗 -->
    <el-dialog v-model="dialogVisible" title="注意" width="500">
      <div class="dialog-container">
        <p>请确认是否退出当前考试</p>
@@ -97,7 +97,7 @@
</template>
<script setup>
import { ref } from 'vue';
import { ref, watchEffect } from 'vue';
import { storeToRefs } from 'pinia';
import { Close } from '@element-plus/icons-vue';
import AnswerTag from './components/answer-tag/index.vue';
@@ -144,17 +144,17 @@
  if (typeQuestion) {
    if (currentIndex.value >= typeQuestion.questionList.length) {
      tempIndex++;
      if(examDetail.value[tempIndex]) {
      if (examDetail.value[tempIndex]) {
        currentType.value = examDetail.value[tempIndex].questionType;
        currentIndex.value = 0;
      } else {
        currentType.value = typeQuestion.questionType;
        currentIndex.value = typeQuestion.questionList.length - 1;
      }
    } else if (currentIndex.value < 0) {
      tempIndex--;
      if(examDetail.value[tempIndex]) {
      if (examDetail.value[tempIndex]) {
        currentType.value = examDetail.value[tempIndex].questionType;
        currentIndex.value = examDetail.value[tempIndex].questionList.length - 1;
      } else {
@@ -185,6 +185,18 @@
  dialogVisible.value = false;
  router.back();
};
watchEffect(() => {
  let progress = 0;
  examDetail.value.forEach(item => {
    item.questionList.forEach(question => {
      if(question.correct) {
        progress += 1;
      }
    });
  });
  examStore.setProgress(progress);
});
</script>
<style lang="scss" scoped>