当前位置: 首页>>代码示例>>Python>>正文


Python CourseEnrollment.bulk_fetch_enrollment_states方法代码示例

本文整理汇总了Python中student.models.CourseEnrollment.bulk_fetch_enrollment_states方法的典型用法代码示例。如果您正苦于以下问题:Python CourseEnrollment.bulk_fetch_enrollment_states方法的具体用法?Python CourseEnrollment.bulk_fetch_enrollment_states怎么用?Python CourseEnrollment.bulk_fetch_enrollment_states使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在student.models.CourseEnrollment的用法示例。


在下文中一共展示了CourseEnrollment.bulk_fetch_enrollment_states方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: bulk_gradebook_view_context

# 需要导入模块: from student.models import CourseEnrollment [as 别名]
# 或者: from student.models.CourseEnrollment import bulk_fetch_enrollment_states [as 别名]
def bulk_gradebook_view_context(course_key, users):
    """
    Prefetches all course and subsection grades in the given course for the given
    list of users, also, fetch all the score relavant data,
    storing the result in a RequestCache and deleting grades on context exit.
    """
    prefetch_course_and_subsection_grades(course_key, users)
    CourseEnrollment.bulk_fetch_enrollment_states(users, course_key)
    cohorts.bulk_cache_cohorts(course_key, users)
    BulkRoleCache.prefetch(users)
    try:
        yield
    finally:
        clear_prefetched_course_and_subsection_grades(course_key)
开发者ID:edx,项目名称:edx-platform,代码行数:16,代码来源:gradebook_views.py

示例2: generate

# 需要导入模块: from student.models import CourseEnrollment [as 别名]
# 或者: from student.models.CourseEnrollment import bulk_fetch_enrollment_states [as 别名]
    def generate(cls, _xmodule_instance_args, _entry_id, course_id, _task_input, action_name):
        """
        Generate a CSV containing all students' problem grades within a given
        `course_id`.
        """
        start_time = time()
        start_date = datetime.now(UTC)
        status_interval = 100
        enrolled_students = CourseEnrollment.objects.users_enrolled_in(course_id, include_inactive=True)
        task_progress = TaskProgress(action_name, enrolled_students.count(), start_time)

        # This struct encapsulates both the display names of each static item in the
        # header row as values as well as the django User field names of those items
        # as the keys.  It is structured in this way to keep the values related.
        header_row = OrderedDict([('id', 'Student ID'), ('email', 'Email'), ('username', 'Username')])

        course = get_course_by_id(course_id)
        graded_scorable_blocks = cls._graded_scorable_blocks_to_header(course)

        # Just generate the static fields for now.
        rows = [list(header_row.values()) + ['Enrollment Status', 'Grade'] + _flatten(graded_scorable_blocks.values())]
        error_rows = [list(header_row.values()) + ['error_msg']]
        current_step = {'step': 'Calculating Grades'}

        # Bulk fetch and cache enrollment states so we can efficiently determine
        # whether each user is currently enrolled in the course.
        CourseEnrollment.bulk_fetch_enrollment_states(enrolled_students, course_id)

        for student, course_grade, error in CourseGradeFactory().iter(enrolled_students, course):
            student_fields = [getattr(student, field_name) for field_name in header_row]
            task_progress.attempted += 1

            if not course_grade:
                err_msg = text_type(error)
                # There was an error grading this student.
                if not err_msg:
                    err_msg = u'Unknown error'
                error_rows.append(student_fields + [err_msg])
                task_progress.failed += 1
                continue

            enrollment_status = _user_enrollment_status(student, course_id)

            earned_possible_values = []
            for block_location in graded_scorable_blocks:
                try:
                    problem_score = course_grade.problem_scores[block_location]
                except KeyError:
                    earned_possible_values.append([u'Not Available', u'Not Available'])
                else:
                    if problem_score.first_attempted:
                        earned_possible_values.append([problem_score.earned, problem_score.possible])
                    else:
                        earned_possible_values.append([u'Not Attempted', problem_score.possible])

            rows.append(student_fields + [enrollment_status, course_grade.percent] + _flatten(earned_possible_values))

            task_progress.succeeded += 1
            if task_progress.attempted % status_interval == 0:
                task_progress.update_task_state(extra_meta=current_step)

        # Perform the upload if any students have been successfully graded
        if len(rows) > 1:
            upload_csv_to_report_store(rows, 'problem_grade_report', course_id, start_date)
        # If there are any error rows, write them out as well
        if len(error_rows) > 1:
            upload_csv_to_report_store(error_rows, 'problem_grade_report_err', course_id, start_date)

        return task_progress.update_task_state(extra_meta={'step': 'Uploading CSV'})
开发者ID:cmscom,项目名称:edx-platform,代码行数:71,代码来源:grades.py

示例3: __init__

# 需要导入模块: from student.models import CourseEnrollment [as 别名]
# 或者: from student.models.CourseEnrollment import bulk_fetch_enrollment_states [as 别名]
 def __init__(self, context, users):
     CourseEnrollment.bulk_fetch_enrollment_states(users, context.course_id)
     self.verified_users = [
         verified.user.id for verified in
         SoftwareSecurePhotoVerification.verified_query().filter(user__in=users).select_related('user__id')
     ]
开发者ID:edx-solutions,项目名称:edx-platform,代码行数:8,代码来源:grades.py

示例4: __init__

# 需要导入模块: from student.models import CourseEnrollment [as 别名]
# 或者: from student.models.CourseEnrollment import bulk_fetch_enrollment_states [as 别名]
 def __init__(self, context, users):
     CourseEnrollment.bulk_fetch_enrollment_states(users, context.course_id)
     self.verified_users = [
         verified.user.id for verified in IDVerificationService.get_verified_users(users)
     ]
开发者ID:cmscom,项目名称:edx-platform,代码行数:7,代码来源:grades.py

示例5: __init__

# 需要导入模块: from student.models import CourseEnrollment [as 别名]
# 或者: from student.models.CourseEnrollment import bulk_fetch_enrollment_states [as 别名]
 def __init__(self, context, users):
     CourseEnrollment.bulk_fetch_enrollment_states(users, context.course_id)
     self.verified_users = set(IDVerificationService.get_verified_user_ids(users))
开发者ID:jolyonb,项目名称:edx-platform,代码行数:5,代码来源:grades.py


注:本文中的student.models.CourseEnrollment.bulk_fetch_enrollment_states方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。