dev_daiao
杨树林 5 years ago
commit f9ce3fa29c

@ -17,9 +17,15 @@ class Admins::LaboratorySubjectsController < Admins::BaseController
def destroy
return render_js_error('不能删除自建课程', type: :notify) if current_laboratory_subject.ownership?
current_laboratory_subject.destroy!
render_delete_success
ActiveRecord::Base.transaction do
current_subject = current_laboratory_subject.subject
current_subject.shixuns.each do |shixun|
shixun.destroy!
end
current_subject.destroy!
render_delete_success
end
end

@ -5,7 +5,7 @@ class Admins::SchoolsController < Admins::BaseController
schools = Admins::SchoolQuery.call(params)
@schools = paginate schools
@schools = paginate schools.includes(:user_extensions)
school_ids = @schools.map(&:id)
@department_count = Department.where(school_id: school_ids).group(:school_id).count

@ -308,6 +308,7 @@ class ChallengesController < ApplicationController
end
def challenge_params
tip_exception("评测时间不能超过300秒") if params[:challenge][:exec_time].to_i > 300
params.require(:challenge).permit(:subject, :task_pass, :difficulty, :score, :st, :modify_time, :test_set_average,
:path, :exec_path, :show_type, :original_picture_path, :test_set_score,
:expect_picture_path, :picture_path, :web_route, :answer, :exec_time)

@ -12,11 +12,13 @@ class HackUserLastestCodesController < ApplicationController
def update_code
@my_hack.update_attribute(:code, params[:code])
render_ok
end
# 回复初始代码
def restore_initial_code
@my_hack.update_attribute(:code, @hack.code)
render_ok
end
# 调试代码
@ -126,6 +128,7 @@ class HackUserLastestCodesController < ApplicationController
# 正则错误行数
def regular_match_error_line content, language
content = Base64.decode64(content).force_encoding("utf-8")
case language
when 'Java'
content.scan(/.java.\d+/).map{|s| s.match(/\d+/)[0].to_i}.min

@ -47,6 +47,8 @@ class HacksController < ApplicationController
hack.identifier = generate_identifier Hack, 8
hack.save!
# 创建测试集与代码
logger.info("hack_sets_params:#{hack_sets_params}")
logger.info("hack_code_params:#{hack_code_params}")
hack.hack_sets.create!(hack_sets_params)
hack.hack_codes.create!(hack_code_params)
end

@ -30,10 +30,10 @@ class HomeController < ApplicationController
@main_shixuns = Shixun.where(homepage_show: true).includes(:tag_repertoires, :challenges).limit(8)
@main_subjects = Subject.where(homepage_show: true).includes(:shixuns, :repertoire).limit(8)
if current_laboratory.main_site?
@tea_users = User.where(homepage_teacher: 1).includes(:user_extension).limit(10).order("experience desc")
@stu_users = User.where(is_test: 0).includes(:user_extension).where(user_extensions: {identity: 1}).limit(10).order("experience desc")
end
# if current_laboratory.main_site?
# @tea_users = User.where(homepage_teacher: 1).includes(:user_extension).limit(10).order("experience desc")
# @stu_users = User.where(is_test: 0).includes(:user_extension).where(user_extensions: {identity: 1}).limit(10).order("experience desc")
# end
end
def search

