ropensci / ruODK

ruODK: An R Client for the ODK Central API
https://docs.ropensci.org/ruODK/
GNU General Public License v3.0
42 stars 13 forks source link

form_schema_ext misses choice lists when choice filter is applied #105

Closed mtyszler closed 3 years ago

mtyszler commented 3 years ago

Problem

When using form_schema_ext the choice lists are missing for select types when a choice_filter is applied.

For example, this form has choice filters from the first question determining the list shown in the second list:

type name label choice_filter
begin group choice_filter_example Choice Filter example
select_multiple filter_example choice_filter_question_1 Select options to be shown in the next question
select_multiple filter_example choice_filter_question_2 Options are filtered name = if(selected(${choice_filter_question_1},'1'),'1',-1) or name = if(selected(${choice_filter_question_1},'2'),'2',-1) or name = if(selected(${choice_filter_question_1},'3'),'3',-1) or name = if(selected(${choice_filter_question_1},'4'),'4',-1)
end group choice_filter_example

Because the choices from the choice_filter_question_2 are dynamic. The current form_schema_ext fails to capture any of that.

Reproducible example

# set-up credentials
fsx <- form_schema_ext()
question_with_choice_list <- fsx %>% subset(name == "choice_filter_question_2") 
question_with_choice_list$choices
# [[1]]
# [1] NA
# expected content
Session Info ```{r} # utils::sessionInfo() R version 3.6.3 (2020-02-29) Platform: x86_64-w64-mingw32/x64 (64-bit) Running under: Windows 10 x64 (build 17763) Matrix products: default locale: [1] LC_COLLATE=Dutch_Netherlands.1252 LC_CTYPE=Dutch_Netherlands.1252 LC_MONETARY=Dutch_Netherlands.1252 [4] LC_NUMERIC=C LC_TIME=Dutch_Netherlands.1252 attached base packages: [1] stats graphics grDevices utils datasets methods base other attached packages: [1] ruODK_0.9.4 loaded via a namespace (and not attached): [1] Rcpp_1.0.5 rstudioapi_0.13 janitor_2.0.1 xml2_1.3.2 magrittr_1.5 tidyselect_1.1.0 [7] R6_2.5.0 rlang_0.4.8 fansi_0.4.1 stringr_1.4.0 httr_1.4.2 dplyr_1.0.2 [13] tools_3.6.3 utf8_1.1.4 cli_2.1.0 ellipsis_0.3.1 assertthat_0.2.1 tibble_3.0.4 [19] lifecycle_0.2.0 crayon_1.3.4 purrr_0.3.4 tidyr_1.1.2 vctrs_0.3.4 clisymbols_1.2.0 [25] curl_4.3 snakecase_0.11.0 glue_1.4.2 stringi_1.5.3 compiler_3.6.3 pillar_1.4.6 [31] generics_0.1.0 jsonlite_1.7.1 lubridate_1.7.9.2 pkgconfig_2.0.3 ```
mtyszler commented 3 years ago

Hi @florianm . I just updated the intro. I'll submit a PR to handle this.