helena 0.3.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (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,20 @@
1
+ en:
2
+ shared:
3
+ delete_question: Are you sure?
4
+ delete: Delete
5
+ save: Save
6
+ edit: Edit
7
+ add: Add
8
+ show: Show
9
+ required: '* indicates required fields'
10
+ code_hint: The code must consist only of lowercase letters, numbers and underscores. Don't begin with a digit or an underscore and don't end with an underscore.
11
+ move_up: Move up
12
+ move_down: Move down
13
+ untitled: Untitled
14
+
15
+ actions:
16
+ deleted: "'%{resource}' successfully deleted"
17
+ updated: "'%{resource}' successfully updated"
18
+ created: "'%{resource}' successfully created"
19
+ error: Ooopss... something is wrong, please check your input
20
+
@@ -0,0 +1,14 @@
1
+ en:
2
+ mongoid:
3
+ models:
4
+ 'helena/label':
5
+ one: Label
6
+ other: Labels
7
+
8
+ attributes:
9
+ 'helena/label':
10
+ preselected: Selected
11
+ position: Position
12
+ _destroy: Delete
13
+ text: Text
14
+ value: Value
@@ -0,0 +1,47 @@
1
+ en:
2
+ mongoid:
3
+ models:
4
+ 'helena/question':
5
+ one: Question
6
+ other: Questions
7
+
8
+ 'helena/questions/short_text':
9
+ one: Short text
10
+ other: Short texts
11
+
12
+ 'helena/questions/long_text':
13
+ one: Long text
14
+ other: Long texts
15
+
16
+ 'helena/questions/static_text':
17
+ one: Static text
18
+ other: Static texts
19
+
20
+ 'helena/questions/radio_group':
21
+ one: Radio Group
22
+ other: Radio Groups
23
+
24
+ 'helena/questions/checkbox_group':
25
+ one: Checkbox Group
26
+ other: Checkbox Groups
27
+
28
+ 'helena/questions/radio_matrix':
29
+ one: Radio Matrix
30
+ other: Radio Matrice
31
+
32
+ 'helena/questions/checkbox_matrix':
33
+ one: Checkbox Matrix
34
+ other: Checkbox Matrice
35
+
36
+ attributes:
37
+ 'helena/question':
38
+ position: Position
39
+ code: Code
40
+ _type: Type
41
+ default_value: Default value
42
+
43
+ 'helena/questions/static_text':
44
+ position: Position
45
+ code: Code
46
+ type: Type
47
+ default_value: Static text
@@ -0,0 +1,11 @@
1
+ en:
2
+ mongoid:
3
+ models:
4
+ 'helena/question_group':
5
+ one: Question Group
6
+ other: Question Groups
7
+
8
+ attributes:
9
+ 'helena/question_group':
10
+ position: Position
11
+ title: Title
@@ -0,0 +1,10 @@
1
+ en:
2
+ mongoid:
3
+ models:
4
+ 'helena/session':
5
+ one: Session
6
+ other: Sessions
7
+
8
+ attributes:
9
+ 'helena/session':
10
+ completed: Completed?
@@ -0,0 +1,14 @@
1
+ en:
2
+ mongoid:
3
+ models:
4
+ 'helena/sub_question':
5
+ one: Sub Question
6
+ other: Sub Questions
7
+
8
+ attributes:
9
+ 'helena/sub_question':
10
+ selected: Selected
11
+ position: Position
12
+ _destroy: Delete
13
+ text: Text
14
+ value: Value
@@ -0,0 +1,6 @@
1
+ en:
2
+ mongoid:
3
+ models:
4
+ 'helena/survey':
5
+ one: Survey
6
+ other: Surveys
@@ -0,0 +1,12 @@
1
+ en:
2
+ mongoid:
3
+ models:
4
+ 'helena/version':
5
+ one: Version
6
+ other: Versions
7
+
8
+ attributes:
9
+ 'helena/version':
10
+ version: Version
11
+ notes: Notes
12
+ created_at: Created
@@ -0,0 +1,26 @@
1
+ en:
2
+ simple_form:
3
+ "yes": 'Yes'
4
+ "no": 'No'
5
+ required:
6
+ text: 'required'
7
+ mark: '*'
8
+ # You can uncomment the line below if you need to overwrite the whole required html.
9
+ # When using html, text and mark won't be used.
10
+ # html: '<abbr title="required">*</abbr>'
11
+ error_notification:
12
+ default_message: "Please review the problems below:"
13
+ # Labels and hints examples
14
+ # labels:
15
+ # defaults:
16
+ # password: 'Password'
17
+ # user:
18
+ # new:
19
+ # email: 'E-mail to sign in.'
20
+ # edit:
21
+ # email: 'E-mail.'
22
+ # hints:
23
+ # defaults:
24
+ # username: 'User name to sign in.'
25
+ # password: 'No special characters, please.'
26
+
@@ -0,0 +1,12 @@
1
+ en:
2
+ helena:
3
+ admin:
4
+ question_groups:
5
+ index:
6
+ empty: There are no question groups in this survey
7
+ add: Add a new question group
8
+ delete: Delete
9
+ edit: Edit
10
+ new: &new_question_group
11
+ new: New question group
12
+ create: *new_question_group
@@ -0,0 +1,16 @@
1
+ en:
2
+ helena:
3
+ admin:
4
+ radio_group:
5
+ only_one_preselection_allowed: only have one preselection
6
+ questions:
7
+ index:
8
+ empty: There are no questions in this question group
9
+ add: Add a new question
10
+ new: &new_question
11
+ new: New question
12
+ create: *new_question
13
+ labels:
14
+ labels: Labels
15
+ sub_questions:
16
+ options: Options
@@ -0,0 +1,11 @@
1
+ en:
2
+ helena:
3
+ admin:
4
+ sessions:
5
+ index:
6
+ empty: This survey has no sessions.
7
+ 'false': "No"
8
+ 'true': "Yes"
9
+ edit: Edit
10
+ export_sessions_csv: I want to export all session from this survey to my local computer as CSV
11
+ export_sessions_json: ... or as JSON
@@ -0,0 +1,10 @@
1
+ en:
2
+ helena:
3
+ admin:
4
+ surveys:
5
+ index:
6
+ add: Add a new survey
7
+ empty: There are no surveys available
8
+ new: &new_survey
9
+ new: New Survey
10
+ create: *new_survey
@@ -0,0 +1,8 @@
1
+ en:
2
+ helena:
3
+ admin:
4
+ versions:
5
+ index:
6
+ empty: No versions published at the moment.
7
+ new:
8
+ new: Publish new version
@@ -0,0 +1,9 @@
1
+ en:
2
+ helena:
3
+ sessions:
4
+ edit:
5
+ next: Next
6
+ save: Save
7
+ back: Back
8
+ end_message:
9
+ message: Thank you for participating.
data/config/routes.rb ADDED
@@ -0,0 +1,28 @@
1
+ Helena::Engine.routes.draw do
2
+ resources :surveys
3
+ resources :sessions, only: [:show, :edit, :update], param: :token
4
+
5
+ scope :admin, as: :admin, module: :admin do
6
+ concern :movable do
7
+ patch :move_up, on: :member
8
+ patch :move_down, on: :member
9
+ end
10
+
11
+ resources :surveys, concerns: :movable do
12
+ resources :sessions, only: [:index, :destroy]
13
+ resources :versions
14
+ resources :question_groups, concerns: :movable do
15
+ resources :questions, concerns: :movable
16
+ resource :questions do
17
+ resources :short_texts, module: 'questions'
18
+ resources :long_texts, module: 'questions'
19
+ resources :static_texts, module: 'questions'
20
+ resources :radio_groups, module: 'questions'
21
+ resources :checkbox_groups, module: 'questions'
22
+ resources :radio_matrix, module: 'questions'
23
+ resources :checkbox_matrix, module: 'questions'
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end
data/db/seeds.rb ADDED
@@ -0,0 +1,182 @@
1
+ require 'factory_girl'
2
+ require 'ffaker'
3
+ require 'database_cleaner'
4
+
5
+ include FactoryGirl::Syntax::Methods
6
+
7
+ # TODO: Codes smells because we have to assign the factory path here
8
+ FactoryGirl.definition_file_paths += ['spec/factories']
9
+ FactoryGirl.find_definitions
10
+
11
+ puts 'Cleaning database ...'.green
12
+ DatabaseCleaner.strategy = :truncation
13
+ DatabaseCleaner.clean
14
+
15
+ puts 'Seeding surveys ...'.green
16
+
17
+ def create_satisfaction_scale_survey
18
+ satisfaction_matrix = build :radio_matrix_question, code: :satisfaction,
19
+ required: true,
20
+ question_text: 'Below are five statements with which you may agree or disagree. Using the 1-7 scale below, indicate your agreement with each item by placing the appropriate number in the line preceding that item. Please be open and honest in your responding.',
21
+ required: true,
22
+ position: 1
23
+
24
+ satisfaction_matrix.labels << build(:label, position: 1, text: 'Strongly Disagree', value: 1)
25
+ satisfaction_matrix.labels << build(:label, position: 2, text: 'Disagree', value: 2)
26
+ satisfaction_matrix.labels << build(:label, position: 3, text: 'Slightly Disagree', value: 3)
27
+ satisfaction_matrix.labels << build(:label, position: 4, text: 'Neither Agree or Disagree', value: 4)
28
+ satisfaction_matrix.labels << build(:label, position: 5, text: 'Slightly Agree', value: 5)
29
+ satisfaction_matrix.labels << build(:label, position: 6, text: 'Agree', value: 6)
30
+ satisfaction_matrix.labels << build(:label, position: 7, text: 'Strongly Agree', value: 7)
31
+
32
+ satisfaction_matrix.sub_questions << build(:sub_question, text: 'In most ways my life is close to my ideal.', code: 'life_is_ideal', position: 1)
33
+ satisfaction_matrix.sub_questions << build(:sub_question, text: 'The conditions of my life are excellent.', code: 'condition', position: 2)
34
+ satisfaction_matrix.sub_questions << build(:sub_question, text: 'I am satisfied with life.', code: 'satisfied_with_life', position: 3)
35
+ satisfaction_matrix.sub_questions << build(:sub_question, text: 'So far I have gotten the important things I want in life.', code: 'important_things', position: 4)
36
+ satisfaction_matrix.sub_questions << build(:sub_question, text: 'If I could live my life over, I would change almost nothing.', code: 'nothing_to_change', position: 5)
37
+
38
+ satisfaction_details = build :question_group, questions: [satisfaction_matrix]
39
+
40
+
41
+ survey = create :survey, name: 'The Satisfaction with Life Scale', tag_list: 'satisfaction, psychology'
42
+ base_version = survey.versions.create version: 0
43
+ base_version.survey_detail = build :survey_detail, title: 'The Satisfaction with Life Scale',
44
+ description: 'A 5-item scale designed to measure global cognitive judgments of ones life satisfaction.'
45
+
46
+ base_version.question_groups << satisfaction_details
47
+ published_version = publish(base_version)
48
+
49
+ generate_sessions(survey, published_version)
50
+ end
51
+
52
+ def create_restaurant_survey
53
+ personal_details = build :question_group,title: 'Personal Details', position: 1
54
+
55
+ personal_details.questions << build(:short_text_question, code: :name,
56
+ question_text: "What's your name?",
57
+ required: true,
58
+ position: 1)
59
+
60
+ personal_details.questions << build(:short_text_question, code: :email,
61
+ question_text: "What's your E-Mail-Address?",
62
+ position: 2)
63
+
64
+ visit_interval = build :radio_group_question, code: :visit_interval,
65
+ question_text: 'How often do you visit the Swiss Chees Restaurant?',
66
+ required: true,
67
+ position: 3
68
+
69
+ visit_interval.labels << build(:label, position: 1, text: 'Just once', value: 1)
70
+ visit_interval.labels << build(:label, position: 2, text: 'Once a year', value: 2)
71
+ visit_interval.labels << build(:label, position: 3, text: 'Once a Month', value: 3)
72
+ visit_interval.labels << build(:label, position: 4, text: 'Once a week', value: 4)
73
+ visit_interval.labels << build(:label, position: 5, text: 'Daily', value:5)
74
+
75
+ food_allergy = build :checkbox_group_question, code: :food_allergy,
76
+ question_text: 'What kind of food allergy do you have?',
77
+ position: 4
78
+
79
+ food_allergy.sub_questions << build(:sub_question, value: 'true', text: 'Garlic', code: 'garlic', position: 1)
80
+ food_allergy.sub_questions << build(:sub_question, value: 'true', text: 'Oats', code: 'oat', position: 2)
81
+ food_allergy.sub_questions << build(:sub_question, value: 'true', text: 'Meat', code: 'meat', position: 3)
82
+ food_allergy.sub_questions << build(:sub_question, value: 'true', text: 'Milk', code: 'milk', position: 4)
83
+ food_allergy.sub_questions << build(:sub_question, value: 'true', text: 'Peanut', code: 'peanut', position: 5)
84
+ food_allergy.sub_questions << build(:sub_question, value: 'true', text: 'Fish / Shellfish', code: 'fish', position: 6)
85
+ food_allergy.sub_questions << build(:sub_question, value: 'true', text: 'Soy', code: 'soy', position: 7)
86
+ food_allergy.sub_questions << build(:sub_question, value: 'true', text: 'Wheat', code: 'wheat', position: 9)
87
+ food_allergy.sub_questions << build(:sub_question, value: 'true', text: 'Gluten', code: 'gluten', position: 10)
88
+ food_allergy.sub_questions << build(:sub_question, value: 'true', text: 'Egg', code: 'egg', position: 11)
89
+ food_allergy.sub_questions << build(:sub_question, value: 'true', text: 'Sulfites', code: 'sulfites', position: 12)
90
+
91
+ personal_details.questions << visit_interval
92
+ personal_details.questions << food_allergy
93
+
94
+
95
+ dinner = build :question_group, title: 'About the dinner', position: 2
96
+ dinner_satisfaction = build :radio_matrix_question, code: :satisfaction,
97
+ required: true,
98
+ question_text: 'Please rate the quality for each topic',
99
+ required: true,
100
+ position: 1
101
+
102
+ dinner_satisfaction.labels << build(:label, position: 1, text: ':-(', value: -1)
103
+ dinner_satisfaction.labels << build(:label, position: 2, text: ':-|', value: 0, preselected: true)
104
+ dinner_satisfaction.labels << build(:label, position: 3, text: ':-)', value: 1)
105
+
106
+ dinner_satisfaction.sub_questions << build(:sub_question, text: 'Food', code: 'food', position: 1)
107
+ dinner_satisfaction.sub_questions << build(:sub_question, text: 'Beverages', code: 'beverages', position: 2)
108
+ dinner_satisfaction.sub_questions << build(:sub_question, text: 'Service', code: 'service', position: 3)
109
+ dinner_satisfaction.sub_questions << build(:sub_question, text: 'Snacks', code: 'snacks', position: 4)
110
+ dinner_satisfaction.sub_questions << build(:sub_question, text: 'Cleanliness', code: 'cleanliness', position: 4)
111
+
112
+ dinner.questions << dinner_satisfaction
113
+
114
+ dinner.questions << build(:short_text_question, code: :catchphrase,
115
+ question_text: 'How would you describe the dinner with one word?',
116
+ required: true,
117
+ position: 2)
118
+
119
+ dinner.questions << build(:long_text_question, code: :feedback,
120
+ question_text: 'Feel free to give us additional feedback ...',
121
+ position: 3)
122
+
123
+ description = <<EOF
124
+ Thank you for your recent stay at our hotel. During your stay you dined at our 5-star Swiss Cheese Restaurant.
125
+ We're conducting a short survey to find out about your dining experience and what we might do to improve.
126
+ Please help us by completing this short survey."
127
+ EOF
128
+
129
+ survey = create :survey, name: 'Restaurant customer satisfaction', tag_list: 'restaurant, survey'
130
+ base_version = survey.versions.create version: 0, question_groups: [personal_details, dinner]
131
+ base_version.survey_detail = create :survey_detail, title: '5-star Swiss Cheese Restaurant customer satisfaction',
132
+ version: base_version,
133
+ description: description
134
+
135
+ published_version = publish(base_version)
136
+ generate_sessions(survey, published_version)
137
+ end
138
+
139
+ def default_session_report
140
+ haml = File.read(File.dirname(__FILE__) + '/../app/views/helena/admin/versions/default_session_report.html.haml')
141
+ Haml::Engine.new(haml).render
142
+ end
143
+
144
+ def publish(version)
145
+ published_version = Helena::VersionPublisher.publish(version)
146
+ published_version.notes = Faker::Lorem.paragraph(1)
147
+ published_version.session_report = default_session_report
148
+ published_version.save
149
+ published_version
150
+ end
151
+
152
+ def generate_sessions(survey, version)
153
+ 3.times {
154
+ survey.sessions << build(:session, version: version, updated_at: DateTime.now - rand(999), completed: false)
155
+ }
156
+
157
+ 3.times {
158
+ session = build :session, version: version, updated_at: DateTime.now - rand(999), completed: true
159
+ version.question_groups.map(&:questions).flatten.each do |question|
160
+ case question
161
+ when Helena::Questions::ShortText
162
+ session.answers << build(:string_answer, code: question.code, value: Faker::Skill.tech_skill )
163
+ when Helena::Questions::LongText
164
+ session.answers << build(:string_answer, code: question.code, value: Faker::Skill.tech_skill )
165
+ when Helena::Questions::RadioGroup
166
+ session.answers << Helena::Answer.build_generic(question.code, question.labels.sample.value, Faker::Internet.ip_v4_address)
167
+ when Helena::Questions::CheckboxGroup
168
+ question.sub_questions.sample(2).each do |sub_question|
169
+ session.answers << Helena::Answer.build_generic(sub_question.code, sub_question.value, Faker::Internet.ip_v4_address)
170
+ end
171
+ when Helena::Questions::RadioMatrix
172
+ question.sub_questions.each do |sub_question|
173
+ session.answers << Helena::Answer.build_generic(sub_question.code, question.labels.sample.value, Faker::Internet.ip_v4_address)
174
+ end
175
+ end
176
+ end
177
+ survey.sessions << session
178
+ }
179
+ end
180
+
181
+ create_satisfaction_scale_survey
182
+ create_restaurant_survey