dev_forum
SylorHuang 5 years ago
parent db6f5e2830
commit 04e46063b2

@ -1519,7 +1519,7 @@ class ExercisesController < ApplicationController
if exercise.present? if exercise.present?
if exercise.unified_setting #统一设置只有两种情况,全部发布,全部截止 if exercise.unified_setting #统一设置只有两种情况,全部发布,全部截止
exercise_user_status = exercise.get_exercise_status(current_user) #当前用户的能看到的试卷 exercise_user_status = exercise.get_exercise_status(current_user) #当前用户的能看到的试卷
if (exercise_user_status == exercise_status) || exercise_status == Exercise::ENDED #未发布的情况 if (exercise_user_status == exercise_status) || exercise_status == Exercise::DEADLINE #未发布的情况
unpublish_group = unpublish_group + user_groups_id unpublish_group = unpublish_group + user_groups_id
end end
else else
@ -1527,7 +1527,7 @@ class ExercisesController < ApplicationController
ex_group_settings = ex_all_group_settings.exercise_group_published.pluck(:course_group_id).uniq #问卷设置的班级 ex_group_settings = ex_all_group_settings.exercise_group_published.pluck(:course_group_id).uniq #问卷设置的班级
if exercise_status == Exercise::UNPUBLISHED if exercise_status == Exercise::UNPUBLISHED
unpublish_group = user_groups_id - ex_group_settings unpublish_group = user_groups_id - ex_group_settings
elsif exercise_status == Exercise::ENDED elsif exercise_status == Exercise::DEADLINE
ex_ended_groups = ex_all_group_settings.exercise_group_ended.pluck(:course_group_id).uniq ex_ended_groups = ex_all_group_settings.exercise_group_ended.pluck(:course_group_id).uniq
ex_and_user = user_groups_id & ex_group_settings #用户已设置的分班 ex_and_user = user_groups_id & ex_group_settings #用户已设置的分班
unpublish_group = unpublish_group + ex_and_user - ex_ended_groups #已发布的全部班级减去截止的全部班级 unpublish_group = unpublish_group + ex_and_user - ex_ended_groups #已发布的全部班级减去截止的全部班级
@ -1627,7 +1627,7 @@ class ExercisesController < ApplicationController
def check_exercise_public def check_exercise_public
if @user_course_identity > Course::ASSISTANT_PROFESSOR #当前为学生,试卷公开统计,且已截止,且已提交 if @user_course_identity > Course::ASSISTANT_PROFESSOR #当前为学生,试卷公开统计,且已截止,且已提交
ex_user = @exercise.exercise_users.exercise_commit_users(current_user.id).first ex_user = @exercise.exercise_users.exercise_commit_users(current_user.id).first
unless @exercise.get_exercise_status(current_user) == Exercise::ENDED && ex_user.present? && ex_user.commit_status == 1 && unless @exercise.get_exercise_status(current_user) == Exercise::DEADLINE && ex_user.present? && ex_user.commit_status == 1 &&
@exercise.show_statistic @exercise.show_statistic
normal_status(-1,"学生暂不能查看") normal_status(-1,"学生暂不能查看")
end end
@ -1650,7 +1650,7 @@ class ExercisesController < ApplicationController
ex_question_random = exercise.question_random ex_question_random = exercise.question_random
question_answered = 0 question_answered = 0
exercise_questions.each_with_index do |q,index| exercise_questions.each_with_index do |q,index|
if ex_question_random && exercise_user_status != Exercise::ENDED if ex_question_random && exercise_user_status != Exercise::DEADLINE
ques_number = index + 1 ques_number = index + 1
else else
ques_number = q.question_number ques_number = q.question_number

@ -89,6 +89,7 @@ module ExercisesHelper
questions.each do |ex| questions.each do |ex|
ex_total_score = user_ids.count * ex&.question_score #该试卷的已回答的总分 ex_total_score = user_ids.count * ex&.question_score #该试卷的已回答的总分
ex_answers = ex.exercise_answers ex_answers = ex.exercise_answers
if ex.question_type != Exercise::PRACTICAL if ex.question_type != Exercise::PRACTICAL
ques_title = ex.question_title ques_title = ex.question_title
ques_less_title = nil ques_less_title = nil
@ -98,13 +99,16 @@ module ExercisesHelper
ques_less_title = ex.question_title ques_less_title = ex.question_title
effictive_users = ex.exercise_shixun_answers.search_shixun_answers("user_id",user_ids) effictive_users = ex.exercise_shixun_answers.search_shixun_answers("user_id",user_ids)
end end
effictive_users_count = effictive_users.count #有效回答数可能有重复的用户id这里仅统计是否回答这个问题的全部人数
effictive_users_count = effictive_users.size #有效回答数可能有重复的用户id这里仅统计是否回答这个问题的全部人数
ex_answered_scores = effictive_users.score_reviewed.pluck(:score).sum #该问题的全部得分 ex_answered_scores = effictive_users.score_reviewed.pluck(:score).sum #该问题的全部得分
if ex_total_score == 0.0 if ex_total_score == 0.0
percent = 0.0 percent = 0.0
else else
percent = (ex_answered_scores / ex_total_score.to_f).round(3) * 100 #正确率 percent = (ex_answered_scores / ex_total_score.to_f).round(3) * 100 #正确率
end end
question_answer_infos = [] question_answer_infos = []
if ex.question_type <= Exercise::JUDGMENT #单选题 if ex.question_type <= Exercise::JUDGMENT #单选题
standard_answer = ex.exercise_standard_answers.pluck(:exercise_choice_id) #标准答案的位置 standard_answer = ex.exercise_standard_answers.pluck(:exercise_choice_id) #标准答案的位置

@ -135,7 +135,7 @@ class Exercise < ApplicationRecord
if pb_time.present? && ed_time.present? && pb_time <= Time.now && ed_time > Time.now if pb_time.present? && ed_time.present? && pb_time <= Time.now && ed_time > Time.now
status = Exercise::PUBLISHED status = Exercise::PUBLISHED
elsif ed_time.present? && ed_time <= Time.now elsif ed_time.present? && ed_time <= Time.now
status = Exercise::ENDED status = Exercise::DEADLINE
else else
status = Exercise::UNPUBLISHED status = Exercise::UNPUBLISHED
end end

Loading…
Cancel
Save