예제 #1
0
def grader_validate_rubrics(ctx, course, grader_id, assignment_id, only):
    grader = course.get_grader(grader_id)
    if not grader:
        print "Grader %s does not exist" % grader_id
        ctx.exit(CHISUBMIT_FAIL)

    assignment = course.get_assignment(assignment_id)
    if not assignment:
        print "Assignment %s does not exist" % assignment_id
        ctx.exit(CHISUBMIT_FAIL)

    teams = get_teams(course, assignment, grader = grader, only = only)
    
    for team in teams:

        repo = GradingGitRepo.get_grading_repo(ctx.obj['config'], course, team, assignment)
        if not repo:
            print "Repository for %s does not exist" % (team.id)
            ctx.exit(CHISUBMIT_FAIL)
    
        rubricfile = repo.repo_path + "/%s.rubric.txt" % assignment.id
    
        if not os.path.exists(rubricfile):
            print "Repository for %s does not exist have a rubric for assignment %s" % (team.id, assignment.id)
            ctx.exit(CHISUBMIT_FAIL)
    
        try:
            RubricFile.from_file(open(rubricfile), assignment)
            print "%s: Rubric OK." % team.id
        except ChisubmitRubricException, cre:
            print "%s: Rubric ERROR: %s" % (team.id, cre.message)
예제 #2
0
def grader_validate_rubrics(ctx, course, grader_id, assignment_id, only):
    grader = course.get_grader(grader_id)
    if not grader:
        print "Grader %s does not exist" % grader_id
        ctx.exit(CHISUBMIT_FAIL)

    assignment = course.get_assignment(assignment_id)
    if not assignment:
        print "Assignment %s does not exist" % assignment_id
        ctx.exit(CHISUBMIT_FAIL)

    teams = get_teams(course, assignment, grader=grader, only=only)

    for team in teams:

        repo = GradingGitRepo.get_grading_repo(ctx.obj['config'], course, team,
                                               assignment)
        if not repo:
            print "Repository for %s does not exist" % (team.id)
            ctx.exit(CHISUBMIT_FAIL)

        rubricfile = repo.repo_path + "/%s.rubric.txt" % assignment.id

        if not os.path.exists(rubricfile):
            print "Repository for %s does not exist have a rubric for assignment %s" % (
                team.id, assignment.id)
            ctx.exit(CHISUBMIT_FAIL)

        try:
            RubricFile.from_file(open(rubricfile), assignment)
            print "%s: Rubric OK." % team.id
        except ChisubmitRubricException, cre:
            print "%s: Rubric ERROR: %s" % (team.id, cre.message)
예제 #3
0
파일: grading.py 프로젝트: jclmns/chisubmit
def instructor_grading_add_rubrics(ctx, course, assignment_id, commit,
                                   all_teams):
    assignment = course.get_assignment(assignment_id)
    if assignment is None:
        print "Assignment %s does not exist" % assignment_id
        ctx.exit(CHISUBMIT_FAIL)

    teams = get_teams(course, assignment, only_ready_for_grading=not all_teams)

    for team in teams:
        repo = GradingGitRepo.get_grading_repo(ctx.obj['config'], course, team,
                                               assignment)
        team_assignment = team.get_assignment(assignment_id)
        rubric = RubricFile.from_assignment(assignment, team_assignment)
        rubricfile = "%s.rubric.txt" % assignment.id
        rubricfilepath = "%s/%s" % (repo.repo_path, rubricfile)

        if commit:
            if not os.path.exists(rubricfilepath):
                rubric.save(rubricfilepath, include_blank_comments=True)
                rv = repo.commit([rubricfile], "Added grading rubric")
                if rv:
                    print rubricfilepath, "(COMMITTED)"
                else:
                    print rubricfilepath, "(NO CHANGES - Not committed)"
            else:
                print rubricfilepath, "(SKIPPED - already exists)"
        else:
            rubric.save(rubricfilepath, include_blank_comments=True)
            print rubricfilepath
예제 #4
0
def instructor_grading_add_rubrics(ctx, course, assignment_id, commit, all_teams):
    assignment = course.get_assignment(assignment_id)
    if assignment is None:
        print "Assignment %s does not exist" % assignment_id
        ctx.exit(CHISUBMIT_FAIL)

    teams_registrations = get_teams_registrations(course, assignment, only_ready_for_grading=not all_teams)
    teams = sorted(teams_registrations.keys(), key=operator.attrgetter("team_id"))

    for team in teams:
        registration = teams_registrations[team]
        repo = GradingGitRepo.get_grading_repo(ctx.obj['config'], course, team, registration)
        
        if repo is None:
            print "%s does not have a grading repository" % team.team_id
            continue        
        
        rubric = RubricFile.from_assignment(assignment, registration.get_grades())
        rubricfile = "%s.rubric.txt" % assignment.assignment_id
        rubricfilepath = "%s/%s" % (repo.repo_path, rubricfile)
        
        if commit:
            if not os.path.exists(rubricfilepath):
                rubric.save(rubricfilepath, include_blank_comments=True)
                rv = repo.commit([rubricfile], "Added grading rubric")
                if rv:
                    print rubricfilepath, "(COMMITTED)"
                else:
                    print rubricfilepath, "(NO CHANGES - Not committed)"
            else:
                print rubricfilepath, "(SKIPPED - already exists)"
        else:
            rubric.save(rubricfilepath, include_blank_comments=True)
            print rubricfilepath
