(SELECTmax(message_num)FROMcourse_contributor_scoresASccsWHEREccs.course_id=#{@course.id} AND ccs.user_id = cm.user_id) AS message_num,
(SELECTcount(messages.id)FROMmessagesjoinboardsonmessages.board_id=boards.idWHEREboards.course_id=#{@course.id} AND messages.author_id = cm.user_id and messages.parent_id is null) AS message_num,
(SELECTmax(message_reply_num)FROMcourse_contributor_scoresASccsWHEREccs.course_id=#{@course.id} AND ccs.user_id = cm.user_id) AS message_reply_num,
(SELECTcount(messages.id)FROMmessagesjoinboardsonmessages.board_id=boards.idWHEREboards.course_id=#{@course.id} AND messages.author_id = cm.user_id and messages.parent_id is not null) AS message_reply_num,
(SELECTmax(resource_num)FROMcourse_contributor_scoresASccsWHEREccs.course_id=#{@course.id} AND ccs.user_id = cm.user_id) AS resource_num,
(SELECTcount(attachments.id)FROMattachmentsWHEREcontainer_id=#{@course.id} and container_type = "Course" AND attachments.author_id = cm.user_id) AS resource_num,
(SELECTmax(homework_journal_num)FROMcourse_contributor_scoresASccsWHEREccs.course_id=#{@course.id} AND ccs.user_id = cm.user_id) AS homework_journal_num,
(SELECTcount(jfm.id)FROMjournals_for_messagesASjfm,homework_commonshsWHEREjfm.jour_id=hs.idANDjfm.user_id=cm.user_idandjfm.jour_type="HomeworkCommon"andhs.course_id=#{@course.id}) AS homework_journal_num,
(SELECTCOUNT(gw.id)FROMgraduation_worksASgw,graduation_tasksASgtWHEREgw.graduation_task_id=gt.idANDgt.course_id=#{@course.id} AND gw.work_status != 0 AND gw.user_id = cm.user_id) AS graduation_num,
(SELECTCOUNT(gw.id)FROMgraduation_worksASgw,graduation_tasksASgtWHEREgw.graduation_task_id=gt.idANDgt.course_id=#{@course.id} AND gw.work_status != 0 AND gw.user_id = cm.user_id) AS graduation_num,
(SELECTCOUNT(ss.id)FROMstudent_worksASss,homework_commonsAShcWHEREss.homework_common_id=hc.idANDhc.course_id=#{@course.id} AND ss.work_status != 0 AND ss.user_id = cm.user_id) AS homework_num,
(SELECTCOUNT(ss.id)FROMstudent_worksASss,homework_commonsAShcWHEREss.homework_common_id=hc.idANDhc.course_id=#{@course.id} AND ss.work_status != 0 AND ss.user_id = cm.user_id) AS homework_num,
(SELECTCOUNT(eu.id)FROMexercise_usersASeu,exercisesWHEREeu.exercise_id=exercises.idANDexercises.course_id=#{@course.id} AND eu.commit_status = 1 AND eu.user_id = cm.user_id) AS exercise_num,
(SELECTCOUNT(eu.id)FROMexercise_usersASeu,exercisesWHEREeu.exercise_id=exercises.idANDexercises.course_id=#{@course.id} AND eu.commit_status = 1 AND eu.user_id = cm.user_id) AS exercise_num,
@ -1166,7 +1162,7 @@ class CoursesController < ApplicationController