hssc_surveyor 1.4.1.pre

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (212) hide show
  1. data/.gitignore +28 -0
  2. data/.rspec +1 -0
  3. data/CHANGELOG.md +198 -0
  4. data/Gemfile +5 -0
  5. data/Gemfile.rails_version +19 -0
  6. data/MIT-LICENSE +20 -0
  7. data/README.md +186 -0
  8. data/Rakefile +105 -0
  9. data/app/controllers/surveyor_controller.rb +6 -0
  10. data/app/helpers/results_helper.rb +20 -0
  11. data/app/helpers/survey_form_builder.rb +37 -0
  12. data/app/helpers/surveyor_helper.rb +3 -0
  13. data/app/inputs/quiet_input.rb +5 -0
  14. data/app/inputs/surveyor_check_boxes_input.rb +35 -0
  15. data/app/inputs/surveyor_radio_input.rb +18 -0
  16. data/app/models/answer.rb +4 -0
  17. data/app/models/dependency.rb +4 -0
  18. data/app/models/dependency_condition.rb +4 -0
  19. data/app/models/question.rb +4 -0
  20. data/app/models/question_group.rb +5 -0
  21. data/app/models/response.rb +5 -0
  22. data/app/models/response_set.rb +4 -0
  23. data/app/models/survey.rb +4 -0
  24. data/app/models/survey_section.rb +5 -0
  25. data/app/models/survey_section_sweeper.rb +15 -0
  26. data/app/models/survey_translation.rb +5 -0
  27. data/app/models/validation.rb +4 -0
  28. data/app/models/validation_condition.rb +4 -0
  29. data/app/views/layouts/results.html.erb +13 -0
  30. data/app/views/layouts/surveyor_default.html.erb +12 -0
  31. data/app/views/partials/_answer.html.haml +25 -0
  32. data/app/views/partials/_dependents.html.haml +5 -0
  33. data/app/views/partials/_question.html.haml +41 -0
  34. data/app/views/partials/_question_group.html.haml +44 -0
  35. data/app/views/partials/_section.html.haml +12 -0
  36. data/app/views/partials/_section_menu.html.haml +12 -0
  37. data/app/views/surveyor/edit.html.haml +24 -0
  38. data/app/views/surveyor/export.json.rabl +85 -0
  39. data/app/views/surveyor/new.html.haml +24 -0
  40. data/app/views/surveyor/show.html.haml +74 -0
  41. data/app/views/surveyor/show.json.rabl +15 -0
  42. data/ci-exec.sh +56 -0
  43. data/config/routes.rb +8 -0
  44. data/cucumber.yml +10 -0
  45. data/doc/REPRESENTATIONS.md +34 -0
  46. data/doc/api_id_schema.json +7 -0
  47. data/doc/question types.png +0 -0
  48. data/doc/response_set_schema.json +54 -0
  49. data/doc/surveyor question combinations.png +0 -0
  50. data/doc/surveyor reject or delete decision matrix.png +0 -0
  51. data/doc/surveyor_models.png +0 -0
  52. data/doc/surveyor_models2.png +0 -0
  53. data/doc/surveyor_timestamp_schema.json +9 -0
  54. data/features/ajax_submissions.feature +140 -0
  55. data/features/export_to_json.feature +344 -0
  56. data/features/internationalization.feature +121 -0
  57. data/features/no_duplicates.feature +110 -0
  58. data/features/show_survey.feature +71 -0
  59. data/features/step_definitions/parser_steps.rb +145 -0
  60. data/features/step_definitions/surveyor_steps.rb +325 -0
  61. data/features/step_definitions/ui_steps.rb +25 -0
  62. data/features/step_definitions/web_steps.rb +225 -0
  63. data/features/support/REDCapDemoDatabase_DataDictionary.csv +127 -0
  64. data/features/support/database_cleaner.rb +16 -0
  65. data/features/support/env.rb +56 -0
  66. data/features/support/hooks.rb +4 -0
  67. data/features/support/paths.rb +39 -0
  68. data/features/support/redcap_new_headers.csv +1 -0
  69. data/features/support/redcap_siblings.csv +1 -0
  70. data/features/support/redcap_whitespace.csv +1 -0
  71. data/features/support/selectors.rb +39 -0
  72. data/features/support/simultaneous_ajax.rb +101 -0
  73. data/features/support/single_quit_selenium_driver.rb +23 -0
  74. data/features/support/slow_updates.rb +18 -0
  75. data/features/surveyor.feature +895 -0
  76. data/features/surveyor_dependencies.feature +476 -0
  77. data/features/surveyor_parser.feature +504 -0
  78. data/features/z_redcap_parser.feature +62 -0
  79. data/lib/assets/images/surveyor/next.gif +0 -0
  80. data/lib/assets/images/surveyor/prev.gif +0 -0
  81. data/lib/assets/images/ui-bg_flat_0_aaaaaa_40x100.png +0 -0
  82. data/lib/assets/images/ui-bg_flat_75_ffffff_40x100.png +0 -0
  83. data/lib/assets/images/ui-bg_glass_55_fbf9ee_1x400.png +0 -0
  84. data/lib/assets/images/ui-bg_glass_65_ffffff_1x400.png +0 -0
  85. data/lib/assets/images/ui-bg_glass_75_dadada_1x400.png +0 -0
  86. data/lib/assets/images/ui-bg_glass_75_e6e6e6_1x400.png +0 -0
  87. data/lib/assets/images/ui-bg_glass_95_fef1ec_1x400.png +0 -0
  88. data/lib/assets/images/ui-bg_highlight-soft_75_cccccc_1x100.png +0 -0
  89. data/lib/assets/images/ui-icons_222222_256x240.png +0 -0
  90. data/lib/assets/images/ui-icons_2e83ff_256x240.png +0 -0
  91. data/lib/assets/images/ui-icons_454545_256x240.png +0 -0
  92. data/lib/assets/images/ui-icons_888888_256x240.png +0 -0
  93. data/lib/assets/images/ui-icons_cd0a0a_256x240.png +0 -0
  94. data/lib/assets/javascripts/surveyor/jquery-1.9.0.js +9555 -0
  95. data/lib/assets/javascripts/surveyor/jquery-ui-1.10.0.custom.js +14850 -0
  96. data/lib/assets/javascripts/surveyor/jquery-ui-timepicker-addon.js +1919 -0
  97. data/lib/assets/javascripts/surveyor/jquery.maskedinput.js +338 -0
  98. data/lib/assets/javascripts/surveyor/jquery.selectToUISlider.js +240 -0
  99. data/lib/assets/javascripts/surveyor/jquery.surveyor.js +156 -0
  100. data/lib/assets/stylesheets/surveyor/jquery-ui-1.10.0.custom.css +1174 -0
  101. data/lib/assets/stylesheets/surveyor/jquery-ui-timepicker-addon.css +11 -0
  102. data/lib/assets/stylesheets/surveyor/reset.css +48 -0
  103. data/lib/assets/stylesheets/surveyor/results.css +125 -0
  104. data/lib/assets/stylesheets/surveyor/ui.slider.extras.css +110 -0
  105. data/lib/assets/stylesheets/surveyor.sass +132 -0
  106. data/lib/generators/surveyor/custom_generator.rb +18 -0
  107. data/lib/generators/surveyor/install_generator.rb +102 -0
  108. data/lib/generators/surveyor/templates/app/assets/javascripts/surveyor_all.js +6 -0
  109. data/lib/generators/surveyor/templates/app/assets/stylesheets/surveyor_all.css +9 -0
  110. data/lib/generators/surveyor/templates/app/controllers/surveyor_controller.rb +40 -0
  111. data/lib/generators/surveyor/templates/app/views/layouts/surveyor_custom.html.erb +13 -0
  112. data/lib/generators/surveyor/templates/config/locales/surveyor_en.yml +19 -0
  113. data/lib/generators/surveyor/templates/config/locales/surveyor_es.yml +19 -0
  114. data/lib/generators/surveyor/templates/config/locales/surveyor_he.yml +19 -0
  115. data/lib/generators/surveyor/templates/config/locales/surveyor_ko.yml +19 -0
  116. data/lib/generators/surveyor/templates/db/migrate/add_api_id_to_question_groups.rb +10 -0
  117. data/lib/generators/surveyor/templates/db/migrate/add_api_ids.rb +14 -0
  118. data/lib/generators/surveyor/templates/db/migrate/add_api_ids_to_response_sets_and_responses.rb +12 -0
  119. data/lib/generators/surveyor/templates/db/migrate/add_attachment_to_response.rb +5 -0
  120. data/lib/generators/surveyor/templates/db/migrate/add_correct_answer_id_to_questions.rb +10 -0
  121. data/lib/generators/surveyor/templates/db/migrate/add_default_value_to_answers.rb +10 -0
  122. data/lib/generators/surveyor/templates/db/migrate/add_display_order_to_surveys.rb +10 -0
  123. data/lib/generators/surveyor/templates/db/migrate/add_display_type_to_answers.rb +14 -0
  124. data/lib/generators/surveyor/templates/db/migrate/add_index_to_response_sets.rb +10 -0
  125. data/lib/generators/surveyor/templates/db/migrate/add_index_to_surveys.rb +10 -0
  126. data/lib/generators/surveyor/templates/db/migrate/add_input_mask_attributes_to_answer.rb +12 -0
  127. data/lib/generators/surveyor/templates/db/migrate/add_section_id_to_responses.rb +12 -0
  128. data/lib/generators/surveyor/templates/db/migrate/add_unique_index_on_access_code_and_version_in_surveys.rb +10 -0
  129. data/lib/generators/surveyor/templates/db/migrate/add_unique_indicies.rb +18 -0
  130. data/lib/generators/surveyor/templates/db/migrate/add_version_to_surveys.rb +10 -0
  131. data/lib/generators/surveyor/templates/db/migrate/api_ids_must_be_unique.rb +23 -0
  132. data/lib/generators/surveyor/templates/db/migrate/create_answers.rb +38 -0
  133. data/lib/generators/surveyor/templates/db/migrate/create_dependencies.rb +23 -0
  134. data/lib/generators/surveyor/templates/db/migrate/create_dependency_conditions.rb +30 -0
  135. data/lib/generators/surveyor/templates/db/migrate/create_question_groups.rb +28 -0
  136. data/lib/generators/surveyor/templates/db/migrate/create_questions.rb +37 -0
  137. data/lib/generators/surveyor/templates/db/migrate/create_response_sets.rb +23 -0
  138. data/lib/generators/surveyor/templates/db/migrate/create_responses.rb +34 -0
  139. data/lib/generators/surveyor/templates/db/migrate/create_survey_sections.rb +30 -0
  140. data/lib/generators/surveyor/templates/db/migrate/create_survey_translations.rb +19 -0
  141. data/lib/generators/surveyor/templates/db/migrate/create_surveys.rb +32 -0
  142. data/lib/generators/surveyor/templates/db/migrate/create_validation_conditions.rb +33 -0
  143. data/lib/generators/surveyor/templates/db/migrate/create_validations.rb +21 -0
  144. data/lib/generators/surveyor/templates/db/migrate/drop_unique_index_on_access_code_in_surveys.rb +10 -0
  145. data/lib/generators/surveyor/templates/db/migrate/update_blank_api_ids_on_question_group.rb +22 -0
  146. data/lib/generators/surveyor/templates/db/migrate/update_blank_versions_on_surveys.rb +13 -0
  147. data/lib/generators/surveyor/templates/surveys/EXTENDING_SURVEYOR.md +52 -0
  148. data/lib/generators/surveyor/templates/surveys/MODIFYING_SURVEYOR.md +91 -0
  149. data/lib/generators/surveyor/templates/surveys/date_survey.rb +16 -0
  150. data/lib/generators/surveyor/templates/surveys/kitchen_sink_survey.rb +284 -0
  151. data/lib/generators/surveyor/templates/surveys/languages.rb +14 -0
  152. data/lib/generators/surveyor/templates/surveys/quiz.rb +11 -0
  153. data/lib/generators/surveyor/templates/surveys/translations/languages.es.yml +18 -0
  154. data/lib/generators/surveyor/templates/surveys/translations/languages.he.yml +18 -0
  155. data/lib/generators/surveyor/templates/surveys/translations/languages.ko.yml +18 -0
  156. data/lib/generators/surveyor/templates/vendor/assets/stylesheets/custom.sass +5 -0
  157. data/lib/surveyor/acts_as_response.rb +17 -0
  158. data/lib/surveyor/common.rb +59 -0
  159. data/lib/surveyor/engine.rb +10 -0
  160. data/lib/surveyor/helpers/asset_pipeline.rb +13 -0
  161. data/lib/surveyor/helpers/formtastic_custom_input.rb +13 -0
  162. data/lib/surveyor/helpers/surveyor_helper_methods.rb +103 -0
  163. data/lib/surveyor/models/answer_methods.rb +86 -0
  164. data/lib/surveyor/models/dependency_condition_methods.rb +72 -0
  165. data/lib/surveyor/models/dependency_methods.rb +60 -0
  166. data/lib/surveyor/models/question_group_methods.rb +61 -0
  167. data/lib/surveyor/models/question_methods.rb +115 -0
  168. data/lib/surveyor/models/response_methods.rb +132 -0
  169. data/lib/surveyor/models/response_set_methods.rb +196 -0
  170. data/lib/surveyor/models/survey_methods.rb +103 -0
  171. data/lib/surveyor/models/survey_section_methods.rb +56 -0
  172. data/lib/surveyor/models/survey_translation_methods.rb +33 -0
  173. data/lib/surveyor/models/validation_condition_methods.rb +56 -0
  174. data/lib/surveyor/models/validation_methods.rb +48 -0
  175. data/lib/surveyor/mustache_context.rb +11 -0
  176. data/lib/surveyor/parser.rb +428 -0
  177. data/lib/surveyor/redcap_parser.rb +289 -0
  178. data/lib/surveyor/surveyor_controller_methods.rb +237 -0
  179. data/lib/surveyor/unparser.rb +147 -0
  180. data/lib/surveyor/version.rb +3 -0
  181. data/lib/surveyor.rb +13 -0
  182. data/lib/tasks/surveyor_tasks.rake +88 -0
  183. data/rails/init.rb +1 -0
  184. data/spec/controllers/surveyor_controller_spec.rb +307 -0
  185. data/spec/factories.rb +161 -0
  186. data/spec/helpers/formtastic_custom_input_spec.rb +15 -0
  187. data/spec/helpers/surveyor_helper_spec.rb +118 -0
  188. data/spec/lib/benchmark_spec.rb +22 -0
  189. data/spec/lib/chinese_survey.rb +14 -0
  190. data/spec/lib/common_spec.rb +34 -0
  191. data/spec/lib/parser_spec.rb +204 -0
  192. data/spec/lib/rake_kitchen_sink.rb +40 -0
  193. data/spec/lib/redcap_parser_spec.rb +75 -0
  194. data/spec/lib/tasks_spec.rake +26 -0
  195. data/spec/lib/unparser_spec.rb +126 -0
  196. data/spec/models/answer_spec.rb +175 -0
  197. data/spec/models/dependency_condition_spec.rb +439 -0
  198. data/spec/models/dependency_spec.rb +101 -0
  199. data/spec/models/question_group_spec.rb +93 -0
  200. data/spec/models/question_spec.rb +207 -0
  201. data/spec/models/response_set_spec.rb +477 -0
  202. data/spec/models/response_spec.rb +218 -0
  203. data/spec/models/survey_section_spec.rb +85 -0
  204. data/spec/models/survey_spec.rb +191 -0
  205. data/spec/models/validation_condition_spec.rb +113 -0
  206. data/spec/models/validation_spec.rb +74 -0
  207. data/spec/rcov.opts +2 -0
  208. data/spec/spec.opts +4 -0
  209. data/spec/spec_helper.rb +56 -0
  210. data/stacktests.sh +65 -0
  211. data/surveyor.gemspec +45 -0
  212. metadata +657 -0
