示例#1
0
def get_questions(domain, app_id, xmlns):
    if not app_id:
        raise QuestionListNotFound(
            _("This form is not associated with an app")
        )
    try:
        app = get_app(domain, app_id)
    except Http404:
        raise QuestionListNotFound(
            _("No app could be found")
        )
    if not isinstance(app, Application):
        raise QuestionListNotFound(
            _("Remote apps are not supported")
        )

    xform = app.get_xform_by_xmlns(xmlns)
    if not xform:
        if xmlns == 'http://code.javarosa.org/devicereport':
            raise QuestionListNotFound(
                _("This is a Device Report")
            )
        else:
            raise QuestionListNotFound(
                _("We could not find the question list "
                  "associated with this form")
            )
    # Search for 'READABLE FORMS TEST' for more info
    # to bootstrap a test and have it print out your form xml
    # uncomment this line. Ghetto but it works.
    # print form.wrapped_xform().render()
    return get_questions_from_xform_node(xform, app.langs)
示例#2
0
def get_questions(domain, app_id, xmlns):
    if not app_id:
        raise QuestionListNotFound(
            _("This form is not associated with an app"))
    try:
        app = get_app(domain, app_id)
    except Http404:
        raise QuestionListNotFound(_("No app could be found"))
    if not isinstance(app, Application):
        raise QuestionListNotFound(_("Remote apps are not supported"))

    form = app.get_form_by_xmlns(xmlns)
    questions = form.wrapped_xform().get_questions(app.langs,
                                                   include_triggers=True,
                                                   include_groups=True)
    return [FormQuestionResponse(q) for q in questions]