helena 0.3.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (202) hide show
  1. checksums.yaml +7 -0
  2. data/.coveralls.yml +2 -0
  3. data/.gitignore +15 -0
  4. data/.rubocop.yml +16 -0
  5. data/.travis.yml +6 -0
  6. data/Gemfile +31 -0
  7. data/Gemfile.lock +290 -0
  8. data/LICENSE +16 -0
  9. data/README.md +90 -0
  10. data/Rakefile +29 -0
  11. data/app/assets/images/helena/.keep +0 -0
  12. data/app/assets/images/helena/helena_mobile_view.jpg +0 -0
  13. data/app/assets/images/helena/icons/export.svg +29 -0
  14. data/app/assets/images/helena/swissmadesoftware.png +0 -0
  15. data/app/assets/javascripts/helena/application.js +4 -0
  16. data/app/assets/javascripts/helena/survey.js +2 -0
  17. data/app/assets/stylesheets/helena/admin/labels.css.sass +7 -0
  18. data/app/assets/stylesheets/helena/admin/layout.css.sass +6 -0
  19. data/app/assets/stylesheets/helena/admin/question_groups.css.sass +7 -0
  20. data/app/assets/stylesheets/helena/admin/questions.css.sass +9 -0
  21. data/app/assets/stylesheets/helena/admin/sessions.css.sass +5 -0
  22. data/app/assets/stylesheets/helena/admin/subquestions.css.sass +7 -0
  23. data/app/assets/stylesheets/helena/admin/versions.css.sass +9 -0
  24. data/app/assets/stylesheets/helena/application.css.sass +21 -0
  25. data/app/assets/stylesheets/helena/forms.css.sass +13 -0
  26. data/app/assets/stylesheets/helena/layout.css.sass +3 -0
  27. data/app/assets/stylesheets/helena/question_groups.css.sass +4 -0
  28. data/app/controllers/helena/admin/application_controller.rb +31 -0
  29. data/app/controllers/helena/admin/question_groups_controller.rb +78 -0
  30. data/app/controllers/helena/admin/questions/checkbox_groups_controller.rb +17 -0
  31. data/app/controllers/helena/admin/questions/checkbox_matrix_controller.rb +9 -0
  32. data/app/controllers/helena/admin/questions/long_texts_controller.rb +13 -0
  33. data/app/controllers/helena/admin/questions/radio_groups_controller.rb +17 -0
  34. data/app/controllers/helena/admin/questions/radio_matrix_controller.rb +9 -0
  35. data/app/controllers/helena/admin/questions/short_texts_controller.rb +13 -0
  36. data/app/controllers/helena/admin/questions/static_texts_controller.rb +13 -0
  37. data/app/controllers/helena/admin/questions_controller.rb +105 -0
  38. data/app/controllers/helena/admin/sessions_controller.rb +35 -0
  39. data/app/controllers/helena/admin/surveys_controller.rb +78 -0
  40. data/app/controllers/helena/admin/versions_controller.rb +71 -0
  41. data/app/controllers/helena/application_controller.rb +15 -0
  42. data/app/controllers/helena/concerns/questions/matrix_questions.rb +24 -0
  43. data/app/controllers/helena/sessions_controller.rb +93 -0
  44. data/app/controllers/helena/surveys_controller.rb +11 -0
  45. data/app/helpers/helena/application_helper.rb +4 -0
  46. data/app/models/helena/answer.rb +48 -0
  47. data/app/models/helena/boolean_answer.rb +5 -0
  48. data/app/models/helena/concerns/application_model.rb +19 -0
  49. data/app/models/helena/concerns/questions/requirable.rb +19 -0
  50. data/app/models/helena/concerns/questions/validates_one_label.rb +22 -0
  51. data/app/models/helena/integer_answer.rb +5 -0
  52. data/app/models/helena/label.rb +18 -0
  53. data/app/models/helena/question.rb +63 -0
  54. data/app/models/helena/question_group.rb +18 -0
  55. data/app/models/helena/questions/checkbox_group.rb +17 -0
  56. data/app/models/helena/questions/long_text.rb +9 -0
  57. data/app/models/helena/questions/radio_group.rb +12 -0
  58. data/app/models/helena/questions/radio_matrix.rb +24 -0
  59. data/app/models/helena/questions/short_text.rb +9 -0
  60. data/app/models/helena/questions/static_text.rb +7 -0
  61. data/app/models/helena/session.rb +76 -0
  62. data/app/models/helena/string_answer.rb +5 -0
  63. data/app/models/helena/sub_question.rb +27 -0
  64. data/app/models/helena/survey.rb +29 -0
  65. data/app/models/helena/survey_detail.rb +10 -0
  66. data/app/models/helena/version.rb +33 -0
  67. data/app/views/helena/admin/question_groups/_form.html.haml +3 -0
  68. data/app/views/helena/admin/question_groups/edit.html.haml +3 -0
  69. data/app/views/helena/admin/question_groups/index.html.haml +41 -0
  70. data/app/views/helena/admin/question_groups/new.html.haml +3 -0
  71. data/app/views/helena/admin/questions/_form.html.haml +15 -0
  72. data/app/views/helena/admin/questions/_labels.html.haml +24 -0
  73. data/app/views/helena/admin/questions/_sub_questions.html.haml +32 -0
  74. data/app/views/helena/admin/questions/edit.html.haml +3 -0
  75. data/app/views/helena/admin/questions/index.html.haml +49 -0
  76. data/app/views/helena/admin/questions/new.html.haml +3 -0
  77. data/app/views/helena/admin/sessions/index.html.haml +46 -0
  78. data/app/views/helena/admin/surveys/_form.html.haml +10 -0
  79. data/app/views/helena/admin/surveys/edit.html.haml +5 -0
  80. data/app/views/helena/admin/surveys/index.html.haml +35 -0
  81. data/app/views/helena/admin/surveys/new.html.haml +3 -0
  82. data/app/views/helena/admin/versions/_form.html.haml +5 -0
  83. data/app/views/helena/admin/versions/default_session_report.html.haml +17 -0
  84. data/app/views/helena/admin/versions/edit.html.haml +3 -0
  85. data/app/views/helena/admin/versions/index.html.haml +35 -0
  86. data/app/views/helena/admin/versions/new.html.haml +3 -0
  87. data/app/views/helena/questions/_checkbox_group.html.haml +17 -0
  88. data/app/views/helena/questions/_long_text.html.haml +8 -0
  89. data/app/views/helena/questions/_radio_group.html.haml +13 -0
  90. data/app/views/helena/questions/_radio_matrix.html.haml +27 -0
  91. data/app/views/helena/questions/_short_text.html.haml +8 -0
  92. data/app/views/helena/sessions/edit.html.haml +16 -0
  93. data/app/views/helena/sessions/end_message.html.haml +5 -0
  94. data/app/views/helena/surveys/_survey.html.haml +3 -0
  95. data/app/views/helena/surveys/index.html.haml +2 -0
  96. data/bin/rails +8 -0
  97. data/config/i18n-tasks.yml +3 -0
  98. data/config/initializers/simple_form.rb +162 -0
  99. data/config/initializers/simple_form_bootstrap.rb +132 -0
  100. data/config/locales/en.yml +20 -0
  101. data/config/locales/models/label/en.yml +14 -0
  102. data/config/locales/models/question/en.yml +47 -0
  103. data/config/locales/models/question_group/en.yml +11 -0
  104. data/config/locales/models/session/en.yml +10 -0
  105. data/config/locales/models/sub_question/en.yml +14 -0
  106. data/config/locales/models/survey/en.yml +6 -0
  107. data/config/locales/models/version/en.yml +12 -0
  108. data/config/locales/simple_form.en.yml +26 -0
  109. data/config/locales/views/admin/question_groups/en.yml +12 -0
  110. data/config/locales/views/admin/questions/en.yml +16 -0
  111. data/config/locales/views/admin/sessions/en.yml +11 -0
  112. data/config/locales/views/admin/surveys/en.yml +10 -0
  113. data/config/locales/views/admin/versions/en.yml +8 -0
  114. data/config/locales/views/sessions/en.yml +9 -0
  115. data/config/routes.rb +28 -0
  116. data/db/seeds.rb +182 -0
  117. data/gpl-3.0.txt +674 -0
  118. data/helena.gemspec +40 -0
  119. data/lib/helena/engine.rb +6 -0
  120. data/lib/helena/version.rb +3 -0
  121. data/lib/helena/version_publisher.rb +16 -0
  122. data/lib/helena.rb +10 -0
  123. data/lib/tasks/helena_tasks.rake +4 -0
  124. data/lib/templates/erb/scaffold/_form.html.erb +13 -0
  125. data/spec/controllers/helena/admin/question_group_controller_spec.rb +59 -0
  126. data/spec/controllers/helena/admin/questions_controller_spec.rb +60 -0
  127. data/spec/controllers/helena/admin/sessions_controller_spec.rb +84 -0
  128. data/spec/controllers/helena/admin/survey_controller_spec.rb +89 -0
  129. data/spec/controllers/helena/admin/versions_controller_spec.rb +19 -0
  130. data/spec/controllers/helena/application_controller_spec.rb +15 -0
  131. data/spec/controllers/helena/sessions_controller_spec.rb +24 -0
  132. data/spec/dummy/README.rdoc +28 -0
  133. data/spec/dummy/Rakefile +6 -0
  134. data/spec/dummy/app/assets/images/.keep +0 -0
  135. data/spec/dummy/app/assets/javascripts/application.js +13 -0
  136. data/spec/dummy/app/controllers/application_controller.rb +9 -0
  137. data/spec/dummy/app/controllers/concerns/.keep +0 -0
  138. data/spec/dummy/app/helpers/application_helper.rb +2 -0
  139. data/spec/dummy/app/mailers/.keep +0 -0
  140. data/spec/dummy/app/models/.keep +0 -0
  141. data/spec/dummy/app/models/concerns/.keep +0 -0
  142. data/spec/dummy/app/views/layouts/application.html.haml +24 -0
  143. data/spec/dummy/bin/bundle +3 -0
  144. data/spec/dummy/bin/rails +4 -0
  145. data/spec/dummy/bin/rake +4 -0
  146. data/spec/dummy/config/application.rb +27 -0
  147. data/spec/dummy/config/boot.rb +5 -0
  148. data/spec/dummy/config/environment.rb +5 -0
  149. data/spec/dummy/config/environments/development.rb +29 -0
  150. data/spec/dummy/config/environments/production.rb +80 -0
  151. data/spec/dummy/config/environments/test.rb +36 -0
  152. data/spec/dummy/config/initializers/filter_parameter_logging.rb +4 -0
  153. data/spec/dummy/config/initializers/secret_token.rb +12 -0
  154. data/spec/dummy/config/initializers/session_store.rb +3 -0
  155. data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
  156. data/spec/dummy/config/locales/en.yml +23 -0
  157. data/spec/dummy/config/mongoid.yml +14 -0
  158. data/spec/dummy/config/routes.rb +4 -0
  159. data/spec/dummy/config.ru +4 -0
  160. data/spec/dummy/db/seeds.rb +1 -0
  161. data/spec/dummy/lib/assets/.keep +0 -0
  162. data/spec/dummy/log/.keep +0 -0
  163. data/spec/dummy/public/404.html +58 -0
  164. data/spec/dummy/public/422.html +58 -0
  165. data/spec/dummy/public/500.html +57 -0
  166. data/spec/dummy/public/favicon.ico +0 -0
  167. data/spec/factories/helena/answers.rb +24 -0
  168. data/spec/factories/helena/labels.rb +7 -0
  169. data/spec/factories/helena/question_groups.rb +6 -0
  170. data/spec/factories/helena/questions.rb +14 -0
  171. data/spec/factories/helena/sessions.rb +9 -0
  172. data/spec/factories/helena/sub_questions.rb +7 -0
  173. data/spec/factories/helena/survey_details.rb +6 -0
  174. data/spec/factories/helena/surveys.rb +7 -0
  175. data/spec/factories/helena/versions.rb +11 -0
  176. data/spec/features/helena/admin/manage_question_group_spec.rb +101 -0
  177. data/spec/features/helena/admin/manage_question_spec.rb +105 -0
  178. data/spec/features/helena/admin/manage_session_spec.rb +40 -0
  179. data/spec/features/helena/admin/manage_survey_spec.rb +141 -0
  180. data/spec/features/helena/admin/manage_version_spec.rb +74 -0
  181. data/spec/features/helena/admin/question_types/manage_checkbox_group_question_spec.rb +55 -0
  182. data/spec/features/helena/admin/question_types/manage_long_text_question_spec.rb +21 -0
  183. data/spec/features/helena/admin/question_types/manage_radio_group_question_spec.rb +59 -0
  184. data/spec/features/helena/admin/question_types/manage_radio_matrix_question_spec.rb +80 -0
  185. data/spec/features/helena/admin/question_types/manage_short_text_question_spec.rb +19 -0
  186. data/spec/features/helena/admin/question_types/manage_static_text_question_spec.rb +17 -0
  187. data/spec/features/helena/manage_session_spec.rb +284 -0
  188. data/spec/features/helena/manage_survey_spec.rb +24 -0
  189. data/spec/lib/version_publisher_spec.rb +26 -0
  190. data/spec/models/helena/answer_spec.rb +53 -0
  191. data/spec/models/helena/label_spec.rb +13 -0
  192. data/spec/models/helena/question_group_spec.rb +11 -0
  193. data/spec/models/helena/question_spec.rb +21 -0
  194. data/spec/models/helena/questions/radio_group_spec.rb +32 -0
  195. data/spec/models/helena/questions/radio_matrix_spec.rb +32 -0
  196. data/spec/models/helena/questions/short_text_spec.rb +10 -0
  197. data/spec/models/helena/session_spec.rb +20 -0
  198. data/spec/models/helena/sub_question_spec.rb +28 -0
  199. data/spec/models/helena/survey_spec.rb +14 -0
  200. data/spec/models/helena/version_spec.rb +15 -0
  201. data/spec/spec_helper.rb +43 -0
  202. metadata +485 -0
