From aa3063a931be08523b9661dc66250c03d93bd9ad Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Sat, 21 Sep 2019 10:57:26 +0800 Subject: [PATCH 01/25] =?UTF-8?q?=E9=87=91=E8=AF=BE=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/subjects_controller.rb | 14 ++++++++++++++ app/decorators/tiding_decorator.rb | 4 ++++ app/models/subject.rb | 8 ++++++++ app/models/subject_appointment.rb | 4 ++++ app/views/subjects/show.json.jbuilder | 5 +++++ config/locales/tidings/zh-CN.yml | 1 + config/routes.rb | 1 + ...20190921010411_add_course_member_to_subjects.rb | 6 ++++++ .../20190921015840_create_subject_appointments.rb | 10 ++++++++++ spec/models/subject_appointment_spec.rb | 5 +++++ 10 files changed, 58 insertions(+) create mode 100644 app/models/subject_appointment.rb create mode 100644 db/migrate/20190921010411_add_course_member_to_subjects.rb create mode 100644 db/migrate/20190921015840_create_subject_appointments.rb create mode 100644 spec/models/subject_appointment_spec.rb diff --git a/app/controllers/subjects_controller.rb b/app/controllers/subjects_controller.rb index 36f14a5d5..16f9361f9 100644 --- a/app/controllers/subjects_controller.rb +++ b/app/controllers/subjects_controller.rb @@ -415,6 +415,20 @@ class SubjectsController < ApplicationController order by ue_count desc limit 10") end + # 预约报名 + def appointment + tip_exception("还存在未结束的课堂") unless @subject.max_course_end_date.nil? || @subject.max_course_end_date < Date.today + tip_exception("无需重复报名") if @subject.subject_appointments.exists?(user_id: current_user.id) + ActiveRecord::Base.transaction do + @subject.subject_appointments << SubjectAppointment.new(user_id: current_user.id) + @subject.increment!(:participant_count) + if @subject.participant_count == @subject.student_count + @subject.start_course_notify + end + normal_status("预约成功") + end + end + private def subject_params tip_exception("实训路径名称不能为空") if params[:name].blank? diff --git a/app/decorators/tiding_decorator.rb b/app/decorators/tiding_decorator.rb index 851c3d075..b4f851e5f 100644 --- a/app/decorators/tiding_decorator.rb +++ b/app/decorators/tiding_decorator.rb @@ -384,4 +384,8 @@ module TidingDecorator def public_course_start_content I18n.t(locale_format) % [belong_container&.name, belong_container&.start_date&.strftime("%Y-%m-%d")] end + + def subject_start_course_content + I18n.t(locale_format) % belong_container&.name + end end diff --git a/app/models/subject.rb b/app/models/subject.rb index d5ea3f433..a58074e6f 100644 --- a/app/models/subject.rb +++ b/app/models/subject.rb @@ -13,6 +13,8 @@ class Subject < ApplicationRecord has_many :stage_shixuns, dependent: :destroy has_many :shixuns, through: :stage_shixuns + has_many :subject_appointments, dependent: :destroy + has_many :subject_members, ->{ order("subject_members.position asc")}, dependent: :destroy has_many :users, through: :subject_members has_many :tidings, as: :container, dependent: :destroy @@ -109,4 +111,10 @@ class Subject < ApplicationRecord def learning? user_id Myshixun.where(user_id: user_id, shixun_id: shixuns).exists? end + + def start_course_notify + Tiding.create(user_id: user_id, trigger_user_id: 0, container_id: id, + container_type: 'SubjectStartCourse', belong_container_id: id, + belong_container_type: 'Subject', tiding_type: 'System') + end end \ No newline at end of file diff --git a/app/models/subject_appointment.rb b/app/models/subject_appointment.rb new file mode 100644 index 000000000..a4bc53b18 --- /dev/null +++ b/app/models/subject_appointment.rb @@ -0,0 +1,4 @@ +class SubjectAppointment < ApplicationRecord + belongs_to :subject + belongs_to :user +end diff --git a/app/views/subjects/show.json.jbuilder b/app/views/subjects/show.json.jbuilder index 997e0c3d6..51311c062 100644 --- a/app/views/subjects/show.json.jbuilder +++ b/app/views/subjects/show.json.jbuilder @@ -24,4 +24,9 @@ if @subject.excellent json.course_identity @user.course_identity(course) json.course_status subject_course_status course end + + if @subject.max_course_end_date.nil? || @subject.max_course_end_date < Date.today + json.student_count @subject.student_count + json.participant_count @subject.participant_count + end end \ No newline at end of file diff --git a/config/locales/tidings/zh-CN.yml b/config/locales/tidings/zh-CN.yml index ce6fd57b0..4d6579066 100644 --- a/config/locales/tidings/zh-CN.yml +++ b/config/locales/tidings/zh-CN.yml @@ -227,3 +227,4 @@ 1_end: "你提交的发布视频申请:%s,审核已通过" 2_end: "你提交的发布视频申请:%s,审核未通过
原因:%{reason}" PublicCourseStart_end: "你报名参与的开放课程:%s,将于%s正式开课" + SubjectStartCourse_end: "您创建的开放课程:%s 已达到开课人数要求。您可以在24小时内自主开设新一期课程。如果超过24小时未开课,平台将自动开课并复制您上一期的课程内容。" diff --git a/config/routes.rb b/config/routes.rb index ba851b2f2..32799286f 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -284,6 +284,7 @@ Rails.application.routes.draw do post :up_member_position post :down_member_position get :right_banner + post :appointment end collection do diff --git a/db/migrate/20190921010411_add_course_member_to_subjects.rb b/db/migrate/20190921010411_add_course_member_to_subjects.rb new file mode 100644 index 000000000..76df05604 --- /dev/null +++ b/db/migrate/20190921010411_add_course_member_to_subjects.rb @@ -0,0 +1,6 @@ +class AddCourseMemberToSubjects < ActiveRecord::Migration[5.2] + def change + add_column :subjects, :student_count, :integer, :default => 0 + add_column :subjects, :participant_count, :integer, :default => 0 + end +end diff --git a/db/migrate/20190921015840_create_subject_appointments.rb b/db/migrate/20190921015840_create_subject_appointments.rb new file mode 100644 index 000000000..68c924de7 --- /dev/null +++ b/db/migrate/20190921015840_create_subject_appointments.rb @@ -0,0 +1,10 @@ +class CreateSubjectAppointments < ActiveRecord::Migration[5.2] + def change + create_table :subject_appointments do |t| + t.references :subject, index: true + t.references :user, index: true + + t.timestamps + end + end +end diff --git a/spec/models/subject_appointment_spec.rb b/spec/models/subject_appointment_spec.rb new file mode 100644 index 000000000..9b8d2e1bd --- /dev/null +++ b/spec/models/subject_appointment_spec.rb @@ -0,0 +1,5 @@ +require 'rails_helper' + +RSpec.describe SubjectAppointment, type: :model do + pending "add some examples to (or delete) #{__FILE__}" +end From 490a30444a46a07d4cd730030061a72e8d095968 Mon Sep 17 00:00:00 2001 From: p31729568 Date: Sat, 21 Sep 2019 10:59:57 +0800 Subject: [PATCH 02/25] fix --- app/views/ecs/graduation_course_supports/show.xlsx.axlsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/ecs/graduation_course_supports/show.xlsx.axlsx b/app/views/ecs/graduation_course_supports/show.xlsx.axlsx index e2c2599ec..6222539af 100644 --- a/app/views/ecs/graduation_course_supports/show.xlsx.axlsx +++ b/app/views/ecs/graduation_course_supports/show.xlsx.axlsx @@ -11,7 +11,7 @@ wb.styles do |style| ec_year_style = style.add_style(sz: 10, height: 14) label_style = style.add_style(sz: 11, b: true, bg_color: '90EE90', alignment: { horizontal: :center }, border: { style: :thin, color: '000000' }) content_style = style.add_style(sz: 11, height: 16, border: { style: :thin, color: '000000' }) - tip_style = style.add_style(sz: 11, height: 16, color: 'FFA07A') + tip_style = style.add_style(sz: 11, height: 16, color: '#FFA07A') wb.add_worksheet(:name => '课程体系对毕业要求的支撑') do |sheet| sheet.add_row ['课程体系VS毕业要求'], style: title_style From f00da2711bf8fe080f6cb42ccae469a60fedfe33 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E6=A0=91=E6=98=8E?= <775174143@qq.com> Date: Sat, 21 Sep 2019 11:08:04 +0800 Subject: [PATCH 03/25] =?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/public/css/edu-all.css | 2 +- .../react/src/modules/ecs/EcSetting/CourseSupports/index.js | 4 ++-- public/stylesheets/educoder/edu-all.css | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/public/react/public/css/edu-all.css b/public/react/public/css/edu-all.css index 425255048..cb78f8e00 100644 --- a/public/react/public/css/edu-all.css +++ b/public/react/public/css/edu-all.css @@ -3048,7 +3048,7 @@ a.singlepublishtwo{ /*工程认证*/ /*首页*/ .authMainImg{width: 100%;height: 240px;background:url("/images/educoder/auth/banner1.jpg") no-repeat top center;background-size: 100% 100%;justify-content: center;align-items: center;display: -webkit-flex;} -.ListTableLine>p,.ListTableLine>.ListTableTitle{padding: 0px 30px;background-color: #F5F5F5;line-height: 40px;height: 56px;padding-top: 8px;box-sizing: border-box;} +.ListTableLine>p,.ListTableLine>.ListTableTitle{margin-bottom: 0px;padding: 0px 30px;background-color: #F5F5F5;line-height: 40px;height: 56px;padding-top: 8px;box-sizing: border-box;} .ListTableLine>p span,.ListTableTitle span{float: left;color: #666;box-sizing: border-box} .ListTableLine li{min-height: 48px;padding: 10px 0px;box-sizing: border-box;margin:0px 30px;border-bottom: 1px solid #eaeaea;} .ListTableLine li>span{float: left;box-sizing: border-box;} diff --git a/public/react/src/modules/ecs/EcSetting/CourseSupports/index.js b/public/react/src/modules/ecs/EcSetting/CourseSupports/index.js index 53ad2d936..1fe126d21 100644 --- a/public/react/src/modules/ecs/EcSetting/CourseSupports/index.js +++ b/public/react/src/modules/ecs/EcSetting/CourseSupports/index.js @@ -579,7 +579,7 @@ class CourseSupports extends Component { let ismidbox={width:123.82*max_support_count+"px",margin:'0px 0px'}; - console.log(this.props.year&&this.props.year.can_manager) + // console.log(this.props.year&&this.props.year.can_manager) return (
毕业要求指标点({data.count} - 课程体系({data.course_count} + 课程体系({data.course_count}
diff --git a/public/stylesheets/educoder/edu-all.css b/public/stylesheets/educoder/edu-all.css index 91ea604d4..c20b648db 100644 --- a/public/stylesheets/educoder/edu-all.css +++ b/public/stylesheets/educoder/edu-all.css @@ -3051,7 +3051,7 @@ a.singlepublishtwo{ /*工程认证*/ /*首页*/ .authMainImg{width: 100%;height: 240px;background:url("/images/educoder/auth/banner1.jpg") no-repeat top center;background-size: 100% 100%;justify-content: center;align-items: center;display: -webkit-flex;} -.ListTableLine>p,.ListTableLine>.ListTableTitle{padding: 0px 30px;background-color: #F5F5F5;line-height: 40px;height: 56px;padding-top: 8px;box-sizing: border-box;} +.ListTableLine>p,.ListTableLine>.ListTableTitle{margin-bottom: 0px;padding: 0px 30px;background-color: #F5F5F5;line-height: 40px;height: 56px;padding-top: 8px;box-sizing: border-box;} .ListTableLine>p span,.ListTableTitle span{float: left;color: #666;box-sizing: border-box} .ListTableLine li{min-height: 48px;padding: 10px 0px;box-sizing: border-box;margin:0px 30px;border-bottom: 1px solid #eaeaea;} .ListTableLine li>span{float: left;box-sizing: border-box;} From b8ae779bd9edd38de3ac56e26c65bb014d17c74b Mon Sep 17 00:00:00 2001 From: p31729568 Date: Sat, 21 Sep 2019 11:18:19 +0800 Subject: [PATCH 04/25] ecs: fix export xlsx --- .../graduation_course_supports/show.xlsx.axlsx | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/app/views/ecs/graduation_course_supports/show.xlsx.axlsx b/app/views/ecs/graduation_course_supports/show.xlsx.axlsx index 6222539af..ae81d931b 100644 --- a/app/views/ecs/graduation_course_supports/show.xlsx.axlsx +++ b/app/views/ecs/graduation_course_supports/show.xlsx.axlsx @@ -9,13 +9,13 @@ wb = xlsx_package.workbook wb.styles do |style| title_style = style.add_style(sz: 16, height: 20, b: true) ec_year_style = style.add_style(sz: 10, height: 14) - label_style = style.add_style(sz: 11, b: true, bg_color: '90EE90', alignment: { horizontal: :center }, border: { style: :thin, color: '000000' }) + label_style = style.add_style(sz: 11, b: true, bg_color: '90EE90', alignment: { horizontal: :center, vertical: :center }, border: { style: :thin, color: '000000' }) content_style = style.add_style(sz: 11, height: 16, border: { style: :thin, color: '000000' }) - tip_style = style.add_style(sz: 11, height: 16, color: '#FFA07A') + tip_style = style.add_style(sz: 11, height: 16, color: Axlsx::Color.new(rgb: 'FFFFA07A')) wb.add_worksheet(:name => '课程体系对毕业要求的支撑') do |sheet| sheet.add_row ['课程体系VS毕业要求'], style: title_style - sheet.merge_cells wb.rows.first.cells[(1..(3 + max_support_length - 1))] + sheet.merge_cells sheet.rows.first.cells[(1..(3 + max_support_length - 1))] sheet.add_row [] @@ -25,8 +25,8 @@ wb.styles do |style| sheet.add_row ['注:有对应关系的课程名称下方为其权重系数,一个指标点的权重系数之和必须等于1'], style: tip_style sheet.add_row ['注:“★” 表示关联度高'] - sheet.merge_cells wb.rows[5].cells[(1..(3 + max_support_length - 1))] - sheet.merge_cells wb.rows[6].cells[(1..(3 + max_support_length - 1))] + sheet.merge_cells sheet.rows[5].cells[(1..(3 + max_support_length - 1))] + sheet.merge_cells sheet.rows[6].cells[(1..(3 + max_support_length - 1))] sheet.add_row [] @@ -34,9 +34,9 @@ wb.styles do |style| data[last_column_index] = '课程数量' sheet.add_row data, style: label_style course_columns = max_support_length.times.map { |i| "课程#{i + 1}" } - sheet.add_row %w('一级 二级') + course_columns + ['∑目标值'], style: label_style + sheet.add_row %w(一级 二级) + course_columns + ['∑目标值'], style: label_style sheet.merge_cells("A9:B9") - sheet.merge_cells wb.rows[8].cells[(3..(3 + max_support_length - 1))] + # sheet.merge_cells sheet.rows[8].cells[(3..(3 + max_support_length - 1))] current_row = 11 graduation_subitems.group_by(&:ec_graduation_requirement).each do |requirement, items| @@ -61,11 +61,11 @@ wb.styles do |style| sheet.add_row course_data, style: styles sheet.add_row weight_data, style: styles - sheet.merge_cells("B#{current_row - 1}:B#{current_row}") + sheet.merge_cells("B#{current_row}:B#{current_row + 1}") current_row += 2 end - sheet.merge_cells("A#{start_row - 1}:B#{current_row - 1}") + sheet.merge_cells("A#{start_row}:A#{current_row - 1}") end end end \ No newline at end of file From df50ee59ecac43bf5f9e880a4edf9870050f2fb9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E6=A0=91=E6=98=8E?= <775174143@qq.com> Date: Sat, 21 Sep 2019 11:18:33 +0800 Subject: [PATCH 05/25] =?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/ecs/EcSetting/CourseSupports/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/react/src/modules/ecs/EcSetting/CourseSupports/index.js b/public/react/src/modules/ecs/EcSetting/CourseSupports/index.js index 1fe126d21..aeaf58f53 100644 --- a/public/react/src/modules/ecs/EcSetting/CourseSupports/index.js +++ b/public/react/src/modules/ecs/EcSetting/CourseSupports/index.js @@ -623,7 +623,7 @@ class CourseSupports extends Component {
- 毕业要求指标点({data.count} + 毕业要求指标点({data.count} 课程体系({data.course_count}
From 5b347ca199f43b4b44429977476a33223c9de790 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E6=A0=91=E6=98=8E?= <775174143@qq.com> Date: Sat, 21 Sep 2019 11:25:03 +0800 Subject: [PATCH 06/25] =?UTF-8?q?=E8=AF=BE=E7=A8=8B=E4=BD=93=E7=B3=BB=20vs?= =?UTF-8?q?=20=E6=AF=95=E4=B8=9A=E8=A6=81=E6=B1=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/react/src/modules/ecs/EcSetting/CourseSupports/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/react/src/modules/ecs/EcSetting/CourseSupports/index.js b/public/react/src/modules/ecs/EcSetting/CourseSupports/index.js index aeaf58f53..511a0da64 100644 --- a/public/react/src/modules/ecs/EcSetting/CourseSupports/index.js +++ b/public/react/src/modules/ecs/EcSetting/CourseSupports/index.js @@ -633,7 +633,7 @@ class CourseSupports extends Component {

毕业要求指标点 - {list(max_support_count<5||max_support_count===undefined?5:max_support_count)} + {data.graduation_subitems===undefined?"":list(max_support_count<5||max_support_count===undefined?5:max_support_count)} Date: Sat, 21 Sep 2019 12:27:40 +0800 Subject: [PATCH 07/25] =?UTF-8?q?=E8=B0=83=E6=95=B4=E8=AF=84=E5=88=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/react/src/modules/tpm/TPMBanner.js | 36 +++++--- .../src/modules/tpm/TPMShixunDiscuss.css | 92 +++++++++---------- .../src/modules/tpm/shixuns/css/TPMBanner.css | 2 +- 3 files changed, 71 insertions(+), 59 deletions(-) diff --git a/public/react/src/modules/tpm/TPMBanner.js b/public/react/src/modules/tpm/TPMBanner.js index 1ac81fe86..70e837bec 100644 --- a/public/react/src/modules/tpm/TPMBanner.js +++ b/public/react/src/modules/tpm/TPMBanner.js @@ -8,7 +8,7 @@ import PropTypes from 'prop-types'; import { Rating ,Progress} from "@icedesign/base"; -import {Modal,Input,Radio,Pagination,message,Spin,Icon,Tooltip} from 'antd'; +import {Modal,Input,Radio,Pagination,message,Spin,Icon,Tooltip,Rate} from 'antd'; import AccountProfile from"../user/AccountProfile"; @@ -607,7 +607,19 @@ class TPMBanner extends Component {

-