updated bundles process
This commit is contained in:
@ -1,4 +1,5 @@
|
|||||||
from lib.irt.models.three_parameter_logistic import ThreeParameterLogistic
|
from lib.irt.models.three_parameter_logistic import ThreeParameterLogistic
|
||||||
|
from lib.errors.item_generation_error import ItemGenerationError
|
||||||
|
|
||||||
class ItemResponseFunction():
|
class ItemResponseFunction():
|
||||||
def __init__(self, irt_model):
|
def __init__(self, irt_model):
|
||||||
@ -8,5 +9,4 @@ class ItemResponseFunction():
|
|||||||
if self.model_data.model == '3PL':
|
if self.model_data.model == '3PL':
|
||||||
return ThreeParameterLogistic(self.model_data, kwargs).result()
|
return ThreeParameterLogistic(self.model_data, kwargs).result()
|
||||||
else:
|
else:
|
||||||
# potentially error out
|
raise ItemGenerationError("irt model not supported or provided")
|
||||||
return None
|
|
||||||
|
@ -32,12 +32,20 @@ class SolverRun(BaseModel):
|
|||||||
bundles = []
|
bundles = []
|
||||||
|
|
||||||
for item in self.items:
|
for item in self.items:
|
||||||
attribute_id = getattr(item, type_attribute)()
|
# dynamically get the attribute that will be used as an identifier to bundle like items
|
||||||
bundle_index = next((index for (index, bundle) in enumerate(bundles) if bundle['id'] == attribute_id), None)
|
attribute_id = getattr(item, type_attribute, None)()
|
||||||
|
|
||||||
if bundle_index == None:
|
# make sure the item has said attribute
|
||||||
bundles.append({ 'id': item.passage, 'count': 1, 'type': type_attribute })
|
if attribute_id != None:
|
||||||
else:
|
# get index of the bundle in the bundles list
|
||||||
bundles[bundle_index]['count'] += 1
|
bundle_index = next((index for (index, bundle) in enumerate(bundles) if bundle['id'] == attribute_id), None)
|
||||||
|
|
||||||
|
# if the bundle index isn't found then the bundle hasn't been created
|
||||||
|
# and added to the list and needs to be, else increment the count of items
|
||||||
|
# in the bundle
|
||||||
|
if bundle_index == None:
|
||||||
|
bundles.append({ 'id': attribute_id, 'count': 1, 'type': type_attribute })
|
||||||
|
else:
|
||||||
|
bundles[bundle_index]['count'] += 1
|
||||||
|
|
||||||
return bundles
|
return bundles
|
||||||
|
Reference in New Issue
Block a user