Skip to content

Commit

Permalink
Merge pull request #67 from filips123/set-course-view
Browse files Browse the repository at this point in the history
  • Loading branch information
filips123 committed May 10, 2023
2 parents dbb2bfe + 54c3f7a commit e49b36a
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions API/gimvicurnik/updaters/eclassroom.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,29 @@ def __init__(self, config: ConfigSourcesEClassroom, session: Session) -> None:
def get_documents(self) -> Iterator[DocumentInfo]:
"""Get all documents from the e-classroom."""

self._mark_course_viewed()

yield from self._get_internal_urls()
yield from self._get_external_urls()

def _mark_course_viewed(self) -> None:
"""Mark the course as viewed, so we are not removed for inactivity."""

params = {
"moodlewsrestformat": "json",
}
data = {
"courseid": self.config.course,
"wstoken": self.config.token,
"wsfunction": "core_course_view_course",
}

try:
response = requests.post(self.config.webserviceUrl, params=params, data=data)
response.raise_for_status()
except (IOError, ValueError) as error:
raise ClassroomApiError("Error while accessing e-classroom API") from error

def _get_internal_urls(self) -> Iterator[DocumentInfo]:
params = {
"moodlewsrestformat": "json",
Expand Down

0 comments on commit e49b36a

Please sign in to comment.