dev_forum
SylorHuang 5 years ago
parent c22ec7dff2
commit a53c20e028

@ -1173,6 +1173,7 @@ class ExercisesController < ApplicationController
ActiveRecord::Base.transaction do
begin
@current_user_id = current_user.id
@exercise = @exercise.includes(:exercise_questions)
exercise_ids = [@exercise.id]
@exercise_status = @exercise.get_exercise_status(current_user.id)
@course_all_members = @course.students
@ -1254,14 +1255,6 @@ class ExercisesController < ApplicationController
end
end
if order == "student_id"
@exercise_users_list = @exercise_users_list.joins(user: [:user_extension]).order("user_extensions.student_id DESC")
elsif order == "score"
@exercise_users_list = @exercise_users_list.order("#{order} DESC")
else
@exercise_users_list = @exercise_users_list.order("end_at DESC, start_at DESC")
end
#答题状态的选择
if params[:commit_status].present?
choose_type = params[:commit_status]
@ -1282,9 +1275,17 @@ class ExercisesController < ApplicationController
@exercise_users_list = @exercise_users_list.joins(user: :user_extension).where("CONCAT(lastname, firstname) like ? OR student_id like ?", "%#{params[:search]}%", "%#{params[:search]}%")
end
if order == "student_id"
@exercise_users_list = @exercise_users_list.joins(user: :user_extension).order("user_extensions.student_id DESC")
elsif order == "score"
@exercise_users_list = @exercise_users_list.joins(user: :user_extension).order("#{order} DESC")
else
@exercise_users_list = @exercise_users_list.order("end_at DESC, start_at DESC")
end
@export_ex_users = @exercise_users_list
@exercise_users_size = @exercise_users_list.count
@exercise_users_size = @exercise_users_list.size
# 分页
@page = params[:page] || 1
@ -1296,10 +1297,14 @@ class ExercisesController < ApplicationController
if @user_course_identity > Course::ASSISTANT_PROFESSOR
tip_exception(403,"无权限操作")
else
get_export_users(@exercise,@course,@export_ex_users)
exercise_export_name =
"#{current_user.real_name}_#{@course.name}_#{@exercise.exercise_name}_#{Time.now.strftime('%Y%m%d_%H%M%S')}"
render xlsx: "#{exercise_export_name.strip.first(30)}",template: "exercises/exercise_lists.xlsx.axlsx",locals: {table_columns:@table_columns,exercise_users:@user_columns}
if @exercise_users_size.size > 0
normal_status(-1,"暂无用户提交")
else
get_export_users(@exercise,@course,@export_ex_users)
exercise_export_name =
"#{current_user.real_name}_#{@course.name}_#{@exercise.exercise_name}_#{Time.now.strftime('%Y%m%d_%H%M%S')}"
render xlsx: "#{exercise_export_name.strip.first(30)}",template: "exercises/exercise_lists.xlsx.axlsx",locals: {table_columns:@table_columns,exercise_users:@user_columns}
end
end
}
end

@ -186,7 +186,7 @@ class HomeworkCommonsController < ApplicationController
end
@work_count = @student_works.size
@work_excel = @student_works.includes(:student_works_scores)
@work_excel = @student_works.includes(:student_works_scores, user: :user_extension, myshixun: :games)
@students = @course.students
# 分页参数
@ -207,7 +207,7 @@ class HomeworkCommonsController < ApplicationController
tip_exception(403, "无权限操作")
else
if @work_excel.present?
@homework = @homework.includes()
@homework = @homework.includes(:shixuns,:homework_detail_manual)
student_work_to_xlsx(@work_excel,@homework)
exercise_export_name = current_user.real_name + "_" + @course.name + "_" + @homework.name + "_" + Time.now.strftime('%Y%m%d_%H%M%S')

