From a9007a546964009dc2979a96b75d02291e4130b5 Mon Sep 17 00:00:00 2001 From: Nao Pross Date: Fri, 12 Feb 2021 01:31:01 +0100 Subject: Continue refractor of muddle.moodle --- muddle/moodle.py | 30 +++++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-) (limited to 'muddle') diff --git a/muddle/moodle.py b/muddle/moodle.py index a9209d7..8146fd4 100644 --- a/muddle/moodle.py +++ b/muddle/moodle.py @@ -104,10 +104,10 @@ class Course(SchemaObj): def get_sections(self, api): req = api.core_course_get_contents(courseid=self.id) - for sec in req.json(): + for s in req.json(): # rest api response does not contain course id - sec["course"] = self.id - yield Section._fromdict(sec) + s["course"] = self.id + yield Section._fromdict(s) @dataclasses.dataclass @@ -122,8 +122,13 @@ class Section(SchemaObj): name: str summary: str visible: bool + modules: List + def get_modules(self): + for m in self.modules: + yield Module._fromdict(m) + @dataclasses.dataclass class Module(SchemaObj): @@ -132,16 +137,23 @@ class Module(SchemaObj): https://www.examulator.com/er/output/tables/course_modules.html """ id: int - course: int - module: int - section: int + name: str + + +@dataclasses.dataclass +class File(SchemaObj): + filename: str + fileurl: str @dataclasses.dataclass class Folder(SchemaObj): - """ - Resource type that holds files - """ + pass + + +@dataclasses.dataclass +class ExternalLink(SchemaObj): + pass class ApiHelper: -- cgit v1.2.1