Class: Exams::ExamPortionsController

Inherits:
GakuController
  • Object
show all
Defined in:
app/controllers/gaku/exams/exam_portions_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



20
21
22
23
24
# File 'app/controllers/gaku/exams/exam_portions_controller.rb', line 20

def create
  @exam_portion = @exam.exam_portions.create(exam_portion_params)
  set_count
  respond_with @exam_portion
end

#destroyObject



41
42
43
44
45
46
47
48
49
50
# File 'app/controllers/gaku/exams/exam_portions_controller.rb', line 41

def destroy
  @exam_portion.destroy
  # if @exam.exam_portions.empty?
  #   if @exam.destroy!
  #     flash[:notice] = t(:'notice.destroyed', resource: t(:'exam.singular'))
  #   end
  # end
  set_count
  respond_with @exam_portion
end

#editObject



30
31
32
# File 'app/controllers/gaku/exams/exam_portions_controller.rb', line 30

def edit
  respond_with @exam_portion
end

#indexObject



12
13
# File 'app/controllers/gaku/exams/exam_portions_controller.rb', line 12

def index
end

#newObject



15
16
17
18
# File 'app/controllers/gaku/exams/exam_portions_controller.rb', line 15

def new
  @exam_portion = ExamPortion.new
  respond_with @exam_portion
end

#showObject



26
27
28
# File 'app/controllers/gaku/exams/exam_portions_controller.rb', line 26

def show
  respond_with @exam_portion
end

#sortObject



52
53
54
55
56
57
# File 'app/controllers/gaku/exams/exam_portions_controller.rb', line 52

def sort
  params[:'exam-portion'].each_with_index do |id, index|
    @exam.exam_portions.update_all({ position: index }, { id: id })
  end
  render nothing: true
end

#updateObject



34
35
36
37
38
39
# File 'app/controllers/gaku/exams/exam_portions_controller.rb', line 34

def update
  @exam_portion.update(exam_portion_params)
  #if params doesnt exist that mean options are removed
  @exam_portion.update_attribute(:score_selection_options, nil) unless score_selection_options?
  respond_with @exam_portion
end