Class: Course::Assessment::Question::ScribingController

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

rubocop:disable Metrics/MethodLength


22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'app/controllers/course/assessment/question/scribing_controller.rb', line 22

def create # rubocop:disable Metrics/MethodLength
  if file_is_pdf?
    respond_to do |format|
      if pdf_import_service.save
        format.json { render_success_json t('.success') }
      else
        format.json { render_failure_json t('.failure') }
      end
    end
  else
    respond_to do |format|
      if @scribing_question.save
        format.json { render_scribing_question_json }
      else
        format.json { render_failure_json t('.failure') }
      end
    end
  end
end

#destroyObject


63
64
65
66
67
68
69
70
71
# File 'app/controllers/course/assessment/question/scribing_controller.rb', line 63

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

#editObject


42
43
44
45
46
47
48
49
# File 'app/controllers/course/assessment/question/scribing_controller.rb', line 42

def edit
  @question_assessment = load_question_assessment_for(@scribing_question)

  respond_to do |format|
    format.html { render 'edit' }
    format.json { render_scribing_question_json }
  end
end

#newObject


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

def new
  respond_to do |format|
    format.html { render 'new' }
    format.json { render_scribing_question_json }
  end
end

#showObject


16
17
18
19
20
# File 'app/controllers/course/assessment/question/scribing_controller.rb', line 16

def show
  respond_to do |format|
    format.json { render_scribing_question_json }
  end
end

#updateObject

Update does not allow replacement of the attachment/file for the question. TODO: To define and clarify behaviour for this controller action.


53
54
55
56
57
58
59
60
61
# File 'app/controllers/course/assessment/question/scribing_controller.rb', line 53

def update
  respond_to do |format|
    if @scribing_question.update(scribing_question_params)
      format.json { render_scribing_question_json }
    else
      format.json { render_failure_json t('.failure') }
    end
  end
end