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 {
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{
Title: title,
Description: req.Description,
@ -959,8 +968,8 @@ func (h *Handler) UpdateQuestionSet(c *fiber.Ctx) error {
Persona: req.Persona,
TimeLimitMinutes: req.TimeLimitMinutes,
PassingScore: req.PassingScore,
ShuffleQuestions: req.ShuffleQuestions,
Status: req.Status,
ShuffleQuestions: shuffleQuestions,
Status: status,
IntroVideoURL: req.IntroVideoURL,
}