1、添加评分后页面刷新
2、如果只填写了评分就只更新评分,不对评论进行修改 3、如果已经评分过,继续评分为修改,如果未进行过评分,就是添加
This commit is contained in:
parent
bdb0f638da
commit
d80ade96c8
|
@ -74,27 +74,25 @@ class StudentWorkController < ApplicationController
|
|||
|
||||
#添加评分,已评分则为修改评分
|
||||
def add_score
|
||||
score = student_work_score @work,User.current
|
||||
if score
|
||||
if params[:new_form] && params[:new_form][:user_message]
|
||||
score.score = params[:score]
|
||||
score.comment = params[:new_form][:user_message]
|
||||
end
|
||||
@score = student_work_score @work,User.current
|
||||
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]
|
||||
@is_new = false
|
||||
else
|
||||
if params[:new_form] && params[:new_form][:user_message]
|
||||
score = StudentWorksScore.new
|
||||
score.score = params[:score]
|
||||
score.comment = params[:new_form][:user_message]
|
||||
score.user_id = User.current.id
|
||||
score.student_work_id = @work.id
|
||||
score.reviewer_role = 1
|
||||
end
|
||||
@score = StudentWorksScore.new
|
||||
@score.score = params[:score] if params[:score]
|
||||
@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
|
||||
@score.reviewer_role = 1
|
||||
@is_new = true
|
||||
end
|
||||
|
||||
score.save_attachments(params[:attachments])
|
||||
render_attachment_warning_if_needed(score)
|
||||
@score.save_attachments(params[:attachments])
|
||||
render_attachment_warning_if_needed(@score)
|
||||
|
||||
if score.save
|
||||
if @score.save
|
||||
respond_to do |format|
|
||||
format.js
|
||||
end
|
||||
|
|
|
@ -32,48 +32,18 @@
|
|||
</li>
|
||||
<div class="cl"></div>
|
||||
|
||||
<div id="add_student_score">
|
||||
<div id="add_student_score_<%= @work.id%>">
|
||||
<%= render :partial => 'add_score',:locals => {:work => @work,:score => @score}%>
|
||||
</div>
|
||||
</ul>
|
||||
|
||||
<% unless @work.student_works_scores.empty?%>
|
||||
<div class="ping_box">
|
||||
<div class="ping_box" id="score_list_<%= @work.id%>">
|
||||
<%@work.student_works_scores.each do |score|%>
|
||||
<ul class="ping_box_ul ping_line">
|
||||
<%= link_to image_tag(url_to_avatar(score.user), :width => "34", :height => "34"), user_path(score.user),:class => "ping_pic fl" %>
|
||||
<div class="ping_box_tit">
|
||||
<%= link_to score.user.show_name, user_path(score.user), :title => score.user.show_name, :class => "c_blue fl" %>
|
||||
<span class="ml5 fl">(<%= student_work_score_role score%>)</span>
|
||||
<span class="ml20 fl">评分:</span>
|
||||
<a href="javascript:void(0);" class="c_orange fl" ><%= score.score%>分</a>
|
||||
<a href="javascript:void(0);" class="fr c_purple mr5" onclick="$('#add_score_reply_<%= score.id%>').slideToggle();">回复</a>
|
||||
<span class=" fr c_grey mr20">
|
||||
<%=format_time score.created_at %>
|
||||
</span>
|
||||
<div class="cl mb5"></div>
|
||||
<p class="break_word">
|
||||
<%= score.comment%>
|
||||
</p>
|
||||
<div class="cl"></div>
|
||||
<%= render :partial => 'work_attachments', :locals => {:attachments => score.attachments} %>
|
||||
<div class="cl"></div>
|
||||
<div id="add_score_reply_<%= score.id%>" class="undis">
|
||||
<%= render :partial => 'add_score_reply',:locals => {:score => score}%>
|
||||
</div>
|
||||
<div class="cl"></div>
|
||||
|
||||
<div id="replay_histroy_<%= score.id%>">
|
||||
<% score.journals_for_messages.order("created_on desc").each do |jour|%>
|
||||
<%= render :partial => 'jour_replay',:locals => {:jour => jour}%>
|
||||
<% end%>
|
||||
</div>
|
||||
</div>
|
||||
<div class="cl"></div>
|
||||
</ul>
|
||||
<div id="work_score_<%= score.id%>">
|
||||
<%= render :partial => 'student_work_score',:locals => {:score => score}%>
|
||||
</div>
|
||||
<% end%>
|
||||
</div><!---ping_box end--->
|
||||
<%end%>
|
||||
<a href="javascript:void(0);" class="fr c_blue mt5 mb5" onclick="$('#about_hwork_<%= @work.id%>').html('');">收起</a>
|
||||
<div class="cl"></div>
|
||||
</div><!---show_hwork end--->
|
|
@ -0,0 +1,31 @@
|
|||
<ul class="ping_box_ul ping_line">
|
||||
<%= link_to image_tag(url_to_avatar(score.user), :width => "34", :height => "34"), user_path(score.user),:class => "ping_pic fl" %>
|
||||
<div class="ping_box_tit">
|
||||
<%= link_to score.user.show_name, user_path(score.user), :title => score.user.show_name, :class => "c_blue fl" %>
|
||||
<span class="ml5 fl">(<%= student_work_score_role score%>)</span>
|
||||
<span class="ml20 fl">评分:</span>
|
||||
<a href="javascript:void(0);" class="c_orange fl" ><%= score.score%>分</a>
|
||||
<a href="javascript:void(0);" class="fr c_purple mr5" onclick="$('#add_score_reply_<%= score.id%>').slideToggle();">回复</a>
|
||||
<span class=" fr c_grey mr20">
|
||||
<%=format_time score.created_at %>
|
||||
</span>
|
||||
<div class="cl mb5"></div>
|
||||
<p class="break_word">
|
||||
<%= score.comment%>
|
||||
</p>
|
||||
<div class="cl"></div>
|
||||
<%= render :partial => 'work_attachments', :locals => {:attachments => score.attachments} %>
|
||||
<div class="cl"></div>
|
||||
<div id="add_score_reply_<%= score.id%>" class="undis">
|
||||
<%= render :partial => 'add_score_reply',:locals => {:score => score}%>
|
||||
</div>
|
||||
<div class="cl"></div>
|
||||
|
||||
<div id="replay_histroy_<%= score.id%>">
|
||||
<% score.journals_for_messages.order("created_on desc").each do |jour|%>
|
||||
<%= render :partial => 'jour_replay',:locals => {:jour => jour}%>
|
||||
<% end%>
|
||||
</div>
|
||||
</div>
|
||||
<div class="cl"></div>
|
||||
</ul>
|
|
@ -1,3 +1,8 @@
|
|||
$("#add_student_score").html("<%= escape_javascript(render :partial => 'add_score',:locals => {:work => @work}) %>");
|
||||
$("#add_student_score_<%= @work.id%>").html("<%= escape_javascript(render :partial => 'add_score',:locals => {:work => @work,:score => @score}) %>");
|
||||
$('#score_<%= @work.id%>').peSlider({range: 'min'});
|
||||
alert("评分成功");
|
||||
|
||||
<% if @is_new%>
|
||||
$("#score_list_<%= @work.id%>").prepend("<%= escape_javascript(render :partial => 'student_work_score', :locals => {:score => @score}) %>");
|
||||
<% else %>
|
||||
$("#work_score_<%= @score.id%>").html("<%= escape_javascript(render :partial => 'student_work_score', :locals => {:score => @score}) %>");
|
||||
<% end%>
|
||||
|
|
Loading…
Reference in New Issue