Merge branch 'dev_aliyun' into develop

dev_video
daiao 5 years ago
commit ced591511f

@ -634,7 +634,8 @@ class ApplicationController < ActionController::Base
end
def paginate(relation)
limit = (params[:limit].to_i.zero? || params[:limit].to_i > 20) ? 20 : params[:limit].to_i
limit = params[:limit] || params[:per_page]
limit = (limit.to_i.zero? || limit.to_i > 20) ? 20 : limit.to_i
page = params[:page].to_i.zero? ? 1 : params[:page].to_i
offset = (page - 1) * limit
@ -645,6 +646,8 @@ class ApplicationController < ActionController::Base
end
end
def strf_time(time)
time.blank? ? '' : time.strftime("%Y-%m-%d %H:%M:%S")
end

@ -227,8 +227,10 @@ class ChallengesController < ApplicationController
@challenge.update_attributes(picture_path: nil, web_route: nil, expect_picture_path: nil, original_picture_path: nil)
end
# 关卡评测执行文件如果被修改,需要修改脚本内容
script = modify_shixun_script @shixun, @shixun.evaluate_script
@shixun.shixun_info.update_column(:evaluate_script, script)
unless @shixun.published
script = modify_shixun_script @shixun, @shixun.evaluate_script
@shixun.shixun_info.update_column(:evaluate_script, script)
end
# TODO:
# if path != params[:challenge][:path]
# shixun_modify_status_without_publish(@shixun, 1)

@ -247,8 +247,8 @@ class SubjectsController < ApplicationController
def send_to_course
@course = Course.find_by!(id: params[:course_id])
stages = @subject.stages.where(id: @subject.stage_shixuns.where(shixun_id: params[:shixun_ids]).pluck(:stage_id))
stages = @subject.stages.where(id: @subject.stage_shixuns.where(shixun_id: params[:shixun_ids]).pluck(:stage_id)).reorder("stages.position DESC")
order_ids = params[:shixun_ids].size > 0 ? params[:shixun_ids].reverse.join(',') : -1
course_module = @course.course_modules.where(module_type: "shixun_homework").first
homework_ids = []
@ -259,7 +259,8 @@ class SubjectsController < ApplicationController
CourseSecondCategory.create!(name: stage.name, course_id: @course.id, category_type: "shixun_homework",
course_module_id: course_module.id, position: course_module.course_second_categories.count + 1)
stage.shixuns.no_jupyter.where(id: params[:shixun_ids], status: 2).each do |shixun|
shixuns = stage.shixuns.no_jupyter.published.where(id: params[:shixun_ids]).reorder("field(shixuns.id, #{order_ids})")
shixuns.each do |shixun|
homework = HomeworksService.new.create_homework shixun, @course, category, current_user
homework_ids << homework.id
end

@ -13,7 +13,7 @@ class Users::VideosController < Users::BaseController
end
def update
return render_error('该状态下不能编辑视频信息') unless current_video.published?
return render_error('该状态下不能编辑视频信息') unless (current_video.published? || current_video.course_videos.present?)
current_video.update!(title: params[:title])
@ -57,6 +57,14 @@ class Users::VideosController < Users::BaseController
def current_video
@_current_video ||= observed_user.videos.find_by(id: params[:id])
if @_current_video.nil?
video = Video.find_by(id: params[:id])
if video.course_videos.present?
video
end
else
@_current_video
end
end
def search_params
@ -64,6 +72,6 @@ class Users::VideosController < Users::BaseController
end
def batch_publish_params
params.permit(videos: %i[video_id title])
params.permit(videos: %i[video_id title course_id])
end
end

