dev_forum
SylorHuang 5 years ago
parent 9a859c5675
commit a56da584d1

@ -203,13 +203,13 @@ class ExercisesController < ApplicationController
else
@is_teacher_or = 1
@user_exercise_answer = 3 #教师页面
@user_commit_counts = @exercise.exercise_users.where(commit_status:1).count #已提交的用户数
@user_commit_counts = @exercise.exercise_users.where(commit_status:1).size #已提交的用户数
end
@ex_status = @exercise.get_exercise_status(current_user)
exercise_id_array = [@exercise.id]
@exercise_publish_count = get_user_permission_course(exercise_id_array,2).count #是否存在已发布的
@exercise_unpublish_count = get_user_permission_course(exercise_id_array,1).count #是否存在未发布的
@exercise_publish_count = get_user_permission_course(exercise_id_array,2).size #是否存在已发布的
@exercise_unpublish_count = get_user_permission_course(exercise_id_array,1).size #是否存在未发布的
if (@exercise_publish_count == 0) && (@exercise_unpublish_count == 0) #即表示没有分班
if @ex_status == 1

@ -115,14 +115,13 @@ module ExercisesHelper
right_users_count = 0 #该问题的回答正确的人数
#计算每个问题的答案人数
# user_ids.each do |user_id|
# answer_choice_array = effictive_users.where(user_id:user_id)&.map {|s| s.exercise_choice.choice_position}.uniq
# if answer_choice_array.sort == standard_answer
# right_users_count += 1
# end
# end
# percent = effictive_users_count > 0 ? (right_users_count / effictive_users_count.to_f).round(3)*100 : 0.0
percent = 0.0
user_ids.each do |user_id|
answer_choice_array = effictive_users.where(user_id:user_id)&.map {|s| s.exercise_choice.choice_position}.uniq
if answer_choice_array.sort == standard_answer
right_users_count += 1
end
end
percent = effictive_users_count > 0 ? (right_users_count / effictive_users_count.to_f).round(3)*100 : 0.0
ex.exercise_choices.each do |c|
right_answer = standard_answer.include?(c.choice_position) #选项的标准答案为选项的位置
answer_this_choice = effictive_users.search_exercise_answer("exercise_choice_id",c.id)

@ -178,13 +178,12 @@ class Exercise < ApplicationRecord
ex_answer_user = exercise_users.where(user_id: user.id).select(:start_at,:end_at,:commit_status)
user_ex_status = get_exercise_status(user)
user_status = 2
if ex_answer_user.exists? && (ex_answer_user.first&.start_at.present? || ex_answer_user.first&.end_at.present?) #学生有过答题的,或者立即截止,但学生未做试卷的
if ex_answer_user.present? && (ex_answer_user.first&.start_at.present? || ex_answer_user.first&.end_at.present?) #学生有过答题的,或者立即截止,但学生未做试卷的
user_status = ex_answer_user.first.commit_status
end
if ex_answer_user.exists? && ex_answer_user.first&.start_at.blank? && user_ex_status == 3
if ex_answer_user.present? && ex_answer_user.first&.start_at.blank? && user_ex_status == 3
user_status = 4
end
user_status
end

Loading…
Cancel
Save