@ -242,7 +242,8 @@ class SubjectsController < ApplicationController
## 云上实验室过滤
@courses = @courses.where(id: current_laboratory.all_courses)
@none_shixun_ids = @subject.shixuns.joins(:shixun_schools).where("school_id != #{current_user.user_extension.try(:school_id).to_i}").where(use_scope: 1).pluck(:id)
@all_shixun_ids = @subject.shixuns.where(use_scope: 0).pluck(:id) +
@subject.shixuns.joins(:shixun_schools).where("school_id = #{current_user.user_extension.try(:school_id).to_i} and use_scope = 1").pluck(:id)
end
def send_to_course
@ -137,7 +137,7 @@ module ApplicationHelper
# 用户图像url,如果不存在的话,source为匿名用户,即默认使用匿名用户图像
def url_to_avatar(source)
if File.exist?(disk_filename(source.class, source.id))
if File.exist?(disk_filename(source&.class, source&.id))
ctime = File.ctime(disk_filename(source.class, source.id)).to_i
if source.class.to_s == 'User'
File.join(relative_path, ["#{source.class}", "#{source.id}"]) + "?t=#{ctime}"
@ -171,7 +171,7 @@ elsif @homework.homework_type == "group" || @homework.homework_type == "normal"
json.user_login @is_evaluation ? "--" : work.user.try(:login)
json.user_name @is_evaluation ? "匿名" : work.user.try(:real_name)
json.user_img url_to_avatar(@is_evaluation ? "0" : work.user)
json.user_img @is_evaluation ? "--" : url_to_avatar(work.user)
@ -7,7 +7,7 @@ end
json.stages @subject.stages.includes(shixuns: [user: :user_extension]) do |stage|
index = 1
json.shixuns stage.shixuns do |shixun|
if shixun.status == 2 && !shixun.is_jupyter && !@none_shixun_ids.include?(shixun.id)
if shixun.status == 2 && !shixun.is_jupyter && @all_shixun_ids.include?(shixun.id)
json.shixun_id shixun.id
json.id shixun.id
json.identifier shixun.identifier