surveyor_gui 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (283) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +44 -0
  3. data/.travis.yml +17 -0
  4. data/Gemfile +7 -0
  5. data/LICENSE +21 -0
  6. data/MIT-LICENSE +20 -0
  7. data/README.md +159 -0
  8. data/Rakefile +66 -0
  9. data/app/controllers/answers_controller.rb +3 -0
  10. data/app/controllers/application_controller.rb +3 -0
  11. data/app/controllers/dependencys_controller.rb +286 -0
  12. data/app/controllers/question_groups_controller.rb +84 -0
  13. data/app/controllers/questions_controller.rb +187 -0
  14. data/app/controllers/survey_sections_controller.rb +80 -0
  15. data/app/controllers/surveyforms_controller.rb +4 -0
  16. data/app/controllers/surveyor_controller.rb +89 -0
  17. data/app/controllers/surveyor_gui/reports_controller.rb +339 -0
  18. data/app/controllers/surveyor_gui/responses_controller.rb +39 -0
  19. data/app/controllers/surveyor_gui/survey_controller.rb +16 -0
  20. data/app/facades/report_formatter.rb +44 -0
  21. data/app/facades/report_preview_wrapper.rb +11 -0
  22. data/app/facades/report_response_generator.rb +147 -0
  23. data/app/helpers/application_helper.rb +2 -0
  24. data/app/helpers/dependency_helper.rb +5 -0
  25. data/app/helpers/question_helper.rb +22 -0
  26. data/app/helpers/surveyform_helper.rb +179 -0
  27. data/app/helpers/surveyor_gui/report_helper.rb +19 -0
  28. data/app/helpers/surveyor_helper.rb +4 -0
  29. data/app/inputs/currency_input.rb +5 -0
  30. data/app/inputs/date_picker_input.rb +7 -0
  31. data/app/inputs/datetime_picker_input.rb +5 -0
  32. data/app/inputs/percent_input.rb +5 -0
  33. data/app/inputs/time_picker_input.rb +5 -0
  34. data/app/mailers/.gitkeep +0 -0
  35. data/app/models/.gitkeep +0 -0
  36. data/app/models/answer.rb +4 -0
  37. data/app/models/column.rb +3 -0
  38. data/app/models/dependency.rb +4 -0
  39. data/app/models/dependency_condition.rb +4 -0
  40. data/app/models/permitted_params_decorator.rb +80 -0
  41. data/app/models/question.rb +4 -0
  42. data/app/models/question_group.rb +4 -0
  43. data/app/models/question_type.rb +7 -0
  44. data/app/models/response.rb +4 -0
  45. data/app/models/response_set.rb +4 -0
  46. data/app/models/row.rb +3 -0
  47. data/app/models/survey.rb +4 -0
  48. data/app/models/survey_section.rb +4 -0
  49. data/app/models/surveyform.rb +103 -0
  50. data/app/uploaders/blob_uploader.rb +48 -0
  51. data/app/views/dependencys/_column.html.erb +1 -0
  52. data/app/views/dependencys/_dependency.html.erb +22 -0
  53. data/app/views/dependencys/_dependency_condition_fields.html.erb +48 -0
  54. data/app/views/dependencys/_form.html.erb +20 -0
  55. data/app/views/dependencys/blank.html.erb +0 -0
  56. data/app/views/dependencys/edit.html.erb +1 -0
  57. data/app/views/dependencys/new.html.erb +1 -0
  58. data/app/views/layouts/application.html.erb +14 -0
  59. data/app/views/layouts/surveyor_gui_blank.html.erb +12 -0
  60. data/app/views/layouts/surveyor_gui_default.html.erb +16 -0
  61. data/app/views/layouts/surveyor_modified.html.erb +14 -0
  62. data/app/views/partials/_answer.html.haml +33 -0
  63. data/app/views/partials/_question.html.haml +33 -0
  64. data/app/views/partials/_question_group.html.haml +73 -0
  65. data/app/views/partials/_section.html.haml +13 -0
  66. data/app/views/question_groups/_form.html.erb +56 -0
  67. data/app/views/question_groups/_group_inline_field.html.erb +21 -0
  68. data/app/views/question_groups/_group_inline_fields.html.erb +25 -0
  69. data/app/views/question_groups/blank.html.erb +0 -0
  70. data/app/views/question_groups/edit.html.erb +1 -0
  71. data/app/views/question_groups/new.html.erb +1 -0
  72. data/app/views/questions/_answer_fields.html.erb +23 -0
  73. data/app/views/questions/_answer_options.html.erb +28 -0
  74. data/app/views/questions/_form.html.erb +65 -0
  75. data/app/views/questions/_grid_dropdown_columns.html.erb +10 -0
  76. data/app/views/questions/_grid_dropdown_fields.html.erb +42 -0
  77. data/app/views/questions/_grid_fields.html.erb +9 -0
  78. data/app/views/questions/_no_picks.html.erb +29 -0
  79. data/app/views/questions/_pick.html +21 -0
  80. data/app/views/questions/_picks.html.erb +12 -0
  81. data/app/views/questions/blank.html.erb +0 -0
  82. data/app/views/questions/edit.html.erb +1 -0
  83. data/app/views/questions/new.html.erb +1 -0
  84. data/app/views/survey_sections/_form.html.erb +13 -0
  85. data/app/views/survey_sections/blank.html.erb +0 -0
  86. data/app/views/survey_sections/edit.html.erb +1 -0
  87. data/app/views/survey_sections/new.html.erb +1 -0
  88. data/app/views/surveyforms/_form.html.erb +50 -0
  89. data/app/views/surveyforms/_question_field.html.erb +148 -0
  90. data/app/views/surveyforms/_question_group.html.erb +116 -0
  91. data/app/views/surveyforms/_question_group_fields.html.erb +3 -0
  92. data/app/views/surveyforms/_question_name_and_number.html.erb +6 -0
  93. data/app/views/surveyforms/_question_section.html.erb +15 -0
  94. data/app/views/surveyforms/_question_wrapper.html.erb +109 -0
  95. data/app/views/surveyforms/_survey_section_fields.html.erb +138 -0
  96. data/app/views/surveyforms/clone_survey.html.erb +13 -0
  97. data/app/views/surveyforms/edit.html.erb +5 -0
  98. data/app/views/surveyforms/index.html.erb +40 -0
  99. data/app/views/surveyforms/new.html.erb +1 -0
  100. data/app/views/surveyforms/show.html.erb +5 -0
  101. data/app/views/surveyor_gui/reports/_graphs.html.haml +21 -0
  102. data/app/views/surveyor_gui/reports/_grid.html.haml +42 -0
  103. data/app/views/surveyor_gui/reports/_grid_dropdown.html.haml +56 -0
  104. data/app/views/surveyor_gui/reports/_repeater.html.haml +28 -0
  105. data/app/views/surveyor_gui/reports/_show_report.html.haml +33 -0
  106. data/app/views/surveyor_gui/reports/_single_question.html.haml +70 -0
  107. data/app/views/surveyor_gui/reports/show.html.erb +14 -0
  108. data/app/views/surveyor_gui/responses/_grid.html.haml +20 -0
  109. data/app/views/surveyor_gui/responses/_grid_dropdown.html.haml +20 -0
  110. data/app/views/surveyor_gui/responses/_repeater.html.haml +22 -0
  111. data/app/views/surveyor_gui/responses/_survey_results.html.haml +40 -0
  112. data/app/views/surveyor_gui/responses/index.html.haml +24 -0
  113. data/app/views/surveyor_gui/responses/show.html.haml +42 -0
  114. data/app/views/surveyor_gui/shared/_grid_comments.html.haml +10 -0
  115. data/app/views/surveyor_gui/shared/_new_line.html.haml +2 -0
  116. data/app/views/surveyor_gui/shared/_pick_comments.html.haml +15 -0
  117. data/app/views/surveyor_gui/shared/_question_number.html.haml +9 -0
  118. data/app/views/surveyor_gui/shared/_report_data.html.haml +24 -0
  119. data/app/views/surveyor_gui/shared/_stars_report_data.html.haml +14 -0
  120. data/config.ru +4 -0
  121. data/config/environment.rb +0 -0
  122. data/config/routes.rb +71 -0
  123. data/db/migrate/20140307204049_add_template_to_surveys.rb +5 -0
  124. data/db/migrate/20140307235607_add_test_data_to_response_sets.rb +5 -0
  125. data/db/migrate/20140308171947_add_original_choice_to_answers.rb +5 -0
  126. data/db/migrate/20140308172118_add_blob_to_responses.rb +5 -0
  127. data/db/migrate/20140308172417_add_modifiable_to_survey_section.rb +5 -0
  128. data/db/migrate/20140308174532_add_modifiable_to_question.rb +5 -0
  129. data/db/migrate/20140308175305_add_dynamically_generate_to_questions.rb +5 -0
  130. data/db/migrate/20140311032923_add_dummy_blob_to_questions.rb +5 -0
  131. data/db/migrate/20140311160609_add_dynamic_source_to_questions.rb +5 -0
  132. data/db/migrate/20140311161714_add_report_code_to_questions.rb +5 -0
  133. data/db/migrate/20140530181134_add_is_comment_to_questions.rb +5 -0
  134. data/db/migrate/20140531012006_add_is_comment_to_answers.rb +5 -0
  135. data/db/migrate/20140531225529_create_rows.rb +9 -0
  136. data/db/migrate/20140601011151_create_columns.rb +11 -0
  137. data/db/migrate/20140602030330_add_column_id_to_answers.rb +5 -0
  138. data/db/migrate/20140603155606_add_column_id_to_responses.rb +5 -0
  139. data/db/migrate/20140606023527_add_column_id_to_dependency_conditions.rb +5 -0
  140. data/db/migrate/20140815165307_add_user_id_to_survey.rb +5 -0
  141. data/lib/assets/.gitkeep +0 -0
  142. data/lib/assets/images/addicon.png +0 -0
  143. data/lib/assets/images/datepicker.gif +0 -0
  144. data/lib/assets/images/delete.gif +0 -0
  145. data/lib/assets/images/delete.png +0 -0
  146. data/lib/assets/images/images/border.png +0 -0
  147. data/lib/assets/images/images/controls.png +0 -0
  148. data/lib/assets/images/images/loading.gif +0 -0
  149. data/lib/assets/images/images/loading_background.png +0 -0
  150. data/lib/assets/images/images/overlay.png +0 -0
  151. data/lib/assets/images/rails.png +0 -0
  152. data/lib/assets/images/star.gif +0 -0
  153. data/lib/assets/javascripts/.gitkeep +0 -0
  154. data/lib/assets/javascripts/surveyor_gui/jquery.MetaData.js +121 -0
  155. data/lib/assets/javascripts/surveyor_gui/jquery.blockUI.js +619 -0
  156. data/lib/assets/javascripts/surveyor_gui/jquery.rating.js +377 -0
  157. data/lib/assets/javascripts/surveyor_gui/jquery.validate.js +1188 -0
  158. data/lib/assets/javascripts/surveyor_gui/surveyor_add_ons.js +10 -0
  159. data/lib/assets/javascripts/surveyor_gui/surveyor_gui.js +1417 -0
  160. data/lib/assets/stylesheets/.gitkeep +0 -0
  161. data/lib/assets/stylesheets/surveyor_gui/jquery.rating.css +12 -0
  162. data/lib/assets/stylesheets/surveyor_gui/surveyor_add_ons.css +3 -0
  163. data/lib/assets/stylesheets/surveyor_gui/surveyor_gui.sass +650 -0
  164. data/lib/enumerable_extenders.rb +31 -0
  165. data/lib/generators/surveyor_gui/install_generator.rb +57 -0
  166. data/lib/generators/surveyor_gui/templates/app/assets/javascripts/surveyor_add_ons.js +2 -0
  167. data/lib/generators/surveyor_gui/templates/app/assets/javascripts/surveyor_gui_all.js +24 -0
  168. data/lib/generators/surveyor_gui/templates/app/assets/stylesheets/surveyor_add_ons.css.sass +1 -0
  169. data/lib/generators/surveyor_gui/templates/app/assets/stylesheets/surveyor_gui_all.css.sass +8 -0
  170. data/lib/generators/surveyor_gui/templates/app/helpers/surveyor_helper.rb +4 -0
  171. data/lib/generators/surveyor_gui/templates/app/models/response_set_user.rb +13 -0
  172. data/lib/generators/surveyor_gui/templates/app/views/layouts/surveyor_gui_default.html.erb +16 -0
  173. data/lib/generators/surveyor_gui/templates/config/initializers/simple_form.rb +140 -0
  174. data/lib/generators/surveyor_gui/templates/config/locales/en.yml +5 -0
  175. data/lib/surveyor_gui.rb +17 -0
  176. data/lib/surveyor_gui/engine.rb +30 -0
  177. data/lib/surveyor_gui/helpers/surveyor_helper_methods.rb +19 -0
  178. data/lib/surveyor_gui/models/answer_methods.rb +24 -0
  179. data/lib/surveyor_gui/models/column_methods.rb +43 -0
  180. data/lib/surveyor_gui/models/dependency_condition_methods.rb +53 -0
  181. data/lib/surveyor_gui/models/dependency_methods.rb +83 -0
  182. data/lib/surveyor_gui/models/question_and_group_shared_methods.rb +11 -0
  183. data/lib/surveyor_gui/models/question_group_methods.rb +55 -0
  184. data/lib/surveyor_gui/models/question_methods.rb +435 -0
  185. data/lib/surveyor_gui/models/question_type_methods.rb +493 -0
  186. data/lib/surveyor_gui/models/response_methods.rb +67 -0
  187. data/lib/surveyor_gui/models/response_set_methods.rb +54 -0
  188. data/lib/surveyor_gui/models/row_methods.rb +11 -0
  189. data/lib/surveyor_gui/models/survey_methods.rb +32 -0
  190. data/lib/surveyor_gui/models/survey_section_methods.rb +32 -0
  191. data/lib/surveyor_gui/surveyforms_controller_methods.rb +258 -0
  192. data/lib/surveyor_gui/version.rb +3 -0
  193. data/lib/tasks/.gitkeep +0 -0
  194. data/lib/tasks/surveyor_gui_tasks.rake +4 -0
  195. data/lib/templates/erb/scaffold/_form.html.erb +13 -0
  196. data/spec/controllers/surveyforms_controller_spec.rb +361 -0
  197. data/spec/controllers/surveyor_controller_spec.rb +303 -0
  198. data/spec/factories.rb +181 -0
  199. data/spec/features/create_survey_spec.rb +418 -0
  200. data/spec/features/dependencies_spec.rb +61 -0
  201. data/spec/features/rearrange_survey_spec.rb +118 -0
  202. data/spec/features/ui_spec.rb +469 -0
  203. data/spec/fixtures/REDCapDemoDatabase_DataDictionary.csv +127 -0
  204. data/spec/fixtures/chinese_survey.rb +14 -0
  205. data/spec/fixtures/everything.rb +215 -0
  206. data/spec/fixtures/favorites-ish.rb +22 -0
  207. data/spec/fixtures/favorites.rb +22 -0
  208. data/spec/fixtures/feelings.rb +38 -0
  209. data/spec/fixtures/lifestyle.rb +55 -0
  210. data/spec/fixtures/numbers.rb +21 -0
  211. data/spec/fixtures/redcap_new_headers.csv +1 -0
  212. data/spec/fixtures/redcap_siblings.csv +1 -0
  213. data/spec/fixtures/redcap_whitespace.csv +1 -0
  214. data/spec/helpers/formtastic_custom_input_spec.rb +15 -0
  215. data/spec/helpers/surveyor_helper_spec.rb +116 -0
  216. data/spec/lib/common_spec.rb +37 -0
  217. data/spec/lib/parser_spec.rb +393 -0
  218. data/spec/lib/rake_kitchen_sink.rb +42 -0
  219. data/spec/lib/redcap_parser_spec.rb +129 -0
  220. data/spec/lib/unparser_spec.rb +126 -0
  221. data/spec/models/answer_spec.rb +144 -0
  222. data/spec/models/dependency_condition_spec.rb +428 -0
  223. data/spec/models/dependency_spec.rb +90 -0
  224. data/spec/models/question_group_spec.rb +66 -0
  225. data/spec/models/question_spec.rb +176 -0
  226. data/spec/models/response_set_spec.rb +452 -0
  227. data/spec/models/response_spec.rb +208 -0
  228. data/spec/models/survey_section_spec.rb +58 -0
  229. data/spec/models/survey_spec.rb +155 -0
  230. data/spec/models/surveyor_gui/question_spec.rb +60 -0
  231. data/spec/models/surveyor_gui/question_type_spec.rb +268 -0
  232. data/spec/models/validation_condition_spec.rb +98 -0
  233. data/spec/models/validation_spec.rb +64 -0
  234. data/spec/spec.opts +4 -0
  235. data/spec/spec_helper.rb +119 -0
  236. data/spec/support/scenario_outline_helper.rb +39 -0
  237. data/spec/support/shared.rb +10 -0
  238. data/spec/support/surveyforms_creation_helpers.rb +312 -0
  239. data/spec/support/surveyforms_rearrangement_helpers.rb +170 -0
  240. data/spec/support/surveyor_api_helpers.rb +15 -0
  241. data/spec/support/surveyor_ui_helpers.rb +108 -0
  242. data/spec/support/wait_for_ajax.rb +11 -0
  243. data/spec/views/questions/edit.html.erb_spec.rb +73 -0
  244. data/spec/views/surveyforms/edit.html.erb_spec.rb +126 -0
  245. data/surveyor_gui.gemspec +52 -0
  246. data/test/dummy/README.rdoc +261 -0
  247. data/test/dummy/Rakefile +7 -0
  248. data/test/dummy/app/assets/javascripts/application.js +15 -0
  249. data/test/dummy/app/assets/stylesheets/application.css +13 -0
  250. data/test/dummy/app/controllers/application_controller.rb +3 -0
  251. data/test/dummy/app/helpers/application_helper.rb +2 -0
  252. data/test/dummy/app/mailers/.gitkeep +0 -0
  253. data/test/dummy/app/models/.gitkeep +0 -0
  254. data/test/dummy/app/views/layouts/application.html.erb +14 -0
  255. data/test/dummy/config.ru +4 -0
  256. data/test/dummy/config/application.rb +59 -0
  257. data/test/dummy/config/boot.rb +10 -0
  258. data/test/dummy/config/database.yml +25 -0
  259. data/test/dummy/config/environment.rb +5 -0
  260. data/test/dummy/config/environments/development.rb +37 -0
  261. data/test/dummy/config/environments/production.rb +67 -0
  262. data/test/dummy/config/environments/test.rb +37 -0
  263. data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
  264. data/test/dummy/config/initializers/inflections.rb +15 -0
  265. data/test/dummy/config/initializers/mime_types.rb +5 -0
  266. data/test/dummy/config/initializers/secret_token.rb +7 -0
  267. data/test/dummy/config/initializers/session_store.rb +8 -0
  268. data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
  269. data/test/dummy/config/locales/en.yml +5 -0
  270. data/test/dummy/config/routes.rb +58 -0
  271. data/test/dummy/lib/assets/.gitkeep +0 -0
  272. data/test/dummy/log/.gitkeep +0 -0
  273. data/test/dummy/public/404.html +26 -0
  274. data/test/dummy/public/422.html +26 -0
  275. data/test/dummy/public/500.html +25 -0
  276. data/test/dummy/public/favicon.ico +0 -0
  277. data/test/dummy/script/rails +6 -0
  278. data/test/surveyor-gui_test.rb +7 -0
  279. data/test/test_helper.rb +15 -0
  280. data/vendor/assets/stylesheets/.gitkeep +0 -0
  281. data/vendor/assets/stylesheets/custom.sass +5 -0
  282. data/vendor/plugins/.gitkeep +0 -0
  283. metadata +664 -0
