Commit ffa01d8b authored by Cyril Matthey-Doret's avatar Cyril Matthey-Doret
Browse files

add script to send feedback to students as issues

parent 9c6f8037
Pipeline #328358 passed with stage
in 13 seconds
#!/usr/bin/env python3
# This script sends feedback to students' forks by opening issues with the Gitlab API
# The target forks and associated metadata are read from stdin. The script expects JSON
# data as outputted by
# The issues are based on a template, with the content read from a separate CSV table
# with columns "id", "grade", "comments"
import sys
import json
import requests
import click
import pandas as pd
from teach_utils.common_requests import parse_repo_url
# {project}, group {group}
Please find below your grade and specific comments for this project:
## Grade:
## Comments:
@click.argument("feedback", type=click.Path(exists=True))
@click.argument("forks", type=click.File(mode="r"), default=sys.stdin)
help="Path to a file containing the Gitlab API token. If not provided, you will be prompted for the token.",
def main(forks, feedback, token):
Send feedback to repositories in input JSON by opening issues.
The feedback table should be a CSV file with columns "id", "grade" and "comments".
The id column should match a gitlab project ID from the JSON input
# Build header with authentication token
if token is None:
token = click.prompt("Please enter your Gitlab API token", hide_input=True)
token = open(token).read().strip()
header = {"PRIVATE-TOKEN": token}
forks = json.load(forks)
feedback = pd.read_csv(feedback)
for fork in forks:
# Replace content for current project in issue template
base, group, repo = parse_repo_url(fork["url"])
grade, comments = feedback.loc[
feedback["id"] == fork["id"], ["grade", "comments"]
description = FEEDBACK_TEMPLATE.format(
project=repo, group=group, grade=grade, comments=comments
# Create issue
data={"description": description},
if __name__ == "__main__":
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment