Files
temmies/temmies/course.py
Boyan 96488ac69c reformatted to make pylint happy
TODO: get rid of the ignore comments - just fix it
2024-12-02 18:21:54 +01:00

41 lines
1.1 KiB
Python

"""
Represents a course.
A course is a group that contains exercises or other groups.
"""
from .group import Group
from .exercise_group import ExerciseGroup
class Course(Group):
"""
Represents a course.
"""
def __init__(self, session, course_path: str, title: str, parent):
super().__init__(session, course_path, title, parent)
self.course_path = course_path # e.g., '/2023-2024/adinc-ai'
def __str__(self):
return f"Course({self.title})"
def create_group(self, item_data):
"""
Create a subgroup (Group or ExerciseGroup) based on item data.
"""
if item_data.get("submitable", False):
return ExerciseGroup(
self.session,
item_data["path"],
item_data["title"],
self,
item_data.get("submitable", False),
)
return Group(
self.session,
item_data["path"],
item_data["title"],
self,
item_data.get("submitable", False),
)