实训作业移动到目录的接口调整

dev_new_shixunsrepository
cxt 5 years ago
parent be1a05adf4
commit c4c2927f87

@ -1117,7 +1117,7 @@ class HomeworkCommonsController < ApplicationController
def choose_category
@main_catrgory = @course.course_modules.where(module_type: "shixun_homework")
@homework_category = @main_catrgory.take.course_second_categories
@homework_category = @main_catrgory.take.course_second_categories.includes(:homework_commons)
end
# 实训作业移动到目录

@ -12,4 +12,13 @@ class CourseSecondCategory < ApplicationRecord
category_type == "graduation" && name == "毕设任务" ? "graduation_tasks" : category_type
)
end
def homework_publish_count
homework_commons.select{|homework| homework.publish_time.present? && homework.publish_time <= Time.now}.size
end
def homework_unpublish_count
homework_commons.select{|homework| homework.publish_time.nil? || homework.publish_time > Time.now}.size
end
end

@ -5,4 +5,7 @@ end
json.homework_category homework_category do |category|
json.category_id category.id
json.category_name category.name
json.publish_count category.homework_publish_count
json.unpublish_count category.homework_unpublish_count
json.all_count category.homework_commons.size
end
Loading…
Cancel
Save