Skip to content
Snippets Groups Projects
Unverified Commit e5872cf8 authored by Christie Rice's avatar Christie Rice Committed by GitHub
Browse files

MICROBA-1032 Add allowlist check and move tests (#26785)

parent 0846e04f
Branches
Tags release-2021-01-05-15.23
No related merge requests found
......@@ -7,6 +7,7 @@ import logging
from django.core.management.base import BaseCommand
from lms.djangoapps.certificates.api import is_using_certificate_allowlist_and_is_on_allowlist
from lms.djangoapps.certificates.models import GeneratedCertificate
from lms.djangoapps.courseware import courses
from lms.djangoapps.grades.api import CourseGradeFactory
......@@ -16,7 +17,8 @@ log = logging.getLogger(__name__)
class Command(BaseCommand):
"""
Management command to find and grade all students that need to be graded.
Management command to find and grade all students that need to be graded, unless the user is on the allowlist
for that course run.
"""
help = """
......@@ -50,9 +52,13 @@ class Command(BaseCommand):
).filter(grade__exact='')
course = courses.get_course_by_id(course_id)
for cert in ungraded:
# grade the student
grade = CourseGradeFactory().read(cert.user, course)
log.info('grading %s - %s', cert.user, grade.percent)
cert.grade = grade.percent
if not options['noop']:
cert.save()
if is_using_certificate_allowlist_and_is_on_allowlist(cert.user, course_id):
log.info(f'{course_id} is using allowlist certificates, and the user {cert.user.id} is on its '
f'allowlist. Certificate will not be regraded')
else:
# grade the student
grade = CourseGradeFactory().read(cert.user, course)
log.info('grading %s - %s', cert.user, grade.percent)
cert.grade = grade.percent
if not options['noop']:
cert.save()
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment