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
83859e1d
Commit
83859e1d
authored
Nov 09, 2012
by
John Jarvis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Cleanup and django-admin commands
parent
f908ef71
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
60 additions
and
18 deletions
+60
-18
lms/djangoapps/certificates/management/commands/find_unusual_certs.py
+36
-0
lms/djangoapps/certificates/management/commands/ungenerated_certs.py
+16
-14
lms/djangoapps/certificates/models.py
+8
-4
No files found.
lms/djangoapps/certificates/management/commands/find_unusual_certs.py
0 → 100644
View file @
83859e1d
# -*- coding: utf-8 -*-
from
django.core.management.base
import
BaseCommand
from
certificates.models
import
GeneratedCertificate
from
certificates.queue
import
XQueueCertInterface
from
django.contrib.auth.models
import
User
from
student.models
import
UserProfile
import
sys
class
Command
(
BaseCommand
):
help
=
"""
Looks for names that have unicode characters
and queues them up for a certificate request
"""
def
handle
(
self
,
*
args
,
**
options
):
course_id
=
'BerkeleyX/CS169.1x/2012_Fall'
enrolled_students
=
User
.
objects
.
filter
(
courseenrollment__course_id
=
course_id
)
.
prefetch_related
(
"groups"
)
.
order_by
(
'username'
)
xq
=
XQueueCertInterface
()
print
"Looking for unusual names.."
for
student
in
enrolled_students
:
if
certificate_status_for_student
(
student
,
course_id
)[
'status'
]
==
'unavailable'
:
continue
name
=
UserProfile
.
objects
.
get
(
user
=
student
)
.
name
for
c
in
name
:
if
ord
(
c
)
>=
0x200
:
ret
=
xq
.
add_cert
(
student
,
course_id
)
if
ret
==
'generating'
:
print
'generating for {0}'
.
format
(
student
)
break
lms/djangoapps/certificates/management/commands/ungenerated_certs.py
View file @
83859e1d
from
django.core.management.base
import
BaseCommand
from
django.core.management.base
import
BaseCommand
from
certificates.models
import
GeneratedCertificate
from
certificates.models
import
GeneratedCertificate
from
certificates.models
import
certificate_status_for_student
from
certificates.queue
import
XQueueCertInterface
from
certificates.queue
import
XQueueCertInterface
from
django.contrib.auth.models
import
User
from
django.contrib.auth.models
import
User
...
@@ -13,22 +14,23 @@ class Command(BaseCommand):
...
@@ -13,22 +14,23 @@ class Command(BaseCommand):
def
handle
(
self
,
*
args
,
**
options
):
def
handle
(
self
,
*
args
,
**
options
):
course_id
=
'BerkeleyX/CS169.1x/2012_Fall'
help
=
"""
Find all students that have need certificates
and put certificate requests on the queue
This is only for BerkeleyX/CS169.1x/2012_Fall
"""
enrolled_students
=
User
.
objects
.
filter
(
def
handle
(
self
,
*
args
,
**
options
):
course_id
=
'BerkeleyX/CS169.1x/2012_Fall'
enrolled_students
=
User
.
objects
.
filter
(
id
=
444894
,
courseenrollment__course_id
=
course_id
)
.
prefetch_related
(
courseenrollment__course_id
=
course_id
)
.
prefetch_related
(
"groups"
)
.
order_by
(
'username'
)
"groups"
)
.
order_by
(
'username'
)
xq
=
XQueueCertInterface
()
xq
=
XQueueCertInterface
()
# TODO (this is for debugging, remove)
for
c
in
GeneratedCertificate
.
objects
.
all
():
c
.
delete
()
count
=
0
for
student
in
enrolled_students
:
for
student
in
enrolled_students
:
ret
=
xq
.
add_cert
(
student
,
course_id
)
if
certificate_status_for_student
(
if
ret
==
'generating'
:
student
,
course_id
)[
'status'
]
==
'unavailable'
:
print
'generating for {0}'
.
format
(
student
)
ret
=
xq
.
add_cert
(
student
,
course_id
)
count
+=
1
if
ret
==
'generating'
:
if
count
>
10
:
print
'generating for {0}'
.
format
(
student
)
break
lms/djangoapps/certificates/models.py
View file @
83859e1d
...
@@ -37,6 +37,7 @@ State diagram:
...
@@ -37,6 +37,7 @@ State diagram:
"""
"""
class
CertificateStatuses
(
object
):
class
CertificateStatuses
(
object
):
unavailable
=
'unavailable'
unavailable
=
'unavailable'
generating
=
'generating'
generating
=
'generating'
...
@@ -83,20 +84,23 @@ def certificate_status_for_student(student, course_id):
...
@@ -83,20 +84,23 @@ def certificate_status_for_student(student, course_id):
deleted - The certificate has been deleted.
deleted - The certificate has been deleted.
downloadable - The certificate is available for download.
downloadable - The certificate is available for download.
notpassing - The student was graded but is not passing
If the status is "downloadable", the dictionary also contains
If the status is "downloadable", the dictionary also contains
"download_url".
"download_url".
If the student has been graded, the dictionary also contains their grade for the course.
If the student has been graded, the dictionary also contains their
grade for the course.
'''
'''
try
:
try
:
generated_certificate
=
GeneratedCertificate
.
objects
.
get
(
generated_certificate
=
GeneratedCertificate
.
objects
.
get
(
user
=
student
,
course_id
=
course_id
)
user
=
student
,
course_id
=
course_id
)
d
=
{
'status'
:
generated_certificate
.
status
,
d
=
{
'status'
:
generated_certificate
.
status
}
'grade'
:
generated_certificate
.
grade
,}
if
generated_certificate
.
grade
:
d
[
'grade'
]
=
generated_certificate
.
grade
if
generated_certificate
.
status
==
CertificateStatuses
.
downloadable
:
if
generated_certificate
.
status
==
CertificateStatuses
.
downloadable
:
d
[
'download_url'
]
=
generated_certificate
.
download_url
d
[
'download_url'
]
=
generated_certificate
.
download_url
return
d
return
d
except
GeneratedCertificate
.
DoesNotExist
:
except
GeneratedCertificate
.
DoesNotExist
:
...
...
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