示例#1
0
    def test_multiple_choice_radio(self):
        question = QuestionFactory(survey=self.survey, title='test', type='table-radio')
        SubQuestionFactory(question=question, title='test')
        SubQuestionFactory(question=question, title='toast')

        for values in [{'test': 2, 'toast': 8}, {'test': 4, 'toast': 9}, {'test': 3, 'toast': 7}]:
            AnswerFactory.create(
                question=question,
                response=self.task_response1,
                options=values
            )

        for values in [{'test': 1, 'toast': 9}]:
            AnswerFactory.create(
                question=question,
                response=self.task_response2,
                options=values
            )

        self.survey.aggregate()

        aggregate = question.aggregateanswer_set.get(question=question,
                                                     aggregation_type='task',
                                                     task=self.task1)
        self.assertEqual(aggregate.options, {'test': 3.0, 'toast': 8.0})

        aggregate = question.aggregateanswer_set.get(question=question,
                                                     aggregation_type='task',
                                                     task=self.task2)
        self.assertEqual(aggregate.options, {'test': 1.0, 'toast': 9.0})

        aggregate = question.aggregateanswer_set.get(question=question,
                                                     aggregation_type='project_tasks',
                                                     project=self.project)
        self.assertEqual(aggregate.options, {'test': 2.0, 'toast': 8.5})
示例#2
0
    def test_multiple_choice_radio(self):
        question = QuestionFactory(survey=self.survey, title='test', type='table-radio')
        SubQuestionFactory(question=question, title='test')
        SubQuestionFactory(question=question, title='toast')

        for values in [{'test': 2, 'toast': 8}, {'test': 4, 'toast': 9}, {'test': 3, 'toast': 7}]:
            AnswerFactory.create(
                question=question,
                response=self.task_response1,
                options=values
            )

        for values in [{'test': 1, 'toast': 9}]:
            AnswerFactory.create(
                question=question,
                response=self.task_response2,
                options=values
            )

        self.survey.aggregate()

        aggregate = question.aggregateanswer_set.get(question=question,
                                                     aggregation_type='task',
                                                     task=self.task1)
        self.assertEqual(aggregate.options, {'test': 3.0, 'toast': 8.0})

        aggregate = question.aggregateanswer_set.get(question=question,
                                                     aggregation_type='task',
                                                     task=self.task2)
        self.assertEqual(aggregate.options, {'test': 1.0, 'toast': 9.0})

        aggregate = question.aggregateanswer_set.get(question=question,
                                                     aggregation_type='project_tasks',
                                                     project=self.project)
        self.assertEqual(aggregate.options, {'test': 2.0, 'toast': 8.5})
示例#3
0
    def test_combined_number(self):

        question = QuestionFactory(survey=self.survey, title='test', aggregation='sum', type='number')

        for value in ['110', '130']:
            AnswerFactory.create(
                question=question,
                response=self.intitiator_response,
                value=value,
            )

        for value in ['200']:
            AnswerFactory.create(
                question=question,
                response=self.organization_response,
                value=value,
            )

        for value in ['10', '20', '30']:
            AnswerFactory.create(
                question=question,
                response=self.task_response1,
                value=value,
            )

        for value in ['50']:
            AnswerFactory.create(
                question=question,
                response=self.task_response2,
                value=value,
            )

        for value in ['90']:
            AnswerFactory.create(
                question=question,
                response=self.task_response3,
                value=value,
            )

        self.survey.aggregate()

        aggregate1 = question.aggregateanswer_set.get(question=question,
                                                      aggregation_type='combined',
                                                      project=self.project)
        # Expected value is calculated
        # initiator:        (110 + 130) / 2
        # organization:     200
        # tasks:            (10 + 20 + 30) / 3 + 50 + 90
        # Mean:             (120 + 200 + 160)/ 3 = 160
        self.assertEqual(aggregate1.value, 160.0)
