From 29eb9de257795dd1d48c41d9352c059f9261fabd Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Mon, 28 Oct 2019 15:19:51 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=9E=E8=AE=AD=E5=AF=BC=E5=87=BA=E6=88=90?= =?UTF-8?q?=E7=BB=A9=E5=A2=9E=E5=8A=A0=E8=AF=84=E8=AF=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/helpers/export_helper.rb | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/app/helpers/export_helper.rb b/app/helpers/export_helper.rb index 36120266b..75facc03f 100644 --- a/app/helpers/export_helper.rb +++ b/app/helpers/export_helper.rb @@ -112,7 +112,7 @@ module ExportHelper @work_cells_column.push(row_cells_column) end else #实训题 - shixun = homework.shixuns.first + shixun = homework.shixuns.take shixun_head_cells = %w(完成情况 通关时间 学员在EduCoder做实训花费的时间 总评测次数 获得经验值 关卡得分) eff_boolean = homework.work_efficiency if eff_boolean @@ -123,7 +123,10 @@ module ExportHelper if allow_late_boolean #允许迟交 eff_score_cell.push("迟交扣分") end - shixun_time_cells = %w(最终成绩 更新时间 作业发布到学员完成作业所耗的时间 评语) + shixun_time_cells = %w(最终成绩 更新时间 作业发布到学员完成作业所耗的时间 总评语) + for i in 1 .. shixun.challenges.size + shixun_time_cells << "第#{i}关评语" + end @work_head_cells = (head_cells_format + shixun_head_cells + eff_score_cell + shixun_time_cells).reject(&:blank?) works.includes(:student_works_scores, user: :user_extension, myshixun: :games).each_with_index do |w, index| myshixun = w.try(:myshixun) @@ -165,21 +168,20 @@ module ExportHelper w_16 = w.update_time ? format_time(w.update_time) : "--" "更新时间" myshixun_complete = myshixun && myshixun.status == 1 w_17 = myshixun_complete && w.cost_time ? (game_spend_time w.cost_time) : "未完成" - teacher_comments = w.student_works_scores - if teacher_comments.present? - w_18 = "" - teacher_comments.each do |t| - user_name = t.user&.real_name - user_time = format_time(t.updated_at) - user_score = t&.score - user_comment = t.comment.present? ? t.comment : "--" - comment_title = "#{user_name}: #{user_time.to_s} #{user_score.to_s}分\n#{user_comment}\n\n" - w_18 = w_18 + comment_title - end + teacher_comment = w.shixun_work_comments.find_by(challenge_id: 0) + if teacher_comment.present? + w_18 = "学生可见:\n #{teacher_comment.comment.to_s} \n\n 老师可见:\n#{teacher_comment.hidden_comment.to_s}" else w_18 = "--" end row_cells_column = [w_1,w_2,w_3,w_3_1,w_4,w_5,w_6,w_7,w_8,w_9,w_10,w_11,w_12,w_13,w_14,w_15,w_16,w_17,w_18] + + # 关卡评语 + shixun.challenges.pluck(:challenge_id) do |challenge_id| + challenge_comment = w.shixun_work_comments.find_by(challenge_id: challenge_id) + row_cells_column << "学生可见:\n #{challenge_comment.comment.to_s} \n\n 老师可见:\n#{challenge_comment.hidden_comment.to_s}" + end + row_cells_column = row_cells_column.reject(&:blank?) @work_cells_column.push(row_cells_column) end