Skip to content

Instantly share code, notes, and snippets.

@bfritscher
Last active March 15, 2024 07:10
Show Gist options
  • Select an option

  • Save bfritscher/b039cc4d1e33efc884a37fb7ddda923f to your computer and use it in GitHub Desktop.

Select an option

Save bfritscher/b039cc4d1e33efc884a37fb7ddda923f to your computer and use it in GitHub Desktop.

Revisions

  1. bfritscher revised this gist Mar 15, 2024. 1 changed file with 12 additions and 6 deletions.
    18 changes: 12 additions & 6 deletions group.py
    Original file line number Diff line number Diff line change
    @@ -3,7 +3,11 @@
    import csv
    from collections import defaultdict

    assignment = 'vuejs-evaluation-03-24-2023-11-56-56'
    # Usage on windows
    # gh classroom clone student-repos
    # add classroom_roster.csv
    # rename root folder and match prefix
    assignment_prefix = 'vuejs-evaluation-ne-'

    index = {}
    folders = defaultdict(lambda: 'other')
    @@ -13,14 +17,15 @@
    with open('classroom_roster.csv') as csvfile:
    spamreader = csv.DictReader(csvfile)
    for row in spamreader:
    index[row['github_username']] = row
    index[f"{assignment_prefix}{row['github_username']}"] = row

    from pathlib import Path
    for fd in ['ne', 'ge', 'vs', 'other']:
    Path(f"./sorted_{assignment}/{fd}").mkdir(parents=True, exist_ok=True)
    Path(f"./sorted_{assignment_prefix}/{fd}").mkdir(parents=True, exist_ok=True)

    # for folder move it to the right folder and rename it
    assignments = list([fd for fd in glob.glob('*', root_dir=assignment)])
    assignments = list([fd for fd in glob.glob('*', root_dir=assignment_prefix)])
    print(f"found assignments {len(assignments)}")
    for fd in assignments:
    dest_dir = 'other'
    ident = fd
    @@ -30,8 +35,9 @@
    dest_dir = folders[row['identifier'].split('@')[1]]
    ident = f"{row['identifier'].split('@')[0]}_{fd}"
    print(dest_dir, fd, row['identifier'])
    src = os.path.join(assignment, fd)
    dest = os.path.join(f"sorted_{assignment}", dest_dir, ident)
    src = os.path.join(assignment_prefix, fd)
    dest = os.path.join(f"sorted_{assignment_prefix}", dest_dir, ident)
    cmd = f"xcopy {src} {dest} /E/H/C/I"
    print(cmd)
    os.system(cmd)

  2. bfritscher created this gist Mar 24, 2023.
    37 changes: 37 additions & 0 deletions group.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,37 @@
    import glob
    import os
    import csv
    from collections import defaultdict

    assignment = 'vuejs-evaluation-03-24-2023-11-56-56'

    index = {}
    folders = defaultdict(lambda: 'other')
    folders['he-arc.ch'] = 'ne'
    folders['etu.hesge.ch'] = 'ge'
    folders['students.hevs.ch'] = 'vs'
    with open('classroom_roster.csv') as csvfile:
    spamreader = csv.DictReader(csvfile)
    for row in spamreader:
    index[row['github_username']] = row

    from pathlib import Path
    for fd in ['ne', 'ge', 'vs', 'other']:
    Path(f"./sorted_{assignment}/{fd}").mkdir(parents=True, exist_ok=True)

    # for folder move it to the right folder and rename it
    assignments = list([fd for fd in glob.glob('*', root_dir=assignment)])
    for fd in assignments:
    dest_dir = 'other'
    ident = fd
    if fd in index:
    row = index[fd]
    if '@' in row['identifier']:
    dest_dir = folders[row['identifier'].split('@')[1]]
    ident = f"{row['identifier'].split('@')[0]}_{fd}"
    print(dest_dir, fd, row['identifier'])
    src = os.path.join(assignment, fd)
    dest = os.path.join(f"sorted_{assignment}", dest_dir, ident)
    cmd = f"xcopy {src} {dest} /E/H/C/I"
    print(cmd)
    os.system(cmd)