示例#4
0
    def test_combined_number(self):

        question = QuestionFactory(survey=self.survey, title='test', aggregation='sum', type='number')

        for value in ['110', '130']:
            AnswerFactory.create(
                question=question,
                response=self.intitiator_response,
                value=value,
            )

        for value in ['200']:
            AnswerFactory.create(
                question=question,
                response=self.organization_response,
                value=value,
            )

        for value in ['10', '20', '30']:
            AnswerFactory.create(
                question=question,
                response=self.task_response1,
                value=value,
            )

        for value in ['50']:
            AnswerFactory.create(
                question=question,
                response=self.task_response2,
                value=value,
            )

        for value in ['90']:
            AnswerFactory.create(
                question=question,
                response=self.task_response3,
                value=value,
            )

        self.survey.aggregate()

        aggregate1 = question.aggregateanswer_set.get(question=question,
                                                      aggregation_type='combined',
                                                      project=self.project)
        # Expected value is calculated
        # initiator:        (110 + 130) / 2
        # organization:     200
        # tasks:            (10 + 20 + 30) / 3 + 50 + 90
        # Mean:             (120 + 200 + 160)/ 3 = 160
        self.assertEqual(aggregate1.value, 160.0)
示例#5
0
    def test_multiple_choice_checkbox(self):
        question = QuestionFactory(survey=self.survey, title='test', type='checkbox')

        for values in [['test'], ['test', 'toast'], ['test'], ['toast', 'wokkel']]:
            AnswerFactory.create(
                question=question,
                response=self.response,
                options=values
            )

        self.survey.aggregate()
        aggregate = question.aggregateanswer_set.get(question=question,
                                                     aggregation_type='project',
                                                     project=self.project)
        self.assertEqual(aggregate.options, {"test": 3, "wokkel": 1, "toast": 2})
示例#6
0
    def test_multiple_choice_radio(self):
        question = QuestionFactory(survey=self.survey, title='test', type='radio')

        for value in ['test', 'toast', 'test']:
            AnswerFactory.create(
                question=question,
                response=self.response,
                options=[value]
            )

        self.survey.aggregate()
        aggregate = question.aggregateanswer_set.get(question=question,
                                                     aggregation_type='project',
                                                     project=self.project)
        self.assertEqual(aggregate.options, {'test': 2, 'toast': 1})
示例#7
0
    def test_average_non_number(self):
        question = QuestionFactory(survey=self.survey, title='test', aggregation='average', type='number')

        for value in ['20', '10', 'onzin test']:
            AnswerFactory.create(
                question=question,
                response=self.response,
                value=value,
            )

        self.survey.aggregate()
        aggregate = question.aggregateanswer_set.get(question=question,
                                                     aggregation_type='project',
                                                     project=self.project)
        self.assertEqual(aggregate.value, 10.0)
示例#8
0
    def test_multiple_choice_radio(self):
        question = QuestionFactory(survey=self.survey, title='test', type='radio')

        for value in ['test', 'toast', 'test']:
            AnswerFactory.create(
                question=question,
                response=self.response,
                options=[value]
            )

        self.survey.aggregate()
        aggregate = question.aggregateanswer_set.get(question=question,
                                                     aggregation_type='project',
                                                     project=self.project)
        self.assertEqual(aggregate.options, {'test': 2, 'toast': 1})
示例#9
0
    def test_multiple_choice_checkbox(self):
        question = QuestionFactory(survey=self.survey, title='test', type='checkbox')

        for values in [['test'], ['test', 'toast'], ['test'], ['toast', 'wokkel']]:
            AnswerFactory.create(
                question=question,
                response=self.response,
                options=values
            )

        self.survey.aggregate()
        aggregate = question.aggregateanswer_set.get(question=question,
                                                     aggregation_type='project',
                                                     project=self.project)
        self.assertEqual(aggregate.options, {"test": 3, "wokkel": 1, "toast": 2})
示例#10
0
    def test_average_non_number(self):
        question = QuestionFactory(survey=self.survey, title='test', aggregation='average', type='number')

        for value in ['20', '10', 'onzin test']:
            AnswerFactory.create(
                question=question,
                response=self.response,
                value=value,
            )

        self.survey.aggregate()
        aggregate = question.aggregateanswer_set.get(question=question,
                                                     aggregation_type='project',
                                                     project=self.project)
        self.assertEqual(aggregate.value, 10.0)
示例#11
0
    def test_slider(self):
        question = QuestionFactory(survey=self.survey, title='how', aggregation='average', type='slider')

        for value in [80, 70, 90]:
            AnswerFactory.create(
                question=question,
                response=self.response,
                value=value,
            )

        self.survey.aggregate()

        aggregate = question.aggregateanswer_set.get(question=question,
                                                     aggregation_type='project',
                                                     project=self.project)
        self.assertEqual(aggregate.value, 80.0)
示例#12
0
    def test_slider(self):
        question = QuestionFactory(survey=self.survey, title='how', aggregation='average', type='slider')

        for value in [80, 70, 90]:
            AnswerFactory.create(
                question=question,
                response=self.response,
                value=value,
            )

        self.survey.aggregate()

        aggregate = question.aggregateanswer_set.get(question=question,
                                                     aggregation_type='project',
                                                     project=self.project)
        self.assertEqual(aggregate.value, 80.0)
示例#13
0
    def test_project_aggregates(self):

        question1 = QuestionFactory(survey=self.survey, title='test', aggregation='sum', type='number')

        for value in ['110', '130']:
            AnswerFactory.create(
                question=question1,
                response=self.intitiator_response,
                value=value,
            )

        self.survey.aggregate()

        aggregate = question1.aggregateanswer_set.get(question=question1,
                                                      aggregation_type='project',
                                                      project=self.project)

        self.assertEqual(aggregate.value, 120.0)
示例#14
0
    def test_table_radio(self):
        question = QuestionFactory(survey=self.survey, title='test', type='table-radio')
        SubQuestionFactory(question=question, title='toast')
        SubQuestionFactory(question=question, title='test')

        for values in [{'test': 2, 'toast': 8}, {'test': 4, 'toast': 9}, {'test': 3, 'toast': 7}]:
            AnswerFactory.create(
                question=question,
                response=self.response,
                options=values
            )

        self.survey.aggregate()
        aggregate = question.aggregateanswer_set.get(question=question,
                                                     aggregation_type='project',
                                                     project=self.project)
        # Answers should follow the ordering of sub questions
        self.assertEqual(aggregate.options, {'toast': 8.0, 'test': 3.0})
示例#15
0
    def test_table_radio(self):
        question = QuestionFactory(survey=self.survey, title='test', type='table-radio')
        SubQuestionFactory(question=question, title='toast')
        SubQuestionFactory(question=question, title='test')

        for values in [{'test': 2, 'toast': 8}, {'test': 4, 'toast': 9}, {'test': 3, 'toast': 7}]:
            AnswerFactory.create(
                question=question,
                response=self.response,
                options=values
            )

        self.survey.aggregate()
        aggregate = question.aggregateanswer_set.get(question=question,
                                                     aggregation_type='project',
                                                     project=self.project)
        # Answers should follow the ordering of sub questions
        self.assertEqual(aggregate.options, {'toast': 8.0, 'test': 3.0})
示例#16
0
    def test_project_aggregates(self):

        question1 = QuestionFactory(survey=self.survey, title='test', aggregation='sum', type='number')

        for value in ['110', '130']:
            AnswerFactory.create(
                question=question1,
                response=self.intitiator_response,
                value=value,
            )

        self.survey.aggregate()

        aggregate = question1.aggregateanswer_set.get(question=question1,
                                                      aggregation_type='project',
                                                      project=self.project)

        self.assertEqual(aggregate.value, 120.0)
示例#17
0
    def test_ignore_sum(self):
        """
        Aggregation=sum only is only intended for tasks-by-project aggregations.
        For project aggregations it should still be mean.
        """
        question = QuestionFactory(survey=self.survey, title='test', aggregation='sum', type='number')

        for value in ['30', '10', '20.0']:
            AnswerFactory.create(
                question=question,
                response=self.response,
                value=value,
            )

        self.survey.aggregate()
        aggregate = question.aggregateanswer_set.get(question=question,
                                                     aggregation_type='project',
                                                     project=self.project)
        self.assertEqual(aggregate.value, 20.0)
示例#18
0
    def test_ignore_sum(self):
        """
        Aggregation=sum only is only intended for tasks-by-project aggregations.
        For project aggregations it should still be mean.
        """
        question = QuestionFactory(survey=self.survey, title='test', aggregation='sum', type='number')

        for value in ['30', '10', '20.0']:
            AnswerFactory.create(
                question=question,
                response=self.response,
                value=value,
            )

        self.survey.aggregate()
        aggregate = question.aggregateanswer_set.get(question=question,
                                                     aggregation_type='project',
                                                     project=self.project)
        self.assertEqual(aggregate.value, 20.0)
示例#19
0
    def test_sum(self):
        question = QuestionFactory(survey=self.survey, title='test', aggregation='sum', type='number')

        for value in ['10', '20', '30']:
            AnswerFactory.create(
                question=question,
                response=self.task_response1,
                value=value,
            )

        for value in ['50']:
            AnswerFactory.create(
                question=question,
                response=self.task_response2,
                value=value,
            )

        for value in ['90']:
            AnswerFactory.create(
                question=question,
                response=self.task_response3,
                value=value,
            )

        self.survey.aggregate()

        aggregate = question.aggregateanswer_set.get(question=question,
                                                     aggregation_type='project_tasks',
                                                     project=self.project)
        self.assertEqual(aggregate.value, 160.0)
示例#20
0
    def test_sum(self):
        question = QuestionFactory(survey=self.survey, title='test', aggregation='sum', type='number')

        for value in ['10', '20', '30']:
            AnswerFactory.create(
                question=question,
                response=self.task_response1,
                value=value,
            )

        for value in ['50']:
            AnswerFactory.create(
                question=question,
                response=self.task_response2,
                value=value,
            )

        for value in ['90']:
            AnswerFactory.create(
                question=question,
                response=self.task_response3,
                value=value,
            )

        self.survey.aggregate()

        aggregate = question.aggregateanswer_set.get(question=question,
                                                     aggregation_type='project_tasks',
                                                     project=self.project)
        self.assertEqual(aggregate.value, 160.0)
示例#21
0
    def setUp(self):
        super(ProjectSurveyAPITestCase, self).setUp()

        self.init_projects()

        phase = ProjectPhase.objects.get(slug='campaign')

        self.project = ProjectFactory.create(status=phase)
        self.survey = SurveyFactory(title='test survey')

        questions = (
            ('Question 1', 'string', None, {}),
            ('Question 2', 'number', 'average', {'max_number': 100, 'min_number': 100}),
            ('Question 3', 'slider', 'sum', {'max_number': 100, 'min_number': 100})
        )

        questions = [
            QuestionFactory.create(
                survey=self.survey,
                title=title,
                type=type,
                aggregation=aggregation,
                properties=properties
            ) for title, type, aggregation, properties in questions]

        response = ResponseFactory.create(
            project=self.project,
            survey=self.survey
        )

        for question in questions:
            AnswerFactory.create(
                question=question,
                response=response,
                value=random.randint(0, 100)
            )

        self.survey_url = reverse('project_survey_list')
示例#22
0
    def setUp(self):
        super(ProjectSurveyAPITestCase, self).setUp()

        self.init_projects()

        phase = ProjectPhase.objects.get(slug='campaign')

        self.project = ProjectFactory.create(status=phase)
        self.survey = SurveyFactory(title='test survey')

        questions = (('Question 1', 'string', None, {}),
                     ('Question 2', 'number', 'average', {
                         'max_number': 100,
                         'min_number': 100
                     }), ('Question 3', 'slider', 'sum', {
                         'max_number': 100,
                         'min_number': 100
                     }))

        questions = [
            QuestionFactory.create(survey=self.survey,
                                   title=title,
                                   type=type,
                                   aggregation=aggregation,
                                   properties=properties)
            for title, type, aggregation, properties in questions
        ]

        response = ResponseFactory.create(project=self.project,
                                          survey=self.survey)

        for question in questions:
            AnswerFactory.create(question=question,
                                 response=response,
                                 value=random.randint(0, 100))

        self.survey_url = reverse('project_survey_list')
示例#23
0
    def test_list(self):
        question = QuestionFactory(survey=self.survey, title='shoot', type='list')

        for value in ['Panda', 'Elephant', 'Rhino']:
            AnswerFactory.create(
                question=question,
                response=self.task_response1,
                value=value,
            )

        for value in ['Hedgehog']:
            AnswerFactory.create(
                question=question,
                response=self.task_response2,
                value=value,
            )

        for value in ['Bear', 'Lion']:
            AnswerFactory.create(
                question=question,
                response=self.task_response3,
                value=value,
            )

        self.survey.aggregate()

        aggregate = question.aggregateanswer_set.get(question=question,
                                                     aggregation_type='task',
                                                     task=self.task1,
                                                     project=self.project)
        self.assertListEqual(aggregate.list, ['Elephant', 'Panda', 'Rhino'])

        aggregate = question.aggregateanswer_set.get(question=question,
                                                     aggregation_type='project_tasks',
                                                     project=self.project)
        self.assertEqual(aggregate.list, ['Bear', 'Elephant', 'Hedgehog', 'Lion', 'Panda', 'Rhino'])
示例#24
0
    def test_list(self):
        question = QuestionFactory(survey=self.survey, title='shoot', type='list')

        for value in ['Panda', 'Elephant', 'Rhino']:
            AnswerFactory.create(
                question=question,
                response=self.task_response1,
                value=value,
            )

        for value in ['Hedgehog']:
            AnswerFactory.create(
                question=question,
                response=self.task_response2,
                value=value,
            )

        for value in ['Bear', 'Lion']:
            AnswerFactory.create(
                question=question,
                response=self.task_response3,
                value=value,
            )

        self.survey.aggregate()

        aggregate = question.aggregateanswer_set.get(question=question,
                                                     aggregation_type='task',
                                                     task=self.task1,
                                                     project=self.project)
        self.assertListEqual(aggregate.list, ['Elephant', 'Panda', 'Rhino'])

        aggregate = question.aggregateanswer_set.get(question=question,
                                                     aggregation_type='project_tasks',
                                                     project=self.project)
        self.assertEqual(aggregate.list, ['Bear', 'Elephant', 'Hedgehog', 'Lion', 'Panda', 'Rhino'])
