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
121078eb
Commit
121078eb
authored
Apr 05, 2017
by
cahrens
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Change default value for "always cohort".
TNL-6815
parent
15ab2b6b
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
106 additions
and
116 deletions
+106
-116
common/lib/xmodule/xmodule/course_module.py
+8
-5
common/test/acceptance/pages/lms/instructor_dashboard.py
+4
-4
common/test/acceptance/tests/discussion/test_cohort_management.py
+22
-52
lms/djangoapps/discussion_api/tests/test_api.py
+24
-30
lms/djangoapps/django_comment_client/tests/test_utils.py
+16
-15
lms/static/js/groups/models/course_cohort_settings.js
+1
-1
lms/static/js/spec/groups/views/cohorts_spec.js
+1
-1
openedx/core/djangoapps/course_groups/migrations/0002_change_inline_default_cohort_value.py
+19
-0
openedx/core/djangoapps/course_groups/models.py
+4
-1
openedx/core/djangoapps/course_groups/tests/helpers.py
+2
-2
openedx/core/djangoapps/course_groups/tests/test_cohorts.py
+3
-3
openedx/core/djangoapps/course_groups/tests/test_views.py
+2
-2
No files found.
common/lib/xmodule/xmodule/course_module.py
View file @
121078eb
...
@@ -1157,16 +1157,19 @@ class CourseDescriptor(CourseFields, SequenceDescriptor, LicenseMixin):
...
@@ -1157,16 +1157,19 @@ class CourseDescriptor(CourseFields, SequenceDescriptor, LicenseMixin):
def
always_cohort_inline_discussions
(
self
):
def
always_cohort_inline_discussions
(
self
):
"""
"""
This allow to change the default behavior of inline discussions cohorting. By
This allow to change the default behavior of inline discussions cohorting. By
setting this to False, all inline discussions are non-cohorted unless their
setting this to 'True', all inline discussions are cohorted. The default value is
ids are specified in cohorted_discussions.
now `False`, meaning that inline discussions are not cohorted unless their discussion IDs
are specifically listed as cohorted.
Note: No longer used. See openedx.core.djangoapps.course_groups.models.CourseCohortSettings.
Note: No longer used except to get the initial value when cohorts are first enabled on a course
(and for migrating old courses). See openedx.core.djangoapps.course_groups.models.CourseCohortSettings.
"""
"""
config
=
self
.
cohort_config
config
=
self
.
cohort_config
if
config
is
None
:
if
config
is
None
:
return
True
# This value sets the default for newly created courses.
return
False
return
bool
(
config
.
get
(
"always_cohort_inline_discussions"
,
Tru
e
))
return
bool
(
config
.
get
(
"always_cohort_inline_discussions"
,
Fals
e
))
@property
@property
def
is_newish
(
self
):
def
is_newish
(
self
):
...
...
common/test/acceptance/pages/lms/instructor_dashboard.py
View file @
121078eb
...
@@ -686,15 +686,15 @@ class CohortManagementSection(PageObject):
...
@@ -686,15 +686,15 @@ class CohortManagementSection(PageObject):
def
always_inline_discussion_selected
(
self
):
def
always_inline_discussion_selected
(
self
):
"""
"""
Returns t
he checked always_cohort_inline_discussions radio button
.
Returns t
rue if always_cohort_inline_discussions radio button is selected
.
"""
"""
return
self
.
q
(
css
=
self
.
_bounded_selector
(
".check-all-inline-discussions:checked"
))
return
len
(
self
.
q
(
css
=
self
.
_bounded_selector
(
".check-all-inline-discussions:checked"
)))
>
0
def
cohort_some_inline_discussion_selected
(
self
):
def
cohort_some_inline_discussion_selected
(
self
):
"""
"""
Returns t
he checked some_cohort_inline_discussions radio button
.
Returns t
rue if some_cohort_inline_discussions radio button is selected
.
"""
"""
return
self
.
q
(
css
=
self
.
_bounded_selector
(
".check-cohort-inline-discussions:checked"
))
return
len
(
self
.
q
(
css
=
self
.
_bounded_selector
(
".check-cohort-inline-discussions:checked"
)))
>
0
def
select_cohort_some_inline_discussion
(
self
):
def
select_cohort_some_inline_discussion
(
self
):
"""
"""
...
...
common/test/acceptance/tests/discussion/test_cohort_management.py
View file @
121078eb
...
@@ -824,36 +824,45 @@ class CohortDiscussionTopicsTest(UniqueCourseTest, CohortTestMixin):
...
@@ -824,36 +824,45 @@ class CohortDiscussionTopicsTest(UniqueCourseTest, CohortTestMixin):
Scenario: Select the always_cohort_inline_topics radio button
Scenario: Select the always_cohort_inline_topics radio button
Given I have a course with a cohort defined,
Given I have a course with a cohort defined,
And a inline discussion topic with disabled Save button.
And a
n
inline discussion topic with disabled Save button.
When I click on always_cohort_inline_topics
When I click on always_cohort_inline_topics
Then I see enabled save button
Then I see enabled save button
And I see disabled inline discussion topics
And I see disabled inline discussion topics
When I reload the page
When I save the change
Then I see the option enabled
And I reload the page
Then I see the always_cohort_inline_topics option enabled
"""
"""
self
.
cohort_discussion_topics_are_visible
()
self
.
cohort_discussion_topics_are_visible
()
# enable always inline discussion topics
.
# enable always inline discussion topics
and save the change
self
.
cohort_management_page
.
select_always_inline_discussion
()
self
.
cohort_management_page
.
select_always_inline_discussion
()
self
.
assertFalse
(
self
.
cohort_management_page
.
is_save_button_disabled
(
self
.
inline_key
))
self
.
assertTrue
(
self
.
cohort_management_page
.
inline_discussion_topics_disabled
())
self
.
assertTrue
(
self
.
cohort_management_page
.
inline_discussion_topics_disabled
())
self
.
cohort_management_page
.
save_discussion_topics
(
key
=
self
.
inline_key
)
self
.
reload_page
()
self
.
reload_page
()
self
.
assert
IsNotNon
e
(
self
.
cohort_management_page
.
always_inline_discussion_selected
())
self
.
assert
Tru
e
(
self
.
cohort_management_page
.
always_inline_discussion_selected
())
def
test_cohort_some_inline_topics_enabled
(
self
):
def
test_cohort_some_inline_topics_enabled
(
self
):
"""
"""
Scenario: Select the cohort_some_inline_topics radio button
Scenario: Select the cohort_some_inline_topics radio button
Given I have a course with a cohort defined
,
Given I have a course with a cohort defined
and always_cohort_inline_topics set to True
And a inline discussion topic with disabled Save button.
And a
n
inline discussion topic with disabled Save button.
When I click on cohort_some_inline_topics
When I click on cohort_some_inline_topics
Then I see enabled save button
Then I see enabled save button
And I see enabled inline discussion topics
And I see enabled inline discussion topics
When I reload the page
When I save the change
Then I see the option enabled
And I reload the page
Then I see the cohort_some_inline_topics option enabled
"""
"""
self
.
cohort_discussion_topics_are_visible
()
self
.
cohort_discussion_topics_are_visible
()
# By default always inline discussion topics is False. Enable it (and reload the page).
self
.
assertFalse
(
self
.
cohort_management_page
.
always_inline_discussion_selected
())
self
.
cohort_management_page
.
select_always_inline_discussion
()
self
.
cohort_management_page
.
save_discussion_topics
(
key
=
self
.
inline_key
)
self
.
reload_page
()
self
.
assertFalse
(
self
.
cohort_management_page
.
cohort_some_inline_discussion_selected
())
# enable some inline discussion topic radio button.
# enable some inline discussion topic radio button.
self
.
cohort_management_page
.
select_cohort_some_inline_discussion
()
self
.
cohort_management_page
.
select_cohort_some_inline_discussion
()
...
@@ -861,18 +870,17 @@ class CohortDiscussionTopicsTest(UniqueCourseTest, CohortTestMixin):
...
@@ -861,18 +870,17 @@ class CohortDiscussionTopicsTest(UniqueCourseTest, CohortTestMixin):
self
.
assertFalse
(
self
.
cohort_management_page
.
is_save_button_disabled
(
self
.
inline_key
))
self
.
assertFalse
(
self
.
cohort_management_page
.
is_save_button_disabled
(
self
.
inline_key
))
# I see that inline discussion topics are enabled
# I see that inline discussion topics are enabled
self
.
assertFalse
(
self
.
cohort_management_page
.
inline_discussion_topics_disabled
())
self
.
assertFalse
(
self
.
cohort_management_page
.
inline_discussion_topics_disabled
())
self
.
cohort_management_page
.
save_discussion_topics
(
key
=
self
.
inline_key
)
self
.
reload_page
()
self
.
reload_page
()
self
.
assert
IsNotNon
e
(
self
.
cohort_management_page
.
cohort_some_inline_discussion_selected
())
self
.
assert
Tru
e
(
self
.
cohort_management_page
.
cohort_some_inline_discussion_selected
())
def
test_cohort_inline_discussion_topic
(
self
):
def
test_cohort_inline_discussion_topic
(
self
):
"""
"""
Scenario: cohort inline discussion topic.
Scenario: cohort inline discussion topic.
Given I have a course with a cohort defined,
Given I have a course with a cohort defined,
And a inline discussion topic with disabled Save button.
And a inline discussion topic with disabled Save button
When I click on cohort_some_inline_discussion_topics
Then I see enabled saved button
And When I click on inline discussion topic
And When I click on inline discussion topic
And I see enabled save button
And I see enabled save button
And When i click save button
And When i click save button
...
@@ -882,9 +890,6 @@ class CohortDiscussionTopicsTest(UniqueCourseTest, CohortTestMixin):
...
@@ -882,9 +890,6 @@ class CohortDiscussionTopicsTest(UniqueCourseTest, CohortTestMixin):
"""
"""
self
.
cohort_discussion_topics_are_visible
()
self
.
cohort_discussion_topics_are_visible
()
# select some inline discussion topics radio button.
self
.
cohort_management_page
.
select_cohort_some_inline_discussion
()
cohorted_topics_before
=
self
.
cohort_management_page
.
get_cohorted_topics_count
(
self
.
inline_key
)
cohorted_topics_before
=
self
.
cohort_management_page
.
get_cohorted_topics_count
(
self
.
inline_key
)
# check the discussion topic.
# check the discussion topic.
self
.
cohort_management_page
.
select_discussion_topic
(
self
.
inline_key
)
self
.
cohort_management_page
.
select_discussion_topic
(
self
.
inline_key
)
...
@@ -912,9 +917,6 @@ class CohortDiscussionTopicsTest(UniqueCourseTest, CohortTestMixin):
...
@@ -912,9 +917,6 @@ class CohortDiscussionTopicsTest(UniqueCourseTest, CohortTestMixin):
"""
"""
self
.
cohort_discussion_topics_are_visible
()
self
.
cohort_discussion_topics_are_visible
()
# enable some inline discussion topics.
self
.
cohort_management_page
.
select_cohort_some_inline_discussion
()
# category should not be selected.
# category should not be selected.
self
.
assertFalse
(
self
.
cohort_management_page
.
is_category_selected
())
self
.
assertFalse
(
self
.
cohort_management_page
.
is_category_selected
())
...
@@ -936,9 +938,6 @@ class CohortDiscussionTopicsTest(UniqueCourseTest, CohortTestMixin):
...
@@ -936,9 +938,6 @@ class CohortDiscussionTopicsTest(UniqueCourseTest, CohortTestMixin):
"""
"""
self
.
cohort_discussion_topics_are_visible
()
self
.
cohort_discussion_topics_are_visible
()
# enable some inline discussion topics.
self
.
cohort_management_page
.
select_cohort_some_inline_discussion
()
# category should not be selected.
# category should not be selected.
self
.
assertFalse
(
self
.
cohort_management_page
.
is_category_selected
())
self
.
assertFalse
(
self
.
cohort_management_page
.
is_category_selected
())
...
@@ -954,35 +953,6 @@ class CohortDiscussionTopicsTest(UniqueCourseTest, CohortTestMixin):
...
@@ -954,35 +953,6 @@ class CohortDiscussionTopicsTest(UniqueCourseTest, CohortTestMixin):
# category should not be selected.
# category should not be selected.
self
.
assertFalse
(
self
.
cohort_management_page
.
is_category_selected
())
self
.
assertFalse
(
self
.
cohort_management_page
.
is_category_selected
())
def
test_verify_that_correct_subset_of_category_being_selected_after_save
(
self
):
"""
Scenario: Category should be selected on selecting final child.
Given I have a course with a cohort defined,
And a inline discussion with disabled Save button.
When I click on child topics
Then I see enabled saved button
When I select subset of category
And I click on save button
Then I see success message with
same sub-category being selected
"""
self
.
cohort_discussion_topics_are_visible
()
# enable some inline discussion topics.
self
.
cohort_management_page
.
select_cohort_some_inline_discussion
()
# category should not be selected.
self
.
assertFalse
(
self
.
cohort_management_page
.
is_category_selected
())
cohorted_topics_after
=
self
.
cohort_management_page
.
get_cohorted_topics_count
(
self
.
inline_key
)
# verifies that changes saved successfully.
self
.
save_and_verify_discussion_topics
(
key
=
self
.
inline_key
)
# verify changes after reload.
self
.
verify_discussion_topics_after_reload
(
self
.
inline_key
,
cohorted_topics_after
)
@attr
(
shard
=
6
)
@attr
(
shard
=
6
)
class
CohortContentGroupAssociationTest
(
UniqueCourseTest
,
CohortTestMixin
):
class
CohortContentGroupAssociationTest
(
UniqueCourseTest
,
CohortTestMixin
):
...
...
lms/djangoapps/discussion_api/tests/test_api.py
View file @
121078eb
...
@@ -84,6 +84,24 @@ def _discussion_disabled_course_for(user):
...
@@ -84,6 +84,24 @@ def _discussion_disabled_course_for(user):
return
course_with_disabled_forums
return
course_with_disabled_forums
def
_create_course_and_cohort_with_user_role
(
course_is_cohorted
,
user
,
role_name
):
"""
Creates a course with the value of `course_is_cohorted`, plus `always_cohort_inline_discussions`
set to True (which is no longer the default value). Then 1) enrolls the user in that course,
2) creates a cohort that the user is placed in, and 3) adds the user to the given role.
Returns: a tuple of the created course and the created cohort
"""
cohort_course
=
CourseFactory
.
create
(
cohort_config
=
{
"cohorted"
:
course_is_cohorted
,
"always_cohort_inline_discussions"
:
True
}
)
CourseEnrollmentFactory
.
create
(
user
=
user
,
course_id
=
cohort_course
.
id
)
cohort
=
CohortFactory
.
create
(
course_id
=
cohort_course
.
id
,
users
=
[
user
])
role
=
Role
.
objects
.
create
(
name
=
role_name
,
course_id
=
cohort_course
.
id
)
role
.
users
=
[
user
]
return
[
cohort_course
,
cohort
]
@attr
(
shard
=
2
)
@attr
(
shard
=
2
)
@mock.patch.dict
(
"django.conf.settings.FEATURES"
,
{
"ENABLE_DISCUSSION_SERVICE"
:
True
})
@mock.patch.dict
(
"django.conf.settings.FEATURES"
,
{
"ENABLE_DISCUSSION_SERVICE"
:
True
})
class
GetCourseTest
(
ForumsEnableMixin
,
UrlResetMixin
,
SharedModuleStoreTestCase
):
class
GetCourseTest
(
ForumsEnableMixin
,
UrlResetMixin
,
SharedModuleStoreTestCase
):
...
@@ -1857,11 +1875,7 @@ class CreateCommentTest(
...
@@ -1857,11 +1875,7 @@ class CreateCommentTest(
)
)
@ddt.unpack
@ddt.unpack
def
test_group_access
(
self
,
role_name
,
course_is_cohorted
,
thread_group_state
):
def
test_group_access
(
self
,
role_name
,
course_is_cohorted
,
thread_group_state
):
cohort_course
=
CourseFactory
.
create
(
cohort_config
=
{
"cohorted"
:
course_is_cohorted
})
cohort_course
,
cohort
=
_create_course_and_cohort_with_user_role
(
course_is_cohorted
,
self
.
user
,
role_name
)
CourseEnrollmentFactory
.
create
(
user
=
self
.
user
,
course_id
=
cohort_course
.
id
)
cohort
=
CohortFactory
.
create
(
course_id
=
cohort_course
.
id
,
users
=
[
self
.
user
])
role
=
Role
.
objects
.
create
(
name
=
role_name
,
course_id
=
cohort_course
.
id
)
role
.
users
=
[
self
.
user
]
self
.
register_get_thread_response
(
make_minimal_cs_thread
({
self
.
register_get_thread_response
(
make_minimal_cs_thread
({
"id"
:
"cohort_thread"
,
"id"
:
"cohort_thread"
,
"course_id"
:
unicode
(
cohort_course
.
id
),
"course_id"
:
unicode
(
cohort_course
.
id
),
...
@@ -2017,11 +2031,7 @@ class UpdateThreadTest(
...
@@ -2017,11 +2031,7 @@ class UpdateThreadTest(
)
)
@ddt.unpack
@ddt.unpack
def
test_group_access
(
self
,
role_name
,
course_is_cohorted
,
thread_group_state
):
def
test_group_access
(
self
,
role_name
,
course_is_cohorted
,
thread_group_state
):
cohort_course
=
CourseFactory
.
create
(
cohort_config
=
{
"cohorted"
:
course_is_cohorted
})
cohort_course
,
cohort
=
_create_course_and_cohort_with_user_role
(
course_is_cohorted
,
self
.
user
,
role_name
)
CourseEnrollmentFactory
.
create
(
user
=
self
.
user
,
course_id
=
cohort_course
.
id
)
cohort
=
CohortFactory
.
create
(
course_id
=
cohort_course
.
id
,
users
=
[
self
.
user
])
role
=
Role
.
objects
.
create
(
name
=
role_name
,
course_id
=
cohort_course
.
id
)
role
.
users
=
[
self
.
user
]
self
.
register_thread
({
self
.
register_thread
({
"course_id"
:
unicode
(
cohort_course
.
id
),
"course_id"
:
unicode
(
cohort_course
.
id
),
"group_id"
:
(
"group_id"
:
(
...
@@ -2419,11 +2429,7 @@ class UpdateCommentTest(
...
@@ -2419,11 +2429,7 @@ class UpdateCommentTest(
)
)
@ddt.unpack
@ddt.unpack
def
test_group_access
(
self
,
role_name
,
course_is_cohorted
,
thread_group_state
):
def
test_group_access
(
self
,
role_name
,
course_is_cohorted
,
thread_group_state
):
cohort_course
=
CourseFactory
.
create
(
cohort_config
=
{
"cohorted"
:
course_is_cohorted
})
cohort_course
,
cohort
=
_create_course_and_cohort_with_user_role
(
course_is_cohorted
,
self
.
user
,
role_name
)
CourseEnrollmentFactory
.
create
(
user
=
self
.
user
,
course_id
=
cohort_course
.
id
)
cohort
=
CohortFactory
.
create
(
course_id
=
cohort_course
.
id
,
users
=
[
self
.
user
])
role
=
Role
.
objects
.
create
(
name
=
role_name
,
course_id
=
cohort_course
.
id
)
role
.
users
=
[
self
.
user
]
self
.
register_get_thread_response
(
make_minimal_cs_thread
())
self
.
register_get_thread_response
(
make_minimal_cs_thread
())
self
.
register_comment
(
self
.
register_comment
(
{
"thread_id"
:
"test_thread"
},
{
"thread_id"
:
"test_thread"
},
...
@@ -2798,11 +2804,7 @@ class DeleteThreadTest(
...
@@ -2798,11 +2804,7 @@ class DeleteThreadTest(
the student role is the author and the thread is not in a cohort,
the student role is the author and the thread is not in a cohort,
the student role is the author and the thread is in the author's cohort.
the student role is the author and the thread is in the author's cohort.
"""
"""
cohort_course
=
CourseFactory
.
create
(
cohort_config
=
{
"cohorted"
:
course_is_cohorted
})
cohort_course
,
cohort
=
_create_course_and_cohort_with_user_role
(
course_is_cohorted
,
self
.
user
,
role_name
)
CourseEnrollmentFactory
.
create
(
user
=
self
.
user
,
course_id
=
cohort_course
.
id
)
cohort
=
CohortFactory
.
create
(
course_id
=
cohort_course
.
id
,
users
=
[
self
.
user
])
role
=
Role
.
objects
.
create
(
name
=
role_name
,
course_id
=
cohort_course
.
id
)
role
.
users
=
[
self
.
user
]
self
.
register_thread
({
self
.
register_thread
({
"course_id"
:
unicode
(
cohort_course
.
id
),
"course_id"
:
unicode
(
cohort_course
.
id
),
"group_id"
:
(
"group_id"
:
(
...
@@ -2955,11 +2957,7 @@ class DeleteCommentTest(
...
@@ -2955,11 +2957,7 @@ class DeleteCommentTest(
the student role is the author and the comment is not in a cohort,
the student role is the author and the comment is not in a cohort,
the student role is the author and the comment is in the author's cohort.
the student role is the author and the comment is in the author's cohort.
"""
"""
cohort_course
=
CourseFactory
.
create
(
cohort_config
=
{
"cohorted"
:
course_is_cohorted
})
cohort_course
,
cohort
=
_create_course_and_cohort_with_user_role
(
course_is_cohorted
,
self
.
user
,
role_name
)
CourseEnrollmentFactory
.
create
(
user
=
self
.
user
,
course_id
=
cohort_course
.
id
)
cohort
=
CohortFactory
.
create
(
course_id
=
cohort_course
.
id
,
users
=
[
self
.
user
])
role
=
Role
.
objects
.
create
(
name
=
role_name
,
course_id
=
cohort_course
.
id
)
role
.
users
=
[
self
.
user
]
self
.
register_comment_and_thread
(
self
.
register_comment_and_thread
(
overrides
=
{
"thread_id"
:
"test_thread"
},
overrides
=
{
"thread_id"
:
"test_thread"
},
thread_overrides
=
{
thread_overrides
=
{
...
@@ -3084,11 +3082,7 @@ class RetrieveThreadTest(
...
@@ -3084,11 +3082,7 @@ class RetrieveThreadTest(
the student role is the author and the thread is not in a cohort,
the student role is the author and the thread is not in a cohort,
the student role is the author and the thread is in the author's cohort.
the student role is the author and the thread is in the author's cohort.
"""
"""
cohort_course
=
CourseFactory
.
create
(
cohort_config
=
{
"cohorted"
:
course_is_cohorted
})
cohort_course
,
cohort
=
_create_course_and_cohort_with_user_role
(
course_is_cohorted
,
self
.
user
,
role_name
)
CourseEnrollmentFactory
.
create
(
user
=
self
.
user
,
course_id
=
cohort_course
.
id
)
cohort
=
CohortFactory
.
create
(
course_id
=
cohort_course
.
id
,
users
=
[
self
.
user
])
role
=
Role
.
objects
.
create
(
name
=
role_name
,
course_id
=
cohort_course
.
id
)
role
.
users
=
[
self
.
user
]
self
.
register_thread
({
self
.
register_thread
({
"course_id"
:
unicode
(
cohort_course
.
id
),
"course_id"
:
unicode
(
cohort_course
.
id
),
"group_id"
:
(
"group_id"
:
(
...
...
lms/djangoapps/django_comment_client/tests/test_utils.py
View file @
121078eb
...
@@ -463,7 +463,7 @@ class CategoryMapTestCase(CategoryMapTestMixin, ModuleStoreTestCase):
...
@@ -463,7 +463,7 @@ class CategoryMapTestCase(CategoryMapTestMixin, ModuleStoreTestCase):
def
test_inline_with_always_cohort_inline_discussion_flag
(
self
):
def
test_inline_with_always_cohort_inline_discussion_flag
(
self
):
self
.
create_discussion
(
"Chapter"
,
"Discussion"
)
self
.
create_discussion
(
"Chapter"
,
"Discussion"
)
set_course_cohort_settings
(
course_key
=
self
.
course
.
id
,
is_cohorted
=
True
)
set_course_cohort_settings
(
course_key
=
self
.
course
.
id
,
is_cohorted
=
True
,
always_cohort_inline_discussions
=
True
)
self
.
assert_category_map_equals
(
self
.
assert_category_map_equals
(
{
{
...
@@ -487,7 +487,7 @@ class CategoryMapTestCase(CategoryMapTestMixin, ModuleStoreTestCase):
...
@@ -487,7 +487,7 @@ class CategoryMapTestCase(CategoryMapTestMixin, ModuleStoreTestCase):
def
test_inline_without_always_cohort_inline_discussion_flag
(
self
):
def
test_inline_without_always_cohort_inline_discussion_flag
(
self
):
self
.
create_discussion
(
"Chapter"
,
"Discussion"
)
self
.
create_discussion
(
"Chapter"
,
"Discussion"
)
set_course_cohort_settings
(
course_key
=
self
.
course
.
id
,
is_cohorted
=
True
,
always_cohort_inline_discussions
=
False
)
set_course_cohort_settings
(
course_key
=
self
.
course
.
id
,
is_cohorted
=
True
)
self
.
assert_category_map_equals
(
self
.
assert_category_map_equals
(
{
{
...
@@ -640,8 +640,8 @@ class CategoryMapTestCase(CategoryMapTestMixin, ModuleStoreTestCase):
...
@@ -640,8 +640,8 @@ class CategoryMapTestCase(CategoryMapTestMixin, ModuleStoreTestCase):
set_course_cohort_settings
(
course_key
=
self
.
course
.
id
,
is_cohorted
=
False
)
set_course_cohort_settings
(
course_key
=
self
.
course
.
id
,
is_cohorted
=
False
)
check_cohorted
(
False
)
check_cohorted
(
False
)
# explicitly enabled cohorting
# explicitly enabled cohorting
with inline discusssions also cohorted.
set_course_cohort_settings
(
course_key
=
self
.
course
.
id
,
is_cohorted
=
True
)
set_course_cohort_settings
(
course_key
=
self
.
course
.
id
,
is_cohorted
=
True
,
always_cohort_inline_discussions
=
True
)
check_cohorted
(
True
)
check_cohorted
(
True
)
def
test_tree_with_duplicate_targets
(
self
):
def
test_tree_with_duplicate_targets
(
self
):
...
@@ -1058,17 +1058,17 @@ class ContentGroupCategoryMapTestCase(CategoryMapTestMixin, ContentGroupTestCase
...
@@ -1058,17 +1058,17 @@ class ContentGroupCategoryMapTestCase(CategoryMapTestMixin, ContentGroupTestCase
'entries'
:
{
'entries'
:
{
'Visible to Alpha'
:
{
'Visible to Alpha'
:
{
'sort_key'
:
None
,
'sort_key'
:
None
,
'is_cohorted'
:
Tru
e
,
'is_cohorted'
:
Fals
e
,
'id'
:
'alpha_group_discussion'
'id'
:
'alpha_group_discussion'
},
},
'Visible to Beta'
:
{
'Visible to Beta'
:
{
'sort_key'
:
None
,
'sort_key'
:
None
,
'is_cohorted'
:
Tru
e
,
'is_cohorted'
:
Fals
e
,
'id'
:
'beta_group_discussion'
'id'
:
'beta_group_discussion'
},
},
'Visible to Everyone'
:
{
'Visible to Everyone'
:
{
'sort_key'
:
None
,
'sort_key'
:
None
,
'is_cohorted'
:
Tru
e
,
'is_cohorted'
:
Fals
e
,
'id'
:
'global_group_discussion'
'id'
:
'global_group_discussion'
}
}
}
}
...
@@ -1103,12 +1103,12 @@ class ContentGroupCategoryMapTestCase(CategoryMapTestMixin, ContentGroupTestCase
...
@@ -1103,12 +1103,12 @@ class ContentGroupCategoryMapTestCase(CategoryMapTestMixin, ContentGroupTestCase
'entries'
:
{
'entries'
:
{
'Visible to Alpha'
:
{
'Visible to Alpha'
:
{
'sort_key'
:
None
,
'sort_key'
:
None
,
'is_cohorted'
:
Tru
e
,
'is_cohorted'
:
Fals
e
,
'id'
:
'alpha_group_discussion'
'id'
:
'alpha_group_discussion'
},
},
'Visible to Everyone'
:
{
'Visible to Everyone'
:
{
'sort_key'
:
None
,
'sort_key'
:
None
,
'is_cohorted'
:
Tru
e
,
'is_cohorted'
:
Fals
e
,
'id'
:
'global_group_discussion'
'id'
:
'global_group_discussion'
}
}
}
}
...
@@ -1143,12 +1143,12 @@ class ContentGroupCategoryMapTestCase(CategoryMapTestMixin, ContentGroupTestCase
...
@@ -1143,12 +1143,12 @@ class ContentGroupCategoryMapTestCase(CategoryMapTestMixin, ContentGroupTestCase
'entries'
:
{
'entries'
:
{
'Visible to Beta'
:
{
'Visible to Beta'
:
{
'sort_key'
:
None
,
'sort_key'
:
None
,
'is_cohorted'
:
Tru
e
,
'is_cohorted'
:
Fals
e
,
'id'
:
'beta_group_discussion'
'id'
:
'beta_group_discussion'
},
},
'Visible to Everyone'
:
{
'Visible to Everyone'
:
{
'sort_key'
:
None
,
'sort_key'
:
None
,
'is_cohorted'
:
Tru
e
,
'is_cohorted'
:
Fals
e
,
'id'
:
'global_group_discussion'
'id'
:
'global_group_discussion'
}
}
}
}
...
@@ -1182,7 +1182,7 @@ class ContentGroupCategoryMapTestCase(CategoryMapTestMixin, ContentGroupTestCase
...
@@ -1182,7 +1182,7 @@ class ContentGroupCategoryMapTestCase(CategoryMapTestMixin, ContentGroupTestCase
'entries'
:
{
'entries'
:
{
'Visible to Everyone'
:
{
'Visible to Everyone'
:
{
'sort_key'
:
None
,
'sort_key'
:
None
,
'is_cohorted'
:
Tru
e
,
'is_cohorted'
:
Fals
e
,
'id'
:
'global_group_discussion'
'id'
:
'global_group_discussion'
}
}
}
}
...
@@ -1333,9 +1333,9 @@ class IsCommentableCohortedTestCase(ModuleStoreTestCase):
...
@@ -1333,9 +1333,9 @@ class IsCommentableCohortedTestCase(ModuleStoreTestCase):
discussion_topics
=
[
"General"
,
"Feedback"
],
discussion_topics
=
[
"General"
,
"Feedback"
],
cohorted_discussions
=
[
"Feedback"
,
"random_inline"
]
cohorted_discussions
=
[
"Feedback"
,
"random_inline"
]
)
)
self
.
assert
Tru
e
(
self
.
assert
Fals
e
(
utils
.
is_commentable_cohorted
(
course
.
id
,
to_id
(
"random"
)),
utils
.
is_commentable_cohorted
(
course
.
id
,
to_id
(
"random"
)),
"By default, Non-top-level discussion
is always cohorted in
cohorted courses."
"By default, Non-top-level discussion
s are not cohorted in a
cohorted courses."
)
)
# if always_cohort_inline_discussions is set to False, non-top-level discussion are always
# if always_cohort_inline_discussions is set to False, non-top-level discussion are always
...
@@ -1365,10 +1365,11 @@ class IsCommentableCohortedTestCase(ModuleStoreTestCase):
...
@@ -1365,10 +1365,11 @@ class IsCommentableCohortedTestCase(ModuleStoreTestCase):
course
=
modulestore
()
.
get_course
(
self
.
toy_course_key
)
course
=
modulestore
()
.
get_course
(
self
.
toy_course_key
)
self
.
assertFalse
(
cohorts
.
is_course_cohorted
(
course
.
id
))
self
.
assertFalse
(
cohorts
.
is_course_cohorted
(
course
.
id
))
config_course_cohorts
(
course
,
is_cohorted
=
True
)
config_course_cohorts
(
course
,
is_cohorted
=
True
,
always_cohort_inline_discussions
=
True
)
team
=
CourseTeamFactory
(
course_id
=
course
.
id
)
team
=
CourseTeamFactory
(
course_id
=
course
.
id
)
# Verify that team discussions are not cohorted, but other discussions are
# Verify that team discussions are not cohorted, but other discussions are
# if "always cohort inline discussions" is set to true.
self
.
assertFalse
(
utils
.
is_commentable_cohorted
(
course
.
id
,
team
.
discussion_topic_id
))
self
.
assertFalse
(
utils
.
is_commentable_cohorted
(
course
.
id
,
team
.
discussion_topic_id
))
self
.
assertTrue
(
utils
.
is_commentable_cohorted
(
course
.
id
,
"random"
))
self
.
assertTrue
(
utils
.
is_commentable_cohorted
(
course
.
id
,
"random"
))
...
...
lms/static/js/groups/models/course_cohort_settings.js
View file @
121078eb
...
@@ -7,7 +7,7 @@
...
@@ -7,7 +7,7 @@
is_cohorted
:
false
,
is_cohorted
:
false
,
cohorted_inline_discussions
:
[],
cohorted_inline_discussions
:
[],
cohorted_course_wide_discussions
:
[],
cohorted_course_wide_discussions
:
[],
always_cohort_inline_discussions
:
tru
e
always_cohort_inline_discussions
:
fals
e
}
}
});
});
return
CourseCohortSettingsModel
;
return
CourseCohortSettingsModel
;
...
...
lms/static/js/spec/groups/views/cohorts_spec.js
View file @
121078eb
...
@@ -76,7 +76,7 @@ define(['backbone', 'jquery', 'edx-ui-toolkit/js/utils/spec-helpers/ajax-helpers
...
@@ -76,7 +76,7 @@ define(['backbone', 'jquery', 'edx-ui-toolkit/js/utils/spec-helpers/ajax-helpers
is_cohorted
:
isCohorted
||
false
,
is_cohorted
:
isCohorted
||
false
,
cohorted_inline_discussions
:
cohortedInlineDiscussions
||
[],
cohorted_inline_discussions
:
cohortedInlineDiscussions
||
[],
cohorted_course_wide_discussions
:
cohortedCourseWideDiscussions
||
[],
cohorted_course_wide_discussions
:
cohortedCourseWideDiscussions
||
[],
always_cohort_inline_discussions
:
alwaysCohortInlineDiscussions
||
tru
e
always_cohort_inline_discussions
:
alwaysCohortInlineDiscussions
||
fals
e
};
};
};
};
...
...
openedx/core/djangoapps/course_groups/migrations/0002_change_inline_default_cohort_value.py
0 → 100644
View file @
121078eb
# -*- coding: utf-8 -*-
from
__future__
import
unicode_literals
from
django.db
import
migrations
,
models
class
Migration
(
migrations
.
Migration
):
dependencies
=
[
(
'course_groups'
,
'0001_initial'
),
]
operations
=
[
migrations
.
AlterField
(
model_name
=
'coursecohortssettings'
,
name
=
'always_cohort_inline_discussions'
,
field
=
models
.
BooleanField
(
default
=
False
),
),
]
openedx/core/djangoapps/course_groups/models.py
View file @
121078eb
...
@@ -176,8 +176,11 @@ class CourseCohortsSettings(models.Model):
...
@@ -176,8 +176,11 @@ class CourseCohortsSettings(models.Model):
_cohorted_discussions
=
models
.
TextField
(
db_column
=
'cohorted_discussions'
,
null
=
True
,
blank
=
True
)
# JSON list
_cohorted_discussions
=
models
.
TextField
(
db_column
=
'cohorted_discussions'
,
null
=
True
,
blank
=
True
)
# JSON list
# Note that although a default value is specified here for always_cohort_inline_discussions (False),
# in reality the default value at the time that cohorting is enabled for a course comes from
# course_module.always_cohort_inline_discussions (via `migrate_cohort_settings`).
# pylint: disable=invalid-name
# pylint: disable=invalid-name
always_cohort_inline_discussions
=
models
.
BooleanField
(
default
=
Tru
e
)
always_cohort_inline_discussions
=
models
.
BooleanField
(
default
=
Fals
e
)
@property
@property
def
cohorted_discussions
(
self
):
def
cohorted_discussions
(
self
):
...
...
openedx/core/djangoapps/course_groups/tests/helpers.py
View file @
121078eb
...
@@ -58,7 +58,7 @@ class CourseCohortSettingsFactory(DjangoModelFactory):
...
@@ -58,7 +58,7 @@ class CourseCohortSettingsFactory(DjangoModelFactory):
course_id
=
SlashSeparatedCourseKey
(
"dummy"
,
"dummy"
,
"dummy"
)
course_id
=
SlashSeparatedCourseKey
(
"dummy"
,
"dummy"
,
"dummy"
)
cohorted_discussions
=
json
.
dumps
([])
cohorted_discussions
=
json
.
dumps
([])
# pylint: disable=invalid-name
# pylint: disable=invalid-name
always_cohort_inline_discussions
=
Tru
e
always_cohort_inline_discussions
=
Fals
e
def
topic_name_to_id
(
course
,
name
):
def
topic_name_to_id
(
course
,
name
):
...
@@ -141,7 +141,7 @@ def config_course_cohorts(
...
@@ -141,7 +141,7 @@ def config_course_cohorts(
manual_cohorts
=
[],
manual_cohorts
=
[],
discussion_topics
=
[],
discussion_topics
=
[],
cohorted_discussions
=
[],
cohorted_discussions
=
[],
always_cohort_inline_discussions
=
Tru
e
always_cohort_inline_discussions
=
Fals
e
):
):
"""
"""
Set discussions and configure cohorts for a course.
Set discussions and configure cohorts for a course.
...
...
openedx/core/djangoapps/course_groups/tests/test_cohorts.py
View file @
121078eb
...
@@ -681,7 +681,7 @@ class TestCohorts(ModuleStoreTestCase):
...
@@ -681,7 +681,7 @@ class TestCohorts(ModuleStoreTestCase):
self
.
assertFalse
(
course_cohort_settings
.
is_cohorted
)
self
.
assertFalse
(
course_cohort_settings
.
is_cohorted
)
self
.
assertEqual
(
course_cohort_settings
.
cohorted_discussions
,
[])
self
.
assertEqual
(
course_cohort_settings
.
cohorted_discussions
,
[])
self
.
assert
Tru
e
(
course_cohort_settings
.
always_cohort_inline_discussions
)
self
.
assert
Fals
e
(
course_cohort_settings
.
always_cohort_inline_discussions
)
def
test_update_course_cohort_settings
(
self
):
def
test_update_course_cohort_settings
(
self
):
"""
"""
...
@@ -694,14 +694,14 @@ class TestCohorts(ModuleStoreTestCase):
...
@@ -694,14 +694,14 @@ class TestCohorts(ModuleStoreTestCase):
course
.
id
,
course
.
id
,
is_cohorted
=
False
,
is_cohorted
=
False
,
cohorted_discussions
=
[
'topic a id'
,
'topic b id'
],
cohorted_discussions
=
[
'topic a id'
,
'topic b id'
],
always_cohort_inline_discussions
=
Fals
e
always_cohort_inline_discussions
=
Tru
e
)
)
course_cohort_settings
=
cohorts
.
get_course_cohort_settings
(
course
.
id
)
course_cohort_settings
=
cohorts
.
get_course_cohort_settings
(
course
.
id
)
self
.
assertFalse
(
course_cohort_settings
.
is_cohorted
)
self
.
assertFalse
(
course_cohort_settings
.
is_cohorted
)
self
.
assertEqual
(
course_cohort_settings
.
cohorted_discussions
,
[
'topic a id'
,
'topic b id'
])
self
.
assertEqual
(
course_cohort_settings
.
cohorted_discussions
,
[
'topic a id'
,
'topic b id'
])
self
.
assert
Fals
e
(
course_cohort_settings
.
always_cohort_inline_discussions
)
self
.
assert
Tru
e
(
course_cohort_settings
.
always_cohort_inline_discussions
)
def
test_update_course_cohort_settings_with_invalid_data_type
(
self
):
def
test_update_course_cohort_settings_with_invalid_data_type
(
self
):
"""
"""
...
...
openedx/core/djangoapps/course_groups/tests/test_views.py
View file @
121078eb
...
@@ -189,7 +189,7 @@ class CourseCohortSettingsHandlerTestCase(CohortViewsTestCase):
...
@@ -189,7 +189,7 @@ class CourseCohortSettingsHandlerTestCase(CohortViewsTestCase):
"""
"""
return
{
return
{
'is_cohorted'
:
True
,
'is_cohorted'
:
True
,
'always_cohort_inline_discussions'
:
Tru
e
,
'always_cohort_inline_discussions'
:
Fals
e
,
'cohorted_inline_discussions'
:
[],
'cohorted_inline_discussions'
:
[],
'cohorted_course_wide_discussions'
:
[],
'cohorted_course_wide_discussions'
:
[],
'id'
:
1
'id'
:
1
...
@@ -247,7 +247,7 @@ class CourseCohortSettingsHandlerTestCase(CohortViewsTestCase):
...
@@ -247,7 +247,7 @@ class CourseCohortSettingsHandlerTestCase(CohortViewsTestCase):
self
.
assertEqual
(
response
,
expected_response
)
self
.
assertEqual
(
response
,
expected_response
)
expected_response
[
'always_cohort_inline_discussions'
]
=
Fals
e
expected_response
[
'always_cohort_inline_discussions'
]
=
Tru
e
response
=
self
.
patch_handler
(
self
.
course
,
data
=
expected_response
,
handler
=
course_cohort_settings_handler
)
response
=
self
.
patch_handler
(
self
.
course
,
data
=
expected_response
,
handler
=
course_cohort_settings_handler
)
self
.
assertEqual
(
response
,
expected_response
)
self
.
assertEqual
(
response
,
expected_response
)
...
...
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