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

restructured repository

parent 6406e185
Branches
No related tags found
No related merge requests found
# Scripts for automating CSCE 361 tasks
These python and bash scripts (and a C program) serve to automate assignment
management, with an eye toward scaling to larger class sizes.
These scripts are designed to automate the creation, population, and staffing
of repositories for student assignments.
The scripts that interface with remote systems are in the `api` directory, and
the scripts that do work are in the top-level directory.
## Requires
- python-gitlab
- `pip3 install python-gitlab`
- documentation: https://python-gitlab.readthedocs.io
- canvasapi
- `pip3 install canvasapi`
- documentation: https://canvasapi.readthedocs.io/en/latest/index.html
- https://community.canvaslms.com/videos/3227-pycanvas-a-python-wrapper-for-the-canvas-api-matthew-emond
- I'm pretty sure this isn't the same API wrapper that Chris Bourke is using
## Files
- config.py
- provides URLs and API keys
- *do not* commit API keys to repository
- you will need to replace `None` with your API keys (as strings)
- course.py
- provides namespace and group ID
- will need to update each semester
- prep_assignment.py
- An early iteration of automated student pairing, canvas student group creation, and gitlab repo creation. It
lacks robustness to odd number of students; it has a quick'n'dirty loop termination that does not guarantee
graylist compliance, and project naming is hard-coded.
- api/
- Directory containing functions that interface with `git.unl.edu` and
`canvas.unl.edu`. When you copy these to the grading directory, place
your api keys in `config.py`.
- canvas_classes.py
- Classes to encapsulate concepts from Canvas CMS
- gitlab_classes.py
- Classes to encapsulate concepts from Gitlab VMS
- composite_user.py
- Wrapper class that pairs a user from Canvas with the corresponding user from Gitlab
## Older Files
These are vestigial files that should not be needed further, but we are retaining until we are certain.
- old-automation/
- Directory containing early fall 2019 scripts to clone, create, process,
etc., student repositories. The contents of this directory are not
needed.
- 1195
- 1195/
- Directory containing scripts from summer 2019 pilot of new course
structure. Should be obsolete (and removed) by end of fall 2019. The
contents of this directory are not needed.
- experimentation/
- gitlab_functions.py
- provides functions to query & update projects (including its members
and issues)
- These functions are those we believe are useful for automating pair
& team projects for CSCE 361
- These generally are wrappers for calls you *could* make directly
from what python-gitlab provides, but these functions don't require
you to memorize the api
- includes an enumeration of the fields for User, Project, and Issue
- includes side-effect-free example function calls
- gitlab_demo.py
- includes commented-out functions demonstrating the creation of
projects, adding users to projects, and creating/updating the projects'
issues
- canvas_experiments.py
- includes experimental use of the Canvas API, culminating in creating
a group set (group_category), adding groups to it, and adding students
to a group
\ No newline at end of file
# CSCE 361 Scripts
These scripts are designed to automate the creation, population, and staffing
of repositories for student assignments.
## Requires
- python-gitlab
- `pip3 install python-gitlab`
- documentation: https://python-gitlab.readthedocs.io
- canvasapi
- `pip3 install canvasapi`
- documentation: https://canvasapi.readthedocs.io/en/latest/index.html
- https://community.canvaslms.com/videos/3227-pycanvas-a-python-wrapper-for-the-canvas-api-matthew-emond
- I'm pretty sure this isn't the same API wrapper that Chris Bourke is using
## Files
- config.py
- provides URLs and API keys
- *do not* commit API keys to repository
- you will need to replace `None` with your API keys (as strings)
- course.py
- provides namespace and group ID
- will need to update each semester
- gitlab_functions.py
- provides functions to query & update projects (including its members
and issues)
- These functions are those we believe are useful for automating pair
& team projects for CSCE 361
- These generally are wrappers for calls you *could* make directly
from what python-gitlab provides, but these functions don't require
you to memorize the api
- includes an enumeration of the fields for User, Project, and Issue
- includes side-effect-free example function calls
- gitlab_demo.py
- includes commented-out functions demonstrating the creation of
projects, adding users to projects, and creating/updating the projects'
issues
- canvas_experiments.py
- includes experimental use of the Canvas API, culminating in creating
a group set (group_category), adding groups to it, and adding students
to a group
File moved
from canvas_classes import CanvasUser
from canvas_classes import CanvasCourse
from gitlab_classes import GitlabUser
from api.canvas_classes import CanvasUser
from api.canvas_classes import CanvasCourse
from api.gitlab_classes import GitlabUser
from course import Course
import csv
......
......@@ -214,7 +214,8 @@ class GitlabProject:
@staticmethod
def create_project_in_group(group_name, project_name):
group_id = GitlabSession.get_session().groups.get(group_name).id
return GitlabProject(GitlabSession.get_session().projects.create({'name': project_name, 'namespace_id': group_id}))
return GitlabProject(GitlabSession.get_session().projects.create({'name': project_name,
'namespace_id': group_id}))
def get_project_id(self):
return self.git_project.id
......
File moved
File moved
File moved
from gitlab import Gitlab
import gitlab_functions
from config import Config
from course import Course
"""
def add_rubi(git_server):
......
......@@ -156,9 +156,9 @@ def create_issue(project, title, description):
if __name__ == '__main__':
git = gitlab.Gitlab(Config.gitlab_url, private_token=Config.gitlab_api_key)
project = get_project_by_id(git, '5484')
student = get_user_by_id(git, project.creator_id)
print(f'{student.name} forked repo at {project.created_at}')
sample_project = get_project_by_id(git, '5484')
student = get_user_by_id(git, sample_project.creator_id)
print(f'{student.name} forked repo at {sample_project.created_at}')
print('getting a user, by name')
print(get_user_by_name(git, 'bohn'))
print('getting a user by user ID and printing only the user\'s name')
......
import random
import subprocess
from composite_user import CompositeUser
from canvas_classes import *
from gitlab_classes import *
from api.composite_user import CompositeUser
from api.canvas_classes import *
from api.gitlab_classes import *
from course import Course
......@@ -13,7 +13,7 @@ def create_pairs(filename):
key=lambda t: len(t.blacklist), reverse=True)
unassigned_students = set(students)
pair_number = 0
pairs = []
student_pairs = []
for student in students_with_blacklist:
pair_number += 1
unassigned_students.remove(student)
......@@ -23,7 +23,7 @@ def create_pairs(filename):
# has the potential to run infinitely
potential_partner = random.choice(tuple(unassigned_students))
unassigned_students.remove(potential_partner)
pairs.append((pair_number, student, potential_partner))
student_pairs.append((pair_number, student, potential_partner))
while unassigned_students:
pair_number += 1
student = random.choice(tuple(unassigned_students))
......@@ -34,8 +34,8 @@ def create_pairs(filename):
attempts += 1
potential_partner = random.choice(tuple(unassigned_students))
unassigned_students.remove(potential_partner)
pairs.append((pair_number, student, potential_partner))
return pairs
student_pairs.append((pair_number, student, potential_partner))
return student_pairs
def save_pairs(assignment_number, student_pairs):
......@@ -54,7 +54,8 @@ def create_repositories(assignment_number, student_pairs):
clone_file.write('#!/bin/bash\n\n')
clone_file.write('# Auto-generated clone script.\n')
for pair in student_pairs:
project = GitlabProject.create_project_in_group(Course.gitlab_namespace, f'{assignment_number}pair{pair[0]}')
project = GitlabProject.create_project_in_group(Course.gitlab_namespace,
f'{assignment_number}pair{pair[0]}')
project.add_user_as_maintainer(pair[1].get_gitlab_user())
project.add_user_as_maintainer(pair[2].get_gitlab_user())
repo_url = project.get_cloning_url()
......@@ -77,12 +78,6 @@ if __name__ == '__main__':
save_pairs(assignment, pairs)
print('Pairs created')
# pair = list(pairs)[0]
# print(f'{pair[1].get_gitlab_user()}, {pair[2].get_gitlab_user()}')
# project = GitlabProject.create_project_in_group(Course.gitlab_namespace, f'{assignment_number}pairx{pair[0]}')
# project.add_user_as_maintainer(pair[1].get_gitlab_user())
# project.add_user_as_maintainer(pair[2].get_gitlab_user())
create_repositories(assignment, pairs)
print('Repositories created')
create_groups(assignment, pairs)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment