Class: Course::Assessment::Question::TextResponsesController

Inherits:
Controller show all
Defined in:
app/controllers/course/assessment/question/text_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


20
21
22
23
24
25
26
27
# File 'app/controllers/course/assessment/question/text_responses_controller.rb', line 20

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

#destroyObject


44
45
46
47
48
49
50
51
52
53
54
# File 'app/controllers/course/assessment/question/text_responses_controller.rb', line 44

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

#editObject


29
30
31
32
# File 'app/controllers/course/assessment/question/text_responses_controller.rb', line 29

def edit
  @question_assessment = load_question_assessment_for(@text_response_question)
  @text_response_question.build_at_least_one_group_one_point if @text_response_question.comprehension_question?
end

#newObject


9
10
11
12
13
14
15
16
17
18
# File 'app/controllers/course/assessment/question/text_responses_controller.rb', line 9

def new
  if params[:file_upload] == 'true'
    @text_response_question.hide_text = true
    @text_response_question.allow_attachment = true
  end
  if params[:comprehension] == 'true'
    @text_response_question.is_comprehension = true
    @text_response_question.build_at_least_one_group_one_point
  end
end

#updateObject


34
35
36
37
38
39
40
41
42
# File 'app/controllers/course/assessment/question/text_responses_controller.rb', line 34

def update
  if @text_response_question.update_attributes(text_response_question_params)
    redirect_to course_assessment_path(current_course, @assessment),
                success: t('.success', name: question_type)
  else
    @question_assessment = load_question_assessment_for(@text_response_question)
    render 'edit'
  end
end