better csv created with additions of tccs, tifs, rounding, and reordering

This commit is contained in:
Josh Burman
2021-11-19 07:11:35 +00:00
parent d02137112a
commit 63e5016307

View File

@ -33,14 +33,29 @@ def solution_to_file(buffer, total_form_items, forms):
wr = csv.writer(buffer, dialect='excel', delimiter=',') wr = csv.writer(buffer, dialect='excel', delimiter=',')
# write header row for first row utilizing the total items all forms will have # write header row for first row utilizing the total items all forms will have
# and the cut score as the last item # fill the rows with the targets and cut score then the items
header = [x + 1 for x in range(total_form_items)] + ['cut score'] header = []
for result in forms[0].tif_results:
header += [f'tif @ {round(result.theta, 2)}']
for result in forms[0].tcc_results:
header += [f'tcc @ {round(result.theta, 2)}']
header += ['cut score'] + [x + 1 for x in range(total_form_items)]
wr.writerow(header) wr.writerow(header)
# add each form as row to processed csv # add each form as row to processed csv
for form in forms: for form in forms:
row = []
for result in form.tif_results:
row += [f'value - {result.value}\nresult - {round(result.result, 2)}']
for result in form.tcc_results:
row += [f'value - {result.value}\nresult - {round(result.result, 2)}']
# provide generated items and cut score # provide generated items and cut score
row = [item.id for item in form.items] + [form.cut_score] row += [round(form.cut_score, 2)] + [item.id for item in form.items]
wr.writerow(row) wr.writerow(row)
buff2 = io.BytesIO(buffer.getvalue().encode()) buff2 = io.BytesIO(buffer.getvalue().encode())