affectiva-surveyor 1.5.0.pre.disco.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (212) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +28 -0
  3. data/.rspec +1 -0
  4. data/CHANGELOG.md +198 -0
  5. data/Gemfile +5 -0
  6. data/Gemfile.rails_version +27 -0
  7. data/MIT-LICENSE +20 -0
  8. data/README.md +166 -0
  9. data/Rakefile +106 -0
  10. data/app/controllers/surveyor_controller.rb +5 -0
  11. data/app/helpers/results_helper.rb +20 -0
  12. data/app/helpers/survey_form_builder.rb +37 -0
  13. data/app/helpers/surveyor_helper.rb +3 -0
  14. data/app/inputs/quiet_input.rb +5 -0
  15. data/app/inputs/surveyor_check_boxes_input.rb +35 -0
  16. data/app/inputs/surveyor_radio_input.rb +18 -0
  17. data/app/models/answer.rb +3 -0
  18. data/app/models/dependency.rb +3 -0
  19. data/app/models/dependency_condition.rb +3 -0
  20. data/app/models/question.rb +3 -0
  21. data/app/models/question_group.rb +4 -0
  22. data/app/models/response.rb +4 -0
  23. data/app/models/response_set.rb +3 -0
  24. data/app/models/survey.rb +3 -0
  25. data/app/models/survey_section.rb +4 -0
  26. data/app/models/survey_section_sweeper.rb +15 -0
  27. data/app/models/survey_translation.rb +4 -0
  28. data/app/models/validation.rb +3 -0
  29. data/app/models/validation_condition.rb +3 -0
  30. data/app/views/layouts/results.html.erb +13 -0
  31. data/app/views/layouts/surveyor_default.html.erb +12 -0
  32. data/app/views/partials/_answer.html.haml +25 -0
  33. data/app/views/partials/_dependents.html.haml +5 -0
  34. data/app/views/partials/_question.html.haml +28 -0
  35. data/app/views/partials/_question_group.html.haml +44 -0
  36. data/app/views/partials/_section.html.haml +12 -0
  37. data/app/views/partials/_section_menu.html.haml +12 -0
  38. data/app/views/surveyor/edit.html.haml +24 -0
  39. data/app/views/surveyor/export.json.rabl +85 -0
  40. data/app/views/surveyor/new.html.haml +24 -0
  41. data/app/views/surveyor/show.html.haml +74 -0
  42. data/app/views/surveyor/show.json.rabl +15 -0
  43. data/ci-exec.sh +56 -0
  44. data/config/routes.rb +8 -0
  45. data/cucumber.yml +10 -0
  46. data/doc/REPRESENTATIONS.md +34 -0
  47. data/doc/api_id_schema.json +7 -0
  48. data/doc/question types.png +0 -0
  49. data/doc/response_set_schema.json +54 -0
  50. data/doc/surveyor question combinations.png +0 -0
  51. data/doc/surveyor reject or delete decision matrix.png +0 -0
  52. data/doc/surveyor_models.png +0 -0
  53. data/doc/surveyor_models2.png +0 -0
  54. data/doc/surveyor_timestamp_schema.json +9 -0
  55. data/features/ajax_submissions.feature +140 -0
  56. data/features/export_to_json.feature +344 -0
  57. data/features/internationalization.feature +121 -0
  58. data/features/no_duplicates.feature +110 -0
  59. data/features/show_survey.feature +71 -0
  60. data/features/step_definitions/parser_steps.rb +145 -0
  61. data/features/step_definitions/surveyor_steps.rb +325 -0
  62. data/features/step_definitions/ui_steps.rb +25 -0
  63. data/features/step_definitions/web_steps.rb +225 -0
  64. data/features/support/REDCapDemoDatabase_DataDictionary.csv +127 -0
  65. data/features/support/database_cleaner.rb +16 -0
  66. data/features/support/env.rb +56 -0
  67. data/features/support/hooks.rb +4 -0
  68. data/features/support/paths.rb +39 -0
  69. data/features/support/redcap_new_headers.csv +1 -0
  70. data/features/support/redcap_siblings.csv +1 -0
  71. data/features/support/redcap_whitespace.csv +1 -0
  72. data/features/support/selectors.rb +39 -0
  73. data/features/support/simultaneous_ajax.rb +101 -0
  74. data/features/support/single_quit_selenium_driver.rb +23 -0
  75. data/features/support/slow_updates.rb +18 -0
  76. data/features/surveyor.feature +895 -0
  77. data/features/surveyor_dependencies.feature +476 -0
  78. data/features/surveyor_parser.feature +504 -0
  79. data/features/z_redcap_parser.feature +62 -0
  80. data/lib/assets/images/surveyor/next.gif +0 -0
  81. data/lib/assets/images/surveyor/prev.gif +0 -0
  82. data/lib/assets/images/surveyor/ui-bg_flat_0_aaaaaa_40x100.png +0 -0
  83. data/lib/assets/images/surveyor/ui-bg_flat_75_ffffff_40x100.png +0 -0
  84. data/lib/assets/images/surveyor/ui-bg_glass_55_fbf9ee_1x400.png +0 -0
  85. data/lib/assets/images/surveyor/ui-bg_glass_65_ffffff_1x400.png +0 -0
  86. data/lib/assets/images/surveyor/ui-bg_glass_75_dadada_1x400.png +0 -0
  87. data/lib/assets/images/surveyor/ui-bg_glass_75_e6e6e6_1x400.png +0 -0
  88. data/lib/assets/images/surveyor/ui-bg_glass_95_fef1ec_1x400.png +0 -0
  89. data/lib/assets/images/surveyor/ui-bg_highlight-soft_75_cccccc_1x100.png +0 -0
  90. data/lib/assets/images/surveyor/ui-icons_222222_256x240.png +0 -0
  91. data/lib/assets/images/surveyor/ui-icons_2e83ff_256x240.png +0 -0
  92. data/lib/assets/images/surveyor/ui-icons_454545_256x240.png +0 -0
  93. data/lib/assets/images/surveyor/ui-icons_888888_256x240.png +0 -0
  94. data/lib/assets/images/surveyor/ui-icons_cd0a0a_256x240.png +0 -0
  95. data/lib/assets/javascripts/surveyor/jquery-1.9.0.js +9555 -0
  96. data/lib/assets/javascripts/surveyor/jquery-ui-1.10.0.custom.js +14850 -0
  97. data/lib/assets/javascripts/surveyor/jquery-ui-timepicker-addon.js +1919 -0
  98. data/lib/assets/javascripts/surveyor/jquery.maskedinput.js +338 -0
  99. data/lib/assets/javascripts/surveyor/jquery.selectToUISlider.js +240 -0
  100. data/lib/assets/javascripts/surveyor/jquery.surveyor.js +154 -0
  101. data/lib/assets/stylesheets/surveyor.sass +132 -0
  102. data/lib/assets/stylesheets/surveyor/jquery-ui-1.10.0.custom.css +1174 -0
  103. data/lib/assets/stylesheets/surveyor/jquery-ui-timepicker-addon.css +11 -0
  104. data/lib/assets/stylesheets/surveyor/reset.css +48 -0
  105. data/lib/assets/stylesheets/surveyor/results.css +125 -0
  106. data/lib/assets/stylesheets/surveyor/ui.slider.extras.css +110 -0
  107. data/lib/generators/surveyor/custom_generator.rb +18 -0
  108. data/lib/generators/surveyor/install_generator.rb +101 -0
  109. data/lib/generators/surveyor/templates/app/assets/javascripts/surveyor_all.js +6 -0
  110. data/lib/generators/surveyor/templates/app/assets/stylesheets/surveyor_all.css +9 -0
  111. data/lib/generators/surveyor/templates/app/controllers/surveyor_controller.rb +40 -0
  112. data/lib/generators/surveyor/templates/app/views/layouts/surveyor_custom.html.erb +13 -0
  113. data/lib/generators/surveyor/templates/config/locales/surveyor_en.yml +19 -0
  114. data/lib/generators/surveyor/templates/config/locales/surveyor_es.yml +19 -0
  115. data/lib/generators/surveyor/templates/config/locales/surveyor_he.yml +19 -0
  116. data/lib/generators/surveyor/templates/config/locales/surveyor_ko.yml +19 -0
  117. data/lib/generators/surveyor/templates/db/migrate/add_api_id_to_question_groups.rb +10 -0
  118. data/lib/generators/surveyor/templates/db/migrate/add_api_ids.rb +14 -0
  119. data/lib/generators/surveyor/templates/db/migrate/add_api_ids_to_response_sets_and_responses.rb +12 -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 +280 -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.rb +13 -0
  158. data/lib/surveyor/acts_as_response.rb +17 -0
  159. data/lib/surveyor/common.rb +59 -0
  160. data/lib/surveyor/engine.rb +10 -0
  161. data/lib/surveyor/helpers/asset_pipeline.rb +18 -0
  162. data/lib/surveyor/helpers/formtastic_custom_input.rb +13 -0
  163. data/lib/surveyor/helpers/surveyor_helper_methods.rb +103 -0
  164. data/lib/surveyor/models/answer_methods.rb +83 -0
  165. data/lib/surveyor/models/dependency_condition_methods.rb +69 -0
  166. data/lib/surveyor/models/dependency_methods.rb +57 -0
  167. data/lib/surveyor/models/question_group_methods.rb +58 -0
  168. data/lib/surveyor/models/question_methods.rb +112 -0
  169. data/lib/surveyor/models/response_methods.rb +126 -0
  170. data/lib/surveyor/models/response_set_methods.rb +188 -0
  171. data/lib/surveyor/models/survey_methods.rb +100 -0
  172. data/lib/surveyor/models/survey_section_methods.rb +53 -0
  173. data/lib/surveyor/models/survey_translation_methods.rb +30 -0
  174. data/lib/surveyor/models/validation_condition_methods.rb +54 -0
  175. data/lib/surveyor/models/validation_methods.rb +45 -0
  176. data/lib/surveyor/mustache_context.rb +11 -0
  177. data/lib/surveyor/parser.rb +427 -0
  178. data/lib/surveyor/redcap_parser.rb +288 -0
  179. data/lib/surveyor/surveyor_controller_methods.rb +236 -0
  180. data/lib/surveyor/unparser.rb +147 -0
  181. data/lib/surveyor/version.rb +3 -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 +311 -0
  185. data/spec/factories.rb +166 -0
  186. data/spec/helpers/formtastic_custom_input_spec.rb +15 -0
  187. data/spec/helpers/surveyor_helper_spec.rb +117 -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 +174 -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 +206 -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 +53 -0
  212. metadata +601 -0
