Merge branch 'dev_aliyun' of http://bdgit.educoder.net/Hjqreturn/educoder into dev_aliyun

dev_course
cxt 5 years ago
commit 2ae3afa6b6

@ -355,9 +355,9 @@ module ExercisesHelper
exercise_questions = exercise.exercise_questions.includes(:exercise_answers,:exercise_shixun_answers,:exercise_standard_answers,:exercise_shixun_challenges)
exercise_questions.each do |q|
if q.question_type != 5
answers_content = q.exercise_answers.search_answer_users("user_id",user.id) #学生的答案
answers_content = q.exercise_answers.where(user_id: user.id) #学生的答案
else
answers_content = q.exercise_shixun_answers.search_shixun_answers("user_id",user.id) #学生的答案
answers_content = q.exercise_shixun_answers.where(user_id: user.id) #学生的答案
end
if q.question_type <= 2 #为选择题或判断题时
if answers_content.present? #学生有回答时
@ -369,11 +369,11 @@ module ExercisesHelper
standard_answer = q.exercise_standard_answers.pluck(:exercise_choice_id).sort #该问题的标准答案,可能有多个
if user_answer_content == standard_answer #答案一致,多选或单选才给分,答案不对不给分
if standard_answer.count > 0
q_score_1 = (q.question_score / standard_answer.count) #当多选答案正确时每个answer的分数均摊。
multi_each_score = (q.question_score / standard_answer.count) #当多选答案正确时每个answer的分数均摊。
else
q_score_1 = 0.0
multi_each_score = 0.0
end
answers_content.update_all(:score => q_score_1)
answers_content.update_all(:score => multi_each_score)
score1 = score1 + q.question_score
end
else
@ -424,7 +424,7 @@ module ExercisesHelper
end
ex_shixun_answer_content = answers_content&.where(exercise_shixun_challenge_id: exercise_cha.id)
if ex_shixun_answer_content.blank? #把关卡的答案存入试卷的实训里
cha_path = challenge_path exercise_cha.challenge&.path
cha_path = challenge_path(exercise_cha.challenge&.path)
game_challenge = game.game_codes.search_challenge_path(cha_path)&.first
if game_challenge.present?
game_code = game_challenge
@ -682,17 +682,27 @@ module ExercisesHelper
def get_exercise_left_time(exercise,user)
ex_time = exercise.time
user_left_time = nil
time_now_i = Time.now.to_i
if ex_time > 0
exercise_user = exercise.exercise_users.find_by(user_id:user.id)
time_mill = ex_time * 60 #转为秒
exercise_end_time = exercise.end_time.present? ? exercise.end_time.to_i : 0
exercise_user_start = exercise_user.present? ? exercise_user.start_at.to_i : 0
#用户未开始答题时即exercise_user_start为0
if exercise_user_start == 0
if (exercise_end_time - time_now_i) > time_mill
user_left_time = time_mill
else
user_left_time = (exercise_end_time < time_now_i) ? nil : (exercise_end_time - time_now_i)
end
else
if (exercise_user_start + time_mill) > exercise_end_time
time_mill = exercise_end_time - exercise_user_start #如果开始答题时间加试卷的限时长大于试卷的截止时间,则以试卷的截止时间到开始答题时间为试卷的限时
end
exercise_user_left_time = Time.now.to_i - exercise_user_start #用户已回答的时间
exercise_user_left_time = time_now_i - exercise_user_start #用户已回答的时间
user_left_time = (time_mill < exercise_user_left_time) ? nil : (time_mill - exercise_user_left_time) #当前用户对试卷的回答剩余时间
end
end
user_left_time
end

