UdacityMobileWebScholarship / guess-quote

This application is a collaborative project made by the Google Udacity Mobile Web Specialist Scholars.
MIT License
22 stars 48 forks source link

API Creation #36

Closed twishasaraiya closed 6 years ago

twishasaraiya commented 6 years ago

I can think of the following

Please let us know your suggestions here.

danivijay commented 6 years ago

What about fetching quote and options together? Like GET Question?? @twishasaraiya

anurag-majumdar commented 6 years ago

Truth is, our MongoDB schema will be somewhat like: questions: [ { question: "...", options: ["....", "..."], answer: ["..."] }, // Continues ]

So during fetching of each of the questions, there will be requirement of just one GET request as @danivijay mentioned. Regarding the customizing of options as @twishasaraiya once told me, if there are 6 options we can use a random option generator function to generate random options (3 of them) from the options list and add the answer as a default to it to make it 4 options.

Let me know what you guys think regarding this?

ashwani99 commented 6 years ago

I agree with @anurag-majumdar I will suggest a minor change to the schema

questions: [
    {
        question: "...",
        answer: "..."  
    },
    ...
],
options: [
    'optionone',
    'optiontwo',
    ...
]

To keep things simple, we can process the GET /question as:

Adding an options list will help us not store redundant data and will help us in future when we add more questions.

@twishasaraiya Regarding score update, I have one doubt. Will there be a profile for every player or we just have to remember the current score and forget it when a new game is played or user logs out. I think as a starting point to make things simple, we can just remember the current score in a single game. The client side can take care of this. So the flow will look like:

anurag-majumdar commented 6 years ago

Looks great @ashwani99 . Can I make a PR to make the initial part of the schema for MongoDB using Mongoose?

skyshader commented 6 years ago

@anurag-majumdar Sure, take it on. Thanks again for contributing. :)

ashwani99 commented 6 years ago

@skyshader I want to work on the API using ExpressJS. May I take that? I will work with @anurag-majumdar

anurag-majumdar commented 6 years ago

@ashwani99 Sounds great. You will be making changes to the route request and adding controllers I guess?

sounak07 commented 6 years ago

I would like to take something as well.

ashwani99 commented 6 years ago

@anurag-majumdar Yes

skyshader commented 6 years ago

@ashwani99 do submit your own PRs. Note that working on something with dependencies needs a lot of collaboration and merges :)

So what I understand is: @anurag-majumdar is taking up the schema creation for Quotes model. @ashwani99 is taking up API creation for getting the quotes (This is tricky, lets discuss this further)

Some of the concerns while creating the API is:

  1. One question per request
  2. Random questions
  3. Can't be repeated unless all options are exhausted.

Let's discuss.

skyshader commented 6 years ago

@sounak07 You can take UserAnswers which would contain user, the question they answered and if they were right or wrong with a score. Let's discuss this in a separate issue thread. Right now we are talking about schema creation. We will move to API next.

JoyBoy-369 commented 6 years ago

Yeah, I'd like to take something up as well... been away for a couple of days.

skyshader commented 6 years ago

@SevenSinS02 and others, please ask the questions not related to issues on slack channel. Let's keep the issues with relevant discussions.

ashwani99 commented 6 years ago

@skyshader Nice points. So my suggestions will go like this:

  1. Not necessarily. We can send a query param limit which will send us that many questions. Or rather make it a constant if the number of questions are same for every game.
  2. I didn't understand this concern. Can you please elaborate?
  3. Options can get repeated(not in a single question). I see no issue with this. If you're concerned about same option coming again and again in a game, we can rectify it by adding more options. We can even make another layer by storing those options in chunks, so while choosing a set of options, we can just pick one from each chunk

If we are using the limit query param, we can have another GET endpoint for /options which will be handled as explained in 3

skyshader commented 6 years ago

@ashwani99

  1. Number of questions are fixed to one. We will be having one question per screen.
  2. These questions will not come in same order if I play again.
  3. I meant if I attempted a certain question I don't want it to repeat for a significant amount of questions. Because if questions are random, it can appear just next or after one question.
ashwani99 commented 6 years ago

@skyshader

  1. So I think we're good with this. One question per request.
  2. As picking question will be done randomly, it's unlikely that this scenario will happen. We can add more questions to negate this scenario.
  3. Okay so what we can do is generate a set of identifiers for the questions like id. We will have /questions?limit=<number-of-questions> which will return a list of ids of questions chosen at random. Then for each question we will make /quote/<id> which will return us the question, answer and the options For example, /questions?limit=3 will return:
    {
    'ids': [5, 8, 2]
    }

    Then for each quote we will request to /quote/5, /quote/8 and /quote/2

skyshader commented 6 years ago

I think we need @twishasaraiya 's input here. Do we want to make it a continuous game play or do we want to keep a quiz session of let's say 10 questions and declare the results. If that's answered we would know what steps we need to take to achieve this.

anurag-majumdar commented 6 years ago

@skyshader I am adding the schema in a new file in develop branch. Will send a PR soon.

twishasaraiya commented 6 years ago

@skyshader and @ashwani99 This is how I have thought about it. Suppose each question is of 100 points, I would like to continue the game till the user reaches 1000 points(If the user gets first 10 question right he wins) else the game continues till he reaches 1000 points. The user can leave the game at any point if he wishes too. Let me know what you guys think.

ashwani99 commented 6 years ago

@twishasaraiya That eliminates the competitiveness. If there are a limited number of questions, user can share that score on social media that will attract new users. I think we should have either a constant number of questions(like 10) or let the user choose number of questions. What do you think? @skyshader

twishasaraiya commented 6 years ago

@ashwani99 I think we should maybe allow the user to select his target in the number of points(like a goal) he wishes to achieve instead of the number of questions.

anurag-majumdar commented 6 years ago

@danivijay @twishasaraiya @skyshader @ashwani99 Added a pull request for the initial question model file. The PR is for develop branch.

ashwani99 commented 6 years ago

@anurag-majumdar I would suggest please move the discussion regarding the DB model to another issue

anurag-majumdar commented 6 years ago

@ashwani99 sure.

skyshader commented 6 years ago

So since we have the basic schema ready, i think we should start looking into the API bit.

Please acknowledge who is taking up the task and let's get started with the development :)

anurag-majumdar commented 6 years ago

I would like to contribute to one of the routes setup for API with schema. @skyshader

VinayV9 commented 6 years ago

i liked to work on backend part is their any features left to do?? @twishasaraiya @skyshader

ashwani99 commented 6 years ago

@skyshader I wanted to take the API creation part https://github.com/UdacityMobileWebScholarship/guess-quote/issues/36#issuecomment-383617589 May I take this?

skyshader commented 6 years ago

Yes, @ashwani99 @anurag-majumdar take it away. Do comment which API you guys will be working on down below. :)

anurag-majumdar commented 6 years ago

@skyshader @ashwani99 I think we need to setup a route for questions in server. Can I work on setting up the routes for the question part? Then @ashwani99 can work on the API GET /questions part.

Or we can negotiate on both.

suhasbansude commented 6 years ago

What about UPDATE Score?? I think we need new collection for Score Details.

anurag-majumdar commented 6 years ago

@suhasbansude There is a high possibility that the score of the quiz won't be saved initially. I guess the back-end of the app is almost ready except for the randomizing and fetching of questions part.

skyshader commented 6 years ago

The API for getting random set of questions is done and we are planning to keep the scoring offline for now. Hence closing this.