fix trang thai sinh vien
This commit is contained in:
@@ -129,14 +129,15 @@ func ApplyScheduleTemplateHandler(db *gorm.DB) fiber.Handler {
|
||||
}
|
||||
|
||||
type attendanceRow struct {
|
||||
StudentRkID int64 `json:"studentRkId"`
|
||||
StudentCode string `json:"studentCode"`
|
||||
FullName string `json:"fullName"`
|
||||
Email string `json:"email"`
|
||||
Status int `json:"status"`
|
||||
StatusLabel string `json:"statusLabel"`
|
||||
OnlineMinutes int `json:"onlineMinutes"`
|
||||
StatusEditedByTeacher bool `json:"statusEditedByTeacher"`
|
||||
StudentRkID int64 `json:"studentRkId"`
|
||||
StudentCode string `json:"studentCode"`
|
||||
FullName string `json:"fullName"`
|
||||
Email string `json:"email"`
|
||||
Status int `json:"status"`
|
||||
StatusLabel string `json:"statusLabel"`
|
||||
OnlineMinutes int `json:"onlineMinutes"`
|
||||
StatusEditedByTeacher bool `json:"statusEditedByTeacher"`
|
||||
PushedToQLDTAt *time.Time `json:"pushedToQldtAt,omitempty"`
|
||||
}
|
||||
|
||||
func resolveScheduleForPeriod(db *gorm.DB, classRkID int64, dayOfWeek, period int) (*models.ClassSchedule, error) {
|
||||
@@ -278,22 +279,38 @@ func GetClassAttendanceHandler(db *gorm.DB) fiber.Handler {
|
||||
row.StatusLabel = r.StatusLabel
|
||||
row.OnlineMinutes = r.OnlineMinutes
|
||||
row.StatusEditedByTeacher = r.StatusEditedByTeacher
|
||||
row.PushedToQLDTAt = r.PushedToQLDTAt
|
||||
}
|
||||
out = append(out, row)
|
||||
}
|
||||
|
||||
sched, _ := resolveScheduleForPeriod(db, classRkID, dayOfWeek, period)
|
||||
shiftInfo := fiber.Map{}
|
||||
if sched != nil {
|
||||
shiftInfo = fiber.Map{
|
||||
"startTime": sched.StartTime,
|
||||
"endTime": sched.EndTime,
|
||||
"courseId": sched.CourseID,
|
||||
"courseName": sched.CourseName,
|
||||
"isActive": sched.IsActive,
|
||||
var shiftPushedAt *time.Time
|
||||
qldtDirty := false
|
||||
for _, r := range results {
|
||||
if r.PushedToQLDTAt != nil {
|
||||
if shiftPushedAt == nil || r.PushedToQLDTAt.After(*shiftPushedAt) {
|
||||
t := *r.PushedToQLDTAt
|
||||
shiftPushedAt = &t
|
||||
}
|
||||
if r.UpdatedAt.After(*r.PushedToQLDTAt) {
|
||||
qldtDirty = true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sched, _ := resolveScheduleForPeriod(db, classRkID, dayOfWeek, period)
|
||||
shiftInfo := fiber.Map{
|
||||
"pushedToQldtAt": shiftPushedAt,
|
||||
"qldtDirty": qldtDirty,
|
||||
}
|
||||
if sched != nil {
|
||||
shiftInfo["startTime"] = sched.StartTime
|
||||
shiftInfo["endTime"] = sched.EndTime
|
||||
shiftInfo["courseId"] = sched.CourseID
|
||||
shiftInfo["courseName"] = sched.CourseName
|
||||
shiftInfo["isActive"] = sched.IsActive
|
||||
}
|
||||
|
||||
return c.JSON(fiber.Map{"data": out, "period": period, "date": date, "shift": shiftInfo})
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user