def get_summary(self): counter = Counter() for answer in self.object.answers: counter.update(answer.data) total = sum(counter.values()) options = self.object.field_data['options'] return {'total': total, 'labels': [alpha_enum(val).upper() for val in xrange(len(options))], 'absolute': OrderedDict((opt['option'], counter[opt['id']]) for opt in options), 'relative': OrderedDict((opt['option'], counter[opt['id']] / total if total else 0) for opt in options)}
def get_summary(self): counter = Counter() for answer in self.object.answers: counter[answer.data] += 1 total = sum(counter.values()) options = self.object.field_data['options'] if counter[None]: no_option = {'id': None, 'option': _("No selection")} options.append(no_option) return {'total': total, 'labels': [alpha_enum(val).upper() for val in xrange(len(options))], 'absolute': OrderedDict((opt['option'], counter[opt['id']]) for opt in options), 'relative': OrderedDict((opt['option'], counter[opt['id']] / total) for opt in options)}