@ -14,7 +14,7 @@ class ShixunsController < ApplicationController
before_action :shixun_access_allowed, except: [:index, :new, :create, :menus, :get_recommend_shixuns,
:propaedeutics, :departments, :apply_shixun_mirror,
:get_mirror_script, :download_file, :shixun_list, :review_shixuns]
:get_mirror_script, :download_file, :shixun_list, :batch_send_to_course]
before_action :find_repo_name, only: [:repository, :commits, :file_content, :update_file, :shixun_exec, :copy, :add_file]
before_action :allowed, only: [:update, :close, :update_propaedeutics, :settings, :publish,
@ -515,7 +515,7 @@ class ShixunsController < ApplicationController
end
# 添加第二仓库
if params[:is_secret_repository]
add_secret_repository
add_secret_repository if @shixun.shixun_secret_repository.blank?
else
# 如果有仓库,就要删
if @shixun.shixun_secret_repository&.repo_name

@ -227,7 +227,7 @@ class SubjectsController < ApplicationController
GitService.add_repository(repo_path: repo_path)
# todo: 为什么保存的时候要去除后面的.git呢??
@shixun.update_column(:repo_name, repo_path.split(".")[0])
mirror_id = MirrorRepository.find_by(type_name: 'Python').id
mirror_id = MirrorRepository.find_by(type_name: 'Python3.6')&.id
if mirror_id
ShixunMirrorRepository.create!(:shixun_id => @shixun.id, :mirror_repository_id => mirror_id)
@shixun.shixun_service_configs.create!(:shixun_id => @shixun.id, :mirror_repository_id => mirror_id)

@ -1,6 +1,6 @@
class HackSet < ApplicationRecord
validates :input, presence: { message: "测试集输入不能为空" }
validates :output, uniqueness: { message: "测试集输出不能为空" }
validates :output, presence: { message: "测试集输出不能为空" }
# 编程题测试集
belongs_to :hack
end

@ -3,5 +3,5 @@ class ShixunTagRepertoire < ApplicationRecord
belongs_to :tag_repertoire
has_many :memos, :through => :memo_tag_repertoires
has_many :memo_tag_repertoires, :dependent => :destroy
# has_many :memo_tag_repertoires, :dependent => :destroy
end

@ -13,11 +13,10 @@ class Admins::SchoolQuery < ApplicationQuery
schools = School.all
keyword = strip_param(:keyword)
schools = schools.where('schools.name LIKE ?', "%#{keyword}%") if keyword
schools = schools.joins(:user_extensions).group(:id)
schools = schools.select('schools.*, COUNT(*) AS users_count')
Rails.logger.info("###########{keyword}")
if keyword
schools = schools.where('schools.name LIKE ?', "%#{keyword}%")
end
custom_sort schools, params[:sort_by], params[:sort_direction]
end
end

@ -31,7 +31,7 @@
<td><%= school.province %></td>
<td><%= school.city %></td>
<td class="text-left"><%= school.address %></td>
<td><%= school.users_count %></td>
<td><%= school.user_extensions.count %></td>
<td><%= @department_count.fetch(school.id, 0) %></td>
<td><%= school.created_at&.strftime('%Y-%m-%d %H:%M') %></td>
<td>

@ -1,2 +1,3 @@
json.(@hack_user, :id, :status, :error_line, :error_msg, :expected_output,
:input, :output, :execute_time, :execute_memory)
:input, :output, :execute_time, :execute_memory)
json.language @hack_user.hack.language

@ -1,3 +1,4 @@
json.array! @my_hack.hack_user_codes do |hack_user|
json.(hack_user, :id, :created_at, :status, :execute_time, :execute_memory)
json.language hack_user.hack.language
end

@ -10,12 +10,12 @@ json.subjects do
json.partial! 'subjects/subject', locals: {subjects: @subjects}
end
if current_laboratory.main_site?
json.teachers do
json.partial! 'users/user_small', users: @tea_users
end
json.students do
json.partial! 'users/user_small', users: @stu_users
end
end
# if current_laboratory.main_site?
# json.teachers do
# json.partial! 'users/user_small', users: @tea_users
# end
#
# json.students do
# json.partial! 'users/user_small', users: @stu_users
# end
# end

