Commit 2909296e authored by Michael Völske's avatar Michael Völske

update exams.py

parent 7b588f99
......@@ -27,10 +27,15 @@ def exams():
@click.argument('pool_yaml')
@click.argument('output_file')
@click.option('--student-list-file', '-f', help='Tab-separated file. '
'defining students for which variants should be sampled. Must have a header. '
'Header names define variable names, rows define their values. '
'ATTENTION: use latin-1 encoding!', required=True)
def generate_variants(pool_yaml, output_file, student_list_file):
'defining students for which variants should be sampled.'
'Must have a header. Header names define variable names, '
'rows define their values. ATTENTION: use latin-1 encoding!',
required=True)
@click.option('--column', '-c',
help='Columns to copy from the student-list-file.',
multiple=True, default=['STUDENT_NAME', 'STUDENT_EMAIL'],
show_default=True)
def generate_variants(pool_yaml, output_file, student_list_file, column):
""" Generate a variant-list-file, where each student in the
student-list-file gets a unique sample of problems, one from each pool
defined in the pool_yaml
......@@ -59,12 +64,11 @@ def generate_variants(pool_yaml, output_file, student_list_file):
newline='', encoding='latin1') as of:
writer = csv.writer(of, delimiter='\t', dialect=dialect)
variable_string = list(pools.keys())
writer.writerow(['STUDENT_NAME', 'STUDENT_EMAIL'] + variable_string)
writer.writerow(column + variable_string)
for env in tqdm(items, desc='generating variants'):
variant_string = [f'{choice(variants)}'
for variants in pools.values()]
writer.writerow([env['STUDENT_NAME'],
env['STUDENT_EMAIL']] + variant_string)
writer.writerow([env[c] for c in column] + variant_string)
########################################################################
......
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