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
6114cf05
Commit
6114cf05
authored
Oct 06, 2014
by
Andy Armstrong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Don't show cohort information when disabled
TNL-552
parent
4fc34ddd
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
45 additions
and
8 deletions
+45
-8
common/test/acceptance/tests/discussion/helpers.py
+14
-1
common/test/acceptance/tests/discussion/test_cohorts.py
+17
-1
lms/djangoapps/django_comment_client/utils.py
+14
-6
No files found.
common/test/acceptance/tests/discussion/helpers.py
View file @
6114cf05
...
@@ -30,6 +30,7 @@ class BaseDiscussionMixin(object):
...
@@ -30,6 +30,7 @@ class BaseDiscussionMixin(object):
thread_fixture
.
addResponse
(
Response
(
id
=
str
(
i
),
body
=
str
(
i
)))
thread_fixture
.
addResponse
(
Response
(
id
=
str
(
i
),
body
=
str
(
i
)))
thread_fixture
.
push
()
thread_fixture
.
push
()
self
.
setup_thread_page
(
thread_id
)
self
.
setup_thread_page
(
thread_id
)
return
thread_id
class
CohortTestMixin
(
object
):
class
CohortTestMixin
(
object
):
...
@@ -46,7 +47,19 @@ class CohortTestMixin(object):
...
@@ -46,7 +47,19 @@ class CohortTestMixin(object):
u"cohort_config"
:
{
u"cohort_config"
:
{
"auto_cohort_groups"
:
auto_cohort_groups
or
[],
"auto_cohort_groups"
:
auto_cohort_groups
or
[],
"cohorted_discussions"
:
[],
"cohorted_discussions"
:
[],
"cohorted"
:
True
"cohorted"
:
True
,
},
},
})
def
disable_cohorting
(
self
,
course_fixture
):
"""
Disables cohorting for the current course fixture.
"""
course_fixture
.
_update_xblock
(
course_fixture
.
_course_location
,
{
"metadata"
:
{
u"cohort_config"
:
{
"cohorted"
:
False
},
},
},
},
})
})
...
...
common/test/acceptance/tests/discussion/test_cohorts.py
View file @
6114cf05
...
@@ -45,12 +45,17 @@ class CohortedDiscussionTestMixin(BaseDiscussionMixin, CohortTestMixin):
...
@@ -45,12 +45,17 @@ class CohortedDiscussionTestMixin(BaseDiscussionMixin, CohortTestMixin):
def
test_cohort_visibility_label
(
self
):
def
test_cohort_visibility_label
(
self
):
# Must be moderator to view content in a cohort other than your own
# Must be moderator to view content in a cohort other than your own
AutoAuthPage
(
self
.
browser
,
course_id
=
self
.
course_id
,
roles
=
"Moderator"
)
.
visit
()
AutoAuthPage
(
self
.
browser
,
course_id
=
self
.
course_id
,
roles
=
"Moderator"
)
.
visit
()
self
.
setup_thread
(
1
,
group_id
=
self
.
cohort_1_id
)
self
.
thread_id
=
self
.
setup_thread
(
1
,
group_id
=
self
.
cohort_1_id
)
self
.
assertEquals
(
self
.
assertEquals
(
self
.
thread_page
.
get_group_visibility_label
(),
self
.
thread_page
.
get_group_visibility_label
(),
"This post is visible only to {}."
.
format
(
self
.
cohort_1_name
)
"This post is visible only to {}."
.
format
(
self
.
cohort_1_name
)
)
)
# Disable cohorts and verify that the post now shows as visible to everyone.
self
.
disable_cohorting
(
self
.
course_fixture
)
self
.
refresh_thread_page
(
self
.
thread_id
)
self
.
assertEquals
(
self
.
thread_page
.
get_group_visibility_label
(),
"This post is visible to everyone."
)
class
DiscussionTabSingleThreadTest
(
UniqueCourseTest
):
class
DiscussionTabSingleThreadTest
(
UniqueCourseTest
):
"""
"""
...
@@ -68,6 +73,10 @@ class DiscussionTabSingleThreadTest(UniqueCourseTest):
...
@@ -68,6 +73,10 @@ class DiscussionTabSingleThreadTest(UniqueCourseTest):
self
.
thread_page
=
DiscussionTabSingleThreadPage
(
self
.
browser
,
self
.
course_id
,
thread_id
)
# pylint:disable=W0201
self
.
thread_page
=
DiscussionTabSingleThreadPage
(
self
.
browser
,
self
.
course_id
,
thread_id
)
# pylint:disable=W0201
self
.
thread_page
.
visit
()
self
.
thread_page
.
visit
()
def
refresh_thread_page
(
self
,
thread_id
):
self
.
browser
.
refresh
()
self
.
thread_page
.
wait_for_page
()
@attr
(
'shard_1'
)
@attr
(
'shard_1'
)
class
CohortedDiscussionTabSingleThreadTest
(
DiscussionTabSingleThreadTest
,
CohortedDiscussionTestMixin
):
class
CohortedDiscussionTabSingleThreadTest
(
DiscussionTabSingleThreadTest
,
CohortedDiscussionTestMixin
):
...
@@ -113,12 +122,19 @@ class InlineDiscussionTest(UniqueCourseTest):
...
@@ -113,12 +122,19 @@ class InlineDiscussionTest(UniqueCourseTest):
def
setup_thread_page
(
self
,
thread_id
):
def
setup_thread_page
(
self
,
thread_id
):
CoursewarePage
(
self
.
browser
,
self
.
course_id
)
.
visit
()
CoursewarePage
(
self
.
browser
,
self
.
course_id
)
.
visit
()
self
.
show_thread
(
thread_id
)
def
show_thread
(
self
,
thread_id
):
discussion_page
=
InlineDiscussionPage
(
self
.
browser
,
self
.
discussion_id
)
discussion_page
=
InlineDiscussionPage
(
self
.
browser
,
self
.
discussion_id
)
discussion_page
.
expand_discussion
()
discussion_page
.
expand_discussion
()
self
.
assertEqual
(
discussion_page
.
get_num_displayed_threads
(),
1
)
self
.
assertEqual
(
discussion_page
.
get_num_displayed_threads
(),
1
)
self
.
thread_page
=
InlineDiscussionThreadPage
(
self
.
browser
,
thread_id
)
# pylint:disable=W0201
self
.
thread_page
=
InlineDiscussionThreadPage
(
self
.
browser
,
thread_id
)
# pylint:disable=W0201
self
.
thread_page
.
expand
()
self
.
thread_page
.
expand
()
def
refresh_thread_page
(
self
,
thread_id
):
self
.
browser
.
refresh
()
self
.
show_thread
(
thread_id
)
@attr
(
'shard_1'
)
@attr
(
'shard_1'
)
class
CohortedInlineDiscussionTest
(
InlineDiscussionTest
,
CohortedDiscussionTestMixin
):
class
CohortedInlineDiscussionTest
(
InlineDiscussionTest
,
CohortedDiscussionTestMixin
):
...
...
lms/djangoapps/django_comment_client/utils.py
View file @
6114cf05
import
json
import
pytz
import
pytz
from
collections
import
defaultdict
from
collections
import
defaultdict
import
logging
import
logging
...
@@ -8,6 +9,8 @@ from django.core.urlresolvers import reverse
...
@@ -8,6 +9,8 @@ from django.core.urlresolvers import reverse
from
django.db
import
connection
from
django.db
import
connection
from
django.http
import
HttpResponse
from
django.http
import
HttpResponse
from
django.utils
import
simplejson
from
django.utils
import
simplejson
from
django.utils.timezone
import
UTC
from
django_comment_common.models
import
Role
,
FORUM_ROLE_STUDENT
from
django_comment_common.models
import
Role
,
FORUM_ROLE_STUDENT
from
django_comment_client.permissions
import
check_permissions_by_view
,
cached_has_permission
from
django_comment_client.permissions
import
check_permissions_by_view
,
cached_has_permission
...
@@ -16,11 +19,10 @@ import pystache_custom as pystache
...
@@ -16,11 +19,10 @@ import pystache_custom as pystache
from
course_groups.cohorts
import
get_cohort_by_id
,
get_cohort_id
,
is_commentable_cohorted
from
course_groups.cohorts
import
get_cohort_by_id
,
get_cohort_id
,
is_commentable_cohorted
from
course_groups.models
import
CourseUserGroup
from
course_groups.models
import
CourseUserGroup
from
xmodule.modulestore.django
import
modulestore
from
courseware.courses
import
get_course_by_id
from
django.utils.timezone
import
UTC
from
opaque_keys.edx.locations
import
i4xEncoder
from
opaque_keys.edx.locations
import
i4xEncoder
from
opaque_keys.edx.keys
import
CourseKey
from
opaque_keys.edx.keys
import
CourseKey
import
json
from
xmodule.modulestore.django
import
modulestore
log
=
logging
.
getLogger
(
__name__
)
log
=
logging
.
getLogger
(
__name__
)
...
@@ -393,6 +395,8 @@ def prepare_content(content, course_key, is_staff=False):
...
@@ -393,6 +395,8 @@ def prepare_content(content, course_key, is_staff=False):
@TODO: not all response pre-processing steps are currently integrated into
@TODO: not all response pre-processing steps are currently integrated into
this function.
this function.
"""
"""
course
=
get_course_by_id
(
course_key
)
fields
=
[
fields
=
[
'id'
,
'title'
,
'body'
,
'course_id'
,
'anonymous'
,
'anonymous_to_peers'
,
'id'
,
'title'
,
'body'
,
'course_id'
,
'anonymous'
,
'anonymous_to_peers'
,
'endorsed'
,
'parent_id'
,
'thread_id'
,
'votes'
,
'closed'
,
'created_at'
,
'endorsed'
,
'parent_id'
,
'thread_id'
,
'votes'
,
'closed'
,
'created_at'
,
...
@@ -438,9 +442,13 @@ def prepare_content(content, course_key, is_staff=False):
...
@@ -438,9 +442,13 @@ def prepare_content(content, course_key, is_staff=False):
]
]
content
[
child_content_key
]
=
children
content
[
child_content_key
]
=
children
# Augment the specified thread info to include the group name if a group id is present.
if
course
.
is_cohorted
:
if
content
.
get
(
'group_id'
)
is
not
None
:
# Augment the specified thread info to include the group name if a group id is present.
content
[
'group_name'
]
=
get_cohort_by_id
(
course_key
,
content
.
get
(
'group_id'
))
.
name
if
content
.
get
(
'group_id'
)
is
not
None
:
content
[
'group_name'
]
=
get_cohort_by_id
(
course_key
,
content
.
get
(
'group_id'
))
.
name
else
:
# Remove any cohort information that might remain if the course had previously been cohorted.
content
.
pop
(
'group_id'
,
None
)
return
content
return
content
...
...
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