Skip to content

Instantly share code, notes, and snippets.

@hig3
Created August 2, 2017 07:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hig3/1c9f55dafc7c00a30fdc7830179606b6 to your computer and use it in GitHub Desktop.
Save hig3/1c9f55dafc7c00a30fdc7830179606b6 to your computer and use it in GitHub Desktop.
Python script to make directory structure of feedback files from the offline grading worksheet in Moodle Assignments
#!/opt/local/bin/python
# mkdirfb.py
# make directories to be zipped for feedback files
# from offline grading worksheet
# of Assignment activity in Moodle
# Usage: cat offlinegradingworksheet.csv | python mkdirfb.py
# Saburo Higuchi
# Time-stamp "2017-08-02 Wed 16:47 JST hig"
import csv
import sys
import re
import os
reader = csv.reader(sys.stdin, delimiter=',',quotechar='"')
header=next(reader) # skip the header
# Assume:
# row[0] internal participant ID
# row[1] Fullname
for row in reader:
partid=int(re.match(r'^[^\d]*(\d.*)$',row[0]).group(1))
fullname=row[1]
dirname="%s_%s_assignsubmission_file_" % (fullname,partid)
print(dirname)
# note no error checking
os.mkdir(dirname)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment