Esempio n. 1
0
    def test_get_groups_that_repeat_with_answer_id(self):
        survey = load_schema_file("test_repeating_household.json")
        groups = [
            group
            for group in SchemaHelper.get_groups_that_repeat_with_answer_id(
                survey, 'first-name')
        ]

        self.assertEqual(len(groups), 1)
Esempio n. 2
0
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']]