Class: Course::Survey::SurveysController

Inherits:
Controller show all
Includes:
ReorderingConcern
Defined in:
app/controllers/course/survey/surveys_controller.rb

Instance Method Summary collapse

Methods included from ReorderingConcern

#reorder_questions, #reorder_sections

Methods included from ApplicationSignInCallbacksConcern

#sign_in

Methods included from ApplicationPaginationConcern

#page_param

Methods included from ApplicationAnnouncementsConcern

#global_announcements, #unread_global_announcements

Methods included from ApplicationInstanceUserConcern

#current_instance_user

Methods included from ApplicationUserTimeZoneConcern

#set_time_zone

Methods included from ApplicationUserConcern

#handle_access_denied, #publicly_accessible?

Methods included from ApplicationComponentsConcern

#handle_component_not_found

Instance Method Details

#createObject


14
15
16
17
18
19
20
# File 'app/controllers/course/survey/surveys_controller.rb', line 14

def create
  if @survey.save
    render partial: 'survey', locals: { survey: @survey }
  else
    render json: { errors: @survey.errors }, status: :bad_request
  end
end

#destroyObject


37
38
39
40
41
42
43
# File 'app/controllers/course/survey/surveys_controller.rb', line 37

def destroy
  if @survey.destroy
    head :ok
  else
    head :bad_request
  end
end

#indexObject


5
6
7
8
9
10
11
12
# File 'app/controllers/course/survey/surveys_controller.rb', line 5

def index
  respond_to do |format|
    format.html
    format.json do
      @surveys = @surveys.includes(responses: { experience_points_record: :course_user })
    end
  end
end

#remindObject


52
53
54
55
56
# File 'app/controllers/course/survey/surveys_controller.rb', line 52

def remind
  authorize!(:manage, @survey)
  Course::Survey::ReminderService.send_closing_reminder(@survey)
  head :ok
end

#resultsObject


45
46
47
48
49
50
# File 'app/controllers/course/survey/surveys_controller.rb', line 45

def results
  respond_to do |format|
    format.html { render 'index' }
    format.json { preload_questions_results }
  end
end

#showObject


22
23
24
25
26
27
# File 'app/controllers/course/survey/surveys_controller.rb', line 22

def show
  respond_to do |format|
    format.html { render 'index' }
    format.json { render_survey_with_questions_json }
  end
end

#updateObject


29
30
31
32
33
34
35
# File 'app/controllers/course/survey/surveys_controller.rb', line 29

def update
  if @survey.update_attributes(survey_params)
    render_survey_with_questions_json
  else
    render json: { errors: @survey.errors }, status: :bad_request
  end
end