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
921dc602
Commit
921dc602
authored
8 years ago
by
Waheed Ahmed
Committed by
Clinton Blackburn
8 years ago
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Automatically enable Self Generating Certificates for Self Paced Courses.
ECOM-3437
parent
f7c28f65
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
84 additions
and
21 deletions
+84
-21
lms/djangoapps/certificates/__init__.py
+3
-0
lms/djangoapps/certificates/signals.py
+26
-0
lms/djangoapps/certificates/tests/test_signals.py
+31
-0
lms/djangoapps/instructor/views/instructor_dashboard.py
+1
-0
lms/templates/instructor/instructor_dashboard_2/certificates.html
+23
-21
No files found.
lms/djangoapps/certificates/__init__.py
View file @
921dc602
""" Certificates app """
# this is here to support registering the signals in signals.py
from
.
import
signals
This diff is collapsed.
Click to expand it.
lms/djangoapps/certificates/signals.py
0 → 100644
View file @
921dc602
""" Signal handler for enabling self-generated certificates by default
for self-paced courses.
"""
from
celery.task
import
task
from
django.dispatch.dispatcher
import
receiver
from
certificates.models
import
CertificateGenerationCourseSetting
from
xmodule.modulestore.django
import
SignalHandler
,
modulestore
@receiver
(
SignalHandler
.
course_published
)
def
_listen_for_course_publish
(
sender
,
course_key
,
**
kwargs
):
# pylint: disable=unused-argument
""" Catches the signal that a course has been published in Studio and
enable the self-generated certificates by default for self-paced
courses.
"""
enable_self_generated_certs
.
delay
(
course_key
)
@task
()
def
enable_self_generated_certs
(
course_key
):
"""Enable the self-generated certificates by default for self-paced courses."""
course
=
modulestore
()
.
get_course
(
course_key
)
is_enabled_for_course
=
CertificateGenerationCourseSetting
.
is_enabled_for_course
(
course_key
)
if
course
.
self_paced
and
not
is_enabled_for_course
:
CertificateGenerationCourseSetting
.
set_enabled_for_course
(
course_key
,
True
)
This diff is collapsed.
Click to expand it.
lms/djangoapps/certificates/tests/test_signals.py
0 → 100644
View file @
921dc602
""" Unit tests for enabling self-generated certificates by default
for self-paced courses.
"""
from
certificates
import
api
as
certs_api
from
certificates.models
import
CertificateGenerationConfiguration
from
certificates.signals
import
_listen_for_course_publish
from
openedx.core.djangoapps.self_paced.models
import
SelfPacedConfiguration
from
xmodule.modulestore.tests.factories
import
CourseFactory
from
xmodule.modulestore.tests.django_utils
import
ModuleStoreTestCase
class
SelfGeneratedCertsSignalTest
(
ModuleStoreTestCase
):
""" Tests for enabling self-generated certificates by default
for self-paced courses.
"""
def
setUp
(
self
):
super
(
SelfGeneratedCertsSignalTest
,
self
)
.
setUp
()
SelfPacedConfiguration
(
enabled
=
True
)
.
save
()
self
.
course
=
CourseFactory
.
create
(
self_paced
=
True
)
# Enable the feature
CertificateGenerationConfiguration
.
objects
.
create
(
enabled
=
True
)
def
test_cert_generation_enabled_for_self_paced
(
self
):
""" Verify the signal enable the self-generated certificates by default for
self-paced courses.
"""
self
.
assertFalse
(
certs_api
.
cert_generation_enabled
(
self
.
course
.
id
))
_listen_for_course_publish
(
'store'
,
self
.
course
.
id
)
self
.
assertTrue
(
certs_api
.
cert_generation_enabled
(
self
.
course
.
id
))
This diff is collapsed.
Click to expand it.
lms/djangoapps/instructor/views/instructor_dashboard.py
View file @
921dc602
...
@@ -327,6 +327,7 @@ def _section_certificates(course):
...
@@ -327,6 +327,7 @@ def _section_certificates(course):
'example_certificate_status'
:
example_cert_status
,
'example_certificate_status'
:
example_cert_status
,
'can_enable_for_course'
:
can_enable_for_course
,
'can_enable_for_course'
:
can_enable_for_course
,
'enabled_for_course'
:
certs_api
.
cert_generation_enabled
(
course
.
id
),
'enabled_for_course'
:
certs_api
.
cert_generation_enabled
(
course
.
id
),
'is_self_paced'
:
course
.
self_paced
,
'instructor_generation_enabled'
:
instructor_generation_enabled
,
'instructor_generation_enabled'
:
instructor_generation_enabled
,
'html_cert_enabled'
:
html_cert_enabled
,
'html_cert_enabled'
:
html_cert_enabled
,
'active_certificate'
:
certs_api
.
get_active_web_certificate
(
course
),
'active_certificate'
:
certs_api
.
get_active_web_certificate
(
course
),
...
...
This diff is collapsed.
Click to expand it.
lms/templates/instructor/instructor_dashboard_2/certificates.html
View file @
921dc602
...
@@ -50,27 +50,29 @@ from openedx.core.djangolib.js_utils import dump_js_escaped_json, js_escaped_str
...
@@ -50,27 +50,29 @@ from openedx.core.djangolib.js_utils import dump_js_escaped_json, js_escaped_str
% endif
% endif
</div>
</div>
<hr
/>
% if not section_data['is_self_paced']:
<hr
/>
<div
class=
"enable-certificates"
>
<h2>
${_("Student-Generated Certificates")}
</h2>
<div
class=
"enable-certificates"
>
% if section_data['enabled_for_course']:
<h2>
${_("Student-Generated Certificates")}
</h2>
<form
id=
"enable-certificates-form"
method=
"post"
action=
"${section_data['urls']['enable_certificate_generation']}"
>
% if section_data['enabled_for_course']:
<input
type=
"hidden"
name=
"csrfmiddlewaretoken"
value=
"${csrf_token}"
>
<form
id=
"enable-certificates-form"
method=
"post"
action=
"${section_data['urls']['enable_certificate_generation']}"
>
<input
type=
"hidden"
id=
"certificates-enabled"
name=
"certificates-enabled"
value=
"false"
/>
<input
type=
"hidden"
name=
"csrfmiddlewaretoken"
value=
"${csrf_token}"
>
<input
type=
"submit"
class=
"btn-blue"
id=
"disable-certificates-submit"
value=
"${_('Disable Student-Generated Certificates')}"
/>
<input
type=
"hidden"
id=
"certificates-enabled"
name=
"certificates-enabled"
value=
"false"
/>
</form>
<input
type=
"submit"
class=
"btn-blue"
id=
"disable-certificates-submit"
value=
"${_('Disable Student-Generated Certificates')}"
/>
% elif section_data['can_enable_for_course']:
</form>
<form
id=
"enable-certificates-form"
method=
"post"
action=
"${section_data['urls']['enable_certificate_generation']}"
>
% elif section_data['can_enable_for_course']:
<input
type=
"hidden"
name=
"csrfmiddlewaretoken"
value=
"${csrf_token}"
>
<form
id=
"enable-certificates-form"
method=
"post"
action=
"${section_data['urls']['enable_certificate_generation']}"
>
<input
type=
"hidden"
id=
"certificates-enabled"
name=
"certificates-enabled"
value=
"true"
/>
<input
type=
"hidden"
name=
"csrfmiddlewaretoken"
value=
"${csrf_token}"
>
<input
type=
"submit"
class=
"btn-blue"
id=
"enable-certificates-submit"
value=
"${_('Enable Student-Generated Certificates')}"
/>
<input
type=
"hidden"
id=
"certificates-enabled"
name=
"certificates-enabled"
value=
"true"
/>
</form>
<input
type=
"submit"
class=
"btn-blue"
id=
"enable-certificates-submit"
value=
"${_('Enable Student-Generated Certificates')}"
/>
% else:
</form>
<p>
${_("You must successfully generate example certificates before you enable student-generated certificates.")}
</p>
% else:
<button
class=
"is-disabled"
disabled
>
${_('Enable Student-Generated Certificates')}
</button>
<p>
${_("You must successfully generate example certificates before you enable student-generated certificates.")}
</p>
% endif
<button
class=
"is-disabled"
disabled
>
${_('Enable Student-Generated Certificates')}
</button>
</div>
% endif
</div>
% endif
% if section_data['instructor_generation_enabled'] and not (section_data['enabled_for_course'] and section_data['html_cert_enabled']):
% if section_data['instructor_generation_enabled'] and not (section_data['enabled_for_course'] and section_data['html_cert_enabled']):
<hr
class=
"section-divider"
/>
<hr
class=
"section-divider"
/>
...
...
This diff is collapsed.
Click to expand it.
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