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

Leading space in Checkbox option causes choices to be omitted #495

Closed
BlairCooper opened this issue Jul 13, 2023 · 0 comments · Fixed by #496
Closed

Leading space in Checkbox option causes choices to be omitted #495

BlairCooper opened this issue Jul 13, 2023 · 0 comments · Fixed by #496

Comments

@BlairCooper
Copy link
Contributor

Describe the behavior: If an option for a checkbox is proceeded with a space the regular expression for extracting the checkbox choices will omit the option with the leading space and the one before it.

Assume the options for a REDCap checkbox field are set as follows: (note leading space on option 3)

1, Depressive mood disorder
2, Adjustment disorder
 3, Personality disorder
4, Anxiety
0, Not Noted

The resulting value in the "select_choices_or_calculations" field will be as follows: (note the missing space a the end of "Adjustment disorder")

"1, Depressive mood disorder | 2, Adjustment disorder| 3, Personality disorder | 4, Anxiety | 0, Not Noted" (note the missing space a the end of "Adjustment disorder"

Calling checkbox_choices() will only return choices 1, 4 and 0.

Expected behavior: All of the checkbox options are returned from checkbox_choices().

Desktop (please complete the following information):

  • OS: Windows 10
  • REDCap version 13.7.5
  • REDCapR Version 1.1.0

Additional context:
Confirmed this behavior with this test case:

test_that("checkbox choices with errant space", {
  choices_1 <- "1, Depressive mood disorder | 2, Adjustment disorder| 3, Personality disorder | 4, Anxiety | 0, Not Noted"
  ds_boxes <- checkbox_choices(select_choices=choices_1)

  ds_expected <- structure(
    list(
      id = c("1", "4", "0"),
      label = c("Depressive mood disorder", "Anxiety", "Not Noted")
    ),
    class = c("tbl_df", "tbl", "data.frame"),
    row.names = c(NA, -3L)
  )

  expect_equal(ds_boxes, expected=ds_expected, label="The returned data.frame should be correct")
  expect_s3_class(ds_boxes, "tbl")
})
@BlairCooper BlairCooper changed the title Unexpected Behavior: Leading space in Checkbox option causes choices to be omitted Leading space in Checkbox option causes choices to be omitted Jul 13, 2023
wibeasley added a commit that referenced this issue Jul 14, 2023
wibeasley added a commit that referenced this issue Jul 14, 2023
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.

1 participant