2022-11-12 16:18:07 +01:00
|
|
|
from datetime import datetime
|
|
|
|
|
2022-05-18 17:36:16 +02:00
|
|
|
from flask_sqlalchemy import BaseQuery
|
|
|
|
|
2023-01-14 17:38:03 +01:00
|
|
|
from ..base.models import Base, Person
|
2022-05-18 17:36:16 +02:00
|
|
|
from ..base.utils import order_by_column_name
|
2023-01-14 17:38:03 +01:00
|
|
|
from ..dependencies import db
|
2022-11-12 16:18:07 +01:00
|
|
|
from ..examination_schedule.models import TermOfDefence
|
|
|
|
|
|
|
|
|
|
|
|
class YearGroup(Base):
|
2023-01-14 17:38:03 +01:00
|
|
|
__tablename__ = "year_groups"
|
2022-11-12 16:18:07 +01:00
|
|
|
|
2022-11-17 10:21:36 +01:00
|
|
|
name = db.Column(db.String(50), nullable=False)
|
|
|
|
mode = db.Column(db.String(1), nullable=False)
|
2022-11-12 16:18:07 +01:00
|
|
|
created_at = db.Column(db.DateTime, nullable=False, default=datetime.utcnow)
|
2022-05-17 22:16:45 +02:00
|
|
|
|
2023-01-14 17:38:03 +01:00
|
|
|
__table__args = db.UniqueConstraint("name", "mode", name="uc_name_mode_year_group")
|
2022-11-17 10:21:36 +01:00
|
|
|
|
|
|
|
|
2023-01-14 17:38:03 +01:00
|
|
|
students_groups = db.Table(
|
|
|
|
"students_groups",
|
|
|
|
db.Column("group_id", db.ForeignKey("groups.id"), nullable=False),
|
|
|
|
db.Column("student_id", db.ForeignKey("students.id"), nullable=False),
|
|
|
|
)
|
2022-11-17 10:21:36 +01:00
|
|
|
|
2022-10-27 11:19:38 +02:00
|
|
|
|
2022-05-17 22:16:45 +02:00
|
|
|
class Group(Base):
|
|
|
|
__tablename__ = "groups"
|
|
|
|
|
|
|
|
name = db.Column(db.String(60), nullable=False)
|
2023-01-14 17:38:03 +01:00
|
|
|
cdyd_kod = db.Column(db.String(60), default="2022/SZ")
|
|
|
|
prz_kod = db.Column(db.String(60), default="06-DPRILI0")
|
|
|
|
tzaj_kod = db.Column(db.String(60), default="LAB")
|
|
|
|
project_supervisor_id = db.Column(
|
|
|
|
db.Integer, db.ForeignKey("project_supervisors.id")
|
|
|
|
)
|
|
|
|
project_supervisor = db.relationship("ProjectSupervisor", backref="groups")
|
|
|
|
year_group_id = db.Column(db.Integer, db.ForeignKey("year_groups.id"))
|
|
|
|
year_group = db.relationship("YearGroup", backref="groups", lazy="joined")
|
2023-01-16 00:35:25 +01:00
|
|
|
points_for_first_term = db.Column(db.Float, default=0, nullable=False)
|
|
|
|
points_for_second_term = db.Column(db.Float, default=0, nullable=False)
|
2023-01-16 01:12:15 +01:00
|
|
|
grade_for_first_term = db.Column(db.Float, default=0, nullable=False)
|
|
|
|
grade_for_second_term = db.Column(db.Float, default=0, nullable=False)
|
2023-01-14 17:38:03 +01:00
|
|
|
students = db.relationship(
|
|
|
|
"Student", secondary=students_groups, back_populates="groups"
|
|
|
|
)
|
2022-05-17 22:16:45 +02:00
|
|
|
|
2022-06-12 17:45:45 +02:00
|
|
|
@classmethod
|
2022-11-12 16:18:07 +01:00
|
|
|
def search_by_name(cls, year_group_id: int, search_name: str = None) -> BaseQuery:
|
|
|
|
group_query = cls.query.filter(Group.year_group_id == year_group_id)
|
2022-06-12 17:45:45 +02:00
|
|
|
|
|
|
|
if search_name is not None:
|
2023-01-14 17:38:03 +01:00
|
|
|
group_query = group_query.filter(Group.name.like(f"{search_name}%"))
|
2022-06-12 17:45:45 +02:00
|
|
|
|
2022-06-13 17:52:15 +02:00
|
|
|
return group_query
|
2022-06-12 17:45:45 +02:00
|
|
|
|
2022-05-17 22:16:45 +02:00
|
|
|
|
2022-12-15 20:44:03 +01:00
|
|
|
class ProjectGradeSheet(Base):
|
2023-01-14 17:38:03 +01:00
|
|
|
__tablename__ = "project_grade_sheets"
|
2022-12-15 20:44:03 +01:00
|
|
|
|
2023-01-14 17:38:03 +01:00
|
|
|
group_id = db.Column(db.Integer, db.ForeignKey("groups.id"))
|
|
|
|
group = db.relationship("Group", backref="project_grade_sheet", uselist=False)
|
2022-12-15 20:44:03 +01:00
|
|
|
|
|
|
|
presentation_required_content_1 = db.Column(db.Integer, default=0)
|
|
|
|
presentation_required_content_2 = db.Column(db.Integer, default=0)
|
|
|
|
presentation_was_compatible_1 = db.Column(db.Integer, default=0)
|
|
|
|
presentation_was_compatible_2 = db.Column(db.Integer, default=0)
|
|
|
|
presentation_showing_1 = db.Column(db.Integer, default=0)
|
|
|
|
presentation_showing_2 = db.Column(db.Integer, default=0)
|
2023-01-14 17:38:03 +01:00
|
|
|
presentation_answers_to_questions_from_committee_1 = db.Column(
|
|
|
|
db.Integer, default=0
|
|
|
|
)
|
|
|
|
presentation_answers_to_questions_from_committee_2 = db.Column(
|
|
|
|
db.Integer, default=0
|
|
|
|
)
|
2022-12-15 20:44:03 +01:00
|
|
|
|
|
|
|
documentation_project_vision_1 = db.Column(db.Integer, default=0)
|
|
|
|
documentation_project_vision_2 = db.Column(db.Integer, default=0)
|
|
|
|
documentation_requirements_1 = db.Column(db.Integer, default=0)
|
|
|
|
documentation_requirements_2 = db.Column(db.Integer, default=0)
|
|
|
|
documentation_for_clients_1 = db.Column(db.Integer, default=0)
|
|
|
|
documentation_for_clients_2 = db.Column(db.Integer, default=0)
|
|
|
|
documentation_for_developers_1 = db.Column(db.Integer, default=0)
|
|
|
|
documentation_for_developers_2 = db.Column(db.Integer, default=0)
|
|
|
|
documentation_license_1 = db.Column(db.Integer, default=0)
|
|
|
|
documentation_license_2 = db.Column(db.Integer, default=0)
|
|
|
|
|
|
|
|
group_work_regularity_1 = db.Column(db.Integer, default=0)
|
|
|
|
group_work_regularity_2 = db.Column(db.Integer, default=0)
|
|
|
|
group_work_division_of_work_1 = db.Column(db.Integer, default=0)
|
|
|
|
group_work_division_of_work_2 = db.Column(db.Integer, default=0)
|
|
|
|
group_work_contact_with_client_1 = db.Column(db.Integer, default=0)
|
|
|
|
group_work_contact_with_client_2 = db.Column(db.Integer, default=0)
|
|
|
|
group_work_management_of_risk_1 = db.Column(db.Integer, default=0)
|
|
|
|
group_work_management_of_risk_2 = db.Column(db.Integer, default=0)
|
|
|
|
group_work_work_methodology_1 = db.Column(db.Integer, default=0)
|
|
|
|
group_work_work_methodology_2 = db.Column(db.Integer, default=0)
|
|
|
|
group_work_management_of_source_code_1 = db.Column(db.Integer, default=0)
|
|
|
|
group_work_management_of_source_code_2 = db.Column(db.Integer, default=0)
|
|
|
|
group_work_devops_1 = db.Column(db.Integer, default=0)
|
|
|
|
group_work_devops_2 = db.Column(db.Integer, default=0)
|
|
|
|
|
|
|
|
products_project_complexity_of_product_1 = db.Column(db.Integer, default=0)
|
|
|
|
products_project_complexity_of_product_2 = db.Column(db.Integer, default=0)
|
|
|
|
products_project_access_to_application_1 = db.Column(db.Integer, default=0)
|
|
|
|
products_project_access_to_application_2 = db.Column(db.Integer, default=0)
|
|
|
|
products_project_security_issues_1 = db.Column(db.Integer, default=0)
|
|
|
|
products_project_security_issues_2 = db.Column(db.Integer, default=0)
|
|
|
|
products_project_access_to_test_application_1 = db.Column(db.Integer, default=0)
|
|
|
|
products_project_access_to_test_application_2 = db.Column(db.Integer, default=0)
|
|
|
|
products_project_acceptance_criteria_1 = db.Column(db.Integer, default=0)
|
|
|
|
products_project_acceptance_criteria_2 = db.Column(db.Integer, default=0)
|
|
|
|
products_project_expected_functionality_1 = db.Column(db.Integer, default=0)
|
|
|
|
products_project_expected_functionality_2 = db.Column(db.Integer, default=0)
|
|
|
|
products_project_promises_well_1 = db.Column(db.Integer, default=0)
|
|
|
|
products_project_promises_well_2 = db.Column(db.Integer, default=0)
|
|
|
|
products_project_has_been_implemented_1 = db.Column(db.Integer, default=0)
|
|
|
|
products_project_has_been_implemented_2 = db.Column(db.Integer, default=0)
|
|
|
|
products_project_is_useful_1 = db.Column(db.Integer, default=0)
|
|
|
|
products_project_is_useful_2 = db.Column(db.Integer, default=0)
|
|
|
|
products_project_prototype_1 = db.Column(db.Integer, default=0)
|
|
|
|
products_project_prototype_2 = db.Column(db.Integer, default=0)
|
|
|
|
products_project_tests_1 = db.Column(db.Integer, default=0)
|
|
|
|
products_project_tests_2 = db.Column(db.Integer, default=0)
|
|
|
|
products_project_technology_1 = db.Column(db.Integer, default=0)
|
|
|
|
products_project_technology_2 = db.Column(db.Integer, default=0)
|
|
|
|
|
|
|
|
|
2023-01-14 01:37:31 +01:00
|
|
|
class Student(Base, Person):
|
2022-05-17 22:16:45 +02:00
|
|
|
__tablename__ = "students"
|
|
|
|
|
2023-01-14 01:37:31 +01:00
|
|
|
index = db.Column(db.Integer, nullable=False)
|
2023-01-14 17:38:03 +01:00
|
|
|
groups = db.relationship(
|
|
|
|
"Group", secondary=students_groups, back_populates="students"
|
|
|
|
)
|
|
|
|
year_group_id = db.Column(db.Integer, db.ForeignKey("year_groups.id"))
|
|
|
|
year_group = db.relationship("YearGroup", backref="students")
|
|
|
|
|
|
|
|
__table__args = db.UniqueConstraint(
|
|
|
|
"index", "year_group_id", name="uc_index_year_group_id"
|
|
|
|
)
|
2022-05-18 17:36:16 +02:00
|
|
|
|
|
|
|
@classmethod
|
2023-01-14 17:38:03 +01:00
|
|
|
def search_by_fullname_and_mode_and_order_by_first_name_or_last_name(
|
|
|
|
cls,
|
|
|
|
year_group_id: int,
|
|
|
|
fullname: str = None,
|
|
|
|
order_by_first_name: str = None,
|
|
|
|
order_by_last_name: str = None,
|
|
|
|
) -> BaseQuery:
|
2023-01-14 01:37:31 +01:00
|
|
|
student_query = cls.query.filter(Student.year_group_id == year_group_id)
|
2022-06-10 18:18:15 +02:00
|
|
|
|
2022-05-18 17:36:16 +02:00
|
|
|
if fullname is not None:
|
2023-01-14 17:38:03 +01:00
|
|
|
student_query = student_query.filter(
|
|
|
|
(Student.first_name + " " + Student.last_name).like(f"{fullname}%")
|
|
|
|
)
|
|
|
|
|
|
|
|
student_query = order_by_column_name(
|
|
|
|
student_query, Student.first_name, order_by_first_name
|
|
|
|
)
|
|
|
|
student_query = order_by_column_name(
|
|
|
|
student_query, Student.last_name, order_by_last_name
|
|
|
|
)
|
2022-05-18 17:36:16 +02:00
|
|
|
|
|
|
|
return student_query
|