Пример #1
0
def set_cert_generation_enabled(course_key, is_enabled):
    """Enable or disable self-generated certificates for a course.

    There are two "switches" that control whether self-generated certificates
    are enabled for a course:

    1) Whether the self-generated certificates feature is enabled.
    2) Whether self-generated certificates have been enabled for this particular course.

    The second flag should be enabled *only* when someone has successfully
    generated example certificates for the course.  This helps avoid
    configuration errors (for example, not having a template configured
    for the course installed on the workers).  The UI for the instructor
    dashboard enforces this constraint.

    Arguments:
        course_key (CourseKey): The course identifier.

    Keyword Arguments:
        is_enabled (boolean): If provided, enable/disable self-generated
            certificates for this course.

    """
    CertificateGenerationCourseSetting.set_enabled_for_course(course_key, is_enabled)
    cert_event_type = 'enabled' if is_enabled else 'disabled'
    event_name = '.'.join(['edx', 'certificate', 'generation', cert_event_type])
    tracker.emit(event_name, {
        'course_id': unicode(course_key),
    })
    if is_enabled:
        log.info(u"Enabled self-generated certificates for course '%s'.", unicode(course_key))
    else:
        log.info(u"Disabled self-generated certificates for course '%s'.", unicode(course_key))
Пример #2
0
def enable_self_generated_certs(course_key):
    """Enable the self-generated certificates by default for self-paced courses."""
    course_key = CourseKey.from_string(course_key)
    course = modulestore().get_course(course_key)
    is_enabled_for_course = CertificateGenerationCourseSetting.is_enabled_for_course(course_key)
    if course.self_paced and not is_enabled_for_course:
        CertificateGenerationCourseSetting.set_enabled_for_course(course_key, True)
Пример #3
0
def set_cert_generation_enabled(course_key, is_enabled):
    """Enable or disable self-generated certificates for a course.

    There are two "switches" that control whether self-generated certificates
    are enabled for a course:

    1) Whether the self-generated certificates feature is enabled.
    2) Whether self-generated certificates have been enabled for this particular course.

    The second flag should be enabled *only* when someone has successfully
    generated example certificates for the course.  This helps avoid
    configuration errors (for example, not having a template configured
    for the course installed on the workers).  The UI for the instructor
    dashboard enforces this constraint.

    Arguments:
        course_key (CourseKey): The course identifier.

    Keyword Arguments:
        is_enabled (boolean): If provided, enable/disable self-generated
            certificates for this course.

    """
    CertificateGenerationCourseSetting.set_enabled_for_course(
        course_key, is_enabled)

    if is_enabled:
        log.info(u"Enabled self-generated certificates for course '%s'.",
                 unicode(course_key))
    else:
        log.info(u"Disabled self-generated certificates for course '%s'.",
                 unicode(course_key))
Пример #4
0
def toggle_self_generated_certs(course_key, course_self_paced):
    """
    Enable or disable self-generated certificates for a course according to pacing.
    """
    course_key = CourseKey.from_string(course_key)
    CertificateGenerationCourseSetting.set_enabled_for_course(
        course_key, course_self_paced)
Пример #5
0
def enable_self_generated_certs(course_key):
    """Enable the self-generated certificates by default for self-paced courses."""
    course_key = CourseKey.from_string(course_key)
    course = CourseOverview.get_from_id(course_key)
    is_enabled_for_course = CertificateGenerationCourseSetting.is_enabled_for_course(
        course_key)
    if course.self_paced and not is_enabled_for_course:
        CertificateGenerationCourseSetting.set_enabled_for_course(
            course_key, True)
def toggle_self_generated_certs(course_key, course_self_paced):
    """
    Enable or disable self-generated certificates for a course according to pacing.

    Enable self-generated certificates on course if:
    course is a self-paced course and self-generated certs on self-paced not explicitly disabled
    course is not self-paced and self-generated certs are explicitly enabled
    """
    course_key = unicode(course_key)
    course_key = CourseKey.from_string(course_key)
    enable = False if app_settings.DISABLE_SELF_GENERATED_CERTS_FOR_SELF_PACED is True else \
        (course_self_paced or app_settings.ALWAYS_ENABLE_SELF_GENERATED_CERTS)
    CertificateGenerationCourseSetting.set_enabled_for_course(
        course_key, enable)
Пример #7
0
def toggle_self_generated_certs(course_key, course_self_paced):
    """
    Enable or disable self-generated certificates for a course according to pacing.

    Enable self-generated certificates on course if:
    course is a self-paced course and self-generated certs on self-paced not explicitly disabled
    course is not self-paced and self-generated certs are explicitly enabled
    """
    course_key = unicode(course_key)
    course_key = CourseKey.from_string(course_key)
    if CertificateGenerationCourseSetting.is_enabled_for_course(course_key) and course_self_paced is True:
        # Catch possible edge case which may happen during upgrades:
        # Never change an enabled active config for a self-paced course to disabled
        logger.warn("""
            toggle_self_generated_certs won't override an enabled CertificateGenerationCourseSetting
            with a disabled one on a course being changed (or probably re-saved) as self-paced.
            """)
        return
    enable = False if app_settings.DISABLE_SELF_GENERATED_CERTS_FOR_SELF_PACED is True else \
        (course_self_paced or app_settings.ALWAYS_ENABLE_SELF_GENERATED_CERTS)

    CertificateGenerationCourseSetting.set_enabled_for_course(course_key, enable)
Пример #8
0
def toggle_self_generated_certs(course_key, course_self_paced):
    """
    Enable or disable self-generated certificates for a course according to pacing.
    """
    course_key = CourseKey.from_string(course_key)
    CertificateGenerationCourseSetting.set_enabled_for_course(course_key, course_self_paced)