@@ -0,0 +1,12 @@
1
+ = div_for @section, :class => @section.custom_class do
2
+ %span.title= @section.translation(I18n.locale)[:title]
3
+ - qs ||= []
4
+ - (questions = @section.questions).each_with_index do |q, i|
5
+ - if q.part_of_group?
6
+ - qs << q # gather up the group questions
7
+ - if (i+1 >= questions.size) or (q.question_group_id != questions[i+1].question_group_id)
8
+ - # this is the last question of the section, or the group
9
+ = render q.question_group.custom_renderer || "/partials/question_group", :g => q.question_group, :qs => qs, :f => f
10
+ - qs = []
11
+ - else # gather up the group questions
12
+ = render q.custom_renderer || "/partials/question", :q => q, :f => f
@@ -0,0 +1,12 @@
1
+ .surveyor_menu
2
+ - if !@survey.translations.empty?
3
+ = hidden_field_tag "current_section", @section.id
4
+ .surveyor_language_selection
5
+ = label_tag "locale", t('surveyor.language')
6
+ %select{:id=>"locale", :name=>"new_locale"}
7
+ = options_for_select(@survey.translations.map(&:locale),I18n.locale)
8
+
9
+ = t('surveyor.sections')
10
+ %ul
11
+ - @sections.each do |s|
12
+ %li{:class => ("active" if s == @section)}= menu_button_for(s)
@@ -0,0 +1,24 @@
1
+ #surveyor
2
+ - unless (types = flash.keys.select{|k| [:notice, :error, :warning].include?(k)}).blank?
3
+ .surveyor_flash
4
+ = flash_messages(types)
5
+ .close
6
+ = semantic_form_for(@response_set, :as => :r, :url => surveyor.update_my_survey_path, :html => {:method => :put, :id => "survey_form", :class => @survey.custom_class}) do |f|
7
+
8
+ = hidden_field_tag :surveyor_javascript_enabled, false
9
+
10
+ = render 'partials/section_menu' # unless @sections.size < 3
11
+ .survey_title= @survey.translation(I18n.locale)[:title]
12
+ .previous_section= previous_section
13
+ = render 'partials/dependents' unless @dependents.empty?
14
+ - if false #@response_set.no_responses_for_section?(@section) # cache if response_set has no responses for current section
15
+ = cache("section_#{@section.id}"){ render "/partials/section", :f => f }
16
+ - else # no cache
17
+ = render "/partials/section", :f => f
18
+ .next_section= next_section
19
+ %br
20
+
21
+ :javascript
22
+ $(document).ready(function() {
23
+ $("input#surveyor_javascript_enabled").val(true);
24
+ });
@@ -0,0 +1,85 @@
1
+ object @survey
2
+ attribute :title
3
+ attribute :api_id => :uuid
4
+ node(:description, :if => lambda {|s| !s.description.blank? }){|s| s.description }
5
+ node(:reference_identifier, :if => lambda {|s| !s.reference_identifier.blank? }){|s| s.reference_identifier }
6
+
7
+ child :sections => :sections do
8
+ attributes :title, :display_order
9
+ node(:description, :if => lambda {|s| !s.description.blank? }){|s| s.description }
10
+ node(:reference_identifier, :if => lambda {|s| !s.reference_identifier.blank? }){|s| s.reference_identifier }
11
+
12
+ child :questions_and_groups => :questions_and_groups do
13
+ # both questions and question_groups have uuid, text, help_text, reference_identifier, and type
14
+ attribute :api_id => :uuid
15
+ node(:text, :if => lambda { |q| q.is_a?(Question)}){ |q| q.split(q.text, :pre) }
16
+ node(:text, :if => lambda { |q| q.is_a?(QuestionGroup)}){ |q| q.text }
17
+ node(:help_text, :if => lambda { |q| !q.help_text.blank? }){ |q| q.help_text }
18
+ node(:reference_identifier, :if => lambda { |q| !q.reference_identifier.blank? }){ |q| q.reference_identifier }
19
+ node(:data_export_identifier, :if => lambda { |q| !q.data_export_identifier.blank? }){ |q| q.data_export_identifier }
20
+ node(:type, :if => lambda { |q| q.display_type != "default" }){ |q| q.display_type }
21
+
22
+ # only questions
23
+ node(:pick, :if => lambda { |q| q.is_a?(Question) && q.pick != "none" }){ |q| q.pick }
24
+ node(:post_text, :if => lambda { |q| q.is_a?(Question) && !q.split(q.text, :post).blank? }){ |q| q.split(q.text, :post) }
25
+
26
+ child :answers, :if => lambda { |q| q.is_a?(Question) && !q.answers.blank? } do
27
+ attribute :api_id => :uuid
28
+ node(:help_text, :if => lambda { |a| !a.help_text.blank? }){ |a| a.help_text }
29
+ node(:exclusive, :if => lambda { |a| a.is_exclusive }){ |a| a.is_exclusive }
30
+ node(:text){ |a| a.split(a.text, :pre) }
31
+ node(:post_text, :if => lambda { |a| !a.split(a.text, :post).blank? }){ |a| a.split(a.text, :post) }
32
+ node(:type, :if => lambda { |a| a.response_class != "answer" }){ |a| a.response_class }
33
+ node(:reference_identifier, :if => lambda { |a| !a.reference_identifier.blank? }){ |a| a.reference_identifier }
34
+ node(:data_export_identifier, :if => lambda { |a| !a.data_export_identifier.blank? }){ |a| a.data_export_identifier }
35
+ node(:input_mask, :if => lambda { |a| !a.input_mask.blank? }){ |a| a.input_mask }
36
+ node(:input_mask_placeholder, :if => lambda { |a| !a.input_mask_placeholder.blank? }){ |a| a.input_mask_placeholder }
37
+ end
38
+
39
+ # both questions and question_groups have dependencies
40
+ child :dependency, :if => lambda { |q| q.dependency } do
41
+ attributes :rule
42
+ child :dependency_conditions => :conditions do
43
+ attributes :rule_key, :operator
44
+ node(:question){ |d| d.question.api_id }
45
+ node(:answer, :if => lambda { |d| d.answer }){ |d| d.answer.api_id }
46
+ node(:value, :if => lambda { |d| d.answer && d.answer.response_class != "answer" && d.as(d.answer.response_class) }){ |d| d.as(d.answer.response_class)}
47
+ end
48
+ end
49
+
50
+ child(:questions, :if => lambda{|x| x.is_a?(QuestionGroup)}) do
51
+ attributes :api_id => :uuid
52
+ node(:text){ |q| q.split(q.text, :pre) }
53
+ node(:post_text, :if => lambda { |q| !q.split(q.text, :post).blank? }){ |q| q.split(q.text, :post) }
54
+ node(:help_text, :if => lambda { |q| !q.help_text.blank? }){ |q| q.help_text }
55
+ node(:reference_identifier, :if => lambda { |q| !q.reference_identifier.blank? }){ |q| q.reference_identifier }
56
+ node(:data_export_identifier, :if => lambda { |q| !q.data_export_identifier.blank? }){ |q| q.data_export_identifier }
57
+ node(:type, :if => lambda { |q| q.display_type != "default" }){ |q| q.display_type }
58
+ node(:pick, :if => lambda { |q| q.pick != "none" }){ |q| q.pick }
59
+
60
+ child :answers, :if => lambda { |q| !q.answers.blank? } do
61
+ attributes :api_id => :uuid
62
+ node(:help_text, :if => lambda { |a| !a.help_text.blank? }){ |a| a.help_text }
63
+ node(:is_exclusive, :if => lambda { |a| a.is_exclusive }){ |a| a.is_exclusive }
64
+ node(:text){ |a| a.split(a.text, :pre) }
65
+ node(:post_text, :if => lambda { |a| !a.split(a.text, :post).blank? }){ |a| a.split(a.text, :post) }
66
+ node(:type, :if => lambda { |a| a.response_class != "answer" }){ |a| a.response_class }
67
+ node(:reference_identifier, :if => lambda { |a| !a.reference_identifier.blank? }){ |a| a.reference_identifier }
68
+ node(:data_export_identifier, :if => lambda { |a| !a.data_export_identifier.blank? }){ |a| a.data_export_identifier }
69
+ node(:input_mask, :if => lambda { |a| !a.input_mask.blank? }){ |a| a.input_mask }
70
+ node(:input_mask_placeholder, :if => lambda { |a| !a.input_mask_placeholder.blank? }){ |a| a.input_mask_placeholder }
71
+ end
72
+
73
+ child :dependency, :if => lambda { |q| q.dependency } do
74
+ attributes :rule
75
+ child :dependency_conditions => :conditions do
76
+ attributes :rule_key, :operator
77
+ node(:question){ |d| d.question.api_id }
78
+ node(:answer, :if => lambda { |d| d.answer }){ |d| d.answer.api_id }
79
+ node(:value, :if => lambda { |d| d.answer && d.answer.response_class != "answer" && d.as(d.answer.response_class) }){ |d| d.as(d.answer.response_class)}
80
+ end
81
+ end
82
+ end
83
+ end
84
+
85
+ end
@@ -0,0 +1,24 @@
1
+ #surveyor
2
+ - unless (types = flash.keys.select{|k| [:notice, :error, :warning].include?(k)}).blank?
3
+ .surveyor_flash
4
+ = flash_messages(types)
5
+ .close
6
+ .survey_title= t('surveyor.take_these_surveys')
7
+ %br
8
+ #survey_list
9
+ %ul
10
+ - @surveys_by_access_code.each do |access_code, surveys|
11
+ %li
12
+ = form_tag surveyor.take_survey_path(:survey_code => access_code) do
13
+ = hidden_field_tag :surveyor_javascript_enabled, false
14
+ = surveys.first.translation(I18n.locale)[:title]
15
+ &nbsp;
16
+ = label_tag :survey_version, 'version:'
17
+ = select_tag(:survey_version, options_for_select([["-- Current version --", ""]] + (surveys.map(&:survey_version) || [])))
18
+ &nbsp;
19
+ = submit_tag( t('surveyor.take_it'), :default => "Take it" )
20
+
21
+ :javascript
22
+ $(document).ready(function() {
23
+ $("input#surveyor_javascript_enabled").val(true);
24
+ });
@@ -0,0 +1,74 @@
1
+ #surveyor
2
+ - unless (types = flash.keys.select{|k| [:notice, :error, :warning].include?(k)}).blank?
3
+ .surveyor_flash
4
+ = flash_messages(types)
5
+ .close
6
+ = semantic_form_for(@response_set, :as => :r, :url => surveyor.update_my_survey_path, :html => {:id => "survey_form", :class => @survey.custom_class}) do |f|
7
+ .survey_title= @survey.title
8
+ - @survey.sections.each do |section|
9
+ = div_for section do
10
+ %span.title= strip_tags(section.title)
11
+ - group_questions = []
12
+ - answered_questions = []
13
+ - label = nil
14
+ - answered_count = 0
15
+ - (questions = section.questions).each_with_index do |q, i|
16
+ - if q.part_of_group?
17
+ - group_questions << q # gather up the group questions
18
+ - unless @response_set.responses.where( :question_id => q.id).empty?
19
+ - answered_questions << q
20
+ - answered_count = answered_count + 1
21
+ - if (i+1 >= questions.size) or (q.question_group_id != questions[i+1].question_group_id) # this is the last question of the section, or the group
22
+ - if answered_questions.length > 0 # there are answered questions in this section or group
23
+ - g = q.question_group
24
+ - renderer = g.renderer
25
+
26
+ - unless label.blank?
27
+ = render q.custom_renderer || "/partials/question", :q => label, :f => f, :disableFlag => true
28
+ - label = nil
29
+ = f.inputs g.text_for(@render_context, I18n.locale), :id => "g_#{g.id}", :class => "g_#{renderer} #{g.css_class(@response_set)}" do
30
+ %li.help= g.help_text
31
+ - case renderer
32
+ - when :grid
33
+ %li
34
+ %table
35
+ %col.pre
36
+ - group_questions.first.answers.each do |a|
37
+ %col{:class => cycle("odd", "even")}
38
+ %col.post
39
+ %tbody
40
+ - group_questions.each_slice(10) do |ten_questions| # header row every 10
41
+ %tr
42
+ %th &nbsp;
43
+ - ten_questions.first.answers.each do |a|
44
+ %th
45
+ = a.text_for(nil, @render_context, I18n.locale)
46
+ %span.help= a.help_text_for(@render_context, I18n.locale)
47
+ %th &nbsp;
48
+ - ten_questions.each_with_index do |q, j|
49
+ %tr{:id => "q_#{q.id}", :class => "q_#{renderer} #{q.css_class(@response_set)}"}
50
+ %th
51
+ = q.text_for(:pre, @render_context, I18n.locale)
52
+ = q.help_text_for(@render_context, I18n.locale)
53
+ - q.answers.each do |a|
54
+ %td= render(a.custom_renderer || '/partials/answer', :g => g, :q => q, :a => a, :f => f, :disableFlag => true) unless q.display_type == "label"
55
+ %th= q.text_for(:post, @render_context, I18n.locale)
56
+ - when :repeater
57
+ - (@response_set.count_group_responses(group_questions) + 1).times do |rg|
58
+ %li
59
+ - group_questions.each do |q|
60
+ = render q.custom_renderer || "/partials/question", :g => g, :rg => rg, :q => q, :f => f, :disableFlag => true
61
+ - else # :inline
62
+ - answered_questions.each do |q|
63
+ = render q.custom_renderer || "/partials/question", :g => g, :q => q, :f => f, :disableFlag => true
64
+ - group_questions = []
65
+ - answered_questions = []
66
+ - else
67
+ - if q.display_type == 'label'
68
+ = render q.custom_renderer || "/partials/question", :q => q, :f => f, :disableFlag => true
69
+ - elsif !(@response_set.responses.where(:question_id => q.id).empty?)
70
+ = render q.custom_renderer || "/partials/question", :q => q, :f => f, :disableFlag => true
71
+ - answered_count = answered_count + 1
72
+ - if (i+1 >= questions.size) and (answered_count == 0)
73
+ #{"--- No data ---"}
74
+
@@ -0,0 +1,15 @@
1
+ object @response_set
2
+ attribute :api_id => :uuid
3
+ attribute :created_at
4
+ attribute :completed_at
5
+ node(:survey_id){|rs| rs.survey.api_id }
6
+
7
+ child (@response_set.responses || []) => :responses do
8
+ attribute :api_id => :uuid
9
+ attribute :created_at
10
+ attribute :updated_at => :modified_at
11
+ attribute :response_group
12
+ node(:answer_id){|r| r.answer.api_id }
13
+ node(:question_id){|r| r.question.api_id }
14
+ node(:value, :if => lambda{|r| r.answer.response_class != "answer"}){|r| r.json_value }
15
+ end
@@ -0,0 +1,56 @@
1
+ #!/bin/bash -xe
2
+
3
+ BUNDLER_VERSION=1.3.1
4
+ GEMSET=surveyor
5
+
6
+ if [ -z $CI_RUBY ]; then
7
+ echo "CI_RUBY must be set"
8
+ exit 1
9
+ fi
10
+
11
+ # TMPDIR under the workspace causes gconfd-2 to stop responding and eat all
12
+ # memory when Firefox is running for the Selenium tests. TMPDIR in user home
13
+ # seems to work fine.
14
+ export TMPDIR="${HOME}/tmp/surveyor-ci-${CI_RUBY}"
15
+
16
+ if [ -n "${RAILS_VERSION}" ]; then
17
+ GEMSET="${GEMSET}-${RAILS_VERSION}"
18
+ TMPDIR="${TMPDIR}-${RAILS_VERSION}"
19
+ fi
20
+
21
+ rm -rf "${TMPDIR}"
22
+ mkdir -p "${TMPDIR}"
23
+
24
+ set +xe
25
+ echo "Initializing RVM"
26
+ source ~/.rvm/scripts/rvm
27
+ set -xe
28
+
29
+ # On the overnight build, reinstall all gems
30
+ if [ `date +%H` -lt 5 ]; then
31
+ set +xe
32
+ echo "Purging gemset to verify that all deps can still be installed"
33
+ rvm --force $CI_RUBY gemset delete $GEMSET
34
+ set -xe
35
+ fi
36
+
37
+ RVM_CONFIG="${CI_RUBY}@${GEMSET}"
38
+ set +xe
39
+ echo "Switching to ${RVM_CONFIG}"
40
+ rvm use $RVM_CONFIG
41
+ set -xe
42
+
43
+ which ruby
44
+ ruby -v
45
+
46
+ set +e
47
+ gem list -i bundler -v $BUNDLER_VERSION
48
+ if [ $? -ne 0 ]; then
49
+ set -e
50
+ gem install bundler -v $BUNDLER_VERSION
51
+ fi
52
+ set -e
53
+
54
+ bundle _${BUNDLER_VERSION}_ update
55
+
56
+ bundle _${BUNDLER_VERSION}_ exec rake ci:all --trace
@@ -0,0 +1,8 @@
1
+ Surveyor::Engine.routes.draw do
2
+ match '/', :to => 'surveyor#new', :as => 'available_surveys', :via => :get
3
+ match '/:survey_code', :to => 'surveyor#create', :as => 'take_survey', :via => :post
4
+ match '/:survey_code', :to => 'surveyor#export', :as => 'export_survey', :via => :get
5
+ match '/:survey_code/:response_set_code', :to => 'surveyor#show', :as => 'view_my_survey', :via => :get
6
+ match '/:survey_code/:response_set_code/take', :to => 'surveyor#edit', :as => 'edit_my_survey', :via => :get
7
+ match '/:survey_code/:response_set_code', :to => 'surveyor#update', :as => 'update_my_survey', :via => :put
8
+ end
@@ -0,0 +1,10 @@
1
+ <%
2
+ rerun = File.file?('rerun.txt') ? IO.read('rerun.txt') : ""
3
+ rerun_opts = rerun.to_s.strip.empty? ? "--format #{ENV['CUCUMBER_FORMAT'] || 'progress'} features" : "--format #{ENV['CUCUMBER_FORMAT'] || 'pretty'} #{rerun}"
4
+ std_opts = "--format #{ENV['CUCUMBER_FORMAT'] || 'pretty'} --strict --tags ~@wip"
5
+ %>
6
+ default: <%= std_opts %> features
7
+ wip: --tags @wip --wip features
8
+ rerun: <%= rerun_opts %> --format rerun --out rerun.txt --strict --tags ~@wip
9
+ ci: --tags ~@wip --format html --out reports/cucumber.html --format junit --out reports/cucumber-xml --format pretty --strict features
10
+ ci_wip: --wip --tags @wip --format html --out reports/cucumber_wip.html --format pretty features
@@ -0,0 +1,34 @@
1
+ # JSON Representations
2
+
3
+ This document describes the JSON representations for the ResponseSet and Survey models. The models can be serialized
4
+ by calling the `to_json` method.
5
+
6
+ ## ResponseSet
7
+
8
+ An example of the serialized ResponseSet JSON can be found below. The schema will be coming soon.
9
+
10
+ /* ResponseSet JSON */
11
+ {
12
+ "uuid" : "9af6d142-7fac-4ccb-9bca-58a05308a5a7",
13
+ "survey_id" : "94b3d750-fb63-4540-a1e2-dd7f88be9b4f",
14
+ "created_at" : "1970-02-04T05:15:30Z",
15
+ "completed_at": "1990-03-06T07:21:42Z"
16
+ "responses": [{
17
+ "uuid" : "07d72796-ebb2-4be2-91b9-68f5a30a0054",
18
+ "answer_id" : "9c788711-8373-44d7-b44b-754c31e596a9",
19
+ "question_id" : "376a501b-c32f-49de-b4d7-e28030a2ea94",
20
+ "value" : "Chimpanzee",
21
+ "created_at" : "1970-02-04T05:15:30Z",
22
+ "modified_at" : "1990-03-06T07:21:42Z"
23
+ },{
24
+ "uuid" : "d0467180-e126-44c0-b112-63bb87f0d869",
25
+ "answer_id" : "86a85d44-9f39-4df9-ae90-da7ff5dbaaf5",
26
+ "question_id" : "6146c103-4a8b-4869-836b-415b8666babe",
27
+ "created_at" : "1970-02-04T05:16:30Z",
28
+ "modified_at" : "1990-03-06T07:22:42Z"
29
+ }]
30
+ }
31
+
32
+ ## Survey
33
+
34
+ Example representation and schema coming soon.
@@ -0,0 +1,7 @@
1
+ {
2
+ "$schema": "http://json-schema.org/draft-03/schema#",
3
+ "description": "Public UUID of a Surveyor entity",
4
+ "maxLength": 36,
5
+ "required": true,
6
+ "type": "string"
7
+ }
Binary file
@@ -0,0 +1,54 @@
1
+ {
2
+ "$schema": "http://json-schema.org/draft-03/schema#",
3
+ "description": "Response set",
4
+ "properties": {
5
+ "completed_at": {
6
+ "$ref": "http://download.nubic.northwestern.edu/surveyor/surveyor_timestamp_schema.json#"
7
+ },
8
+ "created_at": {
9
+ "$ref": "http://download.nubic.northwestern.edu/surveyor/surveyor_timestamp_schema.json#"
10
+ },
11
+ "responses": {
12
+ "description": "Responses in the response set",
13
+ "items": {
14
+ "properties": {
15
+ "answer_id": {
16
+ "$ref": "http://download.nubic.northwestern.edu/surveyor/api_id_schema.json#"
17
+ },
18
+ "created_at": {
19
+ "$ref": "http://download.nubic.northwestern.edu/surveyor/surveyor_timestamp_schema.json#"
20
+ },
21
+ "question_id": {
22
+ "$ref": "http://download.nubic.northwestern.edu/surveyor/api_id_schema.json#"
23
+ },
24
+ "response_group": {
25
+ "type": [
26
+ "string",
27
+ "null"
28
+ ]
29
+ },
30
+ "updated_at": {
31
+ "$ref": "http://download.nubic.northwestern.edu/surveyor/surveyor_timestamp_schema.json#"
32
+ },
33
+ "uuid": {
34
+ "$ref": "http://download.nubic.northwestern.edu/surveyor/api_id_schema.json#"
35
+ },
36
+ "value": {
37
+ "type": [
38
+ "string",
39
+ "number",
40
+ "null"
41
+ ]
42
+ }
43
+ }
44
+ },
45
+ "type": "array"
46
+ },
47
+ "survey_id": {
48
+ "$ref": "http://download.nubic.northwestern.edu/surveyor/api_id_schema.json#"
49
+ },
50
+ "uuid": {
51
+ "$ref": "http://download.nubic.northwestern.edu/surveyor/api_id_schema.json#"
52
+ }
53
+ }
54
+ }
Binary file
Binary file
@@ -0,0 +1,9 @@
1
+ {
2
+ "$schema": "http://json-schema.org/draft-03/schema#",
3
+ "description": "Timestamp on a Surveyor entity",
4
+ "format": "\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(?:Z|[+-]\\d{2}:\\d{2})",
5
+ "type": [
6
+ "string",
7
+ "null"
8
+ ]
9
+ }