當前位置: 首頁>>代碼示例>>Python>>正文


Python ScoresClient.create_for_locations方法代碼示例

本文整理匯總了Python中courseware.model_data.ScoresClient.create_for_locations方法的典型用法代碼示例。如果您正苦於以下問題:Python ScoresClient.create_for_locations方法的具體用法?Python ScoresClient.create_for_locations怎麽用?Python ScoresClient.create_for_locations使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在courseware.model_data.ScoresClient的用法示例。


在下文中一共展示了ScoresClient.create_for_locations方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: _csm_scores

# 需要導入模塊: from courseware.model_data import ScoresClient [as 別名]
# 或者: from courseware.model_data.ScoresClient import create_for_locations [as 別名]
 def _csm_scores(self):
     """
     Lazily queries and returns all the scores stored in the user
     state (in CSM) for the course, while caching the result.
     """
     scorable_locations = [block_key for block_key in self.course_structure if possibly_scored(block_key)]
     return ScoresClient.create_for_locations(self.course.id, self.student.id, scorable_locations)
開發者ID:shevious,項目名稱:edx-platform,代碼行數:9,代碼來源:subsection_grade.py

示例2: _grade

# 需要導入模塊: from courseware.model_data import ScoresClient [as 別名]
# 或者: from courseware.model_data.ScoresClient import create_for_locations [as 別名]
def _grade(student, course, keep_raw_scores, course_structure=None):
    """
    Unwrapped version of "grade"

    This grades a student as quickly as possible. It returns the
    output from the course grader, augmented with the final letter
    grade. The keys in the output are:

    - course: a CourseDescriptor
    - keep_raw_scores : if True, then value for key 'raw_scores' contains scores
      for every graded module

    More information on the format is in the docstring for CourseGrader.
    """
    if course_structure is None:
        course_structure = get_course_blocks(student, course.location)
    grading_context_result = grading_context(course_structure)
    scorable_locations = [block.location for block in grading_context_result['all_graded_blocks']]

    with outer_atomic():
        scores_client = ScoresClient.create_for_locations(course.id, student.id, scorable_locations)

    # Dict of item_ids -> (earned, possible) point tuples. This *only* grabs
    # scores that were registered with the submissions API, which for the moment
    # means only openassessment (edx-ora2)
    # We need to import this here to avoid a circular dependency of the form:
    # XBlock --> submissions --> Django Rest Framework error strings -->
    # Django translation --> ... --> courseware --> submissions
    from submissions import api as sub_api  # installed from the edx-submissions repository

    with outer_atomic():
        submissions_scores = sub_api.get_scores(
            course.id.to_deprecated_string(),
            anonymous_id_for_user(student, course.id)
        )

    totaled_scores, raw_scores = _calculate_totaled_scores(
        student, grading_context_result, submissions_scores, scores_client, keep_raw_scores
    )

    with outer_atomic():
        # Grading policy might be overriden by a CCX, need to reset it
        course.set_grading_policy(course.grading_policy)
        grade_summary = course.grader.grade(totaled_scores, generate_random_scores=settings.GENERATE_PROFILE_SCORES)

        # We round the grade here, to make sure that the grade is a whole percentage and
        # doesn't get displayed differently than it gets grades
        grade_summary['percent'] = round(grade_summary['percent'] * 100 + 0.05) / 100

        letter_grade = grade_for_percentage(course.grade_cutoffs, grade_summary['percent'])
        grade_summary['grade'] = letter_grade
        grade_summary['totaled_scores'] = totaled_scores   # make this available, eg for instructor download & debugging
        if keep_raw_scores:
            # way to get all RAW scores out to instructor
            # so grader can be double-checked
            grade_summary['raw_scores'] = raw_scores

    return grade_summary
開發者ID:marcore,項目名稱:edx-platform,代碼行數:60,代碼來源:grades.py

示例3: _prefetch_scores

