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 test_get_group(self): survey = load_schema_file("test_repeating_household.json") group = SchemaHelper.get_group(survey, "repeating-group") self.assertEqual(group['title'], "Group 2")