Skip to content
This repository has been archived by the owner on Feb 8, 2018. It is now read-only.

Modularity #28

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
Open

Modularity #28

wants to merge 10 commits into from

Conversation

newbazz
Copy link
Contributor

@newbazz newbazz commented Sep 29, 2017

No description provided.

},
{
method: 'get',
path: '/:qno/getall',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dont put getall at the back. A GET request already implies that

@@ -10,24 +10,40 @@ export async function get(ctx) {
}

export async function checkAnswer(ctx) {
//var wrongAttempts=0
var correctAttempts=0
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use let instead of var

},
})
for(var i in preAnswered){
if (preAnswered[i].useranswer in JSON.parse(question.answer))
Copy link
Member

@ironmaniiith ironmaniiith Sep 30, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Store the output of JSON.parse(question.answer) in a variable outside the for loop and use it wherever required. It will avoid recomputing it everytime.

@@ -43,7 +44,7 @@ export async function checkAnswer(ctx) {
}
ctx.body = { response: true }
}
else if(correctAttempts==1) ctx.body = { response: "Already attempted" }
else if(correctAttempts==1 && (ctx.body.answer in answers)) ctx.body = { response: "Already attempted" }
Copy link
Member

@ironmaniiith ironmaniiith Sep 30, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do not put this second condition && (ctx.body.answer in answers), as we would like to send the response as Already attempted irrespective of whether the current answer is right or wrong

@Pk13055
Copy link

Pk13055 commented Oct 10, 2017

Fixes #30

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants