fix(canvas): monkey patch missing login_id
This commit is contained in:
parent
599a07d41f
commit
305ea6d31b
|
@ -4,6 +4,7 @@ from typing import cast
|
||||||
|
|
||||||
from canvasapi import Canvas as PyCanvas
|
from canvasapi import Canvas as PyCanvas
|
||||||
from canvasapi.assignment import Assignment
|
from canvasapi.assignment import Assignment
|
||||||
|
from canvasapi.user import User
|
||||||
from patoolib import extract_archive
|
from patoolib import extract_archive
|
||||||
from patoolib.util import PatoolError
|
from patoolib.util import PatoolError
|
||||||
|
|
||||||
|
@ -30,7 +31,15 @@ class Canvas:
|
||||||
logger.info(f"Canvas course loaded. {self.course}")
|
logger.info(f"Canvas course loaded. {self.course}")
|
||||||
# types = ["student", "observer"]
|
# types = ["student", "observer"]
|
||||||
types = ["student"]
|
types = ["student"]
|
||||||
self.students = self.course.get_users(enrollment_type=types, include=["email"])
|
|
||||||
|
def patch_student(student: User) -> User:
|
||||||
|
student.login_id = student.email.split("@")[0]
|
||||||
|
return student
|
||||||
|
|
||||||
|
self.students = [
|
||||||
|
patch_student(student)
|
||||||
|
for student in self.course.get_users(enrollment_type=types)
|
||||||
|
]
|
||||||
for attr in ["login_id", "sortable_name", "name"]:
|
for attr in ["login_id", "sortable_name", "name"]:
|
||||||
if not hasattr(self.students[0], attr):
|
if not hasattr(self.students[0], attr):
|
||||||
raise Exception(
|
raise Exception(
|
||||||
|
|
Loading…
Reference in New Issue
Block a user