From 77cee20dc65f1ec54e14a23d43efd7fd026feab5 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Fri, 28 Jun 2019 11:27:54 +0800 Subject: [PATCH 01/11] =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/courses_controller.rb | 24 ++++++++++++------------ app/models/exercise.rb | 2 +- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb index 10332752..2175aa3e 100644 --- a/app/controllers/courses_controller.rb +++ b/app/controllers/courses_controller.rb @@ -2437,8 +2437,8 @@ class CoursesController < ApplicationController sheet1[count_row,column+=1] = member.course_group_id == 0 ? "暂无" : member.course_group.name # current_col = 5 shixun_score = 0 - homeworks.where(:homework_type => 4).includes(:student_works).each do |homework| - student_works = homework.student_works.where("user_id = #{member.user.id}") + homeworks.where(:homework_type => 4).includes(:score_student_works).each do |homework| + student_works = homework.score_student_works.select{|work| work.user_id == member.user.id} if student_works.empty? sheet1[count_row,column+=1] = 0 else @@ -2449,8 +2449,8 @@ class CoursesController < ApplicationController # current_col += 1 end common_score = 0 - homeworks.where(:homework_type => 1).includes(:student_works).each do |homework| - student_works = homework.student_works.where("user_id = #{member.user.id}") + homeworks.where(:homework_type => 1).includes(:score_student_works).each do |homework| + student_works = homework.score_student_works.select{|work| work.user_id == member.user.id} if student_works.empty? sheet1[count_row,column+=1] = 0 else @@ -2461,8 +2461,8 @@ class CoursesController < ApplicationController # current_col += 1 end group_score = 0 - homeworks.where(:homework_type => 3).includes(:student_works).each do |homework| - student_works = homework.student_works.where("user_id = #{member.user.id}") + homeworks.where(:homework_type => 3).includes(:score_student_works).each do |homework| + student_works = homework.score_student_works.select{|work| work.user_id == member.user.id} if student_works.empty? sheet1[count_row,column+=1] = 0 else @@ -2473,8 +2473,8 @@ class CoursesController < ApplicationController # current_col += 1 end exercise_score = 0 - exercises.includes(:exercise_users).each do |exercise| - exercise_user = exercise.exercise_users.where("user_id = #{member.user.id}") + exercises.includes(:score_exercise_users).each do |exercise| + exercise_user = exercise.score_exercise_users.select{|work| work.user_id == member.user.id} if exercise_user.empty? sheet1[count_row,column+=1] = 0 else @@ -2562,7 +2562,7 @@ class CoursesController < ApplicationController count_row += 1 end - homeworks.where(:homework_type => 4).includes(:score_student_works).each_with_index do |home, i| + homeworks.where(:homework_type => 4).each_with_index do |home, i| sheet = book.create_worksheet :name => "#{home.name}" sheet[0,0] = "课程编号" sheet[0,1] = course.id @@ -2596,7 +2596,7 @@ class CoursesController < ApplicationController end end - homeworks.where(:homework_type => 1).includes(:score_student_works).each_with_index do |home, i| + homeworks.where(:homework_type => 1).each_with_index do |home, i| sheet = book.create_worksheet :name => "普通作业第#{i+1}次" sheet[0,0] = "课程编号" sheet[0,1] = course.id @@ -2643,7 +2643,7 @@ class CoursesController < ApplicationController end - homeworks.where(:homework_type => 3).includes(:score_student_works).each_with_index do |home, i| + homeworks.where(:homework_type => 3).each_with_index do |home, i| sheet = book.create_worksheet :name => "分组作业第#{i+1}次" sheet[0,0] = "课程编号" sheet[0,1] = course.id @@ -2691,7 +2691,7 @@ class CoursesController < ApplicationController end end - exercises.includes(:score_exercise_users).each_with_index do |exercise, i| + exercises.each_with_index do |exercise, i| sheet = book.create_worksheet :name => "试卷第#{i+1}次" sheet[0,0] = "课程编号" sheet[0,1] = course.id diff --git a/app/models/exercise.rb b/app/models/exercise.rb index f82b6047..cb65c5ce 100644 --- a/app/models/exercise.rb +++ b/app/models/exercise.rb @@ -7,7 +7,7 @@ class Exercise < ActiveRecord::Base has_many :exercise_group_settings, :dependent => :destroy has_many :exercise_questions, :dependent => :destroy,:order => "#{ExerciseQuestion.table_name}.question_number" has_many :exercise_users, :dependent => :destroy, :conditions => "exercise_users.is_delete = 0" - has_many :score_exercise_users, :conditions => "exercise_users.is_delete = 0 and commit_status != 0", :order => "exercise_users.score desc" + has_many :score_exercise_users, :class_name => "ExerciseUser", :conditions => "exercise_users.is_delete = 0 and commit_status != 0", :order => "exercise_users.score desc" has_many :users, :through => :exercise_users #该测试被哪些用户提交答案过 has_many :course_acts, :class_name => 'CourseActivity',:as =>:course_act ,:dependent => :destroy # 课程消息 From d3b2e47dc0b6c0d41b05ccc1702a9738c49cbd8d Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Fri, 28 Jun 2019 12:49:57 +0800 Subject: [PATCH 02/11] =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/courses_controller.rb | 484 +++++++++++++------------- 1 file changed, 242 insertions(+), 242 deletions(-) diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb index 2175aa3e..f219d06f 100644 --- a/app/controllers/courses_controller.rb +++ b/app/controllers/courses_controller.rb @@ -2562,248 +2562,248 @@ class CoursesController < ApplicationController count_row += 1 end - homeworks.where(:homework_type => 4).each_with_index do |home, i| - sheet = book.create_worksheet :name => "#{home.name}" - sheet[0,0] = "课程编号" - sheet[0,1] = course.id - sheet[1,0] = "课程名称" - sheet[1,1] = course.name - sheet[2,0] = "教师团队" - sheet[2,1] = teacher_co - sheet[3,0] = "主讲教师" - sheet[3,1] = course.teacher.show_real_name - sheet[3,0] = "作业批次" - sheet[3,1] = "第#{i+1}次" - sheet[3,0] = "作业名称" - sheet[3,1] = home.name - sheet.row(4).concat([l(:excel_rank),l(:excel_user_name),l(:excel_nickname),l(:excel_student_id),l(:excel_homework_des),l(:excel_l_penalty),l(:excel_f_score),l(:excel_commit_time)]) - count_row = 5 - items = home.score_student_works - # if items.count == 0 && home.publish_time < Time.now && !course.is_end - # update_shixun_work_status home - # items = StudentWork.where("work_status != 0 and homework_common_id = #{home.id}").order("work_score desc") - # end - items.each_with_index do |stu, j| - sheet[count_row,0]= j + 1 - sheet[count_row,1] = stu.user.show_real_name - sheet[count_row,2] = stu.user.login - sheet[count_row,3] = stu.user.user_extensions.student_id - sheet[count_row,4] = strip_html stu.description - sheet[count_row,5] = stu.late_penalty - sheet[count_row,6] = stu.work_score.nil? ? l(:label_without_score) : stu.work_score.round(1) - sheet[count_row,7] = format_time(stu.commit_time) - count_row += 1 - end - end - - homeworks.where(:homework_type => 1).each_with_index do |home, i| - sheet = book.create_worksheet :name => "普通作业第#{i+1}次" - sheet[0,0] = "课程编号" - sheet[0,1] = course.id - sheet[1,0] = "课程名称" - sheet[1,1] = course.name - sheet[2,0] = "教师团队" - sheet[2,1] = teacher_co - sheet[3,0] = "主讲教师" - sheet[3,1] = course.teacher.show_real_name - sheet[3,0] = "作业批次" - sheet[3,1] = "第#{i+1}次" - sheet[3,0] = "作业名称" - sheet[3,1] = home.name - if home.anonymous_comment ==0 - sheet.row(4).concat([l(:excel_rank),l(:excel_user_name),l(:excel_nickname),l(:excel_student_id),l(:excel_homework_des), - l(:excel_t_score),l(:excel_ta_score), l(:excel_n_score),l(:excel_a_penalty),l(:excel_l_penalty),l(:excel_f_score),l(:excel_commit_time)]) - else - sheet.row(4).concat([l(:excel_rank),l(:excel_user_name),l(:excel_nickname),l(:excel_student_id),l(:excel_homework_des), - l(:excel_t_score),l(:excel_ta_score),l(:excel_l_penalty),l(:excel_f_score),l(:excel_commit_time)]) - end - count_row = 5 - items = home.score_student_works - items.each_with_index do |stu, j| - sheet[count_row,0]= j + 1 - sheet[count_row,1] = stu.user.show_real_name - sheet[count_row,2] = stu.user.login - sheet[count_row,3] = stu.user.user_extensions.student_id - sheet[count_row,4] = strip_html stu.description - sheet[count_row,5] = stu.teacher_score.nil? ? l(:label_without_score) : stu.teacher_score.round(1) - sheet[count_row,6] = stu.teaching_asistant_score.nil? ? l(:label_without_score) : stu.teaching_asistant_score.round(1) - if home.anonymous_comment ==0 - sheet[count_row,7] = stu.student_score.nil? ? l(:label_without_score) : stu.student_score.round(1) - sheet[count_row,8] = (home.teacher_priority == 1 && !stu.teacher_score.nil?) ? 0 : stu.absence_penalty - sheet[count_row,9] = (home.teacher_priority == 1 && !stu.teacher_score.nil?) ? 0 : stu.late_penalty - sheet[count_row,10] = stu.work_score.nil? ? l(:label_without_score) : stu.work_score.round(1) - sheet[count_row,11] = format_time(stu.commit_time) - else - sheet[count_row,7] = (home.teacher_priority == 1 && !stu.teacher_score.nil?) ? 0 : stu.late_penalty - sheet[count_row,8] = stu.work_score.nil? ? l(:label_without_score) : stu.work_score.round(1) - sheet[count_row,9] = format_time(stu.commit_time) - end - count_row += 1 - end - - end - - homeworks.where(:homework_type => 3).each_with_index do |home, i| - sheet = book.create_worksheet :name => "分组作业第#{i+1}次" - sheet[0,0] = "课程编号" - sheet[0,1] = course.id - sheet[1,0] = "课程名称" - sheet[1,1] = course.name - sheet[2,0] = "教师团队" - sheet[2,1] = teacher_co - sheet[3,0] = "主讲教师" - sheet[3,1] = course.teacher.show_real_name - sheet[3,0] = "作业批次" - sheet[3,1] = "第#{i+1}次" - sheet[3,0] = "作业名称" - sheet[3,1] = home.name - - if home.anonymous_comment ==0 - sheet.row(4).concat([l(:excel_rank),l(:excel_user_name),l(:excel_nickname),l(:excel_student_id),l(:excel_group_member),l(:excel_homework_des), - l(:excel_t_score),l(:excel_ta_score),l(:excel_n_score),l(:excel_a_penalty),l(:excel_l_penalty),l(:excel_f_score),l(:excel_commit_time)]) - else - sheet.row(4).concat([l(:excel_rank),l(:excel_user_name),l(:excel_nickname),l(:excel_student_id),l(:excel_group_member),l(:excel_homework_des), - l(:excel_t_score),l(:excel_ta_score),l(:excel_l_penalty),l(:excel_f_score),l(:excel_commit_time)]) - end - count_row = 5 - items = home.score_student_works - items.each_with_index do |stu, j| - sheet[count_row,0] = j + 1 - sheet[count_row,1] = stu.user.show_real_name - sheet[count_row,2] = stu.user.login - sheet[count_row,3] = stu.user.user_extensions.student_id - sheet[count_row,4] = get_group_member_names home.student_works.where(:group_id => stu.group_id).pluck(:user_id) - sheet[count_row,5] = strip_html stu.description - sheet[count_row,6] = stu.teacher_score.nil? ? l(:label_without_score) : stu.teacher_score.round(1) - sheet[count_row,7] = stu.teaching_asistant_score.nil? ? l(:label_without_score) : stu.teaching_asistant_score.round(1) - if home.anonymous_comment ==0 - sheet[count_row,8] = stu.student_score.nil? ? l(:label_without_score) : stu.student_score.round(1) - sheet[count_row,9] = (home.teacher_priority == 1 && !stu.teacher_score.nil?) ? 0 : stu.absence_penalty - sheet[count_row,10] = (home.teacher_priority == 1 && !stu.teacher_score.nil?) ? 0 : stu.late_penalty - sheet[count_row,11] = stu.work_score.nil? ? l(:label_without_score) : stu.work_score.round(1) - sheet[count_row,12] = format_time(stu.commit_time) - else - sheet[count_row,8] = (home.teacher_priority == 1 && !stu.teacher_score.nil?) ? 0 : stu.late_penalty - sheet[count_row,9] = stu.work_score.nil? ? l(:label_without_score) : stu.work_score.round(1) - sheet[count_row,10] = format_time(stu.commit_time) - end - count_row += 1 - end - end - - exercises.each_with_index do |exercise, i| - sheet = book.create_worksheet :name => "试卷第#{i+1}次" - sheet[0,0] = "课程编号" - sheet[0,1] = course.id - sheet[1,0] = "课程名称" - sheet[1,1] = course.name - sheet[3,0] = "教师团队" - sheet[3,1] = teacher_co - sheet[3,0] = "主讲教师" - sheet[3,1] = course.teacher.show_real_name - sheet[3,0] = "试卷批次" - sheet[3,1] = "第#{i+1}次" - sheet[3,0] = "试卷名称" - sheet[3,1] = exercise.exercise_name - - sheet.row(4).concat([l(:excel_rank),l(:excel_user_name),l(:excel_nickname),l(:excel_student_id),l(:excel_objective_score),l(:excel_subjective_score),l(:excel_f_score),l(:excel_answer_time)]) - count_row = 5 - items = exercise.score_exercise_users - items.each_with_index do |stu, j| - sheet[count_row,0] = j + 1 - sheet[count_row,1] = stu.user.show_real_name - sheet[count_row,2] = stu.user.login - sheet[count_row,3] = stu.user.user_extensions.student_id - sheet[count_row,4] = stu.objective_score == -1 ? "0.0" : format("%.1f",stu.objective_score) - sheet[count_row,5] = stu.subjective_score == -1 ? "0.0" : format("%.1f",stu.subjective_score) - sheet[count_row,6] = stu.score.nil? ? '--' : stu.score.round(1) - sheet[count_row,7] = stu.commit_status == 0 ? l(:excel_no_answer) : format_time(stu.start_at) - count_row += 1 - end - end - - tasks.each_with_index do |task, i| - sheet = book.create_worksheet :name => "毕设任务第#{i+1}次" - sheet[0,0] = "课程编号" - sheet[0,1] = course.id - sheet[1,0] = "课程名称" - sheet[1,1] = course.name - sheet[2,0] = "教师团队" - sheet[2,1] = teacher_co - sheet[3,0] = "主讲教师" - sheet[3,1] = course.teacher.show_real_name - sheet[3,0] = "作业批次" - sheet[3,1] = "第#{i+1}次" - sheet[3,0] = "作业名称" - sheet[3,1] = task.name - sheet.row(4).concat([l(:excel_rank),l(:excel_user_name),l(:excel_nickname),l(:excel_student_id)]) - if task.task_type == 2 - sheet.row(4).concat([l(:excel_group_member)]) - end - sheet.row(4).concat([l(:excel_homework_des), l(:excel_t_score)]) - if task.cross_comment - sheet.row(4).concat(["交叉评分"]) - end - sheet.row(4).concat([l(:excel_l_penalty),l(:excel_f_score),l(:excel_commit_time)]) - count_row = 5 - items = task.graduation_works.where("work_status != 0").order("work_score desc") - items.each_with_index do |stu, j| - column = 0 - sheet[count_row,column]= j + 1 - sheet[count_row,column+=1] = stu.user.show_real_name - sheet[count_row,column+=1] = stu.user.login - sheet[count_row,column+=1] = stu.user.user_extensions.student_id - if task.task_type == 2 - sheet[count_row,column+=1] = get_group_member_names task.graduation_works.where(:group_id => stu.group_id).pluck(:user_id) - end - sheet[count_row,column+=1] = strip_html stu.description - sheet[count_row,column+=1] = stu.teacher_score.nil? ? l(:label_without_score) : stu.teacher_score.round(1) - if task.cross_comment - sheet[count_row,column+=1] = stu.cross_score.nil? ? l(:label_without_score) : stu.cross_score.round(1) - end - sheet[count_row,column+=1] = stu.late_penalty - sheet[count_row,column+=1] = stu.work_score.nil? ? l(:label_without_score) : stu.work_score.round(1) - sheet[count_row,column+=1] = format_time(stu.commit_time) - count_row += 1 - end -=begin - if task.task_type == 1 - if task.cross_comment - sheet.row(4).concat([l(:excel_rank),l(:excel_user_name),l(:excel_nickname),l(:excel_student_id),l(:excel_homework_des), - l(:excel_t_score),"交叉评分",l(:excel_l_penalty),l(:excel_f_score),l(:excel_commit_time)]) - else - sheet.row(4).concat([l(:excel_rank),l(:excel_user_name),l(:excel_nickname),l(:excel_student_id),l(:excel_homework_des), - l(:excel_t_score),l(:excel_l_penalty),l(:excel_f_score),l(:excel_commit_time)]) - end - else - if task.cross_comment - sheet.row(4).concat([l(:excel_rank),l(:excel_user_name),l(:excel_nickname),l(:excel_student_id),l(:excel_group_member),l(:excel_homework_des), - l(:excel_t_score),"交叉评分",l(:excel_l_penalty),l(:excel_f_score),l(:excel_commit_time)]) - else - sheet.row(4).concat([l(:excel_rank),l(:excel_user_name),l(:excel_nickname),l(:excel_student_id),l(:excel_group_member),l(:excel_homework_des), - l(:excel_t_score),l(:excel_l_penalty),l(:excel_f_score),l(:excel_commit_time)]) - end - count_row = 5 - items = task.graduation_works.order("work_score desc") - items.each_with_index do |stu, j| - column = 0 - sheet[count_row,column]= j + 1 - sheet[count_row,column+1] = stu.user.show_name - sheet[count_row,column+1] = stu.user.login - sheet[count_row,column+1] = stu.user.user_extensions.student_id - sheet[count_row,column+1] = strip_html stu.description - sheet[count_row,column+1] = stu.teacher_score.nil? ? l(:label_without_score) : stu.teacher_score.round(2) - if task.cross_comment - sheet[count_row,column+1] = stu.cross_score.nil? ? l(:label_without_score) : stu.cross_score.round(2) - end - sheet[count_row,column+1] = stu.late_penalty - sheet[count_row,column+1] = stu.work_score.nil? ? l(:label_without_score) : stu.work_score.round(2) - sheet[count_row,column+1] = format_time(stu.commit_time) - count_row += 1 - end - end -=end - end +# homeworks.where(:homework_type => 4).each_with_index do |home, i| +# sheet = book.create_worksheet :name => "#{home.name}" +# sheet[0,0] = "课程编号" +# sheet[0,1] = course.id +# sheet[1,0] = "课程名称" +# sheet[1,1] = course.name +# sheet[2,0] = "教师团队" +# sheet[2,1] = teacher_co +# sheet[3,0] = "主讲教师" +# sheet[3,1] = course.teacher.show_real_name +# sheet[3,0] = "作业批次" +# sheet[3,1] = "第#{i+1}次" +# sheet[3,0] = "作业名称" +# sheet[3,1] = home.name +# sheet.row(4).concat([l(:excel_rank),l(:excel_user_name),l(:excel_nickname),l(:excel_student_id),l(:excel_homework_des),l(:excel_l_penalty),l(:excel_f_score),l(:excel_commit_time)]) +# count_row = 5 +# items = home.score_student_works +# # if items.count == 0 && home.publish_time < Time.now && !course.is_end +# # update_shixun_work_status home +# # items = StudentWork.where("work_status != 0 and homework_common_id = #{home.id}").order("work_score desc") +# # end +# items.each_with_index do |stu, j| +# sheet[count_row,0]= j + 1 +# sheet[count_row,1] = stu.user.show_real_name +# sheet[count_row,2] = stu.user.login +# sheet[count_row,3] = stu.user.user_extensions.student_id +# sheet[count_row,4] = strip_html stu.description +# sheet[count_row,5] = stu.late_penalty +# sheet[count_row,6] = stu.work_score.nil? ? l(:label_without_score) : stu.work_score.round(1) +# sheet[count_row,7] = format_time(stu.commit_time) +# count_row += 1 +# end +# end +# +# homeworks.where(:homework_type => 1).each_with_index do |home, i| +# sheet = book.create_worksheet :name => "普通作业第#{i+1}次" +# sheet[0,0] = "课程编号" +# sheet[0,1] = course.id +# sheet[1,0] = "课程名称" +# sheet[1,1] = course.name +# sheet[2,0] = "教师团队" +# sheet[2,1] = teacher_co +# sheet[3,0] = "主讲教师" +# sheet[3,1] = course.teacher.show_real_name +# sheet[3,0] = "作业批次" +# sheet[3,1] = "第#{i+1}次" +# sheet[3,0] = "作业名称" +# sheet[3,1] = home.name +# if home.anonymous_comment ==0 +# sheet.row(4).concat([l(:excel_rank),l(:excel_user_name),l(:excel_nickname),l(:excel_student_id),l(:excel_homework_des), +# l(:excel_t_score),l(:excel_ta_score), l(:excel_n_score),l(:excel_a_penalty),l(:excel_l_penalty),l(:excel_f_score),l(:excel_commit_time)]) +# else +# sheet.row(4).concat([l(:excel_rank),l(:excel_user_name),l(:excel_nickname),l(:excel_student_id),l(:excel_homework_des), +# l(:excel_t_score),l(:excel_ta_score),l(:excel_l_penalty),l(:excel_f_score),l(:excel_commit_time)]) +# end +# count_row = 5 +# items = home.score_student_works +# items.each_with_index do |stu, j| +# sheet[count_row,0]= j + 1 +# sheet[count_row,1] = stu.user.show_real_name +# sheet[count_row,2] = stu.user.login +# sheet[count_row,3] = stu.user.user_extensions.student_id +# sheet[count_row,4] = strip_html stu.description +# sheet[count_row,5] = stu.teacher_score.nil? ? l(:label_without_score) : stu.teacher_score.round(1) +# sheet[count_row,6] = stu.teaching_asistant_score.nil? ? l(:label_without_score) : stu.teaching_asistant_score.round(1) +# if home.anonymous_comment ==0 +# sheet[count_row,7] = stu.student_score.nil? ? l(:label_without_score) : stu.student_score.round(1) +# sheet[count_row,8] = (home.teacher_priority == 1 && !stu.teacher_score.nil?) ? 0 : stu.absence_penalty +# sheet[count_row,9] = (home.teacher_priority == 1 && !stu.teacher_score.nil?) ? 0 : stu.late_penalty +# sheet[count_row,10] = stu.work_score.nil? ? l(:label_without_score) : stu.work_score.round(1) +# sheet[count_row,11] = format_time(stu.commit_time) +# else +# sheet[count_row,7] = (home.teacher_priority == 1 && !stu.teacher_score.nil?) ? 0 : stu.late_penalty +# sheet[count_row,8] = stu.work_score.nil? ? l(:label_without_score) : stu.work_score.round(1) +# sheet[count_row,9] = format_time(stu.commit_time) +# end +# count_row += 1 +# end +# +# end +# +# homeworks.where(:homework_type => 3).each_with_index do |home, i| +# sheet = book.create_worksheet :name => "分组作业第#{i+1}次" +# sheet[0,0] = "课程编号" +# sheet[0,1] = course.id +# sheet[1,0] = "课程名称" +# sheet[1,1] = course.name +# sheet[2,0] = "教师团队" +# sheet[2,1] = teacher_co +# sheet[3,0] = "主讲教师" +# sheet[3,1] = course.teacher.show_real_name +# sheet[3,0] = "作业批次" +# sheet[3,1] = "第#{i+1}次" +# sheet[3,0] = "作业名称" +# sheet[3,1] = home.name +# +# if home.anonymous_comment ==0 +# sheet.row(4).concat([l(:excel_rank),l(:excel_user_name),l(:excel_nickname),l(:excel_student_id),l(:excel_group_member),l(:excel_homework_des), +# l(:excel_t_score),l(:excel_ta_score),l(:excel_n_score),l(:excel_a_penalty),l(:excel_l_penalty),l(:excel_f_score),l(:excel_commit_time)]) +# else +# sheet.row(4).concat([l(:excel_rank),l(:excel_user_name),l(:excel_nickname),l(:excel_student_id),l(:excel_group_member),l(:excel_homework_des), +# l(:excel_t_score),l(:excel_ta_score),l(:excel_l_penalty),l(:excel_f_score),l(:excel_commit_time)]) +# end +# count_row = 5 +# items = home.score_student_works +# items.each_with_index do |stu, j| +# sheet[count_row,0] = j + 1 +# sheet[count_row,1] = stu.user.show_real_name +# sheet[count_row,2] = stu.user.login +# sheet[count_row,3] = stu.user.user_extensions.student_id +# sheet[count_row,4] = get_group_member_names home.student_works.where(:group_id => stu.group_id).pluck(:user_id) +# sheet[count_row,5] = strip_html stu.description +# sheet[count_row,6] = stu.teacher_score.nil? ? l(:label_without_score) : stu.teacher_score.round(1) +# sheet[count_row,7] = stu.teaching_asistant_score.nil? ? l(:label_without_score) : stu.teaching_asistant_score.round(1) +# if home.anonymous_comment ==0 +# sheet[count_row,8] = stu.student_score.nil? ? l(:label_without_score) : stu.student_score.round(1) +# sheet[count_row,9] = (home.teacher_priority == 1 && !stu.teacher_score.nil?) ? 0 : stu.absence_penalty +# sheet[count_row,10] = (home.teacher_priority == 1 && !stu.teacher_score.nil?) ? 0 : stu.late_penalty +# sheet[count_row,11] = stu.work_score.nil? ? l(:label_without_score) : stu.work_score.round(1) +# sheet[count_row,12] = format_time(stu.commit_time) +# else +# sheet[count_row,8] = (home.teacher_priority == 1 && !stu.teacher_score.nil?) ? 0 : stu.late_penalty +# sheet[count_row,9] = stu.work_score.nil? ? l(:label_without_score) : stu.work_score.round(1) +# sheet[count_row,10] = format_time(stu.commit_time) +# end +# count_row += 1 +# end +# end +# +# exercises.each_with_index do |exercise, i| +# sheet = book.create_worksheet :name => "试卷第#{i+1}次" +# sheet[0,0] = "课程编号" +# sheet[0,1] = course.id +# sheet[1,0] = "课程名称" +# sheet[1,1] = course.name +# sheet[3,0] = "教师团队" +# sheet[3,1] = teacher_co +# sheet[3,0] = "主讲教师" +# sheet[3,1] = course.teacher.show_real_name +# sheet[3,0] = "试卷批次" +# sheet[3,1] = "第#{i+1}次" +# sheet[3,0] = "试卷名称" +# sheet[3,1] = exercise.exercise_name +# +# sheet.row(4).concat([l(:excel_rank),l(:excel_user_name),l(:excel_nickname),l(:excel_student_id),l(:excel_objective_score),l(:excel_subjective_score),l(:excel_f_score),l(:excel_answer_time)]) +# count_row = 5 +# items = exercise.score_exercise_users +# items.each_with_index do |stu, j| +# sheet[count_row,0] = j + 1 +# sheet[count_row,1] = stu.user.show_real_name +# sheet[count_row,2] = stu.user.login +# sheet[count_row,3] = stu.user.user_extensions.student_id +# sheet[count_row,4] = stu.objective_score == -1 ? "0.0" : format("%.1f",stu.objective_score) +# sheet[count_row,5] = stu.subjective_score == -1 ? "0.0" : format("%.1f",stu.subjective_score) +# sheet[count_row,6] = stu.score.nil? ? '--' : stu.score.round(1) +# sheet[count_row,7] = stu.commit_status == 0 ? l(:excel_no_answer) : format_time(stu.start_at) +# count_row += 1 +# end +# end +# +# tasks.each_with_index do |task, i| +# sheet = book.create_worksheet :name => "毕设任务第#{i+1}次" +# sheet[0,0] = "课程编号" +# sheet[0,1] = course.id +# sheet[1,0] = "课程名称" +# sheet[1,1] = course.name +# sheet[2,0] = "教师团队" +# sheet[2,1] = teacher_co +# sheet[3,0] = "主讲教师" +# sheet[3,1] = course.teacher.show_real_name +# sheet[3,0] = "作业批次" +# sheet[3,1] = "第#{i+1}次" +# sheet[3,0] = "作业名称" +# sheet[3,1] = task.name +# sheet.row(4).concat([l(:excel_rank),l(:excel_user_name),l(:excel_nickname),l(:excel_student_id)]) +# if task.task_type == 2 +# sheet.row(4).concat([l(:excel_group_member)]) +# end +# sheet.row(4).concat([l(:excel_homework_des), l(:excel_t_score)]) +# if task.cross_comment +# sheet.row(4).concat(["交叉评分"]) +# end +# sheet.row(4).concat([l(:excel_l_penalty),l(:excel_f_score),l(:excel_commit_time)]) +# count_row = 5 +# items = task.graduation_works.where("work_status != 0").order("work_score desc") +# items.each_with_index do |stu, j| +# column = 0 +# sheet[count_row,column]= j + 1 +# sheet[count_row,column+=1] = stu.user.show_real_name +# sheet[count_row,column+=1] = stu.user.login +# sheet[count_row,column+=1] = stu.user.user_extensions.student_id +# if task.task_type == 2 +# sheet[count_row,column+=1] = get_group_member_names task.graduation_works.where(:group_id => stu.group_id).pluck(:user_id) +# end +# sheet[count_row,column+=1] = strip_html stu.description +# sheet[count_row,column+=1] = stu.teacher_score.nil? ? l(:label_without_score) : stu.teacher_score.round(1) +# if task.cross_comment +# sheet[count_row,column+=1] = stu.cross_score.nil? ? l(:label_without_score) : stu.cross_score.round(1) +# end +# sheet[count_row,column+=1] = stu.late_penalty +# sheet[count_row,column+=1] = stu.work_score.nil? ? l(:label_without_score) : stu.work_score.round(1) +# sheet[count_row,column+=1] = format_time(stu.commit_time) +# count_row += 1 +# end +# =begin +# if task.task_type == 1 +# if task.cross_comment +# sheet.row(4).concat([l(:excel_rank),l(:excel_user_name),l(:excel_nickname),l(:excel_student_id),l(:excel_homework_des), +# l(:excel_t_score),"交叉评分",l(:excel_l_penalty),l(:excel_f_score),l(:excel_commit_time)]) +# else +# sheet.row(4).concat([l(:excel_rank),l(:excel_user_name),l(:excel_nickname),l(:excel_student_id),l(:excel_homework_des), +# l(:excel_t_score),l(:excel_l_penalty),l(:excel_f_score),l(:excel_commit_time)]) +# end +# else +# if task.cross_comment +# sheet.row(4).concat([l(:excel_rank),l(:excel_user_name),l(:excel_nickname),l(:excel_student_id),l(:excel_group_member),l(:excel_homework_des), +# l(:excel_t_score),"交叉评分",l(:excel_l_penalty),l(:excel_f_score),l(:excel_commit_time)]) +# else +# sheet.row(4).concat([l(:excel_rank),l(:excel_user_name),l(:excel_nickname),l(:excel_student_id),l(:excel_group_member),l(:excel_homework_des), +# l(:excel_t_score),l(:excel_l_penalty),l(:excel_f_score),l(:excel_commit_time)]) +# end +# count_row = 5 +# items = task.graduation_works.order("work_score desc") +# items.each_with_index do |stu, j| +# column = 0 +# sheet[count_row,column]= j + 1 +# sheet[count_row,column+1] = stu.user.show_name +# sheet[count_row,column+1] = stu.user.login +# sheet[count_row,column+1] = stu.user.user_extensions.student_id +# sheet[count_row,column+1] = strip_html stu.description +# sheet[count_row,column+1] = stu.teacher_score.nil? ? l(:label_without_score) : stu.teacher_score.round(2) +# if task.cross_comment +# sheet[count_row,column+1] = stu.cross_score.nil? ? l(:label_without_score) : stu.cross_score.round(2) +# end +# sheet[count_row,column+1] = stu.late_penalty +# sheet[count_row,column+1] = stu.work_score.nil? ? l(:label_without_score) : stu.work_score.round(2) +# sheet[count_row,column+1] = format_time(stu.commit_time) +# count_row += 1 +# end +# end +# =end +# end book.write xls_report xls_report.string From cf6c2912d74fc0ccfb0a00fce44591cde1dcd426 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Fri, 28 Jun 2019 13:42:51 +0800 Subject: [PATCH 03/11] =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/courses_controller.rb | 817 +++++++++++++------------- 1 file changed, 409 insertions(+), 408 deletions(-) diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb index f219d06f..4bc69dd5 100644 --- a/app/controllers/courses_controller.rb +++ b/app/controllers/courses_controller.rb @@ -2381,430 +2381,431 @@ class CoursesController < ApplicationController def member_to_xls homeworks, exercises, tasks, course, members, groups xls_report = StringIO.new book = Spreadsheet::Workbook.new - sheet1 = book.create_worksheet :name => "总成绩" - blue = Spreadsheet::Format.new :color => :blue, :weight => :bold, :size => 10 - #sheet1.row(0).default_format = blue - #sheet1.row(0).concat([l(:excel_user_id),l(:excel_user_name),l(:excel_nickname),l(:excel_student_id),l(:excel_mail),l(:excel_class),l(:excel_f_score),l(:excel_commit_time)]) + # sheet1 = book.create_worksheet :name => "总成绩" + # blue = Spreadsheet::Format.new :color => :blue, :weight => :bold, :size => 10 + # #sheet1.row(0).default_format = blue + # #sheet1.row(0).concat([l(:excel_user_id),l(:excel_user_name),l(:excel_nickname),l(:excel_student_id),l(:excel_mail),l(:excel_class),l(:excel_f_score),l(:excel_commit_time)]) teacher_co = (searchTeacherAndAssistant course).map{|member| member.user.show_real_name}.join('、') - sheet1[0,0] = "课程编号" - sheet1[0,1] = course.id - sheet1[1,0] = "课程名称" - sheet1[1,1] = course.name - sheet1[2,0] = "教师团队" - sheet1[2,1] = teacher_co - sheet1[3,0] = "主讲教师" - sheet1[3,1] = course.teacher.show_real_name - sheet1[4,0] = "排名" - sheet1[4,1] = "学生姓名" - sheet1[4,2] = "昵称" - sheet1[4,3] = "邮箱" - sheet1[4,4] = "学号" - sheet1[4,5] = "分班" - current_col = 5 - homeworks.where(:homework_type => 4).each do |homework| - sheet1[4,current_col+=1] = "#{homework.name}" - end - for i in 0 ... homeworks.where(:homework_type => 1).size - sheet1[4,current_col+=1] = "普通作业第"+(i+1).to_s+"次" - end - for i in 0 ... homeworks.where(:homework_type => 3).size - sheet1[4,current_col+=1] = "分组作业第"+(i+1).to_s+"次" - end - for i in 0 ... exercises.size - sheet1[4,current_col+=1] = "试卷第"+(i+1).to_s+"次" - end - for i in 0 ... tasks.size - sheet1[4,current_col+=1] = "毕设任务第"+(i+1).to_s+"次" - end - - sheet1[4,current_col+=1] = "实训作业总得分" - sheet1[4,current_col+=1] = "普通作业总得分" - sheet1[4,current_col+=1] = "分组作业总得分" - sheet1[4,current_col+=1] = "试卷总得分" - if tasks.count > 0 - sheet1[4,current_col+=1] = "毕设任务总得分" - end - #sheet1[6,homeworks.count+6] = "社区得分" - sheet1[4,current_col+=1] = "总得分" - count_row = 5 - members.each_with_index do |member, i| - column = 0 - sheet1[count_row,column]= i+1 - sheet1[count_row,column+=1] = member.user.show_real_name - sheet1[count_row,column+=1] = member.user.login - sheet1[count_row,column+=1] = member.user.mail - sheet1[count_row,column+=1] = member.user.user_extensions.student_id - sheet1[count_row,column+=1] = member.course_group_id == 0 ? "暂无" : member.course_group.name - # current_col = 5 - shixun_score = 0 - homeworks.where(:homework_type => 4).includes(:score_student_works).each do |homework| - student_works = homework.score_student_works.select{|work| work.user_id == member.user.id} - if student_works.empty? - sheet1[count_row,column+=1] = 0 - else - work_score = student_works.first.work_score.nil? ? 0 : student_works.first.work_score - sheet1[count_row,column+=1] = work_score < 0 ? 0 : work_score.round(1) - shixun_score += work_score < 0 ? 0 : work_score.round(1) - end - # current_col += 1 + # sheet1[0,0] = "课程编号" + # sheet1[0,1] = course.id + # sheet1[1,0] = "课程名称" + # sheet1[1,1] = course.name + # sheet1[2,0] = "教师团队" + # sheet1[2,1] = teacher_co + # sheet1[3,0] = "主讲教师" + # sheet1[3,1] = course.teacher.show_real_name + # sheet1[4,0] = "排名" + # sheet1[4,1] = "学生姓名" + # sheet1[4,2] = "昵称" + # sheet1[4,3] = "邮箱" + # sheet1[4,4] = "学号" + # sheet1[4,5] = "分班" + # current_col = 5 + # homeworks.where(:homework_type => 4).each do |homework| + # sheet1[4,current_col+=1] = "#{homework.name}" + # end + # for i in 0 ... homeworks.where(:homework_type => 1).size + # sheet1[4,current_col+=1] = "普通作业第"+(i+1).to_s+"次" + # end + # for i in 0 ... homeworks.where(:homework_type => 3).size + # sheet1[4,current_col+=1] = "分组作业第"+(i+1).to_s+"次" + # end + # for i in 0 ... exercises.size + # sheet1[4,current_col+=1] = "试卷第"+(i+1).to_s+"次" + # end + # for i in 0 ... tasks.size + # sheet1[4,current_col+=1] = "毕设任务第"+(i+1).to_s+"次" + # end + # + # sheet1[4,current_col+=1] = "实训作业总得分" + # sheet1[4,current_col+=1] = "普通作业总得分" + # sheet1[4,current_col+=1] = "分组作业总得分" + # sheet1[4,current_col+=1] = "试卷总得分" + # if tasks.count > 0 + # sheet1[4,current_col+=1] = "毕设任务总得分" + # end + # #sheet1[6,homeworks.count+6] = "社区得分" + # sheet1[4,current_col+=1] = "总得分" + # count_row = 5 + # members.each_with_index do |member, i| + # column = 0 + # sheet1[count_row,column]= i+1 + # sheet1[count_row,column+=1] = member.user.show_real_name + # sheet1[count_row,column+=1] = member.user.login + # sheet1[count_row,column+=1] = member.user.mail + # sheet1[count_row,column+=1] = member.user.user_extensions.student_id + # sheet1[count_row,column+=1] = member.course_group_id == 0 ? "暂无" : member.course_group.name + # # current_col = 5 + # shixun_score = 0 + # homeworks.where(:homework_type => 4).includes(:score_student_works).each do |homework| + # student_works = homework.score_student_works.select{|work| work.user_id == member.user.id} + # if student_works.empty? + # sheet1[count_row,column+=1] = 0 + # else + # work_score = student_works.first.work_score.nil? ? 0 : student_works.first.work_score + # sheet1[count_row,column+=1] = work_score < 0 ? 0 : work_score.round(1) + # shixun_score += work_score < 0 ? 0 : work_score.round(1) + # end + # # current_col += 1 + # end + # common_score = 0 + # homeworks.where(:homework_type => 1).includes(:score_student_works).each do |homework| + # student_works = homework.score_student_works.select{|work| work.user_id == member.user.id} + # if student_works.empty? + # sheet1[count_row,column+=1] = 0 + # else + # work_score = student_works.first.work_score.nil? ? 0 : student_works.first.work_score + # sheet1[count_row,column+=1] = work_score < 0 ? 0 : work_score.round(1) + # common_score += work_score < 0 ? 0 : work_score.round(1) + # end + # # current_col += 1 + # end + # group_score = 0 + # homeworks.where(:homework_type => 3).includes(:score_student_works).each do |homework| + # student_works = homework.score_student_works.select{|work| work.user_id == member.user.id} + # if student_works.empty? + # sheet1[count_row,column+=1] = 0 + # else + # work_score = student_works.first.work_score.nil? ? 0 : student_works.first.work_score + # sheet1[count_row,column+=1] = work_score < 0 ? 0 : work_score.round(1) + # group_score += work_score < 0 ? 0 : work_score.round(1) + # end + # # current_col += 1 + # end + # exercise_score = 0 + # exercises.includes(:score_exercise_users).each do |exercise| + # exercise_user = exercise.score_exercise_users.select{|work| work.user_id == member.user.id} + # if exercise_user.empty? + # sheet1[count_row,column+=1] = 0 + # else + # work_score = exercise_user.first.score.nil? ? 0 : exercise_user.first.score + # sheet1[count_row,column+=1] = work_score < 0 ? 0 : work_score.round(1) + # exercise_score += work_score < 0 ? 0 : work_score.round(1) + # end + # # current_col += 1 + # end + # + # graduation_score = 0 + # tasks.includes(:graduation_works).each do |task| + # graduation_works = task.graduation_works.where("user_id = #{member.user.id}") + # if graduation_works.empty? + # sheet1[count_row,column+=1] = 0 + # else + # work_score = graduation_works.first.work_score.nil? ? 0 : graduation_works.first.work_score + # sheet1[count_row,column+=1] = work_score < 0 ? 0 : work_score.round(1) + # graduation_score += work_score < 0 ? 0 : work_score.round(1) + # end + # # current_col += 1 + # end + # + # sum = shixun_score + common_score + group_score + exercise_score + graduation_score + # sheet1[count_row,column+=1] = shixun_score + # sheet1[count_row,column+=1] = common_score + # sheet1[count_row,column+=1] = group_score + # sheet1[count_row,column+=1] = exercise_score + # if tasks.count > 0 + # sheet1[count_row,column+=1] = graduation_score + # end + # sheet1[count_row,column+=1] = sum.round(1) + # count_row += 1 + # end + # + # if course.course_groups.count > 0 + # sheet = book.create_worksheet :name => "分班信息" + # sheet.row(0).concat(["课程编号", course.id]) + # sheet.row(1).concat(["课程名称", course.name]) + # sheet.row(2).concat(["教师团队", teacher_co]) + # sheet.row(3).concat(["主讲教师", course.teacher.show_real_name]) + # sheet.row(4).concat(["序号", "分班名称", "邀请码", "学生数量"]) + # current_row = 5 + # course.course_groups.includes(:members).each do |course_group| + # sheet[current_row,0]= current_row - 4 + # sheet[current_row,1]= course_group.name + # sheet[current_row,2]= course_group.invite_code + # sheet[current_row,3]= course_group.members.size + # current_row += 1 + # end + # end + # + # sheet2 = book.create_worksheet :name => "活跃度" + # sheet2[0,0] = "课程编号" + # sheet2[0,1] = course.id + # sheet2[1,0] = "课程名称" + # sheet2[1,1] = course.name + # sheet2[2,0] = "教师团队" + # sheet2[2,1] = teacher_co + # sheet2[3,0] = "主讲教师" + # sheet2[3,1] = course.teacher.show_real_name + # sheet2.row(4).concat(["排名","学生姓名","昵称","学号","分班","作业完成数(*10)","试卷完成数(*10)","问卷完成数(*7)","资源发布数(*5)","帖子发布数(*2)","帖子回复数(*1)","作业回复数(*1)","活跃度"]) + # act_members = members + # act_members.each do |member| + # member[:act_score] = ((member.homework_num.to_i + member.graduation_num.to_i) * 10) + (member.exercise_num.to_i * 10) + (member.poll_num.to_i * 7) + (member.resource_num.to_i * 5) + (member.message_num.to_i * 2) + member.message_reply_num.to_i + member.homework_journal_num.to_i + # end + # act_members = act_members.sort do |a, b| + # [b[:act_score]] <=> [a[:act_score]] + # end + # count_row = 5 + # act_members.each_with_index do |act_member, index| + # sheet2[count_row,0]= index + 1 + # sheet2[count_row,1] = act_member.user.show_real_name + # sheet2[count_row,2] = act_member.user.login + # sheet2[count_row,3] = act_member.user.user_extensions.student_id + # sheet2[count_row,4] = act_member.course_group_id == 0 ? "暂无" : act_member.course_group.name + # sheet2[count_row,5]= act_member.homework_num.to_i + act_member.graduation_num.to_i + # sheet2[count_row,6]= act_member.exercise_num + # sheet2[count_row,7]= act_member.poll_num + # sheet2[count_row,8]= act_member.resource_num + # sheet2[count_row,9]= act_member.message_num + # sheet2[count_row,10]= act_member.message_reply_num + # sheet2[count_row,11]= act_member.homework_journal_num + # sheet2[count_row,12]= act_member.act_score + # count_row += 1 + # end + + homeworks.where(:homework_type => 4).includes(:score_student_works).each_with_index do |home, i| + sheet = book.create_worksheet :name => "#{home.name}" + sheet[0,0] = "课程编号" + sheet[0,1] = course.id + sheet[1,0] = "课程名称" + sheet[1,1] = course.name + sheet[2,0] = "教师团队" + sheet[2,1] = teacher_co + sheet[3,0] = "主讲教师" + sheet[3,1] = course.teacher.show_real_name + sheet[3,0] = "作业批次" + sheet[3,1] = "第#{i+1}次" + sheet[3,0] = "作业名称" + sheet[3,1] = home.name + sheet.row(4).concat([l(:excel_rank),l(:excel_user_name),l(:excel_nickname),l(:excel_student_id),"分班",l(:excel_homework_des),l(:excel_l_penalty),l(:excel_f_score),l(:excel_commit_time)]) + count_row = 5 + items = home.score_student_works + # if items.count == 0 && home.publish_time < Time.now && !course.is_end + # update_shixun_work_status home + # items = StudentWork.where("work_status != 0 and homework_common_id = #{home.id}").order("work_score desc") + # end + items.each_with_index do |stu, j| + sheet[count_row,0]= j + 1 + sheet[count_row,1] = stu.user.show_real_name + sheet[count_row,2] = stu.user.login + sheet[count_row,3] = stu.user.user_extensions.student_id + sheet[count_row,4] = member_group_name course.members, stu.user_id + sheet[count_row,5] = strip_html stu.description + sheet[count_row,6] = stu.late_penalty + sheet[count_row,7] = stu.work_score.nil? ? l(:label_without_score) : stu.work_score.round(1) + sheet[count_row,8] = format_time(stu.commit_time) + count_row += 1 end - common_score = 0 - homeworks.where(:homework_type => 1).includes(:score_student_works).each do |homework| - student_works = homework.score_student_works.select{|work| work.user_id == member.user.id} - if student_works.empty? - sheet1[count_row,column+=1] = 0 - else - work_score = student_works.first.work_score.nil? ? 0 : student_works.first.work_score - sheet1[count_row,column+=1] = work_score < 0 ? 0 : work_score.round(1) - common_score += work_score < 0 ? 0 : work_score.round(1) - end - # current_col += 1 + end + + homeworks.where(:homework_type => 1).each_with_index do |home, i| + sheet = book.create_worksheet :name => "普通作业第#{i+1}次" + sheet[0,0] = "课程编号" + sheet[0,1] = course.id + sheet[1,0] = "课程名称" + sheet[1,1] = course.name + sheet[2,0] = "教师团队" + sheet[2,1] = teacher_co + sheet[3,0] = "主讲教师" + sheet[3,1] = course.teacher.show_real_name + sheet[3,0] = "作业批次" + sheet[3,1] = "第#{i+1}次" + sheet[3,0] = "作业名称" + sheet[3,1] = home.name + if home.anonymous_comment ==0 + sheet.row(4).concat([l(:excel_rank),l(:excel_user_name),l(:excel_nickname),l(:excel_student_id),l(:excel_homework_des), + l(:excel_t_score),l(:excel_ta_score), l(:excel_n_score),l(:excel_a_penalty),l(:excel_l_penalty),l(:excel_f_score),l(:excel_commit_time)]) + else + sheet.row(4).concat([l(:excel_rank),l(:excel_user_name),l(:excel_nickname),l(:excel_student_id),l(:excel_homework_des), + l(:excel_t_score),l(:excel_ta_score),l(:excel_l_penalty),l(:excel_f_score),l(:excel_commit_time)]) end - group_score = 0 - homeworks.where(:homework_type => 3).includes(:score_student_works).each do |homework| - student_works = homework.score_student_works.select{|work| work.user_id == member.user.id} - if student_works.empty? - sheet1[count_row,column+=1] = 0 + count_row = 5 + items = home.score_student_works + items.each_with_index do |stu, j| + sheet[count_row,0]= j + 1 + sheet[count_row,1] = stu.user.show_real_name + sheet[count_row,2] = stu.user.login + sheet[count_row,3] = stu.user.user_extensions.student_id + sheet[count_row,4] = strip_html stu.description + sheet[count_row,5] = stu.teacher_score.nil? ? l(:label_without_score) : stu.teacher_score.round(1) + sheet[count_row,6] = stu.teaching_asistant_score.nil? ? l(:label_without_score) : stu.teaching_asistant_score.round(1) + if home.anonymous_comment ==0 + sheet[count_row,7] = stu.student_score.nil? ? l(:label_without_score) : stu.student_score.round(1) + sheet[count_row,8] = (home.teacher_priority == 1 && !stu.teacher_score.nil?) ? 0 : stu.absence_penalty + sheet[count_row,9] = (home.teacher_priority == 1 && !stu.teacher_score.nil?) ? 0 : stu.late_penalty + sheet[count_row,10] = stu.work_score.nil? ? l(:label_without_score) : stu.work_score.round(1) + sheet[count_row,11] = format_time(stu.commit_time) else - work_score = student_works.first.work_score.nil? ? 0 : student_works.first.work_score - sheet1[count_row,column+=1] = work_score < 0 ? 0 : work_score.round(1) - group_score += work_score < 0 ? 0 : work_score.round(1) + sheet[count_row,7] = (home.teacher_priority == 1 && !stu.teacher_score.nil?) ? 0 : stu.late_penalty + sheet[count_row,8] = stu.work_score.nil? ? l(:label_without_score) : stu.work_score.round(1) + sheet[count_row,9] = format_time(stu.commit_time) end - # current_col += 1 + count_row += 1 + end + + end + + homeworks.where(:homework_type => 3).each_with_index do |home, i| + sheet = book.create_worksheet :name => "分组作业第#{i+1}次" + sheet[0,0] = "课程编号" + sheet[0,1] = course.id + sheet[1,0] = "课程名称" + sheet[1,1] = course.name + sheet[2,0] = "教师团队" + sheet[2,1] = teacher_co + sheet[3,0] = "主讲教师" + sheet[3,1] = course.teacher.show_real_name + sheet[3,0] = "作业批次" + sheet[3,1] = "第#{i+1}次" + sheet[3,0] = "作业名称" + sheet[3,1] = home.name + + if home.anonymous_comment ==0 + sheet.row(4).concat([l(:excel_rank),l(:excel_user_name),l(:excel_nickname),l(:excel_student_id),l(:excel_group_member),l(:excel_homework_des), + l(:excel_t_score),l(:excel_ta_score),l(:excel_n_score),l(:excel_a_penalty),l(:excel_l_penalty),l(:excel_f_score),l(:excel_commit_time)]) + else + sheet.row(4).concat([l(:excel_rank),l(:excel_user_name),l(:excel_nickname),l(:excel_student_id),l(:excel_group_member),l(:excel_homework_des), + l(:excel_t_score),l(:excel_ta_score),l(:excel_l_penalty),l(:excel_f_score),l(:excel_commit_time)]) end - exercise_score = 0 - exercises.includes(:score_exercise_users).each do |exercise| - exercise_user = exercise.score_exercise_users.select{|work| work.user_id == member.user.id} - if exercise_user.empty? - sheet1[count_row,column+=1] = 0 + count_row = 5 + items = home.score_student_works + items.each_with_index do |stu, j| + sheet[count_row,0] = j + 1 + sheet[count_row,1] = stu.user.show_real_name + sheet[count_row,2] = stu.user.login + sheet[count_row,3] = stu.user.user_extensions.student_id + sheet[count_row,4] = get_group_member_names home.student_works.where(:group_id => stu.group_id).pluck(:user_id) + sheet[count_row,5] = strip_html stu.description + sheet[count_row,6] = stu.teacher_score.nil? ? l(:label_without_score) : stu.teacher_score.round(1) + sheet[count_row,7] = stu.teaching_asistant_score.nil? ? l(:label_without_score) : stu.teaching_asistant_score.round(1) + if home.anonymous_comment ==0 + sheet[count_row,8] = stu.student_score.nil? ? l(:label_without_score) : stu.student_score.round(1) + sheet[count_row,9] = (home.teacher_priority == 1 && !stu.teacher_score.nil?) ? 0 : stu.absence_penalty + sheet[count_row,10] = (home.teacher_priority == 1 && !stu.teacher_score.nil?) ? 0 : stu.late_penalty + sheet[count_row,11] = stu.work_score.nil? ? l(:label_without_score) : stu.work_score.round(1) + sheet[count_row,12] = format_time(stu.commit_time) else - work_score = exercise_user.first.score.nil? ? 0 : exercise_user.first.score - sheet1[count_row,column+=1] = work_score < 0 ? 0 : work_score.round(1) - exercise_score += work_score < 0 ? 0 : work_score.round(1) + sheet[count_row,8] = (home.teacher_priority == 1 && !stu.teacher_score.nil?) ? 0 : stu.late_penalty + sheet[count_row,9] = stu.work_score.nil? ? l(:label_without_score) : stu.work_score.round(1) + sheet[count_row,10] = format_time(stu.commit_time) end - # current_col += 1 + count_row += 1 end + end - graduation_score = 0 - tasks.includes(:graduation_works).each do |task| - graduation_works = task.graduation_works.where("user_id = #{member.user.id}") - if graduation_works.empty? - sheet1[count_row,column+=1] = 0 - else - work_score = graduation_works.first.work_score.nil? ? 0 : graduation_works.first.work_score - sheet1[count_row,column+=1] = work_score < 0 ? 0 : work_score.round(1) - graduation_score += work_score < 0 ? 0 : work_score.round(1) - end - # current_col += 1 + exercises.each_with_index do |exercise, i| + sheet = book.create_worksheet :name => "试卷第#{i+1}次" + sheet[0,0] = "课程编号" + sheet[0,1] = course.id + sheet[1,0] = "课程名称" + sheet[1,1] = course.name + sheet[3,0] = "教师团队" + sheet[3,1] = teacher_co + sheet[3,0] = "主讲教师" + sheet[3,1] = course.teacher.show_real_name + sheet[3,0] = "试卷批次" + sheet[3,1] = "第#{i+1}次" + sheet[3,0] = "试卷名称" + sheet[3,1] = exercise.exercise_name + + sheet.row(4).concat([l(:excel_rank),l(:excel_user_name),l(:excel_nickname),l(:excel_student_id),l(:excel_objective_score),l(:excel_subjective_score),l(:excel_f_score),l(:excel_answer_time)]) + count_row = 5 + items = exercise.score_exercise_users + items.each_with_index do |stu, j| + sheet[count_row,0] = j + 1 + sheet[count_row,1] = stu.user.show_real_name + sheet[count_row,2] = stu.user.login + sheet[count_row,3] = stu.user.user_extensions.student_id + sheet[count_row,4] = stu.objective_score == -1 ? "0.0" : format("%.1f",stu.objective_score) + sheet[count_row,5] = stu.subjective_score == -1 ? "0.0" : format("%.1f",stu.subjective_score) + sheet[count_row,6] = stu.score.nil? ? '--' : stu.score.round(1) + sheet[count_row,7] = stu.commit_status == 0 ? l(:excel_no_answer) : format_time(stu.start_at) + count_row += 1 end + end - sum = shixun_score + common_score + group_score + exercise_score + graduation_score - sheet1[count_row,column+=1] = shixun_score - sheet1[count_row,column+=1] = common_score - sheet1[count_row,column+=1] = group_score - sheet1[count_row,column+=1] = exercise_score - if tasks.count > 0 - sheet1[count_row,column+=1] = graduation_score + tasks.each_with_index do |task, i| + sheet = book.create_worksheet :name => "毕设任务第#{i+1}次" + sheet[0,0] = "课程编号" + sheet[0,1] = course.id + sheet[1,0] = "课程名称" + sheet[1,1] = course.name + sheet[2,0] = "教师团队" + sheet[2,1] = teacher_co + sheet[3,0] = "主讲教师" + sheet[3,1] = course.teacher.show_real_name + sheet[3,0] = "作业批次" + sheet[3,1] = "第#{i+1}次" + sheet[3,0] = "作业名称" + sheet[3,1] = task.name + sheet.row(4).concat([l(:excel_rank),l(:excel_user_name),l(:excel_nickname),l(:excel_student_id)]) + if task.task_type == 2 + sheet.row(4).concat([l(:excel_group_member)]) end - sheet1[count_row,column+=1] = sum.round(1) - count_row += 1 - end - - if course.course_groups.count > 0 - sheet = book.create_worksheet :name => "分班信息" - sheet.row(0).concat(["课程编号", course.id]) - sheet.row(1).concat(["课程名称", course.name]) - sheet.row(2).concat(["教师团队", teacher_co]) - sheet.row(3).concat(["主讲教师", course.teacher.show_real_name]) - sheet.row(4).concat(["序号", "分班名称", "邀请码", "学生数量"]) - current_row = 5 - course.course_groups.includes(:members).each do |course_group| - sheet[current_row,0]= current_row - 4 - sheet[current_row,1]= course_group.name - sheet[current_row,2]= course_group.invite_code - sheet[current_row,3]= course_group.members.size - current_row += 1 + sheet.row(4).concat([l(:excel_homework_des), l(:excel_t_score)]) + if task.cross_comment + sheet.row(4).concat(["交叉评分"]) end + sheet.row(4).concat([l(:excel_l_penalty),l(:excel_f_score),l(:excel_commit_time)]) + count_row = 5 + items = task.graduation_works.where("work_status != 0").order("work_score desc") + items.each_with_index do |stu, j| + column = 0 + sheet[count_row,column]= j + 1 + sheet[count_row,column+=1] = stu.user.show_real_name + sheet[count_row,column+=1] = stu.user.login + sheet[count_row,column+=1] = stu.user.user_extensions.student_id + if task.task_type == 2 + sheet[count_row,column+=1] = get_group_member_names task.graduation_works.where(:group_id => stu.group_id).pluck(:user_id) + end + sheet[count_row,column+=1] = strip_html stu.description + sheet[count_row,column+=1] = stu.teacher_score.nil? ? l(:label_without_score) : stu.teacher_score.round(1) + if task.cross_comment + sheet[count_row,column+=1] = stu.cross_score.nil? ? l(:label_without_score) : stu.cross_score.round(1) + end + sheet[count_row,column+=1] = stu.late_penalty + sheet[count_row,column+=1] = stu.work_score.nil? ? l(:label_without_score) : stu.work_score.round(1) + sheet[count_row,column+=1] = format_time(stu.commit_time) + count_row += 1 + end +=begin + if task.task_type == 1 + if task.cross_comment + sheet.row(4).concat([l(:excel_rank),l(:excel_user_name),l(:excel_nickname),l(:excel_student_id),l(:excel_homework_des), + l(:excel_t_score),"交叉评分",l(:excel_l_penalty),l(:excel_f_score),l(:excel_commit_time)]) + else + sheet.row(4).concat([l(:excel_rank),l(:excel_user_name),l(:excel_nickname),l(:excel_student_id),l(:excel_homework_des), + l(:excel_t_score),l(:excel_l_penalty),l(:excel_f_score),l(:excel_commit_time)]) + end + else + if task.cross_comment + sheet.row(4).concat([l(:excel_rank),l(:excel_user_name),l(:excel_nickname),l(:excel_student_id),l(:excel_group_member),l(:excel_homework_des), + l(:excel_t_score),"交叉评分",l(:excel_l_penalty),l(:excel_f_score),l(:excel_commit_time)]) + else + sheet.row(4).concat([l(:excel_rank),l(:excel_user_name),l(:excel_nickname),l(:excel_student_id),l(:excel_group_member),l(:excel_homework_des), + l(:excel_t_score),l(:excel_l_penalty),l(:excel_f_score),l(:excel_commit_time)]) + end + count_row = 5 + items = task.graduation_works.order("work_score desc") + items.each_with_index do |stu, j| + column = 0 + sheet[count_row,column]= j + 1 + sheet[count_row,column+1] = stu.user.show_name + sheet[count_row,column+1] = stu.user.login + sheet[count_row,column+1] = stu.user.user_extensions.student_id + sheet[count_row,column+1] = strip_html stu.description + sheet[count_row,column+1] = stu.teacher_score.nil? ? l(:label_without_score) : stu.teacher_score.round(2) + if task.cross_comment + sheet[count_row,column+1] = stu.cross_score.nil? ? l(:label_without_score) : stu.cross_score.round(2) + end + sheet[count_row,column+1] = stu.late_penalty + sheet[count_row,column+1] = stu.work_score.nil? ? l(:label_without_score) : stu.work_score.round(2) + sheet[count_row,column+1] = format_time(stu.commit_time) + count_row += 1 + end + end +=end end - sheet2 = book.create_worksheet :name => "活跃度" - sheet2[0,0] = "课程编号" - sheet2[0,1] = course.id - sheet2[1,0] = "课程名称" - sheet2[1,1] = course.name - sheet2[2,0] = "教师团队" - sheet2[2,1] = teacher_co - sheet2[3,0] = "主讲教师" - sheet2[3,1] = course.teacher.show_real_name - sheet2.row(4).concat(["排名","学生姓名","昵称","学号","分班","作业完成数(*10)","试卷完成数(*10)","问卷完成数(*7)","资源发布数(*5)","帖子发布数(*2)","帖子回复数(*1)","作业回复数(*1)","活跃度"]) - act_members = members - act_members.each do |member| - member[:act_score] = ((member.homework_num.to_i + member.graduation_num.to_i) * 10) + (member.exercise_num.to_i * 10) + (member.poll_num.to_i * 7) + (member.resource_num.to_i * 5) + (member.message_num.to_i * 2) + member.message_reply_num.to_i + member.homework_journal_num.to_i - end - act_members = act_members.sort do |a, b| - [b[:act_score]] <=> [a[:act_score]] - end - count_row = 5 - act_members.each_with_index do |act_member, index| - sheet2[count_row,0]= index + 1 - sheet2[count_row,1] = act_member.user.show_real_name - sheet2[count_row,2] = act_member.user.login - sheet2[count_row,3] = act_member.user.user_extensions.student_id - sheet2[count_row,4] = act_member.course_group_id == 0 ? "暂无" : act_member.course_group.name - sheet2[count_row,5]= act_member.homework_num.to_i + act_member.graduation_num.to_i - sheet2[count_row,6]= act_member.exercise_num - sheet2[count_row,7]= act_member.poll_num - sheet2[count_row,8]= act_member.resource_num - sheet2[count_row,9]= act_member.message_num - sheet2[count_row,10]= act_member.message_reply_num - sheet2[count_row,11]= act_member.homework_journal_num - sheet2[count_row,12]= act_member.act_score - count_row += 1 - end - -# homeworks.where(:homework_type => 4).each_with_index do |home, i| -# sheet = book.create_worksheet :name => "#{home.name}" -# sheet[0,0] = "课程编号" -# sheet[0,1] = course.id -# sheet[1,0] = "课程名称" -# sheet[1,1] = course.name -# sheet[2,0] = "教师团队" -# sheet[2,1] = teacher_co -# sheet[3,0] = "主讲教师" -# sheet[3,1] = course.teacher.show_real_name -# sheet[3,0] = "作业批次" -# sheet[3,1] = "第#{i+1}次" -# sheet[3,0] = "作业名称" -# sheet[3,1] = home.name -# sheet.row(4).concat([l(:excel_rank),l(:excel_user_name),l(:excel_nickname),l(:excel_student_id),l(:excel_homework_des),l(:excel_l_penalty),l(:excel_f_score),l(:excel_commit_time)]) -# count_row = 5 -# items = home.score_student_works -# # if items.count == 0 && home.publish_time < Time.now && !course.is_end -# # update_shixun_work_status home -# # items = StudentWork.where("work_status != 0 and homework_common_id = #{home.id}").order("work_score desc") -# # end -# items.each_with_index do |stu, j| -# sheet[count_row,0]= j + 1 -# sheet[count_row,1] = stu.user.show_real_name -# sheet[count_row,2] = stu.user.login -# sheet[count_row,3] = stu.user.user_extensions.student_id -# sheet[count_row,4] = strip_html stu.description -# sheet[count_row,5] = stu.late_penalty -# sheet[count_row,6] = stu.work_score.nil? ? l(:label_without_score) : stu.work_score.round(1) -# sheet[count_row,7] = format_time(stu.commit_time) -# count_row += 1 -# end -# end -# -# homeworks.where(:homework_type => 1).each_with_index do |home, i| -# sheet = book.create_worksheet :name => "普通作业第#{i+1}次" -# sheet[0,0] = "课程编号" -# sheet[0,1] = course.id -# sheet[1,0] = "课程名称" -# sheet[1,1] = course.name -# sheet[2,0] = "教师团队" -# sheet[2,1] = teacher_co -# sheet[3,0] = "主讲教师" -# sheet[3,1] = course.teacher.show_real_name -# sheet[3,0] = "作业批次" -# sheet[3,1] = "第#{i+1}次" -# sheet[3,0] = "作业名称" -# sheet[3,1] = home.name -# if home.anonymous_comment ==0 -# sheet.row(4).concat([l(:excel_rank),l(:excel_user_name),l(:excel_nickname),l(:excel_student_id),l(:excel_homework_des), -# l(:excel_t_score),l(:excel_ta_score), l(:excel_n_score),l(:excel_a_penalty),l(:excel_l_penalty),l(:excel_f_score),l(:excel_commit_time)]) -# else -# sheet.row(4).concat([l(:excel_rank),l(:excel_user_name),l(:excel_nickname),l(:excel_student_id),l(:excel_homework_des), -# l(:excel_t_score),l(:excel_ta_score),l(:excel_l_penalty),l(:excel_f_score),l(:excel_commit_time)]) -# end -# count_row = 5 -# items = home.score_student_works -# items.each_with_index do |stu, j| -# sheet[count_row,0]= j + 1 -# sheet[count_row,1] = stu.user.show_real_name -# sheet[count_row,2] = stu.user.login -# sheet[count_row,3] = stu.user.user_extensions.student_id -# sheet[count_row,4] = strip_html stu.description -# sheet[count_row,5] = stu.teacher_score.nil? ? l(:label_without_score) : stu.teacher_score.round(1) -# sheet[count_row,6] = stu.teaching_asistant_score.nil? ? l(:label_without_score) : stu.teaching_asistant_score.round(1) -# if home.anonymous_comment ==0 -# sheet[count_row,7] = stu.student_score.nil? ? l(:label_without_score) : stu.student_score.round(1) -# sheet[count_row,8] = (home.teacher_priority == 1 && !stu.teacher_score.nil?) ? 0 : stu.absence_penalty -# sheet[count_row,9] = (home.teacher_priority == 1 && !stu.teacher_score.nil?) ? 0 : stu.late_penalty -# sheet[count_row,10] = stu.work_score.nil? ? l(:label_without_score) : stu.work_score.round(1) -# sheet[count_row,11] = format_time(stu.commit_time) -# else -# sheet[count_row,7] = (home.teacher_priority == 1 && !stu.teacher_score.nil?) ? 0 : stu.late_penalty -# sheet[count_row,8] = stu.work_score.nil? ? l(:label_without_score) : stu.work_score.round(1) -# sheet[count_row,9] = format_time(stu.commit_time) -# end -# count_row += 1 -# end -# -# end -# -# homeworks.where(:homework_type => 3).each_with_index do |home, i| -# sheet = book.create_worksheet :name => "分组作业第#{i+1}次" -# sheet[0,0] = "课程编号" -# sheet[0,1] = course.id -# sheet[1,0] = "课程名称" -# sheet[1,1] = course.name -# sheet[2,0] = "教师团队" -# sheet[2,1] = teacher_co -# sheet[3,0] = "主讲教师" -# sheet[3,1] = course.teacher.show_real_name -# sheet[3,0] = "作业批次" -# sheet[3,1] = "第#{i+1}次" -# sheet[3,0] = "作业名称" -# sheet[3,1] = home.name -# -# if home.anonymous_comment ==0 -# sheet.row(4).concat([l(:excel_rank),l(:excel_user_name),l(:excel_nickname),l(:excel_student_id),l(:excel_group_member),l(:excel_homework_des), -# l(:excel_t_score),l(:excel_ta_score),l(:excel_n_score),l(:excel_a_penalty),l(:excel_l_penalty),l(:excel_f_score),l(:excel_commit_time)]) -# else -# sheet.row(4).concat([l(:excel_rank),l(:excel_user_name),l(:excel_nickname),l(:excel_student_id),l(:excel_group_member),l(:excel_homework_des), -# l(:excel_t_score),l(:excel_ta_score),l(:excel_l_penalty),l(:excel_f_score),l(:excel_commit_time)]) -# end -# count_row = 5 -# items = home.score_student_works -# items.each_with_index do |stu, j| -# sheet[count_row,0] = j + 1 -# sheet[count_row,1] = stu.user.show_real_name -# sheet[count_row,2] = stu.user.login -# sheet[count_row,3] = stu.user.user_extensions.student_id -# sheet[count_row,4] = get_group_member_names home.student_works.where(:group_id => stu.group_id).pluck(:user_id) -# sheet[count_row,5] = strip_html stu.description -# sheet[count_row,6] = stu.teacher_score.nil? ? l(:label_without_score) : stu.teacher_score.round(1) -# sheet[count_row,7] = stu.teaching_asistant_score.nil? ? l(:label_without_score) : stu.teaching_asistant_score.round(1) -# if home.anonymous_comment ==0 -# sheet[count_row,8] = stu.student_score.nil? ? l(:label_without_score) : stu.student_score.round(1) -# sheet[count_row,9] = (home.teacher_priority == 1 && !stu.teacher_score.nil?) ? 0 : stu.absence_penalty -# sheet[count_row,10] = (home.teacher_priority == 1 && !stu.teacher_score.nil?) ? 0 : stu.late_penalty -# sheet[count_row,11] = stu.work_score.nil? ? l(:label_without_score) : stu.work_score.round(1) -# sheet[count_row,12] = format_time(stu.commit_time) -# else -# sheet[count_row,8] = (home.teacher_priority == 1 && !stu.teacher_score.nil?) ? 0 : stu.late_penalty -# sheet[count_row,9] = stu.work_score.nil? ? l(:label_without_score) : stu.work_score.round(1) -# sheet[count_row,10] = format_time(stu.commit_time) -# end -# count_row += 1 -# end -# end -# -# exercises.each_with_index do |exercise, i| -# sheet = book.create_worksheet :name => "试卷第#{i+1}次" -# sheet[0,0] = "课程编号" -# sheet[0,1] = course.id -# sheet[1,0] = "课程名称" -# sheet[1,1] = course.name -# sheet[3,0] = "教师团队" -# sheet[3,1] = teacher_co -# sheet[3,0] = "主讲教师" -# sheet[3,1] = course.teacher.show_real_name -# sheet[3,0] = "试卷批次" -# sheet[3,1] = "第#{i+1}次" -# sheet[3,0] = "试卷名称" -# sheet[3,1] = exercise.exercise_name -# -# sheet.row(4).concat([l(:excel_rank),l(:excel_user_name),l(:excel_nickname),l(:excel_student_id),l(:excel_objective_score),l(:excel_subjective_score),l(:excel_f_score),l(:excel_answer_time)]) -# count_row = 5 -# items = exercise.score_exercise_users -# items.each_with_index do |stu, j| -# sheet[count_row,0] = j + 1 -# sheet[count_row,1] = stu.user.show_real_name -# sheet[count_row,2] = stu.user.login -# sheet[count_row,3] = stu.user.user_extensions.student_id -# sheet[count_row,4] = stu.objective_score == -1 ? "0.0" : format("%.1f",stu.objective_score) -# sheet[count_row,5] = stu.subjective_score == -1 ? "0.0" : format("%.1f",stu.subjective_score) -# sheet[count_row,6] = stu.score.nil? ? '--' : stu.score.round(1) -# sheet[count_row,7] = stu.commit_status == 0 ? l(:excel_no_answer) : format_time(stu.start_at) -# count_row += 1 -# end -# end -# -# tasks.each_with_index do |task, i| -# sheet = book.create_worksheet :name => "毕设任务第#{i+1}次" -# sheet[0,0] = "课程编号" -# sheet[0,1] = course.id -# sheet[1,0] = "课程名称" -# sheet[1,1] = course.name -# sheet[2,0] = "教师团队" -# sheet[2,1] = teacher_co -# sheet[3,0] = "主讲教师" -# sheet[3,1] = course.teacher.show_real_name -# sheet[3,0] = "作业批次" -# sheet[3,1] = "第#{i+1}次" -# sheet[3,0] = "作业名称" -# sheet[3,1] = task.name -# sheet.row(4).concat([l(:excel_rank),l(:excel_user_name),l(:excel_nickname),l(:excel_student_id)]) -# if task.task_type == 2 -# sheet.row(4).concat([l(:excel_group_member)]) -# end -# sheet.row(4).concat([l(:excel_homework_des), l(:excel_t_score)]) -# if task.cross_comment -# sheet.row(4).concat(["交叉评分"]) -# end -# sheet.row(4).concat([l(:excel_l_penalty),l(:excel_f_score),l(:excel_commit_time)]) -# count_row = 5 -# items = task.graduation_works.where("work_status != 0").order("work_score desc") -# items.each_with_index do |stu, j| -# column = 0 -# sheet[count_row,column]= j + 1 -# sheet[count_row,column+=1] = stu.user.show_real_name -# sheet[count_row,column+=1] = stu.user.login -# sheet[count_row,column+=1] = stu.user.user_extensions.student_id -# if task.task_type == 2 -# sheet[count_row,column+=1] = get_group_member_names task.graduation_works.where(:group_id => stu.group_id).pluck(:user_id) -# end -# sheet[count_row,column+=1] = strip_html stu.description -# sheet[count_row,column+=1] = stu.teacher_score.nil? ? l(:label_without_score) : stu.teacher_score.round(1) -# if task.cross_comment -# sheet[count_row,column+=1] = stu.cross_score.nil? ? l(:label_without_score) : stu.cross_score.round(1) -# end -# sheet[count_row,column+=1] = stu.late_penalty -# sheet[count_row,column+=1] = stu.work_score.nil? ? l(:label_without_score) : stu.work_score.round(1) -# sheet[count_row,column+=1] = format_time(stu.commit_time) -# count_row += 1 -# end -# =begin -# if task.task_type == 1 -# if task.cross_comment -# sheet.row(4).concat([l(:excel_rank),l(:excel_user_name),l(:excel_nickname),l(:excel_student_id),l(:excel_homework_des), -# l(:excel_t_score),"交叉评分",l(:excel_l_penalty),l(:excel_f_score),l(:excel_commit_time)]) -# else -# sheet.row(4).concat([l(:excel_rank),l(:excel_user_name),l(:excel_nickname),l(:excel_student_id),l(:excel_homework_des), -# l(:excel_t_score),l(:excel_l_penalty),l(:excel_f_score),l(:excel_commit_time)]) -# end -# else -# if task.cross_comment -# sheet.row(4).concat([l(:excel_rank),l(:excel_user_name),l(:excel_nickname),l(:excel_student_id),l(:excel_group_member),l(:excel_homework_des), -# l(:excel_t_score),"交叉评分",l(:excel_l_penalty),l(:excel_f_score),l(:excel_commit_time)]) -# else -# sheet.row(4).concat([l(:excel_rank),l(:excel_user_name),l(:excel_nickname),l(:excel_student_id),l(:excel_group_member),l(:excel_homework_des), -# l(:excel_t_score),l(:excel_l_penalty),l(:excel_f_score),l(:excel_commit_time)]) -# end -# count_row = 5 -# items = task.graduation_works.order("work_score desc") -# items.each_with_index do |stu, j| -# column = 0 -# sheet[count_row,column]= j + 1 -# sheet[count_row,column+1] = stu.user.show_name -# sheet[count_row,column+1] = stu.user.login -# sheet[count_row,column+1] = stu.user.user_extensions.student_id -# sheet[count_row,column+1] = strip_html stu.description -# sheet[count_row,column+1] = stu.teacher_score.nil? ? l(:label_without_score) : stu.teacher_score.round(2) -# if task.cross_comment -# sheet[count_row,column+1] = stu.cross_score.nil? ? l(:label_without_score) : stu.cross_score.round(2) -# end -# sheet[count_row,column+1] = stu.late_penalty -# sheet[count_row,column+1] = stu.work_score.nil? ? l(:label_without_score) : stu.work_score.round(2) -# sheet[count_row,column+1] = format_time(stu.commit_time) -# count_row += 1 -# end -# end -# =end -# end - book.write xls_report xls_report.string end From 94abdac63563fe300851aa623d4484fa35d637f3 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Fri, 28 Jun 2019 13:44:19 +0800 Subject: [PATCH 04/11] =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/courses_controller.rb | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb index 4bc69dd5..c35b7911 100644 --- a/app/controllers/courses_controller.rb +++ b/app/controllers/courses_controller.rb @@ -1176,19 +1176,19 @@ class CoursesController < ApplicationController def export_course_member_excel q = params[:name] ? "#{params[:name].strip}" : "" - filename="#{@course.teacher.show_real_name.to_s }_#{@course.name}_#{l(:excel_member_list)}"; - if params[:group_id] && params[:group_id] != "0" && params[:group_id] != "-1" - group = CourseGroup.find params[:group_id] - unless group.nil? - @all_members = searchmember_by_name(student_homework_score(group.id,0,0,"desc"), q) - filename="#{@course.teacher.show_real_name.to_s }_#{@course.name}_#{group.name}_#{l(:excel_member_list)}" - end - elsif params[:group_id] && params[:group_id] == "0" - @all_members = searchmember_by_name(student_homework_score(-1, 0, 10,"desc"), q) - filename="#{@course.teacher.show_real_name.to_s }_#{@course.name}_未分班_#{l(:excel_member_list)}" - else - @all_members = searchmember_by_name(student_homework_score(0, 0, 10,"desc"), q) - end + filename="#{@course.teacher.show_real_name.to_s }_#{@course.name}_#{l(:excel_member_list)}" + # if params[:group_id] && params[:group_id] != "0" && params[:group_id] != "-1" + # group = CourseGroup.find params[:group_id] + # unless group.nil? + # @all_members = searchmember_by_name(student_homework_score(group.id,0,0,"desc"), q) + # filename="#{@course.teacher.show_real_name.to_s }_#{@course.name}_#{group.name}_#{l(:excel_member_list)}" + # end + # elsif params[:group_id] && params[:group_id] == "0" + # @all_members = searchmember_by_name(student_homework_score(-1, 0, 10,"desc"), q) + # filename="#{@course.teacher.show_real_name.to_s }_#{@course.name}_未分班_#{l(:excel_member_list)}" + # else + # @all_members = searchmember_by_name(student_homework_score(0, 0, 10,"desc"), q) + # end @homeworks = @course.homework_commons.where("publish_time <= '#{Time.now}'").order("publish_time asc, created_at asc") @exercises = @course.exercises.where("publish_time <= '#{Time.now}'").order("publish_time asc, created_at asc") From fc64faa030a9f87729513559760c5e5037125f68 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Fri, 28 Jun 2019 13:51:57 +0800 Subject: [PATCH 05/11] =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/courses_controller.rb | 842 +++++++++++++------------- 1 file changed, 421 insertions(+), 421 deletions(-) diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb index c35b7911..a74e1fc8 100644 --- a/app/controllers/courses_controller.rb +++ b/app/controllers/courses_controller.rb @@ -1177,18 +1177,18 @@ class CoursesController < ApplicationController def export_course_member_excel q = params[:name] ? "#{params[:name].strip}" : "" filename="#{@course.teacher.show_real_name.to_s }_#{@course.name}_#{l(:excel_member_list)}" - # if params[:group_id] && params[:group_id] != "0" && params[:group_id] != "-1" - # group = CourseGroup.find params[:group_id] - # unless group.nil? - # @all_members = searchmember_by_name(student_homework_score(group.id,0,0,"desc"), q) - # filename="#{@course.teacher.show_real_name.to_s }_#{@course.name}_#{group.name}_#{l(:excel_member_list)}" - # end - # elsif params[:group_id] && params[:group_id] == "0" - # @all_members = searchmember_by_name(student_homework_score(-1, 0, 10,"desc"), q) - # filename="#{@course.teacher.show_real_name.to_s }_#{@course.name}_未分班_#{l(:excel_member_list)}" - # else - # @all_members = searchmember_by_name(student_homework_score(0, 0, 10,"desc"), q) - # end + if params[:group_id] && params[:group_id] != "0" && params[:group_id] != "-1" + group = CourseGroup.find params[:group_id] + unless group.nil? + @all_members = searchmember_by_name(student_homework_score(group.id,0,0,"desc"), q) + filename="#{@course.teacher.show_real_name.to_s }_#{@course.name}_#{group.name}_#{l(:excel_member_list)}" + end + elsif params[:group_id] && params[:group_id] == "0" + @all_members = searchmember_by_name(student_homework_score(-1, 0, 10,"desc"), q) + filename="#{@course.teacher.show_real_name.to_s }_#{@course.name}_未分班_#{l(:excel_member_list)}" + else + @all_members = searchmember_by_name(student_homework_score(0, 0, 10,"desc"), q) + end @homeworks = @course.homework_commons.where("publish_time <= '#{Time.now}'").order("publish_time asc, created_at asc") @exercises = @course.exercises.where("publish_time <= '#{Time.now}'").order("publish_time asc, created_at asc") @@ -2381,431 +2381,431 @@ class CoursesController < ApplicationController def member_to_xls homeworks, exercises, tasks, course, members, groups xls_report = StringIO.new book = Spreadsheet::Workbook.new - # sheet1 = book.create_worksheet :name => "总成绩" - # blue = Spreadsheet::Format.new :color => :blue, :weight => :bold, :size => 10 - # #sheet1.row(0).default_format = blue - # #sheet1.row(0).concat([l(:excel_user_id),l(:excel_user_name),l(:excel_nickname),l(:excel_student_id),l(:excel_mail),l(:excel_class),l(:excel_f_score),l(:excel_commit_time)]) + sheet1 = book.create_worksheet :name => "总成绩" + blue = Spreadsheet::Format.new :color => :blue, :weight => :bold, :size => 10 + #sheet1.row(0).default_format = blue + #sheet1.row(0).concat([l(:excel_user_id),l(:excel_user_name),l(:excel_nickname),l(:excel_student_id),l(:excel_mail),l(:excel_class),l(:excel_f_score),l(:excel_commit_time)]) teacher_co = (searchTeacherAndAssistant course).map{|member| member.user.show_real_name}.join('、') - # sheet1[0,0] = "课程编号" - # sheet1[0,1] = course.id - # sheet1[1,0] = "课程名称" - # sheet1[1,1] = course.name - # sheet1[2,0] = "教师团队" - # sheet1[2,1] = teacher_co - # sheet1[3,0] = "主讲教师" - # sheet1[3,1] = course.teacher.show_real_name - # sheet1[4,0] = "排名" - # sheet1[4,1] = "学生姓名" - # sheet1[4,2] = "昵称" - # sheet1[4,3] = "邮箱" - # sheet1[4,4] = "学号" - # sheet1[4,5] = "分班" - # current_col = 5 - # homeworks.where(:homework_type => 4).each do |homework| - # sheet1[4,current_col+=1] = "#{homework.name}" - # end - # for i in 0 ... homeworks.where(:homework_type => 1).size - # sheet1[4,current_col+=1] = "普通作业第"+(i+1).to_s+"次" - # end - # for i in 0 ... homeworks.where(:homework_type => 3).size - # sheet1[4,current_col+=1] = "分组作业第"+(i+1).to_s+"次" - # end - # for i in 0 ... exercises.size - # sheet1[4,current_col+=1] = "试卷第"+(i+1).to_s+"次" - # end - # for i in 0 ... tasks.size - # sheet1[4,current_col+=1] = "毕设任务第"+(i+1).to_s+"次" - # end - # - # sheet1[4,current_col+=1] = "实训作业总得分" - # sheet1[4,current_col+=1] = "普通作业总得分" - # sheet1[4,current_col+=1] = "分组作业总得分" - # sheet1[4,current_col+=1] = "试卷总得分" - # if tasks.count > 0 - # sheet1[4,current_col+=1] = "毕设任务总得分" - # end - # #sheet1[6,homeworks.count+6] = "社区得分" - # sheet1[4,current_col+=1] = "总得分" - # count_row = 5 - # members.each_with_index do |member, i| - # column = 0 - # sheet1[count_row,column]= i+1 - # sheet1[count_row,column+=1] = member.user.show_real_name - # sheet1[count_row,column+=1] = member.user.login - # sheet1[count_row,column+=1] = member.user.mail - # sheet1[count_row,column+=1] = member.user.user_extensions.student_id - # sheet1[count_row,column+=1] = member.course_group_id == 0 ? "暂无" : member.course_group.name - # # current_col = 5 - # shixun_score = 0 - # homeworks.where(:homework_type => 4).includes(:score_student_works).each do |homework| - # student_works = homework.score_student_works.select{|work| work.user_id == member.user.id} - # if student_works.empty? - # sheet1[count_row,column+=1] = 0 - # else - # work_score = student_works.first.work_score.nil? ? 0 : student_works.first.work_score - # sheet1[count_row,column+=1] = work_score < 0 ? 0 : work_score.round(1) - # shixun_score += work_score < 0 ? 0 : work_score.round(1) - # end - # # current_col += 1 - # end - # common_score = 0 - # homeworks.where(:homework_type => 1).includes(:score_student_works).each do |homework| - # student_works = homework.score_student_works.select{|work| work.user_id == member.user.id} - # if student_works.empty? - # sheet1[count_row,column+=1] = 0 - # else - # work_score = student_works.first.work_score.nil? ? 0 : student_works.first.work_score - # sheet1[count_row,column+=1] = work_score < 0 ? 0 : work_score.round(1) - # common_score += work_score < 0 ? 0 : work_score.round(1) - # end - # # current_col += 1 - # end - # group_score = 0 - # homeworks.where(:homework_type => 3).includes(:score_student_works).each do |homework| - # student_works = homework.score_student_works.select{|work| work.user_id == member.user.id} - # if student_works.empty? - # sheet1[count_row,column+=1] = 0 - # else - # work_score = student_works.first.work_score.nil? ? 0 : student_works.first.work_score - # sheet1[count_row,column+=1] = work_score < 0 ? 0 : work_score.round(1) - # group_score += work_score < 0 ? 0 : work_score.round(1) - # end - # # current_col += 1 - # end - # exercise_score = 0 - # exercises.includes(:score_exercise_users).each do |exercise| - # exercise_user = exercise.score_exercise_users.select{|work| work.user_id == member.user.id} - # if exercise_user.empty? - # sheet1[count_row,column+=1] = 0 - # else - # work_score = exercise_user.first.score.nil? ? 0 : exercise_user.first.score - # sheet1[count_row,column+=1] = work_score < 0 ? 0 : work_score.round(1) - # exercise_score += work_score < 0 ? 0 : work_score.round(1) - # end - # # current_col += 1 - # end - # - # graduation_score = 0 - # tasks.includes(:graduation_works).each do |task| - # graduation_works = task.graduation_works.where("user_id = #{member.user.id}") - # if graduation_works.empty? - # sheet1[count_row,column+=1] = 0 - # else - # work_score = graduation_works.first.work_score.nil? ? 0 : graduation_works.first.work_score - # sheet1[count_row,column+=1] = work_score < 0 ? 0 : work_score.round(1) - # graduation_score += work_score < 0 ? 0 : work_score.round(1) - # end - # # current_col += 1 - # end - # - # sum = shixun_score + common_score + group_score + exercise_score + graduation_score - # sheet1[count_row,column+=1] = shixun_score - # sheet1[count_row,column+=1] = common_score - # sheet1[count_row,column+=1] = group_score - # sheet1[count_row,column+=1] = exercise_score - # if tasks.count > 0 - # sheet1[count_row,column+=1] = graduation_score - # end - # sheet1[count_row,column+=1] = sum.round(1) - # count_row += 1 - # end - # - # if course.course_groups.count > 0 - # sheet = book.create_worksheet :name => "分班信息" - # sheet.row(0).concat(["课程编号", course.id]) - # sheet.row(1).concat(["课程名称", course.name]) - # sheet.row(2).concat(["教师团队", teacher_co]) - # sheet.row(3).concat(["主讲教师", course.teacher.show_real_name]) - # sheet.row(4).concat(["序号", "分班名称", "邀请码", "学生数量"]) - # current_row = 5 - # course.course_groups.includes(:members).each do |course_group| - # sheet[current_row,0]= current_row - 4 - # sheet[current_row,1]= course_group.name - # sheet[current_row,2]= course_group.invite_code - # sheet[current_row,3]= course_group.members.size - # current_row += 1 - # end - # end - # - # sheet2 = book.create_worksheet :name => "活跃度" - # sheet2[0,0] = "课程编号" - # sheet2[0,1] = course.id - # sheet2[1,0] = "课程名称" - # sheet2[1,1] = course.name - # sheet2[2,0] = "教师团队" - # sheet2[2,1] = teacher_co - # sheet2[3,0] = "主讲教师" - # sheet2[3,1] = course.teacher.show_real_name - # sheet2.row(4).concat(["排名","学生姓名","昵称","学号","分班","作业完成数(*10)","试卷完成数(*10)","问卷完成数(*7)","资源发布数(*5)","帖子发布数(*2)","帖子回复数(*1)","作业回复数(*1)","活跃度"]) - # act_members = members - # act_members.each do |member| - # member[:act_score] = ((member.homework_num.to_i + member.graduation_num.to_i) * 10) + (member.exercise_num.to_i * 10) + (member.poll_num.to_i * 7) + (member.resource_num.to_i * 5) + (member.message_num.to_i * 2) + member.message_reply_num.to_i + member.homework_journal_num.to_i - # end - # act_members = act_members.sort do |a, b| - # [b[:act_score]] <=> [a[:act_score]] - # end - # count_row = 5 - # act_members.each_with_index do |act_member, index| - # sheet2[count_row,0]= index + 1 - # sheet2[count_row,1] = act_member.user.show_real_name - # sheet2[count_row,2] = act_member.user.login - # sheet2[count_row,3] = act_member.user.user_extensions.student_id - # sheet2[count_row,4] = act_member.course_group_id == 0 ? "暂无" : act_member.course_group.name - # sheet2[count_row,5]= act_member.homework_num.to_i + act_member.graduation_num.to_i - # sheet2[count_row,6]= act_member.exercise_num - # sheet2[count_row,7]= act_member.poll_num - # sheet2[count_row,8]= act_member.resource_num - # sheet2[count_row,9]= act_member.message_num - # sheet2[count_row,10]= act_member.message_reply_num - # sheet2[count_row,11]= act_member.homework_journal_num - # sheet2[count_row,12]= act_member.act_score - # count_row += 1 - # end - - homeworks.where(:homework_type => 4).includes(:score_student_works).each_with_index do |home, i| - sheet = book.create_worksheet :name => "#{home.name}" - sheet[0,0] = "课程编号" - sheet[0,1] = course.id - sheet[1,0] = "课程名称" - sheet[1,1] = course.name - sheet[2,0] = "教师团队" - sheet[2,1] = teacher_co - sheet[3,0] = "主讲教师" - sheet[3,1] = course.teacher.show_real_name - sheet[3,0] = "作业批次" - sheet[3,1] = "第#{i+1}次" - sheet[3,0] = "作业名称" - sheet[3,1] = home.name - sheet.row(4).concat([l(:excel_rank),l(:excel_user_name),l(:excel_nickname),l(:excel_student_id),"分班",l(:excel_homework_des),l(:excel_l_penalty),l(:excel_f_score),l(:excel_commit_time)]) - count_row = 5 - items = home.score_student_works - # if items.count == 0 && home.publish_time < Time.now && !course.is_end - # update_shixun_work_status home - # items = StudentWork.where("work_status != 0 and homework_common_id = #{home.id}").order("work_score desc") - # end - items.each_with_index do |stu, j| - sheet[count_row,0]= j + 1 - sheet[count_row,1] = stu.user.show_real_name - sheet[count_row,2] = stu.user.login - sheet[count_row,3] = stu.user.user_extensions.student_id - sheet[count_row,4] = member_group_name course.members, stu.user_id - sheet[count_row,5] = strip_html stu.description - sheet[count_row,6] = stu.late_penalty - sheet[count_row,7] = stu.work_score.nil? ? l(:label_without_score) : stu.work_score.round(1) - sheet[count_row,8] = format_time(stu.commit_time) - count_row += 1 - end - end - - homeworks.where(:homework_type => 1).each_with_index do |home, i| - sheet = book.create_worksheet :name => "普通作业第#{i+1}次" - sheet[0,0] = "课程编号" - sheet[0,1] = course.id - sheet[1,0] = "课程名称" - sheet[1,1] = course.name - sheet[2,0] = "教师团队" - sheet[2,1] = teacher_co - sheet[3,0] = "主讲教师" - sheet[3,1] = course.teacher.show_real_name - sheet[3,0] = "作业批次" - sheet[3,1] = "第#{i+1}次" - sheet[3,0] = "作业名称" - sheet[3,1] = home.name - if home.anonymous_comment ==0 - sheet.row(4).concat([l(:excel_rank),l(:excel_user_name),l(:excel_nickname),l(:excel_student_id),l(:excel_homework_des), - l(:excel_t_score),l(:excel_ta_score), l(:excel_n_score),l(:excel_a_penalty),l(:excel_l_penalty),l(:excel_f_score),l(:excel_commit_time)]) - else - sheet.row(4).concat([l(:excel_rank),l(:excel_user_name),l(:excel_nickname),l(:excel_student_id),l(:excel_homework_des), - l(:excel_t_score),l(:excel_ta_score),l(:excel_l_penalty),l(:excel_f_score),l(:excel_commit_time)]) - end - count_row = 5 - items = home.score_student_works - items.each_with_index do |stu, j| - sheet[count_row,0]= j + 1 - sheet[count_row,1] = stu.user.show_real_name - sheet[count_row,2] = stu.user.login - sheet[count_row,3] = stu.user.user_extensions.student_id - sheet[count_row,4] = strip_html stu.description - sheet[count_row,5] = stu.teacher_score.nil? ? l(:label_without_score) : stu.teacher_score.round(1) - sheet[count_row,6] = stu.teaching_asistant_score.nil? ? l(:label_without_score) : stu.teaching_asistant_score.round(1) - if home.anonymous_comment ==0 - sheet[count_row,7] = stu.student_score.nil? ? l(:label_without_score) : stu.student_score.round(1) - sheet[count_row,8] = (home.teacher_priority == 1 && !stu.teacher_score.nil?) ? 0 : stu.absence_penalty - sheet[count_row,9] = (home.teacher_priority == 1 && !stu.teacher_score.nil?) ? 0 : stu.late_penalty - sheet[count_row,10] = stu.work_score.nil? ? l(:label_without_score) : stu.work_score.round(1) - sheet[count_row,11] = format_time(stu.commit_time) + sheet1[0,0] = "课程编号" + sheet1[0,1] = course.id + sheet1[1,0] = "课程名称" + sheet1[1,1] = course.name + sheet1[2,0] = "教师团队" + sheet1[2,1] = teacher_co + sheet1[3,0] = "主讲教师" + sheet1[3,1] = course.teacher.show_real_name + sheet1[4,0] = "排名" + sheet1[4,1] = "学生姓名" + sheet1[4,2] = "昵称" + sheet1[4,3] = "邮箱" + sheet1[4,4] = "学号" + sheet1[4,5] = "分班" + current_col = 5 + homeworks.where(:homework_type => 4).each do |homework| + sheet1[4,current_col+=1] = "#{homework.name}" + end + for i in 0 ... homeworks.where(:homework_type => 1).size + sheet1[4,current_col+=1] = "普通作业第"+(i+1).to_s+"次" + end + for i in 0 ... homeworks.where(:homework_type => 3).size + sheet1[4,current_col+=1] = "分组作业第"+(i+1).to_s+"次" + end + for i in 0 ... exercises.size + sheet1[4,current_col+=1] = "试卷第"+(i+1).to_s+"次" + end + for i in 0 ... tasks.size + sheet1[4,current_col+=1] = "毕设任务第"+(i+1).to_s+"次" + end + + sheet1[4,current_col+=1] = "实训作业总得分" + sheet1[4,current_col+=1] = "普通作业总得分" + sheet1[4,current_col+=1] = "分组作业总得分" + sheet1[4,current_col+=1] = "试卷总得分" + if tasks.count > 0 + sheet1[4,current_col+=1] = "毕设任务总得分" + end + #sheet1[6,homeworks.count+6] = "社区得分" + sheet1[4,current_col+=1] = "总得分" + count_row = 5 + members.each_with_index do |member, i| + column = 0 + sheet1[count_row,column]= i+1 + sheet1[count_row,column+=1] = member.user.show_real_name + sheet1[count_row,column+=1] = member.user.login + sheet1[count_row,column+=1] = member.user.mail + sheet1[count_row,column+=1] = member.user.user_extensions.student_id + sheet1[count_row,column+=1] = member.course_group_id == 0 ? "暂无" : member.course_group.name + # current_col = 5 + shixun_score = 0 + homeworks.where(:homework_type => 4).each do |homework| + student_works = homework.score_student_works.find_by_user_id(member.user.id) + if student_works.nil? + sheet1[count_row,column+=1] = 0 else - sheet[count_row,7] = (home.teacher_priority == 1 && !stu.teacher_score.nil?) ? 0 : stu.late_penalty - sheet[count_row,8] = stu.work_score.nil? ? l(:label_without_score) : stu.work_score.round(1) - sheet[count_row,9] = format_time(stu.commit_time) + work_score = student_works.work_score.nil? ? 0 : student_works.work_score + sheet1[count_row,column+=1] = work_score < 0 ? 0 : work_score.round(1) + shixun_score += work_score < 0 ? 0 : work_score.round(1) end - count_row += 1 - end - - end - - homeworks.where(:homework_type => 3).each_with_index do |home, i| - sheet = book.create_worksheet :name => "分组作业第#{i+1}次" - sheet[0,0] = "课程编号" - sheet[0,1] = course.id - sheet[1,0] = "课程名称" - sheet[1,1] = course.name - sheet[2,0] = "教师团队" - sheet[2,1] = teacher_co - sheet[3,0] = "主讲教师" - sheet[3,1] = course.teacher.show_real_name - sheet[3,0] = "作业批次" - sheet[3,1] = "第#{i+1}次" - sheet[3,0] = "作业名称" - sheet[3,1] = home.name - - if home.anonymous_comment ==0 - sheet.row(4).concat([l(:excel_rank),l(:excel_user_name),l(:excel_nickname),l(:excel_student_id),l(:excel_group_member),l(:excel_homework_des), - l(:excel_t_score),l(:excel_ta_score),l(:excel_n_score),l(:excel_a_penalty),l(:excel_l_penalty),l(:excel_f_score),l(:excel_commit_time)]) - else - sheet.row(4).concat([l(:excel_rank),l(:excel_user_name),l(:excel_nickname),l(:excel_student_id),l(:excel_group_member),l(:excel_homework_des), - l(:excel_t_score),l(:excel_ta_score),l(:excel_l_penalty),l(:excel_f_score),l(:excel_commit_time)]) + # current_col += 1 end - count_row = 5 - items = home.score_student_works - items.each_with_index do |stu, j| - sheet[count_row,0] = j + 1 - sheet[count_row,1] = stu.user.show_real_name - sheet[count_row,2] = stu.user.login - sheet[count_row,3] = stu.user.user_extensions.student_id - sheet[count_row,4] = get_group_member_names home.student_works.where(:group_id => stu.group_id).pluck(:user_id) - sheet[count_row,5] = strip_html stu.description - sheet[count_row,6] = stu.teacher_score.nil? ? l(:label_without_score) : stu.teacher_score.round(1) - sheet[count_row,7] = stu.teaching_asistant_score.nil? ? l(:label_without_score) : stu.teaching_asistant_score.round(1) - if home.anonymous_comment ==0 - sheet[count_row,8] = stu.student_score.nil? ? l(:label_without_score) : stu.student_score.round(1) - sheet[count_row,9] = (home.teacher_priority == 1 && !stu.teacher_score.nil?) ? 0 : stu.absence_penalty - sheet[count_row,10] = (home.teacher_priority == 1 && !stu.teacher_score.nil?) ? 0 : stu.late_penalty - sheet[count_row,11] = stu.work_score.nil? ? l(:label_without_score) : stu.work_score.round(1) - sheet[count_row,12] = format_time(stu.commit_time) + common_score = 0 + homeworks.where(:homework_type => 1).each do |homework| + student_works = homework.score_student_works.find_by_user_id(member.user.id) + if student_works.nil? + sheet1[count_row,column+=1] = 0 else - sheet[count_row,8] = (home.teacher_priority == 1 && !stu.teacher_score.nil?) ? 0 : stu.late_penalty - sheet[count_row,9] = stu.work_score.nil? ? l(:label_without_score) : stu.work_score.round(1) - sheet[count_row,10] = format_time(stu.commit_time) + work_score = student_works.work_score.nil? ? 0 : student_works.work_score + sheet1[count_row,column+=1] = work_score < 0 ? 0 : work_score.round(1) + common_score += work_score < 0 ? 0 : work_score.round(1) end - count_row += 1 - end - end - - exercises.each_with_index do |exercise, i| - sheet = book.create_worksheet :name => "试卷第#{i+1}次" - sheet[0,0] = "课程编号" - sheet[0,1] = course.id - sheet[1,0] = "课程名称" - sheet[1,1] = course.name - sheet[3,0] = "教师团队" - sheet[3,1] = teacher_co - sheet[3,0] = "主讲教师" - sheet[3,1] = course.teacher.show_real_name - sheet[3,0] = "试卷批次" - sheet[3,1] = "第#{i+1}次" - sheet[3,0] = "试卷名称" - sheet[3,1] = exercise.exercise_name - - sheet.row(4).concat([l(:excel_rank),l(:excel_user_name),l(:excel_nickname),l(:excel_student_id),l(:excel_objective_score),l(:excel_subjective_score),l(:excel_f_score),l(:excel_answer_time)]) - count_row = 5 - items = exercise.score_exercise_users - items.each_with_index do |stu, j| - sheet[count_row,0] = j + 1 - sheet[count_row,1] = stu.user.show_real_name - sheet[count_row,2] = stu.user.login - sheet[count_row,3] = stu.user.user_extensions.student_id - sheet[count_row,4] = stu.objective_score == -1 ? "0.0" : format("%.1f",stu.objective_score) - sheet[count_row,5] = stu.subjective_score == -1 ? "0.0" : format("%.1f",stu.subjective_score) - sheet[count_row,6] = stu.score.nil? ? '--' : stu.score.round(1) - sheet[count_row,7] = stu.commit_status == 0 ? l(:excel_no_answer) : format_time(stu.start_at) - count_row += 1 + # current_col += 1 end - end - - tasks.each_with_index do |task, i| - sheet = book.create_worksheet :name => "毕设任务第#{i+1}次" - sheet[0,0] = "课程编号" - sheet[0,1] = course.id - sheet[1,0] = "课程名称" - sheet[1,1] = course.name - sheet[2,0] = "教师团队" - sheet[2,1] = teacher_co - sheet[3,0] = "主讲教师" - sheet[3,1] = course.teacher.show_real_name - sheet[3,0] = "作业批次" - sheet[3,1] = "第#{i+1}次" - sheet[3,0] = "作业名称" - sheet[3,1] = task.name - sheet.row(4).concat([l(:excel_rank),l(:excel_user_name),l(:excel_nickname),l(:excel_student_id)]) - if task.task_type == 2 - sheet.row(4).concat([l(:excel_group_member)]) - end - sheet.row(4).concat([l(:excel_homework_des), l(:excel_t_score)]) - if task.cross_comment - sheet.row(4).concat(["交叉评分"]) - end - sheet.row(4).concat([l(:excel_l_penalty),l(:excel_f_score),l(:excel_commit_time)]) - count_row = 5 - items = task.graduation_works.where("work_status != 0").order("work_score desc") - items.each_with_index do |stu, j| - column = 0 - sheet[count_row,column]= j + 1 - sheet[count_row,column+=1] = stu.user.show_real_name - sheet[count_row,column+=1] = stu.user.login - sheet[count_row,column+=1] = stu.user.user_extensions.student_id - if task.task_type == 2 - sheet[count_row,column+=1] = get_group_member_names task.graduation_works.where(:group_id => stu.group_id).pluck(:user_id) - end - sheet[count_row,column+=1] = strip_html stu.description - sheet[count_row,column+=1] = stu.teacher_score.nil? ? l(:label_without_score) : stu.teacher_score.round(1) - if task.cross_comment - sheet[count_row,column+=1] = stu.cross_score.nil? ? l(:label_without_score) : stu.cross_score.round(1) + group_score = 0 + homeworks.where(:homework_type => 3).each do |homework| + student_works = homework.score_student_works.find_by_user_id(member.user.id) + if student_works.nil? + sheet1[count_row,column+=1] = 0 + else + work_score = student_works.work_score.nil? ? 0 : student_works.work_score + sheet1[count_row,column+=1] = work_score < 0 ? 0 : work_score.round(1) + group_score += work_score < 0 ? 0 : work_score.round(1) end - sheet[count_row,column+=1] = stu.late_penalty - sheet[count_row,column+=1] = stu.work_score.nil? ? l(:label_without_score) : stu.work_score.round(1) - sheet[count_row,column+=1] = format_time(stu.commit_time) - count_row += 1 + # current_col += 1 end -=begin - if task.task_type == 1 - if task.cross_comment - sheet.row(4).concat([l(:excel_rank),l(:excel_user_name),l(:excel_nickname),l(:excel_student_id),l(:excel_homework_des), - l(:excel_t_score),"交叉评分",l(:excel_l_penalty),l(:excel_f_score),l(:excel_commit_time)]) + exercise_score = 0 + exercises.each do |exercise| + exercise_user = exercise.score_exercise_users.find_by_user_id(member.user.id) + if exercise_user.nil? + sheet1[count_row,column+=1] = 0 else - sheet.row(4).concat([l(:excel_rank),l(:excel_user_name),l(:excel_nickname),l(:excel_student_id),l(:excel_homework_des), - l(:excel_t_score),l(:excel_l_penalty),l(:excel_f_score),l(:excel_commit_time)]) + work_score = exercise_user.score.nil? ? 0 : exercise_user.score + sheet1[count_row,column+=1] = work_score < 0 ? 0 : work_score.round(1) + exercise_score += work_score < 0 ? 0 : work_score.round(1) end - else - if task.cross_comment - sheet.row(4).concat([l(:excel_rank),l(:excel_user_name),l(:excel_nickname),l(:excel_student_id),l(:excel_group_member),l(:excel_homework_des), - l(:excel_t_score),"交叉评分",l(:excel_l_penalty),l(:excel_f_score),l(:excel_commit_time)]) + # current_col += 1 + end + + graduation_score = 0 + tasks.each do |task| + graduation_works = task.graduation_works.where("user_id = #{member.user.id}") + if graduation_works.empty? + sheet1[count_row,column+=1] = 0 else - sheet.row(4).concat([l(:excel_rank),l(:excel_user_name),l(:excel_nickname),l(:excel_student_id),l(:excel_group_member),l(:excel_homework_des), - l(:excel_t_score),l(:excel_l_penalty),l(:excel_f_score),l(:excel_commit_time)]) - end - count_row = 5 - items = task.graduation_works.order("work_score desc") - items.each_with_index do |stu, j| - column = 0 - sheet[count_row,column]= j + 1 - sheet[count_row,column+1] = stu.user.show_name - sheet[count_row,column+1] = stu.user.login - sheet[count_row,column+1] = stu.user.user_extensions.student_id - sheet[count_row,column+1] = strip_html stu.description - sheet[count_row,column+1] = stu.teacher_score.nil? ? l(:label_without_score) : stu.teacher_score.round(2) - if task.cross_comment - sheet[count_row,column+1] = stu.cross_score.nil? ? l(:label_without_score) : stu.cross_score.round(2) - end - sheet[count_row,column+1] = stu.late_penalty - sheet[count_row,column+1] = stu.work_score.nil? ? l(:label_without_score) : stu.work_score.round(2) - sheet[count_row,column+1] = format_time(stu.commit_time) - count_row += 1 + work_score = graduation_works.first.work_score.nil? ? 0 : graduation_works.first.work_score + sheet1[count_row,column+=1] = work_score < 0 ? 0 : work_score.round(1) + graduation_score += work_score < 0 ? 0 : work_score.round(1) end + # current_col += 1 + end + + sum = shixun_score + common_score + group_score + exercise_score + graduation_score + sheet1[count_row,column+=1] = shixun_score + sheet1[count_row,column+=1] = common_score + sheet1[count_row,column+=1] = group_score + sheet1[count_row,column+=1] = exercise_score + if tasks.count > 0 + sheet1[count_row,column+=1] = graduation_score + end + sheet1[count_row,column+=1] = sum.round(1) + count_row += 1 + end + + if course.course_groups.count > 0 + sheet = book.create_worksheet :name => "分班信息" + sheet.row(0).concat(["课程编号", course.id]) + sheet.row(1).concat(["课程名称", course.name]) + sheet.row(2).concat(["教师团队", teacher_co]) + sheet.row(3).concat(["主讲教师", course.teacher.show_real_name]) + sheet.row(4).concat(["序号", "分班名称", "邀请码", "学生数量"]) + current_row = 5 + course.course_groups.includes(:members).each do |course_group| + sheet[current_row,0]= current_row - 4 + sheet[current_row,1]= course_group.name + sheet[current_row,2]= course_group.invite_code + sheet[current_row,3]= course_group.members.size + current_row += 1 end -=end end + sheet2 = book.create_worksheet :name => "活跃度" + sheet2[0,0] = "课程编号" + sheet2[0,1] = course.id + sheet2[1,0] = "课程名称" + sheet2[1,1] = course.name + sheet2[2,0] = "教师团队" + sheet2[2,1] = teacher_co + sheet2[3,0] = "主讲教师" + sheet2[3,1] = course.teacher.show_real_name + sheet2.row(4).concat(["排名","学生姓名","昵称","学号","分班","作业完成数(*10)","试卷完成数(*10)","问卷完成数(*7)","资源发布数(*5)","帖子发布数(*2)","帖子回复数(*1)","作业回复数(*1)","活跃度"]) + act_members = members + act_members.each do |member| + member[:act_score] = ((member.homework_num.to_i + member.graduation_num.to_i) * 10) + (member.exercise_num.to_i * 10) + (member.poll_num.to_i * 7) + (member.resource_num.to_i * 5) + (member.message_num.to_i * 2) + member.message_reply_num.to_i + member.homework_journal_num.to_i + end + act_members = act_members.sort do |a, b| + [b[:act_score]] <=> [a[:act_score]] + end + count_row = 5 + act_members.each_with_index do |act_member, index| + sheet2[count_row,0]= index + 1 + sheet2[count_row,1] = act_member.user.show_real_name + sheet2[count_row,2] = act_member.user.login + sheet2[count_row,3] = act_member.user.user_extensions.student_id + sheet2[count_row,4] = act_member.course_group_id == 0 ? "暂无" : act_member.course_group.name + sheet2[count_row,5]= act_member.homework_num.to_i + act_member.graduation_num.to_i + sheet2[count_row,6]= act_member.exercise_num + sheet2[count_row,7]= act_member.poll_num + sheet2[count_row,8]= act_member.resource_num + sheet2[count_row,9]= act_member.message_num + sheet2[count_row,10]= act_member.message_reply_num + sheet2[count_row,11]= act_member.homework_journal_num + sheet2[count_row,12]= act_member.act_score + count_row += 1 + end + +# homeworks.where(:homework_type => 4).includes(:score_student_works).each_with_index do |home, i| +# sheet = book.create_worksheet :name => "#{home.name}" +# sheet[0,0] = "课程编号" +# sheet[0,1] = course.id +# sheet[1,0] = "课程名称" +# sheet[1,1] = course.name +# sheet[2,0] = "教师团队" +# sheet[2,1] = teacher_co +# sheet[3,0] = "主讲教师" +# sheet[3,1] = course.teacher.show_real_name +# sheet[3,0] = "作业批次" +# sheet[3,1] = "第#{i+1}次" +# sheet[3,0] = "作业名称" +# sheet[3,1] = home.name +# sheet.row(4).concat([l(:excel_rank),l(:excel_user_name),l(:excel_nickname),l(:excel_student_id),"分班",l(:excel_homework_des),l(:excel_l_penalty),l(:excel_f_score),l(:excel_commit_time)]) +# count_row = 5 +# items = home.score_student_works +# # if items.count == 0 && home.publish_time < Time.now && !course.is_end +# # update_shixun_work_status home +# # items = StudentWork.where("work_status != 0 and homework_common_id = #{home.id}").order("work_score desc") +# # end +# items.each_with_index do |stu, j| +# sheet[count_row,0]= j + 1 +# sheet[count_row,1] = stu.user.show_real_name +# sheet[count_row,2] = stu.user.login +# sheet[count_row,3] = stu.user.user_extensions.student_id +# sheet[count_row,4] = member_group_name course.members, stu.user_id +# sheet[count_row,5] = strip_html stu.description +# sheet[count_row,6] = stu.late_penalty +# sheet[count_row,7] = stu.work_score.nil? ? l(:label_without_score) : stu.work_score.round(1) +# sheet[count_row,8] = format_time(stu.commit_time) +# count_row += 1 +# end +# end +# +# homeworks.where(:homework_type => 1).each_with_index do |home, i| +# sheet = book.create_worksheet :name => "普通作业第#{i+1}次" +# sheet[0,0] = "课程编号" +# sheet[0,1] = course.id +# sheet[1,0] = "课程名称" +# sheet[1,1] = course.name +# sheet[2,0] = "教师团队" +# sheet[2,1] = teacher_co +# sheet[3,0] = "主讲教师" +# sheet[3,1] = course.teacher.show_real_name +# sheet[3,0] = "作业批次" +# sheet[3,1] = "第#{i+1}次" +# sheet[3,0] = "作业名称" +# sheet[3,1] = home.name +# if home.anonymous_comment ==0 +# sheet.row(4).concat([l(:excel_rank),l(:excel_user_name),l(:excel_nickname),l(:excel_student_id),l(:excel_homework_des), +# l(:excel_t_score),l(:excel_ta_score), l(:excel_n_score),l(:excel_a_penalty),l(:excel_l_penalty),l(:excel_f_score),l(:excel_commit_time)]) +# else +# sheet.row(4).concat([l(:excel_rank),l(:excel_user_name),l(:excel_nickname),l(:excel_student_id),l(:excel_homework_des), +# l(:excel_t_score),l(:excel_ta_score),l(:excel_l_penalty),l(:excel_f_score),l(:excel_commit_time)]) +# end +# count_row = 5 +# items = home.score_student_works +# items.each_with_index do |stu, j| +# sheet[count_row,0]= j + 1 +# sheet[count_row,1] = stu.user.show_real_name +# sheet[count_row,2] = stu.user.login +# sheet[count_row,3] = stu.user.user_extensions.student_id +# sheet[count_row,4] = strip_html stu.description +# sheet[count_row,5] = stu.teacher_score.nil? ? l(:label_without_score) : stu.teacher_score.round(1) +# sheet[count_row,6] = stu.teaching_asistant_score.nil? ? l(:label_without_score) : stu.teaching_asistant_score.round(1) +# if home.anonymous_comment ==0 +# sheet[count_row,7] = stu.student_score.nil? ? l(:label_without_score) : stu.student_score.round(1) +# sheet[count_row,8] = (home.teacher_priority == 1 && !stu.teacher_score.nil?) ? 0 : stu.absence_penalty +# sheet[count_row,9] = (home.teacher_priority == 1 && !stu.teacher_score.nil?) ? 0 : stu.late_penalty +# sheet[count_row,10] = stu.work_score.nil? ? l(:label_without_score) : stu.work_score.round(1) +# sheet[count_row,11] = format_time(stu.commit_time) +# else +# sheet[count_row,7] = (home.teacher_priority == 1 && !stu.teacher_score.nil?) ? 0 : stu.late_penalty +# sheet[count_row,8] = stu.work_score.nil? ? l(:label_without_score) : stu.work_score.round(1) +# sheet[count_row,9] = format_time(stu.commit_time) +# end +# count_row += 1 +# end +# +# end +# +# homeworks.where(:homework_type => 3).each_with_index do |home, i| +# sheet = book.create_worksheet :name => "分组作业第#{i+1}次" +# sheet[0,0] = "课程编号" +# sheet[0,1] = course.id +# sheet[1,0] = "课程名称" +# sheet[1,1] = course.name +# sheet[2,0] = "教师团队" +# sheet[2,1] = teacher_co +# sheet[3,0] = "主讲教师" +# sheet[3,1] = course.teacher.show_real_name +# sheet[3,0] = "作业批次" +# sheet[3,1] = "第#{i+1}次" +# sheet[3,0] = "作业名称" +# sheet[3,1] = home.name +# +# if home.anonymous_comment ==0 +# sheet.row(4).concat([l(:excel_rank),l(:excel_user_name),l(:excel_nickname),l(:excel_student_id),l(:excel_group_member),l(:excel_homework_des), +# l(:excel_t_score),l(:excel_ta_score),l(:excel_n_score),l(:excel_a_penalty),l(:excel_l_penalty),l(:excel_f_score),l(:excel_commit_time)]) +# else +# sheet.row(4).concat([l(:excel_rank),l(:excel_user_name),l(:excel_nickname),l(:excel_student_id),l(:excel_group_member),l(:excel_homework_des), +# l(:excel_t_score),l(:excel_ta_score),l(:excel_l_penalty),l(:excel_f_score),l(:excel_commit_time)]) +# end +# count_row = 5 +# items = home.score_student_works +# items.each_with_index do |stu, j| +# sheet[count_row,0] = j + 1 +# sheet[count_row,1] = stu.user.show_real_name +# sheet[count_row,2] = stu.user.login +# sheet[count_row,3] = stu.user.user_extensions.student_id +# sheet[count_row,4] = get_group_member_names home.student_works.where(:group_id => stu.group_id).pluck(:user_id) +# sheet[count_row,5] = strip_html stu.description +# sheet[count_row,6] = stu.teacher_score.nil? ? l(:label_without_score) : stu.teacher_score.round(1) +# sheet[count_row,7] = stu.teaching_asistant_score.nil? ? l(:label_without_score) : stu.teaching_asistant_score.round(1) +# if home.anonymous_comment ==0 +# sheet[count_row,8] = stu.student_score.nil? ? l(:label_without_score) : stu.student_score.round(1) +# sheet[count_row,9] = (home.teacher_priority == 1 && !stu.teacher_score.nil?) ? 0 : stu.absence_penalty +# sheet[count_row,10] = (home.teacher_priority == 1 && !stu.teacher_score.nil?) ? 0 : stu.late_penalty +# sheet[count_row,11] = stu.work_score.nil? ? l(:label_without_score) : stu.work_score.round(1) +# sheet[count_row,12] = format_time(stu.commit_time) +# else +# sheet[count_row,8] = (home.teacher_priority == 1 && !stu.teacher_score.nil?) ? 0 : stu.late_penalty +# sheet[count_row,9] = stu.work_score.nil? ? l(:label_without_score) : stu.work_score.round(1) +# sheet[count_row,10] = format_time(stu.commit_time) +# end +# count_row += 1 +# end +# end +# +# exercises.each_with_index do |exercise, i| +# sheet = book.create_worksheet :name => "试卷第#{i+1}次" +# sheet[0,0] = "课程编号" +# sheet[0,1] = course.id +# sheet[1,0] = "课程名称" +# sheet[1,1] = course.name +# sheet[3,0] = "教师团队" +# sheet[3,1] = teacher_co +# sheet[3,0] = "主讲教师" +# sheet[3,1] = course.teacher.show_real_name +# sheet[3,0] = "试卷批次" +# sheet[3,1] = "第#{i+1}次" +# sheet[3,0] = "试卷名称" +# sheet[3,1] = exercise.exercise_name +# +# sheet.row(4).concat([l(:excel_rank),l(:excel_user_name),l(:excel_nickname),l(:excel_student_id),l(:excel_objective_score),l(:excel_subjective_score),l(:excel_f_score),l(:excel_answer_time)]) +# count_row = 5 +# items = exercise.score_exercise_users +# items.each_with_index do |stu, j| +# sheet[count_row,0] = j + 1 +# sheet[count_row,1] = stu.user.show_real_name +# sheet[count_row,2] = stu.user.login +# sheet[count_row,3] = stu.user.user_extensions.student_id +# sheet[count_row,4] = stu.objective_score == -1 ? "0.0" : format("%.1f",stu.objective_score) +# sheet[count_row,5] = stu.subjective_score == -1 ? "0.0" : format("%.1f",stu.subjective_score) +# sheet[count_row,6] = stu.score.nil? ? '--' : stu.score.round(1) +# sheet[count_row,7] = stu.commit_status == 0 ? l(:excel_no_answer) : format_time(stu.start_at) +# count_row += 1 +# end +# end +# +# tasks.each_with_index do |task, i| +# sheet = book.create_worksheet :name => "毕设任务第#{i+1}次" +# sheet[0,0] = "课程编号" +# sheet[0,1] = course.id +# sheet[1,0] = "课程名称" +# sheet[1,1] = course.name +# sheet[2,0] = "教师团队" +# sheet[2,1] = teacher_co +# sheet[3,0] = "主讲教师" +# sheet[3,1] = course.teacher.show_real_name +# sheet[3,0] = "作业批次" +# sheet[3,1] = "第#{i+1}次" +# sheet[3,0] = "作业名称" +# sheet[3,1] = task.name +# sheet.row(4).concat([l(:excel_rank),l(:excel_user_name),l(:excel_nickname),l(:excel_student_id)]) +# if task.task_type == 2 +# sheet.row(4).concat([l(:excel_group_member)]) +# end +# sheet.row(4).concat([l(:excel_homework_des), l(:excel_t_score)]) +# if task.cross_comment +# sheet.row(4).concat(["交叉评分"]) +# end +# sheet.row(4).concat([l(:excel_l_penalty),l(:excel_f_score),l(:excel_commit_time)]) +# count_row = 5 +# items = task.graduation_works.where("work_status != 0").order("work_score desc") +# items.each_with_index do |stu, j| +# column = 0 +# sheet[count_row,column]= j + 1 +# sheet[count_row,column+=1] = stu.user.show_real_name +# sheet[count_row,column+=1] = stu.user.login +# sheet[count_row,column+=1] = stu.user.user_extensions.student_id +# if task.task_type == 2 +# sheet[count_row,column+=1] = get_group_member_names task.graduation_works.where(:group_id => stu.group_id).pluck(:user_id) +# end +# sheet[count_row,column+=1] = strip_html stu.description +# sheet[count_row,column+=1] = stu.teacher_score.nil? ? l(:label_without_score) : stu.teacher_score.round(1) +# if task.cross_comment +# sheet[count_row,column+=1] = stu.cross_score.nil? ? l(:label_without_score) : stu.cross_score.round(1) +# end +# sheet[count_row,column+=1] = stu.late_penalty +# sheet[count_row,column+=1] = stu.work_score.nil? ? l(:label_without_score) : stu.work_score.round(1) +# sheet[count_row,column+=1] = format_time(stu.commit_time) +# count_row += 1 +# end +# =begin +# if task.task_type == 1 +# if task.cross_comment +# sheet.row(4).concat([l(:excel_rank),l(:excel_user_name),l(:excel_nickname),l(:excel_student_id),l(:excel_homework_des), +# l(:excel_t_score),"交叉评分",l(:excel_l_penalty),l(:excel_f_score),l(:excel_commit_time)]) +# else +# sheet.row(4).concat([l(:excel_rank),l(:excel_user_name),l(:excel_nickname),l(:excel_student_id),l(:excel_homework_des), +# l(:excel_t_score),l(:excel_l_penalty),l(:excel_f_score),l(:excel_commit_time)]) +# end +# else +# if task.cross_comment +# sheet.row(4).concat([l(:excel_rank),l(:excel_user_name),l(:excel_nickname),l(:excel_student_id),l(:excel_group_member),l(:excel_homework_des), +# l(:excel_t_score),"交叉评分",l(:excel_l_penalty),l(:excel_f_score),l(:excel_commit_time)]) +# else +# sheet.row(4).concat([l(:excel_rank),l(:excel_user_name),l(:excel_nickname),l(:excel_student_id),l(:excel_group_member),l(:excel_homework_des), +# l(:excel_t_score),l(:excel_l_penalty),l(:excel_f_score),l(:excel_commit_time)]) +# end +# count_row = 5 +# items = task.graduation_works.order("work_score desc") +# items.each_with_index do |stu, j| +# column = 0 +# sheet[count_row,column]= j + 1 +# sheet[count_row,column+1] = stu.user.show_name +# sheet[count_row,column+1] = stu.user.login +# sheet[count_row,column+1] = stu.user.user_extensions.student_id +# sheet[count_row,column+1] = strip_html stu.description +# sheet[count_row,column+1] = stu.teacher_score.nil? ? l(:label_without_score) : stu.teacher_score.round(2) +# if task.cross_comment +# sheet[count_row,column+1] = stu.cross_score.nil? ? l(:label_without_score) : stu.cross_score.round(2) +# end +# sheet[count_row,column+1] = stu.late_penalty +# sheet[count_row,column+1] = stu.work_score.nil? ? l(:label_without_score) : stu.work_score.round(2) +# sheet[count_row,column+1] = format_time(stu.commit_time) +# count_row += 1 +# end +# end +# =end +# end + book.write xls_report xls_report.string end From 11418510e306a02abd2b4a8b5c03cb5011aeb417 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Fri, 28 Jun 2019 14:10:51 +0800 Subject: [PATCH 06/11] =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/courses_controller.rb | 486 +++++++++++++------------- 1 file changed, 243 insertions(+), 243 deletions(-) diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb index a74e1fc8..a850d16c 100644 --- a/app/controllers/courses_controller.rb +++ b/app/controllers/courses_controller.rb @@ -2562,249 +2562,249 @@ class CoursesController < ApplicationController count_row += 1 end -# homeworks.where(:homework_type => 4).includes(:score_student_works).each_with_index do |home, i| -# sheet = book.create_worksheet :name => "#{home.name}" -# sheet[0,0] = "课程编号" -# sheet[0,1] = course.id -# sheet[1,0] = "课程名称" -# sheet[1,1] = course.name -# sheet[2,0] = "教师团队" -# sheet[2,1] = teacher_co -# sheet[3,0] = "主讲教师" -# sheet[3,1] = course.teacher.show_real_name -# sheet[3,0] = "作业批次" -# sheet[3,1] = "第#{i+1}次" -# sheet[3,0] = "作业名称" -# sheet[3,1] = home.name -# sheet.row(4).concat([l(:excel_rank),l(:excel_user_name),l(:excel_nickname),l(:excel_student_id),"分班",l(:excel_homework_des),l(:excel_l_penalty),l(:excel_f_score),l(:excel_commit_time)]) -# count_row = 5 -# items = home.score_student_works -# # if items.count == 0 && home.publish_time < Time.now && !course.is_end -# # update_shixun_work_status home -# # items = StudentWork.where("work_status != 0 and homework_common_id = #{home.id}").order("work_score desc") -# # end -# items.each_with_index do |stu, j| -# sheet[count_row,0]= j + 1 -# sheet[count_row,1] = stu.user.show_real_name -# sheet[count_row,2] = stu.user.login -# sheet[count_row,3] = stu.user.user_extensions.student_id -# sheet[count_row,4] = member_group_name course.members, stu.user_id -# sheet[count_row,5] = strip_html stu.description -# sheet[count_row,6] = stu.late_penalty -# sheet[count_row,7] = stu.work_score.nil? ? l(:label_without_score) : stu.work_score.round(1) -# sheet[count_row,8] = format_time(stu.commit_time) -# count_row += 1 -# end -# end -# -# homeworks.where(:homework_type => 1).each_with_index do |home, i| -# sheet = book.create_worksheet :name => "普通作业第#{i+1}次" -# sheet[0,0] = "课程编号" -# sheet[0,1] = course.id -# sheet[1,0] = "课程名称" -# sheet[1,1] = course.name -# sheet[2,0] = "教师团队" -# sheet[2,1] = teacher_co -# sheet[3,0] = "主讲教师" -# sheet[3,1] = course.teacher.show_real_name -# sheet[3,0] = "作业批次" -# sheet[3,1] = "第#{i+1}次" -# sheet[3,0] = "作业名称" -# sheet[3,1] = home.name -# if home.anonymous_comment ==0 -# sheet.row(4).concat([l(:excel_rank),l(:excel_user_name),l(:excel_nickname),l(:excel_student_id),l(:excel_homework_des), -# l(:excel_t_score),l(:excel_ta_score), l(:excel_n_score),l(:excel_a_penalty),l(:excel_l_penalty),l(:excel_f_score),l(:excel_commit_time)]) -# else -# sheet.row(4).concat([l(:excel_rank),l(:excel_user_name),l(:excel_nickname),l(:excel_student_id),l(:excel_homework_des), -# l(:excel_t_score),l(:excel_ta_score),l(:excel_l_penalty),l(:excel_f_score),l(:excel_commit_time)]) -# end -# count_row = 5 -# items = home.score_student_works -# items.each_with_index do |stu, j| -# sheet[count_row,0]= j + 1 -# sheet[count_row,1] = stu.user.show_real_name -# sheet[count_row,2] = stu.user.login -# sheet[count_row,3] = stu.user.user_extensions.student_id -# sheet[count_row,4] = strip_html stu.description -# sheet[count_row,5] = stu.teacher_score.nil? ? l(:label_without_score) : stu.teacher_score.round(1) -# sheet[count_row,6] = stu.teaching_asistant_score.nil? ? l(:label_without_score) : stu.teaching_asistant_score.round(1) -# if home.anonymous_comment ==0 -# sheet[count_row,7] = stu.student_score.nil? ? l(:label_without_score) : stu.student_score.round(1) -# sheet[count_row,8] = (home.teacher_priority == 1 && !stu.teacher_score.nil?) ? 0 : stu.absence_penalty -# sheet[count_row,9] = (home.teacher_priority == 1 && !stu.teacher_score.nil?) ? 0 : stu.late_penalty -# sheet[count_row,10] = stu.work_score.nil? ? l(:label_without_score) : stu.work_score.round(1) -# sheet[count_row,11] = format_time(stu.commit_time) -# else -# sheet[count_row,7] = (home.teacher_priority == 1 && !stu.teacher_score.nil?) ? 0 : stu.late_penalty -# sheet[count_row,8] = stu.work_score.nil? ? l(:label_without_score) : stu.work_score.round(1) -# sheet[count_row,9] = format_time(stu.commit_time) -# end -# count_row += 1 -# end -# -# end -# -# homeworks.where(:homework_type => 3).each_with_index do |home, i| -# sheet = book.create_worksheet :name => "分组作业第#{i+1}次" -# sheet[0,0] = "课程编号" -# sheet[0,1] = course.id -# sheet[1,0] = "课程名称" -# sheet[1,1] = course.name -# sheet[2,0] = "教师团队" -# sheet[2,1] = teacher_co -# sheet[3,0] = "主讲教师" -# sheet[3,1] = course.teacher.show_real_name -# sheet[3,0] = "作业批次" -# sheet[3,1] = "第#{i+1}次" -# sheet[3,0] = "作业名称" -# sheet[3,1] = home.name -# -# if home.anonymous_comment ==0 -# sheet.row(4).concat([l(:excel_rank),l(:excel_user_name),l(:excel_nickname),l(:excel_student_id),l(:excel_group_member),l(:excel_homework_des), -# l(:excel_t_score),l(:excel_ta_score),l(:excel_n_score),l(:excel_a_penalty),l(:excel_l_penalty),l(:excel_f_score),l(:excel_commit_time)]) -# else -# sheet.row(4).concat([l(:excel_rank),l(:excel_user_name),l(:excel_nickname),l(:excel_student_id),l(:excel_group_member),l(:excel_homework_des), -# l(:excel_t_score),l(:excel_ta_score),l(:excel_l_penalty),l(:excel_f_score),l(:excel_commit_time)]) -# end -# count_row = 5 -# items = home.score_student_works -# items.each_with_index do |stu, j| -# sheet[count_row,0] = j + 1 -# sheet[count_row,1] = stu.user.show_real_name -# sheet[count_row,2] = stu.user.login -# sheet[count_row,3] = stu.user.user_extensions.student_id -# sheet[count_row,4] = get_group_member_names home.student_works.where(:group_id => stu.group_id).pluck(:user_id) -# sheet[count_row,5] = strip_html stu.description -# sheet[count_row,6] = stu.teacher_score.nil? ? l(:label_without_score) : stu.teacher_score.round(1) -# sheet[count_row,7] = stu.teaching_asistant_score.nil? ? l(:label_without_score) : stu.teaching_asistant_score.round(1) -# if home.anonymous_comment ==0 -# sheet[count_row,8] = stu.student_score.nil? ? l(:label_without_score) : stu.student_score.round(1) -# sheet[count_row,9] = (home.teacher_priority == 1 && !stu.teacher_score.nil?) ? 0 : stu.absence_penalty -# sheet[count_row,10] = (home.teacher_priority == 1 && !stu.teacher_score.nil?) ? 0 : stu.late_penalty -# sheet[count_row,11] = stu.work_score.nil? ? l(:label_without_score) : stu.work_score.round(1) -# sheet[count_row,12] = format_time(stu.commit_time) -# else -# sheet[count_row,8] = (home.teacher_priority == 1 && !stu.teacher_score.nil?) ? 0 : stu.late_penalty -# sheet[count_row,9] = stu.work_score.nil? ? l(:label_without_score) : stu.work_score.round(1) -# sheet[count_row,10] = format_time(stu.commit_time) -# end -# count_row += 1 -# end -# end -# -# exercises.each_with_index do |exercise, i| -# sheet = book.create_worksheet :name => "试卷第#{i+1}次" -# sheet[0,0] = "课程编号" -# sheet[0,1] = course.id -# sheet[1,0] = "课程名称" -# sheet[1,1] = course.name -# sheet[3,0] = "教师团队" -# sheet[3,1] = teacher_co -# sheet[3,0] = "主讲教师" -# sheet[3,1] = course.teacher.show_real_name -# sheet[3,0] = "试卷批次" -# sheet[3,1] = "第#{i+1}次" -# sheet[3,0] = "试卷名称" -# sheet[3,1] = exercise.exercise_name -# -# sheet.row(4).concat([l(:excel_rank),l(:excel_user_name),l(:excel_nickname),l(:excel_student_id),l(:excel_objective_score),l(:excel_subjective_score),l(:excel_f_score),l(:excel_answer_time)]) -# count_row = 5 -# items = exercise.score_exercise_users -# items.each_with_index do |stu, j| -# sheet[count_row,0] = j + 1 -# sheet[count_row,1] = stu.user.show_real_name -# sheet[count_row,2] = stu.user.login -# sheet[count_row,3] = stu.user.user_extensions.student_id -# sheet[count_row,4] = stu.objective_score == -1 ? "0.0" : format("%.1f",stu.objective_score) -# sheet[count_row,5] = stu.subjective_score == -1 ? "0.0" : format("%.1f",stu.subjective_score) -# sheet[count_row,6] = stu.score.nil? ? '--' : stu.score.round(1) -# sheet[count_row,7] = stu.commit_status == 0 ? l(:excel_no_answer) : format_time(stu.start_at) -# count_row += 1 -# end -# end -# -# tasks.each_with_index do |task, i| -# sheet = book.create_worksheet :name => "毕设任务第#{i+1}次" -# sheet[0,0] = "课程编号" -# sheet[0,1] = course.id -# sheet[1,0] = "课程名称" -# sheet[1,1] = course.name -# sheet[2,0] = "教师团队" -# sheet[2,1] = teacher_co -# sheet[3,0] = "主讲教师" -# sheet[3,1] = course.teacher.show_real_name -# sheet[3,0] = "作业批次" -# sheet[3,1] = "第#{i+1}次" -# sheet[3,0] = "作业名称" -# sheet[3,1] = task.name -# sheet.row(4).concat([l(:excel_rank),l(:excel_user_name),l(:excel_nickname),l(:excel_student_id)]) -# if task.task_type == 2 -# sheet.row(4).concat([l(:excel_group_member)]) -# end -# sheet.row(4).concat([l(:excel_homework_des), l(:excel_t_score)]) -# if task.cross_comment -# sheet.row(4).concat(["交叉评分"]) -# end -# sheet.row(4).concat([l(:excel_l_penalty),l(:excel_f_score),l(:excel_commit_time)]) -# count_row = 5 -# items = task.graduation_works.where("work_status != 0").order("work_score desc") -# items.each_with_index do |stu, j| -# column = 0 -# sheet[count_row,column]= j + 1 -# sheet[count_row,column+=1] = stu.user.show_real_name -# sheet[count_row,column+=1] = stu.user.login -# sheet[count_row,column+=1] = stu.user.user_extensions.student_id -# if task.task_type == 2 -# sheet[count_row,column+=1] = get_group_member_names task.graduation_works.where(:group_id => stu.group_id).pluck(:user_id) -# end -# sheet[count_row,column+=1] = strip_html stu.description -# sheet[count_row,column+=1] = stu.teacher_score.nil? ? l(:label_without_score) : stu.teacher_score.round(1) -# if task.cross_comment -# sheet[count_row,column+=1] = stu.cross_score.nil? ? l(:label_without_score) : stu.cross_score.round(1) -# end -# sheet[count_row,column+=1] = stu.late_penalty -# sheet[count_row,column+=1] = stu.work_score.nil? ? l(:label_without_score) : stu.work_score.round(1) -# sheet[count_row,column+=1] = format_time(stu.commit_time) -# count_row += 1 -# end -# =begin -# if task.task_type == 1 -# if task.cross_comment -# sheet.row(4).concat([l(:excel_rank),l(:excel_user_name),l(:excel_nickname),l(:excel_student_id),l(:excel_homework_des), -# l(:excel_t_score),"交叉评分",l(:excel_l_penalty),l(:excel_f_score),l(:excel_commit_time)]) -# else -# sheet.row(4).concat([l(:excel_rank),l(:excel_user_name),l(:excel_nickname),l(:excel_student_id),l(:excel_homework_des), -# l(:excel_t_score),l(:excel_l_penalty),l(:excel_f_score),l(:excel_commit_time)]) -# end -# else -# if task.cross_comment -# sheet.row(4).concat([l(:excel_rank),l(:excel_user_name),l(:excel_nickname),l(:excel_student_id),l(:excel_group_member),l(:excel_homework_des), -# l(:excel_t_score),"交叉评分",l(:excel_l_penalty),l(:excel_f_score),l(:excel_commit_time)]) -# else -# sheet.row(4).concat([l(:excel_rank),l(:excel_user_name),l(:excel_nickname),l(:excel_student_id),l(:excel_group_member),l(:excel_homework_des), -# l(:excel_t_score),l(:excel_l_penalty),l(:excel_f_score),l(:excel_commit_time)]) -# end -# count_row = 5 -# items = task.graduation_works.order("work_score desc") -# items.each_with_index do |stu, j| -# column = 0 -# sheet[count_row,column]= j + 1 -# sheet[count_row,column+1] = stu.user.show_name -# sheet[count_row,column+1] = stu.user.login -# sheet[count_row,column+1] = stu.user.user_extensions.student_id -# sheet[count_row,column+1] = strip_html stu.description -# sheet[count_row,column+1] = stu.teacher_score.nil? ? l(:label_without_score) : stu.teacher_score.round(2) -# if task.cross_comment -# sheet[count_row,column+1] = stu.cross_score.nil? ? l(:label_without_score) : stu.cross_score.round(2) -# end -# sheet[count_row,column+1] = stu.late_penalty -# sheet[count_row,column+1] = stu.work_score.nil? ? l(:label_without_score) : stu.work_score.round(2) -# sheet[count_row,column+1] = format_time(stu.commit_time) -# count_row += 1 -# end -# end -# =end -# end + homeworks.where(:homework_type => 4).includes(:score_student_works).each_with_index do |home, i| + sheet = book.create_worksheet :name => "#{home.name}" + sheet[0,0] = "课程编号" + sheet[0,1] = course.id + sheet[1,0] = "课程名称" + sheet[1,1] = course.name + sheet[2,0] = "教师团队" + sheet[2,1] = teacher_co + sheet[3,0] = "主讲教师" + sheet[3,1] = course.teacher.show_real_name + sheet[3,0] = "作业批次" + sheet[3,1] = "第#{i+1}次" + sheet[3,0] = "作业名称" + sheet[3,1] = home.name + sheet.row(4).concat([l(:excel_rank),l(:excel_user_name),l(:excel_nickname),l(:excel_student_id),"分班",l(:excel_homework_des),l(:excel_l_penalty),l(:excel_f_score),l(:excel_commit_time)]) + count_row = 5 + items = home.score_student_works + # if items.count == 0 && home.publish_time < Time.now && !course.is_end + # update_shixun_work_status home + # items = StudentWork.where("work_status != 0 and homework_common_id = #{home.id}").order("work_score desc") + # end + items.each_with_index do |stu, j| + sheet[count_row,0]= j + 1 + sheet[count_row,1] = stu.user.show_real_name + sheet[count_row,2] = stu.user.login + sheet[count_row,3] = stu.user.user_extensions.student_id + sheet[count_row,4] = member_group_name course.members, stu.user_id + sheet[count_row,5] = strip_html stu.description + sheet[count_row,6] = stu.late_penalty + sheet[count_row,7] = stu.work_score.nil? ? l(:label_without_score) : stu.work_score.round(1) + sheet[count_row,8] = format_time(stu.commit_time) + count_row += 1 + end + end + + homeworks.where(:homework_type => 1).includes(:score_student_works).each_with_index do |home, i| + sheet = book.create_worksheet :name => "普通作业第#{i+1}次" + sheet[0,0] = "课程编号" + sheet[0,1] = course.id + sheet[1,0] = "课程名称" + sheet[1,1] = course.name + sheet[2,0] = "教师团队" + sheet[2,1] = teacher_co + sheet[3,0] = "主讲教师" + sheet[3,1] = course.teacher.show_real_name + sheet[3,0] = "作业批次" + sheet[3,1] = "第#{i+1}次" + sheet[3,0] = "作业名称" + sheet[3,1] = home.name + if home.anonymous_comment ==0 + sheet.row(4).concat([l(:excel_rank),l(:excel_user_name),l(:excel_nickname),l(:excel_student_id),l(:excel_homework_des), + l(:excel_t_score),l(:excel_ta_score), l(:excel_n_score),l(:excel_a_penalty),l(:excel_l_penalty),l(:excel_f_score),l(:excel_commit_time)]) + else + sheet.row(4).concat([l(:excel_rank),l(:excel_user_name),l(:excel_nickname),l(:excel_student_id),l(:excel_homework_des), + l(:excel_t_score),l(:excel_ta_score),l(:excel_l_penalty),l(:excel_f_score),l(:excel_commit_time)]) + end + count_row = 5 + items = home.score_student_works + items.each_with_index do |stu, j| + sheet[count_row,0]= j + 1 + sheet[count_row,1] = stu.user.show_real_name + sheet[count_row,2] = stu.user.login + sheet[count_row,3] = stu.user.user_extensions.student_id + sheet[count_row,4] = strip_html stu.description + sheet[count_row,5] = stu.teacher_score.nil? ? l(:label_without_score) : stu.teacher_score.round(1) + sheet[count_row,6] = stu.teaching_asistant_score.nil? ? l(:label_without_score) : stu.teaching_asistant_score.round(1) + if home.anonymous_comment ==0 + sheet[count_row,7] = stu.student_score.nil? ? l(:label_without_score) : stu.student_score.round(1) + sheet[count_row,8] = (home.teacher_priority == 1 && !stu.teacher_score.nil?) ? 0 : stu.absence_penalty + sheet[count_row,9] = (home.teacher_priority == 1 && !stu.teacher_score.nil?) ? 0 : stu.late_penalty + sheet[count_row,10] = stu.work_score.nil? ? l(:label_without_score) : stu.work_score.round(1) + sheet[count_row,11] = format_time(stu.commit_time) + else + sheet[count_row,7] = (home.teacher_priority == 1 && !stu.teacher_score.nil?) ? 0 : stu.late_penalty + sheet[count_row,8] = stu.work_score.nil? ? l(:label_without_score) : stu.work_score.round(1) + sheet[count_row,9] = format_time(stu.commit_time) + end + count_row += 1 + end + + end + + homeworks.where(:homework_type => 3).includes(:score_student_works).each_with_index do |home, i| + sheet = book.create_worksheet :name => "分组作业第#{i+1}次" + sheet[0,0] = "课程编号" + sheet[0,1] = course.id + sheet[1,0] = "课程名称" + sheet[1,1] = course.name + sheet[2,0] = "教师团队" + sheet[2,1] = teacher_co + sheet[3,0] = "主讲教师" + sheet[3,1] = course.teacher.show_real_name + sheet[3,0] = "作业批次" + sheet[3,1] = "第#{i+1}次" + sheet[3,0] = "作业名称" + sheet[3,1] = home.name + + if home.anonymous_comment ==0 + sheet.row(4).concat([l(:excel_rank),l(:excel_user_name),l(:excel_nickname),l(:excel_student_id),l(:excel_group_member),l(:excel_homework_des), + l(:excel_t_score),l(:excel_ta_score),l(:excel_n_score),l(:excel_a_penalty),l(:excel_l_penalty),l(:excel_f_score),l(:excel_commit_time)]) + else + sheet.row(4).concat([l(:excel_rank),l(:excel_user_name),l(:excel_nickname),l(:excel_student_id),l(:excel_group_member),l(:excel_homework_des), + l(:excel_t_score),l(:excel_ta_score),l(:excel_l_penalty),l(:excel_f_score),l(:excel_commit_time)]) + end + count_row = 5 + items = home.score_student_works + items.each_with_index do |stu, j| + sheet[count_row,0] = j + 1 + sheet[count_row,1] = stu.user.show_real_name + sheet[count_row,2] = stu.user.login + sheet[count_row,3] = stu.user.user_extensions.student_id + sheet[count_row,4] = get_group_member_names home.student_works.where(:group_id => stu.group_id).pluck(:user_id) + sheet[count_row,5] = strip_html stu.description + sheet[count_row,6] = stu.teacher_score.nil? ? l(:label_without_score) : stu.teacher_score.round(1) + sheet[count_row,7] = stu.teaching_asistant_score.nil? ? l(:label_without_score) : stu.teaching_asistant_score.round(1) + if home.anonymous_comment ==0 + sheet[count_row,8] = stu.student_score.nil? ? l(:label_without_score) : stu.student_score.round(1) + sheet[count_row,9] = (home.teacher_priority == 1 && !stu.teacher_score.nil?) ? 0 : stu.absence_penalty + sheet[count_row,10] = (home.teacher_priority == 1 && !stu.teacher_score.nil?) ? 0 : stu.late_penalty + sheet[count_row,11] = stu.work_score.nil? ? l(:label_without_score) : stu.work_score.round(1) + sheet[count_row,12] = format_time(stu.commit_time) + else + sheet[count_row,8] = (home.teacher_priority == 1 && !stu.teacher_score.nil?) ? 0 : stu.late_penalty + sheet[count_row,9] = stu.work_score.nil? ? l(:label_without_score) : stu.work_score.round(1) + sheet[count_row,10] = format_time(stu.commit_time) + end + count_row += 1 + end + end + + exercises.includes(:score_exercise_users).each_with_index do |exercise, i| + sheet = book.create_worksheet :name => "试卷第#{i+1}次" + sheet[0,0] = "课程编号" + sheet[0,1] = course.id + sheet[1,0] = "课程名称" + sheet[1,1] = course.name + sheet[3,0] = "教师团队" + sheet[3,1] = teacher_co + sheet[3,0] = "主讲教师" + sheet[3,1] = course.teacher.show_real_name + sheet[3,0] = "试卷批次" + sheet[3,1] = "第#{i+1}次" + sheet[3,0] = "试卷名称" + sheet[3,1] = exercise.exercise_name + + sheet.row(4).concat([l(:excel_rank),l(:excel_user_name),l(:excel_nickname),l(:excel_student_id),l(:excel_objective_score),l(:excel_subjective_score),l(:excel_f_score),l(:excel_answer_time)]) + count_row = 5 + items = exercise.score_exercise_users + items.each_with_index do |stu, j| + sheet[count_row,0] = j + 1 + sheet[count_row,1] = stu.user.show_real_name + sheet[count_row,2] = stu.user.login + sheet[count_row,3] = stu.user.user_extensions.student_id + sheet[count_row,4] = stu.objective_score == -1 ? "0.0" : format("%.1f",stu.objective_score) + sheet[count_row,5] = stu.subjective_score == -1 ? "0.0" : format("%.1f",stu.subjective_score) + sheet[count_row,6] = stu.score.nil? ? '--' : stu.score.round(1) + sheet[count_row,7] = stu.commit_status == 0 ? l(:excel_no_answer) : format_time(stu.start_at) + count_row += 1 + end + end + + tasks.each_with_index do |task, i| + sheet = book.create_worksheet :name => "毕设任务第#{i+1}次" + sheet[0,0] = "课程编号" + sheet[0,1] = course.id + sheet[1,0] = "课程名称" + sheet[1,1] = course.name + sheet[2,0] = "教师团队" + sheet[2,1] = teacher_co + sheet[3,0] = "主讲教师" + sheet[3,1] = course.teacher.show_real_name + sheet[3,0] = "作业批次" + sheet[3,1] = "第#{i+1}次" + sheet[3,0] = "作业名称" + sheet[3,1] = task.name + sheet.row(4).concat([l(:excel_rank),l(:excel_user_name),l(:excel_nickname),l(:excel_student_id)]) + if task.task_type == 2 + sheet.row(4).concat([l(:excel_group_member)]) + end + sheet.row(4).concat([l(:excel_homework_des), l(:excel_t_score)]) + if task.cross_comment + sheet.row(4).concat(["交叉评分"]) + end + sheet.row(4).concat([l(:excel_l_penalty),l(:excel_f_score),l(:excel_commit_time)]) + count_row = 5 + items = task.graduation_works.where("work_status != 0").order("work_score desc") + items.each_with_index do |stu, j| + column = 0 + sheet[count_row,column]= j + 1 + sheet[count_row,column+=1] = stu.user.show_real_name + sheet[count_row,column+=1] = stu.user.login + sheet[count_row,column+=1] = stu.user.user_extensions.student_id + if task.task_type == 2 + sheet[count_row,column+=1] = get_group_member_names task.graduation_works.where(:group_id => stu.group_id).pluck(:user_id) + end + sheet[count_row,column+=1] = strip_html stu.description + sheet[count_row,column+=1] = stu.teacher_score.nil? ? l(:label_without_score) : stu.teacher_score.round(1) + if task.cross_comment + sheet[count_row,column+=1] = stu.cross_score.nil? ? l(:label_without_score) : stu.cross_score.round(1) + end + sheet[count_row,column+=1] = stu.late_penalty + sheet[count_row,column+=1] = stu.work_score.nil? ? l(:label_without_score) : stu.work_score.round(1) + sheet[count_row,column+=1] = format_time(stu.commit_time) + count_row += 1 + end +=begin + if task.task_type == 1 + if task.cross_comment + sheet.row(4).concat([l(:excel_rank),l(:excel_user_name),l(:excel_nickname),l(:excel_student_id),l(:excel_homework_des), + l(:excel_t_score),"交叉评分",l(:excel_l_penalty),l(:excel_f_score),l(:excel_commit_time)]) + else + sheet.row(4).concat([l(:excel_rank),l(:excel_user_name),l(:excel_nickname),l(:excel_student_id),l(:excel_homework_des), + l(:excel_t_score),l(:excel_l_penalty),l(:excel_f_score),l(:excel_commit_time)]) + end + else + if task.cross_comment + sheet.row(4).concat([l(:excel_rank),l(:excel_user_name),l(:excel_nickname),l(:excel_student_id),l(:excel_group_member),l(:excel_homework_des), + l(:excel_t_score),"交叉评分",l(:excel_l_penalty),l(:excel_f_score),l(:excel_commit_time)]) + else + sheet.row(4).concat([l(:excel_rank),l(:excel_user_name),l(:excel_nickname),l(:excel_student_id),l(:excel_group_member),l(:excel_homework_des), + l(:excel_t_score),l(:excel_l_penalty),l(:excel_f_score),l(:excel_commit_time)]) + end + count_row = 5 + items = task.graduation_works.order("work_score desc") + items.each_with_index do |stu, j| + column = 0 + sheet[count_row,column]= j + 1 + sheet[count_row,column+1] = stu.user.show_name + sheet[count_row,column+1] = stu.user.login + sheet[count_row,column+1] = stu.user.user_extensions.student_id + sheet[count_row,column+1] = strip_html stu.description + sheet[count_row,column+1] = stu.teacher_score.nil? ? l(:label_without_score) : stu.teacher_score.round(2) + if task.cross_comment + sheet[count_row,column+1] = stu.cross_score.nil? ? l(:label_without_score) : stu.cross_score.round(2) + end + sheet[count_row,column+1] = stu.late_penalty + sheet[count_row,column+1] = stu.work_score.nil? ? l(:label_without_score) : stu.work_score.round(2) + sheet[count_row,column+1] = format_time(stu.commit_time) + count_row += 1 + end + end +=end + end book.write xls_report xls_report.string From 0c478172eeb769560bf92c6c2b351c784723c42b Mon Sep 17 00:00:00 2001 From: p31729568 Date: Sat, 29 Jun 2019 14:06:02 +0800 Subject: [PATCH 07/11] new competition --- .../_gq_second_code_competition.html.erb | 6 ++-- .../_qg_second_course_competition.html.erb | 34 ++++++++++++++----- app/views/competitions/show.html.erb | 2 ++ 3 files changed, 30 insertions(+), 12 deletions(-) diff --git a/app/views/competitions/_gq_second_code_competition.html.erb b/app/views/competitions/_gq_second_code_competition.html.erb index ccdfe190..35c5dd17 100644 --- a/app/views/competitions/_gq_second_code_competition.html.erb +++ b/app/views/competitions/_gq_second_code_competition.html.erb @@ -34,11 +34,11 @@ ] %> -<% @competition.competition_stages.each_with_index do |stage, i| %> +<% @competition.competition_stages.includes(:competition_stage_sections).each_with_index do |stage, i| %>
<% - first_section = stage.competition_stage_sections.first - second_section = stage.competition_stage_sections.second + first_section = stage.competition_stage_sections[0] + second_section = stage.competition_stage_sections[1] %>
"> <% if i.zero? %> diff --git a/app/views/competitions/_qg_second_course_competition.html.erb b/app/views/competitions/_qg_second_course_competition.html.erb index 92d2a9f9..b808deab 100644 --- a/app/views/competitions/_qg_second_course_competition.html.erb +++ b/app/views/competitions/_qg_second_course_competition.html.erb @@ -1,14 +1,30 @@ -

