Merge pull request #10363 from edx/saleem-latif/SOL-1315

SOL-1315: Add Cert Exception UI on Instructor Dash
This commit is contained in:
Matt Drayer
2015-11-03 10:09:19 -05:00
24 changed files with 1471 additions and 10 deletions

View File

@@ -491,3 +491,24 @@ def generate_certificates_for_all_students(request, course_key): # pylint: dis
task_key = ""
return submit_task(request, task_type, task_class, course_key, task_input, task_key)
def generate_certificates_for_students(request, course_key, students=None): # pylint: disable=invalid-name
"""
Submits a task to generate certificates for given students enrolled in the course or
all students if argument 'students' is None
Raises AlreadyRunningError if certificates are currently being generated.
"""
if students:
task_type = 'generate_certificates_certain_student'
students = [student.id for student in students]
task_input = {'students': students}
else:
task_type = 'generate_certificates_all_student'
task_input = {}
task_class = generate_certificates
task_key = ""
return submit_task(request, task_type, task_class, course_key, task_input, task_key)

View File

@@ -1398,11 +1398,17 @@ def upload_proctored_exam_results_report(_xmodule_instance_args, _entry_id, cour
def generate_students_certificates(
_xmodule_instance_args, _entry_id, course_id, task_input, action_name): # pylint: disable=unused-argument
"""
For a given `course_id`, generate certificates for all students
that are enrolled.
For a given `course_id`, generate certificates for only students present in 'students' key in task_input
json column, otherwise generate certificates for all enrolled students.
"""
start_time = time()
enrolled_students = CourseEnrollment.objects.users_enrolled_in(course_id)
students = task_input.get('students', None)
if students is not None:
enrolled_students = enrolled_students.filter(id__in=students)
task_progress = TaskProgress(action_name, enrolled_students.count(), start_time)
current_step = {'step': 'Calculating students already have certificates'}

View File

@@ -9,6 +9,7 @@ Tests that CSV grade report generation works with unicode emails.
import ddt
from mock import Mock, patch
import tempfile
import json
from openedx.core.djangoapps.course_groups import cohorts
import unicodecsv
from django.core.urlresolvers import reverse
@@ -1611,12 +1612,18 @@ class TestCertificateGeneration(InstructorTaskModuleTestCase):
current_task = Mock()
current_task.update_state = Mock()
instructor_task = Mock()
instructor_task.task_input = json.dumps({'students': None})
with self.assertNumQueries(125):
with patch('instructor_task.tasks_helper._get_current_task') as mock_current_task:
mock_current_task.return_value = current_task
with patch('capa.xqueue_interface.XQueueInterface.send_to_queue') as mock_queue:
mock_queue.return_value = (0, "Successfully queued")
result = generate_students_certificates(None, None, self.course.id, None, 'certificates generated')
with patch('instructor_task.models.InstructorTask.objects.get') as instructor_task_object:
instructor_task_object.return_value = instructor_task
result = generate_students_certificates(
None, None, self.course.id, {}, 'certificates generated'
)
self.assertDictContainsSubset(
{
'action_name': 'certificates generated',