Skip to content

Commit

Permalink
feat: Update QA rest engine to support enabling and disabling QA cate…
Browse files Browse the repository at this point in the history
…gories when using the API

Signed-off-by: Akash Nayak <[email protected]>
  • Loading branch information
Akash-Nayak committed Mar 20, 2024
1 parent c8164a0 commit 4973170
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions qaengine/httprestengine.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down

0 comments on commit 4973170

Please sign in to comment.