示例#1
0
    def get_path(self, group_delimiter='/'):
        '''
        Get the elements path within the survey.
        '''
        # TODO: Any other way of avoiding a circular import?
        from pyxform.survey import Survey

        path = self.name
        parent = self.get(constants.PARENT, Survey())
        while not isinstance(parent, Survey):
            path = parent.name + group_delimiter + path
            parent = parent.get(constants.PARENT, Survey())

        return path
示例#2
0
 def test_survey_can_have_to_xml_called_twice(self):
     """
     Test: Survey can have "to_xml" called multiple times
     
     (This was not being allowed before.)
     
     It would be good to know (with confidence) that a survey object
     can be exported to_xml twice, and the same thing will be returned
     both times.
     """
     survey = Survey(name=u"SampleSurvey")
     q = create_survey_element_from_dict({u'type':u'text', u'name':u'name'})
     survey.add_child(q)
     
     str1 = survey.to_xml()
     str2 = survey.to_xml()
     
     self.assertEqual(str1, str2)
示例#3
0
 def select_zone_state_lga(self):
     survey = Survey(name=u"need_xml_tag")
     survey.set(u"type", u"survey")
     questions = [self.select_zone()] + \
         self.select_state_questions() + \
         self.select_lga_questions()
     for question in questions:
         survey.add_child(question)
     pyobj = survey.to_dict()
     print_pyobj_to_json(pyobj, "zone_state_lga.json")