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

dev_aliyun
daiao 5 years ago
commit 032ee23de5

@ -246,14 +246,14 @@ class CompetitionsController < ApplicationController
# 第一阶段的得分和耗时
challenges_1 = Challenge.where(:shixun_id => shixun1_id)
challenge_rate1 = 0.5
result1 = chart_exp_score_pre user_ids, s1_time, e1_time, challenges_1, challenge_rate1
result1 = chart_exp_score_pre user_ids, s1_time, e1_time, challenges_1, challenge_rate1, 3
score1 = result1[0]
time1 = result1[1]
# 第二阶段的得分和耗时
challenge_rate2 = 1.0
challenges_2 = Challenge.where(:shixun_id => shixun2_id)
result2 = chart_exp_score_pre user_ids, s2_time, e2_time, challenges_2, challenge_rate2
result2 = chart_exp_score_pre user_ids, s2_time, e2_time, challenges_2, challenge_rate2, 3
score2 = result2[0]
time2 = result2[1]
@ -322,7 +322,7 @@ class CompetitionsController < ApplicationController
# 'nyog9r7c','yugrij4n','48flws5g','bfgau7s6','mfv6zrj7','f398leqr','qwaffs2p','ose7482b','y5wh2ofx'
# 预赛的实训id 第一阶段118511971195 第二阶段1202, 1210, 1207 第三阶段125412551243
shixun1_id = [2303]
shixun2_id = [2994, 3012, 3014]
shixun2_id = [2994, 3012, 3024]
shixun3_id = [2944, 2938, 2943]
elsif @type == "决赛"
# '92b7vt8x','a7fxenvc','wt2xfzny','xa4m9cng','tng6heyf','am5o73er','9fla2zry','fzp3iu4w','qlsy6xb4'
@ -346,15 +346,15 @@ class CompetitionsController < ApplicationController
user_ids = team.team_members.where(:is_teacher => 0).pluck(:user_id)
# 第一阶段的得分和耗时
challenges_1 = Challenge.where(:shixun_id => shixun1_id)
challenge_rate1 = 0.5
result1 = chart_exp_score_pre user_ids, s1_time, e1_time, challenges_1, challenge_rate1
challenge_rate1 = 1.0
result1 = chart_exp_score_pre user_ids, s1_time, e1_time, challenges_1, challenge_rate1, 2
score1 = result1[0]
time1 = result1[1]
# 第二阶段的得分和耗时
challenge_rate2 = 1.0
challenges_2 = Challenge.where(:shixun_id => shixun2_id)
result2 = chart_exp_score_pre user_ids, s2_time, e2_time, challenges_2, challenge_rate2
result2 = chart_exp_score_pre user_ids, s2_time, e2_time, challenges_2, challenge_rate2, 2
score2 = result2[0]
time2 = result2[1]
@ -452,8 +452,10 @@ class CompetitionsController < ApplicationController
sheet1[count_row,11] = com_spend_time user[:s_spend_time].to_i
count_row += 1
end
elsif @competition.identifier == "gcc-dev-2018"
elsif @competition.identifier == "gcc-dev-2018" || @competition.identifier == "gcc-task-2019"
records = @competition.competition_teams
f_rate = @competition.identifier == "gcc-dev-2018" ? 0.85 : 0.8
p_rate = @competition.identifier == "gcc-dev-2018" ? 0.15 : 0.2
records.each do |team|
# 决赛记录
f_score = team.competition_scores.where(:competition_stage_id => @competition.competition_stages.where(:name => "决赛").first.try(:id)).first
@ -463,7 +465,7 @@ class CompetitionsController < ApplicationController
team[:p_time] = p_score.try(:cost_time)
team[:f_score] = f_score.try(:score)
team[:f_time] = f_score.try(:cost_time)
team[:s_score] = (f_score.try(:score).to_f * 0.85 + p_score.try(:score).to_f * 0.15).try(:round, 2)
team[:s_score] = (f_score.try(:score).to_f * f_rate + p_score.try(:score).to_f * p_rate).try(:round, 2)
team[:s_spend_time] = f_score.try(:cost_time).to_i + p_score.try(:cost_time).to_i
end
records = records.sort do |a, b|
@ -741,11 +743,12 @@ class CompetitionsController < ApplicationController
# challenges 每阶段三个实训的所有关卡
# s_time 阶段开始时间 e_time 阶段结束时间
# rate 关卡经验值与分数的比值
# challenge_count 每个实训的关卡数
# 对三个实训的所有关卡循环: 找到在比赛时间内通关的最低耗时
def chart_exp_score_pre user_ids, s_time, e_time, challenges, rate
def chart_exp_score_pre user_ids, s_time, e_time, challenges, rate, challenge_count
total_score = 0
total_time = 0
length = challenges.size / 3 #每个实训的关卡数
length = challenge_count #每个实训的关卡数
for i in 1..length
score = 0
time = 0