예제 #5
0
def instructor_assignment_add_rubric(ctx, course, assignment_id, rubric_file,
                                     yes):
    assignment = get_assignment_or_exit(ctx, course, assignment_id)

    try:
        rubric = RubricFile.from_file(rubric_file)
    except ChisubmitRubricException as cre:
        print("ERROR: Rubric does not validate (%s)" % (cre))
        ctx.exit(CHISUBMIT_FAIL)

    rubric_components = assignment.get_rubric_components()

    if len(rubric_components) > 0:
        print("This assignment already has a rubric. If you load this")
        print("new rubric, the old one will be REMOVED. If grading of")
        print("this assignment has already begun, doing this may break")
        print("existing rubric files completed by the graders.")
        print()
        if not ask_yesno(yes=yes):
            ctx.exit(CHISUBMIT_FAIL)
        print()
        for rc in rubric_components:
            rc.delete()

    order = 10
    for rc in rubric.rubric_components:
        points = rubric.points_possible[rc]
        assignment.create_rubric_component(rc, points, order)
        order += 10

    return CHISUBMIT_SUCCESS
예제 #6
0
파일: grading.py 프로젝트: jclmns/chisubmit
def instructor_grading_add_rubrics(ctx, course, assignment_id, commit, all_teams):
    assignment = course.get_assignment(assignment_id)
    if assignment is None:
        print "Assignment %s does not exist" % assignment_id
        ctx.exit(CHISUBMIT_FAIL)

    teams = get_teams(course, assignment, only_ready_for_grading=not all_teams)

    for team in teams:
        repo = GradingGitRepo.get_grading_repo(ctx.obj['config'], course, team, assignment)
        team_assignment = team.get_assignment(assignment_id)
        rubric = RubricFile.from_assignment(assignment, team_assignment)
        rubricfile = "%s.rubric.txt" % assignment.id
        rubricfilepath = "%s/%s" % (repo.repo_path, rubricfile)
        
        if commit:
            if not os.path.exists(rubricfilepath):
                rubric.save(rubricfilepath, include_blank_comments=True)
                rv = repo.commit([rubricfile], "Added grading rubric")
                if rv:
                    print rubricfilepath, "(COMMITTED)"
                else:
                    print rubricfilepath, "(NO CHANGES - Not committed)"
            else:
                print rubricfilepath, "(SKIPPED - already exists)"
        else:
            rubric.save(rubricfilepath, include_blank_comments=True)
            print rubricfilepath
예제 #7
0
def instructor_assignment_add_rubric(ctx, course, assignment_id, rubric_file, yes):
    assignment = get_assignment_or_exit(ctx, course, assignment_id)

    try:
        rubric = RubricFile.from_file(rubric_file) 
    except ChisubmitRubricException as cre:
        print("ERROR: Rubric does not validate (%s)" % (cre))
        ctx.exit(CHISUBMIT_FAIL)
    
    rubric_components = assignment.get_rubric_components()

    if len(rubric_components) > 0:
        print("This assignment already has a rubric. If you load this")
        print("new rubric, the old one will be REMOVED. If grading of")
        print("this assignment has already begun, doing this may break")
        print("existing rubric files completed by the graders.")
        print()
        if not ask_yesno(yes=yes):
            ctx.exit(CHISUBMIT_FAIL)
        print()
        for rc in rubric_components:
            rc.delete()
    
    order = 10
    for rc in rubric.rubric_components:
        points = rubric.points_possible[rc]
        assignment.create_rubric_component(rc, points, order)
        order += 10

    return CHISUBMIT_SUCCESS
예제 #8
0
def validate_repo_rubric(ctx, course, assignment, team, registration):
    repo = GradingGitRepo.get_grading_repo(ctx.obj['config'], course, team, registration)
    if not repo:
        print("Repository for %s does not exist" % (team.team_id))
        ctx.exit(CHISUBMIT_FAIL)

    rubricfile = repo.repo_path + "/%s.rubric.txt" % assignment.assignment_id

    if not os.path.exists(rubricfile):
        print("Repository for %s does not exist have a rubric for assignment %s" % (team.team_id, assignment.assignment_id))
        ctx.exit(CHISUBMIT_FAIL)

    try:
        RubricFile.from_file(open(rubricfile), assignment)
        return (True, None)
    except ChisubmitRubricException as cre:
        return (False, str(cre))
