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
b84d4c02
Commit
b84d4c02
authored
Jun 13, 2017
by
rabiaiftikhar
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Review Rehan
parent
511e6536
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
14 additions
and
14 deletions
+14
-14
lms/djangoapps/certificates/signals.py
+1
-1
lms/djangoapps/certificates/tests/test_signals.py
+7
-11
openedx/core/djangoapps/models/course_details.py
+6
-2
No files found.
lms/djangoapps/certificates/signals.py
View file @
b84d4c02
...
...
@@ -10,7 +10,7 @@ from openedx.core.djangoapps.models.course_details import COURSE_PACING_CHANGE
@receiver
(
COURSE_PACING_CHANGE
,
dispatch_uid
=
"course_pacing_changed"
)
def
_listen_for_course_p
ublish
(
sender
,
course_key
,
course_self_paced
,
**
kwargs
):
# pylint: disable=unused-argument
def
_listen_for_course_p
acing_changed
(
sender
,
course_key
,
course_self_paced
,
**
kwargs
):
# pylint: disable=unused-argument
"""
Catches the signal that course pacing has changed and enable/disable
the self-generated certificates according to course-pacing.
...
...
lms/djangoapps/certificates/tests/test_signals.py
View file @
b84d4c02
...
...
@@ -4,7 +4,7 @@ and disabling for instructor-paced courses.
"""
from
certificates
import
api
as
certs_api
from
certificates.models
import
CertificateGenerationConfiguration
from
certificates.signals
import
_listen_for_course_p
ublish
from
certificates.signals
import
_listen_for_course_p
acing_changed
from
openedx.core.djangoapps.self_paced.models
import
SelfPacedConfiguration
from
xmodule.modulestore.tests.django_utils
import
ModuleStoreTestCase
from
xmodule.modulestore.tests.factories
import
CourseFactory
...
...
@@ -22,23 +22,19 @@ class SelfGeneratedCertsSignalTest(ModuleStoreTestCase):
# Enable the feature
CertificateGenerationConfiguration
.
objects
.
create
(
enabled
=
True
)
def
test_cert_generation_enabled_for_self_paced
(
self
):
def
test_cert_generation_flag_on_pacing_toggle
(
self
):
"""
Verify th
e signal enables the self-generated certificates for
self-paced courses
.
Verify th
at signal enables or disables self-generated certificates
according to course-pacing
.
"""
self
.
assertFalse
(
certs_api
.
cert_generation_enabled
(
self
.
course
.
id
))
_listen_for_course_p
ublish
(
'store'
,
self
.
course
.
id
,
self
.
course
.
self_paced
)
_listen_for_course_p
acing_changed
(
'store'
,
self
.
course
.
id
,
self
.
course
.
self_paced
)
self
.
assertTrue
(
certs_api
.
cert_generation_enabled
(
self
.
course
.
id
))
def
test_cert_generation_disabled_for_instructor_paced
(
self
):
"""
Verify the signal disables the self-generated certificates for
instructor-paced courses.
"""
self
.
course
.
self_paced
=
False
self
.
store
.
update_item
(
self
.
course
,
self
.
user
.
id
)
_listen_for_course_p
ublish
(
'store'
,
self
.
course
.
id
,
self
.
course
.
self_paced
)
_listen_for_course_p
acing_changed
(
'store'
,
self
.
course
.
id
,
self
.
course
.
self_paced
)
self
.
assertFalse
(
certs_api
.
cert_generation_enabled
(
self
.
course
.
id
))
openedx/core/djangoapps/models/course_details.py
View file @
b84d4c02
...
...
@@ -191,6 +191,7 @@ class CourseDetails(object):
descriptor
=
module_store
.
get_course
(
course_key
)
dirty
=
False
is_pacing_changed
=
False
# In the descriptor's setter, the date is converted to JSON
# using Date's to_json method. Calling to_json on something that
...
...
@@ -274,8 +275,7 @@ class CourseDetails(object):
and
jsondict
[
'self_paced'
]
!=
descriptor
.
self_paced
):
descriptor
.
self_paced
=
jsondict
[
'self_paced'
]
dirty
=
True
# sends out the signal that course pacing has changed
COURSE_PACING_CHANGE
.
send
(
sender
=
None
,
course_key
=
course_key
,
course_self_paced
=
descriptor
.
self_paced
)
is_pacing_changed
=
True
if
dirty
:
module_store
.
update_item
(
descriptor
,
user
.
id
)
...
...
@@ -290,6 +290,10 @@ class CourseDetails(object):
cls
.
update_about_video
(
descriptor
,
jsondict
[
'intro_video'
],
user
.
id
)
# fires the signal that course pacing has changed after changes are reflected in db
if
is_pacing_changed
:
COURSE_PACING_CHANGE
.
send
(
sender
=
None
,
course_key
=
course_key
,
course_self_paced
=
descriptor
.
self_paced
)
# Could just return jsondict w/o doing any db reads, but I put
# the reads in as a means to confirm it persisted correctly
return
CourseDetails
.
fetch
(
course_key
)
...
...
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