|
|
@ -146,7 +146,7 @@ class PollsController < ApplicationController
|
|
|
|
def edit
|
|
|
|
def edit
|
|
|
|
ActiveRecord::Base.transaction do
|
|
|
|
ActiveRecord::Base.transaction do
|
|
|
|
begin
|
|
|
|
begin
|
|
|
|
@poll_questions = @poll.poll_questions.order("question_number ASC")
|
|
|
|
|
|
|
|
rescue Exception => e
|
|
|
|
rescue Exception => e
|
|
|
|
uid_logger_error(e.message)
|
|
|
|
uid_logger_error(e.message)
|
|
|
|
tip_exception("页面请求失败!")
|
|
|
|
tip_exception("页面请求失败!")
|
|
|
@ -183,7 +183,7 @@ class PollsController < ApplicationController
|
|
|
|
else
|
|
|
|
else
|
|
|
|
@is_teacher_or = 0
|
|
|
|
@is_teacher_or = 0
|
|
|
|
end
|
|
|
|
end
|
|
|
|
@poll_questions = @poll.poll_questions&.includes(:poll_answers).order("question_number ASC")
|
|
|
|
|
|
|
|
rescue Exception => e
|
|
|
|
rescue Exception => e
|
|
|
|
uid_logger_error(e.message)
|
|
|
|
uid_logger_error(e.message)
|
|
|
|
tip_exception("没有权限")
|
|
|
|
tip_exception("没有权限")
|
|
|
@ -868,7 +868,6 @@ class PollsController < ApplicationController
|
|
|
|
@user_poll_status = 0 #可编辑
|
|
|
|
@user_poll_status = 0 #可编辑
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
# @answer_user = User.find_by(id:@poll_current_user_id)
|
|
|
|
|
|
|
|
@answer_status = []
|
|
|
|
@answer_status = []
|
|
|
|
question_answered = 0
|
|
|
|
question_answered = 0
|
|
|
|
|
|
|
|
|
|
|
@ -925,7 +924,6 @@ class PollsController < ApplicationController
|
|
|
|
@page = params[:page] || 1
|
|
|
|
@page = params[:page] || 1
|
|
|
|
@limit = params[:limit] || 10
|
|
|
|
@limit = params[:limit] || 10
|
|
|
|
@poll_export_questions = @poll_questions
|
|
|
|
@poll_export_questions = @poll_questions
|
|
|
|
|
|
|
|
|
|
|
|
@poll_questions = @poll_questions.page(@page).per(@limit)
|
|
|
|
@poll_questions = @poll_questions.page(@page).per(@limit)
|
|
|
|
if params[:format] == "xlsx"
|
|
|
|
if params[:format] == "xlsx"
|
|
|
|
if @user_course_identity > Course::ASSISTANT_PROFESSOR
|
|
|
|
if @user_course_identity > Course::ASSISTANT_PROFESSOR
|
|
|
@ -1151,7 +1149,7 @@ class PollsController < ApplicationController
|
|
|
|
|
|
|
|
|
|
|
|
def get_questions_count
|
|
|
|
def get_questions_count
|
|
|
|
@poll_questions = @poll.poll_questions.order("question_number ASC")
|
|
|
|
@poll_questions = @poll.poll_questions.order("question_number ASC")
|
|
|
|
@poll_questions_count = @poll_questions.size # 全部的题目数
|
|
|
|
@poll_questions_count = @poll_questions&.size # 全部的题目数
|
|
|
|
@poll_question_singles = @poll_questions.ques_count(1).size # 单选题
|
|
|
|
@poll_question_singles = @poll_questions.ques_count(1).size # 单选题
|
|
|
|
@poll_question_doubles = @poll_questions.ques_count(2).size # 多选题
|
|
|
|
@poll_question_doubles = @poll_questions.ques_count(2).size # 多选题
|
|
|
|
@poll_question_mains = @poll_questions.ques_count(3).size #主观题
|
|
|
|
@poll_question_mains = @poll_questions.ques_count(3).size #主观题
|
|
|
@ -1301,7 +1299,6 @@ class PollsController < ApplicationController
|
|
|
|
|
|
|
|
|
|
|
|
#问卷的统计结果的导出
|
|
|
|
#问卷的统计结果的导出
|
|
|
|
def poll_commit_result(poll,poll_questions,poll_users,poll_commit_ids)
|
|
|
|
def poll_commit_result(poll,poll_questions,poll_users,poll_commit_ids)
|
|
|
|
obj_commit = []
|
|
|
|
|
|
|
|
sub_commit = []
|
|
|
|
sub_commit = []
|
|
|
|
user_commit = []
|
|
|
|
user_commit = []
|
|
|
|
poll_users_info = %w(序号)
|
|
|
|
poll_users_info = %w(序号)
|
|
|
@ -1315,30 +1312,28 @@ class PollsController < ApplicationController
|
|
|
|
poll_users_info = poll_users_info + user_info + poll_ques_titles
|
|
|
|
poll_users_info = poll_users_info + user_info + poll_ques_titles
|
|
|
|
poll_questions.each do |q|
|
|
|
|
poll_questions.each do |q|
|
|
|
|
if q.question_type != 3 #问题不为主观题
|
|
|
|
if q.question_type != 3 #问题不为主观题
|
|
|
|
question_vote_user = q.poll_votes.find_current_vote("user_id",poll_commit_ids).size #该问题的有效填写量
|
|
|
|
question_vote_user = q.poll_votes.find_current_vote("user_id",poll_commit_ids)&.size #该问题的有效填写量
|
|
|
|
sheet_row = ["第#{q.question_number}题"] #选择题答案选项的数组
|
|
|
|
sheet_row = ["第#{q.question_number}题"] #选择题答案选项的数组
|
|
|
|
sheet_answer_row = ["小计"] #选择题回答的答案人数,数组
|
|
|
|
sheet_answer_row = ["小计"] #选择题回答的答案人数,数组
|
|
|
|
sheet_answer_percent = ["比例"]
|
|
|
|
sheet_answer_percent = ["比例"]
|
|
|
|
sheet_answer_useful = ["有效填写人次",question_vote_user]
|
|
|
|
sheet_answer_useful = ["本题有效填写人次",question_vote_user]
|
|
|
|
q.poll_answers.each do |a| #问卷的答案选项
|
|
|
|
q.poll_answers.each do |a| #问卷的答案选项
|
|
|
|
answer_users_count = a.poll_votes.find_current_vote("user_id",poll_commit_ids).size
|
|
|
|
answer_users_count = a.poll_votes.find_current_vote("user_id",poll_commit_ids)&.size
|
|
|
|
answer_percent = (question_vote_user == 0) ? "0.0%" : "#{((answer_users_count / question_vote_user.to_f)*100).round(1).to_s}%"
|
|
|
|
answer_percent = (question_vote_user == 0) ? "0.0%" : "#{((answer_users_count / question_vote_user.to_f)*100).round(1).to_s}%"
|
|
|
|
sheet_row.push(a.answer_text)
|
|
|
|
sheet_row.push(a.answer_text)
|
|
|
|
sheet_answer_row.push(answer_users_count)
|
|
|
|
sheet_answer_row.push(answer_users_count)
|
|
|
|
sheet_answer_percent.push(answer_percent)
|
|
|
|
sheet_answer_percent.push(answer_percent)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
sheet_obj_commit = {
|
|
|
|
sheet_sub_commit = {
|
|
|
|
sheet_row:sheet_row,
|
|
|
|
sub_title: sheet_row,
|
|
|
|
sheet_answer_row:sheet_answer_row,
|
|
|
|
sub_user_votes:[sheet_answer_row,sheet_answer_percent,sheet_answer_useful]
|
|
|
|
sheet_answer_percent:sheet_answer_percent,
|
|
|
|
|
|
|
|
sheet_answer_useful:sheet_answer_useful
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
obj_commit.push(sheet_obj_commit)
|
|
|
|
sub_commit.push(sheet_sub_commit)
|
|
|
|
else #主观题答案
|
|
|
|
else #主观题答案
|
|
|
|
user_votes= []
|
|
|
|
user_votes= []
|
|
|
|
main_show_row = ["第#{q.question_number}题", q.question_title]
|
|
|
|
main_show_row = ["第#{q.question_number}题", q.question_title ]
|
|
|
|
q.poll_votes.each_with_index do |v,index| #主观题的答案
|
|
|
|
q.poll_votes.each_with_index do |v,index| #主观题的答案
|
|
|
|
q_poll_vote = [(index+1),v.vote_text.present? ? v.vote_text : "--"]
|
|
|
|
q_poll_vote = [(index+1), v.vote_text.present? ? v.vote_text : "--"]
|
|
|
|
user_votes.push(q_poll_vote)
|
|
|
|
user_votes.push(q_poll_vote)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
sheet_sub_commit = {
|
|
|
|
sheet_sub_commit = {
|
|
|
@ -1347,9 +1342,10 @@ class PollsController < ApplicationController
|
|
|
|
}
|
|
|
|
}
|
|
|
|
sub_commit.push(sheet_sub_commit)
|
|
|
|
sub_commit.push(sheet_sub_commit)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
end #each_with_index
|
|
|
|
end #each_with_index
|
|
|
|
|
|
|
|
|
|
|
|
poll_users.includes(user: :user_extension).each_with_index do |u,index|
|
|
|
|
poll_users.includes(user: [:user_extension,:poll_votes]).each_with_index do |u,index|
|
|
|
|
u_user = u.user
|
|
|
|
u_user = u.user
|
|
|
|
user_answer_array = []
|
|
|
|
user_answer_array = []
|
|
|
|
poll_questions.each do |q|
|
|
|
|
poll_questions.each do |q|
|
|
|
@ -1390,7 +1386,6 @@ class PollsController < ApplicationController
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
{
|
|
|
|
obj_commit:obj_commit,
|
|
|
|
|
|
|
|
poll_users_info:poll_users_info,
|
|
|
|
poll_users_info:poll_users_info,
|
|
|
|
sub_commit:sub_commit,
|
|
|
|
sub_commit:sub_commit,
|
|
|
|
user_commit:user_commit
|
|
|
|
user_commit:user_commit
|
|
|
|