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

issues25489
杨树林 5 years ago
commit aaccd0da68

@ -1512,7 +1512,7 @@ class HomeworkCommonsController < ApplicationController
end_time = game.end_time end_time = game.end_time
# 用户关卡的得分 # 用户关卡的得分
all_score = homework_challenge_settings.find_by(challenge_id: challenge.id).try(:score).to_f all_score = homework_challenge_settings.find_by(challenge_id: challenge.id).try(:score).to_f
final_score = @student_work.work_challenge_score game, all_score final_score = @student_work.work_challenge_score game, all_score, challenge.id
# 抄袭用户 # 抄袭用户
copy_user = User.find_by_id(game_codes[0].try(:target_user_id)) copy_user = User.find_by_id(game_codes[0].try(:target_user_id))
copy_end_time = copy_user.games.find_by(challenge_id: challenge.id).try(:end_time) if copy_user.present? copy_end_time = copy_user.games.find_by(challenge_id: challenge.id).try(:end_time) if copy_user.present?

@ -213,7 +213,7 @@ class MessagesController < ApplicationController
def notify_course_students message, course def notify_course_students message, course
course.students.includes(:user).each do |student| course.students.includes(:user).each do |student|
UserMailer.course_message_email(student&.user&.mail, message.id).deliver_later if student&.user&.mail UserMailer.course_message_email(student&.user&.mail, message.id).deliver_now if student&.user&.mail
end end
end end
end end

@ -464,6 +464,7 @@ class StudentWorksController < ApplicationController
@shixun = @homework.shixuns.take @shixun = @homework.shixuns.take
# 提示: 这里如果includes outputs表的话 sum(:evaluate_count)会出现错误 # 提示: 这里如果includes outputs表的话 sum(:evaluate_count)会出现错误
@games = @work.myshixun.games.joins(:challenge).reorder("challenges.position asc") if @work.myshixun @games = @work.myshixun.games.joins(:challenge).reorder("challenges.position asc") if @work.myshixun
@challenges = @shixun.challenges if @shixun
@comment = @work.shixun_work_comments.find_by(challenge_id: 0) @comment = @work.shixun_work_comments.find_by(challenge_id: 0)
# 用户最大评测次数 # 用户最大评测次数
@ -517,6 +518,7 @@ class StudentWorksController < ApplicationController
@user = @work.user @user = @work.user
@shixun = @homework.shixuns.take @shixun = @homework.shixuns.take
@games = @work.myshixun.games.includes(:challenge, :game_codes, :outputs) if @work.myshixun @games = @work.myshixun.games.includes(:challenge, :game_codes, :outputs) if @work.myshixun
@challenges = @shixun.challenges if @shixun
# 用户最大评测次数 # 用户最大评测次数
@user_evaluate_count = @games.pluck(:evaluate_count).sum if @games @user_evaluate_count = @games.pluck(:evaluate_count).sum if @games
@ -717,27 +719,35 @@ class StudentWorksController < ApplicationController
tip_exception("参数错误score和challenge_id不能为空") tip_exception("参数错误score和challenge_id不能为空")
end end
challenge_setting = @homework.homework_challenge_settings.find_by(challenge_id: params[:challenge_id]) challenge_setting = @homework.homework_challenge_settings.find_by(challenge_id: params[:challenge_id])
challenge = challenge_setting&.challenge if challenge_setting
tip_exception("不能小于零") if params[:score].to_i < 0 challenge = challenge_setting&.challenge
tip_exception("不能大于关卡分值:#{challenge_setting.score}") if challenge_setting.score < params[:score].to_i tip_exception("不能小于零") if params[:score].to_i < 0
tip_exception("不能大于关卡分值:#{challenge_setting.score}") if challenge_setting && challenge_setting.score < params[:score].to_i
ActiveRecord::Base.transaction do ActiveRecord::Base.transaction do
begin begin
if params[:type] == "review" if params[:type] == "review"
copy_user = User.find params[:copy_user_id] copy_user = User.find params[:copy_user_id]
comment = "代码查重结果显示与#{copy_user.try(:show_real_name)}的代码相似度#{params[:code_rate]}%" comment = "代码查重结果显示与#{copy_user.try(:show_real_name)}的代码相似度#{params[:code_rate]}%"
else else
comment = "根据实训报告中最终提交的代码调整第#{challenge.position}关分数" comment = "根据实训报告中最终提交的代码调整第#{challenge.position}关分数"
end
challenge_score = @work.challenge_work_scores.create(challenge_id: params[:challenge_id], user_id: current_user.id, score: params[:score],
comment: comment)
challenge_score.create_tiding current_user.id
if @work.work_status != 0 && @work.myshixun
HomeworksService.new.update_myshixun_work_score @work, @work.myshixun, @work.myshixun&.games, @homework, @homework.homework_challenge_settings
else
update_none_commit_work @work, @homework
end
rescue Exception => e
uid_logger(e.message)
tip_exception("调分失败")
raise ActiveRecord::Rollback
end end
challenge_score = @work.challenge_work_scores.create(challenge_id: params[:challenge_id], user_id: current_user.id, score: params[:score],
comment: comment)
challenge_score.create_tiding current_user.id
HomeworksService.new.update_myshixun_work_score @work, @work&.myshixun, @work&.myshixun&.games, @homework, @homework.homework_challenge_settings
rescue Exception => e
uid_logger(e.message)
tip_exception(e.message)
raise ActiveRecord::Rollback
end end
else
tip_exception("该关卡不记分")
end end
end end
@ -860,4 +870,20 @@ class StudentWorksController < ApplicationController
end end
end end
end end
def update_none_commit_work work, homework
if work.work_status == 0
work.work_status = 1
work.commit_time = homework.end_time
work.update_time = Time.now
end
final_score = 0
homework.homework_challenge_settings.each do |cha_setting|
adjust_score = work.challenge_work_scores.select{|work_score| work_score.challenge_id == cha_setting.challenge_id}.last
final_score += adjust_score.score if adjust_score.present?
end
work.final_score = final_score
work.work_score = final_score
work.save!
end
end end

