From 2c7f9f9f77106ca40da3ac59f84d17a3a307c287 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Sat, 22 Jun 2019 10:21:21 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AD=A6=E7=94=9F=E8=BA=AB=E4=BB=BD=E8=AE=BF?= =?UTF-8?q?=E9=97=AE=E6=AF=95=E8=AE=BE=E4=BD=9C=E5=93=81=E5=88=97=E8=A1=A8?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/helpers/graduation_tasks_helper.rb | 16 ++++++++++++++++ app/models/graduation_task.rb | 2 ++ app/views/graduation_tasks/index.json.jbuilder | 7 ++++--- .../graduation_tasks/tasks_list.json.jbuilder | 10 ++++++++-- 4 files changed, 30 insertions(+), 5 deletions(-) diff --git a/app/helpers/graduation_tasks_helper.rb b/app/helpers/graduation_tasks_helper.rb index a5f05d623..b9039544d 100644 --- a/app/helpers/graduation_tasks_helper.rb +++ b/app/helpers/graduation_tasks_helper.rb @@ -131,4 +131,20 @@ module GraduationTasksHelper end end end + + # 阶段剩余时间 + def task_left_time task + if task.publish_time && task.publish_time < Time.now + if task.end_time > Time.now + status = "剩余提交时间" + time = "#{how_much_time(task.end_time)}" + else + if task.allow_late && task.late_time && task.late_time >= Time.now + status = "剩余补交时间" + time = "#{how_much_time(task.late_time)}" + end + end + end + {status: status, time: time} + end end diff --git a/app/models/graduation_task.rb b/app/models/graduation_task.rb index 8d89da693..d85f9782d 100644 --- a/app/models/graduation_task.rb +++ b/app/models/graduation_task.rb @@ -168,6 +168,8 @@ class GraduationTask < ApplicationRecord end end + + # 是否具有分组 def have_grouping? self.task_type == 2 diff --git a/app/views/graduation_tasks/index.json.jbuilder b/app/views/graduation_tasks/index.json.jbuilder index 80780b209..7fcececd9 100644 --- a/app/views/graduation_tasks/index.json.jbuilder +++ b/app/views/graduation_tasks/index.json.jbuilder @@ -12,10 +12,11 @@ json.tasks @tasks.each do |task| json.name task.name json.private_icon !task.is_public json.task_status task.status #6.12 -hs - json.status task_curr_status(task, @course)[:status] - json.status_time task_curr_status(task, @course)[:time] + task_curr_status = task_curr_status(task, @course) + json.status task_curr_status[:status] + json.status_time task_curr_status[:time] - unless task_curr_status(task, @course)[:status].include?("未发布") + unless task_curr_status[:status].include?("未发布") json.commit_count grduationwork_count task, 1 json.uncommit_count grduationwork_count task, 0 end diff --git a/app/views/graduation_tasks/tasks_list.json.jbuilder b/app/views/graduation_tasks/tasks_list.json.jbuilder index 5868be4fb..a0cffc41b 100644 --- a/app/views/graduation_tasks/tasks_list.json.jbuilder +++ b/app/views/graduation_tasks/tasks_list.json.jbuilder @@ -26,8 +26,14 @@ if @task.published? || @user_course_identity < Course::STUDENT # 是否具有分组 json.have_grouping @task.have_grouping? - json.work_count @work_count - json.all_work_count @all_work_count + if @user_course_identity == Course::STUDENT + json.commit_count grduationwork_count @task, 1 + json.uncommit_count grduationwork_count @task, 0 + json.left_time task_left_time @task + else + json.work_count @work_count + json.all_work_count @all_work_count + end # 学生数据 json.work_lists do json.array! @work_list do |work|