def instructor_grading_pull_grading(ctx, course, assignment_id, from_students, only, yes): assignment = get_assignment_or_exit(ctx, course, assignment_id) if from_students: print "Pulling grading from the student repositories is an uncommon operation." print "Instead, you should only ever make changes to the grading in the staging" print "repositories, and push those changes to the student repositories (which" print "should always mirror what is in the staging repositories). So, there should" print "never be a need to pull grading from a student repository." print print "Are you sure you want to continue and pull the grading from" print "the student repositories? (y/n): ", if not yes: yesno = raw_input() else: yesno = 'y' print 'y' if yesno not in ('y', 'Y', 'yes', 'Yes', 'YES'): ctx.exit(CHISUBMIT_FAIL) teams_registrations = get_teams_registrations(course, assignment, only = only) teams = sorted(teams_registrations.keys(), key=operator.attrgetter("team_id")) for team in teams: registration = teams_registrations[team] print "Pulling grading branch for team %s... " % team.team_id gradingrepo_pull_grading_branch(ctx.obj['config'], course, team, registration, from_students = from_students) return CHISUBMIT_SUCCESS
def grader_pull_grading_branches(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, only_ready_for_grading=True) if not teams: ctx.exit(CHISUBMIT_FAIL) for team in teams: print "Pulling grading branch for team %s... " % team.id gradingrepo_pull_grading_branch(ctx.obj['config'], course, team, assignment, from_staging=True) return CHISUBMIT_SUCCESS
def grader_create_local_grading_repos(ctx, course, grader_id, assignment_id): 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) if not teams: print "No teams found" ctx.exit(CHISUBMIT_FAIL) repos = create_grading_repos(ctx.obj['config'], course, assignment, teams) if not repos: print "There was some kind of problem creating the grading repos." ctx.exit(CHISUBMIT_FAIL) for repo in repos: repo.set_grader_author() for team in teams: print ("Pulling grading branch for team %s... " % team.id), gradingrepo_pull_grading_branch(ctx.obj['config'], course, team, assignment, from_staging = True) print "done" return CHISUBMIT_SUCCESS
def instructor_grading_create_grading_repos(ctx, course, assignment_id, all_teams, only, master): assignment = get_assignment_or_exit(ctx, course, assignment_id) teams_registrations = get_teams_registrations( course, assignment, only=only, only_ready_for_grading=not all_teams) if len(teams_registrations) == 0: 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("%40s -- Creating grading repo... " % team.team_id), repo = GradingGitRepo.create_grading_repo(ctx.obj['config'], course, team, registration, staging_only=not master) repo.sync() if registration.final_submission is not None: if repo.has_grading_branch_staging(): gradingrepo_pull_grading_branch(ctx.obj['config'], course, team, registration) print "done" else: if master: repo.create_grading_branch() print "done (and created grading branch)" else: print "done (warning: could not pull grading branch; it does not exist)" else: print "done (note: has not submitted yet)" else: print("%40s -- Updating grading repo... " % team.team_id), if repo.has_grading_branch_staging(): gradingrepo_pull_grading_branch(ctx.obj['config'], course, team, registration) print "done (pulled latest grading branch)" elif repo.has_grading_branch(): print "nothing to update (grading branch is not in staging)" elif registration.final_submission is not None and master: repo.create_grading_branch() print "done (created missing grading branch)" else: print "nothing to update (there is no grading branch)" 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(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 instructor_grading_pull_grading_branches(ctx, course, assignment_id, from_staging, from_students, only): 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 = only) if teams is None: ctx.exit(CHISUBMIT_FAIL) for team in teams: print "Pulling grading branch for team %s... " % team.id gradingrepo_pull_grading_branch(ctx.obj['config'], course, team, assignment, from_staging = from_staging, from_students = from_students) return CHISUBMIT_SUCCESS
def instructor_grading_pull_grading(ctx, course, assignment_id, from_students, only, yes): assignment = get_assignment_or_exit(ctx, course, assignment_id) if from_students: print( "Pulling grading from the student repositories is an uncommon operation." ) print( "Instead, you should only ever make changes to the grading in the staging" ) print( "repositories, and push those changes to the student repositories (which" ) print( "should always mirror what is in the staging repositories). So, there should" ) print("never be a need to pull grading from a student repository.") print() print("Are you sure you want to continue and pull the grading from") print("the student repositories? (y/n): ", end=' ') if not yes: yesno = input() else: yesno = 'y' print('y') if yesno not in ('y', 'Y', 'yes', 'Yes', 'YES'): ctx.exit(CHISUBMIT_FAIL) teams_registrations = get_teams_registrations(course, assignment, only=only) teams = sorted(list(teams_registrations.keys()), key=operator.attrgetter("team_id")) for team in teams: registration = teams_registrations[team] print("Pulling grading branch for team %s... " % team.team_id) gradingrepo_pull_grading_branch(ctx.obj['config'], course, team, registration, from_students=from_students) return CHISUBMIT_SUCCESS
def instructor_grading_create_grading_repos(ctx, course, assignment_id, all_teams, only, master): assignment = get_assignment_or_exit(ctx, course, assignment_id) teams_registrations = get_teams_registrations(course, assignment, only = only, only_ready_for_grading=not all_teams) if len(teams_registrations) == 0: 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 = not master) repo.sync() if registration.final_submission is not None: if repo.has_grading_branch_staging(): gradingrepo_pull_grading_branch(ctx.obj['config'], course, team, registration) print "done" else: if master: repo.create_grading_branch() print "done (and created grading branch)" else: print "done (warning: could not pull grading branch; it does not exist)" else: print "done (note: has not submitted yet)" else: print "%20s -- Updating grading repo... " % team.team_id if repo.has_grading_branch_staging(): gradingrepo_pull_grading_branch(ctx.obj['config'], course, team, registration) print "done (pulled latest grading branch)" elif registration.final_submission is not None and master: repo.create_grading_branch() print "done (created missing grading branch)" else: print "nothing to update (there is no grading branch)" 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 grader_pull_grading_branches(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, only_ready_for_grading=True) if not teams: ctx.exit(CHISUBMIT_FAIL) for team in teams: print "Pulling grading branch for team %s... " % team.id gradingrepo_pull_grading_branch(ctx.obj['config'], course, team, assignment, from_staging = True) return CHISUBMIT_SUCCESS
def instructor_grading_pull_grading_branches(ctx, course, assignment_id, from_staging, from_students, only): 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=only) if teams is None: ctx.exit(CHISUBMIT_FAIL) for team in teams: print "Pulling grading branch for team %s... " % team.id gradingrepo_pull_grading_branch(ctx.obj['config'], course, team, assignment, from_staging=from_staging, from_students=from_students) return CHISUBMIT_SUCCESS
def grader_create_local_grading_repos(ctx, course, grader_id, assignment_id): 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) if not teams: print "No teams found" ctx.exit(CHISUBMIT_FAIL) repos = create_grading_repos(ctx.obj['config'], course, assignment, teams) if not repos: print "There was some kind of problem creating the grading repos." ctx.exit(CHISUBMIT_FAIL) for repo in repos: repo.set_grader_author() for team in teams: print("Pulling grading branch for team %s... " % team.id), gradingrepo_pull_grading_branch(ctx.obj['config'], course, team, assignment, from_staging=True) print "done" return CHISUBMIT_SUCCESS
def instructor_grading_create_grading_repos(ctx, course, assignment_id, all_teams, only, master): assignment = get_assignment_or_exit(ctx, course, assignment_id) teams_registrations = get_teams_registrations(course, assignment, only = only, only_ready_for_grading=not all_teams) if len(teams_registrations) == 0: print("There are no grading repos to create.") 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=' ') try: repo = GradingGitRepo.create_grading_repo(ctx.obj['config'], course, team, registration, staging_only = not master) repo.sync() except GitCommandError as gce: print(gce) if registration.final_submission is not None: if repo.has_grading_branch_staging(): if not registration.grading_started: print("ERROR: This repo has a grading branch, but is not marked as ready for grading.") else: gradingrepo_pull_grading_branch(ctx.obj['config'], course, team, registration) print("done") else: if master: repo.create_grading_branch() registration.grading_started = True print("done (and created grading branch)") else: print("done (warning: could not pull grading branch; it does not exist)") else: if registration.grading_started: print("ERROR: This team has not submitted this assignment, but the repo is marked as ready for grading.") else: print("done (note: has not submitted yet)") else: print(("%40s -- Updating grading repo... " % team.team_id), end=' ') if repo.has_grading_branch_staging(): if not registration.grading_started: print("ERROR: This repo has a grading branch, but is not marked as ready for grading.") else: try: gradingrepo_pull_grading_branch(ctx.obj['config'], course, team, registration) print("done (pulled latest grading branch)") except GitCommandError as gce: print(gce) elif repo.has_grading_branch(): print("nothing to update (grading branch is not in staging)") elif registration.final_submission is not None and master: try: repo.create_grading_branch() if not registration.grading_started: registration.grading_started = True print("done (created missing grading branch)") except GitCommandError as gce: print(gce) else: print("nothing to update (there is no grading branch)") return CHISUBMIT_SUCCESS
def instructor_grading_create_grading_repos(ctx, course, assignment_id, all_teams, only, master): assignment = get_assignment_or_exit(ctx, course, assignment_id) teams_registrations = get_teams_registrations( course, assignment, only=only, only_ready_for_grading=not all_teams) if len(teams_registrations) == 0: print("There are no grading repos to create.") 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=' ') try: repo = GradingGitRepo.create_grading_repo( ctx.obj['config'], course, team, registration, staging_only=not master) repo.sync() except GitCommandError as gce: print(gce) if registration.final_submission is not None: if repo.has_grading_branch_staging(): if not registration.grading_started: print( "ERROR: This repo has a grading branch, but is not marked as ready for grading." ) else: gradingrepo_pull_grading_branch( ctx.obj['config'], course, team, registration) print("done") else: if master: repo.create_grading_branch() registration.grading_started = True print("done (and created grading branch)") else: print( "done (warning: could not pull grading branch; it does not exist)" ) else: if registration.grading_started: print( "ERROR: This team has not submitted this assignment, but the repo is marked as ready for grading." ) else: print("done (note: has not submitted yet)") else: print(("%40s -- Updating grading repo... " % team.team_id), end=' ') if repo.has_grading_branch_staging(): if not registration.grading_started: print( "ERROR: This repo has a grading branch, but is not marked as ready for grading." ) else: try: gradingrepo_pull_grading_branch( ctx.obj['config'], course, team, registration) print("done (pulled latest grading branch)") except GitCommandError as gce: print(gce) elif repo.has_grading_branch(): print("nothing to update (grading branch is not in staging)") elif registration.final_submission is not None and master: try: repo.create_grading_branch() if not registration.grading_started: registration.grading_started = True print("done (created missing grading branch)") except GitCommandError as gce: print(gce) else: print("nothing to update (there is no grading branch)") return CHISUBMIT_SUCCESS