示例#25
0
    def setUp(self):
        super(PlatformAggregateTest, self).setUp()
        now = timezone.now()
        last_year = now - datetime.timedelta(days=365)

        self.init_projects()

        survey = SurveyFactory.create()

        old_project = ProjectFactory.create(campaign_ended=last_year)
        new_project = ProjectFactory.create(campaign_ended=now)

        old_task1 = TaskFactory.create(project=old_project)
        old_task2 = TaskFactory.create(project=new_project)

        question1 = QuestionFactory.create(remote_id=1,
                                           type='number',
                                           survey=survey)
        question2 = QuestionFactory.create(remote_id=2,
                                           type='table-radio',
                                           survey=survey)
        SubQuestionFactory.create(question=question2, title='before')
        SubQuestionFactory.create(question=question2, title='after')
        question3 = QuestionFactory.create(remote_id=3,
                                           type='checkbox',
                                           survey=survey)
        question4 = QuestionFactory.create(remote_id=4,
                                           type='number',
                                           aggregation='average',
                                           survey=survey)

        for answer1, answer2, answer3, answer4 in ((4, {
                'before': 1,
                'after': 3
        }, {
                'test': 3,
                'tast': 4
        }, 62), (6, {
                'before': 3,
                'after': 5
        }, {
                'test': 4,
                'tast': 3
        }, 65), (8, {
                'before': 5,
                'after': 5
        }, {
                'test': 5,
                'tast': 5
        }, 55), (2, {
                'before': 7,
                'after': 3
        }, {
                'test': 6,
                'tast': 5
        }, 62)):
            response = ResponseFactory(project=old_project, survey=survey)
            AnswerFactory.create(question=question1,
                                 response=response,
                                 value=answer1)
            AnswerFactory.create(question=question2,
                                 response=response,
                                 options=answer2)
            AnswerFactory.create(question=question3,
                                 response=response,
                                 options=answer3)
            AnswerFactory.create(question=question4,
                                 response=response,
                                 value=answer4)

        for answer1, answer2, answer3, answer4 in (
            (2, {
                'before': 6,
                'after': 8
            }, {
                'test': 4,
                'tast': 5
            }, 60),
            (4, {
                'before': 2,
                'after': 4
            }, {
                'test': 4,
                'tast': 2
            }, 40),
        ):
            response = ResponseFactory(task=old_task1, survey=survey)
            AnswerFactory.create(question=question1,
                                 response=response,
                                 value=answer1)
            AnswerFactory.create(question=question2,
                                 response=response,
                                 options=answer2)
            AnswerFactory.create(question=question3,
                                 response=response,
                                 options=answer3)
            AnswerFactory.create(question=question4,
                                 response=response,
                                 value=answer4)

        for answer1, answer2, answer3, answer4 in (
            (11, {
                'before': 0,
                'after': 2
            }, {
                'test': 2,
                'tast': 3
            }, 12),
            (9, {
                'before': 2,
                'after': 4
            }, {
                'test': 4,
                'tast': 2
            }, 16),
        ):
            response = ResponseFactory(task=old_task2, survey=survey)
            AnswerFactory.create(question=question1,
                                 response=response,
                                 value=answer1)
            AnswerFactory.create(question=question2,
                                 response=response,
                                 options=answer2)
            AnswerFactory.create(question=question3,
                                 response=response,
                                 options=answer3)
            AnswerFactory.create(question=question4,
                                 response=response,
                                 value=answer4)

        for answer1, answer2, answer3, answer4 in ((3, {
                'before': 0,
                'after': 2
        }, {
                'test': 2,
                'tast': 3
        }, 23), (5, {
                'before': 2,
                'after': 4
        }, {
                'test': 4,
                'tast': 2
        }, 12), (7, {
                'before': 5,
                'after': 4
        }, {
                'test': 4,
                'tast': 5
        }, 14), (1, {
                'before': 6,
                'after': 2
        }, {
                'test': 5,
                'tast': 4
        }, 500)):
            response = ResponseFactory(project=new_project, survey=survey)
            AnswerFactory.create(question=question1,
                                 response=response,
                                 value=answer1)
            AnswerFactory.create(question=question2,
                                 response=response,
                                 options=answer2)
            AnswerFactory.create(question=question3,
                                 response=response,
                                 options=answer3)
            AnswerFactory.create(question=question4,
                                 response=response,
                                 value=answer4)

        survey.aggregate()
示例#26
0
    def test_combined_table_radio(self):

        question = QuestionFactory(survey=self.survey, title='test', type='table-radio')
        SubQuestionFactory(question=question, title='test')
        SubQuestionFactory(question=question, title='toast')

        for values in [{'test': 4, 'toast': 6}]:
            AnswerFactory.create(
                question=question,
                response=self.intitiator_response,
                options=values
            )

        for values in [{'test': 5, 'toast': 9}, {'test': 7, 'toast': 10}]:
            AnswerFactory.create(
                question=question,
                response=self.organization_response,
                options=values
            )

        for values in [{'test': 2, 'toast': 8}, {'test': 4, 'toast': 9}, {'test': 3, 'toast': 7}]:
            AnswerFactory.create(
                question=question,
                response=self.task_response1,
                options=values
            )

        for values in [{'test': 1, 'toast': 9}]:
            AnswerFactory.create(
                question=question,
                response=self.task_response2,
                options=values
            )

        self.survey.aggregate()

        aggregate = question.aggregateanswer_set.get(question=question,
                                                     aggregation_type='task',
                                                     task=self.task1)
        self.assertEqual(aggregate.options, {'test': 3.0, 'toast': 8.0})

        aggregate = question.aggregateanswer_set.get(question=question,
                                                     aggregation_type='project_tasks',
                                                     project=self.project)
        self.assertEqual(aggregate.options, {'test': 2.0, 'toast': 8.5})

        aggregate = question.aggregateanswer_set.get(question=question,
                                                     aggregation_type='project',
                                                     project=self.project)
        self.assertEqual(aggregate.options, {'test': 5.333333333333333, 'toast': 8.333333333333334})

        aggregate = question.aggregateanswer_set.get(question=question,
                                                     aggregation_type='organization',
                                                     project=self.project)
        self.assertEqual(aggregate.options, {'test': 6.0, 'toast': 9.5})

        aggregate = question.aggregateanswer_set.get(question=question,
                                                     aggregation_type='initiator',
                                                     project=self.project)
        self.assertEqual(aggregate.options, {'test': 4.0, 'toast': 6.0})

        aggregate = question.aggregateanswer_set.get(question=question,
                                                     aggregation_type='combined',
                                                     project=self.project)
        # Calculation of combined
        # Initiator mean:    {'test': 4.0, 'toast': 6.0}
        # Organization mean: {'test': 6.0, 'toast': 9.5}
        # Tasks mean:        {'test': 2.0, 'toast': 8.5}
        # Combined:          {'test': 4.0, 'toast': 8.0}
        self.assertEqual(aggregate.options, {'test': 4.0, 'toast': 8.0})
示例#27
0
    def test_combined_table_radio(self):

        question = QuestionFactory(survey=self.survey, title='test', type='table-radio')
        SubQuestionFactory(question=question, title='test')
        SubQuestionFactory(question=question, title='toast')

        for values in [{'test': 4, 'toast': 6}]:
            AnswerFactory.create(
                question=question,
                response=self.intitiator_response,
                options=values
            )

        for values in [{'test': 5, 'toast': 9}, {'test': 7, 'toast': 10}]:
            AnswerFactory.create(
                question=question,
                response=self.organization_response,
                options=values
            )

        for values in [{'test': 2, 'toast': 8}, {'test': 4, 'toast': 9}, {'test': 3, 'toast': 7}]:
            AnswerFactory.create(
                question=question,
                response=self.task_response1,
                options=values
            )

        for values in [{'test': 1, 'toast': 9}]:
            AnswerFactory.create(
                question=question,
                response=self.task_response2,
                options=values
            )

        self.survey.aggregate()

        aggregate = question.aggregateanswer_set.get(question=question,
                                                     aggregation_type='task',
                                                     task=self.task1)
        self.assertEqual(aggregate.options, {'test': 3.0, 'toast': 8.0})

        aggregate = question.aggregateanswer_set.get(question=question,
                                                     aggregation_type='project_tasks',
                                                     project=self.project)
        self.assertEqual(aggregate.options, {'test': 2.0, 'toast': 8.5})

        aggregate = question.aggregateanswer_set.get(question=question,
                                                     aggregation_type='project',
                                                     project=self.project)
        self.assertEqual(aggregate.options, {'test': 5.333333333333333, 'toast': 8.333333333333334})

        aggregate = question.aggregateanswer_set.get(question=question,
                                                     aggregation_type='organization',
                                                     project=self.project)
        self.assertEqual(aggregate.options, {'test': 6.0, 'toast': 9.5})

        aggregate = question.aggregateanswer_set.get(question=question,
                                                     aggregation_type='initiator',
                                                     project=self.project)
        self.assertEqual(aggregate.options, {'test': 4.0, 'toast': 6.0})

        aggregate = question.aggregateanswer_set.get(question=question,
                                                     aggregation_type='combined',
                                                     project=self.project)
        # Calculation of combined
        # Initiator mean:    {'test': 4.0, 'toast': 6.0}
        # Organization mean: {'test': 6.0, 'toast': 9.5}
        # Tasks mean:        {'test': 2.0, 'toast': 8.5}
        # Combined:          {'test': 4.0, 'toast': 8.0}
        self.assertEqual(aggregate.options, {'test': 4.0, 'toast': 8.0})