def _graded_scorable_blocks_to_header(cls, course):
     """
     Returns an OrderedDict that maps a scorable block's id to its
     headers in the final report.
     """
     scorable_blocks_map = OrderedDict()
     grading_context = grading_context_for_course(course)
     for assignment_type_name, subsection_infos in grading_context[
             'all_graded_subsections_by_type'].iteritems():
         for subsection_index, subsection_info in enumerate(
                 subsection_infos, start=1):
             for scorable_block in subsection_info['scored_descendants']:
                 header_name = (
                     u"{assignment_type} {subsection_index}: "
                     u"{subsection_name} - {scorable_block_name}").format(
                         scorable_block_name=scorable_block.display_name,
                         assignment_type=assignment_type_name,
                         subsection_index=subsection_index,
                         subsection_name=subsection_info['subsection_block']
                         .display_name,
                     )
                 scorable_blocks_map[scorable_block.location] = [
                     header_name + " (Earned)", header_name + " (Possible)"
                 ]
     return scorable_blocks_map
Exemple #2
0
def dump_grading_context(course):
    """
    Render information about course grading context
    (e.g. which problems are graded in what assignments)
    Useful for debugging grading_policy.json and policy.json

    Returns HTML string
    """
    hbar = "{}\n".format("-" * 77)
    msg = hbar
    msg += "Course grader:\n"

    msg += '%s\n' % course.grader.__class__
    graders = {}
    if isinstance(course.grader, xmgraders.WeightedSubsectionsGrader):
        msg += '\n'
        msg += "Graded sections:\n"
        for subgrader, category, weight in course.grader.subgraders:
            msg += "  subgrader=%s, type=%s, category=%s, weight=%s\n"\
                % (subgrader.__class__, subgrader.type, category, weight)
            subgrader.index = 1
            graders[subgrader.type] = subgrader
    msg += hbar
    msg += "Listing grading context for course %s\n" % course.id.to_deprecated_string(
    )

    gcontext = grading_context_for_course(course.id)
    msg += "graded sections:\n"

    msg += '%s\n' % gcontext['all_graded_subsections_by_type'].keys()
    for (gsomething,
         gsvals) in gcontext['all_graded_subsections_by_type'].items():
        msg += "--> Section %s:\n" % (gsomething)
        for sec in gsvals:
            sdesc = sec['subsection_block']
            frmat = getattr(sdesc, 'format', None)
            aname = ''
            if frmat in graders:
                gform = graders[frmat]
                aname = '%s %02d' % (gform.short_label, gform.index)
                gform.index += 1
            elif sdesc.display_name in graders:
                gform = graders[sdesc.display_name]
                aname = '%s' % gform.short_label
            notes = ''
            if getattr(sdesc, 'score_by_attempt', False):
                notes = ', score by attempt!'
            msg += "      %s (format=%s, Assignment=%s%s)\n"\
                % (sdesc.display_name, frmat, aname, notes)
    msg += "all graded blocks:\n"
    msg += "length=%d\n" % len(gcontext['all_graded_blocks'])
    msg = '<pre>%s</pre>' % msg.replace('<', '&lt;')
    return msg
Exemple #3
0
def dump_grading_context(course):
    """
    Render information about course grading context
    (e.g. which problems are graded in what assignments)
    Useful for debugging grading_policy.json and policy.json

    Returns HTML string
    """
    hbar = "{}\n".format("-" * 77)
    msg = hbar
    msg += "Course grader:\n"

    msg += '%s\n' % course.grader.__class__
    graders = {}
    if isinstance(course.grader, xmgraders.WeightedSubsectionsGrader):
        msg += '\n'
        msg += "Graded sections:\n"
        for subgrader, category, weight in course.grader.subgraders:
            msg += "  subgrader=%s, type=%s, category=%s, weight=%s\n"\
                % (subgrader.__class__, subgrader.type, category, weight)
            subgrader.index = 1
            graders[subgrader.type] = subgrader
    msg += hbar
    msg += "Listing grading context for course %s\n" % course.id.to_deprecated_string()

    gcontext = grading_context_for_course(course.id)
    msg += "graded sections:\n"

    msg += '%s\n' % gcontext['all_graded_subsections_by_type'].keys()
    for (gsomething, gsvals) in gcontext['all_graded_subsections_by_type'].items():
        msg += "--> Section %s:\n" % (gsomething)
        for sec in gsvals:
            sdesc = sec['subsection_block']
            frmat = getattr(sdesc, 'format', None)
            aname = ''
            if frmat in graders:
                gform = graders[frmat]
                aname = '%s %02d' % (gform.short_label, gform.index)
                gform.index += 1
            elif sdesc.display_name in graders:
                gform = graders[sdesc.display_name]
                aname = '%s' % gform.short_label
            notes = ''
            if getattr(sdesc, 'score_by_attempt', False):
                notes = ', score by attempt!'
            msg += "      %s (format=%s, Assignment=%s%s)\n"\
                % (sdesc.display_name, frmat, aname, notes)
    msg += "all graded blocks:\n"
    msg += "length=%d\n" % len(gcontext['all_graded_blocks'])
    msg = '<pre>%s</pre>' % msg.replace('<', '&lt;')
    return msg
Exemple #4
0
 def _graded_scorable_blocks_to_header(cls, course):
     """
     Returns an OrderedDict that maps a scorable block's id to its
     headers in the final report.
     """
     scorable_blocks_map = OrderedDict()
     grading_context = grading_context_for_course(course)
     for assignment_type_name, subsection_infos in grading_context['all_graded_subsections_by_type'].iteritems():
         for subsection_index, subsection_info in enumerate(subsection_infos, start=1):
             for scorable_block in subsection_info['scored_descendants']:
                 header_name = (
                     u"{assignment_type} {subsection_index}: "
                     u"{subsection_name} - {scorable_block_name}"
                 ).format(
                     scorable_block_name=scorable_block.display_name,
                     assignment_type=assignment_type_name,
                     subsection_index=subsection_index,
                     subsection_name=subsection_info['subsection_block'].display_name,
                 )
                 scorable_blocks_map[scorable_block.location] = [header_name + " (Earned)",
                                                                 header_name + " (Possible)"]
     return scorable_blocks_map
    def graded_assignments(self):
        """
        Returns an OrderedDict that maps an assignment type to a dict of
        subsection-headers and average-header.
        """
        grading_context = grading_context_for_course(self.course_id)
        graded_assignments_map = OrderedDict()
        for assignment_type_name, subsection_infos in grading_context[
                'all_graded_subsections_by_type'].iteritems():
            graded_subsections_map = OrderedDict()
            for subsection_index, subsection_info in enumerate(
                    subsection_infos, start=1):
                subsection = subsection_info['subsection_block']
                header_name = u"{assignment_type} {subsection_index}: {subsection_name}".format(
                    assignment_type=assignment_type_name,
                    subsection_index=subsection_index,
                    subsection_name=subsection.display_name,
                )
                graded_subsections_map[subsection.location] = header_name

            average_header = u"{assignment_type}".format(
                assignment_type=assignment_type_name)

            # Use separate subsection and average columns only if
            # there's more than one subsection.
            separate_subsection_avg_headers = len(subsection_infos) > 1
            if separate_subsection_avg_headers:
                average_header += u" (Avg)"

            graded_assignments_map[assignment_type_name] = {
                'subsection_headers': graded_subsections_map,
                'average_header': average_header,
                'separate_subsection_avg_headers':
                separate_subsection_avg_headers
            }
        return graded_assignments_map