From 52a907e9340d1212a89c5b8d9e2adffd28fa3fcc Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Wed, 19 Feb 2020 12:48:09 +0800 Subject: [PATCH 1/6] =?UTF-8?q?=E5=8C=BF=E8=AF=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/helpers/application_helper.rb | 2 +- app/views/homework_commons/works_list.json.jbuilder | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 40e6cb365..7e5926bab 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -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}" diff --git a/app/views/homework_commons/works_list.json.jbuilder b/app/views/homework_commons/works_list.json.jbuilder index cd2f17cf5..9fb2d6971 100644 --- a/app/views/homework_commons/works_list.json.jbuilder +++ b/app/views/homework_commons/works_list.json.jbuilder @@ -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) end end From 5c77b8c7fec909a27009d8b17657ac2eb62a232f Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Wed, 19 Feb 2020 12:57:11 +0800 Subject: [PATCH 2/6] =?UTF-8?q?=E5=8F=91=E9=80=81=E8=87=B3=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/subjects_controller.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/controllers/subjects_controller.rb b/app/controllers/subjects_controller.rb index 92976e05a..bf5466b1e 100644 --- a/app/controllers/subjects_controller.rb +++ b/app/controllers/subjects_controller.rb @@ -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) + @none_shixun_ids = @subject.shixuns.joins(:shixun_schools) + .where("school_id != #{current_user.user_extension.try(:school_id).to_i}").pluck(:id) end def send_to_course From 9cbe753b219445a6258d63b2d5d0f15866372366 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Wed, 19 Feb 2020 13:02:36 +0800 Subject: [PATCH 3/6] =?UTF-8?q?=E8=AF=BE=E5=A0=82=E5=8F=91=E9=80=81?= =?UTF-8?q?=E8=87=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/subjects_controller.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/controllers/subjects_controller.rb b/app/controllers/subjects_controller.rb index bf5466b1e..ff969e97e 100644 --- a/app/controllers/subjects_controller.rb +++ b/app/controllers/subjects_controller.rb @@ -244,6 +244,8 @@ class SubjectsController < ApplicationController @none_shixun_ids = @subject.shixuns.joins(:shixun_schools) .where("school_id != #{current_user.user_extension.try(:school_id).to_i}").pluck(:id) + logger.info("########:#{current_user.user_extension.try(:school_id)}") + logger.info("########:#{@subject.shixuns.joins(:shixun_schools).pluck("shixun_schools.school_id")}") end def send_to_course From e3de73ce3263c3b50b770580216156f7c2713698 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Wed, 19 Feb 2020 13:06:15 +0800 Subject: [PATCH 4/6] 1 --- app/controllers/subjects_controller.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/controllers/subjects_controller.rb b/app/controllers/subjects_controller.rb index ff969e97e..38410eae0 100644 --- a/app/controllers/subjects_controller.rb +++ b/app/controllers/subjects_controller.rb @@ -243,9 +243,10 @@ 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}").pluck(:id) + .where("school_id != #{current_user.user_extension.try(:school_id).to_i}").pluck("shixuns.shixun_id") logger.info("########:#{current_user.user_extension.try(:school_id)}") logger.info("########:#{@subject.shixuns.joins(:shixun_schools).pluck("shixun_schools.school_id")}") + logger.info("########:#{@none_shixun_ids}") end def send_to_course From ea1b76396aa1ccfa924123cf2c8d9095def131b1 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Wed, 19 Feb 2020 13:07:08 +0800 Subject: [PATCH 5/6] 1 --- app/controllers/subjects_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/subjects_controller.rb b/app/controllers/subjects_controller.rb index 38410eae0..df92d11d8 100644 --- a/app/controllers/subjects_controller.rb +++ b/app/controllers/subjects_controller.rb @@ -243,7 +243,7 @@ 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}").pluck("shixuns.shixun_id") + .where("school_id != #{current_user.user_extension.try(:school_id).to_i}").pluck("shixun_schools.shixun_id") logger.info("########:#{current_user.user_extension.try(:school_id)}") logger.info("########:#{@subject.shixuns.joins(:shixun_schools).pluck("shixun_schools.school_id")}") logger.info("########:#{@none_shixun_ids}") From bd73c88edd1a0673d75df661badce1b9eaea0280 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Wed, 19 Feb 2020 13:08:52 +0800 Subject: [PATCH 6/6] =?UTF-8?q?=E5=8F=91=E9=80=81=E8=87=B3=E8=AF=BE?= =?UTF-8?q?=E5=A0=82=E7=9A=84=E6=8E=A5=E5=8F=A3=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/subjects_controller.rb | 4 ++-- app/views/subjects/choose_course.json.jbuilder | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/controllers/subjects_controller.rb b/app/controllers/subjects_controller.rb index bf5466b1e..efc117d6a 100644 --- a/app/controllers/subjects_controller.rb +++ b/app/controllers/subjects_controller.rb @@ -242,8 +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}").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 diff --git a/app/views/subjects/choose_course.json.jbuilder b/app/views/subjects/choose_course.json.jbuilder index 2e03c5287..8dae4e3e4 100644 --- a/app/views/subjects/choose_course.json.jbuilder +++ b/app/views/subjects/choose_course.json.jbuilder @@ -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