Пример #1
0
def certificate_dashboard(request, course_key_string):
    """Certificate management dashboard for the support team."""

    course_key = get_course_key(course_key_string)
    course = get_course(course_key_string)
    if course is None:
        raise Http404

    # generate list of pending background tasks and filter the output
    task_types = ['certificate-generation', 'verified-certificate-generation']
    instructor_tasks = filter_instructor_task(
        get_running_instructor_tasks(course_key, task_types))

    # Get list of tasks sorted by decreasing id
    instructor_tasks_history = []
    for task_type in task_types:
        instructor_tasks_history += list(
            filter_instructor_task(
                get_instructor_task_history(course_key,
                                            task_type=task_type,
                                            usage_key=None,
                                            student=None)))
    instructor_tasks_history.sort(key=lambda x: -x.id)

    return render(
        request, 'backoffice/certificate.html', {
            'course': course,
            'certificates_directory': settings.CERTIFICATES_DIRECTORY_NAME,
            'instructor_tasks': instructor_tasks,
            'instructor_tasks_history': instructor_tasks_history,
        })
Пример #2
0
    def handle(self, *args, **options):
        collection = utils_proctorU_api.get_proctoru_api_collection(drop=True)
        begin = datetime.datetime.today() - datetime.timedelta(days=200)
        end = datetime.datetime.today()
        student_activities = []


        for start, end in utils_proctorU_api.split_large_date_range(begin, end, 30):
            student_activity = utils_proctorU_api.query_api(requests.post,
                                         utils_proctorU_api.BASE_URL + utils_proctorU_api.API_URLS["client_activity_report"],
                                         utils_proctorU_api.request_infos(start, end))
            if "error" in student_activity:
                logger.error("Error between {} and {}, nothing was added".format(begin, end))
                raise student_activity["error"]

            student_activities.append(student_activity)

        logger.info("Received student activities")

        courses_grades = {}
        verified_course_ids = CourseMode.objects.filter(mode_display_name=CourseMode.VERIFIED).values_list("course_id", flat=True)
        for course_id in verified_course_ids:
            course = get_course(course_id)
            students_grades = get_verified_student_grades(course.id)
            logger.info("Computed grades for course: {}".format(course_id))
            courses_grades[course_id] = students_grades

        res = {
            "reports": student_activities,
            "grades": courses_grades,
            "last_update": datetime.datetime.now()
        }
        collection.insert(res)
        logger.info(("Data inserted in mongo -- size: reports: {}, grades: {}, "
                    "last_update: {}").format(len(res["reports"]), len(res["grades"]), res["last_update"]))
    def handle(self, *args, **options):
        if options["course_key_string"]:
            course_key_string = options["course_key_string"]
        else:
            raise CommandError(
                "Option `--course-key-string=...` must be specified.")

        course = get_course(course_key_string)

        verified_students = get_enrolled_verified_students(
            course.id).select_related("profile")
        proctoru_registered_user = ProctoruUser.objects.filter(
            student__in=verified_students)
        students_registered_in_proctoru = User.objects.filter(
            proctoruuser__in=proctoru_registered_user)

        # TODO : not the best way to get students without reservations :
        #  * inscriptions in proctoru model is not bound to course (false negative)
        #  * we can't spot people who registered and cancelled their reservation
        # Thus we can fail to spot some people without reservations
        enrolled_students_not_proctoru = set(verified_students) - set(
            students_registered_in_proctoru)

        header = ("Name", "Username", "Email")
        rows = [(s.profile.name, s.username, s.email)
                for s in enrolled_students_not_proctoru]

        if options['filename']:
            with open(options['filename'], "w") as f:
                write_csv(f, header, rows)
        else:
            write_csv(sys.stdout, header, rows)
Пример #4
0
def certificate_dashboard(request, course_key_string):
    """Certificate management dashboard for the support team."""

    course_key = get_course_key(course_key_string)
    course = get_course(course_key_string)
    if course is None:
        raise Http404

    # generate list of pending background tasks and filter the output
    task_types = ['certificate-generation', 'verified-certificate-generation']
    instructor_tasks = filter_instructor_task(
        get_running_instructor_tasks(course_key, task_types)
    )

    # Get list of tasks sorted by decreasing id
    instructor_tasks_history = []
    for task_type in task_types:
        instructor_tasks_history += list(filter_instructor_task(
            get_instructor_task_history(
            course_key, task_type=task_type, usage_key=None, student=None)
        ))
    instructor_tasks_history.sort(key=lambda x: -x.id)

    return render(request, 'backoffice/certificate.html', {
        'course': course,
        'certificate_base_url': settings.CERTIFICATE_BASE_URL,
        'instructor_tasks': instructor_tasks,
        'instructor_tasks_history': instructor_tasks_history,
    })
