Skip to content

Commit 4528f6c

Browse files
authored
Merge pull request #1559 from cmu-delphi/ndefries/if-false-displaylogic
[CTIS utils] Correctly handle static display logic in QSFs
2 parents 95fb526 + eeff479 commit 4528f6c

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

facebook/qsf-tools/generate-codebook.R

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,23 @@ process_qsf <- function(path_to_qsf,
192192
map(~ gsubfn("(QID[0-9]+)", function(qid) {items[qids == qid]}, .x)) %>%
193193
# Collapse logic into a single string.
194194
map(~ paste(.x, collapse=" "))
195+
196+
# Handle questions that use a fixed condition ("If False", "If True")
197+
ii_boolean_displaylogic <- (displayed_questions %>%
198+
map(~ .x$Payload$DisplayLogic) %>%
199+
map(~ .x$`0`) %>%
200+
map(~ map(.x, "LogicType") %>% unlist()) == "BooleanValue") %>%
201+
which()
202+
203+
display_logic[ii_boolean_displaylogic] <- displayed_questions[ii_boolean_displaylogic] %>%
204+
map(~ .x$Payload$DisplayLogic) %>%
205+
map(~ .x$`0`) %>%
206+
map(~ paste(
207+
map(.x, "Value")
208+
)) %>%
209+
map(~ gsub(" ?NULL ?", "", .x)) %>%
210+
# Collapse logic into a single string.
211+
map(~ paste(.x, collapse=""))
195212

196213
logic_type <- displayed_questions %>%
197214
map(~ .x$Payload$DisplayLogic) %>%

0 commit comments

Comments
 (0)