From 32479e4d3a8f4ffeff1dda8e7e22243a8fd54db9 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Sat, 22 Jun 2019 15:22:57 +0800 Subject: [PATCH 01/18] =?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/graduation_tasks_controller.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/controllers/graduation_tasks_controller.rb b/app/controllers/graduation_tasks_controller.rb index a1f1d01c4..2e72c57d3 100644 --- a/app/controllers/graduation_tasks_controller.rb +++ b/app/controllers/graduation_tasks_controller.rb @@ -109,8 +109,8 @@ class GraduationTasksController < ApplicationController end # 排序 - rorder = params[:order] || "updated_at" - b_order = params[:b_order] || "desc" + rorder = params[:order].blank? ? "updated_at" : params[:order] + b_order = params[:b_order].blank? ? "desc" : params[:b_order] if rorder == "created_at" || rorder == "work_score" @work_list = @work_list.order("graduation_works.#{rorder} #{b_order}") elsif rorder == "student_id" From 2fa4e118feade84bf0a5a397db170f3ed2dc3431 Mon Sep 17 00:00:00 2001 From: jingquan huang Date: Sat, 22 Jun 2019 16:33:17 +0800 Subject: [PATCH 02/18] =?UTF-8?q?git=20=E6=8F=90=E4=BA=A4=E8=AE=B0?= =?UTF-8?q?=E5=BD=95=E6=B2=A1=E5=AE=9A=E4=BD=8D=E5=88=B0=E5=85=B7=E4=BD=93?= =?UTF-8?q?=E7=94=A8=E6=88=B7=E7=9A=84=E6=97=B6=E5=80=99=E5=A4=84=E7=90=86?= =?UTF-8?q?=E6=96=B9=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/shixuns/_commit.json.jbuilder | 1 + 1 file changed, 1 insertion(+) diff --git a/app/views/shixuns/_commit.json.jbuilder b/app/views/shixuns/_commit.json.jbuilder index cd934baea..b752affb6 100644 --- a/app/views/shixuns/_commit.json.jbuilder +++ b/app/views/shixuns/_commit.json.jbuilder @@ -14,6 +14,7 @@ json.commits commits do |commit| json.author do json.id nil json.login nil + json.image_url "avatars/User/b" json.name commit["author_name"] json.email commit["author_email"] end From 08861416f2f1c7fdad04bf4e00be6781d321d874 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Sat, 22 Jun 2019 16:52:28 +0800 Subject: [PATCH 03/18] =?UTF-8?q?TPI=E5=A4=B4=E5=83=8F=E7=82=B9=E5=87=BB?= =?UTF-8?q?=E8=B7=B3=E8=BD=AC=E6=9C=89=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/users/_user.json.jbuilder | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/users/_user.json.jbuilder b/app/views/users/_user.json.jbuilder index 1d26506f3..8c5f58265 100644 --- a/app/views/users/_user.json.jbuilder +++ b/app/views/users/_user.json.jbuilder @@ -4,5 +4,5 @@ json.name user.full_name json.grade user.grade # json.email user.mail # 邮箱原则上不暴露的,如果实在需要的话只能对某些具体的接口公开 json.image_url url_to_avatar(user) -json.user_url user_path(user) +json.user_url "/users/#{user.login}" json.school user.school_name \ No newline at end of file From db67ed37fadf7751851e41e54193fe974e8ed45c Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Sat, 22 Jun 2019 16:54:55 +0800 Subject: [PATCH 04/18] =?UTF-8?q?=E5=88=A0=E9=99=A4tpi=E7=9A=84user=5Furl?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/users/_user.json.jbuilder | 1 - 1 file changed, 1 deletion(-) diff --git a/app/views/users/_user.json.jbuilder b/app/views/users/_user.json.jbuilder index 8c5f58265..afec979a1 100644 --- a/app/views/users/_user.json.jbuilder +++ b/app/views/users/_user.json.jbuilder @@ -4,5 +4,4 @@ json.name user.full_name json.grade user.grade # json.email user.mail # 邮箱原则上不暴露的,如果实在需要的话只能对某些具体的接口公开 json.image_url url_to_avatar(user) -json.user_url "/users/#{user.login}" json.school user.school_name \ No newline at end of file From 66c2f52f4896491dee0e3985a005bc995003ab3f Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Sat, 22 Jun 2019 16:56:47 +0800 Subject: [PATCH 05/18] =?UTF-8?q?user.jbuider=E8=BF=98=E6=98=AF=E9=9C=80?= =?UTF-8?q?=E8=A6=81user=5Furl=E4=BA=86=EF=BC=8C=E5=A4=AA=E5=A4=9A?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3=E8=B0=83=E7=94=A8=E5=89=8D=E7=AB=AF=E6=94=B9?= =?UTF-8?q?=E7=9A=84=E5=A4=AA=E9=BA=BB=E7=83=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/users/_user.json.jbuilder | 1 + 1 file changed, 1 insertion(+) diff --git a/app/views/users/_user.json.jbuilder b/app/views/users/_user.json.jbuilder index afec979a1..8c5f58265 100644 --- a/app/views/users/_user.json.jbuilder +++ b/app/views/users/_user.json.jbuilder @@ -4,4 +4,5 @@ json.name user.full_name json.grade user.grade # json.email user.mail # 邮箱原则上不暴露的,如果实在需要的话只能对某些具体的接口公开 json.image_url url_to_avatar(user) +json.user_url "/users/#{user.login}" json.school user.school_name \ No newline at end of file From d335f9315e20b51910032d3ae160d8a41dc71907 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Sat, 22 Jun 2019 16:59:32 +0800 Subject: [PATCH 06/18] =?UTF-8?q?tpi=E6=8E=A5=E5=8F=A3=E5=8E=BB=E9=99=A4us?= =?UTF-8?q?er=5Furl?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/users/_user.json.jbuilder | 1 - 1 file changed, 1 deletion(-) diff --git a/app/views/users/_user.json.jbuilder b/app/views/users/_user.json.jbuilder index 8c5f58265..afec979a1 100644 --- a/app/views/users/_user.json.jbuilder +++ b/app/views/users/_user.json.jbuilder @@ -4,5 +4,4 @@ json.name user.full_name json.grade user.grade # json.email user.mail # 邮箱原则上不暴露的,如果实在需要的话只能对某些具体的接口公开 json.image_url url_to_avatar(user) -json.user_url "/users/#{user.login}" json.school user.school_name \ No newline at end of file From 28ae66071901ab1b3ecdff6c971afd34f613d9c7 Mon Sep 17 00:00:00 2001 From: jingquan huang Date: Sat, 22 Jun 2019 17:07:08 +0800 Subject: [PATCH 07/18] =?UTF-8?q?=E8=AE=A4=E8=AF=81=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/application_controller.rb | 27 ++++++++++++----------- app/controllers/shixuns_controller.rb | 2 +- 2 files changed, 15 insertions(+), 14 deletions(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 1915281bf..1fffc0cb7 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -176,19 +176,20 @@ class ApplicationController < ActionController::Base # 系统全局认证 # def check_auth - old_edu_host = edu_setting('old_edu_host') - ue = current_user.user_extension - - if current_user.lastname.blank? || ue.school_id.blank? || ue.identity.blank? || current_user.mail.blank? - info_url = old_edu_host + '/account/user_info' - render :json => { status: 402, url: info_url } - elsif current_user.certification != 1 - day_cer = UserDayCertification.where(user_id: current_user.id).last - unless (Time.now.to_i - day_cer.try(:created_at).to_i) < 86400 - account_url = old_edu_host + "/my/account" - render :json => { status: 402, url: account_url } - end - end + # old_edu_host = edu_setting('old_edu_host') + # ue = current_user.user_extension + # + # if current_user.lastname.blank? || ue.school_id.blank? || ue.identity.blank? || current_user.mail.blank? + # info_url = old_edu_host + '/account/user_info' + # render :json => { status: 402, url: info_url } + # elsif current_user.certification != 1 + # day_cer = UserDayCertification.where(user_id: current_user.id).last + # unless (Time.now.to_i - day_cer.try(:created_at).to_i) < 86400 + # account_url = old_edu_host + "/my/account" + # render :json => { status: 402, url: account_url } + # end + # end + true end # 身份资料的认证: diff --git a/app/controllers/shixuns_controller.rb b/app/controllers/shixuns_controller.rb index 6dfa94252..5cc470d61 100644 --- a/app/controllers/shixuns_controller.rb +++ b/app/controllers/shixuns_controller.rb @@ -1,5 +1,5 @@ class ShixunsController < ApplicationController - # before_action :require_login, except: [:download_file, :index, :menus] + before_action :require_login, except: [:download_file, :index, :menus] before_action :check_auth, except: [:download_file, :index] before_action :find_shixun, except: [:index, :new, :create, :menus, :get_recommend_shixuns, :propaedeutics, From 92bd6ea4b5c31924e801806038b4c4737e0d9ccb Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Sat, 22 Jun 2019 17:16:53 +0800 Subject: [PATCH 08/18] =?UTF-8?q?=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/user.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/user.rb b/app/models/user.rb index 0d5517c50..8e25efe70 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -260,7 +260,7 @@ class User < ApplicationRecord # 实训管理员:实训合作者、admin def manager_of_shixun?(shixun) - shixun.shixun_members.exists?(role: [1,2], user_id: id) || admin? + shixun.shixun_members.exists?(role: [1,2], user_id: id) || admin? || business? end # 实训管理员 From fc92232cdea1d4a8e6415355c525d6c14d7378b8 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Sat, 22 Jun 2019 17:50:11 +0800 Subject: [PATCH 09/18] =?UTF-8?q?vnc=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/games_controller.rb | 16 ++++++++++++++++ app/views/games/show.json.jbuilder | 3 +++ 2 files changed, 19 insertions(+) diff --git a/app/controllers/games_controller.rb b/app/controllers/games_controller.rb index 4aa0b13b8..79167150e 100644 --- a/app/controllers/games_controller.rb +++ b/app/controllers/games_controller.rb @@ -62,6 +62,22 @@ class GamesController < ApplicationController praise_count: praise_count, user_praise: user_praise, time_limit: time_limit, tomcat_url: edu_setting('cloud_tomcat_php'), is_teacher: is_teacher, myshixun_manager: myshixun_manager} + if @shixun.vnc + begin + shixun_tomcat = edu_setting('shixun_tomcat') + service_host = edu_setting('vnc_url') + uri = "#{shixun_tomcat}/bridge/vnc/getvnc" + params = {tpiID: @myshixun.id, :containers => "#{Base64.urlsafe_encode64(container_limit(@shixun.mirror_repositories))}"} + res = uri_post uri, params + if res && res['code'].to_i != 0 + raise("实训云平台繁忙(繁忙等级:99)") + end + @url = "http://#{service_host}:#{res['port']}}/vnc_lite.html?password=headless" + Rails.logger.info("66666666sssssss#{url}") + rescue Exception => e + Rails.logger.error(e.message) + end + end # 区分选择题和编程题,st:0编程题; if @st == 0 diff --git a/app/views/games/show.json.jbuilder b/app/views/games/show.json.jbuilder index acbc8c2ef..607a57a15 100644 --- a/app/views/games/show.json.jbuilder +++ b/app/views/games/show.json.jbuilder @@ -1,6 +1,9 @@ json.(@base_date, :st, :discusses_count, :game_count, :record_onsume_time, :prev_game, :next_game, :praise_count, :user_praise, :time_limit, :tomcat_url, :is_teacher, :myshixun_manager, :game, :challenge, :shixun, :myshixun) +if @shixun.vnc + json.vnc_url @vnc_url +end json.user do json.partial! 'users/user', user: @user json.identity @identity From 7b92517d3df36485e2fdfcbecfc679356e76a8ac Mon Sep 17 00:00:00 2001 From: jingquan huang Date: Sat, 22 Jun 2019 18:09:04 +0800 Subject: [PATCH 10/18] =?UTF-8?q?=E8=AF=84=E6=B5=8B=E8=BF=94=E5=9B=9E?= =?UTF-8?q?=E9=97=AE=E9=A2=98=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/myshixuns_controller.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/controllers/myshixuns_controller.rb b/app/controllers/myshixuns_controller.rb index 042945b6e..91cff3c19 100644 --- a/app/controllers/myshixuns_controller.rb +++ b/app/controllers/myshixuns_controller.rb @@ -1,7 +1,7 @@ class MyshixunsController < ApplicationController before_action :require_login, :except => [:training_task_status, :code_runinng_message] - before_action :find_myshixun, :except => [:training_task_status] - before_action :find_repo_name, :except => [:training_task_status] + before_action :find_myshixun, :except => [:training_task_status, :code_runinng_message] + before_action :find_repo_name, :except => [:training_task_status, :code_runinng_message] skip_before_action :verify_authenticity_token, :only => [:html_content] ## TPI关卡列表 From 73de92d405a5c3055a0c47b979e8848f5a752699 Mon Sep 17 00:00:00 2001 From: jingquan huang Date: Sat, 22 Jun 2019 18:13:49 +0800 Subject: [PATCH 11/18] production ignore --- .gitignore | 1 + Gemfile | 4 ++-- .../environments/{development.rb => development.rb.example} | 0 3 files changed, 3 insertions(+), 2 deletions(-) rename config/environments/{development.rb => development.rb.example} (100%) diff --git a/.gitignore b/.gitignore index 309e960d7..4f52644ff 100644 --- a/.gitignore +++ b/.gitignore @@ -47,6 +47,7 @@ public/upload.html /config/configuration.yml +/config/environments/production.rb /config/initializers/gitlab_config.rb /db/schema.rb .vscode/ diff --git a/Gemfile b/Gemfile index dfc9d41fd..f7c7e487a 100644 --- a/Gemfile +++ b/Gemfile @@ -45,12 +45,12 @@ gem 'rqrcode_png' gem 'acts-as-taggable-on', '~> 6.0' -group :development, :test do +group :'development.rb.example', :test do gem 'byebug', platforms: [:mri, :mingw, :x64_mingw] gem 'rspec-rails', '~> 3.8' end -group :development do +group :'development.rb.example' do gem 'awesome_print' gem 'web-console', '>= 3.3.0' gem 'listen', '>= 3.0.5', '< 3.2' diff --git a/config/environments/development.rb b/config/environments/development.rb.example similarity index 100% rename from config/environments/development.rb rename to config/environments/development.rb.example From 8ac11cace5a7f2a157b35e1249f7c781e7065d3e Mon Sep 17 00:00:00 2001 From: jingquan huang Date: Sat, 22 Jun 2019 18:15:36 +0800 Subject: [PATCH 12/18] .. --- config/environments/development.rb | 76 ++++++++++++++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100644 config/environments/development.rb diff --git a/config/environments/development.rb b/config/environments/development.rb new file mode 100644 index 000000000..0b31f5828 --- /dev/null +++ b/config/environments/development.rb @@ -0,0 +1,76 @@ +Rails.application.configure do + # Settings specified here will take precedence over those in config/application.rb. + + # In the development environment your application's code is reloaded on + # every request. This slows down response time but is perfect for development + # since you don't have to restart the web server when you make code changes. + config.cache_classes = false + + # Do not eager load code on boot. + config.eager_load = false + + # Show full error reports. + config.consider_all_requests_local = true + + # Enable/disable caching. By default caching is disabled. + # Run rails dev:cache to toggle caching. + + config.cache_store = :file_store, "#{Rails.root }/files/cache_store/" + + # if Rails.root.join('tmp', 'caching-dev.txt').exist? + # config.action_controller.perform_caching = true + # + # config.cache_store = :memory_store + # config.public_file_server.headers = { + # 'Cache-Control' => "public, max-age=#{2.days.to_i}" + # } + # else + # config.action_controller.perform_caching = false + # + # config.cache_store = :null_store + # end + + # Store uploaded files on the local file system (see config/storage.yml for options) + config.active_storage.service = :local + + # Don't care if the mailer can't send. + config.action_mailer.raise_delivery_errors = false + + config.action_mailer.perform_caching = false + + # Print deprecation notices to the Rails logger. + config.active_support.deprecation = :log + + # Raise an error on page load if there are pending migrations. + config.active_record.migration_error = :page_load + + # Highlight code that triggered database queries in logs. + config.active_record.verbose_query_logs = true + + # Debug mode disables concatenation and preprocessing of assets. + # This option may cause significant delays in view rendering with a large + # number of complex assets. + config.assets.debug = true + + # Suppress logger output for asset requests. + config.assets.quiet = true + + # Raises error for missing translations + # config.action_view.raise_on_missing_translations = true + + # Use an evented file watcher to asynchronously detect changes in source code, + # routes, locales, etc. This feature depends on the listen gem. + config.file_watcher = ActiveSupport::EventedFileUpdateChecker + + config.action_controller.perform_caching = true + + config.action_mailer.delivery_method = :smtp + config.action_mailer.smtp_settings = { + address: 'smtp.exmail.qq.com', + port: 25, + domain: 'smtp.qq.com', + user_name: 'educoder@trustie.org', + password: 'mAZc9EWbe2Kawaqo2', + authentication: 'login', + enable_starttls_auto: true } +end From 5ad7840fb4f6ee1b47cb23eede31b488168c96b7 Mon Sep 17 00:00:00 2001 From: jingquan huang Date: Sat, 22 Jun 2019 18:17:24 +0800 Subject: [PATCH 13/18] development ignore --- config/environments/{production.rb => production.rb.example} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename config/environments/{production.rb => production.rb.example} (100%) diff --git a/config/environments/production.rb b/config/environments/production.rb.example similarity index 100% rename from config/environments/production.rb rename to config/environments/production.rb.example From 26d0e0a917878ce7f4400d71d6a5746035b36591 Mon Sep 17 00:00:00 2001 From: jingquan huang Date: Sat, 22 Jun 2019 19:48:06 +0800 Subject: [PATCH 14/18] =?UTF-8?q?reset=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/shixuns_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/shixuns_controller.rb b/app/controllers/shixuns_controller.rb index 5cc470d61..b11444716 100644 --- a/app/controllers/shixuns_controller.rb +++ b/app/controllers/shixuns_controller.rb @@ -492,7 +492,7 @@ class ShixunsController < ApplicationController if current_myshixun # 如果TPM和TPI的管卡数不相等或者关卡顺序错了,说明实训被极大的改动,需要重置 - if current_myshixun.games.count != @shixun.challenges_count || current_myshixun.games.map(&:challenge_id).sort != Challenge.where(shixun_id: @shixun.id).pluck(:id).sort + if current_myshixun.games.count != @shixun.challenges_count # 这里页面弹框要收到 当前用户myshixun的identifier. tip_show_exception("/myshixuns/#{current_myshixun.try(:identifier)}/reset_my_game") end From 8fc26a69f36f856cc0ee4511228de40b50de75bf Mon Sep 17 00:00:00 2001 From: jingquan huang Date: Sat, 22 Jun 2019 19:50:04 +0800 Subject: [PATCH 15/18] log --- app/controllers/shixuns_controller.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/controllers/shixuns_controller.rb b/app/controllers/shixuns_controller.rb index b11444716..8359b14f9 100644 --- a/app/controllers/shixuns_controller.rb +++ b/app/controllers/shixuns_controller.rb @@ -492,7 +492,8 @@ class ShixunsController < ApplicationController if current_myshixun # 如果TPM和TPI的管卡数不相等或者关卡顺序错了,说明实训被极大的改动,需要重置 - if current_myshixun.games.count != @shixun.challenges_count + uid_logger_error("7777777777777777#{current_myshixun.games.count}, #{@shixun.challenges_count}") + if current_myshixun.games.count != @shixun.challenges_count || current_myshixun.games.map(&:challenge_id).sort != Challenge.where(shixun_id: @shixun.id).pluck(:id).sort # 这里页面弹框要收到 当前用户myshixun的identifier. tip_show_exception("/myshixuns/#{current_myshixun.try(:identifier)}/reset_my_game") end From 7833d10caee5845da43cb3e7c859aeec10294d0d Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Mon, 24 Jun 2019 10:01:15 +0800 Subject: [PATCH 16/18] =?UTF-8?q?=E6=AF=95=E4=B8=9A=E8=AE=BE=E8=AE=A1?= =?UTF-8?q?=E7=9A=84=E5=8B=BE=E9=80=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/courses_controller.rb | 2 +- app/models/course.rb | 2 +- app/models/course_module.rb | 1 + app/views/courses/index.json.jbuilder | 2 +- app/views/users/courses/shared/_course.json.jbuilder | 2 +- 5 files changed, 5 insertions(+), 4 deletions(-) diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb index b76673945..01ce1f6e8 100644 --- a/app/controllers/courses_controller.rb +++ b/app/controllers/courses_controller.rb @@ -913,7 +913,7 @@ class CoursesController < ApplicationController def left_banner @user = current_user @is_teacher = @user.teacher_of_course?(@course) - @course_modules = @course.course_modules.where.not(module_type: "activity").where(hidden: 0) + @course_modules = @course.course_modules.where(hidden: 0) @hidden_modules = @course.course_modules.where(hidden: 1) @second_category_type = ["shixun_homework", "graduation", "attachment", "board", "course_group"] end diff --git a/app/models/course.rb b/app/models/course.rb index a2f5add51..7729a2650 100644 --- a/app/models/course.rb +++ b/app/models/course.rb @@ -7,7 +7,7 @@ class Course < ApplicationRecord has_many :course_infos, dependent: :destroy # 课堂左侧导航栏的模块 - has_many :course_modules, -> {where hidden: 0}, dependent: :destroy + has_many :course_modules, dependent: :destroy has_many :board_course_modules, -> { board_module }, class_name: "CourseModule" has_many :attachment_course_modules, -> { attachment_module }, class_name: "CourseModule" has_many :common_course_modules, -> { common_homework_module }, class_name: "CourseModule" diff --git a/app/models/course_module.rb b/app/models/course_module.rb index 7b96a044f..641c70425 100644 --- a/app/models/course_module.rb +++ b/app/models/course_module.rb @@ -7,6 +7,7 @@ class CourseModule < ApplicationRecord validates :module_name, length: { maximum: 20 } + scope :not_hidden, -> { where(hidden: 0) } scope :graduation_module, -> { where(module_type: "graduation") } scope :graduation_module_not_hidden, -> { graduation_module.where(hidden: 0) } scope :board_module, -> { where(module_type: 'board') } diff --git a/app/views/courses/index.json.jbuilder b/app/views/courses/index.json.jbuilder index 1993851e8..5a128a0b7 100644 --- a/app/views/courses/index.json.jbuilder +++ b/app/views/courses/index.json.jbuilder @@ -12,7 +12,7 @@ json.courses do json.is_public course.is_public json.is_accessible course.is_public == 1 || @user.course_identity(course) < Course::NORMAL json.is_end course.is_end - json.first_category_url module_url(course.course_modules.first, course) + json.first_category_url module_url(course.course_modules.not_hidden.first, course) end end json.courses_count @courses_count diff --git a/app/views/users/courses/shared/_course.json.jbuilder b/app/views/users/courses/shared/_course.json.jbuilder index e5823212e..629f47264 100644 --- a/app/views/users/courses/shared/_course.json.jbuilder +++ b/app/views/users/courses/shared/_course.json.jbuilder @@ -4,7 +4,7 @@ json.members_count course.members_count json.homework_commons_count course.homework_commons_count json.attachments_count course.attachments.count -json.first_category_url module_url(course.course_modules.where.not(module_type: "activity").where(hidden: 0).order(position: :desc).first, course) +json.first_category_url module_url(course.course_modules.where(hidden: 0).order(position: :desc).first, course) json.is_public course.is_public json.can_visited observed_logged_user? || course.can_visited? From d0683cd83cf04e1427c250bf2ed5662c154d1c4e Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Mon, 24 Jun 2019 10:11:49 +0800 Subject: [PATCH 17/18] =?UTF-8?q?=E5=AE=9E=E8=AE=AD=E6=8A=A5=E5=91=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/helpers/student_works_helper.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/helpers/student_works_helper.rb b/app/helpers/student_works_helper.rb index 93a1a3f9a..682bfbf81 100644 --- a/app/helpers/student_works_helper.rb +++ b/app/helpers/student_works_helper.rb @@ -41,7 +41,7 @@ module StudentWorksHelper def student_efficiency(homework_common, work) myshixun_ids = homework_common.student_works.pluck(:myshixun_id) - myshixuns = Myshixun.where(id: myshixun_ids).includes(games: [:outputs]) + myshixuns = Myshixun.where(id: myshixun_ids).includes(:games) #student_works_user_id = homework_common.student_works.pluck(:user_id).uniq #shixun = homework_common.shixuns.first #logger.info("#########shixun_id: ###{shixun.id}") @@ -54,13 +54,13 @@ module StudentWorksHelper objects = myshixuns.map do |myshixun| # 评测次数 - evaluate_count = myshixun.games.inject(0) {|sum, g| sum + g.outputs.pluck(:query_index).first.to_i} + evaluate_count = myshixun.games.sum(:evaluate_count) # 获取最大评测次数 max_evaluate_count = (evaluate_count > max_evaluate_count ? evaluate_count : max_evaluate_count) # 通关耗时 pass_consume_time = (myshixun.games.where(status: 2).pluck(:cost_time).sum / 60.0) # 总耗时 - all_time = (myshixun.games.pluck(:cost_time).sum / 60.0) + all_time = (myshixun.games.sum(:cost_time) / 60.0) # 通关得分 user_total_score = myshixun.total_score.to_i # 耗时,保留2位小数, From 85363ea89f3e5d1e00be00214284914aeeb4a89f Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Mon, 24 Jun 2019 10:26:26 +0800 Subject: [PATCH 18/18] =?UTF-8?q?=E7=94=B3=E8=AF=89=E6=88=90=E5=8A=9F?= =?UTF-8?q?=E5=90=8E=EF=BC=8C=E8=AF=A5=E8=AF=84=E5=88=86=E5=BA=94=E5=A4=B1?= =?UTF-8?q?=E6=95=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/student_works_controller.rb | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/controllers/student_works_controller.rb b/app/controllers/student_works_controller.rb index 9e3a1930c..f4a072a4b 100644 --- a/app/controllers/student_works_controller.rb +++ b/app/controllers/student_works_controller.rb @@ -582,6 +582,9 @@ class StudentWorksController < ApplicationController score_appeal.tidings.update_all(status: 1) if params[:status].to_i == 3 + # 申诉成功后该评分失效 + score.update_attributes(is_invalid: 1) + # 申诉成功后 扣匿评学生的违规匿评扣分 sw = @homework.student_works.find_by(user_id: score.user_id) sw.update_attribute("appeal_penalty", @homework.homework_detail_manual.appeal_penalty + sw.appeal_penalty) if sw.present?