Skip to content
Snippets Groups Projects
Commit c9f8b987 authored by Christopher Bohn's avatar Christopher Bohn :thinking:
Browse files

Added code to retrieve student contributions to codebase

parent d48d8883
No related branches found
No related tags found
No related merge requests found
import textwrap import textwrap
from typing import List from math import ceil, log10
from typing import Tuple
from api.canvas_classes import * from api.canvas_classes import *
from api.gitlab_classes import * from api.gitlab_classes import *
...@@ -36,9 +37,26 @@ def get_project_prefix(canvas_groups): ...@@ -36,9 +37,26 @@ def get_project_prefix(canvas_groups):
return prefix return prefix
def display_git_contributions(project): def display_git_contributions(project: GitlabProject):
print('Review git contributions offline') # TODO: recognize that this only works for projects in namespace; will need to ask whether to retrieve project.
# TODO: recognize that this only works for projects in namespace; will need to ask whether project should be retrieved. commits: List[GitlabCommit] = project.get_commits() # TODO: narrow the selection
contributions: Dict[str, int] = {}
contributors: Set[Tuple[str, str]] = set()
# noinspection PyShadowingNames
for commit in commits:
if not commit.is_merge():
author = commit.get_author()
contributors.add((author['name'], author['email']))
email = author['email'] # TODO: manage aliases
size = commit.get_diff_size() # TODO: distinguish between file types
if email != 'bohn@unl.edu': # TODO: un-hard-code this
if email not in contributions:
contributions[email] = 0
contributions[email] += size
print(f'Total line changes by each contributor to {project} :')
for contribution in contributions:
contributor = list(filter(lambda c: c[1] == contribution, contributors))[0]
print(f'\t{str(contributions[contribution]).rjust(5)}\t{contributor}')
def grade(assignment1, assignment2, students): def grade(assignment1, assignment2, students):
...@@ -68,11 +86,13 @@ if __name__ == '__main__': ...@@ -68,11 +86,13 @@ if __name__ == '__main__':
if option is options[1]: if option is options[1]:
print('Which group?') print('Which group?')
student_groups = [select_from_list(student_groups, 'student group')] student_groups = [select_from_list(student_groups, 'student group')]
zero_padding: int = ceil(log10(len(projects)))
for student_group in student_groups: # TODO: Skip past graded groups for student_group in student_groups: # TODO: Skip past graded groups
input(f'\n\nPress Enter to grade {student_group}') input(f'\n\nPress Enter to grade {student_group}')
project_name = f'{project_prefix}{student_group.get_name().split()[1]}'.zfill(zero_padding)
display_git_contributions(list(filter(lambda p: p.get_name() == project_name, projects))[0])
print()
display_peer_reviews(peer_review_assignment, student_group.get_students()) display_peer_reviews(peer_review_assignment, student_group.get_students())
project_name = f'{project_prefix}{student_group.get_name().split()[1]}'
# display_git_contributions(list(filter(lambda p: p.get_name() == project_name, projects))[0])
# TODO: Ask if you want to grade (keep track of groups that you don't grade) # TODO: Ask if you want to grade (keep track of groups that you don't grade)
if True: if True:
grade(peer_review_assignment, None, student_group.get_students()) grade(peer_review_assignment, None, student_group.get_students())
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment