(session, domain, contact, app, form, case_id=None, yield_responses=False)
Starts a session in touchforms and saves the record in the database.
    
    Returns a tuple containing the session object and the (text-only) 
    list of generated questions/responses based on the form.
    
    Special params:
    yield_responses - If True, the list of xforms responses is returned, otherwise the text prompt for each is returned
Starts a session in touchforms and saves the record in the database.
    
    Returns a tuple containing the session object and the (text-only) 
    list of generated questions/responses based on the form.
    
    Special params:
    yield_responses - If True, the list of xforms responses is returned, otherwise the text prompt for each is returned
Starts a session in touchforms and saves the record in the database . Returns a tuple containing the session object and the ( text - only ) list of generated questions / responses based on the form . Special params : yield_responses - If True the list of xforms responses is returned otherwise the text prompt for each is returned
def start_session(session, domain, contact, app, form, case_id=None, yield_responses=False):
    """
    Starts a session in touchforms and saves the record in the database.
    
    Returns a tuple containing the session object and the (text-only) 
    list of generated questions/responses based on the form.
    
    Special params:
    yield_responses - If True, the list of xforms responses is returned, otherwise the text prompt for each is returned
    """
    # NOTE: this call assumes that "contact" will expose three
    # properties: .raw_username, .get_id, and .get_language_code
    session_data = CaseSessionDataHelper(domain, contact, case_id, app, form).get_session_data(
        COMMCONNECT_DEVICE_ID)

    kwargs = {}
    if is_commcarecase(contact):
        kwargs['restore_as_case_id'] = contact.case_id
    else:
        kwargs['restore_as'] = contact.raw_username

    if app and form:
        session_data.update(get_cloudcare_session_data(domain, form, contact))

    language = contact.get_language_code()
    config = XFormsConfig(form_content=form.render_xform().decode('utf-8'),
                          language=language,
                          session_data=session_data,
                          domain=domain,
                          **kwargs)

    session_start_info = tfsms.start_session(config)
    session.session_id = session_start_info.session_id
    session.save()
    responses = session_start_info.first_responses

    if len(responses) > 0 and responses[0].status == 'http-error':
        session.mark_completed(False)
        session.save()
        raise TouchformsError('Cannot connect to touchforms.')

    # Prevent future update conflicts by getting the session again from the db
    # since the session could have been updated separately in the first_responses call
    session = SQLXFormsSession.objects.get(pk=session.pk)
    if yield_responses:
        return (session, responses)
    else:
        return (session, _responses_to_text(responses))
def start_session ( session , domain , contact , app , form , case_id = None , yield_responses = False ) : # NOTE: this call assumes that "contact" will expose three # properties: .raw_username, .get_id, and .get_language_code session_data = CaseSessionDataHelper ( domain , contact , case_id , app , form ) . get_session_data ( COMMCONNECT_DEVICE_ID ) kwargs = { } if is_commcarecase ( contact ) : kwargs [ 'restore_as_case_id' ] = contact . case_id else : kwargs [ 'restore_as' ] = contact . raw_username if app and form : session_data . update ( get_cloudcare_session_data ( domain , form , contact ) ) language = contact . get_language_code ( ) config = XFormsConfig ( form_content = form . render_xform ( ) . decode ( 'utf-8' ) , language = language , session_data = session_data , domain = domain , * * kwargs ) session_start_info = tfsms . start_session ( config ) session . session_id = session_start_info . session_id session . save ( ) responses = session_start_info . first_responses if len ( responses ) > 0 and responses [ 0 ] . status == 'http-error' : session . mark_completed ( False ) session . save ( ) raise TouchformsError ( 'Cannot connect to touchforms.' ) # Prevent future update conflicts by getting the session again from the db # since the session could have been updated separately in the first_responses call session = SQLXFormsSession . objects . get ( pk = session . pk ) if yield_responses : return ( session , responses ) else : return ( session , _responses_to_text ( responses ) )