def test_percentage_completed(self): completion_rate = BatchCompletionRates(self.batch) self.batch.completed_households.create(householdmember=self.member_1) self.assertEqual(50, completion_rate.percentage_completed( Household.all_households_in(self.investigator_1.location, self.open_survey))) self.batch.completed_households.create(householdmember=self.member_2) self.assertEqual(100, completion_rate.percentage_completed( Household.all_households_in(self.investigator_1.location, self.open_survey)))
def test_percentage_completed(self): completion_rate = BatchCompletionRates(self.batch) self.batch.completed_households.create(householdmember=self.member_1) self.assertEqual( 50, completion_rate.percentage_completed( Household.all_households_in(self.investigator_1.location, self.open_survey))) self.batch.completed_households.create(householdmember=self.member_2) self.assertEqual( 100, completion_rate.percentage_completed( Household.all_households_in(self.investigator_1.location, self.open_survey)))
def attributes(self): _completion_rates =[] for location in self.locations: attribute = {'location': location, 'total_households': Household.all_households_in(location, self.batch.survey, self.ea).count(), 'completed_households_percent': self.percent_completed_households(location, self.batch.survey, self.ea)} _completion_rates.append(attribute) return _completion_rates
def __init__(self, batch, location=None, ea=None, specific_households=None): self.batch = batch self.ea = ea self.location = location if specific_households: self.all_households = Household.objects.filter( pk__in=specific_households) else: self.all_households = Household.all_households_in( self.location, batch.survey, ea)
def __init__(self, batch, location, ea=None): self.batch = batch self.ea = ea self.location = location self.all_households = Household.all_households_in(self.location, batch.survey, ea)
def percent_completed_households(self, location, survey, ea=None): all_households = Household.all_households_in(location, survey, ea) return self.percentage_completed(all_households)