예제 #9
0
def validate_repo_rubric(ctx, course, assignment, team, registration):
    repo = GradingGitRepo.get_grading_repo(ctx.obj['config'], course, team, registration)
    if not repo:
        print "Repository for %s does not exist" % (team.team_id)
        ctx.exit(CHISUBMIT_FAIL)

    rubricfile = repo.repo_path + "/%s.rubric.txt" % assignment.assignment_id

    if not os.path.exists(rubricfile):
        print "Repository for %s does not exist have a rubric for assignment %s" % (team.team_id, assignment.assignment_id)
        ctx.exit(CHISUBMIT_FAIL)

    try:
        RubricFile.from_file(open(rubricfile), assignment)
        return (True, None)
    except ChisubmitRubricException, cre:
        return (False, cre.message)
예제 #10
0
def grader_pull_grading(ctx, course, grader, assignment_id):
    if grader is None:
        user = ctx.obj["client"].get_user()

        grader = get_grader_or_exit(ctx, course, user.username)
    else:
        grader = get_grader_or_exit(ctx, course, grader)

    assignment = get_assignment_or_exit(ctx, course, assignment_id)

    teams_registrations = get_teams_registrations(course,
                                                  assignment,
                                                  grader=grader)

    if len(teams_registrations) == 0:
        print("No teams found")
        ctx.exit(CHISUBMIT_FAIL)

    teams = sorted(list(teams_registrations.keys()),
                   key=operator.attrgetter("team_id"))

    for team in teams:
        registration = teams_registrations[team]
        repo = GradingGitRepo.get_grading_repo(ctx.obj['config'], course, team,
                                               registration)

        if repo is None:
            print(("%40s -- Creating grading repo... " % team.team_id),
                  end=' ')
            repo = GradingGitRepo.create_grading_repo(ctx.obj['config'],
                                                      course,
                                                      team,
                                                      registration,
                                                      staging_only=True)
            repo.sync()
            gradingrepo_pull_grading_branch(ctx.obj['config'], course, team,
                                            registration)
            repo.set_grader_author()

            print("done")
        else:
            print(("%40s -- Pulling grading branch..." % team.team_id),
                  end=' ')
            gradingrepo_pull_grading_branch(ctx.obj['config'], course, team,
                                            registration)
            print("done")

        rubricfile = "%s.rubric.txt" % assignment.assignment_id
        rubricfilepath = "%s/%s" % (repo.repo_path, rubricfile)
        if not os.path.exists(rubricfilepath):
            rubric = RubricFile.from_assignment(assignment)
            rubric.save(rubricfilepath, include_blank_comments=True)

    return CHISUBMIT_SUCCESS
예제 #11
0
def grader_pull_grading(ctx, course, grader, assignment_id):
    if grader is None:
        user = ctx.obj["client"].get_user()    
        
        grader = get_grader_or_exit(ctx, course, user.username)
    else:
        grader = get_grader_or_exit(ctx, course, grader)
        
    assignment = get_assignment_or_exit(ctx, course, assignment_id)

    teams_registrations = get_teams_registrations(course, assignment, grader = grader)
    
    if len(teams_registrations) == 0:
        print "No teams found"
        ctx.exit(CHISUBMIT_FAIL)

    teams = sorted(teams_registrations.keys(), key=operator.attrgetter("team_id"))

    for team in teams:
        registration = teams_registrations[team]
        repo = GradingGitRepo.get_grading_repo(ctx.obj['config'], course, team, registration)

        if repo is None:
            print ("%20s -- Creating grading repo... " % team.team_id),
            repo = GradingGitRepo.create_grading_repo(ctx.obj['config'], course, team, registration, staging_only = True)
            repo.sync()
            gradingrepo_pull_grading_branch(ctx.obj['config'], course, team, registration)
            repo.set_grader_author()
            
            print "done"
        else:
            print ("%20s -- Pulling grading branch..." % team.team_id),
            gradingrepo_pull_grading_branch(ctx.obj['config'], course, team, registration)
            print "done"
            
        rubricfile = "%s.rubric.txt" % assignment.assignment_id
        rubricfilepath = "%s/%s" % (repo.repo_path, rubricfile)
        if not os.path.exists(rubricfilepath):
            rubric = RubricFile.from_assignment(assignment)
            rubric.save(rubricfilepath, include_blank_comments=True)            
        
    return CHISUBMIT_SUCCESS
