from pydantic import BaseModel from typing import List from models.attribute import Attribute from lib.irt.item_response_function import ItemResponseFunction from lib.irt.item_information_function import ItemInformationFunction class Item(BaseModel): id: int attributes: List[Attribute] b_param: float = 0.00 def iif(self, solver_run, theta): return ItemInformationFunction(solver_run.irt_model).calculate(b_param=self.b_param,theta=theta) def irf(self, solver_run, theta): return ItemResponseFunction(solver_run.irt_model).calculate(b_param=self.b_param,theta=theta) def get_attribute(self, id, value): for attribute in self.attributes: if attribute.id == id and attribute.value == value: return attribute.value return False def attribute_exists(self, id, value): for attribute in self.attributes: if attribute.id == id and attribute.value == value: return True return False