示例#1
0
def tool_config(request):
    url = "https://{}{}".format(request.get_host(), reverse('lti_launch'))
    url = _url(url)

    title = 'Admin Console'
    lti_tool_config = ToolConfig(
        title=title,
        launch_url=url,
        secure_launch_url=url,
        description=
        "This LTI tool provides a suite of tools for administering your Canvas account."
    )

    # this is how to tell Canvas that this tool provides an account navigation link:
    nav_params = {
        'enabled': 'true',
        'text': title,
        'default': 'disabled',
        'visibility': 'admins',
    }
    custom_fields = {'canvas_membership_roles': '$Canvas.membership.roles'}
    lti_tool_config.set_ext_param('canvas.instructure.com', 'custom_fields',
                                  custom_fields)
    lti_tool_config.set_ext_param('canvas.instructure.com',
                                  'account_navigation', nav_params)
    lti_tool_config.set_ext_param('canvas.instructure.com', 'privacy_level',
                                  'public')

    return HttpResponse(lti_tool_config.to_xml(), content_type='text/xml')
示例#2
0
def tool_config(request):
    """
    This produces a Canvas specific XML config that can be used to
    add this tool to the Canvas LMS
    """
    if request.is_secure():
        host = 'https://' + request.get_host()
    else:
        host = 'http://' + request.get_host()

    url = host + reverse('canvasPR_app:lti_launch')

    lti_tool_config = ToolConfig(
        title='Photo Roster - Test',
        launch_url=url,
        secure_launch_url=url,
    )
    account_nav_params = {
        'enabled': 'true',
        'visibility': 'admins',
        # optionally, supply a different URL for the link:
        # 'url': 'http://library.harvard.edu',
        'text': 'Photo Roster - Test',
    }
    lti_tool_config.set_ext_param('canvas.instructure.com', 'privacy_level',
                                  'public')
    lti_tool_config.set_ext_param('canvas.instructure.com',
                                  'course_navigation', account_nav_params)
    lti_tool_config.description = 'This LTI app shows all the LTI parameters'

    resp = HttpResponse(lti_tool_config.to_xml(),
                        content_type='text/xml',
                        status=200)
    return resp
示例#3
0
def tool_config(request):
    """
    This produces a Canvas specific XML config that can be used to
    add this tool to the Canvas LMS
    """
    if request.is_secure():
        host = 'https://' + request.get_host()
    else:
        host = 'http://' + request.get_host()

    url = host + reverse('edx2canvas:lti_launch')

    lti_tool_config = ToolConfig(
        title='Add edX Content',
        launch_url=url,
        secure_launch_url=url,
    )
    account_nav_params = {
        'enabled': 'true',
        'text': 'Add edX Content',
        'visibility': 'admins',
    }
    lti_tool_config.set_ext_param('canvas.instructure.com', 'privacy_level',
                                  'public')
    lti_tool_config.set_ext_param('canvas.instructure.com',
                                  'course_navigation', account_nav_params)
    lti_tool_config.description = 'Import content from edX to Canvas'

    return http.HttpResponse(lti_tool_config.to_xml(),
                             content_type='text/xml',
                             status=200)
示例#4
0
 def get_tool_config(self):
     '''Returns an instance of ToolConfig()'''
     return ToolConfig(
         title=self.TOOL_TITLE,
         description=self.TOOL_DESCRIPTION,
         launch_url=self.get_launch_url(),
         secure_launch_url=self.get_launch_url(force_secure=True),
     )
示例#5
0
 def get_tool_config(self, request):
     '''
     Returns an instance of ToolConfig().
     '''
     launch_url = self.get_launch_url(request)
     return ToolConfig(
         title=self.TOOL_TITLE,
         launch_url=launch_url,
         secure_launch_url=launch_url,
     )
示例#6
0
 def get_tool_config(self, request):
     '''
     Returns an instance of ToolConfig().
     '''
     launch_url = self.get_launch_url(request)
     return ToolConfig(
         title=LTI_SETUP['TOOL_TITLE'],
         description=LTI_SETUP['TOOL_DESCRIPTION'],
         launch_url=launch_url,
         secure_launch_url=launch_url,
     )
    def test_tool_config(self):
        launch_url = "http://foo.bar/"
        self.view.get_launch_url = Mock(return_value=launch_url)

        expected = ToolConfig(title=self.view.TOOL_TITLE,
                              launch_url=launch_url,
                              secure_launch_url=launch_url)
        actual = self.view.get_tool_config(self.view.request)

        self.assertEqual(actual.title, expected.title)
        self.assertEqual(actual.launch_url, expected.launch_url)
        self.assertEqual(actual.secure_launch_url, expected.secure_launch_url)
示例#8
0
def tool_config(request):
    '''
    Generates an XML config that can be used to add this tool to the Canvas LMS
    '''
    TOOL_NAME = 'Adaptive Quiz LTI'
    host = 'https://' + request.get_host()

    lti_tool_config = ToolConfig(
        title=TOOL_NAME,
        launch_url = host,
        secure_launch_url = host,
    )

    # # configuration for nav bar
    # course_nav_params = {
    #     'enabled': 'true',
    #     'selection_width':"700",
    #     'selection_height':"500",
    #     'url': host + reverse('lti:manage_quizzes'),
    # }
    # lti_tool_config.set_ext_param('canvas.instructure.com', 'course_navigation', course_nav_params)

    # configuration for quiz selection mode
    resource_selection_params = {
        'enabled': 'true',
        'selection_width':"700",
        'selection_height':"500",
        'url': request.build_absolute_uri(reverse('lti:launch_resource_selection')),
    }
    # add resource selection params to the xml
    lti_tool_config.set_ext_param('canvas.instructure.com', 'resource_selection', resource_selection_params)

    lti_tool_config.set_ext_param('canvas.instructure.com', 'privacy_level', 'public')
    lti_tool_config.set_ext_param('canvas.instructure.com', 'domain', request.get_host().partition(':')[0])
    lti_tool_config.description = 'The Qualtrics LTI Bridge allows instructors to embed qualtrics quizzes in an LMS as an LTI tool.'
    
    return HttpResponse(lti_tool_config.to_xml(), content_type='text/xml', status=200)