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
21ef60b4
Commit
21ef60b4
authored
Mar 27, 2017
by
Albert St. Aubin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added filter to the cohort user count data to show the counts of only
active users
parent
c98fb5b6
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
3 deletions
+25
-3
openedx/core/djangoapps/course_groups/tests/test_views.py
+23
-2
openedx/core/djangoapps/course_groups/views.py
+2
-1
No files found.
openedx/core/djangoapps/course_groups/tests/test_views.py
View file @
21ef60b4
...
...
@@ -838,6 +838,7 @@ class AddUsersToCohortTestCase(CohortViewsTestCase):
else
:
response
=
add_users_to_cohort
(
request
,
unicode
(
course
.
id
),
cohort
.
id
)
self
.
assertEqual
(
response
.
status_code
,
200
)
return
json
.
loads
(
response
.
content
)
def
verify_added_users_to_cohort
(
self
,
response_dict
,
cohort
,
course
,
expected_added
,
expected_changed
,
...
...
@@ -993,22 +994,37 @@ class AddUsersToCohortTestCase(CohortViewsTestCase):
expected_unknown
=
usernames
)
def
check_user_count
(
self
,
expected_count
,
cohort
):
"""
Check that the expected number of users are present in the user_count returned by the view handler
"""
cohort_listed
=
False
for
c
in
self
.
get_handler
(
self
.
course
)[
'cohorts'
]:
if
c
[
'name'
]
==
cohort
.
name
:
cohort_listed
=
True
self
.
assertEqual
(
expected_count
,
c
[
'user_count'
])
self
.
assertTrue
(
cohort_listed
)
def
test_all
(
self
):
"""
Test all adding conditions together.
"""
unknowns
=
[
"unknown_user{}"
.
format
(
i
)
for
i
in
range
(
3
)]
new_users
=
self
.
cohortless_users
+
self
.
cohort1_users
+
self
.
cohort2_users
+
self
.
cohort3_users
response_dict
=
self
.
request_add_users_to_cohort
(
","
.
join
(
unknowns
+
[
user
.
username
for
user
in
self
.
cohortless_users
+
self
.
cohort1_users
+
self
.
cohort2_users
+
self
.
cohort3
_users
for
user
in
new
_users
]
),
self
.
cohort1
,
self
.
course
)
self
.
check_user_count
(
expected_count
=
len
(
new_users
),
cohort
=
self
.
cohort1
)
self
.
verify_added_users_to_cohort
(
response_dict
,
self
.
cohort1
,
...
...
@@ -1077,14 +1093,19 @@ class AddUsersToCohortTestCase(CohortViewsTestCase):
"""
Verify that users can be added to a cohort of a course they're not
enrolled in. This feature is currently used to pre-cohort users that
are expected to enroll in a course.
are expected to enroll in a course. Also tests that adding unenrolled
users does not alter the number of "active" users in the user_count.
"""
start_count
=
self
.
cohort1
.
users
.
count
()
unenrolled_usernames
=
[
user
.
username
for
user
in
self
.
unenrolled_users
]
response_dict
=
self
.
request_add_users_to_cohort
(
","
.
join
(
unenrolled_usernames
),
self
.
cohort1
,
self
.
course
)
self
.
check_user_count
(
expected_count
=
start_count
,
cohort
=
self
.
cohort1
)
self
.
verify_added_users_to_cohort
(
response_dict
,
self
.
cohort1
,
...
...
openedx/core/djangoapps/course_groups/views.py
View file @
21ef60b4
...
...
@@ -90,7 +90,8 @@ def _get_cohort_representation(cohort, course):
return
{
'name'
:
cohort
.
name
,
'id'
:
cohort
.
id
,
'user_count'
:
cohort
.
users
.
count
(),
'user_count'
:
cohort
.
users
.
filter
(
courseenrollment__course_id
=
course
.
location
.
course_key
,
courseenrollment__is_active
=
1
)
.
count
(),
'assignment_type'
:
assignment_type
,
'user_partition_id'
:
partition_id
,
'group_id'
:
group_id
,
...
...
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