FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

new: getExams -- needs additional rights · robquant/python-webuntis@9196759 · GitHub

Commit 9196759

Browse files
committed
new: getExams -- needs additional rights
1 parent 946a2f1 commit 9196759

4 files changed

Lines changed: 61 additions & 4 deletions

File tree

‎tests/test_session.py‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -328,8 +328,10 @@ def test_students(self):
328328
assert student.full_name == "Alexander Mueller"
329329
assert student.gender == "male"
330330

331-
332-
333-
334331
def test_examtype(self):
332+
"""@TODO"""
333+
pass
334+
335+
def test_exam(self):
336+
"""@TODO"""
335337
pass

‎webuntis/objects.py‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -693,6 +693,7 @@ def end(self):
693693

694694
class TimegridDayObject(Result):
695695
"""Information about one day in the time grid"""
696+
696697
@lazyproperty
697698
def day(self):
698699
return self._data[u'day']
@@ -727,10 +728,12 @@ def full_name(self):
727728
def gender(self):
728729
return self._data[u'gender']
729730

731+
730732
class StudentsList(ListResult):
731733
"""A list of students"""
732734
_itemclass = StudentObject
733735

736+
734737
'''
735738
@TODO: need additional rights
736739
class ExamTypeObject(Result):
@@ -739,4 +742,11 @@ class ExamTypeObject(Result):
739742
class ExamTypeList(ListResult):
740743
"""A list of exam types"""
741744
_itemclass = ExamTypeObject
745+
746+
class ExamObject(Result):
747+
"""Represents an Exam."""
748+
749+
class ExamList(ListResult):
750+
"""A list of exams."""
751+
_itemclass = ExamObject
742752
'''

‎webuntis/objects.pyi‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,7 @@ class StudentObject(PersonObject):
312312
def gender(self) -> str:
313313
...
314314

315+
315316
class StudentsList(ListResult):
316317
_itemclass = StudentObject
317318

@@ -413,6 +414,7 @@ class TimegridObject(ListResult):
413414
def __getitem__(self, i: int) -> TimegridDayObject:
414415
...
415416

417+
416418
"""
417419
@TODO: need additional rights
418420
@@ -427,4 +429,16 @@ class ExamTypeList(ListResult):
427429
428430
def __getitem__(self, i: int) -> ExamTypeObject:
429431
...
432+
433+
class ExamObject(Result):
434+
...
435+
436+
class ExamList(ListResult):
437+
_itemclass = ExamObject
438+
439+
def filter(self, **criterions) -> ExamObject:
440+
...
441+
442+
def __getitem__(self, i: int) -> ExamObject:
443+
...
430444
"""

‎webuntis/session.py‎

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -335,13 +335,44 @@ def students(self):
335335
@TODO: need additional rights
336336
@result_wrapper
337337
def examTypes(self):
338-
"""Information about the Exams.
338+
"""Information about the Exam types.
339339
340340
:rtype: :py:class:`webuntis.objects.ExamTypeList`
341341
"""
342342
return objects.ExamTypeList, 'getExamTypes', {}
343+
344+
345+
@result_wrapper
346+
def exams(self, start, end, examTypeId=0):
347+
"""Information about the Exams.
348+
349+
:type start: :py:class:`datetime.datetime` or :py:class:`datetime.date` or int
350+
:param start: The beginning of the time period.
351+
352+
:type end: :py:class:`datetime.datetime` or :py:class:`datetime.date` or int
353+
:param end: The end of the time period.
354+
355+
:param examTypeId: int, ??
356+
357+
:rtype: :py:class:`webuntis.objects.ExamList`
358+
"""
359+
360+
json_start = utils.datetime_utils.format_date(start)
361+
json_end = utils.datetime_utils.format_date(end)
362+
363+
if json_start > json_end:
364+
raise ValueError('Start can\'t be later than the end.')
365+
366+
parameters = {
367+
'startDate': json_start,
368+
'endDate': json_end,
369+
'examTypeId': examTypeId
370+
}
371+
372+
return objects.ExamList, 'getExams', parameters
343373
'''
344374

375+
345376
class Session(JSONRPCSession, ResultWrapperMixin):
346377
"""The origin of everything you want to do with the WebUntis API. Can be
347378
used as a context-manager to provide automatic log-out.

0 commit comments

Comments
 (0)

Back | FazBrowse Home | New Git URL