surveyor 0.22.0 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (144) hide show
  1. data/.gitignore +1 -0
  2. data/.rspec +1 -0
  3. data/CHANGELOG.md +83 -0
  4. data/Gemfile.rails_version +7 -1
  5. data/README.md +114 -16
  6. data/Rakefile +15 -9
  7. data/app/inputs/quiet_input.rb +5 -0
  8. data/app/inputs/surveyor_check_boxes_input.rb +35 -0
  9. data/app/inputs/surveyor_radio_input.rb +18 -0
  10. data/app/views/partials/_answer.html.haml +4 -4
  11. data/app/views/partials/_question.html.haml +7 -7
  12. data/app/views/partials/_question_group.html.haml +9 -8
  13. data/app/views/surveyor/export.json.rabl +28 -25
  14. data/app/views/surveyor/new.html.haml +8 -5
  15. data/app/views/surveyor/show.json.rabl +3 -2
  16. data/ci-exec.sh +13 -7
  17. data/cucumber.yml +3 -3
  18. data/doc/REPRESENTATIONS.md +34 -0
  19. data/doc/api_id_schema.json +7 -0
  20. data/doc/response_set_schema.json +54 -0
  21. data/doc/surveyor question combinations.png +0 -0
  22. data/doc/surveyor_timestamp_schema.json +9 -0
  23. data/features/ajax_submissions.feature +140 -0
  24. data/features/export_to_json.feature +182 -34
  25. data/features/no_duplicates.feature +110 -0
  26. data/features/show_survey.feature +1 -1
  27. data/features/step_definitions/parser_steps.rb +25 -2
  28. data/features/step_definitions/surveyor_steps.rb +145 -20
  29. data/features/step_definitions/ui_steps.rb +3 -0
  30. data/features/support/database_cleaner.rb +16 -0
  31. data/features/support/env.rb +21 -17
  32. data/features/support/simultaneous_ajax.rb +101 -0
  33. data/features/support/single_quit_selenium_driver.rb +23 -0
  34. data/features/support/slow_updates.rb +18 -0
  35. data/features/surveyor.feature +174 -44
  36. data/features/surveyor_dependencies.feature +80 -39
  37. data/features/surveyor_parser.feature +114 -20
  38. data/features/z_redcap_parser.feature +0 -1
  39. data/lib/{generators/surveyor/templates/public → assets}/images/surveyor/next.gif +0 -0
  40. data/lib/{generators/surveyor/templates/public → assets}/images/surveyor/prev.gif +0 -0
  41. data/lib/{generators/surveyor/templates/public/stylesheets/surveyor → assets/images}/ui-bg_glass_100_f6f6f6_1x400.png +0 -0
  42. data/lib/{generators/surveyor/templates/public/stylesheets/surveyor → assets/images}/ui-bg_glass_100_fdf5ce_1x400.png +0 -0
  43. data/lib/{generators/surveyor/templates/public/stylesheets/surveyor → assets/images}/ui-bg_glass_65_ffffff_1x400.png +0 -0
  44. data/lib/{generators/surveyor/templates/public/stylesheets/surveyor → assets/images}/ui-bg_gloss-wave_35_f6a828_500x100.png +0 -0
  45. data/lib/assets/images/ui-bg_highlight-soft_100_eeeeee_1x100.png +0 -0
  46. data/lib/{generators/surveyor/templates/public/stylesheets/surveyor → assets/images}/ui-bg_highlight-soft_75_ffe45c_1x100.png +0 -0
  47. data/lib/{generators/surveyor/templates/public/stylesheets/surveyor → assets/images}/ui-icons_ef8c08_256x240.png +0 -0
  48. data/lib/{generators/surveyor/templates/public/stylesheets/surveyor → assets/images}/ui-icons_ffffff_256x240.png +0 -0
  49. data/lib/{generators/surveyor/templates/public → assets}/javascripts/surveyor/jquery-ui-timepicker-addon.js +23 -23
  50. data/lib/{generators/surveyor/templates/public → assets}/javascripts/surveyor/jquery-ui.js +125 -125
  51. data/lib/assets/javascripts/surveyor/jquery.selectToUISlider.js +240 -0
  52. data/lib/{generators/surveyor/templates/public → assets}/javascripts/surveyor/jquery.surveyor.js +52 -57
  53. data/lib/{generators/surveyor/templates/public → assets}/javascripts/surveyor/jquery.tools.min.js +7 -7
  54. data/lib/{generators/surveyor/templates/public → assets}/stylesheets/surveyor/dateinput.css +13 -13
  55. data/lib/{generators/surveyor/templates/public → assets}/stylesheets/surveyor/jquery-ui-timepicker-addon.css +0 -0
  56. data/lib/{generators/surveyor/templates/public → assets}/stylesheets/surveyor/jquery-ui.custom.css +17 -17
  57. data/lib/{generators/surveyor/templates/public → assets}/stylesheets/surveyor/reset.css +1 -1
  58. data/lib/{generators/surveyor/templates/public → assets}/stylesheets/surveyor/results.css +0 -0
  59. data/lib/assets/stylesheets/surveyor/ui.slider.extras.css +110 -0
  60. data/lib/{generators/surveyor/templates/public/stylesheets/sass → assets/stylesheets}/surveyor.sass +15 -7
  61. data/lib/generators/surveyor/custom_generator.rb +3 -2
  62. data/lib/generators/surveyor/install_generator.rb +59 -17
  63. data/lib/generators/surveyor/templates/app/assets/javascripts/surveyor_all.js +5 -0
  64. data/lib/generators/surveyor/templates/app/assets/stylesheets/surveyor_all.css +9 -0
  65. data/lib/generators/surveyor/templates/app/controllers/surveyor_controller.rb +2 -1
  66. data/lib/generators/surveyor/templates/app/views/layouts/surveyor_custom.html.erb +1 -0
  67. data/lib/generators/surveyor/templates/config/locales/surveyor_es.yml +1 -0
  68. data/lib/generators/surveyor/templates/config/locales/surveyor_he.yml +1 -0
  69. data/lib/generators/surveyor/templates/db/migrate/add_api_id_to_question_groups.rb +1 -0
  70. data/lib/generators/surveyor/templates/db/migrate/add_api_ids.rb +1 -0
  71. data/lib/generators/surveyor/templates/db/migrate/add_api_ids_to_response_sets_and_responses.rb +1 -0
  72. data/lib/generators/surveyor/templates/db/migrate/add_correct_answer_id_to_questions.rb +1 -0
  73. data/lib/generators/surveyor/templates/db/migrate/add_default_value_to_answers.rb +1 -0
  74. data/lib/generators/surveyor/templates/db/migrate/add_display_order_to_surveys.rb +1 -0
  75. data/lib/generators/surveyor/templates/db/migrate/add_display_type_to_answers.rb +1 -0
  76. data/lib/generators/surveyor/templates/db/migrate/add_index_to_response_sets.rb +1 -0
  77. data/lib/generators/surveyor/templates/db/migrate/add_index_to_surveys.rb +1 -0
  78. data/lib/generators/surveyor/templates/db/migrate/add_section_id_to_responses.rb +1 -0
  79. data/lib/generators/surveyor/templates/db/migrate/add_unique_index_on_access_code_and_version_in_surveys.rb +10 -0
  80. data/lib/generators/surveyor/templates/db/migrate/add_unique_indicies.rb +3 -2
  81. data/lib/generators/surveyor/templates/db/migrate/add_version_to_surveys.rb +10 -0
  82. data/lib/generators/surveyor/templates/db/migrate/api_ids_must_be_unique.rb +23 -0
  83. data/lib/generators/surveyor/templates/db/migrate/create_answers.rb +6 -5
  84. data/lib/generators/surveyor/templates/db/migrate/create_dependencies.rb +2 -1
  85. data/lib/generators/surveyor/templates/db/migrate/create_dependency_conditions.rb +2 -1
  86. data/lib/generators/surveyor/templates/db/migrate/create_question_groups.rb +5 -4
  87. data/lib/generators/surveyor/templates/db/migrate/create_questions.rb +4 -3
  88. data/lib/generators/surveyor/templates/db/migrate/create_response_sets.rb +1 -0
  89. data/lib/generators/surveyor/templates/db/migrate/create_responses.rb +10 -9
  90. data/lib/generators/surveyor/templates/db/migrate/create_survey_sections.rb +5 -4
  91. data/lib/generators/surveyor/templates/db/migrate/create_surveys.rb +4 -3
  92. data/lib/generators/surveyor/templates/db/migrate/create_validation_conditions.rb +5 -4
  93. data/lib/generators/surveyor/templates/db/migrate/create_validations.rb +3 -2
  94. data/lib/generators/surveyor/templates/db/migrate/drop_unique_index_on_access_code_in_surveys.rb +10 -0
  95. data/lib/generators/surveyor/templates/db/migrate/update_blank_api_ids_on_question_group.rb +22 -0
  96. data/lib/generators/surveyor/templates/db/migrate/update_blank_versions_on_surveys.rb +13 -0
  97. data/lib/generators/surveyor/templates/surveys/date_survey.rb +1 -0
  98. data/lib/generators/surveyor/templates/surveys/kitchen_sink_survey.rb +54 -24
  99. data/lib/generators/surveyor/templates/surveys/quiz.rb +1 -0
  100. data/lib/generators/surveyor/templates/{public/stylesheets/sass → vendor/assets/stylesheets}/custom.sass +1 -1
  101. data/lib/surveyor/common.rb +16 -31
  102. data/lib/surveyor/engine.rb +2 -4
  103. data/lib/surveyor/helpers/asset_pipeline.rb +13 -0
  104. data/lib/surveyor/helpers/formtastic_custom_input.rb +17 -0
  105. data/lib/surveyor/helpers/surveyor_helper_methods.rb +10 -8
  106. data/lib/surveyor/models/answer_methods.rb +3 -0
  107. data/lib/surveyor/models/dependency_condition_methods.rb +27 -28
  108. data/lib/surveyor/models/dependency_methods.rb +3 -0
  109. data/lib/surveyor/models/question_group_methods.rb +3 -0
  110. data/lib/surveyor/models/question_methods.rb +10 -7
  111. data/lib/surveyor/models/response_methods.rb +16 -0
  112. data/lib/surveyor/models/response_set_methods.rb +71 -64
  113. data/lib/surveyor/models/survey_methods.rb +19 -28
  114. data/lib/surveyor/models/survey_section_methods.rb +3 -0
  115. data/lib/surveyor/models/validation_condition_methods.rb +4 -2
  116. data/lib/surveyor/models/validation_methods.rb +3 -0
  117. data/lib/surveyor/parser.rb +198 -148
  118. data/lib/surveyor/redcap_parser.rb +120 -80
  119. data/lib/surveyor/surveyor_controller_methods.rb +86 -37
  120. data/lib/surveyor/version.rb +2 -2
  121. data/lib/surveyor.rb +5 -6
  122. data/lib/tasks/surveyor_tasks.rake +19 -7
  123. data/spec/controllers/surveyor_controller_spec.rb +166 -92
  124. data/spec/factories.rb +33 -32
  125. data/spec/helpers/formtastic_custom_input_spec.rb +16 -0
  126. data/spec/lib/common_spec.rb +0 -39
  127. data/spec/lib/redcap_parser_spec.rb +24 -24
  128. data/spec/models/answer_spec.rb +12 -0
  129. data/spec/models/dependency_condition_spec.rb +279 -323
  130. data/spec/models/dependency_spec.rb +10 -0
  131. data/spec/models/question_group_spec.rb +12 -0
  132. data/spec/models/question_spec.rb +12 -0
  133. data/spec/models/response_set_spec.rb +189 -139
  134. data/spec/models/response_spec.rb +60 -0
  135. data/spec/models/survey_section_spec.rb +9 -0
  136. data/spec/models/survey_spec.rb +72 -9
  137. data/spec/models/validation_condition_spec.rb +9 -1
  138. data/spec/models/validation_spec.rb +10 -0
  139. data/spec/spec_helper.rb +25 -6
  140. data/surveyor.gemspec +5 -4
  141. metadata +332 -291
  142. data/features/step_definitions/common_steps.rb +0 -3
  143. data/lib/formtastic/surveyor_builder.rb +0 -82
  144. data/lib/generators/surveyor/templates/public/javascripts/surveyor/jquery.blockUI.js +0 -499
