def get_teams_members(self): runtime = self.xmodule_runtime user = runtime.service(self, 'user').get_current_user() course_id = runtime.course_id username = user.opt_attrs['edx-platform.username'] xblock_settings = self.get_xblock_settings() try: user = xblock_settings["username"] password = xblock_settings["password"] client_id = xblock_settings["client_id"] client_secret = xblock_settings["client_secret"] except KeyError: raise server_url = settings.LMS_ROOT_URL api = ApiTeams(user, password, client_id, client_secret, server_url) team = api.get_user_team(course_id, username) if team: team = team[0] team_id = team["id"] members = api.get_members(team_id) if members: return members
def api_teams(self): """ Returns an instance of ApiTeams """ try: client_id = self.get_xblock_settings()["client_id"] client_secret = self.get_xblock_settings()["client_secret"] except KeyError: raise return ApiTeams(settings.LMS_ROOT_URL, client_id, client_secret, self.location)
def _api_teams(self): """ Creates an ApiTeams object """ try: client_id = self.xblock_settings["client_id"] client_secret = self.xblock_settings["client_secret"] except KeyError: raise server_url = settings.LMS_ROOT_URL api = ApiTeams(client_id, client_secret, server_url) LOG.info("Api Teams initialize: %s ", api) return api
def api_teams(self): """ Creates an ApiTeams object """ if not self._api_teams: try: client_id = self.xblock_settings["client_id"] client_secret = self.xblock_settings["client_secret"] except KeyError, xblock_settings_error: LOG.error('Get rocketchat xblock settings error: %s', xblock_settings_error) raise server_url = settings.LMS_ROOT_URL self._api_teams = ApiTeams( # pylint: disable=attribute-defined-outside-init client_id, client_secret, server_url) LOG.info("Api Teams initialize: %s ", self._api_teams)