def generate_certificate(request, course_key_string): """ Submit the certificate-generation task to the instructor task api, then redirect to the certificate dashboard. """ # TODO: only one function that return both the course and the course_key course_key = get_course_key(course_key_string) course = get_course(course_key_string) # this input dict as to be passed the celery task to operate # the instructor_task update api # see (get_task_completion_info lms/djangoapps/instructor_task/views.py) input_args = {'student' : '', 'problem_url' : '', 'email_id' : ''} if not get_university_attached_to_course(course): messages.warning(request, _("University doesn't exist")) return redirect('backoffice:certificate-dashboard', course_key_string) try: submit_generate_certificate(request, course_key, input_args) return redirect('backoffice:certificate-dashboard', course_key_string) except AlreadyRunningError: messages.warning(request, _("A certificate generation is already running")) return redirect('backoffice:certificate-dashboard', course_key_string)
def generate_test_certificate(request, course_key_string): """ Return the HttpResponse for downloading the certificate pdf file. """ # TODO: only one function that return both the course and the course_key course_key = get_course_key(course_key_string) course = get_course(course_key_string) university = get_university_attached_to_course(course) messages.warning(request, _("University doesn't exist")) if university is not None: certificate = create_test_certificate(course, course_key, university) return certificate_file_response(certificate) else: return redirect('backoffice:certificate-dashboard', course_key_string)