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
dc1ad233
Commit
dc1ad233
authored
May 25, 2022
by
黄奎
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
页面修改
parent
a8fcda25
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
317 additions
and
187 deletions
+317
-187
ICourseStudentRepository.cs
EduSpider.IRepository/ICourseStudentRepository.cs
+9
-0
RB_Stu_HomeWork.cs
EduSpider.Model/Entity/RB_Stu_HomeWork.cs
+180
-181
CourseQuery.cs
EduSpider.Model/Query/CourseQuery.cs
+2
-0
CourseStudentRepository.cs
EduSpider.Repository/CourseStudentRepository.cs
+29
-0
HomeWorkManager.cs
EduSpider/Spiders/ClassInRule/HomeWorkManager.cs
+97
-6
No files found.
EduSpider.IRepository/ICourseStudentRepository.cs
View file @
dc1ad233
using
EduSpider.Model.Entity
;
using
EduSpider.Model.Query
;
using
System.Collections.Generic
;
using
VTX.FW.Config
;
using
VTX.FW.DB
;
...
...
@@ -17,5 +18,13 @@ namespace EduSpider.Repository
/// <returns></returns>
public
bool
BatchSetCourseStudentRepository
(
List
<
RB_Course_Student
>
courses
);
/// <summary>
/// 跟进查询条件获取课程学员列表
/// </summary>
/// <param name="courseQuery"></param>
/// <returns></returns>
public
List
<
RB_Course_Student
>
GetCourseStudentListRepository
(
CourseQuery
query
);
}
}
EduSpider.Model/Entity/RB_Stu_HomeWork.cs
View file @
dc1ad233
...
...
@@ -10,185 +10,184 @@ namespace EduSpider.Model.Entity
[
DB
(
ConnectionName
=
"DefaultConnection"
)]
public
class
RB_Stu_HomeWork
{
/// <summary>
/// 学生家庭作业主键编号
/// </summary>
public
int
stu_homework_id
{
get
;
set
;
}
/// <summary>
/// admire
/// </summary>
public
string
admire
{
get
;
set
;
}
/// <summary>
/// cancel
/// </summary>
public
string
cancel
{
get
;
set
;
}
/// <summary>
/// 正确数量
/// </summary>
public
decimal
?
correct
{
get
;
set
;
}
/// <summary>
/// 错误题数
/// </summary>
public
int
?
wrong
{
get
;
set
;
}
/// <summary>
/// 课程编号
/// </summary>
public
int
?
course_id
{
get
;
set
;
}
/// <summary>
/// is_cream
/// </summary>
public
int
?
is_cream
{
get
;
set
;
}
/// <summary>
/// emend
/// </summary>
public
int
?
emend
{
get
;
set
;
}
/// <summary>
/// 作业编号
/// </summary>
public
int
?
homework_id
{
get
;
set
;
}
/// <summary>
/// 作业分享Key
/// </summary>
public
string
homework_share_key
{
get
;
set
;
}
/// <summary>
/// is_draft
/// </summary>
public
int
?
is_draft
{
get
;
set
;
}
/// <summary>
/// is_reform
/// </summary>
public
int
?
is_reform
{
get
;
set
;
}
/// <summary>
/// is_revised
/// </summary>
public
int
?
is_revised
{
get
;
set
;
}
/// <summary>
/// is_startd
/// </summary>
public
int
?
is_startd
{
get
;
set
;
}
/// <summary>
/// readover
/// </summary>
public
string
readover
{
get
;
set
;
}
/// <summary>
/// 提交时间
/// </summary>
public
DateTime
?
ref_time
{
get
;
set
;
}
/// <summary>
/// 评语
/// </summary>
public
string
comment
{
get
;
set
;
}
/// <summary>
/// reform
/// </summary>
public
string
reform
{
get
;
set
;
}
/// <summary>
/// school_uid
/// </summary>
public
int
?
school_uid
{
get
;
set
;
}
/// <summary>
/// 得分
/// </summary>
public
decimal
?
score
{
get
;
set
;
}
/// <summary>
/// 得分率
/// </summary>
public
decimal
?
score_p
{
get
;
set
;
}
/// <summary>
/// 评分机制
/// </summary>
public
int
?
score_type
{
get
;
set
;
}
/// <summary>
/// show_time
/// </summary>
public
DateTime
?
show_time
{
get
;
set
;
}
/// <summary>
/// status
/// </summary>
public
string
status
{
get
;
set
;
}
/// <summary>
/// 学生作业分享Key
/// </summary>
public
string
stu_homework_share_key
{
get
;
set
;
}
/// <summary>
/// 学生账号
/// </summary>
public
string
student_account
{
get
;
set
;
}
/// <summary>
/// 学生姓名
/// </summary>
public
string
student_name
{
get
;
set
;
}
/// <summary>
/// 学生编号
/// </summary>
public
int
?
student_uid
{
get
;
set
;
}
/// <summary>
/// 教师账号
/// </summary>
public
string
th_account
{
get
;
set
;
}
/// <summary>
/// th_cancel
/// </summary>
public
string
th_cancel
{
get
;
set
;
}
/// <summary>
/// 教师姓名
/// </summary>
public
string
th_name
{
get
;
set
;
}
/// <summary>
/// 教师数量
/// </summary>
public
int
?
th_num
{
get
;
set
;
}
/// <summary>
/// 教师创建时间
/// </summary>
public
DateTime
?
th_time
{
get
;
set
;
}
/// <summary>
/// 教师账号表编号
/// </summary>
public
int
?
th_uid
{
get
;
set
;
}
/// <summary>
/// 创建时间
/// </summary>
public
DateTime
?
add_time
{
get
;
set
;
}
/// <summary>
/// 更新时间
/// </summary>
public
DateTime
?
update_time
{
get
;
set
;
}
}
/// <summary>
/// 学生家庭作业主键编号
/// </summary>
public
int
stu_homework_id
{
get
;
set
;
}
/// <summary>
/// admire
/// </summary>
public
string
admire
{
get
;
set
;
}
/// <summary>
/// cancel
/// </summary>
public
string
cancel
{
get
;
set
;
}
/// <summary>
/// 正确数量
/// </summary>
public
decimal
correct
{
get
;
set
;
}
/// <summary>
/// 错误题数
/// </summary>
public
int
wrong
{
get
;
set
;
}
/// <summary>
/// 课程编号
/// </summary>
public
int
course_id
{
get
;
set
;
}
/// <summary>
/// is_cream
/// </summary>
public
int
is_cream
{
get
;
set
;
}
/// <summary>
/// emend
/// </summary>
public
int
emend
{
get
;
set
;
}
/// <summary>
/// 作业编号
/// </summary>
public
int
homework_id
{
get
;
set
;
}
/// <summary>
/// 作业分享Key
/// </summary>
public
string
homework_share_key
{
get
;
set
;
}
/// <summary>
/// is_draft
/// </summary>
public
int
is_draft
{
get
;
set
;
}
/// <summary>
/// is_reform
/// </summary>
public
int
?
is_reform
{
get
;
set
;
}
/// <summary>
/// is_revised
/// </summary>
public
int
is_revised
{
get
;
set
;
}
/// <summary>
/// is_startd
/// </summary>
public
int
is_startd
{
get
;
set
;
}
/// <summary>
/// readover
/// </summary>
public
string
readover
{
get
;
set
;
}
/// <summary>
/// 提交时间
/// </summary>
public
DateTime
ref_time
{
get
;
set
;
}
/// <summary>
/// 评语
/// </summary>
public
string
comment
{
get
;
set
;
}
/// <summary>
/// reform
/// </summary>
public
string
reform
{
get
;
set
;
}
/// <summary>
/// school_uid
/// </summary>
public
int
school_uid
{
get
;
set
;
}
/// <summary>
/// 得分
/// </summary>
public
decimal
score
{
get
;
set
;
}
/// <summary>
/// 得分率
/// </summary>
public
decimal
score_p
{
get
;
set
;
}
/// <summary>
/// 评分机制
/// </summary>
public
int
score_type
{
get
;
set
;
}
/// <summary>
/// show_time
/// </summary>
public
DateTime
show_time
{
get
;
set
;
}
/// <summary>
/// status
/// </summary>
public
string
status
{
get
;
set
;
}
/// <summary>
/// 学生作业分享Key
/// </summary>
public
string
stu_homework_share_key
{
get
;
set
;
}
/// <summary>
/// 学生账号
/// </summary>
public
string
student_account
{
get
;
set
;
}
/// <summary>
/// 学生姓名
/// </summary>
public
string
student_name
{
get
;
set
;
}
/// <summary>
/// 学生编号
/// </summary>
public
int
student_uid
{
get
;
set
;
}
/// <summary>
/// 教师账号
/// </summary>
public
string
th_account
{
get
;
set
;
}
/// <summary>
/// th_cancel
/// </summary>
public
string
th_cancel
{
get
;
set
;
}
/// <summary>
/// 教师姓名
/// </summary>
public
string
th_name
{
get
;
set
;
}
/// <summary>
/// 教师数量
/// </summary>
public
int
th_num
{
get
;
set
;
}
/// <summary>
/// 教师创建时间
/// </summary>
public
DateTime
th_time
{
get
;
set
;
}
/// <summary>
/// 教师账号表编号
/// </summary>
public
int
th_uid
{
get
;
set
;
}
/// <summary>
/// 创建时间
/// </summary>
public
DateTime
add_time
{
get
;
set
;
}
/// <summary>
/// 更新时间
/// </summary>
public
DateTime
update_time
{
get
;
set
;
}
}
}
EduSpider.Model/Query/CourseQuery.cs
View file @
dc1ad233
...
...
@@ -21,5 +21,7 @@ namespace EduSpider.Model.Query
/// 课程名称
/// </summary>
public
string
courseName
{
get
;
set
;
}
}
}
EduSpider.Repository/CourseStudentRepository.cs
View file @
dc1ad233
using
EduSpider.Model.Entity
;
using
EduSpider.Model.Query
;
using
EduSpider.Repository.Base
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Text
;
using
VTX.FW.DB.Dapper
;
namespace
EduSpider.Repository
{
...
...
@@ -20,5 +24,30 @@ namespace EduSpider.Repository
flag
=
base
.
BatchInsert
(
courses
,
isReplace
:
true
);
return
flag
;
}
/// <summary>
/// 跟进查询条件获取课程学员列表
/// </summary>
/// <param name="courseQuery"></param>
/// <returns></returns>
public
List
<
RB_Course_Student
>
GetCourseStudentListRepository
(
CourseQuery
query
)
{
var
parameters
=
new
DynamicParameters
();
StringBuilder
builder
=
new
();
builder
.
AppendFormat
(
@"
SELECT A.*
FROM RB_Course_Student AS A
WHERE 1=1
"
);
if
(
query
!=
null
)
{
if
(
query
.
courseId
>
0
)
{
builder
.
AppendFormat
(
" AND A.{0}={1} "
,
nameof
(
RB_Course_Student
.
courseId
),
query
.
courseId
);
}
}
return
base
.
Get
<
RB_Course_Student
>(
builder
.
ToString
(),
parameters
).
ToList
();
}
}
}
EduSpider/Spiders/ClassInRule/HomeWorkManager.cs
View file @
dc1ad233
...
...
@@ -32,6 +32,7 @@ namespace EduSpider.Spiders.ClassInRule
IHomeWorkRepository
homeWorkRepository
=
new
HomeWorkRepository
();
int
totalCount
=
0
;
Console
.
WriteLine
(
string
.
Format
(
"开始第{0}次获取家庭作业"
,
pageCount
));
string
url
=
"https://console.eeo.cn/saasajax/homework.ajax.php?action=getHomeworkList"
;
var
response
=
await
request
.
PostAsync
(
url
,
content
);
var
result
=
response
.
Content
.
ReadAsStringAsync
().
Result
;
...
...
@@ -50,8 +51,7 @@ namespace EduSpider.Spiders.ClassInRule
Console
.
WriteLine
(
string
.
Format
(
"第{0}次,导入完成{1}条."
,
pageCount
,
totalCount
));
foreach
(
var
item
in
tempList
)
{
//TODO
RunStuHomeWork
(
cookie
,
item
.
homework_id
,
item
.
course_id
);
}
}
if
(
totalNum
%
perpage
==
0
)
...
...
@@ -62,6 +62,7 @@ namespace EduSpider.Spiders.ClassInRule
{
pageCount
=
totalNum
/
perpage
+
1
;
}
if
(
totalNum
>
perpage
)
{
for
(
var
i
=
2
;
i
<=
pageCount
;
i
++)
...
...
@@ -87,7 +88,7 @@ namespace EduSpider.Spiders.ClassInRule
Console
.
WriteLine
(
string
.
Format
(
"第{0}次,导入完成{1}条."
,
i
,
totalCount
));
foreach
(
var
sItem
in
subtempList
)
{
//TODO
RunStuHomeWork
(
cookie
,
sItem
.
homework_id
,
sItem
.
course_id
);
}
}
}
...
...
@@ -155,9 +156,99 @@ namespace EduSpider.Spiders.ClassInRule
/// </summary>
/// <param name="cookie"></param>
/// <param name="homework_id"></param>
public
static
void
RunStuHomeWork
(
string
cookie
,
int
homework_id
)
{
public
static
async
void
RunStuHomeWork
(
string
cookie
,
int
homework_id
,
int
courseId
)
{
var
request
=
Utility
.
HttpHelper
.
GenerateHttp
(
cookie
);
IStuHomeWorkRepository
stuHomeWorkRepository
=
new
StuHomeWorkRepository
();
ICourseStudentRepository
courseStudentRepository
=
new
CourseStudentRepository
();
string
stuIds
=
""
;
var
courseStuList
=
courseStudentRepository
.
GetCourseStudentListRepository
(
new
Model
.
Query
.
CourseQuery
()
{
courseId
=
courseId
});
if
(
courseStuList
!=
null
)
{
stuIds
=
string
.
Join
(
","
,
courseStuList
.
Select
(
qitem
=>
qitem
.
uid
));
}
string
queryStr
=
"page=1&perpage=100000&homework_id=[{0}]&course_id=[{1}]&is_del=[0]&student_uid=[{2}]&by=2"
;
string
paramStr
=
string
.
Format
(
queryStr
,
homework_id
,
courseId
,
stuIds
);
var
content
=
new
StringContent
(
paramStr
,
System
.
Text
.
Encoding
.
UTF8
,
"application/x-www-form-urlencoded"
);
Console
.
WriteLine
(
string
.
Format
(
"开始获取{0}作业学员数据"
,
homework_id
));
string
url
=
"https://console.eeo.cn/saasajax/homework.ajax.php?action=getStudentsHomeworkList"
;
var
response
=
await
request
.
PostAsync
(
url
,
content
);
var
sutHomeWorkResult
=
response
.
Content
.
ReadAsStringAsync
().
Result
;
List
<
RB_Stu_HomeWork
>
list
=
new
List
<
RB_Stu_HomeWork
>();
if
(!
string
.
IsNullOrWhiteSpace
(
sutHomeWorkResult
))
{
JObject
stuHomeRootObj
=
JObject
.
Parse
(
sutHomeWorkResult
);
if
(!
string
.
IsNullOrWhiteSpace
(
stuHomeRootObj
.
GetString
(
"data"
)))
{
JObject
stuHomeDataObj
=
JObject
.
Parse
(
stuHomeRootObj
.
GetString
(
"data"
));
if
(!
string
.
IsNullOrWhiteSpace
(
stuHomeDataObj
.
GetString
(
"list"
)))
{
JArray
stuHomeArray
=
JArray
.
Parse
(
stuHomeDataObj
.
GetString
(
"list"
));
if
(
stuHomeArray
!=
null
&&
stuHomeArray
.
Count
>
0
)
{
foreach
(
var
rootItem
in
stuHomeArray
)
{
JObject
stuItemObj
=
JObject
.
Parse
(
rootItem
.
ToString
());
if
(!
string
.
IsNullOrWhiteSpace
(
stuItemObj
.
GetString
(
"students"
)))
{
JArray
stuListArray
=
JArray
.
Parse
(
stuItemObj
.
GetString
(
"students"
));
if
(
stuListArray
!=
null
&&
stuListArray
.
Count
>
0
)
{
foreach
(
var
sItem
in
stuListArray
)
{
JObject
lastObj
=
JObject
.
Parse
(
sItem
.
ToString
());
list
.
Add
(
new
RB_Stu_HomeWork
()
{
stu_homework_id
=
lastObj
.
GetInt
(
"stu_homework_id"
),
admire
=
lastObj
.
GetString
(
"admire"
),
cancel
=
lastObj
.
GetString
(
"cancel"
),
correct
=
lastObj
.
GetDecimal
(
"correct"
),
wrong
=
lastObj
.
GetInt
(
"wrong"
),
course_id
=
lastObj
.
GetInt
(
"course_id"
),
is_cream
=
lastObj
.
GetInt
(
"is_cream"
),
emend
=
lastObj
.
GetInt
(
"emend"
),
homework_id
=
lastObj
.
GetInt
(
"homework_id"
),
homework_share_key
=
lastObj
.
GetString
(
"homework_share_key"
),
is_draft
=
lastObj
.
GetInt
(
"is_draft"
),
is_reform
=
lastObj
.
GetInt
(
"is_reform"
),
is_revised
=
lastObj
.
GetInt
(
"is_revised"
),
is_startd
=
lastObj
.
GetInt
(
"is_startd"
),
readover
=
lastObj
.
GetString
(
"readover"
),
ref_time
=
ConvertHelper
.
UnixToDateTime
(
lastObj
.
GetInt
(
"ref_time"
)),
comment
=
lastObj
.
GetString
(
"comment"
),
reform
=
lastObj
.
GetString
(
"reform"
),
school_uid
=
lastObj
.
GetInt
(
"school_uid"
),
score
=
lastObj
.
GetDecimal
(
"score"
),
score_p
=
lastObj
.
GetDecimal
(
"score_p"
),
score_type
=
lastObj
.
GetInt
(
"score_type"
),
show_time
=
ConvertHelper
.
UnixToDateTime
(
lastObj
.
GetInt
(
"show_time"
)),
status
=
lastObj
.
GetString
(
"status"
),
stu_homework_share_key
=
lastObj
.
GetString
(
"stu_homework_share_key"
),
student_account
=
lastObj
.
GetString
(
"student_account"
),
student_name
=
lastObj
.
GetString
(
"student_name"
),
student_uid
=
lastObj
.
GetInt
(
"student_uid"
),
th_account
=
lastObj
.
GetString
(
"th_account"
),
th_cancel
=
lastObj
.
GetString
(
"th_cancel"
),
th_name
=
lastObj
.
GetString
(
"th_name"
),
th_num
=
lastObj
.
GetInt
(
"th_num"
),
th_time
=
ConvertHelper
.
UnixToDateTime
(
lastObj
.
GetInt
(
"th_time"
)),
th_uid
=
lastObj
.
GetInt
(
"th_uid"
),
add_time
=
ConvertHelper
.
UnixToDateTime
(
lastObj
.
GetInt
(
"add_time"
)),
update_time
=
ConvertHelper
.
UnixToDateTime
(
lastObj
.
GetInt
(
"update_time"
)),
});
}
}
}
}
}
}
}
}
if
(
list
!=
null
&&
list
.
Count
>
0
)
{
stuHomeWorkRepository
.
BatchSetStuHomeWorkRepository
(
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