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
f53b3c09
Commit
f53b3c09
authored
Nov 01, 2012
by
John Jarvis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Certificate model for tracking certificate statuses
parent
8b437c26
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 @
f53b3c09
...
@@ -7,71 +7,68 @@ Certificates are created for a student and an offering of a course.
...
@@ -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
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
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
it can't be easily guessed and so that it is unique.
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.
Certificates are generated in batches by a cron job, when a
Certificates are generated in batches by a cron job, when a
certificate is available for download the GeneratedCertificate
certificate is available for download the GeneratedCertificate
table is updated with information that will be displayed
table is updated with information that will be displayed
on the course overview page.
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
):
class
GeneratedCertificate
(
models
.
Model
):
user
=
models
.
ForeignKey
(
User
)
user
=
models
.
ForeignKey
(
User
)
course_id
=
models
.
CharField
(
max_length
=
255
,
default
=
False
)
course_id
=
models
.
CharField
(
max_length
=
255
,
blank
=
True
,
default
=
''
)
certificate_id
=
models
.
CharField
(
max_length
=
32
,
default
=
False
)
verify_uuid
=
models
.
CharField
(
max_length
=
32
,
blank
=
True
,
default
=
''
)
graded_certificate_id
=
models
.
CharField
(
max_length
=
32
,
default
=
False
)
download_uuid
=
models
.
CharField
(
max_length
=
32
,
blank
=
True
,
default
=
''
)
download_url
=
models
.
CharField
(
max_length
=
128
,
blank
=
True
,
default
=
''
)
download_url
=
models
.
CharField
(
max_length
=
128
,
default
=
False
)
grade
=
models
.
CharField
(
max_length
=
5
,
blank
=
True
,
default
=
''
)
graded_download_url
=
models
.
CharField
(
max_length
=
128
,
default
=
False
)
key
=
models
.
CharField
(
max_length
=
32
,
blank
=
True
,
default
=
''
)
grade
=
models
.
CharField
(
max_length
=
5
,
default
=
False
)
distinction
=
models
.
BooleanField
(
default
=
False
)
key
=
models
.
CharField
(
max_length
=
32
,
default
=
False
)
status
=
models
.
CharField
(
max_length
=
32
,
default
=
'unavailable'
)
# enabled should only be true if the student has earned a passing grade
class
Meta
:
# in the course.
unique_together
=
((
'user'
,
'course_id'
),)
enabled
=
models
.
BooleanField
(
default
=
False
)
def
certificate_status_for_student
(
student
,
course_id
):
def
certificate_state_for_student
(
student
):
'''
'''
This returns a dictionary with a key for stat
e
, and other information.
This returns a dictionary with a key for stat
us
, and other information.
The stat
e
is one of the following:
The stat
us
is one of the following:
unavailable - A student is not eligible for a certificate.
unavailable - A student is not eligible for a certificate.
generating - A student has requested a certificate,
generating - A request has been made to generate a certificate,
but it is not generated yet.
but it has not been generated yet.
downloadable - The certificate has been requested and is
regenerating - A request has been made to regenerate a certificate,
available for download.
but it has not been generated yet.
deleting - A request has been made to delete a certificate.
If the state is "downloadable", the dictionary also contains
"download_url" and "graded_download_url".
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
:
try
:
generated_certificate
=
GeneratedCertificate
.
objects
.
get
(
generated_certificate
=
GeneratedCertificate
.
objects
.
get
(
user
=
student
)
user
=
student
,
course_id
=
course_id
)
if
generated_certificate
.
enabled
:
if
generated_certificate
.
status
==
CertificateStatuses
.
downloadable
:
if
generated_certificate
.
download_url
:
return
{
return
{
'status'
:
CertificateStatuses
.
downloadable
,
'state'
:
'downloadable'
,
'download_url'
:
generated_certificate
.
download_url
,
'download_url'
:
}
generated_certificate
.
download_url
,
else
:
'graded_download_url'
:
return
{
'status'
:
generated_certificate
.
status
}
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
except
GeneratedCertificate
.
DoesNotExist
:
except
GeneratedCertificate
.
DoesNotExist
:
pass
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