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

courseware
cxt 5 years ago
commit 09e81ce359

@ -162,7 +162,7 @@ class ChallengesController < ApplicationController
#@pass_games_map = @shixun.challenges.joins(:games).where(games: {status:2}).group(:challenge_id).reorder(nil).count #@pass_games_map = @shixun.challenges.joins(:games).where(games: {status:2}).group(:challenge_id).reorder(nil).count
#@play_games_map = @shixun.challenges.joins(:games).where(games: {status:[0,1]}).group(:challenge_id).reorder(nil).count #@play_games_map = @shixun.challenges.joins(:games).where(games: {status:[0,1]}).group(:challenge_id).reorder(nil).count
@challenges = @shixun.challenges.joins(join_sql).select(base_columns) @challenges = @shixun.challenges.joins(join_sql).select(base_columns).uniq
#@challenges = @shixun.challenges.fields_for_list #@challenges = @shixun.challenges.fields_for_list
@editable = @shixun.status == 0 # before_action有判断权限如果没发布则肯定是管理人员 @editable = @shixun.status == 0 # before_action有判断权限如果没发布则肯定是管理人员

@ -22,23 +22,17 @@ class MyshixunsController < ApplicationController
tip_exception("403", "") tip_exception("403", "")
end end
begin begin
@shixun = Shixun.select(:id, :identifier, :challenges_count).find(@myshixun.shixun_id)
ActiveRecord::Base.transaction do ActiveRecord::Base.transaction do
begin
@shixun = Shixun.select(:id, :identifier, :challenges_count).find(@myshixun.shixun_id)
@myshixun.destroy! @myshixun.destroy!
StudentWork.where(:myshixun_id => @myshixun.id).update_all(myshixun_id: 0, work_status: 0, work_score: nil,
final_score: nil, efficiency: 0, eff_score: 0, calculation_time: nil, cost_time: 0, compelete_status: 0) StudentWork.where(:myshixun_id => @myshixun.id)
rescue Exception => e .update_all(myshixun_id: 0, work_status: 0, work_score: nil,
logger.error("######reset_my_game_failed:#{e.message}") final_score: nil, efficiency: 0, eff_score: 0, calculation_time: nil, cost_time: 0, compelete_status: 0)
raise("ActiveRecord::RecordInvalid")
end
end end
# 删除版本库 # 删除版本库
GitService.delete_repository(repo_path: @repo_path) unless @shixun.is_choice_type? GitService.delete_repository(repo_path: @repo_path) unless @shixun.is_choice_type?
rescue Exception => e rescue Exception => e
if e.message != "ActiveRecord::RecordInvalid"
logger.error("######delete_repository_error-:#{e.message}")
end
raise "delete_repository_error:#{e.message}" raise "delete_repository_error:#{e.message}"
end end
end end

@ -143,7 +143,7 @@ class Challenge < ApplicationRecord
# 关卡用户通关数 # 关卡用户通关数
def user_passed_count def user_passed_count
#games.map{|g| g.status == 2}.count #games.map{|g| g.status == 2}.count
self.games.where(status: 1).count self.games.where(status: 2).count
end end
# 关卡用户正在挑战的人数 # 关卡用户正在挑战的人数

@ -7,6 +7,7 @@
class Game < ApplicationRecord class Game < ApplicationRecord
default_scope { order("games.created_at desc") } default_scope { order("games.created_at desc") }
#TODO: games表要增加challenge_id与user_id的唯一索引
has_many :outputs, -> { order('query_index DESC') } has_many :outputs, -> { order('query_index DESC') }
has_many :challenge_samples, :dependent => :destroy has_many :challenge_samples, :dependent => :destroy
has_many :game_codes, :dependent => :destroy has_many :game_codes, :dependent => :destroy

@ -0,0 +1,28 @@
#coding=utf-8
desc "合并高校的数据,第一个参数是: 正确高校的id, 第二个参数是: 错误高校需要合并到正确高校的id"
# 命令: bundle exec rake schools:merge_school_data f_school=1 s_school=2,3
namespace :schools do
task merge_school_data: :environment do
f_school = ENV['f_school'].to_i
school = School.find_by(id: f_school)
return if school.blank?
s_school = ENV['s_school'].split(",")
merge_schools = School.where(id: s_school)
# 改变用户的学校id 和 单位
UserExtension.where(school_id: merge_schools)
.update_all(school_id: f_school, department_id: nil)
# 改变课堂的学校id
Course.where(school_id: merge_schools).update_all(school_id: f_school)
# 实训报告表迁移数据
s_report = SchoolReport.find_by(school_id: f_school)
SchoolReport.where(school_id: merge_schools).each do |sr|
s_report.update_column(:shixun_evaluate_count, (s_report.shixun_evaluate_count+sr.shixun_evaluate_count))
sr.update(shixun_evaluate_count: 0)
end
end
end

@ -2,13 +2,18 @@
namespace :video_transcode do namespace :video_transcode do
desc "视频转码成h264" desc "视频转码成h264"
task :submit => :environment do task :submit => :environment do
Video.find_each do |v| i = []
if v.uuid && !v.transcoded && !v.file_url.include?('.mp4') && !AliyunVod::Service.get_meta_code_info(v.uuid)[:codecnamne].start_with?("h264", "h265") Video.where.not(uuid: nil, file_url: nil).where(transcoded: false, status: "published").find_each do |v|
p "--- Start submit video trans code #{v.uuid}" code_info = AliyunVod::Service.get_meta_code_info(v.uuid)
AliyunVod::Service.submit_transcode_job(v.uuid, 'a0277c5c0c7458458e171b0cee6ebf5e') if v.file_url.include?('.mp4') && code_info[:codecnamne]&.include?("h264")
else
v.update(transcoded: true) v.update(transcoded: true)
else
puts("uuid: #{v.uuid}")
i << "#{v.id}, #{v.file_url}, #{code_info[:codecnamne]}"
AliyunVod::Service.submit_transcode_job(v.uuid, 'a0277c5c0c7458458e171b0cee6ebf5e')
end end
end end
puts "###########转码个数:#{i.size}"
puts "###########id,file_url, codecnamne:#{i}"
end end
end end

@ -34,6 +34,9 @@ render() {
} }
.color848282{ .color848282{
color:#848282; color:#848282;
}
.task-btn{
color: #fff !important;
} }
` `
} }
@ -50,7 +53,7 @@ render() {
</div> </div>
: :
<div className="clearfix mt30 edu-txt-center"> <div className="clearfix mt30 edu-txt-center">
<a className="task-btn mr30" onClick={this.props.modalCancel}>取消</a> <a className="task-btn mr30" onClick={this.props.modalCancel}>{this.props.cancelText || '取消'}</a>
<a className="task-btn task-btn-orange" onClick={this.props.modalSave}>{this.props.okText || '确定'}</a> <a className="task-btn task-btn-orange" onClick={this.props.modalSave}>{this.props.okText || '确定'}</a>
</div> </div>
} }

