瀏覽代碼

学习记录显示组卷作业

shmily1213 1 月之前
父節點
當前提交
e059604d4f

+ 4 - 2
src/composables/useExam.ts

@@ -608,7 +608,8 @@ export const useExam = () => {
             isMark: false,
             isNotKnow: false,
             hasParsed: false,
-            showParse: false
+            showParse: false,
+            duration: 0, // 清空做题时长
           }
         }),
         options: item.options.map(option => {
@@ -620,7 +621,8 @@ export const useExam = () => {
             isMissed: false,
             isIncorrect: false
           }
-        })
+        }),
+        duration: 0, // 清空做题时长
       }
     });
     changeIndex(0);

+ 4 - 3
src/pagesStudy/components/exam-record-item.vue

@@ -2,8 +2,8 @@
   <view class="bg-white">
     <view class="text-30 text-fore-title">{{ data.name }}</view>
     <view class="mt-32 flex items-center justify-between">
-      <view class="text-26 text-fore-light">提交时间: {{ data.date || '-' }}</view>
-      <view class="text-26 text-primary flex items-center gap-x-4" @click="handleDetail">
+      <view class="text-24 text-fore-light">提交时间: {{ data.date || '-' }}</view>
+      <view class="text-28 text-primary flex items-center gap-x-4" @click="handleDetail">
         <text>{{ isFinished ? '查看分析' : '继续考试' }}</text>
         <uv-icon name="arrow-right" size="14" color="var(--primary-color)" />
       </view>
