1.作业参与人员可以对作业进行修改,但不能进行删除
2.作业成员(发布人员和参与人员)不能对作业进行评分 3.修改进行作业删除、添加、修改、添加成员等方法的权限判断
This commit is contained in:
parent
8ed95f132a
commit
a100193373
|
@ -35,7 +35,7 @@ class HomeworkAttachController < ApplicationController
|
|||
|
||||
#作业添加成员(参与人员)
|
||||
def add_homework_users
|
||||
if User.current.admin? || User.current == @homework.user
|
||||
if User.current.admin? || User.current.member_of?(@homework.bid.courses.first)
|
||||
#@homework = HomeworkAttach.find(params[:id])
|
||||
if params[:membership]
|
||||
if params[:membership][:user_ids]
|
||||
|
@ -59,7 +59,7 @@ class HomeworkAttachController < ApplicationController
|
|||
#作业删除成员(参与人员)
|
||||
def destory_homework_users
|
||||
#@homework = HomeworkAttach.find(params[:id])
|
||||
if User.current.admin? || User.current == @homework.user
|
||||
if User.current.admin? || User.current.member_of?(@homework.bid.courses.first)
|
||||
homework_user = @homework.homework_users.where("user_id = #{params[:user_id]}").first
|
||||
homework_user.destroy
|
||||
get_homework_member @homework
|
||||
|
@ -196,7 +196,7 @@ class HomeworkAttachController < ApplicationController
|
|||
|
||||
def destroy
|
||||
#@homework = HomeworkAttach.find(params[:id])
|
||||
if User.current.admin? || User.current.member_of?(@homework.bid.courses.first)
|
||||
if User.current.admin? || User.current == @homework
|
||||
if @homework.destroy
|
||||
respond_to do |format|
|
||||
format.html { redirect_to project_for_bid_path @homework.bid }
|
||||
|
|
|
@ -177,4 +177,9 @@ module CoursesHelper
|
|||
seem_count = homework.rates(:quality).where("rater_id = ?",User.current).count
|
||||
seem_count > 0
|
||||
end
|
||||
|
||||
#获取指定作业的所有成员
|
||||
def users_for_homework homework
|
||||
homework.nil? ? [] : (homework.users + [homework.user])
|
||||
end
|
||||
end
|
||||
|
|
|
@ -90,11 +90,13 @@
|
|||
<% end %>
|
||||
</td>
|
||||
<td>
|
||||
<% if (User.current == homework.user) || is_teacher %>
|
||||
<% if (users_for_homework(homework).include?(User.current) || is_teacher) %>
|
||||
<%= link_to l(:button_edit), edit_homework_attach_path(homework) %>
|
||||
<% if homework.user == User.current || is_teacher %>
|
||||
<%= link_to(l(:label_bid_respond_delete), homework,
|
||||
method: :delete, :confirm => l(:text_are_you_sure)) %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
|
|
@ -142,7 +142,8 @@
|
|||
|
||||
<div class="underline-contests_one"></div>
|
||||
|
||||
<% if User.current != @homework.user %>
|
||||
<!-- 作业成员(发布人员和参与人员)不能对作业进行评分 -->
|
||||
<% if !users_for_homework(@homework).include?(User.current) %>
|
||||
<div style="height: 50px">
|
||||
<div style="font-size: 15px"><strong>作业评论:</strong></div>
|
||||
<% if is_student %>
|
||||
|
|
Loading…
Reference in New Issue