From 5e242aea7afa9ac33a21c43c29467edc57c691cf Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Wed, 4 Mar 2020 16:20:28 +0800 Subject: [PATCH 01/10] =?UTF-8?q?=E7=AD=BE=E5=88=B0=E4=B8=BB=E9=A1=B5?= =?UTF-8?q?=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/application_controller.rb | 2 +- .../weapps/attendances_controller.rb | 10 ++++++---- app/helpers/weapps/attendances_helper.rb | 8 ++++++++ .../weapps/attendances/index.json.jbuilder | 20 ++++++++++++++----- 4 files changed, 30 insertions(+), 10 deletions(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index b7a74cbc1..90a5e494e 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -321,7 +321,7 @@ class ApplicationController < ActionController::Base end if !User.current.logged? && Rails.env.development? - User.current = User.find 3117 + User.current = User.find 1 end diff --git a/app/controllers/weapps/attendances_controller.rb b/app/controllers/weapps/attendances_controller.rb index 567bfae77..6804f0ce4 100644 --- a/app/controllers/weapps/attendances_controller.rb +++ b/app/controllers/weapps/attendances_controller.rb @@ -27,14 +27,16 @@ class Weapps::AttendancesController < ApplicationController tip_exception(403) if @user_course_identity >= Course::STUDENT current_date = Date.current current_end_time = Time.current.strftime("%H:%M:%S") - @current_attendance = @course.course_attendances.where("attendance_date = '#{current_date}' and start_time <= '#{current_end_time}' and end_time > '#{current_end_time}'").take + @current_attendance = @course.course_attendances.where("attendance_date = '#{current_date}' and end_time > '#{current_end_time}'").take - all_attendances = @course.course_attendances + all_attendances = @course.course_attendances.where("attendance_date < '#{current_date}' or (attendance_date = '#{current_date}' and end_time < '#{current_end_time}')") + @all_member_attendances = CourseMemberAttendance.where(course_attendance_id: all_attendances) if params[:group_id].present? - all_attendances = all_attendances.where(course_group_id: [params[:group_id], 0]) + all_attendances = all_attendances.joins(:course_attendance_groups).where(course_attendance_groups: {course_group_id: [params[:group_id], 0]}) + @all_member_attendances = @all_member_attendances.joins(:course_member).where(course_members: {course_group_id: params[:group_id]}) end - @history_attendances = all_attendances.where("attendance_date < '#{current_date}' or (attendance_date = '#{current_date}' and end_time < '#{current_end_time}')").order("id asc") + @history_attendances = all_attendances.order("id asc") @all_history_count = @history_attendances.size end diff --git a/app/helpers/weapps/attendances_helper.rb b/app/helpers/weapps/attendances_helper.rb index 60a9cfe26..30591c149 100644 --- a/app/helpers/weapps/attendances_helper.rb +++ b/app/helpers/weapps/attendances_helper.rb @@ -9,4 +9,12 @@ module Weapps::AttendancesHelper course_member_ids = group.course_members.pluck(:id) attendances.select{|attendance| course_member_ids.include?(attendance.course_member_id) && attendance.attendance_status == "NORMAL"}.size end + + def history_member_count member_attendances, status, attendance_id + member_attendances.select{|member_attendance| member_attendance.attendance_status == status && member_attendance.course_attendance_id == attendance_id}.size + end + + def cal_rate base, sum + sum == 0 ? 0 : (base.to_f / sum) + end end \ No newline at end of file diff --git a/app/views/weapps/attendances/index.json.jbuilder b/app/views/weapps/attendances/index.json.jbuilder index 9541fe231..9ab10de66 100644 --- a/app/views/weapps/attendances/index.json.jbuilder +++ b/app/views/weapps/attendances/index.json.jbuilder @@ -1,11 +1,21 @@ json.current_attendance do - json.(@current_attendance, :id, :normal_count, :all_count) + json.(@current_attendance, :id, :normal_count, :all_count) if @current_attendance end -json.history_attendances @history_attendances do |attendance| +all_normal_rate = [] +all_absence_rate = [] +json.history_attendances @history_attendances.each_with_index.to_a do |attendance, index| + normal_count = history_member_count(@all_member_attendances, "NORMAL", attendance.id) + absence_count = history_member_count(@all_member_attendances, "ABSENCE", attendance.id) + all_count = @all_member_attendances.select{|member_attendance| member_attendance.course_attendance_id == attendance.id}.size + + json.index index + 1 + json.normal_rate cal_rate(normal_count, all_count) + all_normal_rate << cal_rate(normal_count, all_count) + json.absence_rate cal_rate(absence_count, all_count) + all_absence_rate << cal_rate(absence_count, all_count) end json.all_history_count @all_history_count -json.normal_count @normal_count -json.leave_count @leave_count -json.absence_count @absence_count \ No newline at end of file +json.avg_normal_rate all_normal_rate.sum / @all_history_count +json.avg_absence_rate all_absence_rate.sum / @all_history_count From 3c518e46c363e1dcf3641de451dbb3031401766f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E6=A0=91=E6=9E=97?= <904079904@qq.com> Date: Wed, 4 Mar 2020 16:40:28 +0800 Subject: [PATCH 02/10] =?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/App.js | 62 ++++++++++++++++++++++------------------- 1 file changed, 33 insertions(+), 29 deletions(-) diff --git a/public/react/src/App.js b/public/react/src/App.js index 4c4908771..288afcb10 100644 --- a/public/react/src/App.js +++ b/public/react/src/App.js @@ -793,37 +793,37 @@ class App extends Component { render={ (props) => () }/> - () - }/> + {/* ()*/} + {/* }/>*/} - () - }/> + {/* ()*/} + {/* }/>*/} () } /> - () - } /> - - () - } /> - () - } /> - () - }/> + {/* ()*/} + {/* } />*/} + + {/* ()*/} + {/* } />*/} + {/* ()*/} + {/* } />*/} + {/* ()*/} + {/* }/>*/} () }/> - () - }/> + {/* ()*/} + {/* }/>*/} + + + {/*()*/} {/* }*/} {/*/>*/} + Date: Wed, 4 Mar 2020 16:47:26 +0800 Subject: [PATCH 03/10] style --- .../react/src/modules/courses/coursesDetail/CoursesLeftNav.js | 1 - .../courses/graduation/topics/GraduateTopicDetailTable.js | 2 +- .../react/src/modules/courses/members/CourseGroupListTable.js | 4 ++-- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/public/react/src/modules/courses/coursesDetail/CoursesLeftNav.js b/public/react/src/modules/courses/coursesDetail/CoursesLeftNav.js index f523238c3..80c250134 100644 --- a/public/react/src/modules/courses/coursesDetail/CoursesLeftNav.js +++ b/public/react/src/modules/courses/coursesDetail/CoursesLeftNav.js @@ -525,7 +525,6 @@ class Coursesleftnav extends Component{ } saveNavmodapost=(url,value,positiontype,coursesId)=>{ - debugger; axios.post(url, {name:value}).then((result)=>{ if(result!=undefined){ diff --git a/public/react/src/modules/courses/graduation/topics/GraduateTopicDetailTable.js b/public/react/src/modules/courses/graduation/topics/GraduateTopicDetailTable.js index 2e2487601..b0c65009d 100644 --- a/public/react/src/modules/courses/graduation/topics/GraduateTopicDetailTable.js +++ b/public/react/src/modules/courses/graduation/topics/GraduateTopicDetailTable.js @@ -228,7 +228,7 @@ class GraduateTopicDetailTable extends Component{ { return 11 ? name : ''} onClick={() => onGoDetail(record)} style={''} - className="overflowHidden1" style2={{maxWidth: '180px', verticalAlign: 'bottom'}}> + className="overflowHidden1 color-dark" style2={{maxWidth: '180px', verticalAlign: 'bottom'}}> {name} } }, @@ -154,7 +154,7 @@ function CourseGroupListTable(props) { {!isCourseEnd && isAdmin && onDelete(record)} style={'grey'}>删除分班} {isStudent && addToDir(record)} style={''}>加入分班} - onGoDetail(record)} style={''}>查看 + onGoDetail(record)} style={''} className="color-dark">查看 } }) From 6b2e836028a002affc9e53b0817d7310700b8540 Mon Sep 17 00:00:00 2001 From: caicai8 <1149225589@qq.com> Date: Wed, 4 Mar 2020 17:02:39 +0800 Subject: [PATCH 04/10] =?UTF-8?q?=E5=AE=9E=E8=AE=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/react/src/modules/tpm/shixuns/ShixunsIndex.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/react/src/modules/tpm/shixuns/ShixunsIndex.js b/public/react/src/modules/tpm/shixuns/ShixunsIndex.js index 3671bc698..4e11537dc 100644 --- a/public/react/src/modules/tpm/shixuns/ShixunsIndex.js +++ b/public/react/src/modules/tpm/shixuns/ShixunsIndex.js @@ -396,7 +396,7 @@ class ShixunsIndex extends Component { } .myshixin-head{ width: 100%; - height: 300px; + height: 240px; background-image: url(${getImageUrl(this.props.mygetHelmetapi && this.props.mygetHelmetapi.shixun_banner_url === null ?`images/educoder/courses/courses.jpg`:this.props.mygetHelmetapi&&this.props.mygetHelmetapi.shixun_banner_url)}); background-color: #081C4B; background-position: center; From 22a1cbf01443c5b2983e70097624091d58322a5e Mon Sep 17 00:00:00 2001 From: caicai8 <1149225589@qq.com> Date: Wed, 4 Mar 2020 17:31:16 +0800 Subject: [PATCH 05/10] name --- public/react/src/modules/courses/Video/LiveNew.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/react/src/modules/courses/Video/LiveNew.js b/public/react/src/modules/courses/Video/LiveNew.js index ba6bbb048..e95400ed0 100644 --- a/public/react/src/modules/courses/Video/LiveNew.js +++ b/public/react/src/modules/courses/Video/LiveNew.js @@ -9,7 +9,7 @@ import axios from 'axios'; const { TextArea } = Input; const { Option } = Select; -const array=['腾讯课堂','B站','斗鱼','威佰通']; +const array=['腾讯课堂','斗鱼直播','Bilibili','威佰通']; function range(start, end) { const result = []; From 67236435e23363bc6b010ecaa177f732d7348ef4 Mon Sep 17 00:00:00 2001 From: caicai8 <1149225589@qq.com> Date: Wed, 4 Mar 2020 17:58:02 +0800 Subject: [PATCH 06/10] shixun --- .../modules/tpm/shixuns/ShixunSearchBar.js | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/public/react/src/modules/tpm/shixuns/ShixunSearchBar.js b/public/react/src/modules/tpm/shixuns/ShixunSearchBar.js index a8ab9cd3a..f8e242a90 100644 --- a/public/react/src/modules/tpm/shixuns/ShixunSearchBar.js +++ b/public/react/src/modules/tpm/shixuns/ShixunSearchBar.js @@ -208,7 +208,7 @@ render() {
- 方向: + 方向:
  • 全部