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.
 
 
 

64 lines
2.3 KiB

  1. # This file is part of CAT-SOOP
  2. # Copyright (c) 2011-2017 Adam Hartz <hartz@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. import collections.abc
  17. defaults = {
  18. 'csq_npoints': 1
  19. }
  20. allow_viewanswer = False
  21. allow_self_submit = False
  22. allow_save = False
  23. def total_points(**info):
  24. return info['csq_npoints']
  25. def handle_submission(submissions, **info):
  26. if 'real_user' not in info['cs_user_info']:
  27. percent = 0
  28. msg = 'You must receive this checkoff from a staff member.'
  29. l = False
  30. else:
  31. import time
  32. un = submissions[info['csq_name']]
  33. new = dict(info)
  34. new['cs_form'] = {}
  35. uinfo = info['csm_auth']._get_user_information(new,
  36. new,
  37. info['cs_course'],
  38. un,
  39. True)
  40. if 'checkoff' not in uinfo.get('permissions', []):
  41. percent = 0
  42. msg = '%s is not allowed to give checkoffs.' % un
  43. l = False
  44. else:
  45. percent = 1
  46. now = info['csm_time'].from_detailed_timestamp(info['cs_timestamp'])
  47. now = info['csm_time'].long_timestamp(now).replace('; ', ' at ')
  48. msg = 'You received this checkoff from %s on %s.' % (un, now)
  49. l = True
  50. return {'score': percent, 'msg': msg, 'lock': l}
  51. def render_html(last_log, **info):
  52. info['csq_description'] = info['csm_language'].source_transform_string(info, info['csq_description'])
  53. return '<b>%s</b>:<br/>%s' % (info['csq_display_name'],
  54. info['csq_description'])
  55. def answer_display(**info):
  56. return ""