ecs: modify api

dev_ec
p31729568 5 years ago
parent d97ced4140
commit 2eb3259cb7

@ -20,8 +20,8 @@ class Ecs::CourseTargetsController < Ecs::CourseBaseController
def with_achievement_methods
@course_targets = current_course.ec_course_targets
.includes(:ec_graduation_subitems,
ec_course_achievement_methods: [:ec_course_evaluation, :ec_course_evaluation_subitems])
.includes(ec_course_achievement_methods:
[:ec_course_evaluation, ec_achievement_evaluation_relates: :ec_course_evaluation_subitem])
end
private

@ -1,2 +1,32 @@
json.course_targets @course_targets,
partial: 'ecs/course_targets/shared/ec_course_target_with_achievement_methods',
as: :ec_course_target
json.course_targets do
json.array! @course_targets do |course_target|
json.extract! course_target, :id, :position, :content
json.course_targets @course_targets, partial: 'ecs/course_targets/shared/ec_course_target_with_achievement_methods', as: :ec_course_target
json.course_achievement_methods do
json.array! course_target.ec_course_achievement_methods do |achievement_method|
evaluation = achievement_method.ec_course_evaluation
json.extract! achievement_method, :id, :score, :percentage
json.course_evaluation do
json.partial! 'ecs/course_evaluations/shared/ec_course_evaluation_only', ec_course_evaluation: evaluation
end
json.course_evaluation_relates do
json.array! achievement_method.ec_achievement_evaluation_relates do |relate|
json.extract! relate, :id, :position, :ec_course_evaluation_subitem_id
subitem = relate.ec_course_evaluation_subitem
if evaluation.is_course_type?
json.name subitem&.name
else
json.name subitem&.name ? "#{evaluation.name}#{relate.position}:#{subitem&.name}" : "#{evaluation.name}#{relate.position}"
end
end
end
end
end
end
end
Loading…
Cancel
Save