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
9009a5b0
Commit
9009a5b0
authored
Aug 25, 2017
by
Alex Dusenbery
Committed by
Alex Dusenbery
Aug 25, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
may_certify_for_course checks if course is self_paced.
parent
010d251d
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
36 additions
and
25 deletions
+36
-25
common/lib/xmodule/xmodule/course_metadata_utils.py
+7
-10
common/lib/xmodule/xmodule/course_module.py
+2
-1
common/lib/xmodule/xmodule/tests/test_course_metadata_utils.py
+10
-8
lms/djangoapps/courseware/views/views.py
+1
-5
openedx/core/djangoapps/content/course_overviews/models.py
+2
-1
openedx/core/djangoapps/programs/tests/test_utils.py
+14
-0
No files found.
common/lib/xmodule/xmodule/course_metadata_utils.py
View file @
9009a5b0
...
...
@@ -97,11 +97,12 @@ def may_certify_for_course(
certificates_display_behavior
,
certificates_show_before_end
,
has_ended
,
certificate_available_date
certificate_available_date
,
self_paced
):
"""
Returns whether it is acceptable to show the student a certificate download
link for a course.
link for a course
, based on provided attributes of the course
.
Arguments:
certificates_display_behavior (str): string describing the course's
...
...
@@ -111,23 +112,19 @@ def may_certify_for_course(
course's certificates before the course has ended.
has_ended (bool): Whether the course has ended.
certificate_available_date (datetime): the date the certificate is available on for the course.
self_paced (bool): Whether the course is self-paced.
"""
show_early
=
(
certificates_display_behavior
in
(
'early_with_info'
,
'early_no_info'
)
or
certificates_show_before_end
)
past_availab
ility
_date
=
(
past_availab
le
_date
=
(
certificate_available_date
and
certificate_available_date
<
datetime
.
now
(
utc
)
)
ended_without_available_date
=
(
certificate_available_date
is
None
)
and
has_ended
if
show_early
:
return
True
if
past_availability_date
:
return
True
if
(
certificate_available_date
is
None
)
and
has_ended
:
return
True
return
False
return
any
((
self_paced
,
show_early
,
past_available_date
,
ended_without_available_date
))
def
sorting_score
(
start
,
advertised_start
,
announcement
):
...
...
common/lib/xmodule/xmodule/course_module.py
View file @
9009a5b0
...
...
@@ -1067,7 +1067,8 @@ class CourseDescriptor(CourseFields, SequenceDescriptor, LicenseMixin):
self
.
certificates_display_behavior
,
self
.
certificates_show_before_end
,
self
.
has_ended
(),
self
.
certificate_available_date
self
.
certificate_available_date
,
self
.
self_paced
)
def
has_started
(
self
):
...
...
common/lib/xmodule/xmodule/tests/test_course_metadata_utils.py
View file @
9009a5b0
...
...
@@ -161,14 +161,16 @@ class CourseMetadataUtilsTestCase(TestCase):
TestScenario
((
DEFAULT_START_DATE
,
None
),
True
),
]),
FunctionTest
(
may_certify_for_course
,
[
TestScenario
((
'early_with_info'
,
True
,
True
,
test_datetime
),
True
),
TestScenario
((
'early_no_info'
,
False
,
False
,
test_datetime
),
True
),
TestScenario
((
'end'
,
True
,
False
,
test_datetime
),
True
),
TestScenario
((
'end'
,
False
,
True
,
test_datetime
),
True
),
TestScenario
((
'end'
,
False
,
False
,
_NEXT_WEEK
),
False
),
TestScenario
((
'end'
,
False
,
False
,
_LAST_WEEK
),
True
),
TestScenario
((
'end'
,
False
,
False
,
None
),
False
),
TestScenario
((
'early_with_info'
,
False
,
False
,
None
),
True
),
TestScenario
((
'early_with_info'
,
True
,
True
,
test_datetime
,
False
),
True
),
TestScenario
((
'early_no_info'
,
False
,
False
,
test_datetime
,
False
),
True
),
TestScenario
((
'end'
,
True
,
False
,
test_datetime
,
False
),
True
),
TestScenario
((
'end'
,
False
,
True
,
test_datetime
,
False
),
True
),
TestScenario
((
'end'
,
False
,
False
,
_NEXT_WEEK
,
False
),
False
),
TestScenario
((
'end'
,
False
,
False
,
_LAST_WEEK
,
False
),
True
),
TestScenario
((
'end'
,
False
,
False
,
None
,
False
),
False
),
TestScenario
((
'early_with_info'
,
False
,
False
,
None
,
False
),
True
),
TestScenario
((
'end'
,
False
,
False
,
_NEXT_WEEK
,
False
),
False
),
TestScenario
((
'end'
,
False
,
False
,
_NEXT_WEEK
,
True
),
True
),
]),
]
...
...
lms/djangoapps/courseware/views/views.py
View file @
9009a5b0
...
...
@@ -930,12 +930,8 @@ def _get_cert_data(student, course, course_key, is_active, enrollment_mode):
)
may_view_certificate
=
False
# https://openedx.atlassian.net/browse/EDUCATOR-1204: historically,
# certificates for self-paced courses are displayed no matter the
# state of advanced course settings regarding certificates.
if
course_key
:
course
=
get_course_by_id
(
course_key
)
may_view_certificate
=
course
.
self_paced
or
course
.
may_certify
()
may_view_certificate
=
get_course_by_id
(
course_key
)
.
may_certify
()
show_message
=
all
([
is_active
,
...
...
openedx/core/djangoapps/content/course_overviews/models.py
View file @
9009a5b0
...
...
@@ -479,7 +479,8 @@ class CourseOverview(TimeStampedModel):
self
.
certificates_display_behavior
,
self
.
certificates_show_before_end
,
self
.
has_ended
(),
self
.
certificate_available_date
self
.
certificate_available_date
,
self
.
self_paced
)
@property
...
...
openedx/core/djangoapps/programs/tests/test_utils.py
View file @
9009a5b0
...
...
@@ -732,6 +732,20 @@ class TestProgramDataExtender(ModuleStoreTestCase):
self
.
_assert_supplemented
(
data
,
certificate_url
=
expected_url
)
@ddt.data
(
True
,
False
)
def
test_may_certify_attached
(
self
,
may_certify
):
"""
Verify that the `may_certify` is included during data extension.
"""
self
.
course
.
certificates_show_before_end
=
may_certify
self
.
course
=
self
.
update_course
(
self
.
course
,
self
.
user
.
id
)
data
=
ProgramDataExtender
(
self
.
program
,
self
.
user
)
.
extend
()
self
.
assertEqual
(
may_certify
,
data
[
'courses'
][
0
][
'course_runs'
][
0
][
'may_certify'
])
self
.
_assert_supplemented
(
data
)
@skip_unless_lms
@mock.patch
(
UTILS_MODULE
+
'.get_credentials'
)
...
...
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