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
bc97ecac
Commit
bc97ecac
authored
May 26, 2022
by
liudong1993
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1
parent
97826a2a
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
287 additions
and
7 deletions
+287
-7
IExamRepository.cs
EduSpider.IRepository/IExamRepository.cs
+2
-1
IExam_QuestionsRepository.cs
EduSpider.IRepository/IExam_QuestionsRepository.cs
+2
-1
IExam_ScoreRepository.cs
EduSpider.IRepository/IExam_ScoreRepository.cs
+2
-1
IExamService.cs
EduSpider.IServices/IExamService.cs
+4
-1
RB_Exam_Extend.cs
EduSpider.Model/Extend/RB_Exam_Extend.cs
+8
-0
RB_Exam_Score_Extend.cs
EduSpider.Model/Extend/RB_Exam_Score_Extend.cs
+40
-0
ExamRepository.cs
EduSpider.Repository/ExamRepository.cs
+33
-0
Exam_QuestionsRepository.cs
EduSpider.Repository/Exam_QuestionsRepository.cs
+16
-1
Exam_ScoreRepository.cs
EduSpider.Repository/Exam_ScoreRepository.cs
+15
-1
ExamService.cs
EduSpider.Services/ExamService.cs
+84
-0
BaseController.cs
EduSpider.WebApi/Controllers/Base/BaseController.cs
+14
-1
ExamController.cs
EduSpider.WebApi/Controllers/Student/ExamController.cs
+67
-0
No files found.
EduSpider.IRepository/IExamRepository.cs
View file @
bc97ecac
using
EduSpider.Model.Entity
;
using
EduSpider.Model.Extend
;
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
...
...
@@ -14,6 +15,6 @@ namespace EduSpider.Repository
/// </summary>
public
interface
IExamRepository
:
IDBRepository
<
RB_Exam
>,
IDependency
{
List
<
RB_Exam_Extend
>
GetExamPageList
(
int
pageIndex
,
int
pageSize
,
out
long
count
,
RB_Exam_Extend
demodel
);
}
}
EduSpider.IRepository/IExam_QuestionsRepository.cs
View file @
bc97ecac
using
EduSpider.Model.Entity
;
using
EduSpider.Model.Extend
;
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
...
...
@@ -14,6 +15,6 @@ namespace EduSpider.Repository
/// </summary>
public
interface
IExam_QuestionsRepository
:
IDBRepository
<
RB_Exam_Questions
>,
IDependency
{
List
<
RB_Exam_Questions_Extend
>
GetList
(
RB_Exam_Questions_Extend
rB_Exam_Questions_Extend
);
}
}
EduSpider.IRepository/IExam_ScoreRepository.cs
View file @
bc97ecac
using
EduSpider.Model.Entity
;
using
EduSpider.Model.Extend
;
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
...
...
@@ -14,6 +15,6 @@ namespace EduSpider.Repository
/// </summary>
public
interface
IExam_ScoreRepository
:
IDBRepository
<
RB_Exam_Score
>,
IDependency
{
List
<
RB_Exam_Score_Extend
>
GetList
(
RB_Exam_Score_Extend
rB_Exam_Score_Extend
);
}
}
EduSpider.IServices/IExamService.cs
View file @
bc97ecac
using
System
;
using
EduSpider.Model.Extend
;
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Text
;
...
...
@@ -13,5 +14,7 @@ namespace EduSpider.IServices
public
interface
IExamService
:
IDependency
{
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
);
}
}
EduSpider.Model/Extend/RB_Exam_Extend.cs
View file @
bc97ecac
...
...
@@ -9,6 +9,14 @@ namespace EduSpider.Model.Extend
/// </summary>
public
class
RB_Exam_Extend
:
RB_Exam
{
/// <summary>
/// 学生数量
/// </summary>
public
int
StuNum
{
get
;
set
;
}
/// <summary>
/// 总分数
/// </summary>
public
decimal
TScore
{
get
;
set
;
}
}
}
EduSpider.Model/Extend/RB_Exam_Score_Extend.cs
View file @
bc97ecac
using
EduSpider.Model.Entity
;
using
System
;
using
System.Collections.Generic
;
using
VTX.FW.Attr
;
namespace
EduSpider.Model.Extend
...
...
@@ -9,6 +10,45 @@ namespace EduSpider.Model.Extend
/// </summary>
public
class
RB_Exam_Score_Extend
:
RB_Exam_Score
{
public
List
<
ExamQScoreModel
>
ScoreList
{
get
;
set
;
}
}
/// <summary>
/// 学生单项分数
/// </summary>
public
class
ExamQScoreModel
{
/// <summary>
/// 题号
/// </summary>
public
int
Sort
{
get
;
set
;
}
/// <summary>
/// 得分
/// </summary>
public
decimal
Score
{
get
;
set
;
}
/// <summary>
/// 平均得分
/// </summary>
public
decimal
AvgScore
{
get
;
set
;
}
/// <summary>
/// 难度
/// </summary>
public
string
Difficulty
{
get
;
set
;
}
/// <summary>
/// 知识点
/// </summary>
public
string
KnowledgePoint
{
get
;
set
;
}
/// <summary>
/// 归属模块
/// </summary>
public
string
Module
{
get
;
set
;
}
/// <summary>
/// 题目分数
/// </summary>
public
decimal
QScore
{
get
;
set
;
}
}
}
EduSpider.Repository/ExamRepository.cs
View file @
bc97ecac
using
EduSpider.Model.Entity
;
using
EduSpider.Model.Extend
;
using
EduSpider.Repository.Base
;
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Text
;
using
System.Threading.Tasks
;
using
VTX.FW.DB.Dapper
;
namespace
EduSpider.Repository
{
...
...
@@ -13,6 +15,37 @@ namespace EduSpider.Repository
/// </summary>
public
class
ExamRepository
:
BaseRepository
<
RB_Exam
>,
IExamRepository
{
/// <summary>
/// 获取分页列表
/// </summary>
/// <param name="pageIndex"></param>
/// <param name="pageSize"></param>
/// <param name="count"></param>
/// <param name="demodel"></param>
/// <returns></returns>
public
List
<
RB_Exam_Extend
>
GetExamPageList
(
int
pageIndex
,
int
pageSize
,
out
long
count
,
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
}
"
;
}
string
sql
=
$@"select e.*,es.StuNum,es.TScore FROM rb_exam e
LEFT JOIN (
SELECT e.ExamId,COUNT(0) as StuNum,SUM(e.TScore) as TScore FROM rb_exam_score e GROUP BY e.ExamId
) es on e.ExamId = es.ExamId
where
{
where
}
order by e.EcamId desc"
;
return
GetPage
<
RB_Exam_Extend
>(
pageIndex
,
pageSize
,
out
count
,
sql
).
ToList
();
}
}
}
EduSpider.Repository/Exam_QuestionsRepository.cs
View file @
bc97ecac
using
EduSpider.Model.Entity
;
using
EduSpider.Model.Extend
;
using
EduSpider.Repository.Base
;
using
System
;
using
System.Collections.Generic
;
...
...
@@ -13,6 +14,20 @@ namespace EduSpider.Repository
/// </summary>
public
class
Exam_QuestionsRepository
:
BaseRepository
<
RB_Exam_Questions
>,
IExam_QuestionsRepository
{
/// <summary>
/// 获取列表
/// </summary>
/// <param name="rB_Exam_Questions_Extend"></param>
/// <returns></returns>
public
List
<
RB_Exam_Questions_Extend
>
GetList
(
RB_Exam_Questions_Extend
dmodel
)
{
string
where
=
" 1=1"
;
if
(
dmodel
.
ExamId
>
0
)
{
where
+=
$" and
{
nameof
(
RB_Exam_Questions_Extend
.
ExamId
)}
=
{
dmodel
.
ExamId
}
"
;
}
string
sql
=
$"select * from RB_Exam_Questions where
{
where
}
"
;
return
Get
<
RB_Exam_Questions_Extend
>(
sql
).
ToList
();
}
}
}
EduSpider.Repository/Exam_ScoreRepository.cs
View file @
bc97ecac
using
EduSpider.Model.Entity
;
using
EduSpider.Model.Extend
;
using
EduSpider.Repository.Base
;
using
System
;
using
System.Collections.Generic
;
...
...
@@ -13,6 +14,19 @@ namespace EduSpider.Repository
/// </summary>
public
class
Exam_ScoreRepository
:
BaseRepository
<
RB_Exam_Score
>,
IExam_ScoreRepository
{
public
List
<
RB_Exam_Score_Extend
>
GetList
(
RB_Exam_Score_Extend
dmodel
)
{
string
where
=
" 1=1"
;
if
(
dmodel
.
ExamId
>
0
)
{
where
+=
$" and
{
nameof
(
RB_Exam_Score_Extend
.
ExamId
)}
=
{
dmodel
.
ExamId
}
"
;
}
if
(
dmodel
.
StuId
>
0
)
{
where
+=
$" and
{
nameof
(
RB_Exam_Score_Extend
.
StuId
)}
=
{
dmodel
.
StuId
}
"
;
}
string
sql
=
$"select * from RB_Exam_Score where
{
where
}
"
;
return
Get
<
RB_Exam_Score_Extend
>(
sql
).
ToList
();
}
}
}
EduSpider.Services/ExamService.cs
View file @
bc97ecac
using
EduSpider.IRepository
;
using
EduSpider.IServices
;
using
EduSpider.Model.Extend
;
using
EduSpider.Repository
;
using
EduSpider.Utility.Data
;
using
System
;
...
...
@@ -44,6 +45,89 @@ namespace EduSpider.Services
[
Autowired
]
private
IStudentRepository
studentRepository
{
get
;
set
;
}
/// <summary>
/// 获取考试分页列表
/// </summary>
/// <param name="pageIndex"></param>
/// <param name="pageSize"></param>
/// <param name="count"></param>
/// <param name="demodel"></param>
/// <returns></returns>
public
List
<
RB_Exam_Extend
>
GetExamPageList
(
int
pageIndex
,
int
pageSize
,
out
long
count
,
RB_Exam_Extend
demodel
)
{
return
examRepository
.
GetExamPageList
(
pageIndex
,
pageSize
,
out
count
,
demodel
);
}
/// <summary>
/// 获取学生考试详情
/// </summary>
/// <param name="examId"></param>
/// <param name="stuId"></param>
/// <returns></returns>
public
object
GetExamStuScoreInfo
(
int
examId
,
int
stuId
)
{
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
.
Module
=
qlist
.
Where
(
x
=>
x
.
Sort
==
qitem
.
Sort
).
FirstOrDefault
()?.
Module
??
""
;
qitem
.
QScore
=
qlist
.
Where
(
x
=>
x
.
Sort
==
qitem
.
Sort
).
FirstOrDefault
()?.
Score
??
0
;
}
}
//开始组装数据
return
new
{
StuId
=
stuModel
.
StudId
,
StuName
=
stuModel
.
StudentName
,
ExamName
=
examModel
.
ExamName
,
sExamModel
?.
TScore
,
sExamModel
?.
Rank
,
sExamModel
?.
RankRate
,
ScoreRate
=
Math
.
Round
((
sExamModel
?.
TScore
??
0
)
/
qlist
.
Sum
(
x
=>
x
.
Score
),
2
,
MidpointRounding
.
AwayFromZero
),
ScoreList
=
sExamModel
?.
ScoreList
.
Select
(
x
=>
new
{
x
.
Sort
,
x
.
Difficulty
,
x
.
KnowledgePoint
,
x
.
QScore
,
x
.
Score
,
ScoreRate
=
Math
.
Round
(
x
.
Score
/
x
.
QScore
,
2
,
MidpointRounding
.
AwayFromZero
),
x
.
AvgScore
,
AvgScoreRate
=
Math
.
Round
(
x
.
AvgScore
/
x
.
QScore
,
2
,
MidpointRounding
.
AwayFromZero
),
}),
ModuleList
=
sExamModel
?.
ScoreList
.
GroupBy
(
x
=>
new
{
x
.
Module
}).
Select
(
x
=>
new
{
x
.
Key
.
Module
,
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
{
x
.
Key
.
Difficulty
,
Count
=
x
.
Count
(),
Score
=
x
.
Sum
(
x
=>
x
.
QScore
)
}),
DifficultyRateList
=
sExamModel
?.
ScoreList
.
GroupBy
(
x
=>
new
{
x
.
Difficulty
}).
Select
(
x
=>
new
{
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>
/// 导入考试成绩
...
...
EduSpider.WebApi/Controllers/Base/BaseController.cs
View file @
bc97ecac
using
Microsoft.AspNetCore.Cors
;
using
EduSpider.Cache.User
;
using
EduSpider.Model.Cache
;
using
Microsoft.AspNetCore.Cors
;
using
Microsoft.AspNetCore.Mvc
;
using
System
;
using
VTX.FW.Helper
;
...
...
@@ -30,5 +32,16 @@ namespace EduSpider.WebApi.Controllers.Base
return
UserId
;
}
}
/// <summary>
/// 获取登录信息
/// </summary>
public
UserInfo
UserInfo
{
get
{
return
UserReidsCache
.
GetUserLoginInfo
(
this
.
BaseUserId
);
}
}
}
}
EduSpider.WebApi/Controllers/Student/ExamController.cs
0 → 100644
View file @
bc97ecac
using
EduSpider.IServices
;
using
EduSpider.Model.Extend
;
using
EduSpider.WebApi.Controllers.Base
;
using
Microsoft.AspNetCore.Mvc
;
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
using
VTX.FW.Api
;
using
VTX.FW.Attr
;
using
VTX.FW.Helper
;
namespace
EduSpider.WebApi.Controllers
{
/// <summary>
/// 考试控制器
/// </summary>
public
class
ExamController
:
BaseController
{
/// <summary>
/// 考试
/// </summary>
[
Autowired
]
public
IExamService
examService
{
get
;
set
;
}
/// <summary>
/// 获取考试分页列表
/// </summary>
/// <returns></returns>
[
HttpPost
]
public
ApiResult
GetExamPageList
()
{
ResultPageModel
pmodel
=
JsonHelper
.
Deserialize
<
ResultPageModel
>(
RequestParm
.
Msg
.
ToString
());
RB_Exam_Extend
demodel
=
JsonHelper
.
Deserialize
<
RB_Exam_Extend
>(
RequestParm
.
Msg
.
ToString
());
var
list
=
examService
.
GetExamPageList
(
pmodel
.
PageIndex
,
pmodel
.
PageSize
,
out
long
count
,
demodel
);
pmodel
.
RowsCount
=
count
;
pmodel
.
PageData
=
list
.
Select
(
x
=>
new
{
x
.
ExamId
,
x
.
ExamName
,
x
.
StuNum
,
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"
)
});
return
ApiResult
.
Success
(
""
,
pmodel
);
}
/// <summary>
/// 获取学生考试明细
/// </summary>
/// <returns></returns>
[
HttpPost
]
public
ApiResult
GetExamStuScoreInfo
()
{
int
ExamId
=
ReqParameters
.
GetInt
(
"ExamId"
);
//考试ID
int
StuId
=
ReqParameters
.
GetInt
(
"StuId"
);
//学生id
if
(
ExamId
<=
0
||
StuId
<=
0
)
{
return
ApiResult
.
ParamIsNull
();
}
var
robj
=
examService
.
GetExamStuScoreInfo
(
ExamId
,
StuId
);
return
ApiResult
.
Success
(
""
,
robj
);
}
}
}
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