affectiva-surveyor 1.5.0.pre.disco.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +28 -0
- data/.rspec +1 -0
- data/CHANGELOG.md +198 -0
- data/Gemfile +5 -0
- data/Gemfile.rails_version +27 -0
- data/MIT-LICENSE +20 -0
- data/README.md +166 -0
- data/Rakefile +106 -0
- data/app/controllers/surveyor_controller.rb +5 -0
- data/app/helpers/results_helper.rb +20 -0
- data/app/helpers/survey_form_builder.rb +37 -0
- data/app/helpers/surveyor_helper.rb +3 -0
- data/app/inputs/quiet_input.rb +5 -0
- data/app/inputs/surveyor_check_boxes_input.rb +35 -0
- data/app/inputs/surveyor_radio_input.rb +18 -0
- data/app/models/answer.rb +3 -0
- data/app/models/dependency.rb +3 -0
- data/app/models/dependency_condition.rb +3 -0
- data/app/models/question.rb +3 -0
- data/app/models/question_group.rb +4 -0
- data/app/models/response.rb +4 -0
- data/app/models/response_set.rb +3 -0
- data/app/models/survey.rb +3 -0
- data/app/models/survey_section.rb +4 -0
- data/app/models/survey_section_sweeper.rb +15 -0
- data/app/models/survey_translation.rb +4 -0
- data/app/models/validation.rb +3 -0
- data/app/models/validation_condition.rb +3 -0
- data/app/views/layouts/results.html.erb +13 -0
- data/app/views/layouts/surveyor_default.html.erb +12 -0
- data/app/views/partials/_answer.html.haml +25 -0
- data/app/views/partials/_dependents.html.haml +5 -0
- data/app/views/partials/_question.html.haml +28 -0
- data/app/views/partials/_question_group.html.haml +44 -0
- data/app/views/partials/_section.html.haml +12 -0
- data/app/views/partials/_section_menu.html.haml +12 -0
- data/app/views/surveyor/edit.html.haml +24 -0
- data/app/views/surveyor/export.json.rabl +85 -0
- data/app/views/surveyor/new.html.haml +24 -0
- data/app/views/surveyor/show.html.haml +74 -0
- data/app/views/surveyor/show.json.rabl +15 -0
- data/ci-exec.sh +56 -0
- data/config/routes.rb +8 -0
- data/cucumber.yml +10 -0
- data/doc/REPRESENTATIONS.md +34 -0
- data/doc/api_id_schema.json +7 -0
- data/doc/question types.png +0 -0
- data/doc/response_set_schema.json +54 -0
- data/doc/surveyor question combinations.png +0 -0
- data/doc/surveyor reject or delete decision matrix.png +0 -0
- data/doc/surveyor_models.png +0 -0
- data/doc/surveyor_models2.png +0 -0
- data/doc/surveyor_timestamp_schema.json +9 -0
- data/features/ajax_submissions.feature +140 -0
- data/features/export_to_json.feature +344 -0
- data/features/internationalization.feature +121 -0
- data/features/no_duplicates.feature +110 -0
- data/features/show_survey.feature +71 -0
- data/features/step_definitions/parser_steps.rb +145 -0
- data/features/step_definitions/surveyor_steps.rb +325 -0
- data/features/step_definitions/ui_steps.rb +25 -0
- data/features/step_definitions/web_steps.rb +225 -0
- data/features/support/REDCapDemoDatabase_DataDictionary.csv +127 -0
- data/features/support/database_cleaner.rb +16 -0
- data/features/support/env.rb +56 -0
- data/features/support/hooks.rb +4 -0
- data/features/support/paths.rb +39 -0
- data/features/support/redcap_new_headers.csv +1 -0
- data/features/support/redcap_siblings.csv +1 -0
- data/features/support/redcap_whitespace.csv +1 -0
- data/features/support/selectors.rb +39 -0
- data/features/support/simultaneous_ajax.rb +101 -0
- data/features/support/single_quit_selenium_driver.rb +23 -0
- data/features/support/slow_updates.rb +18 -0
- data/features/surveyor.feature +895 -0
- data/features/surveyor_dependencies.feature +476 -0
- data/features/surveyor_parser.feature +504 -0
- data/features/z_redcap_parser.feature +62 -0
- data/lib/assets/images/surveyor/next.gif +0 -0
- data/lib/assets/images/surveyor/prev.gif +0 -0
- data/lib/assets/images/surveyor/ui-bg_flat_0_aaaaaa_40x100.png +0 -0
- data/lib/assets/images/surveyor/ui-bg_flat_75_ffffff_40x100.png +0 -0
- data/lib/assets/images/surveyor/ui-bg_glass_55_fbf9ee_1x400.png +0 -0
- data/lib/assets/images/surveyor/ui-bg_glass_65_ffffff_1x400.png +0 -0
- data/lib/assets/images/surveyor/ui-bg_glass_75_dadada_1x400.png +0 -0
- data/lib/assets/images/surveyor/ui-bg_glass_75_e6e6e6_1x400.png +0 -0
- data/lib/assets/images/surveyor/ui-bg_glass_95_fef1ec_1x400.png +0 -0
- data/lib/assets/images/surveyor/ui-bg_highlight-soft_75_cccccc_1x100.png +0 -0
- data/lib/assets/images/surveyor/ui-icons_222222_256x240.png +0 -0
- data/lib/assets/images/surveyor/ui-icons_2e83ff_256x240.png +0 -0
- data/lib/assets/images/surveyor/ui-icons_454545_256x240.png +0 -0
- data/lib/assets/images/surveyor/ui-icons_888888_256x240.png +0 -0
- data/lib/assets/images/surveyor/ui-icons_cd0a0a_256x240.png +0 -0
- data/lib/assets/javascripts/surveyor/jquery-1.9.0.js +9555 -0
- data/lib/assets/javascripts/surveyor/jquery-ui-1.10.0.custom.js +14850 -0
- data/lib/assets/javascripts/surveyor/jquery-ui-timepicker-addon.js +1919 -0
- data/lib/assets/javascripts/surveyor/jquery.maskedinput.js +338 -0
- data/lib/assets/javascripts/surveyor/jquery.selectToUISlider.js +240 -0
- data/lib/assets/javascripts/surveyor/jquery.surveyor.js +154 -0
- data/lib/assets/stylesheets/surveyor.sass +132 -0
- data/lib/assets/stylesheets/surveyor/jquery-ui-1.10.0.custom.css +1174 -0
- data/lib/assets/stylesheets/surveyor/jquery-ui-timepicker-addon.css +11 -0
- data/lib/assets/stylesheets/surveyor/reset.css +48 -0
- data/lib/assets/stylesheets/surveyor/results.css +125 -0
- data/lib/assets/stylesheets/surveyor/ui.slider.extras.css +110 -0
- data/lib/generators/surveyor/custom_generator.rb +18 -0
- data/lib/generators/surveyor/install_generator.rb +101 -0
- data/lib/generators/surveyor/templates/app/assets/javascripts/surveyor_all.js +6 -0
- data/lib/generators/surveyor/templates/app/assets/stylesheets/surveyor_all.css +9 -0
- data/lib/generators/surveyor/templates/app/controllers/surveyor_controller.rb +40 -0
- data/lib/generators/surveyor/templates/app/views/layouts/surveyor_custom.html.erb +13 -0
- data/lib/generators/surveyor/templates/config/locales/surveyor_en.yml +19 -0
- data/lib/generators/surveyor/templates/config/locales/surveyor_es.yml +19 -0
- data/lib/generators/surveyor/templates/config/locales/surveyor_he.yml +19 -0
- data/lib/generators/surveyor/templates/config/locales/surveyor_ko.yml +19 -0
- data/lib/generators/surveyor/templates/db/migrate/add_api_id_to_question_groups.rb +10 -0
- data/lib/generators/surveyor/templates/db/migrate/add_api_ids.rb +14 -0
- data/lib/generators/surveyor/templates/db/migrate/add_api_ids_to_response_sets_and_responses.rb +12 -0
- data/lib/generators/surveyor/templates/db/migrate/add_correct_answer_id_to_questions.rb +10 -0
- data/lib/generators/surveyor/templates/db/migrate/add_default_value_to_answers.rb +10 -0
- data/lib/generators/surveyor/templates/db/migrate/add_display_order_to_surveys.rb +10 -0
- data/lib/generators/surveyor/templates/db/migrate/add_display_type_to_answers.rb +14 -0
- data/lib/generators/surveyor/templates/db/migrate/add_index_to_response_sets.rb +10 -0
- data/lib/generators/surveyor/templates/db/migrate/add_index_to_surveys.rb +10 -0
- data/lib/generators/surveyor/templates/db/migrate/add_input_mask_attributes_to_answer.rb +12 -0
- data/lib/generators/surveyor/templates/db/migrate/add_section_id_to_responses.rb +12 -0
- data/lib/generators/surveyor/templates/db/migrate/add_unique_index_on_access_code_and_version_in_surveys.rb +10 -0
- data/lib/generators/surveyor/templates/db/migrate/add_unique_indicies.rb +18 -0
- data/lib/generators/surveyor/templates/db/migrate/add_version_to_surveys.rb +10 -0
- data/lib/generators/surveyor/templates/db/migrate/api_ids_must_be_unique.rb +23 -0
- data/lib/generators/surveyor/templates/db/migrate/create_answers.rb +38 -0
- data/lib/generators/surveyor/templates/db/migrate/create_dependencies.rb +23 -0
- data/lib/generators/surveyor/templates/db/migrate/create_dependency_conditions.rb +30 -0
- data/lib/generators/surveyor/templates/db/migrate/create_question_groups.rb +28 -0
- data/lib/generators/surveyor/templates/db/migrate/create_questions.rb +37 -0
- data/lib/generators/surveyor/templates/db/migrate/create_response_sets.rb +23 -0
- data/lib/generators/surveyor/templates/db/migrate/create_responses.rb +34 -0
- data/lib/generators/surveyor/templates/db/migrate/create_survey_sections.rb +30 -0
- data/lib/generators/surveyor/templates/db/migrate/create_survey_translations.rb +19 -0
- data/lib/generators/surveyor/templates/db/migrate/create_surveys.rb +32 -0
- data/lib/generators/surveyor/templates/db/migrate/create_validation_conditions.rb +33 -0
- data/lib/generators/surveyor/templates/db/migrate/create_validations.rb +21 -0
- data/lib/generators/surveyor/templates/db/migrate/drop_unique_index_on_access_code_in_surveys.rb +10 -0
- data/lib/generators/surveyor/templates/db/migrate/update_blank_api_ids_on_question_group.rb +22 -0
- data/lib/generators/surveyor/templates/db/migrate/update_blank_versions_on_surveys.rb +13 -0
- data/lib/generators/surveyor/templates/surveys/EXTENDING_SURVEYOR.md +52 -0
- data/lib/generators/surveyor/templates/surveys/MODIFYING_SURVEYOR.md +91 -0
- data/lib/generators/surveyor/templates/surveys/date_survey.rb +16 -0
- data/lib/generators/surveyor/templates/surveys/kitchen_sink_survey.rb +280 -0
- data/lib/generators/surveyor/templates/surveys/languages.rb +14 -0
- data/lib/generators/surveyor/templates/surveys/quiz.rb +11 -0
- data/lib/generators/surveyor/templates/surveys/translations/languages.es.yml +18 -0
- data/lib/generators/surveyor/templates/surveys/translations/languages.he.yml +18 -0
- data/lib/generators/surveyor/templates/surveys/translations/languages.ko.yml +18 -0
- data/lib/generators/surveyor/templates/vendor/assets/stylesheets/custom.sass +5 -0
- data/lib/surveyor.rb +13 -0
- data/lib/surveyor/acts_as_response.rb +17 -0
- data/lib/surveyor/common.rb +59 -0
- data/lib/surveyor/engine.rb +10 -0
- data/lib/surveyor/helpers/asset_pipeline.rb +18 -0
- data/lib/surveyor/helpers/formtastic_custom_input.rb +13 -0
- data/lib/surveyor/helpers/surveyor_helper_methods.rb +103 -0
- data/lib/surveyor/models/answer_methods.rb +83 -0
- data/lib/surveyor/models/dependency_condition_methods.rb +69 -0
- data/lib/surveyor/models/dependency_methods.rb +57 -0
- data/lib/surveyor/models/question_group_methods.rb +58 -0
- data/lib/surveyor/models/question_methods.rb +112 -0
- data/lib/surveyor/models/response_methods.rb +126 -0
- data/lib/surveyor/models/response_set_methods.rb +188 -0
- data/lib/surveyor/models/survey_methods.rb +100 -0
- data/lib/surveyor/models/survey_section_methods.rb +53 -0
- data/lib/surveyor/models/survey_translation_methods.rb +30 -0
- data/lib/surveyor/models/validation_condition_methods.rb +54 -0
- data/lib/surveyor/models/validation_methods.rb +45 -0
- data/lib/surveyor/mustache_context.rb +11 -0
- data/lib/surveyor/parser.rb +427 -0
- data/lib/surveyor/redcap_parser.rb +288 -0
- data/lib/surveyor/surveyor_controller_methods.rb +236 -0
- data/lib/surveyor/unparser.rb +147 -0
- data/lib/surveyor/version.rb +3 -0
- data/lib/tasks/surveyor_tasks.rake +88 -0
- data/rails/init.rb +1 -0
- data/spec/controllers/surveyor_controller_spec.rb +311 -0
- data/spec/factories.rb +166 -0
- data/spec/helpers/formtastic_custom_input_spec.rb +15 -0
- data/spec/helpers/surveyor_helper_spec.rb +117 -0
- data/spec/lib/benchmark_spec.rb +22 -0
- data/spec/lib/chinese_survey.rb +14 -0
- data/spec/lib/common_spec.rb +34 -0
- data/spec/lib/parser_spec.rb +204 -0
- data/spec/lib/rake_kitchen_sink.rb +40 -0
- data/spec/lib/redcap_parser_spec.rb +75 -0
- data/spec/lib/tasks_spec.rake +26 -0
- data/spec/lib/unparser_spec.rb +126 -0
- data/spec/models/answer_spec.rb +174 -0
- data/spec/models/dependency_condition_spec.rb +439 -0
- data/spec/models/dependency_spec.rb +101 -0
- data/spec/models/question_group_spec.rb +93 -0
- data/spec/models/question_spec.rb +206 -0
- data/spec/models/response_set_spec.rb +477 -0
- data/spec/models/response_spec.rb +218 -0
- data/spec/models/survey_section_spec.rb +85 -0
- data/spec/models/survey_spec.rb +191 -0
- data/spec/models/validation_condition_spec.rb +113 -0
- data/spec/models/validation_spec.rb +74 -0
- data/spec/rcov.opts +2 -0
- data/spec/spec.opts +4 -0
- data/spec/spec_helper.rb +56 -0
- data/stacktests.sh +65 -0
- data/surveyor.gemspec +53 -0
- metadata +601 -0
@@ -0,0 +1,140 @@
|
|
1
|
+
@javascript
|
2
|
+
Feature: AJAX submissions
|
3
|
+
As a survey administrator
|
4
|
+
I want participants' responses to be saved as soon as possible
|
5
|
+
|
6
|
+
Scenario: With a simple pick-one question
|
7
|
+
Given the question
|
8
|
+
"""
|
9
|
+
q_1 "Was this saved?", :pick => :one
|
10
|
+
a_y "Yes"
|
11
|
+
a_n "No"
|
12
|
+
"""
|
13
|
+
When I start the survey
|
14
|
+
And I choose "Yes"
|
15
|
+
Then there should be a response for answer "y"
|
16
|
+
|
17
|
+
Scenario: With a simple pick-any question
|
18
|
+
Given the question
|
19
|
+
"""
|
20
|
+
q_1 "What is the state of the cat?", :pick => :any
|
21
|
+
a_d "Dead"
|
22
|
+
a_a "Alive"
|
23
|
+
a_s "Sleeping"
|
24
|
+
"""
|
25
|
+
When I start the survey
|
26
|
+
And I check "Alive"
|
27
|
+
And I check "Sleeping"
|
28
|
+
Then there should be a response for answer "a"
|
29
|
+
And there should be a response for answer "s"
|
30
|
+
And there should not be a response for answer "d"
|
31
|
+
|
32
|
+
Scenario: With a free text question
|
33
|
+
Given the question
|
34
|
+
"""
|
35
|
+
q_1 "What is your favorite movie?"
|
36
|
+
answer "Title", :string
|
37
|
+
"""
|
38
|
+
When I start the survey
|
39
|
+
And I fill in "Title" with "The Shawshank Redemption"
|
40
|
+
And I click elsewhere
|
41
|
+
Then there should be a string response with value "The Shawshank Redemption"
|
42
|
+
|
43
|
+
Scenario: With a date question
|
44
|
+
Given the question
|
45
|
+
"""
|
46
|
+
q_1 "When do you want to depart?"
|
47
|
+
answer "Departure date", :date
|
48
|
+
"""
|
49
|
+
When I start the survey
|
50
|
+
And I click "Departure date"
|
51
|
+
And I select "Mar" as the datepicker's month
|
52
|
+
And I select "2013" as the datepicker's year
|
53
|
+
And I follow "9"
|
54
|
+
Then there should be a date response with value "2013-03-09"
|
55
|
+
|
56
|
+
Scenario: With a datetime question
|
57
|
+
Given the question
|
58
|
+
"""
|
59
|
+
q_1 "When do you want to depart?"
|
60
|
+
answer "Departure date and time", :datetime
|
61
|
+
"""
|
62
|
+
When I start the survey
|
63
|
+
And I click "Departure date and time"
|
64
|
+
And I select "Apr" as the datepicker's month
|
65
|
+
And I select "2013" as the datepicker's year
|
66
|
+
And I follow "8"
|
67
|
+
Then there should be a date response with value "2013-04-08 00:00:00"
|
68
|
+
|
69
|
+
# How to move the sliders progammatically?
|
70
|
+
@wip
|
71
|
+
Scenario: With a time question
|
72
|
+
Given the question
|
73
|
+
"""
|
74
|
+
q_1 "When do you want lunch?"
|
75
|
+
answer "Meal time", :time
|
76
|
+
"""
|
77
|
+
When I start the survey
|
78
|
+
And I click "Meal time"
|
79
|
+
And ?
|
80
|
+
Then there should be a time response with value "11:45:00"
|
81
|
+
|
82
|
+
Scenario: With a pick-one plus free text question
|
83
|
+
Given the question
|
84
|
+
"""
|
85
|
+
q_1 "Where is Panama City?", :pick => :one
|
86
|
+
a_florida "Florida"
|
87
|
+
a_panama "Panama"
|
88
|
+
a_other :other, :string
|
89
|
+
"""
|
90
|
+
When I start the survey
|
91
|
+
And I fill in the string for "other" with "Chicago"
|
92
|
+
Then I click elsewhere
|
93
|
+
And there should be a string response for answer "other" with value "Chicago"
|
94
|
+
|
95
|
+
# How to move the slider programmatically?
|
96
|
+
@wip
|
97
|
+
Scenario: With a slider
|
98
|
+
Given the question
|
99
|
+
"""
|
100
|
+
q_1 "How many?", :pick => :one, :display_type => :slider
|
101
|
+
a_0 "None"
|
102
|
+
a_10 "Some"
|
103
|
+
a_100 "Lots"
|
104
|
+
"""
|
105
|
+
When I start the survey
|
106
|
+
And ?
|
107
|
+
Then there should be a response for answer "100"
|
108
|
+
|
109
|
+
# Issue #339
|
110
|
+
Scenario: With a grid question
|
111
|
+
Given the question
|
112
|
+
"""
|
113
|
+
grid "Tell us how often do you cover these each day" do
|
114
|
+
a_1 "1"
|
115
|
+
a_2 "2"
|
116
|
+
a_3 "3"
|
117
|
+
q_h "Head", :pick => :one
|
118
|
+
q_k "Knees", :pick => :one
|
119
|
+
q_t "Toes", :pick => :one
|
120
|
+
end
|
121
|
+
"""
|
122
|
+
When I start the survey
|
123
|
+
And I choose "3"
|
124
|
+
Then there should be a response for answer "3"
|
125
|
+
|
126
|
+
Scenario: With a repeater
|
127
|
+
Given the question
|
128
|
+
"""
|
129
|
+
repeater "List your former addresses" do
|
130
|
+
q "Address"
|
131
|
+
a_address_line "Line", :string
|
132
|
+
end
|
133
|
+
"""
|
134
|
+
When I start the survey
|
135
|
+
And I fill in the 1st string for "address_line" with "10 Downing St."
|
136
|
+
And I press "+ add row"
|
137
|
+
And I fill in the 2nd string for "address_line" with "1600 Penn Ave."
|
138
|
+
And I click elsewhere
|
139
|
+
Then there should be a string response for answer "address_line" with value "10 Downing St."
|
140
|
+
And there should be a string response for answer "address_line" with value "1600 Penn Ave."
|
@@ -0,0 +1,344 @@
|
|
1
|
+
Feature: Survey export
|
2
|
+
As an api consumer
|
3
|
+
I want to represent a survey in JSON
|
4
|
+
So that I can use it offline
|
5
|
+
|
6
|
+
Scenario: Exporting basic questions
|
7
|
+
Given I parse
|
8
|
+
"""
|
9
|
+
survey "Simple json" do
|
10
|
+
section "Basic questions" do
|
11
|
+
label "These questions are examples of the basic supported input types"
|
12
|
+
|
13
|
+
question_1 "What is your favorite color?", :pick => :one
|
14
|
+
answer "red"
|
15
|
+
answer "blue"
|
16
|
+
answer "green"
|
17
|
+
answer :other
|
18
|
+
|
19
|
+
q_2b "Choose the colors you don't like", :pick => :any
|
20
|
+
a "orange"
|
21
|
+
a "purple"
|
22
|
+
a "brown"
|
23
|
+
a :omit
|
24
|
+
end
|
25
|
+
end
|
26
|
+
"""
|
27
|
+
And I visit "/surveys/simple-json.json"
|
28
|
+
Then the JSON should be:
|
29
|
+
"""
|
30
|
+
{
|
31
|
+
"title": "Simple json",
|
32
|
+
"uuid": "*",
|
33
|
+
"sections": [{
|
34
|
+
"title": "Basic questions",
|
35
|
+
"display_order":0,
|
36
|
+
"questions_and_groups": [
|
37
|
+
{ "uuid": "*", "type": "label", "text": "These questions are examples of the basic supported input types" },
|
38
|
+
{ "uuid": "*", "reference_identifier": "1", "pick": "one", "text": "What is your favorite color?", "answers": [{"text": "red", "uuid": "*"}, {"text": "blue", "uuid": "*"}, {"text": "green", "uuid": "*"}, {"text": "Other", "uuid": "*"}]},
|
39
|
+
{ "uuid": "*", "reference_identifier": "2b", "pick": "any", "text": "Choose the colors you don't like", "answers": [{"text": "orange", "uuid": "*"},{"text": "purple", "uuid": "*"},{"text": "brown", "uuid": "*"},{"text": "Omit", "exclusive":true, "uuid": "*"}]}]
|
40
|
+
}]
|
41
|
+
}
|
42
|
+
"""
|
43
|
+
|
44
|
+
Scenario: Exporting export and reference identifiers
|
45
|
+
Given I parse
|
46
|
+
"""
|
47
|
+
survey "Exportable" do
|
48
|
+
section "First section" do
|
49
|
+
question_1 "What is your favorite color?", :pick => :one, :data_export_identifier => "favorite_color"
|
50
|
+
a_red "red"
|
51
|
+
a_blue "blue"
|
52
|
+
|
53
|
+
q_2b "Choose the colors you don't like", :pick => :any
|
54
|
+
a_1 "orange", :data_export_identifier => "dont_like_orange"
|
55
|
+
a_2 "purple"
|
56
|
+
end
|
57
|
+
end
|
58
|
+
"""
|
59
|
+
And I visit "/surveys/exportable.json"
|
60
|
+
Then the JSON should be:
|
61
|
+
"""
|
62
|
+
{
|
63
|
+
"title": "Exportable",
|
64
|
+
"uuid": "*",
|
65
|
+
"sections": [{
|
66
|
+
"title": "First section",
|
67
|
+
"display_order":0,
|
68
|
+
"questions_and_groups": [
|
69
|
+
{ "uuid": "*", "reference_identifier": "1", "pick": "one", "text": "What is your favorite color?", "data_export_identifier": "favorite_color", "answers": [{"text": "red", "uuid": "*", "reference_identifier": "red"}, {"text": "blue", "uuid": "*", "reference_identifier": "blue"}]},
|
70
|
+
{ "uuid": "*", "reference_identifier": "2b", "pick": "any", "text": "Choose the colors you don't like", "answers": [{"text": "orange", "uuid": "*", "reference_identifier": "1", "data_export_identifier": "dont_like_orange"},{"text": "purple", "uuid": "*", "reference_identifier": "2"}]}]
|
71
|
+
}]
|
72
|
+
}
|
73
|
+
"""
|
74
|
+
|
75
|
+
Scenario: Exporting versioned survey questions
|
76
|
+
Given I parse
|
77
|
+
"""
|
78
|
+
survey "Simple json" do
|
79
|
+
section "Basic questions" do
|
80
|
+
label "These questions are examples of the basic supported input types"
|
81
|
+
|
82
|
+
question_1 "What is your favorite color?", :pick => :one
|
83
|
+
answer "red"
|
84
|
+
answer "blue"
|
85
|
+
answer "green"
|
86
|
+
answer :other
|
87
|
+
|
88
|
+
q_2b "Choose the colors you don't like", :pick => :any
|
89
|
+
a "orange"
|
90
|
+
a "purple"
|
91
|
+
a "brown"
|
92
|
+
a :omit
|
93
|
+
end
|
94
|
+
end
|
95
|
+
"""
|
96
|
+
And I parse
|
97
|
+
"""
|
98
|
+
survey "Simple json" do
|
99
|
+
section "Not so basic questions" do
|
100
|
+
label "These questions are examples of the basic supported input types"
|
101
|
+
|
102
|
+
question_1 "What is your favorite color?", :pick => :one
|
103
|
+
answer "reddish"
|
104
|
+
answer "blueish"
|
105
|
+
answer "greenish"
|
106
|
+
answer :other
|
107
|
+
|
108
|
+
q_2b "Choose the colors you don't like", :pick => :any
|
109
|
+
a "orange"
|
110
|
+
a "purple"
|
111
|
+
a "brown"
|
112
|
+
a :omit
|
113
|
+
end
|
114
|
+
end
|
115
|
+
"""
|
116
|
+
And I visit "/surveys/simple-json.json"
|
117
|
+
Then the JSON should be:
|
118
|
+
"""
|
119
|
+
{
|
120
|
+
"title": "Simple json",
|
121
|
+
"uuid": "*",
|
122
|
+
"sections": [{
|
123
|
+
"title": "Not so basic questions",
|
124
|
+
"display_order":0,
|
125
|
+
"questions_and_groups": [
|
126
|
+
{ "uuid": "*", "type": "label", "text": "These questions are examples of the basic supported input types" },
|
127
|
+
{ "uuid": "*", "reference_identifier": "1", "pick": "one", "text": "What is your favorite color?", "answers": [{"text": "reddish", "uuid": "*"}, {"text": "blueish", "uuid": "*"}, {"text": "greenish", "uuid": "*"}, {"text": "Other", "uuid": "*"}]},
|
128
|
+
{ "uuid": "*", "reference_identifier": "2b", "pick": "any", "text": "Choose the colors you don't like", "answers": [{"text": "orange", "uuid": "*"},{"text": "purple", "uuid": "*"},{"text": "brown", "uuid": "*"},{"text": "Omit", "exclusive":true, "uuid": "*"}]}]
|
129
|
+
}]
|
130
|
+
}
|
131
|
+
"""
|
132
|
+
And I visit "/surveys/simple-json.json?survey_version=0"
|
133
|
+
Then the JSON should be:
|
134
|
+
"""
|
135
|
+
{
|
136
|
+
"title": "Simple json",
|
137
|
+
"uuid": "*",
|
138
|
+
"sections": [{
|
139
|
+
"title": "Basic questions",
|
140
|
+
"display_order":0,
|
141
|
+
"questions_and_groups": [
|
142
|
+
{ "uuid": "*", "type": "label", "text": "These questions are examples of the basic supported input types" },
|
143
|
+
{ "uuid": "*", "reference_identifier": "1", "pick": "one", "text": "What is your favorite color?", "answers": [{"text": "red", "uuid": "*"}, {"text": "blue", "uuid": "*"}, {"text": "green", "uuid": "*"}, {"text": "Other", "uuid": "*"}]},
|
144
|
+
{ "uuid": "*", "reference_identifier": "2b", "pick": "any", "text": "Choose the colors you don't like", "answers": [{"text": "orange", "uuid": "*"},{"text": "purple", "uuid": "*"},{"text": "brown", "uuid": "*"},{"text": "Omit", "exclusive":true, "uuid": "*"}]}]
|
145
|
+
}]
|
146
|
+
}
|
147
|
+
"""
|
148
|
+
|
149
|
+
Scenario: Exporting input mask and mask placeholder
|
150
|
+
Given I parse
|
151
|
+
"""
|
152
|
+
survey "Personal" do
|
153
|
+
section "Guy" do
|
154
|
+
q "What is your phone number?"
|
155
|
+
a :string, :input_mask => '(999)999-9999', :input_mask_placeholder => '#'
|
156
|
+
end
|
157
|
+
end
|
158
|
+
"""
|
159
|
+
And I visit "/surveys/personal.json"
|
160
|
+
Then the JSON should be:
|
161
|
+
"""
|
162
|
+
{
|
163
|
+
"title": "Personal",
|
164
|
+
"uuid": "*",
|
165
|
+
"sections": [{
|
166
|
+
"display_order": 0,
|
167
|
+
"title": "Guy",
|
168
|
+
"questions_and_groups": [
|
169
|
+
{
|
170
|
+
"uuid": "*",
|
171
|
+
"text": "What is your phone number?",
|
172
|
+
"answers": [
|
173
|
+
{
|
174
|
+
"input_mask": "(999)999-9999",
|
175
|
+
"input_mask_placeholder": "#",
|
176
|
+
"text": "String",
|
177
|
+
"type": "string",
|
178
|
+
"uuid": "*"
|
179
|
+
}
|
180
|
+
]
|
181
|
+
}]
|
182
|
+
}]
|
183
|
+
}
|
184
|
+
"""
|
185
|
+
|
186
|
+
Scenario: Exporting response sets
|
187
|
+
Given I parse
|
188
|
+
"""
|
189
|
+
survey "Simple json response sets" do
|
190
|
+
section "Section 1" do
|
191
|
+
|
192
|
+
question_1 "What is your favorite color?", :pick => :one
|
193
|
+
answer "red"
|
194
|
+
answer "blue"
|
195
|
+
answer "green"
|
196
|
+
answer :other
|
197
|
+
|
198
|
+
q_2b "What color don't you like?"
|
199
|
+
a_1 "color", :string
|
200
|
+
end
|
201
|
+
section "Section 2" do
|
202
|
+
label "no"
|
203
|
+
end
|
204
|
+
end
|
205
|
+
"""
|
206
|
+
When I start the "Simple json response sets" survey
|
207
|
+
And I choose "red"
|
208
|
+
And I press "Section 2"
|
209
|
+
And I press "Section 1"
|
210
|
+
And I fill in "color" with "orange"
|
211
|
+
And I press "Section 2"
|
212
|
+
And I press "Click here to finish"
|
213
|
+
Then there should be 1 response set with 2 responses with:
|
214
|
+
| answer |
|
215
|
+
| red |
|
216
|
+
And I export the response set
|
217
|
+
Then the JSON at "responses" should have 2 entries
|
218
|
+
Then the JSON should not have "responses/0/value"
|
219
|
+
And the JSON response at "responses/0/answer_id" should correspond to an answer with text "red"
|
220
|
+
And the JSON response at "responses/1/value" should be "orange"
|
221
|
+
And the JSON response at "responses/1/answer_id" should correspond to an answer with text "color"
|
222
|
+
|
223
|
+
# Issue #294 - ResponseSet#to_json generates unexpected results with zero Responses
|
224
|
+
Scenario: Exporting response sets without responses
|
225
|
+
Given I parse
|
226
|
+
"""
|
227
|
+
survey "Simple json response sets" do
|
228
|
+
section "Colors" do
|
229
|
+
|
230
|
+
question_1 "What is your favorite color?", :pick => :one
|
231
|
+
answer "red"
|
232
|
+
answer "blue"
|
233
|
+
answer "green"
|
234
|
+
answer :other
|
235
|
+
|
236
|
+
q_2b "What color don't you like?"
|
237
|
+
a_1 "color", :string
|
238
|
+
end
|
239
|
+
section "Other" do
|
240
|
+
label "no"
|
241
|
+
end
|
242
|
+
end
|
243
|
+
"""
|
244
|
+
When I start the "Simple json response sets" survey
|
245
|
+
And I export the response set
|
246
|
+
Then the JSON at "responses" should be an array
|
247
|
+
Then the JSON at "responses" should have 0 entries
|
248
|
+
|
249
|
+
Scenario: Exporting response sets for versioned surveys
|
250
|
+
Given I parse
|
251
|
+
"""
|
252
|
+
survey "Simple json response sets" do
|
253
|
+
section "Colors" do
|
254
|
+
question "What is your least favorite color?"
|
255
|
+
a "least favorite color", :string
|
256
|
+
end
|
257
|
+
end
|
258
|
+
"""
|
259
|
+
And I start the "Simple json response sets" survey
|
260
|
+
And I fill in "color" with "orange"
|
261
|
+
And I press "Click here to finish"
|
262
|
+
And I export the response set
|
263
|
+
Then the JSON at "responses" should have 1 entry
|
264
|
+
And the JSON response at "responses/0/value" should be "orange"
|
265
|
+
And the JSON response at "responses/0/answer_id" should correspond to an answer with text "least favorite color"
|
266
|
+
And I parse
|
267
|
+
"""
|
268
|
+
survey "Simple json response sets" do
|
269
|
+
section "Colors" do
|
270
|
+
question_1 "What is your most favorite color?"
|
271
|
+
a "most favorite color", :string
|
272
|
+
end
|
273
|
+
end
|
274
|
+
"""
|
275
|
+
And I start the "Simple json response sets" survey
|
276
|
+
And I fill in "color" with "blueish"
|
277
|
+
And I press "Click here to finish"
|
278
|
+
And I export the response set
|
279
|
+
Then the JSON at "responses" should have 1 entry
|
280
|
+
And the JSON response at "responses/0/value" should be "blueish"
|
281
|
+
And the JSON response at "responses/0/answer_id" should correspond to an answer with text "most favorite color"
|
282
|
+
|
283
|
+
Scenario: Exporting null datetime response
|
284
|
+
Given I parse
|
285
|
+
"""
|
286
|
+
survey "Health" do
|
287
|
+
section "Doctor" do
|
288
|
+
question "When did you visit?", :pick => :one
|
289
|
+
a "Date", :date
|
290
|
+
a "Not sure"
|
291
|
+
end
|
292
|
+
end
|
293
|
+
"""
|
294
|
+
And I start the "Health" survey
|
295
|
+
And I choose "Date"
|
296
|
+
And I press "Click here to finish"
|
297
|
+
And I export the response set
|
298
|
+
Then the JSON at "responses" should have 1 entry
|
299
|
+
And the JSON response at "responses/0/value" should be null
|
300
|
+
|
301
|
+
Scenario: Exporting non-existent surveys
|
302
|
+
When I visit "/surveys/simple-json.json"
|
303
|
+
Then I should get a "404" response
|
304
|
+
|
305
|
+
Scenario: Exporting with survey modifications
|
306
|
+
Given I parse
|
307
|
+
"""
|
308
|
+
survey "Simple" do
|
309
|
+
section "Colors" do
|
310
|
+
question "What is your least favorite color?"
|
311
|
+
a "least favorite color", :string
|
312
|
+
end
|
313
|
+
end
|
314
|
+
"""
|
315
|
+
When I prefix the titles of exported surveys with "NUBIC - "
|
316
|
+
Then the JSON representation for "Simple" should be:
|
317
|
+
"""
|
318
|
+
{
|
319
|
+
"title": "NUBIC - Simple",
|
320
|
+
"uuid": "*",
|
321
|
+
"sections": [{
|
322
|
+
"title": "Colors",
|
323
|
+
"display_order":0,
|
324
|
+
"questions_and_groups": [
|
325
|
+
{ "uuid": "*", "text": "What is your least favorite color?", "answers": [{"text": "least favorite color", "uuid": "*", "type": "string"}]}
|
326
|
+
]
|
327
|
+
}]
|
328
|
+
}
|
329
|
+
"""
|
330
|
+
When I visit "/surveys/simple.json"
|
331
|
+
Then the JSON should be:
|
332
|
+
"""
|
333
|
+
{
|
334
|
+
"title": "NUBIC - Simple",
|
335
|
+
"uuid": "*",
|
336
|
+
"sections": [{
|
337
|
+
"title": "Colors",
|
338
|
+
"display_order":0,
|
339
|
+
"questions_and_groups": [
|
340
|
+
{ "uuid": "*", "text": "What is your least favorite color?", "answers": [{"text": "least favorite color", "uuid": "*", "type": "string"}]}
|
341
|
+
]
|
342
|
+
}]
|
343
|
+
}
|
344
|
+
"""
|