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
4655b914
Commit
4655b914
authored
Aug 05, 2015
by
Jonathan Piacenti
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed low-hanging fruit in post-rebase discussion tests and functionality.
parent
87596152
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
13 additions
and
21 deletions
+13
-21
common/templates/discussion/_underscore_templates.html
+3
-4
lms/djangoapps/django_comment_client/base/views.py
+0
-1
lms/djangoapps/django_comment_client/forum/tests.py
+1
-0
lms/djangoapps/django_comment_client/forum/views.py
+0
-1
lms/djangoapps/django_comment_client/management/commands/export_discussion_participation.py
+1
-1
lms/djangoapps/django_comment_client/tests/management/test_export_discussion_participation.py
+2
-2
lms/djangoapps/django_comment_client/tests/test_utils.py
+5
-4
lms/djangoapps/django_comment_client/tests/utils.py
+0
-8
lms/djangoapps/django_comment_client/utils.py
+1
-0
No files found.
common/templates/discussion/_underscore_templates.html
View file @
4655b914
<
%!
from
django
.
utils
.
translation
import
ugettext
as
_
%
>
<
%!
from
django
.
utils
.
translation
import
ugettext
as
_
%
>
<
%!
from
django
.
template
.
defaultfilters
import
escapejs
%
>
<
%!
from
django
.
template
.
defaultfilters
import
escapejs
%
>
<
%!
from
django_comment_client
.
permissions
import
cached_has_permission
%
>
<
%
namespace
name=
'static'
file=
'../static_content.html'
/>
<
%
namespace
name=
'static'
file=
'../static_content.html'
/>
<
%!
<
%!
...
@@ -22,7 +21,7 @@ from django_comment_client.permissions import has_permission
...
@@ -22,7 +21,7 @@ from django_comment_client.permissions import has_permission
<
/div
>
<
/div
>
<
div
class
=
"post-extended-content"
>
<
div
class
=
"post-extended-content"
>
<
div
class
=
"response-count"
/>
<
div
class
=
"response-count"
/>
%
if
course
is
UNDEFINED
or
cached_
has_permission
(
user
,
'create_comment'
,
course
.
id
):
%
if
course
is
UNDEFINED
or
has_permission
(
user
,
'create_comment'
,
course
.
id
):
<
div
class
=
"add-response"
>
<
div
class
=
"add-response"
>
<
button
class
=
"button add-response-btn"
>
<
button
class
=
"button add-response-btn"
>
<
i
class
=
"icon fa fa-reply"
><
/i
>
<
i
class
=
"icon fa fa-reply"
><
/i
>
...
@@ -35,7 +34,7 @@ from django_comment_client.permissions import has_permission
...
@@ -35,7 +34,7 @@ from django_comment_client.permissions import has_permission
<
div
class
=
"post-status-closed bottom-post-status"
style
=
"display: none"
>
<
div
class
=
"post-status-closed bottom-post-status"
style
=
"display: none"
>
$
{
_
(
"This thread is closed."
)}
$
{
_
(
"This thread is closed."
)}
<
/div
>
<
/div
>
%
if
course
is
UNDEFINED
or
cached_
has_permission
(
user
,
'create_comment'
,
course
.
id
):
%
if
course
is
UNDEFINED
or
has_permission
(
user
,
'create_comment'
,
course
.
id
):
<
form
class
=
"discussion-reply-new"
data
-
id
=
"${'<%- id %>'}"
>
<
form
class
=
"discussion-reply-new"
data
-
id
=
"${'<%- id %>'}"
>
<
h4
>
$
{
_
(
"Post a response:"
)}
<
/h4
>
<
h4
>
$
{
_
(
"Post a response:"
)}
<
/h4
>
<
ul
class
=
"discussion-errors"
><
/ul
>
<
ul
class
=
"discussion-errors"
><
/ul
>
...
@@ -83,7 +82,7 @@ from django_comment_client.permissions import has_permission
...
@@ -83,7 +82,7 @@ from django_comment_client.permissions import has_permission
<
/a
>
<
/a
>
<
ol
class
=
"comments"
>
<
ol
class
=
"comments"
>
<
li
class
=
"new-comment"
>
<
li
class
=
"new-comment"
>
%
if
course
is
UNDEFINED
or
cached_
has_permission
(
user
,
'create_sub_comment'
,
course
.
id
):
%
if
course
is
UNDEFINED
or
has_permission
(
user
,
'create_sub_comment'
,
course
.
id
):
<
form
class
=
"comment-form"
data
-
id
=
"${'<%- wmdId %>'}"
>
<
form
class
=
"comment-form"
data
-
id
=
"${'<%- wmdId %>'}"
>
<
ul
class
=
"discussion-errors"
><
/ul
>
<
ul
class
=
"discussion-errors"
><
/ul
>
<
label
class
=
"sr"
for
=
"add-new-comment"
>
$
{
_
(
"Add a comment"
)}
<
/label
>
<
label
class
=
"sr"
for
=
"add-new-comment"
>
$
{
_
(
"Add a comment"
)}
<
/label
>
...
...
lms/djangoapps/django_comment_client/base/views.py
View file @
4655b914
...
@@ -296,7 +296,6 @@ def create_thread(request, course_id, commentable_id):
...
@@ -296,7 +296,6 @@ def create_thread(request, course_id, commentable_id):
data
=
thread
.
to_dict
()
data
=
thread
.
to_dict
()
add_courseware_context
([
data
],
course
)
if
request
.
is_ajax
():
if
request
.
is_ajax
():
return
ajax_content_response
(
request
,
course_key
,
data
)
return
ajax_content_response
(
request
,
course_key
,
data
)
else
:
else
:
...
...
lms/djangoapps/django_comment_client/forum/tests.py
View file @
4655b914
...
@@ -1003,6 +1003,7 @@ class InlineDiscussionTestCase(ModuleStoreTestCase):
...
@@ -1003,6 +1003,7 @@ class InlineDiscussionTestCase(ModuleStoreTestCase):
@patch
(
'requests.request'
)
@patch
(
'requests.request'
)
class
SingleCohortedThreadTestCase
(
ModuleStoreTestCase
):
class
SingleCohortedThreadTestCase
(
ModuleStoreTestCase
):
def
setUp
(
self
):
def
setUp
(
self
):
super
(
SingleCohortedThreadTestCase
,
self
)
.
setUp
()
self
.
course
=
CourseFactory
.
create
()
self
.
course
=
CourseFactory
.
create
()
self
.
student
=
UserFactory
.
create
()
self
.
student
=
UserFactory
.
create
()
CourseEnrollmentFactory
.
create
(
user
=
self
.
student
,
course_id
=
self
.
course
.
id
)
CourseEnrollmentFactory
.
create
(
user
=
self
.
student
,
course_id
=
self
.
course
.
id
)
...
...
lms/djangoapps/django_comment_client/forum/views.py
View file @
4655b914
...
@@ -397,7 +397,6 @@ def single_thread(request, course_key, discussion_id, thread_id):
...
@@ -397,7 +397,6 @@ def single_thread(request, course_key, discussion_id, thread_id):
threads
,
query_params
=
get_threads
(
request
,
course
)
threads
,
query_params
=
get_threads
(
request
,
course
)
except
ValueError
:
except
ValueError
:
return
HttpResponseBadRequest
(
"Invalid group_id"
)
return
HttpResponseBadRequest
(
"Invalid group_id"
)
threads
,
query_params
=
get_threads
(
request
,
course_key
)
threads
.
append
(
thread
.
to_dict
())
threads
.
append
(
thread
.
to_dict
())
with
newrelic
.
agent
.
FunctionTrace
(
nr_transaction
,
"add_courseware_context"
):
with
newrelic
.
agent
.
FunctionTrace
(
nr_transaction
,
"add_courseware_context"
):
...
...
lms/djangoapps/django_comment_client/management/commands/export_discussion_participation.py
View file @
4655b914
...
@@ -238,7 +238,7 @@ class Extractor(object):
...
@@ -238,7 +238,7 @@ class Extractor(object):
def
_get_users
(
self
,
course_key
):
def
_get_users
(
self
,
course_key
):
""" Returns users enrolled to a course as dictionary user_id => user """
""" Returns users enrolled to a course as dictionary user_id => user """
users
=
CourseEnrollment
.
users_enrolled_in
(
course_key
)
users
=
CourseEnrollment
.
objects
.
users_enrolled_in
(
course_key
)
return
{
user
.
id
:
user
for
user
in
users
}
return
{
user
.
id
:
user
for
user
in
users
}
def
_get_social_stats
(
self
,
course_key
,
end_date
=
None
,
thread_type
=
None
,
thread_ids
=
None
):
def
_get_social_stats
(
self
,
course_key
,
end_date
=
None
,
thread_type
=
None
,
thread_ids
=
None
):
...
...
lms/djangoapps/django_comment_client/tests/management/test_export_discussion_participation.py
View file @
4655b914
...
@@ -255,7 +255,7 @@ class ExtractorTest(TestCase):
...
@@ -255,7 +255,7 @@ class ExtractorTest(TestCase):
@ddt.data
(
*
_std_parameters_list
)
@ddt.data
(
*
_std_parameters_list
)
def
test_extract_invokes_correct_data_extraction_methods
(
self
,
course_key
,
end_date
,
thread_type
,
thread_ids
):
def
test_extract_invokes_correct_data_extraction_methods
(
self
,
course_key
,
end_date
,
thread_type
,
thread_ids
):
""" Tests that correct underlying extractors are called with proper arguments """
""" Tests that correct underlying extractors are called with proper arguments """
with
mock
.
patch
(
_target_module
+
'.CourseEnrollment.users_enrolled_in'
)
as
patched_users_enrolled_in
,
\
with
mock
.
patch
(
_target_module
+
'.CourseEnrollment.
objects.
users_enrolled_in'
)
as
patched_users_enrolled_in
,
\
mock
.
patch
(
_target_module
+
".User.all_social_stats"
)
as
patched_all_social_stats
:
mock
.
patch
(
_target_module
+
".User.all_social_stats"
)
as
patched_all_social_stats
:
self
.
extractor
.
extract
(
course_key
,
end_date
=
end_date
,
thread_type
=
thread_type
,
thread_ids
=
thread_ids
)
self
.
extractor
.
extract
(
course_key
,
end_date
=
end_date
,
thread_type
=
thread_type
,
thread_ids
=
thread_ids
)
patched_users_enrolled_in
.
return_value
=
[]
patched_users_enrolled_in
.
return_value
=
[]
...
@@ -306,7 +306,7 @@ class ExtractorTest(TestCase):
...
@@ -306,7 +306,7 @@ class ExtractorTest(TestCase):
)
)
def
test_extract_correctly_merges_data
(
self
,
user_data
,
social_stats
,
expected_result
):
def
test_extract_correctly_merges_data
(
self
,
user_data
,
social_stats
,
expected_result
):
""" Tests that extracted data is merged correctly """
""" Tests that extracted data is merged correctly """
with
mock
.
patch
(
_target_module
+
'.CourseEnrollment.users_enrolled_in'
)
as
patched_users_enrolled_in
,
\
with
mock
.
patch
(
_target_module
+
'.CourseEnrollment.
objects.
users_enrolled_in'
)
as
patched_users_enrolled_in
,
\
mock
.
patch
(
_target_module
+
".User.all_social_stats"
)
as
patched_all_social_stats
:
mock
.
patch
(
_target_module
+
".User.all_social_stats"
)
as
patched_all_social_stats
:
patched_users_enrolled_in
.
return_value
=
user_data
patched_users_enrolled_in
.
return_value
=
user_data
patched_all_social_stats
.
return_value
=
social_stats
patched_all_social_stats
.
return_value
=
social_stats
...
...
lms/djangoapps/django_comment_client/tests/test_utils.py
View file @
4655b914
# -*- coding: utf-8 -*-
# -*- coding: utf-8 -*-
import
json
import
json
import
datetime
import
mock
import
mock
from
nose.plugins.attrib
import
attr
from
nose.plugins.attrib
import
attr
import
ddt
import
ddt
...
@@ -722,7 +723,7 @@ class CategoryMapTestCase(CategoryMapTestMixin, ModuleStoreTestCase):
...
@@ -722,7 +723,7 @@ class CategoryMapTestCase(CategoryMapTestMixin, ModuleStoreTestCase):
)
)
def
test_ids_empty
(
self
):
def
test_ids_empty
(
self
):
self
.
assertEqual
(
utils
.
get_discussion_categories_ids
(
self
.
course
),
[])
self
.
assertEqual
(
utils
.
get_discussion_categories_ids
(
self
.
course
,
self
.
user
),
[])
def
test_ids_configured_topics
(
self
):
def
test_ids_configured_topics
(
self
):
self
.
course
.
discussion_topics
=
{
self
.
course
.
discussion_topics
=
{
...
@@ -731,7 +732,7 @@ class CategoryMapTestCase(CategoryMapTestMixin, ModuleStoreTestCase):
...
@@ -731,7 +732,7 @@ class CategoryMapTestCase(CategoryMapTestMixin, ModuleStoreTestCase):
"Topic C"
:
{
"id"
:
"Topic_C"
}
"Topic C"
:
{
"id"
:
"Topic_C"
}
}
}
self
.
assertItemsEqual
(
self
.
assertItemsEqual
(
utils
.
get_discussion_categories_ids
(
self
.
course
),
utils
.
get_discussion_categories_ids
(
self
.
course
,
self
.
user
),
[
"Topic_A"
,
"Topic_B"
,
"Topic_C"
]
[
"Topic_A"
,
"Topic_B"
,
"Topic_C"
]
)
)
...
@@ -743,7 +744,7 @@ class CategoryMapTestCase(CategoryMapTestMixin, ModuleStoreTestCase):
...
@@ -743,7 +744,7 @@ class CategoryMapTestCase(CategoryMapTestMixin, ModuleStoreTestCase):
self
.
create_discussion
(
"Chapter 2 / Section 1 / Subsection 2"
,
"Discussion"
)
self
.
create_discussion
(
"Chapter 2 / Section 1 / Subsection 2"
,
"Discussion"
)
self
.
create_discussion
(
"Chapter 3 / Section 1"
,
"Discussion"
)
self
.
create_discussion
(
"Chapter 3 / Section 1"
,
"Discussion"
)
self
.
assertItemsEqual
(
self
.
assertItemsEqual
(
utils
.
get_discussion_categories_ids
(
self
.
course
),
utils
.
get_discussion_categories_ids
(
self
.
course
,
self
.
user
),
[
"discussion1"
,
"discussion2"
,
"discussion3"
,
"discussion4"
,
"discussion5"
,
"discussion6"
]
[
"discussion1"
,
"discussion2"
,
"discussion3"
,
"discussion4"
,
"discussion5"
,
"discussion6"
]
)
)
...
@@ -757,7 +758,7 @@ class CategoryMapTestCase(CategoryMapTestMixin, ModuleStoreTestCase):
...
@@ -757,7 +758,7 @@ class CategoryMapTestCase(CategoryMapTestMixin, ModuleStoreTestCase):
self
.
create_discussion
(
"Chapter 2"
,
"Discussion"
)
self
.
create_discussion
(
"Chapter 2"
,
"Discussion"
)
self
.
create_discussion
(
"Chapter 2 / Section 1 / Subsection 1"
,
"Discussion"
)
self
.
create_discussion
(
"Chapter 2 / Section 1 / Subsection 1"
,
"Discussion"
)
self
.
assertItemsEqual
(
self
.
assertItemsEqual
(
utils
.
get_discussion_categories_ids
(
self
.
course
),
utils
.
get_discussion_categories_ids
(
self
.
course
,
self
.
user
),
[
"Topic_A"
,
"Topic_B"
,
"Topic_C"
,
"discussion1"
,
"discussion2"
,
"discussion3"
]
[
"Topic_A"
,
"Topic_B"
,
"Topic_C"
,
"discussion1"
,
"discussion2"
,
"discussion3"
]
)
)
...
...
lms/djangoapps/django_comment_client/tests/utils.py
View file @
4655b914
...
@@ -33,14 +33,6 @@ class CohortedContentTestCase(ModuleStoreTestCase):
...
@@ -33,14 +33,6 @@ class CohortedContentTestCase(ModuleStoreTestCase):
"cohorted_discussions"
:
[
"cohorted_topic"
]
"cohorted_discussions"
:
[
"cohorted_topic"
]
}
}
)
)
self
.
student_cohort
=
CohortFactory
.
create
(
name
=
"student_cohort"
,
course_id
=
self
.
course
.
id
)
self
.
moderator_cohort
=
CohortFactory
.
create
(
name
=
"moderator_cohort"
,
course_id
=
self
.
course
.
id
)
self
.
course
.
discussion_topics
[
"cohorted topic"
]
=
{
"id"
:
"cohorted_topic"
}
self
.
course
.
discussion_topics
[
"cohorted topic"
]
=
{
"id"
:
"cohorted_topic"
}
self
.
course
.
discussion_topics
[
"non-cohorted topic"
]
=
{
"id"
:
"non_cohorted_topic"
}
self
.
course
.
discussion_topics
[
"non-cohorted topic"
]
=
{
"id"
:
"non_cohorted_topic"
}
self
.
store
.
update_item
(
self
.
course
,
self
.
user
.
id
)
self
.
store
.
update_item
(
self
.
course
,
self
.
user
.
id
)
...
...
lms/djangoapps/django_comment_client/utils.py
View file @
4655b914
...
@@ -452,6 +452,7 @@ def add_courseware_context(content_list, course, user, id_map=None):
...
@@ -452,6 +452,7 @@ def add_courseware_context(content_list, course, user, id_map=None):
id_map
=
get_discussion_id_map
(
course
,
user
)
id_map
=
get_discussion_id_map
(
course
,
user
)
for
content
in
content_list
:
for
content
in
content_list
:
print
content
commentable_id
=
content
[
'commentable_id'
]
commentable_id
=
content
[
'commentable_id'
]
if
commentable_id
in
id_map
:
if
commentable_id
in
id_map
:
location
=
id_map
[
commentable_id
][
"location"
]
.
to_deprecated_string
()
location
=
id_map
[
commentable_id
][
"location"
]
.
to_deprecated_string
()
...
...
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