@@ -0,0 +1,110 @@
1
+ /*NEW SLIDER STYLES FOR SCALE, ETC*/
2
+ /* slider widget */
3
+ .ui-slider {
4
+ text-decoration: none !important;
5
+ }
6
+ .ui-slider .ui-slider-handle {
7
+ overflow: visible !important;
8
+ }
9
+ .ui-slider .ui-slider-tooltip {
10
+ display: none;
11
+ }
12
+ .ui-slider .screenReaderContext {
13
+ position: absolute;
14
+ width: 0;
15
+ height: 0;
16
+ overflow: hidden;
17
+ left: -999999999px;
18
+ }
19
+ .ui-slider .ui-state-active .ui-slider-tooltip, .ui-slider .ui-state-focus .ui-slider-tooltip, .ui-slider .ui-state-hover .ui-slider-tooltip {
20
+ display: block;
21
+ position: absolute;
22
+ bottom: 2.5em;
23
+ text-align: center;
24
+ padding: .3em .2em .4em;
25
+ font-size: .9em;
26
+ width: 8em;
27
+ margin-left: -3.7em;
28
+ }
29
+ .ui-slider .ui-slider-tooltip .ui-tooltip-pointer-down, .ui-slider .ui-slider-tooltip .ui-tooltip-pointer-down-inner {
30
+ position: absolute;
31
+ display: block;
32
+ width:0;
33
+ height:0;
34
+ border-bottom-width: 0;
35
+ background: none;
36
+ }
37
+ .ui-slider .ui-slider-tooltip .ui-tooltip-pointer-down {
38
+ border-left: 7px dashed transparent;
39
+ border-right: 7px dashed transparent;
40
+ border-top-width: 8px;
41
+ bottom: -8px;
42
+ right: auto;
43
+ left: 50%;
44
+ margin-left: -7px;
45
+ }
46
+ .ui-slider .ui-slider-tooltip .ui-tooltip-pointer-down-inner {
47
+ border-left: 6px dashed transparent;
48
+ border-right: 6px dashed transparent;
49
+ border-top: 7px solid #fff;
50
+ bottom: auto;
51
+ top: -9px;
52
+ left: -6px;
53
+ }
54
+ .ui-slider a {
55
+ text-decoration: none;
56
+ }
57
+ .ui-slider ol, .ui-slider li, .ui-slider dl, .ui-slider dd, .ui-slider dt {
58
+ list-style: none;
59
+ margin: 0;
60
+ padding: 0;
61
+ }
62
+ .ui-slider ol, .ui-slider dl {
63
+ position: relative;
64
+ top: 1.3em;
65
+ width: 100%;
66
+ }
67
+ .ui-slider dt {
68
+ top: 1.5em;
69
+ position: absolute;
70
+ padding-top: .2em;
71
+ text-align: center;
72
+ border-bottom: 1px dotted #ddd;
73
+ height: .7em;
74
+ color: #999;
75
+ }
76
+ .ui-slider dt span {
77
+ background: #fff;
78
+ padding: 0 .5em;
79
+ }
80
+ .ui-slider li, .ui-slider dd {
81
+ position: absolute;
82
+ overflow: visible;
83
+ color: #666;
84
+ }
85
+ .ui-slider span.ui-slider-label {
86
+ position: absolute;
87
+ }
88
+ .ui-slider li span.ui-slider-label, .ui-slider dd span.ui-slider-label {
89
+ display: none;
90
+ }
91
+ .ui-slider li span.ui-slider-label-show, .ui-slider dd span.ui-slider-label-show {
92
+ display: block;
93
+ }
94
+ .ui-slider span.ui-slider-tic {
95
+ position: absolute;
96
+ left: 0;
97
+ height: .8em;
98
+ top: -1.3em;
99
+ }
100
+ .ui-slider li span.ui-widget-content, .ui-slider dd span.ui-widget-content {
101
+ border-right: 0;
102
+ border-left-width: 1px;
103
+ border-left-style: solid;
104
+ border-top: 0;
105
+ border-bottom: 0;
106
+ }
107
+ .ui-slider .first .ui-slider-tic, .ui-slider .last .ui-slider-tic {
108
+ display: none;
109
+ }
110
+
@@ -6,7 +6,7 @@
6
6
 
7
7
  $background_color:#EEEEEE
8
8
  $surveyor_flash_background_color:#FFF1A8
9
- $surveyor_color:#FFFFF1
9
+ $surveyor_color:#FFFFF1
10
10
  $surveyor_text_color:#333333
11
11
  $surveyor_dependent_color:#FFFFDF
12
12
  $surveyor_menus_active_color:#EBEBCC
@@ -49,7 +49,7 @@ body
49
49
  :background-color $surveyor_menus_active_color
50
50
  .previous_section
51
51
  .next_section
52
- :float right
52
+ :float right
53
53
  .survey_section
54
54
  span.title
55
55
  :display block
@@ -71,11 +71,11 @@ body
71
71
  ol fieldset
72
72
  :display inline
73
73
  input[type="submit"].add_row
74
- :font-size 0.7em
75
-
74
+ :font-size 0.7em
75
+
76
76
  // question groups and questions
77
77
  .survey_section>fieldset>ol
78
- :padding-left 1em
78
+ :padding-left 1em
79
79
  fieldset
80
80
  :padding-top 5px
81
81
  :margin-bottom 10px
@@ -102,7 +102,7 @@ body
102
102
  input[type="text"], textarea
103
103
  :font-size 0.8em
104
104
 
105
- fieldset.q_hidden, fieldset.g_hidden
105
+ fieldset.q_hidden, fieldset.g_hidden, fieldset.g_grid tr.q_hidden
106
106
  :display none !important
