Compare commits
2 Commits
484dabe4c2
...
b1502db778
Author | SHA1 | Date |
---|---|---|
Markus Bauer | b1502db778 | |
Markus Bauer | 9f7f99a865 |
|
@ -49,6 +49,19 @@ class CakeCMS:
|
|||
print('[', r.status_code, ']')
|
||||
return r
|
||||
|
||||
def post_traditional(self, uri, data, course=None, named_params={}, **kwargs):
|
||||
if self.token:
|
||||
self.session.headers['X-CMS-API-TOKEN'] = self.token
|
||||
url = self.url + '/' + (self.course if course is None else course) + '/api/' + uri
|
||||
for k, v in named_params.items():
|
||||
url += '/{}:{}'.format(quote_named_param(k), quote_named_param(v))
|
||||
if self.debug:
|
||||
print('> POST', url, ' ', end='')
|
||||
r = self.session.post(url, data=data, **kwargs)
|
||||
if self.debug:
|
||||
print('[', r.status_code, ']')
|
||||
return r
|
||||
|
||||
def get_exams_api(self, uri, course=None, **kwargs):
|
||||
if self.token:
|
||||
self.session.headers['X-CMS-API-TOKEN'] = self.token
|
||||
|
@ -218,6 +231,31 @@ class CakeCMS:
|
|||
if tutorial_id: named_params['byTutorial'] = tutorial_id
|
||||
return self.get('submission_items/downloadAll', course=course, named_params=named_params, stream=True).raw
|
||||
|
||||
def submission_items_feedback(self, submission_item_id, course=None):
|
||||
"""
|
||||
Get the current feedback for a submission
|
||||
:param submission_item_id: the id of the student's submission item (from submission_items_index for example)
|
||||
:param course:
|
||||
:return:
|
||||
"""
|
||||
return self.get('submission_items/feedback/' + str(submission_item_id), course=course).json()['item']
|
||||
|
||||
def submission_item_feedback_set(self, submission_item_id, feedback='', attachment=None, points=None, course=None):
|
||||
"""
|
||||
Set submission feedback (and optionally points) for a submitted item. If this item was submitted by a team, feedback and points apply to all team members.
|
||||
:param submission_item_id: student's submission item id
|
||||
:param feedback: feedback text
|
||||
:param attachment: this can be: an open file, None, or anything else that requests accepts: https://requests.readthedocs.io/en/latest/user/quickstart/#post-a-multipart-encoded-file
|
||||
:param points: if a testing is linked to this submission, enter points
|
||||
:param course:
|
||||
:return:
|
||||
"""
|
||||
body = {'data[SubmissionFeedback][feedback]': feedback}
|
||||
if points is not None:
|
||||
body['data[SubmissionFeedback][points]'] = points
|
||||
files = {'data[SubmissionFeedback][upload]': attachment if attachment else ('', b'')}
|
||||
return self.post_traditional('submission_items/feedback/' + str(submission_item_id), body, files=files, course=None).json()
|
||||
|
||||
def registrations_import(self, id, matriculations, system='hispos', complete=True, timestamp=None, course=None):
|
||||
if not timestamp:
|
||||
dt = datetime.datetime.now()
|
||||
|
@ -337,6 +375,23 @@ class CakeCMS:
|
|||
fd.write(chunk)
|
||||
return self.__get_content_disposition_filename(response)
|
||||
|
||||
def team_groupings_index(self, course=None):
|
||||
"""
|
||||
List all team groupings
|
||||
:param course:
|
||||
:return:
|
||||
"""
|
||||
return self.get('team_groupings/index', course=course).json()
|
||||
|
||||
def team_groupings_view(self, team_grouping_id, course=None):
|
||||
"""
|
||||
Get team grouping infos and all existing teams
|
||||
:param team_grouping_id:
|
||||
:param course:
|
||||
:return:
|
||||
"""
|
||||
return self.get('team_groupings/view/' + str(team_grouping_id)).json()['teamGrouping']
|
||||
|
||||
def tokens_index(self, course=None):
|
||||
return self.get('tokens/index', course=course).json()['tokens']
|
||||
|
||||
|
|
Loading…
Reference in New Issue