From 767c0455089f446910a965316b354b12b5f012e0 Mon Sep 17 00:00:00 2001 From: anke1460 Date: Thu, 5 Mar 2020 22:10:18 +0800 Subject: [PATCH 1/8] =?UTF-8?q?=E8=A7=86=E9=A2=91=E6=92=AD=E6=94=BE?= =?UTF-8?q?=E8=AE=B0=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../watch_video_histories_controller.rb | 8 +++ app/models/course_video.rb | 2 + app/models/user.rb | 4 ++ app/models/watch_course_video.rb | 9 +++ app/models/watch_video_history.rb | 5 ++ app/services/create_watch_video_service.rb | 71 +++++++++++++++++++ config/routes.rb | 2 + ...200305072442_create_watch_course_videos.rb | 15 ++++ ...0305074638_create_watch_video_histories.rb | 18 +++++ 9 files changed, 134 insertions(+) create mode 100644 app/controllers/watch_video_histories_controller.rb create mode 100644 app/models/watch_course_video.rb create mode 100644 app/models/watch_video_history.rb create mode 100644 app/services/create_watch_video_service.rb create mode 100644 db/migrate/20200305072442_create_watch_course_videos.rb create mode 100644 db/migrate/20200305074638_create_watch_video_histories.rb diff --git a/app/controllers/watch_video_histories_controller.rb b/app/controllers/watch_video_histories_controller.rb new file mode 100644 index 000000000..996c76d24 --- /dev/null +++ b/app/controllers/watch_video_histories_controller.rb @@ -0,0 +1,8 @@ +class WatchVideoHistoriesController < ApplicationController + before_action :require_login + + def create + watch_log = CreateWatchVideoService.new(current_user, request, params).call + render_ok(log_id: watch_log&.id) + end +end diff --git a/app/models/course_video.rb b/app/models/course_video.rb index 2cfa151ce..e192cf7f8 100644 --- a/app/models/course_video.rb +++ b/app/models/course_video.rb @@ -5,4 +5,6 @@ class CourseVideo < ApplicationRecord validates :title, length: { maximum: 60, too_long: "不能超过60个字符" }, allow_blank: true validates :link, format: { with: CustomRegexp::URL, message: "必须为网址超链接" }, allow_blank: true + + has_many :watch_course_videos end diff --git a/app/models/user.rb b/app/models/user.rb index b0bd191d2..fb4cc50da 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -162,6 +162,10 @@ class User < ApplicationRecord has_many :teacher_group_records, dependent: :destroy + # 视频观看记录 + has_many :watch_video_histories, dependent: :destroy + has_many :watch_course_video, dependent: :destroy + # Groups and active users scope :active, lambda { where(status: STATUS_ACTIVE) } diff --git a/app/models/watch_course_video.rb b/app/models/watch_course_video.rb new file mode 100644 index 000000000..cf2d67028 --- /dev/null +++ b/app/models/watch_course_video.rb @@ -0,0 +1,9 @@ +class WatchCourseVideo < ApplicationRecord + belongs_to :course_video + belongs_to :user + + has_many :watch_video_histories + + + validates :course_video_id, uniqueness: {scope: :user_id} +end diff --git a/app/models/watch_video_history.rb b/app/models/watch_video_history.rb new file mode 100644 index 000000000..0f9ab4a8a --- /dev/null +++ b/app/models/watch_video_history.rb @@ -0,0 +1,5 @@ +class WatchVideoHistory < ApplicationRecord + belongs_to :user + belongs_to :video + belongs_to :watch_course_video, optional: true +end diff --git a/app/services/create_watch_video_service.rb b/app/services/create_watch_video_service.rb new file mode 100644 index 000000000..b16a65535 --- /dev/null +++ b/app/services/create_watch_video_service.rb @@ -0,0 +1,71 @@ +class CreateWatchVideoService < ApplicationService + attr_reader :user, :params, :request + + def initialize(user, request, params) + @user = user + @request = request + @params = params + end + + def call + ActiveRecord::Base.transaction do + current_time = Time.now + if params[:log_id].present? + # 更新观看时长 + watch_video_history = user.watch_video_histories.find(params[:log_id]) + + if watch_video_history.present? && watch_video_history.watch_duration < params[:watch_duration].to_f + # 如果观看时长少于原有的,说明拖放到前面重新观看了,不必再去记录 + watch_video_history.end_at = current_time + watch_video_history.watch_duration = params[:watch_duration] + watch_video_history.is_finished = (watch_video_history.duration <= params[:watch_duration].to_f) + watch_video_history.save! + + watch_course_video = watch_video_history.watch_course_video + + if watch_course_video.present? && !watch_course_video.is_finished && watch_course_video.watch_duration < params[:watch_duration].to_f + # 更新课程视频的时长及是否看完 + watch_course_video.watch_duration = params[:watch_duration] + watch_course_video.is_finished = (watch_course_video.duration <= params[:watch_duration].to_f) + watch_course_video.end_at = current_time + watch_course_video.save! + end + end + else + # 开始播放时记录一次 + if params[:course_id].present? + # 课堂视频 + course_video = CourseVideo.find_by(course_id: params[:course_id], video_id: params[: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] + end + + watch_video_history = build_video_log(current_time, course_video.video_id, watch_course_video.id) + watch_video_history.save! + + watch_course_video.save! unless watch_course_video.persisted? + else + # 非课堂视频 + video = Video.find_by(params[:video_id]) + watch_video_history = build_video_log(current_time, video.id) + watch_video_history.save! + end + end + watch_video_history + end + end + + + def build_video_log(current_time, video_id, watch_course_video_id) + WatchVideoHistory.new( + user_id: user.id, + watch_course_video_id: watch_course_video_id, + start_at: current_time, + duration: params[:duration], + video_id: video_id, + device: params[:device], + ip: request.remote_ip + ) + end +end \ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index db9b74bd2..bcab93203 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -29,6 +29,8 @@ Rails.application.routes.draw do put 'commons/unhidden', to: 'commons#unhidden' delete 'commons/delete', to: 'commons#delete' + resources :watch_video_histories, only: [:create] + resources :jupyters do collection do get :save_with_tpi diff --git a/db/migrate/20200305072442_create_watch_course_videos.rb b/db/migrate/20200305072442_create_watch_course_videos.rb new file mode 100644 index 000000000..5695344fc --- /dev/null +++ b/db/migrate/20200305072442_create_watch_course_videos.rb @@ -0,0 +1,15 @@ +class CreateWatchCourseVideos < ActiveRecord::Migration[5.2] + def change + create_table :watch_course_videos do |t| + t.references :course_video, index: true + t.references :user, index: true + t.boolean :is_finished, default: false + t.float :duration, default: 0 + t.float :watch_duration, default: 0 + t.datetime :start_at + t.datetime :end_at + + t.timestamps + end + end +end diff --git a/db/migrate/20200305074638_create_watch_video_histories.rb b/db/migrate/20200305074638_create_watch_video_histories.rb new file mode 100644 index 000000000..ad9645a6a --- /dev/null +++ b/db/migrate/20200305074638_create_watch_video_histories.rb @@ -0,0 +1,18 @@ +class CreateWatchVideoHistories < ActiveRecord::Migration[5.2] + def change + create_table :watch_video_histories do |t| + t.references :watch_course_video, index: true + t.references :user, index: true + t.references :video, index: true + t.boolean :is_finished, default: false + t.float :duration, default: 0 + t.float :watch_duration, default: 0 + t.datetime :start_at + t.datetime :end_at + t.string :device + t.string :ip + + t.timestamps + end + end +end From 9c337ef66bfa50051ac13ad9f06aad6800205876 Mon Sep 17 00:00:00 2001 From: anke1460 Date: Thu, 12 Mar 2020 10:55:59 +0800 Subject: [PATCH 2/8] =?UTF-8?q?=E8=A7=86=E9=A2=91=E8=AE=B0=E5=BD=95?= =?UTF-8?q?=E6=97=B6=E9=95=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../watch_video_histories_controller.rb | 2 ++ app/models/watch_video_history.rb | 2 ++ app/services/create_watch_video_service.rb | 17 +++++++++++------ ...d_total_duration_to_watch_video_histories.rb | 5 +++++ 4 files changed, 20 insertions(+), 6 deletions(-) create mode 100644 db/migrate/20200312014100_add_total_duration_to_watch_video_histories.rb diff --git a/app/controllers/watch_video_histories_controller.rb b/app/controllers/watch_video_histories_controller.rb index 996c76d24..15ee62113 100644 --- a/app/controllers/watch_video_histories_controller.rb +++ b/app/controllers/watch_video_histories_controller.rb @@ -4,5 +4,7 @@ class WatchVideoHistoriesController < ApplicationController def create watch_log = CreateWatchVideoService.new(current_user, request, params).call render_ok(log_id: watch_log&.id) + rescue CreateWatchVideoService::Error => ex + render_error(ex.message) end end diff --git a/app/models/watch_video_history.rb b/app/models/watch_video_history.rb index 0f9ab4a8a..36f7be0f3 100644 --- a/app/models/watch_video_history.rb +++ b/app/models/watch_video_history.rb @@ -2,4 +2,6 @@ class WatchVideoHistory < ApplicationRecord belongs_to :user belongs_to :video belongs_to :watch_course_video, optional: true + + validates :duration, numericality: { greater_than_or_equal_to: 0 } end diff --git a/app/services/create_watch_video_service.rb b/app/services/create_watch_video_service.rb index b16a65535..c7b3bb3bb 100644 --- a/app/services/create_watch_video_service.rb +++ b/app/services/create_watch_video_service.rb @@ -11,20 +11,25 @@ class CreateWatchVideoService < ApplicationService ActiveRecord::Base.transaction do current_time = Time.now if params[:log_id].present? + if params[:total_duration].to_f < params[:watch_duration].to_f || params[:watch_duration].to_f < 0 + raise Error, '观看时长错误' + end # 更新观看时长 watch_video_history = user.watch_video_histories.find(params[:log_id]) - if watch_video_history.present? && watch_video_history.watch_duration < params[:watch_duration].to_f - # 如果观看时长少于原有的,说明拖放到前面重新观看了,不必再去记录 + if watch_video_history.present? && watch_video_history.watch_duration <= params[:watch_duration].to_f && params[:total_duration].to_f > watch_video_history.total_duration + # 如果观看总时长没变,说明视频没有播放,无需再去记录 + watch_video_history.end_at = current_time - watch_video_history.watch_duration = params[:watch_duration] + watch_video_history.total_duration = params[:total_duration] + watch_video_history.watch_duration = params[:watch_duration].to_f > watch_video_history.duration ? watch_video_history.duration : params[:watch_duration] watch_video_history.is_finished = (watch_video_history.duration <= params[:watch_duration].to_f) watch_video_history.save! watch_course_video = watch_video_history.watch_course_video if watch_course_video.present? && !watch_course_video.is_finished && watch_course_video.watch_duration < params[:watch_duration].to_f - # 更新课程视频的时长及是否看完 + # 更新课程视频的时长及是否看完状态 watch_course_video.watch_duration = params[:watch_duration] watch_course_video.is_finished = (watch_course_video.duration <= params[:watch_duration].to_f) watch_course_video.end_at = current_time @@ -35,7 +40,7 @@ class CreateWatchVideoService < ApplicationService # 开始播放时记录一次 if params[:course_id].present? # 课堂视频 - course_video = CourseVideo.find_by(course_id: params[:course_id], video_id: params[:video_id]) + course_video = CourseVideo.find_by(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] @@ -57,7 +62,7 @@ class CreateWatchVideoService < ApplicationService end - def build_video_log(current_time, video_id, watch_course_video_id) + def build_video_log(current_time, video_id, watch_course_video_id=nil) WatchVideoHistory.new( user_id: user.id, watch_course_video_id: watch_course_video_id, diff --git a/db/migrate/20200312014100_add_total_duration_to_watch_video_histories.rb b/db/migrate/20200312014100_add_total_duration_to_watch_video_histories.rb new file mode 100644 index 000000000..e595384e0 --- /dev/null +++ b/db/migrate/20200312014100_add_total_duration_to_watch_video_histories.rb @@ -0,0 +1,5 @@ +class AddTotalDurationToWatchVideoHistories < ActiveRecord::Migration[5.2] + def change + add_column :watch_video_histories, :total_duration, :float, default: 0 + end +end From 450ba26dc72d822f47572d1d9744e2bc4a1b4496 Mon Sep 17 00:00:00 2001 From: anke1460 Date: Thu, 12 Mar 2020 11:05:35 +0800 Subject: [PATCH 3/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 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/services/create_watch_video_service.rb b/app/services/create_watch_video_service.rb index c7b3bb3bb..8e4297aee 100644 --- a/app/services/create_watch_video_service.rb +++ b/app/services/create_watch_video_service.rb @@ -40,7 +40,7 @@ class CreateWatchVideoService < ApplicationService # 开始播放时记录一次 if params[:course_id].present? # 课堂视频 - course_video = CourseVideo.find_by(params[:course_video_id]) + course_video = CourseVideo.find_by(course_id: params[:course_id], video_id: params[: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 eddb4440721173e763db02bdd227ef1ed34d0acb Mon Sep 17 00:00:00 2001 From: anke1460 Date: Thu, 12 Mar 2020 11:27:52 +0800 Subject: [PATCH 4/8] =?UTF-8?q?=E8=AF=BE=E7=A8=8B=E8=A7=86=E9=A2=91?= =?UTF-8?q?=E6=97=B6=E9=95=BFid?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/services/create_watch_video_service.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/services/create_watch_video_service.rb b/app/services/create_watch_video_service.rb index 8e4297aee..c7b3bb3bb 100644 --- a/app/services/create_watch_video_service.rb +++ b/app/services/create_watch_video_service.rb @@ -40,7 +40,7 @@ class CreateWatchVideoService < ApplicationService # 开始播放时记录一次 if params[:course_id].present? # 课堂视频 - course_video = CourseVideo.find_by(course_id: params[:course_id], video_id: params[:video_id]) + course_video = CourseVideo.find_by(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 03be8d94f81d948ab428711f1a7bf3fac7c447a2 Mon Sep 17 00:00:00 2001 From: harry Date: Thu, 12 Mar 2020 11:54:38 +0800 Subject: [PATCH 5/8] =?UTF-8?q?fix=20=E5=AE=9E=E8=AE=AD=E6=A0=B7=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/modules/paths/ShixunPathSearch.js | 4 +- public/react/src/modules/paths/btn-new.png | Bin 0 -> 2745 bytes public/react/src/modules/tpm/TPMIndex.css | 452 +++++++++++------- .../src/modules/tpm/shixuns/ShixunsIndex.js | 2 +- .../tpm/shixuns/shixun-keyword-list.scss | 4 + 5 files changed, 276 insertions(+), 186 deletions(-) create mode 100644 public/react/src/modules/paths/btn-new.png diff --git a/public/react/src/modules/paths/ShixunPathSearch.js b/public/react/src/modules/paths/ShixunPathSearch.js index be1d3a33c..844215974 100644 --- a/public/react/src/modules/paths/ShixunPathSearch.js +++ b/public/react/src/modules/paths/ShixunPathSearch.js @@ -8,7 +8,7 @@ import Pagination from '@icedesign/base/lib/pagination'; import '@icedesign/base/lib/pagination/style.js'; import './ShixunPaths.css'; import KeywordList from '../tpm/shixuns/shixun-keyword-list'; -import btnUrl from '../tpm/shixuns/btn-new.png'; +import btnUrl from './btn-new.png'; class ShixunPathSearch extends Component { constructor(props) { @@ -252,7 +252,7 @@ class ShixunPathSearch extends Component { - + { diff --git a/public/react/src/modules/paths/btn-new.png b/public/react/src/modules/paths/btn-new.png new file mode 100644 index 0000000000000000000000000000000000000000..b900fa1f48d0f6dcb63e0f4a1c1d5c5394aa178c GIT binary patch literal 2745 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 literal 0 HcmV?d00001 diff --git a/public/react/src/modules/tpm/TPMIndex.css b/public/react/src/modules/tpm/TPMIndex.css index 2ec090e7d..325b0fc54 100644 --- a/public/react/src/modules/tpm/TPMIndex.css +++ b/public/react/src/modules/tpm/TPMIndex.css @@ -4,48 +4,58 @@ } */ body { overflow: auto !important; - font-family: "Microsoft YaHei"; + font-family: "Microsoft YaHei"; } #root { - /* ie兼容性 */ - position: relative; - min-height: 100%; + /* ie兼容性 */ + position: relative; + min-height: 100%; } + body>.-task-title { - opacity: 1 !important; + opacity: 1 !important; } + /*�����Ŵ󾵵�����·Ŵ󾵵�λ��*/ #root .search-all { - width: 219px; + width: 219px; } /*Header START*/ .newHeader .logoimg { - margin-top: 16px; - float: left; - width: 97px; + margin-top: 16px; + float: left; + width: 97px; } + .head-right i { - font-size: 20px; - float: none !important; + font-size: 20px; + float: none !important; } -.headIcon, #header_keyword_search { - padding-top: 13px !important; + +.headIcon, +#header_keyword_search { + padding-top: 13px !important; } + .search-icon { - height: 30px !important; + height: 30px !important; } + .search-icon i { - font-size: 20px; + font-size: 20px; } + #header_keyword_search i { - color: #4cacff; + color: #4cacff; } -.ant-select-selection--multiple{ - padding-bottom: 0px!important; - padding-top:3px; + +.ant-select-selection--multiple { + padding-bottom: 0px !important; + padding-top: 3px; } + /* 先注释掉下面2个样式,这样写影响范围太广了,并不是所有的select都需要40px高 */ /* .ant-select-selection--single{ height:40px!important; @@ -53,247 +63,323 @@ body>.-task-title { .ant-select-selection__rendered{ line-height: 40px!important; } */ -.ant-select-selection--multiple .ant-select-selection__rendered>ul>li, .ant-select-selection--multiple>ul>li{ - height: 25px!important; - line-height: 23px!important; - margin-bottom:3px; - margin-top:0px; +.ant-select-selection--multiple .ant-select-selection__rendered>ul>li, +.ant-select-selection--multiple>ul>li { + height: 25px !important; + line-height: 23px !important; + margin-bottom: 3px; + margin-top: 0px; } + /*Main START*/ -.newContainer{ - background: #fafafa!important; +.newContainer { + background: #fafafa !important; } -.ant-modal-title{ - font-size: 16px; - font-weight: bold !important; - color: #333; +.ant-modal-title { + font-size: 16px; + font-weight: bold !important; + color: #333; } -.ant-modal-title{ - text-align: center; +.ant-modal-title { + text-align: center; } + /*.ant-modal{*/ - /*top:10rem !important;*/ +/*top:10rem !important;*/ /*}*/ @-moz-document url-prefix() { - .ant-radio-inner { - width: 17px !important; - height: 17px !important; - } + .ant-radio-inner { + width: 17px !important; + height: 17px !important; + } } + /* IE只能用padding,不能用上下居中 */ -.shixunDetail_top{ - display: block!important; - padding-top: 48px; -} -.totalScore{ - display: block!important; - padding-top: 40px; +.shixunDetail_top { + display: block !important; + padding-top: 48px; } -.head-nav ul#header-nav li{ - /*font-weight: 600;*/ + +.totalScore { + display: block !important; + padding-top: 40px; } + /*.newFooter{*/ - /*position: fixed !important;*/ +/*position: fixed !important;*/ /*}*/ -.edu-menu-panel .edu-menu-listnew:hover .careersiconfont{ - color: #000 !important; +.edu-menu-panel .edu-menu-listnew:hover .careersiconfont { + color: #000 !important; } .newHeader { - background: #24292D !important; - height: 60px !important; + background: #24292D !important; + height: 60px !important; } /*-------------------个人主页:右侧提示区域--------------------------*/ -.-task-sidebar{position:fixed;width:40px;height:180px;right:0;bottom:80px !important;z-index: 10;} -.-task-sidebar>div{height: 40px;line-height: 40px;box-sizing: border-box;width:40px;background:#4CACFF;color:#fff;font-size:20px;text-align:center;margin-bottom:5px;border-radius: 4px;} -.-task-sidebar>div i{ color:#fff;} -.-task-sidebar>div i:hover{color: #fff!important;} -.gotop{background-color: rgba(208,207,207,0.5)!important;padding: 0px!important;} -.-task-desc{background:#494949;width:90px;line-height: 36px;text-align: center; - position: absolute;color: #fff;font-size: 13px;z-index: 999999;opacity: 0;} -.-task-desc div{position: absolute;top:10px;right: -7px;height: 13px;} -.-task-desc div img{float: left} -.-task-sidebar .scan_ewm{ - position: absolute !important; - right: 45px !important; - bottom: 0px !important; - background-color: #494949 !important; - -webkit-box-sizing: border-box !important; - box-sizing: border-box !important; - font-size: 14px !important; - line-height: 16px !important; - display: none; - height: 213px !important; -} -.trangle_right{position: absolute;right: -5px;bottom: 15px;width: 0;height: 0px;border-top: 6px solid transparent;border-left: 5px solid #494949;border-bottom: 6px solid transparent} - -.HeaderSearch{ - margin-top: 18px; - margin-right: 20px; -} -.HeaderSearch .ant-input-search .ant-input{ - /*height:30px;*/ - background: #373e3f !important; - border: 1px solid #373e3f !important; - -} -.ant-input-search .ant-input-affix-wrapper{ - border:transparent; +.-task-sidebar { + position: fixed; + width: 40px; + height: 180px; + right: 0; + bottom: 20px !important; + z-index: 10; +} + +.-task-sidebar>div { + height: 40px; + line-height: 40px; + box-sizing: border-box; + width: 40px; + background: #4CACFF; + color: #fff; + font-size: 20px; + text-align: center; + margin-bottom: 5px; + border-radius: 4px; +} + +.-task-sidebar>div i { + color: #fff; +} + +.-task-sidebar>div i:hover { + color: #fff !important; +} + +.gotop { + background-color: rgba(208, 207, 207, 0.5) !important; + padding: 0px !important; +} + +.-task-desc { + background: #494949; + width: 90px; + line-height: 36px; + text-align: center; + position: absolute; + color: #fff; + font-size: 13px; + z-index: 999999; + opacity: 0; +} + +.-task-desc div { + position: absolute; + top: 10px; + right: -7px; + height: 13px; } + +.-task-desc div img { + float: left +} + +.-task-sidebar .scan_ewm { + position: absolute !important; + right: 45px !important; + bottom: 0px !important; + background-color: #494949 !important; + -webkit-box-sizing: border-box !important; + box-sizing: border-box !important; + font-size: 14px !important; + line-height: 16px !important; + display: none; + height: 213px !important; +} + +.trangle_right { + position: absolute; + right: -5px; + bottom: 15px; + width: 0; + height: 0px; + border-top: 6px solid transparent; + border-left: 5px solid #494949; + border-bottom: 6px solid transparent +} + +.HeaderSearch { + margin-top: 18px; + margin-right: 20px; +} + +.HeaderSearch .ant-input-search .ant-input { + /*height:30px;*/ + background: #373e3f !important; + border: 1px solid #373e3f !important; + +} + +.ant-input-search .ant-input-affix-wrapper { + border: transparent; +} + .ant-input-affix-wrapper:hover .ant-input:not(.ant-input-disabled) { - /* 比较奇怪的需求,先注释掉了,如果需要启用,麻烦增加class限制,别影响别的地方的使用 */ - /* border-color: transparent; */ + /* 比较奇怪的需求,先注释掉了,如果需要启用,麻烦增加class限制,别影响别的地方的使用 */ + /* border-color: transparent; */ } .ant-input:focus { - /*border-color: transparent;*/ - border-right-width: 1px !important; - outline: 0; - -webkit-box-shadow: 0 0 0 2px transparent; - box-shadow: 0 0 0 2px transparent; - border: 1px solid #d9d9d9; + /*border-color: transparent;*/ + border-right-width: 1px !important; + outline: 0; + -webkit-box-shadow: 0 0 0 2px transparent; + box-shadow: 0 0 0 2px transparent; + border: 1px solid #d9d9d9; } -.HeaderSearch .ant-input-search .ant-input::-webkit-input-placeholder{ - color: #999; - font-size: 14px; +.HeaderSearch .ant-input-search .ant-input::-webkit-input-placeholder { + color: #999; + font-size: 14px; } .HeaderSearch .ant-input-search .ant-input:-moz-placeholder { - color: #999; - font-size: 14px; + color: #999; + font-size: 14px; } -.HeaderSearch .ant-input-search .ant-input::-moz-placeholder{ - color: #999; - font-size: 14px; +.HeaderSearch .ant-input-search .ant-input::-moz-placeholder { + color: #999; + font-size: 14px; } -.HeaderSearch .ant-input-search .ant-input:-ms-input-placeholder{ - color: #999; - font-size: 14px; +.HeaderSearch .ant-input-search .ant-input:-ms-input-placeholder { + color: #999; + font-size: 14px; } .HeaderSearch .ant-input-search .ant-input-suffix .anticon-search { - color: #999; + color: #999; } -.HeaderSearch .ant-input-search .ant-input{ - color: #fff; +.HeaderSearch .ant-input-search .ant-input { + color: #fff; } -.HeaderSearch .ant-input-search .ant-input-suffix{ - background: transparent !important; +.HeaderSearch .ant-input-search .ant-input-suffix { + background: transparent !important; } -.roundedRectangles{ - position: absolute; - top: 10px; - right: -22px; +.roundedRectangles { + position: absolute; + top: 10px; + right: -22px; } -.HeaderSearch{ - width: 325px; - /*right: 20px;*/ +.HeaderSearch { + width: 325px; + /*right: 20px;*/ } -.HeaderSearch .ant-input-search{ - right: 20px; + +.HeaderSearch .ant-input-search { + right: 20px; } -.mainheighs{ - height: 100%; - display: block; + +.mainheighs { + height: 100%; + display: block; } -.ml18a{ - margin-left:18%; +.ml18a { + margin-left: 18%; } -.logoimg{ - float: left; - min-width: 40px; - height:40px; +.logoimg { + float: left; + min-width: 40px; + height: 40px; } -.headwith100b{ - width: 100%; +.headwith100b { + width: 100%; } -.wechatcenter{ - text-align: center; + +.wechatcenter { + text-align: center; } -.myrigthsiderbar{ - right: 9% !important; +.myrigthsiderbar { + right: 9% !important; } -.feedbackdivcolor{ - background: #33BD8C !important; - height: 49px !important; - line-height: 24px !important; +.feedbackdivcolor { + background: #33BD8C !important; + height: 49px !important; + line-height: 24px !important; } -.xiaoshou{ - cursor:pointer + +.xiaoshou { + cursor: pointer } -.questiontypes{ - width:37px; - height:17px; - font-size:12px; - color:rgba(51,51,51,1); - line-height:17px; - cursor:pointer; + +.questiontypes { + width: 37px; + height: 17px; + font-size: 12px; + color: rgba(51, 51, 51, 1); + line-height: 17px; + cursor: pointer; } -.questiontype{ - width: 100%; - font-size: 12px; - color: #333333; - line-height: 17px; - text-align: center; - padding: 11px; - cursor:pointer; + +.questiontype { + width: 100%; + font-size: 12px; + color: #333333; + line-height: 17px; + text-align: center; + padding: 11px; + cursor: pointer; } -.questiontypeheng{ - width:100%; - height:1px; - background: #EEEEEE; + +.questiontypeheng { + width: 100%; + height: 1px; + background: #EEEEEE; } -.mystask-sidebar{ - right: 181px !important; + +.mystask-sidebar { + right: 181px !important; } -.mystask-sidebars{ - right: 20px !important; + +.mystask-sidebars { + right: 20px !important; } -.shitikussmys{ - width:29px !important; - height:20px!important; - background:#FF6601 !important; - border-radius:10px !important; - position: absolute !important; - font-size:11px !important; - color:#ffffff !important; - line-height:20px !important; - top: -13px !important; - right: -10px !important; + +.shitikussmys { + width: 29px !important; + height: 20px !important; + background: #FF6601 !important; + border-radius: 10px !important; + position: absolute !important; + font-size: 11px !important; + color: #ffffff !important; + line-height: 20px !important; + top: -13px !important; + right: -10px !important; } -.maxnamewidth30{ - max-width: 30px; - overflow:hidden; - text-overflow:ellipsis; - white-space:nowrap; - cursor: default; -} -.mystask-sidebarss{ - right: 5px !important; +.maxnamewidth30 { + max-width: 30px; + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; + cursor: default; } + +.mystask-sidebarss { + right: 5px !important; +} \ No newline at end of file diff --git a/public/react/src/modules/tpm/shixuns/ShixunsIndex.js b/public/react/src/modules/tpm/shixuns/ShixunsIndex.js index c0fbb2c01..2613fc1c7 100644 --- a/public/react/src/modules/tpm/shixuns/ShixunsIndex.js +++ b/public/react/src/modules/tpm/shixuns/ShixunsIndex.js @@ -392,7 +392,7 @@ class ShixunsIndex extends Component { // console.log(this.state.updata) return ( -
+
{this.state.updata === undefined ? "" : } diff --git a/public/react/src/modules/tpm/shixuns/shixun-keyword-list.scss b/public/react/src/modules/tpm/shixuns/shixun-keyword-list.scss index c8a62bdd8..d74f54e03 100644 --- a/public/react/src/modules/tpm/shixuns/shixun-keyword-list.scss +++ b/public/react/src/modules/tpm/shixuns/shixun-keyword-list.scss @@ -1,3 +1,7 @@ +.shi-xun-index .search-keyword-container { + padding: 20px 0 15px 0; +} + .search-keyword-container { display: flex; flex-flow: row nowrap; From 60e087b0eb528e9cf87219b135a82e27c3257fb6 Mon Sep 17 00:00:00 2001 From: anke1460 Date: Thu, 12 Mar 2020 13:39:33 +0800 Subject: [PATCH 6/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 7/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 92804ee277408fbd5ef0635e60d64adc527a3a1c Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Thu, 12 Mar 2020 14:48:33 +0800 Subject: [PATCH 8/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 # 立即发布