예제 #12
0
def instructor_grading_add_rubrics(ctx, course, assignment_id, commit,
                                   all_teams):
    assignment = course.get_assignment(assignment_id)
    if assignment is None:
        print("Assignment %s does not exist" % assignment_id)
        ctx.exit(CHISUBMIT_FAIL)

    teams_registrations = get_teams_registrations(
        course, assignment, only_ready_for_grading=not all_teams)
    teams = sorted(list(teams_registrations.keys()),
                   key=operator.attrgetter("team_id"))

    for team in teams:
        registration = teams_registrations[team]
        repo = GradingGitRepo.get_grading_repo(ctx.obj['config'], course, team,
                                               registration)

        if repo is None:
            print("%s does not have a grading repository" % team.team_id)
            continue

        rubric = RubricFile.from_assignment(assignment,
                                            registration.get_grades())
        rubricfile = "%s.rubric.txt" % assignment.assignment_id
        rubricfilepath = "%s/%s" % (repo.repo_path, rubricfile)

        if commit:
            if not os.path.exists(rubricfilepath):
                rubric.save(rubricfilepath, include_blank_comments=True)
                rv = repo.commit([rubricfile], "Added grading rubric")
                if rv:
                    print(rubricfilepath, "(COMMITTED)")
                else:
                    print(rubricfilepath, "(NO CHANGES - Not committed)")
            else:
                print(rubricfilepath, "(SKIPPED - already exists)")
        else:
            rubric.save(rubricfilepath, include_blank_comments=True)
            print(rubricfilepath)
예제 #13
0
def instructor_grading_show_grading_status(ctx, course, assignment_id, by_grader, include_diff_urls, use_stored_grades):
    assignment = get_assignment_or_exit(ctx, course, assignment_id, include_rubric = True)
    rubric_components = assignment.get_rubric_components()

    teams_registrations = get_teams_registrations(course, assignment, include_grades = True)
    teams = sorted(teams_registrations.keys(), key=operator.attrgetter("team_id"))
    
    team_status = []
    graders = set()
    
    for team in teams:
        registration = teams_registrations[team]

        if registration.grader is None:
            grader_str = "<no grader assigned>"
        else:
            grader_str = registration.grader.user.username
        graders.add(grader_str)
        
        grading_status = None
        
        if use_stored_grades:
            grades = registration.get_grades()
            total_grade = registration.get_total_grade()
            
            graded_rc_ids = [g.rubric_component_id for g in grades]            
        else:
            total_grade = 0.0
            repo = GradingGitRepo.get_grading_repo(ctx.obj['config'], course, team, registration)
            if repo is None:
                grading_status = "NO GRADING REPO"
            else:
                rubricfile = repo.repo_path + "/%s.rubric.txt" % assignment.assignment_id
        
                if not os.path.exists(rubricfile):
                    grading_status = "NOT GRADED - No rubric"
                else:        
                    try:
                        rubric = RubricFile.from_file(open(rubricfile), assignment)
            
                        graded_rc_ids = [rc.id for rc in rubric_components if rubric.points[rc.description] is not None]  
                
                        for rc in rubric_components:
                            grade = rubric.points[rc.description]
                            if grade is not None:
                                total_grade += grade
                
                        if rubric.penalties is not None:
                            for p in rubric.penalties.values():
                                total_grade += p
                
                        if rubric.bonuses is not None:
                            for p in rubric.bonuses.values():
                                total_grade += p  
                    except ChisubmitRubricException, cre:
                        grading_status = "ERROR: Rubric does not validate (%s)" % (cre.message)
                        
        if grading_status is None:
            has_some = False
            has_all = True
            for rc in rubric_components:
                if rc.id in graded_rc_ids:
                    has_some = True
                else:
                    has_all = False
                            
            if not has_some:
                grading_status = "NOT GRADED"
            elif has_all:
                grading_status = "GRADED"
            else:
                grading_status = "PARTIALLY GRADED"

            
        if include_diff_urls and has_some:
            commit_sha = registration.final_submission.commit_sha[:8]
            diff_url = "https://mit.cs.uchicago.edu/%s-staging/%s/compare/%s...%s-grading" % (course.course_id, team.team_id, commit_sha, assignment.assignment_id)
        else:
            diff_url = ""
            
        team_status.append((team.team_id, grader_str, total_grade, diff_url, grading_status))
