|
|
@ -81,12 +81,11 @@ class ExerciseController < ApplicationController
|
|
|
|
@can_edit_excercise = can_edit_exercise @exercise, @exercise_user
|
|
|
|
@can_edit_excercise = can_edit_exercise @exercise, @exercise_user
|
|
|
|
if !@can_edit_excercise && !@exercise_user.status
|
|
|
|
if !@can_edit_excercise && !@exercise_user.status
|
|
|
|
time = (@exercise_user.start_at.to_i + @exercise.time.to_i * 60) > @exercise.end_time.to_i ? @exercise.end_time : Time.at(@exercise_user.start_at.to_i + @exercise.time.to_i * 60)
|
|
|
|
time = (@exercise_user.start_at.to_i + @exercise.time.to_i * 60) > @exercise.end_time.to_i ? @exercise.end_time : Time.at(@exercise_user.start_at.to_i + @exercise.time.to_i * 60)
|
|
|
|
@exercise_user.update_attributes(:status => true, :end_at => time, :commit_status => 1)
|
|
|
|
|
|
|
|
s_score = calculate_student_score(@exercise, @exercise_user.user)
|
|
|
|
s_score = calculate_student_score(@exercise, @exercise_user.user)
|
|
|
|
@exercise_user.update_attributes(:objective_score => s_score, :score => (s_score + (@exercise_user.subjective_score && @exercise_user.subjective_score > 0 ? @exercise_user.subjective_score : 0)))
|
|
|
|
sub_score = @exercise_user.user.exercise_answer.where(:exercise_question_id => @exercise.exercise_questions.where(:question_type => 4).map(&:id)).empty? ? 0 : @exercise_user.subjective_score
|
|
|
|
if @exercise_user.user.exercise_answer.where(:exercise_question_id => @exercise.exercise_questions.where(:question_type => 4).map(&:id)).empty?
|
|
|
|
total_score = s_score + (sub_score && sub_score > 0 ? sub_score : 0)
|
|
|
|
@exercise_user.update_attributes(:subjective_score => 0)
|
|
|
|
@exercise_user.update_attributes(:status => true, :end_at => time, :commit_status => 1, :objective_score => s_score,
|
|
|
|
end
|
|
|
|
:subjective_score => sub_score, :score => total_score)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
if @exercise_user.commit_status == 1 && @exercise.end_time > Time.now
|
|
|
|
if @exercise_user.commit_status == 1 && @exercise.end_time > Time.now
|
|
|
@ -313,12 +312,11 @@ class ExerciseController < ApplicationController
|
|
|
|
@exercise.exercise_status = 3
|
|
|
|
@exercise.exercise_status = 3
|
|
|
|
@exercise.exercise_users.each do |exercise_user|
|
|
|
|
@exercise.exercise_users.each do |exercise_user|
|
|
|
|
if exercise_user.commit_status == 0 && !exercise_user.start_at.nil?
|
|
|
|
if exercise_user.commit_status == 0 && !exercise_user.start_at.nil?
|
|
|
|
exercise_user.update_attributes(:commit_status => 1, :end_at => params[:exercise_end_time], :status => true)
|
|
|
|
|
|
|
|
s_score = calculate_student_score(@exercise, exercise_user.user)
|
|
|
|
s_score = calculate_student_score(@exercise, exercise_user.user)
|
|
|
|
exercise_user.update_attributes(:objective_score => s_score, :score => (s_score + (exercise_user.subjective_score && exercise_user.subjective_score > 0 ? exercise_user.subjective_score : 0)))
|
|
|
|
sub_score = exercise_user.user.exercise_answer.where(:exercise_question_id => @exercise.exercise_questions.where(:question_type => 4).map(&:id)).empty? ? 0 : exercise_user.subjective_score
|
|
|
|
if exercise_user.user.exercise_answer.where(:exercise_question_id => @exercise.exercise_questions.where(:question_type => 4).map(&:id)).empty?
|
|
|
|
total_score = s_score + (sub_score && sub_score > 0 ? sub_score : 0)
|
|
|
|
exercise_user.update_attributes(:subjective_score => 0)
|
|
|
|
exercise_user.update_attributes(:commit_status => 1, :end_at => params[:exercise_end_time], :status => true, :objective_score => s_score,
|
|
|
|
end
|
|
|
|
:subjective_score => sub_score, :score => total_score)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
elsif @exercise.end_time > Time.now && @exercise.exercise_status == 3
|
|
|
|
elsif @exercise.end_time > Time.now && @exercise.exercise_status == 3
|
|
|
@ -373,7 +371,7 @@ class ExerciseController < ApplicationController
|
|
|
|
:question_title => question_title,
|
|
|
|
:question_title => question_title,
|
|
|
|
:question_type => params[:question_type] || 1,
|
|
|
|
:question_type => params[:question_type] || 1,
|
|
|
|
:question_number => @exercise.exercise_questions.count + 1,
|
|
|
|
:question_number => @exercise.exercise_questions.count + 1,
|
|
|
|
:question_score => params[:question_score],
|
|
|
|
:question_score => params[:question_type] == '5' ? 0 : params[:question_score],
|
|
|
|
:shixun_id => params[:shixun]
|
|
|
|
:shixun_id => params[:shixun]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@exercise_questions = @exercise.exercise_questions.new option
|
|
|
|
@exercise_questions = @exercise.exercise_questions.new option
|
|
|
@ -766,12 +764,10 @@ class ExerciseController < ApplicationController
|
|
|
|
exercise_users.each do |exercise_user|
|
|
|
|
exercise_users.each do |exercise_user|
|
|
|
|
if exercise_user.commit_status == 0 && !exercise_user.start_at.nil?
|
|
|
|
if exercise_user.commit_status == 0 && !exercise_user.start_at.nil?
|
|
|
|
time = (exercise_user.start_at.to_i + @exercise.time.to_i * 60) > @exercise.end_time.to_i ? @exercise.end_time : Time.at(exercise_user.start_at.to_i + @exercise.time.to_i * 60)
|
|
|
|
time = (exercise_user.start_at.to_i + @exercise.time.to_i * 60) > @exercise.end_time.to_i ? @exercise.end_time : Time.at(exercise_user.start_at.to_i + @exercise.time.to_i * 60)
|
|
|
|
exercise_user.update_attributes(:status => 1, :commit_status => 1, :end_at => time)
|
|
|
|
|
|
|
|
s_score = calculate_student_score(@exercise, exercise_user.user)
|
|
|
|
s_score = calculate_student_score(@exercise, exercise_user.user)
|
|
|
|
exercise_user.update_attributes(:objective_score => s_score, :score => (s_score + (exercise_user.subjective_score && exercise_user.subjective_score > 0 ? exercise_user.subjective_score : 0)))
|
|
|
|
sub_score = exercise_user.user.exercise_answer.where(:exercise_question_id => @exercise.exercise_questions.where(:question_type => 4).map(&:id)).empty? ? 0 : exercise_user.subjective_score
|
|
|
|
if exercise_user.user.exercise_answer.where(:exercise_question_id => @exercise.exercise_questions.where(:question_type => 4).map(&:id)).empty?
|
|
|
|
exercise_user.update_attributes(:status => 1, :commit_status => 1, :end_at => time, :objective_score => s_score, :subjective_score => sub_score,
|
|
|
|
exercise_user.update_attributes(:subjective_score => 0)
|
|
|
|
:score => (s_score + (exercise_user.subjective_score && exercise_user.subjective_score > 0 ? exercise_user.subjective_score : 0)))
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
#end
|
|
|
|
#end
|
|
|
@ -827,23 +823,20 @@ class ExerciseController < ApplicationController
|
|
|
|
setting_time = exercise_group_setting @exercise, member.try(:course_group)
|
|
|
|
setting_time = exercise_group_setting @exercise, member.try(:course_group)
|
|
|
|
if ((Time.now.to_i - exercise_user.start_at.to_i) > @exercise.time.to_i * 60) || setting_time.end_time < Time.now
|
|
|
|
if ((Time.now.to_i - exercise_user.start_at.to_i) > @exercise.time.to_i * 60) || setting_time.end_time < Time.now
|
|
|
|
time = (exercise_user.start_at.to_i + @exercise.time.to_i * 60) > setting_time.end_time.to_i ? setting_time.end_time : Time.at(exercise_user.start_at.to_i + @exercise.time.to_i * 60)
|
|
|
|
time = (exercise_user.start_at.to_i + @exercise.time.to_i * 60) > setting_time.end_time.to_i ? setting_time.end_time : Time.at(exercise_user.start_at.to_i + @exercise.time.to_i * 60)
|
|
|
|
exercise_user.update_attributes(:commit_status => 1, :end_at => time, :status => true)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
s_score = calculate_student_score(@exercise, exercise_user.user)
|
|
|
|
s_score = calculate_student_score(@exercise, exercise_user.user)
|
|
|
|
exercise_user.update_attributes(:objective_score => s_score, :score => (s_score + (exercise_user.subjective_score && exercise_user.subjective_score > 0 ? exercise_user.subjective_score : 0)))
|
|
|
|
sub_score = exercise_user.user.exercise_answer.where(:exercise_question_id => @exercise.exercise_questions.where(:question_type => 4).map(&:id)).empty? ? 0 : exercise_user.subjective_score
|
|
|
|
if exercise_user.user.exercise_answer.where(:exercise_question_id => @exercise.exercise_questions.where(:question_type => 4).map(&:id)).empty?
|
|
|
|
total_score = s_score + (sub_score && sub_score > 0 ? sub_score : 0)
|
|
|
|
exercise_user.update_attributes(:subjective_score => 0)
|
|
|
|
exercise_user.update_attributes(:commit_status => 1, :end_at => time, :status => true, :objective_score => s_score,
|
|
|
|
end
|
|
|
|
:subjective_score => sub_score, :score => total_score)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
@exercise.exercise_users.where("commit_status = 1 and score is null").each do |exercise_user|
|
|
|
|
@exercise.exercise_users.where("commit_status = 1 and score is null").each do |exercise_user|
|
|
|
|
s_score = calculate_student_score(@exercise, exercise_user.user)
|
|
|
|
s_score = calculate_student_score(@exercise, exercise_user.user)
|
|
|
|
exercise_user.update_attributes(:objective_score => s_score, :score => (s_score + (exercise_user.subjective_score && exercise_user.subjective_score > 0 ? exercise_user.subjective_score : 0)))
|
|
|
|
sub_score = exercise_user.user.exercise_answer.where(:exercise_question_id => @exercise.exercise_questions.where(:question_type => 4).map(&:id)).empty? ? 0 : exercise_user.subjective_score
|
|
|
|
if exercise_user.user.exercise_answer.where(:exercise_question_id => @exercise.exercise_questions.where(:question_type => 4).map(&:id)).empty?
|
|
|
|
total_score = s_score + (sub_score && sub_score > 0 ? sub_score : 0)
|
|
|
|
exercise_user.update_attributes(:subjective_score => 0)
|
|
|
|
exercise_user.update_attributes(:objective_score => s_score, :subjective_score => sub_score, :score => total_score)
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
@group_teacher = @is_teacher && @member.present? && @member.teacher_course_groups.count > 0
|
|
|
|
@group_teacher = @is_teacher && @member.present? && @member.teacher_course_groups.count > 0
|
|
|
@ -1119,13 +1112,12 @@ class ExerciseController < ApplicationController
|
|
|
|
|
|
|
|
|
|
|
|
# 试卷未截止且试卷未提交过才能提交
|
|
|
|
# 试卷未截止且试卷未提交过才能提交
|
|
|
|
if @exercise.exercise_status == 2 && cur_exercise_user.present? && cur_exercise_user.commit_status == 0
|
|
|
|
if @exercise.exercise_status == 2 && cur_exercise_user.present? && cur_exercise_user.commit_status == 0
|
|
|
|
cur_exercise_user.update_attributes(:status => 1, :commit_status => 1, :end_at => Time.now)
|
|
|
|
|
|
|
|
#if @exercise.time && @exercise.time != -1
|
|
|
|
#if @exercise.time && @exercise.time != -1
|
|
|
|
score = calculate_student_score(@exercise, User.current)
|
|
|
|
score = calculate_student_score(@exercise, User.current)
|
|
|
|
cur_exercise_user.update_attributes(:objective_score => score, :score => score + (cur_exercise_user.subjective_score > 0 ? cur_exercise_user.subjective_score : 0))
|
|
|
|
sub_score = User.current.exercise_answer.where(:exercise_question_id => @exercise.exercise_questions.where(:question_type => 4).map(&:id)).empty? ? 0 : cur_exercise_user.subjective_score
|
|
|
|
if User.current.exercise_answer.where(:exercise_question_id => @exercise.exercise_questions.where(:question_type => 4).map(&:id)).empty?
|
|
|
|
total_score = score + (sub_score && sub_score > 0 ? sub_score : 0)
|
|
|
|
cur_exercise_user.update_attributes(:subjective_score => 0)
|
|
|
|
cur_exercise_user.update_attributes(:status => 1, :commit_status => 1, :end_at => Time.now, :objective_score => score,
|
|
|
|
end
|
|
|
|
:subjective_score => sub_score, :score => total_score)
|
|
|
|
|
|
|
|
|
|
|
|
# 提交后给老师和助教发消息
|
|
|
|
# 提交后给老师和助教发消息
|
|
|
|
tid_str = ""
|
|
|
|
tid_str = ""
|
|
|
|