Skip to content

Commit

Permalink
Merge pull request #112 from uw-it-aca/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
mikeseibel authored Jan 10, 2025
2 parents 8896530 + 5dab9c5 commit 8ea388c
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 10 deletions.
19 changes: 12 additions & 7 deletions blti/models/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,25 @@

from django.db import models
from pylti1p3.roles import (
AbstractRole, StaffRole, TeacherRole, TeachingAssistantRole,
AbstractRole, StaffRole, TeachingAssistantRole,
DesignerRole, ObserverRole, TransientRole)
import re


LTI_DATA_CLAIM_BASE = 'https://purl.imsglobal.org/spec/lti/claim/'


# Instructor and student roles are specific to the given context (course)
class TeacherRole(AbstractRole):
_common_roles = ("Instructor", "Administrator")
_context_roles = ("Instructor", "Administrator")


class StudentRole(AbstractRole):
_common_roles = ("Learner")
_context_roles = ("Learner")


class LTILaunchData(object):
def __init__(self, **data):
self._data = data
Expand Down Expand Up @@ -107,9 +118,3 @@ def _claim_data(self, claim, key, default=None):
def _claim(self, claim):
# specific claim key
return f"{LTI_DATA_CLAIM_BASE}{claim}"


class StudentRole(AbstractRole):
_common_roles = ("Learner")
_institution_roles = ("Student", "Learner")
_context_roles = ("Learner")
6 changes: 3 additions & 3 deletions blti/roles.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,17 @@ def roles_from_role_name(role_names):
roles += [
"institution/person#Learner",
"institution/person#Student",
"membeship#Learner"]
"membership#Learner"]
elif role_name in ['Instructor', 'Faculty', 'Teacher']:
roles += [
"institution/person#Instructor",
"institution/person#Faculty",
"membeship#Instructor"]
"membership#Instructor"]
elif role_name == 'Administrator':
roles += [
"system/person#User",
"institution/person#Administrator",
"membeship#Administrator"]
"membership#Administrator"]
elif role_name == 'TeachingAssistant':
roles += ["membership/Instructor#TeachingAssistant"]
elif role_name == 'ContentDeveloper':
Expand Down
4 changes: 4 additions & 0 deletions blti/tests/test_lti_1p3.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,10 @@ def test_authorize_member(self):
self.launch_data = CanvasData(**self.params)
self.assertEquals(None, self._authorize('member'))

self._set_role('Learner')
self.launch_data = CanvasData(**self.params)
self.assertEquals(None, self._authorize('member'))

self._set_role('Observer')
self.launch_data = CanvasData(**self.params)
self.assertEquals(None, self._authorize('member'))
Expand Down

0 comments on commit 8ea388c

Please sign in to comment.