survey_says 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (180) hide show
  1. data/MIT-LICENSE +20 -0
  2. data/README.rdoc +65 -0
  3. data/Rakefile +39 -0
  4. data/app/assets/images/survey_says/sprites.png +0 -0
  5. data/app/assets/javascripts/bootstrap.js.coffee +21 -0
  6. data/app/assets/javascripts/survey_says/answer_form.js +42 -0
  7. data/app/assets/javascripts/survey_says.js +2 -0
  8. data/app/assets/stylesheets/survey_says/bootstrap.css +356 -0
  9. data/app/assets/stylesheets/survey_says/general.css.erb +138 -0
  10. data/app/assets/stylesheets/survey_says/sprite.css.erb +1 -0
  11. data/app/assets/stylesheets/survey_says.css +1 -0
  12. data/app/controllers/survey_admin/answers_controller.rb +64 -0
  13. data/app/controllers/survey_admin/base_controller.rb +15 -0
  14. data/app/controllers/survey_admin/questionnaires_controller.rb +44 -0
  15. data/app/controllers/survey_admin/questions_controller.rb +61 -0
  16. data/app/controllers/survey_admin/survey_properties_controller.rb +50 -0
  17. data/app/helpers/survey_admin/answers_helper.rb +2 -0
  18. data/app/helpers/survey_admin/questionnaires_helper.rb +2 -0
  19. data/app/helpers/survey_admin/questions_helper.rb +2 -0
  20. data/app/helpers/survey_admin/survey_properties_helper.rb +2 -0
  21. data/app/models/answer.rb +21 -0
  22. data/app/models/question.rb +11 -0
  23. data/app/models/questionnaire.rb +3 -0
  24. data/app/models/score.rb +12 -0
  25. data/app/models/survey_image.rb +29 -0
  26. data/app/models/survey_property.rb +5 -0
  27. data/app/models/user_answer.rb +6 -0
  28. data/app/views/layouts/survey_admin.html.erb +39 -0
  29. data/app/views/survey_admin/answers/_form.html.erb +49 -0
  30. data/app/views/survey_admin/answers/_score.html.erb +13 -0
  31. data/app/views/survey_admin/answers/_survey_image.html.erb +10 -0
  32. data/app/views/survey_admin/answers/edit.html.erb +12 -0
  33. data/app/views/survey_admin/answers/index.html.erb +61 -0
  34. data/app/views/survey_admin/answers/new.html.erb +8 -0
  35. data/app/views/survey_admin/answers/show.html.erb +38 -0
  36. data/app/views/survey_admin/questionnaires/_form.html.erb +8 -0
  37. data/app/views/survey_admin/questionnaires/edit.html.erb +11 -0
  38. data/app/views/survey_admin/questionnaires/index.html.erb +18 -0
  39. data/app/views/survey_admin/questionnaires/new.html.erb +8 -0
  40. data/app/views/survey_admin/questionnaires/show.html.erb +17 -0
  41. data/app/views/survey_admin/questions/_answer.html.erb +13 -0
  42. data/app/views/survey_admin/questions/_form.html.erb +52 -0
  43. data/app/views/survey_admin/questions/edit.html.erb +11 -0
  44. data/app/views/survey_admin/questions/index.html.erb +30 -0
  45. data/app/views/survey_admin/questions/new.html.erb +10 -0
  46. data/app/views/survey_admin/questions/show.html.erb +29 -0
  47. data/app/views/survey_admin/survey_properties/_form.html.erb +8 -0
  48. data/app/views/survey_admin/survey_properties/edit.html.erb +11 -0
  49. data/app/views/survey_admin/survey_properties/index.html.erb +19 -0
  50. data/app/views/survey_admin/survey_properties/new.html.erb +8 -0
  51. data/app/views/survey_admin/survey_properties/show.html.erb +12 -0
  52. data/config/routes.rb +17 -0
  53. data/db/development.sqlite3 +0 -0
  54. data/db/migrate/20111208181247_create_questions.rb +11 -0
  55. data/db/migrate/20111208181414_create_answers.rb +14 -0
  56. data/db/migrate/20111208181429_create_survey_properties.rb +9 -0
  57. data/db/migrate/20111208181449_create_scores.rb +15 -0
  58. data/db/migrate/20111211175518_create_user_answers.rb +12 -0
  59. data/db/migrate/20111211175604_create_questionnaires.rb +8 -0
  60. data/db/migrate/20111211180011_add_questionaire_id_to_questions.rb +7 -0
  61. data/db/migrate/20111213185612_create_survey_images.rb +15 -0
  62. data/lib/generators/survey_models_generator.rb +32 -0
  63. data/lib/generators/survey_says_generator.rb +60 -0
  64. data/lib/survey_says/acts_as_survey_says.rb +59 -0
  65. data/lib/survey_says/core_ext.rb +0 -0
  66. data/lib/survey_says/engine.rb +4 -0
  67. data/lib/survey_says/version.rb +3 -0
  68. data/lib/survey_says.rb +7 -0
  69. data/lib/tasks/survey_says_tasks.rake +4 -0
  70. data/test/acts_as_survey_test.rb +87 -0
  71. data/test/dummy/Rakefile +7 -0
  72. data/test/dummy/app/assets/javascripts/application.js +12 -0
  73. data/test/dummy/app/assets/stylesheets/application.css +10 -0
  74. data/test/dummy/app/controllers/application_controller.rb +3 -0
  75. data/test/dummy/app/helpers/application_helper.rb +2 -0
  76. data/test/dummy/app/helpers/error_messages_helper.rb +23 -0
  77. data/test/dummy/app/helpers/layout_helper.rb +22 -0
  78. data/test/dummy/app/views/layouts/application.html.erb +19 -0
  79. data/test/dummy/config/application.rb +45 -0
  80. data/test/dummy/config/boot.rb +10 -0
  81. data/test/dummy/config/database.yml +25 -0
  82. data/test/dummy/config/environment.rb +5 -0
  83. data/test/dummy/config/environments/development.rb +39 -0
  84. data/test/dummy/config/environments/production.rb +69 -0
  85. data/test/dummy/config/environments/test.rb +48 -0
  86. data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
  87. data/test/dummy/config/initializers/inflections.rb +10 -0
  88. data/test/dummy/config/initializers/mime_types.rb +5 -0
  89. data/test/dummy/config/initializers/secret_token.rb +7 -0
  90. data/test/dummy/config/initializers/session_store.rb +8 -0
  91. data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
  92. data/test/dummy/config/locales/en.yml +5 -0
  93. data/test/dummy/config/routes.rb +58 -0
  94. data/test/dummy/config.ru +4 -0
  95. data/test/dummy/db/development.sqlite3 +0 -0
  96. data/test/dummy/db/migrate/20111010112000_create_users.rb +7 -0
  97. data/test/dummy/db/schema.rb +82 -0
  98. data/test/dummy/db/test.sqlite3 +0 -0
  99. data/test/dummy/log/development.log +11108 -0
  100. data/test/dummy/log/test.log +12731 -0
  101. data/test/dummy/public/404.html +26 -0
  102. data/test/dummy/public/422.html +26 -0
  103. data/test/dummy/public/500.html +26 -0
  104. data/test/dummy/public/assets/products/1/large/image01.jpg +0 -0
  105. data/test/dummy/public/assets/products/1/mini/image01.jpg +0 -0
  106. data/test/dummy/public/assets/products/1/original/image01.jpg +0 -0
  107. data/test/dummy/public/assets/products/1/product/image01.jpg +0 -0
  108. data/test/dummy/public/assets/products/1/small/image01.jpg +0 -0
  109. data/test/dummy/public/assets/products/2/large/delete.png +0 -0
  110. data/test/dummy/public/assets/products/2/mini/delete.png +0 -0
  111. data/test/dummy/public/assets/products/2/original/delete.png +0 -0
  112. data/test/dummy/public/assets/products/2/product/delete.png +0 -0
  113. data/test/dummy/public/assets/products/2/small/delete.png +0 -0
  114. data/test/dummy/public/favicon.ico +0 -0
  115. data/test/dummy/public/stylesheets/application.css +83 -0
  116. data/test/dummy/script/rails +6 -0
  117. data/test/dummy/tmp/cache/assets/BF8/2D0/sprockets%2F061365584f62ff829333e404d3566614 +0 -0
  118. data/test/dummy/tmp/cache/assets/C17/0E0/sprockets%2F976726a8626e66694980f590bc387807 +0 -0
  119. data/test/dummy/tmp/cache/assets/C4B/B20/sprockets%2F75e3756ba610340b7d9e0501e2738815 +0 -0
  120. data/test/dummy/tmp/cache/assets/C74/4F0/sprockets%2F2b3933c1c8b63193cbf460019680641c +0 -0
  121. data/test/dummy/tmp/cache/assets/C8B/250/sprockets%2F1a17d2874364d2e99677211577ccbd29 +0 -0
  122. data/test/dummy/tmp/cache/assets/CBA/690/sprockets%2F4b4be759f94f48654023ccf82558c202 +0 -0
  123. data/test/dummy/tmp/cache/assets/CD1/FA0/sprockets%2F887d02a66c0be114c4d845e0e31b5046 +0 -0
  124. data/test/dummy/tmp/cache/assets/CDE/2F0/sprockets%2F01f7a04861b8d5c6ff5259b931b513a8 +0 -0
  125. data/test/dummy/tmp/cache/assets/CDE/990/sprockets%2Fd076ad241795a6dce56456d661c3c540 +0 -0
  126. data/test/dummy/tmp/cache/assets/CE8/960/sprockets%2F055e1879b589151f8c914fd4d2faa451 +0 -0
  127. data/test/dummy/tmp/cache/assets/CEA/E30/sprockets%2F3b6e44c89e8821a8ade264ba89536306 +0 -0
  128. data/test/dummy/tmp/cache/assets/CFB/EC0/sprockets%2F7b68fde8e3e0b2496451649499a339fd +0 -0
  129. data/test/dummy/tmp/cache/assets/D0A/650/sprockets%2F3892c73640ba239ad055eb70adc7d376 +0 -0
  130. data/test/dummy/tmp/cache/assets/D1A/400/sprockets%2F3db3e35d06c8ee7eea759a5561609176 +0 -0
  131. data/test/dummy/tmp/cache/assets/D32/A10/sprockets%2F13fe41fee1fe35b49d145bcc06610705 +0 -0
  132. data/test/dummy/tmp/cache/assets/D35/7F0/sprockets%2Fb0bf073fb61c9ab736703d17e7223d7c +0 -0
  133. data/test/dummy/tmp/cache/assets/D39/260/sprockets%2F1c93edd8921f9c9dd8f9b391a8576996 +0 -0
  134. data/test/dummy/tmp/cache/assets/D44/8F0/sprockets%2Fd4882ae3d2b7e5c4a792a962b96d0c53 +0 -0
  135. data/test/dummy/tmp/cache/assets/D45/380/sprockets%2Fdcec95a29ee086a4283091e0671cee84 +0 -0
  136. data/test/dummy/tmp/cache/assets/D4F/990/sprockets%2F448cea593d65f06453fd58c813be85ec +0 -0
  137. data/test/dummy/tmp/cache/assets/D54/ED0/sprockets%2F71c9fa01091d432b131da3bb73faf3d4 +0 -0
  138. data/test/dummy/tmp/cache/assets/D5C/B80/sprockets%2F25fb254ba6af4c046abe0d457470b6b4 +0 -0
  139. data/test/dummy/tmp/cache/assets/D5F/B70/sprockets%2F7df07cffaafc819374564f89a9779d33 +0 -0
  140. data/test/dummy/tmp/cache/assets/D6A/A80/sprockets%2F65d4f0c9709bb65e6f0d20c4d33f6bd0 +0 -0
  141. data/test/dummy/tmp/cache/assets/D7D/470/sprockets%2Fc4f8c42e5a8d6a013a72e1e4dee99879 +0 -0
  142. data/test/dummy/tmp/cache/assets/D84/210/sprockets%2Fabd0103ccec2b428ac62c94e4c40b384 +0 -0
  143. data/test/dummy/tmp/cache/assets/D90/570/sprockets%2Fc28a3557e8dc87e9666afd75e7a578fa +0 -0
  144. data/test/dummy/tmp/cache/assets/D9F/AA0/sprockets%2F5faefd4c3b0d325d6046fc76bc634f93 +0 -0
  145. data/test/dummy/tmp/cache/assets/DA9/CA0/sprockets%2F65298b70d60c89a7fc08cea4dee62f2d +0 -0
  146. data/test/dummy/tmp/cache/assets/DE4/230/sprockets%2F2edbb30dab2c30af6660456f54aca6cb +0 -0
  147. data/test/dummy/tmp/cache/assets/E04/890/sprockets%2F2f5173deea6c795b8fdde723bb4b63af +0 -0
  148. data/test/dummy/tmp/cache/assets/E06/600/sprockets%2Fe4ef2dbc6691ad7f906b8cbca636e45d +0 -0
  149. data/test/dummy/tmp/cache/assets/E23/5C0/sprockets%2Ffdb40ef1a5e8bbeda0c5732a545cc8f3 +0 -0
  150. data/test/dummy/tmp/cache/assets/E36/A40/sprockets%2Fbb57cff6dedd610b280b8fbfd9285b5f +0 -0
  151. data/test/factories/answers.rb +6 -0
  152. data/test/factories/questionnaires.rb +3 -0
  153. data/test/factories/questions.rb +12 -0
  154. data/test/factories/scores.rb +5 -0
  155. data/test/factories/survey_images.rb +9 -0
  156. data/test/factories/survey_properties.rb +3 -0
  157. data/test/factories/user_answers.rb +4 -0
  158. data/test/factories/users.rb +3 -0
  159. data/test/fixtures/answers.yml +13 -0
  160. data/test/fixtures/questionnaires.yml +7 -0
  161. data/test/fixtures/questions.yml +11 -0
  162. data/test/fixtures/scores.yml +11 -0
  163. data/test/fixtures/survey_images.yml +19 -0
  164. data/test/fixtures/survey_properties.yml +7 -0
  165. data/test/fixtures/user_answers.yml +9 -0
  166. data/test/functional/survey_admin/answers_controller_test.rb +71 -0
  167. data/test/functional/survey_admin/questionnaires_controller_test.rb +52 -0
  168. data/test/functional/survey_admin/questions_controller_test.rb +61 -0
  169. data/test/functional/survey_admin/survey_properties_controller_test.rb +59 -0
  170. data/test/integration/navigation_test.rb +10 -0
  171. data/test/survey_says_test.rb +7 -0
  172. data/test/test_helper.rb +16 -0
  173. data/test/unit/answer_test.rb +12 -0
  174. data/test/unit/question_test.rb +7 -0
  175. data/test/unit/questionaire_test.rb +7 -0
  176. data/test/unit/score_test.rb +7 -0
  177. data/test/unit/survey_image_test.rb +7 -0
  178. data/test/unit/survey_property_test.rb +7 -0
  179. data/test/unit/user_answer_test.rb +7 -0
  180. metadata +420 -0
