From 221276ba1f1559fc01f54634cd51ad2813651dc3 Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Mon, 23 Mar 2015 20:30:38 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E8=80=81=E5=B8=88=E5=B8=83?= =?UTF-8?q?=E7=BD=AE=E4=BD=9C=E4=B8=9A=E5=AD=A6=E7=94=9F=E8=AE=BF=E9=97=AE?= =?UTF-8?q?=E7=9A=84=E5=88=97=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/courses_controller.rb | 1 + app/helpers/courses_helper.rb | 40 +++++++++++++++++++++++---- app/views/courses/homework.html.erb | 3 ++ 3 files changed, 39 insertions(+), 5 deletions(-) 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 %>