@@ -0,0 +1,19 @@
1
+ # encoding: UTF-8
2
+ # Sample localization file for Korean. Add more files in this directory for other locales.
3
+ # See http://github.com/svenfuchs/rails-i18n/tree/master/rails%2Flocale for starting points.
4
+
5
+ ko:
6
+ surveyor:
7
+ take_these_surveys: "설문에 답을 하셔도 좋습니다"
8
+ take_it: "답을 하십시요"
9
+ completed_survey: "완료된 설문"
10
+ unable_to_find_your_responses: "설문에 대한 답을 찾을 수 없습니다"
11
+ unable_to_update_survey: "설문을 업데이트 할 수 없습니다"
12
+ unable_to_find_that_survey: "이 설문을 찾을 수 없습니다"
13
+ survey_started_success: "설문 조사가 성공적으로 시작되었습니다"
14
+ click_here_to_finish: "종료 하려면 여기를 누르십시요"
15
+ previous_section: "« 이전 항목으로"
16
+ next_section: "다음 항목으로 »"
17
+ select_one: "하나를 선택하십시요"
18
+ sections: "항목"
19
+ language: "언어"
@@ -0,0 +1,10 @@
1
+ # encoding: UTF-8
2
+ class AddApiIdToQuestionGroups < ActiveRecord::Migration
3
+ def self.up
4
+ add_column :question_groups, :api_id, :string
5
+ end
6
+
7
+ def self.down
8
+ remove_column :question_groups, :api_id
9
+ end
10
+ end
@@ -0,0 +1,14 @@
1
+ # encoding: UTF-8
2
+ class AddApiIds < ActiveRecord::Migration
3
+ def self.up
4
+ add_column :surveys, :api_id, :string
5
+ add_column :questions, :api_id, :string
6
+ add_column :answers, :api_id, :string
7
+ end
8
+
9
+ def self.down
10
+ remove_column :surveys, :api_id
11
+ remove_column :questions, :api_id
12
+ remove_column :answers, :api_id
13
+ end
14
+ end
@@ -0,0 +1,12 @@
1
+ # encoding: UTF-8
2
+ class AddApiIdsToResponseSetsAndResponses < ActiveRecord::Migration
3
+ def self.up
4
+ add_column :response_sets, :api_id, :string
5
+ add_column :responses, :api_id, :string
6
+ end
7
+
8
+ def self.down
9
+ remove_column :response_sets, :api_id
10
+ remove_column :responses, :api_id
11
+ end
12
+ end
@@ -0,0 +1,5 @@
1
+ class AddAttachmentToResponse < ActiveRecord::Migration
2
+ def change
3
+ add_attachment :responses, :file
4
+ end
5
+ end
@@ -0,0 +1,10 @@
1
+ # encoding: UTF-8
2
+ class AddCorrectAnswerIdToQuestions < ActiveRecord::Migration
3
+ def self.up
4
+ add_column :questions, :correct_answer_id, :integer
5
+ end
6
+
7
+ def self.down
8
+ remove_column :questions, :correct_answer_id
9
+ end
10
+ end
@@ -0,0 +1,10 @@
1
+ # encoding: UTF-8
2
+ class AddDefaultValueToAnswers < ActiveRecord::Migration
3
+ def self.up
4
+ add_column :answers, :default_value, :string
5
+ end
6
+
7
+ def self.down
8
+ remove_column :answers, :default_value
9
+ end
10
+ end
@@ -0,0 +1,10 @@
1
+ # encoding: UTF-8
2
+ class AddDisplayOrderToSurveys < ActiveRecord::Migration
3
+ def self.up
4
+ add_column :surveys, :display_order, :integer
5
+ end
6
+
7
+ def self.down
8
+ remove_column :surveys, :display_order
9
+ end
10
+ end
@@ -0,0 +1,14 @@
1
+ # encoding: UTF-8
2
+ class AddDisplayTypeToAnswers < ActiveRecord::Migration
3
+ def self.up
4
+ add_column :answers, :display_type, :string
5
+ Answer.all.each{|a| a.update_attributes(:display_type => "hidden_label") if a.hide_label == true}
6
+ remove_column :answers, :hide_label
7
+ end
8
+
9
+ def self.down
10
+ add_column :answers, :hide_label, :boolean
11
+ Answer.all.each{|a| a.update_attributes(:hide_label => true) if a.display_type == "hidden_label"}
12
+ remove_column :answers, :display_type
13
+ end
14
+ end
@@ -0,0 +1,10 @@
1
+ # encoding: UTF-8
2
+ class AddIndexToResponseSets < ActiveRecord::Migration
3
+ def self.up
4
+ add_index(:response_sets, :access_code, :name => 'response_sets_ac_idx')
5
+ end
6
+
7
+ def self.down
8
+ remove_index(:response_sets, :name => 'response_sets_ac_idx')
9
+ end
10
+ end
@@ -0,0 +1,10 @@
1
+ # encoding: UTF-8
2
+ class AddIndexToSurveys < ActiveRecord::Migration
3
+ def self.up
4
+ add_index(:surveys, :access_code, :name => 'surveys_ac_idx')
5
+ end
6
+
7
+ def self.down
8
+ remove_index(:surveys, :name => 'surveys_ac_idx')
9
+ end
10
+ end
@@ -0,0 +1,12 @@
1
+ # encoding: UTF-8
2
+ class AddInputMaskAttributesToAnswer < ActiveRecord::Migration
3
+ def self.up
4
+ add_column :answers, :input_mask, :string
5
+ add_column :answers, :input_mask_placeholder, :string
6
+ end
7
+
8
+ def self.down
9
+ remove_column :answers, :input_mask
10
+ remove_column :answers, :input_mask_placeholder
11
+ end
12
+ end
@@ -0,0 +1,12 @@
1
+ # encoding: UTF-8
2
+ class AddSectionIdToResponses < ActiveRecord::Migration
3
+ def self.up
4
+ add_column :responses, :survey_section_id, :integer
5
+ add_index :responses, :survey_section_id
6
+ end
7
+
8
+ def self.down
9
+ remove_index :responses, :survey_section_id
10
+ remove_column :responses, :survey_section_id
11
+ end
12
+ end
@@ -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
@@ -0,0 +1,18 @@
1
+ # encoding: UTF-8
2
+ class AddUniqueIndicies < ActiveRecord::Migration
3
+ def self.up
4
+ remove_index(:response_sets, :name => 'response_sets_ac_idx')
5
+ add_index(:response_sets, :access_code, :name => 'response_sets_ac_idx', :unique => true)
6
+
7
+ remove_index(:surveys, :name => 'surveys_ac_idx')
8
+ add_index(:surveys, :access_code, :name => 'surveys_ac_idx', :unique => true)
9
+ end
10
+
11
+ def self.down
12
+ remove_index(:response_sets, :name => 'response_sets_ac_idx')
13
+ add_index(:response_sets, :access_code, :name => 'response_sets_ac_idx')
14
+
15
+ remove_index(:surveys, :name => 'surveys_ac_idx')
16
+ add_index(:surveys, :access_code, :name => 'surveys_ac_idx')
17
+ end
18
+ 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
@@ -0,0 +1,38 @@
1
+ # encoding: UTF-8
2
+ class CreateAnswers < ActiveRecord::Migration
3
+ def self.up
4
+ create_table :answers do |t|
5
+ # Context
6
+ t.integer :question_id
7
+
8
+ # Content
9
+ t.text :text
10
+ t.text :short_text #Used for presenting responses to experts (ie non-survey takers). Just a shorted version of the string
11
+ t.text :help_text
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)
13
+ t.string :response_class # What kind of additional data does this answer accept?
14
+
15
+ # Reference
16
+ t.string :reference_identifier # from paper
17
+ t.string :data_export_identifier # data export
18
+ t.string :common_namespace # maping to a common vocab
19
+ t.string :common_identifier # maping to a common vocab
20
+
21
+ # Display
22
+ t.integer :display_order
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)
24
+ t.boolean :hide_label
25
+ t.integer :display_length # if smaller than answer.length the html input length will be this value
26
+
27
+ t.string :custom_class
28
+ t.string :custom_renderer
29
+
30
+ t.timestamps
31
+
32
+ end
33
+ end
34
+
35
+ def self.down
36
+ drop_table :answers
37
+ end
38
+ end
@@ -0,0 +1,23 @@
1
+ # encoding: UTF-8
2
+ class CreateDependencies < ActiveRecord::Migration
3
+ def self.up
4
+ create_table :dependencies do |t|
5
+ # Context
6
+ t.integer :question_id # the dependent question
7
+ t.integer :question_group_id
8
+
9
+ # Conditional
10
+ t.string :rule
11
+
12
+ # Result - TODO: figure out the dependency hook presentation options
13
+ # t.string :property_to_toggle # visibility, class_name,
14
+ # t.string :effect #blind, opacity
15
+
16
+ t.timestamps
17
+ end
18
+ end
19
+
20
+ def self.down
21
+ drop_table :dependencies
22
+ end
23
+ end
@@ -0,0 +1,30 @@
1
+ # encoding: UTF-8
2
+ class CreateDependencyConditions < ActiveRecord::Migration
3
+ def self.up
4
+ create_table :dependency_conditions do |t|
5
+ # Context
6
+ t.integer :dependency_id
7
+ t.string :rule_key
8
+
9
+ # Conditional
10
+ t.integer :question_id # the conditional question
11
+ t.string :operator
12
+
13
+ # Value
14
+ t.integer :answer_id
15
+ t.datetime :datetime_value
16
+ t.integer :integer_value
17
+ t.float :float_value
18
+ t.string :unit
19
+ t.text :text_value
20
+ t.string :string_value
21
+ t.string :response_other
22
+
23
+ t.timestamps
24
+ end
25
+ end
26
+
27
+ def self.down
28
+ drop_table :dependency_conditions
29
+ end
30
+ end
@@ -0,0 +1,28 @@
1
+ # encoding: UTF-8
2
+ class CreateQuestionGroups < ActiveRecord::Migration
3
+ def self.up
4
+ create_table :question_groups do |t|
5
+ # Content
6
+ t.text :text
7
+ t.text :help_text
8
+
9
+ # Reference
10
+ t.string :reference_identifier # from paper
11
+ t.string :data_export_identifier # data export
12
+ t.string :common_namespace # maping to a common vocab
13
+ t.string :common_identifier # maping to a common vocab
14
+
15
+ # Display
16
+ t.string :display_type
17
+
18
+ t.string :custom_class
19
+ t.string :custom_renderer
20
+
21
+ t.timestamps
22
+ end
23
+ end
24
+
25
+ def self.down
26
+ drop_table :question_groups
27
+ end
28
+ end
@@ -0,0 +1,37 @@
1
+ # encoding: UTF-8
2
+ class CreateQuestions < ActiveRecord::Migration
3
+ def self.up
4
+ create_table :questions do |t|
5
+ # Context
6
+ t.integer :survey_section_id
7
+ t.integer :question_group_id
8
+
9
+ # Content
10
+ t.text :text
11
+ t.text :short_text # For experts (ie non-survey takers). Short version of text
12
+ t.text :help_text
13
+ t.string :pick
14
+
15
+ # Reference
16
+ t.string :reference_identifier # from paper
17
+ t.string :data_export_identifier # data export
18
+ t.string :common_namespace # maping to a common vocab
19
+ t.string :common_identifier # maping to a common vocab
20
+
21
+ # Display
22
+ t.integer :display_order
23
+ t.string :display_type
24
+ t.boolean :is_mandatory
25
+ t.integer :display_width # used only for slider component (if needed)
26
+
27
+ t.string :custom_class
28
+ t.string :custom_renderer
29
+
30
+ t.timestamps
31
+ end
32
+ end
33
+
34
+ def self.down
35
+ drop_table :questions
36
+ end
37
+ end
@@ -0,0 +1,23 @@
1
+ # encoding: UTF-8
2
+ class CreateResponseSets < ActiveRecord::Migration
3
+ def self.up
4
+ create_table :response_sets do |t|
5
+ # Context
6
+ t.integer :user_id
7
+ t.integer :survey_id
8
+
9
+ # Content
10
+ t.string :access_code #unique id for the object used in urls
11
+
12
+ # Expiry
13
+ t.datetime :started_at
14
+ t.datetime :completed_at
15
+
16
+ t.timestamps
17
+ end
18
+ end
19
+
20
+ def self.down
21
+ drop_table :response_sets
22
+ end
23
+ end
@@ -0,0 +1,34 @@
1
+ # encoding: UTF-8
2
+ class CreateResponses < ActiveRecord::Migration
3
+ def self.up
4
+ create_table :responses do |t|
5
+ # Context
6
+ t.integer :response_set_id
7
+ t.integer :question_id
8
+
9
+ # Content
10
+ t.integer :answer_id
11
+ t.datetime :datetime_value # handles date, time, and datetime (segregate by answer.response_class)
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
18
+ t.string :string_value
19
+ t.string :response_other #used to hold the string entered with "Other" type answers in multiple choice questions
20
+
21
+ # arbitrary identifier used to group responses
22
+ # the pertinent example here is Q: What's your car's make/model/year
23
+ # group 1: Ford/Focus/2007
24
+ # group 2: Toyota/Prius/2006
25
+ t.string :response_group
26
+
27
+ t.timestamps
28
+ end
29
+ end
30
+
31
+ def self.down
32
+ drop_table :responses
33
+ end
34
+ end
@@ -0,0 +1,30 @@
1
+ # encoding: UTF-8
2
+ class CreateSurveySections < ActiveRecord::Migration
3
+ def self.up
4
+ create_table :survey_sections do |t|
5
+ # Context
6
+ t.integer :survey_id
7
+
8
+ # Content
9
+ t.string :title
10
+ t.text :description
11
+
12
+ # Reference
13
+ t.string :reference_identifier # from paper
14
+ t.string :data_export_identifier # data export
15
+ t.string :common_namespace # maping to a common vocab
16
+ t.string :common_identifier # maping to a common vocab
17
+
18
+ # Display
19
+ t.integer :display_order
20
+
21
+ t.string :custom_class
22
+
23
+ t.timestamps
24
+ end
25
+ end
26
+
27
+ def self.down
28
+ drop_table :survey_sections
29
+ end
30
+ end
@@ -0,0 +1,19 @@
1
+ # encoding: UTF-8
2
+ class CreateSurveyTranslations < ActiveRecord::Migration
3
+ def self.up
4
+ create_table :survey_translations do |t|
5
+ # Content
6
+ t.integer :survey_id
7
+
8
+ # Reference
9
+ t.string :locale
10
+ t.text :translation
11
+
12
+ t.timestamps
13
+ end
14
+ end
15
+
16
+ def self.down
17
+ drop_table :survey_translations
18
+ end
19
+ end
@@ -0,0 +1,32 @@
1
+ # encoding: UTF-8
2
+ class CreateSurveys < ActiveRecord::Migration
3
+ def self.up
4
+ create_table :surveys do |t|
5
+ # Content
6
+ t.string :title
7
+ t.text :description
8
+
9
+ # Reference
10
+ t.string :access_code
11
+ t.string :reference_identifier # from paper
12
+ t.string :data_export_identifier # data export
13
+ t.string :common_namespace # maping to a common vocab
14
+ t.string :common_identifier # maping to a common vocab
15
+
16
+ # Expiry
17
+ t.datetime :active_at
18
+ t.datetime :inactive_at
19
+
20
+ # Display
21
+ t.string :css_url
22
+
23
+ t.string :custom_class
24
+
25
+ t.timestamps
26
+ end
27
+ end
28
+
29
+ def self.down
30
+ drop_table :surveys
31
+ end
32
+ end
@@ -0,0 +1,33 @@
1
+ # encoding: UTF-8
2
+ class CreateValidationConditions < ActiveRecord::Migration
3
+ def self.up
4
+ create_table :validation_conditions do |t|
5
+ # Context
6
+ t.integer :validation_id
7
+ t.string :rule_key
8
+
9
+ # Conditional
10
+ t.string :operator
11
+
12
+ # Optional external reference
13
+ t.integer :question_id
14
+ t.integer :answer_id
15
+
16
+ # Value
17
+ t.datetime :datetime_value
18
+ t.integer :integer_value
19
+ t.float :float_value
20
+ t.string :unit
21
+ t.text :text_value
22
+ t.string :string_value
23
+ t.string :response_other
24
+ t.string :regexp
25
+
26
+ t.timestamps
27
+ end
28
+ end
29
+
30
+ def self.down
31
+ drop_table :validation_conditions
32
+ end
33
+ end
@@ -0,0 +1,21 @@
1
+ # encoding: UTF-8
2
+ class CreateValidations < ActiveRecord::Migration
3
+ def self.up
4
+ create_table :validations do |t|
5
+ # Context
6
+ t.integer :answer_id # the answer to validate
7
+
8
+ # Conditional
9
+ t.string :rule
10
+
11
+ # Message
12
+ t.string :message
13
+
14
+ t.timestamps
15
+ end
16
+ end
17
+
18
+ def self.down
19
+ drop_table :validations
20
+ end
21
+ end
@@ -0,0 +1,10 @@
1
+ # encoding: UTF-8
2
+ class DropUniqueIndexOnAccessCodeInSurveys < ActiveRecord::Migration
3
+ def self.up
4
+ remove_index( :surveys, :name => 'surveys_ac_idx' )
5
+ end
6
+
7
+ def self.down
8
+ add_index(:surveys, :access_code, :name => 'surveys_ac_idx')
9
+ end
10
+ end
@@ -0,0 +1,22 @@
1
+ # encoding: UTF-8
2
+ class Survey < ActiveRecord::Base; end
3
+ class Question < ActiveRecord::Base; end
4
+ class QuestionGroup < ActiveRecord::Base; end
5
+ class Answer < ActiveRecord::Base; end
6
+ class Response < ActiveRecord::Base; end
7
+ class ResponseSet < ActiveRecord::Base; end
8
+
9
+ class UpdateBlankApiIdsOnQuestionGroup < ActiveRecord::Migration
10
+ def self.up
11
+ check = [Survey, Question, QuestionGroup, Answer, Response, ResponseSet]
12
+ check.each do |clazz|
13
+ clazz.where('api_id IS ?', nil).each do |c|
14
+ c.api_id = Surveyor::Common.generate_api_id
15
+ c.save!
16
+ end
17
+ end
18
+ end
19
+
20
+ def self.down
21
+ end
22
+ end
@@ -0,0 +1,13 @@
1
+ # encoding: UTF-8
2
+ class Survey < ActiveRecord::Base; end
3
+ class UpdateBlankVersionsOnSurveys < ActiveRecord::Migration
4
+ def self.up
5
+ Survey.where('survey_version IS ?', nil).each do |s|
6
+ s.survey_version = 0
7
+ s.save!
8
+ end
9
+ end
10
+
11
+ def self.down
12
+ end
13
+ end