diff --git a/app/controllers/attachments_controller.rb b/app/controllers/attachments_controller.rb
index c8b6a6fda..c310087f7 100644
--- a/app/controllers/attachments_controller.rb
+++ b/app/controllers/attachments_controller.rb
@@ -191,9 +191,19 @@ class AttachmentsController < ApplicationController
if !@attachment.container.nil? &&
(@attachment.container.is_a?(Course) || ((@attachment.container.has_attribute?(:course) || @attachment.container.has_attribute?(:course_id) ) &&
@attachment.container.course ) || ((@attachment.container.has_attribute?(:board) || @attachment.container.has_attribute?(:board_id)) &&
- @attachment.container.board && @attachment.container.board.course ) )
+ @attachment.container.board && @attachment.container.board.course ) || @attachment.container.is_a?(StudentWorksScore) || @attachment.container.is_a?(HomeworkCommon) ||
+ @attachment.container.is_a?(StudentWork))
if @attachment.container.is_a?(News)
format.html { redirect_to_referer_or news_path(@attachment.container) }
+ elsif @attachment.container.is_a?(StudentWorksScore)
+ @is_destroy = true #根据ID删除页面对应的数据,js刷新页面
+ format.js
+ elsif @attachment.container.is_a?(HomeworkCommon)
+ @is_destroy = true #根据ID删除页面对应的数据,js刷新页面
+ format.js
+ elsif @attachment.container.is_a?(StudentWork)
+ @is_destroy = true #根据ID删除页面对应的数据,js刷新页面
+ format.js
elsif @attachment.container.is_a?(Message)
format.html { redirect_to_referer_or new_board_message_path(@attachment.container) }
elsif @course.nil?
@@ -431,7 +441,7 @@ private
@attachment.container.board.course)
@course = @attachment.container.board.course
else
- unless @attachment.container_type == 'Bid' || @attachment.container_type == 'HomeworkAttach' || @attachment.container_type == 'Memo' || @attachment.container_type == 'Softapplication' || @attachment.container_type == 'PhoneAppVersion' || @attachment.container_type == 'StudentWorksScore'|| @attachment.container_type == 'StudentWorks'
+ unless @attachment.container_type == 'Bid' || @attachment.container_type == 'HomeworkAttach' || @attachment.container_type == 'Memo' || @attachment.container_type == 'Softapplication' || @attachment.container_type == 'PhoneAppVersion' || @attachment.container_type == 'StudentWorksScore'|| @attachment.container_type == 'StudentWork'
@project = @attachment.project
end
end
diff --git a/app/controllers/homework_attach_controller.rb b/app/controllers/homework_attach_controller.rb
index f6b044c63..5dd5363b9 100644
--- a/app/controllers/homework_attach_controller.rb
+++ b/app/controllers/homework_attach_controller.rb
@@ -334,9 +334,8 @@ class HomeworkAttachController < ApplicationController
@homework.name = name
@homework.description = description
@homework.project_id = params[:project_id] || 0
- if params[:attachments]
- @homework.save_attachments(params[:attachments])
- end
+ @homework.save_attachments(params[:attachments])
+ render_attachment_warning_if_needed(@homework)
if @homework.save
respond_to do |format|
format.html { redirect_to course_for_bid_url @homework.bid }
diff --git a/app/controllers/homework_common_controller.rb b/app/controllers/homework_common_controller.rb
index 58c959512..c301ae0f9 100644
--- a/app/controllers/homework_common_controller.rb
+++ b/app/controllers/homework_common_controller.rb
@@ -5,7 +5,7 @@ class HomeworkCommonController < ApplicationController
before_filter :teacher_of_course, :only => [:new, :create, :edit, :update, :destroy, :start_anonymous_comment, :stop_anonymous_comment, :alert_anonymous_comment]
def index
- homeworks = @course.homework_commons
+ homeworks = @course.homework_commons.order("created_at desc")
@is_teacher = User.current.logged? && (User.current.admin? || User.current.allowed_to?(:as_teacher,@course))
@is_student = User.current.logged? && (User.current.admin? || (User.current.member_of_course?(@course) && !@is_teacher))
@homeworks = paginateHelper homeworks,20
@@ -17,14 +17,14 @@ class HomeworkCommonController < ApplicationController
def new
@homework = HomeworkCommon.new
@homework.safe_attributes = params[:homework_common]
- @homework.late_penalty = 2
+ @homework.late_penalty = 0
@homework.end_time = (Time.now + 3600 * 24).strftime('%Y-%m-%d')
@homework.publish_time = Time.now.strftime('%Y-%m-%d')
#匿评作业相关属性
@homework_detail_manual = HomeworkDetailManual.new
@homework_detail_manual.ta_proportion = 0.6
- @homework_detail_manual.absence_penalty = 2
+ @homework_detail_manual.absence_penalty = 0
@homework_detail_manual.evaluation_num = 3
@homework_detail_manual.evaluation_start = Time.now.strftime('%Y-%m-%d')
@homework_detail_manual.evaluation_end = (Time.now + 3600 * 24).strftime('%Y-%m-%d')
@@ -101,6 +101,9 @@ class HomeworkCommonController < ApplicationController
@homework_detail_manual.evaluation_num = params[:evaluation_num]
@homework_detail_manual.absence_penalty = params[:absence_penalty]
+ @homework.save_attachments(params[:attachments])
+ render_attachment_warning_if_needed(@homework)
+
if @homework.save && @homework_detail_manual.save
respond_to do |format|
format.html {
diff --git a/app/helpers/homework_common_helper.rb b/app/helpers/homework_common_helper.rb
index 5399fd5bf..b9940f4be 100644
--- a/app/helpers/homework_common_helper.rb
+++ b/app/helpers/homework_common_helper.rb
@@ -3,7 +3,7 @@ module HomeworkCommonHelper
#迟交扣分下拉框
def late_penalty_option
type = []
- for i in (1..5)
+ for i in (0..5)
option = []
option << i
option << i
@@ -29,7 +29,7 @@ module HomeworkCommonHelper
#缺评扣分
def absence_penalty_option
type = []
- i = 1
+ i = 0
while i <= 5
option = []
option << i
diff --git a/app/views/attachments/destroy.js.erb b/app/views/attachments/destroy.js.erb
index 0b6cee0df..d23422e24 100644
--- a/app/views/attachments/destroy.js.erb
+++ b/app/views/attachments/destroy.js.erb
@@ -1,26 +1,30 @@
-var attachment_html_obj = $('#attachments_<%= j params[:attachment_id] %>');
-//modify by yutao 2015-5-14 当1个页面存在多个上传控件时此块代码存在bug 故改之 start
-var containerid=$('.remove-upload',attachment_html_obj).data('containerid');
-if(containerid==undefined){
- $('#attachments_<%= j params[:attachment_id] %>').remove();
- var count=$('#attachments_fields>span').length;
- if(count<=0){
- $("#upload_file_count").text('<%= l(:label_no_file_uploaded)%>');
- $(".remove_all").remove();
+<% if @is_destroy%>
+ $("#attachment_<%= @attachment.id%>").remove();
+<%else%>
+ var attachment_html_obj = $('#attachments_<%= j params[:attachment_id] %>');
+ //modify by yutao 2015-5-14 当1个页面存在多个上传控件时此块代码存在bug 故改之 start
+ var containerid=$('.remove-upload',attachment_html_obj).data('containerid');
+ if(containerid==undefined){
+ $('#attachments_<%= j params[:attachment_id] %>').remove();
+ var count=$('#attachments_fields>span').length;
+ if(count<=0){
+ $("#upload_file_count").text('<%= l(:label_no_file_uploaded)%>');
+ $(".remove_all").remove();
+ }else{
+ $("#upload_file_count").html(""+count+""+"个文件"+"已上传");
+ }
}else{
- $("#upload_file_count").html(""+count+""+"个文件"+"已上传");
+ $('#attachments_<%= j params[:attachment_id] %>').remove();
+ var count=$('#attachments_fields'+containerid+'>span').length;
+ if(count<=0){
+ $('#upload_file_count'+containerid).text('<%= l(:label_no_file_uploaded)%>');
+ var remove_all_html_obj = $(".remove_all").filter(function(index){
+ return $(this).data('containerid')==containerid;
+ });
+ remove_all_html_obj.remove();
+ }else{
+ $('#upload_file_count'+containerid).html(""+count+""+"个文件"+"已上传");
+ }
}
-}else{
- $('#attachments_<%= j params[:attachment_id] %>').remove();
- var count=$('#attachments_fields'+containerid+'>span').length;
- if(count<=0){
- $('#upload_file_count'+containerid).text('<%= l(:label_no_file_uploaded)%>');
- var remove_all_html_obj = $(".remove_all").filter(function(index){
- return $(this).data('containerid')==containerid;
- });
- remove_all_html_obj.remove();
- }else{
- $('#upload_file_count'+containerid).html(""+count+""+"个文件"+"已上传");
- }
-}
-//modify by yutao 2015-5-14 当1个页面存在多个上传控件时此块代码存在bug 故改之 end
\ No newline at end of file
+ //modify by yutao 2015-5-14 当1个页面存在多个上传控件时此块代码存在bug 故改之 end
+<% end%>
\ No newline at end of file
diff --git a/app/views/courses/_show_member_score.html.erb b/app/views/courses/_show_member_score.html.erb
index bb080b57b..0d250cf14 100644
--- a/app/views/courses/_show_member_score.html.erb
+++ b/app/views/courses/_show_member_score.html.erb
@@ -1,24 +1,5 @@