You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
educoder/app/views/homework_commons/index.json.jbuilder

52 lines
2.1 KiB

6 years ago
json.course_identity @user_course_identity
json.homework_type @homework_type
json.course_public @course.is_public == 1
json.is_end @course.is_end
json.main_category_id @main_category.try(:id)
json.main_category_name @main_category.try(:module_name)
json.category_id @category.try(:id)
json.category_name @category.try(:name)
json.homeworks @homework_commons.each do |homework|
# homework_private = (@user_course_identity > Course::STUDENT) && !homework.is_public
6 years ago
curr_status = homework_curr_status(homework, @user_course_identity, @course, @member, @member&.teacher_course_groups)
6 years ago
json.homework_id homework.id
json.name homework.name
json.private_icon !homework.is_public
6 years ago
json.status curr_status[:status]
json.status_time curr_status[:time]
json.time_status curr_status[:time_status]
6 years ago
json.allow_late homework.allow_late
6 years ago
unless curr_status[:status].include?("未发布")
json.commit_count studentwork_count homework, 1, @member
json.uncommit_count studentwork_count homework, 0, @member
6 years ago
end
if @user_course_identity < Course::STUDENT
if homework.homework_type == "practice"
5 years ago
json.shixun_identifier homework.shixuns.take.try(:identifier)
6 years ago
end
elsif @user_course_identity == Course::STUDENT
if homework.homework_type == "practice"
5 years ago
shixun = homework.shixuns.take
6 years ago
# json.challenge_count homework.shixuns.first.try(:challenges_count).to_i
current_myshixun = homework.user_work(@user.id).try(:myshixun)
5 years ago
myshixun = current_myshixun ? current_myshixun : shixun.myshixuns.find_by(user_id: @user.id)
6 years ago
# json.game_count current_myshixun ? current_myshixun.exec_count : 0
5 years ago
json.task_operation task_operation_url(myshixun, shixun)
6 years ago
else
work = homework.user_work(@user.id)
json.work_id work.try(:id)
json.work_status student_work_status(homework, @user.id, @course, work)
json.un_commit_work !work.present? || work.work_status == 0
end
end
end
json.all_count @all_count
json.published_count @published_count
json.unpublished_count @all_count - @published_count
json.task_count @task_count