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)
def get_page_title_for_location(schema_json, current_location): block = SchemaHelper.get_block_for_location(schema_json, current_location) if block['type'] == 'Interstitial': group = SchemaHelper.get_group(schema_json, current_location.group_id) page_title = '{group_title} - {survey_title}'.format( group_title=group['title'], survey_title=schema_json['title']) elif block['type'] == 'Questionnaire': first_question = next(SchemaHelper.get_questions_for_block(block)) page_title = '{question_title} - {survey_title}'.format( question_title=first_question['title'], survey_title=schema_json['title']) else: page_title = schema_json['title'] return TemplateRenderer.safe_content(page_title)
def _get_front_end_navigation(answer_store, current_location, metadata, routing_path=None): completed_blocks = get_completed_blocks(current_user) navigation = Navigation(g.schema_json, answer_store, metadata, completed_blocks, routing_path) block_json = SchemaHelper.get_block_for_location(g.schema_json, current_location) if block_json is not None and block_json['type'] in ( 'Questionnaire', 'Interstitial', 'Confirmation', 'Summary'): return navigation.build_navigation(current_location.group_id, current_location.group_instance) else: return None