# 需要導入模塊: from courseware.model_data import ScoresClient [as 別名]
# 或者: from courseware.model_data.ScoresClient import create_for_locations [as 別名]
 def _prefetch_scores(self, course_structure, course):
     """
     Returns the prefetched scores for the given student and course.
     """
     if not self._scores_client:
         scorable_locations = [block_key for block_key in course_structure if possibly_scored(block_key)]
         self._scores_client = ScoresClient.create_for_locations(
             course.id, self.student.id, scorable_locations
         )
         self._submissions_scores = submissions_api.get_scores(
             unicode(course.id), anonymous_id_for_user(self.student, course.id)
         )
開發者ID:longmen21,項目名稱:edx-platform,代碼行數:14,代碼來源:subsection_grade.py

示例4: _progress_summary

# 需要導入模塊: from courseware.model_data import ScoresClient [as 別名]
# 或者: from courseware.model_data.ScoresClient import create_for_locations [as 別名]
def _progress_summary(student, course, course_structure=None):
    """
    Unwrapped version of "progress_summary".

    This pulls a summary of all problems in the course.

    Returns
    - courseware_summary is a summary of all sections with problems in the course.
    It is organized as an array of chapters, each containing an array of sections,
    each containing an array of scores. This contains information for graded and
    ungraded problems, and is good for displaying a course summary with due dates,
    etc.
    - None if the student does not have access to load the course module.

    Arguments:
        student: A User object for the student to grade
        course: A Descriptor containing the course to grade

    """
    if course_structure is None:
        course_structure = get_course_blocks(student, course.location)
    if not len(course_structure):
        return None
    scorable_locations = [block_key for block_key in course_structure if possibly_scored(block_key)]

    with outer_atomic():
        scores_client = ScoresClient.create_for_locations(course.id, student.id, scorable_locations)

    # We need to import this here to avoid a circular dependency of the form:
    # XBlock --> submissions --> Django Rest Framework error strings -->
    # Django translation --> ... --> courseware --> submissions
    from submissions import api as sub_api  # installed from the edx-submissions repository
    with outer_atomic():
        submissions_scores = sub_api.get_scores(
            unicode(course.id), anonymous_id_for_user(student, course.id)
        )

    # Check for gated content
    gated_content = gating_api.get_gated_content(course, student)

    chapters = []
    locations_to_weighted_scores = {}

    for chapter_key in course_structure.get_children(course_structure.root_block_usage_key):
        chapter = course_structure[chapter_key]
        sections = []
        for section_key in course_structure.get_children(chapter_key):
            if unicode(section_key) in gated_content:
                continue

            section = course_structure[section_key]

            graded = getattr(section, 'graded', False)
            scores = []

            for descendant_key in course_structure.post_order_traversal(
                    filter_func=possibly_scored,
                    start_node=section_key,
            ):
                descendant = course_structure[descendant_key]

                (correct, total) = get_score(
                    student,
                    descendant,
                    scores_client,
                    submissions_scores,
                )
                if correct is None and total is None:
                    continue

                weighted_location_score = Score(
                    correct,
                    total,
                    graded,
                    block_metadata_utils.display_name_with_default_escaped(descendant),
                    descendant.location
                )

                scores.append(weighted_location_score)
                locations_to_weighted_scores[descendant.location] = weighted_location_score

            escaped_section_name = block_metadata_utils.display_name_with_default_escaped(section)
            section_total, _ = graders.aggregate_scores(scores, escaped_section_name)

            sections.append({
                'display_name': escaped_section_name,
                'url_name': block_metadata_utils.url_name_for_block(section),
                'scores': scores,
                'section_total': section_total,
                'format': getattr(section, 'format', ''),
                'due': getattr(section, 'due', None),
                'graded': graded,
            })

        chapters.append({
            'course': course.display_name_with_default_escaped,
            'display_name': block_metadata_utils.display_name_with_default_escaped(chapter),
            'url_name': block_metadata_utils.url_name_for_block(chapter),
            'sections': sections
        })
#.........這裏部分代碼省略.........
開發者ID:marcore,項目名稱:edx-platform,代碼行數:103,代碼來源:grades.py


注:本文中的courseware.model_data.ScoresClient.create_for_locations方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。