diff --git a/web/config/config.ts b/web/config/config.ts index 2e78b03..33c1dd5 100644 --- a/web/config/config.ts +++ b/web/config/config.ts @@ -158,10 +158,17 @@ export default defineConfig({ { name: '综合模拟考试答题', icon: 'smile', - path: '/mockExamination/index/paper/:rules_id', + path: '/mockExamination/index/paper/:rules_id/:rules_time', component: './mockExamination/paper', hideInMenu: true, }, + { + name: '综合模拟考试结果', + icon: 'smile', + path: '/mockExamination/index/success/:time/:pass_score/:score/:sum_score', + component: './mockExamination/paper/success', + hideInMenu: true, + }, ] }, { diff --git a/web/src/pages/mockExamination/index.tsx b/web/src/pages/mockExamination/index.tsx index c263716..8a6768f 100644 --- a/web/src/pages/mockExamination/index.tsx +++ b/web/src/pages/mockExamination/index.tsx @@ -45,7 +45,7 @@ const columns: ProColumns[] = [ { - history.push(`/mockExamination/index/paper/${record.id}`); + history.push(`/mockExamination/index/paper/${record.id}/${record.examination_time}`); }} > 开始考试 diff --git a/web/src/pages/mockExamination/paper/index.tsx b/web/src/pages/mockExamination/paper/index.tsx index b3ab565..2497991 100644 --- a/web/src/pages/mockExamination/paper/index.tsx +++ b/web/src/pages/mockExamination/paper/index.tsx @@ -5,7 +5,7 @@ import { PageContainer } from '@ant-design/pro-layout'; import { useParams, useRequest } from 'umi'; import { useEffect, useRef, useState } from 'react'; const { Text, Link } = Typography; -import { getRulesPaper, getPaperQuestionList, finishExamination } from '../service'; +import { getRulesPaper, getPaperQuestionList, finishExamination, getCurrentDate } from '../service'; import type { CardListItemDataType } from '../data'; import styles from './style.less'; import cookie from 'react-cookies'; @@ -15,8 +15,59 @@ const CheckboxGroup = Checkbox.Group; const { Paragraph } = Typography; +// 秒数转化为时分秒 +const formatSeconds = (value) => { + // 秒 + let second = parseInt(value) + // 分 + let minute = 0 + // 小时 + let hour = 0 + // 天 + // let day = 0 + // 如果秒数大于60,将秒数转换成整数 + if (second > 60) { + // 获取分钟,除以60取整数,得到整数分钟 + minute = parseInt(second / 60) + // 获取秒数,秒数取佘,得到整数秒数 + second = parseInt(second % 60) + // 如果分钟大于60,将分钟转换成小时 + if (minute > 60) { + // 获取小时,获取分钟除以60,得到整数小时 + hour = parseInt(minute / 60) + // 获取小时后取佘的分,获取分钟除以60取佘的分 + minute = parseInt(minute % 60) + // 如果小时大于24,将小时转换成天 + // if (hour > 23) { + // // 获取天数,获取小时除以24,得到整天数 + // day = parseInt(hour / 24) + // // 获取天数后取余的小时,获取小时除以24取余的小时 + // hour = parseInt(hour % 24) + // } + } + } + + let result = '' + parseInt(second) + ' 秒 ' + if (minute > 0) { + result = '' + parseInt(minute) + ' 分 ' + result + } + if (hour > 0) { + result = '' + parseInt(hour) + ' 小时 ' + result + } + // if (day > 0) { + // result = '' + parseInt(day) + '天' + result + // } + console.log('result:', result) + return result +} + + + + + const CardList = () => { const formRef = useRef(); + const params = useParams(); // 组卷详情查询 const [rulesPaperInfo, setRulesPaperInfo] = useState([]); @@ -37,11 +88,31 @@ const CardList = () => { const [questionNowNum, setQuestionNowNum] = useState(0) const [questionNum, setQuestioNum] = useState(0) + const [timeData, setTimeData] = useState(0); + + + + + + + useEffect(() => { + let secondValue = params.rules_time * 60; // 秒 截至时间 - 服务器当前时间 + setTimeData(secondValue) + console.log(secondValue); + + const timer = setInterval(() => { // + setTimeData((secondValue >= 1) ? secondValue-- : 0); + }, 1000); + return () => { + clearInterval(timer) // 清理计算器 + } + }, []) + + - const params = useParams(); const { loading, data } = useRequest(() => { return getRulesPaper({ rules_id: params.rules_id @@ -122,7 +193,12 @@ const CardList = () => { return result; }, onSuccess: (result, params) => { - console.log(result, 'questionFinish server', params) + + if (result.success) { + console.log(result, 'questionFinish server', params) + history.push(`/mockExamination/index/paper/${record.id}/${record.examination_time}`); + + } } }); @@ -273,7 +349,7 @@ const CardList = () => {
- + {questionNow.question_type === 0 ? @@ -400,7 +476,7 @@ const CardList = () => {
剩余时间 - 6分14秒 + {formatSeconds(timeData)} 答题序号 {questionNowNum}/{questionNum}