-

-

-

-
+<% index = 0 %> +

+<% index += 1 %> +

+<% index += 1 %> +

+<% index += 1 %> +

+<% index += 1 %> + +<% + stage = @competition.competition_stages.first + first_section = stage.competition_stage_sections.first + is_start = Time.now > first_section.start_time +%> + -

+<% index += 1 %> + +

diff --git a/app/views/competitions/show.html.erb b/app/views/competitions/show.html.erb index 1549c46d..0df98a24 100644 --- a/app/views/competitions/show.html.erb +++ b/app/views/competitions/show.html.erb @@ -11,5 +11,7 @@ <%= render :partial => "qg_second_competition" %> <% elsif @competition.identifier == "gcc-annotation-2019" %> <%= render :partial => "gq_second_code_competition" %> + <% elsif @competition.identifier == "gcc-course-2019" %> + <%= render :partial => "qg_second_course_competition" %> <% end %>
\ No newline at end of file From 5b1abe2d64793ebde16f19cf6aed4f99da919127 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Sat, 29 Jun 2019 14:09:57 +0800 Subject: [PATCH 08/11] =?UTF-8?q?=E5=AE=9E=E8=AE=AD=E5=85=B3=E5=8D=A1?= =?UTF-8?q?=E7=9A=84=E8=B6=85=E6=97=B6=E6=97=B6=E9=97=B4=E9=BB=98=E8=AE=A4?= =?UTF-8?q?=E8=AE=BE=E7=BD=AE=E6=88=9020?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...90629060410_change_exec_time_default_for_challenges.rb | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 db/migrate/20190629060410_change_exec_time_default_for_challenges.rb diff --git a/db/migrate/20190629060410_change_exec_time_default_for_challenges.rb b/db/migrate/20190629060410_change_exec_time_default_for_challenges.rb new file mode 100644 index 00000000..43464dc0 --- /dev/null +++ b/db/migrate/20190629060410_change_exec_time_default_for_challenges.rb @@ -0,0 +1,8 @@ +class ChangeExecTimeDefaultForChallenges < ActiveRecord::Migration + def up + change_column :challenges, :exec_time, :integer, :default => 20 + end + + def down + end +end From 65523c2d2c2a0b776f1a1468b42a5e252664c837 Mon Sep 17 00:00:00 2001 From: p31729568 Date: Sat, 29 Jun 2019 14:10:43 +0800 Subject: [PATCH 09/11] fix competition join team --- app/controllers/competition_teams_controller.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/controllers/competition_teams_controller.rb b/app/controllers/competition_teams_controller.rb index 0d78fb58..817de9be 100644 --- a/app/controllers/competition_teams_controller.rb +++ b/app/controllers/competition_teams_controller.rb @@ -145,7 +145,7 @@ class CompetitionTeamsController < ApplicationController # 老师身份加入战队 if User.current.user_extensions.identity == 0 - teacher_staff = @competition.where(category: 'teacher').first + teacher_staff = @competition.competition_staffs.where(category: 'teacher').first if teacher_staff.blank? @status, @message = -1, '该竞赛不能配备导师' @@ -158,7 +158,7 @@ class CompetitionTeamsController < ApplicationController end team.team_members.create!(user_id: User.current.id, role: 3, competition_id: @competition.id, is_teacher: true) else - max_member_count = @competition.where('category != "teacher"').sum(:maximum) + max_member_count = @competition.competition_staffs.where('category != "teacher"').sum(:maximum) if team.members.count + 1 > max_member_count @status, @message = -1, '该战队成员人数已满' return From 87afa692321aa7052b9d9f67f138c74ea6af0950 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Sat, 29 Jun 2019 14:13:59 +0800 Subject: [PATCH 10/11] =?UTF-8?q?=E5=AF=B9=E9=9D=9E=E8=AF=BE=E5=A0=82?= =?UTF-8?q?=E6=88=90=E5=91=98=E9=9A=90=E8=97=8F=E5=AD=A6=E5=8F=B7=E4=BF=A1?= =?UTF-8?q?=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../courses/settings/_student_table.html.erb | 12 ++-- app/views/exercise/_student_exercise.html.erb | 12 ++-- .../_student_work_list.html.erb | 56 ++++++++++--------- .../_student_topic_list.html.erb | 10 +++- app/views/poll/_student_poll.html.erb | 12 ++-- .../_evaluation_un_common_title.html.erb | 14 +++-- .../_evaluation_un_group_title.html.erb | 14 +++-- .../_evaluation_un_shixun_title.html.erb | 14 +++-- 8 files changed, 89 insertions(+), 55 deletions(-) diff --git a/app/views/courses/settings/_student_table.html.erb b/app/views/courses/settings/_student_table.html.erb index 49c59421..f3b0c254 100644 --- a/app/views/courses/settings/_student_table.html.erb +++ b/app/views/courses/settings/_student_table.html.erb @@ -5,7 +5,9 @@ 用户ID 姓名 - 学号 + <% if User.current.admin || User.current.member_of_course?(@course) %> + 学号 + <% end %> 分班 @@ -22,9 +24,11 @@ <% end %> <%= user.login %> <%= link_to user.show_real_name, user_path(user), :class => 'edu-txt-w140 task-hide mt5 color-grey-3', :target => '_blank' %> - - <%= user.user_extensions ? user.user_extensions.student_id : '' %> - + <% if User.current.admin || User.current.member_of_course?(@course) %> + + <%= user.user_extensions ? user.user_extensions.student_id : '' %> + + <% end %> <%= member.course_group_id == 0 || member.course_group_id.nil? ? '未分班' : member.course_group.name %> <% if false %> <%= format("%.1f", member.course_score) %> diff --git a/app/views/exercise/_student_exercise.html.erb b/app/views/exercise/_student_exercise.html.erb index 68a92d3f..bb83e49d 100644 --- a/app/views/exercise/_student_exercise.html.erb +++ b/app/views/exercise/_student_exercise.html.erb @@ -12,7 +12,9 @@ 序号 姓名 分班 - 学号 + <% if User.current.admin || User.current.member_of_course?(@course) %> + 学号 + <% end %> 提交状态 提交时间 客观题得分 @@ -35,9 +37,11 @@ <%= member.try(:course_group_id).to_i == 0 ? '未分班' : member.course_group.name %> - "> - <%= exercise.user.user_extensions.nil? ? "--" : exercise.user.user_extensions.student_id %> - + <% if User.current.admin || User.current.member_of_course?(@course) %> + "> + <%= exercise.user.user_extensions.nil? ? "--" : exercise.user.user_extensions.student_id %> + + <% end %> <%= (ex_poll_work_status exercise.commit_status).html_safe %> diff --git a/app/views/graduation_tasks/_student_work_list.html.erb b/app/views/graduation_tasks/_student_work_list.html.erb index 84187cf4..3f3e2661 100644 --- a/app/views/graduation_tasks/_student_work_list.html.erb +++ b/app/views/graduation_tasks/_student_work_list.html.erb @@ -16,27 +16,29 @@
- +
- + - - + <% if User.current.admin || User.current.member_of_course?(@course) %> + + <% end %> + <% if @task.task_type == 2 %> - + <% if @task.base_on_project %> - + <% end %> <% end %> - - - + + + <% if @task.cross_comment %> - + <% end %> - - + + @@ -44,16 +46,20 @@ <% @works.each_with_index do |work, i| %> <% score_open = task_score_open || work.user == User.current %> - - - <% student_id = work.user.user_extensions.nil? ? "--" : work.user.user_extensions.student_id %> - + + + <% if User.current.admin || User.current.member_of_course?(@course) %> + <% student_id = work.user.user_extensions.nil? ? "--" : work.user.user_extensions.student_id %> + + <% end %> <% group_name = member_group_name @course.members, work.user_id %> - + <% if @task.task_type == 2 %> - + <% if @task.base_on_project %> - <% end %> <% end %> - - - + + <% if @task.cross_comment %> - <% end %> <% score = work.work_score %> - - - + <% if User.current.admin || User.current.member_of_course?(@course) %> + + <% end %> <% if @poll.un_anonymous && @is_teacher %> @@ -29,9 +31,11 @@ - + <% if User.current.admin || User.current.member_of_course?(@course) %> + + <% end %> diff --git a/app/views/student_work/_evaluation_un_common_title.html.erb b/app/views/student_work/_evaluation_un_common_title.html.erb index 20c85456..da53c12d 100644 --- a/app/views/student_work/_evaluation_un_common_title.html.erb +++ b/app/views/student_work/_evaluation_un_common_title.html.erb @@ -3,7 +3,9 @@ - + <% if User.current.admin || User.current.member_of_course?(@course) %> + + <% end %> @@ -33,10 +35,12 @@ - <% student_id = student_work.user.user_extensions.nil? ? "--" : student_work.user.user_extensions.student_id %> - + <% if User.current.admin || User.current.member_of_course?(@course) %> + <% student_id = student_work.user.user_extensions.nil? ? "--" : student_work.user.user_extensions.student_id %> + + <% end %> diff --git a/app/views/student_work/_evaluation_un_group_title.html.erb b/app/views/student_work/_evaluation_un_group_title.html.erb index 9bc44e9b..d782fe7f 100644 --- a/app/views/student_work/_evaluation_un_group_title.html.erb +++ b/app/views/student_work/_evaluation_un_group_title.html.erb @@ -3,7 +3,9 @@ - + <% if User.current.admin || User.current.member_of_course?(@course) %> + + <% end %> <% if @homework.homework_detail_group.base_on_project == 1 %> @@ -38,10 +40,12 @@ - <% student_id = student_work.user.user_extensions.nil? ? "--" : student_work.user.user_extensions.student_id %> - + <% if User.current.admin || User.current.member_of_course?(@course) %> + <% student_id = student_work.user.user_extensions.nil? ? "--" : student_work.user.user_extensions.student_id %> + + <% end %> diff --git a/app/views/student_work/_evaluation_un_shixun_title.html.erb b/app/views/student_work/_evaluation_un_shixun_title.html.erb index d732fcf7..f8380cdc 100644 --- a/app/views/student_work/_evaluation_un_shixun_title.html.erb +++ b/app/views/student_work/_evaluation_un_shixun_title.html.erb @@ -3,7 +3,9 @@ - + <% if User.current.admin || User.current.member_of_course?(@course) %> + + <% end %> @@ -30,10 +32,12 @@ - <% student_id = student_work.user.user_extensions.nil? ? "--" : student_work.user.user_extensions.student_id %> - + <% if User.current.admin || User.current.member_of_course?(@course) %> + <% student_id = student_work.user.user_extensions.nil? ? "--" : student_work.user.user_extensions.student_id %> + + <% end %>
序号序号 姓名学号分班学号分班分组分组关联项目关联项目提交状态更新时间教师评分提交状态更新时间教师评分交叉评分交叉评分最终成绩操作最终成绩操作
<%= (@page - 1) * @limit + i + 1 %><%= link_to work.user.show_real_name, user_path(work.user), :target => "_blank" %><%= student_id %><%= (@page - 1) * @limit + i + 1 %><%= link_to work.user.show_real_name, user_path(work.user), :target => "_blank" %><%= student_id %><%= group_name %> + <%= group_name %> + <%= work.group_id == 0 ? '--' : '分组'+work.group_id.to_s %><%= work.group_id == 0 ? '--' : '分组'+work.group_id.to_s %> + <% if work.project %> <% project = work.project %> <% if project.status != 9 && (project.is_public || User.current.member_of?(project) || @is_teacher) %> @@ -85,18 +91,18 @@ <%= (ex_poll_work_status work.work_status).html_safe %><%= work.work_status == 0 ? '--' : format_time(work.update_time) %> + <%= (ex_poll_work_status work.work_status).html_safe %><%= work.work_status == 0 ? '--' : format_time(work.update_time) %> <%= work.work_status == 0 ? '--' : (work.teacher_score.nil? ? "未批阅" : (!score_open ? "**" : format("%.1f", work.teacher_score.round(1)))) %> + <%= work.work_status == 0 ? '--' : (work.cross_score.nil? ? "未批阅" : (!score_open ? "**" : (format("%.1f", work.cross_score.round(1)) + "(#{work.graduation_work_scores.where(:reviewer_role => 2).group_by(&:user_id).count})"))) %> + <%= score.nil? ? "--" : (!score_open ? "**" : format("%.1f",score<0 ? 0 : score.round(1)))%> <% if score.present? %> <% end %> + <% if @is_teacher && @task.cross_comment && @task.comment_status == 2 %> 分配 <% end %> diff --git a/app/views/graduation_topics/_student_topic_list.html.erb b/app/views/graduation_topics/_student_topic_list.html.erb index cbe40195..80fdf4aa 100644 --- a/app/views/graduation_topics/_student_topic_list.html.erb +++ b/app/views/graduation_topics/_student_topic_list.html.erb @@ -3,7 +3,9 @@

