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
4e40b8a5
Commit
4e40b8a5
authored
May 31, 2022
by
liudong1993
Browse files
Options
Browse Files
Download
Plain Diff
1
parents
cd1a913b
98504ff4
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
289 additions
and
16 deletions
+289
-16
ICommentRepository.cs
EduSpider.IRepository/ICommentRepository.cs
+7
-0
IStuCommentRepository.cs
EduSpider.IRepository/IStuCommentRepository.cs
+16
-0
ICourseService.cs
EduSpider.IServices/ICourseService.cs
+22
-0
CourseQuery.cs
EduSpider.Model/Query/CourseQuery.cs
+10
-0
CommentRepository.cs
EduSpider.Repository/CommentRepository.cs
+18
-1
StuCommentRepository.cs
EduSpider.Repository/StuCommentRepository.cs
+56
-0
StuHomeWorkRepository.cs
EduSpider.Repository/StuHomeWorkRepository.cs
+7
-7
CourseService.cs
EduSpider.Services/CourseService.cs
+62
-3
TeacherController.cs
EduSpider.WebApi/Controllers/Student/TeacherController.cs
+91
-5
No files found.
EduSpider.IRepository/ICommentRepository.cs
View file @
4e40b8a5
using
EduSpider.Model.Entity
;
using
System.Collections.Generic
;
using
VTX.FW.Config
;
using
VTX.FW.DB
;
...
...
@@ -15,5 +16,11 @@ namespace EduSpider.IRepository
/// <param name="Score"></param>
/// <returns></returns>
public
RB_Comment
GetComment
(
decimal
Score
);
/// <summary>
/// 获取系统配置评价列表
/// </summary>
/// <returns></returns>
public
List
<
RB_Comment
>
GetCommentListRepository
();
}
}
EduSpider.IRepository/IStuCommentRepository.cs
View file @
4e40b8a5
...
...
@@ -33,11 +33,27 @@ namespace EduSpider.IRepository
/// <returns></returns>
public
bool
SetStuCommentShowTypeRepository
(
int
ShowType
,
string
Ids
);
/// <summary>
/// 根据课程评论次数修改可见等级
/// </summary>
/// <param name="CourseId">课程编号</param>
/// <param name="Times">次数</param>
/// <param name="ShowType">可见性</param>
/// <returns></returns>
public
bool
SetStuCommentShowTypeByTimesRepository
(
int
CourseId
,
int
Times
,
int
ShowType
);
/// <summary>
/// 根据编号删除学员评论
/// </summary>
/// <param name="Ids"></param>
/// <returns></returns>
public
bool
DeleteStuCommentRepository
(
string
Ids
);
/// <summary>
/// 获取系统生成评论次数
/// </summary>
/// <param name="query"></param>
/// <returns></returns>
public
List
<
RB_Stu_Comment
>
GetCourseCommentTimesListRepository
(
CourseQuery
query
);
}
}
EduSpider.IServices/ICourseService.cs
View file @
4e40b8a5
...
...
@@ -102,11 +102,33 @@ namespace EduSpider.IServices
/// <returns></returns>
public
bool
SetStuCommentShowType
(
int
ShowType
,
string
Ids
);
/// <summary>
/// 根据课程评论次数修改可见等级
/// </summary>
/// <param name="CourseId">课程编号</param>
/// <param name="Times">次数</param>
/// <param name="ShowType">可见性</param>
/// <returns></returns>
public
bool
SetStuCommentShowTypeByTimes
(
int
CourseId
,
int
Times
,
int
ShouType
);
/// <summary>
/// 根据编号删除学员评论
/// </summary>
/// <param name="Ids"></param>
/// <returns></returns>
public
bool
RemoveStuComment
(
string
Ids
);
/// <summary>
/// 获取系统生成评论次数
/// </summary>
/// <param name="query"></param>
/// <returns></returns>
public
List
<
RB_Stu_Comment
>
GetCourseCommentTimesList
(
CourseQuery
query
);
/// <summary>
/// 获取系统评价配置
/// </summary>
/// <returns></returns>
public
List
<
RB_Comment
>
GetSysComment
();
}
}
EduSpider.Model/Query/CourseQuery.cs
View file @
4e40b8a5
...
...
@@ -44,5 +44,15 @@
/// 作业编号
/// </summary>
public
int
HomeWorkId
{
get
;
set
;
}
/// <summary>
/// 创建类型(1-系统创建,2-老师创建)
/// </summary>
public
int
CreateCommentType
{
get
;
set
;
}
/// <summary>
/// 评论次数
/// </summary>
public
int
CommentTimes
{
get
;
set
;
}
}
}
EduSpider.Repository/CommentRepository.cs
View file @
4e40b8a5
using
EduSpider.IRepository
;
using
EduSpider.Model.Entity
;
using
EduSpider.Repository.Base
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Text
;
using
VTX.FW.DB.Dapper
;
...
...
@@ -36,5 +37,21 @@ WHERE 1=1
return
base
.
Get
<
RB_Comment
>(
builder
.
ToString
()).
ToList
().
FirstOrDefault
();
}
/// <summary>
/// 获取系统配置评价列表
/// </summary>
/// <returns></returns>
public
List
<
RB_Comment
>
GetCommentListRepository
()
{
StringBuilder
builder
=
new
();
builder
.
AppendFormat
(
@"
SELECT A.*
FROM RB_Comment AS A
WHERE 1=1
"
);
return
base
.
Get
<
RB_Comment
>(
builder
.
ToString
()).
ToList
();
}
}
}
EduSpider.Repository/StuCommentRepository.cs
View file @
4e40b8a5
...
...
@@ -44,6 +44,10 @@ WHERE 1=1
{
builder
.
AppendFormat
(
" AND A.{0}={1} "
,
nameof
(
RB_Stu_Comment
.
HomeWorkId
),
query
.
HomeWorkId
);
}
if
(
query
.
CommentTimes
>
0
)
{
builder
.
AppendFormat
(
" AND A.{0} IN({1}) "
,
nameof
(
RB_Stu_Comment
.
Times
),
query
.
CommentTimes
);
}
}
return
Get
<
RB_Stu_Comment
>(
builder
.
ToString
()).
ToList
();
}
...
...
@@ -85,6 +89,19 @@ WHERE 1=1
return
base
.
Execute
(
sql
)
>
0
;
}
/// <summary>
/// 根据课程评论次数修改可见等级
/// </summary>
/// <param name="CourseId">课程编号</param>
/// <param name="Times">次数</param>
/// <param name="ShowType">可见性</param>
/// <returns></returns>
public
bool
SetStuCommentShowTypeByTimesRepository
(
int
CourseId
,
int
Times
,
int
ShowType
)
{
string
sql
=
string
.
Format
(
"UPDATE RB_Stu_Comment SET ShowType={0} WHERE CourseId={1} AND Times={2}"
,
ShowType
,
CourseId
,
Times
);
return
base
.
Execute
(
sql
)
>
0
;
}
/// <summary>
/// 根据编号删除学员评论
/// </summary>
...
...
@@ -95,5 +112,44 @@ WHERE 1=1
string
sql
=
string
.
Format
(
"UPDATE RB_Stu_Comment SET Status=1 WHERE Id IN({0}) "
,
Ids
);
return
base
.
Execute
(
sql
)
>
0
;
}
/// <summary>
/// 获取系统生成评论次数
/// </summary>
/// <param name="query"></param>
/// <returns></returns>
public
List
<
RB_Stu_Comment
>
GetCourseCommentTimesListRepository
(
CourseQuery
query
)
{
StringBuilder
builder
=
new
();
builder
.
AppendFormat
(
@"
SELECT A.Times,A.CourseId,MAX(CreateTime) AS CreateTime,CreateType
FROM RB_Stu_Comment AS A
WHERE 1=1
"
);
builder
.
AppendFormat
(
" AND A.{0}=0 "
,
nameof
(
RB_Stu_Comment
.
Status
));
if
(
query
!=
null
)
{
if
(
query
.
CourseId
>
0
)
{
builder
.
AppendFormat
(
" AND A.{0}={1} "
,
nameof
(
RB_Stu_Comment
.
CourseId
),
query
.
CourseId
);
}
if
(!
string
.
IsNullOrWhiteSpace
(
query
.
StuIds
))
{
builder
.
AppendFormat
(
" AND A.{0} IN({1}) "
,
nameof
(
RB_Stu_Comment
.
StuUid
),
query
.
StuIds
);
}
if
(
query
.
HomeWorkId
>
0
)
{
builder
.
AppendFormat
(
" AND A.{0}={1} "
,
nameof
(
RB_Stu_Comment
.
HomeWorkId
),
query
.
HomeWorkId
);
}
if
(
query
.
CreateCommentType
>
0
)
{
builder
.
AppendFormat
(
" AND A.{0}={1} "
,
nameof
(
RB_Stu_Comment
.
CreateType
),
query
.
CreateCommentType
);
}
}
builder
.
AppendFormat
(
@" GROUP BY A.Times,A.CourseId "
);
return
Get
<
RB_Stu_Comment
>(
builder
.
ToString
()).
ToList
();
}
}
}
EduSpider.Repository/StuHomeWorkRepository.cs
View file @
4e40b8a5
...
...
@@ -125,7 +125,7 @@ WHERE 1=1
if
(
homeWorkList
.
Count
>=
5
)
{
var
firstList
=
homeWorkList
.
Where
(
qitem
=>
qitem
.
RowNum
<=
5
).
ToList
();
var
firstFlag
=
firstList
.
Where
(
qitem
=>
qitem
.
HomeWorkStatus
==
0
).
Count
()
>
0
;
var
firstFlag
=
firstList
.
Where
(
qitem
=>
qitem
.
HomeWorkStatus
==
0
).
Any
()
;
//第一阶段有未提交的作业就不生成系统评价
if
(!
firstFlag
)
{
...
...
@@ -169,7 +169,7 @@ WHERE 1=1
if
(
homeWorkList
.
Count
>=
9
)
{
var
secondList
=
homeWorkList
.
Where
(
qitem
=>
qitem
.
RowNum
>
5
&&
qitem
.
RowNum
<=
9
).
ToList
();
var
secondFlag
=
secondList
.
Where
(
qitem
=>
qitem
.
HomeWorkStatus
==
0
).
Count
()
>
0
;
var
secondFlag
=
secondList
.
Where
(
qitem
=>
qitem
.
HomeWorkStatus
==
0
).
Any
()
;
if
(!
secondFlag
)
{
var
secondScore
=
secondList
.
Average
(
qitem
=>
qitem
.
Score_p
)
*
100
;
...
...
@@ -212,7 +212,7 @@ WHERE 1=1
if
(
homeWorkList
.
Count
>=
13
)
{
var
thirdList
=
homeWorkList
.
Where
(
qitem
=>
qitem
.
RowNum
>
9
&&
qitem
.
RowNum
<=
13
).
ToList
();
var
thirdFlag
=
thirdList
.
Where
(
qitem
=>
qitem
.
HomeWorkStatus
==
0
).
Count
()
>
0
;
var
thirdFlag
=
thirdList
.
Where
(
qitem
=>
qitem
.
HomeWorkStatus
==
0
).
Any
()
;
if
(!
thirdFlag
)
{
var
thirdScore
=
thirdList
.
Average
(
qitem
=>
qitem
.
Score_p
)
*
100
;
...
...
@@ -290,9 +290,9 @@ WHERE 1=1
/// 生成随机数
/// </summary>
/// <returns></returns>
private
int
CreateRandomNum
()
private
static
int
CreateRandomNum
()
{
Random
rnd
=
new
Random
();
Random
rnd
=
new
();
return
rnd
.
Next
(
5
,
20
);
}
...
...
@@ -303,9 +303,9 @@ WHERE 1=1
/// <param name="CourseId"></param>
/// <param name="Stu_HomeWork_Id"></param>
/// <returns></returns>
private
RB_Stu_Comment
GetSystemCreateComment
(
List
<
RB_Stu_Comment
>
commentList
,
int
CourseId
,
int
Stu_HomeWork_Id
)
private
static
RB_Stu_Comment
GetSystemCreateComment
(
List
<
RB_Stu_Comment
>
commentList
,
int
CourseId
,
int
Stu_HomeWork_Id
)
{
var
tempModel
=
commentList
.
Where
(
qitem
=>
qitem
.
CourseId
==
qitem
.
CourseId
&&
qitem
.
HomeWorkId
==
Stu_HomeWork_Id
&&
qitem
.
CreateType
==
1
).
FirstOrDefault
();
var
tempModel
=
commentList
.
Where
(
qitem
=>
qitem
.
CourseId
==
CourseId
&&
qitem
.
HomeWorkId
==
Stu_HomeWork_Id
&&
qitem
.
CreateType
==
1
).
FirstOrDefault
();
return
tempModel
;
}
...
...
EduSpider.Services/CourseService.cs
View file @
4e40b8a5
...
...
@@ -249,7 +249,7 @@ namespace EduSpider.Services
public
object
GetHomeWorkDetails
(
CourseQuery
query
)
{
List
<
object
>
result
=
new
();
var
HomeWork
=
HomeWorkRepository
.
GetCourseHomeWorkListRepository
(
query
).
FirstOrDefault
();
var
HomeWork
=
HomeWorkRepository
.
GetCourseHomeWorkListRepository
(
query
).
FirstOrDefault
();
var
list
=
StuHomeWorkRepository
.
GetStuHomeWorkDetailsListRepository
(
query
);
if
(
list
!=
null
&&
list
.
Count
>
0
)
{
...
...
@@ -277,7 +277,7 @@ namespace EduSpider.Services
item
.
student_name
,
item
.
student_uid
,
item
.
score
,
score_p
=
item
.
score_p
*
100
,
score_p
=
item
.
score_p
*
100
,
add_time
=
VTX
.
FW
.
Helper
.
ConvertHelper
.
FormatDate
(
item
.
add_time
)
});
}
...
...
@@ -368,6 +368,19 @@ namespace EduSpider.Services
return
StuCommentRepository
.
SetStuCommentShowTypeRepository
(
ShowType
,
Ids
);
}
/// <summary>
/// 根据课程评论次数修改可见等级
/// </summary>
/// <param name="CourseId">课程编号</param>
/// <param name="Times">次数</param>
/// <param name="ShowType">可见性</param>
/// <returns></returns>
public
bool
SetStuCommentShowTypeByTimes
(
int
CourseId
,
int
Times
,
int
ShowType
)
{
return
StuCommentRepository
.
SetStuCommentShowTypeByTimesRepository
(
CourseId
,
Times
,
ShowType
);
}
/// <summary>
/// 根据编号删除学员评论
/// </summary>
...
...
@@ -377,6 +390,52 @@ namespace EduSpider.Services
{
return
StuCommentRepository
.
DeleteStuCommentRepository
(
Ids
);
}
/// <summary>
/// 获取系统生成评论次数
/// </summary>
/// <param name="query"></param>
/// <returns></returns>
public
List
<
RB_Stu_Comment
>
GetCourseCommentTimesList
(
CourseQuery
query
)
{
var
list
=
StuCommentRepository
.
GetCourseCommentTimesListRepository
(
query
);
if
(
list
!=
null
&&
list
.
Count
>
0
)
{
foreach
(
var
item
in
list
)
{
int
ShowType
=
3
;
var
subList
=
StuCommentRepository
.
GetStuCommentListRepository
(
new
CourseQuery
()
{
CourseId
=
item
.
CourseId
,
CommentTimes
=
item
.
Times
});
if
(
subList
!=
null
&&
subList
.
Count
>
0
)
{
var
totalCount
=
subList
.
Count
();
if
(
subList
.
Where
(
qitem
=>
qitem
.
ShowType
==
1
).
Count
()
==
totalCount
)
{
ShowType
=
1
;
}
else
if
(
subList
.
Where
(
qitem
=>
qitem
.
ShowType
==
3
).
Count
()
==
totalCount
)
{
ShowType
=
3
;
}
else
{
ShowType
=
2
;
}
}
item
.
ShowType
=
ShowType
;
}
}
return
list
;
}
}
/// <summary>
/// 获取系统评价配置
/// </summary>
/// <returns></returns>
public
List
<
RB_Comment
>
GetSysComment
()
{
var
list
=
CommentRepository
.
GetCommentListRepository
();
return
list
;
}
}
}
EduSpider.WebApi/Controllers/Student/TeacherController.cs
View file @
4e40b8a5
...
...
@@ -138,19 +138,41 @@ namespace EduSpider.WebApi.Controllers
}
/// <summary>
/// 获取课程
评语列表
/// 获取课程
配置评价信息
/// </summary>
/// <returns></returns>
[
HttpPost
]
[
HttpGet
]
public
ApiResult
GetCourseComment
List
()
public
ApiResult
GetCourseComment
()
{
var
query
=
new
Model
.
Query
.
CourseQuery
()
{
CourseId
=
base
.
ReqParameters
.
GetInt
(
"CourseId"
)
};
var
list
=
CourseService
.
GetCourseCommentList
(
query
);
return
ApiResult
.
Success
(
data
:
list
);
var
courseRule
=
CourseService
.
GetCourseCommentList
(
query
).
FirstOrDefault
();
object
result
;
if
(
courseRule
!=
null
)
{
result
=
new
{
courseRule
.
Id
,
courseRule
.
Title
,
courseRule
.
CourseId
,
courseRule
.
CommentDetails
};
}
else
{
var
sysList
=
CourseService
.
GetSysComment
();
result
=
new
{
Id
=
0
,
Title
=
"系统默认配置"
,
CourseId
=
0
,
CommentDetails
=
sysList
};
}
return
ApiResult
.
Success
(
data
:
result
);
}
/// <summary>
...
...
@@ -272,6 +294,70 @@ namespace EduSpider.WebApi.Controllers
}
[
HttpPost
]
[
HttpGet
]
/// <summary>
/// 设置学员评论可见性
/// </summary>
/// <returns></returns>
public
ApiResult
SetStuCommentShowTypeByTimes
()
{
int
CourseId
=
base
.
ReqParameters
.
GetInt
(
"CourseId"
);
int
Times
=
base
.
ReqParameters
.
GetInt
(
"Times"
);
int
ShowType
=
base
.
ReqParameters
.
GetInt
(
"ShowType"
);
var
flag
=
CourseService
.
SetStuCommentShowTypeByTimes
(
CourseId
,
Times
,
ShowType
);
;
return
flag
?
ApiResult
.
Success
()
:
ApiResult
.
Failed
();
}
[
HttpPost
]
[
HttpGet
]
/// <summary>
/// 获取课程已经生成的评论统计列表
/// </summary>
/// <returns></returns>
public
ApiResult
GetCourseCommentTimes
()
{
var
query
=
new
CourseQuery
()
{
CourseId
=
base
.
ReqParameters
.
GetInt
(
"CourseId"
),
CreateCommentType
=
1
};
List
<
object
>
result
=
new
();
var
list
=
CourseService
.
GetCourseCommentTimesList
(
query
);
if
(
list
!=
null
&&
list
.
Count
>
0
)
{
foreach
(
var
item
in
list
)
{
string
ShowTypeStr
=
""
;
if
(
item
.
ShowType
==
1
)
{
ShowTypeStr
=
"全部可见"
;
}
else
if
(
item
.
ShowType
==
2
)
{
ShowTypeStr
=
"部分可见"
;
}
else
if
(
item
.
ShowType
==
3
)
{
ShowTypeStr
=
"不可见"
;
}
result
.
Add
(
new
{
item
.
Times
,
item
.
CourseId
,
item
.
CreateType
,
CreateTypeStr
=
item
.
CreateType
==
1
?
"系统创建"
:
"老师创建"
,
item
.
ShowType
,
ShowTypeStr
,
CreateTime
=
VTX
.
FW
.
Helper
.
ConvertHelper
.
FormatDate
(
item
.
CreateTime
),
optionsShow
=
false
,
});
}
}
return
ApiResult
.
Success
(
data
:
result
);
}
[
HttpPost
]
[
HttpGet
]
/// <summary>
...
...
@@ -282,7 +368,7 @@ namespace EduSpider.WebApi.Controllers
{
var
query
=
new
CourseQuery
()
{
CourseId
=
base
.
ReqParameters
.
GetInt
(
"CourseId"
)
};
var
list
=
CourseService
.
GetStuCommentList
(
query
);
return
ApiResult
.
Success
(
data
:
list
);
...
...
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