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
|
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 = []
|
items = []
|
||||||
headers = []
|
headers = []
|
||||||
|
|
||||||
@ -46,9 +46,8 @@ def items_csv_to_dict(items_csv_reader, solver_run):
|
|||||||
valid_item = True
|
valid_item = True
|
||||||
item = Item.parse_obj(item)
|
item = Item.parse_obj(item)
|
||||||
for constraint in solver_run.constraints:
|
for constraint in solver_run.constraints:
|
||||||
attribute = item.get_attribute(constraint.reference_attribute)
|
if item.attribute_exists(constraint.reference_attribute) == False and constraint.minimum == 100:
|
||||||
if attribute and constraint.minimum == 100 and int(attribute.value) == 0:
|
valid_item = False
|
||||||
valid_item = False
|
|
||||||
|
|
||||||
if valid_item: items.append(item)
|
if valid_item: items.append(item)
|
||||||
|
|
||||||
|
@ -19,12 +19,12 @@ class Item(BaseModel):
|
|||||||
def irf(self, solver_run, theta):
|
def irf(self, solver_run, theta):
|
||||||
return ItemResponseFunction(solver_run.irt_model).calculate(b_param=self.b_param, theta=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:
|
for attribute in self.attributes:
|
||||||
if attribute.id == ref_attribute.id and attribute.value.lower(
|
if self.attribute_exists(ref_attribute):
|
||||||
) == ref_attribute.value.lower():
|
return attribute
|
||||||
return attribute.value
|
|
||||||
return False
|
return None
|
||||||
|
|
||||||
def attribute_exists(self, ref_attribute: Attribute) -> bool:
|
def attribute_exists(self, ref_attribute: Attribute) -> bool:
|
||||||
for attribute in self.attributes:
|
for attribute in self.attributes:
|
||||||
|
@ -53,7 +53,7 @@ class LoftService(Base):
|
|||||||
items_csv_reader = csv_helper.file_stream_reader(items_csv)
|
items_csv_reader = csv_helper.file_stream_reader(items_csv)
|
||||||
|
|
||||||
# add items to solver run
|
# 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...')
|
logging.info('Processed Attributes...')
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user