+ );
+ }
}
export default NewFooter;
diff --git a/public/stylesheets/educoder/edu-all.css b/public/stylesheets/educoder/edu-all.css
index 3ed8a36c3..6fcbd3b5c 100644
--- a/public/stylesheets/educoder/edu-all.css
+++ b/public/stylesheets/educoder/edu-all.css
@@ -84,6 +84,27 @@ em.vertical-line{display: inline-block;width: 2px;background: #999;height: 10px}
.inner-footernav li{float: left;height: 50px;width: 80px;text-align: center}
.inner-footernav li a{width: 100%;text-align: center;line-height: 50px;color: #888}
.inner-footer_con{ width: 1200px; margin: 0 auto;}
+.inner-footernavysl{ display: flex;flex-direction:initial;}
+.inner-footernavysl li a {
+ height: 40px;
+ line-height: 40px;
+ color:#878786;
+ font-size: 19px;
+}
+
+.inner-footernavysl li Link {
+ height: 40px;
+ line-height: 40px;
+ color:#878786;
+}
+
+.intermediatecenter{
+ width:100%;
+ display: flex;
+ flex-direction: column;
+ align-items: center;
+ justify-content: center;
+}
.footer_con-p{ color: #888; margin-top:10px;}
/*banner图*/
.banner{width:100%;height:345px;position: relative;overflow: hidden;border-radius: 10px;}
@@ -3773,4 +3794,4 @@ a.singlepublishtwo{
.fontweightbold{
font-weight: bold !important;
-}
\ No newline at end of file
+}
From d968c37807d85af91e95b4946783fe6f7f76010a Mon Sep 17 00:00:00 2001
From: cxt <853663049@qq.com>
Date: Tue, 26 Nov 2019 11:30:37 +0800
Subject: [PATCH 25/43] =?UTF-8?q?=E5=B0=8F=E7=A8=8B=E5=BA=8F=E7=9A=84?=
=?UTF-8?q?=E6=95=99=E5=B8=88=E5=88=97=E8=A1=A8=E5=92=8C=E5=AD=A6=E7=94=9F?=
=?UTF-8?q?=E5=88=97=E8=A1=A8=E7=9A=84=E4=B8=AD=E8=8B=B1=E6=96=87=E6=B7=B7?=
=?UTF-8?q?=E5=90=88=E6=8E=92=E5=BA=8F?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/controllers/weapps/courses_controller.rb | 25 +++++++++++++++++++-
app/helpers/weapps/courses_helper.rb | 16 ++++++-------
2 files changed, 32 insertions(+), 9 deletions(-)
diff --git a/app/controllers/weapps/courses_controller.rb b/app/controllers/weapps/courses_controller.rb
index f35b0591a..c2335998e 100644
--- a/app/controllers/weapps/courses_controller.rb
+++ b/app/controllers/weapps/courses_controller.rb
@@ -35,6 +35,9 @@ class Weapps::CoursesController < Weapps::BaseController
# 教师列表
def teachers
@course = current_course
+ @page = (params[:page] || 1).to_i
+ @limit = (params[:limit] || 20).to_i
+ search = params[:search].present? ? params[:search].strip : ""
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
@@ -42,17 +45,26 @@ class Weapps::CoursesController < Weapps::BaseController
and course_members.role = 2))")
end
+ if search.present?
+ @teacher_list = @teacher_list.joins(:user).where("LOWER(CONCAT(users.lastname, users.firstname)) like ?", "%#{search}%")
+ 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])
+ @teacher_list = @teacher_list.includes(user: [user_extension: :school])
+ # 中英文混合排序(忽略大小写)
+ @teacher_list = @teacher_list.sort {|x, y| Pinyin.t(x.user&.real_name, splitter: '').upcase <=> Pinyin.t(y.user&.real_name, splitter: '').upcase}
+ @teacher_list = @teacher_list[(@page-1)*@limit ... @page*@limit]
end
# 批量删除教师或助教
def delete_course_teachers
begin
@course = current_course
+ @page = (params[:page] || 1).to_i
+ @limit = (params[:limit] || 20).to_i
course_members = @course.course_members.where(id: params[:course_member_ids], role: %i[PROFESSOR ASSISTANT_PROFESSOR])
user_ids = course_members.pluck(:user_id)
course_members.destroy_all
@@ -67,10 +79,18 @@ class Weapps::CoursesController < Weapps::BaseController
def students
@course = current_course
+ @page = (params[:page] || 1).to_i
+ @limit = (params[:limit] || 20).to_i
+ search = params[:search].present? ? params[:search].strip : nil
course_group_id = params[:course_group_id].present? ? params[:course_group_id].to_i : nil
@students = CourseMember.students(@course)
+ if search.present?
+ @students = @students.joins(user: :user_extension).where("LOWER(CONCAT(users.lastname, users.firstname)) like ? or
+ user_extensions.student_id like ?", "%#{search}%", "%#{search}%")
+ end
+
if course_group_id.present?
course_group = CourseGroup.find(course_group_id) if course_group_id != 0
@students = @students.where(course_group_id: course_group&.id.to_i)
@@ -78,6 +98,9 @@ class Weapps::CoursesController < Weapps::BaseController
@students_count = @students.size
@students = @students.includes(user: :user_extension)
+ # 中英文混合排序(忽略大小写)
+ @students = @students.sort {|x, y| Pinyin.t(x.user&.real_name, splitter: '').upcase <=> Pinyin.t(y.user&.real_name, splitter: '').upcase}
+ @students = @students[(@page-1)*@limit ... @page*@limit]
end
# 批量修改角色
diff --git a/app/helpers/weapps/courses_helper.rb b/app/helpers/weapps/courses_helper.rb
index 94769fc2e..32de8f253 100644
--- a/app/helpers/weapps/courses_helper.rb
+++ b/app/helpers/weapps/courses_helper.rb
@@ -20,10 +20,10 @@ module Weapps::CoursesHelper
end
end
end
- data = data.sort do |a, b|
- [a[:letter]] <=> [b[:letter]]
- end
- data.push(data.shift) if data.select{|a|a[:letter]=='#'}.first.present? # '#'排在最后
+ # data = data.sort do |a, b|
+ # [a[:letter]] <=> [b[:letter]]
+ # end
+ # data.push(data.shift) if data.select{|a|a[:letter]=='#'}.first.present? # '#'排在最后
return data
end
@@ -47,10 +47,10 @@ module Weapps::CoursesHelper
end
end
end
- data = data.sort do |a, b|
- [a[:letter]] <=> [b[:letter]]
- end
- data.push(data.shift) if data.select{|a|a[:letter]=='#'}.first.present? # '#'排在最后
+ # data = data.sort do |a, b|
+ # [a[:letter]] <=> [b[:letter]]
+ # end
+ # data.push(data.shift) if data.select{|a|a[:letter]=='#'}.first.present? # '#'排在最后
return data
end
From dcff3adeaba8035b3e3de6f1c5ddf15b84ebc07e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E6=9D=A8=E6=A0=91=E6=9E=97?= <904079904@qq.com>
Date: Tue, 26 Nov 2019 11:45:20 +0800
Subject: [PATCH 26/43] =?UTF-8?q?=E8=B0=83=E6=95=B4?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
public/react/src/modules/tpm/NewFooter.js | 148 ++++++----------------
1 file changed, 37 insertions(+), 111 deletions(-)
diff --git a/public/react/src/modules/tpm/NewFooter.js b/public/react/src/modules/tpm/NewFooter.js
index f54fa1d3f..4ff1cc46a 100644
--- a/public/react/src/modules/tpm/NewFooter.js
+++ b/public/react/src/modules/tpm/NewFooter.js
@@ -1,127 +1,53 @@
-import React, {Component} from 'react';
-import {Redirect} from 'react-router';
-import {Link} from 'react-router-dom';
-import {getImageUrl, toPath} from 'educoder'
+import React, { Component } from 'react';
+import { Redirect } from 'react-router';
+import { Link } from 'react-router-dom';
+import { getImageUrl, toPath } from 'educoder'
import PropTypes from 'prop-types';
class NewFooter extends Component {
- constructor(props) {
- super(props)
+ constructor(props) {
+ super(props)
- }
+ }
- componentWillReceiveProps(newProps, newContext) {
+ componentWillReceiveProps(newProps, newContext) {
- }
+ }
- render() {
- return (
-
+ render() {
+ return (
+
{/*newContainers*/}
-
- {this.props.user && this.props.user.main_site === true ?
- {/*
+
+ {this.props.user&&this.props.user.main_site===true?
+ {/*
EduCoder.net
*/}
-
- 网站首页
- 关于我们
- 联系我们
- 合作伙伴
- 服务协议
- 帮助中心
- 意见反馈
-
-
: ""}
-
-
-
- {this.props.mygetHelmetapi === null ? "" :
- this.props.mygetHelmetapi === undefined || this.props.mygetHelmetapi.footer === null || this.props.mygetHelmetapi.footer === undefined ?
+
+ 网站首页
+ 关于我们
+ 联系我们
+ 合作伙伴
+ 服务协议
+ 帮助中心
+ 意见反馈
+
+
:""}
+
+ {this.props.mygetHelmetapi === null ? "" :
+ this.props.mygetHelmetapi===undefined|| this.props.mygetHelmetapi.footer===null||this.props.mygetHelmetapi.footer===undefined?
© 2019 EduCoder
- 湘ICP备17009477号
-
+ 湘ICP备17009477号
+
湘公网安备43019002000962号
- Trustie & IntelliDE inside. 版权所有 湖南智擎科技有限公司
@@ -130,12 +56,12 @@ class NewFooter extends Component {
}
-
-
-
-
- );
- }
+
+
+
+
+ );
+ }
}
export default NewFooter;
From 861cf7d7b2218e98baac8601d8603de0f62a0a31 Mon Sep 17 00:00:00 2001
From: cxt <853663049@qq.com>
Date: Tue, 26 Nov 2019 14:02:08 +0800
Subject: [PATCH 27/43] =?UTF-8?q?=E5=B0=8F=E7=A8=8B=E5=BA=8F=E7=9A=84?=
=?UTF-8?q?=E6=B6=88=E6=81=AF=E6=8E=A5=E5=8F=A3?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/controllers/tidings_controller.rb | 5 ++++-
app/views/tidings/index.json.jbuilder | 1 +
2 files changed, 5 insertions(+), 1 deletion(-)
diff --git a/app/controllers/tidings_controller.rb b/app/controllers/tidings_controller.rb
index 9324b2755..5acffcb16 100644
--- a/app/controllers/tidings_controller.rb
+++ b/app/controllers/tidings_controller.rb
@@ -6,6 +6,7 @@ class TidingsController < ApplicationController
def index
tidings = current_user.tidings
+ @onclick_time = current_user.click_time
tiding_types =
case params[:type]
@@ -18,11 +19,13 @@ class TidingsController < ApplicationController
end
tidings = tidings.where(tiding_type: tiding_types) if tiding_types.present?
+ tidings = tidings.where(container_type: 'JoinCourse') if params[:type] == 'course_apply'
+ @course_apply_count = tidings.where("created_at > '#{@onclick_time}'").where(container_type: 'JoinCourse').count
+
tidings = tidings.where(container_type: 'ProjectPackage') if params[:type] == 'project_package'
@count = tidings.count
@tidings = paginate(tidings.order(created_at: :desc), per_page: 10)
- @onclick_time = current_user.click_time
end
private
diff --git a/app/views/tidings/index.json.jbuilder b/app/views/tidings/index.json.jbuilder
index 69f932f8f..26c31d98b 100644
--- a/app/views/tidings/index.json.jbuilder
+++ b/app/views/tidings/index.json.jbuilder
@@ -1,2 +1,3 @@
json.count @count
json.tidings @tidings, partial: 'tidings/tiding', as: :tiding
+json.course_apply_count @course_apply_count
From bb3bee01d20b27908d7d72605b502477318707c9 Mon Sep 17 00:00:00 2001
From: daiao <358551898@qq.com>
Date: Tue, 26 Nov 2019 14:06:36 +0800
Subject: [PATCH 28/43] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=AE=9E=E8=AE=AD?=
=?UTF-8?q?=E5=90=8D=E7=A7=B0?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/controllers/subjects_controller.rb | 12 +++++++++++-
app/views/subjects/add_shixun_to_stage.json.jbuilder | 3 +++
2 files changed, 14 insertions(+), 1 deletion(-)
create mode 100644 app/views/subjects/add_shixun_to_stage.json.jbuilder
diff --git a/app/controllers/subjects_controller.rb b/app/controllers/subjects_controller.rb
index d38293a8f..9ba8bb55d 100644
--- a/app/controllers/subjects_controller.rb
+++ b/app/controllers/subjects_controller.rb
@@ -5,7 +5,7 @@ class SubjectsController < ApplicationController
before_action :find_subject, except: [:index, :create, :new, :append_to_stage]
before_action :allowed, only: [:update, :edit, :destroy, :publish, :cancel_publish, :cancel_has_publish,
:search_members, :add_subject_members, :statistics, :shixun_report, :school_report,
- :up_member_position, :down_member_position, :update_team_title]
+ :up_member_position, :down_member_position, :update_team_title, :add_shixun_to_stage]
before_action :require_admin, only: [:copy_subject]
include ApplicationHelper
@@ -212,6 +212,16 @@ class SubjectsController < ApplicationController
@shixuns = Shixun.where(id: params[:shixun_id]).order("id desc")
end
+ # 添加实训项目
+ def add_shixun_to_stage
+ identifier = generate_identifier Shixun, 8
+ ActiveRecord::Base.transaction do
+ @shixun = Shixun.create!(name: params[:name], user_id: current_user.id, identifier: identifier)
+ # 添加合作者
+ @shixun.shixun_members.create!(user_id: current_user.id, role: 1)
+ end
+ end
+
def choose_course
course_ids = Course.find_by_sql("SELECT c.id FROM courses c, course_members m
WHERE m.course_id = c.id AND m.role in (1,2,3)
diff --git a/app/views/subjects/add_shixun_to_stage.json.jbuilder b/app/views/subjects/add_shixun_to_stage.json.jbuilder
new file mode 100644
index 000000000..45b584231
--- /dev/null
+++ b/app/views/subjects/add_shixun_to_stage.json.jbuilder
@@ -0,0 +1,3 @@
+json.shixun_identifier @shixun.identifier
+json.shixun_name @shixun.name
+json.shixun_id @shixun.id
\ No newline at end of file
From baf6774aab15cc51fbc5072da1721bcae3e395a3 Mon Sep 17 00:00:00 2001
From: daiao <358551898@qq.com>
Date: Tue, 26 Nov 2019 14:07:37 +0800
Subject: [PATCH 29/43] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=AE=9E=E8=AE=AD?=
=?UTF-8?q?=E5=90=8D=E7=A7=B0=E8=B7=AF=E7=94=B1?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
config/routes.rb | 1 +
1 file changed, 1 insertion(+)
diff --git a/config/routes.rb b/config/routes.rb
index 0f31c6d48..fc2ff5e3d 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -325,6 +325,7 @@ Rails.application.routes.draw do
get 'create_subject'
get 'new_subject'
post 'append_to_stage'
+ post :add_shixun_to_stage
get 'search'
end
end
From 11c6e54d904131dbab71c15e3b195c36867c0ba1 Mon Sep 17 00:00:00 2001
From: daiao <358551898@qq.com>
Date: Tue, 26 Nov 2019 14:49:37 +0800
Subject: [PATCH 30/43] =?UTF-8?q?=E6=9D=83=E9=99=90=E9=97=AE=E9=A2=98?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/controllers/subjects_controller.rb | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/app/controllers/subjects_controller.rb b/app/controllers/subjects_controller.rb
index 9ba8bb55d..f25459ee4 100644
--- a/app/controllers/subjects_controller.rb
+++ b/app/controllers/subjects_controller.rb
@@ -2,7 +2,7 @@ class SubjectsController < ApplicationController
before_action :require_login, :check_auth, except: [:index, :show, :right_banner]
# before_action :check_auth, except: [:index]
before_action :check_account, except: [:index, :show, :right_banner]
- before_action :find_subject, except: [:index, :create, :new, :append_to_stage]
+ before_action :find_subject, except: [:index, :create, :new, :append_to_stage, :add_shixun_to_stage]
before_action :allowed, only: [:update, :edit, :destroy, :publish, :cancel_publish, :cancel_has_publish,
:search_members, :add_subject_members, :statistics, :shixun_report, :school_report,
:up_member_position, :down_member_position, :update_team_title, :add_shixun_to_stage]
From 02fead012bf5e4ab1a35cb8337c2fba231de859c Mon Sep 17 00:00:00 2001
From: daiao <358551898@qq.com>
Date: Tue, 26 Nov 2019 14:51:31 +0800
Subject: [PATCH 31/43] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=AE=9E=E8=AE=AD?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/controllers/subjects_controller.rb | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/app/controllers/subjects_controller.rb b/app/controllers/subjects_controller.rb
index f25459ee4..917f3ad8e 100644
--- a/app/controllers/subjects_controller.rb
+++ b/app/controllers/subjects_controller.rb
@@ -5,7 +5,7 @@ class SubjectsController < ApplicationController
before_action :find_subject, except: [:index, :create, :new, :append_to_stage, :add_shixun_to_stage]
before_action :allowed, only: [:update, :edit, :destroy, :publish, :cancel_publish, :cancel_has_publish,
:search_members, :add_subject_members, :statistics, :shixun_report, :school_report,
- :up_member_position, :down_member_position, :update_team_title, :add_shixun_to_stage]
+ :up_member_position, :down_member_position, :update_team_title]
before_action :require_admin, only: [:copy_subject]
include ApplicationHelper
From c1bc58de8d24e17a133f502b5d2a607fefd97289 Mon Sep 17 00:00:00 2001
From: cxt <853663049@qq.com>
Date: Tue, 26 Nov 2019 16:52:40 +0800
Subject: [PATCH 32/43] =?UTF-8?q?=E5=B0=8F=E7=A8=8B=E5=BA=8F=E8=B0=83?=
=?UTF-8?q?=E8=AF=95?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/libs/wechat/weapp.rb | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/app/libs/wechat/weapp.rb b/app/libs/wechat/weapp.rb
index ca356b28d..cbf26efd2 100644
--- a/app/libs/wechat/weapp.rb
+++ b/app/libs/wechat/weapp.rb
@@ -22,8 +22,8 @@ class Wechat::Weapp
end
def decrypt(session_key, encrypted_data, iv)
- session_key = Base64.decode64(session_key)
- encrypted_data = Base64.decode64(encrypted_data)
+ session_key = Base64.decode64(session_key).force_encoding("utf-8")
+ encrypted_data = Base64.decode64(encrypted_data).force_encoding("utf-8")
iv = Base64.decode64(iv)
cipher = OpenSSL::Cipher::AES.new(128, :CBC)
From 24b7e9763302aa0ad1c09c2c0db429a99d200378 Mon Sep 17 00:00:00 2001
From: cxt <853663049@qq.com>
Date: Tue, 26 Nov 2019 16:57:50 +0800
Subject: [PATCH 33/43] =?UTF-8?q?=E5=AD=A6=E7=94=9F=E8=BA=AB=E4=BB=BD?=
=?UTF-8?q?=E7=9A=84=E9=97=AE=E5=8D=B7=E7=8A=B6=E6=80=81=E4=B8=8D=E5=AF=B9?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/models/poll.rb | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/app/models/poll.rb b/app/models/poll.rb
index ea6656ca2..5c1a9a64c 100644
--- a/app/models/poll.rb
+++ b/app/models/poll.rb
@@ -128,7 +128,7 @@ class Poll < ApplicationRecord
en_time = end_time
else
poll_group_setting = poll_group_settings
- user_group = course.course_members.where(user_id: user_id).select(:course_group_id)
+ user_group = course.students.where(user_id: user_id).select(:course_group_id)
if user_group.exists?
user_group_id = user_group.first&.course_group_id
user_p_group_setting = poll_group_setting.where(course_group_id: user_group_id).select(:publish_time,:end_time)
From 91b7648d9e33487d4c2b4313e6c52e521b186ace Mon Sep 17 00:00:00 2001
From: cxt <853663049@qq.com>
Date: Tue, 26 Nov 2019 17:09:06 +0800
Subject: [PATCH 34/43] =?UTF-8?q?=E5=B0=8F=E7=A8=8B=E5=BA=8F=E8=B0=83?=
=?UTF-8?q?=E8=AF=95?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/libs/wechat/weapp.rb | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/app/libs/wechat/weapp.rb b/app/libs/wechat/weapp.rb
index cbf26efd2..aed14128b 100644
--- a/app/libs/wechat/weapp.rb
+++ b/app/libs/wechat/weapp.rb
@@ -22,8 +22,16 @@ class Wechat::Weapp
end
def decrypt(session_key, encrypted_data, iv)
- session_key = Base64.decode64(session_key).force_encoding("utf-8")
- encrypted_data = Base64.decode64(encrypted_data).force_encoding("utf-8")
+ session_key = Base64.decode64(session_key)
+ encrypted_data = Base64.decode64(encrypted_data)
+ cd = CharDet.detect(content)
+ encrypted_data =
+ if cd["encoding"] == 'GB18030' && cd['confidence'] > 0.8
+ encrypted_data.encode('UTF-8', 'GBK', {:invalid => :replace, :undef => :replace, :replace => ' '})
+ else
+ encrypted_data.force_encoding('UTF-8')
+ end
+
iv = Base64.decode64(iv)
cipher = OpenSSL::Cipher::AES.new(128, :CBC)
From 52528fa4c1fc03b9fa4234e7f0f2eb642fbd4b21 Mon Sep 17 00:00:00 2001
From: cxt <853663049@qq.com>
Date: Tue, 26 Nov 2019 17:15:11 +0800
Subject: [PATCH 35/43] =?UTF-8?q?=E5=B0=8F=E7=A8=8B=E5=BA=8F=E8=B0=83?=
=?UTF-8?q?=E8=AF=95?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/libs/wechat/weapp.rb | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/app/libs/wechat/weapp.rb b/app/libs/wechat/weapp.rb
index aed14128b..0a1cc5eed 100644
--- a/app/libs/wechat/weapp.rb
+++ b/app/libs/wechat/weapp.rb
@@ -24,7 +24,7 @@ class Wechat::Weapp
def decrypt(session_key, encrypted_data, iv)
session_key = Base64.decode64(session_key)
encrypted_data = Base64.decode64(encrypted_data)
- cd = CharDet.detect(content)
+ cd = CharDet.detect(encrypted_data)
encrypted_data =
if cd["encoding"] == 'GB18030' && cd['confidence'] > 0.8
encrypted_data.encode('UTF-8', 'GBK', {:invalid => :replace, :undef => :replace, :replace => ' '})
From ac61421fb2c1c7d0c80e1cc869fe028f3b260fd7 Mon Sep 17 00:00:00 2001
From: cxt <853663049@qq.com>
Date: Tue, 26 Nov 2019 17:27:48 +0800
Subject: [PATCH 36/43] =?UTF-8?q?=E5=B0=8F=E7=A8=8B=E5=BA=8F=E8=B0=83?=
=?UTF-8?q?=E8=AF=95?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/libs/wechat/weapp.rb | 8 --------
1 file changed, 8 deletions(-)
diff --git a/app/libs/wechat/weapp.rb b/app/libs/wechat/weapp.rb
index 0a1cc5eed..ca356b28d 100644
--- a/app/libs/wechat/weapp.rb
+++ b/app/libs/wechat/weapp.rb
@@ -24,14 +24,6 @@ class Wechat::Weapp
def decrypt(session_key, encrypted_data, iv)
session_key = Base64.decode64(session_key)
encrypted_data = Base64.decode64(encrypted_data)
- cd = CharDet.detect(encrypted_data)
- encrypted_data =
- if cd["encoding"] == 'GB18030' && cd['confidence'] > 0.8
- encrypted_data.encode('UTF-8', 'GBK', {:invalid => :replace, :undef => :replace, :replace => ' '})
- else
- encrypted_data.force_encoding('UTF-8')
- end
-
iv = Base64.decode64(iv)
cipher = OpenSSL::Cipher::AES.new(128, :CBC)
From 1e30415c10785d745cf99f618cd6760302c4e459 Mon Sep 17 00:00:00 2001
From: daiao <358551898@qq.com>
Date: Tue, 26 Nov 2019 18:06:09 +0800
Subject: [PATCH 37/43] =?UTF-8?q?OJ=E6=8F=90=E4=BA=A4=E8=AE=B0=E5=BD=95?=
=?UTF-8?q?=E7=9A=84=E8=B7=AF=E7=94=B1?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
config/routes.rb | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/config/routes.rb b/config/routes.rb
index fc2ff5e3d..4d277cd54 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -57,8 +57,14 @@ Rails.application.routes.draw do
get :code_debug
get :code_submit
match :listen_result, :via => [:get, :post]
+ get :submit_records
end
+ collection do
+ get :record_detail
+ end
+
+
end
From 082650e839a700779493f0da8fff0e2535b522b1 Mon Sep 17 00:00:00 2001
From: cxt <853663049@qq.com>
Date: Tue, 26 Nov 2019 18:20:45 +0800
Subject: [PATCH 38/43] =?UTF-8?q?=E5=B0=8F=E7=A8=8B=E5=BA=8F=E8=B0=83?=
=?UTF-8?q?=E8=AF=95?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/controllers/weapps/code_sessions_controller.rb | 2 ++
1 file changed, 2 insertions(+)
diff --git a/app/controllers/weapps/code_sessions_controller.rb b/app/controllers/weapps/code_sessions_controller.rb
index 887e97eed..2dbd08e82 100644
--- a/app/controllers/weapps/code_sessions_controller.rb
+++ b/app/controllers/weapps/code_sessions_controller.rb
@@ -15,6 +15,8 @@ class Weapps::CodeSessionsController < Weapps::BaseController
logged = true
else
# 根据 code没拿到 unionid
+ Rails.logger.info("[Weapp] session_key: #{result['session_key']}")
+ Rails.logger.info("[Weapp] code: #{params[:code]}")
user_info = Wechat::Weapp.decrypt(result['session_key'], params[:encrypted_data], params[:iv])
# 老用户,已绑定
From 4d6f66ea3c28ab321c8a37dc3b88bdd1d113ef13 Mon Sep 17 00:00:00 2001
From: daiao <358551898@qq.com>
Date: Tue, 26 Nov 2019 19:53:26 +0800
Subject: [PATCH 39/43] =?UTF-8?q?=E5=8E=BB=E9=99=A4=E9=87=8D=E5=A4=8D?=
=?UTF-8?q?=E4=BB=A3=E7=A0=81?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/controllers/application_controller.rb | 19 -------------------
1 file changed, 19 deletions(-)
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb
index 4c61fb1df..06adc676d 100644
--- a/app/controllers/application_controller.rb
+++ b/app/controllers/application_controller.rb
@@ -404,25 +404,6 @@ class ApplicationController < ActionController::Base
end
end
- # 处理返回非0就报错的请求
- def interface_post(uri, params, status, message)
- begin
- uid_logger_dubug("--uri_exec: params is #{params}, url is #{uri}")
- uri = URI.parse(URI.encode(uri.strip))
- res = Net::HTTP.post_form(uri, params).body
- uid_logger_dubug("--uri_exec: .....res is #{res}")
- res = JSON.parse(res)
- if (res && res['code'] != 0)
- tip_exception(status, message)
- else
- res
- end
- rescue Exception => e
- uid_logger("--uri_exec: exception #{e.message}")
- raise Educoder::TipException.new("实训平台繁忙(繁忙等级:84)")
- end
- end
-
# json格式请求
def interface_json_post(uri, params, status, message)
begin
From b18588464a17709e099456d94c22f9ba50dbaaf3 Mon Sep 17 00:00:00 2001
From: daiao <358551898@qq.com>
Date: Tue, 26 Nov 2019 19:57:25 +0800
Subject: [PATCH 40/43] 1
---
config/routes.rb | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/config/routes.rb b/config/routes.rb
index 4d277cd54..070d2f383 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -42,7 +42,6 @@ Rails.application.routes.draw do
member do
post :publish
get :start
- get :result
post :update_set
delete :delete_set
end
@@ -57,6 +56,7 @@ Rails.application.routes.draw do
get :code_debug
get :code_submit
match :listen_result, :via => [:get, :post]
+ get :result
get :submit_records
end
From bf1c27666dad744ebf102066ee76cff9b3fcaf4a Mon Sep 17 00:00:00 2001
From: daiao <358551898@qq.com>
Date: Tue, 26 Nov 2019 20:13:10 +0800
Subject: [PATCH 41/43] =?UTF-8?q?=E5=9B=9E=E5=A4=8D=E5=88=9D=E5=A7=8B?=
=?UTF-8?q?=E4=BB=A3=E7=A0=81?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/controllers/hack_user_lastest_codes_controller.rb | 9 +++++++--
.../restore_initial_code.json.jbuilder | 1 +
config/routes.rb | 1 +
3 files changed, 9 insertions(+), 2 deletions(-)
create mode 100644 app/views/hack_user_lastest_codes/restore_initial_code.json.jbuilder
diff --git a/app/controllers/hack_user_lastest_codes_controller.rb b/app/controllers/hack_user_lastest_codes_controller.rb
index 2d749ce75..d03b9bd7d 100644
--- a/app/controllers/hack_user_lastest_codes_controller.rb
+++ b/app/controllers/hack_user_lastest_codes_controller.rb
@@ -1,9 +1,9 @@
class HackUserLastestCodesController < ApplicationController
before_action :require_login, except: [:listen_result]
before_action :find_my_hack, only: [:show, :code_debug, :code_submit, :update_code,
- :listen_result, :result, :submit_records]
+ :listen_result, :result, :submit_records, :restore_initial_code]
before_action :update_user_hack_status, only: [:code_debug, :code_submit]
- before_action :require_auth_identity, only: [:update_code]
+ before_action :require_auth_identity, only: [:update_code, :restore_initial_code]
before_action :require_manager_identity, only: [:update_code]
def show
@@ -14,6 +14,11 @@ class HackUserLastestCodesController < ApplicationController
@my_hack.update_attribute(:code, params[:code])
end
+ # 回复初始代码
+ def restore_initial_code
+ @my_hack.update_attribute(:code, @hack.code)
+ end
+
# 调试代码
def code_debug
exec_mode = "debug"
diff --git a/app/views/hack_user_lastest_codes/restore_initial_code.json.jbuilder b/app/views/hack_user_lastest_codes/restore_initial_code.json.jbuilder
new file mode 100644
index 000000000..3b272f298
--- /dev/null
+++ b/app/views/hack_user_lastest_codes/restore_initial_code.json.jbuilder
@@ -0,0 +1 @@
+json.code @hack.code
\ No newline at end of file
diff --git a/config/routes.rb b/config/routes.rb
index 070d2f383..577428c7a 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -58,6 +58,7 @@ Rails.application.routes.draw do
match :listen_result, :via => [:get, :post]
get :result
get :submit_records
+ post :restore_initial_code
end
collection do
From 2045fb59907aba3097fe56fd4d286a242de274dd Mon Sep 17 00:00:00 2001
From: daiao <358551898@qq.com>
Date: Wed, 27 Nov 2019 09:48:54 +0800
Subject: [PATCH 42/43] 1
---
app/controllers/concerns/login_helper.rb | 2 +-
app/controllers/oauth/base_controller.rb | 9 +++++++++
2 files changed, 10 insertions(+), 1 deletion(-)
diff --git a/app/controllers/concerns/login_helper.rb b/app/controllers/concerns/login_helper.rb
index cf0c8e1e3..ec4656e3b 100644
--- a/app/controllers/concerns/login_helper.rb
+++ b/app/controllers/concerns/login_helper.rb
@@ -29,7 +29,7 @@ module LoginHelper
Rails.logger.info("id: #{user&.id} Successful authentication start: '#{user.login}' from #{request.remote_ip} at #{Time.now.utc}")
# Valid user
self.logged_user = user
-
+ session[:"#{default_yun_session}"] = user.id
# generate a key and set cookie if autologin
set_autologin_cookie(user)
diff --git a/app/controllers/oauth/base_controller.rb b/app/controllers/oauth/base_controller.rb
index 327f21845..6236ff02b 100644
--- a/app/controllers/oauth/base_controller.rb
+++ b/app/controllers/oauth/base_controller.rb
@@ -5,6 +5,10 @@ class Oauth::BaseController < ActionController::Base
skip_before_action :verify_authenticity_token
+ included do
+ helper_method :default_yun_session
+ end
+
def auth_failure
render_error(params[:message])
end
@@ -24,4 +28,9 @@ class Oauth::BaseController < ActionController::Base
Rails.logger.info("[OAuth2] omniauth.auth -> #{request.env['omniauth.auth'].inspect}")
request.env['omniauth.auth']
end
+
+ def default_yun_session
+ @_default_yun_session = "#{request.subdomain.split('.').first}_user_id"
+ # @_default_yun_session = "#{current_laboratory.try(:identifier).split('.').first}_user_id"
+ end
end
\ No newline at end of file
From c5217b93a95bb723dd6089d038e3aa368b8e3a53 Mon Sep 17 00:00:00 2001
From: daiao <358551898@qq.com>
Date: Wed, 27 Nov 2019 09:51:10 +0800
Subject: [PATCH 43/43] 2
---
app/controllers/oauth/base_controller.rb | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)
diff --git a/app/controllers/oauth/base_controller.rb b/app/controllers/oauth/base_controller.rb
index 6236ff02b..11ac69d71 100644
--- a/app/controllers/oauth/base_controller.rb
+++ b/app/controllers/oauth/base_controller.rb
@@ -2,13 +2,10 @@ class Oauth::BaseController < ActionController::Base
include RenderHelper
include LoginHelper
include ControllerRescueHandler
+ include LaboratoryHelper
skip_before_action :verify_authenticity_token
- included do
- helper_method :default_yun_session
- end
-
def auth_failure
render_error(params[:message])
end