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

Commas used in answers cause problems with results calculations #19

Closed
alexnesbitt opened this issue May 11, 2014 · 14 comments · Fixed by #34
Closed

Commas used in answers cause problems with results calculations #19

alexnesbitt opened this issue May 11, 2014 · 14 comments · Fixed by #34

Comments

@alexnesbitt
Copy link

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.

@iffyuva
Copy link
Member

iffyuva commented May 12, 2014

maybe we can have a config, where we can change delimiter. say from , to : ?

@alexnesbitt
Copy link
Author

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 [email protected] 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.

@alain-andre
Copy link
Contributor

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 ?

@iffyuva
Copy link
Member

iffyuva commented May 13, 2014

+1 for config, but im not in favor of utf-8 chars.
@gnufied suggested to use \r\n\r\n, which web uses.

@alain-andre
Copy link
Contributor

+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.

@alexnesbitt
Copy link
Author

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)

@iffyuva
Copy link
Member

iffyuva commented May 19, 2014

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)

@iffyuva
Copy link
Member

iffyuva commented May 19, 2014

@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.

@alexnesbitt
Copy link
Author

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.

@iffyuva
Copy link
Member

iffyuva commented May 20, 2014

@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.

@alexnesbitt
Copy link
Author

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 [email protected] 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

@iffyuva
Copy link
Member

iffyuva commented May 20, 2014

i think i should have explained it better: rendering multiple answers associated with a single question (checkbox) was an issue:

  1. we have to iterate over all the existing answers, and it didn't seem very straightforward.
  2. 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 :)

@alexnesbitt
Copy link
Author

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 [email protected] 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.

@iffyuva
Copy link
Member

iffyuva commented May 20, 2014

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.

jfr added a commit to jfr/rapidfire that referenced this issue Feb 16, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants