作业标签状态有显示空白的

This commit is contained in:
cxt 2017-05-24 17:17:00 +08:00
parent 542eebd810
commit 4aa6c830b2
4 changed files with 56 additions and 52 deletions

View File

@ -30,13 +30,13 @@ class HomeworkCommonController < ApplicationController
if @order.blank?
@homework_commons = @course.homework_commons.where("name like '%#{@search}%'").order("created_at desc")
else
@homework_commons = HomeworkCommon.find_by_sql("SELECT * FROM `homework_commons` hc, `homework_detail_manuals` hdm where hdm.homework_common_id = hc.id and hc.course_id=#{@course.id} and hc.name like '%#{@search}%' and hdm.comment_status='#{@order}';")
@homework_commons = @course.homework_commons.includes(:homework_detail_manual).where("name like '%#{@search}%' and homework_detail_manuals.comment_status = #{@order}")
end
else
if @order.blank?
@homework_commons = @course.homework_commons.where("name like '%#{@search}%' and publish_time <= '#{Time.now}'").order("created_at desc")
else
@homework_commons = HomeworkCommon.find_by_sql("SELECT * FROM `homework_commons` hc, `homework_detail_manuals` hdm where hdm.homework_common_id = hc.id and hc.course_id=#{@course.id} and hc.name like '%#{@search}%' and hc.publish_time <= #{Time.now} and hdm.comment_status='#{@order}';")
@homework_commons = @course.homework_commons.includes(:homework_detail_manual).where("name like '%#{@search}%' and publish_time <= '#{Time.now}' and homework_detail_manuals.comment_status = #{@order}")
end
end
@is_student = User.current.logged? && (User.current.admin? || (User.current.member_of_course?(@course) && !@is_teacher))

View File

@ -328,58 +328,60 @@ module ApplicationHelper
status = ""
time = ""
ho_detail_manual = homework_common.homework_detail_manual
case ho_detail_manual.comment_status
when 0
status = "挂起"
if homework_common.publish_time && homework_common.publish_time > Time.now
time = time_from_future(homework_common.publish_time).to_s + "后发布"
end
when 1
status = "提交中"
if homework_common.end_time && homework_common.end_time > Time.now
time = time_from_future(homework_common.end_time).to_s + "后结束"
elsif !homework_common.allow_late && homework_common.anonymous_comment == 0
if ho_detail_manual.evaluation_start && ho_detail_manual.evaluation_start >= Time.now
status = "匿评中"
time = time_from_future(ho_detail_manual.evaluation_start).to_s + "后开始"
if ho_detail_manual
case ho_detail_manual.comment_status
when 0
status = "挂起"
if homework_common.publish_time && homework_common.publish_time > Time.now
time = time_from_future(homework_common.publish_time).to_s + "后发布"
end
elsif !homework_common.allow_late && homework_common.anonymous_comment == 1
if homework_common.archive_time && homework_common.archive_time >= Time.now
status = "评阅中"
when 1
status = "提交中"
if homework_common.end_time && homework_common.end_time > Time.now
time = time_from_future(homework_common.end_time).to_s + "后结束"
elsif !homework_common.allow_late && homework_common.anonymous_comment == 0
if ho_detail_manual.evaluation_start && ho_detail_manual.evaluation_start >= Time.now
status = "匿评中"
time = time_from_future(ho_detail_manual.evaluation_start).to_s + "后开始"
end
elsif !homework_common.allow_late && homework_common.anonymous_comment == 1
if homework_common.archive_time && homework_common.archive_time >= Time.now
status = "评阅中"
time = time_from_future(homework_common.archive_time).to_s + "后结束"
end
end
when 2
status = "补交中"
if homework_common.late_time && homework_common.late_time >= Time.now
time = time_from_future(homework_common.late_time).to_s + "后结束"
elsif homework_common.anonymous_comment == 0
if ho_detail_manual.evaluation_start && ho_detail_manual.evaluation_start >= Time.now
status = "匿评中"
time = time_from_future(ho_detail_manual.evaluation_start).to_s + "后开始"
end
end
when 3
status = "匿评中"
if ho_detail_manual.evaluation_end && ho_detail_manual.evaluation_end > Time.now
time = time_from_future(ho_detail_manual.evaluation_end).to_s + "后结束"
elsif homework_common.anonymous_appeal && ho_detail_manual.appeal_time && ho_detail_manual.appeal_time >= Time.now
status = "申诉"
time = time_from_future(ho_detail_manual.appeal_time).to_s + "后开始"
end
when 4
status = "申诉中"
if ho_detail_manual.appeal_time && ho_detail_manual.appeal_time > Time.now
time = time_from_future(ho_detail_manual.appeal_time).to_s + "后结束"
end
when 5
status = "评阅中"
if homework_common.archive_time && homework_common.archive_time > Time.now
time = time_from_future(homework_common.archive_time).to_s + "后结束"
end
end
when 2
status = "补交中"
if homework_common.late_time && homework_common.late_time >= Time.now
time = time_from_future(homework_common.late_time).to_s + "后结束"
elsif homework_common.anonymous_comment == 0
if ho_detail_manual.evaluation_start && ho_detail_manual.evaluation_start >= Time.now
status = "匿评中"
time = time_from_future(ho_detail_manual.evaluation_start).to_s + "后开始"
end
end
when 3
status = "匿评中"
if ho_detail_manual.evaluation_end && ho_detail_manual.evaluation_end > Time.now
time = time_from_future(ho_detail_manual.evaluation_end).to_s + "后结束"
elsif homework_common.anonymous_appeal && ho_detail_manual.appeal_time && ho_detail_manual.appeal_time >= Time.now
status = "申诉"
time = time_from_future(ho_detail_manual.appeal_time).to_s + "后开始"
end
when 4
status = "申诉中"
if ho_detail_manual.appeal_time && ho_detail_manual.appeal_time > Time.now
time = time_from_future(ho_detail_manual.appeal_time).to_s + "后结束"
end
when 5
status = "评阅中"
if homework_common.archive_time && homework_common.archive_time > Time.now
time = time_from_future(homework_common.archive_time).to_s + "后结束"
end
when 6
status = "已结束"
time = format_time homework_common.archive_time
when 6
status = "已结束"
time = format_time homework_common.archive_time
end
end
result[:status] = status
result[:time] = time

