Beispiel #1
0
def submit_answer():

    rjson = request.get_json()
    session_name = rjson["session_name"]
    path_option = rjson.get("path_option", None)
    selector_choices = rjson.get("selector_choices", [])

    session = SESSIONS.get(session_name)
    resp = {
        "session_name": session_name,
        "path_option": path_option,
        "selectors": selector_choices,
        "current_step": None,
        "redirect_url": None
    }

    if path_option:
        path = None
        for op in session.questions:
            if op.id == path_option:
                path = op
                break

        if len(selector_choices) == len(path.selectors):
            resp["current_step"] = {"title": ""}
            resp["redirect_url"] = path.redirect % (
                selector_choices[0], selector_choices[1])
        else:
            resp["current_step"] = path.selectors[len(selector_choices)]

    return jsonify(resp)
Beispiel #2
0
def session(session_name):

    session_obj = SESSIONS.get(session_name, False)
    return jsonify({
        "session_name": session_name,
        "title": session_obj.title,
        "options": map(lambda x: x.serialize, session_obj.options)
    })
Beispiel #3
0
def session(session_name):
    session_obj = SESSIONS.get(session_name, False)

    return jsonify({
        "session_name": session_name,
        "session_title": session_obj.session_title,
        "title": session_obj.title,
        "questions": map(lambda x: x.serialize, session_obj.questions),
    })