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
1fe68faf
Commit
1fe68faf
authored
Mar 21, 2014
by
Joe Blaylock
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #2530 from edx/jrbl/certs_regen_handy_flags
Certificates: Additional flags for regenerate_user
parents
3bcf619f
b8b86527
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
10 deletions
+27
-10
lms/djangoapps/certificates/management/commands/regenerate_user.py
+13
-1
lms/djangoapps/certificates/queue.py
+14
-9
No files found.
lms/djangoapps/certificates/management/commands/regenerate_user.py
View file @
1fe68faf
...
...
@@ -35,6 +35,16 @@ class Command(BaseCommand):
dest
=
'username'
,
default
=
False
,
help
=
'The username or email address for whom grading and certification should be requested'
),
make_option
(
'-G'
,
'--grade'
,
metavar
=
'GRADE'
,
dest
=
'grade_value'
,
default
=
None
,
help
=
'The grade string, such as "Distinction", which should be passed to the certificate agent'
),
make_option
(
'-T'
,
'--template'
,
metavar
=
'TEMPLATE'
,
dest
=
'template_file'
,
default
=
None
,
help
=
'The template file used to render this certificate, like "QMSE01-distinction.pdf"'
),
)
def
handle
(
self
,
*
args
,
**
options
):
...
...
@@ -59,7 +69,9 @@ class Command(BaseCommand):
xq
=
XQueueCertInterface
()
if
options
[
'insecure'
]:
xq
.
use_https
=
False
ret
=
xq
.
regen_cert
(
student
,
course_id
,
course
=
course
)
ret
=
xq
.
regen_cert
(
student
,
course_id
,
course
=
course
,
forced_grade
=
options
[
'grade_value'
],
template_file
=
options
[
'template_file'
])
print
'{0} - {1}'
.
format
(
student
,
ret
)
else
:
print
"noop option given, skipping work queueing..."
lms/djangoapps/certificates/queue.py
View file @
1fe68faf
...
...
@@ -78,7 +78,7 @@ class XQueueCertInterface(object):
self
.
restricted
=
UserProfile
.
objects
.
filter
(
allow_certificate
=
False
)
self
.
use_https
=
True
def
regen_cert
(
self
,
student
,
course_id
,
course
=
None
):
def
regen_cert
(
self
,
student
,
course_id
,
course
=
None
,
forced_grade
=
None
,
template_file
=
None
):
"""(Re-)Make certificate for a particular student in a particular course
Arguments:
...
...
@@ -105,7 +105,7 @@ class XQueueCertInterface(object):
except
GeneratedCertificate
.
DoesNotExist
:
pass
return
self
.
add_cert
(
student
,
course_id
,
course
)
return
self
.
add_cert
(
student
,
course_id
,
course
,
forced_grade
,
template_file
)
def
del_cert
(
self
,
student
,
course_id
):
...
...
@@ -124,21 +124,24 @@ class XQueueCertInterface(object):
raise
NotImplementedError
def
add_cert
(
self
,
student
,
course_id
,
course
=
None
):
def
add_cert
(
self
,
student
,
course_id
,
course
=
None
,
forced_grade
=
None
,
template_file
=
None
,
title
=
'None'
):
"""
Request a new certificate for a student.
Arguments:
student - User.object
student
- User.object
course_id - courseenrollment.course_id (string)
forced_grade - a string indicating a grade parameter to pass with
the certificate request. If this is given, grading
will be skipped.
Request a new certificate for a student.
Will change the certificate status to 'generating'.
Certificate must be in the 'unavailable', 'error',
'deleted' or 'generating' state.
If a student has a passing grade or is in the whitelist
table for the course a request will made for a new cert.
table for the course a request will
be
made for a new cert.
If a student has allow_certificate set to False in the
userprofile table the status will change to 'restricted'
...
...
@@ -147,7 +150,6 @@ class XQueueCertInterface(object):
will change to status.notpassing
Returns the student's status
"""
VALID_STATUSES
=
[
status
.
generating
,
...
...
@@ -173,9 +175,8 @@ class XQueueCertInterface(object):
self
.
request
.
user
=
student
self
.
request
.
session
=
{}
is_whitelisted
=
self
.
whitelist
.
filter
(
user
=
student
,
course_id
=
course_id
,
whitelist
=
True
)
.
exists
()
grade
=
grades
.
grade
(
student
,
self
.
request
,
course
)
is_whitelisted
=
self
.
whitelist
.
filter
(
user
=
student
,
course_id
=
course_id
,
whitelist
=
True
)
.
exists
()
enrollment_mode
=
CourseEnrollment
.
enrollment_mode_for_user
(
student
,
course_id
)
mode_is_verified
=
(
enrollment_mode
==
GeneratedCertificate
.
MODES
.
verified
)
user_is_verified
=
SoftwareSecurePhotoVerification
.
user_is_verified
(
student
)
...
...
@@ -190,6 +191,8 @@ class XQueueCertInterface(object):
else
:
# honor code and audit students
template_pdf
=
"certificate-template-{org}-{course}.pdf"
.
format
(
**
course_id_dict
)
if
forced_grade
:
grade
[
'grade'
]
=
forced_grade
cert
,
__
=
GeneratedCertificate
.
objects
.
get_or_create
(
user
=
student
,
course_id
=
course_id
)
...
...
@@ -221,6 +224,8 @@ class XQueueCertInterface(object):
'grade'
:
grade
[
'grade'
],
'template_pdf'
:
template_pdf
,
}
if
template_file
:
contents
[
'template_pdf'
]
=
template_file
new_status
=
status
.
generating
cert
.
status
=
new_status
cert
.
save
()
...
...
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