Commit 6a970535 by maolipeng
parent 57a0bc6a
......@@ -36,7 +36,7 @@ import _ from "underscore";
import { Route, withRouter } from "react-router-dom";
import * as paperEmpty from '../../lottie/paperEmpty/data.json';
import AddExam from "@/modules/teach-tool/examination-manager/AddExam";
import BatchGrade from "./components/BatchGrade";
import BatchScore from "./components/BatchScore";
const questionTypeEnum = {
SINGLE_CHOICE: "单选题",
......@@ -75,7 +75,7 @@ class OperatePaper extends Component {
selectQuestionModal: null,
paperPreviewModal: null,
quickSortModalVisible: false, // 快捷排序弹窗显隐
batchSetGradeVisible: false, //批量设置题型分数
batchSetScoreVisible: false, //批量设置题型分数
selectQuestionList: [],
currentOperate: "",
currentNav: "",
......@@ -107,35 +107,35 @@ class OperatePaper extends Component {
typeKey: "INDEFINITE_CHOICE",
},
],
gradeRule: [
scoreRule: [
{
typeKey: "SINGLE_CHOICE",
grade: 2,
halfGrade: 1,
score: 2,
portionScore: 1,
totalQuestion: 0,
},
{
typeKey: "MULTI_CHOICE",
grade: 2,
halfGrade: 1,
score: 2,
portionScore: 1,
totalQuestion: 0,
},
{
typeKey: "JUDGE",
grade: 2,
halfGrade: 1,
score: 2,
portionScore: 1,
totalQuestion: 0,
},
{
typeKey: "GAP_FILLING",
grade: 2,
halfGrade: 1,
score: 2,
portionScore: 1,
totalQuestion: 0,
},
{
typeKey: "INDEFINITE_CHOICE",
grade: 2,
halfGrade: 1,
score: 2,
portionScore: 1,
totalQuestion: 0,
},
]
......@@ -264,6 +264,29 @@ class OperatePaper extends Component {
}, 0);
const passScore = Math.round(totalScore * formData.passRate * 0.01);
let _scorerule = _.map(this.state.scoreRule,(item)=> {
switch(item.typeKey) {
case "SINGLE_CHOICE":
item.totalQuestion = singleQuestion.length;
break;
case "MULTI_CHOICE":
item.totalQuestion = multiQuestion.length;
break;
case "JUDGE":
item.totalQuestion = judgeQuestion.length;
break;
case "GAP_FILLING":
item.totalQuestion = gapQuestion.length;
break;
case "INDEFINITE_CHOICE":
item.totalQuestion = indefiniteQuestion.length;
break;
default:
item.totalQuestion = 0
break;
}
return item
})
this.setState({
formData: {
...formData,
......@@ -281,6 +304,7 @@ class OperatePaper extends Component {
questionCnt: _selectQuestionList.length,
totalScore,
},
scoreRule:_scorerule,
});
};
......@@ -291,9 +315,11 @@ class OperatePaper extends Component {
<SelectQuestionModal
getSelectedQuestion={selectQuestionList}
setSelectedQuestion={(list) => {
//按分数规则给每一题重新设置分数(只对新增题目有效)
let _list = this.setScoreByRule(list)
this.setState({ selectQuestionModal: null }, () => {
this.setFormData(list);
this.quickSorter(list, sorterMethod, sorterBy);
this.setFormData(_list);
this.quickSorter(_list, sorterMethod, sorterBy);
});
}}
close={() => {
......@@ -306,6 +332,25 @@ class OperatePaper extends Component {
this.setState({ selectQuestionModal: m });
};
setScoreByRule = (list) => {
//按批量设置分数规则给每一题重新设置分数(只对新增题目有效)
return _.map(list, (item)=> {
let exist = _.find(this.state.selectQuestionList, (q)=> {
return q.questionId === item.questionId
})
if (exist) {
return item
}
let rule = _.find(this.state.scoreRule,(g)=> {
return g.typeKey === item.questionType
})
if (rule) {
item.score = rule.score
item.portionScore = rule.portionScore
}
return item
})
}
// 移动已选题目
handleMoveItem = (index, moveLength) => {
const selectQuestionList = [...this.state.selectQuestionList];
......@@ -715,6 +760,25 @@ class OperatePaper extends Component {
return columns;
};
//
onBatchScoreOK = (rules) => {
this.setState({
batchSetScoreVisible:false,
scoreRule:rules
},()=> {
let questionList = _.map(this.state.selectQuestionList,(item)=> {
let rule = _.find(this.state.scoreRule,(s)=> {
return s.typeKey === item.questionType
})
if (rule) {
item.score = rule.score
item.portionScore = rule.portionScore
}
return item
})
this.setState({selectQuestionList:questionList})
})
}
// 上下移题型
handleMoveTypeSorter = (index, moveLength) => {
const sorterTypeList = [...this.state.sorterTypeList];
......@@ -909,7 +973,7 @@ class OperatePaper extends Component {
className="choose-btn"
onClick={() => {
this.setState({
batchSetGradeVisible: true,
batchSetScoreVisible: true,
});
}}
>
......@@ -1004,9 +1068,13 @@ class OperatePaper extends Component {
/>
)}
</Modal>
<BatchGrade
visible={this.state.batchSetGradeVisible}
onClose={()=> this.setState({batchSetGradeVisible:false})}/>
{/* 批量设置分数规则 */}
<BatchScore
visible={this.state.batchSetScoreVisible}
onOK={this.onBatchScoreOK}
onCancel={()=> this.setState({batchSetScoreVisible:false})}
rules={this.state.scoreRule}
/>
</div>
<Route
path={`${match.url}/exam-operate-page`}
......
import React, { useState} from "react";
import { Modal, Button, InputNumber } from 'antd';
import "./BatchGrade.less"
interface BatchGradeProps {
visible:boolean,
onClose: () => void,
}
export default function BatchGrade(props:BatchGradeProps) {
if (!props.visible) {
return ("")
}
function onOk() {
}
function onCancel() {
props.onClose()
}
const inputNumberStyle = {width:"57px",margin:"0 8px"}
return (
<Modal
className="batchgrade"
title="批量设置分数"
onCancel={onCancel}
onOk={onOk}
visible={props.visible}
maskClosable={false}
width={660}
>
<div className="content">
<div className="item">
<span className="type">【单选题】</span>
<span className="grade">每题<InputNumber defaultValue={2} style={inputNumberStyle} /></span>
</div>
<div className="item">
<span className="type">【多选题】</span>
<span className="grade">每题<InputNumber style={inputNumberStyle} />分,漏选得<InputNumber defaultValue={1} style={inputNumberStyle} /></span>
</div>
<div className="item">
<span className="type">【不定项选择题】</span>
<span className="grade">每题<InputNumber style={inputNumberStyle} />分,漏选得<InputNumber defaultValue={1} style={inputNumberStyle} /></span>
</div>
<div className="item">
<span className="type">【判断题】</span>
<span className="grade">每题<InputNumber style={inputNumberStyle} /></span>
</div>
<div className="item">
<span className="type">【填空题】</span>
<span className="grade">每题<InputNumber style={inputNumberStyle} />分,半对得<InputNumber defaultValue={1} style={inputNumberStyle} /></span>
</div>
</div>
</Modal>
)
}
\ No newline at end of file
.batchgrade {
.batchscore {
.content {
.item {
display: flex;
......@@ -13,9 +13,10 @@
.type {
width: 112px;
}
.grade {
.score {
margin-left: 8px;
margin-right: 29px;
width: 258px;
}
}
.item:not(:last-of-type) {
......
import React, { useEffect, useState} from "react";
import { Modal, Button, InputNumber } from 'antd';
import "./BatchScore.less"
import _ from "underscore";
interface Rule {
typeKey: "SINGLE_CHOICE"|"MULTI_CHOICE"| "JUDGE"|"GAP_FILLING"|"INDEFINITE_CHOICE",
score: number,
portionScore: number,
totalQuestion: number,
}
interface BatchScoreProps {
visible:boolean,
rules: Rule[],
onOK: (rules:Rule[]) => void,
onCancel: () => void,
}
export default function BatchScore(props:BatchScoreProps) {
const [rules, setRules] = useState<Rule[]>(props.rules)
const [singleCount, setSingleCount] = useState<number[]>([0])
const [multiCount, setMultiCount] = useState<number[]>([0])
const [judgeCount, setJudgeCount] = useState<number[]>([0])
const [gapCount, setgapCount] = useState<number[]>([0])
const [indefiniteCount, setIndefiniteCount] = useState<number[]>([0])
useEffect(()=> {
_.map(props.rules,(item)=> {
switch(item.typeKey) {
case "SINGLE_CHOICE":
setSingleCount([item.totalQuestion,item.totalQuestion*item.score])
break;
case "MULTI_CHOICE":
setMultiCount([item.totalQuestion,item.totalQuestion*item.score])
break;
case "JUDGE":
setJudgeCount([item.totalQuestion,item.totalQuestion*item.score])
break;
case "GAP_FILLING":
setgapCount([item.totalQuestion,item.totalQuestion*item.score])
break;
case "INDEFINITE_CHOICE":
setIndefiniteCount([item.totalQuestion,item.totalQuestion*item.score])
break;
default:
break;
}
})
console.log("KKKKKKKKKKKKKKK")
},[rules])
if (!props.visible) {
return ("")
}
function onOk() {
props.onOK(rules)
}
function onCancel() {
props.onCancel()
}
const inputNumberStyle = {width:"57px",margin:"0 8px"}
return (
<Modal
className="batchscore"
title="批量设置分数"
onCancel={onCancel}
onOk={onOk}
visible={props.visible}
maskClosable={false}
width={660}
>
<div className="content">
<div className="item">
<span className="type">【单选题】</span>
<span className="score">每题
<InputNumber
min={1}
defaultValue={_.find(rules,(it)=>{return it.typeKey === "SINGLE_CHOICE"})?.score}
style={inputNumberStyle}
onChange={(v)=> {
setRules(_.map(rules,(item)=>{
if (item.typeKey === "SINGLE_CHOICE") {
item.score = Number(v)
}
return item
}))
}}
/>
</span>
<span className="total"><span style={{color:"#2966FF"}}>{singleCount[0]}</span>题,合计<span style={{color:"#2966FF"}}>{singleCount[1]}</span></span>
</div>
<div className="item">
<span className="type">【多选题】</span>
<span className="score">每题
<InputNumber
min={1}
defaultValue={_.find(rules,(it)=>{return it.typeKey === "MULTI_CHOICE"})?.score}
style={inputNumberStyle}
onChange={(v)=> {
setRules(_.map(rules,(item)=>{
if (item.typeKey === "MULTI_CHOICE") {
item.score = Number(v)
}
return item
}))
}}
/>
分,漏选得
<InputNumber
min={0}
defaultValue={1}
style={inputNumberStyle}
onChange={(v)=> {
setRules(_.map(rules,(item)=>{
if (item.typeKey === "MULTI_CHOICE") {
item.portionScore = Number(v)
}
return item
}))
}}
/>
</span>
<span className="total"><span style={{color:"#2966FF"}}>{multiCount[0]}</span>题,合计<span style={{color:"#2966FF"}}>{multiCount[1]}</span></span>
</div>
<div className="item">
<span className="type">【不定项选择题】</span>
<span className="score">每题
<InputNumber
min={1}
defaultValue={_.find(rules,(it)=>{return it.typeKey === "INDEFINITE_CHOICE"})?.score}
style={inputNumberStyle}
onChange={(v)=> {
setRules(_.map(rules,(item)=>{
if (item.typeKey === "INDEFINITE_CHOICE") {
item.score = Number(v)
}
return item
}))
}}
/>
分,漏选得
<InputNumber
min={0}
defaultValue={1}
style={inputNumberStyle}
onChange={(v)=> {
setRules(_.map(rules,(item)=>{
if (item.typeKey === "INDEFINITE_CHOICE") {
item.portionScore = Number(v)
}
return item
}))
}}
/></span>
<span className="total"><span style={{color:"#2966FF"}}>{judgeCount[0]}</span>题,合计<span style={{color:"#2966FF"}}>{judgeCount[1]}</span></span>
</div>
<div className="item">
<span className="type">【判断题】</span>
<span className="score">每题
<InputNumber
min={1}
defaultValue={_.find(rules,(it)=>{return it.typeKey === "JUDGE"})?.score}
style={inputNumberStyle}
onChange={(v)=> {
setRules(_.map(rules,(item)=>{
if (item.typeKey === "JUDGE") {
item.score = Number(v)
}
return item
}))
}}
/>
</span>
<span className="total"><span style={{color:"#2966FF"}}>{indefiniteCount[0]}</span>题,合计<span style={{color:"#2966FF"}}>{indefiniteCount[1]}</span></span>
</div>
<div className="item">
<span className="type">【填空题】</span>
<span className="score">每题
<InputNumber
min={1}
defaultValue={_.find(rules,(it)=>{return it.typeKey === "GAP_FILLING"})?.score}
style={inputNumberStyle}
onChange={(v)=> {
setRules(_.map(rules,(item)=>{
if (item.typeKey === "GAP_FILLING") {
item.score = Number(v)
}
return item
}))
}}
/>
分,半对得<InputNumber
min={0}
defaultValue={1}
style={inputNumberStyle}
onChange={(v)=> {
setRules(_.map(rules,(item)=>{
if (item.typeKey === "GAP_FILLING") {
item.portionScore = Number(v)
}
return item
}))
}}
/>
</span>
<span className="total"><span style={{color:"#2966FF"}}>{gapCount[0]}</span>题,合计<span style={{color:"#2966FF"}}>{gapCount[1]}</span></span>
</div>
</div>
</Modal>
)
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment