-
Notifications
You must be signed in to change notification settings - Fork 48
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
Trailing newline in Checkbox option causes choice to omitted #501
Comments
fixes OuhscBbmc#501 - Modified pattern_checkboxes regular expression to allow for case where there is no space in front of the pipe character in the Lookbehind and Lookahead expressions, and allow the space(s) after the comma to be optional. - Created test case to verify correct handling when a checkbox options has a trailing newline. - Created test case to verify correct handling when the space is missing after the comma for an option.
@BlairCooper, man you're devious. I like it. Did you see #500? I think that approach will be more robust. Will you try that branch? Conceptually, extra lines shouldn't make a difference. readr will just ignore them. Try this around line 50 of the test file. # extra lines
"| | 1, American Indian/Alaska Native | | | -2, Asian | 3, Native Hawaiian or Other Pacific Islander | 4, Black or African American | 5, White | 66, Unknown / Not Reported | | | " |>
checkbox_choices() |>
expect_equal(ds_expected, label = "extra lines:") |
@BlairCooper, I just read through your commit more carefully. I like all the detail in the regex explanation. That's a good way to explain it. I was having trouble keeping track of the parts. |
@wibeasley Re: CSV, see comments on #500 |
As a result of the scenario you raised in this issue, PR #504 addresses extra new lines. Thank you. |
Describe the behavior: If there is an extra newline after the last option for a checkbox, the regular expression for extracting the checkbox choices will omit the last option.
Assume the options for a REDCap checkbox field are set as follows: (note trailing newline after the last option)
The resulting value in the "select_choices_or_calculations" field will be as follows: (note the extra trailing pipe at the end)
Calling checkbox_choices() will only return choices 1 through 4, omitting 0.
Expected behavior: All of the checkbox options are returned from checkbox_choices().
Desktop (please complete the following information):
Additional context:
Side note: It is actually now not possible to create these scenarios in REDCap 13.7.5. Looks like they've added JavaScript to clean up the options when the field is saved. I was encountering these issues with fields that had been setup with an earlier version of REDCap. So you can't create these scenarios in 13.7.5 but they can still exist in that version.
The text was updated successfully, but these errors were encountered: