班级作业:修改评分后,同一人的之前的评分,就不显示了

This commit is contained in:
cxt 2016-11-04 11:27:15 +08:00
parent c9db4d6bba
commit 6f1c648770
7 changed files with 33 additions and 24 deletions

View File

@ -691,7 +691,7 @@ class StudentWorkController < ApplicationController
def show
@score = student_work_score @work,User.current
@is_teacher = User.current.allowed_to?(:as_teacher,@course) || User.current.admin?
@student_work_scores = @work.student_works_scores.order("updated_at desc")
@student_work_scores = student_work_score_record(@work)
respond_to do |format|
format.js
end
@ -854,6 +854,7 @@ class StudentWorkController < ApplicationController
if @work.save
@work = @homework.student_works.select("student_works.*,student_works.work_score as score").where(:id => @work.id).first
@count = @homework.student_works.has_committed.count
@student_work_scores = student_work_score_record @work
respond_to do |format|
format.js
end

View File

@ -69,6 +69,15 @@ module StudentWorkHelper
str
end
#获取学生作品的评分记录:同一个教师或教辅只显示最后一次评分
def student_work_score_record work
sql = "SELECT MAX(id) id FROM student_works_scores WHERE (reviewer_role = 2 OR reviewer_role = 1) AND score IS NOT NULL AND student_work_id = #{work.id} GROUP BY user_id"
tea_ts_ids = StudentWorksScore.find_by_sql sql
tea_ts_ids = tea_ts_ids.empty? ? "(-1)" : "(" + tea_ts_ids.map{|tea| tea.id}.join(",") + ")"
scores = work.student_works_scores.where("score IS NULL or reviewer_role = 3 or id in #{tea_ts_ids}").order("updated_at desc")
return scores
end
#获取赞的总数
def praise_homework_count obj_id
PraiseTread.where("praise_tread_object_id = #{obj_id} AND praise_tread_object_type = 'StudentWork'").count

View File

@ -106,12 +106,8 @@
</div>
<div class="cl"></div>
<div class="ping_box fl" id="score_list_<%= work.id%>" style="<%= work.student_works_scores.empty? ? 'padding:0px;' : ''%>">
<%student_work_scores.each do |student_score|%>
<div id="work_score_<%= student_score.id%>">
<%= render :partial => 'student_work_score',:locals => {:score => student_score,:is_last => student_score == student_work_scores.last}%>
</div>
<% end%>
<div class="ping_box fl" id="score_list_<%= work.id%>" style="<%= student_work_scores.empty? ? 'padding:0px;' : ''%>">
<%= render :partial => 'student_work_score_records', :locals => {:student_work_scores => student_work_scores, :is_member_work => false} %>
</div>
<div class="cl"></div>
<!---ping_box end--->

View File

@ -109,15 +109,8 @@
</ul>
<% end %>
<div class="ping_box fl" id="score_list_<%= work.id%>" style="<%= work.student_works_scores.empty? ? 'padding:0px;' : ''%>">
<%student_work_scores.each do |student_score|%>
<div id="work_score_<%= student_score.id%>">
<%= render :partial => 'student_work_score',:locals => {:score => student_score,:is_last => student_score == student_work_scores.last}%>
</div>
<% end%>
<% if is_member_work && student_work_scores.empty? && !@is_teacher %>
<p class="c_red" style="text-align: center">暂无评分</p>
<% end %>
<div class="ping_box fl" id="score_list_<%= work.id%>" style="<%= student_work_scores.empty? ? 'padding:0px;' : ''%>">
<%= render :partial => 'student_work_score_records', :locals => {:student_work_scores => student_work_scores, :is_member_work => is_member_work} %>
</div>
<div class="cl"></div>
<!---ping_box end--->

View File

@ -76,7 +76,7 @@
<% unless work.nil? %>
location.hash = "<%=work.id %>";
<% if @homework.homework_type == 2 %>
$("#about_hwork_<%= work.id%>").html("<%= escape_javascript(render :partial => 'programing_work_show',:locals => {:work =>work,:score =>student_work_score(work,User.current),:student_work_scores => work.student_works_scores.order("updated_at desc"),:is_focus => @is_focus}) %>");
$("#about_hwork_<%= work.id%>").html("<%= escape_javascript(render :partial => 'programing_work_show',:locals => {:work =>work,:score =>student_work_score(work,User.current),:student_work_scores => student_work_score_record(work),:is_focus => @is_focus}) %>");
var program_name = "text/x-csrc";
var language = <%= @homework.language %>;
@ -100,9 +100,9 @@
value: $("#work-src_<%= work.id%>").text()
});
<% elsif @homework.homework_type == 1 %>
$("#about_hwork_<%= work.id%>").html("<%= escape_javascript(render :partial => 'show',:locals => {:work => work, :score =>student_work_score(work,User.current),:student_work_scores => work.student_works_scores.order("updated_at desc"),:is_focus => @is_focus}) %>");
$("#about_hwork_<%= work.id%>").html("<%= escape_javascript(render :partial => 'show',:locals => {:work => work, :score =>student_work_score(work,User.current),:student_work_scores => student_work_score_record(work),:is_focus => @is_focus}) %>");
<% elsif @homework.homework_type == 3 %>
$("#about_hwork_<%= work.id%>").html("<%= escape_javascript(render :partial => 'show',:locals => {:work => work, :score =>student_work_score(work,User.current),:student_work_scores => work.student_works_scores.order("updated_at desc"),:is_focus => @is_focus}) %>");
$("#about_hwork_<%= work.id%>").html("<%= escape_javascript(render :partial => 'show',:locals => {:work => work, :score =>student_work_score(work,User.current),:student_work_scores => student_work_score_record(work),:is_focus => @is_focus}) %>");
<% end %>
$('#score_<%= work.id%>').peSlider({range: 'min'});
<% end %>

View File

@ -0,0 +1,8 @@
<%student_work_scores.each do |student_score|%>
<div id="work_score_<%= student_score.id%>">
<%= render :partial => 'student_work_score',:locals => {:score => student_score,:is_last => student_score == student_work_scores.last}%>
</div>
<% end%>
<% if is_member_work && student_work_scores.empty? && !@is_teacher %>
<p class="c_red" style="text-align: center">暂无评分</p>
<% end %>

View File

@ -1,12 +1,14 @@
$("#add_student_score_<%= @work.id%>").html("<%= escape_javascript(render :partial => 'add_score',:locals => {:work => @work,:score => @new_score}) %>");
$('#score_<%= @work.id%>').peSlider({range: 'min'});
<% if @is_new%>
$("#score_list_<%= @work.id%>").prepend("<div id='work_score_<%= @new_score.id%>'><%= escape_javascript(render :partial => 'student_work_score', :locals => {:score => @new_score,:is_last => @is_last_a}) %></div>");
<% else %>
$("#work_score_<%= @score.id%>").html("<%= escape_javascript(render :partial => 'student_work_score', :locals => {:score => @new_score,:is_last => @is_last}) %>");
<% end%>
<%# if @is_new%>
//$("#score_list_<%#= @work.id%>").prepend("<div id='work_score_<%#= @new_score.id%>'><%#= escape_javascript(render :partial => 'student_work_score', :locals => {:score => @new_score,:is_last => @is_last_a}) %></div>");
<%# else %>
//$("#work_score_<%#= @score.id%>").html("<%#= escape_javascript(render :partial => 'student_work_score', :locals => {:score => @new_score,:is_last => @is_last}) %>");
<%# end%>
<% is_member_work = @homework.homework_type == 3 && @work.student_work_projects.empty? %>
$("#score_list_<%= @work.id%>").replaceWith("<%=escape_javascript(render :partial => 'student_work_score_records', :locals => {:student_work_scores => @student_work_scores, :is_member_work => is_member_work}) %>");
var num = $("#work_num_<%= @work.id%>").html();
$("#score_list_<%= @work.id%>").removeAttr("style");