From 0f22210bf5f3da0a9300bd28fd86ee2f17285048 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Thu, 12 Mar 2020 12:00:48 +0800 Subject: [PATCH 1/8] =?UTF-8?q?=E9=AB=98=E6=A0=A1=E5=90=88=E5=B9=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/tasks/schools.rake | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 lib/tasks/schools.rake diff --git a/lib/tasks/schools.rake b/lib/tasks/schools.rake new file mode 100644 index 000000000..f5a66a786 --- /dev/null +++ b/lib/tasks/schools.rake @@ -0,0 +1,21 @@ +#coding=utf-8 + +desc "合并高校的数据,第一个参数是: 正确高校的id, 第二个参数是: 错误高校需要合并到正确高校的id" +# 命令: bundle exec rake schools:merge_school_data f_school=1 s_school=2,3 +namespace :schools do + task merge_school_data: :environment do + f_school = ENV['f_school'].to_i + school = School.find_by(id: f_school) + return if school.blank? + + s_school = ENV['s_school'].split(",") + merge_schools = School.where(id: s_school) + + # 改变用户的学校id 和 单位 + UserExtension.where(school_id: merge_schools) + .update_all(school_id: f_school, department_id: nil) + + # 改变课堂的学校id + Course.where(school_id: merge_schools).update_all(school_id: f_school) + end +end \ No newline at end of file From d2a282e37befae934cd25424c9e1b0dad371d1fb Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Thu, 12 Mar 2020 12:10:46 +0800 Subject: [PATCH 2/8] =?UTF-8?q?=E5=AE=9E=E8=AE=AD=E6=95=B0=E7=9B=AE?= =?UTF-8?q?=E8=BF=81=E7=A7=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/tasks/schools.rake | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lib/tasks/schools.rake b/lib/tasks/schools.rake index f5a66a786..3b62c5e20 100644 --- a/lib/tasks/schools.rake +++ b/lib/tasks/schools.rake @@ -17,5 +17,12 @@ namespace :schools do # 改变课堂的学校id Course.where(school_id: merge_schools).update_all(school_id: f_school) + + # 实训报告表迁移数据 + s_report = SchoolReport.find_by(school_id: f_school) + SchoolReport.where(school_id: merge_schools).each do |sr| + s_report.update_column(:shixun_evaluate_count, shixun_evaluate_count+sr.shixun_evaluate_count) + sr.update(shixun_evaluate_count: 0) + end end end \ No newline at end of file From 52fe87875b6a3044bbb1422090cc270d2d309cf3 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Thu, 12 Mar 2020 12:11:49 +0800 Subject: [PATCH 3/8] =?UTF-8?q?=E8=B0=83=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/tasks/schools.rake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/tasks/schools.rake b/lib/tasks/schools.rake index 3b62c5e20..0d2cf0899 100644 --- a/lib/tasks/schools.rake +++ b/lib/tasks/schools.rake @@ -21,7 +21,7 @@ namespace :schools do # 实训报告表迁移数据 s_report = SchoolReport.find_by(school_id: f_school) SchoolReport.where(school_id: merge_schools).each do |sr| - s_report.update_column(:shixun_evaluate_count, shixun_evaluate_count+sr.shixun_evaluate_count) + s_report.update_column(:shixun_evaluate_count, s_report.shixun_evaluate_count+sr.shixun_evaluate_count) sr.update(shixun_evaluate_count: 0) end end From 60e087b0eb528e9cf87219b135a82e27c3257fb6 Mon Sep 17 00:00:00 2001 From: anke1460 Date: Thu, 12 Mar 2020 13:39:33 +0800 Subject: [PATCH 4/8] =?UTF-8?q?=E8=AF=BE=E5=A0=82=E8=A7=86=E9=A2=91id?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/services/create_watch_video_service.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/services/create_watch_video_service.rb b/app/services/create_watch_video_service.rb index c7b3bb3bb..8a9bb7f08 100644 --- a/app/services/create_watch_video_service.rb +++ b/app/services/create_watch_video_service.rb @@ -38,9 +38,9 @@ class CreateWatchVideoService < ApplicationService end else # 开始播放时记录一次 - if params[:course_id].present? + if params[:course_video_id].present? # 课堂视频 - course_video = CourseVideo.find_by(params[:course_video_id]) + course_video = CourseVideo.find(params[:course_video_id]) watch_course_video = WatchCourseVideo.find_or_initialize_by(course_video_id: course_video.id, user_id: user.id) do |d| d.start_at = current_time d.duration = params[:duration] From 341fb50e585a3ad8226ac8e83f1f6e4bda4a49cd Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Thu, 12 Mar 2020 14:00:43 +0800 Subject: [PATCH 5/8] =?UTF-8?q?=E6=AD=A3=E5=9C=A8=E7=AD=BE=E5=88=B0?= =?UTF-8?q?=E7=9A=84=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/weapps/attendances_controller.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/controllers/weapps/attendances_controller.rb b/app/controllers/weapps/attendances_controller.rb index 6cc2dda4e..2ec4180a1 100644 --- a/app/controllers/weapps/attendances_controller.rb +++ b/app/controllers/weapps/attendances_controller.rb @@ -94,7 +94,9 @@ class Weapps::AttendancesController < ApplicationController @absence_count = @attendance.absence_count @all_count = @attendance.course_member_attendances.size - @_is_current_attendance = @attendance.current_attendance? + a_end_time = "#{@attendance.attendance_date} #{@attendance.end_time}".to_time + + @_is_current_attendance = Time.current < a_end_time if @attendance.course_attendance_groups.first&.course_group_id.to_i == 0 @group_ids = @course.course_groups.pluck(:id) + [0] From 56c90e53cedb7c0949f564d2bc1d22e8b899a6ad Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Thu, 12 Mar 2020 14:32:38 +0800 Subject: [PATCH 6/8] 1 --- lib/tasks/schools.rake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/tasks/schools.rake b/lib/tasks/schools.rake index 0d2cf0899..a788d57d1 100644 --- a/lib/tasks/schools.rake +++ b/lib/tasks/schools.rake @@ -21,7 +21,7 @@ namespace :schools do # 实训报告表迁移数据 s_report = SchoolReport.find_by(school_id: f_school) SchoolReport.where(school_id: merge_schools).each do |sr| - s_report.update_column(:shixun_evaluate_count, s_report.shixun_evaluate_count+sr.shixun_evaluate_count) + s_report.update_column(:shixun_evaluate_count, (s_report.shixun_evaluate_count+sr.shixun_evaluate_count)) sr.update(shixun_evaluate_count: 0) end end From 92804ee277408fbd5ef0635e60d64adc527a3a1c Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Thu, 12 Mar 2020 14:48:33 +0800 Subject: [PATCH 7/8] =?UTF-8?q?web=E7=AB=AF=E7=9A=84=E6=AD=A3=E5=9C=A8?= =?UTF-8?q?=E7=AD=BE=E5=88=B0=E5=92=8C=E5=8E=86=E5=8F=B2=E7=AD=BE=E5=88=B0?= =?UTF-8?q?=E5=88=97=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/attendances_controller.rb | 39 +++++++++++++++++++++++ app/views/attendances/index.json.jbuilder | 18 +++++++++++ config/routes.rb | 4 +++ 3 files changed, 61 insertions(+) create mode 100644 app/controllers/attendances_controller.rb create mode 100644 app/views/attendances/index.json.jbuilder diff --git a/app/controllers/attendances_controller.rb b/app/controllers/attendances_controller.rb new file mode 100644 index 000000000..17eeab1d6 --- /dev/null +++ b/app/controllers/attendances_controller.rb @@ -0,0 +1,39 @@ +class AttendancesController < ApplicationController + before_action :require_login + before_action :find_course, only: [:index, :student_attendances, :history_attendances] + before_action :find_attendance, except: [:index, :student_attendances, :history_attendances] + before_action :user_course_identity + + def index + current_date = Date.current + current_end_time = Time.current.strftime("%H:%M:%S") + + if params[:history] + @attendances = @course.course_attendances.where("attendance_date < '#{current_date}' or + (attendance_date = '#{current_date}' and end_time < '#{current_end_time}')") + else + @attendances = @course.course_attendances.where("attendance_date > '#{current_date}' or + (attendance_date = '#{current_date}' and end_time > '#{current_end_time}')") + end + @attendances_count = @attendances.size + + @attendances = @attendances.order("attendance_date desc, start_time desc") + @attendances = paginate @attendances.includes(:user, :course_member_attendances) + end + + def history_attendances + current_date = Date.current + current_end_time = Time.current.strftime("%H:%M:%S") + + @history_attendances = @course.course_attendances.where("attendance_date < '#{current_date}' or + (attendance_date = '#{current_date}' and end_time < '#{current_end_time}')").order("id desc") + @all_history_count = @history_attendances.size + @history_attendances = paginate @history_attendances.includes(:course_member_attendances) + end + + private + def find_attendance + @attendance = CourseAttendance.find params[:id] + @course = @attendance.course + end +end \ No newline at end of file diff --git a/app/views/attendances/index.json.jbuilder b/app/views/attendances/index.json.jbuilder new file mode 100644 index 000000000..76febf51e --- /dev/null +++ b/app/views/attendances/index.json.jbuilder @@ -0,0 +1,18 @@ +json.attendances @attendances do |attendance| + json.(attendance, :id, :name, :normal_count, :all_count, :mode) + json.author do + user = attendance.user + json.user_name user.real_name + json.user_login user.login + end + json.attendance_date attendance.attendance_date.strftime("%Y-%m-%d") + json.start_time attendance.start_time.strftime("%H:%M") + json.end_time attendance.end_time.strftime("%H:%M") + json.edit_auth @user_course_identity < Course::PROFESSOR || attendance.user_id == User.current.id + + if @user_course_identity < Course::PROFESSOR == Course::STUDENT + json.attendance_status student_attendance_status(attendance, User.current) + end +end + +json.attendances_count @attendances_count \ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index bcab93203..0f1bc5ba4 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -550,6 +550,10 @@ Rails.application.routes.draw do end end + resources :attendances, shallow: true do + + end + resources :polls, only:[:index,:new,:create] do collection do post :publish # 立即发布 From 3d2c7097d9732b6a51c81a9cfc6574565e6aaeed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E6=A0=91=E6=98=8E?= <775174143@qq.com> Date: Thu, 12 Mar 2020 15:24:35 +0800 Subject: [PATCH 8/8] =?UTF-8?q?=E8=B0=83=E6=95=B4=E5=AE=9E=E8=AE=AD?= =?UTF-8?q?=E3=80=81=E8=AF=BE=E7=A8=8B=E9=A1=B6=E9=83=A8=E6=8C=89=E9=92=AE?= =?UTF-8?q?=E6=8F=90=E7=A4=BA=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/react/src/modules/modals/Modals.js | 5 +- .../src/modules/paths/PathDetail/DetailTop.js | 56 +++++++++++-------- public/react/src/modules/tpm/TPMBanner.js | 55 ++++++++++++++---- public/react/src/modules/tpm/TPMIndex.js | 1 + 4 files changed, 82 insertions(+), 35 deletions(-) diff --git a/public/react/src/modules/modals/Modals.js b/public/react/src/modules/modals/Modals.js index 1aaec6402..60485b26a 100644 --- a/public/react/src/modules/modals/Modals.js +++ b/public/react/src/modules/modals/Modals.js @@ -34,6 +34,9 @@ render() { } .color848282{ color:#848282; + } + .task-btn{ + color: #fff !important; } ` } @@ -50,7 +53,7 @@ render() { :
- 取消 + {this.props.cancelText || '取消'} {this.props.okText || '确定'}
} diff --git a/public/react/src/modules/paths/PathDetail/DetailTop.js b/public/react/src/modules/paths/PathDetail/DetailTop.js index d542c225e..1509b2b43 100644 --- a/public/react/src/modules/paths/PathDetail/DetailTop.js +++ b/public/react/src/modules/paths/PathDetail/DetailTop.js @@ -32,7 +32,10 @@ class DetailTop extends Component{ getappointmenttype:false, openpathss:false, cancel_publics:false, - cancel_has_publics:false + cancel_has_publics:false, + applyissuePaths:false, + cancelText:undefined, + okText:undefined } } componentDidMount(){ @@ -110,21 +113,27 @@ class DetailTop extends Component{ applyissuePath=()=>{ + this.setState({ + loadtype:true, + Modalstype: true, + Modalstopval:` 课程需经过平台审核方可公开使用,公开的课程将对平台所`, + modalsMidval:"有人公开可见,若仅本人教学使用则无需申请公开,直接发", + Modalsbottomval:"送到课堂即可。", + applyissuePaths:true + }) + + } + + showapplyissuePath=()=>{ let pathid=this.props.match.params.pathId; let url ="/paths/"+pathid+"/publish.json"; axios.post(url).then((result)=>{ if(result.status===200){ if(result.data.status===0){ - this.setState({ - loadtype:true, - Modalstype: true, - Modalstopval: ` 课程需经过平台审核方可公开使用,公开的课程将对平台所`, - modalsMidval:"有人公开可见。若仅本人教学使用则无需申请公开, 直接发", - Modalsbottomval:"送到课堂即可.", - cardsModalsavetype: true, - }) + this.props.showNotification(result.data.message) this.props.getlistdatas(); + this.cardsModalcancel() }else if(result.data.status===1){ // window.location.reload(); } @@ -132,9 +141,7 @@ class DetailTop extends Component{ }).catch((error)=>{ console.log(error); }) - - - } + } postcancelissuePath=()=>{ let pathId=this.props.match.params.pathId; let url ="/paths/"+pathId+"/cancel_publish.json"; @@ -180,12 +187,15 @@ class DetailTop extends Component{ modalsMidval:'', modalstyles:'', cardsModalsavetype:false, - applyissuePath:false, + applyissuePaths:false, openpathss:false, cancel_publics:false, cancel_has_publics:false, Modalstopval:``, + cancelText:undefined, + okText:undefined }) + } cardsModalsave=()=>{ @@ -369,13 +379,13 @@ class DetailTop extends Component{ openpaths=()=>{ this.setState({ - loadtype:true, Modalstype: true, openpathss:true, - Modalstopval: "公开申请已提交,请等待管理员的审核", - modalsMidval:"• 我们将在1-2个工作日内完成审核", - Loadtype:true, - modalstyles:"848282" + Modalstopval: "公开课程需经过平台标准化审核,审核周期为1-2天,公开", + modalsMidval:"的课程将对平台所有人可见。若仅本人教学使用则无需", + Modalsbottomval:"申请公开,直接发送到课堂即可", + cancelText:"取消申请", + okText:"确定申请" }) } @@ -433,7 +443,7 @@ class DetailTop extends Component{ render(){ let{detailInfoList}=this.props; - let{Modalstype,Modalstopval,cardsModalcancel,putappointmenttype,Modalsbottomval,cardsModalsavetype,loadtype,getappointmenttype,openpathss,cancel_publics,cancel_has_publics}=this.state; + let{Modalstype,Modalstopval,cardsModalcancel,putappointmenttype,Modalsbottomval,cardsModalsavetype,loadtype,getappointmenttype,openpathss,cancel_publics,cancel_has_publics,applyissuePaths}=this.state; const radioStyle = { display: 'block', height: '30px', @@ -470,8 +480,10 @@ class DetailTop extends Component{ modalsTopval={Modalstopval} modalsBottomval={Modalsbottomval} modalCancel={cardsModalcancel} - modalSave={loadtype===true&&openpathss===false?()=>this.cardsModalcancel():cardsModalsavetype===true?()=>this.postcancelissuePath():openpathss===true?()=>this.postopenpaths():cancel_publics===true?()=>this.postcancel_public():cancel_has_publics===true?()=>this.postcancel_has_public():putappointmenttype===true?()=>this.getappointment():()=>this.cardsModalsave()} + modalSave={applyissuePaths===true?()=>this.showapplyissuePath():loadtype===true&&openpathss===false?()=>this.cardsModalcancel():cardsModalsavetype===true?()=>this.postcancelissuePath():openpathss===true?()=>this.postopenpaths():cancel_publics===true?()=>this.postcancel_public():cancel_has_publics===true?()=>this.postcancel_has_public():putappointmenttype===true?()=>this.getappointment():()=>this.cardsModalsave()} loadtype={loadtype} + cancelText={this.state.cancelText} + okText={this.state.okText} modalsMidval={this.state.modalsMidval} modalstyles={this.state.modalstyles} > @@ -605,8 +617,8 @@ class DetailTop extends Component{ { detailInfoList.publish_status===0&&detailInfoList.allow_add_member===true? 发布:"" + style={{'width':'95px'}} + onClick={this.applyissuePath}>申请发布:"" } diff --git a/public/react/src/modules/tpm/TPMBanner.js b/public/react/src/modules/tpm/TPMBanner.js index 9ba752827..7527357c0 100644 --- a/public/react/src/modules/tpm/TPMBanner.js +++ b/public/react/src/modules/tpm/TPMBanner.js @@ -60,7 +60,8 @@ class TPMBanner extends Component { openshowpublictype:false, Radiovalue:1, TextAreaintshow:false, - + cancelText:undefined, + okText:undefined, } } @@ -434,6 +435,9 @@ class TPMBanner extends Component { modalsMidval:undefined, ModalsBottomval:"", modalstyles:"", + cancelText:undefined, + okText:undefined, + Loadtype:false, }) } ModalSave = () => { @@ -441,7 +445,10 @@ class TPMBanner extends Component { let url = "/shixuns/" + id + "/cancel_publish.json"; axios.get(url).then((response) => { this.props.showSnackbar(response.data.message); - window.location.reload() + // window.location.reload() + this.ModalCancel() + this.props.getcomponentdidmount() + }).catch((error) => { console.log(error) }); @@ -461,16 +468,21 @@ class TPMBanner extends Component { ModalSaveopenpublic= () => { this.setState({ Modalstype: true, - Modalstopval: "公开申请已提交,请等待管理员的审核", - modalsMidval:"• 我们将在1-2个工作日内完成审核", - ModalCancel: this.eopenpublicupdatadata, + Modalstopval:"公开实训需经过平台标准化审核,审核周期为1-2天,", + modalsMidval:"公开的实训将对平台所有人可见。若仅本人教学使用", + ModalsBottomval:"则无需申请公开, 直接发送到课堂即可。", + cancelText:"取消申请", + okText:"确定申请", + ModalCancel: this.ModalCancel, ModalSave: this.eopenpublicupdatadata, - Loadtype:true, - modalstyles:"848282" + // Loadtype:true, + // modalstyles:"848282" }) } eopenpublicupdatadata=()=>{ - window.location.reload() + // window.location.reload() + this.ModalCancel() + this.props.getcomponentdidmount() } openpublic=()=>{ let id = this.props.match.params.shixunId; @@ -490,7 +502,9 @@ class TPMBanner extends Component { let url = `/shixuns/${id}/cancel_apply_public.json`; axios.get(url).then((response) => { if(response.data.status===0){ - window.location.reload() + // window.location.reload() + this.ModalCancel() + this.props.getcomponentdidmount() } }).catch((error) => { console.log(error) @@ -522,7 +536,10 @@ class TPMBanner extends Component { evaluation_set_position = response.data.evaluation_set_position } if(response.data.status===0){ - window.location.reload() + // window.location.reload() + this.applyreleaseopen() + // this.ModalCancel() + this.props.getcomponentdidmount() }else{ this.setState({ Issuevisible: true, @@ -536,13 +553,23 @@ class TPMBanner extends Component { console.log(error) }); }; + applyreleaseopen = () => { + this.setState({ + Modalstype: true, + Loadtype:true, + Modalstopval: "实训发布后即可发送课堂使用", + ModalSave: this.ModalCancel, + }) + } hiddenIssuevisible = (val) => { this.setState({ Issuevisible: false }) if (val === 0 || val === 1) { - window.location.reload() + // window.location.reload() + this.ModalCancel() + this.props.getcomponentdidmount() } } @@ -803,7 +830,9 @@ class TPMBanner extends Component { hidestartshixunsreplacevalue, Forkvisibletype, AccountProfiletype, - isIE + isIE, + cancelText, + okText, } = this.state; let {shixunsDetails, shixunId, star_info, star_infos} = this.props; let challengeBtnTipText = ''; @@ -900,6 +929,8 @@ class TPMBanner extends Component { modalsMidval={this.state.modalsMidval} loadtype={this.state.Loadtype} modalstyles={this.state.modalstyles} + cancelText={this.state.cancelText} + okText={this.state.okText} /> : ""}
diff --git a/public/react/src/modules/tpm/TPMIndex.js b/public/react/src/modules/tpm/TPMIndex.js index 7c7a706c5..2a650e3d0 100644 --- a/public/react/src/modules/tpm/TPMIndex.js +++ b/public/react/src/modules/tpm/TPMIndex.js @@ -412,6 +412,7 @@ class TPMIndex extends Component { {...this.props} {...this.state} is_jupyter={this.state. is_jupyter} + getcomponentdidmount={()=>this.getcomponentdidmount()} > }