-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Add poll questions that accept multiple answers per user #5012
Conversation
6cbe3c2
to
e5dc702
Compare
82e36ed
to
dde5dd5
Compare
0700282
to
fce3acb
Compare
Hi @javierm, thanks for the review. I think I applied all the suggestions 👌🏼 . The only thing I kept the same is the text mentioned in your comment: #discussion_r996903531. Not sure what to do about it 🤔 |
<p> | ||
<strong><%= t("admin.polls.votation_type.title") %></strong> | ||
<br> | ||
<%= VotationType.human_attribute_name("votation_type/vote_type.#{@question.vote_type}") %> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can simplify this line a bit:
<%= VotationType.human_attribute_name("votation_type/vote_type.#{@question.vote_type}") %> | |
<%= VotationType.human_attribute_name("vote_type.#{@question.vote_type}") %> |
@@ -10,16 +10,18 @@ def already_answered?(answer) | |||
user_answers.find_by(answer: answer.title).present? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we can now reuse the new method 🤔.
user_answers.find_by(answer: answer.title).present? | |
user_answer(answer).present? |
method: :delete, | ||
remote: true, | ||
title: t("poll_questions.show.voted", answer: question_answer.title), | ||
class: "button answered expand", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does the expand
class do anything? 🤔 Since it isn't present in the button to remove the question, I guess it's a typo.
class: "button answered expand", | |
class: "button answered", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No. Removed.
In this context, `this` already points to the element, so there is no need to search it again.
In case we receive consecutive requests we are locking the poll author record until the first request transaction ends, so the author answers count during subsequent requests validations is up to date.
dde5dd5
to
8311e7e
Compare
fce3acb
to
45eabf1
Compare
Now we can remove answers we should provide a way of removing voting.
The `reload` method added to max_votes validation is needed because the author gets here with some changes because of the around_action `switch_locale`, which adds some changes to the current user record and therefore, the lock method raises an exception when trying to lock it requiring us to save or discard those record changes.
45eabf1
to
1eb52fb
Compare
References
This PR includes the multiple questions part of the original PR:
This PR depends on:
Objectives
Add a new type of question where the users can select multiple answers.
Visual Changes
Check original PR screenshots related to multiple answers.
The only difference for questions with multiple answers is that now buttons are disabled when the user reaches the maximum of answers allowed.