def get_school_data_for_sis_account_id(school_sis_account_id): school = None if not school_sis_account_id: return school school_sis_account_id = 'sis_account_id:{}'.format(school_sis_account_id) accounts = canvas_api_accounts_helper.get_all_sub_accounts_of_account( school_sis_account_id) for account in accounts: sis_account_id = account['sis_account_id'] school = { 'id': account['sis_account_id'], 'name': account['name'] } if school_sis_account_id == sis_account_id: return school return school
def get_department_data_for_school(school_sis_account_id, department_sis_account_id=None): """ get sub accounts where sis_account_id starts with dept :param school_sis_account_id: :param department_sis_account_id: :return: """ departments = [] school_sis_account_id = 'sis_account_id:{}'.format(school_sis_account_id) accounts = canvas_api_accounts_helper.get_all_sub_accounts_of_account( school_sis_account_id) for account in accounts: account_id = account['sis_account_id'] if account_id and account_id.lower().startswith('dept:'): department = { 'id': account_id.lower(), 'name': account['name'] } if department_sis_account_id and department_sis_account_id == account_id: return department else: departments.append(department) return departments
def get_course_group_data_for_school(school_sis_account_id, course_group_sis_account_id=None): """ get sub accounts where sis_account_id starts with coursegroup :param school_sis_account_id: :param course_group_sis_account_id: :return: """ course_groups = [] school_sis_account_id = 'sis_account_id:{}'.format(school_sis_account_id) accounts = canvas_api_accounts_helper.get_all_sub_accounts_of_account( school_sis_account_id) for account in accounts: account_id = account['sis_account_id'] if account_id and account_id.lower().startswith('coursegroup:'): course_group = { 'id': account_id.lower(), 'name': account['name'] } if course_group_sis_account_id and course_group_sis_account_id == account_id: return course_group else: course_groups.append(course_group) return course_groups
def get_department_data_for_school(school_sis_account_id, department_sis_account_id=None): """ get sub accounts where sis_account_id starts with dept :param school_sis_account_id: :param department_sis_account_id: :return: """ departments = [] school_sis_account_id = 'sis_account_id:{}'.format(school_sis_account_id) accounts = canvas_api_accounts_helper.get_all_sub_accounts_of_account( school_sis_account_id) for account in accounts: account_id = account['sis_account_id'] if account_id and account_id.lower().startswith('dept:'): department = { 'id': account_id.lower(), 'name': account['name'] } if department_sis_account_id and department_sis_account_id == account_id: return department else: departments.append(department) return sorted(departments, key=lambda k: k['name'])
def get_course_group_data_for_school(school_sis_account_id, course_group_sis_account_id=None): """ get sub accounts where sis_account_id starts with coursegroup :param school_sis_account_id: :param course_group_sis_account_id: :return: """ course_groups = [] school_sis_account_id = 'sis_account_id:{}'.format(school_sis_account_id) accounts = canvas_api_accounts_helper.get_all_sub_accounts_of_account( school_sis_account_id) for account in accounts: account_id = account['sis_account_id'] if account_id and account_id.lower().startswith('coursegroup:'): course_group = { 'id': account_id.lower(), 'name': account['name'] } if course_group_sis_account_id and course_group_sis_account_id == account_id: return course_group else: course_groups.append(course_group) # Sort the resulting course group list by its name return sorted(course_groups, key=lambda k: k['name'])