diff --git a/app/controllers/student_work_controller.rb b/app/controllers/student_work_controller.rb index c2a76fb4f..b65fc2743 100644 --- a/app/controllers/student_work_controller.rb +++ b/app/controllers/student_work_controller.rb @@ -3,11 +3,11 @@ class StudentWorkController < ApplicationController include StudentWorkHelper require 'bigdecimal' require "base64" - before_filter :find_homework, :only => [:new, :index, :create, :student_work_absence_penalty, :absence_penalty_list, :evaluation_list, :program_test] + before_filter :find_homework, :only => [:new, :index, :create, :student_work_absence_penalty, :absence_penalty_list, :evaluation_list, :program_test,:set_score_rule] before_filter :find_work, :only => [:edit, :update, :show, :destroy, :add_score, :praise_student_work] before_filter :member_of_course, :only => [:index, :new, :create, :show, :add_score, :praise_student_work] before_filter :author_of_work, :only => [:edit, :update, :destroy] - before_filter :teacher_of_course, :only => [:student_work_absence_penalty, :absence_penalty_list, :evaluation_list] + before_filter :teacher_of_course, :only => [:student_work_absence_penalty, :absence_penalty_list, :evaluation_list, :set_score_rule] ### def program_test @@ -362,6 +362,50 @@ class StudentWorkController < ApplicationController end end + #设置评分规则 + def set_score_rule + homework_detail_manual = @homework.homework_detail_manual + homework_detail_programing = @homework.homework_detail_programing + + unless @homework.late_penalty.to_s == params[:late_penalty].to_s + @homework.late_penalty = params[:late_penalty] + @homework.student_works.where("created_at > '#{@homework.end_time} 23:59:59'").each do |student_work| + student_work.late_penalty = @homework.late_penalty + student_work.save + end + end + + unless homework_detail_manual.absence_penalty.to_s == params[:absence_penalty].to_s + homework_detail_manual.absence_penalty = params[:absence_penalty] + if homework_detail_manual.comment_status == 3 #当前作业处于匿评结束状态,修改缺评扣分才会修改每个作品应扣分的值 + work_ids = "(" + @homework.student_works.map(&:id).join(",") + ")" + @homework.student_works.each do |student_work| + absence_penalty_count = student_work.user.student_works_evaluation_distributions.where("student_work_id IN #{work_ids}").count - student_work.user.student_works_scores.where("student_work_id IN #{work_ids}").count + student_work.absence_penalty = absence_penalty_count > 0 ? absence_penalty_count * @homework_detail_manual.absence_penalty : 0 + student_work.save + end + end + end + + teacher_priority = params[:teacher_priority] ? 1 : 0 + if homework_detail_manual.ta_proportion.to_s != params[:ta_proportion].to_s || @homework.teacher_priority.to_s != teacher_priority.to_s || (homework_detail_programing && homework_detail_programing.ta_proportion.to_s != params[:sy_proportion].to_s) + homework_detail_manual.ta_proportion = params[:ta_proportion] + homework_detail_programing.ta_proportion = params[:sy_proportion] if homework_detail_programing + @homework.teacher_priority = teacher_priority + @homework.student_works.each do |student_work| + set_final_score @homework,student_work + student_work.save + end + end + + @homework.save + homework_detail_manual.save if homework_detail_manual + homework_detail_programing.save if homework_detail_programing + respond_to do |format| + format.html{redirect_to student_work_index_url(:homework => @homework.id)} + end + end + private #获取作业 def find_homework @@ -392,7 +436,7 @@ class StudentWorkController < ApplicationController end def teacher_of_course - render_403 unless User.current.allowed_to?(:as_teacher,@course) + render_403 unless User.current.allowed_to?(:as_teacher,@course) || User.current.admin? end #根据条件过滤作业结果 diff --git a/app/helpers/student_work_helper.rb b/app/helpers/student_work_helper.rb index aa359e273..834b8dd61 100644 --- a/app/helpers/student_work_helper.rb +++ b/app/helpers/student_work_helper.rb @@ -99,4 +99,31 @@ module StudentWorkHelper end result end + + #教辅评分比例下拉框 + def ta_proportion_option + type = [] + i = 0 + while i <= 100 + option = [] + option << i.to_s + "%" + option << i.to_f / 100 + type << option + i += 10 + end + type + end + + def ta_proportion_option_to num + type = [] + i = 0 + while i <= num + option = [] + option << i.to_s + "%" + option << i.to_f / 100 + type << option + i += 10 + end + type + end end \ No newline at end of file diff --git a/app/views/student_work/_set_score_rule.html.erb b/app/views/student_work/_set_score_rule.html.erb new file mode 100644 index 000000000..97deafde8 --- /dev/null +++ b/app/views/student_work/_set_score_rule.html.erb @@ -0,0 +1,63 @@ +<%= form_for('new_form',:url => {:controller => 'student_work',:action => 'set_score_rule',:homework => homework.id},:method => "post") do |f|%> +
+ 评分设置 +
+ 迟交扣分 + +
+
+ 缺评扣分 + +
+ + <% if homework.homework_type == 2%> +
+ 系统评分 + <%= select_tag :sy_proportion,options_for_select(ta_proportion_option), {:class => "markPercentage"} %> +
+ + + <% else%> + + <% end%> + +
+ 教辅评分 + <%= select_tag :ta_proportion,options_for_select(ta_proportion_option,homework.homework_detail_manual.ta_proportion), {:class => "markPercentage"} %> +
+
+ 学生匿评 + +
+
+ 教师优先 + /> + 教师评分为最终评分 +
+
+
+ 确定 +
+
+ 取消 +
+
+
+
+<% end%> diff --git a/app/views/student_work/index.html.erb b/app/views/student_work/index.html.erb index fcd70fe83..9dfebefbb 100644 --- a/app/views/student_work/index.html.erb +++ b/app/views/student_work/index.html.erb @@ -18,9 +18,16 @@ }); <% end%> -// $(function(){ -// $('.animated').autosize(); -// }); + //设置评分规则 + function set_score_rule(){ + $('#ajax-modal').html('<%= escape_javascript(render :partial => 'student_work/set_score_rule',:locals => {:homework => @homework}) %>'); + showModal('ajax-modal', '350px'); + $('#ajax-modal').siblings().remove(); + $('#ajax-modal').before("" + + ""); + $('#ajax-modal').parent().css("top","25%").css("left","35%").css("position","fixed"); + } +
@@ -65,7 +72,9 @@
  • <%= link_to("导出匿评情况", evaluation_list_student_work_index_path(:homework => @homework.id, :format => 'xls'),:class=>'hworkExport resourcesGrey') if @homework.homework_type == 1%>
  • -
  • 评分设置
  • +
  • + 评分设置 +
  • diff --git a/config/routes.rb b/config/routes.rb index 96b193862..756f744ae 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -121,6 +121,7 @@ RedmineApp::Application.routes.draw do get 'evaluation_list' # post 'set_program_score' post 'program_test' + post 'set_score_rule' end end diff --git a/public/javascripts/course.js b/public/javascripts/course.js index 2882ccdcc..43341658e 100644 --- a/public/javascripts/course.js +++ b/public/javascripts/course.js @@ -427,10 +427,10 @@ function regex_homework_name() } } -//处理迟交扣分 -function check_late_penalty() +//处理迟交、缺评扣分 +function check_late_penalty(id) { - var obj = $("input[name='late_penalty']"); + var obj = $("#" + id); var regex = /^\d+$/; if(regex.test(obj.val())) { @@ -499,11 +499,26 @@ $(function(){ $("#absence_penalty_notice").html(" "+ $("#absence_penalty").val() +" "); }); - $("#ta_proportion").change(function(){ - var ta_proportion = $("#ta_proportion").val(); - $("#student_proportion").val((100 - parseInt(ta_proportion * 100)) + "%"); - }); + //$("#ta_proportion").change(function(){ + // var ta_proportion = $("#ta_proportion").val(); + // $("#student_proportion").val((100 - parseInt(ta_proportion * 100)) + "%"); + //}); }); + +//生成select +function build_selector(max_num){ + var html = ""; + return html; +} + //第一次加载时,如果未开启匿评作业,隐藏显示匿评配置信息 $(function(){ if($("#homework_common_homework_type").attr("id") != null && $("#homework_common_homework_type").val() != 2) diff --git a/public/stylesheets/public.css b/public/stylesheets/public.css index 4c5261e02..2305fe0ff 100644 --- a/public/stylesheets/public.css +++ b/public/stylesheets/public.css @@ -497,9 +497,9 @@ a.uploadIcon {background:url(../images/resource_icon_list.png) 8px -60px no-repe .uploadKeyword {margin-bottom:10px; outline:none; border:1px solid #e6e6e6; height:30px; width:280px;} /*评分设置弹窗*/ -.markPopup {width:290px; height:auto; border:3px solid #269ac9; padding:0px 0px 15px 15px; background-color:#ffffff; z-index:1000;} -.markInput {margin-bottom:10px; outline:none; border:1px solid #e6e6e6; height:30px; width:95px; color:#3d3c3c;} -.markPercentage {margin:10px 0; border:1px solid #e6e6e6; width:60px; height:30px; outline:none; font-size:12px; color:#3d3c3c;} +.markPopup {width:290px; height:auto; padding:5px 0px 15px 15px; background-color:#ffffff; z-index:1000;} +.markInput {margin-bottom:10px; outline:none; border:1px solid #e6e6e6; height:30px; width:140px; color:#3d3c3c;} +.markPercentage {margin:10px 0; border:1px solid #e6e6e6; width:70px; height:30px; outline:none; font-size:12px; color:#3d3c3c;} /*新个人主页框架css*/