diff --git a/admin/src/pages/dashboard/analysis/index.tsx b/admin/src/pages/dashboard/analysis/index.tsx index 651e1cf..9360997 100644 --- a/admin/src/pages/dashboard/analysis/index.tsx +++ b/admin/src/pages/dashboard/analysis/index.tsx @@ -59,7 +59,7 @@ const Analysis: FC = () => { - {/** 课程浏览量/月柱形图 */} + {/** 课程浏览量/月柱形图 需要处理 */} { + // 秒 + 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 +} export default () => { const uuid = uuidv4() console.log('uuid', uuidv4()); @@ -131,12 +175,24 @@ export default () => { const [selectedCourse, setSelectedCourse] = useState(0); const [menu, setMenu] = useState(); + + const [timeData, setTimeData] = useState(0); + + useEffect(() => { + let secondValue = 3000; // 秒 截至时间 - 服务器当前时间 + setTimeData(secondValue) + const timer = setInterval(() => { // + setTimeData((secondValue > 1) ? secondValue-- : 0); + }, 1000); + return ()=>{ + clearInterval(timer) // 清理计算器 + } + },[]) + /** 获取课程数据 */ const { data: listData } = useRequest(() => { return queryCourseList(); }); - - useEffect(() => { console.log('listData', listData) setInterval(() => { @@ -261,6 +317,9 @@ export default () => { D {}}>rrrrr + + +
{formatSeconds(timeData)}
) }; diff --git a/admin/src/pages/examinationrules/attestation/index.tsx b/admin/src/pages/examinationrules/attestation/index.tsx index 27f10f2..48a58c0 100644 --- a/admin/src/pages/examinationrules/attestation/index.tsx +++ b/admin/src/pages/examinationrules/attestation/index.tsx @@ -177,7 +177,7 @@ const ExaminationRules: React.FC = () => { valueType: 'text', hideInSearch: true, hideInForm: false, - renderText: (val: string) => `${val}分`, + renderText: (val: string) => `${val || '-'}`, }, { title: '通过线', @@ -186,7 +186,7 @@ const ExaminationRules: React.FC = () => { valueType: 'text', hideInSearch: true, hideInForm: false, - renderText: (val: string) => `${val}`, + renderText: (val: string) => `${val || '-'}`, }, { title: '操作', diff --git a/admin/src/pages/examinationrules/attestation/step/index.tsx b/admin/src/pages/examinationrules/attestation/step/index.tsx index 336a353..aedd7db 100644 --- a/admin/src/pages/examinationrules/attestation/step/index.tsx +++ b/admin/src/pages/examinationrules/attestation/step/index.tsx @@ -8,7 +8,7 @@ import { Button, Checkbox, Col, Divider, Input, List, Menu, message, Radio, Row, import { PageContainer } from '@ant-design/pro-layout'; import ProDescriptions from '@ant-design/pro-descriptions'; import styles from './index.less' -import { saveRules, querySubjectList, queryRulesView, queryRulesList, queryRulesPaper, saveQuestionTypeScore, autoPaperOfficial, queryPaperQuestionList } from '../../service'; +import { saveRules, querySubjectList, queryRulesView, queryRulesList, queryRulesPaper, saveQuestionTypeScore, autoPaperOfficial, queryPaperQuestionList, updateScore } from '../../service'; import { queryQuestionList, queryQuestionType } from '@/pages/questionbank/service'; import ProTable, { ActionType, EditableProTable, ProColumns } from '@ant-design/pro-table'; //import { TableListPagination } from '@/pages/ListTableList2/data'; @@ -120,7 +120,7 @@ export default () => { valueType: 'text', hideInSearch: true, hideInForm: false, - renderText: (val: string) => `${val || 0} 分`, + renderText: (val: string) => `${val || '-'}`, }, { title: '通过线', @@ -322,7 +322,6 @@ export default () => { }} >
- {`试卷`} { page_number: value.current, page_size: value.pageSize } - ); - + ); const _questionTypeCountData = []; _data.question_list[0]?.question_type_count.forEach((item)=>{ @@ -480,19 +478,31 @@ export default () => { width="60%" visible={scoreModalVisible} onVisibleChange={handleScoreModalVisible} - footer={null} onFinish={async () => { - const values = setterRef.current?.getData() + const values = setterRef.current?.getData() // 获取题型分值数据 + const passSocre = setterRef.current?.getValue() // 获取通过分数线 console.log('批量设置分值v::::', values); const {code, data: paper, msg} = await saveQuestionTypeScore({rules_id:Number(params?.id), type_score: JSON.stringify(values)}) console.log('paper', paper) + // 总分及通过分 + let _sumScore = 0; + values?.forEach((item: { score: number; })=>{ + console.log('item--',item) + _sumScore += item?.score + }) + console.log('_sumScore', _sumScore) + // 需要处理 + console.log('passSocre',passSocre) + //console.log('sumScore',sumScore) + const {success} = await updateScore({rules_id:Number(params?.id), pass_socre: passSocre, sum_score: _sumScore}) + //setSumScore(_sumScore) // setUuidPaper(paper?.paper_uuid) // message.success('提交成功'); handleScoreModalVisible(false) return true; }} > - + { parsingMap.clear(); } }, [data]); - + //saveQuestion return ( @@ -315,7 +315,7 @@ const QuestionPaper = (props: any, ref: any) => { console.log('item', item); return ( - {`${(record?.question_type === 2) ? ['T','F'][key] : labels[key]}. ${item?.answer}`} + {`${(record?.question_type === 2) ? ['A','B'][key] : labels[key]}. ${item?.answer}`} ) }} /> @@ -335,7 +335,7 @@ const QuestionPaper = (props: any, ref: any) => { answer = labels?.filter((x, idx, self)=>answertrue[idx] === `${idx}`).toString() break; case 2: // 判断 - answer = ['T', 'F']?.filter((x, idx, self)=>answertrue[idx] === `${idx}`).toString() + answer = ['A', 'B']?.filter((x, idx, self)=>answertrue[idx] === `${idx}`).toString() break; } console.log('expandedDescRowKeys', expandedDescRowKeys) diff --git a/admin/src/pages/examinationrules/components/QuestionSelector.tsx b/admin/src/pages/examinationrules/components/QuestionSelector.tsx index dc588c9..b2c5bc1 100644 --- a/admin/src/pages/examinationrules/components/QuestionSelector.tsx +++ b/admin/src/pages/examinationrules/components/QuestionSelector.tsx @@ -112,6 +112,7 @@ const QuestionSelector = (props: any, ref: any) => { return selectedRowsState; }, })); + return ( <> { - const {questionTypeValues} = props - console.log('questionTypeValues', questionTypeValues) + const {questionTypeValues } = props + + console.log('questionTypeValues:::', questionTypeValues) + //console.log('passScoreValue:::', passScoreValue) + const match = useRouteMatch(); console.log('match', match); @@ -47,8 +50,10 @@ const ScoreSetter = (props: any, ref: any) => { const [dataSource, setDataSource] = useState([]); //const [selectedRowsState, setSelectedRows] = useState([]); //const [addType, setAddType] = useState({name: '', value: 0}); - - let sumScore = 0 // 总分 + const [sumScore, setSumScore] = useState(0); + const [passScore, setPassScore] = useState(0); // 设置通过分数线 + + //let sumScore = 0 // 总分 const formRef = useRef(); @@ -70,7 +75,7 @@ const ScoreSetter = (props: any, ref: any) => { render: (text, record, index) => 每题 - { + { console.log('row', index) console.log('v1',value) const _data = []; @@ -88,8 +93,8 @@ const ScoreSetter = (props: any, ref: any) => { { (record?.code === 1) && <> - 错选、漏选得:: - { + 错选、漏选得: + { // const _data = []; console.log('typeScore',typeScore) @@ -107,7 +112,7 @@ const ScoreSetter = (props: any, ref: any) => { title: '题目数量', dataIndex: 'count', width: 80, - render: (text, _, index) => <>{questionTypeValues ? questionTypeValues[index].count : '0'}, + render: (text, _, index) => <>{questionTypeValues ? questionTypeValues[index]?.count : '0'}, /* editable: (text, record, index) => { return true; @@ -119,8 +124,6 @@ const ScoreSetter = (props: any, ref: any) => { //key: 'age', width: 80, render: (text, _, index) => { - //console.log('===',typeScore ? typeScore[index].score * questionTypeValues[index].count : '0') - sumScore = sumScore + ((typeScore && questionTypeValues) ? typeScore[index]?.score * questionTypeValues[index]?.count : 0) return <> {(typeScore && questionTypeValues) ? typeScore[index]?.score * questionTypeValues[index]?.count : '0'} @@ -170,12 +173,27 @@ const ScoreSetter = (props: any, ref: any) => { //return ()=>{} }, [data]); + /** 计算总分 */ + useEffect(() => { + console.log('typeScore', typeScore) + let _sum = 0; + typeScore?.forEach((item, index)=>{ + _sum += item.score * questionTypeValues[index]?.count; + }) + + setSumScore(_sum) + //return ()=>{} + }, [typeScore]); + // 暴露组件的方法 接受外部获取的ref useImperativeHandle(ref, () => ({ // 构造ref的获取数据方法 getData: () => { return typeScore; }, + getValue: () => { + return passScore; + }, })); return ( @@ -185,7 +203,9 @@ const ScoreSetter = (props: any, ref: any) => { { return 共计 {sumQuestion} 题, 总计 {sumScore} 分 通过分数线 - + { + setPassScore(value) + }} />}} //formMapRef={formMapRef} //rowKey={'code'} diff --git a/admin/src/pages/examinationrules/normal/components/AutoSelector.tsx b/admin/src/pages/examinationrules/normal/components/AutoSelector.tsx index f82dca2..d7d7a46 100644 --- a/admin/src/pages/examinationrules/normal/components/AutoSelector.tsx +++ b/admin/src/pages/examinationrules/normal/components/AutoSelector.tsx @@ -47,15 +47,7 @@ type DataSourceType = { children?: DataSourceType[]; }; -const defaultData: DataSourceType[] = new Array(10).fill(1).map((_, index) => { - return { - id: (Date.now() + index).toString(), - title: `章节${index}`, - decs: '这个活动真好玩', - state: 'open', - created_at: '2020-05-26T09:42:56Z', - }; -}); +// 需要处理 // React.forwardRef 接受渲染函数作为参数。React 将使用 props 和 ref 作为参数来调用此函数。此函数应返回 React 节点。 const AutoSelector = (props: any, ref: any) => { /** 获取章节数据 */ @@ -86,7 +78,7 @@ const AutoSelector = (props: any, ref: any) => { //key: 'code', dataIndex: `type${item?.code}`, render: ( item, { defaultRender, ...rest }, form) => { - return { // const _data = []; @@ -105,8 +97,8 @@ const AutoSelector = (props: any, ref: any) => { // 暴露组件的方法 接受外部获取的ref useImperativeHandle(ref, () => ({ // 构造ref的获取数据方法 - createPaper: () => { // 组卷 - //return selectedRowsState; + getData: () => { // 组卷数据 + return []; }, })); @@ -148,10 +140,10 @@ const AutoSelector = (props: any, ref: any) => { // setDataSource }} toolBarRender={false} - /* +/* editable={{ type: 'multiple', - editableKeys, + //editableKeys, actionRender: (row, config, defaultDoms) => { return [defaultDoms.delete]; }, @@ -159,9 +151,9 @@ const AutoSelector = (props: any, ref: any) => { console.log('rrrr',record, recordList) // setDataSource(recordList); }, - onChange: setEditableRowKeys, + //onChange: setEditableRowKeys, }} - */ +*/ /> ); diff --git a/admin/src/pages/examinationrules/normal/components/QuestionPaper.tsx b/admin/src/pages/examinationrules/normal/components/QuestionPaper.tsx index 18e6103..cd50805 100644 --- a/admin/src/pages/examinationrules/normal/components/QuestionPaper.tsx +++ b/admin/src/pages/examinationrules/normal/components/QuestionPaper.tsx @@ -315,7 +315,7 @@ const QuestionPaper = (props: any, ref: any) => { console.log('item', item); return ( - {`${(record?.question_type === 2) ? ['T','F'][key] : labels[key]}. ${item?.answer}`} + {`${(record?.question_type === 2) ? ['A','B'][key] : labels[key]}. ${item?.answer}`} ) }} /> @@ -335,7 +335,7 @@ const QuestionPaper = (props: any, ref: any) => { answer = labels?.filter((x, idx, self)=>answertrue[idx] === `${idx}`).toString() break; case 2: // 判断 - answer = ['T', 'F']?.filter((x, idx, self)=>answertrue[idx] === `${idx}`).toString() + answer = ['A', 'B']?.filter((x, idx, self)=>answertrue[idx] === `${idx}`).toString() break; } console.log('expandedDescRowKeys', expandedDescRowKeys) diff --git a/admin/src/pages/examinationrules/normal/index.tsx b/admin/src/pages/examinationrules/normal/index.tsx index 28fce60..aeaaec8 100644 --- a/admin/src/pages/examinationrules/normal/index.tsx +++ b/admin/src/pages/examinationrules/normal/index.tsx @@ -152,7 +152,7 @@ const ExaminationRules: React.FC = () => { valueType: 'text', hideInForm: false, hideInSearch: true, - renderText: (val: string) => `${val}分`, + renderText: (val: string) => `${val || '-'}`, }, { title: '通过线', @@ -161,7 +161,7 @@ const ExaminationRules: React.FC = () => { valueType: 'text', hideInForm: false, hideInSearch: true, - renderText: (val: string) => `${val}`, + renderText: (val: string) => `${val || '-'}`, }, { title: '操作', diff --git a/admin/src/pages/examinationrules/normal/step/index.tsx b/admin/src/pages/examinationrules/normal/step/index.tsx index 07e9ae2..7d98cbe 100644 --- a/admin/src/pages/examinationrules/normal/step/index.tsx +++ b/admin/src/pages/examinationrules/normal/step/index.tsx @@ -16,7 +16,7 @@ import { Button, Checkbox, Col, Divider, Dropdown, Form, Input, List, Menu, mess import { PageContainer } from '@ant-design/pro-layout'; import ProDescriptions from '@ant-design/pro-descriptions'; import styles from './index.less' -import { saveRules, querySubjectList, queryRulesView, queryTempQuestionList, saveQuestionTypeScore } from '../../service'; +import { saveRules, querySubjectList, queryRulesView, queryTempQuestionList, saveQuestionTypeScore, queryRulesPaper, updateScore } from '../../service'; import { queryCourseView } from '@/pages/course/option/service'; import { queryQuestionList, queryQuestionById, queryQuestionType } from '@/pages/questionbank/service'; import { PlusOutlined, DownOutlined, DeleteOutlined, DownloadOutlined, UploadOutlined, EyeInvisibleOutlined, EyeOutlined, EditOutlined, ArrowDownOutlined, ArrowUpOutlined } from '@ant-design/icons'; @@ -30,6 +30,7 @@ import ScoreSetter from '../../components/ScoreSetter'; import AutoSelector from '../components/AutoSelector'; import { ConsoleMessage } from 'puppeteer-core'; import { getSubjectInfo } from '@/pages/course/subject/service'; +import { forEach } from 'lodash'; /** * 保存选题 @@ -85,13 +86,6 @@ const handleAppend = async (rules_id: number, rows: any[]) => { } }; -const waitTime = (time: number = 100) => { - return new Promise((resolve) => { - setTimeout(() => { - resolve(true); - }, time); - }); -}; const labels = ['A','B','C','D','E','F','G','H','I','J','K'] // 模拟考试规则维护 export default () => { @@ -103,10 +97,15 @@ export default () => { const [subjectId, setSubjectId] = useState(0); // 关联主题id const [subjectName, setSubjectName] = useState(''); // 关联主题name + const [questionTypeValues, setQuestionTypeValues] = useState([]); // 题型数据[{count:0, score:0, score_harf:0}] + const [uuidPaper, setUuidPaper] = useState(0); const [createType, setCreateType] = useState(1); // 组卷类型 const [rulesName, setRulesName] = useState(''); // 组卷类型 + const [sumScore, setSumScore] = useState(0); // 总分 + const [passScore, setPassScore] = useState(0); // 通过分数线 + const [typeQuestionCount, setTypeQuestionCount] = useState([0, 0, 0]); // 临时卷 各题型数量 const formRef = useRef(); @@ -120,6 +119,7 @@ export default () => { const [questionType, setQuestionType] = useState([]); // 题型 const [scoreValues, SetscoreValues] = useState([]); // 分值 [{"question_type": "0","score": "3","score_harf": "0"},] + const [paperInfo, setPaperInfo] = useState({}) /** 获取题型 */ const { data: questionTypeData } = useRequest(() => { @@ -141,13 +141,52 @@ export default () => { /** 组卷,查询试题临时表(当前选题列表) */ const { data: questions, run } = useRequest(async (params) => { console.log('questions', questions) - return queryTempQuestionList(params); + const _data = await queryTempQuestionList(params); + return _data; },{ manual: true, formatResult: (result) => { return result?.table_List; }}); + /** 从临时表中计算各题型数量 */ + useEffect(() => { + let _data = [0, 0, 0]; // 当前仅支持 单选 / 多选 / 判断 的顺序 + console.log('questions-info', questions) + questions?.forEach((item)=>{ + _data[Number(item?.question_type)] += 1 + }) + + setTypeQuestionCount(_data); + return ()=>{ + /** 退出当前页面清空Map */ + //parsingMap.clear(); + } + }, [questions]); + // + const { data: paperData, run: runPaper } = useRequest(async (params) => { + console.log('paperData', paperData) + /** + * rules_id: params?.id, + page_number: value.current, + page_size: value.pageSize + */ + return queryRulesPaper(params); + },{ + manual: true, + formatResult: (result) => { + return result?.question_list; + }}); + + useEffect(() => { + console.log('paperData2', paperData) + if(paperData?.length > 0){ + console.log('paperData[0]', paperData[0]) + setPaperInfo(paperData[0]) + } + console.log('PaperInfo', paperInfo) + }, [paperData]); + console.log(params, 'params'); let ruleData = {} @@ -256,7 +295,7 @@ export default () => { width="md" initialValue={ruleData?.examination_time} rules={[{ required: true, message: '请输入考试时长' }]} - tooltip="限制考试时长的情况下,用户考试中离开,倒计时不会停止。" /> + tooltip="单位(分钟)" /> )} @@ -275,6 +314,7 @@ export default () => { onFinish={async () => { console.log(formRef.current?.getFieldsValue()); setCurrentStep(2) // 设置步骤号 + runPaper({rules_id: params?.id }) return true; }} > @@ -349,7 +389,6 @@ export default () => { -
@@ -359,7 +398,7 @@ export default () => { { questionType.map((item)=>{ - return {item?.name} 共 { '-' } 题 { '-' } 分 + return {item?.name} 共 { typeQuestionCount[Number(item.code)] } 题 { '-' } 分 } )} @@ -378,6 +417,17 @@ export default () => { }}>选择试题