breakpointer-surveyor 0.2.0

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 (198) hide show
  1. data/.gitignore +6 -0
  2. data/MIT-LICENSE +20 -0
  3. data/README.md +20 -0
  4. data/Rakefile +57 -0
  5. data/VERSION +1 -0
  6. data/app/controllers/answers_controller.rb +87 -0
  7. data/app/controllers/dependencies_controller.rb +87 -0
  8. data/app/controllers/dependency_conditions_controller.rb +87 -0
  9. data/app/controllers/questions_controller.rb +85 -0
  10. data/app/controllers/sections_controller.rb +87 -0
  11. data/app/controllers/surveying_controller.rb +139 -0
  12. data/app/controllers/surveys_controller.rb +87 -0
  13. data/app/helpers/answers_helper.rb +2 -0
  14. data/app/helpers/application_helper.rb +3 -0
  15. data/app/helpers/questions_helper.rb +2 -0
  16. data/app/helpers/sections_helper.rb +2 -0
  17. data/app/helpers/survey_form_builder.rb +38 -0
  18. data/app/helpers/survey_importer_helper.rb +2 -0
  19. data/app/helpers/surveying_helper.rb +91 -0
  20. data/app/helpers/surveys_helper.rb +2 -0
  21. data/app/models/answer.rb +18 -0
  22. data/app/models/dependency.rb +43 -0
  23. data/app/models/dependency_condition.rb +76 -0
  24. data/app/models/question.rb +44 -0
  25. data/app/models/question_group.rb +5 -0
  26. data/app/models/response.rb +58 -0
  27. data/app/models/response_set.rb +174 -0
  28. data/app/models/survey.rb +54 -0
  29. data/app/models/survey_section.rb +19 -0
  30. data/app/models/user.rb +5 -0
  31. data/app/views/answer_display_types/_any_answer.html.haml +3 -0
  32. data/app/views/answer_display_types/_any_other_and_string.html.haml +5 -0
  33. data/app/views/answer_display_types/_any_string.html.haml +4 -0
  34. data/app/views/answer_display_types/_date.html.haml +3 -0
  35. data/app/views/answer_display_types/_datetime.html.haml +2 -0
  36. data/app/views/answer_display_types/_default.html.haml +1 -0
  37. data/app/views/answer_display_types/_float.html.haml +5 -0
  38. data/app/views/answer_display_types/_grid_any_answer.html.haml +2 -0
  39. data/app/views/answer_display_types/_grid_default.html.haml +2 -0
  40. data/app/views/answer_display_types/_grid_float.html.haml +2 -0
  41. data/app/views/answer_display_types/_grid_integer.html.haml +2 -0
  42. data/app/views/answer_display_types/_grid_one_answer.html.haml +2 -0
  43. data/app/views/answer_display_types/_grid_string.html.haml +2 -0
  44. data/app/views/answer_display_types/_integer.html.haml +6 -0
  45. data/app/views/answer_display_types/_one_answer.html.haml +3 -0
  46. data/app/views/answer_display_types/_one_string.html.haml +6 -0
  47. data/app/views/answer_display_types/_repeater_integer.html.haml +6 -0
  48. data/app/views/answer_display_types/_repeater_string.html.haml +7 -0
  49. data/app/views/answer_display_types/_string.html.haml +7 -0
  50. data/app/views/answer_display_types/_text.html.haml +6 -0
  51. data/app/views/answer_display_types/_time.html.haml +2 -0
  52. data/app/views/layouts/surveys.html.erb +17 -0
  53. data/app/views/question_display_types/_default.html.haml +12 -0
  54. data/app/views/question_display_types/_dropdown.html.haml +12 -0
  55. data/app/views/question_display_types/_grid_default.html.haml +14 -0
  56. data/app/views/question_display_types/_grid_dropdown.html.haml +15 -0
  57. data/app/views/question_display_types/_group_default.html.haml +8 -0
  58. data/app/views/question_display_types/_group_dropdown.html.haml +6 -0
  59. data/app/views/question_display_types/_image.html.haml +2 -0
  60. data/app/views/question_display_types/_inline.html.haml +12 -0
  61. data/app/views/question_display_types/_label.html.haml +4 -0
  62. data/app/views/question_display_types/_repeater_default.html.haml +10 -0
  63. data/app/views/question_display_types/_repeater_dropdown.html.haml +8 -0
  64. data/app/views/question_display_types/_slider.html.haml +17 -0
  65. data/app/views/question_group_display_types/_default.html.haml +13 -0
  66. data/app/views/question_group_display_types/_grid.html.haml +24 -0
  67. data/app/views/question_group_display_types/_repeater.html.haml +20 -0
  68. data/app/views/surveying/edit.html.haml +38 -0
  69. data/app/views/surveying/finish.html.haml +1 -0
  70. data/app/views/surveying/index.html.erb +19 -0
  71. data/app/views/surveying/new.html.haml +17 -0
  72. data/app/views/surveying/show.html.haml +8 -0
  73. data/config/routes.rb +10 -0
  74. data/generators/surveyor/surveyor_generator.rb +38 -0
  75. data/generators/surveyor/templates/README +9 -0
  76. data/generators/surveyor/templates/assets/images/222222_11x11_icon_arrows_leftright.gif +0 -0
  77. data/generators/surveyor/templates/assets/images/222222_11x11_icon_arrows_updown.gif +0 -0
  78. data/generators/surveyor/templates/assets/images/222222_11x11_icon_close.gif +0 -0
  79. data/generators/surveyor/templates/assets/images/222222_11x11_icon_doc.gif +0 -0
  80. data/generators/surveyor/templates/assets/images/222222_11x11_icon_folder_closed.gif +0 -0
  81. data/generators/surveyor/templates/assets/images/222222_11x11_icon_folder_open.gif +0 -0
  82. data/generators/surveyor/templates/assets/images/222222_11x11_icon_minus.gif +0 -0
  83. data/generators/surveyor/templates/assets/images/222222_11x11_icon_plus.gif +0 -0
  84. data/generators/surveyor/templates/assets/images/222222_11x11_icon_resize_se.gif +0 -0
  85. data/generators/surveyor/templates/assets/images/222222_35x9_colorpicker_indicator.gif.gif +0 -0
  86. data/generators/surveyor/templates/assets/images/222222_7x7_arrow_down.gif +0 -0
  87. data/generators/surveyor/templates/assets/images/222222_7x7_arrow_left.gif +0 -0
  88. data/generators/surveyor/templates/assets/images/222222_7x7_arrow_right.gif +0 -0
  89. data/generators/surveyor/templates/assets/images/222222_7x7_arrow_up.gif +0 -0
  90. data/generators/surveyor/templates/assets/images/454545_11x11_icon_arrows_leftright.gif +0 -0
  91. data/generators/surveyor/templates/assets/images/454545_11x11_icon_arrows_updown.gif +0 -0
  92. data/generators/surveyor/templates/assets/images/454545_11x11_icon_close.gif +0 -0
  93. data/generators/surveyor/templates/assets/images/454545_11x11_icon_doc.gif +0 -0
  94. data/generators/surveyor/templates/assets/images/454545_11x11_icon_folder_closed.gif +0 -0
  95. data/generators/surveyor/templates/assets/images/454545_11x11_icon_folder_open.gif +0 -0
  96. data/generators/surveyor/templates/assets/images/454545_11x11_icon_minus.gif +0 -0
  97. data/generators/surveyor/templates/assets/images/454545_11x11_icon_plus.gif +0 -0
  98. data/generators/surveyor/templates/assets/images/454545_7x7_arrow_down.gif +0 -0
  99. data/generators/surveyor/templates/assets/images/454545_7x7_arrow_left.gif +0 -0
  100. data/generators/surveyor/templates/assets/images/454545_7x7_arrow_right.gif +0 -0
  101. data/generators/surveyor/templates/assets/images/454545_7x7_arrow_up.gif +0 -0
  102. data/generators/surveyor/templates/assets/images/888888_11x11_icon_arrows_leftright.gif +0 -0
  103. data/generators/surveyor/templates/assets/images/888888_11x11_icon_arrows_updown.gif +0 -0
  104. data/generators/surveyor/templates/assets/images/888888_11x11_icon_close.gif +0 -0
  105. data/generators/surveyor/templates/assets/images/888888_11x11_icon_doc.gif +0 -0
  106. data/generators/surveyor/templates/assets/images/888888_11x11_icon_folder_closed.gif +0 -0
  107. data/generators/surveyor/templates/assets/images/888888_11x11_icon_folder_open.gif +0 -0
  108. data/generators/surveyor/templates/assets/images/888888_11x11_icon_minus.gif +0 -0
  109. data/generators/surveyor/templates/assets/images/888888_11x11_icon_plus.gif +0 -0
  110. data/generators/surveyor/templates/assets/images/888888_7x7_arrow_down.gif +0 -0
  111. data/generators/surveyor/templates/assets/images/888888_7x7_arrow_left.gif +0 -0
  112. data/generators/surveyor/templates/assets/images/888888_7x7_arrow_right.gif +0 -0
  113. data/generators/surveyor/templates/assets/images/888888_7x7_arrow_up.gif +0 -0
  114. data/generators/surveyor/templates/assets/images/dadada_40x100_textures_02_glass_75.png +0 -0
  115. data/generators/surveyor/templates/assets/images/e6e6e6_40x100_textures_02_glass_75.png +0 -0
  116. data/generators/surveyor/templates/assets/images/ffffff_40x100_textures_01_flat_0.png +0 -0
  117. data/generators/surveyor/templates/assets/images/ffffff_40x100_textures_02_glass_65.png +0 -0
  118. data/generators/surveyor/templates/assets/javascripts/accessibleUISlider.jQuery.js +201 -0
  119. data/generators/surveyor/templates/assets/javascripts/jquery-1.2.6.js +3549 -0
  120. data/generators/surveyor/templates/assets/javascripts/jquery-ui-personalized-1.5.3.js +7616 -0
  121. data/generators/surveyor/templates/assets/javascripts/jquery.form.js +637 -0
  122. data/generators/surveyor/templates/assets/javascripts/surveyor.js +35 -0
  123. data/generators/surveyor/templates/assets/stylesheets/jquery-ui-slider-additions.css +71 -0
  124. data/generators/surveyor/templates/assets/stylesheets/reset.css +46 -0
  125. data/generators/surveyor/templates/assets/stylesheets/sass/surveyor.sass +321 -0
  126. data/generators/surveyor/templates/assets/stylesheets/surveyor.css +245 -0
  127. data/generators/surveyor/templates/assets/stylesheets/ui.theme.css +851 -0
  128. data/generators/surveyor/templates/migrate/create_answers.rb +46 -0
  129. data/generators/surveyor/templates/migrate/create_dependencies.rb +21 -0
  130. data/generators/surveyor/templates/migrate/create_dependency_conditions.rb +29 -0
  131. data/generators/surveyor/templates/migrate/create_question_groups.rb +18 -0
  132. data/generators/surveyor/templates/migrate/create_questions.rb +33 -0
  133. data/generators/surveyor/templates/migrate/create_response_sets.rb +22 -0
  134. data/generators/surveyor/templates/migrate/create_responses.rb +33 -0
  135. data/generators/surveyor/templates/migrate/create_survey_sections.rb +25 -0
  136. data/generators/surveyor/templates/migrate/create_surveys.rb +25 -0
  137. data/generators/surveyor/templates/surveys/kitchen_sink_survey.rb +201 -0
  138. data/init.rb +1 -0
  139. data/install.rb +1 -0
  140. data/lib/tasks/surveyor_tasks.rake +29 -0
  141. data/lib/tiny_code.rb +58 -0
  142. data/lib/user_manager.rb +9 -0
  143. data/lib/xml_formatter.rb +12 -0
  144. data/script/surveyor/answer.rb +84 -0
  145. data/script/surveyor/columnizer.rb +36 -0
  146. data/script/surveyor/dependency.rb +43 -0
  147. data/script/surveyor/dependency_condition.rb +74 -0
  148. data/script/surveyor/dslparse.rb +66 -0
  149. data/script/surveyor/question.rb +76 -0
  150. data/script/surveyor/question_group.rb +33 -0
  151. data/script/surveyor/specs/answer_spec.rb +66 -0
  152. data/script/surveyor/specs/question_dependency_spec.rb +46 -0
  153. data/script/surveyor/specs/question_group_spec.rb +9 -0
  154. data/script/surveyor/specs/question_spec.rb +111 -0
  155. data/script/surveyor/specs/section_spec.rb +58 -0
  156. data/script/surveyor/survey.rb +108 -0
  157. data/script/surveyor/survey_section.rb +153 -0
  158. data/script/surveyor/whr_dsl.tmproj +244 -0
  159. data/spec/controllers/answers_controller_spec.rb +64 -0
  160. data/spec/controllers/dependencies_controller_spec.rb +63 -0
  161. data/spec/controllers/dependency_conditions_controller_spec.rb +64 -0
  162. data/spec/controllers/questions_controller_spec.rb +64 -0
  163. data/spec/controllers/sections_controller_spec.rb +64 -0
  164. data/spec/controllers/surveying_controller_spec.rb +328 -0
  165. data/spec/controllers/surveying_routing_spec.rb +45 -0
  166. data/spec/controllers/surveys_controller_spec.rb +64 -0
  167. data/spec/fixtures/answers.yml +9 -0
  168. data/spec/fixtures/dependencies.yml +7 -0
  169. data/spec/fixtures/dependency_conditions.yml +27 -0
  170. data/spec/fixtures/question_groups.yml +7 -0
  171. data/spec/fixtures/questions.yml +15 -0
  172. data/spec/fixtures/response_sets.yml +13 -0
  173. data/spec/fixtures/responses.yml +9 -0
  174. data/spec/fixtures/survey_sections.yml +11 -0
  175. data/spec/fixtures/surveys.yml +9 -0
  176. data/spec/fixtures/users.yml +7 -0
  177. data/spec/helpers/survey_importer_helper_spec.rb +11 -0
  178. data/spec/helpers/surveying_helper_spec.rb +11 -0
  179. data/spec/models/answer_spec.rb +62 -0
  180. data/spec/models/dependency_condition_spec.rb +347 -0
  181. data/spec/models/dependency_spec.rb +82 -0
  182. data/spec/models/question_group_spec.rb +11 -0
  183. data/spec/models/question_spec.rb +70 -0
  184. data/spec/models/response_set_spec.rb +172 -0
  185. data/spec/models/response_spec.rb +94 -0
  186. data/spec/models/survey_section_spec.rb +34 -0
  187. data/spec/models/survey_spec.rb +72 -0
  188. data/spec/models/user_spec.rb +11 -0
  189. data/spec/rcov.opts +2 -0
  190. data/spec/spec.opts +4 -0
  191. data/spec/spec_helper.rb +72 -0
  192. data/spec/views/app/edit.html.erb_spec.rb +20 -0
  193. data/spec/views/app/index.html.erb_spec.rb +19 -0
  194. data/spec/views/app/new.html.erb_spec.rb +21 -0
  195. data/spec/views/app/show.html.erb_spec.rb +17 -0
  196. data/surveyor.gemspec +258 -0
  197. data/uninstall.rb +1 -0
  198. metadata +286 -0
