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
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
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
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
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
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)
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())
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())