From 49731707c69fcc88b29a4ca26a55232db2a736e3 Mon Sep 17 00:00:00 2001 From: Akash Nayak Date: Fri, 15 Mar 2024 19:01:17 +0530 Subject: [PATCH] feat: Update QA rest engine to support enabling and disabling QA categories when using the API Signed-off-by: Akash Nayak --- qaengine/httprestengine.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/qaengine/httprestengine.go b/qaengine/httprestengine.go index 01fc8c280..0d3b24454 100644 --- a/qaengine/httprestengine.go +++ b/qaengine/httprestengine.go @@ -99,6 +99,16 @@ func (h *HTTPRESTEngine) FetchAnswer(prob qatypes.Problem) (qatypes.Problem, err if err := ValidateProblem(prob); err != nil { return prob, fmt.Errorf("the QA problem object is invalid. Error: %w", err) } + probCategories := qatypes.GetProblemCategories(prob.ID, prob.Categories) + for _, category := range probCategories { + if common.IsStringPresent(common.DisabledCategories, category) { + if err := prob.SetAnswer(prob.Default, true); err != nil { + return prob, fmt.Errorf("failed to set the given solution as the answer. Error: %w", err) + } + return prob, nil + } + } + if prob.Answer != nil { return prob, nil }