Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When user submits answer, goes to next question, and comes back, the state doesn't remain #108

Open
austintackaberry opened this issue Jul 2, 2018 · 4 comments
Labels
good first issue Good for newcomers help wanted Extra attention is needed

Comments

@austintackaberry
Copy link
Owner

If the user answers a questions (correctly or incorrectly), the state of that page should not be any different than it was when they left.

awesomescreenshot-2018-07-02t00-04-06-824z

@austintackaberry austintackaberry added help wanted Extra attention is needed good first issue Good for newcomers labels Jul 2, 2018
@rreubenreyes
Copy link
Collaborator

I'm curious as to what the best solution to this is. I actually want to say that we should allow users to re-answer questions if they want to (say they want to review or something), but I agree that there should be some indicator that the user has interacted with that question before, like a banner indicating as such? What do you think?

@austintackaberry
Copy link
Owner Author

I definitely think that users should be able to re-answer as many times as they like. But I think users would want to remember what they answered. Especially when they go to the next question and then go right back.

Maybe we could have a "reset" option that wipes away the state. This option would be for users who are using it like a quiz.

@sterlingdeng
Copy link

would it be possible to implement like a Map() as a state, with the key : value pair to be problem ID : selected answer?
Whenever previous or next is selected, it first Map.has(problem id) to see if the question has been answered before, and if it returns true, it renders the state based on the selected answer. and if Map.has(problem id) returns false, renders page as if user has not seen the question, and then when submit is clicked, save the problem id : answer pair in the Map()

@austintackaberry
Copy link
Owner Author

I don't think we will have to use a Map. The questionId is a string, so a plain old object will do. Since we lose the question state every time we move to a new question, I think we would have to use React Context API for this.

We could save this info in bookScores -> (https://github.com/austintackaberry/ydkjs-exercises/blob/master/src/score-context.js)

Or we could make a whole new object that only has questionId as the key and whatever state we want to keep as the value.

My personal opinion is that we should save it in bookScores since we are already saving some question state in there (correct, incorrect, or unanswered)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

3 participants