diff --git a/app/controllers/homework_common_controller.rb b/app/controllers/homework_common_controller.rb
index 71782ee28..293346365 100644
--- a/app/controllers/homework_common_controller.rb
+++ b/app/controllers/homework_common_controller.rb
@@ -190,11 +190,11 @@ class HomeworkCommonController < ApplicationController
#开启匿评
#statue 1:启动成功,2:启动失败,作业总数大于等于2份时才能启动匿评,3:已开启匿评,请务重复开启,4:没有开启匿评的权限
def start_anonymous_comment
- @statue =4 and return unless User.current.admin? || User.current.allowed_to?(:as_teacher,@course)
+ @statue = 4 and return unless User.current.admin? || User.current.allowed_to?(:as_teacher,@course)
@statue = 5 and return if Time.parse(@homework.end_time.to_s).strftime("%Y-%m-%d") >= Time.now.strftime("%Y-%m-%d")
if @homework_detail_manual.comment_status == 1
student_works = @homework.student_works
- if student_works && student_works.size >=2
+ if student_works && student_works.size >= 2
student_works.each_with_index do |work, index|
user = work.user
n = @homework_detail_manual.evaluation_num
@@ -218,11 +218,11 @@ class HomeworkCommonController < ApplicationController
#关闭匿评
def stop_anonymous_comment
@homework_detail_manual.update_column('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.absence_penalty = absence_penalty_count > 0 ? absence_penalty_count : 0
student_work.save
end
diff --git a/app/controllers/student_work_controller.rb b/app/controllers/student_work_controller.rb
index 0de5184c7..474fb81bc 100644
--- a/app/controllers/student_work_controller.rb
+++ b/app/controllers/student_work_controller.rb
@@ -180,15 +180,15 @@ class StudentWorkController < ApplicationController
student_work.homework_common_id = @homework.id
student_work.user_id = User.current.id
student_work.save_attachments(params[:attachments])
+ render_attachment_warning_if_needed(student_work)
+ #提交作品时,计算是否迟交
if Time.parse(@homework.end_time.to_s).strftime("%Y-%m-%d") < Time.parse(Time.now.to_s).strftime("%Y-%m-%d")
- student_work.late_penalty = @homework.late_penalty
- else
+ student_work.late_penalty = 1
+ else
student_work.late_penalty = 0
end
- render_attachment_warning_if_needed(student_work)
if student_work.save
-
respond_to do |format|
format.html {
flash[:notice] = l(:notice_successful_create)
diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb
index 05e828aae..4796d0c0c 100644
--- a/app/controllers/users_controller.rb
+++ b/app/controllers/users_controller.rb
@@ -419,6 +419,14 @@ class UsersController < ApplicationController
homework = HomeworkCommon.find(params[:homework])
student_work = StudentWork.where(homework_common_id: homework.id, user_id: User.current.id).first
if student_work
+
+ #提交作品时,计算是否迟交
+ if Time.parse(homework.end_time.to_s).strftime("%Y-%m-%d") < Time.parse(Time.now.to_s).strftime("%Y-%m-%d")
+ student_work.late_penalty = 1
+ else
+ student_work.late_penalty = 0
+ end
+
student_work.save
flash[:notice] = l(:notice_successful_create)
redirect_to student_work_index_url(:homework => params[:homework])
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb
index a1663c76b..f085032c3 100644
--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -2304,20 +2304,19 @@ module ApplicationHelper
# else
# link = "启动匿评".html_safe
# end
-
if Time.parse(homework.end_time.to_s).strftime("%Y-%m-%d") >= Time.now.strftime("%Y-%m-%d")
- link = "启动匿评".html_safe
+ link = link_to "启动匿评","javascript:void(0)", :class => "postOptionLink", :title => "作业截止日期之前不可以启动匿评"
elsif homework.student_works.count >= 2 #作业份数大于2
case homework.homework_detail_manual.comment_status
- when 1
- link = link_to '启动匿评', alert_anonymous_comment_homework_common_path(homework), id: "#{homework.id}_start_anonymous_comment", remote: true, disable_with: '加载中...',:class => 'fr mr10 work_edit'
- when 2
- link = link_to '关闭匿评', alert_anonymous_comment_homework_common_path(homework), id: "#{homework.id}_stop_anonymous_comment", remote: true,:class => 'fr mr10 work_edit'
- when 3
- link = "匿评结束".html_safe
+ when 1
+ link = link_to '启动匿评', alert_anonymous_comment_homework_common_path(homework), id: "#{homework.id}_start_anonymous_comment", remote: true, disable_with: '加载中...',:class => 'postOptionLink'
+ when 2
+ link = link_to '关闭匿评', alert_anonymous_comment_homework_common_path(homework), id: "#{homework.id}_stop_anonymous_comment", remote: true,:class => 'postOptionLink'
+ when 3
+ link = link_to "匿评结束","javascript:void(0)", :class => "postOptionLink", :title => "匿评结束"
end
else
- link = "启动匿评".html_safe
+ link = link = link_to "启动匿评","javascript:void(0)", :class => "postOptionLink", :title => "学生提交作业数大于2时才可以启动匿评"
end
link
end
diff --git a/app/views/homework_common/alert_anonymous_comment.js.erb b/app/views/homework_common/alert_anonymous_comment.js.erb
index 2b3248dc2..375b333f1 100644
--- a/app/views/homework_common/alert_anonymous_comment.js.erb
+++ b/app/views/homework_common/alert_anonymous_comment.js.erb
@@ -3,5 +3,4 @@ showModal('ajax-modal', '500px');
$('#ajax-modal').siblings().remove();
$('#ajax-modal').before("" +
"");
-$('#ajax-modal').parent().css("top","").css("left","");
-$('#ajax-modal').parent().addClass("anonymos");
\ No newline at end of file
+$('#ajax-modal').parent().css("top","30%").css("left","30%");
\ No newline at end of file
diff --git a/app/views/homework_common/start_anonymous_comment.js.erb b/app/views/homework_common/start_anonymous_comment.js.erb
index 5f27a5b82..b0424bf7a 100644
--- a/app/views/homework_common/start_anonymous_comment.js.erb
+++ b/app/views/homework_common/start_anonymous_comment.js.erb
@@ -1,6 +1,6 @@
<% if @statue == 1%>
alert('启动成功');
-$("#<%= @homework.id %>_start_anonymous_comment").replaceWith('<%= escape_javascript(link_to "关闭匿评", alert_anonymous_comment_homework_common_path(@homework), remote: true, id:"#{@homework.id}_stop_anonymous_comment",:class => "fr mr10 work_edit")%>');
+$("#<%= @homework.id %>_start_anonymous_comment").replaceWith('<%= escape_javascript(link_to "关闭匿评", alert_anonymous_comment_homework_common_path(@homework), remote: true, id:"#{@homework.id}_stop_anonymous_comment",:class => "postOptionLink")%>');
<% elsif @statue == 2 %>
alert('启动失败\n作业总数大于等于2份时才能启动匿评');
<% elsif @statue == 3%>
diff --git a/app/views/student_work/new.html.erb b/app/views/student_work/new.html.erb
index c755014d1..f9b242443 100644
--- a/app/views/student_work/new.html.erb
+++ b/app/views/student_work/new.html.erb
@@ -12,9 +12,6 @@
});
<% end%>
- //匿评弹框取消按钮
- function clickCanel(){hideModal("#popbox02");}
-
//快速创建项目的弹框
function new_project(){
$('#ajax-modal').html('<%= escape_javascript(render :partial => 'student_work/new_project') %>');
diff --git a/app/views/users/_user_homework_list.html.erb b/app/views/users/_user_homework_list.html.erb
index 37afc3384..6a9ffb727 100644
--- a/app/views/users/_user_homework_list.html.erb
+++ b/app/views/users/_user_homework_list.html.erb
@@ -48,7 +48,7 @@
<%= link_to(l(:label_bid_respond_delete), homework_common_path(homework_common),:method => 'delete', :confirm => l(:text_are_you_sure), :class => "postOptionLink") %>