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
e063a8bd
Unverified
Commit
e063a8bd
authored
Dec 19, 2017
by
Jeff LaJoie
Committed by
GitHub
Dec 19, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #16952 from edx/jlajoie/LEARNER-3482
LEARNER-3482: Do not show sessions past their enrollment end
parents
3f9ab6ef
23dbc611
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
73 additions
and
2 deletions
+73
-2
common/djangoapps/student/tests/test_views.py
+63
-0
common/djangoapps/student/views.py
+10
-2
No files found.
common/djangoapps/student/tests/test_views.py
View file @
e063a8bd
...
@@ -397,6 +397,69 @@ class StudentDashboardTests(SharedModuleStoreTestCase, MilestonesTestCaseMixin):
...
@@ -397,6 +397,69 @@ class StudentDashboardTests(SharedModuleStoreTestCase, MilestonesTestCaseMixin):
response
=
self
.
client
.
get
(
self
.
path
)
response
=
self
.
client
.
get
(
self
.
path
)
self
.
assertEqual
(
response
.
content
.
count
(
'<li class="course-item">'
),
0
)
self
.
assertEqual
(
response
.
content
.
count
(
'<li class="course-item">'
),
0
)
@patch
(
'student.views.get_course_runs_for_course'
)
@patch.object
(
CourseOverview
,
'get_from_id'
)
@patch
(
'opaque_keys.edx.keys.CourseKey.from_string'
)
def
test_sessions_for_entitlement_course_runs
(
self
,
mock_course_key
,
mock_course_overview
,
mock_course_runs
):
"""
When a learner has a fulfilled entitlement for a course run in the past, there should be no availableSession
data passed to the JS view. When a learner has a fulfilled entitlement for a course run enrollment ending in the
future, there should not be an empty availableSession variable. When a learner has a fulfilled entitlement
for a course that doesn't have an enrollment ending, there should not be an empty availableSession variable.
"""
# Test an enrollment end in the past
mocked_course_overview
=
CourseOverviewFactory
.
create
(
start
=
self
.
TOMORROW
,
self_paced
=
True
,
enrollment_end
=
self
.
THREE_YEARS_AGO
)
mock_course_overview
.
return_value
=
mocked_course_overview
mock_course_key
.
return_value
=
mocked_course_overview
.
id
course_enrollment
=
CourseEnrollmentFactory
(
user
=
self
.
user
,
course_id
=
unicode
(
mocked_course_overview
.
id
))
mock_course_runs
.
return_value
=
[
{
'key'
:
mocked_course_overview
.
id
,
'enrollment_end'
:
mocked_course_overview
.
enrollment_end
,
'pacing_type'
:
'self_paced'
,
'type'
:
'verified'
}
]
CourseEntitlementFactory
(
user
=
self
.
user
,
enrollment_course_run
=
course_enrollment
)
response
=
self
.
client
.
get
(
self
.
path
)
self
.
assertIn
(
"availableSessions: '[]'"
,
response
.
content
)
# Test an enrollment end in the future sets an availableSession
mocked_course_overview
.
enrollment_end
=
self
.
TOMORROW
mocked_course_overview
.
save
()
mock_course_overview
.
return_value
=
mocked_course_overview
mock_course_key
.
return_value
=
mocked_course_overview
.
id
mock_course_runs
.
return_value
=
[
{
'key'
:
mocked_course_overview
.
id
,
'enrollment_end'
:
mocked_course_overview
.
enrollment_end
,
'pacing_type'
:
'self_paced'
,
'type'
:
'verified'
}
]
response
=
self
.
client
.
get
(
self
.
path
)
self
.
assertNotIn
(
"availableSessions: '[]'"
,
response
.
content
)
# Test an enrollment end that doesn't exist sets an availableSession
mocked_course_overview
.
enrollment_end
=
None
mocked_course_overview
.
save
()
mock_course_overview
.
return_value
=
mocked_course_overview
mock_course_key
.
return_value
=
mocked_course_overview
.
id
mock_course_runs
.
return_value
=
[
{
'key'
:
mocked_course_overview
.
id
,
'enrollment_end'
:
mocked_course_overview
.
enrollment_end
,
'pacing_type'
:
'self_paced'
,
'type'
:
'verified'
}
]
response
=
self
.
client
.
get
(
self
.
path
)
self
.
assertNotIn
(
"availableSessions: '[]'"
,
response
.
content
)
@patch
(
'openedx.core.djangoapps.programs.utils.get_programs'
)
@patch
(
'openedx.core.djangoapps.programs.utils.get_programs'
)
@patch
(
'student.views.get_course_runs_for_course'
)
@patch
(
'student.views.get_course_runs_for_course'
)
@patch.object
(
CourseOverview
,
'get_from_id'
)
@patch.object
(
CourseOverview
,
'get_from_id'
)
...
...
common/djangoapps/student/views.py
View file @
e063a8bd
...
@@ -702,8 +702,16 @@ def dashboard(request):
...
@@ -702,8 +702,16 @@ def dashboard(request):
course_entitlement_available_sessions
=
{}
course_entitlement_available_sessions
=
{}
for
course_entitlement
in
course_entitlements
:
for
course_entitlement
in
course_entitlements
:
course_entitlement
.
update_expired_at
()
course_entitlement
.
update_expired_at
()
course_entitlement_available_sessions
[
str
(
course_entitlement
.
uuid
)]
=
\
# Filter only the course runs that do not have an enrollment_end date set, or have one set in the future
get_course_runs_for_course
(
str
(
course_entitlement
.
course_uuid
))
course_runs_for_course
=
get_course_runs_for_course
(
str
(
course_entitlement
.
course_uuid
))
enrollable_course_runs
=
[]
for
course_run
in
course_runs_for_course
:
enrollment_end
=
course_run
.
get
(
'enrollment_end'
)
if
not
enrollment_end
or
enrollment_end
>
datetime
.
datetime
.
now
(
UTC
):
enrollable_course_runs
.
append
(
course_run
)
course_entitlement_available_sessions
[
str
(
course_entitlement
.
uuid
)]
=
enrollable_course_runs
# Record how many courses there are so that we can get a better
# Record how many courses there are so that we can get a better
# understanding of usage patterns on prod.
# understanding of usage patterns on prod.
...
...
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