Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
edx-platform-release
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
1
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Hsin-Yu Chien
edx-platform-release
Commits
21ef60b4
Commit
21ef60b4
authored
8 years ago
by
Albert St. Aubin
Browse files
Options
Downloads
Patches
Plain Diff
Added filter to the cohort user count data to show the counts of only
active users
parent
c98fb5b6
Loading
Loading
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
openedx/core/djangoapps/course_groups/tests/test_views.py
+23
-2
23 additions, 2 deletions
openedx/core/djangoapps/course_groups/tests/test_views.py
openedx/core/djangoapps/course_groups/views.py
+2
-1
2 additions, 1 deletion
openedx/core/djangoapps/course_groups/views.py
with
25 additions
and
3 deletions
openedx/core/djangoapps/course_groups/tests/test_views.py
+
23
−
2
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
,
...
...
This diff is collapsed.
Click to expand it.
openedx/core/djangoapps/course_groups/views.py
+
2
−
1
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
,
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment