From 36b58c93b13e4d8362ab47b3d6e20922e8cbe3e4 Mon Sep 17 00:00:00 2001 From: zhengpengju Date: Fri, 25 Mar 2022 20:17:55 +0800 Subject: [PATCH 1/7] fix --- .../attestation/components/AutoSelector.tsx | 5 +- .../attestation/step/index.tsx | 39 +++++----- .../components/ScoreSetter.tsx | 48 ++++++------ .../examinationrules/normal/step/index.tsx | 51 +++++++++--- .../analysis/components/IntroduceRow.tsx | 1 - admin/src/pages/training/option/index.tsx | 78 ++++++++++++++++--- admin/src/pages/training/option/service.ts | 45 +++++++++++ 7 files changed, 202 insertions(+), 65 deletions(-) diff --git a/admin/src/pages/examinationrules/attestation/components/AutoSelector.tsx b/admin/src/pages/examinationrules/attestation/components/AutoSelector.tsx index 41d215e..082f4c4 100644 --- a/admin/src/pages/examinationrules/attestation/components/AutoSelector.tsx +++ b/admin/src/pages/examinationrules/attestation/components/AutoSelector.tsx @@ -92,8 +92,9 @@ console.log('props---', props) return ( <> - 生成试卷数量:{ - setPaperCount(value) + 生成试卷数量:{ + const value = e.currentTarget.value; + setPaperCount(value || 0) }} />试卷数量与学生重复考试次数一致 题库选择 diff --git a/admin/src/pages/examinationrules/attestation/step/index.tsx b/admin/src/pages/examinationrules/attestation/step/index.tsx index 328c01d..348c2b9 100644 --- a/admin/src/pages/examinationrules/attestation/step/index.tsx +++ b/admin/src/pages/examinationrules/attestation/step/index.tsx @@ -398,7 +398,7 @@ export default () => { 限制考试时长的情况下,用户考试中离开,倒计时不会停止。 - + {/* { 试卷数量与学生重复考试次数一致 + */} {console.log('###', ruleData)} @@ -477,7 +478,18 @@ export default () => { 请选择试题组卷并设置分值后保存} placement="bottom" color='#108ee9'> @@ -775,8 +798,8 @@ export default () => { handleScoreModalVisible(false) return true; }} - > - + >{console.log('q1',questionTypeValues)}{console.log('q2',scoreData)} + From a230a706e81f5e21035264ecee2220d77567c088 Mon Sep 17 00:00:00 2001 From: zhengpengju Date: Sun, 27 Mar 2022 21:48:42 +0800 Subject: [PATCH 5/7] fix --- .../components/ScoreSetter.tsx | 49 ++++++++----------- 1 file changed, 20 insertions(+), 29 deletions(-) diff --git a/admin/src/pages/examinationrules/components/ScoreSetter.tsx b/admin/src/pages/examinationrules/components/ScoreSetter.tsx index fb4cb0e..b848fb3 100644 --- a/admin/src/pages/examinationrules/components/ScoreSetter.tsx +++ b/admin/src/pages/examinationrules/components/ScoreSetter.tsx @@ -1,5 +1,4 @@ /** 模拟考试 | 资质考试选题 */ - import { InputNumber, Space, Form, Input} from 'antd'; //import styles from '../style.less'; import { forwardRef, useImperativeHandle, useRef, useState } from 'react'; @@ -24,18 +23,15 @@ export type TableListItem = { }; // React.forwardRef 接受渲染函数作为参数。React 将使用 props 和 ref 作为参数来调用此函数。此函数应返回 React 节点。 -const ScoreSetter = (props: any, ref: any) => { - const [flag, setFlag] = useState([]) // 分数变更标记 +const ScoreSetter = (props: any, ref: any) => { const {questionTypeValues, passScore: passScoreValue } = props + + const [flag, setFlag] = useState([]) // 分数变更标记 const [typeScore, setTypeScore] = useState(questionTypeValues.map((item: { code: number; score: number; score_harf: number; })=>({question_type:item.code, score: item.score, score_harf: item.score_harf}))) ; // 题型分数数组 [{"question_type": "0","score": "3","score_harf": "0"},] //const type = history.location.pathname === '/questionbank/attestation' ? 1 : 0 ; // 题库类型 - //const [selectedRowsState, setSelectedRows] = useState([]); - //const [addType, setAddType] = useState({name: '', value: 0}); //const [sumScore, setSumScore] = useState(); const [passScore, setPassScore] = useState(passScoreValue); // 设置通过分数线 - - //let sumScore = 0 // 总分 - //console.log('init........', typeScore) + const formRef = useRef(); /** 列表项定义 */ @@ -82,24 +78,22 @@ const ScoreSetter = (props: any, ref: any) => { { (record?.code === 1) && <> - 错选、漏选得: - { - // - const _data = []; - typeScore?.forEach((item: { score_harf: any; }, key: number)=>{ - _data.push({...item, score_harf: ((index === key) ? value : item?.score_harf)}) - }) - setTypeScore(_data) - }} /> - + 错选、漏选得: + { + const harf = typeScore?.map((item: { score_harf: any; }, key: number)=>{ + return {...item, score_harf: ((index === key) ? value : item?.score_harf)} + }) + setTypeScore(harf) + }} /> + } , @@ -117,9 +111,6 @@ const ScoreSetter = (props: any, ref: any) => { width: 80, defaultValue:()=>{ return 123}, render: (_text: any, _: any, index: number) => { - //console.log('typeScore---', typeScore) - //console.log('questionTypeValues',questionTypeValues) - //console.log('==score==',typeScore) return <> {flag?.indexOf(index) === -1 ? questionTypeValues[index]?.score * questionTypeValues[index].count : From 40767fb46bbea7cc5b1400dc6ccb5ed3c0083382 Mon Sep 17 00:00:00 2001 From: zhengpengju Date: Sun, 27 Mar 2022 21:59:11 +0800 Subject: [PATCH 6/7] fix --- admin/src/pages/examinationrules/components/ScoreSetter.tsx | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/admin/src/pages/examinationrules/components/ScoreSetter.tsx b/admin/src/pages/examinationrules/components/ScoreSetter.tsx index b848fb3..39c65ca 100644 --- a/admin/src/pages/examinationrules/components/ScoreSetter.tsx +++ b/admin/src/pages/examinationrules/components/ScoreSetter.tsx @@ -25,7 +25,7 @@ export type TableListItem = { // React.forwardRef 接受渲染函数作为参数。React 将使用 props 和 ref 作为参数来调用此函数。此函数应返回 React 节点。 const ScoreSetter = (props: any, ref: any) => { const {questionTypeValues, passScore: passScoreValue } = props - + const [flag, setFlag] = useState([]) // 分数变更标记 const [typeScore, setTypeScore] = useState(questionTypeValues.map((item: { code: number; score: number; score_harf: number; })=>({question_type:item.code, score: item.score, score_harf: item.score_harf}))) ; // 题型分数数组 [{"question_type": "0","score": "3","score_harf": "0"},] //const type = history.location.pathname === '/questionbank/attestation' ? 1 : 0 ; // 题库类型 @@ -109,7 +109,6 @@ const ScoreSetter = (props: any, ref: any) => { dataIndex: 'score_sum', //key: 'age', width: 80, - defaultValue:()=>{ return 123}, render: (_text: any, _: any, index: number) => { return <> {flag?.indexOf(index) === -1 ? From b1ebe5ded9926985446a89378cf746fbd40efa01 Mon Sep 17 00:00:00 2001 From: zhengpengju Date: Mon, 28 Mar 2022 15:46:06 +0800 Subject: [PATCH 7/7] fix score setter --- admin/src/pages/course/option/index.tsx | 10 +++++-- .../components/ScoreSetter.tsx | 28 ++++++++++++++----- .../examinationrules/normal/step/index.tsx | 7 +++-- admin/src/pages/questionbank/index.tsx | 5 ++-- 4 files changed, 34 insertions(+), 16 deletions(-) diff --git a/admin/src/pages/course/option/index.tsx b/admin/src/pages/course/option/index.tsx index 78ebaac..6ea760c 100644 --- a/admin/src/pages/course/option/index.tsx +++ b/admin/src/pages/course/option/index.tsx @@ -275,6 +275,7 @@ const CourseList: React.FC = () => { message.error('视频编码格式不正确(视频采用AVC,音频采用AAC)') return false; } + console.log('filename', file?.name) // 获取文件名 SetUploadFileName(file?.name); // 获取最后一个.的位置 @@ -609,9 +610,12 @@ const CourseList: React.FC = () => { //return false; await handleAdd({ ...values, - //course_id: currentRow?.course_id, - attachment_json: `{"img":"", "name": "${values?.attachment_json?.file?.name}", "url": "down/Syzx/${uuid?.substr(0, 2)}/${uuid}.mp4"}`, - attachment_filesize: values?.attachment_json?.file?.size, // 字节 + ////course_id: currentRow?.course_id, + //attachment_json: `{"img":"", "name": "${values?.attachment_json?.file?.name}", "url": "down/Syzx/${uuid?.substr(0, 2)}/${uuid}.mp4"}`, + //attachment_filesize: values?.attachment_json?.file?.size, // 字节 + + attachment_json: `{"img":"", "name": "${values?.attachment_json[0]?.name}", "url": "down/Syzx/${uuid?.substr(0, 2)}/${uuid}.mp4"}`, + attachment_filesize: values?.attachment_json[0]?.size, // 字节 }); handleCreateModalVisible(false); // 隐藏创建窗口 actionRef.current?.reloadAndRest?.(); diff --git a/admin/src/pages/examinationrules/components/ScoreSetter.tsx b/admin/src/pages/examinationrules/components/ScoreSetter.tsx index 39c65ca..3f2f6f3 100644 --- a/admin/src/pages/examinationrules/components/ScoreSetter.tsx +++ b/admin/src/pages/examinationrules/components/ScoreSetter.tsx @@ -61,7 +61,7 @@ const ScoreSetter = (props: any, ref: any) => { e.currentTarget.value = val.slice(0,3) } }} - defaultValue={questionTypeValues ? questionTypeValues[index]?.score : 0} + defaultValue={questionTypeValues ? questionTypeValues[index]?.score || 0 : 0} placeholder="请输入" size="small" onChange={(e)=>{ @@ -87,7 +87,7 @@ const ScoreSetter = (props: any, ref: any) => { message: '请输入分值!', },*/ ]} - >{ + >{ const harf = typeScore?.map((item: { score_harf: any; }, key: number)=>{ return {...item, score_harf: ((index === key) ? value : item?.score_harf)} }) @@ -102,7 +102,7 @@ const ScoreSetter = (props: any, ref: any) => { title: '题目数量', dataIndex: 'count', width: 80, - render: (_text: any, _: any, index: number) => <>{questionTypeValues ? questionTypeValues[index]?.count : '0'}, + render: (_text: any, _: any, index: number) => <>{questionTypeValues ? questionTypeValues[index]?.count || 0 : '0'}, }, { title: '总分值', @@ -112,8 +112,8 @@ const ScoreSetter = (props: any, ref: any) => { render: (_text: any, _: any, index: number) => { return <> {flag?.indexOf(index) === -1 ? - questionTypeValues[index]?.score * questionTypeValues[index].count : - (typeScore && questionTypeValues) ? ((typeScore[index]?.score > 0 ? typeScore[index]?.score : 0) * questionTypeValues[index]?.count).toFixed(1) : '0' + (questionTypeValues[index]?.score || 0) * (questionTypeValues[index]?.count || 0) : + (typeScore && questionTypeValues) ? ((typeScore[index]?.score > 0 ? typeScore[index]?.score : 0) * (questionTypeValues[index]?.count || 0)).toFixed(1) : '0' } }, @@ -154,20 +154,23 @@ const ScoreSetter = (props: any, ref: any) => { > { - return 共计 {sumQuestion} 题,总计 { + return 共计 {sumQuestion || 0} 题,总计 { + typeScore?.length > 0 && typeScore?.map((item: any, key: number)=>{return item?.score * questionTypeValues[key].count})?.reduce((total: number, item: number)=>(total + item)) || 0 } 分 通过分数线 - { + { setPassScore(value) }} />}} //formMapRef={formMapRef} rowKey={'code'} request={async ()=>{ + console.log('questionTypeValues1111', questionTypeValues) const result = await queryQuestionType() // 从字典获取题型数据 [{code: 0, name:"单选题"},] setTypeScore(questionTypeValues?.map((item: { score: any; score_harf: any; }, key: number)=>{ return {question_type: result.list[key]?.code, score: item?.score, score_harf: (item?.score_harf || 0)} })) + return {data:questionTypeValues?.map((item: any, key: number)=>({ ...item, code: result.list[key]?.code, @@ -175,6 +178,17 @@ const ScoreSetter = (props: any, ref: any) => { name: result.list[key]?.name, count: result.list[key]?.count }))} + + /* + return {data:result?.list?.map((item: any)=>({ + ...item, + code: item?.code, + question_type: item?.code, + name: item?.name, + count: item?.count || 0 + }))} + */ + }} bordered cardProps={{bodyStyle:{padding:0}}} diff --git a/admin/src/pages/examinationrules/normal/step/index.tsx b/admin/src/pages/examinationrules/normal/step/index.tsx index 1f5c1e1..7e804ac 100644 --- a/admin/src/pages/examinationrules/normal/step/index.tsx +++ b/admin/src/pages/examinationrules/normal/step/index.tsx @@ -642,7 +642,8 @@ export default () => { //const questionTypeScore = await queryQuestionTypeScore(params?.id || rulesId) //console.log('q::', questionTypeScore) - console.log('typeQuestionCount', typeQuestionCount); + console.log('typeQuestionCount---------------', typeQuestionCount); + setPassScore(ruleData?.pass_score) handleScoreModalVisible(true) }}>批量设置分值 @@ -798,8 +799,8 @@ export default () => { handleScoreModalVisible(false) return true; }} - >{console.log('q1',questionTypeValues)}{console.log('q2',scoreData)} - + > + 0 ? questionTypeValues : questionType?.map((item,key)=>({...item, count: typeQuestionCount[key]}))} passScore={passScore} /> diff --git a/admin/src/pages/questionbank/index.tsx b/admin/src/pages/questionbank/index.tsx index 269853e..0f7dd37 100644 --- a/admin/src/pages/questionbank/index.tsx +++ b/admin/src/pages/questionbank/index.tsx @@ -34,6 +34,7 @@ console.log('first'); * @param fields */ const handleAdd = async (fields: TableListItem) => { + console.log('handleadd...') const hide = message.loading('正在添加'); try { await saveQuestion({ ...fields }); @@ -292,7 +293,7 @@ const QuestionBank = () => { hideInForm: false, hideInSearch: true, formItemProps: { - rules: [ + rules: [ { required: true, message: '请填写试题解析', @@ -784,8 +785,6 @@ const QuestionBank = () => { onFinish={async (values: any) => { //console.log('formRef.current', formRef.current.getFieldsValue(['answertrue'])) console.log(values); - return - // 表单处理 console.log('columns:', columns); console.log('values:', values);