@ -11,26 +11,35 @@ class Videos::BatchPublishService < ApplicationService
def call
video_params = Array.wrap(params[:videos]).compact
return if video_params.blank?
Rails.logger.info("#####video_course: #{video_params}")
video_ids = []
ActiveRecord::Base.transaction do
video_params.each do |param|
video = user.videos.find_by(uuid: param[:video_id])
Rails.logger.info("video.processing_video_apply:#{video}")
Rails.logger.info("video.processing_video_apply:#{video.blank? || video.processing_video_apply}")
next if video.blank? || video.processing_video_apply.present?
raise Error, '视频还未上传完成' if video.vod_uploading?
video.title = param[:title].to_s.strip.presence || video.title
video.apply_publish
video.save!
video.video_applies.create!
if param[:course_id].present?
video.video_applies.create!(status: "agreed")
else
video.video_applies.create!
end
video_ids << video.id
# 如果是课堂上传则创建课堂记录
if params[:course_id].present?
video.course_videos.create!(course_id: params[:course_id])
Rails.logger.info("#####param: #{ param[:course_id]}")
if param[:course_id].present?
video.course_videos.create!(course_id: param[:course_id])
end
end
end

@ -1,2 +1,3 @@
json.count @count
json.videos @videos, partial: 'users/videos/video', as: :video
json.videos @videos, partial: 'users/videos/video', as: :video
json.course_id @course.id

@ -45,18 +45,11 @@ class Showoldfiles extends Component{
showfiless=(url)=>{
this.props.ShowOnlinePdf(url)
}
isaboxonClick=(item)=>{
this.props.Clicktobroadcastthevideo(true,item.url+'&file_name='+item.title);
}
isaboxonClicks=(item)=>{
this.props.Clicktobroadcastthevideo(true,item.url+'?file_name='+item.title);
}
render(){
let {visible,allfiles}=this.props;
return(
<div >
<div>
{/*提示*/}
<Modals
modalsType={this.state.Modalstype}
@ -75,9 +68,6 @@ class Showoldfiles extends Component{
width="600px"
destroyOnClose={true}
keyboard={false}
style={{
marginTop: '30px',
}}
>
<a id='closeIcon' onClick={this.cloasshanchudiao}><i className='iconfont icon-shanchudiao'></i></a>
<style>
@ -188,13 +178,11 @@ class Showoldfiles extends Component{
<div className="clearfix edu-txt-center lineh-40 bor-bottom-greyE" id={allfiles.id}>
<li className="fl fontlefts">
{
allfiles&&allfiles.content_type&&allfiles.content_type==="video/mp4"?
<a className={"isabox"} target="_blank" onClick={()=>this.isaboxonClicks(allfiles)}>{allfiles.title}</a>
:
<a className={"isabox"} href={allfiles.url} target="_blank" >{allfiles.title}</a>
}
<a className={"isabox"} href={allfiles.url} target="_blank" >{allfiles.title}</a>
{/*{allfiles.is_pdf===false?*/}
{/*<a className={"isabox"} href={allfiles.url} >{allfiles.title}</a>:*/}
{/*<a className={"isabox"} onClick={()=>this.showfiless(allfiles.url)} >{allfiles.title}</a>*/}
{/*}*/}
<span className={"newcolor-orange fl"}>当前版本</span>
</li>
@ -210,13 +198,7 @@ class Showoldfiles extends Component{
<div className="clearfix edu-txt-center lineh-40 bor-bottom-greyE" id={item.id} key={key}>
<li className="fl fontlefts">
{
item&&item.content_type&&item.content_type==="video/mp4"?
<a className={"isabox"} target="_blank" onClick={()=>this.isaboxonClick(item)}>{item.title}</a>
:
<a className={"isabox"} href={item.url} target="_blank" >{item.title}</a>
}
<a className={"isabox"} href={item.url} target="_blank" >{item.title}</a>
{/*{item.is_pdf===false?*/}
{/*<a className={"isabox"} href={item.url}>{item.title}</a>:*/}
{/*<a className={"isabox"} onClick={()=>this.showfiless(item.url)} >{item.title}</a>*/}
@ -242,4 +224,4 @@ class Showoldfiles extends Component{
)
}
}
export default Showoldfiles;
export default Showoldfiles;
Loading…
Cancel
Save