diff --git a/lms/static/coffee/src/discussion/content.coffee b/lms/static/coffee/src/discussion/content.coffee index d489782571..4e612dfc40 100644 --- a/lms/static/coffee/src/discussion/content.coffee +++ b/lms/static/coffee/src/discussion/content.coffee @@ -129,6 +129,12 @@ if Backbone? json_attributes = _.clone(@attributes) _.extend(json_attributes, { title: @display_title(), body: @display_body() }) + created_at_date: -> + new Date(@get("created_at")) + + created_at_time: -> + new Date(@get("created_at")).getTime() + class @Comment extends @Content urlMappers: 'reply': -> DiscussionUtil.urlFor('create_sub_comment', @id) diff --git a/lms/static/coffee/src/discussion/discussion.coffee b/lms/static/coffee/src/discussion/discussion.coffee index 2b4339015f..af74afc6e9 100644 --- a/lms/static/coffee/src/discussion/discussion.coffee +++ b/lms/static/coffee/src/discussion/discussion.coffee @@ -66,9 +66,15 @@ if Backbone? sortByVotes: (thread1, thread2) -> thread1_count = parseInt(thread1.get("votes")['up_count']) thread2_count = parseInt(thread2.get("votes")['up_count']) - thread2_count - thread1_count + if thread2_count != thread1_count + thread2_count - thread1_count + else + thread2.created_at_time() - thread1.created_at_time() sortByComments: (thread1, thread2) -> thread1_count = parseInt(thread1.get("comments_count")) thread2_count = parseInt(thread2.get("comments_count")) - thread2_count - thread1_count + if thread2_count != thread1_count + thread2_count - thread1_count + else + thread2.created_at_time() - thread1.created_at_time()