예제 #14
0
파일: grading.py 프로젝트: jclmns/chisubmit
def instructor_grading_collect_rubrics(ctx, course, assignment_id, dry_run, grader_id):
    assignment = course.get_assignment(assignment_id)
    if assignment is None:
        print "Assignment %s does not exist" % assignment_id
        ctx.exit(CHISUBMIT_FAIL)

    if grader_id is not None:
        grader = course.get_grader(grader_id)
        if grader is None:
            print "Grader %s does not exist" % grader_id
            ctx.exit(CHISUBMIT_FAIL)
    else:
        grader = None

    gcs = assignment.grade_components

    teams = get_teams(course, assignment, grader=grader)

    for team in teams:
        repo = GradingGitRepo.get_grading_repo(ctx.obj['config'], course, team, assignment)
        if repo is None:
            print "Repository for %s does not exist" % (team.id)
            continue

        rubricfile = repo.repo_path + "/%s.rubric.txt" % assignment.id

        if not os.path.exists(rubricfile):
            print "Repository for %s does not have a rubric for assignment %s" % (team.id, assignment.id)
            continue

        try:
            rubric = RubricFile.from_file(open(rubricfile), assignment)
        except ChisubmitRubricException, cre:
            print "ERROR: Rubric for %s does not validate (%s)" % (team.id, cre.message)
            continue

        points = []
        for gc in gcs:
            grade = rubric.points[gc.description]
            if grade is None:
                points.append(0.0)
            else:
                if not dry_run:
                    team.set_assignment_grade(assignment.id, gc.id, grade)
                points.append(grade)

        penalties = {}
        total_penalties = 0.0
        if rubric.penalties is not None:
            for desc, p in rubric.penalties.items():
                penalties[desc] = p
                total_penalties += p

        if not dry_run:
            team.set_assignment_penalties(assignment.id, penalties)

        if ctx.obj["verbose"]:
            print team.id
            print "+ %s" % points
            print "- %.2f" % total_penalties

        if not dry_run:
            new_team = course.get_team(team.id)
            assignment_team = new_team.get_assignment(assignment.id)
            total_grade = assignment_team.get_total_grade()
        else:
            total_grade = sum(points) + total_penalties
            
        if ctx.obj["verbose"]:
            print "TOTAL: %.2f" % total_grade
            print
        else:
            print "%-40s %.2f" % (team.id, total_grade)
예제 #15
0
def instructor_assignment_show_rubric(ctx, course, assignment_id):
    assignment = get_assignment_or_exit(ctx, course, assignment_id)

    rubric = RubricFile.from_assignment(assignment)
    print(rubric.to_yaml())
예제 #16
0
def instructor_grading_collect_rubrics(ctx, course, assignment_id, dry_run,
                                       only, grader_id):
    assignment = get_assignment_or_exit(ctx, course, assignment_id)

    if grader_id is not None:
        grader = get_grader_or_exit(ctx, course, grader_id)
    else:
        grader = None

    rcs = assignment.get_rubric_components()

    teams_registrations = get_teams_registrations(course,
                                                  assignment,
                                                  grader=grader,
                                                  only=only)
    teams = sorted(list(teams_registrations.keys()),
                   key=operator.attrgetter("team_id"))

    for team in teams:
        registration = teams_registrations[team]
        repo = GradingGitRepo.get_grading_repo(ctx.obj['config'], course, team,
                                               registration)
        if repo is None:
            print("Repository for %s does not exist" % (team.team_id))
            continue

        rubricfile = repo.repo_path + "/%s.rubric.txt" % assignment.assignment_id

        if not os.path.exists(rubricfile):
            print(
                "Repository for %s does not have a rubric for assignment %s" %
                (team.team_id, assignment.assignment_id))
            continue

        try:
            rubric = RubricFile.from_file(open(rubricfile), assignment)
        except ChisubmitRubricException as cre:
            print("ERROR: Rubric for %s does not validate (%s)" %
                  (team.team_id, cre))
            continue

        points = []
        for rc in rcs:
            grade = rubric.points_obtained[rc.description]
            if grade is None:
                points.append(0.0)
            else:
                if not dry_run:
                    registration.set_grade(rc, grade)
                points.append(grade)

        adjustments = {}
        total_penalties = 0.0
        total_bonuses = 0.0
        if rubric.penalties is not None:
            for desc, p in list(rubric.penalties.items()):
                adjustments[desc] = p
                total_penalties += p

        if rubric.bonuses is not None:
            for desc, p in list(rubric.bonuses.items()):
                adjustments[desc] = p
                total_bonuses += p

        if not dry_run:
            registration.grade_adjustments = adjustments

        if ctx.obj["verbose"]:
            print(team.team_id)
            print("Points Obtained: %s" % points)
            print("Penalties: %.2f" % total_penalties)
            print("Bonuses: %.2f" % total_bonuses)

        if not dry_run:
            total_grade = registration.get_total_grade()
        else:
            total_grade = sum(points) + total_penalties + total_bonuses

        if ctx.obj["verbose"]:
            print("TOTAL: %.2f" % total_grade)
            print()
        else:
            print("%-40s %.2f" % (team.team_id, total_grade))
