Commas used in answers cause problems with results calculations
alexnesbitt opened this issue · 14 comments
If you use a comma within an answer it causes a problem with results.
for example, If my answer is "no, that is not right" the results will tabulate 1:"no" and 1:"that is not right"
I think the answers are being counted by splitting on a comma which leads to this problem. Not sure how to fix it.
maybe we can have a config, where we can change delimiter. say from ,
to :
?
I think it's splitting an array based on commas and commas within the array elements are getting split.
Sent from my iPhone
On May 11, 2014, at 8:22 PM, Yuva notifications@github.com wrote:
maybe we can have a config, where we can change delimiter. say from , to : ?
—
Reply to this email directly or view it on GitHub.
Hi, I'm having the same problem with comma. I think it comes from the flatten :
rapidfire / app / services / rapidfire / question_group_results.rb
answers = question.answers.map(&:answer_text).map { |text| text.split(',') }.flatten
I'm not sure there is a better way than changing the comma in something else (with a config or not). When changing this delimiter, could we use §
or |
as it has huge chance not to be in the answer_text ?
I have listed the functions I think that should be changed :
- save! in rapidfire / app / services / rapidfire / answer_group_builder.rb
- extract in rapidfire / app / services / rapidfire / question_group_results.rb
- checkbox_checked? in rapidfire / app / helpers / rapidfire / application_helper.rb
What do you think ?
+1 for config, but im not in favor of utf-8 chars.
@gnufied suggested to use \r\n\r\n
, which web uses.
+1 for config and \r\n\r\n
.
I used to split with \n
in perl, I should have think about it ;p good idea @gnufied.
I think this will give the results without having to worry about commas or special characters.
answers = question.answers.group(:answer_text).count(:answer_text)
work is under progress in this branch: provide-delimiter-config-for-answers
. please feel free to test that branch. i have to write a rake task to convert the existing questions and answers to use new delimiter (if required)
@alexnesbitt there is a slight catch with
answers = question.answers.group(:answer_text).count(:answer_text)
in case of checkboxes, we store all the answers in answer_text
with a delimiter. so, count
wont help in that case.
Why do you treat checkboxes that way? Why not just store each answer that gets checked as it's own answer? That way, count will work fine.
@alexnesbitt we have a usecase where user can see his/her answers against a questionnaire, and modify them. it becomes easy to populate the form again, if we have only answer, rather than a bunch of answers. i haven't faced any difficulties so far, so i guess we are good.
I don't understand why having multiple answers is an issue for rendering a
user's answer group. It should be pretty simple to get the questions, get
the question's answers, iterate and set the matched values to true.
But it's not an issue for me so no need to change things for me.
On Mon, May 19, 2014 at 8:35 PM, Yuva notifications@github.com wrote:
@alexnesbitt https://github.com/alexnesbitt we have a usecase where
user can see his/her answers against a questionnaire, and modify them. it
becomes easy to populate the form again, if we have only answer, rather
than a bunch of answers. i haven't faced any difficulties so far, so i
guess we are good.—
Reply to this email directly or view it on GitHubhttps://github.com//issues/19#issuecomment-43583332
.
Alex Nesbitt
Digital Podcast
562-824-5193
Connect with me on:
Digital Podcast http://www.digitalpodcast.com/company
LinkedIn: http://www.linkedin.com/in/alexnesbitt
Facebook: http://www.facebook.com/alexnesbitt
Twitter: http://twitter.com/alexnesbitt
i think i should have explained it better: rendering multiple answers associated with a single question (checkbox) was an issue:
- we have to iterate over all the existing answers, and it didn't seem very straightforward.
- updating answers seemed difficult, say user is updating questionnaire, and changed answers to a checkbox. now backend should delete individual answers which are unchecked. it was becoming bit of work.
@alexnesbitt thanks for bringing this up. i will keep this solution at the back of mind, and implement it if i get into trouble in future :)
I understand the problem of trying to sync the answer when something that is becomes something that isn't. Very tough.
In this case, I would delete all the answers in the answer group in case of an update and create new answers for whatever the user submits in their edit form.
Thanks for what you have built. It was the best I could find for my use case.
My bigger problem is scalability. Neither the method you use or the count method is going to work with Very high volume. I'm thinking I need to combine your approach to building the questionnaire with something like redis to keep the totals ready for a responsive view with 1000s if answer groups
Sent from my iPhone
On May 19, 2014, at 9:43 PM, Yuva notifications@github.com wrote:
i think i should have explained it better: rendering multiple answers associated with a single question (checkbox) was an issue:
we have to iterate over all the existing answers, and it didn't seem very straightforward.
updating answers seemed difficult, say user is updating questionnaire, and changed answers to a checkbox. now backend should delete individual answers which are unchecked. it was becoming bit of work.
@alexnesbitt thanks for bringing this up. i will keep this solution at the back of mind, and implement it if i get into trouble in future :)—
Reply to this email directly or view it on GitHub.
nice :)
im looking forward to those scalability issues. maybe i can learn a thing or two, if you can share your experience, as in how you have solved those problems.