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

dev_course
cxt 5 years ago
commit d6326a553c

@ -369,11 +369,11 @@ module ExercisesHelper
standard_answer = q.exercise_standard_answers.pluck(:exercise_choice_id).sort #该问题的标准答案,可能有多个 standard_answer = q.exercise_standard_answers.pluck(:exercise_choice_id).sort #该问题的标准答案,可能有多个
if user_answer_content == standard_answer #答案一致,多选或单选才给分,答案不对不给分 if user_answer_content == standard_answer #答案一致,多选或单选才给分,答案不对不给分
if standard_answer.count > 0 if standard_answer.count > 0
multi_each_score = (q.question_score / standard_answer.count) #当多选答案正确时每个answer的分数均摊。 q_score_1 = (q.question_score.to_f / standard_answer.count) #当多选答案正确时每个answer的分数均摊。
else else
multi_each_score = 0.0 q_score_1 = 0.0
end end
answers_content.update_all(:score => multi_each_score) answers_content.update_all(:score => q_score_1)
score1 = score1 + q.question_score score1 = score1 + q.question_score
end end
else else
@ -461,13 +461,13 @@ module ExercisesHelper
"q_type":q.question_type, "q_type":q.question_type,
"q_position":q.question_number, #该问题的位置 "q_position":q.question_number, #该问题的位置
"stand_status":stand_answer, #该问题是否正确,1为正确0为错误 "stand_status":stand_answer, #该问题是否正确,1为正确0为错误
"user_score":user_scores #每个问题的总得分 "user_score":user_scores.round(1) #每个问题的总得分
} }
ques_stand.push(ques_option) ques_stand.push(ques_option)
end end
total_score = score1 + score2 + score5 total_score = score1 + score2 + score5
{ {
"total_score":total_score, "total_score":total_score.round(1),
"stand_status":ques_stand "stand_status":ques_stand
} }
end end
@ -687,7 +687,7 @@ module ExercisesHelper
exercise_user = exercise.exercise_users.find_by(user_id:user.id) exercise_user = exercise.exercise_users.find_by(user_id:user.id)
time_mill = ex_time * 60 #转为秒 time_mill = ex_time * 60 #转为秒
exercise_end_time = exercise.end_time.present? ? exercise.end_time.to_i : 0 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 = exercise_user&.start_at.present? ? exercise_user.start_at.to_i : 0
#用户未开始答题时即exercise_user_start为0 #用户未开始答题时即exercise_user_start为0
if exercise_user_start == 0 if exercise_user_start == 0
if (exercise_end_time - time_now_i) > time_mill if (exercise_end_time - time_now_i) > time_mill

@ -92,7 +92,7 @@ module ExportHelper
user_name = t.user&.real_name user_name = t.user&.real_name
user_time = format_time(t.updated_at) user_time = format_time(t.updated_at)
user_score = t&.score user_score = t&.score
user_comment = t&.comment user_comment = t.comment.present? ? t.comment : "--"
comment_title = "教师:#{user_name}\n时间:#{user_time.to_s}\n分数:#{user_score.to_s}\n评语:#{user_comment}\n\n" 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 w_18 = w_18 + comment_title
end end
@ -164,7 +164,7 @@ module ExportHelper
user_name = t.user&.real_name user_name = t.user&.real_name
user_time = format_time(t.updated_at) user_time = format_time(t.updated_at)
user_score = t&.score user_score = t&.score
user_comment = t&.comment user_comment = t.comment.present? ? t.comment : "--"
comment_title = "教师:#{user_name}\n时间:#{user_time.to_s}\n分数:#{user_score.to_s}\n评语:#{user_comment}\n\n" 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") # ("教师:" + user_name + "\n" + "时间:" + user_time.to_s + "\n" + "分数:" + user_score.to_s + "分" + "\n" + "评语:" + user_comment + "\n\n")
w_18 = w_18 + comment_title w_18 = w_18 + comment_title

@ -20,6 +20,6 @@ class EduSetting < ApplicationRecord
private private
def expire_value_cache def expire_value_cache
Rails.cache.clear(value_cache_key) Rails.cache.write(value_cache_key, value)
end end
end end

@ -23,7 +23,8 @@ if @exercises_count > 0
ex_index = exercise_index_show(exercise,@course,@is_teacher_or,@current_user_) ex_index = exercise_index_show(exercise,@course,@is_teacher_or,@current_user_)
json.extract! exercise, :id, :exercise_name,:is_public,:created_at json.extract! exercise, :id, :exercise_name,:is_public,:created_at
if @is_teacher_or == 2 if @is_teacher_or == 2
json.time get_exercise_left_time(exercise,@current_user_) second_left = get_exercise_left_time(exercise,@current_user_)
json.time second_left.present? ? (second_left / 60) : nil
end end
json.exercise_status ex_index[:ex_status] json.exercise_status ex_index[:ex_status]

Loading…
Cancel
Save