Exemplo n.º 1
0
    def test_group_has_questions_returns_false_when_group_doesnt_have_questionnaire_blocks(
            self):
        group = {
            'blocks': [
                {
                    'id': 'summary-block',
                    'type': 'Summary'
                },
            ]
        }

        has_questions = SchemaHelper.group_has_questions(group)

        self.assertFalse(has_questions)
Exemplo n.º 2
0
    def test_group_has_questions_returns_true_when_group_has_questionnaire_blocks(
            self):
        group = {
            'blocks': [{
                'id': 'introduction',
                'type': 'Introduction'
            }, {
                'id': 'question',
                'type': 'Questionnaire'
            }]
        }

        has_questions = SchemaHelper.group_has_questions(group)

        self.assertTrue(has_questions)
Exemplo n.º 3
0
def build_summary_rendering_context(schema_json, answer_store, metadata):
    """
    Build questionnaire summary context containing metadata and content from the answers of the questionnaire
    :param schema_json: schema of the current questionnaire
    :param answer_store: all of the answers to the questionnaire
    :param metadata: all of the metadata
    :return: questionnaire summary context
    """
    navigator = PathFinder(schema_json, answer_store, metadata)
    path = navigator.get_routing_path()
    groups = []

    for group in schema_json['groups']:
        if SchemaHelper.group_has_questions(group) \
                and group['id'] in [location.group_id for location in path]:
            groups.extend(
                [Group(group, answer_store.map(), path, metadata, url_for)])

    return groups