From 21981825a7baab538c478fc05979a97c4a187abf Mon Sep 17 00:00:00 2001 From: Mo8it Date: Tue, 28 Jun 2022 00:57:59 +0200 Subject: [PATCH] Add experiment_marks_missing --- advlabdb/models.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/advlabdb/models.py b/advlabdb/models.py index 445ebba..67bdd0a 100644 --- a/advlabdb/models.py +++ b/advlabdb/models.py @@ -203,6 +203,7 @@ class GroupExperiment(db.Model): # An experiment specified to a group id = db.Column(db.Integer, primary_key=True) note = db.Column(db.Text, nullable=True) + experiment_marks_missing = db.Column(db.Boolean, default=False, nullable=False) semester_experiment_id = db.Column(db.Integer, db.ForeignKey("semester_experiment.id"), nullable=False) semester_experiment = db.relationship("SemesterExperiment", back_populates="group_experiments") @@ -238,6 +239,14 @@ class GroupExperiment(db.Model): for partStudent in group.part_students: db.session.add(ExperimentMark(part_student=partStudent, group_experiment=self)) + def update_experiment_marks_missing(self): + for experiment_mark in self.experiment_marks: + if experiment_mark.final_part_mark is None: + self.experiment_marks_missing = False + return + + self.experiment_marks_missing = True + class Experiment(db.Model): id = db.Column(db.Integer, primary_key=True)