new Survey(_jsonSurvey)
Survey constructor. Takes a json survey and returns an internal survey
object.
Parameters:
| Name | Type | Description |
|---|---|---|
_jsonSurvey |
json | The input survey, typically generated by another program. |
- Source:
Members
breakoff :boolean
Boolean indicating whether breakoff is permitted for this survey.
Type:
- boolean
- Source:
filename :string
The path of the source file used to generate this survey; may be empty.
Type:
- string
- Source:
questions :Array.<survey.Question>
The list of all questions.
Type:
- Array.<survey.Question>
- Source:
topLevelBlocks :Array.<survey.Block>
The list of top level blocks in this survey.
Type:
- Array.<survey.Block>
- Source:
Methods
(static) randomize(_survey)
Randomizes the survey blocks and questions, as appropriate.
Parameters:
| Name | Type | Description |
|---|---|---|
_survey |
Survey |
- Source:
add_block(block, parentnullable, indexnullable)
Adds the block to the survey. Mutates the survey object. If index is provided with
a parent block, it will try to insert the block at the provided index in the parent
block. If the block is a top-level block, it will insert at the provided index in
the survey's topLevelBlock list.
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
block |
Block | The top-level block to add. | |
parent |
Block |
<nullable> |
This block's parent. If null, it will attempt to find it. |
index |
number |
<nullable> |
The index at which to insert the provided block. the parent. |
- Source:
add_question(question, block)
Adds the provided question to the provided block in this survey.
Parameters:
| Name | Type | Description |
|---|---|---|
question |
Question | The question to add. |
block |
Block | The block to add to. |
- Source:
equals(that) → {boolean}
Compares two surveys to see if they are equal, by comparing the equality of their
subblocks.
Parameters:
| Name | Type | Description |
|---|---|---|
that |
Survey | The survey to compare to. |
- Source:
Returns:
- Type
- boolean
get_block_by_id(block_id) → {Block}
Returns the Block object in this survey that has the provided id.
Parameters:
| Name | Type | Description |
|---|---|---|
block_id |
string | Block identifier. |
- Source:
Throws:
ObjectNotFoundException
Returns:
- Type
- Block
get_option_by_id(oid) → {Option}
Searches through the survey for the option with the provided id.
Parameters:
| Name | Type | Description |
|---|---|---|
oid |
string | The id of the option. |
- Source:
Throws:
ObjectNotFoundException if the survey does not contain any options with this id.
Returns:
- Type
- Option
get_question_by_id(question_id) → {Question}
Returns the Question object in this survey that has the provided id.
Parameters:
| Name | Type | Description |
|---|---|---|
question_id |
string | The identifier of the question of interest. |
- Source:
Returns:
- Type
- Question
remove_block(block, parentnullable)
Removes the block from the survey. Mutates the survey object.
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
block |
Block | The block to delete. | |
parent |
Block |
<nullable> |
This block's parent. If null, it will attempt to find the parent. |
- Source:
remove_option(option, questionnullable)
Removes the provided option from the survey by searching through the survey.
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
option |
Option | The option to remove. | |
question |
Question |
<nullable> |
The question this option belongs to. |
- Source:
remove_question(question)
Removes the provided question from the survey. If the containing block is not
provided, the method will search for it.
Parameters:
| Name | Type | Description |
|---|---|---|
question |
Question | The question to remove. |
- Source:
toJSON() → {Object}
Returns the JSON representation of this survey.
Note: we cannot just return the input json because the survey may have been mutated.
- Source:
Returns:
- Type
- Object