@ -969,18 +969,13 @@ class CoursesController < ApplicationController
@all_members = @course . students
@all_members = @course . students
end
end
if name . present?
if name . present?
nick_name_search = @all_members . joins ( :user ) . where ( " nickname like ? " , " % #{ name } % " )
@all_members = @all_members . joins ( user : [ :user_extension ] ) . where ( 'concat(users.lastname, users.firstname) like ? or user_extensions.student_id like ?' , " % #{ name } % " , " % #{ name } % " )
if nick_name_search . present?
@all_members = nick_name_search
else
@all_members = @all_members . joins ( user : [ :user_extension ] ) . where ( 'user_extensions.student_id like ? OR user_extensions.student_realname like ?' , " % #{ name } % " , " % #{ name } % " )
end
end
end
@c_homeworks = @course . homework_commons . homework_published . order ( " publish_time asc, created_at asc" )
@c_homeworks = @course . homework_commons . homework_published . order ( " homework_commons.publish_time asc, homework_commons.created_at asc " )
@c_exercises = @course . exercises . is_exercise_published . order ( " publish_time asc, created_at asc" )
@c_exercises = @course . exercises . is_exercise_published . order ( " exercises.publish_time asc, exercises.created_at asc " )
@c_polls = @course . polls . publish_or_not . order ( " p ublish_time asc, created_at asc" )
@c_polls = @course . polls . publish_or_not . order ( " polls.publish_time asc, polls.created_at asc " )
@c_tasks = @course . graduation_tasks . task_published . order ( " publish_time asc, created_at asc" )
@c_tasks = @course . graduation_tasks . task_published . order ( " graduation_tasks. publish_time asc, graduation_tasks. created_at asc" )
if @user_course_identity > Course :: ASSISTANT_PROFESSOR
if @user_course_identity > Course :: ASSISTANT_PROFESSOR
tip_exception ( 403 , " 无权限操作 " )
tip_exception ( 403 , " 无权限操作 " )
else
else
@ -1058,14 +1053,14 @@ class CoursesController < ApplicationController
def member_to_xlsx ( course , all_members , homeworks , exercises , tasks , polls )
def member_to_xlsx ( course , all_members , homeworks , exercises , tasks , polls )
#课堂的作业信息
#课堂的作业信息
shixun_homeworks = homeworks . search_homework_type ( 4 ) #全部实训作业
shixun_homeworks = homeworks . search_homework_type ( 4 ) . includes ( :score_student_works ) #全部实训作业
shixun_titles = shixun_homeworks . pluck ( :name ) + [ " 总得分 " ]
shixun_titles = shixun_homeworks . pluck ( :name ) + [ " 总得分 " ]
common_homeworks = homeworks . search_homework_type ( 1 ) #全部普通作业
common_homeworks = homeworks . search_homework_type ( 1 ) . includes ( :score_student_works ) #全部普通作业
common_titles = common_homeworks . pluck ( :name ) + [ " 总得分 " ]
common_titles = common_homeworks . pluck ( :name ) + [ " 总得分 " ]
group_homeworks = homeworks . search_homework_type ( 3 ) #全部分组作业
group_homeworks = homeworks . search_homework_type ( 3 ) . includes ( :score_student_works ) #全部分组作业
group_titles = group_homeworks . pluck ( :name ) + [ " 总得分 " ]
group_titles = group_homeworks . pluck ( :name ) + [ " 总得分 " ]
task_titles = tasks . pluck( :name ) + [ " 总得分 " ]
task_titles = tasks . includes( :score_graduation_works ) . pluck( :name ) + [ " 总得分 " ]
exercise_titles = exercises . pluck( :exercise_name ) + [ " 总得分 " ]
exercise_titles = exercises . includes( :score_exercise_users ) . pluck( :exercise_name ) + [ " 总得分 " ]
total_user_score_array = [ ] #学生总成绩集合
total_user_score_array = [ ] #学生总成绩集合
#课堂信息
#课堂信息
@ -1114,7 +1109,7 @@ class CoursesController < ApplicationController
course_user_level = [ ]
course_user_level = [ ]
course_activity_title = " 课堂活跃度统计 "
course_activity_title = " 课堂活跃度统计 "
user_cell_head = %w( 排名 真实姓名 登录名 邮箱 学号 分班 作业完成数 ( *10 ) 试卷完成数 ( *10 ) 问卷完成数 ( *7 ) 资源发布数 ( *5 ) 帖子发布数 ( *2 ) 帖子回复数 ( *1 ) 作业回复数 ( *1 ) 活跃度 )
user_cell_head = %w( 排名 真实姓名 登录名 邮箱 学号 分班 作业完成数 ( *10 ) 试卷完成数 ( *10 ) 问卷完成数 ( *7 ) 资源发布数 ( *5 ) 帖子发布数 ( *2 ) 帖子回复数 ( *1 ) 作业回复数 ( *1 ) 活跃度 )
all_members . each do | u |
all_members . includes( user : :user_extension ) . each do | u |
#用户的基本信息
#用户的基本信息
user = u . user
user = u . user
user_login = user . login
user_login = user . login
@ -1174,12 +1169,11 @@ class CoursesController < ApplicationController
#实训作业
#实训作业
if shixun_homeworks . count > 0
if shixun_homeworks . count > 0
shixun_homeworks . each do | s |
shixun_homeworks . each do | s |
user_student_work = s . s tudent_works. homework_by_user ( user . id ) #当前用户的对该作业的回答
user_student_work = s . s core_student_works. find_by_user_id ( user . id ) #当前用户的对该作业的回答
if user_student_work . blank ?
if user_student_work . nil ?
h_score = 0 . 0 #该作业的得分为0
h_score = 0 . 0 #该作业的得分为0
else
else
user_stu_work = user_student_work . first
h_score = user_student_work . work_score . nil? ? 0 . 0 : user_student_work . work_score #用户对该作业的分数
h_score = user_stu_work . work_score . nil? ? 0 . 0 : user_stu_work . work_score #用户对该作业的分数
end
end
shixun_score_array . push ( h_score )
shixun_score_array . push ( h_score )
end
end
@ -1191,12 +1185,11 @@ class CoursesController < ApplicationController
#普通作业
#普通作业
if common_homeworks . count > 0
if common_homeworks . count > 0
common_homeworks . each do | c |
common_homeworks . each do | c |
user_student_work_1 = c . s tudent_works. homework_by_user ( user . id ) #当前用户的对该作业的回答
user_student_work_1 = c . s core_student_works. find_by_user_id ( user . id ) #当前用户的对该作业的回答
if user_student_work_1 . blank ?
if user_student_work_1 . nil ?
h_score_1 = 0 . 0 #该作业的得分为0
h_score_1 = 0 . 0 #该作业的得分为0
else
else
user_stu_work_1 = user_student_work_1 . first
h_score_1 = user_student_work_1 . work_score . nil? ? 0 . 0 : user_student_work_1 . work_score #用户对该作业的分数
h_score_1 = user_stu_work_1 . work_score . nil? ? 0 . 0 : user_stu_work_1 . work_score #用户对该作业的分数
end
end
common_score_array . push ( h_score_1 )
common_score_array . push ( h_score_1 )
end
end
@ -1208,12 +1201,11 @@ class CoursesController < ApplicationController
#分组作业
#分组作业
if group_homeworks . count > 0
if group_homeworks . count > 0
group_homeworks . each do | g |
group_homeworks . each do | g |
user_student_work_3 = g . s tudent_works. homework_by_user ( user . id ) #当前用户的对该作业的回答
user_student_work_3 = g . s core_student_works. find_by_user_id ( user . id ) #当前用户的对该作业的回答
if user_student_work_3 . blank ?
if user_student_work_3 . nil ?
h_score_3 = 0 . 0 #该作业的得分为0
h_score_3 = 0 . 0 #该作业的得分为0
else
else
user_stu_work_3 = user_student_work_3 . first
h_score_3 = user_student_work_3 . work_score . nil? ? 0 . 0 : user_student_work_3 . work_score #用户对该作业的分数
h_score_3 = user_stu_work_3 . work_score . nil? ? 0 . 0 : user_stu_work_3 . work_score #用户对该作业的分数
end
end
group_score_array . push ( h_score_3 )
group_score_array . push ( h_score_3 )
end
end
@ -1225,11 +1217,11 @@ class CoursesController < ApplicationController
#毕设作业
#毕设作业
if tasks . count > 0
if tasks . count > 0
tasks . each do | task |
tasks . each do | task |
graduation_work s = task . graduation_works. find_by_ task_ user( user . id )
graduation_work = task . score_ graduation_works. find_by_ user_id ( user . id )
if graduation_work s. empty ?
if graduation_work . nil ?
t_score = 0 . 0
t_score = 0 . 0
else
else
t_score = graduation_work s. first . work_score . nil? ? 0 . 0 : graduation_work s. first . work_score
t_score = graduation_work . work_score . nil? ? 0 . 0 : graduation_work . work_score
end
end
task_score_array . push ( t_score )
task_score_array . push ( t_score )
end
end
@ -1241,11 +1233,11 @@ class CoursesController < ApplicationController
#试卷
#试卷
if exercises . count > 0
if exercises . count > 0
exercises . each do | ex |
exercises . each do | ex |
exercise_work s = ex . exercise_users . exercise_commit_users ( user . id )
exercise_work = ex . score_exercise_users . find_by_user_id ( user . id )
if exercise_work s. empty ?
if exercise_work . nil ?
e_score = 0 . 0
e_score = 0 . 0
else
else
e_score = exercise_work s. first . score . nil? ? 0 . 0 : exercise_work s. first . score
e_score = exercise_work . score . nil? ? 0 . 0 : exercise_work . score
end
end
exercise_score_array . push ( e_score )
exercise_score_array . push ( e_score )
end
end
@ -1285,7 +1277,7 @@ class CoursesController < ApplicationController
#实训作业
#实训作业
if count_1 > 0
if count_1 > 0
shixun_homeworks . each_with_index do | s , index |
shixun_homeworks . each_with_index do | s , index |
all_student_works = s . s tudent_works. has_committed . order ( " work_score desc " ) #该实训题的全部用户回答
all_student_works = s . s core_s tudent_works #该实训题的全部用户回答
title_no = index . to_i + 1
title_no = index . to_i + 1
student_work_to_xlsx ( all_student_works , s )
student_work_to_xlsx ( all_student_works , s )
shixun_work_display_name = ( title_no . to_s + " . " + s . name ) . strip . first ( 30 )
shixun_work_display_name = ( title_no . to_s + " . " + s . name ) . strip . first ( 30 )
@ -1297,7 +1289,7 @@ class CoursesController < ApplicationController
#普通作业
#普通作业
if count_2 > 0
if count_2 > 0
common_homeworks . each_with_index do | c , index |
common_homeworks . each_with_index do | c , index |
all_student_works = c . s tudent_works. has_committed . order ( " work_score desc " ) #当前用户的对该作业的回答
all_student_works = c . s core_s tudent_works #当前用户的对该作业的回答
title_no = count_1 + index . to_i + 1
title_no = count_1 + index . to_i + 1
student_work_to_xlsx ( all_student_works , c )
student_work_to_xlsx ( all_student_works , c )
@ -1311,7 +1303,7 @@ class CoursesController < ApplicationController
#分组作业
#分组作业
if count_3 > 0
if count_3 > 0
group_homeworks . each_with_index do | c , index |
group_homeworks . each_with_index do | c , index |
all_student_works = c . s tudent_works. has_committed . order ( " work_score desc " ) #当前用户的对该作业的回答
all_student_works = c . s core_s tudent_works #当前用户的对该作业的回答
title_no = count_1 + count_2 + index . to_i + 1
title_no = count_1 + count_2 + index . to_i + 1
student_work_to_xlsx ( all_student_works , c )
student_work_to_xlsx ( all_student_works , c )
work_name = ( title_no . to_s + " . " + c . name ) . strip . first ( 30 )
work_name = ( title_no . to_s + " . " + c . name ) . strip . first ( 30 )
@ -1323,7 +1315,7 @@ class CoursesController < ApplicationController
#毕设任务
#毕设任务
if count_4 > 0
if count_4 > 0
tasks . each_with_index do | c , index |
tasks . each_with_index do | c , index |
all_student_works = c . graduation_works. has_committed . order ( " work_score desc " ) #当前用户的对该作业的回答
all_student_works = c . score_ graduation_works #当前用户的对该作业的回答
title_no = count_1 + count_2 + count_3 + index . to_i + 1
title_no = count_1 + count_2 + count_3 + index . to_i + 1
graduation_work_to_xlsx ( all_student_works , c , current_user )
graduation_work_to_xlsx ( all_student_works , c , current_user )
work_name = ( title_no . to_s + " . " + c . name ) . strip . first ( 30 )
work_name = ( title_no . to_s + " . " + c . name ) . strip . first ( 30 )
@ -1336,7 +1328,7 @@ class CoursesController < ApplicationController
#试卷的导出
#试卷的导出
if count_5 > 0
if count_5 > 0
exercises . each_with_index do | c , index |
exercises . each_with_index do | c , index |
all_student_works = c . exercise_users. exercise_user_committed #当前用户的对该作业的回答
all_student_works = c . score_exercise_users #当前用户的对该作业的回答
title_no = count_1 + count_2 + count_3 + count_4 + index . to_i + 1
title_no = count_1 + count_2 + count_3 + count_4 + index . to_i + 1
get_export_users ( c , course , all_student_works )
get_export_users ( c , course , all_student_works )
work_name = ( title_no . to_s + " . " + c . exercise_name ) . strip . first ( 30 )
work_name = ( title_no . to_s + " . " + c . exercise_name ) . strip . first ( 30 )