Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
X
xiaomai-cloud-class-web
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
xiaomai-cloud-class
xiaomai-cloud-class-web
Commits
2d9ad9a1
Commit
2d9ad9a1
authored
Jul 01, 2021
by
yuananting
Browse files
Options
Browse Files
Download
Plain Diff
fix:解决合并试卷详情接口参数新增的功能冲突
parents
845af639
4603352f
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
115 additions
and
92 deletions
+115
-92
src/modules/teach-tool/paper-manage/OperatePaper.jsx
+115
-92
No files found.
src/modules/teach-tool/paper-manage/OperatePaper.jsx
View file @
2d9ad9a1
/*
* @Author: yuananting
* @Date: 2021-03-27 16:15:13
* @LastEditors:
Please set LastEditors
* @LastEditTime: 2021-0
6-28 15:44:38
* @LastEditors:
yuananting
* @LastEditTime: 2021-0
7-01 16:44:39
* @Description: 助学工具-新建/复制/编辑试卷
* @Copyrigh: © 2020 杭州杰竞科技有限公司 版权所有
*/
...
...
@@ -21,8 +21,8 @@ import Bus from '@/core/bus';
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
BatchScore
from
"./components/BatchScore"
;
import
AddExam
from
'@/modules/teach-tool/examination-manager/AddExam'
;
import
BatchScore
from
'./components/BatchScore'
;
const
questionTypeEnum
=
{
SINGLE_CHOICE
:
'单选题'
,
...
...
@@ -60,7 +60,7 @@ class OperatePaper extends Component {
},
selectQuestionModal
:
null
,
paperPreviewModal
:
null
,
quickSortModalVisible
:
false
,
// 快捷排序弹窗显隐
quickSortModalVisible
:
false
,
// 快捷排序弹窗显隐
batchSetScoreVisible
:
false
,
//批量设置题型分数
selectQuestionList
:
[],
currentOperate
:
''
,
...
...
@@ -89,36 +89,36 @@ class OperatePaper extends Component {
],
scoreRule
:
[
{
typeKey
:
"SINGLE_CHOICE"
,
typeKey
:
'SINGLE_CHOICE'
,
score
:
2
,
portionScore
:
0
,
totalQuestion
:
0
,
},
{
typeKey
:
"MULTI_CHOICE"
,
typeKey
:
'MULTI_CHOICE'
,
score
:
2
,
portionScore
:
0
,
totalQuestion
:
0
,
},
{
typeKey
:
"JUDGE"
,
typeKey
:
'JUDGE'
,
score
:
2
,
portionScore
:
0
,
totalQuestion
:
0
,
},
{
typeKey
:
"GAP_FILLING"
,
typeKey
:
'GAP_FILLING'
,
score
:
2
,
portionScore
:
0
,
totalQuestion
:
0
,
},
{
typeKey
:
"INDEFINITE_CHOICE"
,
typeKey
:
'INDEFINITE_CHOICE'
,
score
:
2
,
portionScore
:
0
,
totalQuestion
:
0
,
},
]
]
,
};
}
...
...
@@ -129,10 +129,10 @@ class OperatePaper extends Component {
this
.
setState
({
currentOperate
:
'new'
,
currentNav
:
'新建试卷'
});
break
;
case
'edit'
:
this
.
setState
({
currentOperate
:
'edit'
,
currentNav
:
'编辑试卷'
},
()
=>
this
.
queryPaperDetail
());
this
.
setState
({
currentOperate
:
'edit'
,
currentNav
:
'编辑试卷'
},
()
=>
this
.
queryPaperDetail
(
'edit'
));
break
;
case
'copy'
:
this
.
setState
({
currentOperate
:
'copy'
,
currentNav
:
'复制试卷'
},
()
=>
this
.
queryPaperDetail
());
this
.
setState
({
currentOperate
:
'copy'
,
currentNav
:
'复制试卷'
},
()
=>
this
.
queryPaperDetail
(
'copy'
));
break
;
}
}
...
...
@@ -156,7 +156,7 @@ class OperatePaper extends Component {
};
// 编辑/复制试卷时获取相应试卷详情
queryPaperDetail
=
async
()
=>
{
queryPaperDetail
=
async
(
flag
)
=>
{
this
.
setState
({
loading
:
true
});
const
{
currentOperate
}
=
this
.
state
;
let
query
=
{
...
...
@@ -164,6 +164,7 @@ class OperatePaper extends Component {
source
:
0
,
userId
:
User
.
getStoreUserId
(),
tenantId
:
User
.
getStoreId
(),
flag
:
flag
===
'copy'
,
};
const
res
=
await
AidToolService
.
queryPaperDetail
(
query
);
const
{
result
}
=
res
;
...
...
@@ -224,29 +225,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"
:
let
_scorerule
=
_
.
map
(
this
.
state
.
scoreRule
,
(
item
)
=>
{
switch
(
item
.
typeKey
)
{
case
'SINGLE_CHOICE'
:
item
.
totalQuestion
=
singleQuestion
.
length
;
break
;
case
"MULTI_CHOICE"
:
case
'MULTI_CHOICE'
:
item
.
totalQuestion
=
multiQuestion
.
length
;
break
;
case
"JUDGE"
:
case
'JUDGE'
:
item
.
totalQuestion
=
judgeQuestion
.
length
;
break
;
case
"GAP_FILLING"
:
case
'GAP_FILLING'
:
item
.
totalQuestion
=
gapQuestion
.
length
;
break
;
case
"INDEFINITE_CHOICE"
:
case
'INDEFINITE_CHOICE'
:
item
.
totalQuestion
=
indefiniteQuestion
.
length
;
break
;
default
:
item
.
totalQuestion
=
0
item
.
totalQuestion
=
0
;
break
;
}
return
item
})
return
item
;
})
;
this
.
setState
({
formData
:
{
...
formData
,
...
...
@@ -264,7 +265,7 @@ class OperatePaper extends Component {
questionCnt
:
_selectQuestionList
.
length
,
totalScore
,
},
scoreRule
:
_scorerule
,
scoreRule
:
_scorerule
,
});
};
...
...
@@ -276,7 +277,7 @@ class OperatePaper extends Component {
getSelectedQuestion=
{
selectQuestionList
}
setSelectedQuestion=
{
(
list
)
=>
{
//按分数规则给每一题重新设置分数(只对新增题目有效)
let
_list
=
this
.
setScoreByRule
(
list
)
let
_list
=
this
.
setScoreByRule
(
list
)
;
this
.
setState
({
selectQuestionModal
:
null
},
()
=>
{
this
.
setFormData
(
_list
);
this
.
quickSorter
(
_list
,
sorterMethod
,
sorterBy
);
...
...
@@ -294,23 +295,23 @@ class OperatePaper extends Component {
setScoreByRule
=
(
list
)
=>
{
//按批量设置分数规则给每一题重新设置分数(只对新增题目有效)
return
_
.
map
(
list
,
(
item
)
=>
{
let
exist
=
_
.
find
(
this
.
state
.
selectQuestionList
,
(
q
)
=>
{
return
q
.
questionId
===
item
.
questionId
})
return
_
.
map
(
list
,
(
item
)
=>
{
let
exist
=
_
.
find
(
this
.
state
.
selectQuestionList
,
(
q
)
=>
{
return
q
.
questionId
===
item
.
questionId
;
})
;
if
(
exist
)
{
return
item
return
item
;
}
let
rule
=
_
.
find
(
this
.
state
.
scoreRule
,
(
g
)
=>
{
return
g
.
typeKey
===
item
.
questionType
})
let
rule
=
_
.
find
(
this
.
state
.
scoreRule
,
(
g
)
=>
{
return
g
.
typeKey
===
item
.
questionType
;
})
;
if
(
rule
)
{
item
.
score
=
rule
.
score
item
.
portionScore
=
rule
.
portionScore
item
.
score
=
rule
.
score
;
item
.
portionScore
=
rule
.
portionScore
;
}
return
item
})
}
return
item
;
})
;
}
;
// 移动已选题目
handleMoveItem
=
(
index
,
moveLength
)
=>
{
const
selectQuestionList
=
[...
this
.
state
.
selectQuestionList
];
...
...
@@ -584,7 +585,7 @@ class OperatePaper extends Component {
max=
{
100
}
value=
{
record
.
score
||
2
}
onChange=
{
(
value
)
=>
{
value
=
Math
.
round
(
value
)
value
=
Math
.
round
(
value
)
;
const
_selectQuestionList
=
[...
selectQuestionList
];
this
.
setState
(
{
...
...
@@ -611,7 +612,7 @@ class OperatePaper extends Component {
max=
{
record
.
score
-
1
}
value=
{
record
.
portionScore
||
0
}
onChange=
{
(
value
)
=>
{
value
=
Math
.
round
(
value
)
value
=
Math
.
round
(
value
)
;
const
_selectQuestionList
=
[...
selectQuestionList
];
this
.
setState
(
{
...
...
@@ -669,49 +670,72 @@ class OperatePaper extends Component {
//
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
})
// 各类型题目总分值
const
{
formData
,
scoreRule
}
=
this
.
state
const
{
singleChoiceCnt
,
multiChoiceCnt
,
judgeCnt
,
gapFillingCnt
,
indefiniteChoiceCnt
}
=
formData
const
singleChoiceScore
=
singleChoiceCnt
*
scoreRule
.
find
((
item
)
=>
{
return
item
.
typeKey
===
"SINGLE_CHOICE"
}).
score
const
multiChoiceScore
=
multiChoiceCnt
*
scoreRule
.
find
((
item
)
=>
{
return
item
.
typeKey
===
"MULTI_CHOICE"
}).
score
const
judgeScore
=
judgeCnt
*
scoreRule
.
find
((
item
)
=>
{
return
item
.
typeKey
===
"JUDGE"
}).
score
const
gapFillingScore
=
gapFillingCnt
*
scoreRule
.
find
((
item
)
=>
{
return
item
.
typeKey
===
"GAP_FILLING"
}).
score
const
indefiniteChoiceScore
=
indefiniteChoiceCnt
*
scoreRule
.
find
((
item
)
=>
{
return
item
.
typeKey
===
"INDEFINITE_CHOICE"
}).
score
const
totalScore
=
questionList
.
reduce
((
prev
,
cur
)
=>
{
return
prev
+
Number
(
cur
.
score
)
||
0
;
},
0
);
const
passScore
=
Math
.
round
(
totalScore
*
formData
.
passRate
*
0.01
);
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
;
});
// 各类型题目总分值
const
{
formData
,
scoreRule
}
=
this
.
state
;
const
{
singleChoiceCnt
,
multiChoiceCnt
,
judgeCnt
,
gapFillingCnt
,
indefiniteChoiceCnt
}
=
formData
;
const
singleChoiceScore
=
singleChoiceCnt
*
scoreRule
.
find
((
item
)
=>
{
return
item
.
typeKey
===
'SINGLE_CHOICE'
;
}).
score
;
const
multiChoiceScore
=
multiChoiceCnt
*
scoreRule
.
find
((
item
)
=>
{
return
item
.
typeKey
===
'MULTI_CHOICE'
;
}).
score
;
const
judgeScore
=
judgeCnt
*
scoreRule
.
find
((
item
)
=>
{
return
item
.
typeKey
===
'JUDGE'
;
}).
score
;
const
gapFillingScore
=
gapFillingCnt
*
scoreRule
.
find
((
item
)
=>
{
return
item
.
typeKey
===
'GAP_FILLING'
;
}).
score
;
const
indefiniteChoiceScore
=
indefiniteChoiceCnt
*
scoreRule
.
find
((
item
)
=>
{
return
item
.
typeKey
===
'INDEFINITE_CHOICE'
;
}).
score
;
const
totalScore
=
questionList
.
reduce
((
prev
,
cur
)
=>
{
return
prev
+
Number
(
cur
.
score
)
||
0
;
},
0
);
this
.
setState
({
selectQuestionList
:
questionList
,
formData
:
{
...
formData
,
singleChoiceScore
,
multiChoiceScore
,
judgeScore
,
gapFillingScore
,
indefiniteChoiceScore
,
totalScore
,
passScore
,
}
})
})
}
const
passScore
=
Math
.
round
(
totalScore
*
formData
.
passRate
*
0.01
);
this
.
setState
({
selectQuestionList
:
questionList
,
formData
:
{
...
formData
,
singleChoiceScore
,
multiChoiceScore
,
judgeScore
,
gapFillingScore
,
indefiniteChoiceScore
,
totalScore
,
passScore
,
},
});
}
);
};
// 上下移题型
handleMoveTypeSorter
=
(
index
,
moveLength
)
=>
{
const
sorterTypeList
=
[...
this
.
state
.
sorterTypeList
];
...
...
@@ -849,7 +873,7 @@ class OperatePaper extends Component {
max=
{
100
}
value=
{
passRate
}
onChange=
{
(
value
)
=>
{
value
=
Math
.
round
(
value
)
value
=
Math
.
round
(
value
)
;
this
.
setState
(
{
formData
:
{
...
...
@@ -884,13 +908,12 @@ class OperatePaper extends Component {
快捷排序
</
Button
>
<
Button
className=
"choose-btn"
className=
'choose-btn'
onClick=
{
()
=>
{
this
.
setState
({
batchSetScoreVisible
:
true
,
});
}
}
>
}
}
>
批量设置分数
</
Button
>
</
Space
>
...
...
@@ -969,11 +992,11 @@ class OperatePaper extends Component {
)
}
</
Modal
>
{
/* 批量设置分数规则 */
}
<
BatchScore
visible=
{
this
.
state
.
batchSetScoreVisible
}
onOK=
{
this
.
onBatchScoreOK
}
onCancel=
{
()
=>
this
.
setState
({
batchSetScoreVisible
:
false
})
}
rules=
{
this
.
state
.
scoreRule
}
<
BatchScore
visible=
{
this
.
state
.
batchSetScoreVisible
}
onOK=
{
this
.
onBatchScoreOK
}
onCancel=
{
()
=>
this
.
setState
({
batchSetScoreVisible
:
false
})
}
rules=
{
this
.
state
.
scoreRule
}
/>
</
div
>
<
Route
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment