prefiltering of items
This commit is contained in:
parent
09d3fce02d
commit
ad3019e478
@ -5,7 +5,7 @@ from tokenize import String
|
||||
|
||||
from models.item import Item
|
||||
|
||||
def items_csv_to_dict(items_csv_reader, solver_run):
|
||||
def csv_to_item(items_csv_reader, solver_run):
|
||||
items = []
|
||||
headers = []
|
||||
|
||||
@ -46,8 +46,7 @@ def items_csv_to_dict(items_csv_reader, solver_run):
|
||||
valid_item = True
|
||||
item = Item.parse_obj(item)
|
||||
for constraint in solver_run.constraints:
|
||||
attribute = item.get_attribute(constraint.reference_attribute)
|
||||
if attribute and constraint.minimum == 100 and int(attribute.value) == 0:
|
||||
if item.attribute_exists(constraint.reference_attribute) == False and constraint.minimum == 100:
|
||||
valid_item = False
|
||||
|
||||
if valid_item: items.append(item)
|
||||
|
@ -19,12 +19,12 @@ class Item(BaseModel):
|
||||
def irf(self, solver_run, theta):
|
||||
return ItemResponseFunction(solver_run.irt_model).calculate(b_param=self.b_param, theta=theta)
|
||||
|
||||
def get_attribute(self, ref_attribute):
|
||||
def get_attribute(self, ref_attribute: Attribute) -> Attribute or None:
|
||||
for attribute in self.attributes:
|
||||
if attribute.id == ref_attribute.id and attribute.value.lower(
|
||||
) == ref_attribute.value.lower():
|
||||
return attribute.value
|
||||
return False
|
||||
if self.attribute_exists(ref_attribute):
|
||||
return attribute
|
||||
|
||||
return None
|
||||
|
||||
def attribute_exists(self, ref_attribute: Attribute) -> bool:
|
||||
for attribute in self.attributes:
|
||||
|
@ -53,7 +53,7 @@ class LoftService(Base):
|
||||
items_csv_reader = csv_helper.file_stream_reader(items_csv)
|
||||
|
||||
# add items to solver run
|
||||
solver_run.items = service_helper.items_csv_to_dict(items_csv_reader, solver_run)
|
||||
solver_run.items = service_helper.csv_to_item(items_csv_reader, solver_run)
|
||||
|
||||
logging.info('Processed Attributes...')
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user