add
This commit is contained in:
@@ -109,7 +109,7 @@ func GetStudentStatusHandler(db *gorm.DB) fiber.Handler {
|
||||
monitorLabel = fmt.Sprintf("Đang giám sát — Ca %d", currentPeriod)
|
||||
}
|
||||
}
|
||||
// monitorMode = "exam" — dành cho phòng thi (sẽ bổ sung sau)
|
||||
// monitorMode = "exam" — xử lý ở nhánh FindActiveExamForStudent phía trên
|
||||
|
||||
sessionMap := map[int]models.StudentSession{}
|
||||
attMap := map[int]models.AttendanceResult{}
|
||||
@@ -169,6 +169,47 @@ func GetStudentStatusHandler(db *gorm.DB) fiber.Handler {
|
||||
})
|
||||
}
|
||||
|
||||
// Ưu tiên phòng thi nếu sinh viên đang trong khung giờ thi
|
||||
if examInfo := internalDb.FindActiveExamForStudent(db, studentID); examInfo != nil {
|
||||
examKeywords := strings.TrimSpace(examInfo.Room.AllowedApps)
|
||||
if examKeywords == "" {
|
||||
examKeywords = defaultExamAllowedApps
|
||||
}
|
||||
paperSent := examInfo.Enrollment.PaperSentAt != nil
|
||||
var subCount int64
|
||||
_ = db.Model(&models.ExamSubmission{}).Where("exam_room_id = ? AND student_rk_id = ?", examInfo.Room.ID, studentID).Count(&subCount).Error
|
||||
examPayload := fiber.Map{
|
||||
"examRoomId": examInfo.Room.ID,
|
||||
"examName": examInfo.Room.Name,
|
||||
"startTime": examInfo.Room.StartTime,
|
||||
"endTime": examInfo.Room.EndTime,
|
||||
"quizUrl": examInfo.Room.QuizURL,
|
||||
"paperSent": paperSent,
|
||||
"submitted": subCount > 0,
|
||||
}
|
||||
if paperSent && examInfo.Paper != nil {
|
||||
examPayload["paperId"] = examInfo.Paper.ID
|
||||
examPayload["paperTitle"] = examInfo.Paper.Title
|
||||
}
|
||||
return c.JSON(fiber.Map{
|
||||
"sessionDate": today,
|
||||
"monitorMode": "exam",
|
||||
"monitorLabel": fmt.Sprintf("Phòng thi: %s", examInfo.Room.Name),
|
||||
"classRkId": classID,
|
||||
"className": className,
|
||||
"classCode": classCode,
|
||||
"currentPeriod": 0,
|
||||
"currentCourseName": "",
|
||||
"currentShiftStart": "",
|
||||
"currentShiftEnd": "",
|
||||
"inScheduleNow": false,
|
||||
"blockerActive": examKeywords != "",
|
||||
"allowedKeywords": examKeywords,
|
||||
"shifts": shifts,
|
||||
"exam": examPayload,
|
||||
})
|
||||
}
|
||||
|
||||
return c.JSON(fiber.Map{
|
||||
"sessionDate": today,
|
||||
"monitorMode": monitorMode,
|
||||
|
||||
Reference in New Issue
Block a user