diff --git a/web/src/pages/mockExamination/paper/index.tsx b/web/src/pages/mockExamination/paper/index.tsx
index 6366cfe..4f21c44 100644
--- a/web/src/pages/mockExamination/paper/index.tsx
+++ b/web/src/pages/mockExamination/paper/index.tsx
@@ -3,14 +3,15 @@ import { AlignLeftOutlined, PlusOutlined } from '@ant-design/icons';
import { Switch, Button, Card, Col, List, Menu, Progress, Row, Typography, Space, Divider, Radio, Checkbox, Form } from 'antd';
import { PageContainer } from '@ant-design/pro-layout';
import { useParams, useRequest } from 'umi';
-import { useRef, useState } from 'react';
+import { useEffect, useRef, useState } from 'react';
const { Text, Link } = Typography;
-import { getRulesPaper, getPaperQuestionList } from '../service';
+import { getRulesPaper, getPaperQuestionList, finishExamination } from '../service';
import type { CardListItemDataType } from '../data';
import styles from './style.less';
-import SubMenu from 'antd/lib/menu/SubMenu';
+import cookie from 'react-cookies';
+
import ProCard from '@ant-design/pro-card';
-import { getDirection } from '../../../.umi/plugin-locale/localeExports';
+const CheckboxGroup = Checkbox.Group;
const { Paragraph } = Typography;
@@ -24,12 +25,17 @@ const CardList = () => {
//答题卡列表
const [questionTypeList, setQuestionTypeList] = useState([])
// 当前答题id
- const [questionNow, setQuestionNow] = useState([])
+ const [questionNow, setQuestionNow] = useState({})
+ // 解析可见
+ const [parsingShow, setParsingShow] = useState(false)
+ const [lastBtnShow, setLastBtnShow] = useState(true)
+ const [nextBtnShow, setNextBtnShow] = useState(false)
-
- const [parsingShow, setParsingShow] = useState(false)
+ // 当前题号
+ const [questionNowNum, setQuestionNowNum] = useState(0)
+ const [questionNum, setQuestioNum] = useState(0)
@@ -47,8 +53,7 @@ const CardList = () => {
},
onSuccess: (result) => {
if (result.success) {
- setRulesPaperInfo(result.question_list || [])
- console.log(result, 'result1')
+ setRulesPaperInfo(result.question_list[0] || [])
run({ paper_id: result.question_list[0].paper_id, question_type_count: result.question_list[0].question_type_count })
// setQuestionTypeList(result.question_list[0].question_type_count)
}
@@ -78,6 +83,8 @@ const CardList = () => {
})
}
})
+
+
// 根据分类拆分试题 左侧答题卡 state:0 未答题 1 : 已答题
paperList.map((e) => {
questionList.map((item, index) => {
@@ -94,32 +101,56 @@ const CardList = () => {
questionInfo.push({ ...e, index: index })
})
}
- const nowQ = setLabVal(questionInfo[0])
+
setPaperInfo(questionInfo || [])
- setQuestionNow(nowQ || [])
+ setQuestionNow(questionInfo[0] || [])
setQuestionTypeList(questionList || [])
+ setQuestioNum(questionInfo.length)
}
}
});
- const setLabVal = (value: []) => {
- const nowQ = value
- console.log(nowQ, "888888");
- nowQ.answers.map((e, i) => {
- console.log(e, 'eeeeee');
- nowQ.answers[i].label = e.answer
- nowQ.answers[i].value = e.id
+
+ const { run: runFinishExamination } = useRequest(finishExamination,
+ {
+ refreshDeps: [rulesPaperInfo],
+ manual: true,
+ formatResult: (result) => {
+ return result;
+ },
+ onSuccess: (result, params) => {
+ console.log(result, 'questionFinish server', params)
+ }
+ });
+
+
+
+
+
+ useEffect(() => {
+ // 已选择题目回显
+ formRef?.current?.setFieldsValue({ note: questionNow.answerId });
+
+ paperInfo.map((item, index) => {
+ if (item.id === questionNow.id) {
+ setQuestionNowNum(index + 1)
+ }
})
- return nowQ
- }
+ }, [questionNow]);
+
+ useEffect(() => {
+ console.log(questionNowNum, questionNum);
+ setLastBtnShow(questionNowNum == 1 ? true : false)
+ setNextBtnShow(questionNowNum == questionNum ? true : false)
+ }, [questionNowNum])
const content = (
- 试卷信息:{rulesPaperInfo[0]?.rules_name}
+ {/* 试卷信息:{rulesPaperInfo?.question_list[0].rules_name} */}
);
@@ -173,16 +204,12 @@ const CardList = () => {
-
- {console.log("当前题号:", questionNow, "试题顺序:", paperInfo, "二维数组:", questionTypeList)}
{
questionTypeList && (
@@ -208,22 +235,15 @@ const CardList = () => {
// 查看解析关闭
setParsingShow(false)
-
paperInfo.map((e) => {
if (e.id === item.id) {
- console.log(e.id, e.index, item)
-
-
- const dQ = setLabVal(item)
-
- setQuestionNow({ ...dQ, index: e.index })
+ // 重写单选的label、value,index:保存当前试题的index。
+ setQuestionNow({ ...item, index: e.index })
}
})
- console.log(questionTypeList);
- formRef?.current.setFieldsValue({ note: e.answerId });
}}
- >{index}
+ >{index + 1}
}}
style={{ background: '#ffffff', margin: '-25px -24px 24px -24px' }}
/>
@@ -232,19 +252,6 @@ const CardList = () => {
)}
- 二. 多选题}
- footer={false}
- bordered
- dataSource={numbers}
- renderItem={item => (
-
- {item.id}
-
- )}
- style={{ background: '#ffffff', margin: '-1px -24px' }}
- />
-
@@ -258,68 +265,30 @@ const CardList = () => {
headerBordered
>
- {/*
-
-
-
-
- {
-
- const qArr = []
- // 默认输出答案0,0,0,0
- questionNow?.answers?.map((e, i) => {
- console.log(e, i, "ei");
- item.target.value === e.id ? qArr.push("1") : qArr.push("0")
- })
- console.log(qArr, 'Arr')
- const questionList = questionTypeList
- const questionAnswer = qArr.join(",")
-
- // 修改答题卡状态 写入答案以及修改答题状态
- const qX = questionNow?.question_type;
- const qI = questionNow?.index;
- questionList[qX].children[qI].answerSelect = questionAnswer;
- // 答题状态
- questionList[qX].children[qI].state = 1
- questionList[qX].children[qI].answerId = item.target.value
-
- console.log(questionList, 'questionList11', questionAnswer)
- // 提交答题卡
- setQuestionTypeList(questionList)
-
- // console.log('0', questionList, questionNow, item, qX, qI, questionList[qX].children[qI].answerSelect, questionAnswer)
- }} defaultValue={questionNow.answerId} />
-
-
-
-
- */}
-
{questionNow?.question_stem}
- {console.log(questionNow.answerId, 'answerId', questionNow.answerId)}
+ {/* {console.log(questionNow.answerId, 'answerId', questionNow.answerId)} */}
- {questionNow.question_type === 0 ?
+
+
+ {questionNow.question_type === 0 ?
- (
-
-
+
{questionNow?.answers?.map((item, index) => {
- console.log(item, 'item')
+
return {
const qArr = []
// 默认输出答案0,0,0,0
questionNow?.answers?.map(() => {
qArr.push("0")
+
})
// 修改用户答案
qArr[index] = item.is_true
@@ -336,20 +305,84 @@ const CardList = () => {
// 提交答题卡
setQuestionTypeList(questionList)
- // console.log('0', questionList, questionNow, item, qX, qI, questionList[qX].children[qI].answerSelect, questionAnswer)
+ // console.log('0', questionList, questionNow, item, qX, qI)
}}
value={item.id}
style={{ padding: 5, fontSize: 16 }}
>{tiNum(index)}{item.answer}
+
})}
-
-
- ) : questionNow.question_type === 1 ? questionNow?.answers?.map((item, index) => {
- return {tiNum(index)}{item.answer}
- }) : questionNow.question_type === 2 ? questionNow?.answers?.map((item, index) => {
- return {tiNum(index)}{item.answer}
- }) : ""}
+ ) : questionNow.question_type === 1 ? {
+ const qArr = []
+ // 默认输出答案0,0,0,0
+ questionNow?.answers?.map((item) => {
+ if (e.indexOf(item.id) > -1) {
+ qArr.push("1")
+ } else {
+ qArr.push("0")
+ }
+ })
+ const questionList = questionTypeList
+ const questionAnswer = qArr.join(",")
+ // 修改答题卡状态 写入答案以及修改答题状态
+ const qX = questionNow?.question_type;
+ const qI = questionNow?.index;
+ questionList[qX].children[qI].answerSelect = questionAnswer;
+ // 答题状态
+ questionList[qX].children[qI].state = 1
+ questionList[qX].children[qI].answerId = e
+ // 提交答题卡
+ setQuestionTypeList(questionList)
+
+ // console.log('0', questionList, questionNow, item, qX, qI)
+ }}>
+ {questionNow?.answers?.map((item, index) => {
+
+ return {tiNum(index)}{item.answer}
+
+ })}
+ : questionNow.question_type === 2 ? (
+
+
+ {questionNow?.answers?.map((item, index) => {
+ return {
+ const qArr = []
+ // 默认输出答案0,0,0,0
+ questionNow?.answers?.map(() => {
+ qArr.push("0")
+ })
+ // 修改用户答案
+ qArr[index] = item.is_true
+
+ const questionList = questionTypeList
+ const questionAnswer = qArr.join(",")
+ // 修改答题卡状态 写入答案以及修改答题状态
+ const qX = questionNow?.question_type;
+ const qI = questionNow?.index;
+ questionList[qX].children[qI].answerSelect = questionAnswer;
+ // 答题状态
+ questionList[qX].children[qI].state = 1
+ questionList[qX].children[qI].answerId = item.id
+ // 提交答题卡
+ setQuestionTypeList(questionList)
+
+ // console.log('0', questionList, questionNow, item, qX, qI)
+ }}
+ value={item.id}
+ style={{ padding: 5, fontSize: 16 }}
+ >{tiNum(index)}{item.answer}
+
+ })}
+ ) : ""
+ }
+
+
{ return true }} value={0} size="large">
@@ -370,11 +403,84 @@ const CardList = () => {
6分14秒
答题序号
- 14/80
+ {questionNowNum}/{questionNum}
-
-
-
+
+
+
+
diff --git a/web/src/pages/mockExamination/paper/success.tsx b/web/src/pages/mockExamination/paper/success.tsx
new file mode 100644
index 0000000..c99569e
--- /dev/null
+++ b/web/src/pages/mockExamination/paper/success.tsx
@@ -0,0 +1,35 @@
+import { DingdingOutlined } from '@ant-design/icons';
+import { Button, Card, Steps, Result, Descriptions } from 'antd';
+import { Fragment } from 'react';
+import { GridContent } from '@ant-design/pro-layout';
+import { history, useParams, useRequest } from 'umi';
+import styles from './index.less';
+
+const { Step } = Steps;
+
+const extra = (
+
+
+
+);
+
+export default () => {
+ const params = useParams();
+ const info = params.msg.split(',');
+ return (
+
+
+
+
+
+ )
+
+}
+
+
diff --git a/web/src/pages/mockExamination/service.ts b/web/src/pages/mockExamination/service.ts
index 5f3b5ad..2d745ad 100644
--- a/web/src/pages/mockExamination/service.ts
+++ b/web/src/pages/mockExamination/service.ts
@@ -43,6 +43,30 @@ export async function getRulesPaper(params: {
params,
});
}
+/**
+ * 14 保存考试结果,返回当前得分
+ * /dsideal_yy/zygh/training/person/finishExamination
+ * @param params
+ * @returns
+ */
+
+export async function finishExamination(
+ params: ParamsType,
+): Promise<{ data: { list: BasicListItemDataType[] } }> {
+ return request('/dsideal_yy/zygh/training/person/finishExamination', {
+ method: 'POST',
+ requestType: 'form',
+ data: {
+ ...params,
+ },
+ });
+}
+
+
+
+
+
+
/**
* 06 获取试卷内容
* /dsideal_yy/zygh/training/rules/getPaperQuestionList
@@ -86,7 +110,7 @@ export async function getCourseExaminationProgressList(params: {
identity_id: number;
person_id: number;
subject_id: number
-}){
+}) {
return request('/dsideal_yy/zygh/training/mock/getCourseExaminationProgressList', {
params,
});