diff --git a/src/controllers/question.js b/src/controllers/question.js index f9e5046..03eeeba 100644 --- a/src/controllers/question.js +++ b/src/controllers/question.js @@ -35,7 +35,7 @@ export async function checkAnswer(ctx) { await UserAnswer.create( { questionId: question.id, userId: user.id, useranswer: ctx.body.answer} ) - if (correctAttempts==0) { + if (correctAttempts==0 && (ctx.body.answer in answers)) { const { user } = ctx.state if (user.maxUnlock == qno) { user.maxUnlock += 1 @@ -44,7 +44,7 @@ export async function checkAnswer(ctx) { } ctx.body = { response: true } } - else if(correctAttempts==1 && (ctx.body.answer in answers)) ctx.body = { response: "Already attempted" } + else if(correctAttempts==1) ctx.body = { response: "Already attempted" } else ctx.body = { response: false } }