Class: Course::Admin::Assessments::CategoriesController

Inherits:
Controller
  • Object
show all
Defined in:
app/controllers/course/admin/assessments/categories_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject


12
13
14
15
16
17
18
19
# File 'app/controllers/course/admin/assessments/categories_controller.rb', line 12

def create
  if @category.save
    redirect_to course_admin_assessments_path(current_course),
                success: t('.success', title: @category.title)
  else
    render 'new'
  end
end

#destroyObject


21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'app/controllers/course/admin/assessments/categories_controller.rb', line 21

def destroy
  tab_ids = @category.tabs.map(&:id)
  if @category.destroy
    tab_ids.each do |tab_id|
      Course::Settings::AssessmentsComponent.delete_lesson_plan_item_setting(current_course,
                                                                             tab_id)
    end
    redirect_to course_admin_assessments_path(current_course),
                success: t('.success', title: @category.title)
  else
    redirect_to course_admin_assessments_path(current_course),
                danger: t('.failure', error: @category.errors.full_messages.to_sentence)
  end
end

#newObject


9
10
# File 'app/controllers/course/admin/assessments/categories_controller.rb', line 9

def new
end