@ -278,7 +278,7 @@ class GamesService
is_teacher = ( current_user . user_extensions . identity == 0 )
is_certification_teacher = current_user . is_certification_teacher
# 这几种情况可以直接查看答案的:实训未发布;当前用户为实训管理员;已经查看过答案;平台认证的老师;
if ( @shixun . status < 2 || shixun_manager ( @shixun , current_user ) || @game . answer_open == 1 || is_certification_teacher )
if ( @shixun . status < 2 || shixun_manager ( @shixun , current_user ) || @game . answer_open || is_certification_teacher )
Rails . logger . info ( " answer #{ params [ :identifier ] } # # # # user is #{ current_user . id } , status is #{ @shixun . status } , manager is #{ shixun_manager ( @shixun , current_user ) } , open #{ @game . answer_open } , cer #{ is_certification_teacher } " )
if challenge . st == 0
result = challenge . try ( :answer )
@ -303,7 +303,7 @@ class GamesService
challenge_score = challenge . try ( :score )
final_score = @game . final_score
if current_user . grade . to_i - challenge_score > 0
if @game . answer_open == 0 # 如果这是第一次查看答案
if ! @game . answer_open # 如果这是第一次查看答案
if challenge . st == 0
final_score = final_score - challenge_score
# 积分消耗情况记录
@ -530,7 +530,7 @@ class GamesService
game = Game . select ( [ :myshixun_id , :status , :challenge_id , :id , :evaluate_count ] ) . find_by_identifier ( params [ :identifier ] )
myshixun = Myshixun . select ( [ :updated_at , :gpid , :id , :shixun_id ] ) . find ( game . myshixun_id )
shixun = Shixun . select ( [ :id , :evaluate_script , :webssh , :exec_time , :sigle_training , :identifier , :status ] ) . find ( myshixun . shixun_id )
game_challenge = Challenge . select ( [ :id , :position , :picture_path ] ) . find ( game . challenge_id )
game_challenge = Challenge . select ( [ :id , :position , :picture_path , :exec_time ] ) . find ( game . challenge_id )
# 更新评测次数
game . update_column ( :evaluate_count , ( game . evaluate_count . to_i + 1 ) )
@ -573,7 +573,7 @@ class GamesService
params = { :tpiID = > " #{ myshixun . id } " , :tpiGitURL = > " #{ gitUrl } " , :buildID = > " #{ taskId } " , :instanceChallenge = > " #{ step } " ,
:testCases = > " #{ testCases } " , :resubmit = > " #{ resubmit } " , :times = > params [ :first ] . to_i , :podType = > shixun . webssh ,
:containers = > " #{ Base64 . urlsafe_encode64 ( shixun_container_limit ( shixun ) ) } " , :tpmScript = > " #{ tpmScript } " ,
:timeLimit = > " #{ shixun . exec_time } " , :content_modified = > content_modified , :persistenceName = > shixun . identifier ,
:timeLimit = > " #{ game_challenge . exec_time } " , :content_modified = > content_modified , :persistenceName = > shixun . identifier ,
:isPublished = > ( shixun . status < 2 ? 0 : 1 ) , :sec_key = > params [ :sec_key ] }
# 评测有文件输出的需要特殊传字段 path: 表示文件存储的位置
@ -749,7 +749,7 @@ class GamesService
if had_passed && ! game . had_passed?
game . update_attributes ( :status = > 2 , :end_time = > Time . now )
# TPM实训已发布并且没有查看答案
if shixun . is_published? && game . answer_open == 0
if shixun . is_published? && ! game . answer_open
# 查看答案的时候处理final_scor和扣分记录
experience = score
reward_grade ( myshixun . owner , game . id , 'Game' , score )
@ -853,7 +853,7 @@ class GamesService
if game_status == 2 # 通关
if shixun . status > 1
score = game . final_score # 查看答案的时候有对最终获得金币进行处理
experience = game . answer_open > 0 ? 0 : game_challenge . score . to_i
experience = game . answer_open ? 0 : game_challenge . score . to_i
else
score = 0
experience = 0