导出成绩的调整

dev_forum
cxt 5 years ago
parent 338c53b769
commit cece1eee5f

@ -959,18 +959,20 @@ class CoursesController < ApplicationController
def export_member_scores_excel def export_member_scores_excel
ActiveRecord::Base.transaction do ActiveRecord::Base.transaction do
begin begin
name = params[:name] ? "#{params[:name].strip}" : "" #用户名或学生学号id搜索 search = params[:search] ? "#{params[:search].strip}" : "" #用户名或学生学号id搜索
group_id = params[:group_id] #分班的班级id group_id = params[:group_id] #分班的班级id
if group_id && group_id != "0" && group_id != "-1" # if group_id && group_id != "0" && group_id != "-1"
@all_members = @course.students.course_find_by_ids("course_group_id",group_id) # @all_members = @course.students.course_find_by_ids("course_group_id",group_id)
elsif group_id && group_id == "0" # 未分班 # elsif group_id && group_id == "0" # 未分班
@all_members = @course.course_members.ungroup_students # @all_members = @course.course_members.ungroup_students
else # else
@all_members = @course.students # @all_members = @course.students
end # end
if name.present? # if name.present?
@all_members = @all_members.joins(user: [:user_extension]).where('concat(users.lastname, users.firstname) like ? or user_extensions.student_id like ?',"%#{name}%","%#{name}%") # @all_members = @all_members.joins(user: [:user_extension]).where('concat(users.lastname, users.firstname) like ? or user_extensions.student_id like ?',"%#{name}%","%#{name}%")
end # end
@all_members = student_act_score group_id, search
@c_homeworks = @course.homework_commons.homework_published.order("homework_commons.publish_time asc, homework_commons.created_at asc") @c_homeworks = @course.homework_commons.homework_published.order("homework_commons.publish_time asc, homework_commons.created_at asc")
@c_exercises = @course.exercises.is_exercise_published.order("exercises.publish_time asc, exercises.created_at asc") @c_exercises = @course.exercises.is_exercise_published.order("exercises.publish_time asc, exercises.created_at asc")
@ -981,7 +983,7 @@ class CoursesController < ApplicationController
else else
member_to_xlsx(@course, @all_members, @c_homeworks, @c_exercises, @c_tasks, @c_polls) member_to_xlsx(@course, @all_members, @c_homeworks, @c_exercises, @c_tasks, @c_polls)
filename = current_user.real_name + "_" + @course.name + "_全部成绩" + Time.now.strftime('%Y%m%d_%H%M%S') filename = current_user.real_name + "_" + @course.name + "_全部成绩" + Time.now.strftime('%Y%m%d_%H%M%S')
render xlsx: "#{filename.strip.first(30)}",template: "courses/export_member_scores_excel.xlsx.axlsx", render xlsx: "#{format_sheet_name filename.strip.first(30)}",template: "courses/export_member_scores_excel.xlsx.axlsx",
locals: {course_info:@course_info, activity_level:@user_activity_level, locals: {course_info:@course_info, activity_level:@user_activity_level,
course_scores:@course_user_scores,shixun_works:@shixun_work_arrays, course_scores:@course_user_scores,shixun_works:@shixun_work_arrays,
common_works:@common_work_arrays,group_works:@group_work_arrays,task_works:@task_work_arrays, common_works:@common_work_arrays,group_works:@group_work_arrays,task_works:@task_work_arrays,
@ -1051,16 +1053,68 @@ class CoursesController < ApplicationController
end end
end end
def member_to_xlsx(course,all_members,homeworks,exercises,tasks,polls) def student_act_score group_id, search
sql_select = %Q{SELECT cm.*,(
SELECT SUM(student_works.work_score)
FROM student_works,homework_commons
WHERE student_works.homework_common_id = homework_commons.id
AND homework_commons.course_id = #{@course.id}
AND student_works.user_id = cm.user_id
) AS score,
(SELECT SUM(gw.work_score) FROM graduation_works gw,graduation_tasks gt WHERE gw.graduation_task_id = gt.id
AND gt.course_id = #{@course.id} AND gw.user_id = cm.user_id) AS graduation_score,
(SELECT SUM(exercise_users.score) FROM exercise_users,exercises WHERE exercise_users.exercise_id = exercises.id
AND exercises.course_id = #{@course.id} AND exercise_users.user_id = cm.user_id) AS ex_score,
(SELECT max(student_id) FROM user_extensions WHERE user_extensions.user_id = cm.user_id) AS student_id,
(SELECT max(message_num) FROM course_contributor_scores AS ccs WHERE ccs.course_id = #{@course.id} AND ccs.user_id = cm.user_id) AS message_num,
(SELECT max(message_reply_num) FROM course_contributor_scores AS ccs WHERE ccs.course_id = #{@course.id} AND ccs.user_id = cm.user_id) AS message_reply_num,
(SELECT max(resource_num) FROM course_contributor_scores AS ccs WHERE ccs.course_id = #{@course.id} AND ccs.user_id = cm.user_id) AS resource_num,
(SELECT max(homework_journal_num) FROM course_contributor_scores AS ccs WHERE ccs.course_id = #{@course.id} AND ccs.user_id = cm.user_id) AS homework_journal_num,
(SELECT COUNT(gw.id) FROM graduation_works AS gw, graduation_tasks AS gt WHERE gw.graduation_task_id = gt.id AND gt.course_id = #{@course.id} AND gw.work_status != 0 AND gw.user_id = cm.user_id) AS graduation_num,
(SELECT COUNT(ss.id) FROM student_works AS ss ,homework_commons AS hc WHERE ss.homework_common_id = hc.id AND hc.course_id = #{@course.id} AND ss.work_status != 0 AND ss.user_id = cm.user_id) AS homework_num,
(SELECT COUNT(eu.id) FROM exercise_users AS eu,exercises WHERE eu.exercise_id = exercises.id AND exercises.course_id = #{@course.id} AND eu.commit_status = 1 AND eu.user_id = cm.user_id) AS exercise_num,
(SELECT COUNT(pu.id) FROM poll_users AS pu, polls WHERE pu.poll_id = polls.id AND polls.course_id = #{@course.id} AND pu.commit_status = 1 AND pu.user_id = cm.user_id) AS poll_num
FROM course_members cm}
if search.present? && group_id.present?
sql_select += %Q{ join users on cm.user_id = users.id
joins user_extensions ue on ue.user_id = users.id
WHERE cm.role = 4 and cm.course_id = #{@course.id} and cm.course_group_id = #{group_id} and
(concat(users.lastname, users.firstname) like '%#{search}%' or ue.student_id like '%#{search}%') ORDER BY score desc}
elsif search.present?
ql_select += %Q{ join users on cm.user_id = users.id
joins user_extensions ue on ue.user_id = users.id
WHERE cm.role = 4 and
(concat(users.lastname, users.firstname) like '%#{search}%' or ue.student_id like '%#{search}%') ORDER BY score desc}
elsif group_id.present?
sql_select += %Q{ WHERE cm.role = 4 and cm.course_id = #{@course.id} and cm.course_group_id = #{group_id} ORDER BY score desc}
else
sql_select += %Q{ WHERE cm.role = 4 and cm.course_id = #{@course.id} ORDER BY score desc}
end
act_scores = CourseMember.find_by_sql(sql_select)
act_scores
end
def member_to_xlsx(course,all_members,homeworks,exercises,tasks)
#课堂的作业信息 #课堂的作业信息
shixun_homeworks = homeworks.search_homework_type(4).includes(:score_student_works) #全部实训作业 shixun_homeworks = homeworks.search_homework_type(4) #全部实训作业
shixun_titles = shixun_homeworks.pluck(:name) + ["总得分"] shixun_titles = shixun_homeworks.pluck(:name) + ["总得分"]
common_homeworks = homeworks.search_homework_type(1).includes(:score_student_works) #全部普通作业 shixun_homeworks = shixun_homeworks.includes(:score_student_works)
common_homeworks = homeworks.search_homework_type(1) #全部普通作业
common_titles = common_homeworks.pluck(:name)+ ["总得分"] common_titles = common_homeworks.pluck(:name)+ ["总得分"]
common_homeworks = common_homeworks.includes(:score_student_works)
group_homeworks = homeworks.search_homework_type(3).includes(:score_student_works) #全部分组作业 group_homeworks = homeworks.search_homework_type(3).includes(:score_student_works) #全部分组作业
group_titles = group_homeworks.pluck(:name)+ ["总得分"] group_titles = group_homeworks.pluck(:name)+ ["总得分"]
task_titles = tasks.includes(:score_graduation_works).pluck(:name) + ["总得分"] group_homeworks = group_homeworks.includes(:score_student_works)
exercise_titles = exercises.includes(:score_exercise_users).pluck(:exercise_name) + ["总得分"]
task_titles = tasks.pluck(:name) + ["总得分"]
tasks = tasks.includes(:score_graduation_works)
exercise_titles = exercises.pluck(:exercise_name) + ["总得分"]
exercises = exercises.includes(:score_exercise_users)
total_user_score_array = [] #学生总成绩集合 total_user_score_array = [] #学生总成绩集合
#课堂信息 #课堂信息
@ -1075,7 +1129,7 @@ class CoursesController < ApplicationController
course_teacher_member = course.course_members.course_user_role(%i[CREATOR]) course_teacher_member = course.course_members.course_user_role(%i[CREATOR])
course_teacher = course_teacher_member.present? ? course_teacher_member.first.user.real_name : "--" course_teacher = course_teacher_member.present? ? course_teacher_member.first.user.real_name : "--"
course_class_counts = course.course_groups_count course_class_counts = course.course_groups_count
course_students_count = course.students.count course_students_count = course.students.size
course_1 = ["课堂编号",course_id] course_1 = ["课堂编号",course_id]
course_2 = ["课程名称",course_list_name] course_2 = ["课程名称",course_list_name]
course_3 = ["课堂名称",course_name] course_3 = ["课堂名称",course_name]
@ -1100,16 +1154,11 @@ class CoursesController < ApplicationController
@course_info += [course_info_title,course_main_info,course_group_info] @course_info += [course_info_title,course_main_info,course_group_info]
#课堂活跃度 #课堂活跃度
course_homework_ids = homeworks.pluck(:id) #该课堂的全部作业id
course_graduate_task_ids = tasks.pluck(:id) #该课堂的全部毕业任务id
course_exercise_ids = exercises.pluck(:id) #课堂的全部试卷数
course_poll_ids = polls.pluck(:id) #课堂的全部问卷数
course_board_ids = course.boards.pluck(:id) #课堂的全部讨论区
@user_activity_level = [] @user_activity_level = []
course_user_level = [] course_user_level = []
course_activity_title = "课堂活跃度统计" course_activity_title = "课堂活跃度统计"
user_cell_head = %w(排名 真实姓名 登录名 邮箱 学号 分班 作业完成数(*10) 试卷完成数(*10) 问卷完成数(*7) 资源发布数(*5) 帖子发布数(*2) 帖子回复数(*1) 作业回复数(*1) 活跃度) user_cell_head = %w(排名 真实姓名 登录名 邮箱 学号 分班 作业完成数(*10) 试卷完成数(*10) 问卷完成数(*7) 资源发布数(*5) 帖子发布数(*2) 帖子回复数(*1) 作业回复数(*1) 活跃度)
all_members.includes(user: :user_extension).each do |u| all_members.each do |u|
#用户的基本信息 #用户的基本信息
user = u.user user = u.user
user_login = user.login user_login = user.login
@ -1121,15 +1170,14 @@ class CoursesController < ApplicationController
user_work_scores = [] user_work_scores = []
#课堂活跃度统计 #课堂活跃度统计
user_homeworks_num = user.student_works.find_by_homework(course_homework_ids).has_committed.count #完成的作业数 user_homeworks_num = u.homework_num.to_i #完成的作业数
user_graduate_num = user.graduation_works.find_by_task(course_graduate_task_ids).has_committed.count #毕业任务完成数 user_graduate_num = u.graduation_num.to_i #毕业任务完成数
user_exercise_num = user.exercise_users.search_by_exercise(course_exercise_ids).commit_exercise_by_status(1).count #根据试卷的id来查找 user_exercise_num = u.exercise_num.to_i #根据试卷的id来查找
user_poll_num = user.poll_users.search_by_poll(course_poll_ids).commit_by_status(1).count #已完成问卷 user_poll_num = u.poll_num.to_i #已完成问卷
user_file_num = user.attachments.search_by_container(course.id).count user_file_num = u.resource_num.to_i
user_messages = user.messages user_messages_num = u.message_num.to_i #帖子发布数
user_messages_num = user_messages.root_nodes.find_by_boards(course_board_ids).count #帖子发布数 user_reply_num = u.message_reply_num.to_i #帖子回复数
user_reply_num = user_messages.reply_nodes.find_by_boards(course_board_ids).count #帖子回复数 user_work_reply_num = u.homework_journal_num.to_i #作业回复数的数量
user_work_reply_num = user.journals_for_messages.search_by_jour_type("HomeworkCommon",course_homework_ids).count #作业回复数的数量
c_works_num = (user_homeworks_num + user_graduate_num)*10 c_works_num = (user_homeworks_num + user_graduate_num)*10
c_exercise_num = user_exercise_num*10 c_exercise_num = user_exercise_num*10
c_poll_num = user_poll_num*7 c_poll_num = user_poll_num*7
@ -1167,7 +1215,7 @@ class CoursesController < ApplicationController
exercise_score_array = [] exercise_score_array = []
#实训作业 #实训作业
if shixun_homeworks.count > 0 if shixun_homeworks.size > 0
shixun_homeworks.each do |s| shixun_homeworks.each do |s|
user_student_work = s.score_student_works.select{|work| work.user_id == user.id}.first #当前用户的对该作业的回答 user_student_work = s.score_student_works.select{|work| work.user_id == user.id}.first #当前用户的对该作业的回答
if user_student_work.nil? if user_student_work.nil?
@ -1183,7 +1231,7 @@ class CoursesController < ApplicationController
user_work_scores += user_info_array + shixun_score_array #单个用户的实训作业得分信息 user_work_scores += user_info_array + shixun_score_array #单个用户的实训作业得分信息
#普通作业 #普通作业
if common_homeworks.count > 0 if common_homeworks.size > 0
common_homeworks.each do |c| common_homeworks.each do |c|
user_student_work_1 = c.score_student_works.select{|work| work.user_id == user.id}.first #当前用户的对该作业的回答 user_student_work_1 = c.score_student_works.select{|work| work.user_id == user.id}.first #当前用户的对该作业的回答
if user_student_work_1.nil? if user_student_work_1.nil?
@ -1199,7 +1247,7 @@ class CoursesController < ApplicationController
user_work_scores += common_score_array #单个用户的普通作业得分信息 user_work_scores += common_score_array #单个用户的普通作业得分信息
#分组作业 #分组作业
if group_homeworks.count > 0 if group_homeworks.size > 0
group_homeworks.each do |g| group_homeworks.each do |g|
user_student_work_3 = g.score_student_works.select{|work| work.user_id == user.id}.first #当前用户的对该作业的回答 user_student_work_3 = g.score_student_works.select{|work| work.user_id == user.id}.first #当前用户的对该作业的回答
if user_student_work_3.nil? if user_student_work_3.nil?
@ -1215,7 +1263,7 @@ class CoursesController < ApplicationController
user_work_scores += group_score_array #单个用户的分组作业得分信息 user_work_scores += group_score_array #单个用户的分组作业得分信息
#毕设作业 #毕设作业
if tasks.count > 0 if tasks.size > 0
tasks.each do |task| tasks.each do |task|
graduation_work = task.score_graduation_works.select{|work| work.user_id == user.id}.first graduation_work = task.score_graduation_works.select{|work| work.user_id == user.id}.first
if graduation_work.nil? if graduation_work.nil?
@ -1231,7 +1279,7 @@ class CoursesController < ApplicationController
user_work_scores += task_score_array #单个用户的分组作业得分信息 user_work_scores += task_score_array #单个用户的分组作业得分信息
#试卷 #试卷
if exercises.count > 0 if exercises.size > 0
exercises.each do |ex| exercises.each do |ex|
exercise_work = ex.score_exercise_users.select{|work| work.user_id == user.id}.first exercise_work = ex.score_exercise_users.select{|work| work.user_id == user.id}.first
if exercise_work.nil? if exercise_work.nil?
@ -1269,73 +1317,63 @@ class CoursesController < ApplicationController
@common_work_arrays = [] @common_work_arrays = []
@task_work_arrays = [] @task_work_arrays = []
@exercise_work_arrays = [] @exercise_work_arrays = []
count_1 = shixun_homeworks.count count_1 = shixun_homeworks.size
count_2 = common_homeworks.count count_2 = common_homeworks.size
count_3 = group_homeworks.count count_3 = group_homeworks.size
count_4 = tasks.count count_4 = tasks.size
count_5 = exercises.count count_5 = exercises.size
#实训作业 #实训作业
if count_1 > 0 shixun_homeworks.each_with_index do |s,index|
shixun_homeworks.each_with_index do |s,index| all_student_works = s.score_student_works #该实训题的全部用户回答
all_student_works = s.score_student_works #该实训题的全部用户回答 title_no = index.to_i + 1
title_no = index.to_i + 1 student_work_to_xlsx(all_student_works,s)
student_work_to_xlsx(all_student_works,s) shixun_work_display_name = format_sheet_name (title_no.to_s + "." + s.name).strip.first(30)
shixun_work_display_name = (title_no.to_s + "." + s.name).strip.first(30) shixun_work_content = [shixun_work_display_name,@work_head_cells,@work_cells_column]
shixun_work_content = [shixun_work_display_name,@work_head_cells,@work_cells_column] @shixun_work_arrays.push(shixun_work_content)
@shixun_work_arrays.push(shixun_work_content)
end
end end
#普通作业 #普通作业
if count_2 > 0 common_homeworks.each_with_index do |c,index|
common_homeworks.each_with_index do |c,index| all_student_works = c.score_student_works #当前用户的对该作业的回答
all_student_works = c.score_student_works #当前用户的对该作业的回答 title_no = count_1 + index.to_i + 1
title_no = count_1 + index.to_i + 1 student_work_to_xlsx(all_student_works,c)
student_work_to_xlsx(all_student_works,c)
work_name = format_sheet_name (title_no.to_s + "." + c.name).strip.first(30)
work_name = (title_no.to_s + "." + c.name).strip.first(30) work_content = [work_name,@work_head_cells,@work_cells_column]
work_content = [work_name,@work_head_cells,@work_cells_column] @common_work_arrays.push(work_content)
@common_work_arrays.push(work_content) title_no
title_no
end
end end
#分组作业 #分组作业
if count_3 > 0 group_homeworks.each_with_index do |c,index|
group_homeworks.each_with_index do |c,index| all_student_works = c.score_student_works #当前用户的对该作业的回答
all_student_works = c.score_student_works #当前用户的对该作业的回答 title_no = count_1 + count_2 + index.to_i + 1
title_no = count_1 + count_2 + index.to_i + 1 student_work_to_xlsx(all_student_works,c)
student_work_to_xlsx(all_student_works,c) work_name = format_sheet_name (title_no.to_s + "." + c.name).strip.first(30)
work_name = (title_no.to_s + "." + c.name).strip.first(30) work_content = [work_name,@work_head_cells,@work_cells_column]
work_content = [work_name,@work_head_cells,@work_cells_column] @group_work_arrays.push(work_content)
@group_work_arrays.push(work_content)
end
end end
#毕设任务 #毕设任务
if count_4 > 0 tasks.each_with_index do |c,index|
tasks.each_with_index do |c,index| all_student_works = c.score_graduation_works #当前用户的对该作业的回答
all_student_works = c.score_graduation_works #当前用户的对该作业的回答 title_no = count_1 + count_2 + count_3 + index.to_i + 1
title_no = count_1 + count_2 + count_3 + index.to_i + 1 graduation_work_to_xlsx(all_student_works,c,current_user)
graduation_work_to_xlsx(all_student_works,c,current_user) work_name = format_sheet_name (title_no.to_s + "." + c.name).strip.first(30)
work_name = (title_no.to_s + "." + c.name).strip.first(30) # work_content = [work_name,@work_head_cells,@work_cells_column]
# work_content = [work_name,@work_head_cells,@work_cells_column] work_content = [work_name,@head_cells_column,@task_cells_column]
work_content = [work_name,@head_cells_column,@task_cells_column] @task_work_arrays.push(work_content)
@task_work_arrays.push(work_content)
end
end end
#试卷的导出 #试卷的导出
if count_5 > 0 exercises.each_with_index do |c,index|
exercises.each_with_index do |c,index| all_student_works = c.score_exercise_users #当前用户的对该作业的回答
all_student_works = c.score_exercise_users #当前用户的对该作业的回答 title_no = count_1 + count_2 + count_3 + count_4 + index.to_i + 1
title_no = count_1 + count_2 + count_3 + count_4 + index.to_i + 1 get_export_users(c,course,all_student_works)
get_export_users(c,course,all_student_works) work_name = format_sheet_name (title_no.to_s + "." + c.exercise_name).strip.first(30)
work_name = (title_no.to_s + "." + c.exercise_name).strip.first(30) # work_content = [work_name,@work_head_cells,@work_cells_column]
# work_content = [work_name,@work_head_cells,@work_cells_column] work_content = [work_name,@table_columns,@user_columns]
work_content = [work_name,@table_columns,@user_columns] @exercise_work_arrays.push(work_content)
@exercise_work_arrays.push(work_content)
end
end end
end end
end end

@ -37,14 +37,14 @@ module ExportHelper
end end
normal_head_b_cells = %w(最终成绩 提交时间 更新时间 评语) normal_head_b_cells = %w(最终成绩 提交时间 更新时间 评语)
@work_head_cells = (head_cells_format + group_cells + normal_head_cells + head_cells_add + allow_late_cell + normal_head_b_cells).reject(&:blank?) @work_head_cells = (head_cells_format + group_cells + normal_head_cells + head_cells_add + allow_late_cell + normal_head_b_cells).reject(&:blank?)
works.includes(student_works_scores: :user).each_with_index do |w, index| works.includes(user: :user_extension, student_works_scores: :user).each_with_index do |w, index|
w_user = w.user w_user = w.user
w_1 = (index + 1) w_1 = (index + 1)
w_2 = w_user.login w_2 = w_user.login
w_3 = w_user.real_name w_3 = w_user.real_name
w_3_1 = w_user.mail w_3_1 = w_user.mail
w_4 = w_user.student_id.present? ? w_user.student_id : "--" w_4 = w_user.student_id.present? ? w_user.student_id : "--"
course_name = course.course_member(w.user_id).try(:course_group_name) course_name = course.students.find_by(user_id: w.user_id).try(:course_group_name)
w_5 = course_name.present? ? course_name : "--" w_5 = course_name.present? ? course_name : "--"
#0 未提交, 1 按时提交, 2 延迟提交 #0 未提交, 1 按时提交, 2 延迟提交
if w.work_status == 0 if w.work_status == 0
@ -118,7 +118,7 @@ module ExportHelper
end end
shixun_time_cells = %w(最终成绩 更新时间 提交耗时 评语) shixun_time_cells = %w(最终成绩 更新时间 提交耗时 评语)
@work_head_cells = (head_cells_format + shixun_head_cells + eff_score_cell + shixun_time_cells).reject(&:blank?) @work_head_cells = (head_cells_format + shixun_head_cells + eff_score_cell + shixun_time_cells).reject(&:blank?)
works.includes(:myshixun).each_with_index do |w, index| works.includes(:student_works_scores, user: :user_extension, myshixun: :games).each_with_index do |w, index|
myshixun = w.try(:myshixun) myshixun = w.try(:myshixun)
w_user = w.user w_user = w.user
w_1 = (index + 1) w_1 = (index + 1)
@ -126,7 +126,7 @@ module ExportHelper
w_3 = w_user.real_name w_3 = w_user.real_name
w_3_1 = w_user.mail w_3_1 = w_user.mail
w_4 = w_user.student_id.present? ? w_user.student_id : "--" w_4 = w_user.student_id.present? ? w_user.student_id : "--"
course_name = course.course_member(w.user_id).try(:course_group_name) course_name = course.students.find_by(user_id: w.user_id).try(:course_group_name)
w_5 = course_name.present? ? course_name : "--" w_5 = course_name.present? ? course_name : "--"
#0 未提交, 1 按时提交, 2 延迟提交 #0 未提交, 1 按时提交, 2 延迟提交
if w.work_status == 0 if w.work_status == 0
@ -138,7 +138,7 @@ module ExportHelper
else else
w_6 = "--" w_6 = "--"
end end
w_7 = w.work_status == 0 ? '--' : myshixun.try(:passed_count).to_s+"/"+shixun.challenges.count.to_s w_7 = w.work_status == 0 ? '--' : myshixun.try(:passed_count).to_s+"/"+shixun.challenges_count.to_s
w_8 = myshixun ? myshixun.try(:passed_time) == "--" ? "--" : format_time(myshixun.try(:passed_time)) : "--" # 通关时间 w_8 = myshixun ? myshixun.try(:passed_time) == "--" ? "--" : format_time(myshixun.try(:passed_time)) : "--" # 通关时间
w_9 = myshixun ? (myshixun.try(:passed_count) > 0 ? myshixun.total_spend_time : '--') : "--" #总耗时 w_9 = myshixun ? (myshixun.try(:passed_count) > 0 ? myshixun.total_spend_time : '--') : "--" #总耗时
w_10 = myshixun ? myshixun.output_times : 0 #评测次数 w_10 = myshixun ? myshixun.output_times : 0 #评测次数
@ -204,7 +204,7 @@ module ExportHelper
@head_cells_column = head_cells_format @head_cells_column = head_cells_format
@task_cells_column = [] @task_cells_column = []
items.each_with_index do |work,index| items.includes(user: :user_extension).each_with_index do |work,index|
w_1 = (index+1) w_1 = (index+1)
w_user = work.user w_user = work.user
w_2 = w_user.login w_2 = w_user.login
@ -260,7 +260,7 @@ module ExportHelper
else else
@table_columns = @table_columns + %w(最终成绩 开始答题时间 提交时间) @table_columns = @table_columns + %w(最终成绩 开始答题时间 提交时间)
end end
export_ex_users.each_with_index do |e_user,index| export_ex_users.includes(user: :user_extension).each_with_index do |e_user,index|
user_info = e_user.user user_info = e_user.user
member = course.students.find_by_user_id(e_user.user_id) member = course.students.find_by_user_id(e_user.user_id)
user_course = member.try(:course_group_name) user_course = member.try(:course_group_name)
@ -295,7 +295,7 @@ module ExportHelper
@topic_body_cells = [] @topic_body_cells = []
if students.count > 0 if students.count > 0
students.each_with_index do |student, index| students.includes(user: :user_extension).each_with_index do |student, index|
user = student.user user = student.user
student_topic = course.student_graduation_topics.user_topics_accept(user.id).first student_topic = course.student_graduation_topics.user_topics_accept(user.id).first
if student_topic.present? if student_topic.present?
@ -308,7 +308,7 @@ module ExportHelper
w_2 = user.login w_2 = user.login
w_3 = user.real_name w_3 = user.real_name
w_3_1 = user.mail w_3_1 = user.mail
w_4 = user.user_extension.student_id w_4 = user.student_id
w_5 = student.course_group_name w_5 = student.course_group_name
w_6 = topic.present? ? topic.name : "--" w_6 = topic.present? ? topic.name : "--"
w_7 = topic.present? ? topic.teacher.full_name : "--" w_7 = topic.present? ? topic.teacher.full_name : "--"
@ -504,4 +504,7 @@ module ExportHelper
attach.filename attach.filename
end end
def format_sheet_name name
name = name.gsub(":", "-")
end
end end

@ -18,7 +18,7 @@ class Myshixun < ApplicationRecord
end end
def output_times def output_times
games.sum(:evaluate_count) games.pluck(:evaluate_count).sum.to_i
end end
def repo_path def repo_path

Loading…
Cancel
Save