CAT-SOOP is a flexible, programmable learning management system based on the Python programming language. https://catsoop.mit.edu
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

44 lines
1.4 KiB

  1. # This file is part of CAT-SOOP
  2. # Copyright (c) 2011-2020 by The CAT-SOOP Developers <catsoop-dev@mit.edu>
  3. #
  4. # This program is free software: you can redistribute it and/or modify it under
  5. # the terms of the GNU Affero General Public License as published by the Free
  6. # Software Foundation, either version 3 of the License, or (at your option) any
  7. # later version.
  8. #
  9. # This program is distributed in the hope that it will be useful, but WITHOUT
  10. # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  11. # FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
  12. # details.
  13. #
  14. # You should have received a copy of the GNU Affero General Public License
  15. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  16. # api endpoint to get user information.
  17. # requires: username and password, or api token
  18. # optional: course ID for extra information
  19. import json
  20. cs_handler = "raw_response"
  21. content_type = "application/json"
  22. output = csm_api.get_user_information(
  23. globals(),
  24. uname=cs_form.get("username", None),
  25. passwd=cs_form.get("password_hash", None),
  26. api_token=cs_form.get("api_token", None),
  27. course=cs_form.get("course", None),
  28. _as=cs_form.get("as", None),
  29. )
  30. def _json_mapper(x):
  31. if isinstance(x, (set, tuple)):
  32. return list(x)
  33. else:
  34. return None
  35. response = json.dumps(output, default=_json_mapper)