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
607bd538
Commit
607bd538
authored
Sep 04, 2015
by
Peter Fogg
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update discussion events to include team_id when appropriate.
TNL-3196
parent
c2197608
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
55 additions
and
1 deletions
+55
-1
lms/djangoapps/django_comment_client/base/tests.py
+51
-1
lms/djangoapps/django_comment_client/base/views.py
+4
-0
No files found.
lms/djangoapps/django_comment_client/base/tests.py
View file @
607bd538
...
@@ -24,6 +24,7 @@ from django_comment_client.tests.unicode import UnicodeTestMixin
...
@@ -24,6 +24,7 @@ from django_comment_client.tests.unicode import UnicodeTestMixin
from
django_comment_common.models
import
Role
from
django_comment_common.models
import
Role
from
django_comment_common.utils
import
seed_permissions_roles
,
ThreadContext
from
django_comment_common.utils
import
seed_permissions_roles
,
ThreadContext
from
student.tests.factories
import
CourseEnrollmentFactory
,
UserFactory
,
CourseAccessRoleFactory
from
student.tests.factories
import
CourseEnrollmentFactory
,
UserFactory
,
CourseAccessRoleFactory
from
teams.tests.factories
import
CourseTeamFactory
,
CourseTeamMembershipFactory
from
util.testing
import
UrlResetMixin
from
util.testing
import
UrlResetMixin
from
xmodule.modulestore.tests.factories
import
CourseFactory
,
ItemFactory
from
xmodule.modulestore.tests.factories
import
CourseFactory
,
ItemFactory
from
xmodule.modulestore.tests.django_utils
import
ModuleStoreTestCase
from
xmodule.modulestore.tests.django_utils
import
ModuleStoreTestCase
...
@@ -1226,7 +1227,7 @@ class CreateSubCommentUnicodeTestCase(ModuleStoreTestCase, UnicodeTestMixin, Moc
...
@@ -1226,7 +1227,7 @@ class CreateSubCommentUnicodeTestCase(ModuleStoreTestCase, UnicodeTestMixin, Moc
request
=
RequestFactory
()
.
post
(
"dummy_url"
,
{
"body"
:
text
})
request
=
RequestFactory
()
.
post
(
"dummy_url"
,
{
"body"
:
text
})
request
.
user
=
self
.
student
request
.
user
=
self
.
student
request
.
view_name
=
"create_sub_comment"
request
.
view_name
=
"create_sub_comment"
Thread
.
commentable_id
=
Mock
()
Thread
.
commentable_id
=
"test_commentable"
try
:
try
:
response
=
views
.
create_sub_comment
(
response
=
views
.
create_sub_comment
(
request
,
course_id
=
unicode
(
self
.
course
.
id
),
comment_id
=
"dummy_comment_id"
request
,
course_id
=
unicode
(
self
.
course
.
id
),
comment_id
=
"dummy_comment_id"
...
@@ -1496,7 +1497,11 @@ class TeamsPermissionsTestCase(UrlResetMixin, ModuleStoreTestCase, MockRequestSe
...
@@ -1496,7 +1497,11 @@ class TeamsPermissionsTestCase(UrlResetMixin, ModuleStoreTestCase, MockRequestSe
self
.
assertEqual
(
response
.
status_code
,
status_code
)
self
.
assertEqual
(
response
.
status_code
,
status_code
)
TEAM_COMMENTABLE_ID
=
'test-team-discussion'
@disable_signal
(
views
,
'comment_created'
)
@disable_signal
(
views
,
'comment_created'
)
@ddt.ddt
class
ForumEventTestCase
(
ModuleStoreTestCase
,
MockRequestSetupMixin
):
class
ForumEventTestCase
(
ModuleStoreTestCase
,
MockRequestSetupMixin
):
"""
"""
Forum actions are expected to launch analytics events. Test these here.
Forum actions are expected to launch analytics events. Test these here.
...
@@ -1592,6 +1597,51 @@ class ForumEventTestCase(ModuleStoreTestCase, MockRequestSetupMixin):
...
@@ -1592,6 +1597,51 @@ class ForumEventTestCase(ModuleStoreTestCase, MockRequestSetupMixin):
self
.
assertEqual
(
event
[
'user_course_roles'
],
[
'Wizard'
])
self
.
assertEqual
(
event
[
'user_course_roles'
],
[
'Wizard'
])
self
.
assertEqual
(
event
[
'options'
][
'followed'
],
False
)
self
.
assertEqual
(
event
[
'options'
][
'followed'
],
False
)
@patch
(
'eventtracking.tracker.emit'
)
@patch
(
'lms.lib.comment_client.utils.requests.request'
)
@ddt.data
((
'create_thread'
,
'edx.forum.thread.created'
,
{
'thread_type'
:
'discussion'
,
'body'
:
'Test text'
,
'title'
:
'Test'
,
'auto_subscribe'
:
True
},
{
'commentable_id'
:
TEAM_COMMENTABLE_ID
}
),
(
'create_comment'
,
'edx.forum.response.created'
,
{
'body'
:
'Test comment'
,
'auto_subscribe'
:
True
},
{
'thread_id'
:
'test_thread_id'
}
),
(
'create_sub_comment'
,
'edx.forum.comment.created'
,
{
'body'
:
'Another comment'
},
{
'comment_id'
:
'dummy_comment_id'
}
))
@ddt.unpack
def
test_team_events
(
self
,
view_name
,
event_name
,
view_data
,
view_kwargs
,
mock_request
,
mock_emit
):
user
=
self
.
student
team
=
CourseTeamFactory
.
create
(
discussion_topic_id
=
TEAM_COMMENTABLE_ID
)
CourseTeamMembershipFactory
.
create
(
team
=
team
,
user
=
user
)
mock_request
.
return_value
.
status_code
=
200
self
.
_set_mock_request_data
(
mock_request
,
{
'closed'
:
False
,
'commentable_id'
:
TEAM_COMMENTABLE_ID
,
'thread_id'
:
'test_thread_id'
,
})
request
=
RequestFactory
()
.
post
(
'dummy_url'
,
view_data
)
request
.
user
=
user
request
.
view_name
=
view_name
getattr
(
views
,
view_name
)(
request
,
course_id
=
unicode
(
self
.
course
.
id
),
**
view_kwargs
)
name
,
event
=
mock_emit
.
call_args
[
0
]
self
.
assertEqual
(
name
,
event_name
)
self
.
assertEqual
(
event
[
'team_id'
],
team
.
team_id
)
class
UsersEndpointTestCase
(
ModuleStoreTestCase
,
MockRequestSetupMixin
):
class
UsersEndpointTestCase
(
ModuleStoreTestCase
,
MockRequestSetupMixin
):
...
...
lms/djangoapps/django_comment_client/base/views.py
View file @
607bd538
...
@@ -94,6 +94,10 @@ def track_forum_event(request, event_name, course, obj, data, id_map=None):
...
@@ -94,6 +94,10 @@ def track_forum_event(request, event_name, course, obj, data, id_map=None):
data
[
'id'
]
=
obj
.
id
data
[
'id'
]
=
obj
.
id
commentable_id
=
data
[
'commentable_id'
]
commentable_id
=
data
[
'commentable_id'
]
team
=
get_team
(
commentable_id
)
if
team
is
not
None
:
data
.
update
(
team_id
=
team
.
team_id
)
if
id_map
is
None
:
if
id_map
is
None
:
id_map
=
get_cached_discussion_id_map
(
course
,
[
commentable_id
],
user
)
id_map
=
get_cached_discussion_id_map
(
course
,
[
commentable_id
],
user
)
...
...
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