diff --git a/qaengine/cliengine.go b/qaengine/cliengine.go index f715a0456..50b727cfa 100644 --- a/qaengine/cliengine.go +++ b/qaengine/cliengine.go @@ -51,21 +51,6 @@ func (c *CliEngine) FetchAnswer(prob qatypes.Problem) (qatypes.Problem, error) { logrus.Errorf("the QA problem object is invalid. Error: %q", err) return prob, err } - // return default if the category is skipped - probCategories := qatypes.GetProblemCategories(prob.ID, prob.Categories) - for _, category := range probCategories { - if common.IsStringPresent(common.DisabledCategories, category) { - // if prob.Default == nil { - // // todo: warn instead of returning error - // return prob, errors.New(fmt.Sprintf("category %s is skipped but default doesn't exist", category)) // TODO: - // } - 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 - } - } - switch prob.Type { case qatypes.SelectSolutionFormType: return c.fetchSelectAnswer(prob) diff --git a/qaengine/engine.go b/qaengine/engine.go index d5179f0e0..f1bbc0a4f 100644 --- a/qaengine/engine.go +++ b/qaengine/engine.go @@ -118,6 +118,19 @@ func SetupConfigFile(writeConfigFile string, configStrings, configFiles, presets } } +func isQuestionDisabled(prob qatypes.Problem) bool { + isDisabled := false + probCategories := qatypes.GetProblemCategories(prob.ID, prob.Categories) + for _, category := range probCategories { + if common.IsStringPresent(common.DisabledCategories, category) { + logrus.Debugf("Question belongs to the disabled category: %s", category) + isDisabled = true + break + } + } + return isDisabled +} + // FetchAnswer fetches the answer for the question func FetchAnswer(prob qatypes.Problem) (qatypes.Problem, error) { logrus.Trace("FetchAnswer start") @@ -127,6 +140,9 @@ func FetchAnswer(prob qatypes.Problem) (qatypes.Problem, error) { logrus.Debugf("Problem already solved.") return prob, nil } + if isQuestionDisabled(prob) { + return defaultEngine.FetchAnswer(prob) + } var err error logrus.Debug("looping through the engines to try and fetch the answer") for _, engine := range engines {