Пример #5
0
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 handle(self, *args, **options):
        if options["course_key_string"]:
            course_key_string = options["course_key_string"]
        else:
            raise CommandError("Option `--course-key-string=...` must be specified.")

        course = get_course(course_key_string)

        verified_students = get_enrolled_verified_students(course.id).select_related("profile")
        proctoru_registered_user = ProctoruUser.objects.filter(student__in=verified_students)
        students_registered_in_proctoru = User.objects.filter(proctoruuser__in=proctoru_registered_user)

        # TODO : not the best way to get students without reservations :
        #  * inscriptions in proctoru model is not bound to course (false negative)
        #  * we can't spot people who registered and cancelled their reservation
        # Thus we can fail to spot some people without reservations
        enrolled_students_not_proctoru = set(verified_students) - set(students_registered_in_proctoru)

        header = ("Name", "Username", "Email")
        rows = [(s.profile.name, s.username, s.email) for s in enrolled_students_not_proctoru]

        if options['filename']:
            with open(options['filename'], "w") as f:
                write_csv(f, header, rows)
        else:
            write_csv(sys.stdout, header, rows)
Пример #7
0
def status(request, course_key_string):
    course = get_course(course_key_string)
    last_file_date = tasks_api.get_last_file_date(course.id)
    task_is_running = tasks_api.is_task_running(course.id)
    return render(request, 'backoffice/ora2_submissions/status.html', {
        'course': course,
        'task_is_running': task_is_running,
        'last_file_date': last_file_date,
    })
Пример #8
0
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)
Пример #9
0
    def handle(self, *args, **options):
        collection = utils_proctorU_api.get_proctoru_api_collection(drop=True)
        begin = datetime.datetime.today() - datetime.timedelta(days=200)
        end = datetime.datetime.today()
        student_activities = []

        for start, end in utils_proctorU_api.split_large_date_range(
                begin, end, 30):
            student_activity = utils_proctorU_api.query_api(
                requests.post, utils_proctorU_api.BASE_URL +
                utils_proctorU_api.API_URLS["client_activity_report"],
                utils_proctorU_api.request_infos(start, end))
            if "error" in student_activity:
                logger.error(
                    "Error between {} and {}, nothing was added".format(
                        begin, end))
                raise student_activity["error"]

            student_activities.append(student_activity)

        logger.info("Received student activities")

        courses_grades = {}
        verified_course_ids = CourseMode.objects.filter(
            mode_display_name=CourseMode.VERIFIED).values_list("course_id",
                                                               flat=True)
        for course_id in verified_course_ids:
            course = get_course(course_id)
            students_grades = get_verified_student_grades(course.id)
            logger.info("Computed grades for course: {}".format(course_id))
            courses_grades[course_id] = students_grades

        res = {
            "reports": student_activities,
            "grades": courses_grades,
            "last_update": datetime.datetime.now()
        }
        collection.insert(res)
        logger.info(
            ("Data inserted in mongo -- size: reports: {}, grades: {}, "
             "last_update: {}").format(len(res["reports"]), len(res["grades"]),
                                       res["last_update"]))
Пример #10
0
def certificate_dashboard(request, course_key_string):
    """
    Will display
    . Two panels, pending and previous certificate generation tasks.
    . Two buttons : one two generate a test certificate and the other to trigger a certificate generation task.
    """

    # 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)

    # generate list of pending background tasks and filter the output
    instructor_tasks = filter_instructor_task(get_running_instructor_tasks(course_key, task_type='certificate-generation'))
    instructor_tasks_history = filter_instructor_task(get_instructor_task_history(course_key, task_type='certificate-generation',
                                                                                  usage_key=None, student=None))

    return render(request, 'backoffice/certificate.html', {
            'course': course,
            'certificate_base_url' : settings.CERTIFICATE_BASE_URL,
            'instructor_tasks' : instructor_tasks,
            'instructor_tasks_history' : instructor_tasks_history,
        })