|
31 | 31 | TA = 'http://purl.imsglobal.org/vocab/lis/v2/membership/Instructor#TeachingAssistant' |
32 | 32 | COURSE_MEMBERSHIP = 'http://purl.imsglobal.org/vocab/lis/v2/membership' |
33 | 33 | DUMMY_CACHE = 'DummyCache' |
| 34 | +CANVAS_TEACHER_ROLE = 'TeacherEnrollment' |
34 | 35 |
|
35 | 36 | # do not require deployment ids if LTI_CONFIG_DISABLE_DEPLOYMENT_ID_VALIDATION is true |
36 | 37 | class ExtendedDjangoMessageLaunch(DjangoMessageLaunch): |
@@ -182,9 +183,9 @@ def get_cache_config(): |
182 | 183 | # Checking if user only has Instructor role in a course to enable MyLA in courses. |
183 | 184 | # A TA could be an instructor in an course section so his role will be both TA and Instructor. |
184 | 185 | # we don't want TA to enable the MyLA data extraction step. |
185 | | -def check_if_instructor(roles, username, course_id): |
| 186 | +def check_if_instructor(roles, canvas_course_roles, username, course_id): |
186 | 187 | user_membership_roles = set([role for role in roles if role.find(COURSE_MEMBERSHIP) == 0]) |
187 | | - if user_membership_roles and INSTRUCTOR in user_membership_roles: |
| 188 | + if user_membership_roles and CANVAS_TEACHER_ROLE in [role.strip() for role in canvas_course_roles.split(",")]: |
188 | 189 | logger.info(f'user {username} is Instructor in the course {course_id}') |
189 | 190 | return True |
190 | 191 | return False |
@@ -224,6 +225,7 @@ def extract_launch_variables_for_tool_use(request, message_launch): |
224 | 225 | username = custom_params['user_username'] |
225 | 226 | course_id = custom_params['canvas_course_id'] |
226 | 227 | canvas_user_id = custom_params['canvas_user_id'] |
| 228 | + canvas_course_roles = custom_params.get('canvas_course_roles', '') |
227 | 229 | time_zone = custom_params.get('person_address_timezone', |
228 | 230 | settings.TIME_ZONE).strip() |
229 | 231 |
|
@@ -257,7 +259,7 @@ def extract_launch_variables_for_tool_use(request, message_launch): |
257 | 259 |
|
258 | 260 | user_obj.backend = 'django.contrib.auth.backends.ModelBackend' |
259 | 261 | django.contrib.auth.login(request, user_obj) |
260 | | - is_instructor = check_if_instructor(roles, username, course_id) |
| 262 | + is_instructor = check_if_instructor(roles, canvas_course_roles, username, course_id) |
261 | 263 |
|
262 | 264 | try: |
263 | 265 | Course.objects.get(canvas_id=course_id) |
|
0 commit comments