Exemplo n.º 1
0
def _get_xmodule_instance_args(request, task_id):
    """
    Calculate parameters needed for instantiating xmodule instances.

    The `request_info` will be passed to a tracking log function, to provide information
    about the source of the task request.   The `xqueue_callback_url_prefix` is used to
    permit old-style xqueue callbacks directly to the appropriate module in the LMS.
    The `task_id` is also passed to the tracking log function.
    """
    host_header = 'HTTP_HOST' if request is not None and 'HTTP_HOST' in request.META else 'SERVER_NAME'

    request_info = {
        'username': request.user.username,
        'user_id': request.user.id,
        'ip': request.META['REMOTE_ADDR'],
        'agent': request.META.get('HTTP_USER_AGENT', '').decode('latin1'),
        'host': request.META[host_header],
    }

    xmodule_instance_args = {
        'xqueue_callback_url_prefix': get_xqueue_callback_url_prefix(request),
        'request_info': request_info,
        'task_id': task_id,
    }
    return xmodule_instance_args
Exemplo n.º 2
0
def _get_xmodule_instance_args(request):
    """
    Calculate parameters needed for instantiating xmodule instances.

    The `request_info` will be passed to a tracking log function, to provide information
    about the source of the task request.   The `xqueue_callback_url_prefix` is used to
    permit old-style xqueue callbacks directly to the appropriate module in the LMS.
    """
    request_info = {'username': request.user.username,
                    'ip': request.META['REMOTE_ADDR'],
                    'agent': request.META.get('HTTP_USER_AGENT', ''),
                    'host': request.META['SERVER_NAME'],
                    }

    xmodule_instance_args = {'xqueue_callback_url_prefix': get_xqueue_callback_url_prefix(request),
                             'request_info': request_info,
                             }
    return xmodule_instance_args