Skip to content

Commit

Permalink
Model for auto grading settings
Browse files Browse the repository at this point in the history
  • Loading branch information
marcospri committed Sep 6, 2024
1 parent 8362cdc commit dafb7e8
Showing 1 changed file with 29 additions and 1 deletion.
30 changes: 29 additions & 1 deletion lms/models/assignment.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,37 @@
from enum import StrEnum

import sqlalchemy as sa
from sqlalchemy.dialects.postgresql import JSONB
from sqlalchemy.ext.mutable import MutableDict
from sqlalchemy.orm import DynamicMapped, Mapped, mapped_column, relationship

from lms.db import Base
from lms.db import Base, varchar_enum
from lms.models._mixins import CreatedUpdatedMixin
from lms.models.grouping import Course, Grouping


class AutoGradingType(StrEnum):
ALL_OR_NOTHING = "all_or_nothing"
SCALED = "scaled"


class AutoGradingCalculation(StrEnum):
CUMULATIVE = "cumulative"
SEPARATE = "separate"


class AutoGradingConfig(Base):
__tablename__ = "assignment_auto_grading_config"

id: Mapped[int] = mapped_column(autoincrement=True, primary_key=True)

activity_calculation: Mapped[str | None] = varchar_enum(AutoGradingCalculation)
grading_type: Mapped[str | None] = varchar_enum(AutoGradingType)

required_annotations: Mapped[int] = mapped_column()
required_replies: Mapped[int | None] = mapped_column()


class Assignment(CreatedUpdatedMixin, Base):
"""
An assignment configuration.
Expand Down Expand Up @@ -109,6 +133,10 @@ class Assignment(CreatedUpdatedMixin, Base):
claim on LTI1.3
"""
auto_grading_config_id: Mapped[int | None] = mapped_column(
sa.ForeignKey("assignment_auto_grading_config.id", ondelete="cascade")
)
auto_grading_config = relationship("AutoGradingConfig")

__table_args__ = (
sa.UniqueConstraint("resource_link_id", "tool_consumer_instance_guid"),
Expand Down

0 comments on commit dafb7e8

Please sign in to comment.