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
58db7150
Commit
58db7150
authored
Jun 06, 2022
by
黄奎
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
页面修改
parent
8a800efb
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
323 additions
and
217 deletions
+323
-217
ICommentRepository.cs
EduSpider.IRepository/ICommentRepository.cs
+2
-7
IStuCommentRepository.cs
EduSpider.IRepository/IStuCommentRepository.cs
+1
-1
IStuHomeWorkRepository.cs
EduSpider.IRepository/IStuHomeWorkRepository.cs
+9
-8
ICourseService.cs
EduSpider.IServices/ICourseService.cs
+2
-2
RB_Stu_Comment.cs
EduSpider.Model/Entity/RB_Stu_Comment.cs
+2
-0
CourseQuery.cs
EduSpider.Model/Query/CourseQuery.cs
+15
-0
CommentRepository.cs
EduSpider.Repository/CommentRepository.cs
+23
-46
StuCommentRepository.cs
EduSpider.Repository/StuCommentRepository.cs
+103
-2
StuHomeWorkRepository.cs
EduSpider.Repository/StuHomeWorkRepository.cs
+118
-114
CourseService.cs
EduSpider.Services/CourseService.cs
+4
-4
TeacherController.cs
EduSpider.WebApi/Controllers/Student/TeacherController.cs
+44
-33
No files found.
EduSpider.IRepository/ICommentRepository.cs
View file @
58db7150
using
EduSpider.Model.Entity
;
using
EduSpider.Model.Extend
;
using
EduSpider.Model.Query
;
using
System.Collections.Generic
;
using
VTX.FW.Config
;
using
VTX.FW.DB
;
...
...
@@ -11,17 +12,11 @@ namespace EduSpider.IRepository
/// </summary>
public
interface
ICommentRepository
:
IDBRepository
<
RB_Comment
>,
IDependency
{
/// <summary>
/// 新增修改默认配置
/// </summary>
/// <param name="model"></param>
/// <returns></returns>
public
bool
SetCommentRepository
(
RB_Comment_Extend
model
);
/// <summary>
/// 获取系统配置评价列表
/// </summary>
/// <returns></returns>
public
RB_Comment_Extend
GetCommentListRepository
(
string
KeyWords
,
int
CommentTimes
);
public
List
<
RB_Comment_Extend
>
GetCommentListRepository
(
CourseQuery
query
);
}
}
EduSpider.IRepository/IStuCommentRepository.cs
View file @
58db7150
...
...
@@ -24,7 +24,7 @@ namespace EduSpider.IRepository
/// </summary>
/// <param name="list"></param>
/// <returns></returns>
public
bool
BatchSetStuCommentRepository
(
List
<
RB_Stu_Comment
>
list
);
public
bool
BatchSetStuCommentRepository
(
List
<
RB_Stu_Comment
>
list
,
StuCommentType
commentType
);
/// <summary>
...
...
EduSpider.IRepository/IStuHomeWorkRepository.cs
View file @
58db7150
...
...
@@ -19,6 +19,14 @@ namespace EduSpider.IRepository
/// <returns></returns>
public
bool
BatchSetStuHomeWorkRepository
(
List
<
RB_Stu_HomeWork
>
homeWorks
);
/// <summary>
/// 获取家庭作业列表
/// </summary>
/// <param name="query"></param>
/// <returns></returns>
public
List
<
RB_Stu_HomeWork_Extend
>
GetStuHomeWorkDetailsListRepository
(
CourseQuery
query
);
/// <summary>
/// 创建课程作业评论
/// </summary>
...
...
@@ -31,12 +39,5 @@ namespace EduSpider.IRepository
/// </summary>
/// <returns></returns>
public
List
<
ExamWorkResult
>
GetStuHomeWorkListRepository
(
CourseQuery
query
);
/// <summary>
/// 获取家庭作业列表
/// </summary>
/// <param name="query"></param>
/// <returns></returns>
public
List
<
RB_Stu_HomeWork_Extend
>
GetStuHomeWorkDetailsListRepository
(
CourseQuery
query
);
}
}
\ No newline at end of file
EduSpider.IServices/ICourseService.cs
View file @
58db7150
...
...
@@ -92,7 +92,7 @@ namespace EduSpider.IServices
/// </summary>
/// <param name="list"></param>
/// <returns></returns>
public
bool
BatchSetStuComment
(
List
<
RB_Stu_Comment
>
list
);
public
bool
BatchSetStuComment
(
List
<
RB_Stu_Comment
>
list
,
StuCommentType
commentType
);
/// <summary>
/// 获取学员评价列表
...
...
@@ -136,7 +136,7 @@ namespace EduSpider.IServices
/// 获取系统评价配置
/// </summary>
/// <returns></returns>
public
RB_Comment_Extend
GetSysComment
(
string
KeyWords
,
int
CommentTimes
);
public
List
<
RB_Comment_Extend
>
GetSysComment
(
CourseQuery
query
);
/// <summary>
/// 创建课程作业评论
...
...
EduSpider.Model/Entity/RB_Stu_Comment.cs
View file @
58db7150
...
...
@@ -75,4 +75,6 @@ namespace EduSpider.Model.Entity
/// </summary>
public
int
Status
{
get
;
set
;
}
}
}
EduSpider.Model/Query/CourseQuery.cs
View file @
58db7150
...
...
@@ -45,6 +45,16 @@
/// </summary>
public
int
HomeWorkId
{
get
;
set
;
}
/// <summary>
/// 开始作业编号
/// </summary>
public
int
StartHomeWorkId
{
get
;
set
;
}
/// <summary>
/// 结束作业编号
/// </summary>
public
int
EndHomeWorkId
{
get
;
set
;
}
/// <summary>
/// 创建类型(1-系统创建,2-老师创建)
/// </summary>
...
...
@@ -54,5 +64,10 @@
/// 评论次数
/// </summary>
public
int
CommentTimes
{
get
;
set
;
}
/// <summary>
/// 默认评价编号
/// </summary>
public
int
DefaultCommentId
{
get
;
set
;
}
}
}
EduSpider.Repository/CommentRepository.cs
View file @
58db7150
using
EduSpider.IRepository
;
using
EduSpider.Model.Entity
;
using
EduSpider.Model.Extend
;
using
EduSpider.Model.Query
;
using
EduSpider.Repository.Base
;
using
System.Collections.Generic
;
using
System.Linq
;
...
...
@@ -18,46 +19,14 @@ namespace EduSpider.Repository
/// <summary>
/// 默认评论详情接口
/// </summary>
I
CommentDetailsRepository
commentDetailsRepository
=
new
CommentDetailsRepository
();
CommentDetailsRepository
commentDetailsRepository
=
new
CommentDetailsRepository
();
/// <summary>
/// 新增修改默认配置
/// </summary>
/// <param name="model"></param>
/// <returns></returns>
public
bool
SetCommentRepository
(
RB_Comment_Extend
model
)
{
bool
flag
=
false
;
if
(
model
.
Id
>
0
)
{
Dictionary
<
string
,
object
>
fileds
=
new
Dictionary
<
string
,
object
>()
{
{
nameof
(
RB_Comment_Extend
.
KeyWords
),
model
.
KeyWords
.
Trim
()
}
};
flag
=
base
.
UpdateOne
(
fileds
,
new
WhereHelper
(
nameof
(
RB_Comment_Extend
.
Id
),
model
.
Id
));
}
else
{
var
newId
=
base
.
Insert
(
model
);
model
.
Id
=
newId
;
flag
=
newId
>
0
;
}
if
(
model
.
Details
!=
null
&&
model
.
Details
.
Count
>
0
)
{
foreach
(
var
item
in
model
.
Details
)
{
item
.
CommentId
=
model
.
Id
;
}
commentDetailsRepository
.
BatchSetCommentDetailsRepository
(
model
.
Details
);
}
return
flag
;
}
/// <summary>
/// 获取系统配置评价列表
/// </summary>
/// <returns></returns>
public
RB_Comment_Extend
GetCommentListRepository
(
string
KeyWords
,
int
CommentTimes
)
public
List
<
RB_Comment_Extend
>
GetCommentListRepository
(
CourseQuery
query
)
{
DynamicParameters
parameters
=
new
DynamicParameters
();
StringBuilder
builder
=
new
();
...
...
@@ -66,45 +35,53 @@ SELECT A.*
FROM RB_Comment AS A
WHERE 1=1
"
);
if
(!
string
.
IsNullOrEmpty
(
KeyWords
))
if
(!
string
.
IsNullOrEmpty
(
query
.
KeyWords
))
{
if
(
KeyWords
.
Contains
(
"高"
))
if
(
query
.
KeyWords
.
Contains
(
"高"
))
{
builder
.
AppendFormat
(
" AND A.{0} LIKE @KeyWords1 "
,
nameof
(
RB_Comment_Extend
.
KeyWords
));
parameters
.
Add
(
"KeyWords1"
,
"%高%"
);
}
if
(
KeyWords
.
Contains
(
"初"
))
if
(
query
.
KeyWords
.
Contains
(
"初"
))
{
builder
.
AppendFormat
(
" AND A.{0} LIKE @KeyWords2 "
,
nameof
(
RB_Comment_Extend
.
KeyWords
));
parameters
.
Add
(
"KeyWords2"
,
"%初%"
);
}
if
(
KeyWords
.
Contains
(
"化学"
))
if
(
query
.
KeyWords
.
Contains
(
"化学"
))
{
builder
.
AppendFormat
(
" AND A.{0} LIKE @KeyWords3 "
,
nameof
(
RB_Comment_Extend
.
KeyWords
));
parameters
.
Add
(
"KeyWords3"
,
"%化学%"
);
}
if
(
KeyWords
.
Contains
(
"数学"
))
if
(
query
.
KeyWords
.
Contains
(
"数学"
))
{
builder
.
AppendFormat
(
" AND A.{0} LIKE @KeyWords4 "
,
nameof
(
RB_Comment_Extend
.
KeyWords
));
parameters
.
Add
(
"KeyWords4"
,
"%数学%"
);
}
}
if
(
CommentTimes
>
0
)
if
(
query
.
CommentTimes
>
0
)
{
builder
.
AppendFormat
(
" AND A.{0}={1} "
,
nameof
(
RB_Comment_Extend
.
Times
),
CommentTimes
);
builder
.
AppendFormat
(
" AND A.{0}={1} "
,
nameof
(
RB_Comment_Extend
.
Times
),
query
.
CommentTimes
);
}
var
model
=
base
.
Get
<
RB_Comment_Extend
>(
builder
.
ToString
(),
parameters
).
ToList
().
FirstOrDefault
();
if
(
model
!=
null
&&
model
.
Id
>
0
)
if
(
query
.
DefaultCommentId
>
0
)
{
string
Ids
=
model
.
Id
.
ToString
();
builder
.
AppendFormat
(
" AND A.{0}={1} "
,
nameof
(
RB_Comment_Extend
.
Id
),
query
.
DefaultCommentId
);
}
var
list
=
base
.
Get
<
RB_Comment_Extend
>(
builder
.
ToString
(),
parameters
).
ToList
();
if
(
list
!=
null
&&
list
.
Count
>
0
)
{
string
Ids
=
string
.
Join
(
","
,
list
.
Select
(
qitem
=>
qitem
.
Id
));
List
<
RB_Comment_Details
>
subList
=
new
List
<
RB_Comment_Details
>();
if
(!
string
.
IsNullOrEmpty
(
Ids
))
{
subList
=
commentDetailsRepository
.
GetCommentDetailsListRepository
(
Ids
);
}
model
.
Details
=
subList
?.
Where
(
qitem
=>
qitem
.
CommentId
==
model
.
Id
)?.
OrderBy
(
qitem
=>
qitem
.
StartNum
)?.
ToList
();
foreach
(
var
item
in
list
)
{
item
.
Details
=
subList
?.
Where
(
qitem
=>
qitem
.
CommentId
==
item
.
Id
)?.
OrderBy
(
qitem
=>
qitem
.
StartNum
)?.
ToList
();
}
}
return
model
;
return
list
;
}
}
}
EduSpider.Repository/StuCommentRepository.cs
View file @
58db7150
...
...
@@ -17,6 +17,8 @@ namespace EduSpider.Repository
/// </summary>
public
class
StuCommentRepository
:
BaseRepository
<
RB_Stu_Comment
>,
IStuCommentRepository
{
/// <summary>
/// 获取学员评语列表
/// </summary>
...
...
@@ -45,6 +47,14 @@ WHERE 1=1
{
builder
.
AppendFormat
(
" AND A.{0}={1} "
,
nameof
(
RB_Stu_Comment
.
HomeWorkId
),
query
.
HomeWorkId
);
}
if
(
query
.
StartHomeWorkId
>
0
)
{
builder
.
AppendFormat
(
" AND A.{0}>={1} "
,
nameof
(
RB_Stu_Comment
.
HomeWorkId
),
query
.
StartHomeWorkId
);
}
if
(
query
.
EndHomeWorkId
>
0
)
{
builder
.
AppendFormat
(
" AND A.{0}<={1} "
,
nameof
(
RB_Stu_Comment
.
HomeWorkId
),
query
.
EndHomeWorkId
);
}
if
(
query
.
CommentTimes
>
0
)
{
builder
.
AppendFormat
(
" AND A.{0} IN({1}) "
,
nameof
(
RB_Stu_Comment
.
Times
),
query
.
CommentTimes
);
...
...
@@ -83,10 +93,99 @@ WHERE 1=1
/// </summary>
/// <param name="list"></param>
/// <returns></returns>
public
bool
BatchSetStuCommentRepository
(
List
<
RB_Stu_Comment
>
list
)
public
bool
BatchSetStuCommentRepository
(
List
<
RB_Stu_Comment
>
list
,
StuCommentType
commentType
)
{
bool
flag
=
false
;
// 以前批量添加接口
if
(
commentType
!=
null
)
{
if
(
commentType
.
CommentType
==
2
)
{
flag
=
AddTemplateStuComment
(
list
,
commentType
.
IsDefault
,
commentType
.
CommentId
);
}
else
{
flag
=
AddDefaultStuComment
(
list
);
}
}
else
{
flag
=
AddDefaultStuComment
(
list
);
}
return
flag
;
}
/// <summary>
/// 根据模板生成评价
/// </summary>
/// <param name="list"></param>
/// <param name="IsDefault"></param>
/// <param name="CommentId"></param>
/// <returns></returns>
private
bool
AddTemplateStuComment
(
List
<
RB_Stu_Comment
>
list
,
int
IsDefault
,
int
CommentId
)
{
bool
flag
=
false
;
if
(
list
!=
null
&&
list
.
Count
>
0
)
{
var
homeworkList
=
new
StuHomeWorkRepository
().
GetStuHomeWorkDetailsListRepository
(
new
CourseQuery
()
{
CourseId
=
list
[
0
].
CourseId
,
StartHomeWorkId
=
list
[
0
].
StartHomeWorkId
,
EndHomeWorkId
=
list
[
0
].
HomeWorkId
});
var
courseComment
=
new
RB_Course_Comment_Extend
();
var
defaultComment
=
new
RB_Comment_Extend
();
if
(
IsDefault
==
1
)
{
defaultComment
=
new
CommentRepository
().
GetCommentListRepository
(
new
CourseQuery
()
{
DefaultCommentId
=
CommentId
}).
FirstOrDefault
();
}
else
{
courseComment
=
new
CourseCommentRepository
().
GetCourseCommentListRepository
(
new
CourseQuery
()
{
CourseId
=
list
[
0
].
CourseId
}).
Where
(
qitem
=>
qitem
.
Id
==
CommentId
).
FirstOrDefault
();
}
foreach
(
var
item
in
list
)
{
var
tempList
=
homeworkList
.
Where
(
qitem
=>
qitem
.
student_uid
==
item
.
StuUid
).
ToList
();
item
.
CreateTime
=
tempList
.
LastOrDefault
().
add_time
.
AddSeconds
(
1
);
var
Score
=
tempList
.
Sum
(
qitem
=>
qitem
.
score_p
)
*
100
;
string
info
=
""
;
if
(
IsDefault
==
1
)
{
if
(
defaultComment
!=
null
&&
defaultComment
.
Details
!=
null
&&
defaultComment
.
Details
.
Count
>
0
)
{
var
tempModel
=
defaultComment
.
Details
.
Where
(
qitem
=>
qitem
.
StartNum
<=
Score
&&
Score
<
qitem
.
EndNum
)?.
FirstOrDefault
();
if
(
tempModel
!=
null
)
{
info
=
tempModel
?.
Info
??
""
;
}
}
}
else
{
if
(
courseComment
!=
null
&&
courseComment
.
CommentDetails
!=
null
&&
courseComment
.
CommentDetails
.
Count
>
0
)
{
var
tempModel
=
courseComment
.
CommentDetails
.
Where
(
qitem
=>
qitem
.
StartNum
<=
Score
&&
Score
<
qitem
.
EndNum
)?.
FirstOrDefault
();
if
(
tempModel
!=
null
)
{
info
=
tempModel
?.
Info
??
""
;
}
}
}
item
.
Info
=
info
;
flag
=
base
.
Insert
(
item
)
>
0
;
}
}
return
flag
;
}
/// <summary>
/// 自定义添加评价
/// </summary>
/// <param name="list"></param>
/// <returns></returns>
private
bool
AddDefaultStuComment
(
List
<
RB_Stu_Comment
>
list
)
{
bool
flag
=
false
;
foreach
(
var
item
in
list
)
{
var
defaultModel
=
GetStuCommentListRepository
(
new
CourseQuery
()
...
...
@@ -94,7 +193,7 @@ WHERE 1=1
CourseId
=
item
.
CourseId
,
CommentTimes
=
item
.
Times
,
StuIds
=
item
.
StuUid
.
ToString
(),
HomeWorkId
=
item
.
HomeWorkId
,
HomeWorkId
=
item
.
HomeWorkId
,
}).
FirstOrDefault
();
item
.
CreateTime
=
defaultModel
.
CreateTime
.
AddSeconds
(
1
);
item
.
HomeWorkId
=
defaultModel
.
HomeWorkId
;
...
...
@@ -103,6 +202,8 @@ WHERE 1=1
return
flag
;
}
/// <summary>
/// 修改学员评论状态
/// </summary>
...
...
EduSpider.Repository/StuHomeWorkRepository.cs
View file @
58db7150
This diff is collapsed.
Click to expand it.
EduSpider.Services/CourseService.cs
View file @
58db7150
...
...
@@ -382,9 +382,9 @@ namespace EduSpider.Services
/// </summary>
/// <param name="list"></param>
/// <returns></returns>
public
bool
BatchSetStuComment
(
List
<
RB_Stu_Comment
>
list
)
public
bool
BatchSetStuComment
(
List
<
RB_Stu_Comment
>
list
,
StuCommentType
commentType
)
{
return
StuCommentRepository
.
BatchSetStuCommentRepository
(
list
);
return
StuCommentRepository
.
BatchSetStuCommentRepository
(
list
,
commentType
);
}
/// <summary>
...
...
@@ -472,9 +472,9 @@ namespace EduSpider.Services
/// 获取系统评价配置
/// </summary>
/// <returns></returns>
public
RB_Comment_Extend
GetSysComment
(
string
KeyWords
,
int
CommentTimes
)
public
List
<
RB_Comment_Extend
>
GetSysComment
(
CourseQuery
query
)
{
var
model
=
CommentRepository
.
GetCommentListRepository
(
KeyWords
,
CommentTimes
);
var
model
=
CommentRepository
.
GetCommentListRepository
(
query
);
return
model
;
}
...
...
EduSpider.WebApi/Controllers/Student/TeacherController.cs
View file @
58db7150
...
...
@@ -166,7 +166,7 @@ namespace EduSpider.WebApi.Controllers
}
else
{
var
sysModel
=
CourseService
.
GetSysComment
(
query
.
CourseName
,
query
.
CommentTimes
);
var
sysModel
=
CourseService
.
GetSysComment
(
new
CourseQuery
()
{
KeyWords
=
query
.
CourseName
,
CommentTimes
=
query
.
CommentTimes
}).
FirstOrDefault
(
);
if
(
sysModel
!=
null
)
{
result
=
new
...
...
@@ -205,52 +205,57 @@ namespace EduSpider.WebApi.Controllers
{
CourseId
=
base
.
ReqParameters
.
GetInt
(
"CourseId"
),
CourseName
=
base
.
ReqParameters
.
GetString
(
"CourseName"
),
};
var
courseRuleList
=
CourseService
.
GetCourseCommentList
(
query
);
object
result
=
new
object
();
if
(
courseRuleList
!=
null
)
List
<
object
>
result
=
new
List
<
object
>
();
if
(
courseRuleList
!=
null
&&
courseRuleList
.
Count
>
0
)
{
result
=
new
foreach
(
var
item
in
courseRuleList
)
{
query
.
CourseId
,
query
.
CourseName
,
CommentDetails
=
courseRuleList
,
};
result
.
Add
(
new
{
IsDefault
=
0
,
item
.
Id
,
item
.
Times
,
CommentDetails
=
item
.
CommentDetails
.
Select
(
qitem
=>
new
{
qitem
.
DetailId
,
qitem
.
CourseCommentId
,
qitem
.
StartNum
,
qitem
.
EndNum
,
qitem
.
Info
,
}),
});
}
}
else
{
var
sysModel
=
CourseService
.
GetSysComment
(
query
.
CourseName
,
query
.
CommentTimes
);
if
(
sysModel
!=
null
)
{
result
=
new
var
sysCommentList
=
CourseService
.
GetSysComment
(
new
CourseQuery
()
{
KeyWords
=
query
.
CourseName
,
CommentTimes
=
query
.
CommentTimes
});
if
(
sysCommentList
!=
null
&&
sysCommentList
.
Count
>
0
)
{
Id
=
0
,
Title
=
"系统默认配置"
,
query
.
CourseId
,
Times
=
query
.
CommentTimes
,
CommentDetails
=
sysModel
.
Details
,
};
}
else
foreach
(
var
item
in
sysCommentList
)
{
result
=
new
result
.
Add
(
new
{
Id
=
0
,
Title
=
"系统默认配置"
,
query
.
CourseId
,
Times
=
query
.
CommentTimes
,
CommentDetails
=
new
List
<
RB_Comment_Details
>()
};
IsDefault
=
1
,
item
.
Id
,
item
.
Times
,
CommentDetails
=
item
.
Details
.
Select
(
qitem
=>
new
{
DetailId
=
0
,
CourseCommentId
=
0
,
qitem
.
StartNum
,
qitem
.
EndNum
,
qitem
.
Info
,
}),
});
}
}
}
return
ApiResult
.
Success
(
data
:
result
);
}
/// <summary>
/// 新增可以课程评语
/// </summary>
...
...
@@ -336,6 +341,12 @@ namespace EduSpider.WebApi.Controllers
public
ApiResult
BatchSetStuComment
()
{
var
stuListStr
=
base
.
ReqParameters
.
GetString
(
"ChooseStuList"
);
StuCommentType
commentType
=
new
StuCommentType
()
{
CommentId
=
base
.
ReqParameters
.
GetInt
(
"CommentId"
),
CommentType
=
base
.
ReqParameters
.
GetInt
(
"CommentType"
),
IsDefault
=
base
.
ReqParameters
.
GetInt
(
"IsDefault"
)
};
List
<
RB_Stu_Comment
>
list
=
new
();
if
(!
string
.
IsNullOrWhiteSpace
(
stuListStr
))
{
...
...
@@ -365,7 +376,7 @@ namespace EduSpider.WebApi.Controllers
}
}
}
var
flag
=
CourseService
.
BatchSetStuComment
(
list
);
var
flag
=
CourseService
.
BatchSetStuComment
(
list
,
commentType
);
return
flag
?
ApiResult
.
Success
()
:
ApiResult
.
Failed
();
}
...
...
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