@@ -0,0 +1,49 @@
1
+ .helena-admin
2
+ %h2
3
+ = Helena::Question.model_name.human(count: 2)
4
+ = "(#{@questions.count})"
5
+ - if @questions.empty?
6
+ .alert.alert-warning
7
+ = t '.empty'
8
+ - else
9
+ .table-responsive
10
+ %table.table.questions
11
+ %thead
12
+ %tr
13
+ %th.position= Helena::Question.human_attribute_name(:position)
14
+ %th= Helena::Question.human_attribute_name(:code)
15
+ %th= Helena::Question.human_attribute_name(:type)
16
+ %th= Helena::Question.human_attribute_name(:question_text)
17
+ %th
18
+ %tbody
19
+ - @questions.each_with_index do |question, index|
20
+ %tr[question]
21
+ %td.position
22
+ = question.position
23
+ %td.code
24
+ = question.code
25
+ %td.type
26
+ = question.class.model_name.human
27
+ - if question.try :required
28
+ %span.glyphicon.glyphicon-flag{ title: Helena::Question.human_attribute_name(:require) }
29
+ %td.question_text
30
+ = question.question_text
31
+ %td
32
+ .btn-group.btn-group-sm
33
+ - unless question.last?
34
+ = link_to move_down_admin_survey_question_group_question_path(@survey, @question_group, question), class: 'btn btn-primary',
35
+ method: :patch,
36
+ title: t('shared.move_down') do
37
+ %i.glyphicon.glyphicon-chevron-down
38
+ - unless question.first?
39
+ = link_to move_up_admin_survey_question_group_question_path(@survey, @question_group, question), class: 'btn btn-primary',
40
+ method: :patch,
41
+ title: t('shared.move_up') do
42
+ %i.glyphicon.glyphicon-chevron-up
43
+
44
+ = link_to t('shared.edit'), [:edit, :admin, @survey, @question_group, question], class: 'btn btn-primary'
45
+
46
+ = link_to t('shared.delete'), admin_survey_question_group_question_path(@survey, @question_group, question), method: :delete, class: 'btn btn-danger', data: { confirm: t('shared.delete_question') }
47
+
48
+ %a.btn.btn-success{ href: new_admin_survey_question_group_question_path(@survey, @question_group) }
49
+ = t '.add'
@@ -0,0 +1,3 @@
1
+ .helena-admin
2
+ %h2= t '.new'
3
+ = render 'form'
@@ -0,0 +1,46 @@
1
+ .helena-admin
2
+ - if @sessions.empty?
3
+ .alert.alert-warning
4
+ = t '.empty'
5
+ - else
6
+ .actions
7
+ = link_to admin_survey_sessions_path(@survey, format: :csv) do
8
+ = image_tag('helena/icons/export.svg', class: :icon)
9
+ = t('.export_sessions_csv')
10
+ = link_to admin_survey_sessions_path(@survey, format: :json) do
11
+ = t('.export_sessions_json')
12
+ %h2
13
+ = Helena::Session.model_name.human(count: 2)
14
+ = "(#{@sessions.count})"
15
+ .table-responsive
16
+ %table.table.sessions
17
+ %thead
18
+ %tr
19
+ %th.updated_at= Helena::Session.human_attribute_name(:updated_at)
20
+ %th.token= Helena::Session.human_attribute_name(:token)
21
+ %th.completed= Helena::Session.human_attribute_name(:completed)
22
+ %th.version= Helena::Session.human_attribute_name(:version)
23
+ %th.answers= Helena::Session.human_attribute_name(:answers)
24
+ %th
25
+ %tbody
26
+ - @sessions.each do |session|
27
+ %tr[session]
28
+ %td.updated_at
29
+ = time_ago_in_words(session.updated_at)
30
+ %td.token
31
+ = session.token
32
+ %td.completed
33
+ .label{class: "label-#{session.completed? ? 'success' : 'danger'}"}
34
+ = t ".#{session.completed}"
35
+ %td.version
36
+ = @survey.versions.find(session.version_id).version if session.version_id
37
+ %td.answers
38
+ = session.answers.count
39
+
40
+ %td
41
+ .btn-group
42
+ - if session.completed?
43
+ = link_to t('shared.show'), session_path(session.view_token), class: 'btn btn-primary'
44
+ = link_to t('shared.edit'), edit_session_path(session.token), class: 'btn btn-success'
45
+ = link_to t('shared.delete'), admin_survey_session_path(@survey, session),
46
+ method: :delete, class: 'btn btn-danger', data: { confirm: t('shared.delete_question') }
@@ -0,0 +1,10 @@
1
+ = simple_form_for [:admin, @survey] do |f|
2
+ = f.input :name
3
+ = f.input :tag_list
4
+ = f.input :language, collection: I18n.available_locales, include_blank: false
5
+ = f.simple_fields_for :versions do |v|
6
+ = v.input :version, as: :hidden, value: 0 if @survey.new_record?
7
+ = v.simple_fields_for :survey_detail do |detail|
8
+ = detail.input :title
9
+ = detail.input :description, as: :text, input_html: { cols: 60, rows: 10 }
10
+ = f.submit t('shared.save'), class: 'btn btn-success'
@@ -0,0 +1,5 @@
1
+ .helena-admin
2
+ %h2
3
+ Edit
4
+ = @survey.name
5
+ = render 'form'
@@ -0,0 +1,35 @@
1
+ .helena-admin
2
+ %h2
3
+ = Helena::Survey.model_name.human(count: 2)
4
+ = "(#{@surveys.count})"
5
+ - if @surveys.empty?
6
+ .alert.alert-warning
7
+ = t('.empty')
8
+ - else
9
+ - @surveys.each do |survey|
10
+ %div[survey]
11
+ %h3= survey.name
12
+ - if survey.draft_version.survey_detail.present?
13
+ %h4= survey.draft_version.survey_detail.title
14
+ %p= survey.draft_version.survey_detail.description
15
+ - if survey.tag_list.present?
16
+ %p
17
+ = "#{Helena::Survey.human_attribute_name :tags}:"
18
+ = survey.tag_list
19
+ .btn-group
20
+ - unless survey.last?
21
+ = link_to move_down_admin_survey_path(survey), class: 'btn btn-primary', method: :patch, title: t('shared.move_down') do
22
+ %i.glyphicon.glyphicon-chevron-down
23
+ - unless survey.first?
24
+ = link_to move_up_admin_survey_path(survey), class: 'btn btn-primary', method: :patch, title: t('shared.move_up') do
25
+ %i.glyphicon.glyphicon-chevron-up
26
+
27
+ = link_to t('shared.edit'), edit_admin_survey_path(survey), class: 'btn btn-primary'
28
+ = link_to Helena::QuestionGroup.model_name.human(count: 2), admin_survey_question_groups_path(survey), class: 'btn btn-primary'
29
+ = link_to Helena::Session.model_name.human(count: 2), admin_survey_sessions_path(survey), class: 'btn btn-primary'
30
+ = link_to Helena::Version.model_name.human(count: 2), admin_survey_versions_path(survey), class: 'btn btn-primary'
31
+ = link_to t('shared.delete'), admin_survey_path(survey), method: :delete, class: 'btn btn-danger', data: { confirm: t('shared.delete_question') }
32
+
33
+ %br
34
+ %a.btn.btn-success{ href: new_admin_survey_path}
35
+ = t '.add'
@@ -0,0 +1,3 @@
1
+ .helena-admin
2
+ %h2= t '.new'
3
+ = render 'form'
@@ -0,0 +1,5 @@
1
+ = simple_form_for [:admin, @survey, @version] do |f|
2
+ = f.input :notes
3
+ = f.input :session_report, as: :text, input_html: { cols: 60, rows: 10 }
4
+
5
+ = f.submit t('shared.save'), class: 'btn btn-success'
@@ -0,0 +1,17 @@
1
+ %h1 {{ survey_title }}
2
+ %p {{ survey_description }}
3
+ %table
4
+ %thead
5
+ %tr
6
+ %th Code
7
+ %th Value
8
+ %tbody
9
+ {% for answer in survey_answers %}
10
+ %tr
11
+ %td {{ answer.code }}
12
+ %td {{ answer.value }}
13
+ {% endfor %}
14
+ %tfoot
15
+ %tr
16
+ %td{ colspan: 2}
17
+ {{ survey_answers.size }} answers
@@ -0,0 +1,3 @@
1
+ .helena-admin
2
+ %h2= t 'shared.edit'
3
+ = render 'form'
@@ -0,0 +1,35 @@
1
+ .helena-admin
2
+ %h2
3
+ = Helena::Version.model_name.human(count: 2)
4
+ = "(#{@versions.count})"
5
+ - if @versions.empty?
6
+ .alert.alert-warning
7
+ = t('.empty')
8
+ - else
9
+ .table-responsive
10
+ %table.table.versions
11
+ %thead
12
+ %tr
13
+ %th.version= Helena::Version.human_attribute_name(:version)
14
+ %th.notes= Helena::Version.human_attribute_name(:notes)
15
+ %th.sessions= Helena::Session.model_name.human(count: 2)
16
+ %th.created_at= Helena::Version.human_attribute_name(:created_at)
17
+ %th
18
+ %tbody
19
+ - @versions.each do |version|
20
+ %tr[version]
21
+ %td.version
22
+ = version.version
23
+ %td.notes
24
+ = version.notes
25
+ %td.sessions
26
+ = Helena::Session.where(version: version).count
27
+ %td.created_at
28
+ = time_ago_in_words(version.created_at)
29
+ %td
30
+ .btn-group
31
+ = link_to t('shared.edit'), edit_admin_survey_version_path(@survey, version), class: 'btn btn-success'
32
+ = link_to t('shared.delete'), admin_survey_version_path(@survey, version), method: :delete, class: 'btn btn-danger', data: { confirm: t('shared.delete_question') }
33
+
34
+ %a.btn.btn-success{ href: new_admin_survey_version_path(@survey)}
35
+ = t 'shared.add'
@@ -0,0 +1,3 @@
1
+ .helena-admin
2
+ %h2= t '.new'
3
+ = render 'form'
@@ -0,0 +1,17 @@
1
+ .checkbox_group.form-group{ class: "#{'has-error' if errors[question.code]}" }
2
+ %label
3
+ = question.question_text
4
+ = ' *' if question.required
5
+ = form.simple_fields_for :answers do |answer_form|
6
+ - question.sub_questions.each do |sub_question|
7
+ .checkbox
8
+ %label
9
+ - checked = (answers[sub_question.code].to_s == sub_question.value.to_s) if sub_question.value
10
+ - checked ||= sub_question.preselected
11
+ = answer_form.input_field sub_question.code, as: :boolean,
12
+ value: sub_question.value,
13
+ checked: checked,
14
+ class: 'form-control'
15
+ = sub_question.text
16
+ - if errors[question.code]
17
+ .help-block.text-danger= errors[question.code]
@@ -0,0 +1,8 @@
1
+ .long_text.form-group{ class: "#{'has-error' if errors[question.code]}" }
2
+ %label
3
+ = question.question_text
4
+ = ' *' if question.required
5
+ = form.simple_fields_for :answers do |answer_form|
6
+ = answer_form.text_area question.code, value: answers[question.code], class: 'form-control'
7
+ - if errors[question.code]
8
+ .help-block.text-danger= errors[question.code]
@@ -0,0 +1,13 @@
1
+ .radio_group.form-group{ class: "#{'has-error' if errors[question.code]}" }
2
+ %label
3
+ = question.question_text
4
+ = ' *' if question.required
5
+ - question.labels.each do |label|
6
+ .radio
7
+ %label
8
+ - checked = (answers[question.code].to_s == label.value.to_s) || label.preselected
9
+ = form.simple_fields_for :answers do |answer_form|
10
+ = answer_form.radio_button question.code, label.value, checked: checked
11
+ = label.text
12
+ - if errors[question.code]
13
+ .help-block.text-danger= errors[question.code]
@@ -0,0 +1,27 @@
1
+ .radio_matrix.form-group{ class: "#{'has-error' if errors.present?}" }
2
+ %label{class: "#{'text-danger' if errors.present?}"}
3
+ = question.question_text
4
+ = ' *' if question.required
5
+ .table-responsive
6
+ %table.table
7
+ %thead
8
+ %tr
9
+ %th
10
+ - question.labels.each do |label|
11
+ %th{ width: "#{80 / question.labels.count}%" }
12
+ = label.text
13
+ %tbody
14
+ - question.sub_questions.each do |sub_question|
15
+ %tr
16
+ %td
17
+ = sub_question.text
18
+ - if errors[sub_question.code]
19
+ .help-block.text-danger= errors[sub_question.code]
20
+ - question.labels.each do |label|
21
+ - checked = answers[sub_question.code].to_s == label.value.to_s if answers[sub_question.code].present?
22
+ - checked ||= (label.preselected? ? true : false)
23
+ %td{ width: "#{80 / question.labels.count}%" }
24
+ %label
25
+ = form.simple_fields_for :answers do |answer_form|
26
+ = answer_form.radio_button sub_question.code, label.value, checked: checked
27
+ %span.hide-text= label.text
@@ -0,0 +1,8 @@
1
+ .short_text.form-group{ class: "#{'has-error' if errors[question.code]}" }
2
+ %label
3
+ = question.question_text
4
+ = ' *' if question.required
5
+ = form.simple_fields_for :answers do |answer_form|
6
+ = answer_form.text_field question.code, value: answers[question.code], class: 'form-control'
7
+ - if errors[question.code]
8
+ .help-block.text-danger= errors[question.code]
@@ -0,0 +1,16 @@
1
+ %h1.survey_title
2
+ = @version.survey_detail.title
3
+ %fieldset[@question_group]
4
+ %legend= @question_group.title
5
+ = simple_form_for(@session, url: helena.session_path(@session.token), as: :session) do |f|
6
+ - @questions.each do |question|
7
+ = render "#{question.class.to_s.underscore}", form: f, question: question, answers: @answers, errors: @errors
8
+
9
+ = hidden_field_tag :question_group, @question_group.id
10
+
11
+ - if @question_group.previous_items.any?
12
+ = link_to t('.back'), edit_session_path(@session.token, question_group: @question_group.previous_item), class: 'btn btn-default'
13
+
14
+ = f.submit class: 'btn btn-success pull-right', value: @question_group.last? ? t('.save') : t('.next')
15
+
16
+ = t('shared.required')
@@ -0,0 +1,5 @@
1
+ %h1.survey_title
2
+ = @version.survey_detail.title
3
+
4
+ .well
5
+ = t '.message'
@@ -0,0 +1,3 @@
1
+ %div[survey]
2
+ %h2= survey.newest_version.survey_detail.title
3
+ %p= survey.newest_version.survey_detail.description
@@ -0,0 +1,2 @@
1
+ %h1 Surveys
2
+ = render @surveys
data/bin/rails ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env ruby
2
+ # This command will automatically be run when you run "rails" with Rails 4 gems installed from the root of your application.
3
+
4
+ ENGINE_ROOT = File.expand_path('../..', __FILE__)
5
+ ENGINE_PATH = File.expand_path('../../lib/helena/engine', __FILE__)
6
+
7
+ require 'rails/all'
8
+ require 'rails/engine/commands'
@@ -0,0 +1,3 @@
1
+ data:
2
+ read:
3
+ - 'config/locales/**/*.yml'
@@ -0,0 +1,162 @@
1
+ # Use this setup block to configure all options available in SimpleForm.
2
+ SimpleForm.setup do |config|
3
+ # Wrappers are used by the form builder to generate a
4
+ # complete input. You can remove any component from the
5
+ # wrapper, change the order or even add your own to the
6
+ # stack. The options given below are used to wrap the
7
+ # whole input.
8
+ config.wrappers :default, class: :input,
9
+ hint_class: :field_with_hint,
10
+ error_class: :field_with_errors do |b|
11
+ ## Extensions enabled by default
12
+ # Any of these extensions can be disabled for a
13
+ # given input by passing: `f.input EXTENSION_NAME => false`.
14
+ # You can make any of these extensions optional by
15
+ # renaming `b.use` to `b.optional`.
16
+
17
+ # Determines whether to use HTML5 (:email, :url, ...)
18
+ # and required attributes
19
+ b.use :html5
20
+
21
+ # Calculates placeholders automatically from I18n
22
+ # You can also pass a string as f.input placeholder: "Placeholder"
23
+ b.use :placeholder
24
+
25
+ ## Optional extensions
26
+ # They are disabled unless you pass `f.input EXTENSION_NAME => :lookup`
27
+ # to the input. If so, they will retrieve the values from the model
28
+ # if any exists. If you want to enable the lookup for any of those
29
+ # extensions by default, you can change `b.optional` to `b.use`.
30
+
31
+ # Calculates maxlength from length validations for string inputs
32
+ b.optional :maxlength
33
+
34
+ # Calculates pattern from format validations for string inputs
35
+ b.optional :pattern
36
+
37
+ # Calculates min and max from length validations for numeric inputs
38
+ b.optional :min_max
39
+
40
+ # Calculates readonly automatically from readonly attributes
41
+ b.optional :readonly
42
+
43
+ ## Inputs
44
+ b.use :label_input
45
+ b.use :hint, wrap_with: { tag: :span, class: :hint }
46
+ b.use :error, wrap_with: { tag: :span, class: :error }
47
+
48
+ ## full_messages_for
49
+ # If you want to display the full error message for the attribute, you can
50
+ # use the component :full_error, like:
51
+ #
52
+ # b.use :full_error, wrap_with: { tag: :span, class: :error }
53
+ end
54
+
55
+ # The default wrapper to be used by the FormBuilder.
56
+ config.default_wrapper = :default
57
+
58
+ # Define the way to render check boxes / radio buttons with labels.
59
+ # Defaults to :nested for bootstrap config.
60
+ # inline: input + label
61
+ # nested: label > input
62
+ config.boolean_style = :nested
63
+
64
+ # Default class for buttons
65
+ config.button_class = 'btn'
66
+
67
+ # Method used to tidy up errors. Specify any Rails Array method.
68
+ # :first lists the first message for each field.
69
+ # Use :to_sentence to list all errors for each field.
70
+ # config.error_method = :first
71
+
72
+ # Default tag used for error notification helper.
73
+ config.error_notification_tag = :div
74
+
75
+ # CSS class to add for error notification helper.
76
+ config.error_notification_class = 'error_notification'
77
+
78
+ # ID to add for error notification helper.
79
+ # config.error_notification_id = nil
80
+
81
+ # Series of attempts to detect a default label method for collection.
82
+ # config.collection_label_methods = [ :to_label, :name, :title, :to_s ]
83
+
84
+ # Series of attempts to detect a default value method for collection.
85
+ # config.collection_value_methods = [ :id, :to_s ]
86
+
87
+ # You can wrap a collection of radio/check boxes in a pre-defined tag, defaulting to none.
88
+ # config.collection_wrapper_tag = nil
89
+
90
+ # You can define the class to use on all collection wrappers. Defaulting to none.
91
+ # config.collection_wrapper_class = nil
92
+
93
+ # You can wrap each item in a collection of radio/check boxes with a tag,
94
+ # defaulting to :span. Please note that when using :boolean_style = :nested,
95
+ # SimpleForm will force this option to be a label.
96
+ # config.item_wrapper_tag = :span
97
+
98
+ # You can define a class to use in all item wrappers. Defaulting to none.
99
+ # config.item_wrapper_class = nil
100
+
101
+ # How the label text should be generated altogether with the required text.
102
+ # config.label_text = lambda { |label, required, explicit_label| "#{required} #{label}" }
103
+
104
+ # You can define the class to use on all labels. Default is nil.
105
+ # config.label_class = nil
106
+
107
+ # You can define the class to use on all forms. Default is simple_form.
108
+ # config.form_class = :simple_form
109
+
110
+ # You can define which elements should obtain additional classes
111
+ # config.generate_additional_classes_for = [:wrapper, :label, :input]
112
+
113
+ # Whether attributes are required by default (or not). Default is true.
114
+ # config.required_by_default = true
115
+
116
+ # Tell browsers whether to use the native HTML5 validations (novalidate form option).
117
+ # These validations are enabled in SimpleForm's internal config but disabled by default
118
+ # in this configuration, which is recommended due to some quirks from different browsers.
119
+ # To stop SimpleForm from generating the novalidate option, enabling the HTML5 validations,
120
+ # change this configuration to true.
121
+ config.browser_validations = false
122
+
123
+ # Collection of methods to detect if a file type was given.
124
+ # config.file_methods = [ :mounted_as, :file?, :public_filename ]
125
+
126
+ # Custom mappings for input types. This should be a hash containing a regexp
127
+ # to match as key, and the input type that will be used when the field name
128
+ # matches the regexp as value.
129
+ # config.input_mappings = { /count/ => :integer }
130
+
131
+ # Custom wrappers for input types. This should be a hash containing an input
132
+ # type as key and the wrapper that will be used for all inputs with specified type.
133
+ # config.wrapper_mappings = { string: :prepend }
134
+
135
+ # Default priority for time_zone inputs.
136
+ # config.time_zone_priority = nil
137
+
138
+ # Default priority for country inputs.
139
+ # config.country_priority = nil
140
+
141
+ # When false, do not use translations for labels.
142
+ # config.translate_labels = true
143
+
144
+ # Automatically discover new inputs in Rails' autoload path.
145
+ # config.inputs_discovery = true
146
+
147
+ # Cache SimpleForm inputs discovery
148
+ # config.cache_discovery = !Rails.env.development?
149
+
150
+ # Default class for inputs
151
+ # config.input_class = nil
152
+
153
+ # Define the default class of the input wrapper of the boolean input.
154
+ config.boolean_label_class = 'checkbox'
155
+
156
+ # Defines if the default input wrapper class should be included in radio
157
+ # collection wrappers.
158
+ # config.include_default_input_wrapper_class = true
159
+
160
+ # Defines which i18n scope will be used in Simple Form.
161
+ # config.i18n_scope = 'simple_form'
162
+ end
@@ -0,0 +1,132 @@
1
+ # Use this setup block to configure all options available in SimpleForm.
2
+ SimpleForm.setup do |config|
3
+ config.error_notification_class = 'alert alert-danger'
4
+ config.button_class = 'btn btn-default'
5
+ config.boolean_label_class = nil
6
+
7
+ config.wrapper_mappings = { boolean: :vertical_boolean }
8
+
9
+ config.wrappers :vertical_form, tag: 'div', class: 'form-group', error_class: 'has-error' do |b|
10
+ b.use :html5
11
+ b.use :placeholder
12
+ b.optional :maxlength
13
+ b.optional :pattern
14
+ b.optional :min_max
15
+ b.optional :readonly
16
+ b.use :label, class: 'control-label'
17
+
18
+ b.use :input, class: 'form-control'
19
+ b.use :error, wrap_with: { tag: 'span', class: 'help-block' }
20
+ b.use :hint, wrap_with: { tag: 'p', class: 'help-block' }
21
+ end
22
+
23
+ config.wrappers :vertical_file_input, tag: 'div', class: 'form-group', error_class: 'has-error' do |b|
24
+ b.use :html5
25
+ b.use :placeholder
26
+ b.optional :maxlength
27
+ b.optional :readonly
28
+ b.use :label, class: 'control-label'
29
+
30
+ b.use :input
31
+ b.use :error, wrap_with: { tag: 'span', class: 'help-block' }
32
+ b.use :hint, wrap_with: { tag: 'p', class: 'help-block' }
33
+ end
34
+
35
+ config.wrappers :vertical_boolean, tag: 'div', class: 'form-group', error_class: 'has-error' do |b|
36
+ b.use :html5
37
+ b.optional :readonly
38
+
39
+ b.wrapper tag: 'div', class: 'checkbox' do |ba|
40
+ ba.use :label_input
41
+ end
42
+
43
+ b.use :error, wrap_with: { tag: 'span', class: 'help-block' }
44
+ b.use :hint, wrap_with: { tag: 'p', class: 'help-block' }
45
+ end
46
+
47
+ config.wrappers :vertical_radio_and_checkboxes, tag: 'div', class: 'form-group', error_class: 'has-error' do |b|
48
+ b.use :html5
49
+ b.optional :readonly
50
+ b.use :label, class: 'control-label'
51
+ b.use :input
52
+ b.use :error, wrap_with: { tag: 'span', class: 'help-block' }
53
+ b.use :hint, wrap_with: { tag: 'p', class: 'help-block' }
54
+ end
55
+
56
+ config.wrappers :horizontal_form, tag: 'div', class: 'form-group', error_class: 'has-error' do |b|
57
+ b.use :html5
58
+ b.use :placeholder
59
+ b.optional :maxlength
60
+ b.optional :pattern
61
+ b.optional :min_max
62
+ b.optional :readonly
63
+ b.use :label, class: 'col-sm-3 control-label'
64
+
65
+ b.wrapper tag: 'div', class: 'col-sm-9' do |ba|
66
+ ba.use :input, class: 'form-control'
67
+ ba.use :error, wrap_with: { tag: 'span', class: 'help-block' }
68
+ ba.use :hint, wrap_with: { tag: 'p', class: 'help-block' }
69
+ end
70
+ end
71
+
72
+ config.wrappers :horizontal_file_input, tag: 'div', class: 'form-group', error_class: 'has-error' do |b|
73
+ b.use :html5
74
+ b.use :placeholder
75
+ b.optional :maxlength
76
+ b.optional :readonly
77
+ b.use :label, class: 'col-sm-3 control-label'
78
+
79
+ b.wrapper tag: 'div', class: 'col-sm-9' do |ba|
80
+ ba.use :input
81
+ ba.use :error, wrap_with: { tag: 'span', class: 'help-block' }
82
+ ba.use :hint, wrap_with: { tag: 'p', class: 'help-block' }
83
+ end
84
+ end
85
+
86
+ config.wrappers :horizontal_boolean, tag: 'div', class: 'form-group', error_class: 'has-error' do |b|
87
+ b.use :html5
88
+ b.optional :readonly
89
+
90
+ b.wrapper tag: 'div', class: 'col-sm-offset-3 col-sm-9' do |wr|
91
+ wr.wrapper tag: 'div', class: 'checkbox' do |ba|
92
+ ba.use :label_input, class: 'col-sm-9'
93
+ end
94
+
95
+ wr.use :error, wrap_with: { tag: 'span', class: 'help-block' }
96
+ wr.use :hint, wrap_with: { tag: 'p', class: 'help-block' }
97
+ end
98
+ end
99
+
100
+ config.wrappers :horizontal_radio_and_checkboxes, tag: 'div', class: 'form-group', error_class: 'has-error' do |b|
101
+ b.use :html5
102
+ b.optional :readonly
103
+
104
+ b.use :label, class: 'col-sm-3 control-label'
105
+
106
+ b.wrapper tag: 'div', class: 'col-sm-9' do |ba|
107
+ ba.use :input
108
+ ba.use :error, wrap_with: { tag: 'span', class: 'help-block' }
109
+ ba.use :hint, wrap_with: { tag: 'p', class: 'help-block' }
110
+ end
111
+ end
112
+
113
+ config.wrappers :inline_form, tag: 'div', class: 'form-group', error_class: 'has-error' do |b|
114
+ b.use :html5
115
+ b.use :placeholder
116
+ b.optional :maxlength
117
+ b.optional :pattern
118
+ b.optional :min_max
119
+ b.optional :readonly
120
+ b.use :label, class: 'sr-only'
121
+
122
+ b.use :input, class: 'form-control'
123
+ b.use :error, wrap_with: { tag: 'span', class: 'help-block' }
124
+ b.use :hint, wrap_with: { tag: 'p', class: 'help-block' }
125
+ end
126
+
127
+ # Wrappers for forms and inputs using the Bootstrap toolkit.
128
+ # Check the Bootstrap docs (http://getbootstrap.com)
129
+ # to learn about the different styles for forms and inputs,
130
+ # buttons and other elements.
131
+ config.default_wrapper = :vertical_form
132
+ end