Пример #1
0
def _render_schema(current_location):
    metadata = get_metadata(current_user)
    answer_store = get_answer_store(current_user)
    block_json = SchemaHelper.get_block_for_location(g.schema_json, current_location)
    block_json = _evaluate_skip_conditions(block_json, current_location, answer_store, metadata)
    aliases = SchemaHelper.get_aliases(g.schema_json)
    block_context = build_schema_context(metadata, aliases, answer_store, current_location.group_instance)
    return renderer.render(block_json, **block_context)
Пример #2
0
def get_summary(eq_id, form_type, collection_id):  # pylint: disable=unused-argument
    answer_store = get_answer_store(current_user)

    path_finder = PathFinder(g.schema_json, answer_store, get_metadata(current_user))
    latest_location = path_finder.get_latest_location(get_completed_blocks(current_user))
    metadata = get_metadata(current_user)

    if latest_location.block_id is 'summary':
        aliases = SchemaHelper.get_aliases(g.schema_json)
        schema_context = build_schema_context(metadata, aliases, answer_store)
        rendered_schema_json = renderer.render(g.schema_json, **schema_context)
        summary_context = build_summary_rendering_context(rendered_schema_json, answer_store, metadata)
        return _build_template(current_location=latest_location, context=summary_context)

    return redirect(latest_location.url(metadata))
Пример #3
0
def _get_context(block, current_location, answer_store):

    error_messages = SchemaHelper.get_messages(g.schema_json)
    form, template_params = get_form_for_location(block, current_location,
                                                  answer_store, error_messages)
    content = {'form': form, 'block': block}
    if template_params:
        content.update(template_params)

    if block['type'] == 'Summary':
        metadata = get_metadata(current_user)
        aliases = SchemaHelper.get_aliases(g.schema_json)
        schema_context = build_schema_context(metadata, aliases, answer_store)
        rendered_schema_json = renderer.render(g.schema_json, **schema_context)
        content.update({
            'summary':
            build_summary_rendering_context(rendered_schema_json, answer_store,
                                            metadata)
        })

    return content