@ -130,7 +130,7 @@ class ExercisesController < ApplicationController
:time = > - 1 ,
:exercise_status = > 1
}
@exercise = Exercise . create ( exercise_options )
@exercise = Exercise . create ! ( exercise_options )
rescue Exception = > e
uid_logger_error ( e . message )
tip_exception ( " 试卷创建失败! " )
@ -161,7 +161,7 @@ class ExercisesController < ApplicationController
:exercise_name = > ex_name ,
:exercise_description = > ex_desc ,
}
@exercise . update _attributes ( exercise_options )
@exercise . update ! ( exercise_options )
normal_status ( 0 , " 试卷更新成功! " )
rescue Exception = > e
uid_logger_error ( e . message )
@ -294,7 +294,7 @@ class ExercisesController < ApplicationController
begin
check_ids = Exercise . where ( id : params [ :check_ids ] )
check_ids . each do | exercise |
exercise . update _attribute( 'is_public' , true )
exercise . update !( is_public : true )
end
normal_status ( 0 , " 试卷已设为公开! " )
rescue Exception = > e
@ -318,7 +318,7 @@ class ExercisesController < ApplicationController
:description = > exercise . exercise_description ,
:course_list_id = > exercise . course . try ( :course_list_id )
}
current_ex_bank . update _attributes ( ex_params )
current_ex_bank . update ! ( ex_params )
# question_bank = QuestionBank.ques_by_container(current_ex_bank.id,current_ex_bank.container_type).first #该习题库是否存在于问题库里
# ques_params = {
# :name => current_ex_bank.name,
@ -352,7 +352,7 @@ class ExercisesController < ApplicationController
# question_bank = QuestionBank.new ques_params
# question_bank.save
# end
exercise . update _attributes !( exercise_bank_id : current_ex_bank . id )
exercise . update !( exercise_bank_id : current_ex_bank . id )
end
# 试卷的问题的输入
exercise . exercise_questions . each do | q |
@ -365,7 +365,7 @@ class ExercisesController < ApplicationController
:shixun_name = > q . shixun_name
}
exercise_bank_question = current_ex_bank . exercise_bank_questions . new option
exercise_bank_question . save
exercise_bank_question . save !
## 试卷选项的输入
if q . question_type != Exercise :: PRACTICAL #不为实训题时,试卷选项加入试题答案库
ex_choices = q . exercise_choices
@ -376,7 +376,7 @@ class ExercisesController < ApplicationController
:choice_text = > c . choice_text
}
ex_bank_choice = exercise_bank_question . exercise_bank_choices . new choice_option
ex_bank_choice . save
ex_bank_choice . save !
end
ex_standard . each do | s |
ex_stand = {
@ -384,7 +384,7 @@ class ExercisesController < ApplicationController
:answer_text = > s . answer_text
}
ex_stand_bank = exercise_bank_question . exercise_bank_standard_answers . new ex_stand
ex_stand_bank . save
ex_stand_bank . save !
end
else #当为实训题时
shixun_challenges = q . exercise_shixun_challenges
@ -396,11 +396,11 @@ class ExercisesController < ApplicationController
:question_score = > c . question_score
}
shixun_challenge_bank = exercise_bank_question . exercise_bank_shixun_challenges . new challenge_option
shixun_challenge_bank . save
shixun_challenge_bank . save !
end
end
end
current_ex_bank . save
current_ex_bank . save !
end
normal_status ( 0 , " 题库更新成功! " )
rescue Exception = > e
@ -486,7 +486,7 @@ class ExercisesController < ApplicationController
:publish_time = > params_publish_time ,
:end_time = > params_end_time
}
@exercise . update _attributes ( exercise_params )
@exercise . update ! ( exercise_params )
@exercise . exercise_group_settings . destroy_all
normal_status ( 0 , " 试卷设置成功! " )
end
@ -539,7 +539,7 @@ class ExercisesController < ApplicationController
:end_time = > exercise_end_time
}
end
the_group_setting . update _attributes !( ex_group_params )
the_group_setting . update !( ex_group_params )
end
end
if new_group_ids . size > 0
@ -590,7 +590,7 @@ class ExercisesController < ApplicationController
:publish_time = > p_time ,
:end_time = > e_time
}
@exercise . update _attributes ( exercise_params )
@exercise . update ! ( exercise_params )
if @exercise . exercise_status == Exercise :: PUBLISHED
if @exercise . course_acts . size == 0
@exercise . course_acts << CourseActivity . new ( :user_id = > @exercise . user_id , :course_id = > @exercise . course_id )
@ -629,9 +629,9 @@ class ExercisesController < ApplicationController
objective_score = @exercise . objective_score > 0 ? params [ :objective_score ] . to_f . round ( 2 ) : 0
score = subjective_score + objective_score
if exercise_user . commit_status == 1
exercise_user . update _attributes !( score : score , subjective_score : subjective_score , objective_score : objective_score )
exercise_user . update !( score : score , subjective_score : subjective_score , objective_score : objective_score )
else
exercise_user . update _attributes !( start_at : start_at_time , end_at : Time . now , status : 1 , commit_status : 1 , score : score ,
exercise_user . update !( 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 )
end
@ -777,7 +777,7 @@ class ExercisesController < ApplicationController
exercise_group_setting = exercise . exercise_group_settings . find_in_exercise_group ( " course_group_id " , i ) . first #根据课堂分班的id, 寻找试卷所在的班级
group_end_time = params [ :detail ] ? group_end_times [ index ] : ex_end_time
if exercise_group_setting . present? #如果该试卷分组存在,则更新,否则新建
exercise_group_setting . update _attributes !( publish_time : Time . now , end_time : group_end_time )
exercise_group_setting . update !( publish_time : Time . now , end_time : group_end_time )
else
p_course_group = {
:exercise_id = > exercise . id ,
@ -787,7 +787,7 @@ class ExercisesController < ApplicationController
:end_time = > group_end_time ,
}
new_exercise_group = exercise . exercise_group_settings . new p_course_group
new_exercise_group . save
new_exercise_group . save !
end
end
# group_ids = params[:group_ids]
@ -806,7 +806,7 @@ class ExercisesController < ApplicationController
:exercise_status = > ex_status ,
:unified_setting = > ex_unified
}
exercise . update _attributes ( exercise_params )
exercise . update ! ( exercise_params )
if exercise . course_acts . size == 0
exercise . course_acts << CourseActivity . new ( :user_id = > exercise . user_id , :course_id = > exercise . course_id )
@ -859,7 +859,7 @@ class ExercisesController < ApplicationController
if exercise . unified_setting && g_course . map ( & :to_i ) . sort == all_course_group_ids . sort #开始为统一设置
exercise . exercise_group_settings . destroy_all
new_ex_status = set_exercise_status ( exercise . publish_time , Time . now )
exercise . update _attributes ( :end_time = > Time . now , :exercise_status = > new_ex_status )
exercise . update ! ( :end_time = > Time . now , :exercise_status = > new_ex_status )
exercise_users = exercise . exercise_users
else
course_members_ids = course_students . course_find_by_ids ( " course_group_id " , g_course ) . pluck ( :user_id ) . uniq #该班级的全部学生
@ -878,7 +878,7 @@ class ExercisesController < ApplicationController
:publish_time = > exercise . publish_time ,
:end_time = > exercise . end_time
}
ExerciseGroupSetting . create ( ex_group_options )
ExerciseGroupSetting . create ! ( ex_group_options )
end
end
end
@ -893,17 +893,17 @@ class ExercisesController < ApplicationController
:publish_time = > exercise . publish_time ,
:end_time = > Time . now
}
ExerciseGroupSetting . create ( ex_group_options )
ExerciseGroupSetting . create ! ( ex_group_options )
end
end
new_end_time = exercise . exercise_group_settings . end_time_no_null . map ( & :end_time ) # 试卷结束时间不为空的
new_end_time_s = new_end_time . count > 0 ? new_end_time . max : Time . now
new_ex_status = set_exercise_status ( exercise . publish_time , new_end_time_s )
exercise . update _attributes ( :end_time = > new_end_time_s , :exercise_status = > new_ex_status , :unified_setting = > false )
exercise . update ! ( :end_time = > new_end_time_s , :exercise_status = > new_ex_status , :unified_setting = > false )
end
else
exercise_users = exercise . exercise_users
exercise . update _attributes ( :exercise_status = > 3 , :end_time = > Time . now , :unified_setting = > true )
exercise . update ! ( :exercise_status = > 3 , :end_time = > Time . now , :unified_setting = > true )
end
ex_user_ids = exercise_users . pluck ( :id )
@ -946,7 +946,7 @@ class ExercisesController < ApplicationController
if exercise_user . present?
if exercise_user . commit_status == 1 && @exercise . get_exercise_status ( current_user ) == Exercise :: PUBLISHED #用户已提交且试卷提交中
if @exercise . time == - 1 || ( ( Time . now . to_i - exercise_user . start_at . to_i ) < @exercise . time . to_i * 60 )
exercise_user . update _attributes ( :score = > nil , :end_at = > nil , :status = > nil , :commit_status = > 0 ,
exercise_user . update ! ( :score = > nil , :end_at = > nil , :status = > nil , :commit_status = > 0 ,
:objective_score = > 0 . 0 , :subjective_score = > - 1 . 0 )
exercise_user . user . exercise_shixun_answers . search_shixun_answers ( " exercise_question_id " , ex_question_ids ) . destroy_all
exercise_answers = exercise_user . user . exercise_answers . search_answer_users ( " exercise_question_id " , ex_question_ids )
@ -1046,7 +1046,7 @@ class ExercisesController < ApplicationController
@exercise_user_current = ex_users_current & . first
if ex_users_current . exists?
if @exercise_user_current . start_at . blank?
@exercise_user_current . update _attribute( " start_at " , Time . now )
@exercise_user_current . update !( start_at : Time . now )
end
else
if @user_course_identity > Course :: ASSISTANT_PROFESSOR #当为老师的时候, 不创建exercise_user表, 理论上老师是不能进入答题的
@ -1056,7 +1056,7 @@ class ExercisesController < ApplicationController
:start_at = > Time . now
}
exercise_user_current = ExerciseUser . new ( exercise_user_params )
exercise_user_current . save
exercise_user_current . save !
end
end
@t_user_exercise_status = @exercise . get_exercise_status ( current_user )
@ -1174,7 +1174,7 @@ class ExercisesController < ApplicationController
:subjective_score = > subjective_score ,
:commit_method = > @answer_committed_user & . commit_method . to_i > 0 ? @answer_committed_user & . commit_method . to_i : params [ :commit_method ] . to_i
}
@answer_committed_user . update _attributes !( commit_option )
@answer_committed_user . update !( commit_option )
CommitExercsieNotifyJobJob . perform_later ( @exercise . id , current_user . id )
normal_status ( 0 , " 试卷提交成功! " )
else