def _create_survey(self, type_constraint_name,
                       allow_multiple=False,
                       choices=None):
        tcn = type_constraint_name
        survey_json = {'email': 'test_email',
                       'survey_title': 'test_question_type_' + tcn,
                       'survey_metadata': {},
                       'questions': [{'question_title': tcn,
                                      'type_constraint_name': tcn,
                                      'allow_multiple': allow_multiple,
                                      'question_to_sequence_number': -1,
                                      'logic': {
                                          'required': False,
                                          'allow_other': False,
                                          'allow_dont_know': False
                                      },
                                      'hint': None,
                                      'choices': choices,
                                      'branches': None}]}

        survey = survey_api.create(connection, survey_json)['result']
        survey_id = survey['survey_id']
        question_id = survey['questions'][0]['question_id']
        return survey_id, question_id
Beispiel #2
0
 def post(self):
     data = get_json_request_body(self)
     self.write(survey_api.create(self.db, data))
     self.set_status(201)