From 2135e35fd039ea35029b110bbba94ce9e6447aa1 Mon Sep 17 00:00:00 2001 From: Marcos Prieto Date: Mon, 4 Nov 2024 11:34:35 +0100 Subject: [PATCH] Model for the LMSGroupSet table --- lms/models/__init__.py | 1 + lms/models/group_set.py | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+) create mode 100644 lms/models/group_set.py diff --git a/lms/models/__init__.py b/lms/models/__init__.py index 0b27ca81a0..26af78f745 100644 --- a/lms/models/__init__.py +++ b/lms/models/__init__.py @@ -19,6 +19,7 @@ from lms.models.grading_info import GradingInfo from lms.models.grading_sync import GradingSync, GradingSyncGrade from lms.models.group_info import GroupInfo +from lms.models.group_set import LMSGroupSet from lms.models.grouping import ( BlackboardGroup, CanvasGroup, diff --git a/lms/models/group_set.py b/lms/models/group_set.py new file mode 100644 index 0000000000..0514aa53f1 --- /dev/null +++ b/lms/models/group_set.py @@ -0,0 +1,36 @@ +from typing import TYPE_CHECKING + +from sqlalchemy import ForeignKey, UniqueConstraint +from sqlalchemy.orm import Mapped, mapped_column, relationship + +from lms.db import Base +from lms.models._mixins import CreatedUpdatedMixin + +if TYPE_CHECKING: + from lms.models import LMSCourse + + +class LMSGroupSet(CreatedUpdatedMixin, Base): + """Group sets are different ways to divide a course's roster into groups. + + Segments that represent groups belong to one group set. + + Some LMS call this concept a "Group category" instead. + """ + + __tablename__ = "lms_group_set" + + __table_args__ = (UniqueConstraint("lms_course_id", "lms_id"),) + + id: Mapped[int] = mapped_column(autoincrement=True, primary_key=True) + + lms_id: Mapped[str] = mapped_column(index=True) + """ID of this group set in the LMS""" + + name: Mapped[str] = mapped_column() + """Name of this group set in the LMS""" + + lms_course_id: Mapped[int] = mapped_column(ForeignKey("lms_course.id")) + """ID of the course this group set belongs to""" + + lms_course: Mapped["LMSCourse"] = relationship("LMSCourse")