From 1ebd0c1f7bfac91e345d68aa9f864a5dd8e6d8e4 Mon Sep 17 00:00:00 2001 From: jingquan huang Date: Sun, 17 Nov 2019 13:46:58 +0800 Subject: [PATCH 01/19] =?UTF-8?q?=E6=8E=A8=E8=8D=90=E5=AE=9E=E8=AE=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Gemfile.lock | 426 --------------------------------------------------- 1 file changed, 426 deletions(-) delete mode 100644 Gemfile.lock diff --git a/Gemfile.lock b/Gemfile.lock deleted file mode 100644 index 4b7902353..000000000 --- a/Gemfile.lock +++ /dev/null @@ -1,426 +0,0 @@ -PATH - remote: lib/gitlab-cli - specs: - gitlab (3.2.0) - httparty - terminal-table - -GEM - remote: https://gems.ruby-china.com/ - specs: - aasm (5.0.5) - concurrent-ruby (~> 1.0) - actioncable (5.2.1) - actionpack (= 5.2.1) - nio4r (~> 2.0) - websocket-driver (>= 0.6.1) - actionmailer (5.2.1) - actionpack (= 5.2.1) - actionview (= 5.2.1) - activejob (= 5.2.1) - mail (~> 2.5, >= 2.5.4) - rails-dom-testing (~> 2.0) - actionpack (5.2.1) - actionview (= 5.2.1) - activesupport (= 5.2.1) - rack (~> 2.0) - rack-test (>= 0.6.3) - rails-dom-testing (~> 2.0) - rails-html-sanitizer (~> 1.0, >= 1.0.2) - actionview (5.2.1) - activesupport (= 5.2.1) - builder (~> 3.1) - erubi (~> 1.4) - rails-dom-testing (~> 2.0) - rails-html-sanitizer (~> 1.0, >= 1.0.3) - active_decorator (1.2.0) - activejob (5.2.1) - activesupport (= 5.2.1) - globalid (>= 0.3.6) - activemodel (5.2.1) - activesupport (= 5.2.1) - activerecord (5.2.1) - activemodel (= 5.2.1) - activesupport (= 5.2.1) - arel (>= 9.0) - activestorage (5.2.1) - actionpack (= 5.2.1) - activerecord (= 5.2.1) - marcel (~> 0.3.1) - activesupport (5.2.1) - concurrent-ruby (~> 1.0, >= 1.0.2) - i18n (>= 0.7, < 2) - minitest (~> 5.1) - tzinfo (~> 1.1) - acts-as-taggable-on (6.0.0) - activerecord (~> 5.0) - addressable (2.7.0) - public_suffix (>= 2.0.2, < 5.0) - archive-zip (0.11.0) - io-like (~> 0.3.0) - arel (9.0.0) - autoprefixer-rails (9.6.1) - execjs - awesome_print (1.8.0) - axlsx (3.0.0.pre) - htmlentities (~> 4.3, >= 4.3.4) - mimemagic (~> 0.3) - nokogiri (~> 1.8, >= 1.8.2) - rubyzip (~> 1.2, >= 1.2.1) - axlsx_rails (0.5.2) - actionpack (>= 3.1) - axlsx (>= 2.0.1) - bindex (0.5.0) - bootsnap (1.3.1) - msgpack (~> 1.0) - bootstrap (4.3.1) - autoprefixer-rails (>= 9.1.0) - popper_js (>= 1.14.3, < 2) - sassc-rails (>= 2.0.0) - builder (3.2.3) - bulk_insert (1.7.0) - activerecord (>= 3.2.0) - byebug (10.0.2) - capybara (3.5.1) - addressable - mini_mime (>= 0.1.3) - nokogiri (~> 1.8) - rack (>= 1.6.0) - rack-test (>= 0.6.3) - xpath (~> 3.1) - childprocess (0.9.0) - ffi (~> 1.0, >= 1.0.11) - chromedriver-helper (1.2.0) - archive-zip (~> 0.10) - nokogiri (~> 1.8) - chunky_png (1.3.10) - concurrent-ruby (1.0.5) - connection_pool (2.2.2) - crass (1.0.4) - diff-lcs (1.3) - diffy (3.3.0) - elasticsearch (7.2.0) - elasticsearch-api (= 7.2.0) - elasticsearch-transport (= 7.2.0) - elasticsearch-api (7.2.0) - multi_json - elasticsearch-transport (7.2.0) - faraday - multi_json - enumerize (2.3.1) - activesupport (>= 3.2) - erubi (1.7.1) - execjs (2.7.0) - faraday (0.15.4) - multipart-post (>= 1.2, < 3) - ffi (1.9.25) - font-awesome-sass (4.7.0) - sass (>= 3.2) - globalid (0.4.1) - activesupport (>= 4.2.0) - grape-entity (0.7.1) - activesupport (>= 4.0) - multi_json (>= 1.3.2) - hashie (3.5.7) - htmlentities (4.3.4) - httparty (0.16.2) - multi_xml (>= 0.5.2) - i18n (1.1.0) - concurrent-ruby (~> 1.0) - io-like (0.3.0) - jbuilder (2.7.0) - activesupport (>= 4.2.0) - multi_json (>= 1.2) - jquery-rails (4.3.5) - rails-dom-testing (>= 1, < 3) - railties (>= 4.2.0) - thor (>= 0.14, < 2.0) - jwt (2.1.0) - kaminari (1.1.1) - activesupport (>= 4.1.0) - kaminari-actionview (= 1.1.1) - kaminari-activerecord (= 1.1.1) - kaminari-core (= 1.1.1) - kaminari-actionview (1.1.1) - actionview - kaminari-core (= 1.1.1) - kaminari-activerecord (1.1.1) - activerecord - kaminari-core (= 1.1.1) - kaminari-core (1.1.1) - listen (3.1.5) - rb-fsevent (~> 0.9, >= 0.9.4) - rb-inotify (~> 0.9, >= 0.9.7) - ruby_dep (~> 1.2) - loofah (2.2.2) - crass (~> 1.0.2) - nokogiri (>= 1.5.9) - mail (2.7.0) - mini_mime (>= 0.1.1) - marcel (0.3.2) - mimemagic (~> 0.3.2) - method_source (0.9.0) - mimemagic (0.3.2) - mini_mime (1.0.0) - mini_portile2 (2.3.0) - minitest (5.11.3) - msgpack (1.2.4) - multi_json (1.13.1) - multi_xml (0.6.0) - multipart-post (2.0.0) - mustermann (1.0.3) - mysql2 (0.5.2) - nio4r (2.3.1) - nokogiri (1.8.4) - mini_portile2 (~> 2.3.0) - oauth2 (1.4.1) - faraday (>= 0.8, < 0.16.0) - jwt (>= 1.0, < 3.0) - multi_json (~> 1.3) - multi_xml (~> 0.5) - rack (>= 1.2, < 3) - omniauth (1.9.0) - hashie (>= 3.4.6, < 3.7.0) - rack (>= 1.6.2, < 3) - omniauth-oauth2 (1.6.0) - oauth2 (~> 1.1) - omniauth (~> 1.9) - pdfkit (0.8.4.1) - popper_js (1.14.5) - public_suffix (4.0.1) - puma (3.12.0) - rack (2.0.5) - rack-cors (1.0.2) - rack-protection (2.0.5) - rack - rack-test (1.1.0) - rack (>= 1.0, < 3) - rails (5.2.1) - actioncable (= 5.2.1) - actionmailer (= 5.2.1) - actionpack (= 5.2.1) - actionview (= 5.2.1) - activejob (= 5.2.1) - activemodel (= 5.2.1) - activerecord (= 5.2.1) - activestorage (= 5.2.1) - activesupport (= 5.2.1) - bundler (>= 1.3.0) - railties (= 5.2.1) - sprockets-rails (>= 2.0.0) - rails-dom-testing (2.0.3) - activesupport (>= 4.2.0) - nokogiri (>= 1.6) - rails-html-sanitizer (1.0.4) - loofah (~> 2.2, >= 2.2.2) - rails-i18n (5.1.3) - i18n (>= 0.7, < 2) - railties (>= 5.0, < 6) - railties (5.2.1) - actionpack (= 5.2.1) - activesupport (= 5.2.1) - method_source - rake (>= 0.8.7) - thor (>= 0.19.0, < 2.0) - rake (12.3.1) - rb-fsevent (0.10.3) - rb-inotify (0.9.10) - ffi (>= 0.5.0, < 2) - rchardet (1.8.0) - redcarpet (3.4.0) - redis (4.1.0) - redis-actionpack (5.0.2) - actionpack (>= 4.0, < 6) - redis-rack (>= 1, < 3) - redis-store (>= 1.1.0, < 2) - redis-activesupport (5.0.7) - activesupport (>= 3, < 6) - redis-store (>= 1.3, < 2) - redis-rack (2.0.5) - rack (>= 1.5, < 3) - redis-store (>= 1.2, < 2) - redis-rails (5.0.2) - redis-actionpack (>= 5.0, < 6) - redis-activesupport (>= 5.0, < 6) - redis-store (>= 1.2, < 2) - redis-store (1.6.0) - redis (>= 2.2, < 5) - roo (2.8.2) - nokogiri (~> 1) - rubyzip (>= 1.2.1, < 2.0.0) - roo-xls (1.2.0) - nokogiri - roo (>= 2.0.0, < 3) - spreadsheet (> 0.9.0) - rqrcode (0.10.1) - chunky_png (~> 1.0) - rqrcode_png (0.1.5) - chunky_png - rqrcode - rspec-core (3.8.0) - rspec-support (~> 3.8.0) - rspec-expectations (3.8.1) - diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.8.0) - rspec-mocks (3.8.0) - diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.8.0) - rspec-rails (3.8.0) - actionpack (>= 3.0) - activesupport (>= 3.0) - railties (>= 3.0) - rspec-core (~> 3.8.0) - rspec-expectations (~> 3.8.0) - rspec-mocks (~> 3.8.0) - rspec-support (~> 3.8.0) - rspec-support (3.8.0) - ruby-ole (1.2.12.2) - ruby_dep (1.5.0) - rubyzip (1.2.1) - sass (3.5.7) - sass-listen (~> 4.0.0) - sass-listen (4.0.0) - rb-fsevent (~> 0.9, >= 0.9.4) - rb-inotify (~> 0.9, >= 0.9.7) - sass-rails (5.0.7) - railties (>= 4.0.0, < 6) - sass (~> 3.1) - sprockets (>= 2.8, < 4.0) - sprockets-rails (>= 2.0, < 4.0) - tilt (>= 1.1, < 3) - sassc (2.0.1) - ffi (~> 1.9) - rake - sassc-rails (2.1.2) - railties (>= 4.0.0) - sassc (>= 2.0) - sprockets (> 3.0) - sprockets-rails - tilt - searchkick (3.1.3) - activemodel (>= 4.2) - elasticsearch (>= 5) - hashie - selenium-webdriver (3.14.0) - childprocess (~> 0.5) - rubyzip (~> 1.2) - sidekiq (5.2.7) - connection_pool (~> 2.2, >= 2.2.2) - rack (>= 1.5.0) - rack-protection (>= 1.5.0) - redis (>= 3.3.5, < 5) - simple_form (4.1.0) - actionpack (>= 5.0) - activemodel (>= 5.0) - simple_xlsx_reader (1.0.4) - nokogiri - rubyzip - sinatra (2.0.5) - mustermann (~> 1.0) - rack (~> 2.0) - rack-protection (= 2.0.5) - tilt (~> 2.0) - spreadsheet (1.2.3) - ruby-ole (>= 1.0) - spring (2.0.2) - activesupport (>= 4.2) - spring-watcher-listen (2.0.1) - listen (>= 2.7, < 4.0) - spring (>= 1.2, < 3.0) - sprockets (3.7.2) - concurrent-ruby (~> 1.0) - rack (> 1, < 3) - sprockets-rails (3.2.1) - actionpack (>= 4.0) - activesupport (>= 4.0) - sprockets (>= 3.0.0) - terminal-table (1.8.0) - unicode-display_width (~> 1.1, >= 1.1.1) - thor (0.20.0) - thread_safe (0.3.6) - tilt (2.0.8) - turbolinks (5.2.0) - turbolinks-source (~> 5.2) - turbolinks-source (5.2.0) - tzinfo (1.2.5) - thread_safe (~> 0.1) - uglifier (4.1.17) - execjs (>= 0.3.0, < 3) - unicode-display_width (1.4.0) - web-console (3.6.2) - actionview (>= 5.0) - activemodel (>= 5.0) - bindex (>= 0.4.0) - railties (>= 5.0) - websocket-driver (0.7.0) - websocket-extensions (>= 0.1.0) - websocket-extensions (0.1.3) - wkhtmltopdf-binary (0.12.4) - xpath (3.1.0) - nokogiri (~> 1.8) - -PLATFORMS - ruby - -DEPENDENCIES - aasm - active_decorator - acts-as-taggable-on (~> 6.0) - awesome_print - axlsx (~> 3.0.0.pre) - axlsx_rails (~> 0.5.2) - bootsnap (>= 1.1.0) - bootstrap (~> 4.3.1) - bulk_insert - byebug - capybara (>= 2.15, < 4.0) - chromedriver-helper - diffy - enumerize - faraday (~> 0.15.4) - font-awesome-sass (= 4.7.0) - gitlab! - grape-entity (~> 0.7.1) - jbuilder (~> 2.5) - jquery-rails - kaminari (~> 1.1, >= 1.1.1) - listen (>= 3.0.5, < 3.2) - mysql2 (>= 0.4.4, < 0.6.0) - oauth2 - omniauth (~> 1.9.0) - omniauth-oauth2 (~> 1.6.0) - pdfkit - puma (~> 3.11) - rack-cors - rails (~> 5.2.0) - rails-i18n (~> 5.1) - rchardet (~> 1.8) - redcarpet (~> 3.4) - redis-rails - roo-xls - rqrcode (~> 0.10.1) - rqrcode_png - rspec-rails (~> 3.8) - ruby-ole - rubyzip - sass-rails (~> 5.0) - searchkick - selenium-webdriver - sidekiq - simple_form - simple_xlsx_reader - sinatra - spreadsheet - spring - spring-watcher-listen (~> 2.0.0) - turbolinks (~> 5) - tzinfo-data - uglifier (>= 1.3.0) - web-console (>= 3.3.0) - wkhtmltopdf-binary - -RUBY VERSION - ruby 2.3.7p456 - -BUNDLED WITH - 1.17.3 From 001a2e69ed49adfc6181a14fd78ab430b491c038 Mon Sep 17 00:00:00 2001 From: jingquan huang Date: Sun, 17 Nov 2019 14:01:25 +0800 Subject: [PATCH 02/19] =?UTF-8?q?=E6=89=80=E5=B1=9E=E8=AF=BE=E7=A8=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .ipynb_checkpoints/未命名-checkpoint.ipynb | 6 ++++++ .ipynb_checkpoints/未命名1-checkpoint.ipynb | 6 ++++++ app/controllers/shixuns_controller.rb | 6 ++++++ app/views/shixuns/_right.json.jbuilder | 2 +- 4 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 .ipynb_checkpoints/未命名-checkpoint.ipynb create mode 100644 .ipynb_checkpoints/未命名1-checkpoint.ipynb diff --git a/.ipynb_checkpoints/未命名-checkpoint.ipynb b/.ipynb_checkpoints/未命名-checkpoint.ipynb new file mode 100644 index 000000000..2fd64429b --- /dev/null +++ b/.ipynb_checkpoints/未命名-checkpoint.ipynb @@ -0,0 +1,6 @@ +{ + "cells": [], + "metadata": {}, + "nbformat": 4, + "nbformat_minor": 2 +} diff --git a/.ipynb_checkpoints/未命名1-checkpoint.ipynb b/.ipynb_checkpoints/未命名1-checkpoint.ipynb new file mode 100644 index 000000000..2fd64429b --- /dev/null +++ b/.ipynb_checkpoints/未命名1-checkpoint.ipynb @@ -0,0 +1,6 @@ +{ + "cells": [], + "metadata": {}, + "nbformat": 4, + "nbformat_minor": 2 +} diff --git a/app/controllers/shixuns_controller.rb b/app/controllers/shixuns_controller.rb index 9077192cf..0b85e3b31 100644 --- a/app/controllers/shixuns_controller.rb +++ b/app/controllers/shixuns_controller.rb @@ -186,6 +186,12 @@ class ShixunsController < ApplicationController #@fans_count = owner.fan_count #@followed_count = owner.follow_count @user_own_shixuns = owner.shixuns.published.count + ## 云上实验室过滤 + if current_laboratory.main_site? + @relate_subject = @shixun.subjects.visible.unhidden.uniq.joins(:laboratory_subjects).where("laboratory_subjects.laboratory_id != #{current_laboratory.id}") + else + @relate_subject = @shixun.subjects.visible.unhidden.uniq.joins(:laboratory_subjects).where(laboratory_subjects: { laboratory_id: current_laboratory.id }) + end end # 排行榜 diff --git a/app/views/shixuns/_right.json.jbuilder b/app/views/shixuns/_right.json.jbuilder index e6f839aa5..f42633d86 100644 --- a/app/views/shixuns/_right.json.jbuilder +++ b/app/views/shixuns/_right.json.jbuilder @@ -5,7 +5,7 @@ end # 相关路径 json.paths do - json.partial! 'subjects/subject', locals: {subjects: shixun.relation_path} + json.partial! 'subjects/subject', locals: {subjects: @relate_subject} end # 推荐实训 From 26a42d048d078dfd867acfe929b354397d8bcd50 Mon Sep 17 00:00:00 2001 From: jingquan huang Date: Sun, 17 Nov 2019 14:17:42 +0800 Subject: [PATCH 03/19] .. --- app/controllers/shixuns_controller.rb | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/app/controllers/shixuns_controller.rb b/app/controllers/shixuns_controller.rb index 0b85e3b31..f721697ea 100644 --- a/app/controllers/shixuns_controller.rb +++ b/app/controllers/shixuns_controller.rb @@ -188,9 +188,13 @@ class ShixunsController < ApplicationController @user_own_shixuns = owner.shixuns.published.count ## 云上实验室过滤 if current_laboratory.main_site? - @relate_subject = @shixun.subjects.visible.unhidden.uniq.joins(:laboratory_subjects).where("laboratory_subjects.laboratory_id != #{current_laboratory.id}") + # @relate_subject = @shixun.subjects.visible.unhidden.uniq.joins(:laboratory_subjects).where("laboratory_subjects.laboratory_id != #{current_laboratory.id}") + @relate_subject = @shixun.subjects.joins(:laboratory_subjects).where("laboratory_subjects.laboratory_id != #{current_laboratory.id} and + subjects.hidden=0 and subjects.status=2") else - @relate_subject = @shixun.subjects.visible.unhidden.uniq.joins(:laboratory_subjects).where(laboratory_subjects: { laboratory_id: current_laboratory.id }) + # @relate_subject = @shixun.subjects.visible.unhidden.uniq.joins(:laboratory_subjects).where(laboratory_subjects: { laboratory_id: current_laboratory.id }) + @relate_subject = @shixun.subjects.joins(:laboratory_subjects).where("laboratory_subjects.laboratory_id != #{current_laboratory.id} and + subjects.hidden=0 and subjects.status=2") end end From 59de2cd1faf42fe94ac8c1658f91d5a901c61077 Mon Sep 17 00:00:00 2001 From: jingquan huang Date: Sun, 17 Nov 2019 17:50:40 +0800 Subject: [PATCH 04/19] =?UTF-8?q?=E8=BF=98=E5=8E=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/shixuns_controller.rb | 10 ---------- app/views/shixuns/_right.json.jbuilder | 2 +- 2 files changed, 1 insertion(+), 11 deletions(-) diff --git a/app/controllers/shixuns_controller.rb b/app/controllers/shixuns_controller.rb index f721697ea..9077192cf 100644 --- a/app/controllers/shixuns_controller.rb +++ b/app/controllers/shixuns_controller.rb @@ -186,16 +186,6 @@ class ShixunsController < ApplicationController #@fans_count = owner.fan_count #@followed_count = owner.follow_count @user_own_shixuns = owner.shixuns.published.count - ## 云上实验室过滤 - if current_laboratory.main_site? - # @relate_subject = @shixun.subjects.visible.unhidden.uniq.joins(:laboratory_subjects).where("laboratory_subjects.laboratory_id != #{current_laboratory.id}") - @relate_subject = @shixun.subjects.joins(:laboratory_subjects).where("laboratory_subjects.laboratory_id != #{current_laboratory.id} and - subjects.hidden=0 and subjects.status=2") - else - # @relate_subject = @shixun.subjects.visible.unhidden.uniq.joins(:laboratory_subjects).where(laboratory_subjects: { laboratory_id: current_laboratory.id }) - @relate_subject = @shixun.subjects.joins(:laboratory_subjects).where("laboratory_subjects.laboratory_id != #{current_laboratory.id} and - subjects.hidden=0 and subjects.status=2") - end end # 排行榜 diff --git a/app/views/shixuns/_right.json.jbuilder b/app/views/shixuns/_right.json.jbuilder index f42633d86..e6f839aa5 100644 --- a/app/views/shixuns/_right.json.jbuilder +++ b/app/views/shixuns/_right.json.jbuilder @@ -5,7 +5,7 @@ end # 相关路径 json.paths do - json.partial! 'subjects/subject', locals: {subjects: @relate_subject} + json.partial! 'subjects/subject', locals: {subjects: shixun.relation_path} end # 推荐实训 From 8ee4afda79f412b699aeee987e2937890ea9becb Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Mon, 18 Nov 2019 11:02:49 +0800 Subject: [PATCH 05/19] =?UTF-8?q?=E4=BA=91=E4=B8=8A=E5=AE=9E=E9=AA=8C?= =?UTF-8?q?=E5=AE=A4fork=E7=89=88=E6=9C=AC=E5=BA=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../admins/laboratory_subjects_controller.rb | 2 +- app/services/subjects/copy_subject_service.rb | 23 +++++++++++-------- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/app/controllers/admins/laboratory_subjects_controller.rb b/app/controllers/admins/laboratory_subjects_controller.rb index e534c6b4b..866a20a76 100644 --- a/app/controllers/admins/laboratory_subjects_controller.rb +++ b/app/controllers/admins/laboratory_subjects_controller.rb @@ -10,7 +10,7 @@ class Admins::LaboratorySubjectsController < Admins::BaseController def create subject = Subject.find(params[:subject_id]) - Subjects::CopySubjectService.call(subject, current_user.id, current_laboratory) + Subjects::CopySubjectService.call(subject, current_user, current_laboratory) render_ok end diff --git a/app/services/subjects/copy_subject_service.rb b/app/services/subjects/copy_subject_service.rb index 7d32189a5..5f8481cae 100644 --- a/app/services/subjects/copy_subject_service.rb +++ b/app/services/subjects/copy_subject_service.rb @@ -1,9 +1,9 @@ class Subjects::CopySubjectService < ApplicationService - attr_reader :subject, :to_subject, :user_id, :laboratory + attr_reader :subject, :to_subject, :user, :laboratory - def initialize(subject, user_id, laboratory=nil) + def initialize(subject, user, laboratory=nil) @subject = subject - @user_id = user_id + @user = user @laboratory = laboratory subject_params = subject.attributes.dup.except('id', 'copy_subject_id', 'user_id', 'homepage_show') @to_subject = Subject.new(subject_params) @@ -21,7 +21,7 @@ class Subjects::CopySubjectService < ApplicationService # 复制实践课程表 def copy_subject! to_subject.copy_subject_id = subject.id - to_subject.user_id = user_id + to_subject.user_id = user.id to_subject.save! copy_stages_data!(subject, to_subject) @@ -34,7 +34,7 @@ class Subjects::CopySubjectService < ApplicationService subject.stages.each do |stage| to_stage = to_subject.stages.new to_stage.attributes = stage.attributes.dup.except('id', 'subject_id', 'user_id') - to_stage.user_id = user_id + to_stage.user_id = user.id to_stage.save! copy_stage_shixuns_data!(stage, to_stage) @@ -61,10 +61,15 @@ class Subjects::CopySubjectService < ApplicationService to_shixun.attributes = shixun.attributes.dup.except('id', 'user_id', 'identifier', 'homepage_show', 'use_scope', 'averge_star', 'myshixuns_count') to_shixun.identifier = Util::UUID.generate_identifier(Shixun, 8) - to_shixun.user_id = user_id + to_shixun.user_id = user.id if laboratory to_shixun.laboratory_id = laboratory.id end + # 复制版本库 + fork_repository_name = "#{user.login}/#{to_shixun.identifier}" + GitService.fork_repository(repo_path: "#{shixun.repo_name}.git", + fork_repository_path: (fork_repository_name + ".git")) + to_shixun.repo_name = fork_repository_name to_shixun.save! copy_shixun_info_data!(shixun, to_shixun) @@ -124,7 +129,7 @@ class Subjects::CopySubjectService < ApplicationService shixun.challenges.each do |challenge| to_challenge = to_shixun.challenges.new to_challenge.attributes = challenge.attributes.dup.except('id', 'shixun_id', 'praises_count', 'user_id', 'visits') - to_challenge.user_id = user_id + to_challenge.user_id = user.id to_challenge.shixun_id = to_shixun.id to_challenge.save! @@ -201,12 +206,12 @@ class Subjects::CopySubjectService < ApplicationService # 创建实训成员 def copy_shixun_members_data!(to_shixun) - to_shixun.shixun_members.create!(user_id: user_id, role: 1) + to_shixun.shixun_members.create!(user_id: user.id, role: 1) end # 创建课程成员 def copy_subject_members_data(to_subject) - to_subject.subject_members.create!(user_id: user_id, role: 1) + to_subject.subject_members.create!(user_id: user.id, role: 1) end end From f1c69deb06ec80ce78d33c6d0be665c40ca909de Mon Sep 17 00:00:00 2001 From: jingquan huang Date: Mon, 18 Nov 2019 11:55:59 +0800 Subject: [PATCH 06/19] =?UTF-8?q?=E4=BA=91=E4=B8=8A=E5=AE=9E=E9=AA=8C?= =?UTF-8?q?=E5=AE=A4=E4=BC=81=E4=B8=9A=E7=89=88=E7=89=88=E6=9C=AC=E5=BA=93?= =?UTF-8?q?=E8=BF=81=E7=A7=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/tasks/shixun_rep.rake | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 lib/tasks/shixun_rep.rake diff --git a/lib/tasks/shixun_rep.rake b/lib/tasks/shixun_rep.rake new file mode 100644 index 000000000..d7a2d01b1 --- /dev/null +++ b/lib/tasks/shixun_rep.rake @@ -0,0 +1,14 @@ +# 针对某个企业,如果课程版本库丢失,可以执行命令一键同步企业版本库 +require GitService + +namespace :shixun_sync do + task :repo => :environment do + subject_id = ENV['args'].split(",")[0].to_i # 课程id + subject = Subject.find_by(subject_id) + subject.shixuns.try(:each) do |shixun| + username = shixun.owner.try(:login) + new_repo_name = "#{username.try(:strip)}/#{shixun.try(:identifier)}#{ Time.now.strftime("%Y%m%d%H%M%S")}" + GitService.fork_repository(repo_path: "#{shixun.try(:repo_name)}.git", fork_repository_path: (new_repo_name + ".git")) + end + end +end \ No newline at end of file From 7edcc97b749bd456bab645253a3ab53d2ed39062 Mon Sep 17 00:00:00 2001 From: jingquan huang Date: Mon, 18 Nov 2019 13:53:48 +0800 Subject: [PATCH 07/19] =?UTF-8?q?=E5=AE=9E=E8=AE=ADfork=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/tasks/shixun_rep.rake | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/tasks/shixun_rep.rake b/lib/tasks/shixun_rep.rake index d7a2d01b1..0d5f0e82a 100644 --- a/lib/tasks/shixun_rep.rake +++ b/lib/tasks/shixun_rep.rake @@ -1,5 +1,6 @@ # 针对某个企业,如果课程版本库丢失,可以执行命令一键同步企业版本库 require GitService +include GitHelper namespace :shixun_sync do task :repo => :environment do @@ -7,8 +8,10 @@ namespace :shixun_sync do subject = Subject.find_by(subject_id) subject.shixuns.try(:each) do |shixun| username = shixun.owner.try(:login) - new_repo_name = "#{username.try(:strip)}/#{shixun.try(:identifier)}#{ Time.now.strftime("%Y%m%d%H%M%S")}" - GitService.fork_repository(repo_path: "#{shixun.try(:repo_name)}.git", fork_repository_path: (new_repo_name + ".git")) + # new_repo_name = "#{username.try(:strip)}/#{shixun.try(:identifier)}#{ Time.now.strftime("%Y%m%d%H%M%S")}" + # GitService.fork_repository(repo_path: "#{shixun.try(:repo_name)}.git", fork_repository_path: (new_repo_name + ".git")) + + project_fork(shixun, "#{shixun.try(:repo_name)}.git", username) end end end \ No newline at end of file From d5f83aebc828add70ce9243692c9e81b83201cd3 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Mon, 18 Nov 2019 14:04:20 +0800 Subject: [PATCH 08/19] =?UTF-8?q?=E5=85=88=E6=B5=8B=E8=AF=95=E8=BF=81?= =?UTF-8?q?=E7=A7=BB=E4=BB=BB=E5=8A=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/services/subjects/copy_subject_service.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/services/subjects/copy_subject_service.rb b/app/services/subjects/copy_subject_service.rb index 5f8481cae..51eaf9342 100644 --- a/app/services/subjects/copy_subject_service.rb +++ b/app/services/subjects/copy_subject_service.rb @@ -66,10 +66,10 @@ class Subjects::CopySubjectService < ApplicationService to_shixun.laboratory_id = laboratory.id end # 复制版本库 - fork_repository_name = "#{user.login}/#{to_shixun.identifier}" - GitService.fork_repository(repo_path: "#{shixun.repo_name}.git", - fork_repository_path: (fork_repository_name + ".git")) - to_shixun.repo_name = fork_repository_name + # fork_repository_name = "#{user.login}/#{to_shixun.identifier}" + # GitService.fork_repository(repo_path: "#{shixun.repo_name}.git", + # fork_repository_path: (fork_repository_name + ".git")) + # to_shixun.repo_name = fork_repository_name to_shixun.save! copy_shixun_info_data!(shixun, to_shixun) From 72b9e394a918cf399d09db7151e1d13b5fc5ca0b Mon Sep 17 00:00:00 2001 From: jingquan huang Date: Mon, 18 Nov 2019 14:18:03 +0800 Subject: [PATCH 09/19] =?UTF-8?q?=E8=BF=81=E7=A7=BB=E4=BB=BB=E5=8A=A1?= =?UTF-8?q?=E5=BC=95=E5=85=A5=E5=8C=85=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/concerns/git_helper.rb | 2 +- lib/tasks/shixun_rep.rake | 10 +++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/app/controllers/concerns/git_helper.rb b/app/controllers/concerns/git_helper.rb index 9242b87ac..085fec360 100644 --- a/app/controllers/concerns/git_helper.rb +++ b/app/controllers/concerns/git_helper.rb @@ -50,7 +50,7 @@ module GitHelper raise Educoder::TipException.new("fork源路径为空,fork失败!") if original_rep_path.blank? # 将要生成的仓库名字 new_repo_name = "#{username.try(:strip)}/#{container.try(:identifier)}#{ Time.now.strftime("%Y%m%d%H%M%S")}" - uid_logger("start fork container: repo_name is #{new_repo_name}") + # uid_logger("start fork container: repo_name is #{new_repo_name}") GitService.fork_repository(repo_path: original_rep_path, fork_repository_path: (new_repo_name + ".git")) container.update_attributes!(:repo_name => new_repo_name) end diff --git a/lib/tasks/shixun_rep.rake b/lib/tasks/shixun_rep.rake index 0d5f0e82a..4ebe9cefe 100644 --- a/lib/tasks/shixun_rep.rake +++ b/lib/tasks/shixun_rep.rake @@ -1,10 +1,14 @@ # 针对某个企业,如果课程版本库丢失,可以执行命令一键同步企业版本库 -require GitService -include GitHelper + namespace :shixun_sync do task :repo => :environment do - subject_id = ENV['args'].split(",")[0].to_i # 课程id + # require GitService + include GitHelper + include LoggerHelper + + subject_id = ENV['args'].to_s # 课程id + puts subject_id subject = Subject.find_by(subject_id) subject.shixuns.try(:each) do |shixun| username = shixun.owner.try(:login) From 92f675385c43e050833df78b006eb7d7962001c5 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Mon, 18 Nov 2019 14:40:17 +0800 Subject: [PATCH 10/19] 1 --- lib/tasks/shixun_rep.rake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/tasks/shixun_rep.rake b/lib/tasks/shixun_rep.rake index 4ebe9cefe..cdae36c35 100644 --- a/lib/tasks/shixun_rep.rake +++ b/lib/tasks/shixun_rep.rake @@ -14,7 +14,7 @@ namespace :shixun_sync do username = shixun.owner.try(:login) # new_repo_name = "#{username.try(:strip)}/#{shixun.try(:identifier)}#{ Time.now.strftime("%Y%m%d%H%M%S")}" # GitService.fork_repository(repo_path: "#{shixun.try(:repo_name)}.git", fork_repository_path: (new_repo_name + ".git")) - + puts "#############{username}" project_fork(shixun, "#{shixun.try(:repo_name)}.git", username) end end From a153c7f3f7784e2a448576891e76a17b2f0bc47b Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Mon, 18 Nov 2019 14:50:29 +0800 Subject: [PATCH 11/19] fixbug --- lib/tasks/shixun_rep.rake | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/tasks/shixun_rep.rake b/lib/tasks/shixun_rep.rake index cdae36c35..27ba7edf5 100644 --- a/lib/tasks/shixun_rep.rake +++ b/lib/tasks/shixun_rep.rake @@ -9,12 +9,13 @@ namespace :shixun_sync do subject_id = ENV['args'].to_s # 课程id puts subject_id - subject = Subject.find_by(subject_id) + subject = Subject.find_by(id: subject_id) subject.shixuns.try(:each) do |shixun| username = shixun.owner.try(:login) # new_repo_name = "#{username.try(:strip)}/#{shixun.try(:identifier)}#{ Time.now.strftime("%Y%m%d%H%M%S")}" # GitService.fork_repository(repo_path: "#{shixun.try(:repo_name)}.git", fork_repository_path: (new_repo_name + ".git")) - puts "#############{username}" + + puts "#############{shixun.id}" project_fork(shixun, "#{shixun.try(:repo_name)}.git", username) end end From 217941434c73fafe075975e47d5477a1bfd7958b Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Mon, 18 Nov 2019 14:56:59 +0800 Subject: [PATCH 12/19] fixbug --- app/services/subjects/copy_subject_service.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/services/subjects/copy_subject_service.rb b/app/services/subjects/copy_subject_service.rb index 51eaf9342..5f8481cae 100644 --- a/app/services/subjects/copy_subject_service.rb +++ b/app/services/subjects/copy_subject_service.rb @@ -66,10 +66,10 @@ class Subjects::CopySubjectService < ApplicationService to_shixun.laboratory_id = laboratory.id end # 复制版本库 - # fork_repository_name = "#{user.login}/#{to_shixun.identifier}" - # GitService.fork_repository(repo_path: "#{shixun.repo_name}.git", - # fork_repository_path: (fork_repository_name + ".git")) - # to_shixun.repo_name = fork_repository_name + fork_repository_name = "#{user.login}/#{to_shixun.identifier}" + GitService.fork_repository(repo_path: "#{shixun.repo_name}.git", + fork_repository_path: (fork_repository_name + ".git")) + to_shixun.repo_name = fork_repository_name to_shixun.save! copy_shixun_info_data!(shixun, to_shixun) From dc3672f2d7f8f790661b4a0cc6dec4bffb5bb590 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Mon, 18 Nov 2019 15:58:30 +0800 Subject: [PATCH 13/19] =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/courses_controller.rb | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb index 7ebf7435d..c0c2cda3f 100644 --- a/app/controllers/courses_controller.rb +++ b/app/controllers/courses_controller.rb @@ -796,18 +796,15 @@ class CoursesController < ApplicationController if approval == 1 course_message.pass! - new_teacher = CourseMember.new(course_id: @course.id, user_id: applier_user.id) content = course_message.content.to_i - if content == 3 || content == 7 - tip_exception("已存在教师/助教身份") if CourseMember.where(course_id: @course.id, user_id: applier_user.id, role: 3).any? - new_teacher.ASSISTANT_PROFESSOR! - elsif content == 2 || content == 9 - tip_exception("已存在教师/助教身份") if CourseMember.where(course_id: @course.id, user_id: applier_user.id, role: 2).any? - new_teacher.PROFESSOR! + role = (content == 3 || content == 7) ? 3 : ((content == 2 || content == 9) ? 2 : nil) + if role + tip_exception("已存在教师/助教身份") if CourseMember.where(course_id: @course.id, user_id: applier_user.id, role: [1, 2 ,3]).any? else tip_exception("申请角色错误") end + new_teacher = CourseMember.new(course_id: @course.id, user_id: applier_user.id, role: role) new_teacher.save! # 课堂管理员才有分配权限,且课堂分班数大于0 From c4f018d274d68bd8319e5a08d7b12fc1e1419f90 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Mon, 18 Nov 2019 16:01:26 +0800 Subject: [PATCH 14/19] =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/courses_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb index c0c2cda3f..323e313dc 100644 --- a/app/controllers/courses_controller.rb +++ b/app/controllers/courses_controller.rb @@ -827,7 +827,7 @@ class CoursesController < ApplicationController normal_status(0, "操作成功") rescue => e uid_logger_error(e.message) - tip_exception("操作失败") + tip_exception(e.message) raise ActiveRecord::Rollback end end From 239674ca75b629d95c96fe0ecafb01ac4619fc06 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Mon, 18 Nov 2019 16:08:59 +0800 Subject: [PATCH 15/19] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E8=A7=92=E8=89=B2?= =?UTF-8?q?=E4=B8=BA=E8=80=81=E5=B8=88=E6=97=B6=E5=BA=94=E6=9B=B4=E6=96=B0?= =?UTF-8?q?=E7=94=B3=E8=AF=B7=E8=AE=B0=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/courses_controller.rb | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb index 323e313dc..7e2432fc4 100644 --- a/app/controllers/courses_controller.rb +++ b/app/controllers/courses_controller.rb @@ -633,6 +633,9 @@ class CoursesController < ApplicationController teacher_member = course_members.where(role: %i[CREATOR]).take elsif (params[:roles].include?("PROFESSOR") || params[:roles].include?("ASSISTANT_PROFESSOR")) && !course_members.exists?(role: %i[PROFESSOR ASSISTANT_PROFESSOR]) teacher_member = CourseMember.create!(course_id: @course.id, user_id: params[:user_id], role: params[:roles].include?("PROFESSOR") ? 2 : 3) + # 如果有未审批的申请教师/助教的记录,则修改状态为已审批 + apply_teacher = CourseMessage.where(course_id: @course.id, course_message_id: params[:user_id], status: 0).last + apply_teacher.update!(status: 1, apply_user_id: current_user.id) elsif course_members.exists?(role: %i[PROFESSOR ASSISTANT_PROFESSOR]) teacher_member = course_members.where(role: %i[PROFESSOR ASSISTANT_PROFESSOR]).take if params[:roles].include?("PROFESSOR") || params[:roles].include?("ASSISTANT_PROFESSOR") From 3876d69b292648832865e73de4815081831dc452 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Mon, 18 Nov 2019 16:20:32 +0800 Subject: [PATCH 16/19] =?UTF-8?q?=E7=AB=9E=E8=B5=9B=E6=8E=92=E8=A1=8C?= =?UTF-8?q?=E6=A6=9C=E7=9A=84=E6=98=BE=E7=A4=BA=E6=9D=A1=E6=95=B0=E5=BA=94?= =?UTF-8?q?=E8=AF=A5=E6=97=B6=E9=85=8D=E7=BD=AE=E9=A1=B5=E7=9A=84=E6=80=BB?= =?UTF-8?q?=E5=A5=96=E9=A1=B9=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/competitions/competitions_controller.rb | 2 +- app/models/competition.rb | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/controllers/competitions/competitions_controller.rb b/app/controllers/competitions/competitions_controller.rb index 829251c38..72f53d1e2 100644 --- a/app/controllers/competitions/competitions_controller.rb +++ b/app/controllers/competitions/competitions_controller.rb @@ -143,7 +143,7 @@ class Competitions::CompetitionsController < Competitions::BaseController } end else - @records = @records.includes(:team_members, competition_prize_users: :competition_prize, user: :user_extension).limit(@competition.awards_count) + @records = @records.includes(:team_members, competition_prize_users: :competition_prize, user: :user_extension).limit(@competition.charts_count) end end diff --git a/app/models/competition.rb b/app/models/competition.rb index aa87e9ef5..0ffd1c7a5 100644 --- a/app/models/competition.rb +++ b/app/models/competition.rb @@ -149,9 +149,9 @@ class Competition < ApplicationRecord competition_stages.map(&:max_end_time).max end - # def awards_count - # competition_awards.pluck(:num)&.sum > 0 ? competition_awards.pluck(:num)&.sum : 20 - # end + def charts_count + competition_awards.pluck(:num)&.sum > 0 ? competition_awards.pluck(:num)&.sum : awards_count + end def manager?(user) user && competition_managers.exists?(user_id: user.id) From 457d4d922899e291d418d1c28dc06618c69ee9b9 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Mon, 18 Nov 2019 16:29:49 +0800 Subject: [PATCH 17/19] =?UTF-8?q?=E6=8E=92=E8=A1=8C=E6=A6=9C=E8=B0=83?= =?UTF-8?q?=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/competition.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/competition.rb b/app/models/competition.rb index 0ffd1c7a5..bb21f0ef8 100644 --- a/app/models/competition.rb +++ b/app/models/competition.rb @@ -150,7 +150,7 @@ class Competition < ApplicationRecord end def charts_count - competition_awards.pluck(:num)&.sum > 0 ? competition_awards.pluck(:num)&.sum : awards_count + competition_awards.pluck(:num)&.sum.to_i > 0 ? competition_awards.pluck(:num)&.sum.to_i : awards_count end def manager?(user) From 666def7e8cca2348d87f6b73dd81cff55914a63f Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Mon, 18 Nov 2019 16:40:06 +0800 Subject: [PATCH 18/19] =?UTF-8?q?=E6=8E=92=E8=A1=8C=E6=A6=9C=E8=B0=83?= =?UTF-8?q?=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/competition.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/competition.rb b/app/models/competition.rb index bb21f0ef8..23fa268ec 100644 --- a/app/models/competition.rb +++ b/app/models/competition.rb @@ -150,7 +150,7 @@ class Competition < ApplicationRecord end def charts_count - competition_awards.pluck(:num)&.sum.to_i > 0 ? competition_awards.pluck(:num)&.sum.to_i : awards_count + competition_prizes&.pluck(:num).sum.to_i > 0 ? competition_prizes&.pluck(:num).sum.to_i : awards_count end def manager?(user) From ec157c5892017cad0c89af7668510ec75d54bcb4 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Mon, 18 Nov 2019 19:27:08 +0800 Subject: [PATCH 19/19] =?UTF-8?q?=E5=B0=8F=E7=A8=8B=E5=BA=8F=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/weapps/courses_controller.rb | 22 ++++++++++++++++++- .../courses/apply_teachers.json.jbuilder | 1 + .../search_teacher_candidate.json.jbuilder | 2 ++ .../weapps/courses/teachers.json.jbuilder | 16 ++++++++++++++ config/routes.rb | 1 + 5 files changed, 41 insertions(+), 1 deletion(-) create mode 100644 app/views/weapps/courses/teachers.json.jbuilder diff --git a/app/controllers/weapps/courses_controller.rb b/app/controllers/weapps/courses_controller.rb index a81446cea..db55a9511 100644 --- a/app/controllers/weapps/courses_controller.rb +++ b/app/controllers/weapps/courses_controller.rb @@ -1,5 +1,6 @@ class Weapps::CoursesController < Weapps::BaseController before_action :require_login + before_action :user_course_identity, except: [:create] before_action :teacher_allowed, except: [:create, :show, :shixun_homework_category] def create @@ -30,6 +31,25 @@ class Weapps::CoursesController < Weapps::BaseController @categories = current_course.shixun_course_modules.first&.course_second_categories end + # 教师列表 + def teachers + @course = current_course + if @course.try(:id) != 1309 || current_user.admin? || current_user.try(:id) == 15582 + @teacher_list = @course.course_members.joins(:user).where("course_members.role in (1, 2, 3)") + else + @teacher_list = @course.course_members.joins(:user).where("(course_members.role in (1, 3) or (course_members.user_id = #{current_user.id} + and course_members.role = 2))") + end + + @teacher_list_size = @teacher_list.size + + @applications_size = CourseMessage.unhandled_join_course_requests_by_course(@course).size + + @teacher_list = @teacher_list.preload(user: [user_extension: :school]).order("CONVERT(CONCAT(users.lastname, users.firstname) USING gbk) COLLATE gbk_chinese_ci asc") + end + + + private def course_params @@ -45,6 +65,6 @@ class Weapps::CoursesController < Weapps::BaseController end def teacher_allowed - return render_forbidden unless current_user.course_identity(current_course) < Course::STUDENT + return render_forbidden unless @user_course_identity < Course::STUDENT end end \ No newline at end of file diff --git a/app/views/courses/apply_teachers.json.jbuilder b/app/views/courses/apply_teachers.json.jbuilder index aee0803b4..bd88d5fbe 100644 --- a/app/views/courses/apply_teachers.json.jbuilder +++ b/app/views/courses/apply_teachers.json.jbuilder @@ -8,6 +8,7 @@ json.application_list do json.name application.application_user.real_name json.name_link user_path(application.application_user) json.login application.application_user.login + json.image_url url_to_avatar(application.application_user) json.role application.content.to_i == 3 || application.content.to_i == 7 ? "助教" : application.content.to_i == 2 || application.content.to_i == 9 ? "教师" : "" end end \ No newline at end of file diff --git a/app/views/courses/search_teacher_candidate.json.jbuilder b/app/views/courses/search_teacher_candidate.json.jbuilder index af3310fb7..cfe781165 100644 --- a/app/views/courses/search_teacher_candidate.json.jbuilder +++ b/app/views/courses/search_teacher_candidate.json.jbuilder @@ -7,6 +7,8 @@ json.candidates do json.school_name user.user_extension.school.try(:name) json.school_id user.user_extension.school.try(:id) json.added @course.course_member?(user.id, [1, 2, 3]) + json.image_url url_to_avatar(user) + json.phone user.hidden_phone end end json.candidates_count @users_size \ No newline at end of file diff --git a/app/views/weapps/courses/teachers.json.jbuilder b/app/views/weapps/courses/teachers.json.jbuilder new file mode 100644 index 000000000..0d89ca814 --- /dev/null +++ b/app/views/weapps/courses/teachers.json.jbuilder @@ -0,0 +1,16 @@ +json.teacher_list do + json.array! @teacher_list do |teacher| + json.course_member_id teacher.id + json.name teacher.user.real_name + json.login teacher.user.login + json.user_id teacher.user.id + json.role teacher.role == "CREATOR" ? "管理员" : teacher.role == "PROFESSOR" ? "教师" : "助教" + json.school teacher.user&.school_name + json.image_url url_to_avatar(teacher.user) + # if @user_course_identity < Course::ASSISTANT_PROFESSOR + # json.member_roles teacher.user.course_role(@course) + # end + end +end +json.teacher_list_size @teacher_list_size +json.apply_size @applications_size \ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index 356f6393c..7c7b95820 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -883,6 +883,7 @@ Rails.application.routes.draw do resources :courses, only: [:create, :update, :edit, :show] do member do get :shixun_homework_category + get :teachers end end end