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_response_function import TestResponseFunction
|
||||
|
||||
from models.attribute import Attribute
|
||||
from models.item import Item
|
||||
from models.irt_model import IRTModel
|
||||
|
||||
|
||||
class Bundle(BaseModel):
|
||||
id: int
|
||||
count: int
|
||||
@ -23,6 +23,14 @@ class Bundle(BaseModel):
|
||||
def tif_trf_sum(self, 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):
|
||||
total = 0
|
||||
|
||||
|
@ -26,7 +26,7 @@ class Item(BaseModel):
|
||||
return attribute.value
|
||||
return False
|
||||
|
||||
def attribute_exists(self, ref_attribute):
|
||||
def attribute_exists(self, ref_attribute: Attribute) -> bool:
|
||||
for attribute in self.attributes:
|
||||
if attribute.id == ref_attribute.id and attribute.value.lower(
|
||||
) == ref_attribute.value.lower():
|
||||
|
Loading…
x
Reference in New Issue
Block a user