教辅可只评语不评分

This commit is contained in:
cxt 2016-05-11 09:18:55 +08:00
parent 5baf467d13
commit 9bc8ccbb9e
10 changed files with 73 additions and 60 deletions

View File

@ -613,51 +613,39 @@ class StudentWorkController < ApplicationController
#老师、教辅可以随时评分,学生只能在匿评作业的匿评阶段进行评分
render_403 and return unless @is_teacher || @homework.homework_detail_manual.comment_status == 2
@score = student_work_score @work,User.current
#@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
@is_last_a = @work.student_works_scores.empty?
@new_score = StudentWorksScore.new
if @score && params[:score]
@new_score.score = params[:score].to_i == -1 ? @score.score : params[:score]
elsif @score.nil? && params[:score]
@new_score.score = params[:score].to_i == -1 ? nil : params[:score]
end
@new_score.comment = params[:new_form][:user_message] if params[:new_form] && params[:new_form][:user_message] && params[:new_form][:user_message] != ""
@new_score.user_id = User.current.id
@new_score.student_work_id = @work.id
if User.current.admin?
@new_score.reviewer_role = 1
else
role = User.current.members.where("course_id = ?",@course.id).first.roles.first.name
@new_score.reviewer_role = get_role_by_name(role)
end
if @score
@new_score = StudentWorksScore.new
if params[:score]
@new_score.score = params[:score].to_i == -1 ? @score.score : params[:score]
end
@new_score.comment = params[:new_form][:user_message] if params[:new_form] && params[:new_form][:user_message] && params[:new_form][:user_message] != ""
@new_score.user_id = User.current.id
@new_score.student_work_id = @work.id
if User.current.admin?
@new_score.reviewer_role = 1
else
role = User.current.members.where("course_id = ?",@course.id).first.roles.first.name
@new_score.reviewer_role = get_role_by_name(role)
end
if @is_teacher
@is_new = true
@is_last_a = false
else
@is_new = false
end
#@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
@is_last_a = @work.student_works_scores.empty?
@new_score = StudentWorksScore.new
if params[:score]
@new_score.score = params[:score].to_i == -1 ? nil : params[:score]
end
@new_score.comment = params[:new_form][:user_message] if params[:new_form] && params[:new_form][:user_message] && params[:new_form][:user_message] != ""
@new_score.user_id = User.current.id
@new_score.student_work_id = @work.id
if User.current.admin?
@new_score.reviewer_role = 1
else
role = User.current.members.where("course_id = ?",@course.id).first.roles.first.name
@new_score.reviewer_role = get_role_by_name(role)
end
@is_new = true
end
@ -669,15 +657,20 @@ class StudentWorkController < ApplicationController
when 1 #教师评分:最后一个教师评分为最终评分
@work.teacher_score = @new_score.score
when 2 #教辅评分 教辅评分显示平均分
@work.teaching_asistant_score = @work.student_works_scores.where(:reviewer_role => 2).average(:score).try(:round, 2).to_f
#@work.teaching_asistant_score = @work.student_works_scores.where(:reviewer_role => 2).average(:score).try(:round, 2).to_f
ts_score = StudentWorksScore.find_by_sql("SELECT AVG(score) AS score FROM (SELECT * FROM (SELECT * FROM student_works_scores WHERE student_work_id = #{@work.id} AND reviewer_role = 2 AND score IS NOT NULL ORDER BY created_at DESC) AS t GROUP BY user_id) AS a")
@work.teaching_asistant_score = ts_score.first.score.nil? ? nil : ts_score.first.score.try(:round, 2).to_f
when 3 #学生评分 学生评分显示平均分
@work.student_score = @work.student_works_scores.where(:reviewer_role => 3).average(:score).try(:round, 2).to_f
#@work.student_score = @work.student_works_scores.where(:reviewer_role => 3).average(:score).try(:round, 2).to_f
stu_score = StudentWorksScore.find_by_sql("SELECT AVG(score) AS score FROM (SELECT * FROM (SELECT * FROM student_works_scores WHERE student_work_id = #{@work.id} AND reviewer_role = 3 ORDER BY created_at DESC) AS t GROUP BY user_id) AS a")
@work.student_score = stu_score.first.score.try(:round, 2).to_f
end
@homework.update_attributes(:updated_at => Time.now)
update_course_activity(@homework.class,@homework.id)
update_user_activity(@homework.class,@homework.id)
update_org_activity(@homework.class,@homework.id)
if @work.save
@work = @homework.student_works.select("student_works.*,student_works.work_score as score").where(:id => @work.id).first
respond_to do |format|
format.js
end
@ -710,6 +703,14 @@ class StudentWorkController < ApplicationController
end
end
#提交未评分的评语
def add_comments_to_work
@work = StudentWork.find params[:id]
respond_to do |format|
format.js
end
end
#为作品点赞
def praise_student_work
pt = PraiseTread.new

