master
xialiang 3 years ago
parent 233c53137a
commit ed5e78a2bf

@ -58,7 +58,7 @@ const handleRemove = async (selectedRows: TableListItem[], currentRow) => {
try {
await removeExamination({
key: selectedRows.map((row) => row.key),
},currentRow);
}, currentRow);
hide();
message.success('删除成功,即将刷新');
return true;
@ -258,7 +258,7 @@ const ExaminationList: React.FC = () => {
hideInSearch: true,
hideInForm: true,
render: (dom, entity) => {
return entity.pass_count + "人/" + entity.apply_person_count + "人";
return entity.apply_person_count + "人";
},
},
{
@ -318,7 +318,7 @@ const ExaminationList: React.FC = () => {
</a>,
<a
key="remove"
onClick={ () => {
onClick={() => {
handleRemove([{ key: record?.examination_id }], record); // 调用批量删除函数如果接口不支持批量需要在service中处理
setSelectedRows([]);
actionRef.current?.reloadAndRest?.();
@ -590,7 +590,7 @@ const ExaminationList: React.FC = () => {
wrapperCol={{ span: 12 }}
onFinish={async (values) => {
console.log('values', values);
//const url = values?.upload[0]?.url?.replace('/dsideal_yy/html/','') || values?.upload[0]?.response?.url;
//const url = values?.upload[0]?.url?.replace('/dsideal_yy/html/','') || values?.upload[0]?.response?.url;
//console.log('url', url)
const params = {
...values,
@ -601,14 +601,14 @@ const ExaminationList: React.FC = () => {
examination_start_time: values?.examination_time[0],
examination_end_time: values?.examination_time[1]
}
delete params.apply_time
delete params.course_time
delete params.examination_time
await handleUpdate({
...params,
examination_id: currentRow?.examination_id,
});
});
handleUpdateModalVisible(false); // 隐藏编辑窗口
actionRef.current?.reloadAndRest?.();
console.log(values);

@ -1,6 +1,7 @@
import React, { useEffect, useRef, useState } from 'react';
import { history, useParams, useRequest } from 'umi';
import { ModalForm, ProFormInstance } from '@ant-design/pro-form';
import type { ProFormInstance } from '@ant-design/pro-form';
import { ModalForm } from '@ant-design/pro-form';
import { ProFormRadio } from '@ant-design/pro-form';
import ProForm, {
StepsForm,
@ -41,11 +42,11 @@ const handleAppend = async (rules_id: number, rows: any[]) => {
const hide = message.loading('正在添加');
try {
const questions: { question_id: any; }[] = [];
rows?.forEach((item)=>{
questions.push({question_id: item?.id})
rows?.forEach((item) => {
questions.push({ question_id: item?.id })
})
const _data = await manualPaper({
question_count: questions?.length || 0,
const _data = await manualPaper({
question_count: questions?.length || 0,
questions: JSON.stringify(questions),
rules_id: Number(rules_id)
});
@ -64,15 +65,15 @@ const handleAppend = async (rules_id: number, rows: any[]) => {
*
* @param values
*/
const handleUpdatePaper = async ( rules_id: number, paper_uuid: number, paper_id: number) => {
const handleUpdatePaper = async (rules_id: number, paper_uuid: number, paper_id: number) => {
const hide = message.loading('正在保存');
try {
const _data = {
rules_id: Number(rules_id),
paper_uuid: paper_uuid,
rules_id: Number(rules_id),
paper_uuid: paper_uuid,
paper_id: paper_id
}
if(paper_id === 0){
if (paper_id === 0) {
delete _data.paper_id;
}
await updatePaper(_data);
@ -86,13 +87,13 @@ const handleAppend = async (rules_id: number, rows: any[]) => {
}
};
const labels = ['A','B','C','D','E','F','G','H','I','J','K']
const labels = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K']
// 模拟考试规则维护
export default () => {
const [selectorModalVisible, handleSelectorModalVisible] = useState<boolean>(false);
const [scoreModalVisible, handleScoreModalVisible] = useState<boolean>(false);
const [autoModalVisible, handleAutoModalVisible] = useState<boolean>(false);
const [autoModalVisible, handleAutoModalVisible] = useState<boolean>(false);
const [subjectId, setSubjectId] = useState<number>(0); // 关联主题id
const [subjectName, setSubjectName] = useState(''); // 关联主题name
@ -104,63 +105,64 @@ export default () => {
const [rulesName, setRulesName] = useState<string>(''); // 组卷类型
const [sumScore, setSumScore] = useState<number>(0); // 总分
const [passScore, setPassScore] = useState<number>(0); // 通过分数线
const [typeQuestionCount, setTypeQuestionCount] = useState([0, 0, 0]); // 临时卷 各题型数量
const formRef = useRef<ProFormInstance>();
const selectorRef = useRef();
const setterRef = useRef();
const autoRef = useRef();
const autoRef = useRef();
const [currentStep, setCurrentStep] = useState(0);
const [currentStep, setCurrentStep] = useState(0);
const params = useParams();
const [questionType, setQuestionType] = useState([]); // 题型
const [scoreValues, SetscoreValues] = useState([]); // 分值 [{"question_type": "0","score": "3","score_harf": "0"},]
const [paperInfo, setPaperInfo] = useState({})
/** 获取题型 */
const { data: questionTypeData } = useRequest(() => {
return queryQuestionType();
},{
}, {
formatResult: (result) => {
return result.list;
return result.list;
}
});
useEffect(() => {
setQuestionType(questionTypeData || []);
return ()=>{
/** 退出当前页面清空Map */
//parsingMap.clear();
return () => {
/** 退出当前页面清空Map */
//parsingMap.clear();
}
}, [questionTypeData]);
/** 组卷,查询试题临时表(当前选题列表) */
const { data: questions, run } = useRequest(async (params) => {
console.log('questions', questions)
const _data = await queryTempQuestionList(params);
return _data;
},{
}, {
manual: true,
formatResult: (result) => {
return result?.table_List;
}});
return result?.table_List;
}
});
/** 从临时表中计算各题型数量 */
useEffect(() => {
let _data = [0, 0, 0]; // 当前仅支持 单选 / 多选 / 判断 的顺序
const _data = [0, 0, 0]; // 当前仅支持 单选 / 多选 / 判断 的顺序
console.log('questions-info', questions)
questions?.forEach((item)=>{
questions?.forEach((item) => {
_data[Number(item?.question_type)] += 1
})
setTypeQuestionCount(_data);
return ()=>{
/** 退出当前页面清空Map */
//parsingMap.clear();
return () => {
/** 退出当前页面清空Map */
//parsingMap.clear();
}
}, [questions]);
//
@ -172,19 +174,20 @@ export default () => {
page_size: value.pageSize
*/
return queryRulesPaper(params);
},{
}, {
manual: true,
formatResult: (result) => {
return result?.question_list;
}});
return result?.question_list;
}
});
useEffect(() => {
console.log('paperData2', paperData)
if(paperData?.length > 0){
if (paperData?.length > 0) {
console.log('paperData[0]', paperData[0])
setPaperInfo(paperData[0])
}
console.log('PaperInfo', paperInfo)
console.log('PaperInfo', paperInfo)
}, [paperData]);
console.log(params, 'params');
@ -194,10 +197,11 @@ export default () => {
//console.log(JSON.stringify(params), "878");
const { data } = useRequest(async () => {
return queryRulesView(params);
},{
}, {
formatResult: (result) => {
return result?.bean;
}});
return result?.bean;
}
});
ruleData = data
}
console.log(ruleData, 'ruleData');
@ -261,9 +265,15 @@ export default () => {
initialValue={ruleData?.rules_name}
// tooltip="最长为 6 位汉字,需要与考生身份证一致"
placeholder="请输入名称"
rules={[{ required: true, message: '请输入考试名称' }]}
// value="锦书"
// disabled
rules={[
{ required: true, message: '请输入考试名称' },
{
pattern: /^[^\s]*$/,
message: '禁止输入空格'
}
]}
// value="锦书"
// disabled
/>
<ProFormSelect
@ -273,7 +283,7 @@ export default () => {
return querySubjectList().then(({ data }) => {
console.log(data, 'querySubjectList')
return data.list.map((item) => {
if(item?.subject_id === ruleData?.subject_id){
if (item?.subject_id === ruleData?.subject_id) {
setSubjectName(item?.subject_name) // 设置关联主题名称
console.log('label::', item?.subject_name)
}
@ -284,7 +294,7 @@ export default () => {
});
});
}}
onChange={(value)=>{
onChange={(value) => {
console.log('on change', value)
}}
rules={[{ required: true, message: '请选择主题' }]}
@ -294,7 +304,15 @@ export default () => {
<ProFormText name="examination_time" label="考试时长"
width="md"
initialValue={ruleData?.examination_time}
rules={[{ required: true, message: '请输入考试时长' }]}
rules={[
{
required: true,
message: '请输入考试时长'
},
{
pattern: /^[^\s]*$/,
message: '禁止输入空格'
}]}
tooltip="单位(分钟)" />
</>
)}
@ -314,26 +332,26 @@ export default () => {
onFinish={async () => {
console.log(formRef.current?.getFieldsValue());
setCurrentStep(2) // 设置步骤号
runPaper({rules_id: params?.id })
runPaper({ rules_id: params?.id })
return true;
}}
>
<div style={{ margin: '0' }}>
<Typography style={{ padding: 24, fontSize: 24, textAlign: 'center' }}>{rulesName}</Typography>
{/** 一旦录入另一项将禁用,清空组卷后可选另一项 */}
<Radio.Group size='large' value={createType} onChange={(e) => {
<Radio.Group size='large' value={createType} onChange={(e) => {
setCreateType(Number(e?.target?.value))
console.log('value', e?.target?.value)
//handleAutoModalVisible(true); // 显示系统组卷窗口
}} style={{ marginBottom: 16, }}>
<Radio.Button value={1} style={{width:200, textAlign:'center'}}></Radio.Button>
<Radio.Button value={2} style={{width:200, textAlign:'center'}}></Radio.Button>
<Radio.Button value={1} style={{ width: 200, textAlign: 'center' }}></Radio.Button>
<Radio.Button value={2} style={{ width: 200, textAlign: 'center' }}></Radio.Button>
</Radio.Group>
<Divider style={{ margin: '6px 0', opacity: 0.5 }} />
<Row>
<Col span={18} style={{ background: '#ffffff', padding: 0 }}>
<ProCard
title=""
extra={false}
@ -342,95 +360,95 @@ export default () => {
headerBordered
>
<Space direction="vertical" style={{ width: '100%', padding: '24px 48px' }}>
{ questions && questions.map((item, idx)=>(
item &&
<div style={{border:'none'}}>
<Typography style={{ marginBottom: 16, fontSize: 14, padding: '15px 15px 0 15px' }}>
{idx+1}. {item?.question_stem}
</Typography>
{(item?.question_type === 0) && // 单选题
<div style={{padding:'0 15px 15px 15px'}}>
{item?.answers && item?.answers.map((anster, k)=>(
<div value={k} checked style={{width: '100%', padding: 5, fontSize: 14 }}>
{anster?.is_true === '0' && <span style={{color:'#1890ff', border:'1px solid #1890ff', display:'inline-block', width:16, height:16, textAlign:'center', borderRadius:'50%', fontSize:12, lineHeight:'12px', marginRight:10}}>{labels[k]} </span> }
{anster?.is_true === '1' && <span style={{color:'#ffffff', border:'1px solid #1890ff', display:'inline-block', width:16, height:16, textAlign:'center', borderRadius:'50%', fontSize:12, lineHeight:'12px', marginRight:10, backgroundColor:'#1890ff'}}>{labels[k]} </span> }
<span style={{display:'inline-block'}}>{anster?.answer}</span>
</div>
))}
</div>
}
{(item?.question_type === 1) && // 多选题
<div style={{padding:'0 15px 15px 15px'}}>
{item?.answers && item?.answers.map((anster, k)=>(
<div value={k} checked style={{width: '100%', padding: 5, fontSize: 14 }}>
{anster?.is_true === '0' && <span style={{color:'#1890ff', border:'1px solid #1890ff', display:'inline-block', width:16, height:16, textAlign:'center', borderRadius:'50%', fontSize:12, lineHeight:'12px', marginRight:10}}>{labels[k]} </span> }
{anster?.is_true === '1' && <span style={{color:'#ffffff', border:'1px solid #1890ff', display:'inline-block', width:16, height:16, textAlign:'center', borderRadius:'50%', fontSize:12, lineHeight:'12px', marginRight:10, backgroundColor:'#1890ff'}}>{labels[k]} </span> }
<span style={{display:'inline-block'}}>{anster?.answer}</span>
</div>
))}
{questions && questions.map((item, idx) => (
item &&
<div style={{ border: 'none' }}>
<Typography style={{ marginBottom: 16, fontSize: 14, padding: '15px 15px 0 15px' }}>
{idx + 1}. {item?.question_stem}
</Typography>
{(item?.question_type === 0) && // 单选题
<div style={{ padding: '0 15px 15px 15px' }}>
{item?.answers && item?.answers.map((anster, k) => (
<div value={k} checked style={{ width: '100%', padding: 5, fontSize: 14 }}>
{anster?.is_true === '0' && <span style={{ color: '#1890ff', border: '1px solid #1890ff', display: 'inline-block', width: 16, height: 16, textAlign: 'center', borderRadius: '50%', fontSize: 12, lineHeight: '12px', marginRight: 10 }}>{labels[k]} </span>}
{anster?.is_true === '1' && <span style={{ color: '#ffffff', border: '1px solid #1890ff', display: 'inline-block', width: 16, height: 16, textAlign: 'center', borderRadius: '50%', fontSize: 12, lineHeight: '12px', marginRight: 10, backgroundColor: '#1890ff' }}>{labels[k]} </span>}
<span style={{ display: 'inline-block' }}>{anster?.answer}</span>
</div>
))}
</div>
}
{(item?.question_type === 1) && // 多选题
<div style={{ padding: '0 15px 15px 15px' }}>
{item?.answers && item?.answers.map((anster, k) => (
<div value={k} checked style={{ width: '100%', padding: 5, fontSize: 14 }}>
{anster?.is_true === '0' && <span style={{ color: '#1890ff', border: '1px solid #1890ff', display: 'inline-block', width: 16, height: 16, textAlign: 'center', borderRadius: '50%', fontSize: 12, lineHeight: '12px', marginRight: 10 }}>{labels[k]} </span>}
{anster?.is_true === '1' && <span style={{ color: '#ffffff', border: '1px solid #1890ff', display: 'inline-block', width: 16, height: 16, textAlign: 'center', borderRadius: '50%', fontSize: 12, lineHeight: '12px', marginRight: 10, backgroundColor: '#1890ff' }}>{labels[k]} </span>}
<span style={{ display: 'inline-block' }}>{anster?.answer}</span>
</div>
))}
</div>
}
{(item?.question_type === 2) && // 判断选题
<div style={{ padding: '0 15px 15px 15px' }}>
{item?.answers && item?.answers.map((anster, k) => (
<div value={k} checked style={{ width: '100%', padding: 5, fontSize: 14 }}>
{anster?.is_true === '0' && <span style={{ color: '#1890ff', border: '1px solid #1890ff', display: 'inline-block', width: 16, height: 16, textAlign: 'center', borderRadius: '50%', fontSize: 12, lineHeight: '12px', marginRight: 10 }}>{labels[k]} </span>}
{anster?.is_true === '1' && <span style={{ color: '#ffffff', border: '1px solid #1890ff', display: 'inline-block', width: 16, height: 16, textAlign: 'center', borderRadius: '50%', fontSize: 12, lineHeight: '12px', marginRight: 10, backgroundColor: '#1890ff' }}>{labels[k]} </span>}
<span style={{ display: 'inline-block' }}>{anster?.answer}</span>
</div>
))}
</div>
}
<div style={{ height: 'auto', backgroundColor: '#f0f0f0', textAlign: 'right', padding: 5, opacity: 0.5 }}>
<Button><ArrowUpOutlined /></Button> <Button><ArrowDownOutlined /></Button> <Button><DeleteOutlined /></Button>
</div>
}
{(item?.question_type === 2) && // 判断选题
<div style={{padding:'0 15px 15px 15px'}}>
{item?.answers && item?.answers.map((anster, k)=>(
<div value={k} checked style={{width: '100%', padding: 5, fontSize: 14 }}>
{anster?.is_true === '0' && <span style={{color:'#1890ff', border:'1px solid #1890ff', display:'inline-block', width:16, height:16, textAlign:'center', borderRadius:'50%', fontSize:12, lineHeight:'12px', marginRight:10}}>{labels[k]} </span> }
{anster?.is_true === '1' && <span style={{color:'#ffffff', border:'1px solid #1890ff', display:'inline-block', width:16, height:16, textAlign:'center', borderRadius:'50%', fontSize:12, lineHeight:'12px', marginRight:10, backgroundColor:'#1890ff'}}>{labels[k]} </span> }
<span style={{display:'inline-block'}}>{anster?.answer}</span>
</div>
))}
</div>
}
<div style={{height:'auto', backgroundColor:'#f0f0f0', textAlign:'right', padding:5, opacity:0.5}}>
<Button><ArrowUpOutlined /></Button> <Button><ArrowDownOutlined /></Button> <Button><DeleteOutlined /></Button>
</div>
</div>
))}
</Space>
))}
</Space>
</ProCard>
</Col>
<Col span={6} style={{ paddingLeft: 24 }}>
<div style={{ background: '#ffffff', padding: 24 }}>
<Space direction="vertical" style={{ width: '100%' }}>
<strong></strong>
<Typography> { '-' } { '-' } </Typography>
<Typography> {'-'} {'-'} </Typography>
<Divider style={{ margin: '6px 0', opacity: 0.5 }} />
<Space direction="vertical">
{ questionType.map((item)=>{
return <Typography>{item?.name} { typeQuestionCount[Number(item.code)] } { '-' } </Typography>
{questionType.map((item) => {
return <Typography>{item?.name} {typeQuestionCount[Number(item.code)]} {'-'} </Typography>
}
)}
)}
</Space>
<Divider style={{ margin: '6px 0', opacity: 0.5 }} />
<Button size="large" block onClick={()=>{
<Button size="large" block onClick={() => {
console.log('createType', createType)
if(createType === 1){
console.log('11:',createType)
if (createType === 1) {
console.log('11:', createType)
handleSelectorModalVisible(true)
}else{
console.log('22:',createType)
} else {
console.log('22:', createType)
handleAutoModalVisible(true); // 显示系统组卷窗口(true)
}
}}></Button>
<Button size="large" block onClick={()=>{
<Button size="large" block onClick={() => {
/**
*
* [{count: 0, score: 0, score_harf: 0},{count: 0, score: 0, score_harf: 0},{count: 0, score: 0, score_harf: 0}]
*/
//
const _data = []
typeQuestionCount?.forEach((item)=>{
_data.push({count: item, score: 0, score_harf: 0})
typeQuestionCount?.forEach((item) => {
_data.push({ count: item, score: 0, score_harf: 0 })
})
setQuestionTypeValues(_data)
console.log('typeQuestionCount', typeQuestionCount);
handleScoreModalVisible(true)
}}></Button>
<Button size="large" type="primary" block onClick={async ()=>{
<Button size="large" type="primary" block onClick={async () => {
console.log('uuidPaper::', uuidPaper)
console.log('rules_id::', params?.id)
const paper_id = paper_id ? paper_id : 0;
@ -463,28 +481,28 @@ export default () => {
column={1}
//actionRef={actionRef}
title={false}
request={async () => {
request={async () => {
const result = await queryRulesView(params)
console.log('queryRulesView', result)
const subjectInfo = await getSubjectInfo({subject_id: result.bean.subject_id})
const subjectInfo = await getSubjectInfo({ subject_id: result.bean.subject_id })
console.log('subjectInfo', subjectInfo)
return {data: {...result.bean, subject_name: subjectInfo.data.subject_name}};
return { data: { ...result.bean, subject_name: subjectInfo.data.subject_name } };
}}
extra={false}
>
<ProDescriptions.Item dataIndex="id" hideInDescriptions />
<ProDescriptions.Item dataIndex="rules_name" label="考试名称" valueType="text" />
<ProDescriptions.Item dataIndex="subject_name" label="关联培训主题" valueType="text" />
<ProDescriptions.Item dataIndex="examination_time" label="考试时长" valueType="text" renderText={(text)=>(`${text} 分钟`)} />
<ProDescriptions.Item dataIndex="examination_time" label="考试时长" valueType="text" renderText={(text) => (`${text} 分钟`)} />
<ProDescriptions.Item dataIndex="grade" label="试卷信息" valueType="text" render={()=>{
{/** 需要从试卷 或 临时试卷 中读取 需要处理 */}
<ProDescriptions.Item dataIndex="grade" label="试卷信息" valueType="text" render={() => {
{/** 需要从试卷 或 临时试卷 中读取 需要处理 */ }
return <Space direction="vertical">
<span> 0 , {paperInfo?.sum_score} </span>
<span>: 0 : 0 : 0 </span>
<span>线 {paperInfo?.pass_score} </span>
</Space>
}} />
</Space>
}} />
</ProDescriptions>
}
</Col>
@ -492,27 +510,27 @@ export default () => {
</StepsForm.StepForm>
</StepsForm>
</ProCard>
<ModalForm
title={`手动组卷`}
width="60%"
visible={selectorModalVisible}
onVisibleChange={handleSelectorModalVisible}
onFinish={async (values) => {
onFinish={async (values) => {
console.log('v::::', values.name);
const rows = selectorRef?.current?.getSelectedRows()
console.log('rows::::', rows);
const {code, data: paper, msg} = await handleAppend(Number(params?.id), rows)
const { code, data: paper, msg } = await handleAppend(Number(params?.id), rows)
console.log('paper', paper)
setUuidPaper(paper?.paper_uuid)
console.log('paper_uuid', paper?.paper_uuid)
run({
paper_uuid: paper?.paper_uuid,
paper_uuid: paper?.paper_uuid,
page_size: 1000,
page_number: 1
}); // 获取当前选题列表
// message.success('提交成功');
handleSelectorModalVisible(false)
handleSelectorModalVisible(false)
return true;
}}
>
@ -523,8 +541,8 @@ export default () => {
//
width="60%"
visible={autoModalVisible}
onVisibleChange={ handleAutoModalVisible }
onFinish={async () => {
onVisibleChange={handleAutoModalVisible}
onFinish={async () => {
// 需要处理
//console.log('111')
//const values = autoRef?.current?.getData()
@ -552,18 +570,18 @@ export default () => {
console.log('批量设置分值v::::2', values);
// 题型分数
const {code, data: paper, msg} = await saveQuestionTypeScore({rules_id:Number(params?.id), type_score: JSON.stringify(values)})
const { code, data: paper, msg } = await saveQuestionTypeScore({ rules_id: Number(params?.id), type_score: JSON.stringify(values) })
// 总分及通过分
let _sumScore = 0;
values?.forEach((item)=>{
console.log('item--',item)
values?.forEach((item) => {
console.log('item--', item)
_sumScore += item?.score
})
//console.log('_sumScore', _sumScore)
//console.log('passScore',passScore)
console.log('sumScore',sumScore)
const {success} = await updateScore({rules_id:Number(params?.id), pass_socre: passSocre, sum_score: _sumScore})
console.log('sumScore', sumScore)
const { success } = await updateScore({ rules_id: Number(params?.id), pass_socre: passSocre, sum_score: _sumScore })
setSumScore(_sumScore)
console.log('paper', paper)
// setUuidPaper(paper?.paper_uuid)
@ -572,7 +590,7 @@ export default () => {
return true;
}}
>
<ScoreSetter ref={setterRef} questionTypeValues={questionTypeValues || false} />
<ScoreSetter ref={setterRef} questionTypeValues={questionTypeValues || false} />
</ModalForm>
</PageContainer>

@ -50,7 +50,7 @@ const TableList: React.FC = () => {
renderText: (val: string) => `${val}`,
},
{
title: '比例',
title: '通过率',
dataIndex: 'pass_rate',
sorter: true,
hideInForm: true,

@ -186,7 +186,7 @@ export default defineConfig({
{
name: '综合模拟考试结果',
icon: 'smile',
path: '/mockExamination/index/success/:time/:pass_score/:score/:sum_score',
path: '/mockExamination/index/success/:time/:pass_score/:score/:sum_score/:rules_name',
component: './mockExamination/paper/success',
hideInMenu: true,
},

@ -104,3 +104,11 @@ ol {
border: #ff1837 1px solid;
color: #ff1818;background-color: #ffe6ea;
}
.dt-demo{
margin: 4px!important;
border-radius: 5px!important;
width: 20px!important;
height: 20px!important;
float: right!important;
}

@ -212,12 +212,18 @@ const CardList = () => {
)}
<div>
<div style={{ float: 'right', lineHeight: "28px" }}>
</div><div className='pdefault dt-demo' />
<div style={{ float: 'right', lineHeight: "28px" }}>
</div><div className='pok dt-demo' />
</div>
</ProCard>
</Col>
<Col span={13} style={{ background: '#ffffff', padding: 0 }}>
<ProCard
title={
questionNow.question_type === 0 ? "一、单选器" : questionNow.question_type === 1 ? "二、多选题" : questionNow.question_type === 2 ? "判断题" : ""
questionNow.question_type === 0 ? "一、单选" : questionNow.question_type === 1 ? "二、多选题" : questionNow.question_type === 2 ? "判断题" : ""
}
extra={false}
split='vertical'
@ -226,14 +232,14 @@ const CardList = () => {
>
<Space direction="vertical" style={{ width: '100%', padding: '24px 48px' }}>
<Typography style={{ marginBottom: 16, fontSize: 18 }}>
{questionNow?.question_stem}
{questionNow.id ? questionNow.index[0] + 1 : ""} {questionNow?.question_stem}
</Typography>
<Space direction="vertical" style={{ fontSize: 16 }}>
<Form
ref={formRef} name="control-ref"
>
<Form.Item name="note" rules={[{ required: true }]}>
<Form.Item name="note">
{questionNow.question_type === 0 ?
@ -247,12 +253,9 @@ const CardList = () => {
onChange={(e) => {
const qArr = []
// 默认输出答案0000
questionNow?.answers?.map(() => {
qArr.push("0")
questionNow?.answers?.map((qitem) => {
qitem.id === e.target.value ? qArr.push("1") : qArr.push("0")
})
// 修改用户答案
qArr[index] = item.is_true
const questionList = questionTypeList
const questionAnswer = qArr.join(",")
@ -344,12 +347,9 @@ const CardList = () => {
onChange={(e) => {
const qArr = []
// 默认输出答案0000
questionNow?.answers?.map(() => {
qArr.push("0")
questionNow?.answers?.map((qitem) => {
qitem.id === e.target.value ? qArr.push("1") : qArr.push("0")
})
// 修改用户答案
qArr[index] = item.is_true
const questionList = questionTypeList
const questionAnswer = qArr.join(",")
@ -417,7 +417,7 @@ const CardList = () => {
let nextData = {}
questionList[nextTemp.index[0]].question_list.map((item, index) => {
if (item.question_id === nextTemp.question_id) {
nextData = { ...item, index: index }
nextData = item
}
})
setQuestionNow(nextData)
@ -441,7 +441,7 @@ const CardList = () => {
let nextData = {}
questionList[nextTemp.index[0]].question_list.map((item, index) => {
if (item.question_id === nextTemp.question_id) {
nextData = { ...item, index: index }
nextData = item
}
})
setQuestionNow(nextData)

@ -40,6 +40,7 @@ const CardList = () => {
const params = useParams();
const info = params.info.split(',');
@ -67,8 +68,10 @@ const CardList = () => {
// 根据答题卡生成考试顺序
const questionSort = []
let questionNum = 0
questionList.map((item, index) => {
questionList[index].question_list.map((e, i) => {
questionNum += 1
questionList[index].question_list[i].index = [index, i]
finish_list.map((f_item, f_index) => {
// console.log("f_item.teacher_answer", e)
@ -89,7 +92,7 @@ const CardList = () => {
})
}
)
// console.log(questionSort, '试题顺序', questionList, "已答", finish_list)
console.log(questionSort, '试题顺序', questionList, "已答", finish_list, "试题总数", questionNum)
setPaperInfo(questionSort)
setQuestionTypeList(questionList || [])
setQuestionNow(questionSort[0] || [])
@ -117,11 +120,13 @@ const CardList = () => {
// 当前选择试题修改已选择状态,设置当前题号
useEffect(() => {
console.log(questionNow.answerId, 'questionNow.answerId questionNow.answerId ')
console.log(questionNow, 'questionNow.answerId questionNow.answerId ')
// 已选择题目回显
formRef?.current?.setFieldsValue({ note: questionNow.answerId });
// 设置当前题号
paperInfo.map((item, index) => {
if (item.id === questionNow.id) {
setQuestionNowNum(index + 1)
@ -129,10 +134,10 @@ const CardList = () => {
})
}, [questionNow]);
// 题号改变判断是否有上一道下一道题按钮
useEffect(() => {
setLastBtnShow(questionNowNum == 1 ? true : false)
setNextBtnShow(questionNowNum == questionNum ? true : false)
}, [questionNowNum])
const content = (
@ -144,10 +149,7 @@ const CardList = () => {
);
const numbers = [];
for (let i = 0; i < 50; i++) {
numbers.push({ id: `${i}` })
}
// 试题选项编号转中文
const tiNum = (a: number) => {
switch (a) {
case 0:
@ -186,10 +188,13 @@ const CardList = () => {
}
}
// 计算试题总数以及已答题数
return (
<PageContainer content={content} extraContent={false}>
<Row>
{/* {console.log("试题列表:", paperInfo, "答题卡:", questionTypeList, "当前试题", questionNow)} */}
{console.log("试题列表:", paperInfo, "答题卡:", questionTypeList, "当前试题", questionNow)}
{/* {console.log(questionTypeList, 'uestionTypeList')} */}
<Col span={6} style={{ paddingRight: 24 }}>
@ -239,12 +244,20 @@ const CardList = () => {
)}
<div>
<div style={{ float: 'right', lineHeight: "28px" }}>
</div><div className='pdefault dt-demo' />
<div style={{ float: 'right', lineHeight: "28px" }}>
</div><div className='pok dt-demo' />
<div style={{ float: 'right', lineHeight: "28px" }}>
</div><div className='perror dt-demo' />
</div>
</ProCard>
</Col>
<Col span={13} style={{ background: '#ffffff', padding: 0 }}>
<ProCard
title={
questionNow.question_type === 0 ? "一、单选器" : questionNow.question_type === 1 ? "二、多选题" : questionNow.question_type === 2 ? "判断题" : ""
questionNow.question_type === 0 ? "一、单选" : questionNow.question_type === 1 ? "二、多选题" : questionNow.question_type === 2 ? "判断题" : ""
}
extra={false}
split='vertical'
@ -253,14 +266,14 @@ const CardList = () => {
>
<Space direction="vertical" style={{ width: '100%', padding: '24px 48px' }}>
<Typography style={{ marginBottom: 16, fontSize: 18 }}>
{questionNow?.question_stem}
{questionNow.id ? questionNow.index[0] + 1 : ""} {questionNow?.question_stem}
{console.log("question", questionNow)}
</Typography>
<Space direction="vertical" style={{ fontSize: 16 }}>
<Form
ref={formRef} name="control-ref"
>
<Form.Item name="note" rules={[{ required: true }]}>
<Form.Item name="note">
{questionNow.question_type === 0 ?
@ -273,12 +286,11 @@ const CardList = () => {
onChange={(e) => {
const qArr = []
// 默认输出答案0000
questionNow?.answers?.map(() => {
qArr.push("0")
questionNow?.answers?.map((qitem) => {
qitem.id === e.target.value ? qArr.push("1") : qArr.push("0")
})
// 修改用户答案
qArr[index] = item.is_true
// qArr[index] = item.is_true
const questionList = questionTypeList
const questionAnswer = qArr.join(",")
@ -291,6 +303,7 @@ const CardList = () => {
// 修改答题卡状态 写入答案以及修改答题状态
const qX = questionNow?.question_type;
const qI = questionNow?.index;
console.log(questionNow, '答题', questionAnswer, questionNow.answertrue)
questionList[questionNow.index[0]].question_list[questionNow.index[1]].answerSelect = questionAnswer;
if (questionAnswer === questionNow.answertrue) {
questionList[questionNow.index[0]].question_list[questionNow.index[1]].state = 0
@ -312,7 +325,7 @@ const CardList = () => {
// 答案 0101
console.log(e, 'questionNow.answerId questionNow.answerId 2')
const qArr = []
// 默认输出答案0000
questionNow?.answers?.map((item) => {
if (e.indexOf(item.id) > -1) {
qArr.push("1")
@ -321,7 +334,7 @@ const CardList = () => {
}
})
console.log("qArrqArr", qArr)
const questionList = questionTypeList
const questionAnswer = qArr.join(",")
@ -367,12 +380,11 @@ const CardList = () => {
onChange={(e) => {
const qArr = []
// 默认输出答案0000
questionNow?.answers?.map(() => {
qArr.push("0")
questionNow?.answers?.map((qitem) => {
qitem.id === e.target.value ? qArr.push("1") : qArr.push("0")
})
// 修改用户答案
qArr[index] = item.is_true
// qArr[index] = item.is_true
const questionList = questionTypeList
const questionAnswer = qArr.join(",")
@ -422,9 +434,7 @@ const CardList = () => {
<Col span={5} style={{ paddingLeft: 24 }}>
<div style={{ background: '#ffffff', padding: 24 }}>
<Space direction="vertical" style={{ width: '100%' }}>
<strong></strong>
<Typography>614</Typography>
<Divider style={{ margin: '6px 0', opacity: 0.5 }} />
<strong></strong>
<Typography>{questionNowNum}/{questionNum}</Typography>
<Divider style={{ margin: '6px 0', opacity: 0.5 }} />
@ -442,7 +452,7 @@ const CardList = () => {
let nextData = {}
questionList[nextTemp.index[0]].question_list.map((item, index) => {
if (item.id === nextTemp.id) {
nextData = { ...item, index: index }
nextData = item
}
})
setQuestionNow(nextData)
@ -466,7 +476,7 @@ const CardList = () => {
let nextData = {}
questionList[nextTemp.index[0]].question_list.map((item, index) => {
if (item.id === nextTemp.id) {
nextData = { ...item, index: index }
nextData = item
}
})
setQuestionNow(nextData)

@ -70,7 +70,9 @@ const CardList = () => {
const params = useParams();
// 组卷详情查询
const [rulesPaperInfo, setRulesPaperInfo] = useState([]);
const [rulesPaperInfo, setRulesPaperInfo] = useState({});
// 试题分数
const [rulesPaperScore, setRulesPaperScore] = useState([]);
// 试题列表
const [paperInfo, setPaperInfo] = useState([]);
//答题卡列表
@ -98,15 +100,21 @@ const CardList = () => {
useEffect(() => {
let secondValue = params.rules_time * 60; // 秒 截至时间 - 服务器当前时间
setTimeData(secondValue)
// console.log(secondValue);
const timer = setInterval(() => { //
setTimeData((secondValue >= 1) ? secondValue-- : 0);
console.log(questionTypeList, 'secondValue', rulesPaperInfo);
if (secondValue === 0) {
handelFinishExamination()
clearInterval(timer)
return
}
}, 1000);
return () => {
clearInterval(timer) // 清理计算器
}
}, [])
}, [questionTypeList, rulesPaperInfo])
@ -123,8 +131,12 @@ const CardList = () => {
return result;
},
onSuccess: (result) => {
// console.log(result, 111111111111111);
if (result.success) {
setRulesPaperInfo(result.question_list[0] || [])
// 设置分数
setRulesPaperScore(result.question_type_score || [])
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)
}
@ -199,9 +211,9 @@ const CardList = () => {
if (result.success) {
const res = result.data
const time = params.rules_time * 60 - timeData
console.log(res, 'questionFinish server111', time)
console.log(res, 'questionFinish server111', rulesPaperInfo)
history.push(`/mockExamination/index/success/${time}/${res.pass_score}/${res.score}/${res.sum_score}`);
history.push(`/mockExamination/index/success/${time}/${res.pass_score}/${res.score}/${res.sum_score}/${rulesPaperInfo.rules_name}`);
}
}
@ -236,6 +248,31 @@ const CardList = () => {
);
// 提交试卷
const handelFinishExamination = () => {
const questionFinishId = []
questionTypeList.map((e, i) => {
questionTypeList[i].children.map((e, index) => {
const answerId = e.answerId
answerId !== "" ? questionFinishId.push({
answer_id: (answerId instanceof Array) ? answerId.join(',') : answerId,
question_id: e.id,
question_type: e.question_type
}) : ""
})
})
const questionFinish = {
answers: JSON.stringify(questionFinishId),
rules_id: rulesPaperInfo.rules_id,
person_id: cookie.load('person_id'),
paper_id: rulesPaperInfo.paper_id
}
console.log(questionFinish, 'questionFinish', rulesPaperInfo)
runFinishExamination(questionFinish)
}
// console.log(rulesPaperInfo, 'rulesPaperInfo', questionList)
const numbers = [];
@ -280,6 +317,57 @@ const CardList = () => {
}
}
// 根据题型返回题数、分数、总分
const showQuestionTypeSocore = (questionType) => {
let questionName = ""
// switch (questionType) {
// case 0:
// questionName = "单选题"
// break;
// case 1:
// questionName = "多选题"
// break;
// case 2:
// questionName = "判断题"
// break;
// }
let num = 0
let score = 0
// 当前分类下试题总数
if (JSON.stringify(rulesPaperInfo) !== "{}") {
rulesPaperInfo.question_type_count.map((e, i) => {
if (e.question_type === questionType) {
num = e.count
questionName = e.type_name
}
})
console.log(rulesPaperScore, rulesPaperInfo, ' console.log(rulesPaperScore)')
rulesPaperScore.map((e, i) => {
if (e.question_type === questionType) {
score = e.score
}
})
}
// if (rulesPaperInfo.id) {
// }
return `${questionName} (共${num}题,每题${score}分)`
}
return (
<PageContainer content={content} extraContent={false}>
<Row>
@ -334,12 +422,19 @@ const CardList = () => {
)}
<div>
<div style={{ float: 'right', lineHeight: "28px" }}>
</div><div className='pdefault dt-demo' />
<div style={{ float: 'right', lineHeight: "28px" }}>
</div><div className='pok dt-demo' />
</div>
</ProCard>
</Col>
<Col span={13} style={{ background: '#ffffff', padding: 0 }}>
<ProCard
title={
questionNow.question_type === 0 ? "一、单选器" : questionNow.question_type === 1 ? "二、多选题" : questionNow.question_type === 2 ? "判断题" : ""
showQuestionTypeSocore(questionNow.question_type)
}
extra={false}
split='vertical'
@ -348,14 +443,15 @@ const CardList = () => {
>
<Space direction="vertical" style={{ width: '100%', padding: '24px 48px' }}>
<Typography style={{ marginBottom: 16, fontSize: 18 }}>
{questionNow?.question_stem}
{questionNow.id ? questionNow.index[0] + 1 : ""} {questionNow?.question_stem}
<Button onClick={() => showQuestionTypeSocore(questionNow.question_type)}>1</Button>
{/* {console.log(questionNow.answerId, 'answerId', questionNow.answerId)} */}
</Typography>
<Space direction="vertical" style={{ fontSize: 16 }}>
<Form
ref={formRef} name="control-ref"
>
<Form.Item name="note" rules={[{ required: true }]}>
<Form.Item name="note">
{questionNow.question_type === 0 ?
@ -365,15 +461,12 @@ const CardList = () => {
<Space direction="vertical">{questionNow?.answers?.map((item, index) => {
return <Radio key={item.id}
onChange={() => {
onChange={(e) => {
const qArr = []
// 默认输出答案0000
questionNow?.answers?.map(() => {
qArr.push("0")
questionNow?.answers?.map((qitem) => {
qitem.id === e.target.value ? qArr.push("1") : qArr.push("0")
})
// 修改用户答案
qArr[index] = item.is_true
const questionList = questionTypeList
const questionAnswer = qArr.join(",")
@ -429,14 +522,12 @@ const CardList = () => {
<Space direction="vertical">{questionNow?.answers?.map((item, index) => {
return <Radio key={item.id}
onChange={() => {
onChange={(e) => {
const qArr = []
// 默认输出答案0000
questionNow?.answers?.map(() => {
qArr.push("0")
questionNow?.answers?.map((qitem) => {
qitem.id === e.target.value ? qArr.push("1") : qArr.push("0")
})
// 修改用户答案
qArr[index] = item.is_true
const questionList = questionTypeList
const questionAnswer = qArr.join(",")
@ -535,27 +626,7 @@ const CardList = () => {
<Button size="large" type="primary"
onClick={() => {
console.log(questionTypeList, 'questionFinish')
const questionFinishId = []
questionTypeList.map((e, i) => {
questionTypeList[i].children.map((e, index) => {
const answerId = e.answerId
answerId !== "" ? questionFinishId.push({
answer_id: (answerId instanceof Array) ? answerId.join(',') : answerId,
question_id: e.id,
question_type: e.question_type
}) : ""
})
})
const questionFinish = {
answers: JSON.stringify(questionFinishId),
rules_id: rulesPaperInfo.rules_id,
person_id: cookie.load('person_id'),
paper_id: rulesPaperInfo.paper_id
}
console.log(questionFinish, 'questionFinish', rulesPaperInfo)
runFinishExamination(questionFinish)
handelFinishExamination()
}}
block></Button>

@ -59,8 +59,8 @@ const Result = () => {
return (
<div className="qualification" style={{ height: window.innerHeight - 300, background: '#fff', width: '100%', padding: 20 }}>
<div ><span className="title" onClick={() => { history.push('/dashboard/workplace') }}></span> / / </div>
<div className={"top"}></div>
<div ><span className="title" onClick={() => { history.push('/dashboard/workplace') }}></span> / / {params.rules_name}</div>
<div className={"top"}>{params.rules_name}</div>
<div style={{ width: '12rem', margin: '0 auto' }}>
<div className='condition' >
<div className='condition-title' ></div>
@ -72,7 +72,7 @@ const Result = () => {
</div>
<div className='condition' >
<div className='condition-title' ></div>
<span className='condition-text' >{params.score >= params.pass_score ? "是" : "否"}</span>
<span className='condition-text' >{params.score >= params.pass_score ? "通过" : "未通过"}</span>
</div>
</div>

Loading…
Cancel
Save