Exemple #1
0
def _create_edevate_course_for_verification(sender, course_key, **kwargs):  # pylint: disable=unused-argument
    """
    Catches the signal that a course has been published in Studio and
    create course on the edevate for verification.
    """
    from cms.djangoapps.contentstore.courseware_index import CourseAboutSearchIndexer
    from student.models import CourseAccessRole, get_user

    try:
        course_access_role = CourseAccessRole.objects.get(course_id=course_key,
                                                          role='instructor')
        course_author = course_access_role.user
        edevate_db = EdevateDbConnector()
        edevate_db.update_or_create_verification_course(course_key,
                                                        course_author.email)
        edevate_db.close()
        CourseAboutSearchIndexer.remove_deleted_items(course_key)

        admin_emails_list = settings.ADMIN_VERIFICATION_EMAILS
        for admin_email in admin_emails_list:
            user, user_profile = get_user(admin_email)
            if user:
                context = {
                    'course_key': course_key
                }
                subject = "Openedx course verification"
                message = render_to_string('emails/edevate_course_verification_email.txt',
                                           context)
                from_address = settings.DEFAULT_FROM_EMAIL
                user.email_user(subject, message, from_address)
    except CourseAccessRole.DoesNotExist:
        pass
Exemple #2
0
def _listen_for_course_delete(sender, course_key, **kwargs):  # pylint: disable=unused-argument
    """
    Catches the signal that a course has been deleted from Studio and
    invalidates the corresponding CourseOverview cache entry if one exists.
    """
    CourseOverview.objects.filter(id=course_key).delete()
    # import CourseAboutSearchIndexer inline due to cyclic import
    from cms.djangoapps.contentstore.courseware_index import CourseAboutSearchIndexer
    # Delete course entry from Course About Search_index
    CourseAboutSearchIndexer.remove_deleted_items(course_key)
Exemple #3
0
def _listen_for_course_delete(sender, course_key, **kwargs):  # pylint: disable=unused-argument
    """
    Catches the signal that a course has been deleted from Studio and
    invalidates the corresponding CourseOverview cache entry if one exists.
    """
    CourseOverview.objects.filter(id=course_key).delete()
    # import CourseAboutSearchIndexer inline due to cyclic import
    from cms.djangoapps.contentstore.courseware_index import CourseAboutSearchIndexer
    # Delete course entry from Course About Search_index
    CourseAboutSearchIndexer.remove_deleted_items(course_key)
Exemple #4
0
def listen_for_course_publish(sender, course_key, **kwargs):  # pylint: disable=unused-argument
    """
    Receives publishing signal and performs publishing related workflows, such as
    registering proctored exams, building up credit requirements, and performing
    search indexing
    """

    # first is to registered exams, the credit subsystem will assume that
    # all proctored exams have already been registered, so we have to do that first
    try:
        register_special_exams(course_key)
    # pylint: disable=broad-except
    except Exception as exception:
        log.exception(exception)

    # then call into the credit subsystem (in /openedx/djangoapps/credit)
    # to perform any 'on_publish' workflow
    on_course_publish(course_key)

    # import here, because signal is registered at startup, but items in tasks are not yet able to be loaded
    from cms.djangoapps.contentstore.tasks import update_outline_from_modulestore_task, update_search_index
    if key_supports_outlines(course_key):
        update_outline_from_modulestore_task.delay(str(course_key))

    # Finally call into the course search subsystem
    # to kick off an indexing action
    if CoursewareSearchIndexer.indexing_is_enabled(
    ) and CourseAboutSearchIndexer.indexing_is_enabled():
        update_search_index.delay(str(course_key),
                                  datetime.now(UTC).isoformat())
Exemple #5
0
def listen_for_course_publish(sender, course_key, **kwargs):  # pylint: disable=unused-argument
    """
    Receives publishing signal and performs publishing related workflows, such as
    registering proctored exams, building up credit requirements, and performing
    search indexing
    """
    # import here, because signal is registered at startup, but items in tasks are not yet able to be loaded
    from cms.djangoapps.contentstore.tasks import (
        update_outline_from_modulestore_task,
        update_search_index,
        update_special_exams_and_publish
    )

    # register special exams asynchronously
    course_key_str = str(course_key)
    update_special_exams_and_publish.delay(course_key_str)

    if key_supports_outlines(course_key):
        # Push the course outline to learning_sequences asynchronously.
        update_outline_from_modulestore_task.delay(course_key_str)

    # Finally call into the course search subsystem
    # to kick off an indexing action
    if CoursewareSearchIndexer.indexing_is_enabled() and CourseAboutSearchIndexer.indexing_is_enabled():
        update_search_index.delay(course_key_str, datetime.now(UTC).isoformat())
Exemple #6
0
def listen_for_course_delete(sender, course_key, **kwargs):  # pylint: disable=unused-argument
    """
    Catches the signal that a course has been deleted
    and removes its entry from the Course About Search index.
    """
    CourseAboutSearchIndexer.remove_deleted_items(course_key)