|
|
@ -15,7 +15,7 @@ func init() { |
|
|
|
service.RegisterHomework(&sHomework{}) |
|
|
|
} |
|
|
|
|
|
|
|
func (s *sHomework) GetHomeworkList(ctx context.Context) (homeworkList []ClientPage.GetHomewordListRse, err error) { |
|
|
|
func (s *sHomework) GetHomeworkList(ctx context.Context) (homeworkList []ClientPage.GetHomeworkListRse, err error) { |
|
|
|
var jwcode = 90038794 //需要从token中获取当前的数据
|
|
|
|
err = dao.ActivityInteractiveGroup.Ctx(ctx).Fields("id", "name", "DATE_FORMAT(end_date, '%Y-%m-%d') as end_date"). |
|
|
|
Where("end_date>?", gtime.Now()).OrderDesc("end_date").Scan(&homeworkList) |
|
|
@ -25,12 +25,23 @@ func (s *sHomework) GetHomeworkList(ctx context.Context) (homeworkList []ClientP |
|
|
|
} |
|
|
|
for i, item := range homeworkList { |
|
|
|
var count int |
|
|
|
count, err = dao.ActivityInteractiveRecord.Ctx(ctx).Where("group_id=?", item.Id).Where("jwcode", jwcode).Count() |
|
|
|
count, err = dao.ActivityInteractiveRecord.Ctx(ctx).Where("group_id=?", item.Id).Where("jwcode", jwcode).Count() //只有精网号和作业id查出来的结果是所需要的结果的题目数倍数
|
|
|
|
if err != nil { |
|
|
|
fmt.Println("提交记录数查询失败:", err) |
|
|
|
return |
|
|
|
} |
|
|
|
homeworkList[i].Status = count |
|
|
|
num, err := dao.ActivityInteractiveForm.Ctx(ctx).Where("group", item.Id).Count() |
|
|
|
if err != nil { |
|
|
|
fmt.Println("题目数查询失败:", err) |
|
|
|
return |
|
|
|
} |
|
|
|
homeworkList[i].Submit = count / num |
|
|
|
} |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
func (s *sHomework) GetHomeworkQuestion(ctx context.Context, groupId int) (questions []ClientPage.GetHomeworkQuestionRes, err error) { |
|
|
|
err = dao.ActivityInteractiveForm.Ctx(ctx).Fields("id", "name", "content", "status", "type"). |
|
|
|
Where("group_id", groupId).Scan(&questions) |
|
|
|
return |
|
|
|
} |