Skip to content

Commit

Permalink
raise LTIError
Browse files Browse the repository at this point in the history
  • Loading branch information
shimulch committed Nov 9, 2020
1 parent a99528d commit c68b0f6
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions lti_consumer/plugin/compat.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
"""
Compatibility layer to isolate core-platform method calls from implementation.
"""
from django.core.exceptions import ValidationError
from lti_consumer.exceptions import LtiError


def run_xblock_handler(*args, **kwargs):
Expand All @@ -27,10 +29,16 @@ def get_user_from_external_user_id(external_user_id):
"""
# pylint: disable=import-error,import-outside-toplevel
from openedx.core.djangoapps.external_user_ids.models import ExternalId
return ExternalId.objects.get(
external_user_id=external_user_id,
external_id_type__name='lti'
).user
try:
external_id = ExternalId.objects.get(
external_user_id=external_user_id,
external_id_type__name='lti'
)
return external_id.user
except ExternalId.DoesNotExist as exception:
raise LtiError('Invalid User') from exception
except ValidationError as exception:
raise LtiError('Invalid userID') from exception


def submit_grade(score):
Expand Down

0 comments on commit c68b0f6

Please sign in to comment.