Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 14 additions & 3 deletions xblocks_contrib/lti/lti.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
from django.utils.translation import gettext_noop as _
from lxml import etree
from oauthlib.oauth1.rfc5849 import signature
from opaque_keys.edx.keys import UsageKey
from opaque_keys.edx.keys import CourseKey, UsageKey
from pytz import UTC
from web_fragments.fragment import Fragment
from webob import Response
Expand Down Expand Up @@ -383,6 +383,15 @@ class LTIBlock(
# Indicates that this XBlock has been extracted from edx-platform.
is_extracted = True

@property
def category(self):
"""Return the block type/category."""
return self.scope_ids.block_type

@property
def url_name(self):
return self.location.block_id

@property
def location(self):
return self.scope_ids.usage_id
Expand Down Expand Up @@ -764,7 +773,9 @@ def get_course(self):
"""
Return course by course id.
"""
return self.runtime.modulestore.get_course(self.location.course_key)
if isinstance(self.location.course_key, CourseKey):
return self.runtime.modulestore.get_course(self.location.course_key)
return None

@property
def context_id(self):
Expand Down Expand Up @@ -992,7 +1003,7 @@ def get_client_key_secret(self):
Obtains client_key and client_secret credentials from current course.
"""
course = self.get_course()
for lti_passport in course.lti_passports:
for lti_passport in course.lti_passports if course else []:
try:
lti_id, key, secret = [i.strip() for i in lti_passport.split(':')]
except ValueError:
Expand Down