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

dev_forum
cxt 5 years ago
commit 05c95fdda9

@ -1519,7 +1519,7 @@ class ExercisesController < ApplicationController
if exercise.present?
if exercise.unified_setting #统一设置只有两种情况,全部发布,全部截止
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
end
else
@ -1527,7 +1527,7 @@ class ExercisesController < ApplicationController
ex_group_settings = ex_all_group_settings.exercise_group_published.pluck(:course_group_id).uniq #问卷设置的班级
if exercise_status == Exercise::UNPUBLISHED
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_and_user = user_groups_id & ex_group_settings #用户已设置的分班
unpublish_group = unpublish_group + ex_and_user - ex_ended_groups #已发布的全部班级减去截止的全部班级
@ -1627,7 +1627,7 @@ class ExercisesController < ApplicationController
def check_exercise_public
if @user_course_identity > Course::ASSISTANT_PROFESSOR #当前为学生,试卷公开统计,且已截止,且已提交
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
normal_status(-1,"学生暂不能查看")
end
@ -1650,7 +1650,7 @@ class ExercisesController < ApplicationController
ex_question_random = exercise.question_random
question_answered = 0
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
else
ques_number = q.question_number

@ -1,15 +1,8 @@
class Users::BaseAccountController < Users::BaseController
before_action :require_login, :check_auth
before_action :require_login
def observed_user
@_observed_user ||= (User.find_by_id(params[:account_id]) || User.find_by_login(params[:account_id]))
end
private
def require_login
return if User.current.logged?
tip_exception(401, "..")
end
end

@ -89,6 +89,7 @@ module ExercisesHelper
questions.each do |ex|
ex_total_score = user_ids.count * ex&.question_score #该试卷的已回答的总分
ex_answers = ex.exercise_answers
if ex.question_type != Exercise::PRACTICAL
ques_title = ex.question_title
ques_less_title = nil
@ -98,13 +99,16 @@ module ExercisesHelper
ques_less_title = ex.question_title
effictive_users = ex.exercise_shixun_answers.search_shixun_answers("user_id",user_ids)
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 #该问题的全部得分
if ex_total_score == 0.0
percent = 0.0
else
percent = (ex_answered_scores / ex_total_score.to_f).round(3) * 100 #正确率
end
question_answer_infos = []
if ex.question_type <= Exercise::JUDGMENT #单选题
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
status = Exercise::PUBLISHED
elsif ed_time.present? && ed_time <= Time.now
status = Exercise::ENDED
status = Exercise::DEADLINE
else
status = Exercise::UNPUBLISHED
end

Loading…
Cancel
Save