Skip to contents

This function sets up the configuration for a surveydown survey, including page and question structures, conditional display settings, and navigation options.

Usage

sd_config(
  skip_if = NULL,
  skip_if_custom = NULL,
  show_if = NULL,
  show_if_custom = NULL,
  required_questions = NULL,
  all_questions_required = FALSE,
  start_page = NULL,
  show_all_pages = FALSE,
  admin_page = FALSE
)

Arguments

skip_if

A list of conditions under which certain pages should be skipped. Defaults to NULL.

skip_if_custom

A custom function to handle conditions under which certain pages should be skipped. Defaults to NULL.

show_if

A list of conditions under which certain pages should be shown. Defaults to NULL.

show_if_custom

A custom function to handle conditions under which certain pages should be shown. Defaults to NULL.

required_questions

Vector of character strings. The IDs of questions that must be answered before the respondent can continue in the survey or survey can be submitted. Defaults to NULL.

all_questions_required

Logical. If TRUE, all questions in the survey will be required. This overrides the required_questions parameter. Defaults to FALSE.

start_page

Character string. The ID of the page to start on. Defaults to NULL.

show_all_pages

Logical. Whether to show all pages initially. Defaults to FALSE.

admin_page

Logical. Whether to include an admin page for viewing and downloading survey data. Defaults to FALSE.

Value

A list containing the configuration settings for the survey, including:

page_structure

A list containing the structure of survey pages

question_structure

A list containing the structure of survey questions

page_ids

A vector of all page IDs

question_ids

A vector of all question IDs

question_values

A vector of all possible question values

question_required

A vector of IDs for required questions

skip_if_custom

Custom skip conditions

skip_if

Standard skip conditions

show_if_custom

Custom show conditions

show_if

Standard show conditions

start_page

The ID of the starting page

show_all_pages

Whether to show all pages initially

admin_page

Whether to include an admin page

Details

The function retrieves the survey metadata, checks for duplicate page and question IDs, validates the conditional display settings, and ensures that the specified start page (if any) exists. It then stores these settings in a configuration list. If admin_page is set to TRUE, an admin page will be included in the survey. This page allows viewing and downloading of survey data upon entering the correct survey password (set using sd_set_password()).

If all_questions_required is set to TRUE, it will override the required_questions parameter and set all questions in the survey as required.

Examples

if (FALSE) { # \dontrun{
# These examples assume you have set up a survey with appropriate .qmd files

# Basic configuration
config <- sd_config()

# Configuration with custom settings
config <- sd_config(
  start_page = "intro",
  all_questions_required = TRUE,
  show_all_pages = FALSE,
  admin_page = TRUE
)
} # }