dev_bj
cxt 5 years ago
parent f73afb5f2f
commit 77cee20dc6

@ -2437,8 +2437,8 @@ class CoursesController < ApplicationController
sheet1[count_row,column+=1] = member.course_group_id == 0 ? "暂无" : member.course_group.name sheet1[count_row,column+=1] = member.course_group_id == 0 ? "暂无" : member.course_group.name
# current_col = 5 # current_col = 5
shixun_score = 0 shixun_score = 0
homeworks.where(:homework_type => 4).includes(:student_works).each do |homework| homeworks.where(:homework_type => 4).includes(:score_student_works).each do |homework|
student_works = homework.student_works.where("user_id = #{member.user.id}") student_works = homework.score_student_works.select{|work| work.user_id == member.user.id}
if student_works.empty? if student_works.empty?
sheet1[count_row,column+=1] = 0 sheet1[count_row,column+=1] = 0
else else
@ -2449,8 +2449,8 @@ class CoursesController < ApplicationController
# current_col += 1 # current_col += 1
end end
common_score = 0 common_score = 0
homeworks.where(:homework_type => 1).includes(:student_works).each do |homework| homeworks.where(:homework_type => 1).includes(:score_student_works).each do |homework|
student_works = homework.student_works.where("user_id = #{member.user.id}") student_works = homework.score_student_works.select{|work| work.user_id == member.user.id}
if student_works.empty? if student_works.empty?
sheet1[count_row,column+=1] = 0 sheet1[count_row,column+=1] = 0
else else
@ -2461,8 +2461,8 @@ class CoursesController < ApplicationController
# current_col += 1 # current_col += 1
end end
group_score = 0 group_score = 0
homeworks.where(:homework_type => 3).includes(:student_works).each do |homework| homeworks.where(:homework_type => 3).includes(:score_student_works).each do |homework|
student_works = homework.student_works.where("user_id = #{member.user.id}") student_works = homework.score_student_works.select{|work| work.user_id == member.user.id}
if student_works.empty? if student_works.empty?
sheet1[count_row,column+=1] = 0 sheet1[count_row,column+=1] = 0
else else
@ -2473,8 +2473,8 @@ class CoursesController < ApplicationController
# current_col += 1 # current_col += 1
end end
exercise_score = 0 exercise_score = 0
exercises.includes(:exercise_users).each do |exercise| exercises.includes(:score_exercise_users).each do |exercise|
exercise_user = exercise.exercise_users.where("user_id = #{member.user.id}") exercise_user = exercise.score_exercise_users.select{|work| work.user_id == member.user.id}
if exercise_user.empty? if exercise_user.empty?
sheet1[count_row,column+=1] = 0 sheet1[count_row,column+=1] = 0
else else
@ -2562,7 +2562,7 @@ class CoursesController < ApplicationController
count_row += 1 count_row += 1
end 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 = book.create_worksheet :name => "#{home.name}"
sheet[0,0] = "课程编号" sheet[0,0] = "课程编号"
sheet[0,1] = course.id sheet[0,1] = course.id
@ -2596,7 +2596,7 @@ class CoursesController < ApplicationController
end end
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 = book.create_worksheet :name => "普通作业第#{i+1}"
sheet[0,0] = "课程编号" sheet[0,0] = "课程编号"
sheet[0,1] = course.id sheet[0,1] = course.id
@ -2643,7 +2643,7 @@ class CoursesController < ApplicationController
end 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 = book.create_worksheet :name => "分组作业第#{i+1}"
sheet[0,0] = "课程编号" sheet[0,0] = "课程编号"
sheet[0,1] = course.id sheet[0,1] = course.id
@ -2691,7 +2691,7 @@ class CoursesController < ApplicationController
end end
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 = book.create_worksheet :name => "试卷第#{i+1}"
sheet[0,0] = "课程编号" sheet[0,0] = "课程编号"
sheet[0,1] = course.id sheet[0,1] = course.id

@ -7,7 +7,7 @@ class Exercise < ActiveRecord::Base
has_many :exercise_group_settings, :dependent => :destroy has_many :exercise_group_settings, :dependent => :destroy
has_many :exercise_questions, :dependent => :destroy,:order => "#{ExerciseQuestion.table_name}.question_number" 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 :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 :users, :through => :exercise_users #该测试被哪些用户提交答案过
has_many :course_acts, :class_name => 'CourseActivity',:as =>:course_act ,:dependent => :destroy has_many :course_acts, :class_name => 'CourseActivity',:as =>:course_act ,:dependent => :destroy
# 课程消息 # 课程消息

Loading…
Cancel
Save