diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 07d2dd4ba..1a3f13082 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -1907,4 +1907,28 @@ module ApplicationHelper '#' end end + + def anonymous_comment_link(bid, course) + link = case bid.comment_status + when 0 + @student_size ||= searchStudent(course).size + @homework_size = bid.homeworks.size + percent = @homework_size.to_f / @student_size + confirm_info = "开启匿评后学生将不能对作业进行提交、修改、删除等操作\n" + confirm_info += percent >= 0.8 ? '' : "目前#{@student_size}个学生,总共提交了#{@homework_size}份作业,只占#{number_to_percentage(percent * 100, precision: 1)}\n" + confirm_info += '是否确定开启匿评?' + link_to '启动匿评', start_anonymous_comment_bid_path(bid), id: "#{bid.id}_start_anonymous_comment", remote: true, :confirm => confirm_info, disable_with: '加载中...' + when 1 + @student_size ||= searchStudent(course).size + @homework_size = bid.homeworks.size + percent = @homework_size.to_f / @student_size + confirm_info = "关闭匿评后所有同学将看到匿评的结果。学生将可以自由的进行公开互评了,但公开互评不影响作业的匿名评分\n" + confirm_info += "" # TODO 当前有多少学生完成了匿评,有多少学生没有进行匿评,并据此给出建议:建议老师暂缓关闭匿评,因为只有x%的学生完成了匿评任务。。。 + confirm_info += '是否确定关闭匿评?' + link_to '关闭匿评', stop_anonymous_comment_bid_path(bid), id: "#{bid.id}_stop_anonymous_comment", remote: true, :confirm => confirm_info + when 2 + '匿评结束' + end + content_tag('span', link, id: "#{bid.id}_anonymous_comment") + end end diff --git a/app/views/bids/_bid_homework_show.html.erb b/app/views/bids/_bid_homework_show.html.erb index c67460fef..4a02a5fb1 100644 --- a/app/views/bids/_bid_homework_show.html.erb +++ b/app/views/bids/_bid_homework_show.html.erb @@ -23,35 +23,18 @@ <%= link_to(bid.name, course_for_bid_path(bid), :class => 'bid_path') %> - <% if User.current.logged? && is_cur_course_student(@course) %> + <% if(User.current.logged? && (!Member.where('user_id = ? and course_id = ?', User.current.id, bid.courses.first.id).first.nil? && (Member.where('user_id = ? and course_id = ?', User.current.id, bid.courses.first.id).first.roles&Role.where('id = ? or id = ? or id =?',5, 10, 7)).size >0)) %> <% cur_user_homework = cur_user_homework_for_bid(bid) %> - <% if cur_user_homework!= nil && cur_user_homework.empty? %> - <% if bid.comment_status == 0 %> - <%= link_to l(:label_commit_homework),new_exercise_book_path(bid) %> - <% else %> - - 提交作业 - - <% end %> + <% 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)%> - <% if bid.homeworks.count >= 2 %> - - <% case bid.comment_status %> - <% when 0 %> - <%= link_to '启动匿评', start_anonymous_comment_bid_path(bid), id: "#{bid.id}_start_anonymous_comment", remote: true, :confirm => "开启匿评后学生将不能对作业进行提交、修改、删除等操作\n是否确定开启匿评?", disable_with: '加载中...' %> - <% when 1 %> - <%= link_to '关闭匿评', stop_anonymous_comment_bid_path(bid), id: "#{bid.id}_stop_anonymous_comment", remote: true, :confirm => "关闭匿评后学生将不能对作业进行评分,且学生作业列表将会被公开\n是否确定关闭匿评?" %> - <% when 2 %> - 匿评结束 - <% end %> - - <% end %> + <% if (User.current.admin?||User.current.id==bid.author_id) %> + <%= anonymous_comment_link(bid, @course) %> <%= link_to( l(:button_edit), {:action => 'edit', :controller=>'bids', :course_id =>@course.id, :bid_id => bid.id}, diff --git a/app/views/layouts/base_homework.html.erb b/app/views/layouts/base_homework.html.erb index 09b77d62a..10bb25f78 100644 --- a/app/views/layouts/base_homework.html.erb +++ b/app/views/layouts/base_homework.html.erb @@ -79,7 +79,7 @@ - <%= link_to "返回课程主页", course_path(course) if course %> + <%= link_to course.name.to_s, homework_course_path(course) if course %> @@ -87,9 +87,7 @@ - - <%=link_to("第#{course.homeworks.index(@bid) + 1}次作业", course_for_bid_path(@bid)) %> - + <%=link_to(@bid.name, course_for_bid_path(@bid)) %> @@ -103,19 +101,10 @@
- <% if (User.current.admin?||User.current.id==@bid.author_id) && @bid.homeworks.count >= 2 %> + <% if (User.current.admin?||User.current.id==@bid.author_id) %> <% end %>
- - <% case @bid.comment_status %> - <% when 0 %> - <%= link_to '启动匿评', start_anonymous_comment_bid_path(@bid), id: "#{@bid.id}_start_anonymous_comment", remote: true, :confirm => "开启匿评后学生将不能对作业进行提交、修改、删除等操作\n是否确定开启匿评?", disable_with: '加载中...' %> - <% when 1 %> - <%= link_to '关闭匿评', stop_anonymous_comment_bid_path(@bid), id: "#{@bid.id}_stop_anonymous_comment", remote: true, :confirm => "关闭匿评后学生将不能对作业进行评分,且学生作业列表将会被公开\n是否确定关闭匿评?" %> - <% when 2 %> - 匿评结束 - <% end %> - + <%= anonymous_comment_link(@bid, course) %>