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

Checkboxes not recording value #50

Open
IanEisenberg opened this issue Apr 25, 2016 · 22 comments
Open

Checkboxes not recording value #50

IanEisenberg opened this issue Apr 25, 2016 · 22 comments

Comments

@IanEisenberg
Copy link
Member

IanEisenberg commented Apr 25, 2016

For checkboxes, value is recorded merely as "on" or "off", instead of the boxes actually checked. So "what is your race" just gives us "on". Involves this function

@vsoch
Copy link
Member

vsoch commented Apr 25, 2016

I think your link is broken. It's not clear from the description what you are describing (data export?) Why is having on/off a problem? It is still an indicator of checked / not checked.

@IanEisenberg
Copy link
Member Author

Sure, that's fine, but some questions have multiple checkboxes and only output one value.

For example, here is an output of one demographics questions "What is your race" which has multiple possible options like this:

screenshot from 2016-04-24 19 30 26

The data output looks like:

index                                                           4
battery                                     Self Regulation Pilot
experiment                                    demographics_survey
finishtime                            ...
id                                  demographics_survey_6_options
options         [{u'text': u'American Indian or Alaska Native'...
question_num                                                    6
required                                                        1
response                                                       on
text                                           What is your race?
worker                       ...

where options are:

[{u'id': u'demographics_survey_6_0',
  u'text': u'American Indian or Alaska Native'},
 {u'id': u'demographics_survey_6_1', u'text': u'Asian'},
 {u'id': u'demographics_survey_6_2', u'text': u' Black or African American'},
 {u'id': u'demographics_survey_6_3',
  u'text': u'Native Hawaiian or Other Pacific Islander'},
 {u'id': u'demographics_survey_6_4', u'text': u'White'},
 {u'id': u'demographics_survey_6_5', u'text': u'Choose not to respond'},
 {u'id': u'demographics_survey_6_6', u'text': u'Other'}]

@vsoch
Copy link
Member

vsoch commented Apr 25, 2016

Ah I see, we will need to export differently! Thanks the the clarification.

@vsoch
Copy link
Member

vsoch commented Apr 25, 2016

image

@vsoch vsoch closed this as completed Apr 25, 2016
@IanEisenberg
Copy link
Member Author

I'm not seeing the data updated in the export. Does this line need to be updated to match this one?

@IanEisenberg
Copy link
Member Author

IanEisenberg commented Apr 25, 2016

Nevermind. Everything looks good.

@vsoch
Copy link
Member

vsoch commented Apr 25, 2016

:)

@IanEisenberg
Copy link
Member Author

I comment too quickly, sorry @vsoch!

Responses are recorded now, but they do not record multiple checks.

A response like this:
screenshot from 2016-04-25 13 08 25

Only records "American Indian or Alaska Native"

@vsoch
Copy link
Member

vsoch commented Apr 25, 2016

Each entry is exported as a separate response with the same question ID.

@vsoch
Copy link
Member

vsoch commented Apr 25, 2016

eg, here I checked three, and the result exports all three for demographics_survey_6_options question:

image

@vsoch
Copy link
Member

vsoch commented Apr 25, 2016

and looks like there is a bug in that survey, an extra space with "Black or African American" if you want to fix.

@IanEisenberg
Copy link
Member Author

Sure, I'll fix the typo.

Something is lost in translation - the data I'm getting out using expanalysis (even just the get_results function you wrote, just to make sure I am avoiding any problem) does not have those multiple entries. I'll make another dataset and double check I'm not missing anything.

@vsoch
Copy link
Member

vsoch commented Apr 25, 2016

get_results is parsing data from the api, correct?

@IanEisenberg
Copy link
Member Author

IanEisenberg commented Apr 25, 2016

yes.

It uses this function

@vsoch
Copy link
Member

vsoch commented Apr 25, 2016

The results in the API from the surveys are not going to magically change - the data that was exported when the surveys submit is recorded and done, you cannot re-obtain values from the form that were not rendered in it.

New surveys that are submit will have what I pasted above, as a value field has been added to checkboxes to replace the default "on." Try doing the demographics survey as a preview to see the change. Let me know if I am misunderstanding something.

@IanEisenberg
Copy link
Member Author

Oh, I know. I am only looking at a demographics survey that I created recently (the old ones obviously have the 'on' value.
Here's what the data looks like that I created. You can see that there is only one row for "demographics_survey_6_options".

screenshot from 2016-04-25 13 47 14

Like I said, let me create another dataset, verify this bug, and look into it a bit more before you waste your time. You have a talk tomorrow :)

@vsoch
Copy link
Member

vsoch commented Apr 25, 2016

Talk tomorrow? Meh, not doing anything special for that. I'll look into this.

@vsoch
Copy link
Member

vsoch commented Apr 25, 2016

My instinct is that given that the result is submit as form data, having an equivalent "name" variable for the checkboxes only submits the first. It works for the preview and locally because the result export is done with jquery.

@vsoch
Copy link
Member

vsoch commented Apr 25, 2016

ok, I've verified this is the issue. The name variable needs to be changed to be unique for the different checkboxes. However, this breaks the validation. If you could please fix the validation to not rely on the name variable, I will then make the checkbox names unique, and the error should be resolved. Thanks!

@vsoch vsoch reopened this Apr 25, 2016
@IanEisenberg
Copy link
Member Author

The reason the validation uses the name variable is precisely because it is shared across checkboxes - we don't want to check whether each checkbox is clicked - but only whether at least one of a type was checked. So I need a way of grouping checkboxes to check if at least one was checked.

So to change the validation I need some sense of how you are changing the name. For instance, now the names are "demographics_survey_2_options". Will you change the names to "demographics_survey_2_options_1", "demographics_survey_2_options_2", etc? That way I can select the questions by a "base" name like "demographics_survey_2_options" and check like that.

@vsoch
Copy link
Member

vsoch commented Apr 27, 2016

We can add any attributes that you want to the boxes to make it work. I would generate a dummy static version, get it working with any additional variables you need, and send to me to update expfactory Python to render as such.

@IanEisenberg
Copy link
Member Author

Cool, I'll do that.

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

No branches or pull requests

2 participants