From e73517cfd0d6c4a74ef5f10544dff593a2def975 Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Fri, 10 Jul 2015 15:34:55 +0800 Subject: [PATCH] =?UTF-8?q?=E6=89=A3=E5=88=86=E8=A7=84=E5=88=99=E6=98=BE?= =?UTF-8?q?=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/helpers/homework_common_helper.rb | 34 ++++++++++++++++++++++-- app/views/homework_common/index.html.erb | 9 ++----- config/locales/zh.yml | 1 + 3 files changed, 35 insertions(+), 9 deletions(-) diff --git a/app/helpers/homework_common_helper.rb b/app/helpers/homework_common_helper.rb index 465df62da..a2ff6dbab 100644 --- a/app/helpers/homework_common_helper.rb +++ b/app/helpers/homework_common_helper.rb @@ -3,7 +3,8 @@ module HomeworkCommonHelper #迟交扣分下拉框 def late_penalty_option type = [] - for i in (0..5) + type << l(:lable_unset) + for i in (1..5) option = [] option << i option << i @@ -29,7 +30,8 @@ module HomeworkCommonHelper #缺评扣分 def absence_penalty_option type = [] - i = 0 + i = 1 + type << l(:lable_unset) while i <= 5 option = [] option << i @@ -50,4 +52,32 @@ module HomeworkCommonHelper end link end + + #评分规则显示 + def scoring_rules late_penalty,homework_id,is_teacher,absence_penalty=nil + if absence_penalty + if late_penalty.to_i == 0 && absence_penalty.to_i == 0 + notice = "尚未设置评分规则" + if is_teacher + notice += ",请 " + link_to("设置",edit_homework_common_path(homework_id),:class => "c_green") + end + elsif late_penalty.to_i != 0 && absence_penalty.to_i == 0 + notice = "迟交扣#{late_penalty}分,缺评扣分未设置" + elsif late_penalty.to_i == 0 && absence_penalty.to_i != 0 + notice = "迟交扣分未设置,缺评一个作品扣#{absence_penalty}分" + elsif late_penalty.to_i != 0 && absence_penalty.to_i != 0 + notice = "迟交扣#{late_penalty}分,缺评一个作品扣#{absence_penalty}分" + end + else + if late_penalty.to_i == 0 + notice = "尚未设置评分规则" + if is_teacher + notice += ",请 " + link_to("设置",edit_homework_common_path(homework_id),:class => "c_green") + end + else + notice = "迟交扣#{late_penalty}分" + end + end + notice.html_safe + end end \ No newline at end of file diff --git a/app/views/homework_common/index.html.erb b/app/views/homework_common/index.html.erb index 870edbfe4..db7dad9c7 100644 --- a/app/views/homework_common/index.html.erb +++ b/app/views/homework_common/index.html.erb @@ -61,15 +61,10 @@