@@ -37,7 +37,8 @@ const handleDetail = () => {
   if (isFinished.value) {
     transferTo('/pagesStudy/pages/simulation-analysis/simulation-analysis', {
       data: {
-        examineeId: props.data.id
+        examineeId: props.data.id,
+        paperType: EnumPaperType.SIMULATED
       }
     });
   } else {

+ 28 - 16
src/pagesStudy/pages/homework/components/paper-work.vue → src/pagesStudy/components/paper-work-item.vue

@@ -22,7 +22,7 @@
           <text class="text-fore-title">{{ data.score || '-' }}/{{ data.total }}</text>
         </view>
         <view class="mt-14">
-          <text class="text-fore-light">批次/科目:</text>
+          <text class="text-fore-light">科目/批次:</text>
           <text class="text-fore-title">{{ batchName }}</text>
         </view>
         <view class="mt-14">
@@ -30,6 +30,11 @@
           <text class="text-fore-title">{{ data.campusName }}</text>
         </view>
       </view>
+      <view v-if="data.state === EnumPaperWorkState.COMPLETED"
+        class="mt-20 bg-[#FFFBEB] py-18 px-20 rounded-5 text-24 text-[#F59E0B] flex items-center justify-between border border-solid border-[#FEF6DA]">
+        <text>提交时间:{{ data.endTime }}</text>
+        <text>做题时长:{{ formatSeconds(data.duration) }}</text>
+      </view>
       <view class="absolute right-50 top-100">
         <view v-if="data.state === EnumPaperWorkState.COMPLETED"
           class="px-28 py-10 border border-solid border-primary rounded-full text-24 text-primary bg-[#EEF8FD]"
@@ -43,8 +48,9 @@
 <script lang="ts" setup>
 import { EnumPaperType, EnumPaperWorkState } from '@/common/enum';
 import { useTransferPage } from '@/hooks/useTransferPage';
-import { getPaperWorkDetail } from '@/api/modules/study';
-import { Study } from '@/types';
+import { getPaperWorkDetail, getOpenExaminee } from '@/api/modules/study';
+import { Study, Transfer } from '@/types';
+import { formatSeconds } from '@/utils/common';
 const { transferTo } = useTransferPage();
 const props = defineProps<{
   data: Study.PaperWork;
@@ -52,7 +58,7 @@ const props = defineProps<{
 
 const batchName = computed(() => {
   const names = props.data.name.split('_');
-  return `${names[0]}(${names[1]})`
+  return `${names[1]}(${names[0]})`
 });
 const publishTime = computed(() => {
   return uni.$ie.formatTime(props.data.publishTime, 'yyyy年mm月dd日 hh:MM:ss');
@@ -64,7 +70,8 @@ const handleDetail = () => {
     uni.$ie.hideLoading();
     transferTo('/pagesStudy/pages/simulation-analysis/simulation-analysis', {
       data: {
-        examineeId: res.data.examineeId
+        examineeId: res.data.examineeId,
+        paperType: EnumPaperType.TEST
       }
     });
   }).catch(err => {
@@ -75,17 +82,22 @@ const handleDetail = () => {
 }
 
 const handleStart = () => {
-  console.log(props.data);
-  transferTo('/pagesStudy/pages/exam-start/exam-start', {
-    data: {
-      name: '组卷作业-' + batchName.value,
-      paperType: EnumPaperType.TEST,
-      practiceInfo: {
-        // name: node.name,
-        relateId: props.data.id,
-        directed: true
-      },
-    }
+  getOpenExaminee({
+    paperType: EnumPaperType.TEST,
+    relateId: props.data.id,
+    directed: props.data.directed
+  }).then(res => {
+    transferTo('/pagesStudy/pages/exam-start/exam-start', {
+      data: {
+        name: '组卷作业-' + batchName.value,
+        paperType: EnumPaperType.TEST,
+        simulationInfo: {
+          examineeId: res.data.examineeId
+        },
+      } as Transfer.ExamAnalysisPageOptions,
+    });
+  }).catch(err => {
+    console.error(err);
   });
 }
 </script>

+ 4 - 4
src/pagesStudy/pages/exam-start/components/question-title.vue

@@ -7,7 +7,7 @@
     </view>
     <text v-if="isSubQuestion" class="text-nowrap text-30">
       <text>{{ getQuestionTitle() }}</text>
-      <text v-if="isSimulation">({{ getScore }}分)</text>
+      <text v-if="isExam">({{ getScore }}分)</text>
       <text v-else>&nbsp;</text>
     </text>
     <uv-parse :content="question.title" containerStyle="display:inline"
@@ -27,15 +27,15 @@ const { questionTypeDesc } = examData;
 const props = defineProps<{
   question: Study.Question;
 }>();
-const isSimulation = computed(() => {
+const isExam = computed(() => {
   const { paperType } = examPageOptions;
-  return paperType === EnumPaperType.SIMULATED;
+  return paperType === EnumPaperType.SIMULATED || paperType === EnumPaperType.TEST;
 });
 const isSubQuestion = computed(() => {
   return props.question.isSubQuestion;
 });
 const showScore = computed(() => {
-  return isSimulation.value;
+  return isExam.value;
 });
 const getScore = computed(() => {
   if (props.question.subQuestions && props.question.subQuestions.length > 0) {

+ 22 - 14
src/pagesStudy/pages/exam-start/exam-start.vue

@@ -90,9 +90,16 @@ provide(EXAM_PAGE_OPTIONS, prevData.value);
 provide(EXAM_DATA, examData);
 provide(EXAM_AUTO_SUBMIT, autoSubmit);
 
-const isExam = computed(() => {
+const isPracticeExam = computed(() => {
+  return prevData.value.paperType === EnumPaperType.PRACTICE || prevData.value.paperType === EnumPaperType.COURSE;
+});
+
+const isSimulationExam = computed(() => {
   // prevData.value
-  return prevData.value.paperType === EnumPaperType.SIMULATED || prevData.value.paperType === EnumPaperType.TEST;
+  return prevData.value.paperType === EnumPaperType.SIMULATED;
+});
+const isTestExam = computed(() => {
+  return prevData.value.paperType === EnumPaperType.TEST;
 });
 
 const isReadOnly = computed(() => {
@@ -139,7 +146,7 @@ const stopTime = () => {
 }
 
 
-const beforeSubmit = () => {
+const beforeSubmit = async () => {
   const text = notDoneCount.value > 0 ? `还有${notDoneCount.value}题未做,确认交卷?` : '是否确认交卷?';
   stopTime();
   uni.$ie.showModal({
@@ -163,7 +170,7 @@ const handleSubmit = (tempSave: boolean = false) => {
   submit();
   const msg = tempSave ? '保存中...' : '提交中...';
   uni.$ie.showLoading(msg);
-  setTimeout(() => {
+  setTimeout(async () => {
     const params = {
       ...paperData.value,
       questions: questionList.value.map(item => {
@@ -185,16 +192,17 @@ const handleSubmit = (tempSave: boolean = false) => {
       duration: practiceDuration.value
     } as Study.ExamPaperSubmit;
     console.log('提交试卷参数', params)
-    commitExamineePaper(params);
-    if (isExam.value) {
+    await commitExamineePaper(params);
+    if (isSimulationExam.value || isTestExam.value) {
       if (!tempSave) {
         setTimeout(async () => {
           uni.$ie.hideLoading();
           await nextTick();
           transferTo('/pagesStudy/pages/simulation-analysis/simulation-analysis', {
             data: {
-              examineeId: examineeId.value
-            },
+              examineeId: examineeId.value,
+              paperType: prevData.value.paperType
+            } as Transfer.SimulationAnalysisPageOptions,
             type: 'redirectTo'
           });
         }, 2500);
@@ -204,7 +212,7 @@ const handleSubmit = (tempSave: boolean = false) => {
           transferBack();
         });
       }
-    } else {
+    } else if (isPracticeExam.value) {
       if (!tempSave) {
         setTimeout(async () => {
           uni.$ie.hideLoading();
@@ -226,7 +234,7 @@ const handleSubmit = (tempSave: boolean = false) => {
         });
       }
     }
-  }, 1000);
+  }, 300);
 }
 
 /**
@@ -285,7 +293,7 @@ const loadPracticeData = async () => {
   totalExamTime.value = Number.MAX_SAFE_INTEGER;
   combinePaperData(data, paperType);
 }
-const loadSimulationData = async () => {
+const loadExamData = async () => {
   const { paperType, readonly, simulationInfo } = prevData.value;
   let data: Study.Examinee;
   if (simulationInfo?.examineeId) {
@@ -361,10 +369,10 @@ const handleGuideClose = () => {
 const loadData = async () => {
   uni.$ie.showLoading();
   const { paperType } = prevData.value;
-  if (paperType === EnumPaperType.PRACTICE || paperType === EnumPaperType.COURSE || paperType === EnumPaperType.TEST) {
+  if (paperType === EnumPaperType.PRACTICE || paperType === EnumPaperType.COURSE) {
     loadPracticeData();
-  } else if (paperType === EnumPaperType.SIMULATED) {
-    loadSimulationData();
+  } else if (paperType === EnumPaperType.SIMULATED || paperType === EnumPaperType.TEST) {
+    loadExamData();
   }
 };
 onLoad(() => {

+ 2 - 2
src/pagesStudy/pages/homework/homework.vue

@@ -24,7 +24,7 @@
 
 <script lang="ts" setup>
 import { useImage } from '@/hooks/useImage';
-import PaperWorkItem from './components/paper-work.vue';
+import PaperWorkItem from '@/pagesStudy/components/paper-work-item.vue';
 import { getPaperWorkList, getPaperWorkStatistic } from '@/api/modules/study';
 import { Study } from '@/types';
 import { EnumPaperWorkState } from '@/common/enum';
@@ -101,7 +101,7 @@ const loadStatistic = () => {
 
 loadStatistic();
 
-onMounted(() => {
+onShow(() => {
   nextTick(() => {
     pagingRef.value.refresh();
   });

+ 14 - 3
src/pagesStudy/pages/simulation-analysis/simulation-analysis.vue

@@ -44,8 +44,19 @@ import { Study, Transfer } from '@/types';
 import { EnumPaperType, EnumQuestionType } from '@/common/enum';
 const { prevData, transferTo } = useTransferPage<Transfer.SimulationAnalysisPageOptions, Transfer.ExamAnalysisPageOptions>();
 const examineeData = ref<Study.Examinee>();
+  const titleMap = {
+  [EnumPaperType.PRACTICE]: '知识点练习',
+  [EnumPaperType.SIMULATED]: '模拟考试',
+  [EnumPaperType.TEST]: '组卷作业',
+}
+const readonlyTitleMap = {
+  [EnumPaperType.PRACTICE]: '练习解析',
+  [EnumPaperType.SIMULATED]: '考试解析',
+  [EnumPaperType.TEST]: '作业解析',
+}
+
 const paperName = computed(() => {
-  return '模拟考试-' + examineeData.value?.subjectName;
+  return titleMap[prevData.value.paperType as keyof typeof titleMap] + '-' + examineeData.value?.subjectName;
 });
 const rightRate = computed(() => {
   const { totalCount = 0, wrongCount = 0 } = examineeData.value || {};
@@ -69,13 +80,13 @@ const formatTime = (time: number) => {
 const handleDetail = (item: Study.Question) => {
   if (!examineeData.value) {
     return;
-  }
+  }  
   transferTo('/pagesStudy/pages/exam-start/exam-start', {
     data: {
       name: paperName.value,
       readonly: true,
       questionId: item.id,
-      paperType: EnumPaperType.SIMULATED,
+      paperType: prevData.value.paperType,
       simulationInfo: {
         examineeId: examineeData.value.examineeId
       }

+ 18 - 11
src/pagesStudy/pages/study-history/components/exam-history-student.vue

@@ -1,8 +1,15 @@
 <template>
-  <view class="px-30 pb-30">
-    <view class="sibling-border-top px-20 py-30" v-for="(item, index) in dataList" :key="index">
-      <exam-record-item :data="item" />
+  <view class="pb-30">
+    <view v-if="examType === EnumExamRecordType.SIMULATED" class="px-30">
+      <view class="sibling-border-top px-20 py-30" v-for="(item, index) in simulatedRecordList" :key="index">
+        <exam-record-item :data="item" />
+      </view>
     </view>
+    <template v-else>
+      <view class="sibling-border-top" v-for="(item, index) in paperWorkRecordList" :key="index">
+        <paper-work-item :data="item" />
+      </view>
+    </template>
   </view>
 </template>
 <script lang="ts" setup>
@@ -10,25 +17,25 @@ import { getSimulatedRecord, getPaperWorkList } from '@/api/modules/study';
 import { EnumExamRecordType, EnumPaperWorkState } from '@/common/enum';
 import examRecordItem from '@/pagesStudy/components/exam-record-item.vue';
 import { Study } from '@/types';
+import PaperWorkItem from '@/pagesStudy/components/paper-work-item.vue';
 const props = defineProps({
   examType: {
     type: String,
     default: 'test'
   }
 });
-const dataList = ref<Study.SimulatedRecord[]>([]);
+const simulatedRecordList = ref<Study.SimulatedRecord[]>([]);
+const paperWorkRecordList = ref<Study.PaperWork[]>([]);
 const loadData = async (type: string) => {
-  dataList.value = [];
+  simulatedRecordList.value = [];
+  paperWorkRecordList.value = [];
   if (type === EnumExamRecordType.SIMULATED) {
     const { data } = await getSimulatedRecord();
-    dataList.value = data;
+    simulatedRecordList.value = data;
   } else {
-    const { rows } = await getPaperWorkList({state: EnumPaperWorkState.COMPLETED});
-    // dataList.value = rows;
-    console.log(rows)
-
+    const { rows } = await getPaperWorkList({ state: EnumPaperWorkState.COMPLETED });
+    paperWorkRecordList.value = rows;
   }
-
 }
 
 watch(() => props.examType, (newVal) => {

+ 2 - 0
src/types/study.ts

@@ -385,4 +385,6 @@ export interface PaperWork {
   schoolName: string;
   score: number;
   universityName: string;
+  endTime: string;
+  duration: number;
 }

+ 3 - 0
src/types/transfer.ts

@@ -21,9 +21,11 @@ export interface ExamAnalysisPageOptions {
   name: string;
   questionId?: number;
   readonly?: boolean;
+  // 模拟考试
   simulationInfo?: {
     examineeId: number;
   };
+  // 知识点练习、教材同步练、组卷作业
   practiceInfo?: {
     name: string;
     relateId: number;
@@ -37,4 +39,5 @@ export interface ExamAnalysisPageOptions {
  */
 export interface SimulationAnalysisPageOptions {
   examineeId: number;
+  paperType: EnumPaperType;
 }

+ 11 - 0
src/utils/common.ts

@@ -0,0 +1,11 @@
+/**
+ * 将秒转化为时分秒
+ * @param seconds 秒
+ * @returns 时分秒
+ */
+export const formatSeconds = (seconds: number, gap: string = ':') => {
+  const hours = Math.floor(seconds / 3600);
+  const minutes = Math.floor((seconds % 3600) / 60);
+  const secs = seconds % 60;
+  return `${hours.toString().padStart(2, '0')}${gap}${minutes.toString().padStart(2, '0')}${gap}${secs.toString().padStart(2, '0')}`;
+};