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
476f6821
Commit
476f6821
authored
Oct 14, 2015
by
Giovanni Di Milia
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed pylint violation for files in lms/djangoapps/certificates
parent
6fb89fee
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
53 additions
and
29 deletions
+53
-29
lms/djangoapps/certificates/management/commands/cert_whitelist.py
+6
-1
lms/djangoapps/certificates/management/commands/fix_ungraded_certs.py
+8
-0
lms/djangoapps/certificates/management/commands/gen_cert_report.py
+14
-11
lms/djangoapps/certificates/management/commands/regenerate_user.py
+5
-0
lms/djangoapps/certificates/management/commands/ungenerated_certs.py
+4
-0
lms/djangoapps/certificates/models.py
+13
-5
lms/djangoapps/certificates/tests/test_api.py
+2
-2
lms/djangoapps/certificates/tests/test_views.py
+1
-10
No files found.
lms/djangoapps/certificates/management/commands/cert_whitelist.py
View file @
476f6821
...
...
@@ -25,6 +25,10 @@ def get_user_from_identifier(identifier):
class
Command
(
BaseCommand
):
"""
Management command to set or get the certificate whitelist
for a given user(s)/course
"""
help
=
"""
Sets or gets the certificate whitelist for a given
...
...
@@ -88,7 +92,8 @@ class Command(BaseCommand):
try
:
course
=
CourseKey
.
from_string
(
course_id
)
except
InvalidKeyError
:
print
(
"Course id {} could not be parsed as a CourseKey; falling back to SSCK.from_dep_str"
.
format
(
course_id
))
print
((
"Course id {} could not be parsed as a CourseKey; "
"falling back to SSCK.from_dep_str"
)
.
format
(
course_id
))
course
=
SlashSeparatedCourseKey
.
from_deprecated_string
(
course_id
)
if
options
[
'add'
]
and
options
[
'del'
]:
...
...
lms/djangoapps/certificates/management/commands/fix_ungraded_certs.py
View file @
476f6821
"""
Management command which fixes ungraded certificates for students
"""
from
certificates.models
import
GeneratedCertificate
from
courseware
import
grades
,
courses
from
django.test.client
import
RequestFactory
...
...
@@ -6,6 +11,9 @@ from optparse import make_option
class
Command
(
BaseCommand
):
"""
Management command to find and grade all students that need to be graded.
"""
help
=
"""
Find all students that need to be graded
...
...
lms/djangoapps/certificates/management/commands/gen_cert_report.py
View file @
476f6821
...
...
@@ -13,6 +13,10 @@ from django.db.models import Count
class
Command
(
BaseCommand
):
"""
Management command to generate a certificate status
report for a given course.
"""
help
=
"""
...
...
@@ -48,7 +52,8 @@ class Command(BaseCommand):
try
:
course_id
=
CourseKey
.
from_string
(
options
[
'course'
])
except
InvalidKeyError
:
print
(
"Course id {} could not be parsed as a CourseKey; falling back to SSCK.from_dep_str"
.
format
(
options
[
'course'
]))
print
(
"Course id {} could not be parsed as a CourseKey; "
"falling back to SSCK.from_dep_str"
)
.
format
(
options
[
'course'
])
course_id
=
SlashSeparatedCourseKey
.
from_deprecated_string
(
options
[
'course'
])
else
:
raise
CommandError
(
"You must specify a course"
)
...
...
@@ -90,8 +95,10 @@ class Command(BaseCommand):
)
cert_data
[
course_id
]
.
update
(
{
status
[
'status'
]:
status
[
'dcount'
]
for
status
in
status_tally
})
{
status
[
'status'
]:
status
[
'dcount'
]
for
status
in
status_tally
}
)
mode_tally
=
GeneratedCertificate
.
objects
.
filter
(
course_id__exact
=
course_id
,
...
...
@@ -100,21 +107,17 @@ class Command(BaseCommand):
dcount
=
Count
(
'mode'
)
)
cert_data
[
course_id
]
.
update
(
{
mode
[
'mode'
]:
mode
[
'dcount'
]
for
mode
in
mode_tally
}
{
mode
[
'mode'
]:
mode
[
'dcount'
]
for
mode
in
mode_tally
}
)
# all states we have seen far all courses
status_headings
=
sorted
(
set
(
[
status
for
course
in
cert_data
for
status
in
cert_data
[
course
]])
status_headings
=
sorted
(
set
([
status
for
course
in
cert_data
for
status
in
cert_data
[
course
]])
)
# print the heading for the report
print
"{:>26}"
.
format
(
"course ID"
),
print
' '
.
join
([
"{:>16}"
.
format
(
heading
)
for
heading
in
status_headings
]
)
print
' '
.
join
([
"{:>16}"
.
format
(
heading
)
for
heading
in
status_headings
])
# print the report
print
"{0:>26}"
.
format
(
course_id
.
to_deprecated_string
()),
...
...
lms/djangoapps/certificates/management/commands/regenerate_user.py
View file @
476f6821
...
...
@@ -16,6 +16,11 @@ LOGGER = logging.getLogger(__name__)
class
Command
(
BaseCommand
):
"""
Management command to recreate the certificate for
a given user in a given course.
"""
help
=
"""Put a request on the queue to recreate the certificate for a particular user in a particular course."""
option_list
=
BaseCommand
.
option_list
+
(
...
...
lms/djangoapps/certificates/management/commands/ungenerated_certs.py
View file @
476f6821
...
...
@@ -21,6 +21,10 @@ LOGGER = logging.getLogger(__name__)
class
Command
(
BaseCommand
):
"""
Management command to find all students that need certificates
for courses that have finished and put their cert requests on the queue.
"""
help
=
"""
Find all students that need certificates for courses that have finished and
...
...
lms/djangoapps/certificates/models.py
View file @
476f6821
...
...
@@ -71,6 +71,9 @@ LOGGER = logging.getLogger(__name__)
class
CertificateStatuses
(
object
):
"""
Enum for certificate statuses
"""
deleted
=
'deleted'
deleting
=
'deleting'
downloadable
=
'downloadable'
...
...
@@ -108,6 +111,9 @@ class CertificateWhitelist(models.Model):
class
GeneratedCertificate
(
models
.
Model
):
"""
Base model for generated certificates
"""
MODES
=
Choices
(
'verified'
,
'honor'
,
'audit'
,
'professional'
,
'no-id-professional'
)
...
...
@@ -191,14 +197,16 @@ def certificate_status_for_student(student, course_id):
try
:
generated_certificate
=
GeneratedCertificate
.
objects
.
get
(
user
=
student
,
course_id
=
course_id
)
d
=
{
'status'
:
generated_certificate
.
status
,
'mode'
:
generated_certificate
.
mode
}
cert_status
=
{
'status'
:
generated_certificate
.
status
,
'mode'
:
generated_certificate
.
mode
}
if
generated_certificate
.
grade
:
d
[
'grade'
]
=
generated_certificate
.
grade
cert_status
[
'grade'
]
=
generated_certificate
.
grade
if
generated_certificate
.
status
==
CertificateStatuses
.
downloadable
:
d
[
'download_url'
]
=
generated_certificate
.
download_url
cert_status
[
'download_url'
]
=
generated_certificate
.
download_url
return
d
return
cert_status
except
GeneratedCertificate
.
DoesNotExist
:
pass
return
{
'status'
:
CertificateStatuses
.
unavailable
,
'mode'
:
GeneratedCertificate
.
MODES
.
honor
}
...
...
lms/djangoapps/certificates/tests/test_api.py
View file @
476f6821
...
...
@@ -118,7 +118,7 @@ class GenerateUserCertificatesTest(EventTestMixin, ModuleStoreTestCase):
ERROR_REASON
=
"Kaboom!"
def
setUp
(
self
):
def
setUp
(
self
):
# pylint: disable=arguments-differ
super
(
GenerateUserCertificatesTest
,
self
)
.
setUp
(
'certificates.api.tracker'
)
self
.
student
=
UserFactory
.
create
(
...
...
@@ -233,7 +233,7 @@ class CertificateGenerationEnabledTest(EventTestMixin, TestCase):
COURSE_KEY
=
CourseLocator
(
org
=
'test'
,
course
=
'test'
,
run
=
'test'
)
def
setUp
(
self
):
def
setUp
(
self
):
# pylint: disable=arguments-differ
super
(
CertificateGenerationEnabledTest
,
self
)
.
setUp
(
'certificates.api.tracker'
)
# Since model-based configuration is cached, we need
...
...
lms/djangoapps/certificates/tests/test_views.py
View file @
476f6821
...
...
@@ -15,7 +15,7 @@ from django.test.utils import override_settings
from
opaque_keys.edx.locator
import
CourseLocator
from
openedx.core.lib.tests.assertions.events
import
assert_event_matches
from
student.tests.factories
import
UserFactory
,
CourseEnrollmentFactory
from
student.tests.factories
import
UserFactory
from
track.tests
import
EventTrackingTestCase
from
xmodule.modulestore.tests.factories
import
CourseFactory
from
xmodule.modulestore.tests.django_utils
import
ModuleStoreTestCase
...
...
@@ -26,21 +26,12 @@ from certificates.models import (
ExampleCertificateSet
,
ExampleCertificate
,
GeneratedCertificate
,
BadgeAssertion
,
CertificateStatuses
,
CertificateHtmlViewConfiguration
,
CertificateSocialNetworks
,
CertificateTemplate
,
)
from
certificates.tests.factories
import
(
CertificateHtmlViewConfigurationFactory
,
LinkedInAddToProfileConfigurationFactory
,
BadgeAssertionFactory
,
)
from
util
import
organizations_helpers
as
organizations_api
from
django.test.client
import
RequestFactory
import
urllib
FEATURES_WITH_CERTS_ENABLED
=
settings
.
FEATURES
.
copy
()
FEATURES_WITH_CERTS_ENABLED
[
'CERTIFICATES_HTML_VIEW'
]
=
True
...
...
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