Exemplo n.º 1
0
def run_xblock_handler(*args, **kwargs):
    """
    Import and run `handle_xblock_callback` from LMS
    """
    # pylint: disable=import-error,import-outside-toplevel
    from lms.djangoapps.courseware.module_render import handle_xblock_callback
    return handle_xblock_callback(*args, **kwargs)
Exemplo n.º 2
0
def launch_gate_endpoint(request, suffix):
    """
    Gate endpoint that triggers LTI launch endpoint XBlock handler

    This is basically a passthrough function that uses the
    OIDC response parameter `login_hint` to locate the block
    and run the proper handler.
    """
    try:
        usage_key = UsageKey.from_string(request.GET.get('login_hint'))

        return handle_xblock_callback(request=request,
                                      course_id=str(usage_key.course_key),
                                      usage_id=str(usage_key),
                                      handler='lti_1p3_launch_callback',
                                      suffix=suffix)
    except:  # pylint: disable=bare-except
        return HttpResponse(status=404)
Exemplo n.º 3
0
 def test_entrance_exam_xblock_response(self):
     """
     Tests entrance exam xblock has `entrance_exam_passed` key in json response.
     """
     request_factory = RequestFactoryNoCsrf()
     data = {
         f'input_{str(self.problem_1.location.html_id())}_2_1': 'choice_2'
     }
     request = request_factory.post('problem_check', data=data)
     request.user = self.user
     response = handle_xblock_callback(
         request,
         str(self.course.id),
         str(self.problem_1.location),
         'xmodule_handler',
         'problem_check',
     )
     assert response.status_code == 200
     self.assertContains(response, 'entrance_exam_passed')