diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb index 0c82edad7..e9b49b6fd 100644 --- a/app/controllers/courses_controller.rb +++ b/app/controllers/courses_controller.rb @@ -184,14 +184,24 @@ class CoursesController < ApplicationController if params[:incourse] results = searchmember_by_name(student_homework_score(0,0,0,"desc"), q) elsif params[:ingroup] - @group = CourseGroup.find(params[:search_group_id]) - results = searchmember_by_name(student_homework_score(@group.id,0,0,"desc"), q) + if params[:search_group_id] == "-1" + @group = -1 + results = searchmember_by_name(student_homework_score(-1,0,0,"desc"), q) + else + @group = CourseGroup.find(params[:search_group_id]) + results = searchmember_by_name(student_homework_score(@group.id,0,0,"desc"), q) + end end @is_remote = true #@result_count = results.count #@results = paginateHelper results, 10 @results = results @search_name = q + @limit = 50 + @page = params[:page].nil? ? 1 : params['page'].to_i + @members_count = @results.count + @mem_pages = Paginator.new @members_count, @limit, @page + @results = paginateHelper @results, @limit end def addgroups @@ -208,6 +218,12 @@ class CoursesController < ApplicationController @is_remote = true @members = student_homework_score(0,0, 10,@score_sort_by) @course_groups = @course.course_groups + @limit = 50 + @page = params[:page].nil? ? 1 : params['page'].to_i + @members_count = @members.count + @no_group_count = @members_count - @course.members.where("course_group_id != 0").count + @mem_pages = Paginator.new @members_count, @limit, @page + @members = paginateHelper @members, @limit end def deletegroup @@ -219,6 +235,12 @@ class CoursesController < ApplicationController @score_sort_by = "desc" @members = student_homework_score(0,0, 10,@score_sort_by) @course_groups = @course.course_groups + @limit = 50 + @page = params[:page].nil? ? 1 : params['page'].to_i + @members_count = @members.count + @no_group_count = @members_count - @course.members.where("course_group_id != 0").count + @mem_pages = Paginator.new @members_count, @limit, @page + @members = paginateHelper @members, @limit end def updategroupname @@ -232,6 +254,12 @@ class CoursesController < ApplicationController @is_remote = true @members = student_homework_score(0,0, 10,"desc") @course_groups = @course.course_groups + @limit = 50 + @page = params[:page].nil? ? 1 : params['page'].to_i + @members_count = @members.count + @no_group_count = @members_count - @course.members.where("course_group_id != 0").count + @mem_pages = Paginator.new @members_count, @limit, @page + @members = paginateHelper @members, @limit end def valid_ajax @@ -268,6 +296,7 @@ class CoursesController < ApplicationController member.course_group_id = params[:course_group_id].to_i member.save @course_groups = @course.course_groups + @no_group_count = @course.student.count - @course.members.where("course_group_id != 0").count @canShowCode = isCourseTeacher(User.current.id,@course) && params[:role] != '1' respond_to do |format| format.js @@ -283,6 +312,7 @@ class CoursesController < ApplicationController @group = group @course_groups = @course.course_groups + @no_group_count = @course.student.count - @course.members.where("course_group_id != 0").count search_group_members group end @@ -294,6 +324,7 @@ class CoursesController < ApplicationController member.save @group = group @course_groups = @course.course_groups + @no_group_count = @course.student.count - @course.members.where("course_group_id != 0").count search_group_members group end @@ -304,14 +335,22 @@ class CoursesController < ApplicationController @is_remote = true @sort_type = 'score' @score_sort_by = "desc" - if params[:group_id] && params[:group_id] != "0" + if params[:group_id] && params[:group_id] != "0" && params[:group_id] != "-1" @group = CourseGroup.find(params[:group_id]) @results = student_homework_score(@group.id,0, 0,"desc") # @results = paginateHelper @results, 10 + elsif params[:group_id] && params[:group_id] == "-1" + @group = -1 + @results = student_homework_score(-1, 0, 10,"desc") else page_from = params[:page].nil? ? 0 : (params[:page].to_i - 1) @results = student_homework_score(0,page_from, 10,"desc") end + @limit = 50 + @page = params[:page].nil? ? 1 : params['page'].to_i + @members_count = @results.count + @mem_pages = Paginator.new @members_count, @limit, @page + @results = paginateHelper @results, @limit end def member @@ -332,10 +371,14 @@ class CoursesController < ApplicationController @members = @all_members when '2' if @course.open_student == 1 || User.current.member_of_course?(@course) || User.current.admin? + @limit = 50 @subPage_title = l :label_student_list - page = params[:page].nil? ? 0 : (params['page'].to_i - 1) - @all_members = student_homework_score(0,page, 10,@score_sort_by,@sort_type) - @members = @all_members + @page = params[:page].nil? ? 1 : params['page'].to_i + @all_members = student_homework_score(0, @page - 1, @limit, @score_sort_by, @sort_type) + @members_count = @all_members.count + @no_group_count = @members_count - @course.members.where("course_group_id != 0").count + @mem_pages = Paginator.new @members_count, @limit, @page + @members = paginateHelper @all_members, @limit else render_403 return @@ -378,25 +421,35 @@ class CoursesController < ApplicationController group_id = params[:group_id] if !@search_name.nil? if group_id == '0' - page = params[:page].nil? ? 0 : (params['page'].to_i - 1) + #page = params[:page].nil? ? 0 : (params['page'].to_i - 1) @results = searchmember_by_name(student_homework_score(0,0,0,@score_sort_by,@sort_type), @search_name) - @result_count = @results.count # @results = paginateHelper @results, 10 + elsif group_id == '-1' + @group = -1 + @results = searchmember_by_name(student_homework_score(-1,0,0,@score_sort_by,@sort_type), @search_name) else @group = CourseGroup.find(group_id) @results = searchmember_by_name(student_homework_score(group_id, 0, 0,@score_sort_by,@sort_type),@search_name) - @result_count = @results.count # @results = paginateHelper @results, 10 end else if group_id == '0' page = params[:page].nil? ? 0 : (params['page'].to_i - 1) @results = student_homework_score(0,page, 10,@score_sort_by,@sort_type) + elsif group_id == '-1' + @group = -1 + @results = student_homework_score(-1,0, 10,@score_sort_by,@sort_type) else @group = CourseGroup.find(group_id) @results = student_homework_score(group_id, 0, 0,@score_sort_by,@sort_type) end end + @limit = 50 + @page = params[:page].nil? ? 1 : params['page'].to_i + @members_count = @results.count + @no_group_count = @members_count - @course.members.where("course_group_id != 0").count + @mem_pages = Paginator.new @members_count, @limit, @page + @results = paginateHelper @results, @limit end # 显示每个学生的作业评分详情 def show_member_score @@ -1223,7 +1276,6 @@ class CoursesController < ApplicationController def student_homework_score(groupid,start_from, nums, score_sort_by, sort_type = 'score') start_from = start_from * nums - sql_select = "" if groupid == 0 sql_select = "SELECT members.*,( SELECT SUM(student_works.work_score) @@ -1233,16 +1285,47 @@ class CoursesController < ApplicationController AND student_works.user_id = members.user_id ) AS score,(SELECT (message_num*2 + message_reply_num*1 + news_reply_num*1 + news_num*1 + resource_num*5 + journal_num*1 + homework_journal_num*1 ) FROM `course_contributor_scores` AS ccs WHERE ccs.course_id = #{@course.id} AND ccs.user_id = members.user_id - ) AS act_score,(SELECT SUM(exercise_users.score) - FROM exercise_users,exercises - WHERE exercise_users.exercise_id = exercises.id - AND exercises.course_id = #{@course.id} - AND exercise_users.user_id = members.user_id - ) AS ex_score + ) AS act_score,(SELECT SUM(exercise_users.score) FROM exercise_users,exercises WHERE exercise_users.exercise_id = exercises.id + AND exercises.course_id = #{@course.id} AND exercise_users.user_id = members.user_id) AS ex_score, + (SELECT student_id FROM user_extensions WHERE user_extensions.user_id = members.user_id) AS student_id, + (SELECT message_num FROM course_contributor_scores AS ccs WHERE ccs.course_id = #{@course.id} AND ccs.user_id = members.user_id) AS message_num, + (SELECT message_reply_num FROM course_contributor_scores AS ccs WHERE ccs.course_id = #{@course.id} AND ccs.user_id = members.user_id) AS message_reply_num, + (SELECT news_reply_num FROM course_contributor_scores AS ccs WHERE ccs.course_id = #{@course.id} AND ccs.user_id = members.user_id) AS news_reply_num, + (SELECT news_num FROM course_contributor_scores AS ccs WHERE ccs.course_id = #{@course.id} AND ccs.user_id = members.user_id) AS news_num, + (SELECT resource_num FROM course_contributor_scores AS ccs WHERE ccs.course_id = #{@course.id} AND ccs.user_id = members.user_id) AS resource_num, + (SELECT journal_num FROM course_contributor_scores AS ccs WHERE ccs.course_id = #{@course.id} AND ccs.user_id = members.user_id) AS journal_num, + (SELECT homework_journal_num FROM course_contributor_scores AS ccs WHERE ccs.course_id = #{@course.id} AND ccs.user_id = members.user_id) AS homework_journal_num, + (SELECT COUNT(ss.id) FROM student_works AS ss ,homework_commons AS hc WHERE ss.homework_common_id = hc.id AND hc.course_id = #{@course.id} AND ss.work_status != 0 AND ss.user_id = members.user_id) AS homework_num, + (SELECT COUNT(eu.id) FROM exercise_users AS eu,exercises WHERE eu.exercise_id = exercises.id AND exercises.course_id = #{@course.id} AND exercises.end_time >= eu.created_at AND eu.user_id = members.user_id) AS exercise_num FROM members JOIN students_for_courses ON students_for_courses.student_id = members.user_id AND students_for_courses.course_id = members.course_id WHERE members.course_id = #{@course.id} ORDER BY #{sort_type} #{score_sort_by}" + elsif groupid == -1 + sql_select = "SELECT members.*,( + SELECT SUM(student_works.work_score) + FROM student_works,homework_commons + WHERE student_works.homework_common_id = homework_commons.id + AND homework_commons.course_id = #{@course.id} + AND student_works.user_id = members.user_id + ) AS score,(SELECT (message_num*2 + message_reply_num*1 + news_reply_num*1 + news_num*1 + + resource_num*5 + journal_num*1 + homework_journal_num*1 ) FROM `course_contributor_scores` AS ccs WHERE ccs.course_id = #{@course.id} AND ccs.user_id = members.user_id + ) AS act_score,(SELECT SUM(exercise_users.score) FROM exercise_users,exercises WHERE exercise_users.exercise_id = exercises.id + AND exercises.course_id = #{@course.id} AND exercise_users.user_id = members.user_id) AS ex_score, + (SELECT student_id FROM user_extensions WHERE user_extensions.user_id = members.user_id) AS student_id, + (SELECT message_num FROM course_contributor_scores AS ccs WHERE ccs.course_id = #{@course.id} AND ccs.user_id = members.user_id) AS message_num, + (SELECT message_reply_num FROM course_contributor_scores AS ccs WHERE ccs.course_id = #{@course.id} AND ccs.user_id = members.user_id) AS message_reply_num, + (SELECT news_reply_num FROM course_contributor_scores AS ccs WHERE ccs.course_id = #{@course.id} AND ccs.user_id = members.user_id) AS news_reply_num, + (SELECT news_num FROM course_contributor_scores AS ccs WHERE ccs.course_id = #{@course.id} AND ccs.user_id = members.user_id) AS news_num, + (SELECT resource_num FROM course_contributor_scores AS ccs WHERE ccs.course_id = #{@course.id} AND ccs.user_id = members.user_id) AS resource_num, + (SELECT journal_num FROM course_contributor_scores AS ccs WHERE ccs.course_id = #{@course.id} AND ccs.user_id = members.user_id) AS journal_num, + (SELECT homework_journal_num FROM course_contributor_scores AS ccs WHERE ccs.course_id = #{@course.id} AND ccs.user_id = members.user_id) AS homework_journal_num, + (SELECT COUNT(ss.id) FROM student_works AS ss ,homework_commons AS hc WHERE ss.homework_common_id = hc.id AND hc.course_id = #{@course.id} AND ss.work_status != 0 AND ss.user_id = members.user_id) AS homework_num, + (SELECT COUNT(eu.id) FROM exercise_users AS eu,exercises WHERE eu.exercise_id = exercises.id AND exercises.course_id = #{@course.id} AND exercises.end_time >= eu.created_at AND eu.user_id = members.user_id) AS exercise_num + FROM members + JOIN students_for_courses + ON students_for_courses.student_id = members.user_id AND students_for_courses.course_id = members.course_id + WHERE members.course_id = #{@course.id} AND members.course_group_id = 0 ORDER BY #{sort_type} #{score_sort_by}" else sql_select = "SELECT members.*,( SELECT SUM(student_works.work_score) @@ -1252,12 +1335,18 @@ class CoursesController < ApplicationController AND student_works.user_id = members.user_id ) AS score,(SELECT (message_num*2 + message_reply_num*1 + news_reply_num*1 + news_num*1 + resource_num*5 + journal_num*1 + homework_journal_num*1 ) FROM `course_contributor_scores` AS ccs WHERE ccs.course_id = #{@course.id} AND ccs.user_id = members.user_id - ) AS act_score,(SELECT SUM(exercise_users.score) - FROM exercise_users,exercises - WHERE exercise_users.exercise_id = exercises.id - AND exercises.course_id = #{@course.id} - AND exercise_users.user_id = members.user_id - ) AS ex_score + ) AS act_score,(SELECT SUM(exercise_users.score) FROM exercise_users,exercises WHERE exercise_users.exercise_id = exercises.id + AND exercises.course_id = #{@course.id} AND exercise_users.user_id = members.user_id) AS ex_score, + (SELECT student_id FROM user_extensions WHERE user_extensions.user_id = members.user_id) AS student_id, + (SELECT message_num FROM course_contributor_scores AS ccs WHERE ccs.course_id = #{@course.id} AND ccs.user_id = members.user_id) AS message_num, + (SELECT message_reply_num FROM course_contributor_scores AS ccs WHERE ccs.course_id = #{@course.id} AND ccs.user_id = members.user_id) AS message_reply_num, + (SELECT news_reply_num FROM course_contributor_scores AS ccs WHERE ccs.course_id = #{@course.id} AND ccs.user_id = members.user_id) AS news_reply_num, + (SELECT news_num FROM course_contributor_scores AS ccs WHERE ccs.course_id = #{@course.id} AND ccs.user_id = members.user_id) AS news_num, + (SELECT resource_num FROM course_contributor_scores AS ccs WHERE ccs.course_id = #{@course.id} AND ccs.user_id = members.user_id) AS resource_num, + (SELECT journal_num FROM course_contributor_scores AS ccs WHERE ccs.course_id = #{@course.id} AND ccs.user_id = members.user_id) AS journal_num, + (SELECT homework_journal_num FROM course_contributor_scores AS ccs WHERE ccs.course_id = #{@course.id} AND ccs.user_id = members.user_id) AS homework_journal_num, + (SELECT COUNT(ss.id) FROM student_works AS ss ,homework_commons AS hc WHERE ss.homework_common_id = hc.id AND hc.course_id = #{@course.id} AND ss.work_status != 0 AND ss.user_id = members.user_id) AS homework_num, + (SELECT COUNT(eu.id) FROM exercise_users AS eu,exercises WHERE eu.exercise_id = exercises.id AND exercises.course_id = #{@course.id} AND exercises.end_time >= eu.created_at AND eu.user_id = members.user_id) AS exercise_num FROM members JOIN students_for_courses ON students_for_courses.student_id = members.user_id AND students_for_courses.course_id = members.course_id @@ -1310,8 +1399,10 @@ class CoursesController < ApplicationController for i in 0 ... homeworks.count sheet1[5,i+4] = "第"+(i+1).to_s+"次" end - sheet1[5,homeworks.count+4] = "总成绩" - sheet1[5,homeworks.count+5] = "活跃度" + sheet1[5,homeworks.count+4] = "作业得分" + sheet1[5,homeworks.count+5] = "测评得分" + sheet1[5,homeworks.count+6] = "社区得分" + sheet1[5,homeworks.count+7] = "总得分" count_row = 6 members.each_with_index do |member, i| sheet1[count_row,0]= i+1 @@ -1328,8 +1419,14 @@ class CoursesController < ApplicationController sheet1[count_row,j+4] = score <0 ? 0:score.round(2) end end - sheet1[count_row,homeworks.count+4] = member.score.nil? ? 0:member.score.round(2) - sheet1[count_row,homeworks.count+5] = member.act_score.nil? ? 0:member.act_score + hw_score = member.score.nil? ? 0 : member.score + ex_score = member.ex_score.nil? ? 0 : member.ex_score + act_score = member.act_score.nil? ? 0 : member.act_score + sum = hw_score + ex_score + act_score + sheet1[count_row,homeworks.count+4] = hw_score.round(2) + sheet1[count_row,homeworks.count+5] = ex_score + sheet1[count_row,homeworks.count+6] = act_score + sheet1[count_row,homeworks.count+7] = sum.round(2) count_row += 1 end diff --git a/app/views/courses/_course_student.html.erb b/app/views/courses/_course_student.html.erb index db0aabc3b..59c0dc641 100644 --- a/app/views/courses/_course_student.html.erb +++ b/app/views/courses/_course_student.html.erb @@ -1,5 +1,7 @@