2021-08-07 15:20:30 +02:00
|
|
|
# -*- coding: UTF-8 -*
|
|
|
|
|
|
|
|
"""Notes, décisions de jury, évènements scolaires
|
|
|
|
"""
|
|
|
|
|
2023-04-03 17:40:45 +02:00
|
|
|
import sqlalchemy as sa
|
2021-08-07 15:20:30 +02:00
|
|
|
from app import db
|
2022-02-12 22:57:46 +01:00
|
|
|
import app.scodoc.sco_utils as scu
|
2021-08-07 15:20:30 +02:00
|
|
|
|
|
|
|
|
2021-11-12 22:17:46 +01:00
|
|
|
class BulAppreciations(db.Model):
|
2021-08-07 15:20:30 +02:00
|
|
|
"""Appréciations sur bulletins"""
|
|
|
|
|
2021-11-12 22:17:46 +01:00
|
|
|
__tablename__ = "notes_appreciations"
|
2021-08-07 15:20:30 +02:00
|
|
|
id = db.Column(db.Integer, primary_key=True)
|
|
|
|
date = db.Column(db.DateTime(timezone=True), server_default=db.func.now())
|
|
|
|
etudid = db.Column(
|
|
|
|
db.Integer,
|
2022-05-26 03:55:03 +02:00
|
|
|
db.ForeignKey("identite.id", ondelete="CASCADE"),
|
2021-08-07 15:20:30 +02:00
|
|
|
index=True,
|
|
|
|
)
|
|
|
|
formsemestre_id = db.Column(
|
|
|
|
db.Integer,
|
|
|
|
db.ForeignKey("notes_formsemestre.id"),
|
|
|
|
)
|
2021-08-10 17:12:10 +02:00
|
|
|
author = db.Column(db.Text) # le pseudo (user_name), sans contrainte
|
2021-08-07 15:20:30 +02:00
|
|
|
comment = db.Column(db.Text) # texte libre
|
|
|
|
|
|
|
|
|
|
|
|
class NotesNotes(db.Model):
|
|
|
|
"""Une note"""
|
|
|
|
|
|
|
|
__tablename__ = "notes_notes"
|
|
|
|
__table_args__ = (db.UniqueConstraint("etudid", "evaluation_id"),)
|
|
|
|
id = db.Column(db.Integer, primary_key=True)
|
|
|
|
etudid = db.Column(
|
|
|
|
db.Integer,
|
2022-05-26 03:55:03 +02:00
|
|
|
db.ForeignKey("identite.id", ondelete="CASCADE"),
|
2021-08-07 15:20:30 +02:00
|
|
|
)
|
|
|
|
evaluation_id = db.Column(
|
|
|
|
db.Integer, db.ForeignKey("notes_evaluation.id"), index=True
|
|
|
|
)
|
|
|
|
value = db.Column(db.Float)
|
|
|
|
# infos sur saisie de cette note:
|
|
|
|
comment = db.Column(db.Text) # texte libre
|
|
|
|
date = db.Column(db.DateTime(timezone=True), server_default=db.func.now())
|
|
|
|
uid = db.Column(db.Integer, db.ForeignKey("user.id"))
|
|
|
|
|
2022-07-19 22:17:10 +02:00
|
|
|
def to_dict(self) -> dict:
|
|
|
|
"dict"
|
|
|
|
d = dict(self.__dict__)
|
|
|
|
d.pop("_sa_instance_state", None)
|
|
|
|
return d
|
2022-06-08 16:13:29 +02:00
|
|
|
|
2023-02-02 18:27:15 +01:00
|
|
|
def __repr__(self):
|
|
|
|
"pour debug"
|
|
|
|
from app.models.evaluations import Evaluation
|
|
|
|
|
2023-05-31 12:25:40 +02:00
|
|
|
return f"""<{self.__class__.__name__} {self.id} etudid={self.etudid} v={self.value} {self.date.isoformat()
|
2023-07-11 06:57:38 +02:00
|
|
|
} {db.session.get(Evaluation, self.evaluation_id) if self.evaluation_id else "X" }>"""
|
2023-02-02 18:27:15 +01:00
|
|
|
|
2021-08-07 15:20:30 +02:00
|
|
|
|
|
|
|
class NotesNotesLog(db.Model):
|
|
|
|
"""Historique des modifs sur notes (anciennes entrees de notes_notes)"""
|
|
|
|
|
|
|
|
__tablename__ = "notes_notes_log"
|
|
|
|
id = db.Column(db.Integer, primary_key=True)
|
|
|
|
|
|
|
|
etudid = db.Column(
|
|
|
|
db.Integer,
|
2022-05-26 03:55:03 +02:00
|
|
|
db.ForeignKey("identite.id", ondelete="CASCADE"),
|
2021-08-07 15:20:30 +02:00
|
|
|
)
|
|
|
|
evaluation_id = db.Column(
|
|
|
|
db.Integer,
|
|
|
|
# db.ForeignKey("notes_evaluation.id"),
|
|
|
|
index=True,
|
|
|
|
)
|
|
|
|
value = db.Column(db.Float)
|
|
|
|
# infos sur saisie de cette note:
|
|
|
|
comment = db.Column(db.Text) # texte libre
|
|
|
|
date = db.Column(db.DateTime(timezone=True), server_default=db.func.now())
|
|
|
|
uid = db.Column(db.Integer, db.ForeignKey("user.id"))
|
2022-02-12 22:57:46 +01:00
|
|
|
|
|
|
|
|
|
|
|
def etud_has_notes_attente(etudid, formsemestre_id):
|
|
|
|
"""Vrai si cet etudiant a au moins une note en attente dans ce semestre.
|
2022-03-28 09:50:40 +02:00
|
|
|
(ne compte que les notes en attente dans des évaluations avec coef. non nul).
|
2022-02-12 22:57:46 +01:00
|
|
|
"""
|
2022-03-28 09:50:40 +02:00
|
|
|
cursor = db.session.execute(
|
2023-04-03 17:40:45 +02:00
|
|
|
sa.text(
|
|
|
|
"""SELECT COUNT(*)
|
2022-02-12 22:57:46 +01:00
|
|
|
FROM notes_notes n, notes_evaluation e, notes_moduleimpl m,
|
|
|
|
notes_moduleimpl_inscription i
|
2022-03-29 10:27:11 +02:00
|
|
|
WHERE n.etudid = :etudid
|
|
|
|
and n.value = :code_attente
|
2022-02-12 22:57:46 +01:00
|
|
|
and n.evaluation_id = e.id
|
|
|
|
and e.moduleimpl_id = m.id
|
2022-03-29 10:27:11 +02:00
|
|
|
and m.formsemestre_id = :formsemestre_id
|
2022-02-12 22:57:46 +01:00
|
|
|
and e.coefficient != 0
|
|
|
|
and m.id = i.moduleimpl_id
|
2022-03-29 10:27:11 +02:00
|
|
|
and i.etudid = :etudid
|
2023-04-03 17:40:45 +02:00
|
|
|
"""
|
|
|
|
),
|
2022-02-12 22:57:46 +01:00
|
|
|
{
|
|
|
|
"formsemestre_id": formsemestre_id,
|
|
|
|
"etudid": etudid,
|
|
|
|
"code_attente": scu.NOTES_ATTENTE,
|
|
|
|
},
|
|
|
|
)
|
2022-03-28 09:50:40 +02:00
|
|
|
return cursor.fetchone()[0] > 0
|