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
de92f985
Commit
de92f985
authored
Apr 02, 2021
by
yuananting
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat:编辑预览接口联调
parent
8bde2114
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
183 additions
and
110 deletions
+183
-110
src/data-source/aidTool/request-apis.ts
+6
-1
src/domains/aid-tool-domain/AidToolService.ts
+26
-2
src/modules/teach-tool/examination-paper/NewExaminationPaper.jsx
+134
-99
src/modules/teach-tool/examination-paper/modal/PaperPreviewModal.jsx
+2
-4
src/modules/teach-tool/examination-paper/modal/SelectQuestionModal.jsx
+15
-4
No files found.
src/data-source/aidTool/request-apis.ts
View file @
de92f985
...
...
@@ -2,7 +2,7 @@
* @Author: yuananting
* @Date: 2021-03-03 15:13:12
* @LastEditors: yuananting
* @LastEditTime: 2021-04-0
1 15:36:48
* @LastEditTime: 2021-04-0
2 14:12:49
* @Description: 助学工具接口
* @Copyrigh: © 2020 杭州杰竞科技有限公司 版权所有
*/
...
...
@@ -71,4 +71,8 @@ export function queryPaperDetail(params: object) {
export
function
viewPaper
(
params
:
object
)
{
return
Service
.
Hades
(
"public/hades/viewPaper"
,
params
);
}
export
function
editPaper
(
params
:
object
)
{
return
Service
.
Hades
(
"public/hades/editPaper"
,
params
);
}
\ No newline at end of file
src/domains/aid-tool-domain/AidToolService.ts
View file @
de92f985
...
...
@@ -2,11 +2,29 @@
* @Author: yuananting
* @Date: 2021-03-11 11:34:37
* @LastEditors: yuananting
* @LastEditTime: 2021-04-0
1 20:09:12
* @LastEditTime: 2021-04-0
2 14:14:06
* @Description: 助学工具接口
* @Copyrigh: © 2020 杭州杰竞科技有限公司 版权所有
*/
import
{
queryCategoryTree
,
addCategory
,
delCategory
,
editCategory
,
editCategoryTree
,
addQuestion
,
queryQuestionPageList
,
deleteQuestion
,
queryQuestionDetails
,
editQuestion
,
batchImport
,
createPaper
,
queryPaperPageList
,
deletePaper
,
queryPaperDetail
,
viewPaper
}
from
'@/data-source/aidTool/request-apis'
;
import
{
queryCategoryTree
,
addCategory
,
delCategory
,
editCategory
,
editCategoryTree
,
addQuestion
,
queryQuestionPageList
,
deleteQuestion
,
queryQuestionDetails
,
editQuestion
,
batchImport
,
createPaper
,
queryPaperPageList
,
deletePaper
,
queryPaperDetail
,
viewPaper
,
editPaper
}
from
'@/data-source/aidTool/request-apis'
;
export
default
class
AidToolService
{
// 获取题目分类树
static
queryCategoryTree
(
params
:
any
)
{
...
...
@@ -87,4 +105,9 @@ export default class AidToolService {
static
viewPaper
(
params
:
any
)
{
return
viewPaper
(
params
);
}
// 编辑试卷
static
editPaper
(
params
:
any
)
{
return
editPaper
(
params
);
}
}
\ No newline at end of file
src/modules/teach-tool/examination-paper/NewExaminationPaper.jsx
View file @
de92f985
...
...
@@ -2,7 +2,7 @@
* @Author: yuananting
* @Date: 2021-03-27 16:15:13
* @LastEditors: yuananting
* @LastEditTime: 2021-04-02 1
0:51:10
* @LastEditTime: 2021-04-02 1
7:23:23
* @Description: 助学工具-新建试卷
* @Copyrigh: © 2020 杭州杰竞科技有限公司 版权所有
*/
...
...
@@ -45,6 +45,11 @@ class NewExaminationPaper extends Component {
judgeCnt
:
0
,
// 判断题数量
gapFillingCnt
:
0
,
// 填空题数量
indefiniteChoiceCnt
:
0
,
// 不定项选择题数量
singleChoiceScore
:
0
,
// 单选题目总分
multiChoiceScore
:
0
,
// 多选题目总分
judgeScore
:
0
,
// 判断题目总分
gapFillingScore
:
0
,
// 填空题目总分
indefiniteChoiceScore
:
0
,
//不定项选择总分
paperName
:
null
,
// 试卷名称
passRate
:
60
,
// 及格线
passScore
:
0
,
// 及格分
...
...
@@ -65,6 +70,8 @@ class NewExaminationPaper extends Component {
// 编辑
this
.
setState
({
currentOperate
:
"edit"
});
this
.
queryPaperDetail
();
}
else
{
this
.
setState
({
currentOperate
:
"new"
});
}
}
...
...
@@ -72,22 +79,30 @@ class NewExaminationPaper extends Component {
queryPaperDetail
=
()
=>
{
let
query
=
{
categoryId
:
getParameterByName
(
"categoryId"
),
paperId
:
getParameterByName
(
"paperId"
),
paperId
:
getParameterByName
(
"paperId"
),
source
:
0
,
userId
:
User
.
getStoreUserId
(),
tenantId
:
User
.
getStoreId
(),
};
AidToolService
.
queryPaperDetail
(
query
).
then
((
res
)
=>
{
const
{
result
}
=
res
;
this
.
setState
({
selectQuestionList
:
result
.
questionList
,
formData
:
result
,
},()
=>
{
this
.
setFormData
([])
})
const
{
paperName
,
passRate
}
=
result
;
this
.
setState
(
{
selectQuestionList
:
result
.
questionList
,
formData
:
result
},
()
=>
{
this
.
formRef
.
current
.
setFieldsValue
({
paperName
,
passRate
,
});
this
.
setFormData
([]);
}
);
});
};
// 校验试卷名称是否重名
checkExistPaperName
=
(
paperName
)
=>
{};
// 自定义表格空状态
customizeRenderEmpty
=
()
=>
{
return
(
...
...
@@ -103,35 +118,66 @@ class NewExaminationPaper extends Component {
setFormData
=
(
list
)
=>
{
const
{
formData
,
selectQuestionList
}
=
this
.
state
;
const
_selectQuestionList
=
[...
selectQuestionList
,
...
list
];
const
_selectQuestionList
=
[...
new
Set
([...
selectQuestionList
,
...
list
])];
console
.
log
(
_selectQuestionList
)
// 各类型题目汇总
const
singleQuestion
=
_
.
filter
(
_selectQuestionList
,
(
item
)
=>
item
.
questionType
===
"SINGLE_CHOICE"
);
const
multiQuestion
=
_
.
filter
(
_selectQuestionList
,
(
item
)
=>
item
.
questionType
===
"MULTI_CHOICE"
);
const
judgeQuestion
=
_
.
filter
(
_selectQuestionList
,
(
item
)
=>
item
.
questionType
===
"JUDGE"
);
const
gapQuestion
=
_
.
filter
(
_selectQuestionList
,
(
item
)
=>
item
.
questionType
===
"GAP_FILLING"
);
const
indefiniteQuestion
=
_
.
filter
(
_selectQuestionList
,
(
item
)
=>
item
.
questionType
===
"INDEFINITE_CHOICE"
);
// 各类型题目总分值
const
singleChoiceScore
=
singleQuestion
.
reduce
((
prev
,
cur
)
=>
{
return
prev
+
Number
(
cur
.
score
)
||
0
;
},
0
);
const
multiChoiceScore
=
multiQuestion
.
reduce
((
prev
,
cur
)
=>
{
return
prev
+
Number
(
cur
.
score
)
||
0
;
},
0
);
const
judgeScore
=
judgeQuestion
.
reduce
((
prev
,
cur
)
=>
{
return
prev
+
Number
(
cur
.
score
)
||
0
;
},
0
);
const
gapFillingScore
=
gapQuestion
.
reduce
((
prev
,
cur
)
=>
{
return
prev
+
Number
(
cur
.
score
)
||
0
;
},
0
);
const
indefiniteChoiceScore
=
indefiniteQuestion
.
reduce
((
prev
,
cur
)
=>
{
return
prev
+
Number
(
cur
.
score
)
||
0
;
},
0
);
const
totalScore
=
_selectQuestionList
.
reduce
((
prev
,
cur
)
=>
{
return
prev
+
Number
(
cur
.
score
)
||
0
;
},
0
);
const
passScore
=
Math
.
round
(
totalScore
*
formData
.
passRate
*
0.01
);
this
.
setState
({
selectQuestionList
:
_selectQuestionList
,
formData
:
{
...
formData
,
singleChoiceCnt
:
_
.
filter
(
_selectQuestionList
,
(
item
)
=>
item
.
questionType
===
"SINGLE_CHOICE"
).
length
,
multiChoiceCnt
:
_
.
filter
(
_selectQuestionList
,
(
item
)
=>
item
.
questionType
===
"MULTI_CHOICE"
).
length
,
judgeCnt
:
_
.
filter
(
_selectQuestionList
,
(
item
)
=>
item
.
questionType
===
"JUDGE"
).
length
,
gapFillingCnt
:
_
.
filter
(
_selectQuestionList
,
(
item
)
=>
item
.
questionType
===
"GAP_FILLING"
).
length
,
indefiniteChoiceCnt
:
_
.
filter
(
_selectQuestionList
,
(
item
)
=>
item
.
questionType
===
"INDEFINITE_CHOICE"
).
length
,
singleChoiceCnt
:
singleQuestion
.
length
,
multiChoiceCnt
:
multiQuestion
.
length
,
judgeCnt
:
judgeQuestion
.
length
,
gapFillingCnt
:
gapQuestion
.
length
,
indefiniteChoiceCnt
:
indefiniteQuestion
.
length
,
singleChoiceScore
,
multiChoiceScore
,
judgeScore
,
gapFillingScore
,
indefiniteChoiceScore
,
passScore
,
questionCnt
:
_selectQuestionList
.
length
,
totalScore
,
...
...
@@ -143,6 +189,7 @@ class NewExaminationPaper extends Component {
chooseQuestion
=
()
=>
{
const
m
=
(
<
SelectQuestionModal
getSelectedQuestion=
{
this
.
state
.
selectQuestionList
}
setSelectedQuestion=
{
(
list
)
=>
{
this
.
setFormData
(
list
);
this
.
setState
({
selectQuestionModal
:
null
});
...
...
@@ -162,16 +209,18 @@ class NewExaminationPaper extends Component {
const
{
selectQuestionList
}
=
this
.
state
;
const
item
=
selectQuestionList
.
splice
(
index
+
moveLength
,
1
);
selectQuestionList
.
splice
(
index
,
0
,
item
[
0
]);
this
.
setState
({
selectQuestionList
});
this
.
setState
({
selectQuestionList
},
()
=>
this
.
setFormData
([])
);
};
// 移除已选题目
handleDelItem
=
(
delId
)
=>
{
handleDelItem
=
(
del
Question
Id
)
=>
{
const
{
selectQuestionList
}
=
this
.
state
;
this
.
setState
(
{
selectQuestionList
:
[...
selectQuestionList
].
filter
(
(
item
)
=>
item
.
id
!==
del
Id
(
item
)
=>
item
.
questionId
!==
delQuestion
Id
),
},
()
=>
this
.
setFormData
([])
...
...
@@ -182,13 +231,13 @@ class NewExaminationPaper extends Component {
saveExaminationPaper
=
async
()
=>
{
try
{
await
this
.
formRef
.
current
.
validateFields
();
const
{
selectQuestionList
,
formData
}
=
this
.
state
;
const
{
selectQuestionList
,
formData
,
currentOperate
}
=
this
.
state
;
let
questionList
=
[];
selectQuestionList
.
forEach
((
item
,
index
)
=>
{
questionList
.
push
({
categoryId
:
item
.
categoryId
,
portionScore
:
item
.
portionScore
||
0
,
questionId
:
item
.
i
d
,
questionId
:
item
.
questionI
d
,
questionType
:
item
.
questionType
,
score
:
item
.
score
||
2
,
sort
:
index
,
...
...
@@ -202,14 +251,32 @@ class NewExaminationPaper extends Component {
},
},
()
=>
{
AidToolService
.
createPaper
(
this
.
state
.
formData
).
then
((
res
)
=>
{
if
(
res
.
success
){
message
.
success
(
"新建成功"
);
window
.
RCHistory
.
push
({
pathname
:
`/examination-paper-index?categoryId=
${
getParameterByName
(
"categoryId"
)}
`
,
});
}
});
if
(
currentOperate
===
"edit"
)
{
AidToolService
.
editPaper
({
...
this
.
state
.
formData
,
paperId
:
getParameterByName
(
"paperId"
),
}).
then
((
res
)
=>
{
if
(
res
.
success
)
{
message
.
success
(
"编辑成功"
);
window
.
RCHistory
.
push
({
pathname
:
`/examination-paper-index?categoryId=
${
getParameterByName
(
"categoryId"
)}
`
,
});
}
});
}
else
if
(
currentOperate
===
"new"
)
{
AidToolService
.
createPaper
(
this
.
state
.
formData
).
then
((
res
)
=>
{
if
(
res
.
success
)
{
message
.
success
(
"新建成功"
);
window
.
RCHistory
.
push
({
pathname
:
`/examination-paper-index?categoryId=
${
getParameterByName
(
"categoryId"
)}
`
,
});
}
});
}
}
);
}
catch
(
e
)
{
...
...
@@ -303,7 +370,9 @@ class NewExaminationPaper extends Component {
this
.
setState
(
{
selectQuestionList
:
_selectQuestionList
.
map
((
item
)
=>
item
.
id
===
record
.
id
?
{
...
item
,
score
:
value
}
:
item
item
.
questionId
===
record
.
questionId
?
{
...
item
,
score
:
value
}
:
item
),
},
()
=>
this
.
setFormData
([])
...
...
@@ -329,14 +398,14 @@ class NewExaminationPaper extends Component {
)
}{
" "
}
<
InputNumber
min=
{
0
}
max=
{
record
.
score
}
max=
{
record
.
score
-
1
}
value=
{
record
.
portionScore
||
0
}
onChange=
{
(
value
)
=>
{
const
_selectQuestionList
=
[...
selectQuestionList
];
this
.
setState
(
{
selectQuestionList
:
_selectQuestionList
.
map
((
item
)
=>
item
.
id
===
record
.
i
d
item
.
questionId
===
record
.
questionI
d
?
{
...
item
,
portionScore
:
value
}
:
item
),
...
...
@@ -384,7 +453,7 @@ class NewExaminationPaper extends Component {
<
div
className=
"record-operate__item"
onClick=
{
()
=>
{
this
.
handleDelItem
(
record
.
i
d
);
this
.
handleDelItem
(
record
.
questionI
d
);
}
}
>
移除
...
...
@@ -405,50 +474,23 @@ class NewExaminationPaper extends Component {
const
{
selectQuestionModal
,
selectQuestionList
,
formData
}
=
this
.
state
;
const
{
singleChoiceCnt
,
multiChoiceCnt
,
judgeCnt
,
gapFillingCnt
,
indefiniteChoiceCnt
,
singleChoiceScore
,
multiChoiceScore
,
judgeScore
,
gapFillingScore
,
indefiniteChoiceScore
,
paperName
,
passRate
,
passScore
,
totalScore
,
questionCnt
,
totalScore
,
}
=
formData
;
const
singleQuestion
=
_
.
filter
(
selectQuestionList
,
(
item
)
=>
item
.
questionType
===
"SINGLE_CHOICE"
);
const
multiQuestion
=
_
.
filter
(
selectQuestionList
,
(
item
)
=>
item
.
questionType
===
"MULTI_CHOICE"
);
const
judgeQuestion
=
_
.
filter
(
selectQuestionList
,
(
item
)
=>
item
.
questionType
===
"JUDGE"
);
const
gapQuestion
=
_
.
filter
(
selectQuestionList
,
(
item
)
=>
item
.
questionType
===
"GAP_FILLING"
);
const
indefiniteQuestion
=
_
.
filter
(
selectQuestionList
,
(
item
)
=>
item
.
questionType
===
"INDEFINITE_CHOICE"
);
const
singleScore
=
singleQuestion
.
reduce
((
prev
,
cur
)
=>
{
return
prev
+
Number
(
cur
.
score
)
||
0
;
},
0
);
const
multiScore
=
multiQuestion
.
reduce
((
prev
,
cur
)
=>
{
return
prev
+
Number
(
cur
.
score
)
||
0
;
},
0
);
const
judgeScore
=
judgeQuestion
.
reduce
((
prev
,
cur
)
=>
{
return
prev
+
Number
(
cur
.
score
)
||
0
;
},
0
);
const
gapScore
=
gapQuestion
.
reduce
((
prev
,
cur
)
=>
{
return
prev
+
Number
(
cur
.
score
)
||
0
;
},
0
);
const
indefiniteScore
=
indefiniteQuestion
.
reduce
((
prev
,
cur
)
=>
{
return
prev
+
Number
(
cur
.
score
)
||
0
;
},
0
);
return
(
<
div
className=
"page new-examination-paper"
>
<
Breadcrumbs
navList=
{
"新建试卷"
}
goBack=
{
()
=>
this
.
handleGoBack
()
}
/>
...
...
@@ -545,19 +587,15 @@ class NewExaminationPaper extends Component {
</
Button
>
<
div
style=
{
{
margin
:
"10px 0 20px"
}
}
>
总计
{
totalScore
}
分,共
{
questionCnt
}
题。
{
" "
}
{
singleQuestion
.
length
>
0
&&
`单选题${singleQuestion.length}题,共
${singleScore}分;`
}
{
multiQuestion
.
length
>
0
&&
`多选题${multiQuestion.length}题,共${multiScore}分;`
}
{
judgeQuestion
.
length
>
0
&&
`判断题
${judgeQuestion.length}题,共${judgeScore}分,`
}
{
gapQuestion
.
length
>
0
&&
`填空题${gapQuestion.length}题,共${gapScore}
分,`
}
{
indefiniteQuestion
.
length
>
0
&&
`不定项选择题${indefiniteQuestion.length}题,共${indefiniteScore}分`
}
{
singleChoiceCnt
>
0
&&
`单选题${singleChoiceCnt}题,共${singleChoiceScore}分;`
}
{
multiChoiceCnt
>
0
&&
`多选题${multiChoiceCnt}题,共${multiChoiceScore}分;`
}
{
judgeCnt
>
0
&&
`判断题${judgeCnt}题,共${judgeScore}分,`
}
{
gapFillingCnt
>
0
&&
`填空题${gapFillingCnt}题,共${gapFillingScore}分,`
}
{
indefiniteChoiceCnt
>
0
&&
`不定项选择题${indefiniteChoiceCnt}题,共${indefiniteChoiceScore}分`
}
</
div
>
<
ConfigProvider
renderEmpty=
{
this
.
customizeRenderEmpty
}
>
...
...
@@ -572,10 +610,7 @@ class NewExaminationPaper extends Component {
<
div
className=
"footer"
>
<
Button
>
取消
</
Button
>
<
Button
>
预览
</
Button
>
<
Button
type=
"primary"
onClick=
{
()
=>
this
.
saveExaminationPaper
()
}
>
<
Button
type=
"primary"
onClick=
{
()
=>
this
.
saveExaminationPaper
()
}
>
保存
</
Button
>
</
div
>
...
...
src/modules/teach-tool/examination-paper/modal/PaperPreviewModal.jsx
View file @
de92f985
...
...
@@ -2,7 +2,7 @@
* @Author: yuananting
* @Date: 2021-03-27 11:15:03
* @LastEditors: yuananting
* @LastEditTime: 2021-04-02 1
2:42:42
* @LastEditTime: 2021-04-02 1
5:07:17
* @Description: 助学工具-试卷-预览试卷
* @Copyrigh: © 2020 杭州杰竞科技有限公司 版权所有
*/
...
...
@@ -145,7 +145,6 @@ class PaperPreviewModal extends Component {
if
(
questionType
===
"GAP_FILLING"
)
{
{
_
.
map
(
gapFillingAnswerList
,
(
gapItem
,
gapIndex
)
=>
{
console
.
log
(
"gapFillingAnswerList"
,
gapFillingAnswerList
)
const
{
correctAnswerList
}
=
gapItem
;
return
(
<
div
>
...
...
@@ -157,7 +156,6 @@ class PaperPreviewModal extends Component {
);
});
}
// this.renderGapFillingAnswer(gapFillingAnswerList)
}
else
{
const
correctAnswerOption
=
_
.
filter
(
optionList
,
...
...
@@ -171,7 +169,7 @@ class PaperPreviewModal extends Component {
return
(
<
div
className=
"answer-line__item"
>
<
span
>
正确答案
</
span
>
<
span
>
【
{
correctOptionSort
.
join
(
"、"
)
}
】
</
span
>
{
/* <span>【{correctOptionSort.join("、")}】</span> */
}
</
div
>
);
}
...
...
src/modules/teach-tool/examination-paper/modal/SelectQuestionModal.jsx
View file @
de92f985
...
...
@@ -2,7 +2,7 @@
* @Author: yuananting
* @Date: 2021-03-29 10:52:26
* @LastEditors: yuananting
* @LastEditTime: 2021-04-0
1 14:01:0
6
* @LastEditTime: 2021-04-0
2 19:41:2
6
* @Description: 助学工具-新建试卷-选择题目弹窗
* @Copyrigh: © 2020 杭州杰竞科技有限公司 版权所有
*/
...
...
@@ -21,6 +21,16 @@ class SelectQuestionModal extends Component {
};
}
componentDidMount
()
{
this
.
listRef
.
current
.
state
.
selectQuestionKeys
=
this
.
props
.
getSelectedQuestion
.
map
(
(
item
)
=>
{
item
.
id
=
item
.
questionId
;
item
.
questionTypeEnum
=
item
.
questionType
;
return
item
;
}
);
}
getCategoryIdFromSider
=
(
selectedCategoryId
)
=>
{
if
(
selectedCategoryId
&&
selectedCategoryId
.
length
>
0
)
{
this
.
setState
({
selectedCategoryId
:
selectedCategoryId
[
0
]
});
...
...
@@ -37,14 +47,15 @@ class SelectQuestionModal extends Component {
onOk=
{
()
=>
{
this
.
props
.
setSelectedQuestion
(
this
.
listRef
.
current
.
state
.
selectQuestionKeys
.
map
((
item
)
=>
{
item
.
questionType
=
item
.
questionTypeEnum
;
item
.
score
=
2
;
item
.
questionId
=
item
.
id
||
item
.
questionId
;
item
.
questionType
=
item
.
questionTypeEnum
||
item
.
questionType
;
item
.
score
=
item
.
score
||
2
;
if
(
[
"MULTI_CHOICE"
,
"GAP_FILLING"
,
"INDEFINITE_CHOICE"
].
includes
(
item
.
questionTypeEnum
)
)
{
item
.
portionScore
=
0
;
item
.
portionScore
=
item
.
portionScore
||
0
;
}
return
item
;
})
...
...
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