@ -2941,12 +2941,12 @@ end
else
for row in 2 .. rows
student_id = worksheet.cell(row, 1)
student_id = student_id.is_a?(Float) ? student_id.to_i : student_id
student_id = student_id.is_a?(Float) ? student_id.to_s.strip.to_i : student_id.to_s.strip
member_role = worksheet.cell(row, 4).to_i
course_id = worksheet.cell(row, 3)
group_name = worksheet.cell(row, 5)
school_id = worksheet.cell(row, 6).is_a?(Float) ? worksheet.cell(row, 6).to_i : worksheet.cell(row, 6)
if student_id && member_role && [9, 7, 10].include?(member_role) && course_id && school_id
if student_id && member_role && [2, 3, 4].include?(member_role) && course_id && school_id
user = User.find_by_sql("SELECT u.* FROM `users` u, `user_extensions` ue where u.id = ue.user_id and
ue.student_id = '#{student_id}' and ue.school_id= #{school_id}").first
course = Course.where(:id => course_id).first
@ -2955,18 +2955,19 @@ end
course_group = CourseGroup.where(:course_id => course.id, :name => group_name).first ||
CourseGroup.create(:name => group_name, :course_id => course.id) if group_name
member = course.course_members.where(:user_id => user.id, :role => 4).first
member = course.course_members.where(:user_id => user.id, :role => member_role).first
# 如果已是课堂成员且是学生身份and不在指定的分班则移动到该分班
if member.present? && member.course_group_id != course_group.try(:id).to_i
if member.present? && member.role == 4 && member.course_group_id != course_group.try(:id).to_i
member.update_column("course_group_id", course_group.try(:id).to_i)
member_count += 1
elsif !member.present?
member = CourseMember.new(:role => 4, :user_id => user.id)
member = CourseMember.new(:role => member_role, :user_id => user.id)
# if member_role == 10
# StudentsForCourse.create(:student_id => user.id, :course_id => course.id)
# end
extra = member_role == 2 ? 9 : (member_role == 3 ? 7 : 10)
Tiding.create(:user_id => user.id, :trigger_user_id => course.tea_id, :container_id => course.id, :container_type => 'TeacherJoinCourse',
:belong_container_id => course.id, :belong_container_type => "Course", :tiding_type => "System", :extra => member_role)
:belong_container_id => course.id, :belong_container_type => "Course", :tiding_type => "System", :extra => extra)
member.course_group_id = course_group.try(:id).to_i
course.course_members << member
@ -3011,7 +3012,7 @@ end
if index == 0
school_id = list[0]
elsif index == 1
prefix = list[0]
prefix = list[0].to_s.strip
elsif index != 2 && list[3] && [0, 1, 2].include?(list[3].to_i)
if list[3].to_i == 1
user = User.find_by_sql("SELECT u.* FROM `users` u, `user_extensions` ue where u.id = ue.user_id and ue.identity = 1 and ue.student_id = '#{list[0]}' and ue.school_id= #{school_id.to_i}").first
@ -3025,16 +3026,16 @@ end
user = User.new
user.admin = false
user.activate
user.login = prefix + list[0]
user.lastname = list[1]
user.nickname = list[1]
user.login = prefix + list[0].to_s.strip
user.lastname = list[1].to_s.strip
user.nickname = list[1].to_s.strip
user.professional_certification = 1
user.certification = 1
user.grade = 0
user.password = "12345678"
user.phone = list[5]
user.phone = list[5].blank? ? nil : list[5]
if user.save
ue = UserExtensions.new(:user_id => user.id, :gender => 0, :school_id => school_id, :location => school.province, :location_city => school.city, :identity => list[3], :student_id => list[0], :department_id => department.try(:id))
ue = UserExtensions.new(:user_id => user.id, :gender => 0, :school_id => school_id, :location => school.province, :location_city => school.city, :identity => list[3].to_i, :student_id => list[0].to_s.strip, :department_id => department.try(:id))
if list[3] && list[3].to_i == 0
ue.technical_title = ["教授", "副教授", "讲师", "助教"].include?(list[4]) ? list[4] : "讲师"
elsif list[3] && list[3].to_i == 2

