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
5f5a44e0
Commit
5f5a44e0
authored
May 15, 2017
by
Matt Drayer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Hide the audit option from track selection for certain enterprise use cases
parent
2955a6e6
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
57 additions
and
33 deletions
+57
-33
common/djangoapps/course_modes/models.py
+3
-0
common/djangoapps/course_modes/tests/test_views.py
+42
-30
common/djangoapps/course_modes/views.py
+9
-2
openedx/features/enterprise_support/tests/mixins/enterprise.py
+3
-1
No files found.
common/djangoapps/course_modes/models.py
View file @
5f5a44e0
...
...
@@ -122,6 +122,9 @@ class CourseMode(models.Model):
DEFAULT_MODE
=
Mode
(
AUDIT
,
_
(
'Audit'
),
0
,
''
,
'usd'
,
None
,
None
,
None
,
None
)
DEFAULT_MODE_SLUG
=
AUDIT
# Modes utilized for audit/free enrollments
AUDIT_MODES
=
[
AUDIT
,
HONOR
]
# Modes that allow a student to pursue a verified certificate
VERIFIED_MODES
=
[
VERIFIED
,
PROFESSIONAL
]
...
...
common/djangoapps/course_modes/tests/test_views.py
View file @
5f5a44e0
...
...
@@ -133,18 +133,28 @@ class CourseModeViewTest(CatalogIntegrationMixin, UrlResetMixin, ModuleStoreTest
self
.
assertRedirects
(
response
,
'http://testserver/test_basket/?sku=TEST'
,
fetch_redirect_response
=
False
)
ecomm_test_utils
.
update_commerce_config
(
enabled
=
False
)
@httpretty.activate
def
test_no_enrollment
(
self
):
def
_generate_enterprise_learner_context
(
self
,
enable_audit_enrollment
=
False
):
"""
Internal helper to support common pieces of test case variations
"""
# Create the course modes
for
mode
in
(
'audit'
,
'honor'
,
'verified'
):
CourseModeFactory
.
create
(
mode_slug
=
mode
,
course_id
=
self
.
course
.
id
)
self
.
mock_enterprise_learner_api
()
catalog_integration
=
self
.
create_catalog_integration
()
UserFactory
(
username
=
catalog_integration
.
service_username
)
# User visits the track selection page directly without ever enrolling
url
=
reverse
(
'course_modes_choose'
,
args
=
[
unicode
(
self
.
course
.
id
)])
response
=
self
.
client
.
get
(
url
)
self
.
mock_course_discovery_api_for_catalog_contains
(
catalog_id
=
1
,
course_run_ids
=
[
str
(
self
.
course
.
id
)]
)
self
.
mock_enterprise_learner_api
(
enable_audit_enrollment
=
enable_audit_enrollment
)
return
reverse
(
'course_modes_choose'
,
args
=
[
unicode
(
self
.
course
.
id
)])
@httpretty.activate
def
test_no_enrollment
(
self
):
url
=
self
.
_generate_enterprise_learner_context
()
response
=
self
.
client
.
get
(
url
)
self
.
assertEquals
(
response
.
status_code
,
200
)
@httpretty.activate
...
...
@@ -152,21 +162,9 @@ class CourseModeViewTest(CatalogIntegrationMixin, UrlResetMixin, ModuleStoreTest
"""
Test: Track selection page should show the enterprise context message if user belongs to the Enterprise.
"""
# Create the course modes
for
mode
in
(
'audit'
,
'honor'
,
'verified'
):
CourseModeFactory
.
create
(
mode_slug
=
mode
,
course_id
=
self
.
course
.
id
)
catalog_integration
=
self
.
create_catalog_integration
()
UserFactory
(
username
=
catalog_integration
.
service_username
)
self
.
mock_enterprise_learner_api
()
self
.
mock_course_discovery_api_for_catalog_contains
(
catalog_id
=
1
,
course_run_ids
=
[
str
(
self
.
course
.
id
)]
)
url
=
self
.
_generate_enterprise_learner_context
()
# User visits the track selection page directly without ever enrolling
url
=
reverse
(
'course_modes_choose'
,
args
=
[
unicode
(
self
.
course
.
id
)])
response
=
self
.
client
.
get
(
url
)
self
.
assertEquals
(
response
.
status_code
,
200
)
self
.
assertContains
(
...
...
@@ -185,16 +183,7 @@ class CourseModeViewTest(CatalogIntegrationMixin, UrlResetMixin, ModuleStoreTest
Test: Track selection page should show the enterprise context message with multiple organization names
if user belongs to the Enterprise.
"""
# Create the course modes
for
mode
in
(
'audit'
,
'honor'
,
'verified'
):
CourseModeFactory
.
create
(
mode_slug
=
mode
,
course_id
=
self
.
course
.
id
)
catalog_integration
=
self
.
create_catalog_integration
()
UserFactory
(
username
=
catalog_integration
.
service_username
)
self
.
mock_enterprise_learner_api
()
self
.
mock_course_discovery_api_for_catalog_contains
(
catalog_id
=
1
,
course_run_ids
=
[
str
(
self
.
course
.
id
)]
)
url
=
self
.
_generate_enterprise_learner_context
()
# Creating organization
for
i
in
xrange
(
2
):
...
...
@@ -209,7 +198,6 @@ class CourseModeViewTest(CatalogIntegrationMixin, UrlResetMixin, ModuleStoreTest
organizations_api
.
add_organization_course
(
organization_data
=
test_org
,
course_id
=
unicode
(
self
.
course
.
id
))
# User visits the track selection page directly without ever enrolling
url
=
reverse
(
'course_modes_choose'
,
args
=
[
unicode
(
self
.
course
.
id
)])
response
=
self
.
client
.
get
(
url
)
self
.
assertEquals
(
response
.
status_code
,
200
)
self
.
assertContains
(
...
...
@@ -222,6 +210,30 @@ class CourseModeViewTest(CatalogIntegrationMixin, UrlResetMixin, ModuleStoreTest
)
@httpretty.activate
def
test_enterprise_learner_context_audit_disabled
(
self
):
"""
Track selection page should hide the audit choice by default in an Enterprise Customer/Learner context
"""
# User visits the track selection page directly without ever enrolling, sees only Verified track choice
url
=
self
.
_generate_enterprise_learner_context
()
response
=
self
.
client
.
get
(
url
)
self
.
assertContains
(
response
,
'Pursue a Verified Certificate'
)
self
.
assertNotContains
(
response
,
'Audit This Course'
)
@httpretty.activate
def
test_enterprise_learner_context_audit_enabled
(
self
):
"""
Track selection page should display Audit choice when specified for an Enterprise Customer
"""
# User visits the track selection page directly without ever enrolling, sees both Verified and Audit choices
url
=
self
.
_generate_enterprise_learner_context
(
enable_audit_enrollment
=
True
)
response
=
self
.
client
.
get
(
url
)
self
.
assertContains
(
response
,
'Pursue a Verified Certificate'
)
self
.
assertContains
(
response
,
'Audit This Course'
)
@httpretty.activate
@ddt.data
(
''
,
'1,,2'
,
...
...
common/djangoapps/course_modes/views.py
View file @
5f5a44e0
...
...
@@ -156,16 +156,17 @@ class ChooseModeView(View):
)
enterprise_learner_data
=
enterprise_api
.
get_enterprise_learner_data
(
site
=
request
.
site
,
user
=
request
.
user
)
if
enterprise_learner_data
:
enterprise_learner
=
enterprise_learner_data
[
0
]
is_course_in_enterprise_catalog
=
enterprise_api
.
is_course_in_enterprise_catalog
(
site
=
request
.
site
,
course_id
=
course_id
,
enterprise_catalog_id
=
enterprise_learner
_data
[
0
]
[
'enterprise_customer'
][
'catalog'
]
enterprise_catalog_id
=
enterprise_learner
[
'enterprise_customer'
][
'catalog'
]
)
if
is_course_in_enterprise_catalog
:
partner_names
=
partner_name
=
course
.
display_organization
\
if
course
.
display_organization
else
course
.
org
enterprise_name
=
enterprise_learner
_data
[
0
]
[
'enterprise_customer'
][
'name'
]
enterprise_name
=
enterprise_learner
[
'enterprise_customer'
][
'name'
]
organizations
=
organization_api
.
get_course_organizations
(
course_id
=
course
.
id
)
if
organizations
:
partner_names
=
' and '
.
join
([
org
.
get
(
'name'
,
partner_name
)
for
org
in
organizations
])
...
...
@@ -178,6 +179,12 @@ class ChooseModeView(View):
partner_names
=
partner_names
,
enterprise_name
=
enterprise_name
)
# Hide the audit modes for this enterprise customer, if necessary
if
not
enterprise_learner
[
'enterprise_customer'
]
.
get
(
'enable_audit_enrollment'
):
for
audit_mode
in
CourseMode
.
AUDIT_MODES
:
modes
.
pop
(
audit_mode
,
None
)
context
[
"title_content"
]
=
title_content
if
"verified"
in
modes
:
...
...
openedx/features/enterprise_support/tests/mixins/enterprise.py
View file @
5f5a44e0
...
...
@@ -62,7 +62,8 @@ class EnterpriseServiceMockMixin(object):
catalog_id
=
1
,
entitlement_id
=
1
,
learner_id
=
1
,
enterprise_customer_uuid
=
'cf246b88-d5f6-4908-a522-fc307e0b0c59'
enterprise_customer_uuid
=
'cf246b88-d5f6-4908-a522-fc307e0b0c59'
,
enable_audit_enrollment
=
False
,
):
"""
Helper function to register enterprise learner API endpoint.
...
...
@@ -85,6 +86,7 @@ class EnterpriseServiceMockMixin(object):
},
'enable_data_sharing_consent'
:
True
,
'enforce_data_sharing_consent'
:
'at_login'
,
'enable_audit_enrollment'
:
enable_audit_enrollment
,
'enterprise_customer_users'
:
[
1
],
...
...
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