View File

@ -140,8 +140,8 @@
<div class="cl"></div>
<% if activity.student_works.count != 0 %>
<% sw_id = "("+activity.student_works.map{|sw| sw.id}.join(",")+")" %>
<% student_work_scores = StudentWorksScore.find_by_sql("select max(created_at) as created_at, student_work_id, user_id from student_works_scores where student_work_id in #{sw_id} group by student_work_id order by max(created_at) desc") %>
<%# student_work_scores = StudentWorksScore.where("student_work_id in #{sw_id}").reorder("created_at desc") %>
<%# student_work_scores = StudentWorksScore.find_by_sql("select max(created_at) as created_at, student_work_id, user_id from student_works_scores where student_work_id in #{sw_id} group by student_work_id order by max(created_at) desc") %>
<% student_work_scores = StudentWorksScore.where("student_work_id in #{sw_id} and score is not null").reorder("created_at desc") %>
<% unless student_work_scores.empty? %>
<% last_score = student_work_scores.first %>
<div>

View File

@ -7,7 +7,7 @@
<p id="hint_message_<%=work.id %>" style="margin-left: 65px;"></p>
<li >
<span class="tit_fb mt2"> 评分:</span>
<input type="number" name="score" id="score_<%= work.id%>" value="<%= score.nil? ? -1 : score.score%>" min="-1" max="100" size="4" data-units="dollars" />
<input type="number" name="score" id="score_<%= work.id%>" value="<%= (score.nil? || score.score.nil?) ? -1 : score.score%>" min="-1" max="100" size="4" data-units="dollars" />
<span class="ml5">分</span>
<span id="score_notice_span_<%= work.id%>" class="ml5 c_red" style="display: none;">未评分</span>
<div class="cl"></div></li>
@ -44,19 +44,21 @@
if($.trim($('#score_comment_'+id).val()) == "" && parseFloat($("#score_"+id).val()) == -1 && $("#attachments_fields"+id).children().length == 0){
$("#none_notice_"+id).show();
} else if(parseFloat($("#score_"+id).val()) == -1) {
$('#ajax-modal').html('<%= escape_javascript(render :partial => 'student_work/no_teacher_score_notice') %>');
showModal('ajax-modal', '500px');
$('#ajax-modal').siblings().remove();
$('#ajax-modal').before("<span style='float: right;cursor:pointer;'>" +
"<a href='javascript:' onclick='clickCanel();'><img src='/images/bid/close.png' width='26px' height='26px' /></a></span>");
$('#ajax-modal').parent().css("top","30%").css("left","30%").css("position","fixed").css("border","3px solid #269ac9");
$.ajax({
type: "GET",
url: "/student_work/"+id+"/add_comments_to_work",
data: 'text',
success: function (data) {
}
});
}
else {
$("#work_submit_" + id).parent().parent().submit();
}
<% end %>
}
function submit_teacher_score(){
$("#work_submit_<%=work.id %>").parent().parent().submit();
function submit_teacher_score(id){
$("#work_submit_"+id).parent().parent().submit();
hideModal();
}
</script>

View File

@ -70,11 +70,11 @@
<% end %>
<% unless student_work.student_score.nil?%>
<span class="linkBlue">
(<%= student_work.student_works_scores.where(:reviewer_role => 3).count%>)
(<%= student_work.student_works_scores.where(:reviewer_role => 3).group_by(&:user_id).count%>)
</span>
<div class="infoNi none">
现共有
<span class="c_red">&nbsp;<%= student_work.student_works_scores.where(:reviewer_role => 3).count%>&nbsp;</span>
<span class="c_red">&nbsp;<%= student_work.student_works_scores.where(:reviewer_role => 3).group_by(&:user_id).count%>&nbsp;</span>
名学生进行了匿评,平均分为
<span class="c_red">&nbsp;<%= format("%.1f",student_work.student_score)%>&nbsp;</span>分。
</div>

View File

@ -4,7 +4,7 @@
当前作品未进行评分,是否确定提交?
</p>
<div class="ni_btn">
<a href="javascript:" class="tijiao" onclick="submit_teacher_score();" style="margin-bottom: 20px;" >
<a href="javascript:" class="tijiao" onclick="submit_teacher_score(<%=work.id %>);" style="margin-bottom: 20px;" >
确&nbsp;&nbsp;定
</a>
<a href="javascript:" class="tijiao" onclick="clickCanel();" style="margin-bottom: 20px;">

View File

@ -6,10 +6,12 @@
<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>
<% unless score.score.nil? %>
<span class="ml20 fl">评分:</span>
<a href="javascript:void(0);" class="c_orange fl" >
<%= score.score%>分
</a>
<% end %>
<a href="javascript:void(0);" class="fr linkBlue mr5" onclick="$('#add_score_reply_<%= score.id%>').slideToggle();">回复</a>
<span class=" fr c_grey mr20">
<%=format_time score.updated_at %>

View File

@ -0,0 +1,6 @@
$('#ajax-modal').html('<%= escape_javascript(render :partial => 'student_work/no_teacher_score_notice', :locals => {:work => @work}) %>');
showModal('ajax-modal', '500px');
$('#ajax-modal').siblings().remove();
$('#ajax-modal').before("<span style='float: right;cursor:pointer;'>" +
"<a href='javascript:' onclick='clickCanel();'><img src='/images/bid/close.png' width='26px' height='26px' /></a></span>");
$('#ajax-modal').parent().css("top","30%").css("left","30%").css("position","fixed").css("border","3px solid #269ac9");

View File

@ -140,7 +140,8 @@
<div class="cl"></div>
<% if activity.student_works.count != 0 %>
<% sw_id = "("+activity.student_works.map{|sw| sw.id}.join(",")+")" %>
<% student_work_scores = StudentWorksScore.find_by_sql("select max(created_at) as created_at, student_work_id, user_id from student_works_scores where student_work_id in #{sw_id} group by student_work_id order by max(created_at) desc") %>
<%# student_work_scores = StudentWorksScore.find_by_sql("select max(created_at) as created_at, student_work_id, user_id from student_works_scores where student_work_id in #{sw_id} group by student_work_id order by max(created_at) desc") %>
<% student_work_scores = StudentWorksScore.where("student_work_id in #{sw_id} and score is not null").reorder("created_at desc") %>
<% unless student_work_scores.empty? %>
<% last_score = student_work_scores.first %>
<div>

View File

@ -144,8 +144,8 @@
<div class="cl"></div>
<% if homework_common.student_works.count != 0 %>
<% sw_id = "("+homework_common.student_works.map{|sw| sw.id}.join(",")+")" %>
<% student_work_scores = StudentWorksScore.find_by_sql("select max(created_at) as created_at, student_work_id, user_id from student_works_scores where student_work_id in #{sw_id} group by student_work_id order by max(created_at) desc") %>
<%# student_work_scores = StudentWorksScore.where("student_work_id in #{sw_id}").reorder("created_at desc") %>
<%# student_work_scores = StudentWorksScore.find_by_sql("select max(created_at) as created_at, student_work_id, user_id from student_works_scores where student_work_id in #{sw_id} group by student_work_id order by max(created_at) desc") %>
<% student_work_scores = StudentWorksScore.where("student_work_id in #{sw_id} and score is not null").reorder("created_at desc") %>
<% unless student_work_scores.empty? %>
<% last_score = student_work_scores.first %>
<div>

View File

@ -266,6 +266,7 @@ RedmineApp::Application.routes.draw do
post 'add_score'
post 'revise_attachment'
get 'retry_work'
get 'add_comments_to_work'
get 'praise_student_work'
get 'forbidden_anonymous_comment'
end