class Ecs::CourseAchievementMethodsController < Ecs::CourseBaseController
  def show
    include_associations = { ec_course_achievement_methods: [:ec_course_evaluation, :ec_course_evaluation_subitems] }
    @course_targets = current_course.ec_course_targets.includes(include_associations)
  end

  def create
    @course_target = Ecs::CreateCourseAchievementMethodsService.call(current_course_target, create_params)
  end

  private

  def create_params
    params.permit(course_achievement_methods: %i[id course_evaluation_id course_evaluation_subitem_ids score percentage])
  end

  def current_course_target
    @_current_course_target ||= current_course.ec_course_targets.find(params[:course_target_id])
  end
end