Beispiel #1
0
 def graded_scorable_blocks_header(self):
     """
     Returns an OrderedDict that maps a scorable block's id to its
     headers in the final report.
     """
     scorable_blocks_map = OrderedDict()
     grading_context = grades_context.grading_context_for_course(
         self.course)
     for assignment_type_name, subsection_infos in grading_context[
             'all_graded_subsections_by_type'].items():
         for subsection_index, subsection_info in enumerate(
                 subsection_infos, start=1):
             for scorable_block in subsection_info['scored_descendants']:
                 header_name = (
                     "{assignment_type} {subsection_index}: "
                     "{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
Beispiel #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 += u"  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 += u"Listing grading context for course %s\n" % text_type(course.id)

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

    msg += '%s\n' % list(gcontext['all_graded_subsections_by_type'].keys())
    for (gsomething,
         gsvals) in gcontext['all_graded_subsections_by_type'].items():
        msg += u"--> 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 = u'%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 += u"      %s (format=%s, Assignment=%s%s)\n"\
                % (sdesc.display_name, frmat, aname, notes)
    msg += "all graded blocks:\n"
    msg += "length=%d\n" % gcontext['count_all_graded_blocks']
    msg = HTML('<pre>{}</pre>').format(Text(msg))
    return msg
Beispiel #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 += u"  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 += u"Listing grading context for course %s\n" % text_type(course.id)

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

    msg += '%s\n' % list(gcontext['all_graded_subsections_by_type'].keys())
    for (gsomething, gsvals) in gcontext['all_graded_subsections_by_type'].items():
        msg += u"--> 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 = u'%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 += u"      %s (format=%s, Assignment=%s%s)\n"\
                % (sdesc.display_name, frmat, aname, notes)
    msg += "all graded blocks:\n"
    msg += "length=%d\n" % gcontext['count_all_graded_blocks']
    msg = HTML('<pre>{}</pre>').format(Text(msg))
    return msg