def test_get_answers_that_repeat_in_block(self): survey = load_schema_file("test_repeating_household.json") answers = [ answer for answer in SchemaHelper.get_answers_that_repeat_in_block( survey, 'household-composition') ] self.assertEqual(len(answers), 3)
def _remove_repeating_on_household_answers(answer_store, group_id): answer_store.remove(group_id=group_id, block_id='household-composition') questionnaire_store = get_questionnaire_store(current_user.user_id, current_user.user_ik) for answer in SchemaHelper.get_answers_that_repeat_in_block(g.schema_json, 'household-composition'): groups_to_delete = SchemaHelper.get_groups_that_repeat_with_answer_id(g.schema_json, answer['id']) for group in groups_to_delete: answer_store.remove(group_id=group['id']) questionnaire_store.completed_blocks[:] = [b for b in questionnaire_store.completed_blocks if b.group_id != group['id']]