@ -32,7 +32,10 @@ class DetailTop extends Component{
getappointmenttype:false, getappointmenttype:false,
openpathss:false, openpathss:false,
cancel_publics:false, cancel_publics:false,
cancel_has_publics:false cancel_has_publics:false,
applyissuePaths:false,
cancelText:undefined,
okText:undefined
} }
} }
componentDidMount(){ componentDidMount(){
@ -110,21 +113,27 @@ class DetailTop extends Component{
applyissuePath=()=>{ applyissuePath=()=>{
this.setState({
loadtype:true,
Modalstype: true,
Modalstopval:` 课程需经过平台审核方可公开使用,公开的课程将对平台所`,
modalsMidval:"有人公开可见,若仅本人教学使用则无需申请公开,直接发",
Modalsbottomval:"送到课堂即可。",
applyissuePaths:true
})
}
showapplyissuePath=()=>{
let pathid=this.props.match.params.pathId; let pathid=this.props.match.params.pathId;
let url ="/paths/"+pathid+"/publish.json"; let url ="/paths/"+pathid+"/publish.json";
axios.post(url).then((result)=>{ axios.post(url).then((result)=>{
if(result.status===200){ if(result.status===200){
if(result.data.status===0){ if(result.data.status===0){
this.setState({
loadtype:true,
Modalstype: true,
Modalstopval: ` 课程需经过平台审核方可公开使用,公开的课程将对平台所`,
modalsMidval:"有人公开可见。若仅本人教学使用则无需申请公开, 直接发",
Modalsbottomval:"送到课堂即可.",
cardsModalsavetype: true,
})
this.props.showNotification(result.data.message) this.props.showNotification(result.data.message)
this.props.getlistdatas(); this.props.getlistdatas();
this.cardsModalcancel()
}else if(result.data.status===1){ }else if(result.data.status===1){
// window.location.reload(); // window.location.reload();
} }
@ -132,9 +141,7 @@ class DetailTop extends Component{
}).catch((error)=>{ }).catch((error)=>{
console.log(error); console.log(error);
}) })
}
}
postcancelissuePath=()=>{ postcancelissuePath=()=>{
let pathId=this.props.match.params.pathId; let pathId=this.props.match.params.pathId;
let url ="/paths/"+pathId+"/cancel_publish.json"; let url ="/paths/"+pathId+"/cancel_publish.json";
@ -180,12 +187,15 @@ class DetailTop extends Component{
modalsMidval:'', modalsMidval:'',
modalstyles:'', modalstyles:'',
cardsModalsavetype:false, cardsModalsavetype:false,
applyissuePath:false, applyissuePaths:false,
openpathss:false, openpathss:false,
cancel_publics:false, cancel_publics:false,
cancel_has_publics:false, cancel_has_publics:false,
Modalstopval:``, Modalstopval:``,
cancelText:undefined,
okText:undefined
}) })
} }
cardsModalsave=()=>{ cardsModalsave=()=>{
@ -369,13 +379,13 @@ class DetailTop extends Component{
openpaths=()=>{ openpaths=()=>{
this.setState({ this.setState({
loadtype:true,
Modalstype: true, Modalstype: true,
openpathss:true, openpathss:true,
Modalstopval: "公开申请已提交,请等待管理员的审核", Modalstopval: "公开课程需经过平台标准化审核审核周期为1-2天公开",
modalsMidval:"• 我们将在1-2个工作日内完成审核", modalsMidval:"的课程将对平台所有人可见。若仅本人教学使用则无需",
Loadtype:true, Modalsbottomval:"申请公开,直接发送到课堂即可",
modalstyles:"848282" cancelText:"取消申请",
okText:"确定申请"
}) })
} }
@ -433,7 +443,7 @@ class DetailTop extends Component{
render(){ render(){
let{detailInfoList}=this.props; let{detailInfoList}=this.props;
let{Modalstype,Modalstopval,cardsModalcancel,putappointmenttype,Modalsbottomval,cardsModalsavetype,loadtype,getappointmenttype,openpathss,cancel_publics,cancel_has_publics}=this.state; let{Modalstype,Modalstopval,cardsModalcancel,putappointmenttype,Modalsbottomval,cardsModalsavetype,loadtype,getappointmenttype,openpathss,cancel_publics,cancel_has_publics,applyissuePaths}=this.state;
const radioStyle = { const radioStyle = {
display: 'block', display: 'block',
height: '30px', height: '30px',
@ -470,8 +480,10 @@ class DetailTop extends Component{
modalsTopval={Modalstopval} modalsTopval={Modalstopval}
modalsBottomval={Modalsbottomval} modalsBottomval={Modalsbottomval}
modalCancel={cardsModalcancel} modalCancel={cardsModalcancel}
modalSave={loadtype===true&&openpathss===false?()=>this.cardsModalcancel():cardsModalsavetype===true?()=>this.postcancelissuePath():openpathss===true?()=>this.postopenpaths():cancel_publics===true?()=>this.postcancel_public():cancel_has_publics===true?()=>this.postcancel_has_public():putappointmenttype===true?()=>this.getappointment():()=>this.cardsModalsave()} modalSave={applyissuePaths===true?()=>this.showapplyissuePath():loadtype===true&&openpathss===false?()=>this.cardsModalcancel():cardsModalsavetype===true?()=>this.postcancelissuePath():openpathss===true?()=>this.postopenpaths():cancel_publics===true?()=>this.postcancel_public():cancel_has_publics===true?()=>this.postcancel_has_public():putappointmenttype===true?()=>this.getappointment():()=>this.cardsModalsave()}
loadtype={loadtype} loadtype={loadtype}
cancelText={this.state.cancelText}
okText={this.state.okText}
modalsMidval={this.state.modalsMidval} modalsMidval={this.state.modalsMidval}
modalstyles={this.state.modalstyles} modalstyles={this.state.modalstyles}
> >
@ -605,8 +617,8 @@ class DetailTop extends Component{
{ {
detailInfoList.publish_status===0&&detailInfoList.allow_add_member===true? detailInfoList.publish_status===0&&detailInfoList.allow_add_member===true?
<a className="fr font-18 color-white kaike mr20 kkbths" <a className="fr font-18 color-white kaike mr20 kkbths"
style={{'width':'65px'}} style={{'width':'95px'}}
onClick={this.applyissuePath}>发布</a>:"" onClick={this.applyissuePath}>申请发布</a>:""
} }

@ -60,7 +60,8 @@ class TPMBanner extends Component {
openshowpublictype:false, openshowpublictype:false,
Radiovalue:1, Radiovalue:1,
TextAreaintshow:false, TextAreaintshow:false,
cancelText:undefined,
okText:undefined,
} }
} }
@ -434,6 +435,9 @@ class TPMBanner extends Component {
modalsMidval:undefined, modalsMidval:undefined,
ModalsBottomval:"", ModalsBottomval:"",
modalstyles:"", modalstyles:"",
cancelText:undefined,
okText:undefined,
Loadtype:false,
}) })
} }
ModalSave = () => { ModalSave = () => {
@ -441,7 +445,10 @@ class TPMBanner extends Component {
let url = "/shixuns/" + id + "/cancel_publish.json"; let url = "/shixuns/" + id + "/cancel_publish.json";
axios.get(url).then((response) => { axios.get(url).then((response) => {
this.props.showSnackbar(response.data.message); this.props.showSnackbar(response.data.message);
window.location.reload() // window.location.reload()
this.ModalCancel()
this.props.getcomponentdidmount()
}).catch((error) => { }).catch((error) => {
console.log(error) console.log(error)
}); });
@ -461,16 +468,21 @@ class TPMBanner extends Component {
ModalSaveopenpublic= () => { ModalSaveopenpublic= () => {
this.setState({ this.setState({
Modalstype: true, Modalstype: true,
Modalstopval: "公开申请已提交,请等待管理员的审核", Modalstopval:"公开实训需经过平台标准化审核审核周期为1-2天",
modalsMidval:"• 我们将在1-2个工作日内完成审核", modalsMidval:"公开的实训将对平台所有人可见。若仅本人教学使用",
ModalCancel: this.eopenpublicupdatadata, ModalsBottomval:"则无需申请公开, 直接发送到课堂即可。",
cancelText:"取消申请",
okText:"确定申请",
ModalCancel: this.ModalCancel,
ModalSave: this.eopenpublicupdatadata, ModalSave: this.eopenpublicupdatadata,
Loadtype:true, // Loadtype:true,
modalstyles:"848282" // modalstyles:"848282"
}) })
} }
eopenpublicupdatadata=()=>{ eopenpublicupdatadata=()=>{
window.location.reload() // window.location.reload()
this.ModalCancel()
this.props.getcomponentdidmount()
} }
openpublic=()=>{ openpublic=()=>{
let id = this.props.match.params.shixunId; let id = this.props.match.params.shixunId;
@ -490,7 +502,9 @@ class TPMBanner extends Component {
let url = `/shixuns/${id}/cancel_apply_public.json`; let url = `/shixuns/${id}/cancel_apply_public.json`;
axios.get(url).then((response) => { axios.get(url).then((response) => {
if(response.data.status===0){ if(response.data.status===0){
window.location.reload() // window.location.reload()
this.ModalCancel()
this.props.getcomponentdidmount()
} }
}).catch((error) => { }).catch((error) => {
console.log(error) console.log(error)
@ -522,7 +536,10 @@ class TPMBanner extends Component {
evaluation_set_position = response.data.evaluation_set_position evaluation_set_position = response.data.evaluation_set_position
} }
if(response.data.status===0){ if(response.data.status===0){
window.location.reload() // window.location.reload()
this.applyreleaseopen()
// this.ModalCancel()
this.props.getcomponentdidmount()
}else{ }else{
this.setState({ this.setState({
Issuevisible: true, Issuevisible: true,
@ -536,13 +553,23 @@ class TPMBanner extends Component {
console.log(error) console.log(error)
}); });
}; };
applyreleaseopen = () => {
this.setState({
Modalstype: true,
Loadtype:true,
Modalstopval: "实训发布后即可发送课堂使用",
ModalSave: this.ModalCancel,
})
}
hiddenIssuevisible = (val) => { hiddenIssuevisible = (val) => {
this.setState({ this.setState({
Issuevisible: false Issuevisible: false
}) })
if (val === 0 || val === 1) { if (val === 0 || val === 1) {
window.location.reload() // window.location.reload()
this.ModalCancel()
this.props.getcomponentdidmount()
} }
} }
@ -803,7 +830,9 @@ class TPMBanner extends Component {
hidestartshixunsreplacevalue, hidestartshixunsreplacevalue,
Forkvisibletype, Forkvisibletype,
AccountProfiletype, AccountProfiletype,
isIE isIE,
cancelText,
okText,
} = this.state; } = this.state;
let {shixunsDetails, shixunId, star_info, star_infos} = this.props; let {shixunsDetails, shixunId, star_info, star_infos} = this.props;
let challengeBtnTipText = ''; let challengeBtnTipText = '';
@ -900,6 +929,8 @@ class TPMBanner extends Component {
modalsMidval={this.state.modalsMidval} modalsMidval={this.state.modalsMidval}
loadtype={this.state.Loadtype} loadtype={this.state.Loadtype}
modalstyles={this.state.modalstyles} modalstyles={this.state.modalstyles}
cancelText={this.state.cancelText}
okText={this.state.okText}
/> : ""} /> : ""}
<div className="educontent clearfix"> <div className="educontent clearfix">

@ -412,6 +412,7 @@ class TPMIndex extends Component {
{...this.props} {...this.props}
{...this.state} {...this.state}
is_jupyter={this.state. is_jupyter} is_jupyter={this.state. is_jupyter}
getcomponentdidmount={()=>this.getcomponentdidmount()}
></TPMBanner> ></TPMBanner>
} }

Loading…
Cancel
Save