diff --git a/app/helpers/courses_helper.rb b/app/helpers/courses_helper.rb index 8f024c1c6..0ee83e839 100644 --- a/app/helpers/courses_helper.rb +++ b/app/helpers/courses_helper.rb @@ -238,7 +238,9 @@ module CoursesHelper # 获取课堂的资源数 def get_attachment_count(course, category_id) - category_id.to_i == 0 ? course.attachments.size : course.attachments.where(course_second_category_id: category_id).size + identity = current_user.course_identity(course) + attachments = category_id.to_i == 0 ? course.attachments : course.attachments.where(course_second_category_id: category_id) + identity > Course::ASSISTANT_PROFESSOR ? attachments.published.size : attachments.size end # 获取课堂的视频数 diff --git a/app/libs/aliyun_vod/service/video_manage.rb b/app/libs/aliyun_vod/service/video_manage.rb index ef8e707b3..f80f31788 100644 --- a/app/libs/aliyun_vod/service/video_manage.rb +++ b/app/libs/aliyun_vod/service/video_manage.rb @@ -26,7 +26,7 @@ module AliyunVod::Service::VideoManage result end - # 读取视频编码格式 + # 读取视频编码格式与视频格式 def get_meta_code_info(video_id) params = { Action: 'GetMezzanineInfo', @@ -36,11 +36,14 @@ module AliyunVod::Service::VideoManage result = request(:post, params) Rails.logger.info("#######:#{result['Mezzanine']['VideoStreamList'][0]['CodecName']}") - result['Mezzanine']['VideoStreamList'][0]['CodecName'] + codecnamne = result['Mezzanine']['VideoStreamList'].first['CodecName'] + file_url = result['Mezzanine']['FileURL'] + format = file_url&.split(".")&.last + {codecnamne: codecnamne, format: format} rescue => e Rails.logger.info "读取视频编码信息失败: #{video_id}, #{e.message}" - "" + {codecnamne: "", format: ""} end # 删除视频信息 diff --git a/app/models/attachment.rb b/app/models/attachment.rb index 3ff9a6a90..1a9b50c3b 100644 --- a/app/models/attachment.rb +++ b/app/models/attachment.rb @@ -24,6 +24,7 @@ class Attachment < ApplicationRecord scope :simple_columns, -> { select(:id, :filename, :filesize, :created_on, :cloud_url, :author_id, :content_type, :container_type, :container_id) } scope :search_by_container, -> (ids) {where(container_id: ids)} scope :unified_setting, -> {where("unified_setting = ? ", 1)} + scope :published, -> {where(is_publish: 1)} validates_length_of :description, maximum: 100, message: "不能超过100个字符" diff --git a/app/services/videos/batch_publish_service.rb b/app/services/videos/batch_publish_service.rb index 022098fd4..553ffe4f2 100644 --- a/app/services/videos/batch_publish_service.rb +++ b/app/services/videos/batch_publish_service.rb @@ -29,12 +29,13 @@ class Videos::BatchPublishService < ApplicationService video.status = "published" end - # 标清转码为h264 + # 非MP4 H264编码的都转码 code_info = AliyunVod::Service.get_meta_code_info(video.uuid) - if code_info.present? && code_info.start_with?('h264', 'h265') + Rails.logger.info("code_info: #{code_info[:format]}, #{code_info[:codecnamne]}") + if code_info[:format] == "mp4" && code_info[:codecnamne].present? && code_info[:codecnamne].start_with?('h264') video.transcoded = true result = AliyunVod::Service.get_play_info(video.uuid) rescue nil - play_url = result['PlayInfoList']['PlayInfo'][0]['PlayURL'] if result.present? + play_url = result['PlayInfoList']['PlayInfo'].first['PlayURL'] if result.present? video.play_url = play_url else AliyunVod::Service.submit_transcode_job(video.uuid, Video::NORMAL_TRANSCODE_GROUP_ID) diff --git a/lib/tasks/video_transcode.rake b/lib/tasks/video_transcode.rake index 955905632..995f9a82f 100644 --- a/lib/tasks/video_transcode.rake +++ b/lib/tasks/video_transcode.rake @@ -3,7 +3,7 @@ namespace :video_transcode do desc "视频转码成h264" task :submit => :environment do Video.find_each do |v| - if v.uuid && !v.transcoded && !v.file_url.include?('.mp4') && !AliyunVod::Service.get_meta_code_info(v.uuid).start_with?("h264", "h265") + if v.uuid && !v.transcoded && !v.file_url.include?('.mp4') && !AliyunVod::Service.get_meta_code_info(v.uuid)[:codecnamne].start_with?("h264", "h265") p "--- Start submit video trans code #{v.uuid}" AliyunVod::Service.submit_transcode_job(v.uuid, 'a0277c5c0c7458458e171b0cee6ebf5e') else diff --git a/public/react/src/modules/courses/Resource/index.js b/public/react/src/modules/courses/Resource/index.js index 11b81c33d..d5d777f3b 100644 --- a/public/react/src/modules/courses/Resource/index.js +++ b/public/react/src/modules/courses/Resource/index.js @@ -64,6 +64,7 @@ class Fileslists extends Component{ }); } componentDidMount=()=>{ + this.getcourse_groupslists() this.setState({ isSpin:true, @@ -85,43 +86,45 @@ class Fileslists extends Component{ this.seactall(parseInt(this.props.match.params.Id),"desc") } this.updadatalist(); - on('updateNavSuccess', this.updateNavSuccess) - on('updateNavSuccess',this.updadatalist) + on('files', this.updateNavSuccess) + on('files',this.updadatalist) } updateNavSuccess=()=>{ + let{sort}=this.state; this.setState({ isSpin:true }) if(this.props.match.params.main_id){ + this.seactall(undefined,sort); }else if(this.props.match.params.Id){ + this.seactall(parseInt(this.props.match.params.Id),sort) } } componentDidUpdate = (prevProps) => { - if(prevProps.coursesidtype!=this.props.coursesidtype||prevProps.match.params.main_id!=this.props.match.params.main_id||prevProps.match.params.Id!=this.props.match.params.Id){ + if(prevProps.coursesidtype!=this.props.coursesidtype||prevProps.match.params.Id!=this.props.match.params.Id&&this.props.coursesidtype!="node") { + if(this.props.coursesidtype==="node") { - if(this.props.match.params.main_id){ this.getcourse_groupslists() this.setState({ - isSpin:true, - checkBoxValues:[], - checkAllValue:false, + isSpin: true, + checkBoxValues: [], + checkAllValue: false, }) - if(this.props.match.params.main_id!=undefined){ + if (this.props.match.params.main_id != undefined) { this.setState({ - child:false, - sort:"desc" + child: false, + sort: "desc" }) - this.seactall(undefined,"desc"); + this.seactall(undefined, "desc"); } - } + }else{ - if(this.props.match.params.Id){ this.getcourse_groupslists() this.setState({ isSpin:true, @@ -136,8 +139,12 @@ class Fileslists extends Component{ this.seactall(parseInt(this.props.match.params.Id),"desc") } } + } + + + } updadatalist=(id)=>{ @@ -174,6 +181,7 @@ class Fileslists extends Component{ } updatafiled=()=>{ + let{sort}=this.state; if(this.props.match.params.main_id){ this.seactall(undefined,sort); @@ -640,7 +648,7 @@ class Fileslists extends Component{ } Settingtypess=(id,title,link)=>{ - debugger + this.setState({ Addanexternallink:true, Exterchainname:"资源设置", @@ -951,10 +959,12 @@ class Fileslists extends Component{ } secondRowLeft={ -
+ this.props.isAdmin()?
共 {total_count} 个资源 已发布:{publish_count}个 未发布:{unpublish_count}个 +
:
+ 共 {publish_count} 个资源
} onPressEnter={this.onPressEnter} diff --git a/public/react/src/modules/courses/busyWork/CommonWorkList.js b/public/react/src/modules/courses/busyWork/CommonWorkList.js index 58156beea..e2b70aed5 100644 --- a/public/react/src/modules/courses/busyWork/CommonWorkList.js +++ b/public/react/src/modules/courses/busyWork/CommonWorkList.js @@ -775,7 +775,7 @@ class CommonWorkList extends Component{ const hasData = this.state.homework_status && this.state.homework_status.indexOf("未发布") == -1 // student_works && !!student_works.length && page == 1 && - console.log(StudentData) + //console.log(StudentData) // console.log(student_works) return( diff --git a/public/react/src/modules/courses/coursesDetail/CoursesBanner.js b/public/react/src/modules/courses/coursesDetail/CoursesBanner.js index 7d2791b15..98c56ff37 100644 --- a/public/react/src/modules/courses/coursesDetail/CoursesBanner.js +++ b/public/react/src/modules/courses/coursesDetail/CoursesBanner.js @@ -706,7 +706,7 @@ class CoursesBanner extends Component { {this.props.isStudent()?this.props.current_user&&this.props.current_user.course_is_end===true?"": this.exitclass()} - > 退出课堂 :""} + > 永久退出课堂 :""}
diff --git a/public/react/src/modules/courses/coursesDetail/CoursesLeftNav.js b/public/react/src/modules/courses/coursesDetail/CoursesLeftNav.js index 63466646e..1c627b78d 100644 --- a/public/react/src/modules/courses/coursesDetail/CoursesLeftNav.js +++ b/public/react/src/modules/courses/coursesDetail/CoursesLeftNav.js @@ -536,7 +536,7 @@ class Coursesleftnav extends Component{ successFunc && successFunc(1); } - saveNavmodapost=(url,value,positiontype,coursesId)=>{ + saveNavmodapost=(url,value,positiontype,coursesId,type)=>{ axios.post(url, {name:value}).then((result)=>{ @@ -548,16 +548,29 @@ class Coursesleftnav extends Component{ description:result.data.message }); - if(positiontype==="shixun_homeworks"){ - this.updasaveNavmoda() - trigger('updateNavSuccess') - this.props.history.push(`/classrooms/${coursesId}/shixun_homework/${result.data.category_id}`); + if(positiontype==="shixun_homeworks"||positiontype==="shixun_homework"){ + if(type===true){ + this.updasaveNavmoda() + trigger('shixun') + }else{ + this.updasaveNavmoda() + this.props.history.push(`/classrooms/${coursesId}/shixun_homework/${result.data.category_id}`); + + } } - if(positiontype==="files"){ - this.updasaveNavmoda() - trigger('updateNavSuccess') - this.props.history.push(`/classrooms/${coursesId}/file/${result.data.category_id}`); - } + + if(positiontype==="files"||positiontype==="file"){ + + if(type===true){ + this.updasaveNavmoda() + trigger('files') + + }else{ + this.updasaveNavmoda() + this.props.history.push(`/classrooms/${coursesId}/file/${result.data.category_id}`); + } + + } if(positiontype==="boards"){ this.updasaveNavmoda() @@ -565,7 +578,7 @@ class Coursesleftnav extends Component{ this.props.history.push(`/classrooms/${coursesId}/boards/${result.data.category_id}`); } - if(positiontype!="course_groups"&&positiontype!="shixun_homeworks"){ + if(positiontype!="course_groups"&&positiontype!="shixun_homeworks"&&positiontype!="shixun_homework"){ this.updasaveNavmoda() } @@ -640,12 +653,12 @@ class Coursesleftnav extends Component{ }else if(Navmodaltypename===3){ let url="/course_modules/"+id+"/rename_module.json" - this.saveNavmodapost(url,NavmodalValue) + this.saveNavmodapost(url,NavmodalValue,this.state.positiontype,null,true) }else if(Navmodaltypename===4){ let url="/course_second_categories/"+id+"/rename_category.json"; - this.saveNavmodapost(url,NavmodalValue) + this.saveNavmodapost(url,NavmodalValue,this.state.positiontype,null,true) }else if(Navmodaltypename===5){ diff --git a/public/react/src/modules/courses/shixunHomework/shixunHomework.js b/public/react/src/modules/courses/shixunHomework/shixunHomework.js index a6fca8e0b..5b6eda89f 100644 --- a/public/react/src/modules/courses/shixunHomework/shixunHomework.js +++ b/public/react/src/modules/courses/shixunHomework/shixunHomework.js @@ -58,6 +58,7 @@ class ShixunHomework extends Component{ } } updateNavSuccess=()=>{ + debugger this.setState({ isSpin:true }) @@ -111,7 +112,7 @@ class ShixunHomework extends Component{ this.updadatalist() } } - on('updateNavSuccess', this.updateNavSuccess) + on('shixun', this.updateNavSuccess) } seactall=(id)=>{ this.setState({ @@ -146,7 +147,7 @@ class ShixunHomework extends Component{ componentDidUpdate = (prevProps) => { - if(prevProps.coursesidtype!=this.props.coursesidtype||prevProps.match.params.main_id!=this.props.match.params.main_id||prevProps.match.params.category_id!=this.props.match.params.category_id) { + if(prevProps.coursesidtype!=this.props.coursesidtype||prevProps.match.params.category_id!=this.props.match.params.category_id&&this.props.coursesidtype!="node") { if(this.props.match.params.main_id){ if(this.props.match.params.main_id!=undefined){ diff --git a/public/react/src/modules/tpm/shixuns/shixun-card.js b/public/react/src/modules/tpm/shixuns/shixun-card.js index 5fe07d074..f33f4f157 100644 --- a/public/react/src/modules/tpm/shixuns/shixun-card.js +++ b/public/react/src/modules/tpm/shixuns/shixun-card.js @@ -83,7 +83,7 @@ export default ({ middleshixundata, pagination, typepvisible, pages, totalcount,
-