(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,
(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,
(SELECTcount(attachments.id)FROMattachmentsWHEREcontainer_id=#{@course.id} and container_type = "Course" AND attachments.author_id = cm.user_id) AS resource_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(attachments.id)FROMattachmentsWHEREcontainer_id=#{@course.id} and container_type = "Course"
(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(pu.id)FROMpoll_usersASpu,pollsWHEREpu.poll_id=polls.idANDpolls.course_id=#{@course.id} AND pu.commit_status = 1 AND pu.user_id = cm.user_id) AS poll_num
jfm.user_id=cm.user_idandjfm.jour_type="HomeworkCommon"andhs.course_id=#{@course.id}) AS homework_journal_num,