diff --git a/app/helpers/courses_helper.rb b/app/helpers/courses_helper.rb index b0c7e186..054b3b5a 100644 --- a/app/helpers/courses_helper.rb +++ b/app/helpers/courses_helper.rb @@ -159,7 +159,7 @@ module CoursesHelper end #获取当前用户在指定作业下提交的作业的集合 def cur_user_homework_for_bid bid - cur_user_homework = HomeworkAttach.where("user_id = ? and bid_id = ?",User.current,params[:id]) + cur_user_homework = HomeworkAttach.where("user_id = ? and bid_id = ?",User.current,bid.id) cur_user_homework end end diff --git a/app/views/bids/_bid_homework_show.html.erb b/app/views/bids/_bid_homework_show.html.erb index 3ef55c56..c4eb875a 100644 --- a/app/views/bids/_bid_homework_show.html.erb +++ b/app/views/bids/_bid_homework_show.html.erb @@ -15,7 +15,13 @@ <% if(User.current.logged? && (!Member.where('user_id = ? and project_id = ?', User.current.id, bid.courses.first.id).first.nil? && (Member.where('user_id = ? and project_id = ?', User.current.id, bid.courses.first.id).first.roles&Role.where('id = ? or id = ? or id =?',5, 10, 7)).size >0)) %> <%# 提交作业按钮 %> - <%= link_to l(:label_commit_homework), '#OpenWindow', rel: 'leanModal', onclick: "showSubH(#{bid.id}, '#{bid.name}');" if User.current.member_of?(@project) %> + + <% cur_user_homework = cur_user_homework_for_bid(bid) %> + <% if cur_user_homework!= nil && cur_user_homework.count == 0 %> + <%= link_to l(:label_commit_homework),new_homework_attach_path(bid) %> + <% else %> + <%= l(:lable_has_commit_homework)%> + <% end %> <% end %> <% if (User.current.admin?||User.current.id==bid.author_id) %> <%= link_to( diff --git a/config/locales/zh.yml b/config/locales/zh.yml index 9f6fb26c..de390a8f 100644 --- a/config/locales/zh.yml +++ b/config/locales/zh.yml @@ -1277,6 +1277,7 @@ zh: label_current_contributors: 位当前贡献者 label_commit_limit: 作业提交时间已过! label_commit_ar: 作业提交截止时间快到了! + lable_has_commit_homework: 您已提交过作业 #modify by men label_x_current_contributors: zero: 位当前贡献者