diff --git a/app/controllers/competitions_controller.rb b/app/controllers/competitions_controller.rb index e6112539..43181d8c 100644 --- a/app/controllers/competitions_controller.rb +++ b/app/controllers/competitions_controller.rb @@ -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 第一阶段:1185,1197,1195 第二阶段:1202, 1210, 1207 第三阶段:1254,1255,1243 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 diff --git a/app/controllers/managements_controller.rb b/app/controllers/managements_controller.rb index 06b29c9f..7e3b3eb0 100644 --- a/app/controllers/managements_controller.rb +++ b/app/controllers/managements_controller.rb @@ -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 diff --git a/app/models/course_member.rb b/app/models/course_member.rb index 8de272a4..d67994ef 100644 --- a/app/models/course_member.rb +++ b/app/models/course_member.rb @@ -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 diff --git a/app/views/competitions/charts.html.erb b/app/views/competitions/charts.html.erb index 29a24b35..5fdbafff 100644 --- a/app/views/competitions/charts.html.erb +++ b/app/views/competitions/charts.html.erb @@ -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" %>
@@ -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 %>
  • "><%= stage.name %>排行榜
  • <% end %> diff --git a/public/react/src/index.js b/public/react/src/index.js index 55cebf17..73bc2829 100644 --- a/public/react/src/index.js +++ b/public/react/src/index.js @@ -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参考来控制 diff --git a/public/react/src/modules/tpm/NewHeader.js b/public/react/src/modules/tpm/NewHeader.js index af2b7fb6..4f656269 100644 --- a/public/react/src/modules/tpm/NewHeader.js +++ b/public/react/src/modules/tpm/NewHeader.js @@ -305,12 +305,11 @@ class NewHeader extends Component { }else{ 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 (
    @@ -352,7 +351,7 @@ class NewHeader extends Component {
    - + {ImageUrlType===true?高校智能化教学与实训平台:高校智能化教学与实训平台}
    @@ -401,51 +400,52 @@ class NewHeader extends Component {
  • 交流问答
  • {ecUrl===null||ecUrl===undefined||ecUrl===""?'':'工程认证'}
  • - - +
    -
    +
    @@ -465,9 +465,20 @@ class NewHeader extends Component {
    - -
    - + +
    + 登录 注册 @@ -475,7 +486,7 @@ class NewHeader extends Component {
    -
    + */}
    -
    +
    ); diff --git a/public/stylesheets/educoder/edu-all.css b/public/stylesheets/educoder/edu-all.css index 0eafefc0..2a185e56 100644 --- a/public/stylesheets/educoder/edu-all.css +++ b/public/stylesheets/educoder/edu-all.css @@ -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}