@ -1,5 +1,5 @@
class TrustieHacksController < ApplicationController class TrustieHacksController < ApplicationController
before_action :require_admin, :except => [:index] before_action :require_admin, :except => [:index, :entry]
before_action :require_login, :except => [:index] before_action :require_login, :except => [:index]
before_action :find_hackathon before_action :find_hackathon
before_action :find_hack, :except => [:create, :index, :edit_hackathon, :update_hackathon] before_action :find_hack, :except => [:create, :index, :edit_hackathon, :update_hackathon]
@ -15,7 +15,7 @@ class TrustieHacksController < ApplicationController
hacks = hacks.where("name like ?", "%#{search}%") hacks = hacks.where("name like ?", "%#{search}%")
end end
@hackathon_users_count = hacks ? 0 : hacks.sum(:hack_users_count) @hackathon_users_count = hacks.blank? ? 0 : hacks.sum(:hack_users_count)
@hacks_count = hacks.count @hacks_count = hacks.count
@hacks = hacks.page(page).per(limit) @hacks = hacks.page(page).per(limit)
@ -49,10 +49,10 @@ class TrustieHacksController < ApplicationController
# 报名入口 # 报名入口
def entry def entry
if @hack.hack_users.exists?(user_id: current_user) if @hack.hack_users.exists?(user_id: current_user.id)
render_error('已经报名,请勿重复操作') render_error('已经报名,请勿重复操作')
else else
@hack.hack_users.create(user_id: current_user) @hack.hack_users.create(user_id: current_user.id)
render_ok render_ok
end end
end end

@ -19,7 +19,7 @@ module StudentWorksHelper
# 作业的开启时间 # 作业的开启时间
def myshixun_open_time game def myshixun_open_time game
game.open_time ? (format_time game.open_time) : "--" game&.open_time ? (format_time game.open_time) : "--"
end end
# 作业完成时间 # 作业完成时间
@ -29,7 +29,7 @@ module StudentWorksHelper
# 作业耗时 # 作业耗时
def time_consuming game def time_consuming game
game.end_time.blank? ? "--" : (game_spend_time game.cost_time) game&.end_time.blank? ? "--" : (game_spend_time game.cost_time)
end end
# 用户个人实训总得分user_total_score # 用户个人实训总得分user_total_score

