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
cb1489a7
Commit
cb1489a7
authored
Nov 01, 2012
by
John Jarvis
Committed by
Carlos Andrés Rocha
Nov 09, 2012
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
docstring cleanup, grading for regen_cert
parent
df37f111
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
46 additions
and
50 deletions
+46
-50
lms/djangoapps/certificates/queue.py
+46
-50
No files found.
lms/djangoapps/certificates/queue.py
View file @
cb1489a7
...
...
@@ -80,13 +80,11 @@ class XQueueCertInterface(object):
Removes certificate for a student, will change
the certificate status to 'regenerating'.
Will invalidate the old certificate and generate
a new one.
When completed the certificate status will chang
e
to 'downloadable'
Certificate must be in the 'error' or 'downloadable' stat
e
and the student must have a passing grade.
Returns the certificate status.
otherwise it will return the current state
"""
...
...
@@ -96,44 +94,49 @@ class XQueueCertInterface(object):
student
,
course_id
)[
'status'
]
if
cert_status
in
VALID_STATUSES
:
# grade the student
course
=
courses
.
get_course_by_id
(
course_id
)
grade
=
grades
.
grade
(
student
,
self
.
request
,
course
)
profile
=
UserProfile
.
objects
.
get
(
user
=
student
)
try
:
cert
=
GeneratedCertificate
.
objects
.
get
(
user
=
student
,
course_id
=
course_id
)
except
GeneratedCertificate
.
DoesNotExist
:
logger
.
warning
(
"Attempting to regenerate a certificate"
"for a user that doesn't have one"
)
raise
cert
.
status
=
status
.
regenerating
cert
.
name
=
profile
.
name
if
grade
[
'grade'
]
is
not
None
:
contents
=
{
'action'
:
'regen'
,
'remove_verify_uuid'
:
cert
.
verify_uuid
,
'remove_download_uuid'
:
cert
.
download_uuid
,
'username'
:
cert
.
user
.
username
,
'course_id'
:
cert
.
course_id
,
'name'
:
profile
.
name
,
}
profile
=
UserProfile
.
objects
.
get
(
user
=
student
)
try
:
cert
=
GeneratedCertificate
.
objects
.
get
(
user
=
student
,
course_id
=
course_id
)
except
GeneratedCertificate
.
DoesNotExist
:
logger
.
warning
(
"Attempting to regenerate a certificate"
"for a user that doesn't have one"
)
raise
cert
.
status
=
status
.
regenerating
cert
.
name
=
profile
.
name
key
=
cert
.
key
xheader
=
make_xheader
(
'http://{0}/certificate'
.
format
(
settings
.
SITE_NAME
),
key
,
'test-pull'
)
(
error
,
msg
)
=
self
.
xqueue_interface
.
send_to_queue
(
header
=
xheader
,
body
=
json
.
dumps
(
contents
))
if
error
:
logger
.
critical
(
'Unable to add a request to the queue'
)
raise
Exception
(
'Unable to send queue message'
)
cert
.
save
()
contents
=
{
'action'
:
'regen'
,
'remove_verify_uuid'
:
cert
.
verify_uuid
,
'remove_download_uuid'
:
cert
.
download_uuid
,
'username'
:
cert
.
user
.
username
,
'course_id'
:
cert
.
course_id
,
'name'
:
profile
.
name
,
}
key
=
cert
.
key
xheader
=
make_xheader
(
'http://{0}/certificate'
.
format
(
settings
.
SITE_NAME
),
key
,
'test-pull'
)
(
error
,
msg
)
=
self
.
xqueue_interface
.
send_to_queue
(
header
=
xheader
,
body
=
json
.
dumps
(
contents
))
if
error
:
logger
.
critical
(
'Unable to add a request to the queue'
)
raise
Exception
(
'Unable to send queue message'
)
cert
.
save
()
return
cert_status
def
del_cert
(
self
,
student
,
course_id
):
"""
"""
Arguments:
student - User.object
course_id - courseenrollment.course_id (string)
...
...
@@ -141,10 +144,8 @@ class XQueueCertInterface(object):
Removes certificate for a student, will change
the certificate status to 'deleting'.
When completed the certificate status will change
to 'deleted'.
Returns the certificate status.
Certificate must be in the 'error' or 'downloadable' state
otherwise it will return the current state
"""
...
...
@@ -189,19 +190,14 @@ class XQueueCertInterface(object):
student - User.object
course_id - courseenrollment.course_id (string)
Adds a new certificate request to the queue only if
the current certificate status is 'unavailable', 'error'
or 'deleted' and the student has a passing grade for
the course.
When completed the certificate status will change
to 'downloadable'.
Request a new certificate for a student.
Will change the certificate status to 'deleting'.
If the current status is 'generating', 'regenerating'
or 'deleting' this function will return that status
Certificate must be in the 'unavailable', 'error',
or 'deleted' state and the student must have
a passing grade.
Returns 'unavailable' if the student is eligible for
a certificate but does not have a passing grade.
otherwise it will return the current state
"""
...
...
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