예제 #17
0
def instructor_grading_collect_rubrics(ctx, course, assignment_id, dry_run, only, grader_id):
    assignment = get_assignment_or_exit(ctx, course, assignment_id)

    if grader_id is not None:
        grader = get_grader_or_exit(ctx, course, grader_id)
    else:
        grader = None

    rcs = assignment.get_rubric_components()

    teams_registrations = get_teams_registrations(course, assignment, grader=grader, only=only)
    teams = sorted(teams_registrations.keys(), key=operator.attrgetter("team_id"))
    
    for team in teams:
        registration = teams_registrations[team]
        repo = GradingGitRepo.get_grading_repo(ctx.obj['config'], course, team, registration)
        if repo is None:
            print "Repository for %s does not exist" % (team.team_id)
            continue

        rubricfile = repo.repo_path + "/%s.rubric.txt" % assignment.assignment_id

        if not os.path.exists(rubricfile):
            print "Repository for %s does not have a rubric for assignment %s" % (team.team_id, assignment.assignment_id)
            continue

        try:
            rubric = RubricFile.from_file(open(rubricfile), assignment)
        except ChisubmitRubricException, cre:
            print "ERROR: Rubric for %s does not validate (%s)" % (team.team_id, cre.message)
            continue

        points = []
        for rc in rcs:
            grade = rubric.points[rc.description]
            if grade is None:
                points.append(0.0)
            else:
                if not dry_run:
                    registration.set_grade(rc, grade)
                points.append(grade)

        adjustments = {}
        total_penalties = 0.0
        total_bonuses = 0.0
        if rubric.penalties is not None:
            for desc, p in rubric.penalties.items():
                adjustments[desc] = p
                total_penalties += p

        if rubric.bonuses is not None:
            for desc, p in rubric.bonuses.items():
                adjustments[desc] = p
                total_bonuses += p

        if not dry_run:
            registration.grade_adjustments = adjustments

        if ctx.obj["verbose"]:
            print team.team_id
            print "Points Obtained: %s" % points
            print "Penalties: %.2f" % total_penalties
            print "Bonuses: %.2f" % total_bonuses

        if not dry_run:
            total_grade = registration.get_total_grade()
        else:
            total_grade = sum(points) + total_penalties + total_bonuses
            
        if ctx.obj["verbose"]:
            print "TOTAL: %.2f" % total_grade
            print
        else:
            print "%-40s %.2f" % (team.team_id, total_grade)
예제 #18
0
def instructor_assignment_show_rubric(ctx, course, assignment_id):
    assignment = get_assignment_or_exit(ctx, course, assignment_id)

    rubric = RubricFile.from_assignment(assignment)
    print(rubric.to_yaml())
예제 #19
0
def instructor_grading_show_grading_status(ctx, course, assignment_id, by_grader, include_diff_urls, use_stored_grades):
    assignment = get_assignment_or_exit(ctx, course, assignment_id, include_rubric = True)
    rubric_components = assignment.get_rubric_components()

    teams_registrations = get_teams_registrations(course, assignment, include_grades = use_stored_grades)
    teams = sorted(list(teams_registrations.keys()), key=operator.attrgetter("team_id"))
    
    team_status = []
    graders = set()
    
    for team in teams:
        registration = teams_registrations[team]

        if registration.grader is None:
            grader_str = "<no grader assigned>"
        else:
            grader_str = registration.grader.user.username
        graders.add(grader_str)
        
        grading_status = None
        diff_url = ""
        
        if use_stored_grades:
            grades = registration.get_grades()
            total_grade = registration.get_total_grade()
            
            graded_rc_ids = [g.rubric_component_id for g in grades]            
        else:
            total_grade = 0.0
            repo = GradingGitRepo.get_grading_repo(ctx.obj['config'], course, team, registration)
            if repo is None:
                grading_status = "NO GRADING REPO"
            else:
                rubricfile = repo.repo_path + "/%s.rubric.txt" % assignment.assignment_id
        
                if not os.path.exists(rubricfile):
                    grading_status = "NOT GRADED - No rubric"
                else:        
                    try:
                        rubric = RubricFile.from_file(open(rubricfile), assignment)

                        graded_rc_ids = [rc.id for rc in rubric_components if rubric.points_obtained[rc.description] is not None]  
                
                        total_grade = rubric.get_total_points_obtained()
                    except ChisubmitRubricException as cre:
                        grading_status = "ERROR: Rubric does not validate (%s)" % (cre)
                        
        if grading_status is None:
            has_some = False
            has_all = True
            for rc in rubric_components:
                if rc.id in graded_rc_ids:
                    has_some = True
                else:
                    has_all = False
                            
            if not has_some:
                grading_status = "NOT GRADED"
            elif has_all:
                grading_status = "GRADED"
            else:
                grading_status = "PARTIALLY GRADED"

            
            if include_diff_urls and has_some:
                commit_sha = registration.final_submission.commit_sha[:8]
                diff_url = "https://mit.cs.uchicago.edu/%s-staging/%s/compare/%s...%s-grading" % (course.course_id, team.team_id, commit_sha, assignment.assignment_id)
            
        team_status.append((team.team_id, grader_str, total_grade, diff_url, grading_status))

    if not by_grader:
        for team, grader, total_grade, diff_url, status in team_status:
            print("%-40s %-20s %-20.2f %10s  %s" % (team, status, total_grade, grader, diff_url))
    else:
        all_grades = []
        for grader in sorted(list(graders)):
            print(grader)
            print("-" * len(grader))
            
            grades = []
            
            team_status_grader = [ts for ts in team_status if ts[1] == grader]
            
            for team, _, total_grade, diff_url, status in team_status_grader:
                if status == "NOT GRADED":
                    print("%-40s %s  %s" % (team, status, diff_url))
                else:
                    print("%-40s %s %8.2f  %s" % (team, status, total_grade, diff_url))
                    if status == "GRADED":
                        grades.append(total_grade)
                        
            if len(grades) > 0:
                all_grades += grades
                print_grades_stats(grades)
            print()

        if len(all_grades) > 0:
            print("TOTAL")
            print("-----")
            print_grades_stats(all_grades)

    return CHISUBMIT_SUCCESS
