Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
E
EduSpider
Project
Project
Details
Activity
Releases
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
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
viitto
EduSpider
Commits
9f372145
Commit
9f372145
authored
Aug 18, 2022
by
liudong1993
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1
parent
4e70c537
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
975 additions
and
51 deletions
+975
-51
IExamRepository.cs
EduSpider.IRepository/IExamRepository.cs
+1
-0
IExamService.cs
EduSpider.IServices/IExamService.cs
+7
-2
RB_Exam.cs
EduSpider.Model/Entity/RB_Exam.cs
+5
-0
RB_Exam_Questions.cs
EduSpider.Model/Entity/RB_Exam_Questions.cs
+5
-0
RB_Exam_Questions_Extend.cs
EduSpider.Model/Extend/RB_Exam_Questions_Extend.cs
+8
-0
RB_Exam_Score_Extend.cs
EduSpider.Model/Extend/RB_Exam_Score_Extend.cs
+99
-0
ExamRepository.cs
EduSpider.Repository/ExamRepository.cs
+32
-0
Exam_QuestionsRepository.cs
EduSpider.Repository/Exam_QuestionsRepository.cs
+5
-0
Exam_ScoreRepository.cs
EduSpider.Repository/Exam_ScoreRepository.cs
+4
-0
ExamService.cs
EduSpider.Services/ExamService.cs
+460
-8
StuExamScoreHelper.cs
EduSpider.Utility/Data/StuExamScoreHelper.cs
+259
-37
ExamController.cs
EduSpider.WebApi/Controllers/Student/ExamController.cs
+88
-2
UploadController.cs
EduSpider.WebApi/Controllers/Upload/UploadController.cs
+2
-2
No files found.
EduSpider.IRepository/IExamRepository.cs
View file @
9f372145
...
...
@@ -16,5 +16,6 @@ namespace EduSpider.Repository
public
interface
IExamRepository
:
IDBRepository
<
RB_Exam
>,
IDependency
{
List
<
RB_Exam_Extend
>
GetExamPageList
(
int
pageIndex
,
int
pageSize
,
out
long
count
,
RB_Exam_Extend
demodel
);
List
<
RB_Exam_Extend
>
GetExamList
(
RB_Exam_Extend
rB_Exam_Extend
);
}
}
EduSpider.IServices/IExamService.cs
View file @
9f372145
using
EduSpider.Model.Extend
;
using
EduSpider.Model.Cache
;
using
EduSpider.Model.Extend
;
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
...
...
@@ -15,8 +16,12 @@ namespace EduSpider.IServices
{
string
ImportExcelForStuExamScore
(
string
path_server
,
int
courseId
,
string
examName
,
int
userId
);
List
<
RB_Exam_Extend
>
GetExamPageList
(
int
pageIndex
,
int
pageSize
,
out
long
count
,
RB_Exam_Extend
demodel
);
object
GetExamStuScoreInfo
(
int
examId
,
int
stuId
,
int
stuUId
);
object
GetExamStuScoreInfo
(
int
examId
,
int
stuId
,
int
stuUId
,
out
string
msg
);
object
GetExamStuScoreInfo_Group
(
int
examId
,
int
stuId
,
int
stuUId
);
List
<
RB_Exam_Score_Extend
>
GetExamStuList
(
RB_Exam_Score_Extend
demodel
);
string
DelExamInfo
(
int
examId
,
int
baseUserId
);
string
SetExamStatAnalysis
(
int
courseId
,
UserInfo
userInfo
);
object
GetExamStatAnalysisInfo
(
int
examId
,
int
stuId
,
int
stuUId
,
out
string
msg
);
}
}
EduSpider.Model/Entity/RB_Exam.cs
View file @
9f372145
...
...
@@ -53,5 +53,10 @@ namespace EduSpider.Model.Entity
/// 更新时间
/// </summary>
public
DateTime
UpdateTime
{
get
;
set
;
}
/// <summary>
/// 类型 1正常考试 2分组试题 3统计分析
/// </summary>
public
int
Type
{
get
;
set
;
}
}
}
EduSpider.Model/Entity/RB_Exam_Questions.cs
View file @
9f372145
...
...
@@ -43,5 +43,10 @@ namespace EduSpider.Model.Entity
/// 分数
/// </summary>
public
decimal
Score
{
get
;
set
;
}
/// <summary>
/// 分组
/// </summary>
public
string
GroupName
{
get
;
set
;
}
}
}
EduSpider.Model/Extend/RB_Exam_Questions_Extend.cs
View file @
9f372145
...
...
@@ -9,6 +9,14 @@ namespace EduSpider.Model.Extend
/// </summary>
public
class
RB_Exam_Questions_Extend
:
RB_Exam_Questions
{
/// <summary>
/// 考试ids
/// </summary>
public
string
ExamIds
{
get
;
set
;
}
/// <summary>
/// 分组排序
/// </summary>
public
int
GroupNum
{
get
;
set
;
}
}
}
EduSpider.Model/Extend/RB_Exam_Score_Extend.cs
View file @
9f372145
...
...
@@ -22,6 +22,26 @@ namespace EduSpider.Model.Extend
/// 考试导入时间
/// </summary>
public
DateTime
ExamCreateTime
{
get
;
set
;
}
/// <summary>
/// 考试ids
/// </summary>
public
string
ExamIds
{
get
;
set
;
}
/// <summary>
/// 1-8题得分
/// </summary>
public
decimal
PartScore
{
get
;
set
;
}
/// <summary>
/// 一试得分
/// </summary>
public
decimal
AScore
{
get
;
set
;
}
/// <summary>
/// 一试排名
/// </summary>
public
int
ARank
{
get
;
set
;
}
}
/// <summary>
...
...
@@ -56,5 +76,84 @@ namespace EduSpider.Model.Extend
/// 题目分数
/// </summary>
public
decimal
QScore
{
get
;
set
;
}
/// <summary>
/// 分组名称
/// </summary>
public
string
GroupName
{
get
;
set
;
}
/// <summary>
/// 分组排序
/// </summary>
public
int
GroupNum
{
get
;
set
;
}
}
/// <summary>
/// 1-8题得分
/// </summary>
public
class
ExamPartScoreModel
{
/// <summary>
/// 学生ID
/// </summary>
public
int
StuId
{
get
;
set
;
}
/// <summary>
/// 第几次考试
/// </summary>
public
int
Sort
{
get
;
set
;
}
/// <summary>
/// 考试名称 /知识点名称
/// </summary>
public
string
ExamName
{
get
;
set
;
}
/// <summary>
/// 个人得分/ 考试排名
/// </summary>
public
decimal
Score
{
get
;
set
;
}
/// <summary>
/// 平均得分
/// </summary>
public
decimal
AvgScore
{
get
;
set
;
}
/// <summary>
/// 分组名称
/// </summary>
public
string
GroupName
{
get
;
set
;
}
/// <summary>
/// 分组次数
/// </summary>
public
int
GroupNum
{
get
;
set
;
}
/// <summary>
/// 总分
/// </summary>
public
decimal
TScore
{
get
;
set
;
}
}
/// <summary>
/// 统计分析
/// </summary>
public
class
ExamStatModel
{
/// <summary>
/// 1-8题
/// </summary>
public
List
<
ExamPartScoreModel
>
PartScoreList
{
get
;
set
;
}
/// <summary>
/// 分组排名
/// </summary>
public
List
<
ExamPartScoreModel
>
GroupScoreList
{
get
;
set
;
}
/// <summary>
/// 总排名
/// </summary>
public
List
<
ExamPartScoreModel
>
TRankScoreList
{
get
;
set
;
}
/// <summary>
/// 模块分析
/// </summary>
public
List
<
ExamPartScoreModel
>
ModuleScoreList
{
get
;
set
;
}
}
}
EduSpider.Repository/ExamRepository.cs
View file @
9f372145
...
...
@@ -47,5 +47,37 @@ LEFT JOIN (
where
{
where
}
order by e.ExamId desc"
;
return
GetPage
<
RB_Exam_Extend
>(
pageIndex
,
pageSize
,
out
count
,
sql
,
parameters
).
ToList
();
}
/// <summary>
/// 获取考试列表
/// </summary>
/// <param name="demodel"></param>
/// <returns></returns>
public
List
<
RB_Exam_Extend
>
GetExamList
(
RB_Exam_Extend
demodel
)
{
var
parameters
=
new
DynamicParameters
();
string
where
=
" 1=1 and e.Status =0"
;
if
(
demodel
.
CourseId
>
0
)
{
where
+=
$@" and e.
{
nameof
(
RB_Exam_Extend
.
CourseId
)}
=
{
demodel
.
CourseId
}
"
;
}
if
(!
string
.
IsNullOrEmpty
(
demodel
.
ExamName
))
{
where
+=
$@" and e.
{
nameof
(
RB_Exam_Extend
.
ExamName
)}
like @ExamName"
;
parameters
.
Add
(
"ExamName"
,
"%"
+
demodel
.
ExamName
.
Trim
()
+
"%"
);
}
if
(
demodel
.
CreateBy
>
0
)
{
where
+=
$@" and e.
{
nameof
(
RB_Exam_Extend
.
CreateBy
)}
=
{
demodel
.
CreateBy
}
"
;
}
if
(
demodel
.
Type
>
0
)
{
where
+=
$@" and e.
{
nameof
(
RB_Exam_Extend
.
Type
)}
=
{
demodel
.
Type
}
"
;
}
string
sql
=
$@"select e.* FROM rb_exam e
where
{
where
}
order by e.ExamId desc"
;
return
Get
<
RB_Exam_Extend
>(
sql
,
parameters
).
ToList
();
}
}
}
EduSpider.Repository/Exam_QuestionsRepository.cs
View file @
9f372145
...
...
@@ -26,6 +26,11 @@ namespace EduSpider.Repository
{
where
+=
$" and
{
nameof
(
RB_Exam_Questions_Extend
.
ExamId
)}
=
{
dmodel
.
ExamId
}
"
;
}
if
(!
string
.
IsNullOrEmpty
(
dmodel
.
ExamIds
))
{
where
+=
$" and
{
nameof
(
RB_Exam_Questions_Extend
.
ExamId
)}
in(
{
dmodel
.
ExamIds
}
)"
;
}
string
sql
=
$"select * from RB_Exam_Questions where
{
where
}
"
;
return
Get
<
RB_Exam_Questions_Extend
>(
sql
).
ToList
();
}
...
...
EduSpider.Repository/Exam_ScoreRepository.cs
View file @
9f372145
...
...
@@ -50,6 +50,10 @@ WHERE 1=1 and B.Status =0
{
where
+=
$" and
{
nameof
(
RB_Exam_Score_Extend
.
ExamId
)}
=
{
dmodel
.
ExamId
}
"
;
}
if
(!
string
.
IsNullOrEmpty
(
dmodel
.
ExamIds
))
{
where
+=
$" and
{
nameof
(
RB_Exam_Score_Extend
.
ExamId
)}
in(
{
dmodel
.
ExamIds
}
)"
;
}
if
(
dmodel
.
StuId
>
0
)
{
where
+=
$" and
{
nameof
(
RB_Exam_Score_Extend
.
StuId
)}
=
{
dmodel
.
StuId
}
"
;
...
...
EduSpider.Services/ExamService.cs
View file @
9f372145
using
EduSpider.IRepository
;
using
EduSpider.IServices
;
using
EduSpider.Model.Cache
;
using
EduSpider.Model.Extend
;
using
EduSpider.Repository
;
using
EduSpider.Utility.Data
;
...
...
@@ -76,17 +77,19 @@ namespace EduSpider.Services
/// <param name="stuId"></param>
/// <param name="stuUId"></param>
/// <returns></returns>
public
object
GetExamStuScoreInfo
(
int
examId
,
int
stuId
,
int
stuUId
)
public
object
GetExamStuScoreInfo
(
int
examId
,
int
stuId
,
int
stuUId
,
out
string
msg
)
{
msg
=
""
;
if
(
stuUId
>
0
)
{
var
accountModel
=
AccountRepository
.
GetAccountList
(
new
rb_account_hk_Extend
()
{
AccountId
=
stuUId
,
AccountType
=
Utility
.
Enum
.
AccountTypeEnum
.
Student
}).
FirstOrDefault
();
if
(
accountModel
==
null
)
{
return
""
;
}
if
(
accountModel
==
null
)
{
msg
=
"账号不存在"
;
return
""
;
}
stuId
=
accountModel
.
Id
;
}
var
stuModel
=
StudentRepository
.
GetEntity
(
stuId
);
if
(
stuModel
==
null
)
{
return
""
;
}
if
(
stuModel
==
null
)
{
msg
=
"学生信息不存在"
;
return
""
;
}
var
examModel
=
ExamRepository
.
GetEntity
(
examId
);
if
(
examModel
==
null
)
{
return
""
;
}
if
(
examModel
==
null
)
{
msg
=
"考试信息不存在"
;
return
""
;
}
if
(
examModel
.
Type
==
3
)
{
msg
=
"统计分析无法请求"
;
return
""
;
}
//考试题目
var
qlist
=
Exam_QuestionsRepository
.
GetList
(
new
RB_Exam_Questions_Extend
()
{
ExamId
=
examId
});
//考试成绩
...
...
@@ -113,6 +116,7 @@ namespace EduSpider.Services
ScoreRate
=
Math
.
Round
((
sExamModel
?.
TScore
??
0
)
/
(
sExamModel
?.
ExamScore
??
1
),
2
,
MidpointRounding
.
AwayFromZero
),
ScoreList
=
sExamModel
?.
ScoreList
.
Select
(
x
=>
new
{
x
.
GroupName
,
x
.
Sort
,
x
.
Difficulty
,
x
.
KnowledgePoint
,
...
...
@@ -129,6 +133,124 @@ namespace EduSpider.Services
ScoreRate
=
Math
.
Round
(
x
.
Sum
(
y
=>
y
.
Score
)
/
x
.
Sum
(
y
=>
y
.
QScore
),
2
,
MidpointRounding
.
AwayFromZero
),
AvgScoreRate
=
Math
.
Round
(
x
.
Sum
(
y
=>
y
.
AvgScore
)
/
x
.
Sum
(
y
=>
y
.
QScore
),
2
,
MidpointRounding
.
AwayFromZero
),
}),
GroupModuleList
=
examModel
.
Type
==
2
?
sExamModel
?.
ScoreList
.
GroupBy
(
z
=>
new
{
z
.
GroupName
}).
Select
(
z
=>
new
{
GroupName
=
z
.
Key
,
GroupList
=
z
.
GroupBy
(
x
=>
new
{
x
.
KnowledgePoint
}).
Take
(
8
).
Select
(
x
=>
new
{
Module
=
x
.
Key
.
KnowledgePoint
.
Length
>
6
?
x
.
Key
.
KnowledgePoint
.
Substring
(
0
,
6
)
+
".."
:
x
.
Key
.
KnowledgePoint
,
Score
=
x
.
Sum
(
y
=>
y
.
QScore
),
ScoreRate
=
Math
.
Round
(
x
.
Sum
(
y
=>
y
.
Score
)
/
x
.
Sum
(
y
=>
y
.
QScore
),
2
,
MidpointRounding
.
AwayFromZero
),
AvgScoreRate
=
Math
.
Round
(
x
.
Sum
(
y
=>
y
.
AvgScore
)
/
x
.
Sum
(
y
=>
y
.
QScore
),
2
,
MidpointRounding
.
AwayFromZero
),
})
})
:
null
,
DifficultyList
=
sExamModel
?.
ScoreList
.
GroupBy
(
x
=>
new
{
x
.
Difficulty
}).
Select
(
x
=>
new
{
Difficulty
=
x
.
Key
.
Difficulty
==
"易"
?
"简单题"
:
x
.
Key
.
Difficulty
==
"中"
?
"中档题"
:
"难题"
,
Count
=
x
.
Count
(),
Score
=
x
.
Sum
(
x
=>
x
.
QScore
)
}),
DifficultyRateList
=
sExamModel
?.
ScoreList
.
GroupBy
(
x
=>
new
{
x
.
Difficulty
}).
Select
(
x
=>
new
{
Difficulty
=
x
.
Key
.
Difficulty
==
"易"
?
"简单题"
:
x
.
Key
.
Difficulty
==
"中"
?
"中档题"
:
"难题"
,
ScoreRate
=
Math
.
Round
(
x
.
Sum
(
y
=>
y
.
Score
)
/
x
.
Sum
(
y
=>
y
.
QScore
),
2
,
MidpointRounding
.
AwayFromZero
),
AvgScoreRate
=
Math
.
Round
(
x
.
Sum
(
y
=>
y
.
AvgScore
)
/
x
.
Sum
(
y
=>
y
.
QScore
),
2
,
MidpointRounding
.
AwayFromZero
),
})
};
}
/// <summary>
/// 获取学生考试详情(分组)
/// </summary>
/// <param name="examId"></param>
/// <param name="stuId"></param>
/// <param name="stuUId"></param>
/// <returns></returns>
public
object
GetExamStuScoreInfo_Group
(
int
examId
,
int
stuId
,
int
stuUId
)
{
if
(
stuUId
>
0
)
{
var
accountModel
=
AccountRepository
.
GetAccountList
(
new
rb_account_hk_Extend
()
{
AccountId
=
stuUId
,
AccountType
=
Utility
.
Enum
.
AccountTypeEnum
.
Student
}).
FirstOrDefault
();
if
(
accountModel
==
null
)
{
return
""
;
}
stuId
=
accountModel
.
Id
;
}
var
stuModel
=
StudentRepository
.
GetEntity
(
stuId
);
if
(
stuModel
==
null
)
{
return
""
;
}
var
examModel
=
ExamRepository
.
GetEntity
(
examId
);
if
(
examModel
==
null
)
{
return
""
;
}
//考试题目
var
qlist
=
Exam_QuestionsRepository
.
GetList
(
new
RB_Exam_Questions_Extend
()
{
ExamId
=
examId
});
//考试成绩
var
sExamModel
=
Exam_ScoreRepository
.
GetList
(
new
RB_Exam_Score_Extend
()
{
ExamId
=
examId
,
StuId
=
stuId
}).
FirstOrDefault
();
if
(
sExamModel
!=
null
)
{
sExamModel
.
ScoreList
=
JsonHelper
.
Deserialize
<
List
<
ExamQScoreModel
>>(
sExamModel
.
Content
);
foreach
(
var
qitem
in
sExamModel
.
ScoreList
)
{
qitem
.
Difficulty
=
qlist
.
Where
(
x
=>
x
.
Sort
==
qitem
.
Sort
).
FirstOrDefault
()?.
Difficulty
??
""
;
qitem
.
KnowledgePoint
=
qlist
.
Where
(
x
=>
x
.
Sort
==
qitem
.
Sort
).
FirstOrDefault
()?.
KnowledgePoint
??
""
;
qitem
.
QScore
=
qlist
.
Where
(
x
=>
x
.
Sort
==
qitem
.
Sort
).
FirstOrDefault
()?.
Score
??
0
;
qitem
.
GroupName
=
qlist
.
Where
(
x
=>
x
.
Sort
==
qitem
.
Sort
).
FirstOrDefault
()?.
GroupName
??
""
;
}
}
//开始组装数据
return
new
{
StuId
=
stuModel
.
StudId
,
StuName
=
stuModel
.
StudentName
,
examModel
.
ExamName
,
sExamModel
?.
TScore
,
sExamModel
?.
Rank
,
sExamModel
?.
RankRate
,
ScoreRate
=
Math
.
Round
((
sExamModel
?.
TScore
??
0
)
/
(
sExamModel
?.
ExamScore
??
1
),
2
,
MidpointRounding
.
AwayFromZero
),
//ScoreList = sExamModel?.ScoreList.GroupBy(x => new { x.GroupName }).Select(x => new
//{
// GroupName = x.Key,
// GroupList = x.Select(z => new
// {
// z.Sort,
// z.Difficulty,
// z.KnowledgePoint,
// z.QScore,
// z.Score,
// ScoreRate = Math.Round(z.Score / z.QScore, 2, MidpointRounding.AwayFromZero),
// AvgScore = Math.Round(z.AvgScore, 6, MidpointRounding.AwayFromZero),
// AvgScoreRate = Math.Round(z.AvgScore / z.QScore, 2, MidpointRounding.AwayFromZero)
// })
//}),
ScoreList
=
sExamModel
?.
ScoreList
.
Select
(
z
=>
new
{
z
.
GroupName
,
z
.
Sort
,
z
.
Difficulty
,
z
.
KnowledgePoint
,
z
.
QScore
,
z
.
Score
,
ScoreRate
=
Math
.
Round
(
z
.
Score
/
z
.
QScore
,
2
,
MidpointRounding
.
AwayFromZero
),
AvgScore
=
Math
.
Round
(
z
.
AvgScore
,
6
,
MidpointRounding
.
AwayFromZero
),
AvgScoreRate
=
Math
.
Round
(
z
.
AvgScore
/
z
.
QScore
,
2
,
MidpointRounding
.
AwayFromZero
)
}),
//ModuleList = sExamModel?.ScoreList.GroupBy(x => new { x.KnowledgePoint }).Take(8).Select(x => new
//{
// Module = x.Key.KnowledgePoint.Length > 6 ? x.Key.KnowledgePoint.Substring(0, 6) + ".." : x.Key.KnowledgePoint,
// Score = x.Sum(y => y.QScore),
// ScoreRate = Math.Round(x.Sum(y => y.Score) / x.Sum(y => y.QScore), 2, MidpointRounding.AwayFromZero),
// AvgScoreRate = Math.Round(x.Sum(y => y.AvgScore) / x.Sum(y => y.QScore), 2, MidpointRounding.AwayFromZero),
//}),
ModuleList
=
sExamModel
?.
ScoreList
.
GroupBy
(
z
=>
new
{
z
.
GroupName
}).
Select
(
z
=>
new
{
GroupName
=
z
.
Key
,
GroupList
=
z
.
GroupBy
(
x
=>
new
{
x
.
KnowledgePoint
}).
Take
(
8
).
Select
(
x
=>
new
{
Module
=
x
.
Key
.
KnowledgePoint
.
Length
>
6
?
x
.
Key
.
KnowledgePoint
.
Substring
(
0
,
6
)
+
".."
:
x
.
Key
.
KnowledgePoint
,
Score
=
x
.
Sum
(
y
=>
y
.
QScore
),
ScoreRate
=
Math
.
Round
(
x
.
Sum
(
y
=>
y
.
Score
)
/
x
.
Sum
(
y
=>
y
.
QScore
),
2
,
MidpointRounding
.
AwayFromZero
),
AvgScoreRate
=
Math
.
Round
(
x
.
Sum
(
y
=>
y
.
AvgScore
)
/
x
.
Sum
(
y
=>
y
.
QScore
),
2
,
MidpointRounding
.
AwayFromZero
),
})
}),
DifficultyList
=
sExamModel
?.
ScoreList
.
GroupBy
(
x
=>
new
{
x
.
Difficulty
}).
Select
(
x
=>
new
{
Difficulty
=
x
.
Key
.
Difficulty
==
"易"
?
"简单题"
:
x
.
Key
.
Difficulty
==
"中"
?
"中档题"
:
"难题"
,
...
...
@@ -178,7 +300,8 @@ namespace EduSpider.Services
{
var
umodel
=
AccountRepository
.
GetAccountList
(
new
Model
.
Extend
.
rb_account_hk_Extend
()
{
Id
=
userId
,
AccountType
=
Utility
.
Enum
.
AccountTypeEnum
.
Teacher
}).
FirstOrDefault
();
if
(
umodel
==
null
||
umodel
.
Status
==
Utility
.
Enum
.
DateStateEnum
.
Delete
||
umodel
.
AccountType
!=
Utility
.
Enum
.
AccountTypeEnum
.
Teacher
)
{
return
"没有权限操作"
;
}
var
EQlist
=
StuExamScoreHelper
.
GetStuExamScoreData
(
path_server
,
out
List
<
StuScoreModel
>
StuList
);
var
EQlist
=
StuExamScoreHelper
.
GetStuExamScoreData
(
path_server
,
out
List
<
StuScoreModel
>
StuList
,
out
string
msg
,
out
int
type
);
if
(
msg
!=
""
)
{
return
msg
;
}
if
(
EQlist
.
Any
())
{
var
AvgList
=
StuList
.
Where
(
x
=>
x
.
Name
==
"平均分"
).
ToList
();
...
...
@@ -195,7 +318,8 @@ namespace EduSpider.Services
ExamName
=
examName
,
CreateBy
=
userId
,
CreateTime
=
DateTime
.
Now
,
Status
=
0
Status
=
0
,
Type
=
type
});
if
(
ExamId
>
0
)
{
List
<
Model
.
Entity
.
RB_Exam_Questions
>
InsertEQ
=
new
();
...
...
@@ -209,7 +333,8 @@ namespace EduSpider.Services
Difficulty
=
item
.
Difficulty
,
KnowledgePoint
=
item
.
KnowledgePoint
,
Score
=
item
.
Score
,
Sort
=
item
.
Id
Sort
=
item
.
Id
,
GroupName
=
item
.
GroupName
});
}
Exam_QuestionsRepository
.
BatchInsert
(
InsertEQ
);
...
...
@@ -262,7 +387,8 @@ namespace EduSpider.Services
{
var
umodel
=
AccountRepository
.
GetAccountList
(
new
Model
.
Extend
.
rb_account_hk_Extend
()
{
Id
=
userId
}).
FirstOrDefault
();
if
(
umodel
==
null
||
umodel
.
Status
==
Utility
.
Enum
.
DateStateEnum
.
Delete
||
umodel
.
AccountType
!=
Utility
.
Enum
.
AccountTypeEnum
.
Teacher
)
{
return
"没有权限操作"
;
}
var
EQlist
=
StuExamScoreHelper
.
GetStuExamScoreData
(
path_server
,
out
List
<
StuScoreModel
>
StuList
);
var
EQlist
=
StuExamScoreHelper
.
GetStuExamScoreData
(
path_server
,
out
List
<
StuScoreModel
>
StuList
,
out
string
msg
,
out
int
type
);
if
(
msg
!=
""
)
{
return
msg
;
}
if
(
EQlist
.
Any
())
{
var
AvgList
=
StuList
.
Where
(
x
=>
x
.
Name
==
"平均分"
).
ToList
();
...
...
@@ -324,5 +450,331 @@ namespace EduSpider.Services
return
"模板匹配失败"
;
}
}
/// <summary>
/// 创建统计分析
/// </summary>
/// <param name="courseId"></param>
/// <param name="userInfo"></param>
/// <returns></returns>
public
string
SetExamStatAnalysis
(
int
courseId
,
UserInfo
userInfo
)
{
//获取所有分组考试
var
examList
=
ExamRepository
.
GetExamList
(
new
RB_Exam_Extend
()
{
CourseId
=
courseId
,
CreateBy
=
userInfo
.
Id
,
Type
=
2
}).
OrderBy
(
x
=>
x
.
ExamId
).
ToList
();
if
(!
examList
.
Any
())
{
return
"未查询到分组考试信息,无法生成统计分析"
;
}
//查询所有的 考试题
string
examIds
=
string
.
Join
(
","
,
examList
.
Select
(
x
=>
x
.
ExamId
));
var
questList
=
Exam_QuestionsRepository
.
GetList
(
new
RB_Exam_Questions_Extend
()
{
ExamIds
=
examIds
});
//查询所有的 学生分数
var
scoreList
=
Exam_ScoreRepository
.
GetList
(
new
RB_Exam_Score_Extend
()
{
ExamIds
=
examIds
});
foreach
(
var
item
in
scoreList
)
{
item
.
ScoreList
=
JsonHelper
.
Deserialize
<
List
<
ExamQScoreModel
>>(
item
.
Content
);
foreach
(
var
qitem
in
item
.
ScoreList
)
{
var
qmodel
=
questList
.
Where
(
x
=>
x
.
ExamId
==
item
.
ExamId
&&
x
.
Sort
==
qitem
.
Sort
).
FirstOrDefault
();
qitem
.
Difficulty
=
qmodel
?.
Difficulty
??
""
;
qitem
.
KnowledgePoint
=
qmodel
?.
KnowledgePoint
??
""
;
qitem
.
QScore
=
qmodel
?.
Score
??
0
;
qitem
.
GroupName
=
qmodel
?.
GroupName
??
""
;
}
item
.
PartScore
=
item
.
ScoreList
.
Where
(
x
=>
x
.
Sort
<=
8
).
Sum
(
x
=>
x
.
Score
);
//个人1-8题得分
}
if
(!
scoreList
.
Any
())
{
return
"未查询到学生考试成绩"
;
}
int
ExamId
=
ExamRepository
.
Insert
(
new
Model
.
Entity
.
RB_Exam
()
{
Type
=
3
,
CourseId
=
courseId
,
CreateBy
=
userInfo
.
Id
,
CreateTime
=
DateTime
.
Now
,
ExamId
=
0
,
ExamName
=
"统计分析"
,
Status
=
0
,
UpdateBy
=
userInfo
.
Id
,
UpdateTime
=
DateTime
.
Now
});
if
(
ExamId
>
0
)
{
List
<
int
>
StuIdList
=
scoreList
.
Select
(
x
=>
x
.
StuId
).
Distinct
().
ToList
();
int
stuNum
=
StuIdList
.
Count
();
#
region
1
-
8
题统计
List
<
ExamPartScoreModel
>
StuPScoreList
=
new
List
<
ExamPartScoreModel
>();
// 1-8题得分列表
List
<
ExamPartScoreModel
>
TestScoreList
=
new
List
<
ExamPartScoreModel
>();
//一试二试排名列表
List
<
ExamPartScoreModel
>
TRScoreList
=
new
List
<
ExamPartScoreModel
>();
//总排名列表
//1-8题统计 先看1-8题 平均得分 x轴 考试次数, y轴 得分
int
ExamNum
=
1
,
MaxGroupNum
=
1
;
foreach
(
var
item
in
examList
)
{
//先算平均得分
var
esList
=
scoreList
.
Where
(
x
=>
x
.
ExamId
==
item
.
ExamId
).
ToList
();
decimal
avgScore
=
Math
.
Round
(
esList
.
Sum
(
x
=>
x
.
PartScore
)
/
esList
.
Count
(),
2
,
MidpointRounding
.
AwayFromZero
);
//1-8题 平均得分
//查看所有的分组
var
groupList
=
questList
.
Where
(
x
=>
x
.
ExamId
==
item
.
ExamId
).
Select
(
x
=>
x
.
GroupName
).
Distinct
();
int
groupNum
=
1
;
foreach
(
var
groupName
in
groupList
)
{
//组装一试排名 二试排名
foreach
(
var
qitem
in
esList
)
{
qitem
.
AScore
=
qitem
.
ScoreList
.
Where
(
x
=>
x
.
GroupName
==
groupName
).
Sum
(
x
=>
x
.
Score
);
qitem
.
ScoreList
.
Where
(
x
=>
x
.
GroupName
==
groupName
).
ToList
().
ForEach
(
x
=>
{
x
.
GroupNum
=
groupNum
;
});
}
int
Rank
=
1
;
esList
.
OrderByDescending
(
x
=>
x
.
AScore
).
GroupBy
(
x
=>
x
.
AScore
).
ToList
().
ForEach
(
x
=>
{
x
.
ToList
().
ForEach
(
y
=>
{
y
.
ARank
=
Rank
;
});
Rank
+=
x
.
Count
();
});
foreach
(
var
stuId
in
StuIdList
)
{
//插入分组排名
TestScoreList
.
Add
(
new
ExamPartScoreModel
()
{
StuId
=
stuId
,
Sort
=
ExamNum
,
ExamName
=
item
.
ExamName
,
GroupName
=
groupName
,
Score
=
esList
.
Where
(
x
=>
x
.
StuId
==
stuId
).
FirstOrDefault
()?.
ARank
??
0
,
GroupNum
=
groupNum
});
}
if
(
MaxGroupNum
<
groupNum
)
{
MaxGroupNum
=
groupNum
;
}
questList
.
Where
(
x
=>
x
.
ExamId
==
item
.
ExamId
&&
x
.
GroupName
==
groupName
).
ToList
().
ForEach
(
x
=>
x
.
GroupNum
=
groupNum
);
groupNum
++;
}
//开始插入 遍历所有的 学生
foreach
(
var
stuId
in
StuIdList
)
{
//插入1-8题
StuPScoreList
.
Add
(
new
ExamPartScoreModel
()
{
StuId
=
stuId
,
Sort
=
ExamNum
,
AvgScore
=
avgScore
,
ExamName
=
item
.
ExamName
,
Score
=
esList
.
Where
(
x
=>
x
.
StuId
==
stuId
).
FirstOrDefault
()?.
PartScore
??
0
});
//插入总排名
TRScoreList
.
Add
(
new
ExamPartScoreModel
()
{
StuId
=
stuId
,
Sort
=
ExamNum
,
ExamName
=
item
.
ExamName
,
Score
=
esList
.
Where
(
x
=>
x
.
StuId
==
stuId
).
FirstOrDefault
()?.
Rank
??
0
});
}
ExamNum
++;
}
#
endregion
#
region
模块分析
//分组版块分析表 x轴 知识点 , y轴 分数(总分 个人分 平均分) 如果有多次考试 知识点 重复的 就累计使用
List
<
ExamPartScoreModel
>
ModuleScoreList
=
new
List
<
ExamPartScoreModel
>();
//考试版块分析列表
var
knowList
=
questList
.
Select
(
x
=>
x
.
KnowledgePoint
).
Distinct
();
foreach
(
var
item
in
knowList
)
{
//查询分组
for
(
int
groupN
=
1
;
groupN
<=
MaxGroupNum
;
groupN
++)
{
decimal
TotalScore
=
questList
.
Where
(
x
=>
x
.
KnowledgePoint
==
item
&&
x
.
GroupNum
==
groupN
).
Sum
(
x
=>
x
.
Score
);
//知识点总分
if
(
TotalScore
>
0
)
{
decimal
AvgScore
=
Math
.
Round
(
scoreList
.
Sum
(
x
=>
x
.
ScoreList
.
Where
(
y
=>
y
.
KnowledgePoint
==
item
&&
y
.
GroupNum
==
groupN
).
Sum
(
y
=>
y
.
Score
))
/
stuNum
,
2
,
MidpointRounding
.
AwayFromZero
);
//知识点平均得分
foreach
(
var
stuId
in
StuIdList
)
{
decimal
Score
=
scoreList
.
Where
(
x
=>
x
.
StuId
==
stuId
).
Sum
(
x
=>
x
.
ScoreList
.
Where
(
y
=>
y
.
KnowledgePoint
==
item
&&
y
.
GroupNum
==
groupN
).
Sum
(
y
=>
y
.
Score
));
//学生这些知识点的总得分
ModuleScoreList
.
Add
(
new
ExamPartScoreModel
()
{
StuId
=
stuId
,
GroupNum
=
groupN
,
ExamName
=
item
,
Score
=
Score
,
TScore
=
TotalScore
,
AvgScore
=
AvgScore
});
}
}
}
}
#
endregion
#
region
开始插入数据
int
eNum
=
examList
.
Count
();
//考试数量
List
<
RB_Exam_Score_Extend
>
TRankList
=
new
List
<
RB_Exam_Score_Extend
>();
//统计排名
foreach
(
var
stuId
in
StuIdList
)
{
decimal
TScore
=
Math
.
Round
(
scoreList
.
Where
(
x
=>
x
.
StuId
==
stuId
).
Sum
(
x
=>
x
.
TScore
)
/
eNum
,
2
,
MidpointRounding
.
AwayFromZero
);
// 平均几次考试 得到总分
decimal
ExamScore
=
Math
.
Round
(
scoreList
.
Where
(
x
=>
x
.
StuId
==
stuId
).
Sum
(
x
=>
x
.
ExamScore
)
/
eNum
,
2
,
MidpointRounding
.
AwayFromZero
);
TRankList
.
Add
(
new
RB_Exam_Score_Extend
()
{
StuId
=
stuId
,
TScore
=
TScore
,
ExamScore
=
ExamScore
});
}
int
TRank
=
1
;
TRankList
.
OrderByDescending
(
x
=>
x
.
TScore
).
GroupBy
(
x
=>
x
.
TScore
).
ToList
().
ForEach
(
x
=>
{
x
.
ToList
().
ForEach
(
y
=>
{
y
.
Rank
=
TRank
;
y
.
RankRate
=
Math
.
Round
(
Convert
.
ToDecimal
(
stuNum
-
TRank
+
1
)
/
stuNum
,
2
,
MidpointRounding
.
AwayFromZero
);
});
TRank
+=
x
.
Count
();
});
//插入
foreach
(
var
stuId
in
StuIdList
)
{
ExamStatModel
statModel
=
new
ExamStatModel
()
{
PartScoreList
=
StuPScoreList
.
Where
(
x
=>
x
.
StuId
==
stuId
).
ToList
(),
GroupScoreList
=
TestScoreList
.
Where
(
x
=>
x
.
StuId
==
stuId
).
ToList
(),
TRankScoreList
=
TRScoreList
.
Where
(
x
=>
x
.
StuId
==
stuId
).
ToList
(),
ModuleScoreList
=
ModuleScoreList
.
Where
(
x
=>
x
.
StuId
==
stuId
).
ToList
()
};
var
smodel
=
scoreList
.
Where
(
x
=>
x
.
StuId
==
stuId
).
FirstOrDefault
();
var
rmodel
=
TRankList
.
Where
(
x
=>
x
.
StuId
==
stuId
).
FirstOrDefault
();
Exam_ScoreRepository
.
Insert
(
new
Model
.
Entity
.
RB_Exam_Score
()
{
Id
=
0
,
StuId
=
stuId
,
ExamId
=
ExamId
,
StuUId
=
smodel
.
StuUId
,
StuName
=
smodel
.
StuName
,
Content
=
JsonHelper
.
Serialize
(
new
{
PartScoreList
=
statModel
.
PartScoreList
.
Select
(
x
=>
new
{
x
.
Sort
,
x
.
ExamName
,
x
.
AvgScore
,
x
.
Score
}),
ModuleScoreList
=
statModel
.
ModuleScoreList
.
Select
(
y
=>
new
{
y
.
GroupNum
,
y
.
ExamName
,
y
.
Score
,
y
.
AvgScore
,
y
.
TScore
}),
GroupScoreList
=
statModel
.
GroupScoreList
.
Select
(
y
=>
new
{
y
.
GroupNum
,
y
.
Sort
,
y
.
ExamName
,
y
.
Score
}),
TRankScoreList
=
statModel
.
TRankScoreList
.
Select
(
x
=>
new
{
x
.
Sort
,
x
.
ExamName
,
x
.
Score
})
}),
TScore
=
rmodel
.
TScore
,
ExamScore
=
rmodel
.
ExamScore
,
Rank
=
rmodel
.
Rank
,
RankRate
=
rmodel
.
RankRate
});
}
#
endregion
}
return
ExamId
>
0
?
""
:
"出错了,请联系管理员"
;
}
/// <summary>
/// 获取统计分析详情
/// </summary>
/// <param name="examId"></param>
/// <param name="stuId"></param>
/// <param name="stuUId"></param>
/// <param name="msg"></param>
/// <returns></returns>
public
object
GetExamStatAnalysisInfo
(
int
examId
,
int
stuId
,
int
stuUId
,
out
string
msg
)
{
msg
=
""
;
if
(
stuUId
>
0
)
{
var
accountModel
=
AccountRepository
.
GetAccountList
(
new
rb_account_hk_Extend
()
{
AccountId
=
stuUId
,
AccountType
=
Utility
.
Enum
.
AccountTypeEnum
.
Student
}).
FirstOrDefault
();
if
(
accountModel
==
null
)
{
msg
=
"账号不存在"
;
return
""
;
}
stuId
=
accountModel
.
Id
;
}
var
stuModel
=
StudentRepository
.
GetEntity
(
stuId
);
if
(
stuModel
==
null
)
{
msg
=
"学生信息不存在"
;
return
""
;
}
var
examModel
=
ExamRepository
.
GetEntity
(
examId
);
if
(
examModel
==
null
)
{
msg
=
"考试信息不存在"
;
return
""
;
}
if
(
examModel
.
Type
!=
3
)
{
msg
=
"非统计分析请求"
;
return
""
;
}
//考试成绩
var
sExamModel
=
Exam_ScoreRepository
.
GetList
(
new
RB_Exam_Score_Extend
()
{
ExamId
=
examId
,
StuId
=
stuId
}).
FirstOrDefault
();
ExamStatModel
statList
=
new
ExamStatModel
();
if
(
sExamModel
!=
null
)
{
statList
=
JsonHelper
.
Deserialize
<
ExamStatModel
>(
sExamModel
.
Content
);
}
//开始组装数据
return
new
{
StuId
=
stuModel
.
StudId
,
StuName
=
stuModel
.
StudentName
,
examModel
.
ExamName
,
sExamModel
?.
TScore
,
sExamModel
?.
Rank
,
sExamModel
?.
RankRate
,
ScoreRate
=
Math
.
Round
((
sExamModel
?.
TScore
??
0
)
/
(
sExamModel
?.
ExamScore
??
1
),
2
,
MidpointRounding
.
AwayFromZero
),
PartScoreList
=
statList
.
PartScoreList
.
Select
(
x
=>
new
{
ExamNum
=
x
.
Sort
,
x
.
ExamName
,
x
.
AvgScore
,
x
.
Score
}),
ModuleScoreList
=
statList
.
ModuleScoreList
.
GroupBy
(
x
=>
x
.
GroupNum
).
Select
(
x
=>
new
{
GroupNum
=
x
.
Key
,
GroupList
=
x
.
Select
(
y
=>
new
{
KnowledgePoint
=
y
.
ExamName
,
y
.
Score
,
y
.
AvgScore
,
y
.
TScore
})
}),
GroupRankList
=
statList
.
GroupScoreList
.
GroupBy
(
x
=>
x
.
GroupNum
).
Select
(
x
=>
new
{
GroupNum
=
x
.
Key
,
GroupList
=
x
.
Select
(
y
=>
new
{
ExamNum
=
y
.
Sort
,
y
.
ExamName
,
Rank
=
y
.
Score
})
}),
TRankScoreList
=
statList
.
TRankScoreList
.
Select
(
x
=>
new
{
ExamNum
=
x
.
Sort
,
x
.
ExamName
,
Rank
=
x
.
Score
})
};
}
}
}
EduSpider.Utility/Data/StuExamScoreHelper.cs
View file @
9f372145
...
...
@@ -17,74 +17,286 @@ namespace EduSpider.Utility.Data
/// </summary>
/// <param name="filePath"></param>
/// <returns></returns>
public
static
List
<
ExamQuestionModel
>
GetStuExamScoreData
(
string
filePath
,
out
List
<
StuScoreModel
>
StuList
)
public
static
List
<
ExamQuestionModel
>
GetStuExamScoreData
(
string
filePath
,
out
List
<
StuScoreModel
>
StuList
,
out
string
msg
,
out
int
type
)
{
StuList
=
new
List
<
StuScoreModel
>();
msg
=
""
;
type
=
1
;
StuList
=
new
List
<
StuScoreModel
>();
var
dt
=
NPOIHelper
.
ImportExcelToDatatable
(
filePath
,
0
,
0
,
true
);
List
<
ExamQuestionModel
>
EQList
=
new
List
<
ExamQuestionModel
>();
if
(
dt
!=
null
&&
dt
.
Rows
.
Count
>
0
)
{
//先抓取 题目列表
for
(
var
i
=
1
;
i
<
1000
;
i
++)
if
(
dt
.
Columns
.
Contains
(
"分组"
))
{
if
(
dt
.
Columns
.
Contains
(
i
.
ToString
()))
type
=
2
;
//首先抓取 分组列
List
<
string
>
colList
=
new
List
<
string
>();
foreach
(
var
item
in
dt
.
Columns
)
{
if
(
item
==
null
)
{
msg
=
"分组项有误,请核实后再试"
;
return
new
List
<
ExamQuestionModel
>();
}
colList
.
Add
(
item
.
ToString
());
if
(
item
!=
null
&&
item
.
ToString
()
==
"百分比排名"
)
{
break
;
}
//最后一个了 跳出循环
}
//抓取题号
#
region
验证题号是否连续
List
<
int
>
THList
=
new
List
<
int
>();
string
GroupName
=
""
;
//分组名称
foreach
(
var
item
in
colList
)
{
if
(
item
==
"分组"
||
item
==
"总分"
||
item
==
"排名"
||
item
==
"百分比排名"
)
{
continue
;
}
string
TH
=
dt
.
Rows
[
0
][
item
].
ToString
();
if
(
string
.
IsNullOrEmpty
(
TH
))
{
msg
=
"题号有合并行/题号不存在,请处理后再试"
;
return
new
List
<
ExamQuestionModel
>();
}
if
(!
item
.
Contains
(
"Column"
))
{
GroupName
=
item
;
}
if
(
string
.
IsNullOrEmpty
(
GroupName
))
{
msg
=
"分组项有误,请核实后再试"
;
return
new
List
<
ExamQuestionModel
>();
}
EQList
.
Add
(
new
ExamQuestionModel
()
{
Id
=
i
,
Difficulty
=
dt
.
Rows
[
0
][
i
.
ToString
()].
ToString
(),
KnowledgePoint
=
dt
.
Rows
[
1
][
i
.
ToString
()].
ToString
(),
Score
=
Convert
.
ToDecimal
(
dt
.
Rows
[
2
][
i
.
ToString
()].
ToString
())
Id
=
TH
==
""
?
0
:
Convert
.
ToInt32
(
TH
),
Difficulty
=
dt
.
Rows
[
1
][
item
].
ToString
(),
KnowledgePoint
=
dt
.
Rows
[
2
][
item
].
ToString
(),
Score
=
Convert
.
ToDecimal
(
dt
.
Rows
[
3
][
item
].
ToString
()),
GroupName
=
GroupName
,
ColName
=
item
});
THList
.
Add
(
TH
==
""
?
0
:
Convert
.
ToInt32
(
TH
));
if
(
item
!=
null
&&
item
.
ToString
()
==
"百分比排名"
)
{
break
;
}
//最后一个了 跳出循环
}
if
(
THList
.
Any
())
{
int
Num
=
1
;
//必须从第一题开始
foreach
(
var
item
in
THList
)
{
if
(
item
!=
Num
)
{
msg
=
$"第
{
Num
}
题不存在/题号有误,请核实后再试"
;
return
new
List
<
ExamQuestionModel
>();
}
Num
++;
}
}
else
{
break
;
msg
=
"题号不存在,请核实后再试"
;
return
new
List
<
ExamQuestionModel
>();
}
#
endregion
if
(
EQList
.
Any
())
{
int
totalCount
=
dt
.
Rows
.
Count
;
//从第5行 开始 是学生
for
(
var
i
=
4
;
i
<
totalCount
;
i
++)
{
string
StuName
=
dt
.
Rows
[
i
][
"分组"
].
ToString
().
Trim
();
foreach
(
var
item
in
EQList
)
{
string
v
=
dt
.
Rows
[
i
][
item
.
ColName
].
ToString
();
if
(
string
.
IsNullOrEmpty
(
v
))
{
msg
=
$"第
{
i
+
1
}
行,第
{
item
.
Id
}
题得分为空,请核实后再试"
;
return
new
List
<
ExamQuestionModel
>();
}
//先装姓名
StuList
.
Add
(
new
StuScoreModel
()
{
Name
=
StuName
,
Id
=
item
.
Id
,
Score
=
Convert
.
ToDecimal
(
v
==
""
?
"0"
:
v
)
});
}
if
(
i
<
totalCount
-
1
)
{
string
z
=
dt
.
Rows
[
i
][
"总分"
].
ToString
();
if
(
string
.
IsNullOrEmpty
(
z
))
{
msg
=
$"第
{
i
+
1
}
行,总分为空,请核实后再试"
;
return
new
List
<
ExamQuestionModel
>();
}
//总分 排名 百分比排名
StuList
.
Add
(
new
StuScoreModel
()
{
Name
=
StuName
,
Id
=
-
1
,
Score
=
Convert
.
ToDecimal
(
z
==
""
?
"0"
:
z
)
});
string
p
=
dt
.
Rows
[
i
][
"排名"
].
ToString
();
if
(
string
.
IsNullOrEmpty
(
p
)
&&
StuName
!=
"平均分"
)
{
msg
=
$"第
{
i
+
1
}
行,排名为空,请核实后再试"
;
return
new
List
<
ExamQuestionModel
>();
}
StuList
.
Add
(
new
StuScoreModel
()
{
Name
=
StuName
,
Id
=
-
2
,
Score
=
Convert
.
ToDecimal
(
p
==
""
?
"0"
:
p
)
});
string
b
=
dt
.
Rows
[
i
][
"百分比排名"
].
ToString
();
if
(
string
.
IsNullOrEmpty
(
b
)
&&
StuName
!=
"平均分"
)
{
msg
=
$"第
{
i
+
1
}
行,百分比排名排名为空,请核实后再试"
;
return
new
List
<
ExamQuestionModel
>();
}
StuList
.
Add
(
new
StuScoreModel
()
{
Name
=
StuName
,
Id
=
-
3
,
Score
=
Convert
.
ToDecimal
(
b
==
""
?
"0"
:
b
)
});
}
if
(
StuName
==
"平均分"
)
{
break
;
}
}
}
}
if
(
EQList
.
Any
())
else
{
int
totalCount
=
dt
.
Rows
.
Count
;
//从第5行 开始 是学生
for
(
var
i
=
3
;
i
<
totalCount
;
i
++
)
#
region
验证题号是否连续
List
<
int
>
THList
=
new
List
<
int
>();
for
each
(
var
item
in
dt
.
Columns
)
{
foreach
(
var
item
in
EQList
)
if
(
item
!=
null
&&
item
.
ToString
().
Contains
(
"Column"
)
)
{
//先装姓名
StuList
.
Add
(
new
StuScoreModel
()
msg
=
"题号有合并行,请处理成单行后再试"
;
return
new
List
<
ExamQuestionModel
>();
}
if
(
item
!=
null
&&
ValidateInt
(
item
.
ToString
()))
{
THList
.
Add
(
Convert
.
ToInt32
(
item
.
ToString
()));
}
if
(
item
!=
null
&&
item
.
ToString
()
==
"百分比排名"
)
{
break
;
}
//最后一个了 跳出循环
}
if
(
THList
.
Any
())
{
int
Num
=
1
;
//必须从第一题开始
foreach
(
var
item
in
THList
)
{
if
(
item
!=
Num
)
{
msg
=
$"第
{
Num
}
题不存在/题号有误,请核实后再试"
;
return
new
List
<
ExamQuestionModel
>();
}
Num
++;
}
}
else
{
msg
=
"题号不存在,请核实后再试"
;
return
new
List
<
ExamQuestionModel
>();
}
#
endregion
//先抓取 题目列表
for
(
var
i
=
1
;
i
<
1000
;
i
++)
{
if
(
dt
.
Columns
.
Contains
(
i
.
ToString
()))
{
EQList
.
Add
(
new
ExamQuestionModel
()
{
Name
=
dt
.
Rows
[
i
][
"题号"
].
ToString
().
Trim
(),
Id
=
item
.
Id
,
Score
=
Convert
.
ToDecimal
(
dt
.
Rows
[
i
][
item
.
Id
.
ToString
()].
ToString
())
Id
=
i
,
Difficulty
=
dt
.
Rows
[
0
][
i
.
ToString
()].
ToString
(),
KnowledgePoint
=
dt
.
Rows
[
1
][
i
.
ToString
()].
ToString
(),
Score
=
Convert
.
ToDecimal
(
dt
.
Rows
[
2
][
i
.
ToString
()].
ToString
())
});
}
if
(
i
<
totalCount
-
1
)
else
{
//总分 排名 百分比排名
StuList
.
Add
(
new
StuScoreModel
()
break
;
}
}
if
(
EQList
.
Any
())
{
int
totalCount
=
dt
.
Rows
.
Count
;
//从第5行 开始 是学生
for
(
var
i
=
3
;
i
<
totalCount
;
i
++)
{
string
StuName
=
dt
.
Rows
[
i
][
"题号"
].
ToString
().
Trim
();
foreach
(
var
item
in
EQList
)
{
Name
=
dt
.
Rows
[
i
][
"题号"
].
ToString
().
Trim
(),
Id
=
-
1
,
Score
=
Convert
.
ToDecimal
(
dt
.
Rows
[
i
][
"总分"
].
ToString
())
});
StuList
.
Add
(
new
StuScoreModel
()
string
v
=
dt
.
Rows
[
i
][
item
.
Id
.
ToString
()].
ToString
();
if
(
string
.
IsNullOrEmpty
(
v
))
{
msg
=
$"第
{
i
}
行,第
{
item
.
Id
}
题得分为空,请核实后再试"
;
return
new
List
<
ExamQuestionModel
>();
}
//先装姓名
StuList
.
Add
(
new
StuScoreModel
()
{
Name
=
StuName
,
Id
=
item
.
Id
,
Score
=
Convert
.
ToDecimal
(
v
==
""
?
"0"
:
v
)
});
}
if
(
i
<
totalCount
-
1
)
{
Name
=
dt
.
Rows
[
i
][
"题号"
].
ToString
().
Trim
(),
Id
=
-
2
,
Score
=
Convert
.
ToDecimal
(
dt
.
Rows
[
i
][
"排名"
].
ToString
())
});
StuList
.
Add
(
new
StuScoreModel
()
string
z
=
dt
.
Rows
[
i
][
"总分"
].
ToString
();
if
(
string
.
IsNullOrEmpty
(
z
))
{
msg
=
$"第
{
i
}
行,总分为空,请核实后再试"
;
return
new
List
<
ExamQuestionModel
>();
}
//总分 排名 百分比排名
StuList
.
Add
(
new
StuScoreModel
()
{
Name
=
StuName
,
Id
=
-
1
,
Score
=
Convert
.
ToDecimal
(
z
==
""
?
"0"
:
z
)
});
string
p
=
dt
.
Rows
[
i
][
"排名"
].
ToString
();
if
(
string
.
IsNullOrEmpty
(
p
)
&&
StuName
!=
"平均分"
)
{
msg
=
$"第
{
i
}
行,排名为空,请核实后再试"
;
return
new
List
<
ExamQuestionModel
>();
}
StuList
.
Add
(
new
StuScoreModel
()
{
Name
=
StuName
,
Id
=
-
2
,
Score
=
Convert
.
ToDecimal
(
p
==
""
?
"0"
:
p
)
});
string
b
=
dt
.
Rows
[
i
][
"百分比排名"
].
ToString
();
if
(
string
.
IsNullOrEmpty
(
b
)
&&
StuName
!=
"平均分"
)
{
msg
=
$"第
{
i
}
行,百分比排名排名为空,请核实后再试"
;
return
new
List
<
ExamQuestionModel
>();
}
StuList
.
Add
(
new
StuScoreModel
()
{
Name
=
StuName
,
Id
=
-
3
,
Score
=
Convert
.
ToDecimal
(
b
==
""
?
"0"
:
b
)
});
}
if
(
StuName
==
"平均分"
)
{
Name
=
dt
.
Rows
[
i
][
"题号"
].
ToString
().
Trim
(),
Id
=
-
3
,
Score
=
Convert
.
ToDecimal
(
dt
.
Rows
[
i
][
"百分比排名"
].
ToString
())
});
break
;
}
}
}
}
}
return
EQList
;
}
/// <summary>
/// 验证是否为数字
/// </summary>
/// <param name="value"></param>
/// <returns></returns>
public
static
bool
ValidateInt
(
string
value
)
{
return
Regex
.
IsMatch
(
value
,
@"^[0-9]*$"
);
}
}
/// <summary>
...
...
@@ -110,6 +322,16 @@ namespace EduSpider.Utility.Data
/// 分数
/// </summary>
public
decimal
Score
{
get
;
set
;
}
/// <summary>
/// 分组名称
/// </summary>
public
string
GroupName
{
get
;
set
;
}
/// <summary>
/// 列名
/// </summary>
public
string
ColName
{
get
;
set
;
}
}
/// <summary>
...
...
EduSpider.WebApi/Controllers/Student/ExamController.cs
View file @
9f372145
...
...
@@ -45,7 +45,8 @@ namespace EduSpider.WebApi.Controllers
x
.
FailNum
,
x
.
TScore
,
AvgScore
=
x
.
StuNum
>
0
?
Math
.
Round
(
x
.
TScore
/
x
.
StuNum
,
2
,
MidpointRounding
.
AwayFromZero
)
:
0
,
CreateTime
=
x
.
CreateTime
.
ToString
(
"yyyy-MM-dd HH:mm"
)
CreateTime
=
x
.
CreateTime
.
ToString
(
"yyyy-MM-dd HH:mm"
),
x
.
Type
});
return
ApiResult
.
Success
(
""
,
pmodel
);
}
...
...
@@ -92,7 +93,34 @@ namespace EduSpider.WebApi.Controllers
return
ApiResult
.
ParamIsNull
();
}
var
robj
=
ExamService
.
GetExamStuScoreInfo
(
ExamId
,
StuId
,
StuUId
);
var
robj
=
ExamService
.
GetExamStuScoreInfo
(
ExamId
,
StuId
,
StuUId
,
out
string
msg
);
if
(
msg
==
""
)
{
return
ApiResult
.
Success
(
""
,
robj
);
}
else
{
return
ApiResult
.
Failed
(
msg
);
}
}
/// <summary>
/// 获取学生考试明细(分组的)
/// </summary>
/// <returns></returns>
[
HttpPost
]
public
ApiResult
GetExamStuScoreInfo_Group
()
{
int
ExamId
=
ReqParameters
.
GetInt
(
"ExamId"
);
//考试ID
int
StuId
=
ReqParameters
.
GetInt
(
"StuId"
);
//学生id
int
StuUId
=
ReqParameters
.
GetInt
(
"StuUId"
);
//学生Uid
if
(
ExamId
<=
0
||
(
StuId
<=
0
&&
StuUId
<=
0
))
{
return
ApiResult
.
ParamIsNull
();
}
var
robj
=
ExamService
.
GetExamStuScoreInfo_Group
(
ExamId
,
StuId
,
StuUId
);
return
ApiResult
.
Success
(
""
,
robj
);
}
...
...
@@ -122,5 +150,63 @@ namespace EduSpider.WebApi.Controllers
}
}
#
region
统计分析
/// <summary>
/// 新增统计分析
/// </summary>
/// <returns></returns>
[
HttpPost
]
public
ApiResult
SetExamStatAnalysis
()
{
int
CourseId
=
ReqParameters
.
GetInt
(
"CourseId"
);
//课程ID
if
(
CourseId
<=
0
)
{
return
ApiResult
.
ParamIsNull
(
"请传递课程ID"
);
}
if
(
UserInfo
.
AccountType
!=
Utility
.
Enum
.
AccountTypeEnum
.
Teacher
)
{
return
ApiResult
.
ParamIsNull
(
"非老师账户,无法操作"
);
}
string
rmsg
=
ExamService
.
SetExamStatAnalysis
(
CourseId
,
base
.
UserInfo
);
if
(
rmsg
==
""
)
{
return
ApiResult
.
Success
();
}
else
{
return
ApiResult
.
Failed
(
rmsg
);
}
}
/// <summary>
/// 获取统计分析详情
/// </summary>
/// <returns></returns>
[
HttpPost
]
public
ApiResult
GetExamStatAnalysisInfo
()
{
int
ExamId
=
ReqParameters
.
GetInt
(
"ExamId"
);
//考试ID
int
StuId
=
ReqParameters
.
GetInt
(
"StuId"
);
//学生id
int
StuUId
=
ReqParameters
.
GetInt
(
"StuUId"
);
//学生Uid
if
(
ExamId
<=
0
||
(
StuId
<=
0
&&
StuUId
<=
0
))
{
return
ApiResult
.
ParamIsNull
();
}
var
robj
=
ExamService
.
GetExamStatAnalysisInfo
(
ExamId
,
StuId
,
StuUId
,
out
string
msg
);
if
(
msg
==
""
)
{
return
ApiResult
.
Success
(
""
,
robj
);
}
else
{
return
ApiResult
.
Failed
(
msg
);
}
}
#
endregion
}
}
EduSpider.WebApi/Controllers/Upload/UploadController.cs
View file @
9f372145
...
...
@@ -126,10 +126,10 @@ namespace EduSpider.WebApi.Controllers
{
try
{
string
path_server
=
"C:/Users/Administrator/Desktop/TempFile/
化学成绩查询表
.xlsx"
;
string
path_server
=
"C:/Users/Administrator/Desktop/TempFile/
进阶小程序考试导入/初中鸿志班第三次测试3组
.xlsx"
;
#
region
解析文档数据并保存
string
rmsg
=
ExamService
.
ImportExcelForStuExamScore
(
path_server
,
44977497
,
"测试考试化学2"
,
11759328
);
string
rmsg
=
ExamService
.
ImportExcelForStuExamScore
(
path_server
,
208720463
,
"测试考试化学2"
,
646277
);
if
(
rmsg
==
""
)
{
return
ApiResult
.
Success
();
...
...
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