Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-platform
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
edx-platform
Commits
c31164c3
Commit
c31164c3
authored
Apr 13, 2016
by
wajeeha-khalid
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #11838 from edx/jia/TNL-3818
TNL-3818: fixed recent activity mapping in thread-list sort
parents
a533472a
5b5fb246
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
20 additions
and
18 deletions
+20
-18
common/static/coffee/spec/discussion/view/discussion_thread_list_view_spec.coffee
+7
-7
common/static/coffee/src/discussion/discussion.coffee
+4
-3
common/static/coffee/src/discussion/views/discussion_thread_list_view.coffee
+1
-1
common/test/acceptance/tests/discussion/test_discussion.py
+3
-3
lms/djangoapps/discussion_api/tests/utils.py
+1
-0
lms/djangoapps/django_comment_client/forum/views.py
+1
-1
lms/djangoapps/django_comment_client/utils.py
+1
-1
lms/lib/comment_client/thread.py
+1
-1
lms/templates/discussion/_thread_list_template.html
+1
-1
No files found.
common/static/coffee/spec/discussion/view/discussion_thread_list_view_spec.coffee
View file @
c31164c3
...
...
@@ -88,7 +88,7 @@ describe "DiscussionThreadListView", ->
<% } %>
<label class="forum-nav-sort">
<select class="forum-nav-sort-control">
<option value="
date
">by recent activity</option>
<option value="
activity
">by recent activity</option>
<option value="comments">by most activity</option>
<option value="votes">by most votes</option>
</select>
...
...
@@ -232,8 +232,8 @@ describe "DiscussionThreadListView", ->
)
).
toEqual
([
"+25 votes"
,
"+20 votes"
,
"+42 votes"
,
"+12 votes"
])
it
"with sort preference
date
"
,
->
checkRender
(
@
threads
,
"
date"
,
[
"Thread1"
,
"Thread4"
,
"Thread2"
,
"Thread3
"
])
it
"with sort preference
activity
"
,
->
checkRender
(
@
threads
,
"
activity"
,
[
"Thread1"
,
"Thread2"
,
"Thread3"
,
"Thread4
"
])
it
"with sort preference votes"
,
->
checkRender
(
@
threads
,
"votes"
,
[
"Thread4"
,
"Thread1"
,
"Thread2"
,
"Thread3"
])
...
...
@@ -249,7 +249,7 @@ describe "DiscussionThreadListView", ->
sortControl
=
view
.
$el
.
find
(
".forum-nav-sort-control"
)
expect
(
sortControl
.
val
()).
toEqual
(
selected_type
)
sorted_threads
=
[]
if
new_type
==
'
date
'
if
new_type
==
'
activity
'
sorted_threads
=
[
threads
[
0
],
threads
[
3
],
threads
[
1
],
threads
[
2
]]
else
if
new_type
==
'comments'
sorted_threads
=
[
threads
[
0
],
threads
[
3
],
threads
[
2
],
threads
[
1
]]
...
...
@@ -265,11 +265,11 @@ describe "DiscussionThreadListView", ->
expect
(
$
.
ajax
).
toHaveBeenCalled
()
checkThreadsOrdering
(
view
,
sort_order
,
new_type
)
it
"with sort preference
date
"
,
->
changeSorting
(
@
threads
,
"comments"
,
"
date"
,
[
"Thread1"
,
"Thread4"
,
"Thread2"
,
"Thread3
"
])
it
"with sort preference
activity
"
,
->
changeSorting
(
@
threads
,
"comments"
,
"
activity"
,
[
"Thread1"
,
"Thread4"
,
"Thread3"
,
"Thread2
"
])
it
"with sort preference votes"
,
->
changeSorting
(
@
threads
,
"
date
"
,
"votes"
,
[
"Thread4"
,
"Thread1"
,
"Thread2"
,
"Thread3"
])
changeSorting
(
@
threads
,
"
activity
"
,
"votes"
,
[
"Thread4"
,
"Thread1"
,
"Thread2"
,
"Thread3"
])
it
"with sort preference comments"
,
->
changeSorting
(
@
threads
,
"votes"
,
"comments"
,
[
"Thread1"
,
"Thread4"
,
"Thread3"
,
"Thread2"
])
...
...
common/static/coffee/src/discussion/discussion.coffee
View file @
c31164c3
...
...
@@ -20,7 +20,7 @@ if Backbone?
setSortComparator
:
(
sortBy
)
->
switch
sortBy
when
'
date
'
then
@
comparator
=
@
sortByDateRecentFirst
when
'
activity
'
then
@
comparator
=
@
sortByDateRecentFirst
when
'votes'
then
@
comparator
=
@
sortByVotes
when
'comments'
then
@
comparator
=
@
sortByComments
...
...
@@ -49,7 +49,7 @@ if Backbone?
url
=
DiscussionUtil
.
urlFor
'followed_threads'
,
options
.
user_id
if
options
[
'group_id'
]
data
[
'group_id'
]
=
options
[
'group_id'
]
data
[
'sort_key'
]
=
sort_options
.
sort_key
||
'
date
'
data
[
'sort_key'
]
=
sort_options
.
sort_key
||
'
activity
'
data
[
'sort_order'
]
=
sort_options
.
sort_order
||
'desc'
DiscussionUtil
.
safeAjax
$elem
:
@
$el
...
...
@@ -117,8 +117,9 @@ if Backbone?
pinnedThreadsSortComparatorWithDate
:
(
thread
,
ascending
)
->
# if threads are pinned they should be displayed on top.
# Unpinned will be sorted by their date
# Unpinned will be sorted by their
last activity
date
threadCreatedTime
=
new
Date
(
thread
.
get
(
"created_at"
)).
getTime
()
threadCreatedTime
=
new
Date
(
thread
.
get
(
"last_activity_at"
)).
getTime
()
if
thread
.
get
(
'pinned'
)
#use tomorrow's date
today
=
new
Date
();
...
...
common/static/coffee/src/discussion/views/discussion_thread_list_view.coffee
View file @
c31164c3
...
...
@@ -161,7 +161,7 @@ if Backbone?
voteCounts
.
hide
()
commentCounts
.
hide
()
switch
@
$
(
".forum-nav-sort-control"
).
val
()
when
"
date
"
,
"comments"
when
"
activity
"
,
"comments"
commentCounts
.
show
()
when
"votes"
voteCounts
.
show
()
...
...
common/test/acceptance/tests/discussion/test_discussion.py
View file @
c31164c3
...
...
@@ -1121,14 +1121,14 @@ class DiscussionSortPreferenceTest(UniqueCourseTest):
Test to check the default sorting preference of user. (Default = date )
"""
selected_sort
=
self
.
sort_page
.
get_selected_sort_preference
()
self
.
assertEqual
(
selected_sort
,
"
date
"
)
self
.
assertEqual
(
selected_sort
,
"
activity
"
)
def
test_change_sort_preference
(
self
):
"""
Test that if user sorting preference is changing properly.
"""
selected_sort
=
""
for
sort_type
in
[
"votes"
,
"comments"
,
"
date
"
]:
for
sort_type
in
[
"votes"
,
"comments"
,
"
activity
"
]:
self
.
assertNotEqual
(
selected_sort
,
sort_type
)
self
.
sort_page
.
change_sort_preference
(
sort_type
)
selected_sort
=
self
.
sort_page
.
get_selected_sort_preference
()
...
...
@@ -1139,7 +1139,7 @@ class DiscussionSortPreferenceTest(UniqueCourseTest):
Test that user last preference is saved.
"""
selected_sort
=
""
for
sort_type
in
[
"votes"
,
"comments"
,
"
date
"
]:
for
sort_type
in
[
"votes"
,
"comments"
,
"
activity
"
]:
self
.
assertNotEqual
(
selected_sort
,
sort_type
)
self
.
sort_page
.
change_sort_preference
(
sort_type
)
selected_sort
=
self
.
sort_page
.
get_selected_sort_preference
()
...
...
lms/djangoapps/discussion_api/tests/utils.py
View file @
c31164c3
...
...
@@ -332,6 +332,7 @@ def make_minimal_cs_thread(overrides=None):
"anonymous_to_peers"
:
False
,
"created_at"
:
"1970-01-01T00:00:00Z"
,
"updated_at"
:
"1970-01-01T00:00:00Z"
,
"last_activity_at"
:
"1970-01-01T00:00:00Z"
,
"thread_type"
:
"discussion"
,
"title"
:
"dummy"
,
"body"
:
"dummy"
,
...
...
lms/djangoapps/django_comment_client/forum/views.py
View file @
c31164c3
...
...
@@ -94,7 +94,7 @@ def get_threads(request, course, discussion_id=None, per_page=THREADS_PER_PAGE):
default_query_params
=
{
'page'
:
1
,
'per_page'
:
per_page
,
'sort_key'
:
'
date
'
,
'sort_key'
:
'
activity
'
,
'sort_order'
:
'desc'
,
'text'
:
''
,
'course_id'
:
unicode
(
course
.
id
),
...
...
lms/djangoapps/django_comment_client/utils.py
View file @
c31164c3
...
...
@@ -654,7 +654,7 @@ def prepare_content(content, course_key, is_staff=False, course_is_cohorted=None
'read'
,
'group_id'
,
'group_name'
,
'pinned'
,
'abuse_flaggers'
,
'stats'
,
'resp_skip'
,
'resp_limit'
,
'resp_total'
,
'thread_type'
,
'endorsed_responses'
,
'non_endorsed_responses'
,
'non_endorsed_resp_total'
,
'endorsement'
,
'context'
'endorsement'
,
'context'
,
'last_activity_at'
]
if
(
content
.
get
(
'anonymous'
)
is
False
)
and
((
content
.
get
(
'anonymous_to_peers'
)
is
False
)
or
is_staff
):
...
...
lms/lib/comment_client/thread.py
View file @
c31164c3
...
...
@@ -20,7 +20,7 @@ class Thread(models.Model):
'highlighted_body'
,
'endorsed'
,
'read'
,
'group_id'
,
'group_name'
,
'pinned'
,
'abuse_flaggers'
,
'resp_skip'
,
'resp_limit'
,
'resp_total'
,
'thread_type'
,
'endorsed_responses'
,
'non_endorsed_responses'
,
'non_endorsed_resp_total'
,
'context'
,
'context'
,
'last_activity_at'
,
]
# updateable_fields are sent in PUT requests
...
...
lms/templates/discussion/_thread_list_template.html
View file @
c31164c3
...
...
@@ -54,7 +54,7 @@
<
span
class
=
"sr"
>
$
{
_
(
"Sort:"
)}
<
/span
>
<
select
class
=
"forum-nav-sort-control"
>
##
Translators
:
This
is
a
menu
option
for
sorting
forum
threads
<
option
value
=
"
date
"
>
$
{
_
(
"by recent activity"
)}
<
/option
>
<
option
value
=
"
activity
"
>
$
{
_
(
"by recent activity"
)}
<
/option
>
##
Translators
:
This
is
a
menu
option
for
sorting
forum
threads
<
option
value
=
"comments"
>
$
{
_
(
"by most activity"
)}
<
/option
>
##
Translators
:
This
is
a
menu
option
for
sorting
forum
threads
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment