@@ -140,16 +140,25 @@ func FetchAnswer(prob qatypes.Problem) (qatypes.Problem, error) {
140
140
logrus .Debugf ("Problem already solved." )
141
141
return prob , nil
142
142
}
143
- if isQuestionDisabled (prob ) {
144
- return defaultEngine .FetchAnswer (prob )
145
- }
146
143
var err error
147
144
logrus .Debug ("looping through the engines to try and fetch the answer" )
145
+ isDisabled := isQuestionDisabled (prob )
148
146
for _ , engine := range engines {
149
147
logrus .Debugf ("engine '%T'" , engine )
150
148
if prob .Desc == "" && engine .IsInteractiveEngine () {
151
149
return defaultEngine .FetchAnswer (prob )
152
150
}
151
+ if isDisabled && engine .IsInteractiveEngine () {
152
+ logrus .Debugf ("The question belongs to a disabled category so we won't ask the user for the answer" )
153
+ prob , err = defaultEngine .FetchAnswer (prob )
154
+ if err != nil {
155
+ return prob , err
156
+ }
157
+ if prob .Answer != nil {
158
+ prob = changeSelectToInputForOther (prob )
159
+ }
160
+ break
161
+ }
153
162
prob , err = engine .FetchAnswer (prob )
154
163
if err != nil {
155
164
if _ , ok := err .(* qatypes.ValidationError ); ok {
@@ -175,6 +184,13 @@ func FetchAnswer(prob qatypes.Problem) (qatypes.Problem, error) {
175
184
logrus .Debug ("there is no interactive engine" )
176
185
return prob , fmt .Errorf ("failed to fetch the answer for problem: %+v . Error: %w" , prob , err )
177
186
}
187
+ if isDisabled {
188
+ logrus .Debugf ("the question is from a disabled category so try with default engine" )
189
+ prob , err = defaultEngine .FetchAnswer (prob )
190
+ if err != nil || prob .Answer == nil {
191
+ return prob , fmt .Errorf ("failed to fetch the answer for problem: %+v . Error: %w" , prob , err )
192
+ }
193
+ }
178
194
for err != nil || prob .Answer == nil {
179
195
prob , err = lastEngine .FetchAnswer (prob )
180
196
if err != nil {
0 commit comments