View File

@ -7,7 +7,7 @@
<span class="edu-filter-btn <%= homework_status_color homework_curr_status[:status] %> ml10 fl mt3"><%= homework_curr_status[:status] %></span>
<div class="cl"></div>
<p class="color-grey font-12">
<span class=""># <%= index + 1 %></span>
<span class=""># <%= get_hw_index(homework_common, @is_teacher) %></span>
<span class="ml30">创建于<%=time_from_now homework_common.created_at %></span>
<span class="ml30"><%=homework_common.homework_type_ch %></span>
<% if [1,2,3,4,5,6].include?(homework_common.homework_detail_manual.try(:comment_status)) %>

View File

@ -1,5 +1,7 @@
<a href="<%= homework_common_index_path(:course => @course.id) %>" class="<%= @order.nil? ? "active" : "" %> edu-filter-cir-grey mr5 " data-remote="true">全部</a>
<% if @is_teacher %>
<a href="<%= homework_common_index_path(:course => @course.id, :order => 0, :search => @search) %>" class="<%= @order == "0" ? "active" : "" %> edu-filter-cir-grey mr5" data-remote="true">挂起</a>
<% end %>
<a href="<%= homework_common_index_path(:course => @course.id, :order => 1, :search => @search) %>" class="<%= @order == "1" ? "active" : "" %> edu-filter-cir-grey mr5" data-remote="true">提交中</a>
<a href="<%= homework_common_index_path(:course => @course.id, :order => 2, :search => @search) %>" class="<%= @order == "2" ? "active" : "" %> edu-filter-cir-grey mr5" data-remote="true">补交中</a>
<a href="<%= homework_common_index_path(:course => @course.id, :order => 3, :search => @search) %>" class="<%= @order == "3" ? "active" : "" %> edu-filter-cir-grey mr5" data-remote="true">匿评中</a>