mirror of
https://codeberg.org/Mo8it/AdvLabDB.git
synced 2024-12-20 23:41:20 +00:00
Added weightings default and check
This commit is contained in:
parent
bb23670403
commit
43678dd18b
1 changed files with 25 additions and 2 deletions
|
@ -210,6 +210,21 @@ class Experiment(db.Model):
|
||||||
|
|
||||||
__table_args__ = (db.UniqueConstraint(number, program_id),)
|
__table_args__ = (db.UniqueConstraint(number, program_id),)
|
||||||
|
|
||||||
|
def checkWeightings(self, roundWeightings=False):
|
||||||
|
roundedOralWeighting = round(self.oral_weighting, 2)
|
||||||
|
roundedProtocolWeighting = round(self.protocol_weighting, 2)
|
||||||
|
|
||||||
|
weightingSum = round(roundedOralWeighting + roundedProtocolWeighting, 2)
|
||||||
|
|
||||||
|
if weightingSum != 1:
|
||||||
|
raise DataBaseException(
|
||||||
|
f"Oral and protocol weighting (rounded to 2 decimal digits) sum to {weightingSum} and not 1.00!"
|
||||||
|
)
|
||||||
|
|
||||||
|
if roundWeightings:
|
||||||
|
self.oral_weighting = roundedOralWeighting
|
||||||
|
self.protocol_weighting = roundedProtocolWeighting
|
||||||
|
|
||||||
def repr(self):
|
def repr(self):
|
||||||
return f"{self.number} {self.program.repr()}"
|
return f"{self.number} {self.program.repr()}"
|
||||||
|
|
||||||
|
@ -381,10 +396,18 @@ class ExperimentMark(db.Model):
|
||||||
id = db.Column(db.Integer, primary_key=True)
|
id = db.Column(db.Integer, primary_key=True)
|
||||||
|
|
||||||
oral_mark = db.Column(
|
oral_mark = db.Column(
|
||||||
db.Integer, db.CheckConstraint("oral_mark > -1"), db.CheckConstraint("oral_mark < 16"), nullable=True
|
db.Integer,
|
||||||
|
db.CheckConstraint("oral_mark > -1"),
|
||||||
|
db.CheckConstraint("oral_mark < 16"),
|
||||||
|
default=0.5,
|
||||||
|
nullable=True,
|
||||||
)
|
)
|
||||||
protocol_mark = db.Column(
|
protocol_mark = db.Column(
|
||||||
db.Integer, db.CheckConstraint("protocol_mark > -1"), db.CheckConstraint("protocol_mark < 16"), nullable=True
|
db.Integer,
|
||||||
|
db.CheckConstraint("protocol_mark > -1"),
|
||||||
|
db.CheckConstraint("protocol_mark < 16"),
|
||||||
|
default=0.5,
|
||||||
|
nullable=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
edited_by_admin = db.Column(db.Boolean, default=False, nullable=False)
|
edited_by_admin = db.Column(db.Boolean, default=False, nullable=False)
|
||||||
|
|
Loading…
Reference in a new issue