From 056326dd8c9fdadfbfb2accc80c98acb0243d90f Mon Sep 17 00:00:00 2001 From: wangxi <123456> Date: Mon, 14 Mar 2022 15:30:00 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B5=8B=E8=AF=95bug=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- web/config/config.ts | 2 +- .../dashboard/qualification/examAnswer.tsx | 93 +++++++++++++++++-- .../pages/dashboard/qualification/index.tsx | 2 +- 3 files changed, 86 insertions(+), 11 deletions(-) diff --git a/web/config/config.ts b/web/config/config.ts index 5bf609a..356137c 100644 --- a/web/config/config.ts +++ b/web/config/config.ts @@ -82,7 +82,7 @@ export default defineConfig({ { name: '资质考试答题', icon: 'dashboard', - path: '/dashboard/qualification/examAnswer/:examination_id/:examination_name/:time', + path: '/dashboard/qualification/examAnswer/:examination_id/:rule_id/:examination_name/:time', component: './dashboard/qualification/examAnswer', hideInMenu: true, }, diff --git a/web/src/pages/dashboard/qualification/examAnswer.tsx b/web/src/pages/dashboard/qualification/examAnswer.tsx index 1a06037..b850eaa 100644 --- a/web/src/pages/dashboard/qualification/examAnswer.tsx +++ b/web/src/pages/dashboard/qualification/examAnswer.tsx @@ -82,9 +82,11 @@ const CardList = () => { // 当前题号 const [questionNowNum, setQuestionNowNum] = useState(0) const [questionNum, setQuestioNum] = useState(0) - + // 试题分数 + const [rulesPaperScore, setRulesPaperScore] = useState([]); const [timeData, setTimeData] = useState(0); const [num,setNum]=useState(0); + const [questionType,setQuestionType]=useState([]); useEffect(() => { let secondValue = params.time; // 秒 截至时间 - 服务器当前时间 @@ -138,6 +140,26 @@ const CardList = () => { } }); + const getRules = useRequest(() => { + return getRulesPaper({ + rules_id: params.rule_id + }); + }, + { + formatResult: (result) => { + return result; + }, + onSuccess: (result) => { + // console.log(result, 111111111111111); + + if (result.success) { + setRulesPaperScore(result.question_type_score || []) + + // setQuestionTypeList(result.question_list[0].question_type_count) + } + } + }); + const { run } = useRequest(getPaperQuestionList, { refreshDeps: [rulesPaperInfo], @@ -172,7 +194,7 @@ const CardList = () => { question_type_count[0].count = arr[0].length; question_type_count[1].count = arr[1].length; question_type_count[2].count = arr[2].length; - + setQuestionType(question_type_count); const qList = question_type_count const questionList: any[] = [] qList.map((e, i) => { @@ -308,9 +330,58 @@ const CardList = () => { } } + + // 题型回数字 + const tiTypeNum = (a: number) => { + switch (a) { + case 0: + return "一、" + break; + case 1: + return "二、" + break; + case 2: + return "三、" + break; + default: + return "" + break; + } + } + + // 根据题型返回题数、分数、总分 + const showQuestionTypeSocore = (type) => { + + let questionName = "" + + let num = 0 + let score = 0 + + // 当前分类下试题总数 + if (questionType.length !== 0) { + + questionType.map((e, i) => { + + if (e.question_type === type) { + + num = e.count + questionName = e.type_name + } + + }) + rulesPaperScore.map((e, i) => { + if (e.question_type === type) { + score = e.score + } + }) + + + } + return `${questionName} (共${num}题,每题${score}分)` + } return ( - +
{params.examination_name}
{ return { )} +
+
未答 +
+
已答 +
+
{ > - {questionNow?.question_stem} + {questionNow.index?questionNow.index[1]+1:''}. + {questionNow?.question_stem} - {/* {console.log(questionNow.answerId, 'answerId', questionNow.answerId)} */}
{ // const time = await getCurrentDate(); // getTime(time); const time=rule.examination_time*60; - history.push(`/dashboard/qualification/examAnswer/${params.examination_id}/${examinationInfo.examination_name}/${time}`) + history.push(`/dashboard/qualification/examAnswer/${params.examination_id}/${examinationInfo.rules_id}/${examinationInfo.examination_name}/${time}`) } } }