diff --git a/internal/api/problem/update.go b/internal/api/problem/update.go index 7977640..8c1d5ba 100644 --- a/internal/api/problem/update.go +++ b/internal/api/problem/update.go @@ -84,6 +84,16 @@ func (h *handler) Update(c *gin.Context) { return } + // if IsEnabled is set to true, check if the problem has a latest version + if req.IsEnabled { + _, status := h.problemService.QueryLatestVersion(p.ID) + if status != e.Success { + e.Pong[any](c, status, nil) + return + } + p.IsEnabled = true + } + // update problem p.Title = utils.If(req.Title != "", req.Title, p.Title) p.Statement = utils.If(req.Statement != "", req.Statement, p.Statement) @@ -92,7 +102,6 @@ func (h *handler) Update(c *gin.Context) { _ = tags.Set(req.Tags) p.Tags = tags } - p.IsEnabled = req.IsEnabled p, status = h.problemService.Update(p) e.Pong(c, status, p)