123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434 |
- <template>
- <view class="phone-score-page">
- <!-- 导航区域 -->
- <view class="icon-title-bjcolor-navBar-box">
- <view @click="handleBack" class="nav-bar-icon"></view>
- <text class="nav-bar-title">{{data.ksName}}</text>
- </view>
- <!-- 上方区域 -->
- <topCard @openCard="handleOpenCard" :name="data.ksName" :zyLevelName="data.zyLevelName" :userScore="data.userScore" :Score="data.ksScore"></topCard>
-
- <!-- 段落 -->
- <view class="score-shiti-content">
- <!-- 试题区域 -->
- <view v-if="activeSt">
- <template v-if="activeSt.stTypeId == 1">
- <!-- 单选 -->
- <danxuan :question="activeSt" :key="activeSt.stId"></danxuan>
- </template>
- <template v-if="activeSt.stTypeId == 2">
- <!-- 多选 -->
- <duoxuan :question="activeSt" :key="activeSt.stId"></duoxuan>
- </template>
- <template v-if="activeSt.stTypeId == 3">
- <!-- 判断 -->
- <panduan :question="activeSt" :key="activeSt.stId"></panduan>
- </template>
- <template v-if="activeSt.stTypeId == 4">
- <!-- 填空 -->
- <tiankong :question="activeSt" :key="activeSt.stId"></tiankong>
- </template>
- </view>
- <!-- 解析 -->
- <view v-if="activeSt" class="score-answer-box">
- <view class="phone-question-answer-box" v-if="activeSt.stTypeId != 4">
- <view class="phone-line-title">答案解析</view>
- <view class="btdf-row">本题得分:<text>{{answerRes.score}}</text>分</view>
- <view class="zqda-row">正确答案:<text>{{answerRes.result}}</text></view>
- <view class="ndda-row">您的答案:<text>{{answerRes.reply}}</text></view>
- <view class="dajx-row">答案解析:
- <rich-text :nodes="answerRes.answer"></rich-text>
- </view>
- </view>
- <view class="phone-question-answer-box" v-else>
- <view class="phone-line-title">答案解析</view>
- <view class="btdf-row">本题得分:<text>{{answerRes.score}}</text>分</view>
- <view class="zqda-row">正确答案:
- <view v-for="(item,index) in answerRes.result">{{`填空${index+1}`}} : {{item}}</view>
- </view>
- <view class="ndda-row">您的答案:
- <view v-for="(item,index) in answerRes.reply"> {{`填空${index+1}`}}: {{item}}</view>
- </view>
- <view class="dajx-row">答案解析:
- <rich-text :nodes="answerRes.answer"></rich-text>
- </view>
- </view>
- </view>
- </view>
- <!-- 上下按钮 -->
- <view class="score-bottom-box" v-if="activeSt">
- <view @click="handleOpenCard" class="score-num-box">
- <icon class="score-num-icon"></icon>
- <text class="active-num">{{activeSt && activeSt.onlyNum||0}}</text>/<text>{{data.StListForSearch.length}}</text>
- </view>
- <view>
- <button type="default" size="mini" hover-class="none" class="phone-green-btn score-answer-btn" @click="handlePrev" v-if="!isFistStId">上一题</button>
- <button type="default" size="mini" hover-class="none"class="phone-green-btn score-answer-btn" @click="handleNext" v-if="!isLastStId">下一题</button>
- </view>
- </view>
- <!-- 答题卡 -->
- <uni-popup ref="popupRef" background-color="#fff" :is-mask-click="false" :mask-click="false">
- <view class="answer-card-popup">
- <view class="icon-title-bjcolor-navBar-box">
- <view @click="handlePopupBack" class="nav-bar-icon"> </view>
- <text class="nav-bar-title">答题卡</text>
- </view>
- <view class="answer-card-content" v-for="(paragraph,paragraphIndex) in questionData" :key="paragraphIndex">
- <view class="paragraph-title">
- {{paragraph.name}}
- </view>
- <view class="paragraph-qa" v-for="(qa,qaIndex) in paragraph.qas" :key="qaIndex"
- :class="getQaClass(qa)" @click="answerCardItemClick(qa)">{{qa.onlyNum}}
- </view>
- </view>
- </view>
- </uni-popup>
-
- </view>
- </template>
- <script setup>
- import topCard from "@/components/score/topCard.vue"
- import danxuan from "@/components/questions/danxuan.vue";
- import duoxuan from "@/components/questions/duoxuan.vue";
- import tiankong from "@/components/questions/tiankong.vue";
- import panduan from "@/components/questions/panduan.vue";
- import {useQuestionTools} from "@/components/questions/useQuestionTools.js";
-
- import { onLoad } from "@dcloudio/uni-app";
- import {ref,reactive,computed} from "vue"
- import * as ksApi from "@/api/kaoshi.js"
- const {
- checkDanxuanReply,
- checkDuoxuanReply,
- checkPanduanReply,
- checkTiankongReply,
- getLetterByIndex
- } = useQuestionTools();
-
-
- const hisId = ref(null)
- const popupRef = ref(null)
-
- const data = reactive({
- ksId: null,
- ksName: '',
- stTotal: 0,
- zyLevelName: '',
- userScore: '',
- ksScore: 0,
- StListForSearch: [],
- duanluo: [],
- from: ''
- })
-
- const questionData = ref([]);
- const progress = reactive({
- dlIndex: 0,
- dtIndex: 0
- })
-
- const dlName = computed(() => {
- if (data.StListForSearch && activeSt.value) {
- return data.StListForSearch[activeSt.value.onlyNum].paragraphName
- } else {
- return ''
- }
- })
-
- const activeSt = computed(() => {
- if (questionData.value.length) {
- return questionData.value.length && questionData.value[progress.dlIndex].qas[progress.dtIndex];
- } else {
- return null
- }
- })
-
- const answerRes = computed(() => {
- const qa = activeSt.value ;
- let score = qa.score;
- let reply = '';
- let result = '';
- let answer = qa.answer;
- if (qa.stTypeId == 1) {
- // 单选题
- if (qa.reply && qa.reply.trim() !== '') {
- reply = getLetterByIndex(qa.reply)
- } else {
- reply = '未答'
- }
-
- if (qa.result) {
- result = getLetterByIndex(qa.result)
- } else {
- result = '无答案'
- }
- }
- if (qa.stTypeId == 2) {
- // 多选题
-
- if (qa.reply && qa.reply.length) {
- reply = qa.reply.map(item => {
- if (item.trim()) {
- return getLetterByIndex(item.trim())
- }
- }).join(',')
- } else {
- reply = '未答'
- }
- if (qa.result) {
- result = qa.result.map(item => {
- if (item.trim()) {
- return getLetterByIndex(item.trim())
- }
- }).join(',')
- } else {
- result = '无答案'
- }
- }
- if (qa.stTypeId == 3) {
- // 判断题
- if (qa.reply == 0) {
- reply = '错误'
- }else if (qa.reply == 1) {
- reply = '正确'
- }
- if (qa.result == 0) {
- result = '错误'
- }else if (qa.result == 1) {
- result = '正确'
- }
- }
- if (qa.stTypeId == 4) {
- let reply = qa.reply || [];
- let result =qa.result || [];
- // 填空题
- return {score,reply,result,answer}
- } else {
- return {
- score,reply,result,answer
- }
- }
- })
-
- const isFistStId = computed(() => {
- if (data.StListForSearch.length) {
- return data.StListForSearch[0].stId == activeSt.value.stId
- } else {
- return false
- }
- });
- const isLastStId = computed(() => {
- if (data.StListForSearch.length) {
- return data.StListForSearch[data.StListForSearch.length - 1].stId == activeSt.value.stId
- } else {
- return false
- }
- });
-
-
- onLoad((options) => {
- hisId.value = options.hisId;
- data.from = options.from;
- initPage()
- })
-
-
- function getQaClass(qa) {
- if (qa.marked && qa.marked === true) {
- return 'paragraph-qa-block-mark';
- } else {
- if (qa.stTypeId == 1) {
- if (checkDanxuanReply(qa)) {
- return 'paragraph-qa-block-done';
- } else {
- return 'paragraph-qa-block-init';
- }
- } else if (qa.stTypeId == 2) {
- if (checkDuoxuanReply(qa)) {
- return 'paragraph-qa-block-done';
- } else {
- return 'paragraph-qa-block-init';
- }
- } else if (qa.stTypeId == 3) {
- if (checkPanduanReply(qa)) {
- return 'paragraph-qa-block-done';
- } else {
- return 'paragraph-qa-block-init';
- }
- } else if (qa.stTypeId == 4) {
- if (checkTiankongReply(qa)) {
- return 'paragraph-qa-block-done';
- } else {
- return 'paragraph-qa-block-init';
- }
- }
- }
- }
-
-
- function handleBack() {
-
- const pages = getCurrentPages();
- if (pages.length>1) {
- uni.navigateBack()
- } else {
- /* if (data.from == 'chengjiList') {
- uni.redirectTo({
- url: "/pages/client/Chengji/list"
- })
- } else if (data.from == 'kaoshi'){
- uni.redirectTo({
- url: "/pages/client/Kaoshi/list"
- })
- } */
- history.back();
- }
-
- }
-
-
- function formatDuanluoList() {
- let uIndex = 0; // 试题num
- let iDuanluo = 0; // 段落num
- let result = [];
- for (const duanluo of data.duanluo) {
- let paragraph = {
- qas: [],
- };
- paragraph.name = duanluo.name;
-
- let iQa = 0; // 当前试题序号
- let order = 0; // 当前题型中第几题
- for (const iDanxuan of duanluo.danxuan) {
- iDanxuan.type = 'danxuan';
- iDanxuan.marked = false;
- iDanxuan.onlyNum = uIndex + 1;
- iDanxuan.order = order;
- iDanxuan.iQa = iQa;
- paragraph.qas.push(iDanxuan);
- uIndex++;
- order++;
- iQa++;
-
- data.StListForSearch.push({
- stId: iDanxuan.stId,
- paragraphName: paragraph.name,
- dlIndex: iDuanluo,
- dtIndex: iDanxuan.iQa,
- num: iDanxuan.onlyNum
- })
- }
- order = 0;
- for (const iDuoxuan of duanluo.duoxuan) {
- iDuoxuan.type = 'duoxuan';
- iDuoxuan.marked = false;
- iDuoxuan.onlyNum = uIndex + 1;
- iDuoxuan.order = order;
- paragraph.qas.push(iDuoxuan);
- iDuoxuan.iQa = iQa;
- uIndex++;
- order++;
- iQa++;
-
- data.StListForSearch.push({
- stId: iDuoxuan.stId,
- paragraphName: paragraph.name,
- dlIndex: iDuanluo,
- dtIndex: iDuoxuan.iQa,
- num: iDuoxuan.onlyNum
- })
- }
- order = 0;
- for (const iPanduan of duanluo.panduan) {
- iPanduan.type = 'panduan';
- iPanduan.marked = false;
- iPanduan.onlyNum = uIndex + 1;
- iPanduan.order = order;
- paragraph.qas.push(iPanduan);
- iPanduan.iQa = iQa;
- uIndex++;
- order++;
- iQa++;
-
- data.StListForSearch.push({
- stId: iPanduan.stId,
- paragraphName: paragraph.name,
- dlIndex: iDuanluo,
- dtIndex: iPanduan.iQa,
- num: iPanduan.onlyNum
- })
- }
- order = 0;
- for (const iTiankong of duanluo.tiankong) {
- iTiankong.type = 'tiankong';
- iTiankong.marked = false;
- iTiankong.onlyNum = uIndex + 1;
- iTiankong.order = order;
- paragraph.qas.push(iTiankong);
- iTiankong.iQa = iQa;
- uIndex++;
- order++;
- iQa++;
-
- data.StListForSearch.push({
- stId: iTiankong.stId,
- paragraphName: paragraph.name,
- dlIndex: iDuanluo,
- dtIndex: iTiankong.iQa,
- num: iTiankong.onlyNum
- })
- }
- iDuanluo++;
- questionData.value.push(paragraph)
-
- }
- }
-
- function handlePrev() {
- const qa = data.StListForSearch.find(item => item.stId == activeSt.value.stId);
- const index = qa.num - 1;
- if (index > 0) {
- const result = data.StListForSearch[index - 1];
- progress.dlIndex = result.dlIndex;
- progress.dtIndex = result.dtIndex
- }
-
- }
-
- function handleNext() {
- const qa = data.StListForSearch.find(item => item.stId == activeSt.value.stId);
- const index = qa.num - 1;
- if (index < data.StListForSearch.length) {
- const result = data.StListForSearch[index + 1];
- progress.dlIndex = result.dlIndex;
- progress.dtIndex = result.dtIndex
- }
- }
-
-
-
- function initPage() {
- ksApi.getClientKsChengjiView({hisId: hisId.value}).then(res => {
- const { duanluoList,ksName, zyLevelName,userScore,ksScore } = res.data;
- data.ksName = ksName;
- data.zyLevelName = zyLevelName;
- data.userScore = userScore;
- data.ksScore = ksScore;
- data.duanluo = duanluoList;
-
- formatDuanluoList();
- })
- }
- function handlePopupBack() {
- popupRef.value.close()
- }
- function handleOpenCard() {
- popupRef.value.open('bottom')
- }
- </script>
- <style>
- </style>
|