diff --git a/cakecms/cakecms.py b/cakecms/cakecms.py index e55b909..96ed7be 100644 --- a/cakecms/cakecms.py +++ b/cakecms/cakecms.py @@ -61,6 +61,18 @@ class CakeCMS: print('[', r.status_code, ']') return r + def post_exams_api(self, uri, data, course=None, **kwargs): + if self.token: + self.session.headers['X-CMS-API-TOKEN'] = self.token + url = self.url + '/examination_backend/' + (self.course if course is None else course) + '/' + uri + headers = {'X-Exams-Tenant': self.course if course is None else course, 'X-CSRF-CHECK': '1'} + if self.debug: + print('> POST', url, ' ', end='') + r = self.session.post(url, json=data, headers=headers, **kwargs) + if self.debug: + print('[', r.status_code, ']') + return r + def assert_success(self, result): if 'error' in result and result['error'] == 'exception': if self.debug: print('