|
|
|
@ -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<number>(0); // 关联主题id
|
|
|
|
|
const [subjectName, setSubjectName] = useState(''); // 关联主题name
|
|
|
|
|
|
|
|
|
|
const [questionTypeValues, setQuestionTypeValues] = useState([]); // 题型数据[{count:0, score:0, score_harf:0}]
|
|
|
|
|
|
|
|
|
|
const [uuidPaper, setUuidPaper] = useState<number>(0);
|
|
|
|
|
const [createType, setCreateType] = useState<number>(1); // 组卷类型
|
|
|
|
|
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>();
|
|
|
|
|
|
|
|
|
@ -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="单位(分钟)" />
|
|
|
|
|
</>
|
|
|
|
|
)}
|
|
|
|
|
</Col>
|
|
|
|
@ -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 () => {
|
|
|
|
|
|
|
|
|
|
</Space>
|
|
|
|
|
</ProCard>
|
|
|
|
|
|
|
|
|
|
</Col>
|
|
|
|
|
<Col span={6} style={{ paddingLeft: 24 }}>
|
|
|
|
|
<div style={{ background: '#ffffff', padding: 24 }}>
|
|
|
|
@ -359,7 +398,7 @@ export default () => {
|
|
|
|
|
<Divider style={{ margin: '6px 0', opacity: 0.5 }} />
|
|
|
|
|
<Space direction="vertical">
|
|
|
|
|
{ questionType.map((item)=>{
|
|
|
|
|
return <Typography>{item?.name} 共 { '-' } 题 { '-' } 分</Typography>
|
|
|
|
|
return <Typography>{item?.name} 共 { typeQuestionCount[Number(item.code)] } 题 { '-' } 分</Typography>
|
|
|
|
|
}
|
|
|
|
|
)}
|
|
|
|
|
</Space>
|
|
|
|
@ -378,6 +417,17 @@ export default () => {
|
|
|
|
|
}}>选择试题</Button>
|
|
|
|
|
|
|
|
|
|
<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})
|
|
|
|
|
})
|
|
|
|
|
setQuestionTypeValues(_data)
|
|
|
|
|
console.log('typeQuestionCount', typeQuestionCount);
|
|
|
|
|
handleScoreModalVisible(true)
|
|
|
|
|
}}>批量设置分值</Button>
|
|
|
|
|
<Button size="large" type="primary" block onClick={async ()=>{
|
|
|
|
@ -428,15 +478,13 @@ export default () => {
|
|
|
|
|
<ProDescriptions.Item dataIndex="examination_time" label="考试时长" valueType="text" renderText={(text)=>(`${text} 分钟`)} />
|
|
|
|
|
|
|
|
|
|
<ProDescriptions.Item dataIndex="grade" label="试卷信息" valueType="text" render={()=>{
|
|
|
|
|
{/** 需要从试卷 或 临时试卷 中读取 需要处理 */}
|
|
|
|
|
return <Space direction="vertical">
|
|
|
|
|
<span>共 0 道题, 100 分</span>
|
|
|
|
|
<span>共 0 道题, {paperInfo?.sum_score} 分</span>
|
|
|
|
|
<span>单选: 0 道题 单选: 0 道题 单选: 0 道题</span>
|
|
|
|
|
<span>通过线 60 分</span>
|
|
|
|
|
</Space>
|
|
|
|
|
|
|
|
|
|
<span>通过线 {paperInfo?.pass_score} 分</span>
|
|
|
|
|
</Space>
|
|
|
|
|
}} />
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</ProDescriptions>
|
|
|
|
|
}
|
|
|
|
|
</Col>
|
|
|
|
@ -447,11 +495,9 @@ export default () => {
|
|
|
|
|
|
|
|
|
|
<ModalForm
|
|
|
|
|
title={`手动组卷`}
|
|
|
|
|
//
|
|
|
|
|
width="60%"
|
|
|
|
|
visible={selectorModalVisible}
|
|
|
|
|
onVisibleChange={handleSelectorModalVisible}
|
|
|
|
|
footer={null}
|
|
|
|
|
onFinish={async (values) => {
|
|
|
|
|
console.log('v::::', values.name);
|
|
|
|
|
const rows = selectorRef?.current?.getSelectedRows()
|
|
|
|
@ -466,8 +512,7 @@ export default () => {
|
|
|
|
|
page_number: 1
|
|
|
|
|
}); // 获取当前选题列表
|
|
|
|
|
// message.success('提交成功');
|
|
|
|
|
handleSelectorModalVisible(false)
|
|
|
|
|
|
|
|
|
|
handleSelectorModalVisible(false)
|
|
|
|
|
return true;
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
@ -479,11 +524,13 @@ export default () => {
|
|
|
|
|
width="60%"
|
|
|
|
|
visible={autoModalVisible}
|
|
|
|
|
onVisibleChange={ handleAutoModalVisible }
|
|
|
|
|
footer={null}
|
|
|
|
|
onFinish={async () => {
|
|
|
|
|
const values = autoRef?.current?.getData()
|
|
|
|
|
const {code, data: paper, msg} = await autoPaper({rules_id: Number(params?.id), auto_param: JSON.stringify(values)})
|
|
|
|
|
console.log('paper', paper)
|
|
|
|
|
onFinish={async () => {
|
|
|
|
|
// 需要处理
|
|
|
|
|
//console.log('111')
|
|
|
|
|
//const values = autoRef?.current?.getData()
|
|
|
|
|
//console.log('2222')
|
|
|
|
|
//const {code, data: paper, msg} = await autoPaper({rules_id: Number(params?.id), auto_param: JSON.stringify(values)})
|
|
|
|
|
//console.log('paper', paper)
|
|
|
|
|
//setUuidPaper(paper?.paper_uuid)
|
|
|
|
|
// message.success('提交成功');
|
|
|
|
|
handleAutoModalVisible(false)
|
|
|
|
@ -498,12 +545,26 @@ export default () => {
|
|
|
|
|
width="60%"
|
|
|
|
|
visible={scoreModalVisible}
|
|
|
|
|
onVisibleChange={handleScoreModalVisible}
|
|
|
|
|
footer={null}
|
|
|
|
|
onFinish={async () => {
|
|
|
|
|
const values = setterRef.current?.getData()
|
|
|
|
|
console.log('批量设置分值v::::', values);
|
|
|
|
|
onFinish={async () => {
|
|
|
|
|
console.log('typeQuestionCount', typeQuestionCount)
|
|
|
|
|
const values = setterRef.current?.getData() // 获取题型分值数据
|
|
|
|
|
const passSocre = setterRef.current?.getValue() // 获取通过分数线
|
|
|
|
|
|
|
|
|
|
console.log('批量设置分值v::::2', 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)
|
|
|
|
|
_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})
|
|
|
|
|
setSumScore(_sumScore)
|
|
|
|
|
console.log('paper', paper)
|
|
|
|
|
// setUuidPaper(paper?.paper_uuid)
|
|
|
|
|
// message.success('提交成功');
|
|
|
|
@ -511,7 +572,7 @@ export default () => {
|
|
|
|
|
return true;
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
<ScoreSetter ref={setterRef} />
|
|
|
|
|
<ScoreSetter ref={setterRef} questionTypeValues={questionTypeValues || false} />
|
|
|
|
|
</ModalForm>
|
|
|
|
|
</PageContainer>
|
|
|
|
|
|
|
|
|
|