data/.gitignore ADDED
@@ -0,0 +1,6 @@
1
+ *.sw?
2
+ .DS_Store
3
+ coverage
4
+ rdoc
5
+ pkg
6
+ surveys/fixtures/*.yml
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2008-2009 Brian Chamberlain and Mark Yoon
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,20 @@
1
+ # SurveyOnRails
2
+
3
+ # Install
4
+
5
+ script/plugin install git://github.com/breakpointer/surveyor.git
6
+
7
+ Generate assets, migrations, and run migrations
8
+
9
+ script/generate surveyor
10
+ rake db:migrate
11
+
12
+ Try out the "kitchen sink" survey:
13
+
14
+ rake surveyor:bootstrap FILE=surveys/kitchen_sink_survey.rb
15
+
16
+ # Dependencices
17
+
18
+ Surveyor requires HAML (http://haml.hamptoncatlin.com/download)
19
+
20
+ Copyright (c) 2008-2009 Brian Chamberlain and Mark Yoon, released under the MIT license
data/Rakefile ADDED
@@ -0,0 +1,57 @@
1
+ require 'rubygems'
2
+ require 'rake'
3
+
4
+ begin
5
+ require 'jeweler'
6
+ Jeweler::Tasks.new do |gem|
7
+ gem.name = "surveyor"
8
+ gem.summary = %Q{A rails (gem) plugin to enable surveys in your application}
9
+ gem.email = "yoon@northwestern.edu"
10
+ gem.homepage = "http://github.com/breakpointer/surveyor"
11
+ gem.authors = ["Brian Chamberlain", "Mark Yoon"]
12
+ gem.add_dependency 'haml'
13
+ # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
14
+ end
15
+
16
+ rescue LoadError
17
+ puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
18
+ end
19
+
20
+ require 'rake/testtask'
21
+ Rake::TestTask.new(:test) do |test|
22
+ test.libs << 'lib' << 'test'
23
+ test.pattern = 'test/**/*_test.rb'
24
+ test.verbose = true
25
+ end
26
+
27
+ begin
28
+ require 'rcov/rcovtask'
29
+ Rcov::RcovTask.new do |test|
30
+ test.libs << 'test'
31
+ test.pattern = 'test/**/*_test.rb'
32
+ test.verbose = true
33
+ end
34
+ rescue LoadError
35
+ task :rcov do
36
+ abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
37
+ end
38
+ end
39
+
40
+
41
+ task :default => :test
42
+
43
+ require 'rake/rdoctask'
44
+ Rake::RDocTask.new do |rdoc|
45
+ if File.exist?('VERSION.yml')
46
+ config = YAML.load(File.read('VERSION.yml'))
47
+ version = "#{config[:major]}.#{config[:minor]}.#{config[:patch]}"
48
+ else
49
+ version = ""
50
+ end
51
+
52
+ rdoc.rdoc_dir = 'rdoc'
53
+ rdoc.title = "surveyor #{version}"
54
+ rdoc.rdoc_files.include('README*')
55
+ rdoc.rdoc_files.include('lib/**/*.rb')
56
+ end
57
+
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.2.0
@@ -0,0 +1,87 @@
1
+ class AnswersController < ApplicationController
2
+
3
+ # GET /answers
4
+ # GET /answers.xml
5
+ def index
6
+ @answers = Answer.find(:all)
7
+
8
+ respond_to do |format|
9
+ format.html # index.html.erb
10
+ format.xml { render :xml => @answers }
11
+ end
12
+ end
13
+
14
+ # GET /answers/1
15
+ # GET /answers/1.xml
16
+ def show
17
+ @answer = Answer.find(params[:id])
18
+
19
+ respond_to do |format|
20
+ format.html # show.html.erb
21
+ format.xml { render :xml => @answer }
22
+ end
23
+ end
24
+
25
+ # GET /answers/new
26
+ # GET /answers/new.xml
27
+ def new
28
+ @answer = Answer.new
29
+
30
+ respond_to do |format|
31
+ format.html # new.html.erb
32
+ format.xml { render :xml => @answer }
33
+ end
34
+ end
35
+
36
+ # GET /answers/1/edit
37
+ def edit
38
+ @answer = Answer.find(params[:id])
39
+ end
40
+
41
+ # POST /answers
42
+ # POST /answers.xml
43
+ def create
44
+ @answer = Answer.new(params[:answer])
45
+
46
+ respond_to do |format|
47
+ if @answer.save
48
+ flash[:notice] = 'Answer was successfully created.'
49
+ format.html { redirect_to(@answer) }
50
+ format.xml { render :xml => @answer, :status => :created, :location => @answer }
51
+ else
52
+ format.html { render :action => "new" }
53
+ format.xml { render :xml => @answer.errors, :status => :unprocessable_entity }
54
+ end
55
+ end
56
+ end
57
+
58
+ # PUT /answers/1
59
+ # PUT /answers/1.xml
60
+ def update
61
+ @answer = Answer.find(params[:id])
62
+
63
+ respond_to do |format|
64
+ if @answer.update_attributes(params[:answer])
65
+ flash[:notice] = 'Answer was successfully updated.'
66
+ format.html { redirect_to(@answer) }
67
+ format.xml { head :ok }
68
+ else
69
+ format.html { render :action => "edit" }
70
+ format.xml { render :xml => @answer.errors, :status => :unprocessable_entity }
71
+ end
72
+ end
73
+ end
74
+
75
+ # DELETE /answers/1
76
+ # DELETE /answers/1.xml
77
+ def destroy
78
+ @answer = Answer.find(params[:id])
79
+ @answer.destroy
80
+
81
+ respond_to do |format|
82
+ format.html { redirect_to(answers_url) }
83
+ format.xml { head :ok }
84
+ end
85
+ end
86
+
87
+ end
@@ -0,0 +1,87 @@
1
+ class DependenciesController < ApplicationController
2
+
3
+ # GET /dependencies
4
+ # GET /dependencies.xml
5
+ def index
6
+ @dependencies = Dependency.find(:all)
7
+
8
+ respond_to do |format|
9
+ format.html # index.html.erb
10
+ format.xml { render :xml => @dependencies}
11
+ end
12
+ end
13
+
14
+ # GET /dependencies/1
15
+ # GET /dependencies/1.xml
16
+ def show
17
+ @dependency = Dependency.find(params[:id])
18
+
19
+ respond_to do |format|
20
+ format.html # show.html.erb
21
+ format.xml { render :xml => @dependency, :include => [:dependency_conditions] }
22
+ end
23
+ end
24
+
25
+ # GET /dependencies/new
26
+ # GET /dependencies/new.xml
27
+ def new
28
+ @dependency = Dependency.new
29
+
30
+ respond_to do |format|
31
+ format.html # new.html.erb
32
+ format.xml { render :xml => @dependency }
33
+ end
34
+ end
35
+
36
+ # GET /dependencies/1/edit
37
+ def edit
38
+ @dependency = Dependency.find(params[:id])
39
+ end
40
+
41
+ # POST /dependencies
42
+ # POST /dependencies.xml
43
+ def create
44
+ @dependency = Dependency.new(params[:dependency])
45
+
46
+ respond_to do |format|
47
+ if @dependency.save
48
+ flash[:notice] = 'Dependency was successfully created.'
49
+ format.html { redirect_to(@dependency) }
50
+ format.xml { render :xml => @dependency, :status => :created, :location => @dependency }
51
+ else
52
+ format.html { render :action => "new" }
53
+ format.xml { render :xml => @dependency.errors, :status => :unprocessable_entity }
54
+ end
55
+ end
56
+ end
57
+
58
+ # PUT /dependencies/1
59
+ # PUT /dependencies/1.xml
60
+ def update
61
+ @dependency = Dependency.find(params[:id])
62
+
63
+ respond_to do |format|
64
+ if @dependency.update_attributes(params[:dependency])
65
+ flash[:notice] = 'Dependency was successfully updated.'
66
+ format.html { redirect_to(@dependency) }
67
+ format.xml { head :ok }
68
+ else
69
+ format.html { render :action => "edit" }
70
+ format.xml { render :xml => @dependency.errors, :status => :unprocessable_entity }
71
+ end
72
+ end
73
+ end
74
+
75
+ # DELETE /dependencies/1
76
+ # DELETE /dependencies/1.xml
77
+ def destroy
78
+ @dependency = Dependency.find(params[:id])
79
+ @dependency.destroy
80
+
81
+ respond_to do |format|
82
+ format.html { redirect_to(dependencies_url) }
83
+ format.xml { head :ok }
84
+ end
85
+ end
86
+
87
+ end
@@ -0,0 +1,87 @@
1
+ class DependencyConditionsController < ApplicationController
2
+
3
+ # GET /dependency_conditions
4
+ # GET /dependency_conditions.xml
5
+ def index
6
+ @dependency_conditions = DependencyCondition.find(:all)
7
+
8
+ respond_to do |format|
9
+ format.html # index.html.erb
10
+ format.xml { render :xml => @dependency_conditions }
11
+ end
12
+ end
13
+
14
+ # GET /dependency_conditions/1
15
+ # GET /dependency_conditions/1.xml
16
+ def show
17
+ @dependency_condition = DependencyCondition.find(params[:id])
18
+
19
+ respond_to do |format|
20
+ format.html # show.html.erb
21
+ format.xml { render :xml => @dependency_condition }
22
+ end
23
+ end
24
+
25
+ # GET /dependency_conditions/new
26
+ # GET /dependency_conditions/new.xml
27
+ def new
28
+ @dependency_condition = DependencyCondition.new
29
+
30
+ respond_to do |format|
31
+ format.html # new.html.erb
32
+ format.xml { render :xml => @dependency_condition }
33
+ end
34
+ end
35
+
36
+ # GET /dependency_conditions/1/edit
37
+ def edit
38
+ @dependency_condition = DependencyCondition.find(params[:id])
39
+ end
40
+
41
+ # POST /dependency_conditions
42
+ # POST /dependency_conditions.xml
43
+ def create
44
+ @dependency_condition = DependencyCondition.new(params[:dependency_condition])
45
+
46
+ respond_to do |format|
47
+ if @dependency_condition.save
48
+ flash[:notice] = 'DependencyCondition was successfully created.'
49
+ format.html { redirect_to(@dependency_condition) }
50
+ format.xml { render :xml => @dependency_condition, :status => :created, :location => @dependency_condition }
51
+ else
52
+ format.html { render :action => "new" }
53
+ format.xml { render :xml => @dependency_condition.errors, :status => :unprocessable_entity }
54
+ end
55
+ end
56
+ end
57
+
58
+ # PUT /dependency_conditions/1
59
+ # PUT /dependency_conditions/1.xml
60
+ def update
61
+ @dependency_condition = DependencyCondition.find(params[:id])
62
+
63
+ respond_to do |format|
64
+ if @dependency_condition.update_attributes(params[:dependency_condition])
65
+ flash[:notice] = 'DependencyCondition was successfully updated.'
66
+ format.html { redirect_to(@dependency_condition) }
67
+ format.xml { head :ok }
68
+ else
69
+ format.html { render :action => "edit" }
70
+ format.xml { render :xml => @dependency_condition.errors, :status => :unprocessable_entity }
71
+ end
72
+ end
73
+ end
74
+
75
+ # DELETE /dependency_conditions/1
76
+ # DELETE /dependency_conditions/1.xml
77
+ def destroy
78
+ @dependency_condition = DependencyCondition.find(params[:id])
79
+ @dependency_condition.destroy
80
+
81
+ respond_to do |format|
82
+ format.html { redirect_to(dependency_conditions_url) }
83
+ format.xml { head :ok }
84
+ end
85
+ end
86
+
87
+ end
@@ -0,0 +1,85 @@
1
+ class QuestionsController < ApplicationController
2
+ # GET /questions
3
+ # GET /questions.xml
4
+ def index
5
+ @questions = Question.find(:all)
6
+
7
+ respond_to do |format|
8
+ format.html # index.html.erb
9
+ format.xml { render :xml => @questions}
10
+ end
11
+ end
12
+
13
+ # GET /questions/1
14
+ # GET /questions/1.xml
15
+ def show
16
+ @question = Question.find(params[:id])
17
+
18
+ respond_to do |format|
19
+ format.html # show.html.erb
20
+ format.xml { render :xml => @question.to_xml(:include => [:answers, :dependency]) }
21
+ end
22
+ end
23
+
24
+ # GET /questions/new
25
+ # GET /questions/new.xml
26
+ def new
27
+ @question = Question.new
28
+
29
+ respond_to do |format|
30
+ format.html # new.html.erb
31
+ format.xml { render :xml => @question }
32
+ end
33
+ end
34
+
35
+ # GET /questions/1/edit
36
+ def edit
37
+ @question = Question.find(params[:id])
38
+ end
39
+
40
+ # POST /questions
41
+ # POST /questions.xml
42
+ def create
43
+ @question = Question.new(params[:question])
44
+
45
+ respond_to do |format|
46
+ if @question.save
47
+ flash[:notice] = 'Question was successfully created.'
48
+ format.html { redirect_to(@question) }
49
+ format.xml { render :xml => @question, :status => :created, :location => @question }
50
+ else
51
+ format.html { render :action => "new" }
52
+ format.xml { render :xml => @question.errors, :status => :unprocessable_entity }
53
+ end
54
+ end
55
+ end
56
+
57
+ # PUT /questions/1
58
+ # PUT /questions/1.xml
59
+ def update
60
+ @question = Question.find(params[:id])
61
+
62
+ respond_to do |format|
63
+ if @question.update_attributes(params[:question])
64
+ flash[:notice] = 'Question was successfully updated.'
65
+ format.html { redirect_to(@question) }
66
+ format.xml { head :ok }
67
+ else
68
+ format.html { render :action => "edit" }
69
+ format.xml { render :xml => @question.errors, :status => :unprocessable_entity }
70
+ end
71
+ end
72
+ end
73
+
74
+ # DELETE /questions/1
75
+ # DELETE /questions/1.xml
76
+ def destroy
77
+ @question = Question.find(params[:id])
78
+ @question.destroy
79
+
80
+ respond_to do |format|
81
+ format.html { redirect_to(questions_url) }
82
+ format.xml { head :ok }
83
+ end
84
+ end
85
+ end