surveyor 0.6.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +6 -0
- data/MIT-LICENSE +20 -0
- data/README.md +104 -0
- data/Rakefile +50 -0
- data/VERSION +1 -0
- data/app/controllers/surveyor_controller.rb +117 -0
- data/app/helpers/survey_form_builder.rb +37 -0
- data/app/helpers/surveyor_helper.rb +66 -0
- data/app/models/answer.rb +21 -0
- data/app/models/dependency.rb +46 -0
- data/app/models/dependency_condition.rb +79 -0
- data/app/models/question.rb +54 -0
- data/app/models/question_group.rb +18 -0
- data/app/models/response.rb +47 -0
- data/app/models/response_set.rb +185 -0
- data/app/models/survey.rb +57 -0
- data/app/models/survey_section.rb +15 -0
- data/app/views/layouts/surveyor_default.html.erb +13 -0
- data/app/views/partials/_answer.html.haml +49 -0
- data/app/views/partials/_question.html.haml +73 -0
- data/app/views/partials/_question_group.html.haml +41 -0
- data/app/views/surveyor/edit.html.haml +32 -0
- data/app/views/surveyor/new.html.haml +17 -0
- data/app/views/surveyor/show.html.haml +12 -0
- data/config/routes.rb +10 -0
- data/generators/surveyor/EXTENDING_SURVEYOR +12 -0
- data/generators/surveyor/extend_surveyor_generator.rb +22 -0
- data/generators/surveyor/surveyor_generator.rb +60 -0
- data/generators/surveyor/templates/README +10 -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 +28 -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 +245 -0
- data/generators/surveyor/templates/assets/stylesheets/surveyor.css +231 -0
- data/generators/surveyor/templates/assets/stylesheets/ui.theme.css +851 -0
- data/generators/surveyor/templates/extensions/survey_extensions.rb +18 -0
- data/generators/surveyor/templates/extensions/surveyor_controller_extensions.rb +28 -0
- data/generators/surveyor/templates/extensions/surveyor_custom.html.erb +13 -0
- data/generators/surveyor/templates/extensions/surveyor_helper_extensions.rb +18 -0
- data/generators/surveyor/templates/initializers/haml.rb +8 -0
- data/generators/surveyor/templates/initializers/surveyor.rb +11 -0
- data/generators/surveyor/templates/migrate/create_answers.rb +45 -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/generators/surveyor/templates/tasks/surveyor.rb +4 -0
- data/init.rb +1 -0
- data/install.rb +1 -0
- data/lib/surveyor.rb +7 -0
- data/lib/surveyor/config.rb +45 -0
- data/lib/tasks/surveyor_tasks.rake +33 -0
- data/lib/tiny_code.rb +58 -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/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_parser.rb +64 -0
- data/script/surveyor/survey_section.rb +153 -0
- data/script/surveyor/whr_dsl.tmproj +244 -0
- data/spec/controllers/surveyor_controller_spec.rb +328 -0
- data/spec/factories.rb +107 -0
- data/spec/models/answer_spec.rb +29 -0
- data/spec/models/dependency_condition_spec.rb +338 -0
- data/spec/models/dependency_spec.rb +82 -0
- data/spec/models/question_group_spec.rb +11 -0
- data/spec/models/question_spec.rb +75 -0
- data/spec/models/response_set_spec.rb +153 -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/rcov.opts +2 -0
- data/spec/spec.opts +4 -0
- data/spec/spec_helper.rb +14 -0
- data/surveyor.gemspec +187 -0
- data/uninstall.rb +1 -0
- metadata +211 -0
@@ -0,0 +1,18 @@
|
|
1
|
+
module SurveyExtensions
|
2
|
+
def self.included(base)
|
3
|
+
base.extend(ClassMethods)
|
4
|
+
base.send(:include, InstanceMethods)
|
5
|
+
base.class_eval do
|
6
|
+
# Same as typing in the class
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
module ClassMethods
|
11
|
+
end
|
12
|
+
|
13
|
+
module InstanceMethods
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
# Add module to Survey
|
18
|
+
Survey.send(:include, SurveyExtensions)
|
@@ -0,0 +1,28 @@
|
|
1
|
+
module SurveyorControllerExtensions
|
2
|
+
def self.included(base)
|
3
|
+
base.extend(ClassMethods)
|
4
|
+
base.send(:include, InstanceMethods)
|
5
|
+
base.class_eval do
|
6
|
+
# Same as typing in the class
|
7
|
+
# before_filter :pimp_my_ride
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
module ClassMethods
|
12
|
+
end
|
13
|
+
|
14
|
+
module InstanceMethods
|
15
|
+
# def pimp_my_ride
|
16
|
+
# flash[:notice] = "pimped!"
|
17
|
+
# end
|
18
|
+
end
|
19
|
+
|
20
|
+
module Actions
|
21
|
+
# Redefine the controller actions [index, new, create, show, update] here
|
22
|
+
# def new
|
23
|
+
# render :text =>"surveys are down"
|
24
|
+
# end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
# Set config['extend_controller'] = true in config/initializers/surveyor.rb to activate these extensions
|
@@ -0,0 +1,13 @@
|
|
1
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
2
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
3
|
+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
4
|
+
<head>
|
5
|
+
<meta http-equiv="content-type" content="text/html;charset=UTF-8" />
|
6
|
+
<title>Survey: <%= controller.action_name %></title>
|
7
|
+
<%= surveyor_includes # calls surveyor_javascripts + surveyor_stylesheets %>
|
8
|
+
</head>
|
9
|
+
<body>
|
10
|
+
<div id="flash"><%= flash[:notice] %></div>
|
11
|
+
<%= yield %>
|
12
|
+
</body>
|
13
|
+
</html>
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module SurveyorHelperExtensions
|
2
|
+
def self.included(base) # :nodoc:
|
3
|
+
base.send(:include, InstanceMethods)
|
4
|
+
base.class_eval do
|
5
|
+
# Same as typing in the module
|
6
|
+
# alias_method_chain :question_number_helper, :sauce
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
module InstanceMethods
|
11
|
+
# def question_number_helper_with_sauce(number)
|
12
|
+
# question_number_helper_without_sauce(number) + "Extra sauce"
|
13
|
+
# end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
# Add module to SurveyorHelper
|
18
|
+
SurveyorHelper.send(:include, SurveyorHelperExtensions)
|
@@ -0,0 +1,11 @@
|
|
1
|
+
Surveyor::Config.run do |config|
|
2
|
+
config['default.relative_url_root'] = nil # "surveys/" # should end with '/'
|
3
|
+
config['default.title'] = nil # "You can take these surveys:"
|
4
|
+
config['default.layout'] = nil # "surveyor_default"
|
5
|
+
config['default.finish'] = nil # "/surveys" # or :finish_path_method
|
6
|
+
config['use_restful_authentication'] = false # set to true to use restful authentication
|
7
|
+
config['extend_controller'] = false # set to true to extend SurveyorController
|
8
|
+
end
|
9
|
+
|
10
|
+
# require 'models/survey_extensions' # Extended the survey model
|
11
|
+
# require 'helpers/surveyor_helper_extensions' # Extend the surveyor helper
|
@@ -0,0 +1,45 @@
|
|
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
|
+
# Reference
|
20
|
+
t.string :reference_identifier # Used to relate this question object to questions imported from a paper questionnaire
|
21
|
+
t.string :data_export_identifier # Used when referencing this quesiton in data export. Usually a shortend/cryptic version of the question text
|
22
|
+
t.string :common_data_identitier # Used to share data across surveys (or perhaps map to a common vocab.)
|
23
|
+
|
24
|
+
# Validations
|
25
|
+
# the response_class attr also has validation implications (int, string, float,etc..) but these attrs below give fine grain control over responses
|
26
|
+
t.integer :max_value
|
27
|
+
t.integer :min_value
|
28
|
+
t.integer :length # number of chars/ints accepted
|
29
|
+
t.integer :decimal_precision # only for floats
|
30
|
+
t.boolean :allow_negative # only for numeric values
|
31
|
+
t.boolean :allow_blank
|
32
|
+
t.string :unit # a string representation of the unit (lbs. USD, oz.) - Context is from the survey domain and question
|
33
|
+
|
34
|
+
# Display property
|
35
|
+
t.integer :display_length # if smaller than answer.length the html input length will be this value
|
36
|
+
|
37
|
+
t.timestamps
|
38
|
+
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
def self.down
|
43
|
+
drop_table :answers
|
44
|
+
end
|
45
|
+
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 you use per day?", :display_type => :inline do
|
97
|
+
q "Quantity"
|
98
|
+
a "Quantity", :float
|
99
|
+
|
100
|
+
q "Unit", :pick => :one, :display_type => :dropdown, :hide_label => true
|
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
|