Skip to content

Commit

Permalink
spanish characters; annotations
Browse files Browse the repository at this point in the history
ref #360
  • Loading branch information
wibeasley committed Nov 3, 2021
1 parent 9c14f5d commit d6d3ff0
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 7 deletions.
29 changes: 23 additions & 6 deletions inst/test-data/super-wide-3/generate-dictionary.R
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ ds <-
`Text Validation Min` = "",
`Text Validation Max` = "",
`Identifier?` = NA_character_,
`Branching Logic (Show field only if...)` = "",
`Branching Logic (Show field only if...)` = NA_character_,
`Required Field?` = NA_character_,
`Custom Alignment` = NA_character_,
`Question Number (surveys only)` = "",
Expand All @@ -37,17 +37,34 @@ ds <-
`Field Label` = sprintf("Long description for variable %s", `Variable / Field Name`),
`Field Note` = sprintf("Field note %s", `Variable / Field Name`),
`Identifier?` = dplyr::if_else(variable_index %% 4 == 0L, "y", ""),
`Branching Logic (Show field only if...)` = dplyr::if_else(variable_index %% 10 == 0L, "[variable_12345] = '1'", ""),
`Required Field?` = dplyr::if_else(variable_index %% 2 == 0L & `Field Type` != "descriptive", "y", ""),
`Custom Alignment` = dplyr::if_else(variable_index %% 5 == 0L, "RH", ""),
) |>
dplyr::mutate(
`Field Annotation` = dplyr::if_else(variable_index %% 6 == 0L, " @READONLY", ""),
`Field Annotation` = dplyr::if_else(variable_index %% 7 == 0L, " @HIDDEN", ""),
`Field Annotation` = dplyr::if_else(variable_index %% 8 == 0L, " @SHARED", ""),
`Field Annotation` = dplyr::if_else(variable_index %% 9 == 0L, " @DEFAULT='-1'", ""),
`Field Annotation` = dplyr::if_else(variable_index %% 10 == 0L, " @NOW", ""),
`Field Annotation` = dplyr::if_else(variable_index %% 6 == 0L, paste(`Field Annotation`, "@READONLY"), ""),
`Field Annotation` = dplyr::if_else(variable_index %% 7 == 0L, paste(`Field Annotation`, "@HIDDEN"), ""),
`Field Annotation` = dplyr::if_else(variable_index %% 8 == 0L, paste(`Field Annotation`, "@SHARED"), ""),
`Field Annotation` = dplyr::if_else(variable_index %% 9 == 0L, paste(`Field Annotation`, "@DEFAULT='-1'"), ""),
`Field Annotation` = dplyr::if_else(variable_index %% 10 == 0L, paste(`Field Annotation`, "@NOW"), ""),
)

# Get a label with things that could potentially mess up JSON if the parser is poor.
ds$`Field Label`[2] <-
'
<span lang="en">{Name of University} is one part of a super awesome study.
We will also collect some small biological samples, such as saliva.
Do you have any questions about what the study involves?</span>
<span lang="es">La {nombre de la universidad} forma parte de un estudio fabuloso.
También se colectará algunas muestras biológicas, como saliva.
¿Tiene alguna pregunta sobre lo que implica el estudio?</span>"
'

ds$variable_index <- NULL # Drop before writing to disk.

readr::write_csv(ds, "inst/test-data/super-wide-3/super-wide-3-dictionary.csv")
Binary file not shown.
Binary file not shown.
2 changes: 1 addition & 1 deletion tests/testthat/test-metadata-read.R
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ test_that("Super-wide 3", {
expected_outcome_message <- "The data dictionary describing 35,004 fields was read from REDCap in \\d+(\\.\\d+\\W|\\W)seconds\\. The http status code was 200\\."
expected_row_count <- 35004L
expected_column_count <- 18L
expected_na_cells <- 404297L
expected_na_cells <- 397297L

expect_message(
regexp = expected_outcome_message,
Expand Down

0 comments on commit d6d3ff0

Please sign in to comment.