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,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 "מהו הצבע האהוב עליך?"
|
@@ -0,0 +1,110 @@
|
|
1
|
+
@javascript @slow_updates @simultaneous_ajax
|
2
|
+
Feature: Duplicate response prevention
|
3
|
+
As a survey administrator
|
4
|
+
I want to get exactly the number of responses entered
|
5
|
+
So that my results are analytically valid
|
6
|
+
|
7
|
+
Scenario: With a simple pick-one question
|
8
|
+
Given the question
|
9
|
+
"""
|
10
|
+
q_1 "Was this saved?", :pick => :one
|
11
|
+
a_y "Yes"
|
12
|
+
a_n "No"
|
13
|
+
"""
|
14
|
+
When I start the survey
|
15
|
+
And I choose "Yes"
|
16
|
+
And I choose "No"
|
17
|
+
And I wait for things to settle out
|
18
|
+
Then there should be a response for answer "n"
|
19
|
+
And there should not be a response for answer "y"
|
20
|
+
|
21
|
+
Scenario: With a simple pick-any question
|
22
|
+
Given the question
|
23
|
+
"""
|
24
|
+
q_1 "What is the state of the cat?", :pick => :any
|
25
|
+
a_d "Dead"
|
26
|
+
a_a "Alive"
|
27
|
+
a_s "Sleeping"
|
28
|
+
"""
|
29
|
+
When I start the survey
|
30
|
+
And I check "Alive"
|
31
|
+
And I check "Dead"
|
32
|
+
And I uncheck "Dead"
|
33
|
+
And I check "Sleeping"
|
34
|
+
And I wait for things to settle out
|
35
|
+
Then there should be a response for answer "a"
|
36
|
+
And there should be a response for answer "s"
|
37
|
+
And there should not be a response for answer "d"
|
38
|
+
|
39
|
+
Scenario: With a free text question
|
40
|
+
Given the question
|
41
|
+
"""
|
42
|
+
q_1 "What is your favorite movie?"
|
43
|
+
answer "Title", :string
|
44
|
+
"""
|
45
|
+
When I start the survey
|
46
|
+
And I fill in "Title" with "The Shawshank Redemption"
|
47
|
+
And I click elsewhere
|
48
|
+
And I fill in "Title" with "Rear Window"
|
49
|
+
And I click elsewhere
|
50
|
+
And I wait for things to settle out
|
51
|
+
And there should be a string response with value "Rear Window"
|
52
|
+
Then there should not be a string response with value "The Shawshank Redemption"
|
53
|
+
|
54
|
+
Scenario: With a pick-one plus free text question
|
55
|
+
Given the question
|
56
|
+
"""
|
57
|
+
q_1 "Where is Panama City?", :pick => :one
|
58
|
+
a_florida "Florida"
|
59
|
+
a_panama "Panama"
|
60
|
+
a_other :other, :string
|
61
|
+
"""
|
62
|
+
When I start the survey
|
63
|
+
And I choose "Florida"
|
64
|
+
And I choose "Other"
|
65
|
+
And I fill in the string for "other" with "Chicago"
|
66
|
+
And I click elsewhere
|
67
|
+
And I wait for things to settle out
|
68
|
+
Then there should be a string response for answer "other" with value "Chicago"
|
69
|
+
And there should not be a response for answer "florida"
|
70
|
+
|
71
|
+
Scenario: With a grid question
|
72
|
+
Given the question
|
73
|
+
"""
|
74
|
+
grid "Tell us how often do you cover these each day" do
|
75
|
+
a_1 "1"
|
76
|
+
a_2 "2"
|
77
|
+
a_3 "3"
|
78
|
+
q_h "Head", :pick => :one
|
79
|
+
q_k "Knees", :pick => :one
|
80
|
+
q_t "Toes", :pick => :one
|
81
|
+
end
|
82
|
+
"""
|
83
|
+
When I start the survey
|
84
|
+
And I choose row 1, column 3 of the grid
|
85
|
+
And I choose row 1, column 2 of the grid
|
86
|
+
And I choose row 2, column 1 of the grid
|
87
|
+
And I wait for things to settle out
|
88
|
+
Then there should be a response for answer "2" on question "h"
|
89
|
+
And there should not be a response for answer "3" on question "h"
|
90
|
+
And there should be a response for answer "1" on question "k"
|
91
|
+
|
92
|
+
Scenario: With a repeater
|
93
|
+
Given the question
|
94
|
+
"""
|
95
|
+
repeater "List your former addresses" do
|
96
|
+
q "Address"
|
97
|
+
a_address_line "Line", :string
|
98
|
+
end
|
99
|
+
"""
|
100
|
+
When I start the survey
|
101
|
+
And I fill in the 1st string for "address_line" with "10 Downing St."
|
102
|
+
And I press "+ add row"
|
103
|
+
And I fill in the 2nd string for "address_line" with "1600 Penn Ave."
|
104
|
+
And I click elsewhere
|
105
|
+
And I fill in the 2nd string for "address_line" with "1600 Pennsylvania Ave."
|
106
|
+
And I click elsewhere
|
107
|
+
And I wait for things to settle out longer
|
108
|
+
Then there should be a string response for answer "address_line" with value "10 Downing St."
|
109
|
+
And there should not be a string response for answer "address_line" with value "1600 Penn Ave."
|
110
|
+
And there should be a string response for answer "address_line" with value "1600 Pennsylvania Ave."
|
@@ -0,0 +1,71 @@
|
|
1
|
+
Feature: showing a survey
|
2
|
+
As a survey administrator
|
3
|
+
I want to see a survey that a participant has taken
|
4
|
+
So that I can understand the data
|
5
|
+
|
6
|
+
Scenario: Take a survey, then look at it
|
7
|
+
Given I parse
|
8
|
+
"""
|
9
|
+
survey "Favorites" do
|
10
|
+
section "Colors" do
|
11
|
+
label "You with the sad eyes don't be discouraged"
|
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_1 "orange"
|
21
|
+
a_2 "purple"
|
22
|
+
a_3 "brown"
|
23
|
+
a :omit
|
24
|
+
end
|
25
|
+
end
|
26
|
+
"""
|
27
|
+
When I start the "Favorites" survey
|
28
|
+
Then I should see "You with the sad eyes don't be discouraged"
|
29
|
+
And I choose "red"
|
30
|
+
And I choose "blue"
|
31
|
+
And I check "orange"
|
32
|
+
And I check "brown"
|
33
|
+
And I press "Click here to finish"
|
34
|
+
Then there should be 1 response set with 3 responses with:
|
35
|
+
| answer |
|
36
|
+
| blue |
|
37
|
+
| orange |
|
38
|
+
| brown |
|
39
|
+
When I go to the last response set show page
|
40
|
+
Then I should see "You with the sad eyes don't be discouraged"
|
41
|
+
Then the "blue" radiobutton should be checked
|
42
|
+
And the "orange" checkbox should be checked
|
43
|
+
And the "brown" checkbox should be checked
|
44
|
+
|
45
|
+
Scenario: Take a survey with group questions, then look at it
|
46
|
+
Given I parse
|
47
|
+
"""
|
48
|
+
survey "Grid question test", :default_mandatory => false do
|
49
|
+
section 'Communication Skills' do
|
50
|
+
grid 'Identify communication and interviewing skills' do
|
51
|
+
a 'Yes'
|
52
|
+
a 'No'
|
53
|
+
|
54
|
+
q 'Able to articulate job duties and skills', :pick => :one
|
55
|
+
end
|
56
|
+
|
57
|
+
q 'Communication Skills Comments'
|
58
|
+
a :text
|
59
|
+
end
|
60
|
+
end
|
61
|
+
"""
|
62
|
+
When I start the "Grid question test" survey
|
63
|
+
Then I should see "Identify communication and interviewing skills"
|
64
|
+
And I choose "Yes"
|
65
|
+
And I press "Click here to finish"
|
66
|
+
Then there should be 1 response set with 1 responses with:
|
67
|
+
| answer |
|
68
|
+
| Yes |
|
69
|
+
When I go to the last response set show page
|
70
|
+
Then I should see "Identify communication and interviewing skills"
|
71
|
+
Then the "Yes" radiobutton should be checked
|
@@ -0,0 +1,145 @@
|
|
1
|
+
Given /^I parse$/ do |string|
|
2
|
+
Surveyor::Parser.parse(string)
|
3
|
+
end
|
4
|
+
|
5
|
+
Given /^the survey$/ do |string|
|
6
|
+
@survey_string = string
|
7
|
+
end
|
8
|
+
|
9
|
+
Then /^the parser should fail with "(.*)"$/ do |error_message|
|
10
|
+
lambda { Surveyor::Parser.parse(@survey_string) }.should raise_error(Surveyor::ParserError, /#{error_message}/)
|
11
|
+
end
|
12
|
+
|
13
|
+
Given /^the questions?$/ do |q_string|
|
14
|
+
Surveyor::Parser.parse(<<-SURVEY)
|
15
|
+
survey "Some questions for you" do
|
16
|
+
section "All the questions" do
|
17
|
+
#{q_string}
|
18
|
+
end
|
19
|
+
end
|
20
|
+
SURVEY
|
21
|
+
end
|
22
|
+
|
23
|
+
Given /^I parse redcap file "(.*)"$/ do |name|
|
24
|
+
Surveyor::RedcapParser.parse File.read(File.join(Rails.root, '..', 'features', 'support', name)), name
|
25
|
+
end
|
26
|
+
|
27
|
+
Then /^there should be (\d+) survey(?:s?) with:$/ do |x, table|
|
28
|
+
Survey.count.should == x.to_i
|
29
|
+
table.hashes.each do |hash|
|
30
|
+
Survey.find(:first, :conditions => hash).should_not be_nil
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
Then /^there should be (\d+) translations with$/ do |x, table|
|
35
|
+
SurveyTranslation.count.should == x.to_i
|
36
|
+
table.hashes.each do |hash|
|
37
|
+
SurveyTranslation.find(:first, :conditions => hash).should_not be_nil
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
Then /^there should be (\d+) section(?:s?) with:$/ do |x, table|
|
42
|
+
SurveySection.count.should == x.to_i
|
43
|
+
table.hashes.each do |hash|
|
44
|
+
SurveySection.find(:first, :conditions => hash).should_not be_nil
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
Then /^there should be (\d+) question groups with:$/ do |x, table|
|
49
|
+
QuestionGroup.count.should == x.to_i
|
50
|
+
table.hashes.each do |hash|
|
51
|
+
QuestionGroup.find(:first, :conditions => hash).should_not be_nil
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
Then /^there should be (\d+) question(?:s?) with:$/ do |x, table|
|
56
|
+
Question.count.should == x.to_i
|
57
|
+
table.hashes.each do |hash|
|
58
|
+
hash["reference_identifier"] = nil if hash["reference_identifier"] == "nil"
|
59
|
+
hash["custom_class"] = nil if hash["custom_class"] == "nil"
|
60
|
+
if hash.has_key?("is_mandatory")
|
61
|
+
hash["is_mandatory"] = (hash["is_mandatory"] == "true" ? true : (hash["is_mandatory"] == "false" ? false : hash["is_mandatory"]))
|
62
|
+
end
|
63
|
+
result = Question.find(:first, :conditions => hash)
|
64
|
+
puts hash if result.nil?
|
65
|
+
result.should_not be_nil
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
Then /^there should be (\d+) question(?:s?) with a correct answer$/ do |x|
|
70
|
+
Question.count(:conditions => "correct_answer_id NOT NULL").should == x.to_i
|
71
|
+
Question.where("correct_answer_id NOT NULL").compact.map(&:correct_answer).compact.size.should == x.to_i
|
72
|
+
end
|
73
|
+
|
74
|
+
Then /^there should be (\d+) answer(?:s?) with:$/ do |x, table|
|
75
|
+
Answer.count.should == x.to_i
|
76
|
+
table.hashes.each do |hash|
|
77
|
+
hash["reference_identifier"] = nil if hash["reference_identifier"] == "nil"
|
78
|
+
Answer.find(:first, :conditions => hash).should_not be_nil
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
Then /^there should be (\d+) dependenc(?:y|ies) with:$/ do |x, table|
|
83
|
+
Dependency.count.should == x.to_i
|
84
|
+
table.hashes.each do |hash|
|
85
|
+
Dependency.find(:first, :conditions => hash).should_not be_nil
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
Then /^there should be (\d+) resolved dependency_condition(?:s?) with:$/ do |x, table|
|
90
|
+
DependencyCondition.count.should == x.to_i
|
91
|
+
|
92
|
+
table.hashes.each do |hash|
|
93
|
+
if hash.has_key?("question_reference")
|
94
|
+
question = Question.find_by_reference_identifier(hash.delete("question_reference"))
|
95
|
+
question.should_not be_nil
|
96
|
+
|
97
|
+
hash.merge!({ :question_id => question.id })
|
98
|
+
|
99
|
+
if hash.has_key?("answer_reference")
|
100
|
+
answer = Answer.find(:first, :conditions => { :question_id => question.id, :reference_identifier => hash.delete("answer_reference") })
|
101
|
+
answer.should_not be_nil
|
102
|
+
|
103
|
+
hash.merge!({ :answer_id => answer.id })
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
d = DependencyCondition.find(:first, :conditions => hash)
|
108
|
+
d.should_not be_nil
|
109
|
+
d.question.should_not be_nil
|
110
|
+
d.answer.should_not be_nil unless d.operator.match(/^count[<>=!]{1,2}\d+/)
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
114
|
+
|
115
|
+
Then /^there should be (\d+) validation(?:s?) with:$/ do |x, table|
|
116
|
+
Validation.count.should == x.to_i
|
117
|
+
table.hashes.each do |hash|
|
118
|
+
Validation.find(:first, :conditions => hash).should_not be_nil
|
119
|
+
end
|
120
|
+
end
|
121
|
+
|
122
|
+
Then /^there should be (\d+) validation_condition(?:s?) with:$/ do |x, table|
|
123
|
+
ValidationCondition.count.should == x.to_i
|
124
|
+
table.hashes.each do |hash|
|
125
|
+
hash["integer_value"] = nil if hash["integer_value"] == "nil"
|
126
|
+
ValidationCondition.find(:first, :conditions => hash).should_not be_nil
|
127
|
+
end
|
128
|
+
end
|
129
|
+
|
130
|
+
Then /^question "([^"]*)" should have correct answer "([^"]*)"$/ do |qr, ar|
|
131
|
+
(q = Question.find_by_reference_identifier(qr)).should_not be_nil
|
132
|
+
q.correct_answer.should == q.answers.find_by_reference_identifier(ar)
|
133
|
+
end
|
134
|
+
|
135
|
+
Then /^(\d+) dependencies should depend on questions$/ do |x|
|
136
|
+
arr = Dependency.find_all_by_question_group_id(nil)
|
137
|
+
arr.size.should == 2
|
138
|
+
arr.each{|d| d.question.should_not be_nil}
|
139
|
+
end
|
140
|
+
|
141
|
+
Then /^(\d+) dependencies should depend on question groups$/ do |x|
|
142
|
+
arr = Dependency.find_all_by_question_id(nil)
|
143
|
+
arr.size.should == 2
|
144
|
+
arr.each{|d| d.question_group.should_not be_nil}
|
145
|
+
end
|