@ -4,4 +4,82 @@ class CourseMember < ActiveRecord::Base
belongs_to :course, counter_cache: true
belongs_to :user
belongs_to :course_group, counter_cache: true
after_create :create_student_works, :create_exercise_users, :create_poll_users, :create_graduation_works
#加入班级时创建作业的作品
def create_student_works
if role == 4
course = self.course
str = ""
homeworks = course.homework_commons.includes(:homework_detail_manual).where("homework_type in (1, 3, 4)")
if homeworks.count != 0
homeworks.each do |hw|
str += "," if str != ""
str += "('#{hw.name}的作品提交',#{hw.id},#{user_id}, '#{Time.now.strftime('%Y-%m-%d %H:%M:%S')}', '#{Time.now.strftime('%Y-%m-%d %H:%M:%S')}')"
end
if str != ""
sql = "insert into student_works (name, homework_common_id, user_id, created_at, updated_at) values" + str
ActiveRecord::Base.connection.execute sql
end
end
end
end
# 加入班级时创建已发布试卷的作品
def create_exercise_users
if role == 4
course = self.course
str = ""
exercises = course.exercises
if exercises.count != 0
exercises.each do |ex|
str += "," if str != ""
str += "(#{ex.id},#{user_id}, 0, '#{Time.now.strftime('%Y-%m-%d %H:%M:%S')}', '#{Time.now.strftime('%Y-%m-%d %H:%M:%S')}')"
end
if str != ""
sql = "insert into exercise_users (exercise_id, user_id, commit_status, created_at, updated_at) values" + str
ActiveRecord::Base.connection.execute sql
end
end
end
end
# 加入班级时创建已发布问卷的作品
def create_poll_users
if role == 4
course = self.course
str = ""
polls = course.polls
if polls.count != 0
polls.each do |poll|
str += "," if str != ""
str += "(#{poll.id},#{user_id}, 0, '#{Time.now.strftime('%Y-%m-%d %H:%M:%S')}', '#{Time.now.strftime('%Y-%m-%d %H:%M:%S')}')"
end
if str != ""
sql = "insert into poll_users (poll_id, user_id, commit_status, created_at, updated_at) values" + str
ActiveRecord::Base.connection.execute sql
end
end
end
end
# 创建毕设任务作品
def create_graduation_works
if role == 4
course = self.course
str = ""
tasks = course.graduation_tasks
if tasks.count != 0
tasks.each do |task|
str += "," if str != ""
str += "(#{task.id}, #{user_id}, #{course.id}, '#{Time.now.strftime('%Y-%m-%d %H:%M:%S')}', '#{Time.now.strftime('%Y-%m-%d %H:%M:%S')}')"
end
if str != ""
sql = "insert into graduation_works (graduation_task_id, user_id, course_id, created_at, updated_at) values" + str
ActiveRecord::Base.connection.execute sql
end
end
end
end
end

@ -1,4 +1,4 @@
<% if @competition.identifier == 'hn' || @competition.identifier == 'gcc-dev-2018' || @competition.identifier == "gcc-annotation-2018" %>
<% if @competition.identifier == 'hn' || @competition.identifier == 'gcc-dev-2018' || @competition.identifier == "gcc-annotation-2018" || @competition.identifier == "gcc-task-2019" %>
<div class="competion-ranking">
<div class="ranking-nav edu-txt-center clearfix">
<div class="inline">
@ -13,7 +13,7 @@
<% end %>
<% @max_min_stage.reverse.each do |section| %>
<% stage = section.competition_stage %>
<% if stage.name != "模拟赛" %>
<% if stage.name != "模拟赛" && !stage.name.blank? %>
<% if section.min_start_time < Time.now %>
<li class="<%= @type == stage.name ? "active" : "" %>"><a href="<%= charts_competition_path(@competition, :stage_id => stage.id) %>" data-remote="true"><%= stage.name %>排行榜</a></li>
<% end %>

