Represents Questionnaire. Contains questions, sections or a pagebreaks and provides easy access to them through global q variable.
Global variables object is useful for the permanent per-session values storage. With the help of this object you can save the answer value at some question and process it later on the next question or section. Variables are stored in the user's session so they survive browser postbacks.
Properties:
Name | Type | Description |
---|---|---|
code | QuestItem | Indexer for QuestItem objects. Returns questionnaire item by its unique code. If the code is not assigned explicitly than question order index can be used for that purpose. If assigned question code starts with letter or underscore sign than dot notation can be used instead of square brackets. |
items | QuestItem | Array of all questionnaire items sorted by inital order (respect randomization) including questions, sections and pagebreaks declarations. |
questions | Question | Array of all questions items sorted by inital order (respect randomization) including questions. |
Examples
// returns question with code
"Q1" q["Q1"]
// returns question with code
"Q1" q.Q1
// returns question with code "_matrix_question"
q._matrix_question
//find questionnaire items where name starts with "some text"
for(var i = 0; i < q.items.length; i++) {
if(q.items[i].name.indexOf('some text') > 0) {
//do something
}
}
//show all previously hidden questions
for (var i = 0; i <q.questions.length; i++) {
if (!q.questions[i].isVisble()) {
q.questions[i].show();
}
}
// saving some variable in the global variables object
variables.someVariable = 'some value';
Methods
(inner)jump(code)
- Jumps to the specified element. This function is the global analog of the QuestItem.jump() method.
Parameters:
Name Type Description code
String Questionnaire item code Example
//jump to the question with code "q12" q.jump('q12'); //search quest item by name and jump to the found element for (var i = 0; i < q.items.length; i++) { if (q.items[i].name.indexOf('value to search for') >= 0) { q.jump(q.items[i].code); } }
(inner)refresh()
- Refreshes current page.
Example
q.refresh();
(inner)screenOutRespondent()
- Screens out current respondent out of the survey.
The respondent will be notified and the answer will be counted as a partial response.
Example
//screen out respondent if specific alternative was selected if(q['Q1'].answer() == 2) { q.screenOutRespondent(); }