Class: Exams::ExamPortionsController
- Inherits:
-
GakuController
- Object
- GakuController
- Exams::ExamPortionsController
- Defined in:
- app/controllers/gaku/exams/exam_portions_controller.rb
Instance Method Summary collapse
- #create ⇒ Object
- #destroy ⇒ Object
- #edit ⇒ Object
- #index ⇒ Object
- #new ⇒ Object
- #show ⇒ Object
- #sort ⇒ Object
- #update ⇒ Object
Instance Method Details
#create ⇒ Object
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 |
#destroy ⇒ Object
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 |
#edit ⇒ Object
30 31 32 |
# File 'app/controllers/gaku/exams/exam_portions_controller.rb', line 30 def edit respond_with @exam_portion end |
#index ⇒ Object
12 13 |
# File 'app/controllers/gaku/exams/exam_portions_controller.rb', line 12 def index end |
#new ⇒ Object
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 |
#show ⇒ Object
26 27 28 |
# File 'app/controllers/gaku/exams/exam_portions_controller.rb', line 26 def show respond_with @exam_portion end |
#sort ⇒ Object
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 |
#update ⇒ Object
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 respond_with @exam_portion end |