canvasapi
canvasapi copied to clipboard
#440: added util.py:obj_or_id_or_sis_str, use it in course.py:enroll…
Change course.py:enroll_user to also support 'sis_login_id:' syntax
Proposed Changes
- in util.py add new function 'obj_or_id_or_sis_str'
- in courses.py import this new function and change function 'enroll_user' to use this function instead of 'obj_or_id'
Fixes #440 Allow using SIS ids like sis_login_id:[loginname].
Extra important for scripts running under subadmin accounts: in that case the scripts can't use the get_user() function for new users, not enrolled yet in a sub-admin related course because the function is reserved for admins. So subadmin scripts really need this format in course.enroll_user() to be able to enroll a user programmaticly.
Notes:
- An alternative approach could be to expand function 'obj_or_id' to accept 'sis_login_id:xxxx' and variants. But not changing the function name is confusing. Changing all occurrances of function name 'obj_or_id' thoughout the code I didn't dare to do.
- in section.py there also an enroll_user function, maybe it could be changed also.
I've just checked my code again, run the tests and coverage on Python 3.11 against current state. Still working ok. Please give me feedback why this is still pending. Happy to rework it!
Added same changes to section.py in def section(). And added tests.