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.
 
 
 

69 lines
2.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. defaults = {"csq_npoints": 1}
  17. allow_viewanswer = False
  18. allow_self_submit = False
  19. allow_save = False
  20. def total_points(**info):
  21. return info["csq_npoints"]
  22. def handle_submission(submissions, **info):
  23. tok, un = submissions[info["csq_name"]].split(",")
  24. i = csm_api.userinfo_from_token(info, tok)
  25. new = dict(info)
  26. uinfo = info["csm_auth"]._get_user_information(
  27. new, new, info["cs_course"], (i or {}).get("username", "None"), True
  28. )
  29. if "impersonate" not in uinfo.get("permissions", []):
  30. percent = 0
  31. msg = "You must receive this checkoff from a staff member."
  32. l = False
  33. else:
  34. new = dict(info)
  35. new["cs_form"] = {}
  36. uinfo = info["csm_auth"]._get_user_information(
  37. new, new, info["cs_course"], un, True
  38. )
  39. if "checkoff" not in uinfo.get("permissions", []):
  40. percent = 0
  41. msg = "%s is not allowed to give checkoffs." % un
  42. l = False
  43. else:
  44. percent = 1
  45. now = info["csm_time"].from_detailed_timestamp(info["cs_timestamp"])
  46. now = info["csm_time"].long_timestamp(now).replace("; ", " at ")
  47. msg = "You received this checkoff from %s on %s." % (un, now)
  48. l = True
  49. return {"score": percent, "msg": msg, "lock": l}
  50. def render_html(last_log, **info):
  51. if info["csq_description"] == info["csq_display_name"] == "":
  52. return ""
  53. info["csq_description"] = info["csm_language"].source_transform_string(
  54. info, info["csq_description"]
  55. )
  56. return "<b>%s</b>:<br/>%s" % (info["csq_display_name"], info["csq_description"])
  57. def answer_display(**info):
  58. return ""