107
107
  fieldset.q_dependent, fieldset.g_dependent
108
108
  :background-color $surveyor_dependent_color
@@ -112,7 +112,15 @@ body
112
112
  fieldset.q_dropdown, fieldset.q_inline_dropdown, fieldset.q_default_dropdown, fieldset.q_slider, fieldset.q_repeater_dropdown
113
113
  label
114
114
  :display none
115
-
115
+ fieldset.q_slider
116
+ :margin-bottom 3em
117
+ li.select
118
+ :width 50%
119
+ :font-size .8em
120
+ .ui-slider span.ui-slider-label-show
121
+ :position relative
122
+ :display inline
123
+
116
124
  // buttons
117
125
  input[type="submit"]
118
126
  :font-size 1em
@@ -1,8 +1,9 @@
1
+ # encoding: UTF-8
1
2
  require 'rails/generators'
2
3
  module Surveyor
3
4
  class CustomGenerator < Rails::Generators::Base
4
5
  source_root File.expand_path("../templates", __FILE__)
5
-
6
+
6
7
  def readme
7
8
  copy_file "surveys/EXTENDING_SURVEYOR.md"
8
9
  end
@@ -12,6 +13,6 @@ module Surveyor
12
13
  def layout
13
14
  copy_file "app/views/layouts/surveyor_custom.html.erb"
