Fix partial question-set updates preserving existing values.

When PUT payload omits title, status, or shuffle_questions, reuse current persisted values so updates do not write invalid empty status values.

Made-with: Cursor
This commit is contained in:
Yared Yemane 2026-04-29 03:02:13 -07:00
parent cdb0fa1bb3
commit 8430b82687

View File

@ -923,7 +923,7 @@ func (h *Handler) UpdateQuestionSet(c *fiber.Ctx) error {
}) })
} }
title := "" title := existingSet.Title
if req.Title != nil { if req.Title != nil {
title = *req.Title title = *req.Title
} }
@ -952,6 +952,15 @@ func (h *Handler) UpdateQuestionSet(c *fiber.Ctx) error {
} }
} }
status := req.Status
if status == nil {
status = &existingSet.Status
}
shuffleQuestions := req.ShuffleQuestions
if shuffleQuestions == nil {
shuffleQuestions = &existingSet.ShuffleQuestions
}
input := domain.CreateQuestionSetInput{ input := domain.CreateQuestionSetInput{
Title: title, Title: title,
Description: req.Description, Description: req.Description,
@ -959,8 +968,8 @@ func (h *Handler) UpdateQuestionSet(c *fiber.Ctx) error {
Persona: req.Persona, Persona: req.Persona,
TimeLimitMinutes: req.TimeLimitMinutes, TimeLimitMinutes: req.TimeLimitMinutes,
PassingScore: req.PassingScore, PassingScore: req.PassingScore,
ShuffleQuestions: req.ShuffleQuestions, ShuffleQuestions: shuffleQuestions,
Status: req.Status, Status: status,
IntroVideoURL: req.IntroVideoURL, IntroVideoURL: req.IntroVideoURL,
} }