优化作业列表和作品列表

dev_ec
cxt 6 years ago
parent cb03317076
commit d69fd728a3

@ -586,9 +586,9 @@ class StudentWorkController < ApplicationController
if @stundet_works.size != 0 if @stundet_works.size != 0
if @order == "student_id" if @order == "student_id"
@stundet_works = @stundet_works.includes(:user => {:user_extensions => []}, :project => {}, :student_works_scores => {}).order("user_extensions.student_id #{@b_sort}") @stundet_works = @stundet_works.includes(:user => {:user_extensions => []}).order("user_extensions.student_id #{@b_sort}")
else else
@stundet_works = @stundet_works.includes(:user => {:user_extensions => []}, :project => {}, :student_works_scores => {}).order("#{@order} #{@b_sort}") @stundet_works = @stundet_works.order("#{@order} #{@b_sort}")
end end
end end
@ -609,6 +609,14 @@ class StudentWorkController < ApplicationController
@student_work_pages = Paginator.new @student_work_count, @limit, @page @student_work_pages = Paginator.new @student_work_count, @limit, @page
@offset ||= @student_work_pages.offset @offset ||= @student_work_pages.offset
@stundet_works = paginateHelper @stundet_works, @limit @stundet_works = paginateHelper @stundet_works, @limit
@stundet_works = if @homework.homework_type == 1
@stundet_works.includes(:student_works_scores, [user: :user_extensions])
elsif @homework.homework_type == 3
@stundet_works.includes(:student_works_scores, [project: :project_score], [user: :user_extensions])
elsif @homework.homework_type == 4
@stundet_works.includes(:student_works_scores, [myshixun: :games], [user: :user_extensions])
end
@members = @course.members.where(user_id: @stundet_works.pluck(:user_id)).select([:user_id, :course_group_id])
respond_to do |format| respond_to do |format|
format.js format.js
format.html { render :layout => 'base_edu'} format.html { render :layout => 'base_edu'}

@ -191,7 +191,7 @@ module ApplicationHelper
# 分班 # 分班
def member_group_name members, user_id def member_group_name members, user_id
member = members.where(:user_id => user_id).first member = members.find_by_user_id(user_id)
group_name = member.try(:course_group_id).to_i == 0 ? '未分班' : member.course_group.name group_name = member.try(:course_group_id).to_i == 0 ? '未分班' : member.course_group.name
end end
@ -269,12 +269,12 @@ module ApplicationHelper
end end
# 实训作品列表的提交状态 # 实训作品列表的提交状态
def list_work_status work, homework, member def list_work_status work, homework, course_group_id
if work.work_status == 0 if work.work_status == 0
str = "未提交" str = "未提交"
else else
if work.compelete_status == 0 if work.compelete_status == 0
setting_time = homework_group_setting homework, member.try(:course_group_id) setting_time = homework_group_setting homework, course_group_id
end_time = setting_time.end_time.present? ? setting_time.end_time : homework.end_time end_time = setting_time.end_time.present? ? setting_time.end_time : homework.end_time
if end_time > Time.now || (homework.allow_late && !homework.course.is_end) if end_time > Time.now || (homework.allow_late && !homework.course.is_end)
str = "正在提交" str = "正在提交"
@ -6568,7 +6568,7 @@ def update_shixun_work_status homework
else else
setting = homework.homework_group_settings.where("publish_time < '#{Time.now}'") setting = homework.homework_group_settings.where("publish_time < '#{Time.now}'")
if setting.blank? if setting.blank?
student_works = student_works.where("0=1") student_works = student_works.none
else else
users = homework.course.members.where(:course_group_id => setting.map(&:course_group_id)) users = homework.course.members.where(:course_group_id => setting.map(&:course_group_id))
student_works = student_works.where(:user_id => users.map(&:user_id)) student_works = student_works.where(:user_id => users.map(&:user_id))
@ -6578,7 +6578,7 @@ def update_shixun_work_status homework
myshixuns = Myshixun.where(:shixun_id => shixun.id, :user_id => student_works.map(&:user_id)) myshixuns = Myshixun.where(:shixun_id => shixun.id, :user_id => student_works.map(&:user_id))
myshixuns.each do |myshixun| myshixuns.each do |myshixun|
work = student_works.where(:user_id => myshixun.user_id).first work = student_works.where(:user_id => myshixun.user_id).first
member = Member.find_by_sql("select course_group_id from members where course_id = #{homework.course_id} and user_id = #{work.user_id}").first member = homework.course.members.find_by(:user_id => work.user_id)
setting_time = homework_group_setting homework, member.try(:course_group_id) setting_time = homework_group_setting homework, member.try(:course_group_id)
games = myshixun.games.where(:challenge_id => challeng_ids) games = myshixun.games.where(:challenge_id => challeng_ids)
myshixun_endtime = games.select{|game| game.status == 2}.size == games.size ? games.map(&:end_time).max : nil myshixun_endtime = games.select{|game| game.status == 2}.size == games.size ? games.map(&:end_time).max : nil
@ -7220,8 +7220,8 @@ def search_work_member works,name
select_works = works select_works = works
else else
name = name.downcase name = name.downcase
select_works = works.select{ |work| work.user.user_extensions[:student_id].to_s.downcase.include?(name) || (work.user[:lastname].to_s.downcase + work.user[:firstname].to_s.downcase).include?(name) select_works = works.joins(user: :user_extensions).where("concat(lastname, firstname) like ?
} or student_id like ?", "%#{name}%", "%#{name}%")
end end
select_works select_works
end end

@ -28,7 +28,8 @@
<td> <td>
<a href="/users/<%= (student_work.user.try(:login)) %>" class="color-grey3"><%= student_work.user.show_real_name %></a> <a href="/users/<%= (student_work.user.try(:login)) %>" class="color-grey3"><%= student_work.user.show_real_name %></a>
</td> </td>
<% group_name = new_member_group_name @course.id, student_work.user_id %> <% group_id = @members.select{|m|m.user_id==student_work.user_id}.first.try(:course_group_id) %>
<% group_name = group_id.to_i == 0 ? '未分班' : @course.course_groups.find_by_id(group_id).name %>
<td title="<%= group_name %>"> <td title="<%= group_name %>">
<span class="task-hide" style="display: block;max-width: 120px;"><%= group_name %></span> <span class="task-hide" style="display: block;max-width: 120px;"><%= group_name %></span>
</td> </td>

@ -33,7 +33,8 @@
<td> <td>
<a href="/users/<%= (student_work.user.try(:login)) %>" class="color-grey3"><%= student_work.user.show_real_name %></a> <a href="/users/<%= (student_work.user.try(:login)) %>" class="color-grey3"><%= student_work.user.show_real_name %></a>
</td> </td>
<% group_name = member_group_name @homework.course.members, student_work.user_id %> <% group_id = @members.select{|m|m.user_id==student_work.user_id}.first.try(:course_group_id) %>
<% group_name = group_id.to_i == 0 ? '未分班' : @course.course_groups.find_by_id(group_id).name %>
<td title="<%= group_name %>"> <td title="<%= group_name %>">
<span class="task-hide" style="display: block;max-width: 120px;"><%= group_name %></span> <span class="task-hide" style="display: block;max-width: 120px;"><%= group_name %></span>
</td> </td>

@ -25,8 +25,8 @@
<td> <td>
<a href="/users/<%= (student_work.user.try(:login)) %>" class="color-grey3"><%= student_work.user.show_real_name %></a> <a href="/users/<%= (student_work.user.try(:login)) %>" class="color-grey3"><%= student_work.user.show_real_name %></a>
</td> </td>
<% member = Member.find_by_sql("select course_group_id from members where course_id = #{@homework.course_id} and user_id = #{student_work.user_id}").first %> <% group_id = @members.select{|m|m.user_id==student_work.user_id}.first.try(:course_group_id) %>
<% group_name = member.try(:course_group_id).to_i == 0 ? '未分班' : member.course_group.name %> <% group_name = group_id.to_i == 0 ? '未分班' : @course.course_groups.find_by_id(group_id).name %>
<td title="<%= group_name %>"> <td title="<%= group_name %>">
<span class="task-hide"><%= group_name %></span> <span class="task-hide"><%= group_name %></span>
</td> </td>
@ -35,7 +35,7 @@
<%= student_id %> <%= student_id %>
</td> </td>
<td> <td>
<% status = list_work_status student_work, @homework, member %> <% status = list_work_status student_work, @homework, group_id %>
<span class='<%= status == "未提交" ? "" : ((status == "按时提交" || status == "正在提交") ? "color-light-green" : "color-red") %>'><%= status %></span> <span class='<%= status == "未提交" ? "" : ((status == "按时提交" || status == "正在提交") ? "color-light-green" : "color-red") %>'><%= status %></span>
</td> </td>
<td data-tip-down='<%= student_work.compelete_status == 0 ? "还未完成" : (student_work.compelete_status == 2 ? "已于发布前完成作品" : "自发布#{work_spend_time(student_work.cost_time)}后提交了最终作品") %>'> <td data-tip-down='<%= student_work.compelete_status == 0 ? "还未完成" : (student_work.compelete_status == 2 ? "已于发布前完成作品" : "自发布#{work_spend_time(student_work.cost_time)}后提交了最终作品") %>'>

@ -71,7 +71,7 @@
<a href="javascript:void(0);" class="tab_type">参考答案</a> <a href="javascript:void(0);" class="tab_type">参考答案</a>
</li> </li>
<% end %> <% end %>
<% if @is_teacher && @homework.homework_type == 4 && @homework.homework_group_reviews.count > 0 %> <% if @is_teacher && @homework.homework_type == 4 && @homework.homework_group_reviews.size > 0 %>
<li id="edu-tab-nav-5" index="5"> <li id="edu-tab-nav-5" index="5">
<a href="javascript:void(0);" class="tab_type"> <a href="javascript:void(0);" class="tab_type">
查重结果 查重结果
@ -100,16 +100,16 @@
<% end %> <% end %>
<%= link_to "导出成绩", student_work_index_path(:homework => @homework.id, :order => @order, :sort => @b_sort, :name => @name, :group => @group, :comment => @comment, :status => @status, :format => 'xls'), :class => 'fr mt3 ml15 white-btn orange-btn', :id => "export_student_work" %> <%= link_to "导出成绩", student_work_index_path(:homework => @homework.id, :order => @order, :sort => @b_sort, :name => @name, :group => @group, :comment => @comment, :status => @status, :format => 'xls'), :class => 'fr mt3 ml15 white-btn orange-btn', :id => "export_student_work" %>
<% if @homework.homework_detail_manual.try(:comment_status) == 0 || @homework.homework_group_settings.where("publish_time is null or publish_time > '#{Time.now}'").count > 0 %> <% if @homework.homework_detail_manual.try(:comment_status) == 0 || @homework.homework_group_settings.where("publish_time is null or publish_time > '#{Time.now}'").size > 0 %>
<%= link_to '立即发布', publish_notice_homework_common_path(@homework), :remote => true, :class => "white-btn orange-btn fr ml15 mt3" %> <%= link_to '立即发布', publish_notice_homework_common_path(@homework), :remote => true, :class => "white-btn orange-btn fr ml15 mt3" %>
<% end %> <% end %>
<% if (@homework.homework_detail_manual.try(:comment_status) == 1 && @homework.end_time > Time.now) || @homework.homework_group_settings.where("publish_time < '#{Time.now}' and end_time > '#{Time.now}'").count > 0 %> <% if (@homework.homework_detail_manual.try(:comment_status) == 1 && @homework.end_time > Time.now) || @homework.homework_group_settings.where("publish_time < '#{Time.now}' and end_time > '#{Time.now}'").size > 0 %>
<%= link_to '立即截止', end_notice_homework_common_path(@homework), :remote => true, :class => "white-btn orange-btn fr ml15 mt3" %> <%= link_to '立即截止', end_notice_homework_common_path(@homework), :remote => true, :class => "white-btn orange-btn fr ml15 mt3" %>
<% end %> <% end %>
<% if @homework.publish_time.present? && @homework.publish_time < Time.now && @homework.end_time > Time.now && (@homework.homework_type == 1 || @homework.homework_type == 3) %> <% if @homework.publish_time.present? && @homework.publish_time < Time.now && @homework.end_time > Time.now && (@homework.homework_type == 1 || @homework.homework_type == 3) %>
<a href="javascript:void(0)" class="white-btn orange-btn fr ml15 mt3" onclick="cancel_publish('<%= cancel_publish_homework_common_path(@homework) %>')">撤销发布</a> <a href="javascript:void(0)" class="white-btn orange-btn fr ml15 mt3" onclick="cancel_publish('<%= cancel_publish_homework_common_path(@homework) %>')">撤销发布</a>
<% end %> <% end %>
<% if @homework.homework_type == 4 && @homework.publish_time.present? && @homework.publish_time < Time.now && @homework.homework_group_reviews.count == 0 %> <% if @homework.homework_type == 4 && @homework.publish_time.present? && @homework.publish_time < Time.now && @homework.homework_group_reviews.size == 0 %>
<a href="<%= homework_code_repeat_homework_common_path(@homework) %>" data-remote="true" class="fr white-btn edu-greenline-btn ml15 mt3">代码查重</a> <a href="<%= homework_code_repeat_homework_common_path(@homework) %>" data-remote="true" class="fr white-btn edu-greenline-btn ml15 mt3">代码查重</a>
<% end %> <% end %>
</div> </div>
@ -185,7 +185,7 @@
<span class="fl mr25"> <span class="fl mr25">
<a href="javascript:void(0);" id="comment_no_limit" class="<%= @comment.blank? ? 'check_on' : '' %> pl10 pr10">不限</a> <a href="javascript:void(0);" id="comment_no_limit" class="<%= @comment.blank? ? 'check_on' : '' %> pl10 pr10">不限</a>
</span> </span>
<% has_comment = StudentWorksScore.where(:student_work_id => student_works.map(&:id), :reviewer_role => [1, 2]).group_by(&:student_work_id).count %> <% has_comment = StudentWorksScore.where(:student_work_id => student_works.map(&:id), :reviewer_role => [1, 2]).group_by(&:student_work_id).size %>
<input id="not_comment" class="magic-checkbox fl" type="checkbox" value="0" name="comment[]" <%= !@comment.blank? && @comment.include?('0') ? 'checked' : '' %>> <input id="not_comment" class="magic-checkbox fl" type="checkbox" value="0" name="comment[]" <%= !@comment.blank? && @comment.include?('0') ? 'checked' : '' %>>
<label for="not_comment" class="fl mr25">未评(<%= @student_work_count - has_comment %>)</label> <label for="not_comment" class="fl mr25">未评(<%= @student_work_count - has_comment %>)</label>
<input id="has_comment" class="magic-checkbox fl" type="checkbox" value="1" name="comment[]" <%= !@comment.blank? && @comment.include?('1') ? 'checked' : '' %>> <input id="has_comment" class="magic-checkbox fl" type="checkbox" value="1" name="comment[]" <%= !@comment.blank? && @comment.include?('1') ? 'checked' : '' %>>
@ -198,11 +198,11 @@
<a href="javascript:void(0);" id="status_no_limit" class="<%= @status.blank? ? 'check_on' : '' %> pl10 pr10">不限</a> <a href="javascript:void(0);" id="status_no_limit" class="<%= @status.blank? ? 'check_on' : '' %> pl10 pr10">不限</a>
</span> </span>
<input id="work_status_1" class="magic-checkbox fl" type="checkbox" value="0" name="status[]" <%= !@status.blank? && @status.include?('0') ? 'checked' : '' %>> <input id="work_status_1" class="magic-checkbox fl" type="checkbox" value="0" name="status[]" <%= !@status.blank? && @status.include?('0') ? 'checked' : '' %>>
<label for="work_status_1" class="fl mr25">未提交(<%= @all_student_works.where(:work_status => 0).count %>)</label> <label for="work_status_1" class="fl mr25">未提交(<%= @all_student_works.where(:work_status => 0).size %>)</label>
<input id="work_status_2" class="magic-checkbox fl" type="checkbox" value="1" name="status[]" <%= !@status.blank? && @status.include?('1') ? 'checked' : '' %>> <input id="work_status_2" class="magic-checkbox fl" type="checkbox" value="1" name="status[]" <%= !@status.blank? && @status.include?('1') ? 'checked' : '' %>>
<label for="work_status_2" class="fl mr25">按时提交(<%= student_works.where(:work_status => 1).count %>)</label> <label for="work_status_2" class="fl mr25">按时提交(<%= student_works.where(:work_status => 1).size %>)</label>
<input id="work_status_3" class="magic-checkbox fl" type="checkbox" value="2" name="status[]" <%= !@status.blank? && @status.include?('2') ? 'checked' : '' %>> <input id="work_status_3" class="magic-checkbox fl" type="checkbox" value="2" name="status[]" <%= !@status.blank? && @status.include?('2') ? 'checked' : '' %>>
<label for="work_status_3" class="fl mr25">延时提交(<%= student_works.where(:work_status => 2).count %>)</label> <label for="work_status_3" class="fl mr25">延时提交(<%= student_works.where(:work_status => 2).size %>)</label>
</li> </li>
<li class="clearfix"> <li class="clearfix">
<span class="fl mr10 color-grey-8">分班情况:</span> <span class="fl mr10 color-grey-8">分班情况:</span>
@ -210,9 +210,9 @@
<a href="javascript:void(0);" id="group_no_limit" class="<%= @group.blank? ? 'check_on' : '' %> pl10 pr10">不限</a> <a href="javascript:void(0);" id="group_no_limit" class="<%= @group.blank? ? 'check_on' : '' %> pl10 pr10">不限</a>
</span> </span>
<p class="fl pb10" style="display: block;max-width: 995px;"> <p class="fl pb10" style="display: block;max-width: 995px;">
<% groups.each do |group| %> <% groups.includes(:members).each do |group| %>
<input id="group_<%= group.id %>" class="magic-checkbox fl" type="checkbox" value="<%= group.id %>" name="group[]" <%= !@group.blank? && @group.include?(group.id) ? 'checked' : '' %>> <input id="group_<%= group.id %>" class="magic-checkbox fl" type="checkbox" value="<%= group.id %>" name="group[]" <%= !@group.blank? && @group.include?(group.id) ? 'checked' : '' %>>
<label for="group_<%= group.id %>" class="fl mr25"><%= group.name %>(<%= group.members.count %>)</label> <label for="group_<%= group.id %>" class="fl mr25"><%= group.name %>(<%= group.members.size %>)</label>
<% end %> <% end %>
<% if !@group_teacher %> <% if !@group_teacher %>
<input id="group_0" class="magic-checkbox fl" type="checkbox" value="0" name="group[]"> <input id="group_0" class="magic-checkbox fl" type="checkbox" value="0" name="group[]">
@ -255,7 +255,7 @@
<% my_work = cur_user_works_for_homework @homework %> <% my_work = cur_user_works_for_homework @homework %>
<% if @homework.homework_detail_manual.comment_status == 3 %> <% if @homework.homework_detail_manual.comment_status == 3 %>
<% unless my_work.nil? %> <% unless my_work.nil? %>
<% if my_work.user.student_works_evaluation_distributions.where(:student_work_id => @homework.student_works.map(&:id)).count != 0 %> <% if my_work.user.student_works_evaluation_distributions.where(:student_work_id => @homework.student_works.map(&:id)).size != 0 %>
<span class="edu-filter-btn edu-filter-btn-orange mb15">你在匿评开启之前提交了作品,你的作品正在匿评中</span> <span class="edu-filter-btn edu-filter-btn-orange mb15">你在匿评开启之前提交了作品,你的作品正在匿评中</span>
<% else %> <% else %>
<span class="edu-filter-btn edu-filter-btn-orange mb15">你在匿评开启之后才提交作品,你的作品没有参与匿评</span> <span class="edu-filter-btn edu-filter-btn-orange mb15">你在匿评开启之后才提交作品,你的作品没有参与匿评</span>
@ -278,8 +278,8 @@
<% end %> <% end %>
<p class="color-grey-8 font-12 clearfix mb15"> <p class="color-grey-8 font-12 clearfix mb15">
<span class=""><%= @homework.student_works.where("work_status != 0").count %> 已交</span> <span class=""><%= @homework.student_works.where("work_status != 0").size %> 已交</span>
<span class="ml30"><%= @homework.course.student.count - @homework.student_works.where("work_status != 0").size %> <span class="ml30"><%= @homework.course.student.size - @homework.student_works.where("work_status != 0").size %>
未交</span> 未交</span>
<% if @homework.homework_detail_manual %> <% if @homework.homework_detail_manual %>
<% if @homework.homework_detail_manual.comment_status == 1 %> <% if @homework.homework_detail_manual.comment_status == 1 %>

@ -37,7 +37,7 @@
<% if comment_status == 0 || activity.homework_group_settings.where("publish_time is null or publish_time > '#{Time.now}'").count > 0 %> <% if comment_status == 0 || activity.homework_group_settings.where("publish_time is null or publish_time > '#{Time.now}'").count > 0 %>
<li><%= link_to '立即发布', publish_notice_homework_common_path(activity), :remote => true %></li> <li><%= link_to '立即发布', publish_notice_homework_common_path(activity), :remote => true %></li>
<% end %> <% end %>
<% if (comment_status == 1 && activity.end_time > Time.now) || activity.homework_group_settings.where("publish_time < '#{Time.now}' and end_time > '#{Time.now}'").count > 0 %> <% if (comment_status == 1 && activity.end_time && activity.end_time > Time.now) || activity.homework_group_settings.where("publish_time < '#{Time.now}' and end_time > '#{Time.now}'").count > 0 %>
<li><%= link_to '立即截止', end_notice_homework_common_path(activity), :remote => true %></li> <li><%= link_to '立即截止', end_notice_homework_common_path(activity), :remote => true %></li>
<% end %> <% end %>
<li><%= link_to "导出成绩", student_work_index_path(:homework => activity, :format => 'xls'), :id => "export_student_work" %></li> <li><%= link_to "导出成绩", student_work_index_path(:homework => activity, :format => 'xls'), :id => "export_student_work" %></li>

Loading…
Cancel
Save