-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
quick overview of assignments without collecting #36
Comments
you can do that manually through the student's work dir |
If you can direct the output of the conversion outside of the student's
working directory, then probably that is the simplest solution
…On Mon, Oct 15, 2018 at 6:54 PM László Oroszlány ***@***.***> wrote:
you can do that manually through the student's work dir
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#36 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ABCtxes4LU0bCMG9Hd4_s-39sKFtUQKnks5ulL3AgaJpZM4Xcqkj>
.
|
This script will do the trick until there's a better solution: eg: import argparse
import os
import glob
import shutil
import pathlib
import subprocess
import pandas as pd
def gatherassignments(course,assignment, destination):
stcounter = 0
nbcounter = 0
for st in os.listdir(course):
snb = False
try:
name = studentmap[st]
except KeyError as e:
# students will not be in the list if they stopped attending the course at some point
continue
for nb in glob.glob(os.path.join(course,st,assignment,"*.ipynb")):
snb = True
nbcounter += 1
shutil.copy(nb,os.path.join(destination,name + "_" + os.path.basename(nb)))
if snb:
stcounter += 1
print("Found {} notebooks from {} students.".format(nbcounter,stcounter))
def convert_notebooks(folder):
for nb in glob.glob(os.path.join(folder,"*.ipynb")):
subprocess.run(["jupyter", "nbconvert", "--execute", "--to", "html",nb],timeout = 60)
if __name__ == '__main__':
parser = argparse.ArgumentParser()
parser.add_argument('course',type=str)
parser.add_argument('assignment',type=str)
parser.add_argument('-c','--convert', action='store_true')
parser.add_argument('-s','--students', type=str,default="hallgatok1.xlsx")
args = parser.parse_args()
studentmap = {line[1].lower() : "_".join(line[0].split()) for line in pd.read_excel(args.students).values}
destination = os.path.join("assignments",args.assignment)
pathlib.Path(destination).mkdir(parents=True, exist_ok=True)
gatherassignments(args.course,args.assignment,destination)
if args.convert:
convert_notebooks(destination) |
This was my solution: WORKDIR=$1
PACKAGE=$2
for diak in `ls $WORKDIR`; do
if [ ! -d $diak/$PACKAGE/ ]; then
mkdir -p $diak/$PACKAGE/
fi
cp $WORKDIR/$diak/$PACKAGE/MEGOLDASOK/*.ipynb $diak/$PACKAGE/
jupyter-nbconvert --to html $diak/$PACKAGE/*.ipynb --output-dir $diak/$PACKAGE
done of course this requires a predefined structure |
I don't touch bash if I don't have to, and I wanted to prepend their names, but definitely shorter :) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Feature request (kooplex-edu):
I would need a quick overview of assignments in one folder, without having to collect and then reassign (reassignment removes them again). Preferably, if only one
.ipynb
is present in the students assignment folder, copy that to a single folder, with the students name prepended and also convert it to html for quick preview (jupyter nbconvert --execute --to html notebook.ipynb
.)The text was updated successfully, but these errors were encountered: