@ -191,7 +191,7 @@ module ApplicationHelper
# 分班
# 分班
def member_group_name members , user_id
def member_group_name members , user_id
member = members . where( :user_id = > user_id ) . first
member = members . find_by_user_id( user_id )
group_name = member . try ( :course_group_id ) . to_i == 0 ? '未分班' : member . course_group . name
group_name = member . try ( :course_group_id ) . to_i == 0 ? '未分班' : member . course_group . name
end
end
@ -269,12 +269,12 @@ module ApplicationHelper
end
end
# 实训作品列表的提交状态
# 实训作品列表的提交状态
def list_work_status work , homework , member
def list_work_status work , homework , course_group_id
if work . work_status == 0
if work . work_status == 0
str = " 未提交 "
str = " 未提交 "
else
else
if work . compelete_status == 0
if work . compelete_status == 0
setting_time = homework_group_setting homework , member. try ( : course_group_id)
setting_time = homework_group_setting homework , course_group_id
end_time = setting_time . end_time . present? ? setting_time . end_time : homework . end_time
end_time = setting_time . end_time . present? ? setting_time . end_time : homework . end_time
if end_time > Time . now || ( homework . allow_late && ! homework . course . is_end )
if end_time > Time . now || ( homework . allow_late && ! homework . course . is_end )
str = " 正在提交 "
str = " 正在提交 "
@ -1319,11 +1319,11 @@ module ApplicationHelper
def had_commit_studentwork_count homework_common
def had_commit_studentwork_count homework_common
member = homework_common . course . members . where ( :user_id = > User . current . id ) . first
member = homework_common . course . members . where ( :user_id = > User . current . id ) . first
student_works = homework_common . student_works
student_works = homework_common . student_works
if member . present? && member . teacher_course_groups . count > 0
if member . present? && member . teacher_course_groups . size > 0
group_students = homework_common . course . members . where ( :course_group_id = > member . teacher_course_groups . pluck ( :course_group_id ) ) . map ( & :user_id )
group_students = homework_common . course . members . where ( :course_group_id = > member . teacher_course_groups . pluck ( :course_group_id ) ) . map ( & :user_id )
student_works = student_works . where ( :user_id = > group_students )
student_works = student_works . where ( :user_id = > group_students )
end
end
student_works . where ( " work_status !=? " , 0 ) . count
student_works . where ( " work_status !=? " , 0 ) . size
end
end
# 实训作业的有效作品数
# 实训作业的有效作品数
@ -1359,11 +1359,11 @@ module ApplicationHelper
def had_uncommit_studentwork_count homework_common
def had_uncommit_studentwork_count homework_common
member = homework_common . course . members . where ( :user_id = > User . current . id ) . first
member = homework_common . course . members . where ( :user_id = > User . current . id ) . first
student_works = homework_common . student_works
student_works = homework_common . student_works
if member . present? && member . teacher_course_groups . count > 0
if member . present? && member . teacher_course_groups . size > 0
group_students = homework_common . course . members . where ( :course_group_id = > member . teacher_course_groups . pluck ( :course_group_id ) ) . map ( & :user_id )
group_students = homework_common . course . members . where ( :course_group_id = > member . teacher_course_groups . pluck ( :course_group_id ) ) . map ( & :user_id )
student_works = student_works . where ( :user_id = > group_students )
student_works = student_works . where ( :user_id = > group_students )
end
end
student_works . where ( " work_status =? " , 0 ) . count
student_works . where ( " work_status =? " , 0 ) . size
end
end
# 未评阅
# 未评阅
@ -1371,12 +1371,12 @@ module ApplicationHelper
#count = StudentWorksScore.find_by_sql("SELECT count(distinct student_work_id) as count FROM student_works_scores sws, student_works sw, homework_commons hc where hc.id =#{homework_common.id} and sw.homework_common_id=hc.id and sw.is_delete = 0 and sws.student_work_id = sw.id and sws.user_id=#{User.current.id};").first.try(:count).to_i
#count = StudentWorksScore.find_by_sql("SELECT count(distinct student_work_id) as count FROM student_works_scores sws, student_works sw, homework_commons hc where hc.id =#{homework_common.id} and sw.homework_common_id=hc.id and sw.is_delete = 0 and sws.student_work_id = sw.id and sws.user_id=#{User.current.id};").first.try(:count).to_i
member = homework_common . course . members . where ( :user_id = > User . current . id ) . first
member = homework_common . course . members . where ( :user_id = > User . current . id ) . first
student_works = homework_common . student_works
student_works = homework_common . student_works
if member . present? && member . teacher_course_groups . count > 0
if member . present? && member . teacher_course_groups . size > 0
group_students = homework_common . course . members . where ( :course_group_id = > member . teacher_course_groups . pluck ( :course_group_id ) ) . map ( & :user_id )
group_students = homework_common . course . members . where ( :course_group_id = > member . teacher_course_groups . pluck ( :course_group_id ) ) . map ( & :user_id )
student_works = student_works . where ( :user_id = > group_students )
student_works = student_works . where ( :user_id = > group_students )
end
end
has_comment = StudentWorksScore . where ( :student_work_id = > student_works . map ( & :id ) , :reviewer_role = > [ 1 , 2 ] ) . group_by ( & :student_work_id ) . count
has_comment = StudentWorksScore . where ( :student_work_id = > student_works . map ( & :id ) , :reviewer_role = > [ 1 , 2 ] ) . group_by ( & :student_work_id ) . size
student_count = student_works . count
student_count = student_works . size
return student_count - has_comment
return student_count - has_comment
end
end
@ -6570,7 +6570,7 @@ def update_shixun_work_status homework
else
else
setting = homework . homework_group_settings . where ( " publish_time < ' #{ Time . now } ' " )
setting = homework . homework_group_settings . where ( " publish_time < ' #{ Time . now } ' " )
if setting . blank?
if setting . blank?
student_works = student_works . where( " 0=1 " )
student_works = student_works . none
else
else
users = homework . course . members . where ( :course_group_id = > setting . map ( & :course_group_id ) )
users = homework . course . members . where ( :course_group_id = > setting . map ( & :course_group_id ) )
student_works = student_works . where ( :user_id = > users . map ( & :user_id ) )
student_works = student_works . where ( :user_id = > users . map ( & :user_id ) )
@ -6580,7 +6580,7 @@ def update_shixun_work_status homework
myshixuns = Myshixun . where ( :shixun_id = > shixun . id , :user_id = > student_works . map ( & :user_id ) )
myshixuns = Myshixun . where ( :shixun_id = > shixun . id , :user_id = > student_works . map ( & :user_id ) )
myshixuns . each do | myshixun |
myshixuns . each do | myshixun |
work = student_works . where ( :user_id = > myshixun . user_id ) . first
work = student_works . where ( :user_id = > myshixun . user_id ) . first
member = Member . find_by_sql ( " select course_group_id from members where course_id = #{ homework . course_id } and user_id = #{ work . user_id } " ) . first
member = homework . course . members . find_by ( :user_id = > work . user_id )
setting_time = homework_group_setting homework , member . try ( :course_group_id )
setting_time = homework_group_setting homework , member . try ( :course_group_id )
games = myshixun . games . where ( :challenge_id = > challeng_ids )
games = myshixun . games . where ( :challenge_id = > challeng_ids )
myshixun_endtime = games . select { | game | game . status == 2 } . size == games . size ? games . map ( & :end_time ) . max : nil
myshixun_endtime = games . select { | game | game . status == 2 } . size == games . size ? games . map ( & :end_time ) . max : nil
@ -7222,8 +7222,8 @@ def search_work_member works,name
select_works = works
select_works = works
else
else
name = name . downcase
name = name . downcase
select_works = works . select{ | work | work . user . user_extensions [ :student_id ] . to_s . downcase . include? ( name ) || ( work . user [ :lastname ] . to_s . downcase + work . user [ :firstname ] . to_s . downcase ) . include? ( name )
select_works = works . joins( user : :user_extensions ) . where ( " concat(lastname, firstname) like ?
}
or student_id like ?" , " % #{ name }% " , " % #{ name } % " )
end
end
select_works
select_works
end
end