From ff90138997fb1d536709b12eb5727630b17c36e6 Mon Sep 17 00:00:00 2001
From: hjm <63528605@qq.com>
Date: Wed, 16 Oct 2019 09:52:31 +0800
Subject: [PATCH 01/16] =?UTF-8?q?=E9=93=BE=E6=8E=A5?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
public/react/src/modules/tpm/challengesnew/TPMMDEditor.js | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/public/react/src/modules/tpm/challengesnew/TPMMDEditor.js b/public/react/src/modules/tpm/challengesnew/TPMMDEditor.js
index 5d54f514b..2e6184428 100644
--- a/public/react/src/modules/tpm/challengesnew/TPMMDEditor.js
+++ b/public/react/src/modules/tpm/challengesnew/TPMMDEditor.js
@@ -131,7 +131,7 @@ function create_editorMD(id, width, high, placeholder, imageUrl, callback, initV
// Or return editormd.toolbarModes[name]; // full, simple, mini
// Using "||" set icons align right.
- const icons = ["bold", "italic", "|", "list-ul", "list-ol", "|", "code", "code-block", "|", "testIcon", "testIcon1", '|', "image", "table", '|', "watch", "clear"];
+ const icons = ["bold", "italic", "|", "list-ul", "list-ol", "|", "code", "code-block", "link", "|", "testIcon", "testIcon1", '|', "image", "table", '|', "watch", "clear"];
if (__that.props.showNullButton) {
icons.push('nullBtton')
}
From 852f131e3b7e66ac9bbd093fa4af9362ecc7725a Mon Sep 17 00:00:00 2001
From: cxt <853663049@qq.com>
Date: Wed, 16 Oct 2019 10:40:49 +0800
Subject: [PATCH 02/16] =?UTF-8?q?=E7=AB=9E=E8=B5=9B=E7=AE=A1=E7=90=86?=
=?UTF-8?q?=E5=91=98=E9=A1=B5=E9=9D=A2?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../admins/competition_settings_controller.rb | 20 ++++++++++++
.../admins/competitions_controller.rb | 31 +++++++++++++++++++
app/models/competition.rb | 23 ++++++++++++++
.../admins/competition_settings/show.html.erb | 0
.../admins/competitions/enroll_list.html.erb | 0
app/views/admins/competitions/index.html.erb | 4 ++-
.../admins/competitions/online_switch.js.erb | 0
app/views/admins/competitions/publish.js.erb | 0
.../admins/competitions/shared/_list.html.erb | 30 ++++++++++++++++++
.../admins/competitions/shared/_td.html.erb | 27 ++++++++++++++++
.../admins/competitions/unpublish.js.erb | 0
config/routes.rb | 10 +++++-
12 files changed, 143 insertions(+), 2 deletions(-)
create mode 100644 app/controllers/admins/competition_settings_controller.rb
create mode 100644 app/views/admins/competition_settings/show.html.erb
create mode 100644 app/views/admins/competitions/enroll_list.html.erb
create mode 100644 app/views/admins/competitions/online_switch.js.erb
create mode 100644 app/views/admins/competitions/publish.js.erb
create mode 100644 app/views/admins/competitions/shared/_list.html.erb
create mode 100644 app/views/admins/competitions/shared/_td.html.erb
create mode 100644 app/views/admins/competitions/unpublish.js.erb
diff --git a/app/controllers/admins/competition_settings_controller.rb b/app/controllers/admins/competition_settings_controller.rb
new file mode 100644
index 000000000..390ad17e8
--- /dev/null
+++ b/app/controllers/admins/competition_settings_controller.rb
@@ -0,0 +1,20 @@
+class Admins::CompetitionSettingsController < Admins::BaseController
+ def show
+ @competition = current_competition
+ end
+
+ def update
+ Admins::SaveLaboratorySettingService.call(current_competition, form_params)
+ render_ok
+ end
+
+ private
+
+ def current_competition
+ @_current_competition ||= Competition.find(params[:competition_id])
+ end
+
+ def form_params
+ params.permit(:identifier, :name, :nav_logo, :login_logo, :tab_logo, :footer, navbar: %i[name link hidden])
+ end
+end
\ No newline at end of file
diff --git a/app/controllers/admins/competitions_controller.rb b/app/controllers/admins/competitions_controller.rb
index 3d6bef819..3b9b63243 100644
--- a/app/controllers/admins/competitions_controller.rb
+++ b/app/controllers/admins/competitions_controller.rb
@@ -1,4 +1,6 @@
class Admins::CompetitionsController < Admins::BaseController
+ include CustomSortable
+ before_action :find_competition, except: [:index]
def index
params[:sort_by] = params[:sort_by].presence || 'created_on'
@@ -6,10 +8,39 @@ class Admins::CompetitionsController < Admins::BaseController
@competitions = custom_sort Competition.all, params[:sort_by], params[:sort_direction]
@params_page = params[:page] || 1
@competitions = paginate @competitions
+ ids = @competitions.map(&:id)
+ @member_count_map = TeamMember.where(competition_id: ids).group(:competition_id).count
respond_to do |format|
format.js
format.html
end
end
+
+ def publish
+ @competition.update_attributes!(:published_at, Time.now)
+ end
+
+ def unpublish
+ @competition.update_attributes!(:published_at, nil)
+ end
+
+ def online_switch
+ if @competition.status
+ @competition.update_attributes!(status: false)
+ else
+ @competition.update_attributes!(status: true, online_time: Time.now)
+ end
+ end
+
+ def enroll_list
+
+ end
+
+ private
+
+ def find_competition
+ @competition = Competition.find_by(id: params[:id])
+ end
+
end
\ No newline at end of file
diff --git a/app/models/competition.rb b/app/models/competition.rb
index 024478ad6..9055adefc 100644
--- a/app/models/competition.rb
+++ b/app/models/competition.rb
@@ -18,6 +18,29 @@ class Competition < ApplicationRecord
after_create :create_competition_modules
+ def mode_type
+ case mode
+ when 1
+ "课堂"
+ when 2
+ "实训"
+ when 3
+ "教学"
+ when 4
+ "托管"
+ else
+ "--"
+ end
+ end
+
+ def teacher_staff_num
+ teacher_staff ? "#{teacher_staff.minimum}~#{teacher_staff.maximum}" : "--"
+ end
+
+ def member_staff_num
+ member_staff ? "#{member_staff.minimum}~#{member_staff.maximum}" : "--"
+ end
+
# 是否上架
def published?
status?
diff --git a/app/views/admins/competition_settings/show.html.erb b/app/views/admins/competition_settings/show.html.erb
new file mode 100644
index 000000000..e69de29bb
diff --git a/app/views/admins/competitions/enroll_list.html.erb b/app/views/admins/competitions/enroll_list.html.erb
new file mode 100644
index 000000000..e69de29bb
diff --git a/app/views/admins/competitions/index.html.erb b/app/views/admins/competitions/index.html.erb
index 8fa238181..b97e26f94 100644
--- a/app/views/admins/competitions/index.html.erb
+++ b/app/views/admins/competitions/index.html.erb
@@ -3,5 +3,7 @@
<% end %>
- <%= render partial: 'admins/shixuns/shared/list', locals: { shixuns: @shixuns } %>
+ <%= render partial: 'admins/competitions/shared/list', locals: { competitions: @competitions } %>
+
+<%= render partial: 'admins/shared/modal/upload_file_modal', locals: { title: '上传图片' } %>
\ No newline at end of file
diff --git a/app/views/admins/competitions/online_switch.js.erb b/app/views/admins/competitions/online_switch.js.erb
new file mode 100644
index 000000000..e69de29bb
diff --git a/app/views/admins/competitions/publish.js.erb b/app/views/admins/competitions/publish.js.erb
new file mode 100644
index 000000000..e69de29bb
diff --git a/app/views/admins/competitions/shared/_list.html.erb b/app/views/admins/competitions/shared/_list.html.erb
new file mode 100644
index 000000000..8f215d54c
--- /dev/null
+++ b/app/views/admins/competitions/shared/_list.html.erb
@@ -0,0 +1,30 @@
+
+
+ 序号 |
+ 竞赛主标题 |
+ 竞赛副标题 |
+ 模式 |
+ 报名人数 |
+ 指导老师 |
+ 参赛者 |
+ 主题图片796*397 |
+ 创建时间 |
+
+ 操作
+ |
+
+
+ <% if competitions.present? %>
+ <% competitions.each_with_index do |competition, index| %>
+
+ <% page_no = list_index_no(@params_page.to_i, index) %>
+ <%= render partial: "admins/competitions/shared/td",locals: {competition: competition, page_no: page_no} %>
+
+ <% end %>
+ <% else %>
+ <%= render 'admins/shared/no_data_for_table' %>
+ <% end %>
+
+
+
+<%= render partial: 'admins/shared/paginate', locals: { objects: competitions } %>
\ No newline at end of file
diff --git a/app/views/admins/competitions/shared/_td.html.erb b/app/views/admins/competitions/shared/_td.html.erb
new file mode 100644
index 000000000..d05974c86
--- /dev/null
+++ b/app/views/admins/competitions/shared/_td.html.erb
@@ -0,0 +1,27 @@
+<%= page_no %> |
+
+ <%= link_to competition.name, enroll_list_admins_competition_path(competition), :target => "_blank", :title => competition.name %>
+ |
+<%= competition.sub_title %> |
+<%= competition.mode_type %> |
+<%= @member_count_map&.fetch(competition.id, 0) || competition.team_members.count %> |
+<%= competition.teacher_staff_num %> |
+<%= competition.member_staff_num %> |
+
+ <% imageExists = File.exist?(disk_filename("Competition", competition.id)) %>
+ <% imageUrl = imageExists ? '/' + url_to_avatar(competition) + "?#{Time.now.to_i}" : '' %>
+ <%= image_tag(imageUrl, width: 60, height: 40, class: "preview-image competition-image-#{competition.id}", data: { toggle: 'tooltip', title: '点击预览' }, style: imageExists ? '' : 'display:none') %>
+ <%= javascript_void_link imageExists ? '重新上传' : '上传图片', class: 'action upload-competition-image-action', data: { source_id: competition.id, source_type: 'Competition', toggle: 'modal', target: '.admin-upload-file-modal' } %>
+ |
+<%= competition.created_at.strftime('%Y-%m-%d %H:%M') %> |
+
+ <%= link_to '配置', admins_competition_competition_setting_path(competition), class: 'action edit-action' %>
+
+ <% if !competition.status? && competition.published_at.blank? %>
+ <%= link_to '发布', publish_admins_competition_path(competition), class: 'action publish-action', method: :post, remote: true %>
+ <% else %>
+ <%= link_to '取消发布', unpublish_admins_competition_path(competition), class: 'action unpublish-action', method: :post, remote: true %>
+ <% end %>
+
+ <%= link_to competition.published? ? "下架" : "上架", online_switch_admins_competition_path(competition), class: 'action online-action', method: :post, remote: true %>
+ |
\ No newline at end of file
diff --git a/app/views/admins/competitions/unpublish.js.erb b/app/views/admins/competitions/unpublish.js.erb
new file mode 100644
index 000000000..e69de29bb
diff --git a/config/routes.rb b/config/routes.rb
index f6f8db066..605ae4194 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -981,7 +981,15 @@ Rails.application.routes.draw do
resource :laboratory_user, only: [:create, :destroy]
end
- resources :competitions, only: [:index, :destroy]
+ resources :competitions, only: [:index, :destroy] do
+ member do
+ post :publish
+ post :unpublish
+ post :online_switch
+ get :enroll_list
+ end
+ resource :competition_setting, only: [:show, :update]
+ end
end
resources :colleges, only: [] do
From 7125e71563179bfd416496f0fa99a1e851a5eeae Mon Sep 17 00:00:00 2001
From: p31729568
Date: Wed, 16 Oct 2019 10:53:37 +0800
Subject: [PATCH 03/16] weapp api
---
app/controllers/weapps/base_controller.rb | 34 ++++++++++
.../weapps/code_sessions_controller.rb | 24 +++++++
.../weapps/registers_controller.rb | 63 +++++++++++++++++++
app/controllers/weapps/sessions_controller.rb | 24 +++++++
app/controllers/weapps/verifies_controller.rb | 8 +++
app/libs/wechat/weapp.rb | 38 ++++++++++-
config/configuration.yml.example | 3 +
config/initializers/wechat_init.rb | 8 +++
config/routes.rb | 7 +++
9 files changed, 208 insertions(+), 1 deletion(-)
create mode 100644 app/controllers/weapps/base_controller.rb
create mode 100644 app/controllers/weapps/code_sessions_controller.rb
create mode 100644 app/controllers/weapps/registers_controller.rb
create mode 100644 app/controllers/weapps/sessions_controller.rb
create mode 100644 app/controllers/weapps/verifies_controller.rb
diff --git a/app/controllers/weapps/base_controller.rb b/app/controllers/weapps/base_controller.rb
new file mode 100644
index 000000000..fadf10fb6
--- /dev/null
+++ b/app/controllers/weapps/base_controller.rb
@@ -0,0 +1,34 @@
+class Weapps::BaseController < ApplicationController
+
+ private
+
+ def require_wechat_login!
+ return if session_unionid.present?
+
+ render_error('请先进行微信授权')
+ end
+
+ def weapp_session_key
+ Wechat::Weapp.session_key(session_openid)
+ end
+
+ def set_weapp_session_key(session_key)
+ Wechat::Weapp.write_session_key(session_openid, session_key)
+ end
+
+ def session_openid
+ session[:openid]
+ end
+
+ def set_session_openid(openid)
+ session[:openid] = openid
+ end
+
+ def session_unionid
+ session[:unionid]
+ end
+
+ def set_session_unionid(unionid)
+ session[:unionid] = unionid
+ end
+end
\ No newline at end of file
diff --git a/app/controllers/weapps/code_sessions_controller.rb b/app/controllers/weapps/code_sessions_controller.rb
new file mode 100644
index 000000000..7c1978e5f
--- /dev/null
+++ b/app/controllers/weapps/code_sessions_controller.rb
@@ -0,0 +1,24 @@
+class Weapps::CodeSessionsController < Weapps::BaseController
+ def create
+ return render_error('code不能为空') if params[:code].blank?
+
+ result = Wechat::Weapp.jscode2session(params[:code])
+
+ set_session_openid(result['openid'])
+ set_weapp_session_key(result['session_key']) # weapp session_key写入缓存 后续解密需要
+
+ # 已授权,绑定过账号
+ open_user = OpenUser::Wechat.find_by(uid: result['unionid'])
+ if open_user.present? && open_user.user
+ set_session_unionid(result['unionid'])
+ successful_authentication(open_user.user)
+ else
+ # 新用户
+ user_info = Wechat::Weapp.decrypt(result['session_key'], params[:encrypted_data], params[:iv])
+
+ set_session_unionid(user_info['unionId'])
+ end
+
+ render_ok(openid: result['openid'])
+ end
+end
\ No newline at end of file
diff --git a/app/controllers/weapps/registers_controller.rb b/app/controllers/weapps/registers_controller.rb
new file mode 100644
index 000000000..0cbab7fd4
--- /dev/null
+++ b/app/controllers/weapps/registers_controller.rb
@@ -0,0 +1,63 @@
+class Weapps::RegistersController < Weapps::BaseController
+ before_action :require_wechat_login!
+
+ def create
+ # 查询验证码是否正确;type只可能是1或者8
+ type = phone_mail_type(params[:login].strip)
+ code = params[:code].strip
+
+ if type == 1
+ uid_logger("start register by phone: type is #{type}")
+ pre = 'p'
+ email = nil
+ phone = params[:login]
+ verifi_code = VerificationCode.where(phone: phone, code: code, code_type: 1).last
+ else
+ uid_logger("start register by email: type is #{type}")
+ pre = 'm'
+ email = params[:login]
+ phone = nil
+ verifi_code = VerificationCode.where(email: email, code: code, code_type: 8).last
+ end
+ uid_logger("start register: verifi_code is #{verifi_code}, code is #{code}, time is #{Time.now.to_i - verifi_code.try(:created_at).to_i}")
+ # check_code = (verifi_code.try(:code) == code.strip && (Time.now.to_i - verifi_code.created_at.to_i) <= 10*60)
+ # todo 上线前请删除万能验证码"513231"
+ unless code == "513231" && request.subdomain == "test-newweb"
+ return render_error('验证码不正确') if verifi_code.try(:code) != code.strip
+ return render_error('验证码已失效') if !verifi_code&.effective?
+ end
+
+ login = User.generate_login(pre)
+ @user = User.new(admin: false, login: login, mail: email, phone: phone, type: 'User')
+ @user.password = params[:password]
+ # 现在因为是验证码,所以在注册的时候就可以激活
+ @user.activate
+ # 必须要用save操作,密码的保存是在users中
+ ActiveRecord::Base.transaction do
+ @user.save!
+ UserExtension.create!(user_id: @user.id)
+ # 绑定微信号
+ OpenUsers::Wechat.create!(user: @user, uid: session_unionid)
+
+ # 注册完成,手机号或邮箱想可以奖励500金币
+ RewardGradeService.call(
+ @user,
+ container_id: @user.id,
+ container_type: pre == 'p' ? 'Phone' : 'Mail',
+ score: 500
+ )
+ end
+ successful_authentication(@user)
+ session[:user_id] = @user.id
+
+ render_ok
+ end
+
+ private
+
+ # 1 手机类型;0 邮箱类型
+ # 注意新版的login是自动名生成的
+ def phone_mail_type value
+ value =~ /^1\d{10}$/ ? 1 : 0
+ end
+end
\ No newline at end of file
diff --git a/app/controllers/weapps/sessions_controller.rb b/app/controllers/weapps/sessions_controller.rb
new file mode 100644
index 000000000..f65111399
--- /dev/null
+++ b/app/controllers/weapps/sessions_controller.rb
@@ -0,0 +1,24 @@
+class Weapps::SessionsController < Weapps::BaseController
+ before_action :require_wechat_login!
+
+ def create
+ return render_error('重复登录') if current_user.present? && current_user.logged?
+
+ user = User.try_to_login(params[:login], params[:password])
+
+ return render_error('错误的账号或密码') if user.blank?
+ return render_error('违反平台使用规范,账号已被锁定') if user.locked?
+ return render_error('错误的账号或密码') unless user.check_password?(params[:password].to_s)
+
+ if user.wechat_open_user && user.wechat_open_user.uid != session_unionid
+ render_error('该账号已被其它微信号绑定')
+ return
+ end
+
+ # 绑定微信号
+ OpenUsers::Wechat.create!(user: user, uid: session_unionid) if user.wechat_open_user.blank?
+
+ successful_authentication(user)
+ render_ok
+ end
+end
\ No newline at end of file
diff --git a/app/controllers/weapps/verifies_controller.rb b/app/controllers/weapps/verifies_controller.rb
new file mode 100644
index 000000000..5d8f4056e
--- /dev/null
+++ b/app/controllers/weapps/verifies_controller.rb
@@ -0,0 +1,8 @@
+class Weapps::VerifiesController < Weapps::BaseController
+ before_action :require_wechat_login!
+
+ def create
+ valid = Wechat::Weapp.verify?(session_openid, params[:verify_string], params[:signature])
+ render_ok(valid: valid)
+ end
+end
\ No newline at end of file
diff --git a/app/libs/wechat/weapp.rb b/app/libs/wechat/weapp.rb
index 54f60fa2a..755c9351a 100644
--- a/app/libs/wechat/weapp.rb
+++ b/app/libs/wechat/weapp.rb
@@ -1,4 +1,4 @@
-class Wechat::App
+class Wechat::Weapp
class << self
attr_accessor :appid, :secret
@@ -7,5 +7,41 @@ class Wechat::App
def client
@_client ||= Wechat::Client.new(appid, secret)
end
+
+ def session_key(openid)
+ Rails.cache.read(session_key_cache_key(openid))
+ end
+
+ def write_session_key(openid, session_key)
+ Rails.cache.write(session_key_cache_key(openid), session_key)
+ end
+
+ def verify?(openid, str, signature)
+ session_key = session_key(openid)
+ Digest::SHA1.hexdigest("#{str}#{session_key}") == signature
+ end
+
+ def decrypt(session_key, encrypted_data, iv)
+ session_key = Base64.decode64(session_key)
+ encrypted_data = Base64.decode64(encrypted_data)
+ iv = Base64.decode64(iv)
+
+ cipher = OpenSSL::Cipher::AES.new(128, :CBC)
+ cipher.decrypt
+ cipher.padding = 0
+ cipher.key = session_key
+ cipher.iv = iv
+ data = cipher.update(encrypted_data) << cipher.final
+ result = JSON.parse(data[0...-data.last.ord])
+
+ raise Wechat::Error, '解密错误' if result.dig('watermark', 'appid') != appid
+ result
+ end
+
+ private
+
+ def session_key_cache_key(openid)
+ "weapp:#{appid}:#{openid}:session_key"
+ end
end
end
\ No newline at end of file
diff --git a/config/configuration.yml.example b/config/configuration.yml.example
index 612011a7f..6ead04a54 100644
--- a/config/configuration.yml.example
+++ b/config/configuration.yml.example
@@ -18,6 +18,9 @@ defaults: &defaults
wechat:
appid: 'test'
secret: 'test'
+ weapp:
+ appid: 'test'
+ secret: 'test'
development:
<<: *defaults
diff --git a/config/initializers/wechat_init.rb b/config/initializers/wechat_init.rb
index 946e5f638..3fd8f9485 100644
--- a/config/initializers/wechat_init.rb
+++ b/config/initializers/wechat_init.rb
@@ -1,9 +1,12 @@
wechat_config = {}
+weapp_config = {}
begin
config = Rails.application.config_for(:configuration)
wechat_config = config['wechat']
+ weapp_config = config['weapp']
raise 'wechat config missing' if wechat_config.blank?
+ raise 'weapp config missing' if weapp_config.blank?
rescue => ex
raise ex if Rails.env.production?
@@ -12,5 +15,10 @@ rescue => ex
wechat_config = {}
end
+# 网站应用
Wechat::OfficialAccount.appid = wechat_config['appid']
Wechat::OfficialAccount.secret = wechat_config['secret']
+
+# 小程序
+Wechat::Weapp.appid = weapp_config['appid']
+Wechat::Weapp.secret = weapp_config['secret']
diff --git a/config/routes.rb b/config/routes.rb
index 605ae4194..1ef62c0e6 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -829,6 +829,13 @@ Rails.application.routes.draw do
get '/auth/qq/callback', to: 'oauth/qq#create'
get '/auth/wechat/callback', to: 'oauth/wechat#create'
resource :bind_user, only: [:create]
+
+ namespace :weapps do
+ resource :session, only: [:create]
+ resource :register, only: [:create]
+ resource :code_session, only: [:create]
+ resource :verify, only: [:create]
+ end
end
namespace :admins do
From e7723a600318836bb3c28458ce2397fb98480974 Mon Sep 17 00:00:00 2001
From: p31729568
Date: Wed, 16 Oct 2019 11:32:54 +0800
Subject: [PATCH 04/16] weapp: home api
---
app/controllers/weapps/homes_controller.rb | 12 ++++++++++++
app/views/weapps/homes/show.json.jbuilder | 14 ++++++++++++++
config/routes.rb | 1 +
3 files changed, 27 insertions(+)
create mode 100644 app/controllers/weapps/homes_controller.rb
create mode 100644 app/views/weapps/homes/show.json.jbuilder
diff --git a/app/controllers/weapps/homes_controller.rb b/app/controllers/weapps/homes_controller.rb
new file mode 100644
index 000000000..efb80b898
--- /dev/null
+++ b/app/controllers/weapps/homes_controller.rb
@@ -0,0 +1,12 @@
+class Weapps::HomesController < Weapps::BaseController
+ def show
+ # banner图
+ @images = PortalImage.where(status: true).order(position: :asc)
+
+ # 热门实训
+ @shixuns = Shixun.where(homepage_show: true).includes(:tag_repertoires, :challenges).limit(4)
+
+ # 热门实践课程
+ @subjects = Subject.where(homepage_show: true).includes(:shixuns, :repertoire).limit(4)
+ end
+end
\ No newline at end of file
diff --git a/app/views/weapps/homes/show.json.jbuilder b/app/views/weapps/homes/show.json.jbuilder
new file mode 100644
index 000000000..d2a451030
--- /dev/null
+++ b/app/views/weapps/homes/show.json.jbuilder
@@ -0,0 +1,14 @@
+json.images do
+ json.array! @images do |image|
+ json.path image.link
+ json.image_url Util::FileManage.source_disk_file_url(image)
+ end
+end
+
+json.shixuns do
+ json.partial! 'shixuns/shixun', locals: { shixuns: @shixuns }
+end
+
+json.subjects do
+ json.partial! 'subjects/subject', locals: { subjects: @subjects }
+end
\ No newline at end of file
diff --git a/config/routes.rb b/config/routes.rb
index 1ef62c0e6..4445278de 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -831,6 +831,7 @@ Rails.application.routes.draw do
resource :bind_user, only: [:create]
namespace :weapps do
+ resource :home, only: [:show]
resource :session, only: [:create]
resource :register, only: [:create]
resource :code_session, only: [:create]
From bd75a26ed270269f765653d5aa24a2d076c0c77e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E6=9D=A8=E6=A0=91=E6=98=8E?= <775174143@qq.com>
Date: Wed, 16 Oct 2019 11:50:18 +0800
Subject: [PATCH 05/16] =?UTF-8?q?=E8=B0=83=E6=95=B4=E8=AF=95=E5=8D=B7?=
=?UTF-8?q?=E5=92=8C=E4=BD=9C=E4=B8=9A=E8=AE=BE=E7=BD=AE=E8=A7=84=E5=88=99?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../courses/busyWork/CommonWorkSetting.js | 4 +-
.../courses/exercise/Exercisesetting.js | 6 ++-
.../exercise/Testpapersettinghomepage.js | 9 ++++
.../modules/courses/poll/PollDetailIndex.js | 21 +++++++-
.../courses/poll/PollDetailTabForth.js | 7 +++
.../courses/poll/PollDetailTabForthRules.js | 51 +++++++++++--------
.../shixunHomework/Trainingjobsetting.js | 2 +
public/react/src/modules/tpm/NewHeader.js | 2 +-
8 files changed, 76 insertions(+), 26 deletions(-)
diff --git a/public/react/src/modules/courses/busyWork/CommonWorkSetting.js b/public/react/src/modules/courses/busyWork/CommonWorkSetting.js
index ad25f553f..9aa31acb1 100644
--- a/public/react/src/modules/courses/busyWork/CommonWorkSetting.js
+++ b/public/react/src/modules/courses/busyWork/CommonWorkSetting.js
@@ -1128,7 +1128,9 @@ class CommonWorkSetting extends Component{
{{publicTimeTip}
}
:
- adaptered_group_settings && !!adaptered_group_settings.length && {
+ console.log(result)
if(result.status==200){
this.props.showNotification(`${result.data.message}`);
this.getSettingInfo();
@@ -369,6 +370,7 @@ class Exercisesetting extends Component{
}
this.commitSetting((result)=>{
+ console.log(result)
if(result.status==200){
this.props.showNotification(`${result.data.message}`);
this.cancelEdit();
@@ -702,7 +704,9 @@ class Exercisesetting extends Component{
:
{
console.log(error);
})
+
+ let{tab}=this.state;
+ try {
+ if(tab[0]==="0"){
+ this.child.Teacherliststudentlist();
+ }
+ if(tab[0]==="1"){
+ this.child.Teacherliststudentlist();
+ }
+ if(tab[0]==="2"){
+ this.child.Teacherliststudentlist();
+ }
+ if(tab[0]==="3"){
+ this.child.getSettingInfo();
+ }
+ }catch (e) {
+
+ }
}
componentDidMount(){
@@ -110,6 +128,7 @@ class PollDetailIndex extends Component{
DownloadMessageval:undefined
})
}
+ bindRef = ref => { this.child = ref };
render(){
let {tab,pollDetail,user_permission,polls_status}=this.state;
const { current_user } = this.props;
@@ -235,7 +254,7 @@ class PollDetailIndex extends Component{
}
{
//设置
- parseInt(tab[0])==3 &&
+ parseInt(tab[0])==3 &&
}
diff --git a/public/react/src/modules/courses/poll/PollDetailTabForth.js b/public/react/src/modules/courses/poll/PollDetailTabForth.js
index 98598a445..4a8a6f44c 100644
--- a/public/react/src/modules/courses/poll/PollDetailTabForth.js
+++ b/public/react/src/modules/courses/poll/PollDetailTabForth.js
@@ -90,6 +90,11 @@ class PollDetailTabForth extends Component{
if(this.props.isAdmin() === false){
this.cancelEdit()
}
+ try {
+ this.props.triggerRef(this);
+ }catch (e) {
+
+ }
}
componentDidUpdate = (prevProps) => {
if(prevProps.pollDetail!= this.props.pollDetail){
@@ -610,6 +615,8 @@ class PollDetailTabForth extends Component{
:
@@ -386,25 +386,30 @@ class PollDetailTabForthRules extends Component{
}`
}
-
+
+
+
{
rule.class_flag && rule.class_flag!=""?{rule.class_flag}:""
@@ -413,7 +418,9 @@ class PollDetailTabForthRules extends Component{
-
+
diff --git a/public/react/src/modules/courses/shixunHomework/Trainingjobsetting.js b/public/react/src/modules/courses/shixunHomework/Trainingjobsetting.js
index b3b79ae28..2556a910b 100644
--- a/public/react/src/modules/courses/shixunHomework/Trainingjobsetting.js
+++ b/public/react/src/modules/courses/shixunHomework/Trainingjobsetting.js
@@ -2261,6 +2261,8 @@ class Trainingjobsetting extends Component {
className="ml40"
>
{
strbool=false
}
}
- console.log(item.hidden);
+ // console.log(item.hidden);
return(
this.headtypesonClick(item.link,true)} className={`${headtypes===undefined?'pr':headtypes===item.link?'pr active':'pr'}`} style={item.hidden==false?{display: 'block'}:{display: 'none'}}>
{
From c12682323f8841758781a7cb4d76c9a7ae7c783b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E6=9D=A8=E6=A0=91=E6=98=8E?= <775174143@qq.com>
Date: Wed, 16 Oct 2019 12:17:00 +0800
Subject: [PATCH 06/16] =?UTF-8?q?=E8=B0=83=E6=95=B4=E6=93=8D=E4=BD=9C?=
=?UTF-8?q?=E6=8F=90=E7=A4=BA=E8=AF=AD?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../react/src/modules/courses/coursesDetail/CoursesBanner.js | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/public/react/src/modules/courses/coursesDetail/CoursesBanner.js b/public/react/src/modules/courses/coursesDetail/CoursesBanner.js
index 8cd56e413..8173b226a 100644
--- a/public/react/src/modules/courses/coursesDetail/CoursesBanner.js
+++ b/public/react/src/modules/courses/coursesDetail/CoursesBanner.js
@@ -248,8 +248,8 @@ class CoursesBanner extends Component {
}
}
if (i ===5) {
- s = "复制将在后台执行,作业、资源、试卷都将复制到新课堂平台";
- ss = "将为你创建一个新的同名课堂,请问是否继续?";
+ s = "复制”功能将会为您创建一个新的课堂旧课堂的作业、资源、试卷";
+ ss = "都将被复制到新的课堂里面请问是否继续??";
this.showActionPoll(i,s,ss)
}
From 3337b86f5864a5ae3ca81ed3bc1a47dea2bfc7ee Mon Sep 17 00:00:00 2001
From: hjm <63528605@qq.com>
Date: Wed, 16 Oct 2019 13:46:25 +0800
Subject: [PATCH 07/16] title={title}
---
.../modules/courses/common/titleSearch/TitleSearchSection.js | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/public/react/src/modules/courses/common/titleSearch/TitleSearchSection.js b/public/react/src/modules/courses/common/titleSearch/TitleSearchSection.js
index aa7a54cce..c71ef38ea 100644
--- a/public/react/src/modules/courses/common/titleSearch/TitleSearchSection.js
+++ b/public/react/src/modules/courses/common/titleSearch/TitleSearchSection.js
@@ -61,7 +61,8 @@ class Titlesearchsection extends Component{
- {title}
+ {/* title={title} */}
+ {title}
{ firstRowRight }
From 8466f8ef3b7b83bd00dd4c9538025244296e3051 Mon Sep 17 00:00:00 2001
From: hjm <63528605@qq.com>
Date: Wed, 16 Oct 2019 13:47:34 +0800
Subject: [PATCH 08/16] =?UTF-8?q?=E8=BF=94=E5=9B=9E=E8=87=B3=E5=88=86?=
=?UTF-8?q?=E7=8F=AD=E5=88=97=E8=A1=A8?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
public/react/src/modules/courses/members/studentsList.js | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/public/react/src/modules/courses/members/studentsList.js b/public/react/src/modules/courses/members/studentsList.js
index a63509c59..8a223ce91 100644
--- a/public/react/src/modules/courses/members/studentsList.js
+++ b/public/react/src/modules/courses/members/studentsList.js
@@ -710,7 +710,7 @@ class studentsList extends Component{
title={isParent ? (pageType == TYPE_STUDENTS ? "全部学生" : "学生列表"):
-
+
{ this.props.history.push(`/courses/${courseId}/course_groups`)}}
style={{color: '#212121', verticalAlign: 'initial', marginRight: '14px' }}
>
From dea0ff8819f6420faac5d4d3b2cbef6bf5e3aa98 Mon Sep 17 00:00:00 2001
From: hjm <63528605@qq.com>
Date: Wed, 16 Oct 2019 13:54:19 +0800
Subject: [PATCH 09/16] =?UTF-8?q?item=E5=AE=BD=E5=BA=A6=E8=B6=85=E9=95=BF?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../src/modules/courses/poll/PollDetailTabForthRules.js | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/public/react/src/modules/courses/poll/PollDetailTabForthRules.js b/public/react/src/modules/courses/poll/PollDetailTabForthRules.js
index cfcdfae4d..2a2ff218b 100644
--- a/public/react/src/modules/courses/poll/PollDetailTabForthRules.js
+++ b/public/react/src/modules/courses/poll/PollDetailTabForthRules.js
@@ -350,6 +350,12 @@ class PollDetailTabForthRules extends Component{
(学生收到{this.props.moduleName || (this.props.type==="Exercise"?"试卷":"问卷")}的时间)
({this.props.moduleName == '作业' ? '学生“按时”提交作品的时间截点' : '学生可以答题的时间截点'})
+ {/* item宽度超长 */}
+
{
rules && rules.length > 0 && rules.map((rule,r)=>{
@@ -383,7 +389,8 @@ class PollDetailTabForthRules extends Component{
`.ant-select{
min-width:200px,
min-heigth:200px
- }`
+ }
+ `
}
Date: Wed, 16 Oct 2019 14:19:01 +0800
Subject: [PATCH 10/16] wechat login: modify error tip when account binded
---
app/libs/hot_search_keyword.rb | 22 ++++++++++++++++++++++
app/services/create_bind_user_service.rb | 2 +-
2 files changed, 23 insertions(+), 1 deletion(-)
create mode 100644 app/libs/hot_search_keyword.rb
diff --git a/app/libs/hot_search_keyword.rb b/app/libs/hot_search_keyword.rb
new file mode 100644
index 000000000..e222bf3a7
--- /dev/null
+++ b/app/libs/hot_search_keyword.rb
@@ -0,0 +1,22 @@
+class HotSearchKeyword
+ class << self
+ def add(keyword)
+ return if keyword.blank?
+ Rails.cache.data.zincrby(redis_key, 1, keyword)
+ end
+
+ def hot(limit = 5)
+ Rails.cache.data.zrevrange(redis_key, 0, limit - 1)
+ end
+
+ def available?
+ Rails.cache.is_a?(ActiveSupport::Cache::RedisStore)
+ end
+
+ private
+
+ def redis_key
+ 'educoder:es:hot_keyword'
+ end
+ end
+end
\ No newline at end of file
diff --git a/app/services/create_bind_user_service.rb b/app/services/create_bind_user_service.rb
index 93d9d87ca..f7fc5b6f6 100644
--- a/app/services/create_bind_user_service.rb
+++ b/app/services/create_bind_user_service.rb
@@ -17,7 +17,7 @@ class CreateBindUserService < ApplicationService
bind_user = User.try_to_login(params[:username], params[:password])
raise Error, '用户名或者密码错误' if bind_user.blank?
- raise Error, '该账号已被绑定' if bind_user.bind_open_user?(params[:type].to_s)
+ raise Error, '该账号已被其他微信号绑定,请更换其他账号进行绑定' if bind_user.bind_open_user?(params[:type].to_s)
ActiveRecord::Base.transaction do
open_user.user_id = bind_user.id
From 7ff2cb9d3fc0f4f686a00213a2d85021dce55bd3 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E6=9D=A8=E6=A0=91=E6=98=8E?= <775174143@qq.com>
Date: Wed, 16 Oct 2019 14:19:18 +0800
Subject: [PATCH 11/16] =?UTF-8?q?=E8=B0=83=E6=95=B4?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../src/modules/courses/poll/PollDetailTabForthRules.js | 5 -----
public/react/src/modules/login/LoginDialog.css | 2 +-
2 files changed, 1 insertion(+), 6 deletions(-)
diff --git a/public/react/src/modules/courses/poll/PollDetailTabForthRules.js b/public/react/src/modules/courses/poll/PollDetailTabForthRules.js
index cfcdfae4d..ce1ee843e 100644
--- a/public/react/src/modules/courses/poll/PollDetailTabForthRules.js
+++ b/public/react/src/modules/courses/poll/PollDetailTabForthRules.js
@@ -386,10 +386,6 @@ class PollDetailTabForthRules extends Component{
}`
}
-
{
rule.class_flag && rule.class_flag!=""?{rule.class_flag}:""
diff --git a/public/react/src/modules/login/LoginDialog.css b/public/react/src/modules/login/LoginDialog.css
index 1b534c790..c791e04b3 100644
--- a/public/react/src/modules/login/LoginDialog.css
+++ b/public/react/src/modules/login/LoginDialog.css
@@ -109,7 +109,7 @@
right: -27px;
z-index: 100000;
}
-#logincloseIcon{
+.logincloseIcon{
position: absolute;
top: -100px;
right: -27px;
From 9bee37b59aa020b6900a33ec76dd759bac95d4e4 Mon Sep 17 00:00:00 2001
From: cxt <853663049@qq.com>
Date: Wed, 16 Oct 2019 14:23:47 +0800
Subject: [PATCH 12/16] =?UTF-8?q?=E8=AF=95=E5=8D=B7=E3=80=81=E9=97=AE?=
=?UTF-8?q?=E5=8D=B7=E7=9A=84=E5=88=86=E7=8F=AD=E8=AE=BE=E7=BD=AE?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/controllers/exercises_controller.rb | 31 +++++++++++++------------
app/controllers/polls_controller.rb | 26 +++++++++++----------
app/models/user.rb | 2 +-
3 files changed, 31 insertions(+), 28 deletions(-)
diff --git a/app/controllers/exercises_controller.rb b/app/controllers/exercises_controller.rb
index 9979ae48f..424b2fe3a 100644
--- a/app/controllers/exercises_controller.rb
+++ b/app/controllers/exercises_controller.rb
@@ -518,27 +518,27 @@ class ExercisesController < ApplicationController
common_group = exercise_groups_ids & course_id #传入的班级与问卷已存在的班级的交集,即表示已有分班的
new_group_ids = course_id - common_group #新传入的班级id
if common_group.count > 0 #判断试卷的分班设置是否存在,存在则更新,负责则新建
- ex_group_params = {
+ exercise_group_sets = exercise_groups.find_in_exercise_group("course_group_id",common_group)
+ exercise_group_sets.each do |the_group_setting|
+ ex_group_params = {
:publish_time => exercise_publish_time,
:end_time => exercise_end_time
- }
- exercise_group_sets = exercise_groups.find_in_exercise_group("course_group_id",common_group)
- the_group_setting = exercise_group_sets.first
- if the_group_setting.present?
+ }
+
the_group_setting_status = set_exercise_status(the_group_setting.publish_time,the_group_setting.end_time)
if the_group_setting_status == 2
ex_group_params = {
- :publish_time => the_group_setting.publish_time,
- :end_time => exercise_end_time
+ :publish_time => the_group_setting.publish_time,
+ :end_time => exercise_end_time
}
elsif the_group_setting_status == 3
ex_group_params = {
- :publish_time => the_group_setting.publish_time,
- :end_time => the_group_setting.end_time
+ :publish_time => the_group_setting.publish_time,
+ :end_time => the_group_setting.end_time
}
end
+ the_group_setting.update_attributes!(ex_group_params)
end
- exercise_group_sets.update_all(ex_group_params)
end
if new_group_ids.size > 0
new_group_ids.each do |c|
@@ -560,8 +560,9 @@ class ExercisesController < ApplicationController
error_count == 0
normal_status(-1,"已发布/已截止的试卷不允许修改时间")
else
+ # 未发布的分班设置才能删除
if old_exercise_groups.size > 0
- old_all_ex_groups = exercise_groups.find_in_exercise_group("course_group_id",old_exercise_groups)
+ old_all_ex_groups = exercise_groups.find_in_exercise_group("course_group_id",old_exercise_groups).exercise_group_not_published
old_all_ex_groups.destroy_all
end
#试卷更新为exercise_group_setting的发布时间最小,截止时间最大
@@ -720,8 +721,8 @@ class ExercisesController < ApplicationController
if exercise.unified_setting
ex_status = exercise.exercise_status #则为试卷的状态
else
- ex_status = exercise.exercise_group_settings.find_in_exercise_group("course_group_id",params[:group_ids])
- .exercise_group_not_published.present? ? 1 : 0
+ ex_status = @course.course_groups.where(id: params[:group_ids]).size !=
+ exercise.exercise_group_settings.where("course_group_id", params[:group_ids]).exercise_group_published.size ? 1 : 0
end
if ex_status == 1 #如果试卷存在已发布的,或者是已截止的,那么则直接跳过
g_course = group_ids #表示是否传入分班参数,如果传入分班的参数,那么试卷的统一设置需修改
@@ -739,8 +740,8 @@ class ExercisesController < ApplicationController
g_course.each_with_index do |i, index|
exercise_group_setting = exercise.exercise_group_settings.find_in_exercise_group("course_group_id",i).first #根据课堂分班的id,寻找试卷所在的班级
group_end_time = params[:detail] ? group_end_times[index] : ex_end_time
- if exercise_group_setting #如果该试卷分组存在,则更新,否则新建
- exercise_group_setting.update_attributes(publish_time: Time.now, end_time: group_end_time)
+ if exercise_group_setting.present? #如果该试卷分组存在,则更新,否则新建
+ exercise_group_setting.update_attributes!(publish_time: Time.now, end_time: group_end_time)
else
p_course_group = {
:exercise_id => exercise.id,
diff --git a/app/controllers/polls_controller.rb b/app/controllers/polls_controller.rb
index da5917e1b..e5cb8b1c2 100644
--- a/app/controllers/polls_controller.rb
+++ b/app/controllers/polls_controller.rb
@@ -279,7 +279,8 @@ class PollsController < ApplicationController
if poll.unified_setting
pl_status = poll.polls_status #则为试卷的状态
else
- pl_status = poll.poll_group_settings.find_in_poll_group("course_group_id",params[:group_ids]).poll_group_not_published.present? ? 1 : 0 #立即发布针对分组设置的全部未发布的班级才生效
+ pl_status = @course.course_groups.where(id: params[:group_ids]).size !=
+ poll.poll_group_settings.where("course_group_id",params[:group_ids]).poll_group_published.size ? 1 : 0 #立即发布针对分组设置的全部未发布的班级才生效
end
if pl_status == 1 #如果问卷存在已发布的,或者是已截止的,那么则直接跳过
g_course = group_ids #表示是否传入分班参数,如果传入分班的参数,那么poll的统一设置需修改
@@ -782,27 +783,27 @@ class PollsController < ApplicationController
common_group = poll_groups_ids & course_id #传入的班级与问卷已存在的班级的交集,即表示已有分班的
new_group_ids = course_id - common_group #新传入的班级id
if common_group.size > 0 #传入的参数存在已发布的分班
- poll_group_params = {
+ poll_group = poll_groups.find_in_poll_group("course_group_id",common_group)
+ poll_group.each do |the_group_setting|
+ poll_group_params = {
:publish_time => poll_publish_time,
:end_time => poll_end_time
- }
- poll_group = poll_groups.find_in_poll_group("course_group_id",common_group)
- the_group_setting = poll_group.first
- if the_group_setting.present?
+ }
+
the_group_setting_status = set_poll_status(the_group_setting.publish_time,the_group_setting.end_time)
if the_group_setting_status == 2
poll_group_params = {
- :publish_time => the_group_setting.publish_time,
- :end_time => poll_end_time
+ :publish_time => the_group_setting.publish_time,
+ :end_time => poll_end_time
}
elsif the_group_setting_status == 3
poll_group_params = {
- :publish_time => the_group_setting.publish_time,
- :end_time => the_group_setting.end_time
+ :publish_time => the_group_setting.publish_time,
+ :end_time => the_group_setting.end_time
}
end
+ the_group_setting.update_attributes(poll_group_params)
end
- poll_group.update_all(poll_group_params)
end
if new_group_ids.size > 0
new_group_ids.each do |c|
@@ -824,8 +825,9 @@ class PollsController < ApplicationController
error_count == 0
normal_status(-1,"已发布/已截止的问卷不允许修改时间")
else
+ # 未发布的分班设置才能删除
if old_poll_groups.size > 0
- old_all_poll_groups = poll_groups.find_in_poll_group("course_group_id",old_poll_groups)
+ old_all_poll_groups = poll_groups.find_in_poll_group("course_group_id",old_poll_groups).poll_group_not_published
old_all_poll_groups.destroy_all
end
#问卷更新为poll_group_setting的发布时间最小,截止时间最大
diff --git a/app/models/user.rb b/app/models/user.rb
index 2f5400051..103f9e0b5 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -274,7 +274,7 @@ class User < ApplicationRecord
# 课堂的学生
def student_of_course?(course)
- course.course_members.exists?(user_id: id, role: %i[STUDENT])
+ course.course_members.exists?(user_id: id, role: %i[STUDENT], is_active: 1)
end
# 课堂成员
From e7b0d82a608ca3df7cc1ac399f9cf660abfe9fe1 Mon Sep 17 00:00:00 2001
From: SylorHuang
Date: Wed, 16 Oct 2019 14:23:56 +0800
Subject: [PATCH 13/16] =?UTF-8?q?=E8=AF=95=E5=8D=B7=E7=9A=84=E7=BB=9F?=
=?UTF-8?q?=E8=AE=A1=E7=BB=93=E6=9E=9C=E5=88=97=E8=A1=A8=E6=8E=92=E5=BA=8F?=
=?UTF-8?q?=E4=BF=AE=E6=94=B9?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../admins/shixun_settings_controller.rb | 2 +-
app/controllers/exercises_controller.rb | 18 ++++++++++++------
2 files changed, 13 insertions(+), 7 deletions(-)
diff --git a/app/controllers/admins/shixun_settings_controller.rb b/app/controllers/admins/shixun_settings_controller.rb
index 9202ccce6..9919c7daa 100644
--- a/app/controllers/admins/shixun_settings_controller.rb
+++ b/app/controllers/admins/shixun_settings_controller.rb
@@ -46,7 +46,7 @@ class Admins::ShixunSettingsController < Admins::BaseController
tag_ids.each do |id|
unless tag_repertoire_ids.include?(id)
tag_repertoire = @shixun.shixun_tag_repertoires.new(shixun_id:@shixun.id,tag_repertoire_id:id)
- tag_repertoire.save
+ tag_repertoire.save!
end
end
else
diff --git a/app/controllers/exercises_controller.rb b/app/controllers/exercises_controller.rb
index 74059b314..317760796 100644
--- a/app/controllers/exercises_controller.rb
+++ b/app/controllers/exercises_controller.rb
@@ -1425,18 +1425,24 @@ class ExercisesController < ApplicationController
@exercise_questions = @exercise.exercise_questions&.includes(:exercise_choices,:exercise_answers,:exercise_standard_answers,:exercise_shixun_challenges,:exercise_shixun_answers)
- @paging_type = "percent"
- # 按题型排序
+ percent_sort = "desc"
+
if params[:sort].present?
- @paging_type = params[:sort].to_s
+ percent_sort = params[:sort]
end
+ # @paging_type = "percent"
+ # # 按题型排序
+ # if params[:sort].present?
+ # @paging_type = params[:sort].to_s
+ # end
ques_result_all = exercise_commit_result(@exercise_questions,@exercise_commit_user_ids)
- if @paging_type == "percent"
- @question_result_hash = ques_result_all.sort_by{|s| s[:percent]}
+ #默认降序排列
+ if percent_sort == "desc"
+ @question_result_hash = ques_result_all.sort_by{|s| s[:percent]}.reverse
else
- @question_result_hash = ques_result_all.sort_by{|s| s[:"#{@paging_type}"]}
+ @question_result_hash = ques_result_all.sort_by{|s| s[:percent]}
end
@exercise_questions_count = @exercise_questions.size
From b00a910259a04fdefbae56523450a5455f6ee25d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E6=9D=A8=E6=A0=91=E6=98=8E?= <775174143@qq.com>
Date: Wed, 16 Oct 2019 14:24:21 +0800
Subject: [PATCH 14/16] =?UTF-8?q?=E5=B7=A6=E4=BE=A7=E5=AF=BC=E8=88=AA?=
=?UTF-8?q?=E6=A0=8F---=E8=BF=9B=E5=85=A5=E6=95=99=E5=B8=88=E5=88=97?=
=?UTF-8?q?=E8=A1=A8=E6=97=B6=E8=AE=B0=E5=BD=95=E6=B8=85=E9=99=A4?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../react/src/modules/courses/coursesDetail/CoursesLeftNav.js | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/public/react/src/modules/courses/coursesDetail/CoursesLeftNav.js b/public/react/src/modules/courses/coursesDetail/CoursesLeftNav.js
index fff535c51..46ca129c5 100644
--- a/public/react/src/modules/courses/coursesDetail/CoursesLeftNav.js
+++ b/public/react/src/modules/courses/coursesDetail/CoursesLeftNav.js
@@ -1002,7 +1002,7 @@ class Coursesleftnav extends Component{
return(
- this.showsandians(e,key,item.category_url,1,item.id,item.type)} className={this.props.mainurl===item.category_url?"liactive":"clearfix active"} onMouseLeave={(e)=>this.hidesandian(e,key)} onMouseEnter={(e)=>this.showsandian(e,key)}>
+ this.showsandians(e,key,item.category_url,1,item.id,item.type)} className={this.props.mainurl===item.category_url&&this.props.location.pathname===item.category_url?"liactive":"clearfix active"} onMouseLeave={(e)=>this.hidesandian(e,key)} onMouseEnter={(e)=>this.showsandian(e,key)}>
this.showsandians(e,key,item.category_url,1,item.id,item.type)} className={ item.second_category===undefined?"fl ml20 pd0":item.second_category.length===0?"fl ml20 pd0":this.state.sandiantypes===key?"fl ml20 pd0 ebebeb":"fl ml20 pd0"}>
{
item.type==="announcement"?:
@@ -1138,7 +1138,7 @@ class Coursesleftnav extends Component{
{/*
*/}
- this.setnavid(e,key,item.id,item.type,item.category_url)} onMouseEnter={(e)=>this.showsandian(e,key)}
title={item.name.length<7?"":item.name}
>
From f119f36ed07811efeedcea3ba212979367a1fc73 Mon Sep 17 00:00:00 2001
From: cxt <853663049@qq.com>
Date: Wed, 16 Oct 2019 14:33:46 +0800
Subject: [PATCH 15/16] =?UTF-8?q?=E9=97=AE=E5=8D=B7=E7=9A=84=E7=AB=8B?=
=?UTF-8?q?=E5=8D=B3=E5=8F=91=E5=B8=83?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/controllers/polls_controller.rb | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/app/controllers/polls_controller.rb b/app/controllers/polls_controller.rb
index e5cb8b1c2..b4da1256e 100644
--- a/app/controllers/polls_controller.rb
+++ b/app/controllers/polls_controller.rb
@@ -279,8 +279,8 @@ class PollsController < ApplicationController
if poll.unified_setting
pl_status = poll.polls_status #则为试卷的状态
else
- pl_status = @course.course_groups.where(id: params[:group_ids]).size !=
- poll.poll_group_settings.where("course_group_id",params[:group_ids]).poll_group_published.size ? 1 : 0 #立即发布针对分组设置的全部未发布的班级才生效
+ pl_status = @course.course_groups.where(id: group_ids).size !=
+ poll.poll_group_settings.where("course_group_id", group_ids).poll_group_published.size ? 1 : 0 #立即发布针对分组设置的全部未发布的班级才生效
end
if pl_status == 1 #如果问卷存在已发布的,或者是已截止的,那么则直接跳过
g_course = group_ids #表示是否传入分班参数,如果传入分班的参数,那么poll的统一设置需修改
@@ -296,8 +296,8 @@ class PollsController < ApplicationController
g_course.each_with_index do |i, index|
poll_group_setting = poll.poll_group_settings.find_in_poll_group("course_group_id",i).first #根据课堂分班的id,寻找问卷所在的班级
group_end_time = params[:detail] ? group_end_times[index] : ex_end_time
- if poll_group_setting #如果该问卷分组存在,则更新,否则新建
- poll_group_setting.update_attributes(publish_time: Time.now, end_time: group_end_time)
+ if poll_group_setting.present? #如果该问卷分组存在,则更新,否则新建
+ poll_group_setting.update_attributes!(publish_time: Time.now, end_time: group_end_time)
else
p_course_group = {
:poll_id => poll.id,
@@ -307,7 +307,7 @@ class PollsController < ApplicationController
:end_time => group_end_time,
}
new_poll_group = poll.poll_group_settings.new p_course_group
- new_poll_group.save
+ new_poll_group.save!
end
end
e_time = poll.poll_group_settings.end_time_present.map(&:end_time).max
From 611de60de2522175acf1fbcb590780db22180e9a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E6=9D=A8=E6=A0=91=E6=98=8E?= <775174143@qq.com>
Date: Wed, 16 Oct 2019 14:34:16 +0800
Subject: [PATCH 16/16] =?UTF-8?q?=E8=B0=83=E6=95=B4?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../react/src/modules/courses/poll/PollDetailTabForthRules.js | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/public/react/src/modules/courses/poll/PollDetailTabForthRules.js b/public/react/src/modules/courses/poll/PollDetailTabForthRules.js
index 19a65f7e7..472d7e351 100644
--- a/public/react/src/modules/courses/poll/PollDetailTabForthRules.js
+++ b/public/react/src/modules/courses/poll/PollDetailTabForthRules.js
@@ -353,7 +353,7 @@ class PollDetailTabForthRules extends Component{
{/* item宽度超长 */}