From 5baf467d13e9fe5d18345bdf70a5e7be9351f1a2 Mon Sep 17 00:00:00 2001 From: cxt Date: Tue, 10 May 2016 15:26:08 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BD=9C=E5=93=81=E8=AF=84=E5=88=86=E4=B8=8D?= =?UTF-8?q?=E8=A6=86=E7=9B=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/student_work_controller.rb | 56 +++++++++++++++------- app/helpers/student_work_helper.rb | 2 +- app/views/student_work/_add_score.html.erb | 2 +- app/views/student_work/add_score.js.erb | 6 +-- public/stylesheets/courses.css | 8 ++-- public/stylesheets/new_user.css | 4 +- 6 files changed, 50 insertions(+), 28 deletions(-) diff --git a/app/controllers/student_work_controller.rb b/app/controllers/student_work_controller.rb index e80b90d7b..c0e54df70 100644 --- a/app/controllers/student_work_controller.rb +++ b/app/controllers/student_work_controller.rb @@ -614,38 +614,60 @@ class StudentWorkController < ApplicationController render_403 and return unless @is_teacher || @homework.homework_detail_manual.comment_status == 2 @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] + @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? - @score.reviewer_role = 1 + @new_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) + @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 - @is_new = false + + #@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? - @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 + @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? - @score.reviewer_role = 1 + @new_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) + @new_score.reviewer_role = get_role_by_name(role) end @is_new = true end - @score.save_attachments(params[:attachments]) - render_attachment_warning_if_needed(@score) + @new_score.save_attachments(params[:attachments]) + render_attachment_warning_if_needed(@new_score) - if @score.save - case @score.reviewer_role + if @new_score.save + case @new_score.reviewer_role when 1 #教师评分:最后一个教师评分为最终评分 - @work.teacher_score = @score.score + @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 when 3 #学生评分 学生评分显示平均分 diff --git a/app/helpers/student_work_helper.rb b/app/helpers/student_work_helper.rb index 4e11e153e..74788751b 100644 --- a/app/helpers/student_work_helper.rb +++ b/app/helpers/student_work_helper.rb @@ -23,7 +23,7 @@ module StudentWorkHelper #获取指定用户对某一作业的评分结果 def student_work_score work,user - StudentWorksScore.where(:user_id => user.id,:student_work_id => work.id).first + StudentWorksScore.where(:user_id => user.id,:student_work_id => work.id).last end #获取指定评分的角色 diff --git a/app/views/student_work/_add_score.html.erb b/app/views/student_work/_add_score.html.erb index 29fd8b63a..74f81a30b 100644 --- a/app/views/student_work/_add_score.html.erb +++ b/app/views/student_work/_add_score.html.erb @@ -45,7 +45,7 @@ $("#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', '450px'); + showModal('ajax-modal', '500px'); $('#ajax-modal').siblings().remove(); $('#ajax-modal').before("" + ""); diff --git a/app/views/student_work/add_score.js.erb b/app/views/student_work/add_score.js.erb index 762aa4a8a..d3cb963f6 100644 --- a/app/views/student_work/add_score.js.erb +++ b/app/views/student_work/add_score.js.erb @@ -1,10 +1,10 @@ -$("#add_student_score_<%= @work.id%>").html("<%= escape_javascript(render :partial => 'add_score',:locals => {:work => @work,:score => @score}) %>"); +$("#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("
<%= escape_javascript(render :partial => 'student_work_score', :locals => {:score => @score,:is_last => @is_last_a}) %>
"); + $("#score_list_<%= @work.id%>").prepend("
<%= escape_javascript(render :partial => 'student_work_score', :locals => {:score => @new_score,:is_last => @is_last_a}) %>
"); <% else %> - $("#work_score_<%= @score.id%>").html("<%= escape_javascript(render :partial => 'student_work_score', :locals => {:score => @score,:is_last => @is_last}) %>"); + $("#work_score_<%= @score.id%>").html("<%= escape_javascript(render :partial => 'student_work_score', :locals => {:score => @new_score,:is_last => @is_last}) %>"); <% end%> $("#score_list_<%= @work.id%>").removeAttr("style"); diff --git a/public/stylesheets/courses.css b/public/stylesheets/courses.css index b81a7a7b6..2bc77b8ff 100644 --- a/public/stylesheets/courses.css +++ b/public/stylesheets/courses.css @@ -434,8 +434,8 @@ span.author { font-size: 0.9em; color: #888; } .bo{height:26px; border:1px solid #CCC; padding-left:5px; background:#fff;width:470px; } .bo02{height:26px; border:1px solid #CCC; padding-left:5px; background:#fff;width:480px; margin-left:2px; color: #999; } .hwork_txt{ width:560px; padding-left:5px; background:#fff;} -a.tijiao{ height:28px; display:block; width:80px; color:#fff; background:#15bccf; text-align:center; padding-top:4px; float:left; margin-right:10px;} -a:hover.tijiao{ background:#0f99a9;} +a.tijiao{ height:28px; display:block; width:80px; color:#fff; background:#269ac9; text-align:center; padding-top:4px; float:left; margin-right:10px;} +a:hover.tijiao{ background:#297fb8;} .members_left{ float:left; width:410px; margin-right:20px; text-align:center;} .members_left{} .members_left ul li{ height:30px; border-bottom:1px solid #E4E4E4; width:410px; padding-top:10px; } @@ -497,8 +497,8 @@ a.xls{ margin-left:5px; color:#136b3b;} .ni_con p{ color:#808181; } .ni_con a:hover{ text-decoration:none;} .ni_btn{ width:190px; margin:15px auto; line-height:1.9;} -a.tijiao{ height:28px; display:block; width:80px; color:#fff; background:#15bccf; text-align:center; padding-top:4px; float:left; margin-right:15px;} -a:hover.tijiao{ background:#0f99a9;} +a.tijiao{ height:28px; display:block; width:80px; color:#fff; background:#269ac9; text-align:center; padding-top:4px; float:left; margin-right:15px;} +a:hover.tijiao{ background:#297fb8;} .c_pink{ color:#e65d5e;} .ni_con_work { width:300px; margin:25px 20px;} .ni_con_work p{ color:#808181; } diff --git a/public/stylesheets/new_user.css b/public/stylesheets/new_user.css index be6cea109..20bc59a0e 100644 --- a/public/stylesheets/new_user.css +++ b/public/stylesheets/new_user.css @@ -1222,8 +1222,8 @@ blockquote { .bo{height:26px; border:1px solid #CCC; padding-left:5px; background:#fff;width:470px; } .bo02{height:26px; border:1px solid #CCC; padding-left:5px; background:#fff;width:480px; margin-left:2px; color: #999; } .hwork_txt{ width:560px; padding-left:5px; background:#fff;} -a.tijiao{ height:28px; display:block; width:80px; color:#fff; background:#15bccf; text-align:center; padding-top:4px; float:left; margin-right:10px;} -a:hover.tijiao{ background:#0f99a9;} +a.tijiao{ height:28px; display:block; width:80px; color:#fff; background:#269ac9; text-align:center; padding-top:4px; float:left; margin-right:10px;} +a:hover.tijiao{ background:#297fb8;} .members_left{ float:left; width:410px; margin-right:20px; text-align:center;} .members_left{} .members_left ul li{ height:30px; border-bottom:1px solid #E4E4E4; width:410px; padding-top:10px; }