Merge branch 'dev_aliyun' of https://bdgit.educoder.net/Hjqreturn/educoder into dev_aliyun

dev_course
daiao 5 years ago
commit 3ef6ae566a

@ -920,7 +920,7 @@ class PollsController < ApplicationController
def commit_result def commit_result
ActiveRecord::Base.transaction do ActiveRecord::Base.transaction do
begin begin
@poll_users = @poll.poll_users @poll_users = @poll.all_poll_users(current_user.id)
@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
@limit = params[:limit] || 10 @limit = params[:limit] || 10

@ -127,4 +127,17 @@ module PollsHelper
"login":user.login "login":user.login
} }
end end
def poll_commit_result(poll,poll_questions,poll_users,poll_commit_ids)
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
if poll_un_anony #是否匿名默认为false
user_info = %w(登陆名 真实姓名 邮箱 学号)
else
user_info = []
end
poll_users_info = poll_users_info + user_info + poll_ques_titles
end
end end

@ -16,7 +16,8 @@ class HomeworkEndUpdateScoreJob < ApplicationJob
student_works = homework.student_works.where(user_id: user_ids) student_works = homework.student_works.where(user_id: user_ids)
end end
myshixuns = Myshixun.where(shixun_id: params[:shixun_id], user_id: user_ids). shixun_id = homework.homework_commons_shixun.try(:shixun_id)
myshixuns = Myshixun.where(shixun_id: shixun_id, user_id: user_ids).
includes(:games).where(games: {challenge_id: homework.homework_challenge_settings.pluck(:challenge_id)}) includes(:games).where(games: {challenge_id: homework.homework_challenge_settings.pluck(:challenge_id)})
challenge_settings = homework.homework_challenge_settings challenge_settings = homework.homework_challenge_settings
myshixuns.find_each(batch_size: 100) do |myshixun| myshixuns.find_each(batch_size: 100) do |myshixun|

@ -31,7 +31,7 @@ class PollPublishNotifyJob < ApplicationJob
Tiding.bulk_insert(*attrs) do |worker| Tiding.bulk_insert(*attrs) do |worker|
teacher_ids = teachers.pluck(:user_id) teacher_ids = teachers.pluck(:user_id)
unless poll.tidings.exists?(parent_container_type: 'PollPublish', user_id: teacher_ids) unless poll.tidings.exists?(parent_container_type: 'PollPublish', user_id: teacher_ids)
teacher_ids.find_each do |user_id| teacher_ids.each do |user_id|
worker.add same_attrs.merge(user_id: user_id) worker.add same_attrs.merge(user_id: user_id)
end end
end end

@ -1,6 +1,8 @@
if identity == Course::STUDENT if identity == Course::STUDENT
if homework.homework_type == "practice" if homework.homework_type == "practice"
json.task_operation task_operation_url(work.try(:myshixun), homework.shixuns.take) shixun = homework.shixuns.take
myshixun = work.try(:myshixun) ? work.myshixun : shixun.myshixuns.find_by(user_id: work.user_id)
json.task_operation task_operation_url(myshixun, shixun)
json.view_report work.work_status > 0 json.view_report work.work_status > 0
json.commit_des commit_des_status(work, homework) json.commit_des commit_des_status(work, homework)
else else

@ -8,7 +8,10 @@ wb.styles do |s|
wb.add_worksheet(:name => "统计结果") do |sheet| wb.add_worksheet(:name => "统计结果") do |sheet|
sheet.sheet_view.show_grid_lines = false sheet.sheet_view.show_grid_lines = false
poll_users_info = %w(序号) poll_users_info = %w(序号)
Rails.logger.info("#############_______________poll_questions.pluck(:question_title)_______####################{poll_questions.pluck(:question_title)}")
poll_ques_titles = poll_questions.pluck(:question_title).map {|k| strip_export_title(k) if k.present?} poll_ques_titles = poll_questions.pluck(:question_title).map {|k| strip_export_title(k) if k.present?}
Rails.logger.info("#############_______________poll_ques_titles_______####################{poll_ques_titles}")
poll_un_anony = poll.un_anonymous poll_un_anony = poll.un_anonymous
if poll_un_anony #是否匿名默认为false if poll_un_anony #是否匿名默认为false
user_info = %w(登陆名 真实姓名 邮箱 学号) user_info = %w(登陆名 真实姓名 邮箱 学号)
@ -18,13 +21,13 @@ wb.styles do |s|
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).count #该问题的有效填写量 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).count answer_users_count = a.poll_votes.find_current_vote("user_id",poll_commit_ids).size
answer_percent = number_to_percentage((answer_users_count.to_f / question_vote_user.to_f)*100,precision:1) 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_row.push(a.answer_text)
sheet_answer_row.push(answer_users_count) sheet_answer_row.push(answer_users_count)
@ -41,8 +44,8 @@ wb.styles do |s|
else #主观题答案 else #主观题答案
main_show_row = ["第#{q.question_number}题",q.question_title] main_show_row = ["第#{q.question_number}题",q.question_title]
sheet.add_row main_show_row,:height =>15, :style => blue_cell sheet.add_row main_show_row,:height =>15, :style => blue_cell
q.poll_votes.each do |v| #主观题的答案 q.poll_votes.each_with_index do |v,index| #主观题的答案
sheet.add_row ["",v.vote_text.present? ? v.vote_text : "--"],:height =>15, :style => sz_all sheet.add_row [(index+1),v.vote_text.present? ? v.vote_text : "--"],:height =>15, :style => sz_all
end end
sheet.add_row [], :style => sz_all sheet.add_row [], :style => sz_all
end end

Loading…
Cancel
Save