Commit 2d23e008 authored by Michael Völske's avatar Michael Völske

exams: make salt for hashed filenames configurable

parent 33567e73
......@@ -117,7 +117,9 @@ class Student(object):
class Students(object):
def __init__(self, list_file, input_pdf_dir, output_pdf_dir, url_prefix):
def __init__(self, list_file,
input_pdf_dir, output_pdf_dir, url_prefix,
hash_salt='42024'):
self.list_file = list_file
self.input_pdf_dir = input_pdf_dir
self.output_pdf_dir = output_pdf_dir
......@@ -127,7 +129,7 @@ class Students(object):
with open(self.list_file, encoding='latin1') as f:
reader = csv.DictReader(f, dialect=dialect)
self.students = [
Student(row['STUDENT_NAME'], row['STUDENT_EMAIL'])
Student(row['STUDENT_NAME'], row['STUDENT_EMAIL'], hash_salt)
for row in reader
]
self.resources = {}
......@@ -187,8 +189,10 @@ class Students(object):
' Moodle Backup file.', show_default=True,
default='https://files.webis.de/teaching/'
'machine-learning-ws20/problem-sheets')
@click.option('--hash-salt', '-x', help='Salt for hashed file names.',
show_default=True, default='42024')
def insert_moodle(backup_file, student_list, input_pdf_dir, output_pdf_dir,
url_prefix):
url_prefix, hash_salt):
"""Update a Moodle backup file with individual students' exam variants.
\b
......@@ -214,7 +218,7 @@ def insert_moodle(backup_file, student_list, input_pdf_dir, output_pdf_dir,
students = Students(student_list,
input_pdf_dir, output_pdf_dir,
url_prefix)
url_prefix, hash_salt)
output_file = backup_file.replace('.mbz', '_MODIFIED.mbz')
with tarfile.open(backup_file) as tf, \
......@@ -234,4 +238,3 @@ def insert_moodle(backup_file, student_list, input_pdf_dir, output_pdf_dir,
f" students! left over: {students.students}"
logging.info(f'Output written to {output_file}')
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