This vignette demonstrates working with Qualtrics survey designs, which qsurvey formalizes as qualtrics_design objects that represent the configuration of a survey. Before continuing you should have installed qsurvey: see the installation instructions.

library(qsurvey)

Retrieve a survey design

Survey metadata is available from the Qualtrics platform via surveys().

survey_meta <- surveys()
survey_meta[grepl("Feedback|Demographics", name), ]
#>                    id             name           owner_id
#> 1: SV_0CGgkDZJaUvxnGl Student Feedback UR_8J1114L8aAeMCPP
#> 2: SV_0VVlb9QwJ4bsBKZ     Demographics UR_8J1114L8aAeMCPP
#>          last_modified is_active
#> 1: 2016-11-24 03:36:38     FALSE
#> 2: 2016-11-24 03:36:11     FALSE

This Qualtrics account has access to a handful of surveys. We’ll pick one for examination in detail. Passing a survey’s id to design() retrieves its qualtrics_design object.

(feedback_id <- find_id("Student Feedback"))
#>     Student Feedback 
#> "SV_0CGgkDZJaUvxnGl"
feedback <- design(feedback_id)

Printing the design gives us some basic information. Some we already saw when calling surveys(). There are three new numbers giving counts of responses, questions, and blocks.

print(feedback)
#> # A qualtrics_design:
#> name               Student Feedback     
#> id                 SV_0CGgkDZJaUvxnGl   
#> created            2016-11-24           
#> modified           2016-11-24           
#> responses          0 (closed)           
#> questions          26                   
#> blocks             3

Note: a qualtrics_design object is immutable and can become outdated. If after downloading a survey’s design you make changes to it in the Qualtrics Control Panel, call design() again to recreate its qualtrics_design object.

Blocks

Blocks of questions are the main organizing element of surveys. The blocks() function shows a survey’s blocks.

blocks(feedback)
#>              block_id   block_description
#> 1: BL_agzU0yMolbPdFGd    Class Evaluation
#> 2: BL_0wUDDTxrMh9vOAd  Teacher Evaluation
#> 3: BL_6FK8SIrVsXuBxFX Student Performance

Each block has a unique block_id. A block_description is the descriptive text (name) given to a block when editing it through the Qualtrics Control Panel. If we wanted more details about these blocks, we could use argument elements=TRUE to see what each block contains.

blocks(feedback, elements = TRUE)
#>               block_id   block_description element_type  question_id
#>  1: BL_agzU0yMolbPdFGd    Class Evaluation     Question QID132224516
#>  2: BL_agzU0yMolbPdFGd    Class Evaluation     Question QID132224536
#>  3: BL_agzU0yMolbPdFGd    Class Evaluation     Question QID132224537
#>  4: BL_agzU0yMolbPdFGd    Class Evaluation     Question QID132224526
#>  5: BL_agzU0yMolbPdFGd    Class Evaluation     Question QID132224538
#>  6: BL_agzU0yMolbPdFGd    Class Evaluation     Question QID132224539
#>  7: BL_agzU0yMolbPdFGd    Class Evaluation     Question QID132224540
#>  8: BL_0wUDDTxrMh9vOAd  Teacher Evaluation     Question QID132224541
#>  9: BL_0wUDDTxrMh9vOAd  Teacher Evaluation     Question QID132224518
#> 10: BL_0wUDDTxrMh9vOAd  Teacher Evaluation     Question QID132224517
#> 11: BL_0wUDDTxrMh9vOAd  Teacher Evaluation     Question QID132224519
#> 12: BL_0wUDDTxrMh9vOAd  Teacher Evaluation     Question QID132224520
#> 13: BL_0wUDDTxrMh9vOAd  Teacher Evaluation     Question QID132224521
#> 14: BL_0wUDDTxrMh9vOAd  Teacher Evaluation     Question QID132224522
#> 15: BL_0wUDDTxrMh9vOAd  Teacher Evaluation     Question QID132224523
#> 16: BL_0wUDDTxrMh9vOAd  Teacher Evaluation     Question QID132224524
#> 17: BL_6FK8SIrVsXuBxFX Student Performance     Question QID132224525
#> 18: BL_6FK8SIrVsXuBxFX Student Performance     Question QID132224528
#> 19: BL_6FK8SIrVsXuBxFX Student Performance     Question QID132224527
#> 20: BL_6FK8SIrVsXuBxFX Student Performance     Question QID132224530
#> 21: BL_6FK8SIrVsXuBxFX Student Performance     Question QID132224529
#> 22: BL_6FK8SIrVsXuBxFX Student Performance     Question QID132224531
#> 23: BL_6FK8SIrVsXuBxFX Student Performance     Question QID132224532
#> 24: BL_6FK8SIrVsXuBxFX Student Performance     Question QID132224533
#> 25: BL_6FK8SIrVsXuBxFX Student Performance     Question QID132224534
#> 26: BL_6FK8SIrVsXuBxFX Student Performance     Question QID132224535
#>               block_id   block_description element_type  question_id
#>     block_randomization
#>  1:                    
#>  2:                    
#>  3:                    
#>  4:                    
#>  5:                    
#>  6:                    
#>  7:                    
#>  8:                    
#>  9:                    
#> 10:                    
#> 11:                    
#> 12:                    
#> 13:                    
#> 14:                    
#> 15:                    
#> 16:                    
#> 17:                    
#> 18:                    
#> 19:                    
#> 20:                    
#> 21:                    
#> 22:                    
#> 23:                    
#> 24:                    
#> 25:                    
#> 26:                    
#>     block_randomization

The new columns show the elements in each block: their type (question or page break); unique question identifiers; and the details of block content randomization, if any.

Questions

We can learn much more about a survey’s questions with the questions() function.

feedback_q <- questions(feedback)
head(feedback_q)
#>    question_order  question_id export_name
#> 1:              1 QID132224516          Q1
#> 2:              2 QID132224536          Q3
#> 3:              3 QID132224537          Q4
#> 4:              4 QID132224526          Q2
#> 5:              5 QID132224538          Q6
#> 6:              6 QID132224539          Q7
#>                                                                            question_text
#> 1:                      Overall, how satisfied or dissatisfied were you with this class?
#> 2:                                                       How interesting was this class?
#> 3:                                                       How challenging was this class?
#> 4:                                    How fair or unfair was the workload in this class?
#> 5:                        How clear or unclear were the assignments given in this class?
#> 6: How relevant or irrelevant were the tests and quizzes to the topics covered in class?

This table gives:

  • The order in which questions appear (WARNING: possibly misleading depending on survey flow setup)

  • Unique identifiers as generated by Qualtrics

  • export_name, which gives the names a user assigned to questions in the Qualtrics Control Panel

  • The respondent-facing question_text

Choices

We didn’t see in the questions() output the response choices that are available to survey-takers. You can access these with the choices() function.

feedback_choices <- choices(feedback)
head(feedback_choices)
#>    choice_id  question_id analyze                        choice_text
#> 1:         1 QID132224516    TRUE                Extremely satisfied
#> 2:         2 QID132224516    TRUE               Moderately satisfied
#> 3:         3 QID132224516    TRUE                 Slightly satisfied
#> 4:         4 QID132224516    TRUE Neither satisfied nor dissatisfied
#> 5:         5 QID132224516    TRUE              Slightly dissatisfied
#> 6:         6 QID132224516    TRUE            Moderately dissatisfied
#>                    choice_description choice_recode
#> 1:                Extremely satisfied             1
#> 2:               Moderately satisfied             2
#> 3:                 Slightly satisfied             3
#> 4: Neither satisfied nor dissatisfied             4
#> 5:              Slightly dissatisfied             5
#> 6:            Moderately dissatisfied             6

Each choice has an identifier choice_id that’s unique within questions. In the other columns:

  • choice_text gives the respondent-visible text associated with a choice.

  • choice_description is (optionally) a different string that you can associate with a choice (e.g., to make the response data more readable). By default, it’s the same as choice_text.

  • choice_recode is (optionally) a number other than the choice_id that you can associate with a choice, for example so that choices are in {-1, 0, 1} instead of {1, 2, 3} when exporting the response data. choice_recode defaults to choice_id.

Visualization

A survey flow describes the order in which respondents can encounter the elements of a survey. The “Survey Flow” view in the Qualtrics Control Panel lets you make changes. You can visualize a survey flow in R using plot_flow().

# Not run
# plot_flow(feedback)

plot_flow() shows the survey flow as a directed graph, whose nodes can be flow elements like blocks, branches, and block randomizers. Edges between nodes can be deterministic, conditional, or random. (In this simple survey, all the edges are deterministic.) Conditional edges implement branch logic. Random edges represent outcomes from a block randomizer.

A Shiny app (experimental) that includes a similar visual representation of survey flow is available through render_flow(). For the nodes and edges in tabular format, see edges() and nodes().

Conclusion

Many of the functions in qsurvey operate on qualtrics_design objects. This vignette demonstrated how to retrieve one with design(), and then use blocks(), questions(), and choices() to examine the respondent-facing content of a survey and the configuration of renaming/recoding schemes and survey flow. If you have a question or suggestion, please open a GitHub issue.