breakpointer-surveyor 0.2.0
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 +6 -0
- data/MIT-LICENSE +20 -0
- data/README.md +20 -0
- data/Rakefile +57 -0
- data/VERSION +1 -0
- data/app/controllers/answers_controller.rb +87 -0
- data/app/controllers/dependencies_controller.rb +87 -0
- data/app/controllers/dependency_conditions_controller.rb +87 -0
- data/app/controllers/questions_controller.rb +85 -0
- data/app/controllers/sections_controller.rb +87 -0
- data/app/controllers/surveying_controller.rb +139 -0
- data/app/controllers/surveys_controller.rb +87 -0
- data/app/helpers/answers_helper.rb +2 -0
- data/app/helpers/application_helper.rb +3 -0
- data/app/helpers/questions_helper.rb +2 -0
- data/app/helpers/sections_helper.rb +2 -0
- data/app/helpers/survey_form_builder.rb +38 -0
- data/app/helpers/survey_importer_helper.rb +2 -0
- data/app/helpers/surveying_helper.rb +91 -0
- data/app/helpers/surveys_helper.rb +2 -0
- data/app/models/answer.rb +18 -0
- data/app/models/dependency.rb +43 -0
- data/app/models/dependency_condition.rb +76 -0
- data/app/models/question.rb +44 -0
- data/app/models/question_group.rb +5 -0
- data/app/models/response.rb +58 -0
- data/app/models/response_set.rb +174 -0
- data/app/models/survey.rb +54 -0
- data/app/models/survey_section.rb +19 -0
- data/app/models/user.rb +5 -0
- data/app/views/answer_display_types/_any_answer.html.haml +3 -0
- data/app/views/answer_display_types/_any_other_and_string.html.haml +5 -0
- data/app/views/answer_display_types/_any_string.html.haml +4 -0
- data/app/views/answer_display_types/_date.html.haml +3 -0
- data/app/views/answer_display_types/_datetime.html.haml +2 -0
- data/app/views/answer_display_types/_default.html.haml +1 -0
- data/app/views/answer_display_types/_float.html.haml +5 -0
- data/app/views/answer_display_types/_grid_any_answer.html.haml +2 -0
- data/app/views/answer_display_types/_grid_default.html.haml +2 -0
- data/app/views/answer_display_types/_grid_float.html.haml +2 -0
- data/app/views/answer_display_types/_grid_integer.html.haml +2 -0
- data/app/views/answer_display_types/_grid_one_answer.html.haml +2 -0
- data/app/views/answer_display_types/_grid_string.html.haml +2 -0
- data/app/views/answer_display_types/_integer.html.haml +6 -0
- data/app/views/answer_display_types/_one_answer.html.haml +3 -0
- data/app/views/answer_display_types/_one_string.html.haml +6 -0
- data/app/views/answer_display_types/_repeater_integer.html.haml +6 -0
- data/app/views/answer_display_types/_repeater_string.html.haml +7 -0
- data/app/views/answer_display_types/_string.html.haml +7 -0
- data/app/views/answer_display_types/_text.html.haml +6 -0
- data/app/views/answer_display_types/_time.html.haml +2 -0
- data/app/views/layouts/surveys.html.erb +17 -0
- data/app/views/question_display_types/_default.html.haml +12 -0
- data/app/views/question_display_types/_dropdown.html.haml +12 -0
- data/app/views/question_display_types/_grid_default.html.haml +14 -0
- data/app/views/question_display_types/_grid_dropdown.html.haml +15 -0
- data/app/views/question_display_types/_group_default.html.haml +8 -0
- data/app/views/question_display_types/_group_dropdown.html.haml +6 -0
- data/app/views/question_display_types/_image.html.haml +2 -0
- data/app/views/question_display_types/_inline.html.haml +12 -0
- data/app/views/question_display_types/_label.html.haml +4 -0
- data/app/views/question_display_types/_repeater_default.html.haml +10 -0
- data/app/views/question_display_types/_repeater_dropdown.html.haml +8 -0
- data/app/views/question_display_types/_slider.html.haml +17 -0
- data/app/views/question_group_display_types/_default.html.haml +13 -0
- data/app/views/question_group_display_types/_grid.html.haml +24 -0
- data/app/views/question_group_display_types/_repeater.html.haml +20 -0
- data/app/views/surveying/edit.html.haml +38 -0
- data/app/views/surveying/finish.html.haml +1 -0
- data/app/views/surveying/index.html.erb +19 -0
- data/app/views/surveying/new.html.haml +17 -0
- data/app/views/surveying/show.html.haml +8 -0
- data/config/routes.rb +10 -0
- data/generators/surveyor/surveyor_generator.rb +38 -0
- data/generators/surveyor/templates/README +9 -0
- data/generators/surveyor/templates/assets/images/222222_11x11_icon_arrows_leftright.gif +0 -0
- data/generators/surveyor/templates/assets/images/222222_11x11_icon_arrows_updown.gif +0 -0
- data/generators/surveyor/templates/assets/images/222222_11x11_icon_close.gif +0 -0
- data/generators/surveyor/templates/assets/images/222222_11x11_icon_doc.gif +0 -0
- data/generators/surveyor/templates/assets/images/222222_11x11_icon_folder_closed.gif +0 -0
- data/generators/surveyor/templates/assets/images/222222_11x11_icon_folder_open.gif +0 -0
- data/generators/surveyor/templates/assets/images/222222_11x11_icon_minus.gif +0 -0
- data/generators/surveyor/templates/assets/images/222222_11x11_icon_plus.gif +0 -0
- data/generators/surveyor/templates/assets/images/222222_11x11_icon_resize_se.gif +0 -0
- data/generators/surveyor/templates/assets/images/222222_35x9_colorpicker_indicator.gif.gif +0 -0
- data/generators/surveyor/templates/assets/images/222222_7x7_arrow_down.gif +0 -0
- data/generators/surveyor/templates/assets/images/222222_7x7_arrow_left.gif +0 -0
- data/generators/surveyor/templates/assets/images/222222_7x7_arrow_right.gif +0 -0
- data/generators/surveyor/templates/assets/images/222222_7x7_arrow_up.gif +0 -0
- data/generators/surveyor/templates/assets/images/454545_11x11_icon_arrows_leftright.gif +0 -0
- data/generators/surveyor/templates/assets/images/454545_11x11_icon_arrows_updown.gif +0 -0
- data/generators/surveyor/templates/assets/images/454545_11x11_icon_close.gif +0 -0
- data/generators/surveyor/templates/assets/images/454545_11x11_icon_doc.gif +0 -0
- data/generators/surveyor/templates/assets/images/454545_11x11_icon_folder_closed.gif +0 -0
- data/generators/surveyor/templates/assets/images/454545_11x11_icon_folder_open.gif +0 -0
- data/generators/surveyor/templates/assets/images/454545_11x11_icon_minus.gif +0 -0
- data/generators/surveyor/templates/assets/images/454545_11x11_icon_plus.gif +0 -0
- data/generators/surveyor/templates/assets/images/454545_7x7_arrow_down.gif +0 -0
- data/generators/surveyor/templates/assets/images/454545_7x7_arrow_left.gif +0 -0
- data/generators/surveyor/templates/assets/images/454545_7x7_arrow_right.gif +0 -0
- data/generators/surveyor/templates/assets/images/454545_7x7_arrow_up.gif +0 -0
- data/generators/surveyor/templates/assets/images/888888_11x11_icon_arrows_leftright.gif +0 -0
- data/generators/surveyor/templates/assets/images/888888_11x11_icon_arrows_updown.gif +0 -0
- data/generators/surveyor/templates/assets/images/888888_11x11_icon_close.gif +0 -0
- data/generators/surveyor/templates/assets/images/888888_11x11_icon_doc.gif +0 -0
- data/generators/surveyor/templates/assets/images/888888_11x11_icon_folder_closed.gif +0 -0
- data/generators/surveyor/templates/assets/images/888888_11x11_icon_folder_open.gif +0 -0
- data/generators/surveyor/templates/assets/images/888888_11x11_icon_minus.gif +0 -0
- data/generators/surveyor/templates/assets/images/888888_11x11_icon_plus.gif +0 -0
- data/generators/surveyor/templates/assets/images/888888_7x7_arrow_down.gif +0 -0
- data/generators/surveyor/templates/assets/images/888888_7x7_arrow_left.gif +0 -0
- data/generators/surveyor/templates/assets/images/888888_7x7_arrow_right.gif +0 -0
- data/generators/surveyor/templates/assets/images/888888_7x7_arrow_up.gif +0 -0
- data/generators/surveyor/templates/assets/images/dadada_40x100_textures_02_glass_75.png +0 -0
- data/generators/surveyor/templates/assets/images/e6e6e6_40x100_textures_02_glass_75.png +0 -0
- data/generators/surveyor/templates/assets/images/ffffff_40x100_textures_01_flat_0.png +0 -0
- data/generators/surveyor/templates/assets/images/ffffff_40x100_textures_02_glass_65.png +0 -0
- data/generators/surveyor/templates/assets/javascripts/accessibleUISlider.jQuery.js +201 -0
- data/generators/surveyor/templates/assets/javascripts/jquery-1.2.6.js +3549 -0
- data/generators/surveyor/templates/assets/javascripts/jquery-ui-personalized-1.5.3.js +7616 -0
- data/generators/surveyor/templates/assets/javascripts/jquery.form.js +637 -0
- data/generators/surveyor/templates/assets/javascripts/surveyor.js +35 -0
- data/generators/surveyor/templates/assets/stylesheets/jquery-ui-slider-additions.css +71 -0
- data/generators/surveyor/templates/assets/stylesheets/reset.css +46 -0
- data/generators/surveyor/templates/assets/stylesheets/sass/surveyor.sass +321 -0
- data/generators/surveyor/templates/assets/stylesheets/surveyor.css +245 -0
- data/generators/surveyor/templates/assets/stylesheets/ui.theme.css +851 -0
- data/generators/surveyor/templates/migrate/create_answers.rb +46 -0
- data/generators/surveyor/templates/migrate/create_dependencies.rb +21 -0
- data/generators/surveyor/templates/migrate/create_dependency_conditions.rb +29 -0
- data/generators/surveyor/templates/migrate/create_question_groups.rb +18 -0
- data/generators/surveyor/templates/migrate/create_questions.rb +33 -0
- data/generators/surveyor/templates/migrate/create_response_sets.rb +22 -0
- data/generators/surveyor/templates/migrate/create_responses.rb +33 -0
- data/generators/surveyor/templates/migrate/create_survey_sections.rb +25 -0
- data/generators/surveyor/templates/migrate/create_surveys.rb +25 -0
- data/generators/surveyor/templates/surveys/kitchen_sink_survey.rb +201 -0
- data/init.rb +1 -0
- data/install.rb +1 -0
- data/lib/tasks/surveyor_tasks.rake +29 -0
- data/lib/tiny_code.rb +58 -0
- data/lib/user_manager.rb +9 -0
- data/lib/xml_formatter.rb +12 -0
- data/script/surveyor/answer.rb +84 -0
- data/script/surveyor/columnizer.rb +36 -0
- data/script/surveyor/dependency.rb +43 -0
- data/script/surveyor/dependency_condition.rb +74 -0
- data/script/surveyor/dslparse.rb +66 -0
- data/script/surveyor/question.rb +76 -0
- data/script/surveyor/question_group.rb +33 -0
- data/script/surveyor/specs/answer_spec.rb +66 -0
- data/script/surveyor/specs/question_dependency_spec.rb +46 -0
- data/script/surveyor/specs/question_group_spec.rb +9 -0
- data/script/surveyor/specs/question_spec.rb +111 -0
- data/script/surveyor/specs/section_spec.rb +58 -0
- data/script/surveyor/survey.rb +108 -0
- data/script/surveyor/survey_section.rb +153 -0
- data/script/surveyor/whr_dsl.tmproj +244 -0
- data/spec/controllers/answers_controller_spec.rb +64 -0
- data/spec/controllers/dependencies_controller_spec.rb +63 -0
- data/spec/controllers/dependency_conditions_controller_spec.rb +64 -0
- data/spec/controllers/questions_controller_spec.rb +64 -0
- data/spec/controllers/sections_controller_spec.rb +64 -0
- data/spec/controllers/surveying_controller_spec.rb +328 -0
- data/spec/controllers/surveying_routing_spec.rb +45 -0
- data/spec/controllers/surveys_controller_spec.rb +64 -0
- data/spec/fixtures/answers.yml +9 -0
- data/spec/fixtures/dependencies.yml +7 -0
- data/spec/fixtures/dependency_conditions.yml +27 -0
- data/spec/fixtures/question_groups.yml +7 -0
- data/spec/fixtures/questions.yml +15 -0
- data/spec/fixtures/response_sets.yml +13 -0
- data/spec/fixtures/responses.yml +9 -0
- data/spec/fixtures/survey_sections.yml +11 -0
- data/spec/fixtures/surveys.yml +9 -0
- data/spec/fixtures/users.yml +7 -0
- data/spec/helpers/survey_importer_helper_spec.rb +11 -0
- data/spec/helpers/surveying_helper_spec.rb +11 -0
- data/spec/models/answer_spec.rb +62 -0
- data/spec/models/dependency_condition_spec.rb +347 -0
- data/spec/models/dependency_spec.rb +82 -0
- data/spec/models/question_group_spec.rb +11 -0
- data/spec/models/question_spec.rb +70 -0
- data/spec/models/response_set_spec.rb +172 -0
- data/spec/models/response_spec.rb +94 -0
- data/spec/models/survey_section_spec.rb +34 -0
- data/spec/models/survey_spec.rb +72 -0
- data/spec/models/user_spec.rb +11 -0
- data/spec/rcov.opts +2 -0
- data/spec/spec.opts +4 -0
- data/spec/spec_helper.rb +72 -0
- data/spec/views/app/edit.html.erb_spec.rb +20 -0
- data/spec/views/app/index.html.erb_spec.rb +19 -0
- data/spec/views/app/new.html.erb_spec.rb +21 -0
- data/spec/views/app/show.html.erb_spec.rb +17 -0
- data/surveyor.gemspec +258 -0
- data/uninstall.rb +1 -0
- metadata +286 -0
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
class CreateAnswers < ActiveRecord::Migration
|
|
2
|
+
def self.up
|
|
3
|
+
create_table :answers do |t|
|
|
4
|
+
# Context
|
|
5
|
+
t.integer :question_id
|
|
6
|
+
|
|
7
|
+
# Content
|
|
8
|
+
t.text :text
|
|
9
|
+
t.text :short_text #Used for presenting responses to experts (ie non-survey takers). Just a shorted version of the string
|
|
10
|
+
t.text :help_text
|
|
11
|
+
t.integer :weight # Used to assign a weight to an answer object (used for computing surveys that have numerical results) (I added this to support the Urology questionnaire -BLC)
|
|
12
|
+
|
|
13
|
+
# Display
|
|
14
|
+
t.string :response_class # What kind of additional data does this answer accept?
|
|
15
|
+
t.integer :display_order
|
|
16
|
+
t.boolean :is_exclusive # If set it causes some UI trigger to remove (and disable) all the other answer choices selected for a question (needed for the WHR)
|
|
17
|
+
t.boolean :hide_label
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
# Reference
|
|
21
|
+
t.string :reference_identifier # Used to relate this question object to questions imported from a paper questionnaire
|
|
22
|
+
t.string :data_export_identifier # Used when referencing this quesiton in data export. Usually a shortend/cryptic version of the question text
|
|
23
|
+
t.string :common_data_identitier # Used to share data across surveys (or perhaps map to a common vocab.)
|
|
24
|
+
|
|
25
|
+
# Validations
|
|
26
|
+
# the response_class attr also has validation implications (int, string, float,etc..) but these attrs below give fine grain control over responses
|
|
27
|
+
t.integer :max_value
|
|
28
|
+
t.integer :min_value
|
|
29
|
+
t.integer :length # number of chars/ints accepted
|
|
30
|
+
t.integer :decimal_precision #only for floats
|
|
31
|
+
t.boolean :allow_negative # only for numeric values
|
|
32
|
+
t.boolean :allow_blank
|
|
33
|
+
t.string :unit #a string representation of the unit (lbs. USD, oz.) - Context is from the survey domain and question
|
|
34
|
+
|
|
35
|
+
# Display property
|
|
36
|
+
t.integer :display_length #if smaller than answer.length the html input length will be this value
|
|
37
|
+
|
|
38
|
+
t.timestamps
|
|
39
|
+
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
def self.down
|
|
44
|
+
drop_table :answers
|
|
45
|
+
end
|
|
46
|
+
end
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
class CreateDependencies < ActiveRecord::Migration
|
|
2
|
+
def self.up
|
|
3
|
+
create_table :dependencies do |t|
|
|
4
|
+
# Context
|
|
5
|
+
t.integer :question_id # the dependent question
|
|
6
|
+
|
|
7
|
+
# Conditional
|
|
8
|
+
t.string :rule
|
|
9
|
+
|
|
10
|
+
# Result - TODO: figure out the dependency hook presentation options
|
|
11
|
+
# t.string :property_to_toggle # visibility, class_name,
|
|
12
|
+
# t.string :effect #blind, opacity
|
|
13
|
+
|
|
14
|
+
t.timestamps
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def self.down
|
|
19
|
+
drop_table :dependencies
|
|
20
|
+
end
|
|
21
|
+
end
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
class CreateDependencyConditions < ActiveRecord::Migration
|
|
2
|
+
def self.up
|
|
3
|
+
create_table :dependency_conditions do |t|
|
|
4
|
+
# Context
|
|
5
|
+
t.integer :dependency_id
|
|
6
|
+
t.string :rule_key
|
|
7
|
+
|
|
8
|
+
# Conditional
|
|
9
|
+
t.integer :question_id # the conditional question
|
|
10
|
+
t.string :operator
|
|
11
|
+
|
|
12
|
+
# Value
|
|
13
|
+
t.integer :answer_id
|
|
14
|
+
t.datetime :datetime_value
|
|
15
|
+
t.integer :integer_value
|
|
16
|
+
t.float :float_value
|
|
17
|
+
t.string :unit
|
|
18
|
+
t.text :text_value
|
|
19
|
+
t.string :string_value
|
|
20
|
+
t.string :response_other
|
|
21
|
+
|
|
22
|
+
t.timestamps
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def self.down
|
|
27
|
+
drop_table :dependency_conditions
|
|
28
|
+
end
|
|
29
|
+
end
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
class CreateQuestionGroups < ActiveRecord::Migration
|
|
2
|
+
def self.up
|
|
3
|
+
create_table :question_groups do |t|
|
|
4
|
+
# Content
|
|
5
|
+
t.string :text
|
|
6
|
+
t.string :help_text
|
|
7
|
+
|
|
8
|
+
# Display
|
|
9
|
+
t.string :display_type
|
|
10
|
+
|
|
11
|
+
t.timestamps
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def self.down
|
|
16
|
+
drop_table :question_groups
|
|
17
|
+
end
|
|
18
|
+
end
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
class CreateQuestions < ActiveRecord::Migration
|
|
2
|
+
def self.up
|
|
3
|
+
create_table :questions do |t|
|
|
4
|
+
# Context
|
|
5
|
+
t.integer :survey_section_id
|
|
6
|
+
|
|
7
|
+
# Content
|
|
8
|
+
t.text :text
|
|
9
|
+
t.text :short_text # For experts (ie non-survey takers). Short version of text
|
|
10
|
+
t.text :help_text
|
|
11
|
+
|
|
12
|
+
# Display
|
|
13
|
+
t.string :pick
|
|
14
|
+
t.string :display_type
|
|
15
|
+
t.integer :display_order
|
|
16
|
+
t.integer :question_group_id
|
|
17
|
+
t.boolean :is_mandatory
|
|
18
|
+
|
|
19
|
+
# Reference
|
|
20
|
+
t.string :reference_identifier # For questions imported from a paper questionnaire
|
|
21
|
+
t.string :data_export_identifier # For data export. Usually a short/cryptic version of text
|
|
22
|
+
|
|
23
|
+
# styling
|
|
24
|
+
t.integer :display_width # used only for slider component (if needed)
|
|
25
|
+
|
|
26
|
+
t.timestamps
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def self.down
|
|
31
|
+
drop_table :questions
|
|
32
|
+
end
|
|
33
|
+
end
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
class CreateResponseSets < ActiveRecord::Migration
|
|
2
|
+
def self.up
|
|
3
|
+
create_table :response_sets do |t|
|
|
4
|
+
# Context
|
|
5
|
+
t.integer :user_id
|
|
6
|
+
t.integer :survey_id
|
|
7
|
+
|
|
8
|
+
# Content
|
|
9
|
+
t.string :access_code #unique id for the object used in urls
|
|
10
|
+
|
|
11
|
+
# Expiry
|
|
12
|
+
t.datetime :started_at
|
|
13
|
+
t.datetime :completed_at
|
|
14
|
+
|
|
15
|
+
t.timestamps
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def self.down
|
|
20
|
+
drop_table :response_sets
|
|
21
|
+
end
|
|
22
|
+
end
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
class CreateResponses < ActiveRecord::Migration
|
|
2
|
+
def self.up
|
|
3
|
+
create_table :responses do |t|
|
|
4
|
+
# Context
|
|
5
|
+
t.integer :response_set_id
|
|
6
|
+
t.integer :question_id
|
|
7
|
+
|
|
8
|
+
# Content
|
|
9
|
+
t.integer :answer_id
|
|
10
|
+
t.datetime :datetime_value # handles date, time, and datetime (segregate by answer.response_class)
|
|
11
|
+
|
|
12
|
+
#t.datetime :time_value
|
|
13
|
+
t.integer :integer_value
|
|
14
|
+
t.float :float_value
|
|
15
|
+
t.string :unit
|
|
16
|
+
t.text :text_value
|
|
17
|
+
t.string :string_value
|
|
18
|
+
t.string :response_other #used to hold the string entered with "Other" type answers in multiple choice questions
|
|
19
|
+
|
|
20
|
+
# arbitrary identifier used to group responses
|
|
21
|
+
# the pertinent example here is Q: What's your car's make/model/year
|
|
22
|
+
# group 1: Ford/Focus/2007
|
|
23
|
+
# group 2: Toyota/Prius/2006
|
|
24
|
+
t.string :response_group
|
|
25
|
+
|
|
26
|
+
t.timestamps
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def self.down
|
|
31
|
+
drop_table :responses
|
|
32
|
+
end
|
|
33
|
+
end
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
class CreateSurveySections < ActiveRecord::Migration
|
|
2
|
+
def self.up
|
|
3
|
+
create_table :survey_sections do |t|
|
|
4
|
+
# Context
|
|
5
|
+
t.integer :survey_id
|
|
6
|
+
|
|
7
|
+
# Content
|
|
8
|
+
t.string :title
|
|
9
|
+
t.text :description
|
|
10
|
+
|
|
11
|
+
# Display
|
|
12
|
+
t.integer :display_order
|
|
13
|
+
|
|
14
|
+
# Reference
|
|
15
|
+
t.string :reference_identifier # Used to relate this question object to questions imported from a paper questionnaire
|
|
16
|
+
t.string :data_export_identifier # Used when referencing this quesiton in data export. Usually a shortend/cryptic version of the question text
|
|
17
|
+
|
|
18
|
+
t.timestamps
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def self.down
|
|
23
|
+
drop_table :survey_sections
|
|
24
|
+
end
|
|
25
|
+
end
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
class CreateSurveys < ActiveRecord::Migration
|
|
2
|
+
def self.up
|
|
3
|
+
create_table :surveys do |t|
|
|
4
|
+
# Content
|
|
5
|
+
t.string :title
|
|
6
|
+
t.text :description
|
|
7
|
+
|
|
8
|
+
# Reference
|
|
9
|
+
t.string :access_code
|
|
10
|
+
|
|
11
|
+
# Expiry
|
|
12
|
+
t.datetime :active_at
|
|
13
|
+
t.datetime :inactive_at
|
|
14
|
+
|
|
15
|
+
# Styling
|
|
16
|
+
t.string :css_url
|
|
17
|
+
|
|
18
|
+
t.timestamps
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def self.down
|
|
23
|
+
drop_table :surveys
|
|
24
|
+
end
|
|
25
|
+
end
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
survey "“Kitchen Sink” survey" do
|
|
2
|
+
|
|
3
|
+
section "Basic questions" do
|
|
4
|
+
|
|
5
|
+
# exclusive
|
|
6
|
+
# name people you live with (choose all that apply)
|
|
7
|
+
# husband, friend, partner, siblings, other, alone, choose not to answer
|
|
8
|
+
# alone unchecks/erases, and disables all the others
|
|
9
|
+
# omit (choose not to answer) is exclusive as well
|
|
10
|
+
|
|
11
|
+
# a label is a question that accepts no answers
|
|
12
|
+
# reference_identifier => label
|
|
13
|
+
label "These questions are examples of the basic supported input types"
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
# a basic question,
|
|
17
|
+
# reference_identifier => 1
|
|
18
|
+
question_1 "What is your favorite color?", :pick => :one
|
|
19
|
+
answer "red"
|
|
20
|
+
answer "blue"
|
|
21
|
+
answer "green"
|
|
22
|
+
answer "yellow"
|
|
23
|
+
answer :other # :other is a custom answer symbol type, it has associated pre-sets with it
|
|
24
|
+
|
|
25
|
+
question_2 "Choose the colors you don't like", :pick => :any
|
|
26
|
+
answer_1 "red"
|
|
27
|
+
answer_2 "blue"
|
|
28
|
+
answer_3 "green"
|
|
29
|
+
answer_4 "yellow"
|
|
30
|
+
answer :omit
|
|
31
|
+
|
|
32
|
+
q_2a "Please explain why you don't like this color?"
|
|
33
|
+
a_1 "explanation", :text
|
|
34
|
+
dependency :rule => "A or B or C or D"
|
|
35
|
+
condition_A :q_2, "==", :a_1
|
|
36
|
+
condition_B :q_2, "==", :a_2
|
|
37
|
+
condition_C :q_2, "==", :a_3
|
|
38
|
+
condition_D :q_2, "==", :a_4
|
|
39
|
+
|
|
40
|
+
# question definitions can be abreviated as shown below
|
|
41
|
+
# questions and answers don't need to have numbers. Only if they are referenced in a dependency condition
|
|
42
|
+
q "What is your name?"
|
|
43
|
+
a :string
|
|
44
|
+
|
|
45
|
+
q "Give your response"
|
|
46
|
+
a "who", :string
|
|
47
|
+
a "what", :string
|
|
48
|
+
a "where", :string
|
|
49
|
+
|
|
50
|
+
q "How many pets do you own?"
|
|
51
|
+
a :integer
|
|
52
|
+
|
|
53
|
+
q "What is your address?"
|
|
54
|
+
a :text
|
|
55
|
+
#
|
|
56
|
+
# q "Pick your favorite date"
|
|
57
|
+
# a :date
|
|
58
|
+
#
|
|
59
|
+
# q "Pick your favorite time"
|
|
60
|
+
# a :time
|
|
61
|
+
|
|
62
|
+
q "Pick your favorite date AND time"
|
|
63
|
+
a :datetime
|
|
64
|
+
|
|
65
|
+
q "What time would you like to meet?"
|
|
66
|
+
a :time
|
|
67
|
+
|
|
68
|
+
q "What date would you like to meet?"
|
|
69
|
+
a :date
|
|
70
|
+
|
|
71
|
+
q "Adjust the slider to reflect your level of awesomeness", :pick => :one, :display_type => :slider
|
|
72
|
+
(1..10).to_a.each{ |num| a num.to_s}
|
|
73
|
+
|
|
74
|
+
q "How much do you like Ruby?", :pick => :one, :display_type => :slider
|
|
75
|
+
["not at all", "a little", "some", "a lot", "a ton"].each{|level| a level}
|
|
76
|
+
|
|
77
|
+
# range "When did you start working at NUBIC?", :range_type => :date do
|
|
78
|
+
# q "From"
|
|
79
|
+
# a :date
|
|
80
|
+
#
|
|
81
|
+
# q "To"
|
|
82
|
+
# a :date
|
|
83
|
+
# end
|
|
84
|
+
#
|
|
85
|
+
# range "What times are you awake?", :range_type => :integer do
|
|
86
|
+
# q "From"
|
|
87
|
+
# a :integer
|
|
88
|
+
#
|
|
89
|
+
# q "To"
|
|
90
|
+
# a :integer
|
|
91
|
+
# end
|
|
92
|
+
|
|
93
|
+
q "How much money do you want?"
|
|
94
|
+
a "$|USD", :float, :unit => "F"
|
|
95
|
+
|
|
96
|
+
group "How much oil do yo use per day?" do
|
|
97
|
+
q "Quantity"
|
|
98
|
+
a "Quantity", :float
|
|
99
|
+
|
|
100
|
+
q "Unit", :pick => :one, :display_type => :dropdown
|
|
101
|
+
a "Barrels"
|
|
102
|
+
a "Gallons"
|
|
103
|
+
a "Quarts"
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
q "Choose your Illinois county", :pick => :one, :display_type => :dropdown
|
|
107
|
+
["Adams","Alexander","Bond", "Boone",
|
|
108
|
+
"Brown","Bureau","Calhoun","Carroll","Cass",
|
|
109
|
+
"Champaign", "Christian", "Clark","Clay",
|
|
110
|
+
"Clinton", "Coles", "Cook", "Crawford","Cumberland","DeKalb",
|
|
111
|
+
"De Witt","Douglas","DuPage","Edgar", "Edwards",
|
|
112
|
+
"Effingham","Fayette", "Ford","Franklin","Fulton",
|
|
113
|
+
"Gallatin","Greene", "Grundy", "Hamilton","Hancock",
|
|
114
|
+
"Hardin","Henderson","Henry","Iroquois","Jackson",
|
|
115
|
+
"Jasper", "Jefferson","Jersey","Jo Daviess","Johnson",
|
|
116
|
+
"Kane","Kankakee","Kendall","Knox", "La Salle",
|
|
117
|
+
"Lake", "Lawrence", "Lee","Livingston","Logan",
|
|
118
|
+
"Macon","Macoupin","Madison","Marion","Marshall", "Mason",
|
|
119
|
+
"Massac","McDonough","McHenry","McLean","Menard",
|
|
120
|
+
"Mercer","Monroe", "Montgomery","Morgan","Moultrie",
|
|
121
|
+
"Ogle","Peoria","Perry","Piatt","Pike","Pope",
|
|
122
|
+
"Pulaski","Putnam","Randolph","Richland","Rock Island",
|
|
123
|
+
"Saline","Sangamon","Schuyler","Scott","Shelby",
|
|
124
|
+
"St. Clair","Stark", "Stephenson","Tazewell","Union",
|
|
125
|
+
"Vermilion","Wabash","Warren","Washington","Wayne",
|
|
126
|
+
"White","Whiteside","Will","Williamson","Winnebago","Woodford"].each{ |county| a county}
|
|
127
|
+
|
|
128
|
+
q "Choose your favorite meats", :display_type => :inline, :pick => :any
|
|
129
|
+
a "Chicken"
|
|
130
|
+
a "Pork"
|
|
131
|
+
a "Beef"
|
|
132
|
+
a "Shellfish"
|
|
133
|
+
a "Fish"
|
|
134
|
+
a "I don't eat meats!!!", :is_exclusive => true
|
|
135
|
+
|
|
136
|
+
q "All out of ideas for questions?", :pick => :one, :display_type => :inline
|
|
137
|
+
a "yes"
|
|
138
|
+
a "maybe"
|
|
139
|
+
a "no"
|
|
140
|
+
a "I don't know"
|
|
141
|
+
end
|
|
142
|
+
|
|
143
|
+
section "Complicated questions" do
|
|
144
|
+
|
|
145
|
+
grid "Tell us how often do you cover these each day" do
|
|
146
|
+
a "1"
|
|
147
|
+
a "2"
|
|
148
|
+
a "3"
|
|
149
|
+
q "Head", :pick => :one
|
|
150
|
+
q "Knees", :pick => :one
|
|
151
|
+
q "Toes", :pick => :one
|
|
152
|
+
end
|
|
153
|
+
|
|
154
|
+
grid "Tell us how you feel today day" do
|
|
155
|
+
a "-2"
|
|
156
|
+
a "-1"
|
|
157
|
+
a "0"
|
|
158
|
+
a "1"
|
|
159
|
+
a "2"
|
|
160
|
+
a :omit
|
|
161
|
+
q "down|up" , :pick => :one
|
|
162
|
+
q "sad|happy", :pick => :one
|
|
163
|
+
q "limp|perky", :pick => :one
|
|
164
|
+
end
|
|
165
|
+
|
|
166
|
+
q "Please rank the following foods based on how much you like them"
|
|
167
|
+
a "|pizza", :integer
|
|
168
|
+
a "|salad", :integer
|
|
169
|
+
a "|sushi", :integer
|
|
170
|
+
a "|ice cream", :integer
|
|
171
|
+
a "|breakfast ceral", :integer
|
|
172
|
+
|
|
173
|
+
|
|
174
|
+
q "Choose your favorite utensils and enter frequency of use (daily, weekly, monthly, etc...)", :pick => :any
|
|
175
|
+
a "spoon", :string
|
|
176
|
+
a "fork", :string
|
|
177
|
+
a "knife", :string
|
|
178
|
+
a :other, :string
|
|
179
|
+
|
|
180
|
+
repeater "Tell us about the cars you own" do
|
|
181
|
+
q "Make", :pick => :one, :display_type => :dropdown
|
|
182
|
+
a "Toyota"
|
|
183
|
+
a "Ford"
|
|
184
|
+
a "GMChevy"
|
|
185
|
+
a "Ferrari"
|
|
186
|
+
a "Tesla"
|
|
187
|
+
a "Honda"
|
|
188
|
+
a "Other weak brand"
|
|
189
|
+
q "Model"
|
|
190
|
+
a :string
|
|
191
|
+
q "Year"
|
|
192
|
+
a :string
|
|
193
|
+
end
|
|
194
|
+
repeater "Tell us the name and age of your siblings" do
|
|
195
|
+
q "Sibling"
|
|
196
|
+
a "Name", :string
|
|
197
|
+
a "Age", :integer, :unit => "years"
|
|
198
|
+
end
|
|
199
|
+
|
|
200
|
+
end
|
|
201
|
+
end
|