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
44141b6a
Commit
44141b6a
authored
Jan 16, 2013
by
John Jarvis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
pep8 cleanup
parent
491027a8
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
19 deletions
+17
-19
lms/djangoapps/certificates/management/commands/ungenerated_certs.py
+17
-19
No files found.
lms/djangoapps/certificates/management/commands/ungenerated_certs.py
View file @
44141b6a
...
...
@@ -23,26 +23,24 @@ class Command(BaseCommand):
option_list
=
BaseCommand
.
option_list
+
(
make_option
(
'-n'
,
'--noop'
,
action
=
'store_true'
,
dest
=
'noop'
,
default
=
False
,
help
=
"Don't add certificate requests to the queue"
),
action
=
'store_true'
,
dest
=
'noop'
,
default
=
False
,
help
=
"Don't add certificate requests to the queue"
),
make_option
(
'-c'
,
'--course'
,
metavar
=
'COURSE_ID'
,
dest
=
'course'
,
default
=
False
,
help
=
'Grade and generate certificates for a specific course'
),
)
metavar
=
'COURSE_ID'
,
dest
=
'course'
,
default
=
False
,
help
=
'Grade and generate certificates '
'for a specific course'
),
)
def
handle
(
self
,
*
args
,
**
options
):
# Will only generate a certificate if the current
# status is in this state
VALID_STATUSES
=
[
CertificateStatuses
.
unavailable
]
VALID_STATUSES
=
[
CertificateStatuses
.
unavailable
]
# Print update after this many students
...
...
@@ -54,8 +52,8 @@ class Command(BaseCommand):
# Find all courses that have ended
ended_courses
=
[]
for
course_id
in
[
course
# all courses in COURSE_LISTINGS
for
sub
in
settings
.
COURSE_LISTINGS
for
course
in
settings
.
COURSE_LISTINGS
[
sub
]]:
for
sub
in
settings
.
COURSE_LISTINGS
for
course
in
settings
.
COURSE_LISTINGS
[
sub
]]:
course_loc
=
CourseDescriptor
.
id_to_location
(
course_id
)
course
=
modulestore
()
.
get_instance
(
course_id
,
course_loc
)
if
course
.
has_ended
():
...
...
@@ -64,8 +62,8 @@ class Command(BaseCommand):
for
course_id
in
ended_courses
:
print
"Fetching enrolled students for {0}"
.
format
(
course_id
)
enrolled_students
=
User
.
objects
.
filter
(
courseenrollment__course_id
=
course_id
)
.
prefetch_related
(
"groups"
)
.
order_by
(
'username'
)
courseenrollment__course_id
=
course_id
)
.
prefetch_related
(
"groups"
)
.
order_by
(
'username'
)
xq
=
XQueueCertInterface
()
total
=
enrolled_students
.
count
()
count
=
0
...
...
@@ -81,11 +79,11 @@ class Command(BaseCommand):
hours
,
remainder
=
divmod
(
timeleft
.
seconds
,
3600
)
minutes
,
seconds
=
divmod
(
remainder
,
60
)
print
"{0}/{1} completed ~{2:02}:{3:02}m remaining"
.
format
(
count
,
total
,
hours
,
minutes
)
count
,
total
,
hours
,
minutes
)
start
=
datetime
.
datetime
.
now
()
if
certificate_status_for_student
(
student
,
course_id
)[
'status'
]
in
VALID_STATUSES
:
student
,
course_id
)[
'status'
]
in
VALID_STATUSES
:
if
not
options
[
'noop'
]:
# Add the certificate request to the queue
ret
=
xq
.
add_cert
(
student
,
course_id
)
...
...
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