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,15 +1563,18 @@ func (h *Handler) CompletePractice(c *fiber.Ctx) error {
|
||||||
Error: setErr.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"})
|
return c.Status(fiber.StatusNotFound).JSON(domain.ErrorResponse{Message: "Practice not found"})
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := h.enforcePracticeSequenceForStudent(c, set); err != nil {
|
// Enforce sequential gating only for published practices.
|
||||||
return c.Status(fiber.StatusForbidden).JSON(domain.ErrorResponse{
|
if strings.EqualFold(set.Status, "PUBLISHED") {
|
||||||
Message: "You must complete previous practices first",
|
if err := h.enforcePracticeSequenceForStudent(c, set); err != nil {
|
||||||
Error: err.Error(),
|
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 {
|
if err := h.lmsProgressSvc.CompletePracticeForUser(c.Context(), userID, set.ID); err != nil {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user