@ -196,12 +196,12 @@ class StudentWork < ApplicationRecord
student_works_scores.where.not(reviewer_role: 3, score: nil).exists? student_works_scores.where.not(reviewer_role: 3, score: nil).exists?
end end
def work_challenge_score game, score def work_challenge_score game, score, challenge_id
game_score = 0 game_score = 0
adjust_score = challenge_work_scores.where(challenge_id: game.challenge_id).last adjust_score = challenge_work_scores.where(challenge_id: challenge_id).last
if adjust_score.present? if adjust_score.present?
game_score = adjust_score.score game_score = adjust_score.score
else elsif game.present?
setting = homework_common.homework_group_setting game.user_id setting = homework_common.homework_group_setting game.user_id
if game.status == 2 && ((game.end_time && game.end_time < setting.end_time) || (homework_common.allow_late && game.end_time && game.end_time < homework_common.late_time)) if game.status == 2 && ((game.end_time && game.end_time < setting.end_time) || (homework_common.allow_late && game.end_time && game.end_time < homework_common.late_time))
answer_open_evaluation = homework_common.homework_detail_manual.answer_open_evaluation answer_open_evaluation = homework_common.homework_detail_manual.answer_open_evaluation

@ -1,4 +1,5 @@
class TrustieHack < ApplicationRecord class TrustieHack < ApplicationRecord
validates_length_of :description, maximum: 500
has_many :hack_users, :dependent => :destroy has_many :hack_users, :dependent => :destroy
belongs_to :trustie_hackathon, counter_cache: true belongs_to :trustie_hackathon, counter_cache: true

@ -1,5 +1,5 @@
class TrustieHackathon < ApplicationRecord class TrustieHackathon < ApplicationRecord
validates_length_of :description, maximum: 500
has_many :trustie_hacks, :dependent => :destroy has_many :trustie_hacks, :dependent => :destroy
end end

@ -76,22 +76,23 @@
<th>调分</th> <th>调分</th>
</thead> </thead>
<tbody> <tbody>
<% @games.each_with_index do |game, index| %> <% @challenges.each_with_index do |challenge, index| %>
<% challenge_score = @homework.challenge_score game.challenge_id %> <% challenge_score = @homework.challenge_score challenge.id %>
<% game_score = @work.work_challenge_score game, challenge_score %> <% game = @games.select{|game| game.challenge_id == challenge.id}.first if @games %>
<% game_score = @work.work_challenge_score game, challenge_score, challenge.id %>
<tr> <tr>
<td><%= index + 1 %></td> <td><%= index + 1 %></td>
<td style="text-align: left;"> <td style="text-align: left;">
<span class="task-hide edu-info-dark fl"><%= game.challenge.subject %></span> <span class="task-hide edu-info-dark fl"><%= challenge.subject %></span>
<% if ((Time.now > @homework.end_time) && game.end_time.blank?) || (game.end_time.present? && game.end_time > @homework.end_time) %> <% if game && (((Time.now > @homework.end_time) && game.end_time.blank?) || (game.end_time.present? && game.end_time > @homework.end_time)) %>
<span class="delay ml10">延时</span> <span class="delay ml10">延时</span>
<% end %> <% end %>
</td> </td>
<td><%= myshixun_open_time(game) %></td> <td><%= myshixun_open_time(game) %></td>
<td><%= game.evaluate_count %></td> <td><%= game ? game&.evaluate_count : 0 %></td>
<td><%= finished_time game.end_time %></td> <td><%= game ? finished_time(game.end_time) : "--" %></td>
<td><%= ApplicationController.helpers.time_consuming game %></td> <td><%= ApplicationController.helpers.time_consuming game %></td>
<td><%= game.final_score %> / <%= game.challenge.all_score %></td> <td><%= game ? game.final_score : 0 %> / <%= challenge.all_score %></td>
<td><span class="color-orange"><%= game_score %></span> / <%= challenge_score %></td> <td><span class="color-orange"><%= game_score %></span> / <%= challenge_score %></td>
<td><%= game_score %></td> <td><%= game_score %></td>
</tr> </tr>