@ -314,7 +314,7 @@ class ShixunsHome extends Component {
</div>}
{/*精选实训 改为 开发社区*/}
{shixuntype===true||homedatalist===undefined?"":homedatalist.shixuns.length===0?"":<div className="clearfix pt20 educontent pr pb20">
{shixuntype===true||homedatalist===undefined?"":homedatalist.shixuns.length===0?"":<div className="clearfix pt20 educontent pr pb20 mb20">
<div className="edu-txt-center">
<p className="color-dark edu-txt-center font-24" style={{lineHeight: '30px'}}>实训项目</p>
<p className="color-grey-cd font-12">DEVELOPMENT COMMUNITY</p>
@ -411,160 +411,160 @@ class ShixunsHome extends Component {
{/*导师排行榜*/}
{ homedatalist !== undefined && homedatalist.teachers !== undefined && (
this.props.user&&this.props.user.main_site===true?<div className="pt60 pb60 mb30 mentor-ranking">
<div className="educontent">
<div className="edu-txt-center">
<p className="color-dark edu-txt-center font-24" style={{lineHeight: '30px'}}>导师排行榜</p>
<p className="color-grey-cd font-12">MENTOR RANKING</p>
</div>
<div className="ranking clearfix">
<ul className="grade color-dark">
{
homedatalist===undefined?"":homedatalist.teachers.map((item,key)=>{
if(key===1){
return(
<li className="mt35 pr" key={key}>
<img src={getImageUrl("images/educoder/huangguan-two.png")} className="huangguan" />
<a href={"/users/"+item.login} className="color-dark">
<img src={'/images/'+item.image_url} />
<p className="task-hide rankName mt5">{item.username}</p>
</a>
</li>
)
}
})}
{
homedatalist===undefined?"":homedatalist.teachers.map((item,key)=>{
if(key===0){
return(
<li className="pr" key={key}>
<img src={getImageUrl("images/educoder/huangguan.png")} className="huangguan" />
<a href={"/users/"+item.login} className="color-dark">
<img src={'/images/'+item.image_url} />
<p className="task-hide rankName mt5">{item.username}</p>
</a>
</li>
)
}
})}
{
homedatalist===undefined?"":homedatalist.teachers.map((item,key)=>{
if(key===2){
return(
<li className="mt35 pr" key={key}>
<img src={getImageUrl("images/educoder/huangguan-three.png")} className="huangguan" />
<a href={"/users/"+item.login} className="color-dark">
<img src={'/images/'+item.image_url} />
<p className="task-hide rankName mt5">{item.username}</p>
</a>
</li>
)
}
})}
</ul>
<br />
<ul className="grade mt30">
{
homedatalist===undefined?"":homedatalist.teachers.map((item,key)=>{
if(key>2) {
return (
<li key={key}>
<a href={"/users/"+item.login} className="color-dark">
<img src={'/images/'+item.image_url}/>
<p className="task-hide rankName mt5">{item.username}</p>
</a>
</li>
)
}
})}
</ul>
</div>
</div>
</div>:""
)}
{/* { homedatalist !== undefined && homedatalist.teachers !== undefined && (*/}
{/* this.props.user&&this.props.user.main_site===true?<div className="pt60 pb60 mb30 mentor-ranking">*/}
{/* <div className="educontent">*/}
{/* <div className="edu-txt-center">*/}
{/* <p className="color-dark edu-txt-center font-24" style={{lineHeight: '30px'}}>导师排行榜</p>*/}
{/* <p className="color-grey-cd font-12">MENTOR RANKING</p>*/}
{/* </div>*/}
{/* <div className="ranking clearfix">*/}
{/* <ul className="grade color-dark">*/}
{/* {*/}
{/* homedatalist===undefined?"":homedatalist.teachers.map((item,key)=>{*/}
{/* if(key===1){*/}
{/* return(*/}
{/* <li className="mt35 pr" key={key}>*/}
{/* <img src={getImageUrl("images/educoder/huangguan-two.png")} className="huangguan" />*/}
{/* <a href={"/users/"+item.login} className="color-dark">*/}
{/* <img src={'/images/'+item.image_url} />*/}
{/* <p className="task-hide rankName mt5">{item.username}</p>*/}
{/* </a>*/}
{/* </li>*/}
{/* )*/}
{/* }*/}
{/* })}*/}
{/* {*/}
{/* homedatalist===undefined?"":homedatalist.teachers.map((item,key)=>{*/}
{/* if(key===0){*/}
{/* return(*/}
{/* <li className="pr" key={key}>*/}
{/* <img src={getImageUrl("images/educoder/huangguan.png")} className="huangguan" />*/}
{/* <a href={"/users/"+item.login} className="color-dark">*/}
{/* <img src={'/images/'+item.image_url} />*/}
{/* <p className="task-hide rankName mt5">{item.username}</p>*/}
{/* </a>*/}
{/* </li>*/}
{/* )*/}
{/* }*/}
{/* })}*/}
{/* {*/}
{/* homedatalist===undefined?"":homedatalist.teachers.map((item,key)=>{*/}
{/* if(key===2){*/}
{/* return(*/}
{/* <li className="mt35 pr" key={key}>*/}
{/* <img src={getImageUrl("images/educoder/huangguan-three.png")} className="huangguan" />*/}
{/* <a href={"/users/"+item.login} className="color-dark">*/}
{/* <img src={'/images/'+item.image_url} />*/}
{/* <p className="task-hide rankName mt5">{item.username}</p>*/}
{/* </a>*/}
{/* </li>*/}
{/* )*/}
{/* }*/}
{/* })}*/}
{/* </ul>*/}
{/* <br />*/}
{/* <ul className="grade mt30">*/}
{/* {*/}
{/* homedatalist===undefined?"":homedatalist.teachers.map((item,key)=>{*/}
{/* if(key>2) {*/}
{/* return (*/}
{/* <li key={key}>*/}
{/* <a href={"/users/"+item.login} className="color-dark">*/}
{/* <img src={'/images/'+item.image_url}/>*/}
{/* <p className="task-hide rankName mt5">{item.username}</p>*/}
{/* </a>*/}
{/* </li>*/}
{/* )*/}
{/* }*/}
{/* })}*/}
{/* </ul>*/}
{/* </div>*/}
{/* </div>*/}
{/* </div>:""*/}
{/* )}*/}
{/*程序员排行榜*/}
{ homedatalist !== undefined && homedatalist.students !== undefined && (
this.props.user&&this.props.user.main_site===true?<div className="pt60 pb60 mb30 pro-ranking">
<div className="educontent">
<div className="edu-txt-center">
<p className="color-dark edu-txt-center font-24" style={{lineHeight: '30px'}}>程序员排行榜</p>
<p className="color-grey-cd font-12">PROGRAMMER RANKING</p>
</div>
<div className="ranking clearfix">
<ul className="grade color-dark">
{
homedatalist===undefined?"":homedatalist.students.map((item,key)=>{
if(key===1){
return(
<li className="mt35 pr" key={key}>
<img src={getImageUrl("images/educoder/huangguan-two.png")} className="huangguan" />
<a href={"/users/"+item.login} className="color-dark">
<img src={'/images/'+item.image_url} />
<p className="task-hide rankName mt5">{item.username}</p>
</a>
</li>
)
}
})}
{
homedatalist===undefined?"":homedatalist.students.map((item,key)=>{
if(key===0){
return(
<li className="pr" key={key}>
<img src={getImageUrl("images/educoder/huangguan.png")} className="huangguan" />
<a href={"/users/"+item.login} className="color-dark">
<img src={'/images/'+item.image_url} />
<p className="task-hide rankName mt5">{item.username}</p>
</a>
</li>
)
}
})}
{
homedatalist===undefined?"":homedatalist.students.map((item,key)=>{
if(key===2){
return(
<li className="mt35 pr" key={key}>
<img src={getImageUrl("images/educoder/huangguan-three.png")} className="huangguan" />
<a href={"/users/"+item.login} className="color-dark">
<img src={'/images/'+item.image_url} />
<p className="task-hide rankName mt5">{item.username}</p>
</a>
</li>
)
}
})}
</ul>
<br />
<ul className="grade mt30">
{
homedatalist===undefined?"":homedatalist.students.map((item,key)=>{
if(key>2) {
return (
<li key={key}>
<a href={"/users/"+item.login} className="color-dark">
<img src={'/images/'+item.image_url}/>
<p className="task-hide rankName mt5">{item.username}</p>
</a>
</li>
)
}
})}
</ul>
</div>
</div>
</div>:""
)}
{/*{ homedatalist !== undefined && homedatalist.students !== undefined && (*/}
{/* this.props.user&&this.props.user.main_site===true?<div className="pt60 pb60 mb30 pro-ranking">*/}
{/* <div className="educontent">*/}
{/* <div className="edu-txt-center">*/}
{/* <p className="color-dark edu-txt-center font-24" style={{lineHeight: '30px'}}>程序员排行榜</p>*/}
{/* <p className="color-grey-cd font-12">PROGRAMMER RANKING</p>*/}
{/* </div>*/}
{/* <div className="ranking clearfix">*/}
{/* <ul className="grade color-dark">*/}
{/* {*/}
{/* homedatalist===undefined?"":homedatalist.students.map((item,key)=>{*/}
{/* if(key===1){*/}
{/* return(*/}
{/* <li className="mt35 pr" key={key}>*/}
{/* <img src={getImageUrl("images/educoder/huangguan-two.png")} className="huangguan" />*/}
{/* <a href={"/users/"+item.login} className="color-dark">*/}
{/* <img src={'/images/'+item.image_url} />*/}
{/* <p className="task-hide rankName mt5">{item.username}</p>*/}
{/* </a>*/}
{/* </li>*/}
{/* )*/}
{/* }*/}
{/* })}*/}
{/* {*/}
{/* homedatalist===undefined?"":homedatalist.students.map((item,key)=>{*/}
{/* if(key===0){*/}
{/* return(*/}
{/* <li className="pr" key={key}>*/}
{/* <img src={getImageUrl("images/educoder/huangguan.png")} className="huangguan" />*/}
{/* <a href={"/users/"+item.login} className="color-dark">*/}
{/* <img src={'/images/'+item.image_url} />*/}
{/* <p className="task-hide rankName mt5">{item.username}</p>*/}
{/* </a>*/}
{/* </li>*/}
{/* )*/}
{/* }*/}
{/* })}*/}
{/* {*/}
{/* homedatalist===undefined?"":homedatalist.students.map((item,key)=>{*/}
{/* if(key===2){*/}
{/* return(*/}
{/* <li className="mt35 pr" key={key}>*/}
{/* <img src={getImageUrl("images/educoder/huangguan-three.png")} className="huangguan" />*/}
{/* <a href={"/users/"+item.login} className="color-dark">*/}
{/* <img src={'/images/'+item.image_url} />*/}
{/* <p className="task-hide rankName mt5">{item.username}</p>*/}
{/* </a>*/}
{/* </li>*/}
{/* )*/}
{/* }*/}
{/* })}*/}
{/* </ul>*/}
{/* <br />*/}
{/* <ul className="grade mt30">*/}
{/* {*/}
{/* homedatalist===undefined?"":homedatalist.students.map((item,key)=>{*/}
{/* if(key>2) {*/}
{/* return (*/}
{/* <li key={key}>*/}
{/* <a href={"/users/"+item.login} className="color-dark">*/}
{/* <img src={'/images/'+item.image_url}/>*/}
{/* <p className="task-hide rankName mt5">{item.username}</p>*/}
{/* </a>*/}
{/* </li>*/}
{/* )*/}
{/* }*/}
{/* })}*/}
{/* </ul>*/}
{/* </div>*/}
{/* </div>*/}
{/*</div>:""*/}
{/*)}*/}
</div>
</Spin>
</div>

@ -490,6 +490,13 @@ class RealNameCertificationModal extends Component{
action: this.props.current_user ? `${getUploadActionUrl()}` : '',
className: 'idPic-uploader',
onChange: this.handleChange2,
beforeUpload: (file) => {
const isJpgOrPng = file.type === 'image/jpeg' || file.type === 'image/png' || file.type === 'image/jpg' || file.type === 'image/bmp';
if (!isJpgOrPng) {
this.props.showNotification('请上传正确文件格式');
}
return isJpgOrPng;
},
};
// form合并了
@ -739,7 +746,9 @@ class RealNameCertificationModal extends Component{
<span className="idPic-uploader demoImg">
<img src={`${certification == 1 ? authImg : jobImg}`} alt="avatar" style={{ maxHeight: '110px'}}/>
</span>
<Dragger {...uploadProps2}>
<Dragger {...uploadProps2}
accept=".png,.jpg,.bmp,.jpeg"
>
{imageUrl2 ?
// <a href={imageUrl2} target="_blank" title="点击重新上传图片"></a>
<img src={imageUrl2} alt="avatar" style={{ maxHeight: '110px'}}/>

@ -81,10 +81,11 @@ class SearchPage extends Component{
setdatafuns =(value)=>{
this.setState({
keywords:value
keywords:value,
page:1
})
this.props.history.replace(`/search?value=${value}`)
this.getdata(this.state.page,this.state.type,value);
this.getdata(1,this.state.type,value);
}
paginationonChanges = (pageNumber) => {
this.setState({

Loading…
Cancel
Save