devape_survey 0.0.2
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.
- data/MIT-LICENSE +20 -0
- data/README.rdoc +3 -0
- data/Rakefile +36 -0
- data/app/controllers/results_controller.rb +22 -0
- data/app/controllers/summaries_controller.rb +47 -0
- data/app/controllers/survey_answers_controller.rb +55 -0
- data/app/controllers/surveys_controller.rb +53 -0
- data/app/helpers/surveys_helper.rb +28 -0
- data/app/models/answer.rb +4 -0
- data/app/models/question.rb +5 -0
- data/app/models/summary.rb +3 -0
- data/app/models/survey.rb +7 -0
- data/app/models/survey_answer.rb +7 -0
- data/app/views/results/index.html.erb +3 -0
- data/app/views/summaries/_answer_fields.html.erb +6 -0
- data/app/views/summaries/_form.html.erb +19 -0
- data/app/views/summaries/_question_fields.html.erb +11 -0
- data/app/views/summaries/edit.html.erb +8 -0
- data/app/views/summaries/index.html.erb +17 -0
- data/app/views/summaries/new.html.erb +5 -0
- data/app/views/summaries/show.html.erb +31 -0
- data/app/views/surveys/_answer_fields.html.erb +6 -0
- data/app/views/surveys/_form.html.erb +29 -0
- data/app/views/surveys/_question_fields.html.erb +11 -0
- data/app/views/surveys/_summary_fields.html.erb +8 -0
- data/app/views/surveys/edit.html.erb +8 -0
- data/app/views/surveys/index.html.erb +17 -0
- data/app/views/surveys/new.html.erb +5 -0
- data/app/views/surveys/show.html.erb +31 -0
- data/lib/devape_survey/engine.rb +7 -0
- data/lib/devape_survey.rb +7 -0
- data/lib/rails/generators/devape_survey/devape_survey_generator.rb +13 -0
- data/lib/rails/generators/devape_survey/templates/create_answers.rb +15 -0
- data/lib/rails/generators/devape_survey/templates/create_questions.rb +14 -0
- data/lib/rails/generators/devape_survey/templates/create_surveys.rb +28 -0
- data/lib/tasks/devape_survey_tasks.rake +4 -0
- metadata +89 -0
data/MIT-LICENSE
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
Copyright 2011 YOURNAME
|
|
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.rdoc
ADDED
data/Rakefile
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
#!/usr/bin/env rake
|
|
2
|
+
begin
|
|
3
|
+
require 'bundler/setup'
|
|
4
|
+
rescue LoadError
|
|
5
|
+
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
|
6
|
+
end
|
|
7
|
+
begin
|
|
8
|
+
require 'rdoc/task'
|
|
9
|
+
rescue LoadError
|
|
10
|
+
require 'rdoc/rdoc'
|
|
11
|
+
require 'rake/rdoctask'
|
|
12
|
+
RDoc::Task = Rake::RDocTask
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
RDoc::Task.new(:rdoc) do |rdoc|
|
|
16
|
+
rdoc.rdoc_dir = 'rdoc'
|
|
17
|
+
rdoc.title = 'DevapeSurvey'
|
|
18
|
+
rdoc.options << '--line-numbers' << '--inline-source'
|
|
19
|
+
rdoc.rdoc_files.include('README.rdoc')
|
|
20
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
APP_RAKEFILE = File.expand_path("../test/dummy/Rakefile", __FILE__)
|
|
24
|
+
load 'rails/tasks/engine.rake'
|
|
25
|
+
|
|
26
|
+
require 'rake/testtask'
|
|
27
|
+
|
|
28
|
+
Rake::TestTask.new(:test) do |t|
|
|
29
|
+
t.libs << 'lib'
|
|
30
|
+
t.libs << 'test'
|
|
31
|
+
t.pattern = 'test/**/*_test.rb'
|
|
32
|
+
t.verbose = false
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
task :default => :test
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
class ResultsController < ApplicationController
|
|
2
|
+
def index
|
|
3
|
+
@surveys = Survey.all
|
|
4
|
+
@survey = Survey.find(params[:survey_id])
|
|
5
|
+
@survey_answers = SurveyAnswer.where(:survey_id =>params[:survey_id])
|
|
6
|
+
@result = ActiveRecord::Base.connection.execute("
|
|
7
|
+
SELECT SUM(`points`) as `sum`
|
|
8
|
+
FROM
|
|
9
|
+
survey_answers `sa`
|
|
10
|
+
INNER JOIN answers `a`
|
|
11
|
+
ON `a`.`id` = `sa`.`answer_id`
|
|
12
|
+
WHERE `survey_id` = #{@survey.id};
|
|
13
|
+
").first
|
|
14
|
+
@summary_sql = ActiveRecord::Base.connection.execute("
|
|
15
|
+
SELECT summary
|
|
16
|
+
FROM `summaries`
|
|
17
|
+
WHERE `range_from` <= #{@result.sum}
|
|
18
|
+
AND `range_to` >= #{@result.sum}
|
|
19
|
+
")
|
|
20
|
+
@summary = @summary_sql.first.first
|
|
21
|
+
end
|
|
22
|
+
end
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
class SummariesController < ApplicationController
|
|
2
|
+
def index
|
|
3
|
+
@summaries = Summary.all
|
|
4
|
+
end
|
|
5
|
+
|
|
6
|
+
def show
|
|
7
|
+
authenticate_user!
|
|
8
|
+
@summary = summary.find(params[:id])
|
|
9
|
+
@summary_answer = summaryAnswer.new
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def new
|
|
13
|
+
@summary = Summary.new
|
|
14
|
+
@survey = Survey.find(1)
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def create
|
|
18
|
+
@summary = summary.new(params[:summary])
|
|
19
|
+
if @summary.save
|
|
20
|
+
flash[:notice] = "Successfully created summary."
|
|
21
|
+
redirect_to @summary
|
|
22
|
+
else
|
|
23
|
+
render :action => 'new'
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def edit
|
|
28
|
+
@summary = summary.find(params[:id])
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def update
|
|
32
|
+
@summary = summary.find(params[:id])
|
|
33
|
+
if @summary.update_attributes(params[:summary])
|
|
34
|
+
flash[:notice] = "Successfully updated summary."
|
|
35
|
+
redirect_to @summary
|
|
36
|
+
else
|
|
37
|
+
render :action => 'edit'
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def destroy
|
|
42
|
+
@summary = summary.find(params[:id])
|
|
43
|
+
@summary.destroy
|
|
44
|
+
flash[:notice] = "Successfully destroyed summary."
|
|
45
|
+
redirect_to summaries_url
|
|
46
|
+
end
|
|
47
|
+
end
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
class SurveyAnswersController < ApplicationController
|
|
2
|
+
def index
|
|
3
|
+
@surveys = Survey.all
|
|
4
|
+
end
|
|
5
|
+
|
|
6
|
+
def show
|
|
7
|
+
authenticate_user!
|
|
8
|
+
@survey = Survey.find(params[:id])
|
|
9
|
+
@survey_answer = SurveyAnswer.new
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def new
|
|
13
|
+
@survey = Survey.new
|
|
14
|
+
3.times do
|
|
15
|
+
question = @survey.questions.build
|
|
16
|
+
4.times { question.answers.build }
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def create
|
|
21
|
+
@survey = Survey.find(params[:survey_id])
|
|
22
|
+
params[:answers].each do |f|
|
|
23
|
+
@survey_answer = SurveyAnswer.new(:question_id=>f[0], :answer_id=>f[1], :user_id=>current_user.id, :survey_id=>@survey.id)
|
|
24
|
+
if (@survey_answer.save)
|
|
25
|
+
|
|
26
|
+
else
|
|
27
|
+
@survey_answer = SurveyAnswer.where(:question_id=>f[0], :user_id=>current_user.id).first
|
|
28
|
+
@survey_answer.answer_id = f[1]
|
|
29
|
+
@survey_answer.save
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
redirect_to survey_results_path(@survey)
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def edit
|
|
36
|
+
@survey = Survey.find(params[:id])
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def update
|
|
40
|
+
@survey = Survey.find(params[:id])
|
|
41
|
+
if @survey.update_attributes(params[:survey])
|
|
42
|
+
flash[:notice] = "Successfully updated survey."
|
|
43
|
+
redirect_to @survey
|
|
44
|
+
else
|
|
45
|
+
render :action => 'edit'
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
def destroy
|
|
50
|
+
@survey = Survey.find(params[:id])
|
|
51
|
+
@survey.destroy
|
|
52
|
+
flash[:notice] = "Successfully destroyed survey."
|
|
53
|
+
redirect_to surveys_url
|
|
54
|
+
end
|
|
55
|
+
end
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
class SurveysController < ApplicationController
|
|
2
|
+
def index
|
|
3
|
+
@surveys = Survey.all
|
|
4
|
+
end
|
|
5
|
+
|
|
6
|
+
def show
|
|
7
|
+
authenticate_user!
|
|
8
|
+
@survey = Survey.find(params[:id])
|
|
9
|
+
@survey_answer = SurveyAnswer.new
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def new
|
|
13
|
+
@survey = Survey.new
|
|
14
|
+
1.times do
|
|
15
|
+
question = @survey.questions.build
|
|
16
|
+
3.times { question.answers.build }
|
|
17
|
+
end
|
|
18
|
+
3.times do
|
|
19
|
+
summary = @survey.summaries.build
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def create
|
|
24
|
+
@survey = Survey.new(params[:survey])
|
|
25
|
+
if @survey.save
|
|
26
|
+
flash[:notice] = "Successfully created survey."
|
|
27
|
+
redirect_to @survey
|
|
28
|
+
else
|
|
29
|
+
render :action => 'new'
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def edit
|
|
34
|
+
@survey = Survey.find(params[:id])
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def update
|
|
38
|
+
@survey = Survey.find(params[:id])
|
|
39
|
+
if @survey.update_attributes(params[:survey])
|
|
40
|
+
flash[:notice] = "Successfully updated survey."
|
|
41
|
+
redirect_to @survey
|
|
42
|
+
else
|
|
43
|
+
render :action => 'edit'
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
def destroy
|
|
48
|
+
@survey = Survey.find(params[:id])
|
|
49
|
+
@survey.destroy
|
|
50
|
+
flash[:notice] = "Successfully destroyed survey."
|
|
51
|
+
redirect_to surveys_url
|
|
52
|
+
end
|
|
53
|
+
end
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
module SurveysHelper
|
|
2
|
+
def link_to_remove_fields(name, f)
|
|
3
|
+
end
|
|
4
|
+
|
|
5
|
+
def link_to_add_fields(name, f, association)
|
|
6
|
+
new_object = f.object.class.reflect_on_association(association).klass.new
|
|
7
|
+
fields = f.fields_for(association, new_object, :child_index => "new_#{association}") do |builder|
|
|
8
|
+
render(association.to_s.singularize + "_fields", :f => builder)
|
|
9
|
+
end
|
|
10
|
+
link_to_function(name, "add_fields(this, \"#{association}\", \"#{escape_javascript(fields)}\")")
|
|
11
|
+
end
|
|
12
|
+
def title(page_title, show_title = true)
|
|
13
|
+
@content_for_title = page_title.to_s
|
|
14
|
+
@show_title = show_title
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def show_title?
|
|
18
|
+
@show_title
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def stylesheet(*args)
|
|
22
|
+
content_for(:head) { stylesheet_link_tag(*args) }
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def javascript(*args)
|
|
26
|
+
content_for(:head) { javascript_include_tag(*args) }
|
|
27
|
+
end
|
|
28
|
+
end
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
class Survey < ActiveRecord::Base
|
|
2
|
+
has_many :questions, :dependent => :destroy
|
|
3
|
+
accepts_nested_attributes_for :questions, :reject_if => lambda { |a| a[:content].blank? }, :allow_destroy => true
|
|
4
|
+
validates_presence_of :name
|
|
5
|
+
has_many :summaries, :dependent => :destroy
|
|
6
|
+
accepts_nested_attributes_for :summaries
|
|
7
|
+
end
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
HELLOWORLD
|
|
2
|
+
<%= form_for [@survey, @summary] do |f| %>
|
|
3
|
+
<% if @summary.errors.any? %>
|
|
4
|
+
<div id="error_explanation">
|
|
5
|
+
<h2><%= pluralize(@summary.errors.count, "error") %> prohibited this summary from being saved:</h2>
|
|
6
|
+
|
|
7
|
+
<ul>
|
|
8
|
+
<% @summary.errors.full_messages.each do |msg| %>
|
|
9
|
+
<li><%= msg %></li>
|
|
10
|
+
<% end %>
|
|
11
|
+
</ul>
|
|
12
|
+
</div>
|
|
13
|
+
<% end %>
|
|
14
|
+
<p>
|
|
15
|
+
<%= f.label :summary %><br />
|
|
16
|
+
<%= f.text_field :summary %>
|
|
17
|
+
</p>
|
|
18
|
+
<p><%= f.submit "Submit" %></p>
|
|
19
|
+
<% end %>
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
<div class="fields">
|
|
2
|
+
<p>
|
|
3
|
+
<%= f.label :content, "Question" %>
|
|
4
|
+
<%= link_to_remove_fields "remove", f %><br />
|
|
5
|
+
<%= f.text_area :content, :rows => 3 %>
|
|
6
|
+
</p>
|
|
7
|
+
<%= f.fields_for :answers do |builder| %>
|
|
8
|
+
<%= render 'answer_fields', :f => builder %>
|
|
9
|
+
<% end %>
|
|
10
|
+
<p><%= link_to_add_fields "Add Answer", f, :answers %></p>
|
|
11
|
+
</div>
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
<% title "summaries" %>
|
|
2
|
+
|
|
3
|
+
<table>
|
|
4
|
+
<tr>
|
|
5
|
+
<th>Name</th>
|
|
6
|
+
</tr>
|
|
7
|
+
<% for summary in @summaries %>
|
|
8
|
+
<tr>
|
|
9
|
+
<td><%=h summary.name %></td>
|
|
10
|
+
<td><%= link_to "Show", summary %></td>
|
|
11
|
+
<td><%= link_to "Edit", edit_summary_path(summary) %></td>
|
|
12
|
+
<td><%= link_to "Destroy", summary, :confirm => 'Are you sure?', :method => :delete %></td>
|
|
13
|
+
</tr>
|
|
14
|
+
<% end %>
|
|
15
|
+
</table>
|
|
16
|
+
|
|
17
|
+
<p><%= link_to "New summary", new_survey_summary_path %></p>
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
<%= form_for @survey_answer do |f| %>
|
|
2
|
+
<input type="hidden" name="survey_id" value="<%= @survey.id %>" />
|
|
3
|
+
|
|
4
|
+
<p>
|
|
5
|
+
<strong>Name:</strong>
|
|
6
|
+
<%=h @survey.name %>
|
|
7
|
+
</p>
|
|
8
|
+
|
|
9
|
+
<ol>
|
|
10
|
+
<% for question in @survey.questions %>
|
|
11
|
+
<li>
|
|
12
|
+
<%=h question.content %>
|
|
13
|
+
<ul>
|
|
14
|
+
<% for answer in question.answers %>
|
|
15
|
+
<li>
|
|
16
|
+
<input type="radio" name="answers[<%= question.id %>]" value="<%= answer.id %>" />
|
|
17
|
+
<%=h answer.content %></li>
|
|
18
|
+
<% end %>
|
|
19
|
+
</ul>
|
|
20
|
+
</li>
|
|
21
|
+
<% end %>
|
|
22
|
+
</ol>
|
|
23
|
+
|
|
24
|
+
<p>
|
|
25
|
+
<%= link_to "Results", survey_results_path(@survey) %> |
|
|
26
|
+
<%= link_to "Edit", edit_survey_path(@survey) %> |
|
|
27
|
+
<%= link_to "Destroy", @survey, :confirm => 'Are you sure?', :method => :delete %> |
|
|
28
|
+
<%= link_to "View All", surveys_path %>
|
|
29
|
+
</p>
|
|
30
|
+
<p><%= f.submit "Submit" %></p>
|
|
31
|
+
<% end %>
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
<%= form_for @survey do |f| %>
|
|
2
|
+
<% if @survey.errors.any? %>
|
|
3
|
+
<div id="error_explanation">
|
|
4
|
+
<h2><%= pluralize(@survey.errors.count, "error") %> prohibited this survey from being saved:</h2>
|
|
5
|
+
|
|
6
|
+
<ul>
|
|
7
|
+
<% @survey.errors.full_messages.each do |msg| %>
|
|
8
|
+
<li><%= msg %></li>
|
|
9
|
+
<% end %>
|
|
10
|
+
</ul>
|
|
11
|
+
</div>
|
|
12
|
+
<% end %>
|
|
13
|
+
<p>
|
|
14
|
+
<%= f.label :name %><br />
|
|
15
|
+
<%= f.text_field :name %>
|
|
16
|
+
</p>
|
|
17
|
+
<%= f.fields_for :questions do |builder| %>
|
|
18
|
+
<%= raw render "question_fields", :f => builder %>
|
|
19
|
+
<% end %>
|
|
20
|
+
<p><%= link_to_add_fields "Add Question", f, :questions %></p>
|
|
21
|
+
|
|
22
|
+
<%= f.fields_for :summaries do |builder| %>
|
|
23
|
+
<%= raw render "summary_fields", :f => builder %>
|
|
24
|
+
<% end %>
|
|
25
|
+
|
|
26
|
+
<p><%= f.submit "Submit" %></p>
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
<% end %>
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
<div class="fields">
|
|
2
|
+
<p>
|
|
3
|
+
<%= f.label :content, "Question" %>
|
|
4
|
+
<%= link_to_remove_fields "remove", f %><br />
|
|
5
|
+
<%= f.text_area :content, :rows => 3 %>
|
|
6
|
+
</p>
|
|
7
|
+
<%= f.fields_for :answers do |builder| %>
|
|
8
|
+
<%= render 'answer_fields', :f => builder %>
|
|
9
|
+
<% end %>
|
|
10
|
+
<p><%= link_to_add_fields "Add Answer", f, :answers %></p>
|
|
11
|
+
</div>
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
<% title "Surveys" %>
|
|
2
|
+
|
|
3
|
+
<table>
|
|
4
|
+
<tr>
|
|
5
|
+
<th>Name</th>
|
|
6
|
+
</tr>
|
|
7
|
+
<% for survey in @surveys %>
|
|
8
|
+
<tr>
|
|
9
|
+
<td><%=h survey.name %></td>
|
|
10
|
+
<td><%= link_to "Show", survey %></td>
|
|
11
|
+
<td><%= link_to "Edit", edit_survey_path(survey) %></td>
|
|
12
|
+
<td><%= link_to "Destroy", survey, :confirm => 'Are you sure?', :method => :delete %></td>
|
|
13
|
+
</tr>
|
|
14
|
+
<% end %>
|
|
15
|
+
</table>
|
|
16
|
+
|
|
17
|
+
<p><%= link_to "New Survey", new_survey_path %></p>
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
<%= form_for @survey_answer do |f| %>
|
|
2
|
+
<input type="hidden" name="survey_id" value="<%= @survey.id %>" />
|
|
3
|
+
|
|
4
|
+
<p>
|
|
5
|
+
<strong>Name:</strong>
|
|
6
|
+
<%=h @survey.name %>
|
|
7
|
+
</p>
|
|
8
|
+
|
|
9
|
+
<ol>
|
|
10
|
+
<% for question in @survey.questions %>
|
|
11
|
+
<li>
|
|
12
|
+
<%=h question.content %>
|
|
13
|
+
<ul>
|
|
14
|
+
<% for answer in question.answers %>
|
|
15
|
+
<li>
|
|
16
|
+
<input type="radio" name="answers[<%= question.id %>]" value="<%= answer.id %>" />
|
|
17
|
+
<%=h answer.content %></li>
|
|
18
|
+
<% end %>
|
|
19
|
+
</ul>
|
|
20
|
+
</li>
|
|
21
|
+
<% end %>
|
|
22
|
+
</ol>
|
|
23
|
+
|
|
24
|
+
<p>
|
|
25
|
+
<%= link_to "Results", survey_results_path(@survey) %> |
|
|
26
|
+
<%= link_to "Edit", edit_survey_path(@survey) %> |
|
|
27
|
+
<%= link_to "Destroy", @survey, :confirm => 'Are you sure?', :method => :delete %> |
|
|
28
|
+
<%= link_to "View All", surveys_path %>
|
|
29
|
+
</p>
|
|
30
|
+
<p><%= f.submit "Submit" %></p>
|
|
31
|
+
<% end %>
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
require 'rails/generators'
|
|
2
|
+
require 'rails/generators/migration'
|
|
3
|
+
|
|
4
|
+
class DevapeSurveyGenerator < Rails::Generators::Base
|
|
5
|
+
include Rails::Generators::Migration
|
|
6
|
+
source_root File.expand_path("../templates", __FILE__)
|
|
7
|
+
def copy_initializer_file
|
|
8
|
+
copy_file "create_answers.rb", "db/migrate/0000000111_create_answers.rb"
|
|
9
|
+
copy_file "create_questions.rb", "db/migrate/0000000112_create_questions.rb"
|
|
10
|
+
copy_file "create_surveys.rb", "db/migrate/0000000113_create_surveys.rb"
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
end
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
class CreateSurveys < ActiveRecord::Migration
|
|
2
|
+
def self.up
|
|
3
|
+
create_table :surveys do |t|
|
|
4
|
+
t.string :name
|
|
5
|
+
t.timestamps
|
|
6
|
+
end
|
|
7
|
+
create_table :survey_answers do |t|
|
|
8
|
+
t.integer :user_id
|
|
9
|
+
t.integer :answer_id
|
|
10
|
+
t.integer :question_id
|
|
11
|
+
t.integer :survey_id
|
|
12
|
+
t.timestamps
|
|
13
|
+
end
|
|
14
|
+
create_table :summaries do |t|
|
|
15
|
+
t.integer :survey_id
|
|
16
|
+
t.integer :range_from
|
|
17
|
+
t.integer :range_to
|
|
18
|
+
t.text :summary
|
|
19
|
+
t.timestamps
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def self.down
|
|
24
|
+
drop_table :surveys
|
|
25
|
+
drop_table :survey_answers
|
|
26
|
+
drop_table :summaries
|
|
27
|
+
end
|
|
28
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: devape_survey
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
prerelease:
|
|
5
|
+
version: 0.0.2
|
|
6
|
+
platform: ruby
|
|
7
|
+
authors:
|
|
8
|
+
- John Kealy
|
|
9
|
+
autorequire:
|
|
10
|
+
bindir: bin
|
|
11
|
+
cert_chain: []
|
|
12
|
+
|
|
13
|
+
date: 2011-08-05 00:00:00 Z
|
|
14
|
+
dependencies: []
|
|
15
|
+
|
|
16
|
+
description: Insert DevapeSurvey description.
|
|
17
|
+
email:
|
|
18
|
+
executables: []
|
|
19
|
+
|
|
20
|
+
extensions: []
|
|
21
|
+
|
|
22
|
+
extra_rdoc_files: []
|
|
23
|
+
|
|
24
|
+
files:
|
|
25
|
+
- lib/tasks/devape_survey_tasks.rake
|
|
26
|
+
- lib/devape_survey.rb
|
|
27
|
+
- lib/rails/generators/devape_survey/templates/create_answers.rb
|
|
28
|
+
- lib/rails/generators/devape_survey/templates/create_questions.rb
|
|
29
|
+
- lib/rails/generators/devape_survey/templates/create_surveys.rb
|
|
30
|
+
- lib/rails/generators/devape_survey/devape_survey_generator.rb
|
|
31
|
+
- lib/devape_survey/engine.rb
|
|
32
|
+
- MIT-LICENSE
|
|
33
|
+
- Rakefile
|
|
34
|
+
- README.rdoc
|
|
35
|
+
- app/views/surveys/edit.html.erb
|
|
36
|
+
- app/views/surveys/show.html.erb
|
|
37
|
+
- app/views/surveys/_question_fields.html.erb
|
|
38
|
+
- app/views/surveys/_form.html.erb
|
|
39
|
+
- app/views/surveys/_answer_fields.html.erb
|
|
40
|
+
- app/views/surveys/_summary_fields.html.erb
|
|
41
|
+
- app/views/surveys/new.html.erb
|
|
42
|
+
- app/views/surveys/index.html.erb
|
|
43
|
+
- app/views/summaries/edit.html.erb
|
|
44
|
+
- app/views/summaries/show.html.erb
|
|
45
|
+
- app/views/summaries/_question_fields.html.erb
|
|
46
|
+
- app/views/summaries/_form.html.erb
|
|
47
|
+
- app/views/summaries/_answer_fields.html.erb
|
|
48
|
+
- app/views/summaries/new.html.erb
|
|
49
|
+
- app/views/summaries/index.html.erb
|
|
50
|
+
- app/views/results/index.html.erb
|
|
51
|
+
- app/controllers/surveys_controller.rb
|
|
52
|
+
- app/controllers/summaries_controller.rb
|
|
53
|
+
- app/controllers/survey_answers_controller.rb
|
|
54
|
+
- app/controllers/results_controller.rb
|
|
55
|
+
- app/models/summary.rb
|
|
56
|
+
- app/models/question.rb
|
|
57
|
+
- app/models/survey_answer.rb
|
|
58
|
+
- app/models/answer.rb
|
|
59
|
+
- app/models/survey.rb
|
|
60
|
+
- app/helpers/surveys_helper.rb
|
|
61
|
+
homepage:
|
|
62
|
+
licenses: []
|
|
63
|
+
|
|
64
|
+
post_install_message:
|
|
65
|
+
rdoc_options: []
|
|
66
|
+
|
|
67
|
+
require_paths:
|
|
68
|
+
- lib
|
|
69
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
70
|
+
none: false
|
|
71
|
+
requirements:
|
|
72
|
+
- - ">="
|
|
73
|
+
- !ruby/object:Gem::Version
|
|
74
|
+
version: "0"
|
|
75
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
76
|
+
none: false
|
|
77
|
+
requirements:
|
|
78
|
+
- - ">="
|
|
79
|
+
- !ruby/object:Gem::Version
|
|
80
|
+
version: "0"
|
|
81
|
+
requirements: []
|
|
82
|
+
|
|
83
|
+
rubyforge_project:
|
|
84
|
+
rubygems_version: 1.8.5
|
|
85
|
+
signing_key:
|
|
86
|
+
specification_version: 3
|
|
87
|
+
summary: Insert DevapeSurvey summary.
|
|
88
|
+
test_files: []
|
|
89
|
+
|