@ -89,11 +89,12 @@ module ExportHelper
if teacher_comments.present?
w_18 = ""
teacher_comments.each do |t|
user_name = t.user.real_name
user_name = t.user&.real_name
user_time = format_time(t.updated_at)
user_score = t.score
user_comment = t.comment
w_18 = w_18 + ("教师:" + user_name + "\n" + "时间:" + user_time.to_s + "\n" + "分数:" + user_score.to_s + "" + "\n" + "评语:" + user_comment + "\n\n")
user_score = t&.score
user_comment = t&.comment
comment_title = "教师:#{user_name}\n时间:#{user_time.to_s}\n分数:#{user_score.to_s}\n评语:#{user_comment}\n\n"
w_18 = w_18 + comment_title
end
else
w_18 = "--"
@ -160,11 +161,13 @@ module ExportHelper
if teacher_comments.present?
w_18 = ""
teacher_comments.each do |t|
user_name = t.user.real_name
user_name = t.user&.real_name
user_time = format_time(t.updated_at)
user_score = t.score
user_comment = t.comment
w_18 = w_18 + ("教师:" + user_name + "\n" + "时间:" + user_time.to_s + "\n" + "分数:" + user_score.to_s + "" + "\n" + "评语:" + user_comment + "\n\n")
user_score = t&.score
user_comment = t&.comment
comment_title = "教师:#{user_name}\n时间:#{user_time.to_s}\n分数:#{user_score.to_s}\n评语:#{user_comment}\n\n"
# ("教师:" + user_name + "\n" + "时间:" + user_time.to_s + "\n" + "分数:" + user_score.to_s + "分" + "\n" + "评语:" + user_comment + "\n\n")
w_18 = w_18 + comment_title
end
else
w_18 = "--"

@ -44,7 +44,7 @@ class ExercisePublishTask
end
# 分组设置发布时间的测验
exercise_group_settings = ExerciseGroupSetting.where("publish_time < ? and publish_time > ?", Time.now + 1800, Time.now - 1800)
exercise_group_settings = ExerciseGroupSetting.where("publish_time < ? and publish_time > ?", Time.now + 900, Time.now - 900)
exercise_group_settings.each do |exercise_group|
exercise = exercise_group.exercise
if exercise.present?
@ -70,12 +70,12 @@ class ExercisePublishTask
Rails.logger.info("log--------------------------------exercise_end start")
puts "--------------------------------exercise_end start"
# 1。统一设置的试卷
exercises = Exercise.includes(:exercise_users,:exercise_questions).where("exercise_status = 2 AND unified_setting = true AND end_time <= ?",Time.now)
exercises = Exercise.includes(:exercise_users,:exercise_questions).where("exercise_status = 2 AND unified_setting = true AND end_time <= ?",Time.now + 900)
exercises.each do |exercise|
ex_type = exercise.exercise_questions.pluck(:question_type).uniq
exercise.update_column('exercise_status', 3)
exercise.exercise_users.each do |exercise_user|
if exercise_user.commit_status == 0 && exercise_user.start_at.present?
if exercise_user&.commit_status == 0 && exercise_user&.start_at.present?
s_score = calculate_student_score(exercise, exercise_user.user)[:total_score]
if ex_type.include?(4) #是否包含主观题
subjective_score = exercise_user.subjective_score
@ -98,7 +98,7 @@ class ExercisePublishTask
end
# 2.非统一的试卷
all_exercises = Exercise.includes(:exercise_group_settings,:exercise_users,:exercise_questions).where("unified_setting = false AND exercise_status = 2 AND end_time > ?",Time.now)
all_exercises = Exercise.includes(:exercise_group_settings,:exercise_users,:exercise_questions).where("unified_setting = false AND exercise_status = 2 AND end_time > ?",Time.now + 900)
exercise_ids = all_exercises.blank? ? "(-1)" : "(" + all_exercises.map(&:id).join(",") + ")"
ex_group_settings = ExerciseGroupSetting.where("end_time <= '#{Time.now}' and exercise_id in #{exercise_ids}")
ex_group_settings.each do |exercise_setting|

@ -241,7 +241,7 @@ p{
position: absolute;
display: inline-block;
bottom: 9px;
left: 1px;
left: 2px;
}
table{
width:100%;

@ -249,8 +249,8 @@
<tbody>
<% if @games.size > 0 %>
<% @games.each_with_index do |game, index| %>
<% user_score = q.exercise_shixun_answers.where(exercise_shixun_challenge_id:game.challenge.id,user_id: @ex_user_user.id) %>
<% game_score = q.exercise_shixun_challenges.where(challenge_id:game.challenge.id) %>
<% user_score = q.exercise_shixun_answers.where(exercise_shixun_challenge_id: game_score&.first&.id,user_id: @ex_user_user.id) %>
<tr>
<td><%= index + 1 %></td>
<td style="text-align: left;">

Loading…
Cancel
Save