canvasapi icon indicating copy to clipboard operation
canvasapi copied to clipboard

#440: added util.py:obj_or_id_or_sis_str, use it in course.py:enroll…

Open ndegroot opened this issue 2 years ago • 1 comments

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:

  1. 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.
  2. in section.py there also an enroll_user function, maybe it could be changed also.

ndegroot avatar Nov 01 '21 12:11 ndegroot