tcc and tif drift, compensated for string value casing, csv to dict improved process

This commit is contained in:
Josh Burman
2021-12-22 22:39:46 +00:00
parent 13f0f383e0
commit 107abcb73a
7 changed files with 61 additions and 47 deletions

View File

@ -2,7 +2,7 @@ import csv
import io
import re
def items_csv_to_dict(items_csv_reader):
def items_csv_to_dict(items_csv_reader, solver_run):
items = []
headers = []
@ -16,21 +16,17 @@ def items_csv_to_dict(items_csv_reader):
# ensure that the b param is formatted correctly
if len(re.findall(".", row[len(headers) - 1])) >= 3:
for key, col in enumerate(headers):
if key == 0:
item[col] = row[key]
if key == 2:
# make sure passage id exists
if row[key]:
item['passage_id'] = row[key]
# b param - tmep fix! use irt model b param for proper reference
elif key == len(headers) - 1:
if solver_run.irt_model.formatted_b_param() == col:
item['b_param'] = row[key]
elif key > 2 and key < len(headers) - 1:
item['attributes'].append({
'id': col,
'value': row[key],
'type': 'metadata'
})
elif solver_run.get_constraint(col) and solver_run.get_constraint(col).reference_attribute.type == 'bundle':
if row[key]:
item[solver_run.get_constraint(col).reference_attribute.id] = row[key]
elif solver_run.get_constraint(col):
constraint = solver_run.get_constraint(col)
item['attributes'].append(constraint.reference_attribute)
else:
if row[key]:
item[col] = row[key]
items.append(item)