问卷/试卷的列表页,预览页面及统计结果页面的优化

dev_forum
SylorHuang 5 years ago
parent 3c1710eefc
commit 133eaf42cb

@ -101,7 +101,7 @@ class ExercisesController < ApplicationController
@page = params[:page] || 1
@limit = params[:limit] || 15
@exercises = @exercises.page(@page).per(@limit)
@exercises = @exercises.includes(:exercise_users,:exercise_questions,:exercise_group_settings)
@exercises = @exercises&.includes(:exercise_users,:exercise_questions,:exercise_group_settings)
else
@exercises = []
end
@ -188,7 +188,7 @@ class ExercisesController < ApplicationController
else
@is_teacher_or = 0 #为学生
end
@exercise_questions = @exercise.exercise_questions.order("question_number ASC")
@exercise_questions = @exercise.exercise_questions&.includes(:exercise_choices,:exercise_shixun_challenges,:exercise_standard_answers).order("question_number ASC")
rescue Exception => e
uid_logger_error(e.message)
tip_exception("试卷创建失败!")

@ -90,7 +90,7 @@ class PollsController < ApplicationController
@limit = params[:limit] || 15
@polls = @polls.page(@page).per(@limit)
@polls = @polls.includes(:poll_users,:poll_questions,:poll_group_settings)
@polls = @polls&.includes(:poll_users,:poll_questions,:poll_group_settings)
else
@polls = []
@ -183,7 +183,7 @@ class PollsController < ApplicationController
else
@is_teacher_or = 0
end
@poll_questions = @poll.poll_questions.order("question_number ASC")
@poll_questions = @poll.poll_questions&.includes(:poll_answers).order("question_number ASC")
rescue Exception => e
uid_logger_error(e.message)
tip_exception("没有权限")
@ -1148,7 +1148,7 @@ class PollsController < ApplicationController
end
def get_questions_count
@poll_questions = @poll.poll_questions.order("question_number ASC")
@poll_questions = @poll.poll_questions&.includes(:poll_answers,:poll_votes).order("question_number ASC")
@poll_questions_count = @poll_questions.count # 全部的题目数
@poll_question_singles = @poll_questions.ques_count(1).all.count # 单选题
@poll_question_doubles = @poll_questions.ques_count(2).all.count # 多选题

Loading…
Cancel
Save