Adding surveys
This commit is contained in:
parent
69a0d12793
commit
335608e6c4
28 changed files with 434 additions and 21 deletions
47
app/controllers/admin/survey_questions_controller.rb
Normal file
47
app/controllers/admin/survey_questions_controller.rb
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
module Admin
|
||||
class SurveyQuestionsController < Admin::BaseController
|
||||
load_and_authorize_resource :conference, find_by: :short_title
|
||||
load_and_authorize_resource :survey, through: :conference
|
||||
load_and_authorize_resource through: :survey
|
||||
|
||||
def index
|
||||
end
|
||||
|
||||
def show
|
||||
end
|
||||
|
||||
def new
|
||||
@survey_question = @survey.survey_questions.new
|
||||
@url = admin_conference_survey_survey_questions_path(@conference.short_title, @survey)
|
||||
end
|
||||
|
||||
def create
|
||||
@survey.survey_questions.create(survey_question_params)
|
||||
redirect_to admin_conference_survey_survey_questions_path(@conference.short_title, @survey)
|
||||
end
|
||||
|
||||
# GET questions/1/edit
|
||||
def edit
|
||||
@url = admin_conference_survey_survey_question_path(@conference.short_title, @survey, @survey_question)
|
||||
end
|
||||
|
||||
# PUT questions/1
|
||||
def update
|
||||
if @survey_question.update_attributes(survey_question_params)
|
||||
redirect_to admin_conference_survey_survey_questions_path(@conference.short_title, @survey), notice: 'Successfully updated survey question.'
|
||||
else
|
||||
render :edit
|
||||
end
|
||||
end
|
||||
|
||||
# DELETE questions/1
|
||||
def destroy
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def survey_question_params
|
||||
params.require(:survey_question).permit(:title, :kind, :possible_answers, :min_choices, :max_choices, :mandatory)
|
||||
end
|
||||
end
|
||||
end
|
||||
42
app/controllers/admin/surveys_controller.rb
Normal file
42
app/controllers/admin/surveys_controller.rb
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
module Admin
|
||||
class SurveysController < Admin::BaseController
|
||||
load_and_authorize_resource :conference, find_by: :short_title
|
||||
load_and_authorize_resource
|
||||
|
||||
def index
|
||||
@surveys = @conference.surveys
|
||||
end
|
||||
|
||||
def new
|
||||
@survey = Survey.new(survey_params)
|
||||
@url = admin_conference_surveys_path(@conference.short_title)
|
||||
end
|
||||
|
||||
def create
|
||||
@survey = Survey.new(survey_params)
|
||||
if @survey.save
|
||||
redirect_to new_admin_conference_survey_survey_question_path(@conference.short_title, @survey)
|
||||
end
|
||||
end
|
||||
|
||||
def edit
|
||||
@url = admin_conference_survey_path(@conference.short_title, @survey)
|
||||
end
|
||||
|
||||
def update
|
||||
@survey.update_attributes(survey_params)
|
||||
redirect_to admin_conference_surveys_path(@conference.short_title)
|
||||
end
|
||||
|
||||
def destroy
|
||||
@survey.destroy
|
||||
redirect_to admin_conference_surveys_path(@conference.short_title)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def survey_params
|
||||
params.require(:survey).permit(:title, :description, :start_date, :end_date, :surveyable_type, :surveyable_id)
|
||||
end
|
||||
end
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue