Skip to content

Commit e49b36a

Browse files
authored
Merge pull request #67 from filips123/set-course-view
2 parents dbb2bfe + 54c3f7a commit e49b36a

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

API/gimvicurnik/updaters/eclassroom.py

+20
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,29 @@ def __init__(self, config: ConfigSourcesEClassroom, session: Session) -> None:
5252
def get_documents(self) -> Iterator[DocumentInfo]:
5353
"""Get all documents from the e-classroom."""
5454

55+
self._mark_course_viewed()
56+
5557
yield from self._get_internal_urls()
5658
yield from self._get_external_urls()
5759

60+
def _mark_course_viewed(self) -> None:
61+
"""Mark the course as viewed, so we are not removed for inactivity."""
62+
63+
params = {
64+
"moodlewsrestformat": "json",
65+
}
66+
data = {
67+
"courseid": self.config.course,
68+
"wstoken": self.config.token,
69+
"wsfunction": "core_course_view_course",
70+
}
71+
72+
try:
73+
response = requests.post(self.config.webserviceUrl, params=params, data=data)
74+
response.raise_for_status()
75+
except (IOError, ValueError) as error:
76+
raise ClassroomApiError("Error while accessing e-classroom API") from error
77+
5878
def _get_internal_urls(self) -> Iterator[DocumentInfo]:
5979
params = {
6080
"moodlewsrestformat": "json",

0 commit comments

Comments
 (0)