14
15
  end
15
-
16
+
16
17
  end
17
18
  end
@@ -1,18 +1,64 @@
1
+ # encoding: UTF-8
1
2
  require 'rails/generators'
3
+ require 'surveyor/helpers/asset_pipeline'
4
+
2
5
  module Surveyor
3
6
  class InstallGenerator < Rails::Generators::Base
7
+ include Surveyor::Helpers::AssetPipeline
8
+
4
9
  source_root File.expand_path("../templates", __FILE__)
5
10
  desc "Generate surveyor README, migrations, assets and sample survey"
6
11
  class_option :skip_migrations, :type => :boolean, :desc => "skip migrations, but generate everything else"
7
12
 
13
+ MIGRATION_ORDER = %w(
14
+ create_surveys
15
+ create_survey_sections
16
+ create_questions
17
+ create_question_groups create_answers
18
+ create_response_sets
19
+ create_responses
20
+ create_dependencies
21
+ create_dependency_conditions
22
+ create_validations
23
+ create_validation_conditions
24
+ add_display_order_to_surveys
25
+ add_correct_answer_id_to_questions
26
+ add_index_to_response_sets
27
+ add_index_to_surveys
28
+ add_unique_indicies
29
+ add_section_id_to_responses
30
+ add_default_value_to_answers
31
+ add_api_ids
32
+ add_display_type_to_answers
33
+ add_api_id_to_question_groups
34
+ add_api_ids_to_response_sets_and_responses
35
+ update_blank_api_ids_on_question_group
36
+ drop_unique_index_on_access_code_in_surveys
37
+ add_version_to_surveys
38
+ add_unique_index_on_access_code_and_version_in_surveys
39
+ update_blank_versions_on_surveys
40
+ api_ids_must_be_unique
41
+ )
42
+
8
43
  def readme
9
44
  copy_file "../../../../README.md", "surveys/README.md"
10
45
  end
11
46
  def migrations
12
47
  unless options[:skip_migrations]
48
+ migration_files = Dir[File.join(self.class.source_root, 'db/migrate/*.rb')]
49
+ migrations_not_in_order =
50
+ migration_files.collect { |f| File.basename(f).sub(/\.rb$/, '') } - MIGRATION_ORDER
51
+ unless migrations_not_in_order.empty?
52
+ fail "%s migration%s not added to MIGRATION_ORDER: %s" % [
53
+ migrations_not_in_order.size,
54
+ migrations_not_in_order.size == 1 ? '' : 's',
55
+ migrations_not_in_order.join(', ')
56
+ ]
57
+ end
58
+
13
59
  # because all migration timestamps end up the same, causing a collision when running rake db:migrate
14
60
  # copied functionality from RAILS_GEM_PATH/lib/rails_generator/commands.rb
