修改用户课程动态接口
This commit is contained in:
parent
83cc1b41f3
commit
26adc13ca2
|
@ -1,3 +1,4 @@
|
|||
#coding=utf-8
|
||||
class CoursesService
|
||||
include ApplicationHelper
|
||||
include CoursesHelper
|
||||
|
@ -351,38 +352,22 @@ class CoursesService
|
|||
result = []
|
||||
membership.each do |mp|
|
||||
course = mp.course
|
||||
#unless current_user.nil? || !(current_user.admin? || course.is_public == 1 || (course.is_public == 0 && current_user.member_of_course?(course)))
|
||||
# count,is_teacher = get_course_anonymous_evaluation current_user,course
|
||||
# if is_teacher
|
||||
# student_commit_number = count
|
||||
# else
|
||||
# need_anonymous_comments_count = count
|
||||
# end
|
||||
# news_count = course.news.count
|
||||
# message_count = course.journals_for_messages.count
|
||||
#
|
||||
# result << {:course_name => course.name,:course_id => course.id,:course_img_url => url_to_avatar(course),:type => 1,:count => message_count}
|
||||
# result << {:course_name => course.name,:course_id => course.id,:course_img_url => url_to_avatar(course),:type => 2,:count => need_anonymous_comments_count}
|
||||
# result << {:course_name => course.name,:course_id => course.id,:course_img_url => url_to_avatar(course),:type => 3,:count => student_commit_number}
|
||||
# result << {:course_name => course.name,:course_id => course.id,:course_img_url => url_to_avatar(course),:type => 4,:count => news_count}
|
||||
# #{:course_name => course.name,:need_anonymous_comments_count=>need_anonymous_comments_count,:student_commit_number=>student_commit_number,:news_count=> news_count,:message_count=>message_count}
|
||||
#end
|
||||
latest_course_dynamics = []
|
||||
latest_news = course.news.order("created_on desc").first
|
||||
unless latest_news.nil?
|
||||
latest_course_dynamics << {:type => 1,:time => latest_news.created_on,:message => l(:label_recently_updated_notification,:locale => current_user.language.nil? ? 'zh':current_user.language)}
|
||||
latest_course_dynamics << {:type => 1,:time => latest_news.created_on,:message => '最近更新了通知' }#l(:label_recently_updated_notification,:locale => current_user.language.nil? ? 'zh':current_user.language)}
|
||||
end
|
||||
latest_message = course.journals_for_messages.order("created_on desc").first
|
||||
unless latest_message.nil?
|
||||
latest_course_dynamics << {:type => 2,:time => latest_message.created_on,:message => l(:label_recently_updated_message,:locale => current_user.language.nil? ? 'zh':current_user.language)}
|
||||
latest_course_dynamics << {:type => 2,:time => latest_message.created_on,:message => '最近更新了留言'}#l(:label_recently_updated_message,:locale => current_user.language.nil? ? 'zh':current_user.language)}
|
||||
end
|
||||
latest_attachment = course.attachments.order("created_on desc").first
|
||||
unless latest_attachment.nil?
|
||||
latest_course_dynamics << {:type => 3,:time => latest_attachment.created_on,:message => l(:label_recently_updated_courseware,:locale => current_user.language.nil? ? 'zh':current_user.language)}
|
||||
latest_course_dynamics << {:type => 3,:time => latest_attachment.created_on,:message => '最近更新了课件'}#l(:label_recently_updated_courseware,:locale => current_user.language.nil? ? 'zh':current_user.language)}
|
||||
end
|
||||
latest_bid = course.homeworks.order('updated_on DESC').first
|
||||
unless latest_bid.nil?
|
||||
latest_course_dynamics << {:type => 4,:time => latest_bid.updated_on,:message => l(:label_recently_updated_homework,:locale => current_user.language.nil? ? 'zh':current_user.language)}
|
||||
latest_course_dynamics << {:type => 4,:time => latest_bid.updated_on,:message => '最近更新了作业'}#l(:label_recently_updated_homework,:locale => current_user.language.nil? ? 'zh':current_user.language)}
|
||||
end
|
||||
#每个作业中的最新留言
|
||||
messages = []
|
||||
|
@ -397,7 +382,7 @@ class CoursesService
|
|||
end
|
||||
latest_bid_message = messages.first
|
||||
unless latest_bid_message.nil?
|
||||
latest_course_dynamics << {:type => 2,:time => latest_bid_message.created_on,:message => l(:label_recently_updated_message,:locale => current_user.language.nil? ? 'zh':current_user.language)}
|
||||
latest_course_dynamics << {:type => 2,:time => latest_bid_message.created_on,:message => '最近更新了留言'}#l(:label_recently_updated_message,:locale => current_user.language.nil? ? 'zh':current_user.language)}
|
||||
end
|
||||
#每个作业中学生最后提交的作业
|
||||
homeworks = []
|
||||
|
@ -412,7 +397,7 @@ class CoursesService
|
|||
end
|
||||
latest_homework_attach = homeworks.first
|
||||
unless latest_homework_attach.nil?
|
||||
latest_course_dynamics << {:type => 4,:time => latest_homework_attach.updated_at,:message => l(:label_recently_updated_homework,:locale => current_user.language.nil? ? 'zh':current_user.language)}
|
||||
latest_course_dynamics << {:type => 4,:time => latest_homework_attach.updated_at,:message => '最近更新了作业'}#l(:label_recently_updated_homework,:locale => current_user.language.nil? ? 'zh':current_user.language)}
|
||||
end
|
||||
latest_course_dynamics.sort!{|order,newer| newer[:time] <=> order[:time]}
|
||||
latest_course_dynamic = latest_course_dynamics.first
|
||||
|
|
Loading…
Reference in New Issue