Allow completion for existing practice sets.
Treat existing PRACTICE sets as completable even when not published, while keeping sequence enforcement only for published practices. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
parent
86ab4e53d4
commit
4ada908555
|
|
@ -1563,16 +1563,19 @@ func (h *Handler) CompletePractice(c *fiber.Ctx) error {
|
|||
Error: setErr.Error(),
|
||||
})
|
||||
}
|
||||
if !strings.EqualFold(set.SetType, string(domain.QuestionSetTypePractice)) || !strings.EqualFold(set.Status, "PUBLISHED") {
|
||||
if !strings.EqualFold(set.SetType, string(domain.QuestionSetTypePractice)) {
|
||||
return c.Status(fiber.StatusNotFound).JSON(domain.ErrorResponse{Message: "Practice not found"})
|
||||
}
|
||||
|
||||
// Enforce sequential gating only for published practices.
|
||||
if strings.EqualFold(set.Status, "PUBLISHED") {
|
||||
if err := h.enforcePracticeSequenceForStudent(c, set); err != nil {
|
||||
return c.Status(fiber.StatusForbidden).JSON(domain.ErrorResponse{
|
||||
Message: "You must complete previous practices first",
|
||||
Error: err.Error(),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
if err := h.lmsProgressSvc.CompletePracticeForUser(c.Context(), userID, set.ID); err != nil {
|
||||
return c.Status(fiber.StatusInternalServerError).JSON(domain.ErrorResponse{
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user