From eb790bdf990a5680966bcdcdc2fdf023d9aa244e Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Fri, 14 Feb 2020 21:51:48 +0800 Subject: [PATCH 1/6] =?UTF-8?q?=E6=99=AE=E9=80=9A=E4=BD=9C=E4=B8=9A?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/helpers/homework_commons_helper.rb | 4 ++-- app/views/homework_commons/index.json.jbuilder | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/app/helpers/homework_commons_helper.rb b/app/helpers/homework_commons_helper.rb index f962288eb..3061a6e80 100644 --- a/app/helpers/homework_commons_helper.rb +++ b/app/helpers/homework_commons_helper.rb @@ -171,10 +171,10 @@ module HomeworkCommonsHelper {status: status, time: time} end - # 作品数统计:type: 1 已提交 0 未提交 + # 作品数统计:type: 1 已提交 0 未提交 2 所有 def studentwork_count homework_common, type, member student_works = homework_common.teacher_works(member) - type == 1 ? student_works.where("work_status != 0").size : student_works.where(work_status: 0).size + type == 2 ? student_works.size : (type == 1 ? student_works.where("work_status != 0").size : student_works.where(work_status: 0).size) end # 上次查重的时间 diff --git a/app/views/homework_commons/index.json.jbuilder b/app/views/homework_commons/index.json.jbuilder index 00c50e519..6b34eb220 100644 --- a/app/views/homework_commons/index.json.jbuilder +++ b/app/views/homework_commons/index.json.jbuilder @@ -27,6 +27,7 @@ json.homeworks @homework_commons.each do |homework| unless curr_status[:status].include?("未发布") json.commit_count studentwork_count homework, 1, @member json.uncommit_count studentwork_count homework, 0, @member + json.all_count studentwork_count homework, 2, @member end if homework.homework_type == "practice" From 7254751f20fea032a4b56f2a31f7bb8f9a83f981 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Fri, 14 Feb 2020 22:38:16 +0800 Subject: [PATCH 2/6] =?UTF-8?q?vnc=E5=AE=9E=E8=AE=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/weapps/challenges_controller.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/controllers/weapps/challenges_controller.rb b/app/controllers/weapps/challenges_controller.rb index 49d065f03..e6ba35731 100644 --- a/app/controllers/weapps/challenges_controller.rb +++ b/app/controllers/weapps/challenges_controller.rb @@ -3,8 +3,8 @@ class Weapps::ChallengesController < Weapps::BaseController before_action :set_challenge def is_play - # 关卡有展示效果 || 选择题 || jupyter实训 || 隐藏代码窗口 || html+css实训 - play = @challenge.show_type != -1 || @challenge.st == 1 || @shixun.is_jupyter? || + # 关卡有展示效果 || 选择题 || jupyter实训 || vnc || 隐藏代码窗口 || html+css实训 + play = @challenge.show_type != -1 || @challenge.st == 1 || @shixun.is_jupyter? || @shixun.vnc || @shixun.hide_code? || (@shixun.small_mirror_name & ["Css", "Html", "Web"]).present? if play normal_status(-5, "该关卡暂不支持小程序") From 71f3f916aeaf7793a744c12988609cd4485ba889 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Sat, 15 Feb 2020 00:06:59 +0800 Subject: [PATCH 3/6] =?UTF-8?q?=E8=A7=A3=E7=BB=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/weapps/unbind_accounts_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/weapps/unbind_accounts_controller.rb b/app/controllers/weapps/unbind_accounts_controller.rb index 4698108e3..551308a6c 100644 --- a/app/controllers/weapps/unbind_accounts_controller.rb +++ b/app/controllers/weapps/unbind_accounts_controller.rb @@ -7,7 +7,7 @@ class Weapps::UnbindAccountsController < Weapps::BaseController def destroy open_user = OpenUsers::Wechat.find_by!(user_id: current_user.id) - open_user.update!(user_id: nil) + open_user.destroy! UserAction.create(action_id: current_user.id, action_type: "UnbindWechat", user_id: current_user.id, :ip => request.remote_ip) logout_user render_ok From 0c42be72f08c29e0115c367c4362d589f957303f Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Sat, 15 Feb 2020 00:27:45 +0800 Subject: [PATCH 4/6] =?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/weapps/sessions_controller.rb | 7 ++++++- app/controllers/weapps/unbind_accounts_controller.rb | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/app/controllers/weapps/sessions_controller.rb b/app/controllers/weapps/sessions_controller.rb index 732d0a686..d586b38f5 100644 --- a/app/controllers/weapps/sessions_controller.rb +++ b/app/controllers/weapps/sessions_controller.rb @@ -17,7 +17,12 @@ class Weapps::SessionsController < Weapps::BaseController # session[:wechat_user_extra].delete(:nickName) # 绑定微信号 - OpenUsers::Wechat.create!(user: user, uid: session_unionid) if user.wechat_open_user.blank? + open_user = OpenUsers::Wechat.find_by(uid: session_unionid) + if open_user.present? && open_user.user_id.nil? + open_user.update!(user_id: user.id) + elsif user.wechat_open_user.blank? + OpenUsers::Wechat.create!(user: user, uid: session_unionid) + end successful_authentication(user) end diff --git a/app/controllers/weapps/unbind_accounts_controller.rb b/app/controllers/weapps/unbind_accounts_controller.rb index 551308a6c..143f4a274 100644 --- a/app/controllers/weapps/unbind_accounts_controller.rb +++ b/app/controllers/weapps/unbind_accounts_controller.rb @@ -7,7 +7,7 @@ class Weapps::UnbindAccountsController < Weapps::BaseController def destroy open_user = OpenUsers::Wechat.find_by!(user_id: current_user.id) - open_user.destroy! + open_user.destroy!(user_id: nil) UserAction.create(action_id: current_user.id, action_type: "UnbindWechat", user_id: current_user.id, :ip => request.remote_ip) logout_user render_ok From 5a5c0d5ccec1a4ab03d8da79d5e1113c119a7e50 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Sat, 15 Feb 2020 00:29:41 +0800 Subject: [PATCH 5/6] =?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/weapps/unbind_accounts_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/weapps/unbind_accounts_controller.rb b/app/controllers/weapps/unbind_accounts_controller.rb index 143f4a274..4698108e3 100644 --- a/app/controllers/weapps/unbind_accounts_controller.rb +++ b/app/controllers/weapps/unbind_accounts_controller.rb @@ -7,7 +7,7 @@ class Weapps::UnbindAccountsController < Weapps::BaseController def destroy open_user = OpenUsers::Wechat.find_by!(user_id: current_user.id) - open_user.destroy!(user_id: nil) + open_user.update!(user_id: nil) UserAction.create(action_id: current_user.id, action_type: "UnbindWechat", user_id: current_user.id, :ip => request.remote_ip) logout_user render_ok From f91fcc9751551585c234f9027d4c4e9726e93c6c Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Sat, 15 Feb 2020 01:06:31 +0800 Subject: [PATCH 6/6] =?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/weapps/sessions_controller.rb | 9 +++++---- app/controllers/weapps/unbind_accounts_controller.rb | 3 ++- app/views/weapps/unbind_accounts/show.json.jbuilder | 2 +- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/app/controllers/weapps/sessions_controller.rb b/app/controllers/weapps/sessions_controller.rb index d586b38f5..2dbab7aa7 100644 --- a/app/controllers/weapps/sessions_controller.rb +++ b/app/controllers/weapps/sessions_controller.rb @@ -17,10 +17,11 @@ class Weapps::SessionsController < Weapps::BaseController # session[:wechat_user_extra].delete(:nickName) # 绑定微信号 - open_user = OpenUsers::Wechat.find_by(uid: session_unionid) - if open_user.present? && open_user.user_id.nil? - open_user.update!(user_id: user.id) - elsif user.wechat_open_user.blank? + # open_user = OpenUsers::Wechat.find_by(uid: session_unionid) + # if open_user.present? && open_user.user_id.nil? + # open_user.update!(user_id: user.id) + # els + if user.wechat_open_user.blank? OpenUsers::Wechat.create!(user: user, uid: session_unionid) end diff --git a/app/controllers/weapps/unbind_accounts_controller.rb b/app/controllers/weapps/unbind_accounts_controller.rb index 4698108e3..53c8d8478 100644 --- a/app/controllers/weapps/unbind_accounts_controller.rb +++ b/app/controllers/weapps/unbind_accounts_controller.rb @@ -7,7 +7,8 @@ class Weapps::UnbindAccountsController < Weapps::BaseController def destroy open_user = OpenUsers::Wechat.find_by!(user_id: current_user.id) - open_user.update!(user_id: nil) + session[:unionid] = open_user.uid + open_user.destroy! UserAction.create(action_id: current_user.id, action_type: "UnbindWechat", user_id: current_user.id, :ip => request.remote_ip) logout_user render_ok diff --git a/app/views/weapps/unbind_accounts/show.json.jbuilder b/app/views/weapps/unbind_accounts/show.json.jbuilder index 057823247..c4223a021 100644 --- a/app/views/weapps/unbind_accounts/show.json.jbuilder +++ b/app/views/weapps/unbind_accounts/show.json.jbuilder @@ -1 +1 @@ -json.user_account @user.phone.present? ? @user.phone : @user.mail +json.user_account @user.phone.present? ? @user.phone : (@user.mail.present? ? @user.mail : @user.login)