Usage
form_schema_ext(
flatten = FALSE,
odata = FALSE,
parse = TRUE,
pid = get_default_pid(),
fid = get_default_fid(),
url = get_default_url(),
un = get_default_un(),
pw = get_default_pw(),
odkc_version = get_default_odkc_version(),
retries = get_retries(),
verbose = get_ru_verbose()
)Arguments
- flatten
Whether to flatten the resulting list of lists (
TRUE) or not (FALSE, default). Only applies to ODK Central version < 0.8.- odata
Whether to sanitise the field names to match the way they will be outputted for OData. While the original field names as given in the XForms definition may be used as-is for CSV output, OData has some restrictions related to the domain-qualified identifier syntax it uses. Only applies to ODK Central version < 0.8. Default:
FALSE.- parse
Whether to parse the form schema into a tibble of form field type and name. This uses
form_schema_parseinternally. If used together withflatten=TRUE,form_schemawill raise a warning and return the unparsed, flattened form schema. Only applies to ODK Central version < 0.8. Default: TRUE.- pid
The numeric ID of the project, e.g.: 2.
Default:
get_default_pid.Set default
pidthroughru_setup(pid="...").See
vignette("Setup", package = "ruODK").- fid
The alphanumeric form ID, e.g. "build_Spotlighting-0-8_1559885147".
Default:
get_default_fid.Set default
fidthroughru_setup(fid="...").See
vignette("Setup", package = "ruODK").- url
The ODK Central base URL without trailing slash.
Default:
get_default_url.Set default
urlthroughru_setup(url="...").See
vignette("Setup", package = "ruODK").- un
The ODK Central username (an email address). Default:
get_default_un. Set defaultunthroughru_setup(un="..."). Seevignette("Setup", package = "ruODK").- pw
The ODK Central password. Default:
get_default_pw. Set defaultpwthroughru_setup(pw="..."). Seevignette("Setup", package = "ruODK").- odkc_version
The ODK Central version as a semantic version string (year.minor.patch), e.g. "2023.5.1". The version is shown on ODK Central's version page
/version.txt. Discard the "v".ruODKuses this parameter to adjust for breaking changes in ODK Central.Default:
get_default_odkc_versionor "2023.5.1" if unset.Set default
get_default_odkc_versionthroughru_setup(odkc_version="2023.5.1").See
vignette("Setup", package = "ruODK").- retries
The number of attempts to retrieve a web resource.
This parameter is given to
RETRY(times = retries).Default: 3.
- verbose
Whether to display debug messages or not.
Read
vignette("setup", package = "ruODK")to learn howruODK's verbosity can be set globally or per function.
Value
A tibble containing the form definition.
For ODK Central 0.8, and with default parameters
(parse=TRUE) for ODK Central 0.7, form_schema returns
a tibble with the columns:
nameThe field name as given in the form schema.typeThe field type, e.g. "string", "select1", etc.pathThe XForms path of the field,ruodk_nameThe predicted field name as generated byodata_submission_get, prefixed by the path, additionally cleaned withmake_clean_namesto match the cleaned column names fromodata_submission_rectangle.labelThe field label as given in the form schema. If specific languages are available, this column will return thedefaultlanguage or it will be empty if this is not specified.label_langThe field label in languange _lang as given in the form schema.choicesA list of lists containing at leastvaluesand, if available,labelsof the choices as given in the form schema. If specific languages are available, this column will return thedefaultlanguage or it will be empty if this is not specified. Please notice that whenever choice filters are applied, this will return the unfiltered choice list.choices_langA list of lists containing at leastvaluesand, if available,labelsof the choices in language _lang as given in the form schema. Please notice that whenever choice filters are applied, this will return the unfiltered choice list.
Details
ODK Central has introduced a new API endpoint in version 0.8 which
returns a parsed and flattened list of fields. This replaces the nested
form schema which is challenging to parse. This list is returned
by form_schema.
However this still misses important elements, in particular labels and
choice_lists.
form_schema_ext returns the same object as
form_schema
adding labels and choice lists in all languages available.
This is done by using the return object from form_xml.
It has the exact function signature as form_schema.
In that sense, any call to form_schema can be replaced
by form_schema_ext
This function, however, has been prepared with ODK Central version 0.8 or higher. If you use it with an earlier version, a warning will be given.
Examples
if (FALSE) { # \dontrun{
# See vignette("setup") for setup and authentication options
# ruODK::ru_setup(svc = "....svc", un = "me@email.com", pw = "...")
# With current ODK Central (>0.7)
# get extended schema:
fsx <- form_schema_ext()
# print choice list in english:
fsx[fsx$name == "test_yn", "choices_english_(en)"][[1]]
# view the extended schema:
fsx
} # }
