Merge branch 'dev_aliyun' of https://bdgit.educoder.net/Hjqreturn/educoder into dev_aliyun

dev_forum
daiao 6 years ago
commit 56b4323c62

@ -59,7 +59,8 @@ class GraduationTasksController < ApplicationController
# 任务发布的情况下: 是老师身份或者任务已截止的情况下公开任务了作品设置的学生也能查看其他人的作品 # 任务发布的情况下: 是老师身份或者任务已截止的情况下公开任务了作品设置的学生也能查看其他人的作品
if @task.published? && (@user_course_identity < Course::STUDENT || if @task.published? && (@user_course_identity < Course::STUDENT ||
(@user_course_identity == Course::STUDENT && @work.present? && @work.take.work_status > 0 && (@user_course_identity == Course::STUDENT && @work.present? && @work.take.work_status > 0 &&
@task.status > 1 && @task.open_work)) ((!@task.allow_late && @task.status > 1) || (@task.allow_late && @task.late_time && @task.late_time < Time.now)) &&
(@task.open_work || @task.open_score)))
# 如有有分班则看分班内的学生,否则看所有学生的作品 # 如有有分班则看分班内的学生,否则看所有学生的作品
user_ids = user_ids =
if @user_course_identity < Course::STUDENT if @user_course_identity < Course::STUDENT
@ -117,6 +118,7 @@ class GraduationTasksController < ApplicationController
@work_list = @work_list.joins(user: :user_extension).order("user_extensions.#{rorder} #{b_order}") @work_list = @work_list.joins(user: :user_extension).order("user_extensions.#{rorder} #{b_order}")
end end
@view_work = @task.open_work || @user_course_identity < Course::STUDENT
@work_count = @work_list.count @work_count = @work_list.count
@work_excel = @work_list @work_excel = @work_list
@ -150,6 +152,7 @@ class GraduationTasksController < ApplicationController
end end
else else
@work_list = @work @work_list = @work
@view_work = false
@work_count = @work_list.count @work_count = @work_list.count
@all_work_count = @work_list.count @all_work_count = @work_list.count
respond_to do |format| respond_to do |format|

@ -13,6 +13,7 @@ class GraduationWorksController < ApplicationController
before_action :published_task, only: [:new, :create, :edit, :update, :search_member_list, :relate_project, before_action :published_task, only: [:new, :create, :edit, :update, :search_member_list, :relate_project,
:cancel_relate_project, :revise_attachment] :cancel_relate_project, :revise_attachment]
before_action :edit_duration, only: [:edit, :update] before_action :edit_duration, only: [:edit, :update]
before_action :open_work, only: [:show, :supply_attachments, :comment_list]
def new def new
if @task.task_type == 2 && @task.base_on_project if @task.task_type == 2 && @task.base_on_project
@ -489,6 +490,11 @@ class GraduationWorksController < ApplicationController
tip_exception("已过了修改时间") if @task.end_time && @task.end_time < Time.now tip_exception("已过了修改时间") if @task.end_time && @task.end_time < Time.now
end end
# 作品是否公开
def open_work
tip_exception(403,"没有操作权限") unless (@user_course_identity < Course::STUDENT || current_user == @work.user || @task.open_work)
end
def update_check work def update_check work
tip_exception("作品描述不能为空") if params[:description].blank? tip_exception("作品描述不能为空") if params[:description].blank?
if @task.task_type == 2 if @task.task_type == 2

@ -63,7 +63,7 @@ class GraduationWork < ApplicationRecord
#用户是否有查看分数的权限 #用户是否有查看分数的权限
def check_score_power? current_user, course_identity def check_score_power? current_user, course_identity
self.work_score.present? || course_identity < Course::STUDENT || self.user_id = current_user.id self.work_score.present? && (course_identity < Course::STUDENT || self.user_id = current_user.id || graduation_task.open_score)
end end
# 作品是否能够分配指导老师 # 作品是否能够分配指导老师

@ -59,6 +59,7 @@ if @task.published? || @user_course_identity < Course::STUDENT
json.late_penalty work.late_penalty if @task.allow_late json.late_penalty work.late_penalty if @task.allow_late
json.final_score work_final_score work, @current_user, @user_course_identity json.final_score work_final_score work, @current_user, @user_course_identity
json.assign work.assign_power?(@user_course_identity) json.assign work.assign_power?(@user_course_identity)
json.view_work @view_work || @current_user.id == work.user_id
end end
end end
end end
Loading…
Cancel
Save