@ -18,7 +18,7 @@ class PollsController < ApplicationController
before_action :check_user_id_start_answer,only: [:start_answer]
before_action :check_poll_question_complete,only: [:commit_poll] #问卷提交前来判断问题是否完成
before_action :check_poll_commit_result,only: [:commit_result]
before_action :get_all_polls_commit, only: [:commit_result] #该问卷全部的用户
# before_action :get_all_polls_commit, only: [:commit_result] #该问卷全部的用户
before_action :get_left_banner_id, only:[:common_header,:start_answer,:new,:edit,:index]
include PollsHelper
@ -920,19 +920,32 @@ class PollsController < ApplicationController
def commit_result
ActiveRecord::Base.transaction do
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_commit_ids = @poll_users.commit_by_status(1).pluck(:user_id) #问卷提交用户的id
@page = params[:page] || 1
@limit = params[:limit] || 10
@poll_export_questions = @poll_questions.order("question_number ASC")
@poll_questions = @poll_questions.page(@page).per(@limit)
respond_to do |format|
format.json
format.xlsx{
if @user_course_identity > Course::ASSISTANT_PROFESSOR
tip_exception(403,"无权限操作")
elsif @poll_export_questions.size == 0 || (@poll_users.where("commit_status = ?",1).size == 0)
normal_status(-1,"暂时没有提交的用户")
else
polls_export_name = current_user.real_name + "_" + @course.name + "_" + @poll.polls_name + "_" + Time.now.strftime('%Y%m%d_%H%M%S')
render xlsx: "#{polls_export_name.strip.first(30)}",template: "polls/commit_result.xlsx.axlsx",locals: {poll_questions:@poll_export_questions}
polls_export_name = "#{current_user.real_name}_#{@course.name}_#{@poll.polls_name}_#{Time.now.strftime('%Y%m%d_%H%M%S')}"
render xlsx: "#{polls_export_name.strip.first(30)}",template: "polls/commit_result.xlsx.axlsx",locals: {
poll_questions:@poll_export_questions,
poll:@poll,
poll_users: @poll_users,
poll_commit_ids:@poll_commit_ids}
end
}
end
@ -1028,15 +1041,12 @@ class PollsController < ApplicationController
@poll_users_list = @poll_users_list.joins(user: :user_extension).order("end_at DESC")
end
logger.info("#######F_______@poll_users_list_last___@users_ids________________####{@poll_users_list.pluck(:user_id)}")
@poll_users_size = @poll_users_list.count
# 分页
page = params[:page] || 1
limit = params[:limit] || 20
@poll_users_list = @poll_users_list.page(page).per(limit)
logger.info("#####page_user: #{@poll_users_list.pluck(:id, :user_id)}")
else
@poll_users_list = []
@poll_users_size = 0
@ -1146,10 +1156,10 @@ class PollsController < ApplicationController
def get_questions_count
@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 # 多选题
@poll_question_mains = @poll_questions.ques_count(3).all.count #主观题
@poll_questions_count = @poll_questions.size # 全部的题目数
@poll_question_singles = @poll_questions.ques_count(1).all.size # 单选题
@poll_question_doubles = @poll_questions.ques_count(2).all.size # 多选题
@poll_question_mains = @poll_questions.ques_count(3).all.size #主观题
end
def check_poll_question_complete #commit_poll 的权限

@ -262,14 +262,14 @@ module ExportHelper
end
export_ex_users.each_with_index do |e_user,index|
user_info = e_user.user
user_course_id = user_info.course_members.course_find_by_ids("course_id",course.id).first
user_course_id = user_info.course_members.course_find_by_ids("course_id",course.id)&.first
if user_course_id.present?
get_course_group_id = user_course_id.course_group_id
if get_course_group_id.present? && get_course_group_id != 0
user_course_info = CourseGroup.by_group_ids(get_course_group_id)
user_course = user_course_info.first.name
else
user_course = "--"
user_course = "未分班"
end
else
user_course = "--"

@ -9,7 +9,7 @@ wb.styles do |s|
sheet.sheet_view.show_grid_lines = false
poll_users_info = %w(序号)
poll_ques_titles = poll_questions.pluck(:question_title).map {|k| strip_export_title(k) if k.present?}
poll_un_anony = @poll.un_anonymous
poll_un_anony = poll.un_anonymous
if poll_un_anony #是否匿名默认为false
user_info = %w(登陆名 真实姓名 邮箱 学号)
else
@ -18,13 +18,13 @@ wb.styles do |s|
poll_users_info = poll_users_info + user_info + poll_ques_titles
poll_questions.each do |q|
if q.question_type != 3 #问题不为主观题
question_vote_user = q.poll_votes.find_current_vote("user_id",@poll_commit_ids).count #该问题的有效填写量
question_vote_user = q.poll_votes.find_current_vote("user_id",poll_commit_ids).count #该问题的有效填写量
sheet_row = ["第#{q.question_number}题"] #选择题答案选项的数组
sheet_answer_row = ["小计"] #选择题回答的答案人数,数组
sheet_answer_percent = ["比例"]
sheet_answer_useful = ["有效填写人次",question_vote_user]
q.poll_answers.each do |a| #问卷的答案选项
answer_users_count = a.poll_votes.find_current_vote("user_id",@poll_commit_ids).count
answer_users_count = a.poll_votes.find_current_vote("user_id",poll_commit_ids).count
answer_percent = number_to_percentage((answer_users_count.to_f / question_vote_user.to_f)*100,precision:1)
sheet_row.push(a.answer_text)
sheet_answer_row.push(answer_users_count)
@ -49,7 +49,7 @@ wb.styles do |s|
end #each_with_index
sheet.add_row poll_users_info, :height =>15, :style => blue_cell
@poll.poll_users.each_with_index do |u,index|
poll_users.each_with_index do |u,index|
u_user = u.user
user_answer_array = []
poll_questions.each do |q|

Loading…
Cancel
Save