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
c488cdac
Commit
c488cdac
authored
4 years ago
by
Christopher Bohn
Browse files
Options
Downloads
Patches
Plain Diff
Added student roster validation
parent
17190b69
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
api/composite_user.py
+6
-0
6 additions, 0 deletions
api/composite_user.py
prep_assignment.py
+64
-14
64 additions, 14 deletions
prep_assignment.py
with
70 additions
and
14 deletions
api/composite_user.py
+
6
−
0
View file @
c488cdac
...
...
@@ -57,6 +57,12 @@ class CompositeUser:
'
GitlabEmail
'
:
gitlab_student
.
get_email
()}
return
CompositeUser
(
student
,
{},
set
())
def
get_name
(
self
)
->
str
:
return
self
.
readable_name
def
get_canvas_username
(
self
)
->
str
:
return
self
.
canvas_username
def
get_canvas_user
(
self
)
->
CanvasUser
:
if
self
.
canvas_user
is
None
:
# self.canvas_user = CanvasUser(self.NUID) # n.b., can retrieve own user but not arbitrary user
...
...
This diff is collapsed.
Click to expand it.
prep_assignment.py
+
64
−
14
View file @
c488cdac
...
...
@@ -23,6 +23,53 @@ def get_students() -> Set[CompositeUser]:
return
students
def
validate_roster_against_canvas
(
course_roster
:
Set
[
CompositeUser
])
->
bool
:
print
(
'
Validating course roster against Canvas.
'
)
course
=
CanvasCourse
(
Course
.
canvas_course_id
)
students_in_canvas
=
course
.
get_students
()
roster_names
:
Set
[
str
]
=
set
(
map
(
lambda
s
:
s
.
get_canvas_username
(),
course_roster
))
canvas_names
:
Set
[
str
]
=
set
(
map
(
lambda
s
:
s
.
get_username
(),
students_in_canvas
))
roster_is_valid
:
bool
=
True
difference
:
Set
[
str
]
=
roster_names
-
canvas_names
if
len
(
difference
)
>
0
:
roster_is_valid
=
False
print
(
'
\t
Student(s) are in roster but not in Canvas. The roster is invalid:
'
)
extra_students
:
Set
[
CompositeUser
]
=
set
(
filter
(
lambda
s
:
s
.
get_canvas_username
()
in
difference
,
course_roster
))
for
student
in
extra_students
:
print
(
f
'
\t\t
{
student
}
'
)
difference
=
canvas_names
-
roster_names
if
len
(
difference
)
>
0
:
roster_is_valid
=
False
print
(
'
\t
Student(s) are in Canvas but not in roster. The roster is invalid:
'
)
extra_students
:
Set
[
CanvasUser
]
=
set
(
filter
(
lambda
s
:
s
.
get_username
()
in
difference
,
students_in_canvas
))
for
student
in
extra_students
:
print
(
f
'
\t\t
{
student
.
get_name
()
}
(
{
student
}
)
'
)
if
roster_is_valid
:
print
(
f
'
\t
{
len
(
roster_names
)
}
names match. The roster is valid.
'
)
return
roster_is_valid
def
validate_roster_against_gitlab
(
course_roster
:
Set
[
CompositeUser
])
->
bool
:
print
(
'
Validating course roster against GitLab.
'
)
roster_is_valid
:
bool
=
True
invalid_users
:
Set
[
CompositeUser
]
=
set
()
for
student
in
course_roster
:
username
:
str
=
student
.
gitlab_username
try
:
print
(
f
'
\t
{
student
.
get_name
()
}
'
.
ljust
(
30
,
'
.
'
),
end
=
'
'
)
GitlabUser
(
username
)
print
(
'
✅
'
)
except
IndexError
:
print
(
'
❌
'
)
invalid_users
.
add
(
student
)
if
len
(
invalid_users
)
>
0
:
roster_is_valid
=
False
print
(
'
\t
Student(s) have invalid GitLab usernames (may have changed usernames):
'
)
for
student
in
invalid_users
:
print
(
f
'
\t\t
{
student
}
'
)
return
roster_is_valid
# TODO: assign_partners for arbitrarily-sized teams
# TODO: break this up into bite-sized chunks
# TODO: manage multiple sections
...
...
@@ -233,8 +280,9 @@ def create_groups(groupset_name: str,
if
__name__
==
'
__main__
'
:
groupset
:
str
=
input
(
'
Please provide the name of the student groupset:
'
)
student_set
:
Set
[
CompositeUser
]
=
get_students
()
# TODO: check for changes to course roster
# TODO: check for changes to gitlab usernames
course_roster_matches_canvas
:
bool
=
validate_roster_against_canvas
(
student_set
)
course_roster_matches_gitlab
:
bool
=
validate_roster_against_gitlab
(
student_set
)
if
course_roster_matches_canvas
and
course_roster_matches_gitlab
:
partners
:
List
[
Tuple
[
int
,
CompositeUser
,
CompositeUser
,
Optional
[
CompositeUser
]]]
=
create_pairs
(
student_set
,
groupset
)
print
()
...
...
@@ -247,3 +295,5 @@ if __name__ == '__main__':
print
()
print
(
'
TODO:
\t
Add issues
'
)
print
(
'
\t
Commit starter code
'
)
else
:
print
(
'
No partners assigned due to invalid roster. Please update student roster file.
'
)
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