diff --git a/app/controllers/files_controller.rb b/app/controllers/files_controller.rb index 7318a4dc2..54babdd64 100644 --- a/app/controllers/files_controller.rb +++ b/app/controllers/files_controller.rb @@ -26,7 +26,7 @@ class FilesController < ApplicationController before_filter :authorize, :except => [:create,:getattachtype,:quote_resource_show,:search,:searchone4reload,:search_project,:quote_resource_show_project, :search_tag_attachment,:subfield_upload_file,:search_org_subfield_tag_attachment, :search_tag_attachment,:quote_resource_show_org_subfield,:find_org_subfield_attache, - :search_files_in_subfield,:upload_files_menu,:file_hidden,:republish_file,:update_file_description] + :search_files_in_subfield,:upload_files_menu,:file_hidden,:republish_file,:update_file_description, :edit_file_description] helper :sort include SortHelper @@ -981,6 +981,13 @@ class FilesController < ApplicationController def upload_files_menu end + + def edit_file_description + @attachment = Attachment.find(params[:id]) + @attachment.description = params[:file_description_edit] + @attachment.save + end + def update_file_description @attachment = Attachment.find(params[:id]) @attachment.description = params[:description] diff --git a/app/controllers/homework_common_controller.rb b/app/controllers/homework_common_controller.rb index 4511e5a1f..9fe29746e 100644 --- a/app/controllers/homework_common_controller.rb +++ b/app/controllers/homework_common_controller.rb @@ -146,7 +146,7 @@ class HomeworkCommonController < ApplicationController @homework_detail_group = @homework.homework_detail_group @homework_detail_group.min_num = params[:min_num].to_i if params[:min_num] @homework_detail_group.max_num = params[:max_num].to_i if params[:max_num] - @homework_detail_group.base_on_project = params[:base_on_project].to_i if params[:base_on_project] + @homework_detail_group.base_on_project = params[:base_on_project] ? 1 : 0 end @homework.anonymous_comment = params[:homework_common][:anonymous_comment] ? params[:homework_common][:anonymous_comment].to_i : 1 @@ -202,24 +202,24 @@ class HomeworkCommonController < ApplicationController if @homework_detail_manual.comment_status == 1 student_works = @homework.student_works.has_committed if student_works && student_works.size >= 2 - if @homework.homework_type == 3 - student_work_projects = @homework.student_work_projects.where("student_work_id is not null") - student_work_projects.each_with_index do |pro_work, pro_index| - n = @homework_detail_manual.evaluation_num - n = n < student_works.size ? n : student_works.size - 1 - work_index = -1 - student_works.each_with_index do |stu_work, stu_index| - if stu_work.id.to_i == pro_work.student_work_id.to_i - work_index = stu_index - end - end - assigned_homeworks = get_assigned_homeworks(student_works, n, work_index) - assigned_homeworks.each do |h| - student_works_evaluation_distributions = StudentWorksEvaluationDistribution.new(user_id: pro_work.user_id, student_work_id: h.id) - student_works_evaluation_distributions.save - end - end - else + # if @homework.homework_type == 3 + # student_work_projects = @homework.student_work_projects.where("student_work_id is not null") + # student_work_projects.each_with_index do |pro_work, pro_index| + # n = @homework_detail_manual.evaluation_num + # n = n < student_works.size ? n : student_works.size - 1 + # work_index = -1 + # student_works.each_with_index do |stu_work, stu_index| + # if stu_work.id.to_i == pro_work.student_work_id.to_i + # work_index = stu_index + # end + # end + # assigned_homeworks = get_assigned_homeworks(student_works, n, work_index) + # assigned_homeworks.each do |h| + # student_works_evaluation_distributions = StudentWorksEvaluationDistribution.new(user_id: pro_work.user_id, student_work_id: h.id) + # student_works_evaluation_distributions.save + # end + # end + # else student_works.each_with_index do |work, index| user = work.user n = @homework_detail_manual.evaluation_num @@ -230,7 +230,7 @@ class HomeworkCommonController < ApplicationController student_works_evaluation_distributions.save end end - end + #end @homework_detail_manual.update_column('comment_status', 2) @homework_detail_manual.update_column('evaluation_start', Date.today) @statue = 1 @@ -255,11 +255,28 @@ class HomeworkCommonController < ApplicationController @homework_detail_manual.update_column('evaluation_end', Date.today) #计算缺评扣分 work_ids = "(" + @homework.student_works.has_committed.map(&:id).join(",") + ")" - @homework.student_works.has_committed.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 + if @homework.homework_type != 3 + @homework.student_works.has_committed.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 + else + @homework.student_works.has_committed.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 + if student_work.absence_penalty != 0 + pros = student_work.student_work_projects.where("is_leader = 0") + user_ids = pros.empty? ? "(-1)" : "(" + pros.map{|stu|stu.user_id}.join(",") + ")" + student_works = @homework.student_works.where("user_id in #{user_ids}") + student_works.each do |st_work| + st_work.update_attribute("absence_penalty", student_work.absence_penalty) + end + end + end end + # 匿评关闭消息邮件通知 send_message_anonymous_comment(@homework, m_status = 3) Mailer.send_mail_anonymous_comment_close(@homework).deliver diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 27e90b356..6474a0eae 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -2280,6 +2280,8 @@ module ApplicationHelper candown = true elsif attachment.container.class.to_s=="Memo" #论坛资源允许下载 candown = true + elsif attachment.container.class.to_s=="Syllabus" #论坛资源允许下载 + candown = true elsif attachment.container.class.to_s == "User" candown = (attachment.is_public == 1 || attachment.is_public == true || attachment.author_id == User.current.id) elsif attachment.container_type == "Bid" && attachment.container && attachment.container.courses @@ -2829,7 +2831,7 @@ module ApplicationHelper link_to "补交作品(#{count})", new_student_work_url_without_domain(homework.id),:class => 'c_red' end else - if homework.homework_detail_manual && homework.homework_detail_manual.comment_status == 2 && StudentWorksEvaluationDistribution.where("student_work_id = #{work.id}").count > 0 #匿评作业,且作业状态不是在开启匿评之前 + if homework.homework_detail_manual && homework.homework_detail_manual.comment_status == 2 && StudentWorksEvaluationDistribution.where("student_work_id = #{work.id}").count > 0 && work.user_id == User.current.id #匿评作业,且作业状态不是在开启匿评之前 link_to "作品匿评", student_work_index_url_in_org(homework.id, 2), :class => 'c_blue', :title => "开启匿评后不可修改作品" elsif homework.homework_detail_manual && homework.homework_detail_manual.comment_status == 3 link_to "查看作品(#{count})",student_work_index_url_in_org(homework.id, 2), :class => 'c_blue', :title => "匿评已结束" diff --git a/app/models/attachment.rb b/app/models/attachment.rb index 88fadd644..879759c89 100644 --- a/app/models/attachment.rb +++ b/app/models/attachment.rb @@ -41,7 +41,7 @@ class Attachment < ActiveRecord::Base validates :filename, presence: true, length: {maximum: 254} validates :author, presence: true validates :disk_filename, length: {maximum: 254} - validates :description, length: {maximum: 254} + # validates :description, length: {maximum: 254} validate :validate_max_file_size #elasticsearch diff --git a/app/models/student_work.rb b/app/models/student_work.rb index a3f692341..a33200b3b 100644 --- a/app/models/student_work.rb +++ b/app/models/student_work.rb @@ -1,6 +1,6 @@ #学生提交作品表 #work_status :0 未提交 1 已提交 2 迟交 3 分组作品复制的组员作品 class StudentWork < ActiveRecord::Base - attr_accessible :name, :description, :homework_common_id, :user_id, :final_score, :teacher_score, :student_score, :teaching_asistant_score, :system_score, :work_score, :project_id, :is_test, :simi_id, :simi_value, :work_status, :commit_time + attr_accessible :name, :description, :homework_common_id, :user_id, :final_score, :teacher_score, :student_score, :teaching_asistant_score, :system_score, :work_score, :project_id, :is_test, :simi_id, :simi_value, :work_status, :commit_time, :late_penalty, :absence_penalty belongs_to :homework_common belongs_to :user diff --git a/app/views/files/_org_subfield_list.html.erb b/app/views/files/_org_subfield_list.html.erb index de37ed054..45aa7095b 100644 --- a/app/views/files/_org_subfield_list.html.erb +++ b/app/views/files/_org_subfield_list.html.erb @@ -43,8 +43,10 @@
<%= render :partial => 'files/file_description', :locals => {:file => file} %>
- + <%= form_tag(edit_file_description_org_subfield_file_path(file, :org_subfield_id => org_subfield.id ),:remote=>'true', :method => :post, :id=>"files_query_form_#{file.id}") do %> + + <% end %> <% else %>
@@ -108,3 +110,8 @@ <%end%> <% end%> + \ No newline at end of file diff --git a/app/views/files/_project_list.html.erb b/app/views/files/_project_list.html.erb index faf254015..3193f4b42 100644 --- a/app/views/files/_project_list.html.erb +++ b/app/views/files/_project_list.html.erb @@ -40,8 +40,10 @@
<%= render :partial => 'files/file_description', :locals => {:file => file} %>
- + <%= form_tag(edit_file_description_project_file_path(file, :project_id => project.id),:remote=>'true', :method => :post, :id=>"files_query_form_#{file.id}") do %> + + <% end %>
<% else %>
@@ -70,6 +72,11 @@ <%= pagination_links_full @feedback_pages, @feedback_count, :per_page_links => false, :remote => true, :flag => true%> + diff --git a/app/views/files/_resource_detail.html.erb b/app/views/files/_resource_detail.html.erb index b60814afd..08b85ab2f 100644 --- a/app/views/files/_resource_detail.html.erb +++ b/app/views/files/_resource_detail.html.erb @@ -42,8 +42,10 @@
<%= render :partial => 'files/file_description', :locals => {:file => file} %>
- + <%= form_tag(edit_file_description_course_file_path(file, :course_id => @course.id),:remote=>'true', :method => :post, :id=>"files_query_form_#{file.id}") do %> + + <% end %>
<% else %>
@@ -99,4 +101,9 @@
-
\ No newline at end of file +
+ diff --git a/app/views/files/edit_file_description.js.erb b/app/views/files/edit_file_description.js.erb new file mode 100644 index 000000000..40b47a2ec --- /dev/null +++ b/app/views/files/edit_file_description.js.erb @@ -0,0 +1,3 @@ +$("#file_description_show_<%= @attachment.id %>").html("<%= escape_javascript render(:partial => "files/file_description", :locals => {:file => @attachment}) %>"); +$("#file_description_show_<%= @attachment.id %>").show(); +$("#file_description_edit_<%= @attachment.id %>").hide(); \ No newline at end of file diff --git a/app/views/layouts/_logined_header.html.erb b/app/views/layouts/_logined_header.html.erb index 378741035..b8235ff1c 100644 --- a/app/views/layouts/_logined_header.html.erb +++ b/app/views/layouts/_logined_header.html.erb @@ -14,9 +14,12 @@ - + <% memo = Memo.where(:id => 1168).first %> + <% unless memo.nil? %> + + <% end %> <% else %>