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
c13b531e
Commit
c13b531e
authored
Oct 02, 2017
by
Andy Armstrong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Display course home message for certificate availability
LEARNER-2182
parent
39671b8e
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
66 additions
and
12 deletions
+66
-12
lms/djangoapps/courseware/date_summary.py
+25
-0
lms/djangoapps/courseware/tests/test_date_summary.py
+41
-12
No files found.
lms/djangoapps/courseware/date_summary.py
View file @
c13b531e
...
...
@@ -354,6 +354,31 @@ class CertificateAvailableDate(DateSummary):
)
if
mode
.
slug
!=
CourseMode
.
AUDIT
])
def
register_alerts
(
self
,
request
,
course
):
"""
Registers an alert close to the certificate delivery date.
"""
is_enrolled
=
CourseEnrollment
.
get_enrollment
(
request
.
user
,
course
.
id
)
if
not
is_enrolled
or
not
self
.
is_enabled
or
course
.
end
>
self
.
current_time
:
return
if
self
.
date
>
self
.
current_time
:
CourseHomeMessages
.
register_info_message
(
request
,
Text
(
_
(
'If you have earned a certificate, you will be able to access it {time_remaining_string}'
' from now. You will also be able to view your certificates on your {learner_profile_link}.'
))
.
format
(
time_remaining_string
=
self
.
time_remaining_string
,
learner_profile_link
=
HTML
(
'<a href="{learner_profile_url}">{learner_profile_name}</a>'
)
.
format
(
learner_profile_url
=
reverse
(
'learner_profile'
,
kwargs
=
{
'username'
:
request
.
user
.
username
}),
learner_profile_name
=
_
(
'Learner Profile'
),
),
),
title
=
Text
(
_
(
'We are working on generating course certificates.'
))
)
class
VerifiedUpgradeDeadlineDate
(
DateSummary
):
"""
...
...
lms/djangoapps/courseware/tests/test_date_summary.py
View file @
c13b531e
...
...
@@ -48,17 +48,6 @@ class CourseDateSummaryTest(SharedModuleStoreTestCase):
super
(
CourseDateSummaryTest
,
self
)
.
setUp
()
SelfPacedConfiguration
.
objects
.
create
(
enable_course_home_improvements
=
True
)
def
enable_course_certificates
(
self
,
course
):
""" Enable course certificate configuration """
course
.
certificates
=
{
u'certificates'
:
[{
u'course_title'
:
u'Test'
,
u'name'
:
u''
,
u'is_active'
:
True
,
}]
}
course
.
save
()
def
test_course_info_feature_flag
(
self
):
SelfPacedConfiguration
(
enable_course_home_improvements
=
False
)
.
save
()
course
=
create_course_run
()
...
...
@@ -369,7 +358,7 @@ class CourseDateSummaryTest(SharedModuleStoreTestCase):
verified_user
=
create_user
()
CourseEnrollmentFactory
(
course_id
=
course
.
id
,
user
=
verified_user
,
mode
=
CourseMode
.
VERIFIED
)
course
.
certificate_available_date
=
datetime
.
now
(
utc
)
+
timedelta
(
days
=
7
)
self
.
enable_course_certificates
(
course
)
enable_course_certificates
(
course
)
CertificateAvailableDate
(
course
,
audit_user
)
for
block
in
(
CertificateAvailableDate
(
course
,
audit_user
),
CertificateAvailableDate
(
course
,
verified_user
)):
self
.
assertIsNotNone
(
course
.
certificate_available_date
)
...
...
@@ -467,6 +456,8 @@ class TestDateAlerts(SharedModuleStoreTestCase):
super
(
TestDateAlerts
,
self
)
.
setUp
()
with
freeze_time
(
'2017-07-01 09:00:00'
):
self
.
course
=
create_course_run
(
days_till_start
=
0
)
self
.
course
.
certificate_available_date
=
self
.
course
.
start
+
timedelta
(
days
=
21
)
enable_course_certificates
(
self
.
course
)
self
.
enrollment
=
CourseEnrollmentFactory
(
course_id
=
self
.
course
.
id
,
mode
=
CourseMode
.
AUDIT
)
self
.
request
=
RequestFactory
()
.
request
()
self
.
request
.
session
=
{}
...
...
@@ -546,6 +537,30 @@ class TestDateAlerts(SharedModuleStoreTestCase):
else
:
self
.
assertEqual
(
len
(
messages
),
0
)
@ddt.data
(
[
'2017-07-15 08:00:00'
,
None
],
[
'2017-07-15 09:00:00'
,
u'If you have earned a certificate, you will be able to access it 1 week from now.'
],
[
'2017-07-21 09:00:00'
,
u'If you have earned a certificate, you will be able to access it 1 day from now.'
],
[
'2017-07-22 08:00:00'
,
u'If you have earned a certificate, you will be able to access it 1 hour from now.'
],
[
'2017-07-22 09:00:00'
,
None
],
[
'2017-07-23 09:00:00'
,
None
],
)
@ddt.unpack
@waffle.testutils.override_switch
(
'certificates.auto_certificate_generation'
,
True
)
def
test_certificate_availability_alert
(
self
,
current_time
,
expected_message_html
):
"""
Verify the verified upgrade deadline alerts.
"""
with
freeze_time
(
current_time
):
block
=
CertificateAvailableDate
(
self
.
course
,
self
.
request
.
user
)
block
.
register_alerts
(
self
.
request
,
self
.
course
)
messages
=
list
(
CourseHomeMessages
.
user_messages
(
self
.
request
))
if
expected_message_html
:
self
.
assertEqual
(
len
(
messages
),
1
)
self
.
assertIn
(
expected_message_html
,
messages
[
0
]
.
message_html
)
else
:
self
.
assertEqual
(
len
(
messages
),
0
)
@attr
(
shard
=
1
)
class
TestScheduleOverrides
(
SharedModuleStoreTestCase
):
...
...
@@ -716,3 +731,17 @@ def create_self_paced_course_run(days_till_start=1):
)
return
course
def
enable_course_certificates
(
course
):
"""
Enable course certificate configuration.
"""
course
.
certificates
=
{
u'certificates'
:
[{
u'course_title'
:
u'Test'
,
u'name'
:
u''
,
u'is_active'
:
True
,
}]
}
course
.
save
()
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