예제 #20
0
def instructor_grading_show_grading_status(ctx, course, assignment_id,
                                           by_grader, include_diff_urls,
                                           use_stored_grades):
    assignment = get_assignment_or_exit(ctx,
                                        course,
                                        assignment_id,
                                        include_rubric=True)
    rubric_components = assignment.get_rubric_components()

    teams_registrations = get_teams_registrations(
        course, assignment, include_grades=use_stored_grades)
    teams = sorted(list(teams_registrations.keys()),
                   key=operator.attrgetter("team_id"))

    team_status = []
    graders = set()

    for team in teams:
        registration = teams_registrations[team]

        if registration.grader is None:
            grader_str = "<no grader assigned>"
        else:
            grader_str = registration.grader.user.username
        graders.add(grader_str)

        grading_status = None
        diff_url = ""

        if use_stored_grades:
            grades = registration.get_grades()
            total_grade = registration.get_total_grade()

            graded_rc_ids = [g.rubric_component_id for g in grades]
        else:
            total_grade = 0.0
            repo = GradingGitRepo.get_grading_repo(ctx.obj['config'], course,
                                                   team, registration)
            if repo is None:
                grading_status = "NO GRADING REPO"
            else:
                rubricfile = repo.repo_path + "/%s.rubric.txt" % assignment.assignment_id

                if not os.path.exists(rubricfile):
                    grading_status = "NOT GRADED - No rubric"
                else:
                    try:
                        rubric = RubricFile.from_file(open(rubricfile),
                                                      assignment)

                        graded_rc_ids = [
                            rc.id for rc in rubric_components if
                            rubric.points_obtained[rc.description] is not None
                        ]

                        total_grade = rubric.get_total_points_obtained()
                    except ChisubmitRubricException as cre:
                        grading_status = "ERROR: Rubric does not validate (%s)" % (
                            cre)

        if grading_status is None:
            has_some = False
            has_all = True
            for rc in rubric_components:
                if rc.id in graded_rc_ids:
                    has_some = True
                else:
                    has_all = False

            if not has_some:
                grading_status = "NOT GRADED"
            elif has_all:
                grading_status = "GRADED"
            else:
                grading_status = "PARTIALLY GRADED"

            if include_diff_urls and has_some:
                commit_sha = registration.final_submission.commit_sha[:8]
                diff_url = "https://mit.cs.uchicago.edu/%s-staging/%s/compare/%s...%s-grading" % (
                    course.course_id, team.team_id, commit_sha,
                    assignment.assignment_id)

        team_status.append(
            (team.team_id, grader_str, total_grade, diff_url, grading_status))

    if not by_grader:
        for team, grader, total_grade, diff_url, status in team_status:
            print("%-40s %-20s %-20.2f %10s  %s" %
                  (team, status, total_grade, grader, diff_url))
    else:
        all_grades = []
        for grader in sorted(list(graders)):
            print(grader)
            print("-" * len(grader))

            grades = []

            team_status_grader = [ts for ts in team_status if ts[1] == grader]

            for team, _, total_grade, diff_url, status in team_status_grader:
                if status == "NOT GRADED":
                    print("%-40s %s  %s" % (team, status, diff_url))
                else:
                    print("%-40s %s %8.2f  %s" %
                          (team, status, total_grade, diff_url))
                    if status == "GRADED":
                        grades.append(total_grade)

            if len(grades) > 0:
                all_grades += grades
                print_grades_stats(grades)
            print()

        if len(all_grades) > 0:
            print("TOTAL")
            print("-----")
            print_grades_stats(all_grades)

    return CHISUBMIT_SUCCESS
