Class: Course::Assessment::Question::MultipleResponsesController

Inherits:
Controller show all
Defined in:
app/controllers/course/assessment/question/multiple_responses_controller.rb

Instance Method Summary collapse

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
21
# File 'app/controllers/course/assessment/question/multiple_responses_controller.rb', line 14

def create
  if @multiple_response_question.save
    redirect_to course_assessment_path(current_course, @assessment),
                success: t('.success')
  else
    render 'new'
  end
end

#destroyObject


36
37
38
39
40
41
42
43
44
45
# File 'app/controllers/course/assessment/question/multiple_responses_controller.rb', line 36

def destroy
  if @multiple_response_question.destroy
    redirect_to course_assessment_path(current_course, @assessment),
                success: t('.success')
  else
    error = @multiple_response_question.errors.full_messages.to_sentence
    redirect_to course_assessment_path(current_course, @assessment),
                danger: t('.failure', error: error)
  end
end

#editObject


23
24
25
# File 'app/controllers/course/assessment/question/multiple_responses_controller.rb', line 23

def edit
  @question_assessment = load_question_assessment_for(@multiple_response_question)
end

#newObject


9
10
11
12
# File 'app/controllers/course/assessment/question/multiple_responses_controller.rb', line 9

def new
  @multiple_response_question.grading_scheme = :any_correct if params[:multiple_choice] == 'true'
  @multiple_response_question.options.build(weight: 1) if @multiple_response_question.options.empty?
end

#updateObject


27
28
29
30
31
32
33
34
# File 'app/controllers/course/assessment/question/multiple_responses_controller.rb', line 27

def update
  if @multiple_response_question.update_attributes(multiple_response_question_params)
    redirect_to course_assessment_path(current_course, @assessment),
                success: t('.success')
  else
    render 'edit'
  end
end