@ -7,40 +7,41 @@ if @shixun
json.shixun_name @shixun.name json.shixun_name @shixun.name
# 总体评价 # 总体评价
json.overall_appraisal @work.overall_appraisal json.overall_appraisal @work.overall_appraisal
json.myself_experience @work.myshixun.try(:total_score) json.myself_experience @work.myshixun.try(:total_score).to_i
json.total_experience @shixun.all_score json.total_experience @shixun.all_score
json.work_score number_with_precision @work.work_score, precision: 1 json.work_score number_with_precision @work.work_score.to_f.round(2), precision: 1
json.all_work_score number_with_precision 100, precision: 1 json.all_work_score number_with_precision 100, precision: 1
json.time_consuming @work.myshixun_consume json.time_consuming @work.myshixun_consume
json.evaluate_count @user_evaluate_count.to_i json.evaluate_count @user_evaluate_count.to_i
if @homework.work_efficiency if @homework.work_efficiency
json.eff_score_full number_with_precision @homework.eff_score, precision: 1 json.eff_score_full number_with_precision @homework.eff_score, precision: 1
json.eff_score number_with_precision @work.eff_score, precision: 1 json.eff_score number_with_precision @work.eff_score.to_f.round(2), precision: 1
json.challenge_score_full number_with_precision (100 - @homework.eff_score), precision: 1 json.challenge_score_full number_with_precision (100 - @homework.eff_score), precision: 1
json.challenge_score number_with_precision @work.final_score, precision: 1 json.challenge_score number_with_precision @work.final_score.to_f.round(2), precision: 1
end end
# 阶段成绩 # 阶段成绩
json.stage_list do json.stage_list do
json.array! @games do |game| json.array! @challenges do |challenge|
json.name game.challenge.subject json.name challenge.subject
json.is_delay student_work_is_delay?(@homework, game) game = @games.select{|game| game.challenge_id == challenge.id}.first if @games
json.is_delay game ? student_work_is_delay?(@homework, game) : false
json.open_time myshixun_open_time game json.open_time myshixun_open_time game
json.evaluate_count game.evaluate_count json.evaluate_count game ? game&.evaluate_count : 0
json.finished_time finished_time game.end_time json.finished_time game ? finished_time(game.end_time) : "--"
json.time_consuming time_consuming game json.time_consuming time_consuming game
json.myself_experience game.final_score json.myself_experience game ? game&.final_score : 0
json.experience game.challenge.all_score json.experience challenge.all_score
json.complete_status game_status(game, @homework) json.complete_status game ? game_status(game, @homework) : 0
json.challenge_id game.challenge_id json.challenge_id challenge.id
challenge_score = @homework.challenge_score game.challenge_id challenge_score = @homework.challenge_score challenge.id
json.game_score_full challenge_score json.game_score_full challenge_score
json.game_score @work.work_challenge_score game, challenge_score json.game_score @work.work_challenge_score game, challenge_score, challenge.id
challenge_comment = @work.shixun_work_comments.find_by(challenge_id: game.challenge_id) challenge_comment = @work.shixun_work_comments.find_by(challenge_id: challenge.id)
json.challenge_comment challenge_comment&.comment json.challenge_comment challenge_comment&.comment
json.challenge_comment_hidden @user_course_identity < Course::STUDENT ? challenge_comment&.hidden_comment : nil json.challenge_comment_hidden @user_course_identity < Course::STUDENT ? challenge_comment&.hidden_comment : nil
json.comment_id challenge_comment&.id json.comment_id challenge_comment&.id
json.view_answer game.answer_open != 0 json.view_answer game ? game.answer_open != 0 : 0
end end
end end
@ -52,7 +53,7 @@ if @shixun
json.username @user.real_name json.username @user.real_name
json.student_id @user.student_id json.student_id @user.student_id
json.image_url url_to_avatar(@user) json.image_url url_to_avatar(@user)
json.complete_count @work.myshixun&.passed_count json.complete_count @work.myshixun&.passed_count.to_i
json.challenges_count @shixun.challenges_count json.challenges_count @shixun.challenges_count
json.efficiency @homework.work_efficiency ? number_with_precision(@work.efficiency, precision: 2) : nil json.efficiency @homework.work_efficiency ? number_with_precision(@work.efficiency, precision: 2) : nil
json.max_efficiency @homework.work_efficiency ? number_with_precision(@homework.max_efficiency, precision: 2) : nil json.max_efficiency @homework.work_efficiency ? number_with_precision(@homework.max_efficiency, precision: 2) : nil

@ -0,0 +1,6 @@
class ModifyDescriotionLimitForHacks < ActiveRecord::Migration[5.2]
def change
change_column :trustie_hackathons, :description, :text
change_column :trustie_hacks, :description, :text
end
end
Loading…
Cancel
Save