예제 #21
0
파일: grading.py 프로젝트: jclmns/chisubmit
def instructor_grading_collect_rubrics(ctx, course, assignment_id, dry_run,
                                       grader_id):
    assignment = course.get_assignment(assignment_id)
    if assignment is None:
        print "Assignment %s does not exist" % assignment_id
        ctx.exit(CHISUBMIT_FAIL)

    if grader_id is not None:
        grader = course.get_grader(grader_id)
        if grader is None:
            print "Grader %s does not exist" % grader_id
            ctx.exit(CHISUBMIT_FAIL)
    else:
        grader = None

    gcs = assignment.grade_components

    teams = get_teams(course, assignment, grader=grader)

    for team in teams:
        repo = GradingGitRepo.get_grading_repo(ctx.obj['config'], course, team,
                                               assignment)
        if repo is None:
            print "Repository for %s does not exist" % (team.id)
            continue

        rubricfile = repo.repo_path + "/%s.rubric.txt" % assignment.id

        if not os.path.exists(rubricfile):
            print "Repository for %s does not have a rubric for assignment %s" % (
                team.id, assignment.id)
            continue

        try:
            rubric = RubricFile.from_file(open(rubricfile), assignment)
        except ChisubmitRubricException, cre:
            print "ERROR: Rubric for %s does not validate (%s)" % (team.id,
                                                                   cre.message)
            continue

        points = []
        for gc in gcs:
            grade = rubric.points[gc.description]
            if grade is None:
                points.append(0.0)
            else:
                if not dry_run:
                    team.set_assignment_grade(assignment.id, gc.id, grade)
                points.append(grade)

        penalties = {}
        total_penalties = 0.0
        if rubric.penalties is not None:
            for desc, p in rubric.penalties.items():
                penalties[desc] = p
                total_penalties += p

        if not dry_run:
            team.set_assignment_penalties(assignment.id, penalties)

        if ctx.obj["verbose"]:
            print team.id
            print "+ %s" % points
            print "- %.2f" % total_penalties

        if not dry_run:
            new_team = course.get_team(team.id)
            assignment_team = new_team.get_assignment(assignment.id)
            total_grade = assignment_team.get_total_grade()
        else:
            total_grade = sum(points) + total_penalties

        if ctx.obj["verbose"]:
            print "TOTAL: %.2f" % total_grade
            print
        else:
            print "%-40s %.2f" % (team.id, total_grade)
예제 #22
0
def instructor_grading_show_grading_status(ctx, course, assignment_id,
                                           by_grader, include_diff_urls,
                                           use_stored_grades):
    assignment = get_assignment_or_exit(ctx,
                                        course,
                                        assignment_id,
                                        include_rubric=True)
    rubric_components = assignment.get_rubric_components()

    teams_registrations = get_teams_registrations(course,
                                                  assignment,
                                                  include_grades=True)
    teams = sorted(teams_registrations.keys(),
                   key=operator.attrgetter("team_id"))

    team_status = []
    graders = set()

    for team in teams:
        registration = teams_registrations[team]

        if registration.grader is None:
            grader_str = "<no grader assigned>"
        else:
            grader_str = registration.grader.user.username
        graders.add(grader_str)

        grading_status = None
        diff_url = ""

        if use_stored_grades:
            grades = registration.get_grades()
            total_grade = registration.get_total_grade()

            graded_rc_ids = [g.rubric_component_id for g in grades]
        else:
            total_grade = 0.0
            repo = GradingGitRepo.get_grading_repo(ctx.obj['config'], course,
                                                   team, registration)
            if repo is None:
                grading_status = "NO GRADING REPO"
            else:
                rubricfile = repo.repo_path + "/%s.rubric.txt" % assignment.assignment_id

                if not os.path.exists(rubricfile):
                    grading_status = "NOT GRADED - No rubric"
                else:
                    try:
                        rubric = RubricFile.from_file(open(rubricfile),
                                                      assignment)

                        graded_rc_ids = [
                            rc.id for rc in rubric_components
                            if rubric.points[rc.description] is not None
                        ]

                        for rc in rubric_components:
                            grade = rubric.points[rc.description]
                            if grade is not None:
                                total_grade += grade

                        if rubric.penalties is not None:
                            for p in rubric.penalties.values():
                                total_grade += p

                        if rubric.bonuses is not None:
                            for p in rubric.bonuses.values():
                                total_grade += p
                    except ChisubmitRubricException, cre:
                        grading_status = "ERROR: Rubric does not validate (%s)" % (
                            cre.message)

        if grading_status is None:
            has_some = False
            has_all = True
            for rc in rubric_components:
                if rc.id in graded_rc_ids:
                    has_some = True
                else:
                    has_all = False

            if not has_some:
                grading_status = "NOT GRADED"
            elif has_all:
                grading_status = "GRADED"
            else:
                grading_status = "PARTIALLY GRADED"

            if include_diff_urls and has_some:
                commit_sha = registration.final_submission.commit_sha[:8]
                diff_url = "https://mit.cs.uchicago.edu/%s-staging/%s/compare/%s...%s-grading" % (
                    course.course_id, team.team_id, commit_sha,
                    assignment.assignment_id)

        team_status.append(
            (team.team_id, grader_str, total_grade, diff_url, grading_status))