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.
 
 
 

48 lines
1.5 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. smbox, _ = csm_tutor.question("smallbox")
  17. defaults = dict(smbox["defaults"])
  18. defaults.update({"csq_rows": 10, "csq_cols": 60})
  19. def escape(s):
  20. return (
  21. s.replace("&", "&amp;")
  22. .replace('"', "&quot;")
  23. .replace("<", "&lt;")
  24. .replace(">", "&gt;")
  25. )
  26. total_points = smbox["total_points"]
  27. answer_display = smbox["answer_display"]
  28. handle_submission = smbox["handle_submission"]
  29. def render_html(last_log, **info):
  30. if last_log is None:
  31. last_log = {}
  32. rows = info["csq_rows"]
  33. cols = info["csq_cols"]
  34. out = '<textarea rows="%d" cols="%d"' % (rows, cols)
  35. out += ' name="%s"' % info["csq_name"]
  36. out += ' id="%s"' % info["csq_name"]
  37. out += ">%s</textarea><br>" % escape(last_log.get(info["csq_name"], ""))
  38. return out