@@ -0,0 +1,20 @@
1
+ <div class="shadebox">
2
+ <h1 ><%= @title %></h1>
3
+ <% if @question.part_of_group? -%>
4
+ <%= simple_form_for @question.question_group, :url => dependencys_path+'/'+@question.id.to_s do |g| %>
5
+ <%= g.error_messages %>
6
+ <div class = 'dependency_editor'>
7
+ <%= render "dependency", f: g %>
8
+ </div>
9
+ <% end %>
10
+ <% else -%>
11
+ <%= simple_form_for @question, :url => dependencys_path+'/'+@question.id.to_s do |q| %>
12
+ <%= q.error_messages %>
13
+ <%= q.hidden_field :survey_section_id %>
14
+ <div class = 'dependency_editor'>
15
+ <%= render "dependency", f: q %>
16
+ </div>
17
+ <% end %>
18
+ <% end -%>
19
+ <% 24.times.each do %><br/><% end -%>
20
+ </div>
File without changes
@@ -0,0 +1 @@
1
+ <%= render 'form' %>
@@ -0,0 +1 @@
1
+ <%= render 'form' %>
@@ -0,0 +1,14 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>SurveyorGui</title>
5
+ <%= stylesheet_link_tag "application", :media => "all" %>
6
+ <%= javascript_include_tag "application" %>
7
+ <%= csrf_meta_tags %>
8
+ </head>
9
+ <body>
10
+
11
+ <%= yield %>
12
+
13
+ </body>
14
+ </html>
@@ -0,0 +1,12 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>SurveyorGui</title>
5
+ <%= stylesheet_link_tag "surveyor_gui_all", :media => "all" %>
6
+ <%= javascript_include_tag "surveyor_gui_all" %>
7
+ <%= csrf_meta_tags %>
8
+ </head>
9
+ <body>
10
+ <%= yield %>
11
+ </body>
12
+ </html>
@@ -0,0 +1,16 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>SurveyorGui</title>
5
+ <%= stylesheet_link_tag "surveyor_gui_all", :media => "all" %>
6
+ <%= javascript_include_tag "surveyor_gui_all" %>
7
+ <%= csrf_meta_tags %>
8
+ </head>
9
+ <body>
10
+ <% flash.each do |key, value| %>
11
+ <%= content_tag(:div, value, :class => "flash #{key}") %>
12
+ <% end %>
13
+ <%= yield %>
14
+
15
+ </body>
16
+ </html>
@@ -0,0 +1,14 @@
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
2
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
4
+ <head>
5
+ <meta http-equiv="content-type" content="text/html;charset=UTF-8" />
6
+ <title>Survey: <%= controller.action_name %></title>
7
+ <%= surveyor_includes %>
8
+ <%= stylesheet_link_tag('surveyor_add_ons') +
9
+ javascript_include_tag('surveyor_add_ons')%>
10
+ </head>
11
+ <body>
12
+ <%= yield %>
13
+ </body>
14
+ </html>
@@ -0,0 +1,33 @@
1
+ -# TODO: disabled
2
+ - rg ||= nil
3
+ - r = response_for(@response_set, q, a, rg)
4
+ - i = response_idx(q.pick != "one") # argument will be false (don't increment i) if we're on radio buttons
5
+ - disabled = defined?(disableFlag) ? disableFlag : false
6
+ = f.semantic_fields_for i, r do |ff|
7
+ = ff.input :question_id, :as => :quiet unless q.pick == "one" # don't repeat question_id if we're on radio buttons
8
+ = ff.input :api_id, :as => :quiet unless q.pick == "one"
9
+ = ff.input :response_group, :input_html => { :value => rg }, :as => :quiet if q.pick != "one" && g && g.display_type == "repeater"
10
+ - case q.pick
11
+ - when "one"
12
+ = ff.input :answer_id, :as => :surveyor_radio, :collection => [[a.text_for(nil, @render_context, I18n.locale), a.id]], :label => false, :input_html => {:class => a.css_class, :disabled => disabled}, :response_class => a.response_class
13
+ - when "any"
14
+ = ff.input :answer_id, :as => :surveyor_check_boxes, :collection => [[a.text_for(nil, @render_context, I18n.locale), a.id]], :label => false, :input_html => {:class => a.css_class, :disabled => disabled}, :response_class => a.response_class
15
+ - when "none"
16
+ - if %w(date datetime time float integer string text).include? a.response_class
17
+ = ff.input :answer_id, :as => :quiet, :input_html => {:class => a.css_class, :value => a.id}
18
+ = ff.input rc_to_attr(a.response_class),
19
+ :as => rc_to_as(a.response_class),
20
+ :label => a.text_for(:pre, @render_context, I18n.locale).blank? ? false : a.text_for(:pre, @render_context, I18n.locale),
21
+ :hint => a.text_for(:post, @render_context, I18n.locale),
22
+ :input_html => generate_pick_none_input_html(r.to_formatted_s, a.default_value_for(@render_context, I18n.locale), a.css_class, a.response_class, disabled, a.input_mask, a.input_mask_placeholder)
23
+ - elsif a.response_class=='blob'
24
+ = ff.input :answer_id, :as => :quiet, :input_html => {:class => a.css_class, :value => a.id}
25
+ = ff.input :blob, :as => :quiet
26
+ = ff.input :blob, :as => :file, :label => false, :input_html => {"data-object-class"=>ff.object.class.name, "data-object-id"=>ff.object.id, "data-response_set_id" => @response_set.id, :required=>q.mandatory?}
27
+ .filename_with_link{:data=>{'image-path'=>'#{image_path("delete.png")}'}}
28
+ - if !ff.object.blob_identifier.blank?
29
+ current file is:
30
+ = link_to ff.object.blob_identifier, ff.object.blob_url, :target=>'_blank'
31
+ - else
32
+ = a.text_for(nil, @render_context, I18n.locale)
33
+ %span.help= a.help_text_for(@render_context, I18n.locale) unless g && g.display_type == "grid"
@@ -0,0 +1,33 @@
1
+ -# TODO: js for slider
2
+ - rg ||= nil
3
+ - renderer = q.renderer(g ||= nil)
4
+ - disabled = defined?(disableFlag) ? disableFlag : false
5
+ - unless q.display_type == "hidden"
6
+ = f.inputs q_text(q, @render_context, I18n.locale), :id => rg ? "q_#{q.id}_#{rg}" : "q_#{q.id}", :class => "q_#{renderer} #{q.css_class(@response_set)}" do
7
+ %span.help= q.help_text_for(@render_context, I18n.locale)
8
+ - case renderer
9
+ - when :image, :label, :default_label, :inline_label, :repeater_label
10
+ - when :dropdown, :inline_dropdown, :default_dropdown, :slider, :repeater_dropdown, :stars
11
+ - r = response_for(@response_set, q, nil, rg)
12
+ - i = response_idx
13
+ = f.semantic_fields_for i, r do |ff|
14
+ = ff.input :question_id, :as => :quiet
15
+ = ff.input :response_group, :as => :quiet, :input_html => { :value => rg } if g && g.display_type == "repeater"
16
+ = ff.input :api_id, :as => :quiet
17
+ -# the next three lines add for sureyor_gui
18
+ - if renderer==:stars
19
+ = ff.input :integer_value, :as => :radio, :collection => [[nil,1],[nil,2],[nil,3],[nil,4],[nil,5]], :include_blank => (renderer != :slider), :label => q.text, :input_html => { :disabled => disabled }
20
+ = ff.input :answer_id, :as => :quiet, :value => q.answers.first.id
21
+ - else
22
+ = ff.input :answer_id, :as => :select, :collection => q.answers.map{|a| [a.text, a.id]}, :include_blank => (renderer != :slider), :label => q.text, :input_html => { :disabled => disabled }
23
+ - else # :default, :inline, :inline_default
24
+ - if q.pick == "one"
25
+ - r = response_for(@response_set, q, nil, rg)
26
+ - i = response_idx # increment the response index since the answer partial skips for q.pick == one
27
+ = f.semantic_fields_for i, r do |ff|
28
+ = ff.input :question_id, :as => :quiet
29
+ = ff.input :response_group, :as => :quiet, :value => rg if g && g.display_type == "repeater"
30
+ = ff.input :api_id, :as => :quiet
31
+ - q.answers.each do |a|
32
+ - next if (q.pick == "one" or q.pick == "any") and disabled and @response_set.responses.where( :question_id => q.id, :answer_id => a.id).empty?
33
+ = render a.custom_renderer || '/partials/answer', :q => q, :a => a, :f => f, :rg => rg, :g => g, :disableFlag => disabled
@@ -0,0 +1,73 @@
1
+ - renderer = g.renderer
2
+ - unless g.display_type == "hidden"
3
+ = f.inputs "#{next_question_number(g)}#{g.text_for(@render_context, I18n.locale)}", :id => "g_#{g.id}", :class => "g_#{renderer} #{g.css_class(@response_set)}" do
4
+ %li.help= g.help_text_for(@render_context, I18n.locale)
5
+ - case renderer
6
+ - when :grid
7
+ - if qs.first.question_type_id == :grid_dropdown
8
+ %li
9
+ %table
10
+ %col.pre
11
+ - g.columns.each do |column|
12
+ %col{:class => cycle("odd", "even")}
13
+ %col.pre
14
+ %col.post
15
+ %tbody
16
+ - g.columns.each_slice(10) do |ten_columns|
17
+ %tr
18
+ %th &nbsp;
19
+ - ten_columns.each do |column|
20
+ %th
21
+ = column.text_for(nil, @render_context, I18n.locale)
22
+ - qs.each_with_index do |q, i|
23
+ %tr{:id => "q_#{q.id}", :class => "q_#{renderer} #{q.css_class(@response_set)}"}
24
+ %td
25
+ = q.text_for(:pre, @render_context, I18n.locale)
26
+ - ten_columns.each_with_index do |column, i|
27
+ %td
28
+ - r = response_for(@response_set, q, nil, nil, column.id)
29
+ - i = response_idx # increment the response index since the answer partial skips for q.pick == one
30
+ = f.semantic_fields_for i, r do |ff|
31
+ = ff.input :question_id, :as => :quiet
32
+ = ff.input :api_id, :as => :quiet
33
+ = ff.input :column_id, :value => column.id, :as => :quiet
34
+ = ff.input :answer_id, :as => :select, :collection => q.answers.where('column_id=?',column.id).map{|a| [a.text, a.id]}, :label => false, :response_class => "answer"
35
+ - else
36
+ %li
37
+ %table
38
+ %col.pre
39
+ - qs.first.answers.each do |a|
40
+ %col{:class => cycle("odd", "even")}
41
+ %col.post
42
+ %tbody
43
+ - qs.each_slice(10) do |ten_questions| # header row every 10
44
+ %tr
45
+ %th &nbsp;
46
+ - ten_questions.first.answers.each do |a|
47
+ %th
48
+ = a.text_for(nil, @render_context, I18n.locale)
49
+ %span.help= a.help_text_for(@render_context, I18n.locale)
50
+ %th &nbsp;
51
+ - ten_questions.each_with_index do |q, i|
52
+ %tr{:id => "q_#{q.id}", :class => "q_#{renderer} #{q.css_class(@response_set)}"}
53
+ %th
54
+ = q.text_for(:pre, @render_context, I18n.locale)
55
+ = q.help_text_for(@render_context, I18n.locale)
56
+ - if q.pick == "one"
57
+ - r = response_for(@response_set, q, nil, g)
58
+ - i = response_idx # increment the response index since the answer partial skips for q.pick == one
59
+ = f.semantic_fields_for i, r do |ff|
60
+ = ff.input :question_id, :as => :quiet
61
+ = ff.input :api_id, :as => :quiet
62
+ - q.answers.each do |a|
63
+ %td= render(a.custom_renderer || '/partials/answer', :g => g, :q => q, :a => a, :f => f) unless q.display_type == "label"
64
+ %th= q.text_for(:post, @render_context, I18n.locale)
65
+ - when :repeater
66
+ - (@response_set.count_group_responses(qs) + 1).times do |rg|
67
+ %li
68
+ - qs.each do |q|
69
+ = render q.custom_renderer || "/partials/question", :g => g, :rg => rg, :q => q, :f => f
70
+ = submit_tag("+ add row", :name => "section[#{@section.id}][g_#{g.id}]", :class => "add_row")
71
+ - else # :inline
72
+ - qs.each do |q|
73
+ = render q.custom_renderer || "/partials/question", :g => g, :q => q, :f => f
@@ -0,0 +1,13 @@
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 if q.is_comment != true # 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
+ = render q.custom_renderer || "/partials/question", :q => q, :f => f if q.is_comment == true
12
+ - else # gather up the group questions
13
+ = render q.custom_renderer || "/partials/question", :q => q, :f => f
@@ -0,0 +1,56 @@
1
+ <div class="question_group_editor shadebox">
2
+ <h1 ><%= @title %></h1>
3
+ <%= simple_form_for @question_group do |qg| %>
4
+ <div class = 'questions'>
5
+ <%= qg.error_messages %>
6
+ <%= qg.hidden_field :id %>
7
+ <%= qg.hidden_field :display_type %>
8
+ <%= qg.hidden_field :question_id %>
9
+ <%= qg.hidden_field :survey_section_id, value: @survey_section_id %>
10
+
11
+ <%= qg.label :Question, :input_html=>{:size=>'15'} %>
12
+ <%= qg.input :text , :input_html=>{:size=>'55'}, :label => false%>
13
+ <span class='fl'>
14
+ <strong>Mandatory?</strong>
15
+ </span>
16
+ <%= qg.input :is_mandatory, :label => false, :as=>:boolean, :wrapper_html=>{:class=>'fl notfirst'}%>
17
+ <br />
18
+ <br />
19
+ <strong>Question Type</strong><br/>
20
+ <div class="question_type">
21
+ <span class="question_type_grid1">
22
+ <%= qg.input :question_type_id,
23
+ collection: question_type_subset([:pick_one]) ,
24
+ :as => :radio_buttons , :wrapper_html=>{:size=>'60'}, :label => false%>
25
+ </span>
26
+ <span class="question_type_grid1">
27
+ <%= qg.input :question_type_id,
28
+ collection: question_type_subset([:pick_any]) ,
29
+ :as => :radio_buttons , :wrapper_html=>{:size=>'60'}, :label => false%>
30
+ </span>
31
+ <div style="clear:both"></div>
32
+ <span class="question_type_grid">
33
+ <%= qg.input :question_type_id,
34
+ collection: question_type_subset([:dropdown, :string, :number, :stars, :label, :box]) ,
35
+ :as => :radio_buttons , :wrapper_html=>{:size=>'60'}, :label => false%>
36
+ </span>
37
+ <span class="question_type_grid">
38
+ <%= qg.input :question_type_id,
39
+ collection: question_type_subset([:date, :datetime, :time, :slider, :group_default ]) ,
40
+ :as => :radio_buttons , :wrapper_html=>{:size=>'60'}, :label => false%>
41
+ </span>
42
+ <span class="question_type_grid">
43
+ <%= qg.input :question_type_id,
44
+ collection: question_type_subset([:file, :grid_one, :grid_any, :grid_dropdown, :group_inline, :repeater]) ,
45
+ :as => :radio_buttons , :wrapper_html=>{:size=>'60'}, :label => false %>
46
+ </span>
47
+ </div>
48
+ <br />
49
+ <div id="answer_choice">
50
+ <%= render "group_inline_fields", f: qg %>
51
+ </div>
52
+ </div>
53
+ <%= qg.button :submit, 'Save Changes', :id=>'question_group_submit' %>
54
+ <% end -%>
55
+ <% 20.times do -%><br/><% end -%>
56
+ </div>
@@ -0,0 +1,21 @@
1
+ <%= simple_fields_for :question_group, @question_group do |qg| %>
2
+ <div class="sortable_group_questions" id="sortable_question<%= @survey_section_id.to_s %>">
3
+ <%= qg.simple_fields_for :questions do |q| %>
4
+ <%= div_for(q.object, class: "group_inline_question") do %>
5
+ <div class="handle"><span class="ui-icon ui-icon-arrowthick-2-n-s"></span></div>
6
+ <%= q.hidden_field :survey_section_id, value: @survey_section_id %>
7
+ <%= q.hidden_field :id %>
8
+ <%= q.input :text, label: false, as: :string, wrapper_html:{class: "question"} %>
9
+ <%= q.input :question_type_id, label: false, collection: QuestionType.all.map{|t|[t.text, t.id]}[0..13].uniq.select{|c| [:box,:number,:date,:string,:dropdown,:pick_one,:pick_any, :slider, :stars, :file].include? c[1]}, wrapper_html:{class: "question"} %>
10
+ <%= q.input :answers_textbox, label: false, as: :text, wrapper_html:{class: "question group_answers_textbox"} %>
11
+
12
+ <%= q.hidden_field :display_order %>
13
+ <%= q.hidden_field :display_type %>
14
+ <%= q.hidden_field :pick %>
15
+ <span class="delete_group_inline_question">
16
+ <%= link_to_remove_fields "remove", q, ".group_inline_question" %>
17
+ </span>
18
+ <% end -%>
19
+ <% end -%>
20
+ </div>
21
+ <% end -%>
@@ -0,0 +1,25 @@
1
+ <%= simple_fields_for :question_group, @question_group do |qg| %>
2
+ <%= qg.hidden_field :id %>
3
+ <%= qg.hidden_field :display_type, value: "inline" %>
4
+ <div class="group_inline">
5
+ <div class="group_inline_header">
6
+ <span class="handle"></span>
7
+ <span>
8
+ Sub Question
9
+ </span>
10
+ <span>
11
+ Question Type
12
+ </span>
13
+ <span>
14
+ Possible Answers
15
+ </span>
16
+ </div>
17
+ <%= render "group_inline_field", qg: qg %>
18
+ <div class="add_question">
19
+ <span></span>
20
+ <span>
21
+ Add Question <%= image_tag("addicon.png", class:"add_group_inline_question") %>
22
+ </span>
23
+ </div>
24
+ </div>
25
+ <% end -%>
@@ -0,0 +1 @@
1
+ <%= render 'form' %>
@@ -0,0 +1 @@
1
+ <%= render 'form' %>
@@ -0,0 +1,23 @@
1
+ <strong>Possible Answers:</strong> enter each choice on a separate line.
2
+ <%= simple_fields_for 'question', @questions do |f| %>
3
+ <%= f.input :answers_textbox, :as => :text, :wrapper_html => {:class=>'answers_collection'}, :label => false %>
4
+ <!-- <%= f.simple_fields_for :answers do |a| %>
5
+ <%= div_for(a.object) do %>
6
+ <div id='original_choice', data-original_choice="<%= a.object.original_choice %>"></div>
7
+ <div class="fields vertical_collection" style='display: table;'>
8
+ <span class='fl ui-icon ui-icon-arrowthick-2-n-s answer_handle'>
9
+ Move
10
+ </span>
11
+ <%= a.input :text, :as => :string, :label => false, :required => false, :wrapper_html=>{:class=>'fl notfirst'}%>
12
+ <%= a.hidden_field :display_order %>
13
+ <%= a.hidden_field :id %>
14
+ <span class="fl notfirst">
15
+ <%= link_to_remove_fields "remove", a %>
16
+ </span>
17
+ </div>
18
+ <% end %>
19
+ <% end -%>
20
+ -->
21
+
22
+ <%= render "answer_options", f: f %>
23
+ <% end -%>
@@ -0,0 +1,28 @@
1
+ <br/>
2
+ <%= f.input :omit_text,
3
+ label: "add a choice for",
4
+ hint: "will uncheck all other choices",
5
+ placeholder: "none of the above",
6
+ as: :string,
7
+ wrapper_html: {class: 'omit_text fl'}
8
+ %>:
9
+ <%= f.input_field :omit, label: false, as: :boolean %>
10
+ <br/><br/><br/>
11
+ <%= f.input :other_text,
12
+ label: "add a choice for",
13
+ hint: "user determines choice",
14
+ placeholder: "Other",
15
+ as: :string,
16
+ wrapper_html: {class: 'other_text fl'}
17
+ %>:
18
+ <%= f.input_field :other, label: false, as: :boolean %>
19
+ <br/><br/><br/>
20
+ <%= f.input :comments_text,
21
+ label: "at the bottom of questions, add",
22
+ hint: "box for notes/comments",
23
+ placeholder: "Comments",
24
+ as: :string,
25
+ wrapper_html: {class: 'comments_text fl'}
26
+ %>:
27
+ <%= f.input_field :comments, label: false, as: :boolean %>
28
+
@@ -0,0 +1,65 @@
1
+ <div class="question_editor shadebox">
2
+ <h1 ><%= @title %></h1>
3
+ <%= simple_form_for @question do |f| %>
4
+ <div class = 'questions'>
5
+ <%= f.error_messages %>
6
+ <%= f.hidden_field :id %>
7
+ <%= f.hidden_field :survey_section_id %>
8
+ <%= f.hidden_field :display_order %>
9
+ <%= f.hidden_field :pick %>
10
+ <%= f.hidden_field :display_type %>
11
+ <%= f.hidden_field :modifiable %>
12
+ <%= f.hidden_field :question_group_id %>
13
+
14
+ <%= f.label :Question, :input_html=>{:size=>'15'} %>
15
+ <%= f.input :text , :label => false, :input_html=>{:size=>'55', value: adjusted_text} %>
16
+ <span class='fl'><strong>Mandatory?</strong></span>
17
+ <%= f.input :is_mandatory, :label => false, :wrapper_html=>{:class=>'fl notfirst'}%>
18
+ <br />
19
+ <br />
20
+ <strong>Question Type</strong><br/>
21
+ <div class="question_type">
22
+ <span class="question_type_grid1">
23
+ <%= f.input :question_type_id,
24
+ collection: question_type_subset([:pick_one]) ,
25
+ :as => :radio_buttons , :wrapper_html=>{:size=>'60'}, :label => false%>
26
+ </span>
27
+ <span class="question_type_grid1">
28
+ <%= f.input :question_type_id,
29
+ collection: question_type_subset([:pick_any]) ,
30
+ :as => :radio_buttons , :wrapper_html=>{:size=>'60'}, :label => false%>
31
+ </span>
32
+ <br />
33
+ <span class="question_type_grid">
34
+ <%= f.input :question_type_id,
35
+ collection: question_type_subset([:dropdown, :string, :number, :stars, :label, :box]) ,
36
+ :as => :radio_buttons , :wrapper_html=>{:size=>'60'}, :label => false%>
37
+ </span>
38
+ <span class="question_type_grid">
39
+ <%= f.input :question_type_id,
40
+ collection: question_type_subset([:date, :datetime, :time, :slider, :group_default ]) ,
41
+ :as => :radio_buttons , :wrapper_html=>{:size=>'60'}, :label => false%>
42
+ </span>
43
+ <span class="question_type_grid">
44
+ <%= f.input :question_type_id,
45
+ collection: question_type_subset([:file, :grid_one, :grid_any, :grid_dropdown, :group_inline, :repeater]) ,
46
+ :as => :radio_buttons , :wrapper_html=>{:size=>'60'}, :label => false %>
47
+ </span>
48
+ </div>
49
+ <br />
50
+ <div id="answer_choice">
51
+ <%= render 'picks', :f => f %>
52
+ </div>
53
+ <div id="number_questions"></div>
54
+
55
+ <div id="report_code" style="display:none">
56
+ <br />
57
+ <%= f.input :report_code, :label=>'Report Code', :label_html=>{:style=>'width:10em;'},:hint=>'Use this code to uniquely identify application data driven questions for reporting.' %>
58
+ <br />
59
+ </div>
60
+ <br />
61
+ </div>
62
+ <%= f.button :submit, 'Save Changes', :id=>'question_submit' %>
63
+ <% end %>
64
+ <% 20.times do -%><br/><% end -%>
65
+ </div>