@@ -0,0 +1,49 @@
1
+
2
+ <%= f.error_messages %>
3
+ <ul>
4
+ <li class="field">
5
+ <%= f.label :question_id %>
6
+ <%= f.hidden_field :question_id %>
7
+ </li>
8
+ <li class="field">
9
+ <%= f.label :details %>
10
+ <%= f.text_area :details %>
11
+ </li>
12
+ <li class="field">
13
+ <%= f.label :active %>
14
+ <%= f.check_box :active %>
15
+ </li>
16
+ <li class="field">
17
+ <%= f.label :position %>
18
+ <%= f.number_field :position %>
19
+ </li>
20
+ </ul>
21
+ <% if @survey_image %>
22
+ <%= f.fields_for :survey_images, @survey_image, :child_index => "new_survey_images" do |survey_images_f|%>
23
+ <div class='<%= @survey_image.new_record? ? 'new_fields' : 'fields' %> answer-div'>
24
+ <h3>Image</h3>
25
+ <%= render :partial => 'survey_image', :locals => { :f => survey_images_f } %>
26
+ <div class='clearfix'></div>
27
+ </div>
28
+ <% end %>
29
+ <% end %>
30
+
31
+ <%= f.fields_for :scores, :child_index => "new_scores" do |score_f|%>
32
+ <div class='fields answer-div'>
33
+ <%= render :partial => 'score', :locals => { :f => score_f } %>
34
+ <div class='clearfix'></div>
35
+ </div>
36
+ <% end %>
37
+
38
+ <p>
39
+ <%= link_to "New Property", '#add_answer', :class => 'add_association', 'data-association' => "scores" %>
40
+ </p>
41
+
42
+ <div id='scores_fields_template' style='display:none'>
43
+ <div class='new_fields answer-div'>
44
+ <%= f.fields_for :scores, Score.new, :child_index => "new_scores" do |score_f|%>
45
+ <%= render :partial => 'score', :locals => { :f => score_f } %>
46
+ <% end %>
47
+ <div class='clearfix'></div>
48
+ </div>
49
+ </div>
@@ -0,0 +1,13 @@
1
+ <ul>
2
+ <li>
3
+ <%= f.label :survey_property, 'Property' %>
4
+ <%= f.select :survey_property_id, survey_properties %>
5
+ </li>
6
+ <li>
7
+ <%= f.label :value %>
8
+ <%= f.number_field :value %>
9
+ </li>
10
+ </ul>
11
+ <div style='float:right;'>
12
+ <%= f.hidden_field(:_destroy) + link_to('remove', "javascript:void(0)", :class => "remove_child") %>
13
+ </div>
@@ -0,0 +1,10 @@
1
+
2
+ <p class='field'>
3
+ Position: <%= f.select :position, [1,2,3,4,5,6,7,8,9] %><br/>
4
+ Caption: <%= f.text_field :caption %><br/>
5
+ Photo: <%= f.file_field :photo %>
6
+ </p>
7
+
8
+ <% if !f.object.new_record? %>
9
+ <%= image_tag f.object.photo.url(:small) %>
10
+ <% end %>
@@ -0,0 +1,12 @@
1
+ <h1> Edit Answer </h1>
2
+
3
+ <%= form_for @answer, :url => [:survey_admin, @answer.question, @answer] do |f| %>
4
+ <%= render :partial => 'form', :locals => {:f => f},
5
+ :html => {:class => '', :multipart => true} %>
6
+ <div class="actions"><%= f.submit 'Update' , :class => 'button' %></div>
7
+ <% end %>
8
+
9
+ <p>
10
+ <%= link_to "Show", [:survey_admin, @answer.question, @answer], :class => 'button' %> |
11
+ <%= link_to "View All", survey_admin_question_answers_path(@answer.question), :class => 'button' %>
12
+ </p>
@@ -0,0 +1,61 @@
1
+
2
+ <p>
3
+ <label style='padding: 0px;'>Question:</label>
4
+ &nbsp; <%= @question.details %>
5
+ </p>
6
+
7
+ <h1> Answers </h1>
8
+
9
+
10
+ <table>
11
+ <thead>
12
+ <tr>
13
+ <th>Details</th>
14
+ <th>Active</th>
15
+ <th>Position</th>
16
+ <th></th>
17
+ <th></th>
18
+ <th></th>
19
+ </tr>
20
+ </thead>
21
+ <% for answer in @answers %>
22
+ <tr>
23
+ <td><%= truncate(answer.details, :limit => 55) %></td>
24
+ <td><%= answer.active.to_s %></td>
25
+ <td><%= answer.position %></td>
26
+ <td><%= link_to "Show", [:survey_admin, @question, answer] %></td>
27
+ <td><%= link_to "", edit_survey_admin_question_answer_path(@question, answer),
28
+ :class => 'ss_sprite ss_application_edit' %></td>
29
+ <td><%= link_to "", [:survey_admin, @question, answer],
30
+ :confirm => 'Are you sure?',
31
+ :method => :delete,
32
+ :class => 'ss_sprite ss_cross' %></td>
33
+ </tr>
34
+ <tbody>
35
+ <tr class='no-divider'>
36
+ <td colspan=6>
37
+ <div class=' row'><label >Properties:</label></div>
38
+ <% if answer.scores.empty? %>
39
+ <%= link_to 'No properties...', edit_survey_admin_question_answer_path(@question, answer) %>
40
+ <% else %>
41
+ <ul class='span7'>
42
+ <% answer.scores.each do |score| %>
43
+ <li style=''>
44
+ <span class='span4' style='padding:0px 5px 0 0;'> <%= score.survey_property.name %>:</span>
45
+ <%= score.value %>
46
+ </li>
47
+ <% end %>
48
+ </ul>
49
+ <% end %>
50
+ <div class='span3'>
51
+ <%= image_tag answer.image unless answer.image.blank? %>
52
+ </div>
53
+ </td>
54
+ </tr>
55
+ </tbody>
56
+ <% end %>
57
+ </table>
58
+
59
+ <%#= will_paginate @answers %>
60
+
61
+ <p><%= link_to "New Answer", new_survey_admin_question_answer_path(@question), :class => 'button' %></p>
@@ -0,0 +1,8 @@
1
+ <h1> New Answer </h1>
2
+
3
+ <%= form_for @answer, :url => survey_admin_question_answers_path(@answer.question, @answer) do |f| %>
4
+ <%= render :partial => 'form', :locals => {:f => f} %>
5
+ <div class="actions"><%= f.submit 'Create' , :class => 'button' %></div>
6
+ <% end %>
7
+
8
+ <p><%= link_to "Back to List", survey_admin_question_answers_path(@answer.question), :class => 'button' %></p>
@@ -0,0 +1,38 @@
1
+ <h1> Answer </h1>
2
+
3
+ <p>
4
+ <strong>Question:</strong>
5
+ <%= link_to @answer.question.details, survey_admin_question_path(@answer.question) %>
6
+ </p>
7
+
8
+ <p>
9
+ <strong>Details:</strong>
10
+ <%= @answer.details %>
11
+ </p>
12
+ <p>
13
+ <strong>Active:</strong>
14
+ <%= @answer.active %>
15
+ </p>
16
+ <p>
17
+ <strong>Position:</strong>
18
+ <%= @answer.position %>
19
+ </p>
20
+ <p>
21
+ <strong>Properties:</strong>
22
+ <ul class='span7'>
23
+ <% @answer.scores.each do |score| %>
24
+ <li style='padding:6px;'>
25
+ <label style='padding:0px 5px 0 0;'> <%= score.survey_property.name %>:</label>
26
+ <%= score.value %>
27
+ </li>
28
+ <% end %>
29
+ </ul>
30
+ <div class='span3'>
31
+ <%= image_tag @answer.image unless @answer.image.blank? %>
32
+ </div>
33
+ </p>
34
+ <p>
35
+ <%= link_to "Edit", edit_survey_admin_question_answer_path(@answer.question, @answer), :class => 'button' %> |
36
+ <%= link_to "Destroy", [:survey_admin, @answer.question, @answer], :confirm => 'Are you sure?', :method => :delete, :class => 'button' %> |
37
+ <%= link_to "View Answers", survey_admin_question_answers_path(@answer.question), :class => 'button' %>
38
+ </p>
@@ -0,0 +1,8 @@
1
+
2
+ <%= f.error_messages %>
3
+ <ul>
4
+ <li class="field">
5
+ <%= f.label :name %>
6
+ <%= f.text_field :name %>
7
+ </li>
8
+ </ul>
@@ -0,0 +1,11 @@
1
+ <h1> Edit Questionnaire </h1>
2
+
3
+ <%= form_for @questionnaire, :url => [:survey_admin, @questionnaire] do |f| %>
4
+ <%= render :partial => 'form', :locals => {:f => f} %>
5
+ <div class="actions"><%= f.submit 'Update' , :class => 'button' %></div>
6
+ <% end %>
7
+
8
+ <p>
9
+ <%= link_to "Show", [:survey_admin, @questionnaire], :class => 'button' %> |
10
+ <%= link_to "View All", survey_admin_questionnaires_path, :class => 'button' %>
11
+ </p>
@@ -0,0 +1,18 @@
1
+ <h1> Questionnaires </h1>
2
+
3
+ <table>
4
+ <tr>
5
+ <th>Name</th>
6
+ </tr>
7
+ <% for questionnaire in @questionnaires %>
8
+ <tr>
9
+ <td><%= questionnaire.name %></td>
10
+ <td><%= link_to "Show", [:survey_admin, questionnaire] %></td>
11
+ <td><%= link_to "", edit_survey_admin_questionnaire_path(questionnaire), :class => 'ss_sprite ss_application_edit' %></td>
12
+ </tr>
13
+ <% end %>
14
+ </table>
15
+
16
+ <%#= will_paginate @questionnaires %>
17
+
18
+ <p><%= link_to "New Questionnaire", new_survey_admin_questionnaire_path, :class => 'button' %></p>
@@ -0,0 +1,8 @@
1
+ <h1> New Questionnaire </h1>
2
+
3
+ <%= form_for @questionnaire, :url => survey_admin_questionnaires_path(@questionnaire) do |f| %>
4
+ <%= render :partial => 'form', :locals => {:f => f} %>
5
+ <div class="actions"><%= f.submit 'Create' , :class => 'button' %></div>
6
+ <% end %>
7
+
8
+ <p><%= link_to "Back to List", survey_admin_questionnaires_path, :class => 'button' %></p>
@@ -0,0 +1,17 @@
1
+ <h1> Questionnaire (<%= @questionnaire.name %>)</h1>
2
+
3
+ <% if @questionnaire.questions.empty? %>
4
+ <p>There currently aren't any questions. </p>
5
+ <% else %>
6
+ <ul>
7
+ <% @questionnaire.questions.each do |question| %>
8
+ <li> <%= question.details %> </li>
9
+ <% end %>
10
+ </ul>
11
+ <% end %>
12
+
13
+ <p><%= link_to "New Question", new_survey_admin_question_path, :class => 'button' %></p>
14
+ <p>
15
+ <%= link_to "Edit", edit_survey_admin_questionnaire_path(@questionnaire), :class => 'button' %> |
16
+ <%= link_to "View Questionnaires", survey_admin_questionnaires_path, :class => 'button' %>
17
+ </p>
@@ -0,0 +1,13 @@
1
+ <ul>
2
+ <li>
3
+ <%= f.label :details, 'Answer' %>
4
+ <%= f.text_area :details %>
5
+ </li>
6
+ <li>
7
+ <%= f.label :position, 'position' %>
8
+ <%= f.number_field :position %>
9
+ </li>
10
+ </ul>
11
+ <div style='float:right;'>
12
+ <%= f.hidden_field(:_destroy) + link_to('remove', "javascript:void(0)", :class => "remove_child") %>
13
+ </div>
@@ -0,0 +1,52 @@
1
+ <% if @question.errors.any? %>
2
+ <div id="error_explanation">
3
+ <h2><%= pluralize(@question.errors.count, "error") %> prohibited this question from being saved:</h2>
4
+
5
+ <ul>
6
+ <% @question.errors.full_messages.each do |msg| %>
7
+ <li><%= msg %></li>
8
+ <% end %>
9
+ </ul>
10
+ </div>
11
+ <% end %>
12
+
13
+ <div class="field">
14
+ <%= f.label :details %><br />
15
+ <%= f.text_area :details %>
16
+ </div>
17
+
18
+ <div class="field">
19
+ <%= f.label :position %><br />
20
+ <%= f.number_field :position %>
21
+ </div>
22
+
23
+ <div class="field">
24
+ <%= f.label :questionnaire_id %><br />
25
+ <%= f.select :questionnaire_id, questionnaire_options, :include_blank => true %>
26
+ </div>
27
+
28
+ <div class=''>
29
+ <%= f.fields_for :answers do |answer_fields| %>
30
+ <div class='fields answer-div'>
31
+ <%= render :partial => 'answer', :locals => { :f => answer_fields } %>
32
+ <div class='clearfix'></div>
33
+ </div>
34
+ <% end %>
35
+ </div>
36
+
37
+ <p>
38
+ <%= link_to "New Answer", '#add_answer', :class => 'add_association', 'data-association' => "answers" %>
39
+ </p>
40
+
41
+ <div id='answers_fields_template' style='display:none'>
42
+ <div class='new_fields answer-div'>
43
+ <%= f.fields_for :answers, Answer.new, :child_index => "new_answers" do |a_f|%>
44
+ <%= render :partial => 'answer', :locals => { :f => a_f } %>
45
+ <% end %>
46
+ <div class='clearfix'></div>
47
+ </div>
48
+ </div>
49
+
50
+ <div class="actions">
51
+ <%= f.submit %>
52
+ </div>
@@ -0,0 +1,11 @@
1
+ <h1> Edit Question </h1>
2
+
3
+ <div class='span-10'>
4
+ <%= form_for(@question, :url => survey_admin_question_path(@question)) do |f| %>
5
+ <%= render :partial => 'form', :locals => {:f => f} %>
6
+ <% end %>
7
+
8
+ <%= link_to 'Show', survey_admin_question_path( @question ), :class => 'button' %> |
9
+ <%= link_to 'View All', survey_admin_questions_path, :class => 'button' %>
10
+ </div>
11
+ <div class='clearfix'></div>
@@ -0,0 +1,30 @@
1
+ <h1> Questions </h1>
2
+
3
+ <table>
4
+ <thead>
5
+ <tr>
6
+ <th>Details</th>
7
+ <th>Status</th>
8
+ <th></th>
9
+ <th></th>
10
+ <th></th>
11
+ </tr>
12
+ </thead>
13
+ <% for question in @questions %>
14
+ <tr>
15
+ <td><%= truncate(question.details, :length => 35) %></td>
16
+ <td><%= question.active? ? 'Active' : 'Inactive' %></td>
17
+ <td><%= link_to "Show", survey_admin_question_answers_path(question) %></td>
18
+ <td><%= link_to "Edit", edit_survey_admin_question_path(question) %></td>
19
+ <td>
20
+ <% if question.active? %>
21
+ <%= link_to "Inactivate", survey_admin_question_path(question),
22
+ :confirm => 'Are you sure?',
23
+ :method => :delete %>
24
+ <% end %>
25
+ </td>
26
+ </tr>
27
+ <% end %>
28
+ </table>
29
+
30
+ <p><%= link_to "New Question", new_survey_admin_question_path, :class => 'button' %></p>
@@ -0,0 +1,10 @@
1
+ <h1> New Question </h1>
2
+
3
+ <div class='span-10'>
4
+ <%= form_for(@question, :url => survey_admin_questions_path(@question)) do |f| %>
5
+ <%= render :partial => 'form', :locals => {:f => f} %>
6
+ <% end %>
7
+
8
+ <%= link_to 'Back to List', survey_admin_questions_path, :class => 'button' %>
9
+ </div>
10
+ <div class='clearfix'></div>
@@ -0,0 +1,29 @@
1
+ <h1> Question </h1>
2
+
3
+ <p>
4
+ <%= @question.details %>
5
+ </p>
6
+
7
+ <h3> <%= link_to 'Answers', survey_admin_question_answers_url(@question) %> </h3>
8
+
9
+ <% if @question.answers.empty? %>
10
+ There are currently no answers for this question.
11
+ <% else %>
12
+ <ul id='answers_to_question'>
13
+ <% @question.answers.each do |answer| %>
14
+ <li data-answer_id=<%= answer.id %> >
15
+ <%= link_to answer.display_position, survey_admin_question_answer_url(@question, answer) %>)
16
+ <%= answer.details %><br/><br/><br/>
17
+ </li>
18
+ <% end %>
19
+ </ul>
20
+ <% end %>
21
+
22
+ <p>
23
+ <%= link_to "Edit", edit_survey_admin_question_path(@question), :class => 'button' %> |
24
+ <%= link_to "Inactivate", survey_admin_question_path(@question),
25
+ :confirm => 'Are you sure?',
26
+ :method => :delete,
27
+ :class => 'button' %> |
28
+ <%= link_to "View Questions", survey_admin_questions_path, :class => 'button' %>
29
+ </p>
@@ -0,0 +1,8 @@
1
+
2
+ <%= f.error_messages %>
3
+ <ul>
4
+ <li class="field">
5
+ <%= f.label :name %>
6
+ <%= f.text_field :name %>
7
+ </li>
8
+ </ul>
@@ -0,0 +1,11 @@
1
+ <h1> Edit Property </h1>
2
+
3
+ <%= form_for @survey_property, :url => [:survey_admin, @survey_property] do |f| %>
4
+ <%= render :partial => 'form', :locals => {:f => f} %>
5
+ <div class="actions"><%= f.submit 'Update' , :class => 'button' %></div>
6
+ <% end %>
7
+
8
+ <p>
9
+ <%= link_to "Show", [:survey_admin, @survey_property], :class => 'button' %> |
10
+ <%= link_to "View Properties", survey_admin_survey_properties_path, :class => 'button' %>
11
+ </p>
@@ -0,0 +1,19 @@
1
+ <h1> Properties </h1>
2
+
3
+ <table>
4
+ <tr>
5
+ <th>Name</th>
6
+ </tr>
7
+ <% for survey_property in @survey_properties %>
8
+ <tr>
9
+ <td><%= survey_property.name %></td>
10
+ <td><%= link_to "Show", [:survey_admin, survey_property] %></td>
11
+ <td><%= link_to "", edit_survey_admin_survey_property_path(survey_property), :class => 'ss_sprite ss_application_edit' %></td>
12
+ <td><%= link_to "", [:survey_admin, survey_property], :confirm => 'Are you sure?', :method => :delete, :class => 'ss_sprite ss_cross' %></td>
13
+ </tr>
14
+ <% end %>
15
+ </table>
16
+
17
+ <%#= will_paginate @survey_properties %>
18
+
19
+ <p><%= link_to "New Property", new_survey_admin_survey_property_path, :class => 'button' %></p>
@@ -0,0 +1,8 @@
1
+ <h1> New Property </h1>
2
+
3
+ <%= form_for @survey_property, :url => survey_admin_survey_properties_path(@survey_property) do |f| %>
4
+ <%= render :partial => 'form', :locals => {:f => f} %>
5
+ <div class="actions"><%= f.submit 'Create' , :class => 'button' %></div>
6
+ <% end %>
7
+
8
+ <p><%= link_to "Back to List", survey_admin_survey_properties_path, :class => 'button' %></p>
@@ -0,0 +1,12 @@
1
+ <h1> Properties </h1>
2
+
3
+ <p>
4
+ <strong>Name:</strong>
5
+ <%= @survey_property.name %>
6
+ </p>
7
+
8
+ <p>
9
+ <%= link_to "Edit", edit_survey_admin_survey_property_path(@survey_property), :class => 'button' %> |
10
+ <%= link_to "Destroy", [:survey_admin, @survey_property], :confirm => 'Are you sure?', :method => :delete, :class => 'button' %> |
11
+ <%= link_to "View Properties", survey_admin_survey_properties_path, :class => 'button' %>
12
+ </p>
data/config/routes.rb ADDED
@@ -0,0 +1,17 @@
1
+ Rails.application.routes.draw do
2
+
3
+ match 'survey_admin' => 'survey_admin/questionnaires#index'
4
+
5
+ namespace(:survey_admin){ resources :questionnaires }
6
+
7
+ namespace(:survey_admin){ resources :survey_properties }
8
+
9
+ #namespace(:survey_admin){ resources :answers }
10
+
11
+ root :to => "survey_admin/questions#index"
12
+ namespace :survey_admin do
13
+ resources :questions do
14
+ resources :answers
15
+ end
16
+ end
17
+ end
Binary file
@@ -0,0 +1,11 @@
1
+ class CreateQuestions < ActiveRecord::Migration
2
+ def change
3
+ create_table :questions do |t|
4
+ t.text :details, :null => false
5
+ t.boolean :active, :default => true
6
+ t.integer :position
7
+
8
+ t.timestamps
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,14 @@
1
+ class CreateAnswers < ActiveRecord::Migration
2
+ def change
3
+ create_table :answers do |t|
4
+ t.integer :question_id, :null => false
5
+ t.text :details
6
+ t.boolean :active, :default => true
7
+ t.integer :position
8
+
9
+ t.timestamps
10
+ end
11
+
12
+ add_index :answers, :question_id
13
+ end
14
+ end
@@ -0,0 +1,9 @@
1
+ class CreateSurveyProperties < ActiveRecord::Migration
2
+ def change
3
+ create_table :survey_properties do |t|
4
+ t.string :name, :null => false
5
+
6
+ t.timestamps
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,15 @@
1
+ class CreateScores < ActiveRecord::Migration
2
+ def change
3
+ create_table :scores do |t|
4
+ t.integer :answer_id, :null => false
5
+ t.integer :survey_property_id, :null => false
6
+ t.integer :value, :null => false
7
+
8
+ t.timestamps
9
+ end
10
+
11
+ add_index :scores, :answer_id
12
+ add_index :scores, :survey_property_id
13
+
14
+ end
15
+ end
@@ -0,0 +1,12 @@
1
+ class CreateUserAnswers < ActiveRecord::Migration
2
+ def change
3
+ create_table :user_answers do |t|
4
+ t.integer :user_id, :null => false
5
+ t.integer :answer_id, :null => false
6
+
7
+ t.timestamps
8
+ end
9
+ add_index :user_answers, :user_id
10
+ add_index :user_answers, :answer_id
11
+ end
12
+ end
@@ -0,0 +1,8 @@
1
+ class CreateQuestionnaires < ActiveRecord::Migration
2
+ def change
3
+ create_table :questionnaires do |t|
4
+ t.string :name, :null => false
5
+ end
6
+ add_index :questionnaires, :name
7
+ end
8
+ end
@@ -0,0 +1,7 @@
1
+ class AddQuestionaireIdToQuestions < ActiveRecord::Migration
2
+ def change
3
+ add_column :questions, :questionnaire_id, :integer
4
+
5
+ add_index :questions, :questionnaire_id
6
+ end
7
+ end
@@ -0,0 +1,15 @@
1
+ class CreateSurveyImages < ActiveRecord::Migration
2
+ def change
3
+ create_table :survey_images do |t|
4
+ t.integer :imageable_id
5
+ t.string :imageable_type
6
+ t.integer :position
7
+ t.string :photo_file_name
8
+ t.string :photo_content_type
9
+ t.integer :photo_file_size
10
+ t.string :caption
11
+
12
+ t.timestamps
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,32 @@
1
+ #To invoke this generator, you just need to do:
2
+ # $ rails generate survey_says
3
+
4
+ #require 'rails/generators/migration'
5
+
6
+ module SurveyModels
7
+ class SurveyModelsGenerator < Rails::Generators::Base
8
+ desc "This generator creates survey_says/models/* in your app/models/ directory"
9
+ def copy_models
10
+ require 'fileutils'
11
+
12
+ puts "#{File.dirname(__FILE__)}"
13
+ file_path = "#{File.dirname(__FILE__)}"
14
+ Dir.foreach( "#{file_path}/../../app/models" ) do |x|
15
+ #Dir.glob("#{file_path}/../../app/models/*.rb") do |x|
16
+ if x.match(/(\.rb)/)
17
+ unless File.exist?("#{Rails.root}/../../app/models/#{x}")
18
+ puts "Moving #{x} to main app."
19
+ FileUtils.cp "#{file_path}/../../app/models/#{x}", "#{Rails.root}/app/models/#{x}"
20
+ else
21
+ puts '##################################'
22
+ puts "app/models/#{x} already exists!"
23
+ puts ''
24
+ puts "Please manually move this model if this is the first time you have run this generator."
25
+ end
26
+ end
27
+ end
28
+ end
29
+ #include Rails::Generators::Migration
30
+
31
+ end
32
+ end