get the items with a specific attribute from the bundle
This commit is contained in:
parent
a61c7a82b9
commit
aaa672c14c
@ -4,10 +4,10 @@ from typing import List
|
|||||||
from lib.irt.test_information_function import TestInformationFunction
|
from lib.irt.test_information_function import TestInformationFunction
|
||||||
from lib.irt.test_response_function import TestResponseFunction
|
from lib.irt.test_response_function import TestResponseFunction
|
||||||
|
|
||||||
|
from models.attribute import Attribute
|
||||||
from models.item import Item
|
from models.item import Item
|
||||||
from models.irt_model import IRTModel
|
from models.irt_model import IRTModel
|
||||||
|
|
||||||
|
|
||||||
class Bundle(BaseModel):
|
class Bundle(BaseModel):
|
||||||
id: int
|
id: int
|
||||||
count: int
|
count: int
|
||||||
@ -23,6 +23,14 @@ class Bundle(BaseModel):
|
|||||||
def tif_trf_sum(self, solver_run):
|
def tif_trf_sum(self, solver_run):
|
||||||
return self.__trf_sum(solver_run) + self.__tif_sum(solver_run)
|
return self.__trf_sum(solver_run) + self.__tif_sum(solver_run)
|
||||||
|
|
||||||
|
def items_with_attribute(self, attribute: Attribute) -> List[Item]:
|
||||||
|
items = []
|
||||||
|
|
||||||
|
for item in self.items:
|
||||||
|
if item.attribute_exists(attribute): items.append(item)
|
||||||
|
|
||||||
|
return items
|
||||||
|
|
||||||
def __tif_sum(self, solver_run):
|
def __tif_sum(self, solver_run):
|
||||||
total = 0
|
total = 0
|
||||||
|
|
||||||
|
@ -26,7 +26,7 @@ class Item(BaseModel):
|
|||||||
return attribute.value
|
return attribute.value
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def attribute_exists(self, ref_attribute):
|
def attribute_exists(self, ref_attribute: Attribute) -> bool:
|
||||||
for attribute in self.attributes:
|
for attribute in self.attributes:
|
||||||
if attribute.id == ref_attribute.id and attribute.value.lower(
|
if attribute.id == ref_attribute.id and attribute.value.lower(
|
||||||
) == ref_attribute.value.lower():
|
) == ref_attribute.value.lower():
|
||||||
|
Loading…
x
Reference in New Issue
Block a user