-
Notifications
You must be signed in to change notification settings - Fork 6
lfs:Question specifications
An lfs:Question object (obtained, e.g., with a query) will contain the following properties
-
text
a string containing the text of the question -
description
an optional string containing a longer explanation/description for the question. -
minAnswers
(default:0
) the minimum number of answers that must be selected. 0 or negative values means no minimum. If a strictly positive number is set, then the question becomes mandatory. -
maxAnswers
(default:0
) the maximum number of answers that can be selected. 0 or negative values means no maximum. -
displayMode
(default:input
) how answer options are displayed. This can be one of the following:-
none
: the question is not displayed at all in the frontend -
hidden
: the question is hidden, but it may be auto-filled by other means, such as javascript, data import, or dynamic computation -
input
: a simple input field where the user can type an answer -
textbox
: a large textbox for longer strings -
list
: a list of options that the user can choose from -
list+input
: a list of options, plus an "other" input where the user can add a non-standard answer
-
This is not an exhaustive list, as support for new display modes may also be added in the future
-
dataType
(default:text
) the type of data being recorded. This can be one of the following:-
text
: simple text, either from a list of predefined options, or free text entered by the user -
long
,double
,decimal
: a number -
date
: a date, with optional time -
boolean
: a yes/no answer -
vocabulary
: a term from a vocabulary -
computed
: a derived value automatically computed based on a formula applied on other values in the questionaire
-
This is not an exhaustive list, as support for new display modes may also be added in the future.
A further note on minAnswers
and maxAnswers
: they define how many answers that must be selected in order for a question to be considered "answered".
- The default is (0, 0), no mimimum and no maximum, which means that any number of options can be selected -- optional checkboxes.
- (0, 1) means that at most one option can be selected, making the question an optional list to choose from -- optional radio boxes.
- (1, 0) makes the question mandatory, at least one answer must be selected -- mandatory checkboxes.
- (1, 1) makes the question mandatory, exactly one option must be selected -- mandatory radio boxes.
- (N, 0), where N >= 1, makes this a list of checkboxes, and at least N must be checked.
- (N, M), where 0 <= N <= M, makes this a list of checkboxes, and between N (inclusive) and M (inclusive) must be checked.
-
validationRegexp
: For text answers, a regular expression that can restrict/validate the allowed answers.
-
minValue
: For numeric answers, the minimum allowed value -
maxValue
: For numeric answers, the maximum allowed value -
unitOfMeasurement
: For numeric answers, the measurement unit used for the value (kg, cm, cGy...)
-
dateFormat
: For date answers, the format in which to display (and accept as input) the date. This is a SimpleDateFormat compatible string.
-
yesLabel
a string containing the label to be displayed for the "true" option -
noLabel
a string containing the label to be displayed for the "false" option -
enableUnknown
a boolean enabling a third answer: "unknown" -
unknownLabel
IfenableUnknown
is true, a string containing the label to be displayed for the "unknown" option
-
sourceVocabulary
: For vocabulary answers, the source vocabulary (or category of vocabularies) in which to search. A simple label like "MONDO", or a value prefixed by "vocabulary:" such as "vocabulary:MONDO" identifies a specific vocabulary. A value prefixed by "category:" such as "category:diseases" identifies a vocabulary category. -
vocabularyFilter
: For vocabulary answers, an extra filter to apply to the query, which can be used, for example, to restrict results to a specific sub-branch, or a specific type of terms. If defined, this must be a valid solr query that can be placed in the fq field.
Answer options for the list
and list+input
questions are given as objects of type [lfs:AnswerOption]
.
Since not all properties are mandatory, customizing a question requires defining only the properties of interest.
Note that the node type does not prevent adding other properties not defined above, so for a custom question type needing other customization options it is enough to simply add new properties.
-
label
The optional text of this option displayed to the user. This is not the value that gets stored when it is selected for an answer, the "value" property is. If the label is missing, the "value" is used instead. -
help
An optional longer explanation for the answer option. If present, a help icon will be displayed next to the label, and hovering/clicking it will display this help text. -
value
The mandatory value to store internally when this option is selected. Separating the label from the stored value allows relabeling options without having to update all existing answers.