|  |  |  | @ -612,13 +612,27 @@ class ExercisesController < ApplicationController | 
			
		
	
		
			
				
					|  |  |  |  |   def adjust_score | 
			
		
	
		
			
				
					|  |  |  |  |     exercise_user = @exercise.exercise_users.find_by!(user_id: params[:user_id]) | 
			
		
	
		
			
				
					|  |  |  |  |     tip_exception("已提交的作品请去评阅页进行调分") if exercise_user.commit_status == 1 | 
			
		
	
		
			
				
					|  |  |  |  |     tip_exception("分数不能为空") if params[:score].blank? | 
			
		
	
		
			
				
					|  |  |  |  |     tip_exception("分数不能超过0-#{@exercise.question_scores}") if params[:score].to_f < 0 || params[:score].to_f.round(1) > @exercise.question_scores.round(1) | 
			
		
	
		
			
				
					|  |  |  |  |     if @exercise.subjective_score > 0 | 
			
		
	
		
			
				
					|  |  |  |  |       tip_exception("主观题成绩不能为空") if params[:subject_score].blank? | 
			
		
	
		
			
				
					|  |  |  |  |       tip_exception("主观题成绩不能小于零") if params[:subject_score].to_f < 0 | 
			
		
	
		
			
				
					|  |  |  |  |       tip_exception("主观题成绩不能大于总分值:#{@exercise.subjective_score}分") if params[:subject_score].to_f.round(1) > @exercise.subjective_score.round(1) | 
			
		
	
		
			
				
					|  |  |  |  |     end | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |     if @exercise.objective_score > 0 | 
			
		
	
		
			
				
					|  |  |  |  |       tip_exception("客观题成绩不能为空") if params[:objective_score].blank? | 
			
		
	
		
			
				
					|  |  |  |  |       tip_exception("客观题成绩不能小于零") if params[:objective_score].to_f < 0 | 
			
		
	
		
			
				
					|  |  |  |  |       tip_exception("客观题成绩不能大于总分值:#{@exercise.objective_score}分") if params[:objective_score].to_f.round(1) > @exercise.objective_score.round(1) | 
			
		
	
		
			
				
					|  |  |  |  |     end | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |     ActiveRecord::Base.transaction do | 
			
		
	
		
			
				
					|  |  |  |  |       start_at_time = exercise_user.start_at || Time.now | 
			
		
	
		
			
				
					|  |  |  |  |       exercise_user.update_attributes!(start_at: start_at_time, end_at: Time.now, status: 1, commit_status: 1, score: params[:score].to_f.round(2), commit_method: 5) | 
			
		
	
		
			
				
					|  |  |  |  |       ExerciseUserScore.create!(exercise_id: @exercise.id, exercise_user_id: exercise_user.id, score: params[:score], comment: params[:comment]) | 
			
		
	
		
			
				
					|  |  |  |  |       subjective_score = @exercise.subjective_score > 0 ? params[:subject_score].to_f.round(2) : 0 | 
			
		
	
		
			
				
					|  |  |  |  |       objective_score = @exercise.objective_score > 0 ? params[:objective_score].to_f.round(2) : 0 | 
			
		
	
		
			
				
					|  |  |  |  |       score = subjective_score + objective_score | 
			
		
	
		
			
				
					|  |  |  |  |       exercise_user.update_attributes!(start_at: start_at_time, end_at: Time.now, status: 1, commit_status: 1, score: score, | 
			
		
	
		
			
				
					|  |  |  |  |                                        subjective_score: subjective_score, objective_score: objective_score, commit_method: 5) | 
			
		
	
		
			
				
					|  |  |  |  |       ExerciseUserScore.create!(exercise_id: @exercise.id, exercise_user_id: exercise_user.id, | 
			
		
	
		
			
				
					|  |  |  |  |                                 subjective_score: subjective_score, objective_score: objective_score) | 
			
		
	
		
			
				
					|  |  |  |  |       normal_status("操作成功") | 
			
		
	
		
			
				
					|  |  |  |  |     end | 
			
		
	
		
			
				
					|  |  |  |  |   end | 
			
		
	
	
		
			
				
					|  |  |  | 
 |