diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb index 53acb2c87..c4f083bee 100644 --- a/app/controllers/courses_controller.rb +++ b/app/controllers/courses_controller.rb @@ -576,6 +576,7 @@ class CoursesController < ApplicationController bids = bids.like(params[:name]) if params[:name].present? @bids = paginateHelper bids,10 @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)) render :layout => 'base_courses' else render_403 diff --git a/app/helpers/courses_helper.rb b/app/helpers/courses_helper.rb index 62879f010..49d2ff9b5 100644 --- a/app/helpers/courses_helper.rb +++ b/app/helpers/courses_helper.rb @@ -694,16 +694,46 @@ module CoursesHelper end def bid_anonymous_comment bid - if bid.open_anonymous_evaluation == 1 && bid.homeworks.count >= 2 + if bid.open_anonymous_evaluation == 1 + if bid.homeworks.count >= 2 + case bid.comment_status + when 0 + link = link_to '启动匿评', alert_anonymous_comment_bid_path(bid), id: "#{bid.id}_start_anonymous_comment", remote: true, disable_with: '加载中...',:class => 'fr mr10 work_edit' + when 1 + link = link_to '关闭匿评', alert_anonymous_comment_bid_path(bid), id: "#{bid.id}_stop_anonymous_comment", remote: true,:class => 'fr mr10 work_edit' + when 2 + link = "匿评结束".html_safe + end + else + link = "启动匿评".html_safe + end + else + link = "启动匿评".html_safe + end + link + end + + def student_new_homework bid + user_homework = cur_user_homework_for_bid bid + if user_homework && user_homework.empty? + link_to l(:label_commit_homework), new_exercise_book_path(bid),:class => 'fr mr10 work_edit' + else + "作业已交".html_safe + end + end + + def student_anonymous_comment bid + if bid.open_anonymous_evaluation == 1 case bid.comment_status when 0 - # 关闭匿评 - link_to '启动匿评', alert_anonymous_comment_bid_path(bid), id: "#{bid.id}_start_anonymous_comment", remote: true, disable_with: '加载中...',:class => 'fr mr10 work_edit' + "未开启匿评".html_safe when 1 - link_to '关闭匿评', alert_anonymous_comment_bid_path(bid), id: "#{bid.id}_stop_anonymous_comment", remote: true,:class => 'fr mr10 work_edit' + "正在匿评中".html_safe when 2 - "匿评结束".html_safe + "匿评已结束".html_safe end + else + "未启用匿评".html_safe end end end diff --git a/app/views/courses/homework.html.erb b/app/views/courses/homework.html.erb index bc210fcff..751558237 100644 --- a/app/views/courses/homework.html.erb +++ b/app/views/courses/homework.html.erb @@ -22,6 +22,9 @@ <% if @is_teacher%> <%= bid_anonymous_comment(bid)%> <%= link_to(l(:button_edit),edit_bid_path(:course_id =>@course.id, :bid_id => bid.id), :class => "fr mr10 work_edit") %> + <% elsif @is_student%> + <%= student_anonymous_comment bid %> + <%= student_new_homework bid %> <% end %>