Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
scripts
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
CSCE 361
scripts
Commits
c9f8b987
Commit
c9f8b987
authored
5 years ago
by
Christopher Bohn
Browse files
Options
Downloads
Patches
Plain Diff
Added code to retrieve student contributions to codebase
parent
d48d8883
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
grade_team_contribution.py
+26
-6
26 additions, 6 deletions
grade_team_contribution.py
with
26 additions
and
6 deletions
grade_team_contribution.py
+
26
−
6
View file @
c9f8b987
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\n
Press Enter to grade
{
student_group
}
'
)
input
(
f
'
\n\n
Press 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
())
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment