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
38df6b06
Commit
38df6b06
authored
5 years ago
by
Christopher Bohn
Browse files
Options
Downloads
Patches
Plain Diff
Added code to create clone script for code review & response assignments
parent
218d9b2f
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
prep-code-review-and-response.py
+57
-13
57 additions, 13 deletions
prep-code-review-and-response.py
with
57 additions
and
13 deletions
prep-code-review-and-response.py
+
57
−
13
View file @
38df6b06
...
...
@@ -4,28 +4,72 @@ from common_functions import select_from_list
# TODO: look for opportunity to reduce DRY, relative to main function in prep_assignment
def
create_partners
():
print
(
'
Creating pairs from students
'
)
the_groupset
:
str
=
input
(
'
Please provide the name of the student groupset:
'
)
the_student_set
:
Set
[
CompositeUser
]
=
get_students
(
)
group_set
:
str
=
input
(
'
Please provide the name of the student groupset:
'
)
students
:
Set
[
CompositeUser
]
=
get_students
(
)
print
(
'
Creating student pairs
'
)
# TODO: check for changes to course roster
# TODO: check for changes to gitlab usernames
the_partner
s
:
List
[
Tuple
[
int
,
CompositeUser
,
CompositeUser
,
Optional
[
CompositeUser
]]]
=
\
create_pairs
(
the_
student
_set
,
the_
groupset
)
pairing
s
:
List
[
Tuple
[
int
,
CompositeUser
,
CompositeUser
,
Optional
[
CompositeUser
]]]
=
\
create_pairs
(
student
s
,
group
_
set
)
print
()
save_student_roster
(
the_
student
_set
)
create_contact_list
(
the_
groupset
,
the_partner
s
)
save_student_roster
(
student
s
)
create_contact_list
(
group
_
set
,
pairing
s
)
print
()
create_groups
(
the_groupset
,
the_partners
)
create_groups
(
group_set
,
pairings
)
print
(
'
TODO: Manually edit the new student roster and the contact list as needed.
'
)
def
clone_forks
():
print
(
'
Cloning the forks (... not yet)
'
)
# TODO: look for opportunity to reduce DRY, relative to prep_assignment.create_repositories
# TODO: extract code for reuse in validate_forks
def
create_clone_script
():
old_groupset
:
str
=
input
(
'
Please provide the name of the student groupset for the previous assignment:
'
)
new_groupset
:
str
=
input
(
'
Please provide the name of the student groupset for the next assignment:
'
)
students
:
Set
[
CompositeUser
]
=
get_students
()
filename
=
f
'
{
new_groupset
}
-clone.sh
'
print
(
f
'
Creating file for clone script:
{
filename
}
.
'
)
course
=
CanvasCourse
(
Course
.
canvas_course_id
)
old_groups
:
List
[
CanvasUserGroup
]
=
list
(
filter
(
lambda
g
:
g
.
get_name
()
==
old_groupset
,
course
.
get_user_groupsets
()))[
0
].
get_groups
()
new_groups
:
List
[
CanvasUserGroup
]
=
list
(
filter
(
lambda
g
:
g
.
get_name
()
==
new_groupset
,
course
.
get_user_groupsets
()))[
0
].
get_groups
()
with
open
(
filename
,
mode
=
'
w
'
)
as
clone_file
:
clone_file
.
write
(
'
#!/bin/bash
\n\n
'
)
clone_file
.
write
(
'
# Auto-generated clone script.
\n\n\n
'
)
for
new_group
in
new_groups
:
new_group_name
:
str
=
new_group
.
get_name
().
strip
().
replace
(
"
"
,
""
)
clone_file
.
write
(
f
'
#
{
new_group_name
}
\n
'
)
group_students
:
List
[
CanvasUser
]
=
new_group
.
get_students
()
for
student
in
group_students
:
old_group_name
:
str
=
list
(
filter
(
lambda
g
:
student
in
g
.
get_students
(),
old_groups
))[
0
].
get_name
().
strip
().
replace
(
"
"
,
""
)
print
(
f
'
\t
{
student
.
get_name
()
}
was in
{
old_group_name
}
and is now in
{
new_group_name
}
.
'
)
composite_student
:
CompositeUser
=
list
(
filter
(
lambda
s
:
s
.
get_canvas_user
()
==
student
,
students
))[
0
]
gitlab_username
:
str
=
composite_student
.
get_gitlab_user
().
get_username
()
# # THIS WOULD BE USED IF WE KNEW THE FORKS WERE PRESENT; IF THEY'RE NOT PRESENT THEN LEN(PROJECTS)==0
# projects: List[GitlabProject] = GitlabProject.get_projects_by_keyword(old_group_name)
# project: GitlabProject = \
# list(filter(lambda p: p.get_creator().get_username() == gitlab_username, projects))[0]
# repo_url: str = project.get_cloning_url()
# # THIS IS HOW WE'LL FAKE IT
repo_url
:
str
=
f
'
git@git.unl.edu:
{
gitlab_username
}
/
{
old_group_name
}
.git
'
clone_file
.
write
(
f
'
git clone
{
repo_url
}
{
new_group_name
}
-
{
student
.
get_name
().
replace
(
"
"
,
"
_
"
)
}
\n
'
)
clone_file
.
write
(
'
\n
'
)
subprocess
.
call
([
'
chmod
'
,
'
+x
'
,
filename
])
def
validate_forks
():
print
(
'
Examining the forks (... not yet)
'
)
if
__name__
==
'
__main__
'
:
print
(
'
There are two steps, creating partners (before the completion of the assignment to be reviewed),
'
)
print
(
'
and cloning/verifying successful forks (after deadline to fork & add Maintainers)
'
)
print
(
'
There are four steps, creating partners (before the completion of the assignment
'
)
print
(
'
to be reviewed), manually adjusting the pairings as needed (e.g., due to
'
)
print
(
'
excusals from previous assignment, creating the cloning script after adjustments
'
)
print
(
'
have been made, and validating successful forks (after deadline to fork & add
'
)
print
(
'
Maintainers).
'
)
print
()
tasks
=
{
'
Create partners
'
:
create_partners
,
'
Clone forks
'
:
clone_forks
}
tasks
=
{
'
Create partners
'
:
create_partners
,
'
Create clone script
'
:
create_clone_script
,
'
Validate forks
'
:
validate_forks
}
task
=
select_from_list
(
list
(
tasks
),
'
task
'
)
tasks
[
task
]()
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