diff --git a/app/controllers/student_work_controller.rb b/app/controllers/student_work_controller.rb
index cf712bfc9..d4a1bd4e5 100644
--- a/app/controllers/student_work_controller.rb
+++ b/app/controllers/student_work_controller.rb
@@ -9,36 +9,75 @@ class StudentWorkController < ApplicationController
before_filter :teacher_of_course, :only => [:student_work_absence_penalty, :absence_penalty_list, :evaluation_list]
def index
- @order,@b_sort,@name = params[:order] || "score",params[:sort] || "desc",params[:name] || ""
+ @order,@b_sort,@name,@group = params[:order] || "score",params[:sort] || "desc",params[:name] || "",params[:group]
@is_teacher = User.current.allowed_to?(:as_teacher,@course)
- #老师 || 非匿评作业 || 匿评结束 显示所有的作品
- @show_all = @is_teacher || @homework.homework_type != 1 || @homework.homework_detail_manual.comment_status == 3 || User.current.admin?
- if @show_all
- if @homework.homework_type == 1 || @is_teacher || User.current.admin? #超级管理员 || 老师 || 匿评结束 显示所有的作品
- if @order == "name"
- @stundet_works = search_homework_member @homework.student_works.select("*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").joins(:user).order("users.lastname #{@b_sort}, users.firstname #{@b_sort}"),@name
- else
- @stundet_works = search_homework_member @homework.student_works.select("*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").order("#{@order} #{@b_sort}"),@name
- end
- else #剩余情况: 学生 && 非匿评作业 如果未提交作品,只能看到自己的,提交了作品,能看到所有作品
- my_work = @homework.student_works.select("*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").where(:user_id => User.current.id)
- if my_work.empty?
- @stundet_works = []
- else
+ unless @group == "0" || @group.nil?
+ group_students = CourseGroup.find_by_id(@group).users
+ if group_students.empty?
+ student_in_group = '(0)'
+ else
+ student_in_group = '(' + group_students.map{|user| user.id}.join(',') + ')'
+ end
+ #老师 || 非匿评作业 || 匿评结束 显示所有的作品
+ @show_all = @is_teacher || @homework.homework_type != 1 || @homework.homework_detail_manual.comment_status == 3 || User.current.admin?
+ if @show_all
+ if @homework.homework_type == 1 || @is_teacher || User.current.admin? #超级管理员 || 老师 || 匿评结束 显示所有的作品
if @order == "name"
- @stundet_works = search_homework_member @homework.student_works.select("*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").joins(:user).order("users.lastname #{@b_sort}, users.firstname #{@b_sort}"),@name
+ @stundet_works = search_homework_member @homework.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").joins(:user).where("users.id in #{student_in_group}").order("users.lastname #{@b_sort}, users.firstname #{@b_sort}"),@name
else
- @stundet_works = search_homework_member @homework.student_works.select("*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").order("#{@order} #{@b_sort}"),@name
+ @stundet_works = search_homework_member @homework.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").joins(:user).where("users.id in #{student_in_group}").order("#{@order} #{@b_sort}"),@name
+ end
+ else #剩余情况: 学生 && 非匿评作业 如果未提交作品,只能看到自己的,提交了作品,能看到所有作品
+ my_work = @homework.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").where(:user_id => User.current.id)
+ if my_work.empty?
+ @stundet_works = []
+ else
+ if @order == "name"
+ @stundet_works = search_homework_member @homework.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").joins(:user).where("users.id in #{student_in_group}").order("users.lastname #{@b_sort}, users.firstname #{@b_sort}"),@name
+ else
+ @stundet_works = search_homework_member @homework.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").joins(:user).where("users.id in #{student_in_group}").order("#{@order} #{@b_sort}"),@name
+ end
end
end
+ else #学生
+ if @homework.homework_detail_manual.comment_status == 1 #未开启匿评,只显示我的作品
+ @stundet_works = @homework.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").where(:user_id => User.current.id)
+ elsif @homework.homework_detail_manual.comment_status == 2 #匿评列表,显示匿评作品和我的作品
+ @is_evaluation = true
+ my_work = @homework.student_works.where(:user_id => User.current.id)
+ @stundet_works = my_work + User.current.student_works_evaluation_distributions.map(&:student_work).select { |work| work.homework_common_id == @homework.id}
+ end
end
- else #学生
- if @homework.homework_detail_manual.comment_status == 1 #未开启匿评,只显示我的作品
- @stundet_works = @homework.student_works.select("*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").where(:user_id => User.current.id)
- elsif @homework.homework_detail_manual.comment_status == 2 #匿评列表,显示匿评作品和我的作品
- @is_evaluation = true
- my_work = @homework.student_works.where(:user_id => User.current.id)
- @stundet_works = my_work + User.current.student_works_evaluation_distributions.map(&:student_work).select { |work| work.homework_common_id == @homework.id}
+ else
+ #老师 || 非匿评作业 || 匿评结束 显示所有的作品
+ @show_all = @is_teacher || @homework.homework_type != 1 || @homework.homework_detail_manual.comment_status == 3 || User.current.admin?
+ if @show_all
+ if @homework.homework_type == 1 || @is_teacher || User.current.admin? #超级管理员 || 老师 || 匿评结束 显示所有的作品
+ if @order == "name"
+ @stundet_works = search_homework_member @homework.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").joins(:user).order("users.lastname #{@b_sort}, users.firstname #{@b_sort}"),@name
+ else
+ @stundet_works = search_homework_member @homework.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").order("#{@order} #{@b_sort}"),@name
+ end
+ else #剩余情况: 学生 && 非匿评作业 如果未提交作品,只能看到自己的,提交了作品,能看到所有作品
+ my_work = @homework.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").where(:user_id => User.current.id)
+ if my_work.empty?
+ @stundet_works = []
+ else
+ if @order == "name"
+ @stundet_works = search_homework_member @homework.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").joins(:user).order("users.lastname #{@b_sort}, users.firstname #{@b_sort}"),@name
+ else
+ @stundet_works = search_homework_member @homework.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").order("#{@order} #{@b_sort}"),@name
+ end
+ end
+ end
+ else #学生
+ if @homework.homework_detail_manual.comment_status == 1 #未开启匿评,只显示我的作品
+ @stundet_works = @homework.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").where(:user_id => User.current.id)
+ elsif @homework.homework_detail_manual.comment_status == 2 #匿评列表,显示匿评作品和我的作品
+ @is_evaluation = true
+ my_work = @homework.student_works.where(:user_id => User.current.id)
+ @stundet_works = my_work + User.current.student_works_evaluation_distributions.map(&:student_work).select { |work| work.homework_common_id == @homework.id}
+ end
end
end
@homework_commons = @course.homework_commons.order("created_at desc")
@@ -170,6 +209,12 @@ class StudentWorkController < ApplicationController
if @score
@score.comment = params[:new_form][:user_message] if params[:new_form] && params[:new_form][:user_message] && params[:new_form][:user_message] != ""
@score.score = params[:score] if params[:score]
+ if User.current.admin?
+ @score.reviewer_role = 1
+ else
+ role = User.current.members.where("course_id = ?",@course.id).first.roles.first.name
+ @score.reviewer_role = get_role_by_name(role)
+ end
@is_new = false
else
@score = StudentWorksScore.new
@@ -177,8 +222,12 @@ class StudentWorkController < ApplicationController
@score.comment = params[:new_form][:user_message] if params[:new_form] && params[:new_form][:user_message] && params[:new_form][:user_message] != ""
@score.user_id = User.current.id
@score.student_work_id = @work.id
- role = User.current.members.where("course_id = ?",@course.id).first.roles.first.name
- User.current.admin? ? @score.reviewer_role = 1 : @score.reviewer_role = get_role_by_name(role)
+ if User.current.admin?
+ @score.reviewer_role = 1
+ else
+ role = User.current.members.where("course_id = ?",@course.id).first.roles.first.name
+ @score.reviewer_role = get_role_by_name(role)
+ end
@is_new = true
end
diff --git a/app/helpers/student_work_helper.rb b/app/helpers/student_work_helper.rb
index 2171d44f5..f24d5078f 100644
--- a/app/helpers/student_work_helper.rb
+++ b/app/helpers/student_work_helper.rb
@@ -85,7 +85,10 @@ module StudentWorkHelper
def course_group_list course
result = []
if course.course_groups && !course.course_groups.empty?
- result << l(:label_chose_group)
+ base = []
+ base << l(:label_chose_group)
+ base << 0
+ result << base
course.course_groups.each do |group|
option = []
option << group.name
diff --git a/app/views/student_work/_evaluation_student_work.html.erb b/app/views/student_work/_evaluation_student_work.html.erb
index 0f66452c7..b83917481 100644
--- a/app/views/student_work/_evaluation_student_work.html.erb
+++ b/app/views/student_work/_evaluation_student_work.html.erb
@@ -9,7 +9,7 @@
<%= link_to student_work.user.show_name,user_path(student_work.user),:title => student_work.user.show_name, :class => "c_blue02"%>
- <%= link_to student_work.name, student_work_path(student_work),:remote => true,:title => student_work.name, :class => "c_blue02"%>
+ <%= link_to student_work.name, student_work_path(student_work.id),:remote => true,:title => student_work.name, :class => "c_blue02"%>
<% if Time.parse(@homework.end_time.to_s).strftime("%Y-%m-%d") < Time.parse(student_work.created_at.to_s).strftime("%Y-%m-%d") %>
diff --git a/app/views/student_work/_evaluation_student_work_title.html.erb b/app/views/student_work/_evaluation_student_work_title.html.erb
index a95106a48..f19438f78 100644
--- a/app/views/student_work/_evaluation_student_work_title.html.erb
+++ b/app/views/student_work/_evaluation_student_work_title.html.erb
@@ -2,46 +2,46 @@
学号
- <%= link_to "姓名",@show_all ? student_work_index_path(:homework => @homework.id,:order => "name", :sort => @score, :name => @name) : "javascript:void(0)",:class => "f14 f_b c_dark fl"%>
+ <%= link_to "姓名",@show_all ? student_work_index_path(:homework => @homework.id,:order => "name", :sort => @score, :name => @name, :group => @group) : "javascript:void(0)",:class => "f14 f_b c_dark fl"%>
<% if @show_all && @order == "name"%>
-
+ <%= link_to "",student_work_index_path(:homework => @homework.id,:order => "name", :sort => @score, :name => @name, :group => @group) ,:class => @score == 'desc' ? 'st_up' : 'st_down'%>
<% end%>
作品名称
- <%= link_to "时间",@show_all ? student_work_index_path(:homework => @homework.id,:order => "created_at", :sort => @score, :name => @name) : "javascript:void(0)",:class => "f14 f_b c_dark fl"%>
+ <%= link_to "时间",@show_all ? student_work_index_path(:homework => @homework.id,:order => "created_at", :sort => @score, :name => @name, :group => @group) : "javascript:void(0)",:class => "f14 f_b c_dark fl"%>
<% if @show_all && @order == "created_at"%>
- <%= link_to "",student_work_index_path(:homework => @homework.id,:order => "created_at", :sort => @score, :name => @name) ,:class => @score == 'desc' ? 'st_up' : 'st_down'%>
+ <%= link_to "",student_work_index_path(:homework => @homework.id,:order => "created_at", :sort => @score, :name => @name, :group => @group) ,:class => @score == 'desc' ? 'st_up' : 'st_down'%>
<% end%>
- <%= link_to "教师",@show_all ? student_work_index_path(:homework => @homework.id,:order => "teacher_score", :sort => @score, :name => @name) : "javascript:void(0)",:class => "f14 f_b c_dark fl"%>
+ <%= link_to "教师",@show_all ? student_work_index_path(:homework => @homework.id,:order => "teacher_score", :sort => @score, :name => @name, :group => @group) : "javascript:void(0)",:class => "f14 f_b c_dark fl"%>
<% if @show_all && @order == "teacher_score"%>
- <%= link_to "", student_work_index_path(:homework => @homework.id,:order => "teacher_score", :sort => @score, :name => @name) ,:class => @score == 'desc' ? 'st_up' : 'st_down'%>
+ <%= link_to "", student_work_index_path(:homework => @homework.id,:order => "teacher_score", :sort => @score, :name => @name, :group => @group) ,:class => @score == 'desc' ? 'st_up' : 'st_down'%>
<% end%>
- <%= link_to "教辅",@show_all ? student_work_index_path(:homework => @homework.id,:order => "teaching_asistant_score", :sort => @score, :name => @name) : "javascript:void(0)",:class => "f14 f_b c_dark fl"%>
+ <%= link_to "教辅",@show_all ? student_work_index_path(:homework => @homework.id,:order => "teaching_asistant_score", :sort => @score, :name => @name, :group => @group) : "javascript:void(0)",:class => "f14 f_b c_dark fl"%>
<% if @show_all && @order == "teaching_asistant_score"%>
- <%= link_to "", student_work_index_path(:homework => @homework.id,:order => "teaching_asistant_score", :sort => @score, :name => @name) ,:class => @score == 'desc' ? 'st_up' : 'st_down'%>
+ <%= link_to "", student_work_index_path(:homework => @homework.id,:order => "teaching_asistant_score", :sort => @score, :name => @name, :group => @group) ,:class => @score == 'desc' ? 'st_up' : 'st_down'%>
<% end%>
<% if @homework.homework_type == 1%>
- <%= link_to "匿评",@show_all ? student_work_index_path(:homework => @homework.id,:order => "student_score", :sort => @score, :name => @name) : "javascript:void(0)",:class => "f14 f_b c_dark fl"%>
+ <%= link_to "匿评",@show_all ? student_work_index_path(:homework => @homework.id,:order => "student_score", :sort => @score, :name => @name, :group => @group) : "javascript:void(0)",:class => "f14 f_b c_dark fl"%>
<% elsif @homework.homework_type == 2%>
- <%= link_to "系统",@show_all ? student_work_index_path(:homework => @homework.id,:order => "student_score", :sort => @score, :name => @name) : "javascript:void(0)",:class => "f14 f_b c_dark fl"%>
+ <%= link_to "系统",@show_all ? student_work_index_path(:homework => @homework.id,:order => "student_score", :sort => @score, :name => @name, :group => @group) : "javascript:void(0)",:class => "f14 f_b c_dark fl"%>
<% end %>
<% if @show_all && @order == "student_score"%>
- <%= link_to "", student_work_index_path(:homework => @homework.id,:order => "student_score", :sort => @score, :name => @name) ,:class => @score == 'desc' ? 'st_up' : 'st_down'%>
+ <%= link_to "", student_work_index_path(:homework => @homework.id,:order => "student_score", :sort => @score, :name => @name, :group => @group) ,:class => @score == 'desc' ? 'st_up' : 'st_down'%>
<% end%>
- <%= link_to "成绩",@show_all ? student_work_index_path(:homework => @homework.id,:order => "score", :sort => @score, :name => @name) : "javascript:void(0)",:class => "f14 f_b c_dark fl"%>
+ <%= link_to "成绩",@show_all ? student_work_index_path(:homework => @homework.id,:order => "score", :sort => @score, :name => @name, :group => @group) : "javascript:void(0)",:class => "f14 f_b c_dark fl"%>
<% if @show_all && @order == "score"%>
- <%= link_to "", student_work_index_path(:homework => @homework.id,:order => "score", :sort => @score, :name => @name) ,:class => @score == 'desc' ? 'st_up' : 'st_down'%>
+ <%= link_to "", student_work_index_path(:homework => @homework.id,:order => "score", :sort => @score, :name => @name, :group => @group) ,:class => @score == 'desc' ? 'st_up' : 'st_down'%>
<% end%>
\ No newline at end of file
diff --git a/app/views/student_work/_student_work_title.html.erb b/app/views/student_work/_student_work_title.html.erb
index c46f7dc79..24e6a1b37 100644
--- a/app/views/student_work/_student_work_title.html.erb
+++ b/app/views/student_work/_student_work_title.html.erb
@@ -2,36 +2,36 @@
学号
- <%= link_to "姓名",@show_all ? student_work_index_path(:homework => @homework.id,:order => "name", :sort => @score, :name => @name) : "javascript:void(0)",:class => "f14 f_b c_dark fl"%>
+ <%= link_to "姓名",@show_all ? student_work_index_path(:homework => @homework.id,:order => "name", :sort => @score, :name => @name, :group => @group) : "javascript:void(0)",:class => "f14 f_b c_dark fl"%>
<% if @show_all && @order == "name"%>
-
+ <%= link_to "",student_work_index_path(:homework => @homework.id,:order => "name", :sort => @score, :name => @name, :group => @group) ,:class => @score == 'desc' ? 'st_up' : 'st_down'%>
<% end%>
作品名称
- <%= link_to "时间",@show_all ? student_work_index_path(:homework => @homework.id,:order => "created_at", :sort => @score, :name => @name) : "javascript:void(0)",:class => "f14 f_b c_dark fl"%>
+ <%= link_to "时间",@show_all ? student_work_index_path(:homework => @homework.id,:order => "created_at", :sort => @score, :name => @name, :group => @group) : "javascript:void(0)",:class => "f14 f_b c_dark fl"%>
<% if @show_all && @order == "created_at"%>
- <%= link_to "",student_work_index_path(:homework => @homework.id,:order => "created_at", :sort => @score, :name => @name) ,:class => @score == 'desc' ? 'st_up' : 'st_down'%>
+ <%= link_to "",student_work_index_path(:homework => @homework.id,:order => "created_at", :sort => @score, :name => @name, :group => @group) ,:class => @score == 'desc' ? 'st_up' : 'st_down'%>
<% end%>
- <%= link_to "教师",@show_all ? student_work_index_path(:homework => @homework.id,:order => "teacher_score", :sort => @score, :name => @name) : "javascript:void(0)",:class => "f14 f_b c_dark fl"%>
+ <%= link_to "教师",@show_all ? student_work_index_path(:homework => @homework.id,:order => "teacher_score", :sort => @score, :name => @name, :group => @group) : "javascript:void(0)",:class => "f14 f_b c_dark fl"%>
<% if @show_all && @order == "teacher_score"%>
- <%= link_to "", student_work_index_path(:homework => @homework.id,:order => "teacher_score", :sort => @score, :name => @name) ,:class => @score == 'desc' ? 'st_up' : 'st_down'%>
+ <%= link_to "", student_work_index_path(:homework => @homework.id,:order => "teacher_score", :sort => @score, :name => @name, :group => @group) ,:class => @score == 'desc' ? 'st_up' : 'st_down'%>
<% end%>
- <%= link_to "教辅",@show_all ? student_work_index_path(:homework => @homework.id,:order => "teaching_asistant_score", :sort => @score, :name => @name) : "javascript:void(0)",:class => "f14 f_b c_dark fl"%>
+ <%= link_to "教辅",@show_all ? student_work_index_path(:homework => @homework.id,:order => "teaching_asistant_score", :sort => @score, :name => @name, :group => @group) : "javascript:void(0)",:class => "f14 f_b c_dark fl"%>
<% if @show_all && @order == "teaching_asistant_score"%>
- <%= link_to "", student_work_index_path(:homework => @homework.id,:order => "teaching_asistant_score", :sort => @score, :name => @name) ,:class => @score == 'desc' ? 'st_up' : 'st_down'%>
+ <%= link_to "", student_work_index_path(:homework => @homework.id,:order => "teaching_asistant_score", :sort => @score, :name => @name, :group => @group) ,:class => @score == 'desc' ? 'st_up' : 'st_down'%>
<% end%>
- <%= link_to "成绩",@show_all ? student_work_index_path(:homework => @homework.id,:order => "score", :sort => @score, :name => @name) : "javascript:void(0)",:class => "f14 f_b c_dark fl"%>
+ <%= link_to "成绩",@show_all ? student_work_index_path(:homework => @homework.id,:order => "score", :sort => @score, :name => @name, :group => @group) : "javascript:void(0)",:class => "f14 f_b c_dark fl"%>
<% if @show_all && @order == "score"%>
- <%= link_to "", student_work_index_path(:homework => @homework.id,:order => "score", :sort => @score, :name => @name) ,:class => @score == 'desc' ? 'st_up' : 'st_down'%>
+ <%= link_to "", student_work_index_path(:homework => @homework.id,:order => "score", :sort => @score, :name => @name, :group => @group) ,:class => @score == 'desc' ? 'st_up' : 'st_down'%>
<% end%>
\ No newline at end of file
diff --git a/app/views/student_work/index.html.erb b/app/views/student_work/index.html.erb
index ad355c4ad..b9148a88f 100644
--- a/app/views/student_work/index.html.erb
+++ b/app/views/student_work/index.html.erb
@@ -48,9 +48,9 @@
<%= link_to "所有作品(#{@stundet_works.count} )".html_safe,student_work_index_path(:homework => @homework.id), :class => "fl"%>
<% if @show_all%>
-
- <%= select_tag :late_penalty,options_for_select(course_group_list(@course),@group), {:class => "fl h22 w100 ml10"} %>
- 搜索
+
+ <%= select_tag(:late_penalty,options_for_select(course_group_list(@course),@group), {:class => "fl h22 w100 ml10"}) if @is_teacher %>
+ 搜索
<%= link_to("缺评情况",student_work_absence_penalty_student_work_index_path(:homework => @homework.id), :class => "student_work_search fl", :target => "_blank") if((@is_teacher || User.current.admin?) && @homework.homework_type == 1) %>
<% end%>
<% if @is_teacher%>
diff --git a/public/javascripts/course.js b/public/javascripts/course.js
index 8db456cbf..db1f761f2 100644
--- a/public/javascripts/course.js
+++ b/public/javascripts/course.js
@@ -861,14 +861,14 @@ function clickOK(path)
});
}
//查询
-function SearchByName(obj,url,event)
+function SearchByName(name,group,url,event)
{
var keycode = (event.keyCode ? event.keyCode : event.which);
if(keycode == '13'){
- location.href = url + "&name=" + obj.val();
+ location.href = url + "&name=" + name + "&group=" + group;
}
}
-function SearchByName_1(obj,url)
+function SearchByName_1(name,group,url)
{
- location.href = url + "&name=" + obj.val();
+ location.href = url + "&name=" + name + "&group=" + group;
}