/
homework.go
465 lines (399 loc) · 22.6 KB
/
homework.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
package gothulearn
import (
"context"
"encoding/json"
"fmt"
"io/ioutil"
"net/http"
"net/url"
"strings"
)
type HomeworkService service
type HomeworkList struct {
Result string `json:"result"`
Msg string `json:"msg"`
Object HomeworkObject `json:"object"`
}
type HomeworkObject struct {
ITotalRecords string `json:"iTotalRecords"`
ITotalDisplayRecords string `json:"iTotalDisplayRecords"`
IDisplayStart string `json:"iDisplayStart"`
IDisplayLength string `json:"iDisplayLength"`
SEcho string `json:"sEcho"`
SSearch string `json:"sSearch"`
AaData []Homework `json:"aaData"`
}
type Homework struct {
Kssj int `json:"kssj"` // 开始时间
KssjStr string `json:"kssjStr"` // 开始时间 String
Jzsj int `json:"jzsj"` // 截止时间
JzsjStr string `json:"jzsjStr"` // 截止时间 String
Bt string `json:"bt"` // 标题
Wz int `json:"wz"` // 序号
Zywcfs int `json:"zywcfs"`
Zytjfs int `json:"zytjfs"`
Jffs int `json:"jffs"`
Mxdxmc string `json:"mxdxmc"`
Mxdx string `json:"mxdx"`
Wlkcid string `json:"wlkcid"`
Xszyid string `json:"xszyid"`
Xh string `json:"xh"` // 学号
Zyid string `json:"zyid"` // 作业ID
Zynr string `json:"zynr"` // 作业内容
ZynrStr string `json:"zynrStr"` // 作业内容 Str
Zyfjid string `json:"zyfjid"` // 作业附件ID
Scr string `json:"scr"` // 上传人
Scsj string `json:"scsj"` // 上传时间
ScsjStr string `json:"scsjStr"` // 上传时间 Str
Ggzh string `json:"gzzh"`
Pysj string `json:"pysj"` // 批阅时间
PysjStr string `json:"pysjStr"` // 批阅时间 Str
Pynr string `json:"pynr"` // 批阅内容
Pylj string `json:"pylj"` //
Cj string `json:"cj"` // 成绩
Zt string `json:"zt"` // 状态
Pyzt string `json:"pyzt"` // 批阅状态
Qzid string `json:"qzid"`
Bz string `json:"bz"`
Qzmc string `json:"qzmc"`
Xm string `json:"xm"` // 姓名
Dwmc string `json:"dwmc"`
Bm string `json:"bm"` // 班名
Cjgbsj string `json:"cjgbsj"`
Fjdxxz string `json:"fjdxxz"`
Djzcj string `json:"djzcj"`
Ywdjzcj string `json:"ywdjzcj"`
Jsm string `json:"jsm"` // 教师名
Wjmc string `json:"wjmc"` // 文件名称
Wjdx string `json:"wjdx"` // 文件大小
Id string `json:"id"` // ID
}
func (h *HomeworkService) GetUnsubmittedHomeworks(courseID string) (*HomeworkList, error) {
// Create request
var payload url.Values = url.Values{}
payload.Add("aoData", fmt.Sprintf("[{\"name\":\"sEcho\",\"value\":1},{\"name\":\"iColumns\",\"value\":8},{\"name\":\"sColumns\",\"value\":\",,,,,,,\"},{\"name\":\"iDisplayStart\",\"value\":0},{\"name\":\"iDisplayLength\",\"value\":\"30\"},{\"name\":\"mDataProp_0\",\"value\":\"wz\"},{\"name\":\"bSortable_0\",\"value\":false},{\"name\":\"mDataProp_1\",\"value\":\"bt\"},{\"name\":\"bSortable_1\",\"value\":true},{\"name\":\"mDataProp_2\",\"value\":\"mxdxmc\"},{\"name\":\"bSortable_2\",\"value\":true},{\"name\":\"mDataProp_3\",\"value\":\"zywcfs\"},{\"name\":\"bSortable_3\",\"value\":true},{\"name\":\"mDataProp_4\",\"value\":\"kssj\"},{\"name\":\"bSortable_4\",\"value\":true},{\"name\":\"mDataProp_5\",\"value\":\"jzsj\"},{\"name\":\"bSortable_5\",\"value\":true},{\"name\":\"mDataProp_6\",\"value\":\"jzsj\"},{\"name\":\"bSortable_6\",\"value\":true},{\"name\":\"mDataProp_7\",\"value\":\"function\"},{\"name\":\"bSortable_7\",\"value\":false},{\"name\":\"iSortCol_0\",\"value\":5},{\"name\":\"sSortDir_0\",\"value\":\"desc\"},{\"name\":\"iSortCol_1\",\"value\":6},{\"name\":\"sSortDir_1\",\"value\":\"desc\"},{\"name\":\"iSortingCols\",\"value\":2},{\"name\":\"wlkcid\",\"value\":\"%s\"}]", courseID))
resp, err := h.client.Request(context.Background(), http.MethodPost, addCSRFTokenToUrl(learnUnsubmittedHomeworkList(courseID), h.client.csrf), strings.NewReader(payload.Encode()))
if err != nil {
return nil, err
}
// Handle response
bytesResponse, err := ioutil.ReadAll(resp.Body)
if err != nil {
return nil, err
}
var response HomeworkList
json.Unmarshal(bytesResponse, &response)
return &response, nil
}
func (h *HomeworkService) GetSubmmitedNotGradedHomeworks(courseID string) (*HomeworkList, error) {
// Create request
var payload url.Values = url.Values{}
payload.Add("aoData", fmt.Sprintf("[{\"name\":\"sEcho\",\"value\":1},{\"name\":\"iColumns\",\"value\":8},{\"name\":\"sColumns\",\"value\":\",,,,,,,\"},{\"name\":\"iDisplayStart\",\"value\":0},{\"name\":\"iDisplayLength\",\"value\":\"30\"},{\"name\":\"mDataProp_0\",\"value\":\"wz\"},{\"name\":\"bSortable_0\",\"value\":false},{\"name\":\"mDataProp_1\",\"value\":\"bt\"},{\"name\":\"bSortable_1\",\"value\":true},{\"name\":\"mDataProp_2\",\"value\":\"mxdxmc\"},{\"name\":\"bSortable_2\",\"value\":true},{\"name\":\"mDataProp_3\",\"value\":\"kssj\"},{\"name\":\"bSortable_3\",\"value\":true},{\"name\":\"mDataProp_4\",\"value\":\"jzsj\"},{\"name\":\"bSortable_4\",\"value\":true},{\"name\":\"mDataProp_5\",\"value\":\"jzsj\"},{\"name\":\"bSortable_5\",\"value\":true},{\"name\":\"mDataProp_6\",\"value\":\"zyfjid\"},{\"name\":\"bSortable_6\",\"value\":false},{\"name\":\"mDataProp_7\",\"value\":\"function\"},{\"name\":\"bSortable_7\",\"value\":false},{\"name\":\"iSortCol_0\",\"value\":4},{\"name\":\"sSortDir_0\",\"value\":\"desc\"},{\"name\":\"iSortCol_1\",\"value\":5},{\"name\":\"sSortDir_1\",\"value\":\"desc\"},{\"name\":\"iSortingCols\",\"value\":2},{\"name\":\"wlkcid\",\"value\":\"%s\"}]", courseID))
resp, err := h.client.Request(context.Background(), http.MethodPost, addCSRFTokenToUrl(learnSubmittedNotGradedHWList(courseID), h.client.csrf), strings.NewReader(payload.Encode()))
// Handle response
bytesResponse, err := ioutil.ReadAll(resp.Body)
if err != nil {
return nil, err
}
var response HomeworkList
json.Unmarshal(bytesResponse, &response)
return &response, nil
}
func (h *HomeworkService) GetGradedHomeworks(courseID string) (*HomeworkList, error) {
// Create request
var payload url.Values = url.Values{}
payload.Add("aoData", fmt.Sprintf("[{\"name\":\"sEcho\",\"value\":1},{\"name\":\"iColumns\",\"value\":9},{\"name\":\"sColumns\",\"value\":\",,,,,,,,\"},{\"name\":\"iDisplayStart\",\"value\":0},{\"name\":\"iDisplayLength\",\"value\":\"30\"},{\"name\":\"mDataProp_0\",\"value\":\"wz\"},{\"name\":\"bSortable_0\",\"value\":true},{\"name\":\"mDataProp_1\",\"value\":\"bt\"},{\"name\":\"bSortable_1\",\"value\":true},{\"name\":\"mDataProp_2\",\"value\":\"zywcfs\"},{\"name\":\"bSortable_2\",\"value\":true},{\"name\":\"mDataProp_3\",\"value\":\"scsj\"},{\"name\":\"bSortable_3\",\"value\":true},{\"name\":\"mDataProp_4\",\"value\":\"jsm\"},{\"name\":\"bSortable_4\",\"value\":false},{\"name\":\"mDataProp_5\",\"value\":\"pysj\"},{\"name\":\"bSortable_5\",\"value\":true},{\"name\":\"mDataProp_6\",\"value\":\"cj\"},{\"name\":\"bSortable_6\",\"value\":true},{\"name\":\"mDataProp_7\",\"value\":\"zyfjid\"},{\"name\":\"bSortable_7\",\"value\":false},{\"name\":\"mDataProp_8\",\"value\":\"function\"},{\"name\":\"bSortable_8\",\"value\":false},{\"name\":\"iSortCol_0\",\"value\":0},{\"name\":\"sSortDir_0\",\"value\":\"desc\"},{\"name\":\"iSortingCols\",\"value\":1},{\"name\":\"wlkcid\",\"value\":\"%s\"}]", courseID))
resp, err := h.client.Request(context.Background(), http.MethodPost, addCSRFTokenToUrl(learnGradedHomeworkList(courseID), h.client.csrf), strings.NewReader(payload.Encode()))
// Handle response
bytesResponse, err := ioutil.ReadAll(resp.Body)
if err != nil {
return nil, err
}
var response HomeworkList
json.Unmarshal(bytesResponse, &response)
return &response, nil
}
// UnsubmittedHomeworkInfo : A struct for a unsubmmited homework instance
type UnsubmittedHomeworkInfo struct {
// 作业内容及要求
Title string // 作业标题
Description string // 作业说明
AttachmentName string // 作业附件
AttachmentLink string // 作业附件链接
AttachmentSize string // 作业附件大小
AnswerDesc string // 答案说明
AnswerAttachmentName string // TODO 大答附件
AnswerAttachmentLink string // TODO 答案附件链接
AnswerAttachmentSize string // TODO 答案附件大小
PublishObject string // 发布对象
FinishType string // 完成方式
DueDate string // 截止日期
}
func (h *HomeworkService) GetUnsubmittedHomeworkInfo(courseID string, homeworkID string, xsHomeworkID string) (*UnsubmittedHomeworkInfo, error) {
// Create request
var emptyData url.Values = url.Values{}
resp, err := h.client.Request(context.Background(), http.MethodPost, learnUnsubmittedHomeworkInfo(courseID, homeworkID, xsHomeworkID), strings.NewReader(emptyData.Encode()))
if err != nil {
return nil, err
}
// Handle response
stringResponse := DecodeRequestBodyToString(resp)
// stringResponse = strings.Split(stringResponse, "<div class=\"ttee\">作业内容及要求:</div>")[1]
var response UnsubmittedHomeworkInfo
// 作业标题
response.Title = strings.Split(strings.Split(stringResponse, ">作业标题</div>")[1], "</div>")[0]
response.Title = stripHtml(response.Title)
// 作业说明
response.Description = strings.Split(strings.Split(stringResponse, ">作业说明</div>")[1], "</div>")[0]
response.Description = stripHtml(response.Description)
// 作业附件
response.AttachmentName = strings.Split(stringResponse, ">作业附件</div>")[1]
response.AttachmentName = strings.Split(response.AttachmentName, "<!--答案说明-->")[0]
// 处理未文件的情况
if stripHtml(response.AttachmentName) != "" {
attachment := response.AttachmentName
response.AttachmentName = strings.Split(response.AttachmentName, "</a>")[0]
response.AttachmentSize = strings.Split(attachment, "</span>")[1]
response.AttachmentSize = stripHtml(response.AttachmentSize)
response.AttachmentLink = strings.Split(attachment, "href=\"")[2]
response.AttachmentLink = strings.Split(response.AttachmentLink, "\">")[0]
response.AttachmentName = stripHtml(response.AttachmentName)
} else {
response.AttachmentName = ""
}
// 答案说明
response.AnswerDesc = strings.Split(strings.Split(stringResponse, ">答案说明</div>")[1], "</div>")[0]
response.AnswerDesc = stripHtml(response.AnswerDesc)
// TODO 答案附件
// response.AnswerAttachmentName = strings.Split(stringResponse, ">答案附件</div>")[1]
// 发布对象
response.PublishObject = strings.Split(strings.Split(stringResponse, ">发布对象</div>")[1], "</div>")[0]
response.PublishObject = stripHtml(response.PublishObject)
// 完成方式
response.FinishType = strings.Split(strings.Split(stringResponse, ">完成方式</div>")[1], "</div>")[0]
response.FinishType = stripHtml(response.FinishType)
// 截止日期
response.DueDate = strings.Split(strings.Split(stringResponse, ">截止日期(GMT+8)</div>")[1], "</div>")[0]
response.DueDate = stripHtml(response.DueDate)
return &response, nil
}
// SubmittedHomeworkInfo : A struct for a submitted homework, but not graded hw instance
type SubmittedHomeworkInfo struct {
// 作业内容及要求
Title string // 作业标题
Description string // 作业说明
AttachmentName string // 作业附件
AttachmentLink string // 作业附件链接
AttachmentSize string // TODO 作业附件大小
AnswerDesc string // 答案说明
AnswerAttachmentName string // TODO 大答附件
AnswerAttachmentLink string // TODO 答案附件链接
AnswerAttachmentSize string // TODO 答案附件大小
PublishObject string // 发布对象
FinishType string // 完成方式
// 本人提交的作业
Studentid string // 学号
SubmissionDate string // 提交日期
SubmissionContent string // 上交作业内容
SubmissionAttachmentName string // 上交作业附件
SubmissionAttachmentLink string // 上交作业附件连接
SubmissionAttachmentSize string // 上交作业附件大小
}
func (h *HomeworkService) GetSubmittedHomeworkInfo(courseID string, homeworkID string, xsHomeworkID string) (*SubmittedHomeworkInfo, error) {
// Create request
var emptyData url.Values = url.Values{}
resp, err := h.client.Request(context.Background(), http.MethodPost, learnSubmittedNotGradedHWInfo(courseID, homeworkID, xsHomeworkID), strings.NewReader(emptyData.Encode()))
if err != nil {
return nil, err
}
// Handle response
stringResponse := DecodeRequestBodyToString(resp)
var response SubmittedHomeworkInfo
// 作业标题
response.Title = strings.Split(strings.Split(stringResponse, ">作业标题</div>")[1], "</div>")[0]
response.Title = stripHtml(response.Title)
// 作业说明
response.Description = strings.Split(strings.Split(stringResponse, ">作业说明</div>")[1], "</div>")[0]
response.Description = stripHtml(response.Description)
// 作业附件
response.AttachmentName = strings.Split(stringResponse, ">作业附件</div>")[1]
response.AttachmentName = strings.Split(response.AttachmentName, "<!--答案说明-->")[0]
// 处理未文件的情况
if stripHtml(response.AttachmentName) != "" {
attachment := response.AttachmentName
response.AttachmentName = strings.Split(response.AttachmentName, "</a>")[0]
response.AttachmentSize = strings.Split(attachment, "</span>")[1]
response.AttachmentSize = stripHtml(response.AttachmentSize)
response.AttachmentLink = strings.Split(attachment, "href=\"")[2]
response.AttachmentLink = strings.Split(response.AttachmentLink, "\">")[0]
response.AttachmentName = stripHtml(response.AttachmentName)
} else {
response.AttachmentName = ""
}
// 答案说明
response.AnswerDesc = strings.Split(strings.Split(stringResponse, ">答案说明</div>")[1], "</div>")[0]
response.AnswerDesc = stripHtml(response.AnswerDesc)
// TODO 答案附件
// 发布对象
response.PublishObject = strings.Split(strings.Split(stringResponse, ">发布对象</div>")[1], "</div>")[0]
response.PublishObject = stripHtml(response.PublishObject)
// 完成方式
response.FinishType = strings.Split(strings.Split(stringResponse, ">完成方式</div>")[1], "</div>")[0]
response.FinishType = stripHtml(response.FinishType)
// 学号
response.Studentid = strings.Split(strings.Split(stringResponse, ">学号</div>")[1], "</div>")[0]
response.Studentid = stripHtml(response.Studentid)
// 提交日期
response.SubmissionDate = strings.Split(strings.Split(stringResponse, ">提交日期</div>")[1], "</div>")[0]
response.SubmissionDate = stripHtml(response.SubmissionDate)
// 上交作业内容
response.SubmissionContent = strings.Split(strings.Split(stringResponse, ">上交作业内容</div>")[1], "</div>")[0]
response.SubmissionContent = stripHtml(response.SubmissionContent)
// 上交作业附件
response.SubmissionAttachmentName = strings.Split(stringResponse, ">上交作业附件</div>")[1]
response.SubmissionAttachmentName = strings.Split(response.SubmissionAttachmentName, "下载")[0] // TODO handle no attachment
// 处理未文件的情况
if stripHtml(response.SubmissionAttachmentName) != "" {
attachment := response.SubmissionAttachmentName
response.SubmissionAttachmentName = strings.Split(response.SubmissionAttachmentName, "</a>")[0]
response.SubmissionAttachmentSize = strings.Split(attachment, "</span>")[1]
response.SubmissionAttachmentSize = stripHtml(response.SubmissionAttachmentSize)
response.SubmissionAttachmentLink = strings.Split(attachment, "href=\"")[2]
response.SubmissionAttachmentLink = strings.Split(response.SubmissionAttachmentLink, "\"")[0]
response.SubmissionAttachmentName = stripHtml(response.SubmissionAttachmentName)
} else {
response.SubmissionAttachmentName = ""
}
return &response, nil
}
// GradedHomeworkInfo : A struct for a graded homework instance
type GradedHomeworkInfo struct {
// 作业内容及要求
Title string // 作业标题
Description string // 作业说明
AttachmentName string // 作业附件
AttachmentLink string // 作业附件链接
AttachmentSize string // 作业附件大小
AnswerDesc string // 答案说明
AnswerAttachment string // 大答附件
AnswerAttachmentLink string // TODO: 答案附件链接
AnswerAttachmentSize string // TODO: 答案附件大小
PublishObject string // 发布对象
FinishType string // 完成方式
DueDate string // 截止日期
// 本人提交的作业
Studentid string // 提交日期
SubmissionDate string // 提交日期
SubmissionContent string // 上交作业内容
SubmissionAttachmentName string // 上交作业附件名字
SubmissionAttachmentLink string // 上交作业附件连接
SubmissionAttachmentSize string // TODO
// 老师批阅结果
ReviewTeacher string // 批阅老师
ReviewTime string // 批阅时间
Grade string // 成绩
Comments string // 评语
CommentsAttachmentName string // 评语附件
CommentsAttachmentLink string // TODO
CommentsAttachmentSize string // TODO
}
func (h *HomeworkService) GetGradedHomeworkInfo(courseID string, homeworkID string, xsHomeworkID string) (*GradedHomeworkInfo, error) {
var emptyData url.Values = url.Values{}
resp, err := h.client.Request(context.Background(), http.MethodPost, learnGradedHomeworkInfo(courseID, homeworkID, xsHomeworkID), strings.NewReader(emptyData.Encode()))
if err != nil {
return nil, err
}
stringResponse := DecodeRequestBodyToString(resp)
var response GradedHomeworkInfo
// 作业标题
response.Title = strings.Split(stringResponse, "<div class=\"left\">作业标题</div>")[1]
response.Title = strings.Split(response.Title, "</p>")[0]
response.Title = stripHtml(response.Title)
// 作业说明
response.Description = strings.Split(stringResponse, ">作业说明</div>")[1]
response.Description = strings.Split(response.Description, "</div>")[0]
response.Description = stripHtml(response.Description)
// 作业附件
response.AttachmentName = strings.Split(stringResponse, ">作业附件</div>")[1]
response.AttachmentName = strings.Split(response.AttachmentName, "<!--答案说明-->")[0]
// 处理未文件的情况
if stripHtml(response.AttachmentName) != "" {
attachment := response.AttachmentName
response.AttachmentName = strings.Split(response.AttachmentName, "</a>")[0]
response.AttachmentSize = strings.Split(attachment, "</span>")[1]
response.AttachmentSize = stripHtml(response.AttachmentSize)
response.AttachmentLink = strings.Split(attachment, "href=\"")[2]
response.AttachmentLink = strings.Split(response.AttachmentLink, "\">")[0]
response.AttachmentName = stripHtml(response.AttachmentName)
} else {
response.AttachmentName = ""
}
// Homework Answer Description
response.AnswerDesc = strings.Split(stringResponse, ">答案说明</div>")[1]
response.AnswerDesc = strings.Split(response.AnswerDesc, "</div>")[0]
response.AnswerDesc = stripHtml(response.AnswerDesc)
// Homework Answer Attachment
// response.AnswerAttachment = strings.Split(stringResponse, ">答案附件</div>")[1]
// response.AnswerAttachment = strings.Split(response.AnswerAttachment, "</div>")[0]
// response.AnswerAttachment = stripHtml(response.AnswerAttachment)
// Homework Publish Object
response.PublishObject = strings.Split(stringResponse, "<div class=\"left\">发布对象</div>")[1]
response.PublishObject = strings.Split(response.PublishObject, "</p>")[0]
response.PublishObject = stripHtml(response.PublishObject)
// Homework Finish Method
response.FinishType = strings.Split(stringResponse, "<div class=\"left\">完成方式</div>")[1]
response.FinishType = strings.Split(response.FinishType, "</p>")[0]
response.FinishType = stripHtml(response.FinishType)
// 作业截止时间
response.DueDate = strings.Split(stringResponse, "<div class=\"left\">截止日期(GMT+8)</div>")[1]
response.DueDate = strings.Split(response.DueDate, "</p>")[0]
response.DueDate = stripHtml(response.DueDate)
// 学生号
response.Studentid = strings.Split(stringResponse, "<div class=\"left\">学号</div>")[1]
response.Studentid = strings.Split(response.Studentid, "</p>")[0]
response.Studentid = stripHtml(response.Studentid)
// 作业上交日期
response.SubmissionDate = strings.Split(stringResponse, "<div class=\"left\">提交日期</div>")[1]
response.SubmissionDate = strings.Split(response.SubmissionDate, "</p>")[0]
response.SubmissionDate = stripHtml(response.SubmissionDate)
// 作业上交内容
response.SubmissionContent = strings.Split(stringResponse, ">上交作业内容</div>")[1]
response.SubmissionContent = strings.Split(response.SubmissionContent, "</div>")[0]
response.SubmissionContent = stripHtml(response.SubmissionContent)
// 上交作业附件
response.SubmissionAttachmentName = strings.Split(stringResponse, ">上交作业附件</div>")[1]
response.SubmissionAttachmentName = strings.Split(response.SubmissionAttachmentName, "老师批阅结果")[0]
// 处理未文件的情况
if stripHtml(response.SubmissionAttachmentName) != "" {
attachment := response.SubmissionAttachmentName
response.SubmissionAttachmentName = strings.Split(response.SubmissionAttachmentName, "</a>")[0]
response.SubmissionAttachmentSize = strings.Split(attachment, "</span>")[1]
response.SubmissionAttachmentSize = stripHtml(response.SubmissionAttachmentSize)
response.SubmissionAttachmentLink = strings.Split(attachment, "href=\"")[2]
response.SubmissionAttachmentLink = strings.Split(response.SubmissionAttachmentLink, "\"")[0]
response.SubmissionAttachmentName = stripHtml(response.SubmissionAttachmentName)
} else {
response.SubmissionAttachmentName = ""
}
// Homework review teacher
response.ReviewTeacher = strings.Split(stringResponse, "<div class=\"left\">批阅老师</div>")[1]
response.ReviewTeacher = strings.Split(response.ReviewTeacher, "</p>")[0]
response.ReviewTeacher = stripHtml(response.ReviewTeacher)
// Homework review time
response.ReviewTime = strings.Split(stringResponse, "<div class=\"left\">批阅时间</div>")[1]
response.ReviewTime = strings.Split(response.ReviewTime, "</p>")[0]
response.ReviewTime = stripHtml(response.ReviewTime)
// Homework grade
response.Grade = strings.Split(stringResponse, "<div class=\"left\">成绩</div>")[1]
response.Grade = strings.Split(response.Grade, "</p>")[0]
response.Grade = stripHtml(response.Grade)
// Homework comments
response.Comments = strings.Split(stringResponse, ">评语</div>")[1]
response.Comments = strings.Split(response.Comments, "</span>")[0]
response.Comments = stripHtml(response.Comments)
// Homework comments attachment
// response.CommentsAttachmentName = strings.Split(stringResponse, ">评语附件</div>")[1]
// response.CommentsAttachmentName = strings.Split(response.CommentsAttachmentName, "</div>")[0]
// response.CommentsAttachmentName = stripHtml(response.CommentsAttachmentName)
return &response, nil
}