diff --git a/app/controllers/users/videos_controller.rb b/app/controllers/users/videos_controller.rb index 32f81f6ed..15365dc69 100644 --- a/app/controllers/users/videos_controller.rb +++ b/app/controllers/users/videos_controller.rb @@ -55,7 +55,7 @@ class Users::VideosController < Users::BaseController def destroy video = Video.find_by(id: params[:id]) - return render_forbidden unless video.user_id == current_user.id || current_user.admin_or_business? + return render_forbidden unless video.user_id == current_user.id || current_user.admin? return render_not_found if video.blank? return render_error('该状态下不能删除视频') unless video.published? diff --git a/app/helpers/courses_helper.rb b/app/helpers/courses_helper.rb index ed76a4b0c..8f024c1c6 100644 --- a/app/helpers/courses_helper.rb +++ b/app/helpers/courses_helper.rb @@ -55,32 +55,32 @@ module CoursesHelper return nil if mod.blank? or course.blank? case mod.module_type when "announcement" - "/courses/#{course.id}/informs" + "/classrooms/#{course.id}/informs" when "online_learning" - "/courses/#{course.id}/online_learning" + "/classrooms/#{course.id}/online_learning" when "shixun_homework" - "/courses/#{course.id}/shixun_homeworks/#{mod.id}" + "/classrooms/#{course.id}/shixun_homeworks/#{mod.id}" when "common_homework" - "/courses/#{course.id}/common_homeworks/#{mod.id}" + "/classrooms/#{course.id}/common_homeworks/#{mod.id}" when "group_homework" - "/courses/#{course.id}/group_homeworks/#{mod.id}" + "/classrooms/#{course.id}/group_homeworks/#{mod.id}" when "graduation" - "/courses/#{course.id}/graduation_topics/#{mod.id}" + "/classrooms/#{course.id}/graduation_topics/#{mod.id}" when "exercise" - "/courses/#{course.id}/exercises/#{mod.id}" + "/classrooms/#{course.id}/exercises/#{mod.id}" when "poll" - "/courses/#{course.id}/polls/#{mod.id}" + "/classrooms/#{course.id}/polls/#{mod.id}" when "attachment" - "/courses/#{course.id}/files/#{mod.id}" + "/classrooms/#{course.id}/files/#{mod.id}" when "board" course_board = course.course_board - "/courses/#{course.id}/boards/#{course_board.id}" + "/classrooms/#{course.id}/boards/#{course_board.id}" when "course_group" - "/courses/#{course.id}/course_groups" + "/classrooms/#{course.id}/course_groups" when "statistics" - "/courses/#{course.id}/statistics" + "/classrooms/#{course.id}/statistics" when "video" - "/courses/#{course.id}/course_videos" + "/classrooms/#{course.id}/course_videos" end end @@ -88,17 +88,17 @@ module CoursesHelper def category_url category, course case category.category_type when "shixun_homework" - "/courses/#{course.id}/shixun_homework/#{category.id}" + "/classrooms/#{course.id}/shixun_homework/#{category.id}" when "graduation" if category.name == "毕设选题" - "/courses/#{course.id}/graduation_topics/#{category.course_module_id}" + "/classrooms/#{course.id}/graduation_topics/#{category.course_module_id}" else - "/courses/#{course.id}/graduation_tasks/#{category.course_module_id}" + "/classrooms/#{course.id}/graduation_tasks/#{category.course_module_id}" end when "attachment" - "/courses/#{course.id}/file/#{category.id}" + "/classrooms/#{course.id}/file/#{category.id}" when "video" - "/courses/#{course.id}/course_video/#{category.id}" + "/classrooms/#{course.id}/course_video/#{category.id}" end end @@ -147,7 +147,7 @@ module CoursesHelper when "online_learning" course.shixuns.count when "video" - course.course_videos.count + course.live_links.count + course.videos_count + course.live_links.count end end @@ -296,11 +296,11 @@ module CoursesHelper none_group_count = course.students.where(course_group_id: 0).size group_info << {category_id: 0, category_name: "未分班", position: course.course_groups.pluck(:position).max.to_i + 1, category_count: none_group_count, category_type: false, - second_category_url: "/courses/#{@course.id}/course_groups/0"} + second_category_url: "/classrooms/#{@course.id}/course_groups/0"} course.course_groups.each do |course_group| group_info << {category_id: course_group.id, category_name: course_group.name, position: course_group.position, category_count: course_group.course_members_count, category_type: false, - second_category_url: "/courses/#{@course.id}/course_groups/#{course_group.id}"} + second_category_url: "/classrooms/#{@course.id}/course_groups/#{course_group.id}"} end end group_info diff --git a/app/models/course.rb b/app/models/course.rb index 2c76f9579..abe17b3cd 100644 --- a/app/models/course.rb +++ b/app/models/course.rb @@ -160,6 +160,10 @@ class Course < ApplicationRecord students.find_by(user_id: user_id)&.course_group_name end + def videos_count + course_videos.where(video_id: videos.where("transcoded = 1 or videos.user_id = #{User.current.id}").pluck(:id)) + .or(course_videos.where(course_videos: {is_link: true})).size + end def teacher_group(user_id) data = diff --git a/public/react/src/modules/courses/Video/Video.js b/public/react/src/modules/courses/Video/Video.js index e9a90c918..89c0a0c6f 100644 --- a/public/react/src/modules/courses/Video/Video.js +++ b/public/react/src/modules/courses/Video/Video.js @@ -94,7 +94,7 @@ class Video extends Component { let videoId = { videoId: item.id, title: item.title, - file_url: item.file_url, + file_url: (item.play_url || item.file_url), cover_url: item.cover_url } this.setState({ diff --git a/public/react/src/modules/user/usersInfo/video/VideoInReviewItem.js b/public/react/src/modules/user/usersInfo/video/VideoInReviewItem.js index b045f54b8..6849db062 100644 --- a/public/react/src/modules/user/usersInfo/video/VideoInReviewItem.js +++ b/public/react/src/modules/user/usersInfo/video/VideoInReviewItem.js @@ -1,5 +1,5 @@ import React, { useState, useEffect, useContext, memo } from 'react'; -import { Progress, Input, Tooltip } from 'antd' +import { Progress, Input, Tooltip , Spin } from 'antd' import { getUrl2, isDev, CBreadcrumb, ActionBtn, ThemeContext } from 'educoder' import axios from 'axios' import moment from 'moment' @@ -20,7 +20,7 @@ let _clipboard = null; const clipboardMap = {} function VideoInReviewItem (props) { const theme = useContext(ThemeContext); - const { history, file_url, cover_url, title, created_at, published_at, isReview, id + const { history, file_url , play_url , cover_url , transcoded , title, created_at, published_at, isReview, id , onEditVideo, onMaskClick, getCopyText, showNotification,vv,play_duration,operation , deleteVideo , moveVideo ,link} = props; useEffect(()=> { if (!isReview) { @@ -44,24 +44,26 @@ function VideoInReviewItem (props) { function toUpload() { history.push(`/users/${username}/videos/upload`) } + const imgUrl = (!transcoded && !link) ? defaultImg : (cover_url || defaultImg); return (
+ + + { link ? + + 外链 + + : "" + } - - { link ? - - 外链 - - : "" - } - - {!isReview &&
onMaskClick(props)}>
} - {!isReview && !link && -
onMaskClick(props)}> - - {play_duration===0?"":
累计学习时长:{play_duration} h
} -
- } + {!isReview &&
onMaskClick(props)}>
} + {!isReview && !link && transcoded && +
onMaskClick(props)}> + + {play_duration===0?"":
累计学习时长:{play_duration} h
} +
+ } +
20 ? title : ''} @@ -106,7 +108,7 @@ function VideoInReviewItem (props) { { !link ? - + :"" } diff --git a/public/react/src/modules/user/usersInfo/video/VideoUploadList.js b/public/react/src/modules/user/usersInfo/video/VideoUploadList.js index 606ba9f32..3c053166a 100644 --- a/public/react/src/modules/user/usersInfo/video/VideoUploadList.js +++ b/public/react/src/modules/user/usersInfo/video/VideoUploadList.js @@ -57,9 +57,12 @@ function VideoUploadList (props) { } function onUploadChange (e) { - var file = e.target.files[0] + var file = e.target.files[0]; + setLoading(true); + if (!file) { // alert("请先选择需要上传的文件!") + setLoading(false); return } // avi、flv、f4v、m4v、mov、mp4、rmvb、swf、webm @@ -71,6 +74,7 @@ function VideoUploadList (props) { && file.name.indexOf('.webm') == -1 ) { showNotification(`不支持的视频格式`) + setLoading(false); clearInput() return; } @@ -79,7 +83,8 @@ function VideoUploadList (props) { }else if (file.size >(parseInt(MAX_FILE_SIZE) * 1024 * 1024)) { // 超过500m TODO - clearInput() + clearInput(); + setLoading(false); showNotification(`视频大小超过${MAX_FILE_SIZE}M`) return; } @@ -91,7 +96,8 @@ function VideoUploadList (props) { } }) if (gotTheSameFileName) { - clearInput() + clearInput(); + setLoading(false); showNotification(`你不能上传同一个视频文件名称,请重新选择。`) return; } @@ -106,7 +112,6 @@ function VideoUploadList (props) { // 重新创建 才会用最新的 dispatch create: !uploader, addFileSuccess: (uploadInfo) => { - setLoading(true); const file = uploadInfo.file; console.log('addFileSuccess', uploadInfo) // const newvideos = [...videos, { @@ -435,9 +440,10 @@ function VideoUploadList (props) { >继续添加}
-
视频大小:不支持断点续传,单个视频文件最大500M;单次最多支持3个视频文件上传
-
视频规格:avi、flv、f4v、m4v、mov、mp4、rmvb、swf、webm
-
温馨提示:请勿上传违法视频。平台将为每一个视频分配一个地址,您可以通过引用该地址将视频使用在实训项目等模块
+
+
上传说明:目前不支持断点续传,单个视频文件最大限制500M,单次最多支持3个视频文件上传
+
视频规格:avi、flv、f4v、m4v、mov、mp4、rmvb、swf、webm
+
温馨提示:为了更好播放的体验,建议您优先上传MP4格式。如果您是自己录制视频,建议您保存的时候将视频编码设置为AVC(H264)
{!noUploads &&