dev_forum
SylorHuang 6 years ago
parent 5fcd1693c8
commit 8551246550

@ -689,7 +689,7 @@ class ExercisesController < ApplicationController
ActiveRecord::Base.transaction do
begin
check_ids = Exercise.where(id: params[:check_ids])
ex_end_time = params[:end_time] || Time.at(((1.month.since.to_i)/3600.0).ceil * 3600)
ex_end_time = params[:end_time].to_time
check_ids.each do |exercise|
if exercise.present?
if exercise.unified_setting
@ -701,20 +701,13 @@ class ExercisesController < ApplicationController
if ex_status == 1 #如果试卷存在已发布的,或者是已截止的,那么则直接跳过
g_course = params[:group_ids] #表示是否传入分班参数,如果传入分班的参数,那么试卷的统一设置需修改
if g_course
# course_groups = @course.teacher_course_groups.get_user_groups(current_user.id)
#
# if course_groups.blank?
# user_course_groups = @course.course_groups.present? ? @course.course_groups.pluck(:id) : []
# else
# user_course_groups = course_groups.pluck(:course_group_id).reject(&:blank?).uniq
# end
user_course_groups = @course.charge_group_ids(current_user)
if g_course.map(&:to_i).sort == user_course_groups.sort # 如果是设置为全部班级,则试卷不用分组,且试卷设定为统一设置,否则则分组设置
exercise.exercise_group_settings.destroy_all
ex_unified = true
e_time = ex_end_time
else
e_time = exercise.exercise_group_settings.end_time_no_null.map(&:end_time).max
ex_unified = false
g_course.each do |i|
exercise_group_setting = exercise.exercise_group_settings.find_in_exercise_group("course_group_id",i).first #根据课堂分班的id寻找试卷所在的班级
@ -732,20 +725,21 @@ class ExercisesController < ApplicationController
new_exercise_group.save
end
end
group_ids = params[:group_ids]
end
else
exercise.exercise_group_settings.destroy_all
ex_unified = true
end
if exercise.end_time.blank?
e_time = ex_end_time
elsif exercise.exercise_group_settings.end_time_no_null.count > 0 # 该试卷分组有结束时间为空的
e_time = exercise.exercise_group_settings.end_time_no_null.map(&:end_time).max
else
e_time = exercise.end_time
end
# if exercise.end_time.blank?
# e_time = ex_end_time
# elsif exercise.exercise_group_settings.end_time_no_null.count > 0 # 该试卷分组有结束时间为空的
# e_time = exercise.exercise_group_settings.end_time_no_null.map(&:end_time).max
# else
# e_time = ex_end_time
# end
ex_status = set_exercise_status(Time.now,e_time)
exercise_params = {
:publish_time => Time.now,

@ -258,15 +258,12 @@ class PollsController < ApplicationController
g_course = params[:group_ids] #表示是否传入分班参数,如果传入分班的参数那么poll的统一设置需修改
if g_course
user_course_groups = @course.charge_group_ids(current_user)
# if course_groups.blank?
# user_course_groups = @course.course_groups.present? ? @course.course_groups.pluck(:id) : []
# else
# user_course_groups = course_groups.pluck(:course_group_id)
# end
if g_course.map(&:to_i).sort == user_course_groups.sort # 如果是设置为全部班级,则问卷不用分组,且问卷设定为统一设置,否则则分组设置
poll.poll_group_settings.destroy_all
poll_unified = true
e_time = ex_end_time
else
e_time = poll.poll_group_settings.end_time_present.map(&:end_time).max
poll_unified = false
g_course.each do |i|
poll_group_setting = poll.poll_group_settings.find_in_poll_group("course_group_id",i).first #根据课堂分班的id寻找问卷所在的班级
@ -289,14 +286,15 @@ class PollsController < ApplicationController
else
poll.poll_group_settings.destroy_all
poll_unified = true
end
if poll.end_time.blank?
e_time = ex_end_time
elsif poll.poll_group_settings.end_time_present.count > 0 # 该问卷分组有结束时间为空的
e_time = poll.poll_group_settings.end_time_present.map(&:end_time).max
else
e_time = poll.end_time
end
# if poll.end_time.blank?
# e_time = ex_end_time
# elsif poll.poll_group_settings.end_time_present.count > 0 # 该问卷分组有结束时间为空的
# e_time = poll.poll_group_settings.end_time_present.map(&:end_time).max
# else
# e_time = poll.end_time
# end
poll_status = set_poll_status(Time.now,e_time)
poll_params = {

@ -87,7 +87,7 @@ module ExercisesHelper
def exercise_commit_result(questions,user_ids)
question_infos = []
percent = 0.0
questions.each do |ex|
questions.includes(:exercise_choices).each do |ex|
ex_total_score = user_ids.count * ex&.question_score #该试卷的已回答的总分
ex_answers = ex.exercise_answers.includes(:exercise_choice)
if ex.question_type != Exercise::PRACTICAL
@ -113,24 +113,9 @@ module ExercisesHelper
if ex.question_type <= Exercise::JUDGMENT #选择题和判断题
standard_answer = ex.exercise_standard_answers.pluck(:exercise_choice_id).sort #标准答案的位置
right_users_count = 0 #该问题的回答正确的人数
# if ex.question_type == Exercise::MULTIPLE #多选题
# user_ids.each do |user_id|
# answer_choice_array = ExerciseChoice.where(id:effictive_users.map{|e| e.exercise_choice_id if a.user_id == user_id}).pluck(:choice_position).uniq
# if answer_choice_array.sort == standard_answer
# right_users_count += 1
# end
# end
# else #单选题和判断题
# user_ids.each do |user_id|
# answer_choice_array = effictive_users.select(:user_id,:exercise_choice_id).find_by(user_id:user_id)&.exercise_choice&.choice_position
# if [answer_choice_array] == standard_answer
# right_users_count += 1
# end
# end
# end
user_ids.each do |user_id|
answer_choice_array = ExerciseChoice.where(id:effictive_users.map{|e| e.exercise_choice_id if e.user_id == user_id}).pluck(:choice_position).uniq
answer_choice_array = ex.exercise_choices.where(id:effictive_users.map{|e| e.exercise_choice_id if e.user_id == user_id}).pluck(:choice_position).uniq
if answer_choice_array.sort == standard_answer
right_users_count += 1
end

Loading…
Cancel
Save