回复通知api

活跃排名api
其他api的修改
This commit is contained in:
lizanle 2015-07-08 17:36:17 +08:00
parent 716dded9fd
commit 1b1cce615d
5 changed files with 36 additions and 6 deletions

View File

@ -113,6 +113,20 @@ module Mobile
present :status, 0
end
desc '通知评论列表'
params do
requires :token, type: String
requires :notice_id,type:Integer,desc:'通知id'
optional :page,type:Integer,desc:'页码'
end
get ':notice_id/notice_comments' do
cs = CommentService.new
comments = cs.notice_comments params,current_user
present :data, comments, with: Mobile::Entities::Comment
present :status, 0
end
end
end
end

View File

@ -312,11 +312,12 @@ module Mobile
present :status,0
end
desc '课程历次作业总成绩列表'
desc '总成绩 or 活跃度列表'
params do
requires :token,type:String
requires :course_id,type:Integer,desc:'课程id'
optional :page,type:Integer,desc:'页码'
optional :type,type:Integer,desc:'0是活跃度1是成绩'
end
get ':course_id/students_score_list' do
cs = CoursesService.new

View File

@ -56,6 +56,8 @@ module Mobile
expose :comments, using: Mobile::Entities::Comment do |f, opt|
if f.is_a?(Hash) && f.key?(:comments)
f[:comments]
elsif f.is_a?(::News) && f.respond_to?(:comments)
f.send(:comments)
end
end

View File

@ -112,6 +112,9 @@ class CommentService
end
end
# 获取课程里的某个通知的所有回复
def notice_comments params,current_user
News.find(params[:notice_id]).comments.page(params[:page] || 1).per(10)
end
end

View File

@ -719,11 +719,21 @@ class CoursesService
# 获取课程历次作业的学生总成绩
def students_score_list params,current_user
homework_count = Course.find(params[:course_id]).homework_commons.count
page = (params[:page] || 1) - 1
sql = "select users.*,sum(IFNULL(0,student_works.final_score))/#{homework_count} score from student_works left outer join users on student_works.user_id = users.id" <<
" where homework_common_id in ( select id from homework_commons where homework_commons.course_id = #{params[:course_id]}) GROUP BY student_works.user_id ORDER BY score limit #{page*10},10"
User.find_by_sql(sql)
if params[:type] == 1
homework_count = Course.find(params[:course_id]).homework_commons.count
sql = "select users.*,sum(IFNULL(0,student_works.final_score))/#{homework_count} score from student_works left outer join users on student_works.user_id = users.id" <<
" where homework_common_id in ( select id from homework_commons where homework_commons.course_id = #{params[:course_id]}) GROUP BY student_works.user_id ORDER BY score limit #{page*10},10"
User.find_by_sql(sql)
else
sql1 = " select users.*,count(author_id)*2 active_count from messages " <<
" LEFT JOIN users on messages.author_id = users.id " <<
" where messages.board_id in (select id from boards where boards.course_id = #{params[:course_id]} ) " <<
" GROUP BY messages.author_id ORDER BY count(author_id) desc " <<
" limit #{page*10},10"
User.find_by_sql(sql1)
end
end
# 获取某次作业的所有作业列表