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
416b5458
Commit
416b5458
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
Certificate model for tracking certificate statuses
parent
29ed95c1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
44 additions
and
47 deletions
+44
-47
lms/djangoapps/certificates/models.py
+44
-47
No files found.
lms/djangoapps/certificates/models.py
View file @
416b5458
...
...
@@ -7,71 +7,68 @@ Certificates are created for a student and an offering of a course.
When a certificate is generated, a unique ID is generated so that
the certificate can be verified later. The ID is a UUID4, so that
it can't be easily guessed and so that it is unique. Even though
we save these generated certificates (for later verification), we
also record the UUID so that if we regenerate the certificate it
will have the same UUID.
it can't be easily guessed and so that it is unique.
Certificates are generated in batches by a cron job, when a
certificate is available for download the GeneratedCertificate
table is updated with information that will be displayed
on the course overview page.
'''
class
CertificateStatuses
(
object
):
unavailable
=
'unavailable'
generating
=
'generating'
regenerating
=
'regenerating'
deleting
=
'deleting'
deleted
=
'deleted'
downloadable
=
'downloadable'
error
=
'error'
class
GeneratedCertificate
(
models
.
Model
):
user
=
models
.
ForeignKey
(
User
)
course_id
=
models
.
CharField
(
max_length
=
255
,
default
=
False
)
certificate_id
=
models
.
CharField
(
max_length
=
32
,
default
=
False
)
graded_certificate_id
=
models
.
CharField
(
max_length
=
32
,
default
=
False
)
download_url
=
models
.
CharField
(
max_length
=
128
,
default
=
False
)
graded_download_url
=
models
.
CharField
(
max_length
=
128
,
default
=
False
)
grade
=
models
.
CharField
(
max_length
=
5
,
default
=
False
)
key
=
models
.
CharField
(
max_length
=
32
,
default
=
False
)
# enabled should only be true if the student has earned a passing grade
# in the course.
enabled
=
models
.
BooleanField
(
default
=
False
)
def
certificate_state_for_student
(
student
):
course_id
=
models
.
CharField
(
max_length
=
255
,
blank
=
True
,
default
=
''
)
verify_uuid
=
models
.
CharField
(
max_length
=
32
,
blank
=
True
,
default
=
''
)
download_uuid
=
models
.
CharField
(
max_length
=
32
,
blank
=
True
,
default
=
''
)
download_url
=
models
.
CharField
(
max_length
=
128
,
blank
=
True
,
default
=
''
)
grade
=
models
.
CharField
(
max_length
=
5
,
blank
=
True
,
default
=
''
)
key
=
models
.
CharField
(
max_length
=
32
,
blank
=
True
,
default
=
''
)
distinction
=
models
.
BooleanField
(
default
=
False
)
status
=
models
.
CharField
(
max_length
=
32
,
default
=
'unavailable'
)
class
Meta
:
unique_together
=
((
'user'
,
'course_id'
),)
def
certificate_status_for_student
(
student
,
course_id
):
'''
This returns a dictionary with a key for stat
e
, and other information.
The stat
e
is one of the following:
This returns a dictionary with a key for stat
us
, and other information.
The stat
us
is one of the following:
unavailable - A student is not eligible for a certificate.
generating - A student has requested a certificate,
but it is not generated yet.
downloadable - The certificate has been requested and is
available for download.
If the state is "downloadable", the dictionary also contains
"download_url" and "graded_download_url".
generating - A request has been made to generate a certificate,
but it has not been generated yet.
regenerating - A request has been made to regenerate a certificate,
but it has not been generated yet.
deleting - A request has been made to delete a certificate.
deleted - The certificate has been deleted.
downloadable - The certificate is available for download.
If the status is "downloadable", the dictionary also contains
"download_url".
'''
try
:
generated_certificate
=
GeneratedCertificate
.
objects
.
get
(
user
=
student
)
if
generated_certificate
.
enabled
:
if
generated_certificate
.
download_url
:
return
{
'state'
:
'downloadable'
,
'download_url'
:
generated_certificate
.
download_url
,
'graded_download_url'
:
generated_certificate
.
graded_download_url
}
else
:
return
{
'state'
:
'generating'
}
else
:
# If enabled=False, there is no certificate available
# Our output will be the same as if the
# GeneratedCertificate did not exist
pass
user
=
student
,
course_id
=
course_id
)
if
generated_certificate
.
status
==
CertificateStatuses
.
downloadable
:
return
{
'status'
:
CertificateStatuses
.
downloadable
,
'download_url'
:
generated_certificate
.
download_url
,
}
else
:
return
{
'status'
:
generated_certificate
.
status
}
except
GeneratedCertificate
.
DoesNotExist
:
pass
return
{
'stat
e
'
:
'unavailable'
}
return
{
'stat
us
'
:
'unavailable'
}
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