forked from bofh/fetsite
AutoCommit Don Jul 30 00:03:02 CEST 2015
This commit is contained in:
3
app/assets/javascripts/survey/answers.js.coffee
Normal file
3
app/assets/javascripts/survey/answers.js.coffee
Normal file
@@ -0,0 +1,3 @@
|
||||
# Place all the behaviors and hooks related to the matching controller here.
|
||||
# All this logic will automatically be available in application.js.
|
||||
# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/
|
||||
3
app/assets/javascripts/survey/choices.js.coffee
Normal file
3
app/assets/javascripts/survey/choices.js.coffee
Normal file
@@ -0,0 +1,3 @@
|
||||
# Place all the behaviors and hooks related to the matching controller here.
|
||||
# All this logic will automatically be available in application.js.
|
||||
# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/
|
||||
3
app/assets/javascripts/survey/questions.js.coffee
Normal file
3
app/assets/javascripts/survey/questions.js.coffee
Normal file
@@ -0,0 +1,3 @@
|
||||
# Place all the behaviors and hooks related to the matching controller here.
|
||||
# All this logic will automatically be available in application.js.
|
||||
# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/
|
||||
3
app/assets/stylesheets/survey/answers.css.scss
Normal file
3
app/assets/stylesheets/survey/answers.css.scss
Normal file
@@ -0,0 +1,3 @@
|
||||
// Place all the styles related to the Survey::answers controller here.
|
||||
// They will automatically be included in application.css.
|
||||
// You can use Sass (SCSS) here: http://sass-lang.com/
|
||||
3
app/assets/stylesheets/survey/choices.css.scss
Normal file
3
app/assets/stylesheets/survey/choices.css.scss
Normal file
@@ -0,0 +1,3 @@
|
||||
// Place all the styles related to the Survey::choices controller here.
|
||||
// They will automatically be included in application.css.
|
||||
// You can use Sass (SCSS) here: http://sass-lang.com/
|
||||
3
app/assets/stylesheets/survey/questions.css.scss
Normal file
3
app/assets/stylesheets/survey/questions.css.scss
Normal file
@@ -0,0 +1,3 @@
|
||||
// Place all the styles related to the Survey::questions controller here.
|
||||
// They will automatically be included in application.css.
|
||||
// You can use Sass (SCSS) here: http://sass-lang.com/
|
||||
83
app/controllers/survey/answers_controller.rb
Normal file
83
app/controllers/survey/answers_controller.rb
Normal file
@@ -0,0 +1,83 @@
|
||||
class Survey::AnswersController < ApplicationController
|
||||
# GET /survey/answers
|
||||
# GET /survey/answers.json
|
||||
def index
|
||||
@survey_answers = Survey::Answer.all
|
||||
|
||||
respond_to do |format|
|
||||
format.html # index.html.erb
|
||||
format.json { render json: @survey_answers }
|
||||
end
|
||||
end
|
||||
|
||||
# GET /survey/answers/1
|
||||
# GET /survey/answers/1.json
|
||||
def show
|
||||
@survey_answer = Survey::Answer.find(params[:id])
|
||||
|
||||
respond_to do |format|
|
||||
format.html # show.html.erb
|
||||
format.json { render json: @survey_answer }
|
||||
end
|
||||
end
|
||||
|
||||
# GET /survey/answers/new
|
||||
# GET /survey/answers/new.json
|
||||
def new
|
||||
@survey_answer = Survey::Answer.new
|
||||
|
||||
respond_to do |format|
|
||||
format.html # new.html.erb
|
||||
format.json { render json: @survey_answer }
|
||||
end
|
||||
end
|
||||
|
||||
# GET /survey/answers/1/edit
|
||||
def edit
|
||||
@survey_answer = Survey::Answer.find(params[:id])
|
||||
end
|
||||
|
||||
# POST /survey/answers
|
||||
# POST /survey/answers.json
|
||||
def create
|
||||
@survey_answer = Survey::Answer.new(params[:survey_answer])
|
||||
|
||||
respond_to do |format|
|
||||
if @survey_answer.save
|
||||
format.html { redirect_to @survey_answer, notice: 'Answer was successfully created.' }
|
||||
format.json { render json: @survey_answer, status: :created, location: @survey_answer }
|
||||
else
|
||||
format.html { render action: "new" }
|
||||
format.json { render json: @survey_answer.errors, status: :unprocessable_entity }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# PUT /survey/answers/1
|
||||
# PUT /survey/answers/1.json
|
||||
def update
|
||||
@survey_answer = Survey::Answer.find(params[:id])
|
||||
|
||||
respond_to do |format|
|
||||
if @survey_answer.update_attributes(params[:survey_answer])
|
||||
format.html { redirect_to @survey_answer, notice: 'Answer was successfully updated.' }
|
||||
format.json { head :no_content }
|
||||
else
|
||||
format.html { render action: "edit" }
|
||||
format.json { render json: @survey_answer.errors, status: :unprocessable_entity }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# DELETE /survey/answers/1
|
||||
# DELETE /survey/answers/1.json
|
||||
def destroy
|
||||
@survey_answer = Survey::Answer.find(params[:id])
|
||||
@survey_answer.destroy
|
||||
|
||||
respond_to do |format|
|
||||
format.html { redirect_to survey_answers_url }
|
||||
format.json { head :no_content }
|
||||
end
|
||||
end
|
||||
end
|
||||
83
app/controllers/survey/choices_controller.rb
Normal file
83
app/controllers/survey/choices_controller.rb
Normal file
@@ -0,0 +1,83 @@
|
||||
class Survey::ChoicesController < ApplicationController
|
||||
# GET /survey/choices
|
||||
# GET /survey/choices.json
|
||||
def index
|
||||
@survey_choices = Survey::Choice.all
|
||||
|
||||
respond_to do |format|
|
||||
format.html # index.html.erb
|
||||
format.json { render json: @survey_choices }
|
||||
end
|
||||
end
|
||||
|
||||
# GET /survey/choices/1
|
||||
# GET /survey/choices/1.json
|
||||
def show
|
||||
@survey_choice = Survey::Choice.find(params[:id])
|
||||
|
||||
respond_to do |format|
|
||||
format.html # show.html.erb
|
||||
format.json { render json: @survey_choice }
|
||||
end
|
||||
end
|
||||
|
||||
# GET /survey/choices/new
|
||||
# GET /survey/choices/new.json
|
||||
def new
|
||||
@survey_choice = Survey::Choice.new
|
||||
|
||||
respond_to do |format|
|
||||
format.html # new.html.erb
|
||||
format.json { render json: @survey_choice }
|
||||
end
|
||||
end
|
||||
|
||||
# GET /survey/choices/1/edit
|
||||
def edit
|
||||
@survey_choice = Survey::Choice.find(params[:id])
|
||||
end
|
||||
|
||||
# POST /survey/choices
|
||||
# POST /survey/choices.json
|
||||
def create
|
||||
@survey_choice = Survey::Choice.new(params[:survey_choice])
|
||||
|
||||
respond_to do |format|
|
||||
if @survey_choice.save
|
||||
format.html { redirect_to @survey_choice, notice: 'Choice was successfully created.' }
|
||||
format.json { render json: @survey_choice, status: :created, location: @survey_choice }
|
||||
else
|
||||
format.html { render action: "new" }
|
||||
format.json { render json: @survey_choice.errors, status: :unprocessable_entity }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# PUT /survey/choices/1
|
||||
# PUT /survey/choices/1.json
|
||||
def update
|
||||
@survey_choice = Survey::Choice.find(params[:id])
|
||||
|
||||
respond_to do |format|
|
||||
if @survey_choice.update_attributes(params[:survey_choice])
|
||||
format.html { redirect_to @survey_choice, notice: 'Choice was successfully updated.' }
|
||||
format.json { head :no_content }
|
||||
else
|
||||
format.html { render action: "edit" }
|
||||
format.json { render json: @survey_choice.errors, status: :unprocessable_entity }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# DELETE /survey/choices/1
|
||||
# DELETE /survey/choices/1.json
|
||||
def destroy
|
||||
@survey_choice = Survey::Choice.find(params[:id])
|
||||
@survey_choice.destroy
|
||||
|
||||
respond_to do |format|
|
||||
format.html { redirect_to survey_choices_url }
|
||||
format.json { head :no_content }
|
||||
end
|
||||
end
|
||||
end
|
||||
85
app/controllers/survey/questions_controller.rb
Normal file
85
app/controllers/survey/questions_controller.rb
Normal file
@@ -0,0 +1,85 @@
|
||||
class Survey::QuestionsController < ApplicationController
|
||||
# GET /survey/questions
|
||||
# GET /survey/questions.json
|
||||
def index
|
||||
@survey_questions = Survey::Question.all
|
||||
|
||||
respond_to do |format|
|
||||
format.html # index.html.erb
|
||||
format.json { render json: @survey_questions }
|
||||
end
|
||||
end
|
||||
def answer
|
||||
render :show
|
||||
end
|
||||
# GET /survey/questions/1
|
||||
# GET /survey/questions/1.json
|
||||
def show
|
||||
@survey_question = Survey::Question.find(params[:id])
|
||||
|
||||
respond_to do |format|
|
||||
format.html # show.html.erb
|
||||
format.json { render json: @survey_question }
|
||||
end
|
||||
end
|
||||
|
||||
# GET /survey/questions/new
|
||||
# GET /survey/questions/new.json
|
||||
def new
|
||||
@survey_question = Survey::Question.new
|
||||
|
||||
respond_to do |format|
|
||||
format.html # new.html.erb
|
||||
format.json { render json: @survey_question }
|
||||
end
|
||||
end
|
||||
|
||||
# GET /survey/questions/1/edit
|
||||
def edit
|
||||
@survey_question = Survey::Question.find(params[:id])
|
||||
end
|
||||
|
||||
# POST /survey/questions
|
||||
# POST /survey/questions.json
|
||||
def create
|
||||
@survey_question = Survey::Question.new(params[:survey_question])
|
||||
|
||||
respond_to do |format|
|
||||
if @survey_question.save
|
||||
format.html { redirect_to @survey_question, notice: 'Question was successfully created.' }
|
||||
format.json { render json: @survey_question, status: :created, location: @survey_question }
|
||||
else
|
||||
format.html { render action: "new" }
|
||||
format.json { render json: @survey_question.errors, status: :unprocessable_entity }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# PUT /survey/questions/1
|
||||
# PUT /survey/questions/1.json
|
||||
def update
|
||||
@survey_question = Survey::Question.find(params[:id])
|
||||
|
||||
respond_to do |format|
|
||||
if @survey_question.update_attributes(params[:survey_question])
|
||||
format.html { redirect_to @survey_question, notice: 'Question was successfully updated.' }
|
||||
format.json { head :no_content }
|
||||
else
|
||||
format.html { render action: "edit" }
|
||||
format.json { render json: @survey_question.errors, status: :unprocessable_entity }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# DELETE /survey/questions/1
|
||||
# DELETE /survey/questions/1.json
|
||||
def destroy
|
||||
@survey_question = Survey::Question.find(params[:id])
|
||||
@survey_question.destroy
|
||||
|
||||
respond_to do |format|
|
||||
format.html { redirect_to survey_questions_url }
|
||||
format.json { head :no_content }
|
||||
end
|
||||
end
|
||||
end
|
||||
2
app/helpers/survey/answers_helper.rb
Normal file
2
app/helpers/survey/answers_helper.rb
Normal file
@@ -0,0 +1,2 @@
|
||||
module Survey::AnswersHelper
|
||||
end
|
||||
2
app/helpers/survey/choices_helper.rb
Normal file
2
app/helpers/survey/choices_helper.rb
Normal file
@@ -0,0 +1,2 @@
|
||||
module Survey::ChoicesHelper
|
||||
end
|
||||
2
app/helpers/survey/questions_helper.rb
Normal file
2
app/helpers/survey/questions_helper.rb
Normal file
@@ -0,0 +1,2 @@
|
||||
module Survey::QuestionsHelper
|
||||
end
|
||||
5
app/models/survey.rb
Normal file
5
app/models/survey.rb
Normal file
@@ -0,0 +1,5 @@
|
||||
module Survey
|
||||
def self.table_name_prefix
|
||||
'survey_'
|
||||
end
|
||||
end
|
||||
5
app/models/survey/answer.rb
Normal file
5
app/models/survey/answer.rb
Normal file
@@ -0,0 +1,5 @@
|
||||
class Survey::Answer < ActiveRecord::Base
|
||||
belongs_to :choice, class_name: 'Survey::Choice'
|
||||
belongs_to :user
|
||||
# attr_accessible :title, :body
|
||||
end
|
||||
5
app/models/survey/choice.rb
Normal file
5
app/models/survey/choice.rb
Normal file
@@ -0,0 +1,5 @@
|
||||
class Survey::Choice < ActiveRecord::Base
|
||||
belongs_to :question, class_name: 'Survey::Question'
|
||||
attr_accessible :picture, :sort, :text
|
||||
has_many :answers, class_name: 'Survey::Answer'
|
||||
end
|
||||
16
app/models/survey/question.rb
Normal file
16
app/models/survey/question.rb
Normal file
@@ -0,0 +1,16 @@
|
||||
class Survey::Question < ActiveRecord::Base
|
||||
attr_accessible :text, :title, :typ, :choice_ids
|
||||
belongs_to :parent, polymorphic: true
|
||||
has_many :choices
|
||||
has_many :answers, through: :choices
|
||||
def add_yesno_choices
|
||||
c=Survey::Choice.new(title: "Ja")
|
||||
c.save
|
||||
this.choices << c
|
||||
c=Survey::Choice.new(title: "Nein")
|
||||
c.save
|
||||
this.choices << c
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
10
app/views/survey/answers/_form.html.erb
Normal file
10
app/views/survey/answers/_form.html.erb
Normal file
@@ -0,0 +1,10 @@
|
||||
<%= semantic_form_for @answer do |f| %>
|
||||
<%= f.inputs do %>
|
||||
<%= f.input :choice %>
|
||||
<%= f.input :user %>
|
||||
<% end %>
|
||||
|
||||
<%= f.actions do %>
|
||||
<%= f.action :submit, :as => :input %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
6
app/views/survey/answers/edit.html.erb
Normal file
6
app/views/survey/answers/edit.html.erb
Normal file
@@ -0,0 +1,6 @@
|
||||
<h1>Editing survey_answer</h1>
|
||||
|
||||
<%= render 'form' %>
|
||||
|
||||
<%= link_to 'Show', @survey_answer %> |
|
||||
<%= link_to 'Back', survey_answers_path %>
|
||||
25
app/views/survey/answers/index.html.erb
Normal file
25
app/views/survey/answers/index.html.erb
Normal file
@@ -0,0 +1,25 @@
|
||||
<h1>Listing survey_answers</h1>
|
||||
|
||||
<table>
|
||||
<tr>
|
||||
<th>Choice</th>
|
||||
<th>User</th>
|
||||
<th></th>
|
||||
<th></th>
|
||||
<th></th>
|
||||
</tr>
|
||||
|
||||
<% @survey_answers.each do |survey_answer| %>
|
||||
<tr>
|
||||
<td><%= survey_answer.choice %></td>
|
||||
<td><%= survey_answer.user %></td>
|
||||
<td><%= link_to 'Show', survey_answer %></td>
|
||||
<td><%= link_to 'Edit', edit_survey_answer_path(survey_answer) %></td>
|
||||
<td><%= link_to 'Destroy', survey_answer, method: :delete, data: { confirm: 'Are you sure?' } %></td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</table>
|
||||
|
||||
<br />
|
||||
|
||||
<%= link_to 'New Answer', new_survey_answer_path %>
|
||||
5
app/views/survey/answers/new.html.erb
Normal file
5
app/views/survey/answers/new.html.erb
Normal file
@@ -0,0 +1,5 @@
|
||||
<h1>New survey_answer</h1>
|
||||
|
||||
<%= render 'form' %>
|
||||
|
||||
<%= link_to 'Back', survey_answers_path %>
|
||||
15
app/views/survey/answers/show.html.erb
Normal file
15
app/views/survey/answers/show.html.erb
Normal file
@@ -0,0 +1,15 @@
|
||||
<p id="notice"><%= notice %></p>
|
||||
|
||||
<p>
|
||||
<b>Choice:</b>
|
||||
<%= @survey_answer.choice %>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<b>User:</b>
|
||||
<%= @survey_answer.user %>
|
||||
</p>
|
||||
|
||||
|
||||
<%= link_to 'Edit', edit_survey_answer_path(@survey_answer) %> |
|
||||
<%= link_to 'Back', survey_answers_path %>
|
||||
12
app/views/survey/choices/_form.html.erb
Normal file
12
app/views/survey/choices/_form.html.erb
Normal file
@@ -0,0 +1,12 @@
|
||||
<%= semantic_form_for @choice do |f| %>
|
||||
<%= f.inputs do %>
|
||||
<%= f.input :text %>
|
||||
<%= f.input :question %>
|
||||
<%= f.input :sort %>
|
||||
<%= f.input :picture %>
|
||||
<% end %>
|
||||
|
||||
<%= f.actions do %>
|
||||
<%= f.action :submit, :as => :input %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
6
app/views/survey/choices/edit.html.erb
Normal file
6
app/views/survey/choices/edit.html.erb
Normal file
@@ -0,0 +1,6 @@
|
||||
<h1>Editing survey_choice</h1>
|
||||
|
||||
<%= render 'form' %>
|
||||
|
||||
<%= link_to 'Show', @survey_choice %> |
|
||||
<%= link_to 'Back', survey_choices_path %>
|
||||
29
app/views/survey/choices/index.html.erb
Normal file
29
app/views/survey/choices/index.html.erb
Normal file
@@ -0,0 +1,29 @@
|
||||
<h1>Listing survey_choices</h1>
|
||||
|
||||
<table>
|
||||
<tr>
|
||||
<th>Text</th>
|
||||
<th>Question</th>
|
||||
<th>Sort</th>
|
||||
<th>Picture</th>
|
||||
<th></th>
|
||||
<th></th>
|
||||
<th></th>
|
||||
</tr>
|
||||
|
||||
<% @survey_choices.each do |survey_choice| %>
|
||||
<tr>
|
||||
<td><%= survey_choice.text %></td>
|
||||
<td><%= survey_choice.question %></td>
|
||||
<td><%= survey_choice.sort %></td>
|
||||
<td><%= survey_choice.picture %></td>
|
||||
<td><%= link_to 'Show', survey_choice %></td>
|
||||
<td><%= link_to 'Edit', edit_survey_choice_path(survey_choice) %></td>
|
||||
<td><%= link_to 'Destroy', survey_choice, method: :delete, data: { confirm: 'Are you sure?' } %></td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</table>
|
||||
|
||||
<br />
|
||||
|
||||
<%= link_to 'New Choice', new_survey_choice_path %>
|
||||
5
app/views/survey/choices/new.html.erb
Normal file
5
app/views/survey/choices/new.html.erb
Normal file
@@ -0,0 +1,5 @@
|
||||
<h1>New survey_choice</h1>
|
||||
|
||||
<%= render 'form' %>
|
||||
|
||||
<%= link_to 'Back', survey_choices_path %>
|
||||
25
app/views/survey/choices/show.html.erb
Normal file
25
app/views/survey/choices/show.html.erb
Normal file
@@ -0,0 +1,25 @@
|
||||
<p id="notice"><%= notice %></p>
|
||||
|
||||
<p>
|
||||
<b>Text:</b>
|
||||
<%= @survey_choice.text %>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<b>Question:</b>
|
||||
<%= @survey_choice.question %>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<b>Sort:</b>
|
||||
<%= @survey_choice.sort %>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<b>Picture:</b>
|
||||
<%= @survey_choice.picture %>
|
||||
</p>
|
||||
|
||||
|
||||
<%= link_to 'Edit', edit_survey_choice_path(@survey_choice) %> |
|
||||
<%= link_to 'Back', survey_choices_path %>
|
||||
13
app/views/survey/questions/_form.html.erb
Normal file
13
app/views/survey/questions/_form.html.erb
Normal file
@@ -0,0 +1,13 @@
|
||||
<%= semantic_form_for @survey_question do |f| %>
|
||||
<%= f.inputs do %>
|
||||
<%= f.input :title %>
|
||||
<%= f.input :text %>
|
||||
|
||||
|
||||
<%= f.input :typ %>
|
||||
<% end %>
|
||||
|
||||
<%= f.actions do %>
|
||||
<%= f.action :submit, :as => :input %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
2
app/views/survey/questions/_question.html.erb
Normal file
2
app/views/survey/questions/_question.html.erb
Normal file
@@ -0,0 +1,2 @@
|
||||
<b><%= question.title%></b>
|
||||
<%= form_for %>
|
||||
6
app/views/survey/questions/edit.html.erb
Normal file
6
app/views/survey/questions/edit.html.erb
Normal file
@@ -0,0 +1,6 @@
|
||||
<h1>Editing survey_question</h1>
|
||||
|
||||
<%= render 'form' %>
|
||||
|
||||
<%= link_to 'Show', @survey_question %> |
|
||||
<%= link_to 'Back', survey_questions_path %>
|
||||
27
app/views/survey/questions/index.html.erb
Normal file
27
app/views/survey/questions/index.html.erb
Normal file
@@ -0,0 +1,27 @@
|
||||
<h1>Listing survey_questions</h1>
|
||||
|
||||
<table>
|
||||
<tr>
|
||||
<th>Title</th>
|
||||
<th>Text</th>
|
||||
<th>Typ</th>
|
||||
<th></th>
|
||||
<th></th>
|
||||
<th></th>
|
||||
</tr>
|
||||
|
||||
<% @survey_questions.each do |survey_question| %>
|
||||
<tr>
|
||||
<td><%= survey_question.title %></td>
|
||||
<td><%= survey_question.text %></td>
|
||||
<td><%= survey_question.typ %></td>
|
||||
<td><%= link_to 'Show', survey_question %></td>
|
||||
<td><%= link_to 'Edit', edit_survey_question_path(survey_question) %></td>
|
||||
<td><%= link_to 'Destroy', survey_question, method: :delete, data: { confirm: 'Are you sure?' } %></td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</table>
|
||||
|
||||
<br />
|
||||
|
||||
<%= link_to 'New Question', new_survey_question_path %>
|
||||
5
app/views/survey/questions/new.html.erb
Normal file
5
app/views/survey/questions/new.html.erb
Normal file
@@ -0,0 +1,5 @@
|
||||
<h1>New survey_question</h1>
|
||||
|
||||
<%= render 'form' %>
|
||||
|
||||
<%= link_to 'Back', survey_questions_path %>
|
||||
21
app/views/survey/questions/show.html.erb
Normal file
21
app/views/survey/questions/show.html.erb
Normal file
@@ -0,0 +1,21 @@
|
||||
<p id="notice"><%= notice %></p>
|
||||
|
||||
<p>
|
||||
<b>Title:</b>
|
||||
<%= @survey_question.title %>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<b>Text:</b>
|
||||
<%= @survey_question.text %>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<b>Typ:</b>
|
||||
<%= @survey_question.typ %>
|
||||
</p>
|
||||
|
||||
<%= render @survey_question %>
|
||||
|
||||
<%= link_to 'Edit', edit_survey_question_path(@survey_question) %> |
|
||||
<%= link_to 'Back', survey_questions_path %>
|
||||
Reference in New Issue
Block a user