序号 姓名 - 学号 + <% if User.current.admin || User.current.member_of_course?(@course) %> + 学号 + <% end %> 分班 选题时间 确认结果 @@ -15,8 +17,10 @@

<%= index + 1 %> <%= student_topic.user.show_real_name %> - <% student_id = student_topic.user.user_extensions.try(:student_id).present? ? student_topic.user.user_extensions.student_id : "--" %> - <%= student_id %> + <% if User.current.admin || User.current.member_of_course?(@course) %> + <% student_id = student_topic.user.user_extensions.try(:student_id).present? ? student_topic.user.user_extensions.student_id : "--" %> + <%= student_id %> + <% end %> <%= student_topic.member.course_group.try(:name) %> <%= format_time student_topic.created_at %> <%= (student_topic_status student_topic.status).html_safe %> diff --git a/app/views/poll/_student_poll.html.erb b/app/views/poll/_student_poll.html.erb index edf97bd4..80589a4c 100644 --- a/app/views/poll/_student_poll.html.erb +++ b/app/views/poll/_student_poll.html.erb @@ -10,7 +10,9 @@

序号 姓名 分班学号学号提交状态 提交时间 <%= member.try(:course_group_id).to_i == 0 ? '未分班' : member.course_group.name %> "> - <%= poll.user.user_extensions.nil? ? "--" : poll.user.user_extensions.student_id %> - "> + <%= poll.user.user_extensions.nil? ? "--" : poll.user.user_extensions.student_id %> + <%= (ex_poll_work_status poll.commit_status).html_safe %> 序号 姓名 分班学号学号提交状态 更新时间 教师评分 <%= group_name %> - <%= student_id %> - + <%= student_id %> + <%= (ex_poll_work_status student_work.work_status).html_safe %> 序号 姓名 分班学号学号分组关联项目 <%= group_name %> - <%= student_id %> - + <%= student_id %> + <%= student_work.group_id == 0 ? '--' : '分组'+student_work.group_id.to_s %> 序号 姓名 分班学号学号提交状态 提交耗时 更新时间 <%= group_name %> - <%= student_id %> - + <%= student_id %> + <% status = list_work_status student_work, @homework, group_id %> <%= status %> From d4af2c8785195eaf84a5f8a7391d0dbee287c8b2 Mon Sep 17 00:00:00 2001 From: p31729568 Date: Sat, 29 Jun 2019 14:24:51 +0800 Subject: [PATCH 11/11] fix gemfile --- Gemfile | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Gemfile b/Gemfile index 7acfb39f..d89f9a24 100644 --- a/Gemfile +++ b/Gemfile @@ -1,4 +1,4 @@ -source 'http://gems.ruby-china.com' +source 'https://gems.ruby-china.com' unless RUBY_PLATFORM =~ /w32/ # unix-like only @@ -57,18 +57,18 @@ gem 'chinese_pinyin' gem 'ansi' gem 'diff-lcs', '~> 1.3' -# gem 'kaminari' +gem 'kaminari' gem 'elasticsearch-model' gem 'elasticsearch-rails' gem 'oauth2' # xlsx -# gem 'axlsx', '3.0.0.pre' -# gem 'axlsx_rails', '0.3.0' +gem 'axlsx', '3.0.0.pre' +gem 'axlsx_rails', '0.3.0' # state machine -# gem 'aasm' +gem 'aasm' #Ruby 2.2+ has removed test/unit from the core library. if RUBY_VERSION>='2.2'