basic funcionality improvements, as well as bundle refactor prep
This commit is contained in:
@ -1,6 +1,7 @@
|
||||
import csv
|
||||
import io
|
||||
import re
|
||||
from tokenize import String
|
||||
|
||||
def items_csv_to_dict(items_csv_reader, solver_run):
|
||||
items = []
|
||||
@ -14,10 +15,11 @@ def items_csv_to_dict(items_csv_reader, solver_run):
|
||||
item = { 'attributes': [] }
|
||||
|
||||
# ensure that the b param is formatted correctly
|
||||
if len(re.findall(".", row[len(headers) - 1])) >= 3:
|
||||
if row[len(headers) - 1] != '' and is_float(row[len(headers) - 1]):
|
||||
for key, col in enumerate(headers):
|
||||
if solver_run.irt_model.formatted_b_param() == col:
|
||||
item['b_param'] = row[key]
|
||||
value = float(row[key])
|
||||
item['b_param'] = value
|
||||
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]
|
||||
@ -81,10 +83,18 @@ def solution_items(variables, solver_run):
|
||||
form_items = []
|
||||
|
||||
for v in variables:
|
||||
if v.varValue is not None and v.varValue > 0:
|
||||
if v.varValue > 0 and 'Item_' in v.name:
|
||||
item_id = v.name.replace('Item_', '')
|
||||
item = solver_run.get_item(item_id)
|
||||
# add item to list and then remove from master item list
|
||||
form_items.append(item)
|
||||
|
||||
return form_items
|
||||
|
||||
# probably a better place for this...
|
||||
def is_float(element: String) -> bool:
|
||||
try:
|
||||
float(element)
|
||||
return True
|
||||
except ValueError:
|
||||
return False
|
||||
|
@ -4,7 +4,7 @@ import logging
|
||||
|
||||
from lib.errors.item_generation_error import ItemGenerationError
|
||||
|
||||
def build_constraints(solver_run, problem, items):
|
||||
def build_constraints(solver_run, problem, items, bundles):
|
||||
try:
|
||||
total_form_items = solver_run.total_form_items
|
||||
constraints = solver_run.constraints
|
||||
|
Reference in New Issue
Block a user