dev_forum
SylorHuang 5 years ago
parent 3a028a6679
commit 8f2be183f6

@ -1173,7 +1173,7 @@ class ExercisesController < ApplicationController
ActiveRecord::Base.transaction do ActiveRecord::Base.transaction do
begin begin
@current_user_id = current_user.id @current_user_id = current_user.id
@exercise = @exercise @exercise = @exercise.joins(:exercise_questions,:exercise_users)
exercise_ids = [@exercise.id] exercise_ids = [@exercise.id]
@exercise_status = @exercise.get_exercise_status(current_user.id) @exercise_status = @exercise.get_exercise_status(current_user.id)
@course_all_members = @course.students @course_all_members = @course.students
@ -1271,16 +1271,17 @@ class ExercisesController < ApplicationController
#搜索 #搜索
if params[:search].present? if params[:search].present?
@exercise_users_list = @exercise_users_list.joins(user: :user_extension).where("CONCAT(lastname, firstname) like ? OR student_id like ?", "%#{params[:search]}%", "%#{params[:search]}%") @exercise_users_list = @exercise_users_list.joins(user: :user_extension).where("CONCAT(lastname, firstname) like ? OR student_id like ?", "%#{params[:search]}%", "%#{params[:search]}%")
end end
exercise_user_joins = @exercise_users_list.joins(user: :user_extension)
if order == "student_id" if order == "student_id"
@exercise_users_list = @exercise_users_list.joins(user: :user_extension).order("user_extensions.student_id DESC") @exercise_users_list = exercise_user_joins.order("user_extensions.student_id DESC")
elsif order == "score" elsif order == "score"
@exercise_users_list = @exercise_users_list.joins(user: :user_extension).order("#{order} DESC") @exercise_users_list = exercise_user_joins.order("#{order} DESC")
else else
@exercise_users_list = @exercise_users_list.order("end_at DESC, start_at DESC") @exercise_users_list = exercise_user_joins.order("end_at DESC, start_at DESC")
end end
@export_ex_users = @exercise_users_list @export_ex_users = @exercise_users_list
@ -1297,9 +1298,11 @@ class ExercisesController < ApplicationController
if @user_course_identity > Course::ASSISTANT_PROFESSOR if @user_course_identity > Course::ASSISTANT_PROFESSOR
tip_exception(403,"无权限操作") tip_exception(403,"无权限操作")
else else
if @exercise_users_size == 0 if @export_ex_users.exercise_user_committed.size == 0
normal_status(-1,"暂无用户提交") normal_status(-1,"暂无用户提交")
else else
@exercise = @exercise.includes(:exercise_questions)
@export_ex_users = @export_ex_users.joins(user: :user_extension)
get_export_users(@exercise,@course,@export_ex_users) get_export_users(@exercise,@course,@export_ex_users)
exercise_export_name = exercise_export_name =
"#{current_user.real_name}_#{@course.name}_#{@exercise.exercise_name}_#{Time.now.strftime('%Y%m%d_%H%M%S')}" "#{current_user.real_name}_#{@course.name}_#{@exercise.exercise_name}_#{Time.now.strftime('%Y%m%d_%H%M%S')}"

@ -920,11 +920,6 @@ class PollsController < ApplicationController
def commit_result def commit_result
ActiveRecord::Base.transaction do ActiveRecord::Base.transaction do
begin begin
# @poll_questions = @poll.poll_questions.order("question_number ASC")
# 全部页面,需返回
# @poll_questions_count = @poll_questions.size
# 分页
# @poll = @poll.includes(:poll_users,user: :user_extension)
@poll_users = @poll.poll_users @poll_users = @poll.poll_users
@poll_commit_ids = @poll_users.commit_by_status(1).pluck(:user_id) #问卷提交用户的id @poll_commit_ids = @poll_users.commit_by_status(1).pluck(:user_id) #问卷提交用户的id
@page = params[:page] || 1 @page = params[:page] || 1
@ -937,7 +932,7 @@ class PollsController < ApplicationController
format.xlsx{ format.xlsx{
if @user_course_identity > Course::ASSISTANT_PROFESSOR if @user_course_identity > Course::ASSISTANT_PROFESSOR
tip_exception(403,"无权限操作") tip_exception(403,"无权限操作")
elsif @poll_export_questions.size == 0 || (@poll_users.where("commit_status = ?",1).size == 0) elsif (@poll.polls_status == 1) || (@poll_export_questions.size == 0) || (@poll_commit_ids.size == 0)
normal_status(-1,"暂时没有提交的用户") normal_status(-1,"暂时没有提交的用户")
else else
polls_export_name = "#{current_user.real_name}_#{@course.name}_#{@poll.polls_name}_#{Time.now.strftime('%Y%m%d_%H%M%S')}" polls_export_name = "#{current_user.real_name}_#{@course.name}_#{@poll.polls_name}_#{Time.now.strftime('%Y%m%d_%H%M%S')}"
@ -1035,10 +1030,12 @@ class PollsController < ApplicationController
@poll_users_list = @poll_users_list.joins(user: :user_extension).where("CONCAT(lastname, firstname) like ? OR student_id like ?", "%#{search_content}%", "%#{search_content}%") @poll_users_list = @poll_users_list.joins(user: :user_extension).where("CONCAT(lastname, firstname) like ? OR student_id like ?", "%#{search_content}%", "%#{search_content}%")
end end
poll_users_joins = @poll_users_list.joins(user: :user_extension)
if order == "student_id" if order == "student_id"
@poll_users_list = @poll_users_list.joins(user: :user_extension).order("user_extensions.student_id DESC") @poll_users_list = poll_users_joins.order("user_extensions.student_id DESC")
else else
@poll_users_list = @poll_users_list.joins(user: :user_extension).order("end_at DESC") @poll_users_list = poll_users_joins.order("end_at DESC")
end end
@poll_users_size = @poll_users_list.count @poll_users_size = @poll_users_list.count

Loading…
Cancel
Save