|
|
|
@ -101,7 +101,9 @@ class ExerciseController < ApplicationController
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
if @exercise_user.commit_status == 1 && @exercise.end_time > Time.now
|
|
|
|
|
member = @exercise.course.members.where(:user_id => User.current.id).first if @exercise_user.commit_status == 1
|
|
|
|
|
setting_time = exercise_group_setting @exercise, member.try(:course_group) if @exercise_user.commit_status == 1
|
|
|
|
|
if @exercise_user.commit_status == 1 && setting_time.end_time > Time.now
|
|
|
|
|
if @exercise.time == -1
|
|
|
|
|
@cancel_commit = true
|
|
|
|
|
else
|
|
|
|
@ -1024,25 +1026,34 @@ class ExerciseController < ApplicationController
|
|
|
|
|
|
|
|
|
|
def cancel_commit_confirm
|
|
|
|
|
exercise_user = @exercise.exercise_users.where(:user_id => User.current.id).first
|
|
|
|
|
if exercise_user.present? && exercise_user.commit_status == 1 && @exercise.end_time > Time.now
|
|
|
|
|
if @exercise.time == -1
|
|
|
|
|
@end_time = @exercise.end_time.strftime("%Y-%m-%d %H:%M")
|
|
|
|
|
elsif (Time.now.to_i - exercise_user.start_at.to_i) < @exercise.time.to_i * 60
|
|
|
|
|
time = Time.at(exercise_user.start_at.to_i + @exercise.time.to_i * 60) > @exercise.end_time ? @exercise.end_time : Time.at(exercise_user.start_at.to_i + @exercise.time.to_i * 60)
|
|
|
|
|
@end_time = time.strftime("%Y-%m-%d %H:%M")
|
|
|
|
|
if exercise_user.present? && exercise_user.commit_status == 1
|
|
|
|
|
member = @exercise.course.members.where(:user_id => User.current.id).first
|
|
|
|
|
setting_time = exercise_group_setting @exercise, member.try(:course_group)
|
|
|
|
|
if setting_time.end_time > Time.now
|
|
|
|
|
if @exercise.time == -1
|
|
|
|
|
@end_time = @exercise.end_time.strftime("%Y-%m-%d %H:%M")
|
|
|
|
|
elsif (Time.now.to_i - exercise_user.start_at.to_i) < @exercise.time.to_i * 60
|
|
|
|
|
time = Time.at(exercise_user.start_at.to_i + @exercise.time.to_i * 60) > @exercise.end_time ? @exercise.end_time : Time.at(exercise_user.start_at.to_i + @exercise.time.to_i * 60)
|
|
|
|
|
@end_time = time.strftime("%Y-%m-%d %H:%M")
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def cancel_commit
|
|
|
|
|
exercise_user = @exercise.exercise_users.where(:user_id => User.current.id).first
|
|
|
|
|
if exercise_user.present? && exercise_user.commit_status == 1 && @exercise.end_time > Time.now
|
|
|
|
|
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, :objective_score => -1, :subjective_score => -1)
|
|
|
|
|
exercise_user.user.exercise_shixun_answers.where(:exercise_question_id => @exercise.exercise_questions.map(&:id)).destroy_all
|
|
|
|
|
exercise_answers = exercise_user.user.exercise_answer.where(:exercise_question_id => @exercise.exercise_questions.map(&:id))
|
|
|
|
|
exercise_answers.update_all(:score => -1)
|
|
|
|
|
ExerciseAnswerComment.where(:exercise_question_id => @exercise.exercise_questions.map(&:id), :exercise_answer_id => exercise_answers.pluck(:id)).destroy_all
|
|
|
|
|
|
|
|
|
|
if exercise_user.present? && exercise_user.commit_status == 1
|
|
|
|
|
member = @exercise.course.members.where(:user_id => User.current.id).first
|
|
|
|
|
setting_time = exercise_group_setting @exercise, member.try(:course_group)
|
|
|
|
|
if setting_time.end_time > Time.now
|
|
|
|
|
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, :objective_score => -1, :subjective_score => -1)
|
|
|
|
|
exercise_user.user.exercise_shixun_answers.where(:exercise_question_id => @exercise.exercise_questions.map(&:id)).destroy_all
|
|
|
|
|
exercise_answers = exercise_user.user.exercise_answer.where(:exercise_question_id => @exercise.exercise_questions.map(&:id))
|
|
|
|
|
exercise_answers.update_all(:score => -1)
|
|
|
|
|
ExerciseAnswerComment.where(:exercise_question_id => @exercise.exercise_questions.map(&:id), :exercise_answer_id => exercise_answers.pluck(:id)).destroy_all
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
redirect_to student_exercise_list_exercise_path(@exercise)
|
|
|
|
|