hssc_surveyor 1.4.1.pre
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +28 -0
- data/.rspec +1 -0
- data/CHANGELOG.md +198 -0
- data/Gemfile +5 -0
- data/Gemfile.rails_version +19 -0
- data/MIT-LICENSE +20 -0
- data/README.md +186 -0
- data/Rakefile +105 -0
- data/app/controllers/surveyor_controller.rb +6 -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 +4 -0
- data/app/models/dependency.rb +4 -0
- data/app/models/dependency_condition.rb +4 -0
- data/app/models/question.rb +4 -0
- data/app/models/question_group.rb +5 -0
- data/app/models/response.rb +5 -0
- data/app/models/response_set.rb +4 -0
- data/app/models/survey.rb +4 -0
- data/app/models/survey_section.rb +5 -0
- data/app/models/survey_section_sweeper.rb +15 -0
- data/app/models/survey_translation.rb +5 -0
- data/app/models/validation.rb +4 -0
- data/app/models/validation_condition.rb +4 -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 +41 -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/ui-bg_flat_0_aaaaaa_40x100.png +0 -0
- data/lib/assets/images/ui-bg_flat_75_ffffff_40x100.png +0 -0
- data/lib/assets/images/ui-bg_glass_55_fbf9ee_1x400.png +0 -0
- data/lib/assets/images/ui-bg_glass_65_ffffff_1x400.png +0 -0
- data/lib/assets/images/ui-bg_glass_75_dadada_1x400.png +0 -0
- data/lib/assets/images/ui-bg_glass_75_e6e6e6_1x400.png +0 -0
- data/lib/assets/images/ui-bg_glass_95_fef1ec_1x400.png +0 -0
- data/lib/assets/images/ui-bg_highlight-soft_75_cccccc_1x100.png +0 -0
- data/lib/assets/images/ui-icons_222222_256x240.png +0 -0
- data/lib/assets/images/ui-icons_2e83ff_256x240.png +0 -0
- data/lib/assets/images/ui-icons_454545_256x240.png +0 -0
- data/lib/assets/images/ui-icons_888888_256x240.png +0 -0
- data/lib/assets/images/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 +156 -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/assets/stylesheets/surveyor.sass +132 -0
- data/lib/generators/surveyor/custom_generator.rb +18 -0
- data/lib/generators/surveyor/install_generator.rb +102 -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_attachment_to_response.rb +5 -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 +284 -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/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 +13 -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 +86 -0
- data/lib/surveyor/models/dependency_condition_methods.rb +72 -0
- data/lib/surveyor/models/dependency_methods.rb +60 -0
- data/lib/surveyor/models/question_group_methods.rb +61 -0
- data/lib/surveyor/models/question_methods.rb +115 -0
- data/lib/surveyor/models/response_methods.rb +132 -0
- data/lib/surveyor/models/response_set_methods.rb +196 -0
- data/lib/surveyor/models/survey_methods.rb +103 -0
- data/lib/surveyor/models/survey_section_methods.rb +56 -0
- data/lib/surveyor/models/survey_translation_methods.rb +33 -0
- data/lib/surveyor/models/validation_condition_methods.rb +56 -0
- data/lib/surveyor/models/validation_methods.rb +48 -0
- data/lib/surveyor/mustache_context.rb +11 -0
- data/lib/surveyor/parser.rb +428 -0
- data/lib/surveyor/redcap_parser.rb +289 -0
- data/lib/surveyor/surveyor_controller_methods.rb +237 -0
- data/lib/surveyor/unparser.rb +147 -0
- data/lib/surveyor/version.rb +3 -0
- data/lib/surveyor.rb +13 -0
- data/lib/tasks/surveyor_tasks.rake +88 -0
- data/rails/init.rb +1 -0
- data/spec/controllers/surveyor_controller_spec.rb +307 -0
- data/spec/factories.rb +161 -0
- data/spec/helpers/formtastic_custom_input_spec.rb +15 -0
- data/spec/helpers/surveyor_helper_spec.rb +118 -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 +175 -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 +207 -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 +45 -0
- metadata +657 -0
@@ -0,0 +1,54 @@
|
|
1
|
+
{
|
2
|
+
"$schema": "http://json-schema.org/draft-03/schema#",
|
3
|
+
"description": "Response set",
|
4
|
+
"properties": {
|
5
|
+
"completed_at": {
|
6
|
+
"$ref": "http://download.nubic.northwestern.edu/surveyor/surveyor_timestamp_schema.json#"
|
7
|
+
},
|
8
|
+
"created_at": {
|
9
|
+
"$ref": "http://download.nubic.northwestern.edu/surveyor/surveyor_timestamp_schema.json#"
|
10
|
+
},
|
11
|
+
"responses": {
|
12
|
+
"description": "Responses in the response set",
|
13
|
+
"items": {
|
14
|
+
"properties": {
|
15
|
+
"answer_id": {
|
16
|
+
"$ref": "http://download.nubic.northwestern.edu/surveyor/api_id_schema.json#"
|
17
|
+
},
|
18
|
+
"created_at": {
|
19
|
+
"$ref": "http://download.nubic.northwestern.edu/surveyor/surveyor_timestamp_schema.json#"
|
20
|
+
},
|
21
|
+
"question_id": {
|
22
|
+
"$ref": "http://download.nubic.northwestern.edu/surveyor/api_id_schema.json#"
|
23
|
+
},
|
24
|
+
"response_group": {
|
25
|
+
"type": [
|
26
|
+
"string",
|
27
|
+
"null"
|
28
|
+
]
|
29
|
+
},
|
30
|
+
"updated_at": {
|
31
|
+
"$ref": "http://download.nubic.northwestern.edu/surveyor/surveyor_timestamp_schema.json#"
|
32
|
+
},
|
33
|
+
"uuid": {
|
34
|
+
"$ref": "http://download.nubic.northwestern.edu/surveyor/api_id_schema.json#"
|
35
|
+
},
|
36
|
+
"value": {
|
37
|
+
"type": [
|
38
|
+
"string",
|
39
|
+
"number",
|
40
|
+
"null"
|
41
|
+
]
|
42
|
+
}
|
43
|
+
}
|
44
|
+
},
|
45
|
+
"type": "array"
|
46
|
+
},
|
47
|
+
"survey_id": {
|
48
|
+
"$ref": "http://download.nubic.northwestern.edu/surveyor/api_id_schema.json#"
|
49
|
+
},
|
50
|
+
"uuid": {
|
51
|
+
"$ref": "http://download.nubic.northwestern.edu/surveyor/api_id_schema.json#"
|
52
|
+
}
|
53
|
+
}
|
54
|
+
}
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
@@ -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
|
+
"""
|
@@ -0,0 +1,121 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
Feature: Internationalization
|
3
|
+
As survey taker
|
4
|
+
I want to see surveys in my own language
|
5
|
+
So that I understand what they're asking
|
6
|
+
|
7
|
+
Scenario:
|
8
|
+
Given I parse
|
9
|
+
"""
|
10
|
+
survey "One language is never enough" do
|
11
|
+
translations :en => :default
|
12
|
+
translations :es => {"title"=>"Un idioma nunca es suficiente", "survey_sections"=>{"one"=>{"title"=>"Uno"}}, "question_groups"=>{"hello"=>{"text"=>"¡Hola!"}}, "questions"=>{"name"=>{"text"=>"¿Cómo se llama Usted?", "answers"=>{"name"=>{"help_text"=>"Mi nombre es..."}}}}}
|
13
|
+
translations :he => {"title"=>"ידיעת שפה אחת אינה מספיקה", "survey_sections"=>{"one"=>{"title"=>"אחת"}}, "question_groups"=>{"hello"=>{"text"=>"שלום"}}, "questions"=>{"name"=>{"text"=>"מה שמך?", "answers"=>{"name"=>{"help_text"=>"שמי..."}}}}}
|
14
|
+
translations :ko => {"title"=>"한가지 언어로는 충분치 않습니다.", "survey_sections"=>{"one"=>{"title"=>"하나"}}, "question_groups"=>{"hello"=>{"text"=>"안녕하십니까"}}, "questions"=>{"name"=>{"text"=>"성함이 어떻게 되십니까?", "answers"=>{"name"=>{"help_text"=>"제 이름은 ... 입니다"}}}}}
|
15
|
+
section_one "One" do
|
16
|
+
g_hello "Hello" do
|
17
|
+
q_name "What is your name?"
|
18
|
+
a_name :string, :help_text => "My name is..."
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
"""
|
23
|
+
Then there should be 4 translations with
|
24
|
+
| locale |
|
25
|
+
| en |
|
26
|
+
| es |
|
27
|
+
| he |
|
28
|
+
| ko |
|
29
|
+
When I start the survey
|
30
|
+
Then I should see "One language is never enough"
|
31
|
+
And a dropdown should exist with the options "en, es, he, ko"
|
32
|
+
And I should see "One"
|
33
|
+
And I should see "Hello"
|
34
|
+
And I should see "What is your name?"
|
35
|
+
And I should see "My name is..."
|
36
|
+
When I start the survey in "en"
|
37
|
+
Then I should see "One language is never enough"
|
38
|
+
And a dropdown should exist with the options "en, es, he, ko"
|
39
|
+
And I should see "One"
|
40
|
+
And I should see "Hello"
|
41
|
+
And I should see "What is your name?"
|
42
|
+
And I should see "My name is..."
|
43
|
+
When I start the survey in "es"
|
44
|
+
Then I should see "Un idioma nunca es suficiente"
|
45
|
+
And a dropdown should exist with the options "en, es, he, ko"
|
46
|
+
And I should see "Uno"
|
47
|
+
And I should see "¡Hola!"
|
48
|
+
And I should see "¿Cómo se llama Usted?"
|
49
|
+
And I should see "Mi nombre es..."
|
50
|
+
When I start the survey in "he"
|
51
|
+
Then I should see "ידיעת שפה אחת אינה מספיקה"
|
52
|
+
And a dropdown should exist with the options "en, es, he, ko"
|
53
|
+
And I should see "אחת"
|
54
|
+
And I should see "שלום"
|
55
|
+
And I should see "מה שמך?"
|
56
|
+
And I should see "שמי..."
|
57
|
+
When I start the survey in "ko"
|
58
|
+
Then I should see "한가지 언어로는 충분치 않습니다."
|
59
|
+
And a dropdown should exist with the options "en, es, he, ko"
|
60
|
+
And I should see "하나"
|
61
|
+
And I should see "안녕하십니까"
|
62
|
+
And I should see "성함이 어떻게 되십니까?"
|
63
|
+
And I should see "제 이름은 ... 입니다"
|
64
|
+
When I start the survey
|
65
|
+
Then I should see "One language is never enough"
|
66
|
+
And a dropdown should exist with the options "en, es, he, ko"
|
67
|
+
And I should see "One"
|
68
|
+
And I should see "Hello"
|
69
|
+
And I should see "What is your name?"
|
70
|
+
And I should see "My name is..."
|
71
|
+
|
72
|
+
|
73
|
+
Scenario:
|
74
|
+
Given I parse
|
75
|
+
"""
|
76
|
+
survey "Favorites" do
|
77
|
+
section "Foods" do
|
78
|
+
question_1 "What is the best meat?", :pick => :one, :correct => "oink"
|
79
|
+
a_oink "bacon"
|
80
|
+
a_tweet "chicken"
|
81
|
+
a_moo "beef"
|
82
|
+
end
|
83
|
+
end
|
84
|
+
"""
|
85
|
+
When I start the survey
|
86
|
+
Then I should not see "Language"
|
87
|
+
|
88
|
+
@javascript
|
89
|
+
Scenario:
|
90
|
+
Given I parse
|
91
|
+
"""
|
92
|
+
survey "One language is never enough" do
|
93
|
+
translations :en => :default
|
94
|
+
translations :es => {"title"=>"Un idioma nunca es suficiente", "survey_sections"=>{"one"=>{"title"=>"Uno"}, "two"=>{"title"=>"Dos"}}, "question_groups"=>{"hello"=>{"text"=>"¡Hola!"}}, "questions"=>{"name"=>{"text"=>"¿Cómo se llama Usted?", "answers"=>{"name"=>{"help_text"=>"Mi nombre es..."}}}, "color"=>{"text"=>"¿Cuál es tu color favorito?"}}}
|
95
|
+
translations :he => {"title"=>"ידיעת שפה אחת אינה מספיקה", "survey_sections"=>{"one"=>{"title"=>"אחת"}, "two"=>{"title"=>"שנים"}}, "question_groups"=>{"hello"=>{"text"=>"שלום"}}, "questions"=>{"name"=>{"text"=>"מה שמך?", "answers"=>{"name"=>{"help_text"=>"שמי..."}}}, "color"=>{"text"=>"מהו הצבע האהוב עליך?"}}}
|
96
|
+
|
97
|
+
section_one "One" do
|
98
|
+
g_hello "Hello" do
|
99
|
+
q_name "What is your name?"
|
100
|
+
a_name :string, :help_text => "My name is..."
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
section_two "Two" do
|
105
|
+
q_color "What is your favorite color?"
|
106
|
+
a_name :string
|
107
|
+
end
|
108
|
+
end
|
109
|
+
"""
|
110
|
+
When I start the survey in "en"
|
111
|
+
Then I should see "One language is never enough"
|
112
|
+
And I should see "What is your name?"
|
113
|
+
And I should see "Language"
|
114
|
+
And a dropdown should exist with the options "en, es, he"
|
115
|
+
When I change the locale to "es"
|
116
|
+
Then I should see "Un idioma nunca es suficiente"
|
117
|
+
And I should see "¿Cómo se llama Usted?"
|
118
|
+
When I press "Dos"
|
119
|
+
Then I should see "¿Cuál es tu color favorito?"
|
120
|
+
When I change the locale to "he"
|
121
|
+
Then I should see "מהו הצבע האהוב עליך?"
|