diff --git a/API/app/infrastructure/database/models/courses.py b/API/app/infrastructure/database/models/courses.py index 4fcb2a3..9e54e4d 100644 --- a/API/app/infrastructure/database/models/courses.py +++ b/API/app/infrastructure/database/models/courses.py @@ -19,3 +19,5 @@ class Course(Base): students = relationship('CourseStudent', back_populates='course') notifications = relationship('Notification', back_populates='course') + + lessons = relationship('Lesson', back_populates='course') diff --git a/API/app/infrastructure/database/models/lectures.py b/API/app/infrastructure/database/models/lectures.py new file mode 100644 index 0000000..f8d9495 --- /dev/null +++ b/API/app/infrastructure/database/models/lectures.py @@ -0,0 +1,17 @@ +from sqlalchemy import Column, Integer, String, ForeignKey +from sqlalchemy.orm import relationship + +from app.infrastructure.database.models import Base + + +class Lectures(Base): + __tablename__ = 'lectures' + + id = Column(Integer, primary_key=True, autoincrement=True) + text = Column(String, nullable=False) + image = Column(String) + number = Column(Integer, nullable=False) + + step_id = Column(Integer, ForeignKey('steps.id'), nullable=False) + + step = relationship('Step', back_populates='lectures') diff --git a/API/app/infrastructure/database/models/lessons.py b/API/app/infrastructure/database/models/lessons.py new file mode 100644 index 0000000..9ecc5bb --- /dev/null +++ b/API/app/infrastructure/database/models/lessons.py @@ -0,0 +1,18 @@ +from sqlalchemy import Column, Integer, String, ForeignKey, VARCHAR +from sqlalchemy.orm import relationship + +from app.infrastructure.database.models import Base + + +class Lesson(Base): + __tablename__ = 'lessons' + + id = Column(Integer, primary_key=True, autoincrement=True) + title = Column(VARCHAR(200), nullable=False) + description = Column(String, nullable=False) + + course_id = Column(Integer, ForeignKey('courses.id'), nullable=False) + + course = relationship('Course', back_populates='lessons') + + steps = relationship('Step', back_populates='lesson') diff --git a/API/app/infrastructure/database/models/step_tasks.py b/API/app/infrastructure/database/models/step_tasks.py new file mode 100644 index 0000000..6f773dc --- /dev/null +++ b/API/app/infrastructure/database/models/step_tasks.py @@ -0,0 +1,19 @@ +from sqlalchemy import Column, Integer, String, ForeignKey +from sqlalchemy.orm import relationship + +from app.infrastructure.database.models import Base + + +class StepTask(Base): + __tablename__ = 'step_tasks' + + id = Column(Integer, primary_key=True, autoincrement=True) + text = Column(String, nullable=False) + + step_id = Column(Integer, ForeignKey('steps.id'), nullable=False) + type_id = Column(Integer, ForeignKey('task_types.id'), nullable=False) + + step = relationship('Step', back_populates='tasks') + type = relationship('TaskType', back_populates='tasks') + + files = relationship('TaskFile', back_populates='task') diff --git a/API/app/infrastructure/database/models/step_types.py b/API/app/infrastructure/database/models/step_types.py new file mode 100644 index 0000000..9ad8f3c --- /dev/null +++ b/API/app/infrastructure/database/models/step_types.py @@ -0,0 +1,14 @@ +from sqlalchemy import Column, Integer, String, VARCHAR +from sqlalchemy.orm import relationship + +from app.infrastructure.database.models import Base + + +class StepType(Base): + __tablename__ = 'step_types' + + id = Column(Integer, primary_key=True, autoincrement=True) + title = Column(VARCHAR(200), nullable=False) + description = Column(String, nullable=False) + + steps = relationship('Step', back_populates='type') diff --git a/API/app/infrastructure/database/models/steps.py b/API/app/infrastructure/database/models/steps.py new file mode 100644 index 0000000..680a206 --- /dev/null +++ b/API/app/infrastructure/database/models/steps.py @@ -0,0 +1,20 @@ +from sqlalchemy import Column, Integer, ForeignKey, VARCHAR +from sqlalchemy.orm import relationship + +from app.infrastructure.database.models import Base + + +class Step(Base): + __tablename__ = 'steps' + + id = Column(Integer, primary_key=True, autoincrement=True) + title = Column(VARCHAR(200)) + + lesson_id = Column(Integer, ForeignKey('lessons.id'), nullable=False) + type_id = Column(Integer, ForeignKey('step_types.id'), nullable=False) + + lesson = relationship('Lesson', back_populates='steps') + type = relationship('StepType', back_populates='steps') + + lectures = relationship('Lectures', back_populates='step') + tasks = relationship('StepTask', back_populates='step') diff --git a/API/app/infrastructure/database/models/task_files.py b/API/app/infrastructure/database/models/task_files.py new file mode 100644 index 0000000..6ee5b5a --- /dev/null +++ b/API/app/infrastructure/database/models/task_files.py @@ -0,0 +1,16 @@ +from sqlalchemy import Column, Integer, String, ForeignKey +from sqlalchemy.orm import relationship + +from app.infrastructure.database.models import Base + + +class TaskFile(Base): + __tablename__ = 'task_files' + + id = Column(Integer, primary_key=True, autoincrement=True) + file_path = Column(String, nullable=False) + file_title = Column(String, nullable=False) + + task_id = Column(Integer, ForeignKey('step_tasks.id'), nullable=False) + + task = relationship('StepTask', back_populates='files') diff --git a/API/app/infrastructure/database/models/task_types.py b/API/app/infrastructure/database/models/task_types.py new file mode 100644 index 0000000..a914587 --- /dev/null +++ b/API/app/infrastructure/database/models/task_types.py @@ -0,0 +1,14 @@ +from sqlalchemy import Column, Integer, String, VARCHAR +from sqlalchemy.orm import relationship + +from app.infrastructure.database.models import Base + + +class TaskType(Base): + __tablename__ = 'task_types' + + id = Column(Integer, primary_key=True, autoincrement=True) + title = Column(VARCHAR(200), nullable=False) + description = Column(String, nullable=False) + + tasks = relationship('StepTask', back_populates='type')