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

dev_hjm
杨树林 6 years ago
commit 66b0611886

@ -354,7 +354,7 @@ class ApplicationController < ActionController::Base
logger.info("--uri_exec: .....res is #{res}") logger.info("--uri_exec: .....res is #{res}")
JSON.parse(res) JSON.parse(res)
rescue Exception => e rescue Exception => e
uid_logger("--uri_exec: exception #{e.message}") uid_logger_error("--uri_exec: exception #{e.message}")
raise Educoder::TipException.new("实训平台繁忙繁忙等级84") raise Educoder::TipException.new("实训平台繁忙繁忙等级84")
end end
end end

@ -151,7 +151,7 @@ class ChallengesController < ApplicationController
def index def index
uid_logger("identifier: #{params}") uid_logger("identifier: #{params}")
@challenges = Challenge.fields_for_list.where(shixun_id: @shixun.id) @challenges = @shixun.challenges.fields_for_list
@editable = @shixun.status == 0 # before_action有判断权限如果没发布则肯定是管理人员 @editable = @shixun.status == 0 # before_action有判断权限如果没发布则肯定是管理人员
@user = current_user @user = current_user

@ -1459,7 +1459,8 @@ class HomeworkCommonsController < ApplicationController
if game_codes.count > 0 if game_codes.count > 0
code_rate += game_codes.map(&:rate).sum / challenge.path.split("").length code_rate += game_codes.map(&:rate).sum / challenge.path.split("").length
end end
target = game_codes.count > 0 ? game_codes[0].target_user_id : nil logger.info("#####game_codes: #{game_codes}")
#target = game_codes.count > 0 ? game_codes[0].target_user_id : nil
# 作品完成时间 # 作品完成时间
game = challenge.games.find_by(user_id: @user.id) game = challenge.games.find_by(user_id: @user.id)
end_time = game.end_time end_time = game.end_time
@ -1467,7 +1468,7 @@ class HomeworkCommonsController < ApplicationController
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
# 抄袭用户 # 抄袭用户
copy_user = User.find_by_id(game_codes[0].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?
# 代码部分 # 代码部分
code_list = [] code_list = []
@ -1477,7 +1478,7 @@ class HomeworkCommonsController < ApplicationController
code_list << {path: path, origin_content: info.origin_content, target_content: info.target_content} code_list << {path: path, origin_content: info.origin_content, target_content: info.target_content}
end end
end end
# TODO: 这里本来应该前端做的,但是现在页面已经刷不开了。
{code_rate: code_rate, copy_user_id: copy_user.try(:id), end_time: end_time, final_score: final_score, {code_rate: code_rate, copy_user_id: copy_user.try(:id), end_time: end_time, final_score: final_score,
all_score: all_score, copy_end_time: copy_end_time, copy_username: copy_user.try(:full_name), all_score: all_score, copy_end_time: copy_end_time, copy_username: copy_user.try(:full_name),
username: game.user.full_name, code_list: code_list, subject: challenge.subject, position: challenge.position, username: game.user.full_name, code_list: code_list, subject: challenge.subject, position: challenge.position,

@ -1,7 +1,6 @@
class Challenge < ApplicationRecord class Challenge < ApplicationRecord
# difficulty: 关卡难度: 1.简单 2.中等 3.困难 # difficulty: 关卡难度: 1.简单 2.中等 3.困难
# show_type: 效果展示:-1.无效果 1.图片 2.apk/exe 3.txt 4.html 5.mp3 6.mp4 # show_type: 效果展示:-1.无效果 1.图片 2.apk/exe 3.txt 4.html 5.mp3 6.mp4
default_scope { order("challenges.position asc") }
belongs_to :shixun, :touch => true, counter_cache: true belongs_to :shixun, :touch => true, counter_cache: true
belongs_to :user belongs_to :user

@ -5,7 +5,7 @@ class Shixun < ApplicationRecord
# hide_code 隐藏代码窗口 # hide_code 隐藏代码窗口
# code_hidden: 隐藏代码目录 # code_hidden: 隐藏代码目录
# task_pass: 跳关 # task_pass: 跳关
has_many :challenges, dependent: :destroy has_many :challenges, -> {order("challenges.position asc")}, dependent: :destroy
has_many :challenge_tags, through: :challenges has_many :challenge_tags, through: :challenges
has_many :myshixuns, :dependent => :destroy has_many :myshixuns, :dependent => :destroy
has_many :shixun_members, dependent: :destroy has_many :shixun_members, dependent: :destroy

@ -196,12 +196,14 @@ class NullEditor extends Component{
} }
onAnswerChange = (index, itemIndex, val) => { onAnswerChange = (index, itemIndex, val) => {
if (this.state.standard_answers[index]) {
this.setState( this.setState(
(prevState) => ({ (prevState) => ({
standard_answers : update(prevState.standard_answers standard_answers : update(prevState.standard_answers
, {[index]: {$splice: [[itemIndex, 1, val]]}}), , {[index]: {$splice: [[itemIndex, 1, val]]}}),
}) })
) )
}
} }
addChildAnswer = (index) => { addChildAnswer = (index) => {
this.setState( this.setState(

Loading…
Cancel
Save