Merge branch 'dev_aliyun' of https://bdgit.educoder.net/Hjqreturn/educoder into dev_aliyun

dev_item_bank
杨树林 5 years ago
commit cf313a2f8e

@ -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?

@ -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

@ -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 =

@ -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({

@ -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 (
<div className={`${isReview ? 'videoInReviewItem' : 'nItem'} videoItem`}>
<Spin tip="正在转码,请稍等..." spinning={!transcoded && !link}>
<img className="cover" src={imgUrl} alt=""></img>
{ link ?
<a href={link} target='_blank' className="otherLinkPanel">
<span className="otherLink">外链</span>
</a>
: ""
}
<img className="cover" src={cover_url || defaultImg} alt=""></img>
{ link ?
<a href={link} target='_blank' className="otherLinkPanel">
<span className="otherLink">外链</span>
</a>
: ""
}
{!isReview && <div className="mask" onClick={() => onMaskClick(props)}></div>}
{!isReview && !link &&
<div className="playWrap" onClick={() => onMaskClick(props)}>
<img className="play mp23" src={playIcon}></img>
{play_duration===0?"":<div className={"play_duration"}>累计学习时长{play_duration} h</div>}
</div>
}
{!isReview && <div className="mask" onClick={() => onMaskClick(props)}></div>}
{!isReview && !link && transcoded &&
<div className="playWrap" onClick={() => onMaskClick(props)}>
<img className="play mp23" src={playIcon}></img>
{play_duration===0?"":<div className={"play_duration"}>累计学习时长{play_duration} h</div>}
</div>
}
</Spin>
<div className="square-main">
<div className="title overflowHidden1"
title={title && title.length > 20 ? title : ''}
@ -106,7 +108,7 @@ function VideoInReviewItem (props) {
{
!link ?
<Tooltip title="复制视频地址" placement="bottom">
<i className={`icon-fuzhi iconfont copybtn_item_${id}`} data-clipboard-text={getCopyText(file_url, cover_url)}></i>
<i className={`icon-fuzhi iconfont copybtn_item_${id}`} data-clipboard-text={getCopyText((play_url || file_url), cover_url)}></i>
</Tooltip>:""
}

@ -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) {
>继续添加</ActionBtn>}
<div className={`description ${noUploads ? 'noUploads' : ''}`}>
<div className="">视频大小不支持断点续传单个视频文件最大500M单次最多支持3个视频文件上传 </div>
<div className="">视频规格aviflvf4vm4vmovmp4rmvbswfwebm </div>
<div className="">温馨提示请勿上传违法视频平台将为每一个视频分配一个地址您可以通过引用该地址将视频使用在实训项目等模块</div>
<div class="description ">
<div>上传说明目前不支持断点续传单个视频文件最大限制500M单次最多支持3个视频文件上传 </div>
<div>视频规格aviflvf4vm4vmovmp4rmvbswfwebm </div>
<div>温馨提示<span class="color-orange-tip">为了更好播放的体验建议您优先上传MP4格式如果您是自己录制视频建议您保存的时候将视频编码设置为AVC(H264)</span></div></div>
</div>
{!noUploads && <React.Fragment>

Loading…
Cancel
Save