@ -41,7 +41,7 @@ var proxy = "http://localhost:3000"
// proxy = "http://testbdweb.trustie.net"
// proxy = "http://testbdweb.educoder.net"
// proxy ="http://192.168.2.63:3000"
proxy='http://120.27.231.56:48080'
proxy='http://localhost:3000'
const requestMap={};
// 在这里使用requestMap控制避免用户通过双击等操作发出重复的请求
// 如果需要支持重复的请求考虑config里面自定义一个allowRepeat参考来控制

@ -306,11 +306,10 @@ class NewHeader extends Component {
activeIndex = true;
}
console.log(this.props.user&&this.props.user.is_student=== true||this.props.current_user&&this.props.current_user.is_student==true)
console.log(this.state.current_user)
// console.log(this.props.user&&this.props.user.is_student=== true||this.props.current_user&&this.props.current_user.is_student==true)
// console.log(this.state.current_user)
// console.log(match.path.startsWith("/ec_courses"))
return (
<div className="newHeader" id="nHeader">
@ -352,7 +351,7 @@ class NewHeader extends Component {
</div>
</div>
</Modal>
<a href="/" className={" fl"}>
<a href="/" className={" fl ml25"}>
{ImageUrlType===true?<img alt="高校智能化教学与实训平台" className="fl" src={getImageUrl(ImageUrl)} style={{height:'60px'}} />:<img alt="高校智能化教学与实训平台" className="logoimg" src={getImageUrl(ImageUrl)}/>}
</a>
<div className="educontent">
@ -401,51 +400,52 @@ class NewHeader extends Component {
<li className={`${activeForums === true ? 'active' : ''}`}><a href="/forums">交流问答</a></li>
<li className={`${activeCourses === true ? 'active' : ''}`} style={{display:ecUrl===null||ecUrl===undefined||ecUrl===""?'none':'block'}}><a href={ecUrl}>{ecUrl===null||ecUrl===undefined||ecUrl===""?'':'工程认证'}</a></li>
</ul>
<style>
{
`
.mar55{
margin-right: 55px;
</div>
</div>
{/*<span className="font-15 fr mt17">
<%= link_to '登录', signin_path, :className => "mr5" %>
<em className="vertical-line"></em>
<%= link_to '注册', user_join_path, :className => "ml5" %>
</span>*/}
<style>
{
`
.marf28{
margin-right: -28px;
}
`
}
</style>
<div className="posi-search mar55" id="posi-search" style={{display: 'none'}}>
<div className="search-all clearfix">
{/*<!--<a href="javascript:void(0)" className="search-clear fl" onclick="closeSearch();">×</a>-->*/}
<div className="fl pr search-clear edu-menu-panel" style={{display: 'none'}}>
<input type="hidden" id="search_type" value="1"></input>
<span className="searchkey">实训</span>
<i className="fa fa-angle-down ml5 font-16"></i>
<ul id="searchkey" className="edu-menu-list edu-txt-center" style={{minWidth: '80px',right: '-10px',top: '50px'}}>
<li><a href="javascript:void(0)">实训</a></li>
<li><a href="javascript:void(0)">课堂</a></li>
<li><a href="javascript:void(0)">用户</a></li>
</ul>
</div>
<input type="text" className="search-input fl" id="search-input" name="search_keyword" placeholder="实践课程/翻转课堂/开发社区/交流问答"/>
<a href="javascript:void(0)" className="search-icon fl" id="header_keyword_search">
{/*<i className="fa fa-search font-16 mt23 color-grey-6"></i>*/}
<i className="iconfont icon-sousuo color-blue"></i>
}
</style>
<div className="posi-search marf28" id="posi-search" style={{display: 'none'}}>
<div className="search-all clearfix">
{/*<!--<a href="javascript:void(0)" className="search-clear fl" onclick="closeSearch();">×</a>-->*/}
<div className="fl pr search-clear edu-menu-panel" style={{display: 'none'}}>
<input type="hidden" id="search_type" value="1"></input>
<span className="searchkey">实训</span>
<i className="fa fa-angle-down ml5 font-16"></i>
<ul id="searchkey" className="edu-menu-list edu-txt-center" style={{minWidth: '80px',right: '-10px',top: '50px'}}>
<li><a href="javascript:void(0)">实训</a></li>
<li><a href="javascript:void(0)">课堂</a></li>
<li><a href="javascript:void(0)">用户</a></li>
</ul>
</div>
<input type="text" className="search-input fl" id="search-input" name="search_keyword" placeholder="实践课程/翻转课堂/开发社区/交流问答"/>
<a href="javascript:void(0)" className="search-icon fl" id="header_keyword_search">
{/*<i className="fa fa-search font-16 mt23 color-grey-6"></i>*/}
<i className="iconfont icon-sousuo color-blue"></i>
</a>
{/* TODO
</a>
{/* TODO
<div class="search-content none" style="width: 86%;left: 0px;">
<div class="search-title">最近搜索</div>
<div><a href="javascript:void(0)" class="search_history">绿盟</a></div>
<div><a href="javascript:void(0)" class="search_history">qwe</a></div>
</div>*/}
</div>
</div>
</div>
{/*<span className="font-15 fr mt17">
<%= link_to '登录', signin_path, :className => "mr5" %>
<em className="vertical-line"></em>
<%= link_to '注册', user_join_path, :className => "ml5" %>
</span>*/}
</div>
</div>
<div style={{display:isLogin===true?'block':'none'}}>
<div className="fr edu-menu-panel" style={{height:'60px'}}>
<div className="fr edu-menu-panel mr10 mtf20 mr25" style={{height:'60px'}}>
<a href={`/users/${current_user.login}`} className="fl">
<img alt="头像" className="radius mt13" height="34" id="nh_user_logo" nhname="avatar_image"
src={`/images/${current_user.image_url}`} width="34">
@ -465,9 +465,20 @@ class NewHeader extends Component {
</div>
</div>
<div style={{display:isLogin===false?'block':'none'}}>
<span className="font-15 fr mt15">
<style>
{
`
.mtf4{
margin-top: -4px;
}
.mtf20{
margin-top: -20px;
}
`
}
</style>
<div style={{display:isLogin===false?'block':'none'}} className={"fr mtf4 mr25"} >
<span className="font-15 fr" >
<a href="/login" className="mr5 color-white">登录</a>
<em className="vertical-line"></em>
<a href="/user_join" className="mr5 color-white">注册</a>
@ -475,7 +486,7 @@ class NewHeader extends Component {
</div>
<div className="fr head-right mr10">
<div className="fr head-right mr10 mtf20" >
<a href="javascript:void(0)" id="search-open" className="fl mr30 headIcon">
{/*"/images/educoder/icon/search.svg"
<img src={getImageUrl(`images/educoder/icon/search.svg`)} /> */}
@ -554,7 +565,7 @@ class NewHeader extends Component {
</div>
*/}
</div>
</div>
</div>
);

@ -6,7 +6,7 @@
float: left;
width: 97px;
}
.head-nav{float: left;width: 915px;text-align: center;height: 60px;box-sizing: border-box; min-width: 400px;}
.head-nav{float: left;width: 890px;text-align: center;height: 60px;box-sizing: border-box; min-width: 400px;}
.head-nav ul#header-nav{position: absolute;top: 0px;z-index: 3;height: 60px;box-sizing: border-box;}
.head-nav ul#header-nav li{float: left;height: 60px;line-height: 60px;margin-right: 30px;cursor: pointer;position: relative;font-size: 16px}
.head-nav ul#header-nav li a{display: block;height: 100%;width: 100%;color: #fff}
@ -48,7 +48,7 @@ em.vertical-line{display: inline-block;width: 2px;background: #999;height: 10px}
.search-icon path{ fill: #4CACFF;}
/* 右侧内容宽度变化的话需要调整posi-search right的值*/
.posi-search{opacity: 1;position: absolute;top: -2px;background: #fff;z-index: 2; right: -200px;}
.posi-search{opacity: 1;position: absolute;top: -2px;background: #fff;z-index: 2; right:140px}
.posi-search.unlogin{right: -161px;}
.search-content{box-sizing: border-box;position: absolute;height: 300px;background: #fff;border-radius: 0px 0px 5px 5px;width: 100%;left: 0px;top:58px;box-shadow: 0 4px 8px 0 rgba(0,0,0,.2);overflow-y: auto}
.search-title{height: 40px;line-height: 40px;padding-left: 20px;font-size: 12px;color: #bbb;text-align: left}

Loading…
Cancel
Save