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
5d446936
Commit
5d446936
authored
Aug 23, 2017
by
Eric Fischer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
EDUCATOR-1189
parent
a23b7469
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
13 deletions
+17
-13
openedx/core/djangoapps/verified_track_content/tasks.py
+3
-2
openedx/core/djangoapps/verified_track_content/tests/test_models.py
+14
-11
No files found.
openedx/core/djangoapps/verified_track_content/tasks.py
View file @
5d446936
...
...
@@ -31,13 +31,14 @@ def sync_cohort_with_mode(self, course_id, user_id, verified_cohort_name, defaul
verified_cohort
=
get_cohort_by_name
(
course_key
,
verified_cohort_name
)
if
enrollment
.
mode
==
CourseMode
.
VERIFIED
and
(
current_cohort
.
id
!=
verified_cohort
.
id
):
acceptable_modes
=
{
CourseMode
.
VERIFIED
,
CourseMode
.
CREDIT_MODE
}
if
enrollment
.
mode
in
acceptable_modes
and
(
current_cohort
.
id
!=
verified_cohort
.
id
):
LOGGER
.
info
(
"MOVING_TO_VERIFIED: Moving user '
%
s' to the verified cohort '
%
s' for course '
%
s'"
,
user
.
id
,
verified_cohort
.
name
,
course_id
)
add_user_to_cohort
(
verified_cohort
,
user
.
username
)
elif
enrollment
.
mode
!=
CourseMode
.
VERIFIED
and
current_cohort
.
id
==
verified_cohort
.
id
:
elif
enrollment
.
mode
not
in
acceptable_modes
and
current_cohort
.
id
==
verified_cohort
.
id
:
default_cohort
=
get_cohort_by_name
(
course_key
,
default_cohort_name
)
LOGGER
.
info
(
"MOVING_TO_DEFAULT: Moving user '
%
s' to the default cohort '
%
s' for course '
%
s'"
,
...
...
openedx/core/djangoapps/verified_track_content/tests/test_models.py
View file @
5d446936
...
...
@@ -4,6 +4,7 @@ Tests for Verified Track Cohorting models
# pylint: disable=attribute-defined-outside-init
# pylint: disable=no-member
import
ddt
import
mock
from
mock
import
patch
...
...
@@ -70,6 +71,7 @@ class TestVerifiedTrackCohortedCourse(TestCase):
@skip_unless_lms
@ddt.ddt
class
TestMoveToVerified
(
SharedModuleStoreTestCase
):
""" Tests for the post-save listener. """
...
...
@@ -115,15 +117,15 @@ class TestMoveToVerified(SharedModuleStoreTestCase):
""" Enroll self.user in self.course. """
self
.
enrollment
=
CourseEnrollmentFactory
(
course_id
=
self
.
course
.
id
,
user
=
self
.
user
)
def
_upgrade_
to_verified
(
self
):
def
_upgrade_
enrollment
(
self
,
mode
=
CourseMode
.
VERIFIED
):
""" Upgrade the default enrollment to verified. """
self
.
enrollment
.
update_enrollment
(
mode
=
CourseMode
.
VERIFIED
)
self
.
enrollment
.
update_enrollment
(
mode
=
mode
)
def
_verify_no_automatic_cohorting
(
self
):
""" Check that upgrading self.user to verified does not move them into a cohort. """
self
.
_enroll_in_course
()
self
.
assertIsNone
(
get_cohort
(
self
.
user
,
self
.
course
.
id
,
assign
=
False
))
self
.
_upgrade_
to_verified
()
self
.
_upgrade_
enrollment
()
self
.
assertIsNone
(
get_cohort
(
self
.
user
,
self
.
course
.
id
,
assign
=
False
))
self
.
assertEqual
(
0
,
self
.
mocked_celery_task
.
call_count
)
...
...
@@ -181,7 +183,8 @@ class TestMoveToVerified(SharedModuleStoreTestCase):
error_message
=
"cohort named '
%
s' does not exist"
self
.
assertIn
(
error_message
,
error_logger
.
call_args
[
0
][
0
])
def
test_automatic_cohorting_enabled
(
self
):
@ddt.data
(
CourseMode
.
VERIFIED
,
CourseMode
.
CREDIT_MODE
)
def
test_automatic_cohorting_enabled
(
self
,
upgrade_mode
):
"""
If the VerifiedTrackCohortedCourse feature is enabled for a course (with course cohorting enabled
with an existing verified cohort), enrollment in the verified track automatically moves learners
...
...
@@ -198,7 +201,7 @@ class TestMoveToVerified(SharedModuleStoreTestCase):
self
.
assertEqual
(
2
,
self
.
mocked_celery_task
.
call_count
)
self
.
assertEqual
(
DEFAULT_COHORT_NAME
,
get_cohort
(
self
.
user
,
self
.
course
.
id
,
assign
=
False
)
.
name
)
self
.
_upgrade_
to_verified
(
)
self
.
_upgrade_
enrollment
(
upgrade_mode
)
self
.
assertEqual
(
4
,
self
.
mocked_celery_task
.
call_count
)
self
.
assertEqual
(
DEFAULT_VERIFIED_COHORT_NAME
,
get_cohort
(
self
.
user
,
self
.
course
.
id
,
assign
=
False
)
.
name
)
...
...
@@ -219,7 +222,7 @@ class TestMoveToVerified(SharedModuleStoreTestCase):
self
.
_enroll_in_course
()
self
.
assertIn
(
get_cohort
(
self
.
user
,
self
.
course
.
id
,
assign
=
False
)
.
name
,
[
"Random 1"
,
"Random 2"
])
self
.
_upgrade_
to_verified
()
self
.
_upgrade_
enrollment
()
self
.
assertEqual
(
DEFAULT_VERIFIED_COHORT_NAME
,
get_cohort
(
self
.
user
,
self
.
course
.
id
,
assign
=
False
)
.
name
)
self
.
_unenroll
()
...
...
@@ -236,7 +239,7 @@ class TestMoveToVerified(SharedModuleStoreTestCase):
self
.
_create_verified_cohort
()
self
.
_enable_verified_track_cohorting
()
self
.
_enroll_in_course
()
self
.
_upgrade_
to_verified
()
self
.
_upgrade_
enrollment
()
self
.
assertEqual
(
DEFAULT_VERIFIED_COHORT_NAME
,
get_cohort
(
self
.
user
,
self
.
course
.
id
,
assign
=
False
)
.
name
)
# Un-enroll from the course and then re-enroll
...
...
@@ -244,7 +247,7 @@ class TestMoveToVerified(SharedModuleStoreTestCase):
self
.
assertEqual
(
DEFAULT_VERIFIED_COHORT_NAME
,
get_cohort
(
self
.
user
,
self
.
course
.
id
,
assign
=
False
)
.
name
)
self
.
_reenroll
()
self
.
assertEqual
(
DEFAULT_COHORT_NAME
,
get_cohort
(
self
.
user
,
self
.
course
.
id
,
assign
=
False
)
.
name
)
self
.
_upgrade_
to_verified
()
self
.
_upgrade_
enrollment
()
self
.
assertEqual
(
DEFAULT_VERIFIED_COHORT_NAME
,
get_cohort
(
self
.
user
,
self
.
course
.
id
,
assign
=
False
)
.
name
)
def
test_custom_verified_cohort_name
(
self
):
...
...
@@ -256,7 +259,7 @@ class TestMoveToVerified(SharedModuleStoreTestCase):
self
.
_create_verified_cohort
(
name
=
custom_cohort_name
)
self
.
_enable_verified_track_cohorting
(
cohort_name
=
custom_cohort_name
)
self
.
_enroll_in_course
()
self
.
_upgrade_
to_verified
()
self
.
_upgrade_
enrollment
()
self
.
assertEqual
(
custom_cohort_name
,
get_cohort
(
self
.
user
,
self
.
course
.
id
,
assign
=
False
)
.
name
)
def
test_custom_default_cohort_name
(
self
):
...
...
@@ -271,7 +274,7 @@ class TestMoveToVerified(SharedModuleStoreTestCase):
self
.
_enable_verified_track_cohorting
()
self
.
_enroll_in_course
()
self
.
assertEqual
(
random_cohort_name
,
get_cohort
(
self
.
user
,
self
.
course
.
id
,
assign
=
False
)
.
name
)
self
.
_upgrade_
to_verified
()
self
.
_upgrade_
enrollment
()
self
.
assertEqual
(
DEFAULT_VERIFIED_COHORT_NAME
,
get_cohort
(
self
.
user
,
self
.
course
.
id
,
assign
=
False
)
.
name
)
# Un-enroll from the course. The learner stays in the verified cohort, but is no longer active.
...
...
@@ -286,5 +289,5 @@ class TestMoveToVerified(SharedModuleStoreTestCase):
# Re-enroll in the course, which will downgrade the learner to audit.
self
.
_reenroll
()
self
.
assertEqual
(
modified_cohort_name
,
get_cohort
(
self
.
user
,
self
.
course
.
id
,
assign
=
False
)
.
name
)
self
.
_upgrade_
to_verified
()
self
.
_upgrade_
enrollment
()
self
.
assertEqual
(
DEFAULT_VERIFIED_COHORT_NAME
,
get_cohort
(
self
.
user
,
self
.
course
.
id
,
assign
=
False
)
.
name
)
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