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
3a8d4f41
Commit
3a8d4f41
authored
Nov 21, 2014
by
David Ormsbee
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Moved cert queuing from CSV into a background task.
parent
355d4be7
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
12 deletions
+13
-12
lms/djangoapps/certificates/queue.py
+1
-0
lms/djangoapps/instructor/views/api.py
+12
-12
No files found.
lms/djangoapps/certificates/queue.py
View file @
3a8d4f41
...
@@ -247,6 +247,7 @@ class XQueueCertInterface(object):
...
@@ -247,6 +247,7 @@ class XQueueCertInterface(object):
new_status
=
status
.
generating
new_status
=
status
.
generating
cert
.
status
=
new_status
cert
.
status
=
new_status
cert
.
save
()
cert
.
save
()
logger
.
info
(
"Requesting certificate generation for course {course_id}, user {username}"
.
format
(
**
contents
))
self
.
_send_to_xqueue
(
contents
,
key
)
self
.
_send_to_xqueue
(
contents
,
key
)
else
:
else
:
cert_status
=
status
.
notpassing
cert_status
=
status
.
notpassing
...
...
lms/djangoapps/instructor/views/api.py
View file @
3a8d4f41
...
@@ -11,6 +11,7 @@ import logging
...
@@ -11,6 +11,7 @@ import logging
import
re
import
re
import
time
import
time
import
requests
import
requests
from
celery.task
import
task
from
django.conf
import
settings
from
django.conf
import
settings
from
django_future.csrf
import
ensure_csrf_cookie
from
django_future.csrf
import
ensure_csrf_cookie
from
django.views.decorators.http
import
require_POST
from
django.views.decorators.http
import
require_POST
...
@@ -1598,6 +1599,7 @@ def calculate_grades_csv(request, course_id):
...
@@ -1598,6 +1599,7 @@ def calculate_grades_csv(request, course_id):
"status"
:
already_running_status
"status"
:
already_running_status
})
})
@task
()
def
_generate_certificates_from_grades_csv_task
(
course_id
,
filename
):
def
_generate_certificates_from_grades_csv_task
(
course_id
,
filename
):
"""Assume this will be run async later."""
"""Assume this will be run async later."""
report_store
=
ReportStore
.
from_config
()
report_store
=
ReportStore
.
from_config
()
...
@@ -1608,9 +1610,15 @@ def _generate_certificates_from_grades_csv_task(course_id, filename):
...
@@ -1608,9 +1610,15 @@ def _generate_certificates_from_grades_csv_task(course_id, filename):
csv_reader
=
csv
.
DictReader
(
grades_csv
)
csv_reader
=
csv
.
DictReader
(
grades_csv
)
xq
=
XQueueCertInterface
()
xq
=
XQueueCertInterface
()
for
row
in
csv_reader
:
for
row
in
csv_reader
:
student
=
User
.
objects
.
get
(
username
=
row
[
'username'
])
try
:
percentage_grade
=
float
(
row
[
'grade'
])
student
=
User
.
objects
.
get
(
username
=
row
[
'username'
])
xq
.
add_cert
(
student
,
course_key
,
course
=
course
,
forced_percentage_grade
=
percentage_grade
)
percentage_grade
=
float
(
row
[
'grade'
])
xq
.
add_cert
(
student
,
course_key
,
course
=
course
,
forced_percentage_grade
=
percentage_grade
)
except
Exception
as
exc
:
log
.
exception
(
"Error requesting certificate for user {} in course {} with file {}"
.
format
(
row
[
'username'
],
course_id
,
filename
)
)
@ensure_csrf_cookie
@ensure_csrf_cookie
...
@@ -1625,15 +1633,7 @@ def generate_certificates_from_grades_csv(request, course_id):
...
@@ -1625,15 +1633,7 @@ def generate_certificates_from_grades_csv(request, course_id):
filename
=
request
.
POST
[
'filename'
]
filename
=
request
.
POST
[
'filename'
]
result
=
_generate_certificates_from_grades_csv_task
(
course_id
,
filename
)
result
=
_generate_certificates_from_grades_csv_task
(
course_id
,
filename
)
return
JsonResponse
({})
return
JsonResponse
({
"status"
:
"success"
})
# response_payload = {
# 'downloads': [
# dict(name=name, url=url, link='<a href="{}" data-filename="{}">{}</a>'.format(url, name, name))
# for name, url in report_store.links_for(course_id)
# ]
# }
# return JsonResponse(response_payload)
@ensure_csrf_cookie
@ensure_csrf_cookie
@cache_control
(
no_cache
=
True
,
no_store
=
True
,
must_revalidate
=
True
)
@cache_control
(
no_cache
=
True
,
no_store
=
True
,
must_revalidate
=
True
)
...
...
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