15
- %w(create_surveys create_survey_sections create_questions create_question_groups create_answers create_response_sets create_responses create_dependencies create_dependency_conditions create_validations create_validation_conditions add_display_order_to_surveys add_correct_answer_id_to_questions add_index_to_response_sets add_index_to_surveys add_unique_indicies add_section_id_to_responses add_default_value_to_answers add_api_ids add_display_type_to_answers add_api_id_to_question_groups add_api_ids_to_response_sets_and_responses).each_with_index do |model, i|
61
+ MIGRATION_ORDER.each_with_index do |model, i|
16
62
  unless (prev_migrations = Dir.glob("db/migrate/[0-9]*_*.rb").grep(/[0-9]+_#{model}.rb$/)).empty?
17
63
  prev_migration_timestamp = prev_migrations[0].match(/([0-9]+)_#{model}.rb$/)[1]
18
64
  end
@@ -20,32 +66,28 @@ module Surveyor
20
66
  end
21
67
  end
22
68
  end
69
+
23
70
  def assets
24
- asset_directory = "public"
25
- if Rails.application.config.respond_to?(:assets) && Rails.application.config.assets.enabled == true
26
- asset_directory = "vendor/assets"
71
+ if asset_pipeline_enabled?
72
+ directory "app/assets"
73
+ copy_file "vendor/assets/stylesheets/custom.sass"
74
+ else
75
+ directory "../../../assets/javascripts", "public/javascripts"
76
+ directory "../../../assets/images", "public/images"
77
+ directory "../../../assets/stylesheets/surveyor", "public/stylesheets/surveyor"
78
+ copy_file "../../../assets/stylesheets/surveyor.sass", "public/stylesheets/sass/surveyor.sass"
79
+ copy_file "vendor/assets/stylesheets/custom.sass", "public/stylesheets/sass/custom.sass"
27
80
  end
28
- %w( templates/public/images/surveyor templates/public/javascripts/surveyor templates/public/stylesheets/surveyor templates/public/stylesheets/sass ).each do |path|
29
- asset_path = File.expand_path("../#{path}", __FILE__)
30
- Dir.foreach(asset_path) do |f|
31
- next if File.directory?(f)
32
-
33
- from_path = "#{path.gsub('templates/public', 'public')}/#{f}"
34
- to_path = "#{path.gsub('templates/public', asset_directory)}/#{f}"
35
- to_path = to_path.gsub("/sass", "") if asset_directory == "vendor/assets"
36
- copy_file(from_path, to_path)
37
- end
38
- end
39
-
40
81
  end
82
+
41
83
  def surveys
42
84
  copy_file "surveys/kitchen_sink_survey.rb"
43
85
  copy_file "surveys/quiz.rb"
44
86
  copy_file "surveys/date_survey.rb"
45
87
  end
88
+
46
89
  def locales
47
90
  directory "config/locales"
48
91
  end
49
-
50
92
  end
51
93
  end
@@ -0,0 +1,5 @@
1
+ //= require surveyor/jquery.tools.min
2
+ //= require surveyor/jquery-ui
3
+ //= require surveyor/jquery-ui-timepicker-addon
4
+ //= require surveyor/jquery.surveyor
5
+ //= require surveyor/jquery.selectToUISlider
@@ -0,0 +1,9 @@
1
+ /*
2
+ *= require surveyor/reset
3
+ *= require surveyor/dateinput
4
+ *= require surveyor/jquery-ui.custom
5
+ *= require surveyor/jquery-ui-timepicker-addon
6
+ *= require surveyor/ui.slider.extras
7
+ *= require surveyor
8
+ *= require custom
9
+ */
@@ -1,3 +1,4 @@
1
+ # encoding: UTF-8
1
2
  module SurveyorControllerCustomMethods
2
3
  def self.included(base)
3
4
  # base.send :before_filter, :require_user # AuthLogic
@@ -22,7 +23,7 @@ module SurveyorControllerCustomMethods
22
23
  def update
23
24
  super
24
25
  end
25
-
26
+
26
27
  # Paths
27
28
  def surveyor_index
28
29
  # most of the above actions redirect to this method
@@ -1,3 +1,4 @@
1
+ # encoding: UTF-8
1
2
  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
2
3
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3
4
  <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
@@ -1,3 +1,4 @@
1
+ # encoding: UTF-8
1
2
  # Sample localization file for Spanish. Add more files in this directory for other locales.
2
3
  # See http://github.com/svenfuchs/rails-i18n/tree/master/rails%2Flocale for starting points.
3
4
 
@@ -1,3 +1,4 @@
1
+ # encoding: UTF-8
1
2
  # Localization file for Hebrew. Add more files in this directory for other locales.
2
3
  # See http://github.com/svenfuchs/rails-i18n/tree/master/rails%2Flocale for starting points.
3
4
 
@@ -1,3 +1,4 @@
1
+ # encoding: UTF-8
1
2
  class AddApiIdToQuestionGroups < ActiveRecord::Migration
2
3
  def self.up
3
4
  add_column :question_groups, :api_id, :string
@@ -1,3 +1,4 @@
1
+ # encoding: UTF-8
1
2
  class AddApiIds < ActiveRecord::Migration
2
3
  def self.up
3
4
  add_column :surveys, :api_id, :string
@@ -1,3 +1,4 @@
1
+ # encoding: UTF-8
1
2
  class AddApiIdsToResponseSetsAndResponses < ActiveRecord::Migration
2
3
  def self.up
3
4
  add_column :response_sets, :api_id, :string
@@ -1,3 +1,4 @@
1
+ # encoding: UTF-8
1
2
  class AddCorrectAnswerIdToQuestions < ActiveRecord::Migration
2
3
  def self.up
3
4
  add_column :questions, :correct_answer_id, :integer
@@ -1,3 +1,4 @@
1
+ # encoding: UTF-8
1
2
  class AddDefaultValueToAnswers < ActiveRecord::Migration
2
3
  def self.up
3
4
  add_column :answers, :default_value, :string
@@ -1,3 +1,4 @@
1
+ # encoding: UTF-8
1
2
  class AddDisplayOrderToSurveys < ActiveRecord::Migration
2
3
  def self.up
3
4
  add_column :surveys, :display_order, :integer
@@ -1,3 +1,4 @@
1
+ # encoding: UTF-8
1
2
  class AddDisplayTypeToAnswers < ActiveRecord::Migration
2
3
  def self.up
3
4
  add_column :answers, :display_type, :string
@@ -1,3 +1,4 @@
1
+ # encoding: UTF-8
1
2
  class AddIndexToResponseSets < ActiveRecord::Migration
2
3
  def self.up
3
4
  add_index(:response_sets, :access_code, :name => 'response_sets_ac_idx')
@@ -1,3 +1,4 @@
1
+ # encoding: UTF-8
1
2
  class AddIndexToSurveys < ActiveRecord::Migration
2
3
  def self.up
3
4
  add_index(:surveys, :access_code, :name => 'surveys_ac_idx')
@@ -1,3 +1,4 @@
1
+ # encoding: UTF-8
1
2
  class AddSectionIdToResponses < ActiveRecord::Migration
2
3
  def self.up
3
4
  add_column :responses, :survey_section_id, :integer
@@ -0,0 +1,10 @@
1
+ # encoding: UTF-8
2
+ class AddUniqueIndexOnAccessCodeAndVersionInSurveys < ActiveRecord::Migration
3
+ def self.up
4
+ add_index(:surveys, [ :access_code, :survey_version], :name => 'surveys_access_code_version_idx', :unique => true)
5
+ end
6
+
7
+ def self.down
8
+ remove_index( :surveys, :name => 'surveys_access_code_version_idx' )
9
+ end
10
+ end
@@ -1,8 +1,9 @@
1
+ # encoding: UTF-8
1
2
  class AddUniqueIndicies < ActiveRecord::Migration
2
3
  def self.up
3
4
  remove_index(:response_sets, :name => 'response_sets_ac_idx')
4
5
  add_index(:response_sets, :access_code, :name => 'response_sets_ac_idx', :unique => true)
5
-
6
+
6
7
  remove_index(:surveys, :name => 'surveys_ac_idx')
7
8
  add_index(:surveys, :access_code, :name => 'surveys_ac_idx', :unique => true)
8
9
  end
@@ -10,7 +11,7 @@ class AddUniqueIndicies < ActiveRecord::Migration
10
11
  def self.down
11
12
  remove_index(:response_sets, :name => 'response_sets_ac_idx')
12
13
  add_index(:response_sets, :access_code, :name => 'response_sets_ac_idx')
13
-
14
+
14
15
  remove_index(:surveys, :name => 'surveys_ac_idx')
15
16
  add_index(:surveys, :access_code, :name => 'surveys_ac_idx')
16
17
  end
@@ -0,0 +1,10 @@
1
+ # encoding: UTF-8
2
+ class AddVersionToSurveys < ActiveRecord::Migration
3
+ def self.up
4
+ add_column :surveys, :survey_version, :integer, :default => 0
5
+ end
6
+
7
+ def self.down
8
+ remove_column :surveys, :survey_version
9
+ end
10
+ end
@@ -0,0 +1,23 @@
1
+ class ApiIdsMustBeUnique < ActiveRecord::Migration
2
+ API_ID_TABLES = %w(surveys questions question_groups answers responses response_sets)
3
+
4
+ class << self
5
+ def up
6
+ API_ID_TABLES.each do |table|
7
+ add_index table, 'api_id', :unique => true, :name => api_id_index_name(table)
8
+ end
9
+ end
10
+
11
+ def down
12
+ API_ID_TABLES.each do |table|
13
+ remove_index table, :name => api_id_index_name(table)
14
+ end
15
+ end
16
+
17
+ private
18
+
19
+ def api_id_index_name(table)
20
+ "uq_#{table}_api_id"
21
+ end
22
+ end
23
+ end
@@ -1,3 +1,4 @@
1
+ # encoding: UTF-8
1
2
  class CreateAnswers < ActiveRecord::Migration
2
3
  def self.up
3
4
  create_table :answers do |t|
@@ -10,24 +11,24 @@ class CreateAnswers < ActiveRecord::Migration
10
11
  t.text :help_text
11
12
  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
  t.string :response_class # What kind of additional data does this answer accept?
13
-
14
+
14
15
  # Reference
15
16
  t.string :reference_identifier # from paper
16
17
  t.string :data_export_identifier # data export
17
18
  t.string :common_namespace # maping to a common vocab
18
19
  t.string :common_identifier # maping to a common vocab
19
-
20
+
20
21
  # Display
21
22
  t.integer :display_order
22
23
  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)
23
24
  t.boolean :hide_label
24
25
  t.integer :display_length # if smaller than answer.length the html input length will be this value
25
-
26
+
26
27
  t.string :custom_class
27
28
  t.string :custom_renderer
28
-
29
+
29
30
  t.timestamps
30
-
31
+
31
32
  end
32
33
  end
33
34
 
@@ -1,10 +1,11 @@
1
+ # encoding: UTF-8
1
2
  class CreateDependencies < ActiveRecord::Migration
2
3
  def self.up
3
4
  create_table :dependencies do |t|
4
5
  # Context
5
6
  t.integer :question_id # the dependent question
6
7
  t.integer :question_group_id
7
-
8
+
8
9
  # Conditional
9
10
  t.string :rule
10
11
 
@@ -1,10 +1,11 @@
1
+ # encoding: UTF-8
1
2
  class CreateDependencyConditions < ActiveRecord::Migration
2
3
  def self.up
3
4
  create_table :dependency_conditions do |t|
4
5
  # Context
5
6
  t.integer :dependency_id
6
7
  t.string :rule_key
7
-
8
+
8
9
  # Conditional
9
10
  t.integer :question_id # the conditional question
10
11
  t.string :operator
@@ -1,22 +1,23 @@
1
+ # encoding: UTF-8
1
2
  class CreateQuestionGroups < ActiveRecord::Migration
2
3
  def self.up
3
4
  create_table :question_groups do |t|
4
5
  # Content
5
6
  t.text :text
6
7
  t.text :help_text
7
-
8
+
8
9
  # Reference
9
10
  t.string :reference_identifier # from paper
10
11
  t.string :data_export_identifier # data export
11
12
  t.string :common_namespace # maping to a common vocab
12
13
  t.string :common_identifier # maping to a common vocab
13
-
14
+
14
15
  # Display
15
16
  t.string :display_type
16
-
17
+
17
18
  t.string :custom_class
18
19
  t.string :custom_renderer
19
-
20
+
20
21
  t.timestamps
21
22
  end
22
23
  end
@@ -1,3 +1,4 @@
1
+ # encoding: UTF-8
1
2
  class CreateQuestions < ActiveRecord::Migration
2
3
  def self.up
3
4
  create_table :questions do |t|
@@ -16,16 +17,16 @@ class CreateQuestions < ActiveRecord::Migration
16
17
  t.string :data_export_identifier # data export
17
18
  t.string :common_namespace # maping to a common vocab
18
19
  t.string :common_identifier # maping to a common vocab
19
-
20
+
20
21
  # Display
21
22
  t.integer :display_order
22
23
  t.string :display_type
23
24
  t.boolean :is_mandatory
24
25
  t.integer :display_width # used only for slider component (if needed)
25
-
26
+
26
27
  t.string :custom_class
27
28
  t.string :custom_renderer
28
-
29
+
29
30
  t.timestamps
30
31
  end
31
32
  end
@@ -1,3 +1,4 @@
1
+ # encoding: UTF-8
1
2
  class CreateResponseSets < ActiveRecord::Migration
2
3
  def self.up
3
4
  create_table :response_sets do |t|
@@ -1,3 +1,4 @@
1
+ # encoding: UTF-8
1
2
  class CreateResponses < ActiveRecord::Migration
2
3
  def self.up
3
4
  create_table :responses do |t|
@@ -5,15 +6,15 @@ class CreateResponses < ActiveRecord::Migration
5
6
  t.integer :response_set_id
6
7
  t.integer :question_id
7
8
 
8
- # Content
9
- t.integer :answer_id
9
+ # Content
10
+ t.integer :answer_id
10
11
  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
12
+
13
+ #t.datetime :time_value
14
+ t.integer :integer_value
15
+ t.float :float_value
16
+ t.string :unit
17
+ t.text :text_value
17
18
  t.string :string_value
18
19
  t.string :response_other #used to hold the string entered with "Other" type answers in multiple choice questions
19
20
 
@@ -22,7 +23,7 @@ class CreateResponses < ActiveRecord::Migration
22
23
  # group 1: Ford/Focus/2007
23
24
  # group 2: Toyota/Prius/2006
24
25
  t.string :response_group
25
-
26
+
26
27
  t.timestamps
27
28
  end
28
29
  end
@@ -1,22 +1,23 @@
1
+ # encoding: UTF-8
1
2
  class CreateSurveySections < ActiveRecord::Migration
2
3
  def self.up
3
4
  create_table :survey_sections do |t|
4
5
  # Context
5
6
  t.integer :survey_id
6
-
7
+
7
8
  # Content
8
9
  t.string :title
9
10
  t.text :description
10
-
11
+
11
12
  # Reference
12
13
  t.string :reference_identifier # from paper
13
14
  t.string :data_export_identifier # data export
14
15
  t.string :common_namespace # maping to a common vocab
15
16
  t.string :common_identifier # maping to a common vocab
16
-
17
+
17
18
  # Display
18
19
  t.integer :display_order
19
-
20
+
20
21
  t.string :custom_class
21
22
 
22
23
  t.timestamps