Compare commits
127 Commits
Author | SHA1 | Date |
---|---|---|
Emmanuel Viennet | 22d90215a0 | |
Emmanuel Viennet | 043985bff6 | |
Emmanuel Viennet | d20ada1797 | |
Iziram | 778fecabb6 | |
Iziram | fa6f83722e | |
Emmanuel Viennet | baa0412071 | |
Emmanuel Viennet | d51a47b71a | |
Lyanis Souidi | f21ef41de6 | |
Lyanis Souidi | 2d673e7a5d | |
Emmanuel Viennet | 3e43495831 | |
Iziram | a4db8c4ff8 | |
Iziram | 1ac35d04c2 | |
Iziram | 687ac3cf13 | |
Emmanuel Viennet | 18b1f00586 | |
Iziram | 6b985620e9 | |
Iziram | 4d234ba353 | |
Iziram | 5d45fcf656 | |
Iziram | 0a5919b788 | |
Iziram | 09f4525e66 | |
Emmanuel Viennet | 0bc57807de | |
Emmanuel Viennet | 87aaf12d27 | |
Emmanuel Viennet | c8ab9b9b6c | |
Emmanuel Viennet | ad7b48e110 | |
Emmanuel Viennet | f2ce16f161 | |
Emmanuel Viennet | 1ddf9b6ab8 | |
Emmanuel Viennet | 0a2e39cae1 | |
Emmanuel Viennet | a194b4b6e0 | |
Emmanuel Viennet | cbe85dfb7d | |
Emmanuel Viennet | beba69bfe4 | |
Emmanuel Viennet | 41fec29452 | |
Emmanuel Viennet | 9bd05ea241 | |
Emmanuel Viennet | 58b831513d | |
Emmanuel Viennet | b861aba6a3 | |
Emmanuel Viennet | c2443c361f | |
Emmanuel Viennet | ab4731bd43 | |
Emmanuel Viennet | c17bc8b61b | |
Emmanuel Viennet | e44a5ee55d | |
Emmanuel Viennet | a747ed22e2 | |
Emmanuel Viennet | 5d0a932634 | |
Emmanuel Viennet | 2b150cf521 | |
Emmanuel Viennet | 5a5ddcacd7 | |
Emmanuel Viennet | 3f6e65b9da | |
Emmanuel Viennet | 5eba6170a5 | |
Emmanuel Viennet | bd9bf87112 | |
Emmanuel Viennet | a0e2af481f | |
Emmanuel Viennet | 42e8f97441 | |
Emmanuel Viennet | 8ec0171ca0 | |
Emmanuel Viennet | 6dfab2d843 | |
Emmanuel Viennet | 523ec59833 | |
Emmanuel Viennet | bde6325391 | |
Emmanuel Viennet | 0577347622 | |
Emmanuel Viennet | 28d46e413d | |
Emmanuel Viennet | 126ea0741a | |
Emmanuel Viennet | a5b5f49f76 | |
Iziram | b7ab10bf4e | |
Emmanuel Viennet | 3e0b19c4a8 | |
Emmanuel Viennet | 1dd5187fae | |
Iziram | 9a3a7d33b2 | |
Iziram | a7569fe4f5 | |
Iziram | 79e973f06d | |
Emmanuel Viennet | b6940e4882 | |
Emmanuel Viennet | 1f24095c57 | |
Emmanuel Viennet | 0ed2455028 | |
Emmanuel Viennet | b841b2f708 | |
Iziram | 0fa1478138 | |
Iziram | 85ad7b5f29 | |
Emmanuel Viennet | 6bfd461bf2 | |
Emmanuel Viennet | e1f1a95a14 | |
Emmanuel Viennet | 70e3006981 | |
Emmanuel Viennet | bae46c2794 | |
Iziram | b1055a4ebe | |
Iziram | b2ef6a4c53 | |
Iziram | a7c7bd655d | |
Iziram | 1309043a98 | |
Iziram | a75b41ca5f | |
Emmanuel Viennet | 8df25ca02f | |
Emmanuel Viennet | 61f9dddeb6 | |
Emmanuel Viennet | a1f5340935 | |
Emmanuel Viennet | 68128c27d5 | |
Emmanuel Viennet | 8ecaa2bed0 | |
Emmanuel Viennet | 7c61dd8d63 | |
Emmanuel Viennet | f493ba344f | |
Emmanuel Viennet | f5079d9aef | |
Emmanuel Viennet | 55add2ffb3 | |
Emmanuel Viennet | 5865b67652 | |
Emmanuel Viennet | 3c8b088d5e | |
Emmanuel Viennet | 2da359ae41 | |
Emmanuel Viennet | 09ec53f573 | |
Emmanuel Viennet | 3787e0145a | |
Emmanuel Viennet | edf989ee04 | |
Emmanuel Viennet | 203f3a5342 | |
Emmanuel Viennet | 161f8476ca | |
Emmanuel Viennet | d419d75515 | |
Emmanuel Viennet | f23630d7fd | |
Emmanuel Viennet | fa0417f0b1 | |
Emmanuel Viennet | 12256dc3d4 | |
Emmanuel Viennet | 46529917ea | |
Emmanuel Viennet | 2367984848 | |
Emmanuel Viennet | 46c86d2928 | |
Emmanuel Viennet | 715e4f94ee | |
Iziram | b2e6ef63b9 | |
Iziram | 30560e5860 | |
Iziram | 0fbcfb1124 | |
Iziram | 2daae1c9c5 | |
Emmanuel Viennet | 635269ff36 | |
Emmanuel Viennet | 4aa30a40bd | |
Emmanuel Viennet | 03c03f3725 | |
Emmanuel Viennet | 29eb8c297b | |
Emmanuel Viennet | 38032a8c09 | |
Emmanuel Viennet | 2f2d98954c | |
Emmanuel Viennet | 2e5d94f048 | |
Emmanuel Viennet | 1b1b8ebdc4 | |
Iziram | 8ded16b94f | |
Iziram | 5d10ee467e | |
Iziram | 7af0dd1e1e | |
Emmanuel Viennet | dece9a82d1 | |
Iziram | b74d525c28 | |
Iziram | c617ee321a | |
Iziram | 56ec4ba43d | |
Iziram | d14f7e21b7 | |
Iziram | c3cb1da561 | |
Iziram | cce60d432d | |
Iziram | 4386994f7d | |
Iziram | fddfddfa7b | |
Iziram | 39dca32d2e | |
Iziram | e2b9cd3ded | |
Iziram | be227f4a2f |
152
README.md
152
README.md
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
(c) Emmanuel Viennet 1999 - 2024 (voir LICENCE.txt).
|
(c) Emmanuel Viennet 1999 - 2024 (voir LICENCE.txt).
|
||||||
|
|
||||||
Installation: voir instructions à jour sur <https://scodoc.org/GuideInstallDebian11>
|
Installation: voir instructions à jour sur <https://scodoc.org/GuideInstallDebian12>
|
||||||
|
|
||||||
Documentation utilisateur: <https://scodoc.org>
|
Documentation utilisateur: <https://scodoc.org>
|
||||||
|
|
||||||
|
@ -23,7 +23,7 @@ Flask, SQLAlchemy, au lien de Python2/Zope dans les versions précédentes).
|
||||||
|
|
||||||
### Lignes de commandes
|
### Lignes de commandes
|
||||||
|
|
||||||
Voir [https://scodoc.org/GuideConfig](le guide de configuration).
|
Voir [le guide de configuration](https://scodoc.org/GuideConfig).
|
||||||
|
|
||||||
## Organisation des fichiers
|
## Organisation des fichiers
|
||||||
|
|
||||||
|
@ -41,45 +41,41 @@ Ils ne doivent pas être modifiés à la main, sauf certains fichiers de configu
|
||||||
Le répertoire `/opt/scodoc-data` doit être régulièrement sauvegardé.
|
Le répertoire `/opt/scodoc-data` doit être régulièrement sauvegardé.
|
||||||
|
|
||||||
Principaux contenus:
|
Principaux contenus:
|
||||||
|
```
|
||||||
/opt/scodoc-data
|
/opt/scodoc-data
|
||||||
/opt/scodoc-data/log # Fichiers de log ScoDoc
|
/opt/scodoc-data/log # Fichiers de log ScoDoc
|
||||||
/opt/scodoc-data/config # Fichiers de configuration
|
/opt/scodoc-data/config # Fichiers de configuration
|
||||||
.../config/logos # Logos de l'établissement
|
.../config/logos # Logos de l'établissement
|
||||||
.../config/depts # un fichier par département
|
.../config/depts # un fichier par département
|
||||||
/opt/scodoc-data/photos # Photos des étudiants
|
/opt/scodoc-data/photos # Photos des étudiants
|
||||||
/opt/scodoc-data/archives # Archives: PV de jury, maquettes Apogée, fichiers étudiants
|
/opt/scodoc-data/archives # Archives: PV de jury, maquettes Apogée, fichiers étudiants
|
||||||
|
```
|
||||||
## Pour les développeurs
|
## Pour les développeurs
|
||||||
|
|
||||||
### Installation du code
|
### Installation du code
|
||||||
|
|
||||||
Installer ScoDoc 9 normalement ([voir la doc](https://scodoc.org/GuideInstallDebian11)).
|
Installer ScoDoc 9 normalement ([voir la doc](https://scodoc.org/GuideInstallDebian12)).
|
||||||
|
|
||||||
Puis remplacer `/opt/scodoc` par un clone du git.
|
Puis remplacer `/opt/scodoc` par un clone du git.
|
||||||
|
```bash
|
||||||
|
sudo su
|
||||||
|
mv /opt/scodoc /opt/off-scodoc # ou ce que vous voulez
|
||||||
|
apt-get install git # si besoin
|
||||||
|
git clone https://scodoc.org/git/ScoDoc/ScoDoc.git /opt/scodoc
|
||||||
|
# (ou bien utiliser votre clone gitea si vous l'avez déjà créé !)
|
||||||
|
|
||||||
sudo su
|
# Donner ce répertoire à l'utilisateur scodoc:
|
||||||
mv /opt/scodoc /opt/off-scodoc # ou ce que vous voulez
|
chown -R scodoc:scodoc /opt/scodoc
|
||||||
apt-get install git # si besoin
|
```
|
||||||
cd /opt
|
|
||||||
git clone https://scodoc.org/git/viennet/ScoDoc.git
|
|
||||||
# (ou bien utiliser votre clone gitea si vous l'avez déjà créé !)
|
|
||||||
|
|
||||||
# Renommer le répertoire:
|
|
||||||
mv ScoDoc scodoc
|
|
||||||
|
|
||||||
# Et donner ce répertoire à l'utilisateur scodoc:
|
|
||||||
chown -R scodoc.scodoc /opt/scodoc
|
|
||||||
|
|
||||||
Il faut ensuite installer l'environnement et le fichier de configuration:
|
Il faut ensuite installer l'environnement et le fichier de configuration:
|
||||||
|
```bash
|
||||||
# Le plus simple est de piquer le virtualenv configuré par l'installeur:
|
# Le plus simple est de piquer le virtualenv configuré par l'installeur:
|
||||||
mv /opt/off-scodoc/venv /opt/scodoc
|
mv /opt/off-scodoc/venv /opt/scodoc
|
||||||
|
```
|
||||||
Et la config:
|
Et la config:
|
||||||
|
```bash
|
||||||
ln -s /opt/scodoc-data/.env /opt/scodoc
|
ln -s /opt/scodoc-data/.env /opt/scodoc
|
||||||
|
```
|
||||||
Cette dernière commande utilise le `.env` crée lors de l'install, ce qui
|
Cette dernière commande utilise le `.env` crée lors de l'install, ce qui
|
||||||
n'est pas toujours le plus judicieux: vous pouvez modifier son contenu, par
|
n'est pas toujours le plus judicieux: vous pouvez modifier son contenu, par
|
||||||
exemple pour travailler en mode "développement" avec `FLASK_ENV=development`.
|
exemple pour travailler en mode "développement" avec `FLASK_ENV=development`.
|
||||||
|
@ -88,11 +84,11 @@ exemple pour travailler en mode "développement" avec `FLASK_ENV=development`.
|
||||||
|
|
||||||
Les tests unitaires utilisent normalement la base postgresql `SCODOC_TEST`.
|
Les tests unitaires utilisent normalement la base postgresql `SCODOC_TEST`.
|
||||||
Avant le premier lancement, créer cette base ainsi:
|
Avant le premier lancement, créer cette base ainsi:
|
||||||
|
```bash
|
||||||
./tools/create_database.sh SCODOC_TEST
|
./tools/create_database.sh SCODOC_TEST
|
||||||
export FLASK_ENV=test
|
export FLASK_ENV=test
|
||||||
flask db upgrade
|
flask db upgrade
|
||||||
|
```
|
||||||
Cette commande n'est nécessaire que la première fois (le contenu de la base
|
Cette commande n'est nécessaire que la première fois (le contenu de la base
|
||||||
est effacé au début de chaque test, mais son schéma reste) et aussi si des
|
est effacé au début de chaque test, mais son schéma reste) et aussi si des
|
||||||
migrations (changements de schéma) ont eu lieu dans le code.
|
migrations (changements de schéma) ont eu lieu dans le code.
|
||||||
|
@ -100,17 +96,17 @@ migrations (changements de schéma) ont eu lieu dans le code.
|
||||||
Certains tests ont besoin d'un département déjà créé, qui n'est pas créé par les
|
Certains tests ont besoin d'un département déjà créé, qui n'est pas créé par les
|
||||||
scripts de tests:
|
scripts de tests:
|
||||||
Lancer au préalable:
|
Lancer au préalable:
|
||||||
|
```bash
|
||||||
flask delete-dept -fy TEST00 && flask create-dept TEST00
|
flask delete-dept -fy TEST00 && flask create-dept TEST00
|
||||||
|
```
|
||||||
Puis dérouler les tests unitaires:
|
Puis dérouler les tests unitaires:
|
||||||
|
```bash
|
||||||
pytest tests/unit
|
pytest tests/unit
|
||||||
|
```
|
||||||
Ou avec couverture (`pip install pytest-cov`)
|
Ou avec couverture (`pip install pytest-cov`)
|
||||||
|
```bash
|
||||||
pytest --cov=app --cov-report=term-missing --cov-branch tests/unit/*
|
pytest --cov=app --cov-report=term-missing --cov-branch tests/unit/*
|
||||||
|
```
|
||||||
#### Utilisation des tests unitaires pour initialiser la base de dev
|
#### Utilisation des tests unitaires pour initialiser la base de dev
|
||||||
|
|
||||||
On peut aussi utiliser les tests unitaires pour mettre la base de données de
|
On peut aussi utiliser les tests unitaires pour mettre la base de données de
|
||||||
|
@ -119,43 +115,43 @@ développement dans un état connu, par exemple pour éviter de recréer à la m
|
||||||
|
|
||||||
Il suffit de positionner une variable d'environnement indiquant la BD utilisée
|
Il suffit de positionner une variable d'environnement indiquant la BD utilisée
|
||||||
par les tests:
|
par les tests:
|
||||||
|
```bash
|
||||||
export SCODOC_TEST_DATABASE_URI=postgresql:///SCODOC_DEV
|
export SCODOC_TEST_DATABASE_URI=postgresql:///SCODOC_DEV
|
||||||
|
```
|
||||||
(si elle n'existe pas, voir plus loin pour la créer) puis de les lancer
|
(si elle n'existe pas, voir plus loin pour la créer) puis de les lancer
|
||||||
normalement, par exemple:
|
normalement, par exemple:
|
||||||
|
```bash
|
||||||
pytest tests/unit/test_sco_basic.py
|
pytest tests/unit/test_sco_basic.py
|
||||||
|
```
|
||||||
Il est en général nécessaire d'affecter ensuite un mot de passe à (au moins) un
|
Il est en général nécessaire d'affecter ensuite un mot de passe à (au moins) un
|
||||||
utilisateur:
|
utilisateur:
|
||||||
|
```bash
|
||||||
flask user-password admin
|
flask user-password admin
|
||||||
|
```
|
||||||
**Attention:** les tests unitaires **effacent** complètement le contenu de la
|
**Attention:** les tests unitaires **effacent** complètement le contenu de la
|
||||||
base de données (tous les départements, et les utilisateurs) avant de commencer !
|
base de données (tous les départements, et les utilisateurs) avant de commencer !
|
||||||
|
|
||||||
#### Modification du schéma de la base
|
#### Modification du schéma de la base
|
||||||
|
|
||||||
On utilise SQLAlchemy avec Alembic et Flask-Migrate.
|
On utilise SQLAlchemy avec Alembic et Flask-Migrate.
|
||||||
|
```bash
|
||||||
flask db migrate -m "message explicatif....."
|
flask db migrate -m "message explicatif....."
|
||||||
flask db upgrade
|
flask db upgrade
|
||||||
|
```
|
||||||
Ne pas oublier de d'ajouter le script de migration à git (`git add migrations/...`).
|
Ne pas oublier de d'ajouter le script de migration à git (`git add migrations/...`).
|
||||||
|
|
||||||
**Mémo**: séquence re-création d'une base (vérifiez votre `.env`
|
**Mémo**: séquence re-création d'une base (vérifiez votre `.env`
|
||||||
ou variables d'environnement pour interroger la bonne base !).
|
ou variables d'environnement pour interroger la bonne base !).
|
||||||
|
```bash
|
||||||
|
dropdb SCODOC_DEV
|
||||||
|
tools/create_database.sh SCODOC_DEV # créé base SQL
|
||||||
|
flask db upgrade # créé les tables à partir des migrations
|
||||||
|
flask sco-db-init # ajoute au besoin les constantes (fait en migration 0)
|
||||||
|
|
||||||
dropdb SCODOC_DEV
|
# puis imports:
|
||||||
tools/create_database.sh SCODOC_DEV # créé base SQL
|
flask import-scodoc7-users
|
||||||
flask db upgrade # créé les tables à partir des migrations
|
flask import-scodoc7-dept STID SCOSTID
|
||||||
flask sco-db-init # ajoute au besoin les constantes (fait en migration 0)
|
```
|
||||||
|
|
||||||
# puis imports:
|
|
||||||
flask import-scodoc7-users
|
|
||||||
flask import-scodoc7-dept STID SCOSTID
|
|
||||||
|
|
||||||
Si la base utilisée pour les dev n'est plus en phase avec les scripts de
|
Si la base utilisée pour les dev n'est plus en phase avec les scripts de
|
||||||
migration, utiliser les commandes `flask db history`et `flask db stamp`pour se
|
migration, utiliser les commandes `flask db history`et `flask db stamp`pour se
|
||||||
positionner à la bonne étape.
|
positionner à la bonne étape.
|
||||||
|
@ -163,23 +159,23 @@ positionner à la bonne étape.
|
||||||
### Profiling
|
### Profiling
|
||||||
|
|
||||||
Sur une machine de DEV, lancer
|
Sur une machine de DEV, lancer
|
||||||
|
```bash
|
||||||
flask profile --host 0.0.0.0 --length 32 --profile-dir /opt/scodoc-data
|
flask profile --host 0.0.0.0 --length 32 --profile-dir /opt/scodoc-data
|
||||||
|
```
|
||||||
le fichier `.prof` sera alors écrit dans `/opt/scodoc-data` (on peut aussi utiliser `/tmp`).
|
le fichier `.prof` sera alors écrit dans `/opt/scodoc-data` (on peut aussi utiliser `/tmp`).
|
||||||
|
|
||||||
Pour la visualisation, [snakeviz](https://jiffyclub.github.io/snakeviz/) est bien:
|
Pour la visualisation, [snakeviz](https://jiffyclub.github.io/snakeviz/) est bien:
|
||||||
|
```bash
|
||||||
pip install snakeviz
|
pip install snakeviz
|
||||||
|
```
|
||||||
puis
|
puis
|
||||||
|
```bash
|
||||||
snakeviz -s --hostname 0.0.0.0 -p 5555 /opt/scodoc-data/GET.ScoDoc......prof
|
snakeviz -s --hostname 0.0.0.0 -p 5555 /opt/scodoc-data/GET.ScoDoc......prof
|
||||||
|
```
|
||||||
## Paquet Debian 12
|
## Paquet Debian 12
|
||||||
|
|
||||||
Les scripts associés au paquet Debian (.deb) sont dans `tools/debian`. Le plus
|
Les scripts associés au paquet Debian (.deb) sont dans `tools/debian`. Le plus
|
||||||
important est `postinst`qui se charge de configurer le système (install ou
|
important est `postinst` qui se charge de configurer le système (install ou
|
||||||
upgrade de scodoc9).
|
upgrade de scodoc9).
|
||||||
|
|
||||||
La préparation d'une release se fait à l'aide du script
|
La préparation d'une release se fait à l'aide du script
|
||||||
|
|
|
@ -315,12 +315,6 @@ def create_app(config_class=DevConfig):
|
||||||
app.register_error_handler(503, postgresql_server_error)
|
app.register_error_handler(503, postgresql_server_error)
|
||||||
app.register_error_handler(APIInvalidParams, handle_invalid_usage)
|
app.register_error_handler(APIInvalidParams, handle_invalid_usage)
|
||||||
|
|
||||||
# Add some globals
|
|
||||||
# previously in Flask-Bootstrap:
|
|
||||||
app.jinja_env.globals["bootstrap_is_hidden_field"] = lambda field: isinstance(
|
|
||||||
field, HiddenField
|
|
||||||
)
|
|
||||||
|
|
||||||
from app.auth import bp as auth_bp
|
from app.auth import bp as auth_bp
|
||||||
|
|
||||||
app.register_blueprint(auth_bp, url_prefix="/auth")
|
app.register_blueprint(auth_bp, url_prefix="/auth")
|
||||||
|
@ -338,8 +332,15 @@ def create_app(config_class=DevConfig):
|
||||||
from app.api import api_bp
|
from app.api import api_bp
|
||||||
from app.api import api_web_bp
|
from app.api import api_web_bp
|
||||||
|
|
||||||
|
# Jinja2 configuration
|
||||||
# Enable autoescaping of all templates, including .j2
|
# Enable autoescaping of all templates, including .j2
|
||||||
app.jinja_env.autoescape = select_autoescape(default_for_string=True, default=True)
|
app.jinja_env.autoescape = select_autoescape(default_for_string=True, default=True)
|
||||||
|
app.jinja_env.trim_blocks = True
|
||||||
|
app.jinja_env.lstrip_blocks = True
|
||||||
|
# previously in Flask-Bootstrap:
|
||||||
|
app.jinja_env.globals["bootstrap_is_hidden_field"] = lambda field: isinstance(
|
||||||
|
field, HiddenField
|
||||||
|
)
|
||||||
|
|
||||||
# https://scodoc.fr/ScoDoc
|
# https://scodoc.fr/ScoDoc
|
||||||
app.register_blueprint(scodoc_bp)
|
app.register_blueprint(scodoc_bp)
|
||||||
|
|
|
@ -3,14 +3,15 @@
|
||||||
# Copyright (c) 1999 - 2024 Emmanuel Viennet. All rights reserved.
|
# Copyright (c) 1999 - 2024 Emmanuel Viennet. All rights reserved.
|
||||||
# See LICENSE
|
# See LICENSE
|
||||||
##############################################################################
|
##############################################################################
|
||||||
"""ScoDoc 9 API : Assiduités
|
"""ScoDoc 9 API : Assiduités"""
|
||||||
"""
|
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
|
||||||
from flask import g, request
|
from flask import g, request
|
||||||
from flask_json import as_json
|
from flask_json import as_json
|
||||||
from flask_login import current_user, login_required
|
from flask_login import current_user, login_required
|
||||||
from flask_sqlalchemy.query import Query
|
from flask_sqlalchemy.query import Query
|
||||||
|
from sqlalchemy.orm.exc import ObjectDeletedError
|
||||||
|
|
||||||
from app import db, log, set_sco_dept
|
from app import db, log, set_sco_dept
|
||||||
import app.scodoc.sco_assiduites as scass
|
import app.scodoc.sco_assiduites as scass
|
||||||
|
@ -858,7 +859,10 @@ def assiduite_edit(assiduite_id: int):
|
||||||
msg=f"assiduite: modif {assiduite_unique}",
|
msg=f"assiduite: modif {assiduite_unique}",
|
||||||
)
|
)
|
||||||
db.session.commit()
|
db.session.commit()
|
||||||
scass.simple_invalidate_cache(assiduite_unique.to_dict())
|
try:
|
||||||
|
scass.simple_invalidate_cache(assiduite_unique.to_dict())
|
||||||
|
except ObjectDeletedError:
|
||||||
|
return json_error(404, "Assiduité supprimée / inexistante")
|
||||||
|
|
||||||
return {"OK": True}
|
return {"OK": True}
|
||||||
|
|
||||||
|
|
|
@ -329,6 +329,8 @@ def desassoc_ue_niveau(ue_id: int):
|
||||||
ue.niveau_competence = None
|
ue.niveau_competence = None
|
||||||
db.session.add(ue)
|
db.session.add(ue)
|
||||||
db.session.commit()
|
db.session.commit()
|
||||||
|
# Invalidation du cache
|
||||||
|
ue.formation.invalidate_cached_sems()
|
||||||
log(f"desassoc_ue_niveau: {ue}")
|
log(f"desassoc_ue_niveau: {ue}")
|
||||||
if g.scodoc_dept:
|
if g.scodoc_dept:
|
||||||
# "usage web"
|
# "usage web"
|
||||||
|
|
|
@ -38,7 +38,7 @@ from app.scodoc import sco_groups
|
||||||
from app.scodoc.sco_permissions import Permission
|
from app.scodoc.sco_permissions import Permission
|
||||||
from app.scodoc.sco_utils import ModuleType
|
from app.scodoc.sco_utils import ModuleType
|
||||||
import app.scodoc.sco_utils as scu
|
import app.scodoc.sco_utils as scu
|
||||||
from app.tables.recap import TableRecap
|
from app.tables.recap import TableRecap, RowRecap
|
||||||
|
|
||||||
|
|
||||||
@bp.route("/formsemestre/<int:formsemestre_id>")
|
@bp.route("/formsemestre/<int:formsemestre_id>")
|
||||||
|
@ -543,16 +543,30 @@ def formsemestre_resultat(formsemestre_id: int):
|
||||||
formsemestre: FormSemestre = query.first_or_404(formsemestre_id)
|
formsemestre: FormSemestre = query.first_or_404(formsemestre_id)
|
||||||
app.set_sco_dept(formsemestre.departement.acronym)
|
app.set_sco_dept(formsemestre.departement.acronym)
|
||||||
res: NotesTableCompat = res_sem.load_formsemestre_results(formsemestre)
|
res: NotesTableCompat = res_sem.load_formsemestre_results(formsemestre)
|
||||||
table = TableRecap(
|
# Ajoute le groupe de chaque partition,
|
||||||
res, convert_values=convert_values, include_evaluations=False, mode_jury=False
|
|
||||||
)
|
|
||||||
# Supprime les champs inutiles (mise en forme)
|
|
||||||
rows = table.to_list()
|
|
||||||
# Ajoute le groupe de chaque partition:
|
|
||||||
etud_groups = sco_groups.get_formsemestre_etuds_groups(formsemestre_id)
|
etud_groups = sco_groups.get_formsemestre_etuds_groups(formsemestre_id)
|
||||||
for row in rows:
|
|
||||||
row["partitions"] = etud_groups.get(row["etudid"], {})
|
|
||||||
|
|
||||||
|
class RowRecapAPI(RowRecap):
|
||||||
|
"""Pour table avec partitions et sort_key"""
|
||||||
|
|
||||||
|
def add_etud_cols(self):
|
||||||
|
"""Ajoute colonnes étudiant: codes, noms"""
|
||||||
|
super().add_etud_cols()
|
||||||
|
self.add_cell("partitions", "partitions", etud_groups.get(self.etud.id, {}))
|
||||||
|
self.add_cell("sort_key", "sort_key", self.etud.sort_key)
|
||||||
|
|
||||||
|
table = TableRecap(
|
||||||
|
res,
|
||||||
|
convert_values=convert_values,
|
||||||
|
include_evaluations=False,
|
||||||
|
mode_jury=False,
|
||||||
|
row_class=RowRecapAPI,
|
||||||
|
)
|
||||||
|
|
||||||
|
rows = table.to_list()
|
||||||
|
|
||||||
|
# for row in rows:
|
||||||
|
# row["partitions"] = etud_groups.get(row["etudid"], {})
|
||||||
return rows
|
return rows
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -603,8 +603,19 @@ class Role(db.Model):
|
||||||
"""Create default roles if missing, then, if reset_permissions,
|
"""Create default roles if missing, then, if reset_permissions,
|
||||||
reset their permissions to default values.
|
reset their permissions to default values.
|
||||||
"""
|
"""
|
||||||
|
Role.reset_roles_permissions(
|
||||||
|
SCO_ROLES_DEFAULTS, reset_permissions=reset_permissions
|
||||||
|
)
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def reset_roles_permissions(roles_perms: dict[str, tuple], reset_permissions=True):
|
||||||
|
"""Ajoute les permissions aux roles
|
||||||
|
roles_perms : { "role_name" : (permission, ...) }
|
||||||
|
reset_permissions : si vrai efface permissions déja existantes
|
||||||
|
Si le role n'existe pas, il est (re) créé.
|
||||||
|
"""
|
||||||
default_role = "Observateur"
|
default_role = "Observateur"
|
||||||
for role_name, permissions in SCO_ROLES_DEFAULTS.items():
|
for role_name, permissions in roles_perms.items():
|
||||||
role = Role.query.filter_by(name=role_name).first()
|
role = Role.query.filter_by(name=role_name).first()
|
||||||
if role is None:
|
if role is None:
|
||||||
role = Role(name=role_name)
|
role = Role(name=role_name)
|
||||||
|
|
|
@ -21,7 +21,7 @@ def form_ue_choix_parcours(ue: UniteEns) -> str:
|
||||||
return ""
|
return ""
|
||||||
ref_comp = ue.formation.referentiel_competence
|
ref_comp = ue.formation.referentiel_competence
|
||||||
if ref_comp is None:
|
if ref_comp is None:
|
||||||
return f"""<div class="ue_advanced">
|
return f"""<div class="scobox ue_advanced">
|
||||||
<div class="warning">Pas de référentiel de compétence associé à cette formation !</div>
|
<div class="warning">Pas de référentiel de compétence associé à cette formation !</div>
|
||||||
<div><a class="stdlink" href="{ url_for('notes.refcomp_assoc_formation',
|
<div><a class="stdlink" href="{ url_for('notes.refcomp_assoc_formation',
|
||||||
scodoc_dept=g.scodoc_dept, formation_id=ue.formation.id)
|
scodoc_dept=g.scodoc_dept, formation_id=ue.formation.id)
|
||||||
|
@ -31,19 +31,28 @@ def form_ue_choix_parcours(ue: UniteEns) -> str:
|
||||||
|
|
||||||
H = [
|
H = [
|
||||||
"""
|
"""
|
||||||
<div class="ue_advanced">
|
<div class="scobox ue_advanced">
|
||||||
<h3>Parcours du BUT</h3>
|
<div class="scobox-title">Parcours du BUT</div>
|
||||||
"""
|
"""
|
||||||
]
|
]
|
||||||
# Choix des parcours
|
# Choix des parcours
|
||||||
ue_pids = [p.id for p in ue.parcours]
|
ue_pids = [p.id for p in ue.parcours]
|
||||||
H.append("""<form id="choix_parcours">""")
|
H.append(
|
||||||
|
"""
|
||||||
|
<div class="help">
|
||||||
|
Cocher tous les parcours dans lesquels cette UE est utilisée,
|
||||||
|
même si vous n'offrez pas ce parcours dans votre département.
|
||||||
|
Sans quoi, les UEs de Tronc Commun ne seront pas reconnues.
|
||||||
|
Ne cocher aucun parcours est équivalent à tous les cocher.
|
||||||
|
</div>
|
||||||
|
<form id="choix_parcours" style="margin-top: 12px;">
|
||||||
|
"""
|
||||||
|
)
|
||||||
|
|
||||||
ects_differents = {
|
ects_differents = {
|
||||||
ue.get_ects(parcour, only_parcours=True) for parcour in ref_comp.parcours
|
ue.get_ects(parcour, only_parcours=True) for parcour in ref_comp.parcours
|
||||||
} != {None}
|
} != {None}
|
||||||
for parcour in ref_comp.parcours:
|
for parcour in ref_comp.parcours:
|
||||||
ects_parcour = ue.get_ects(parcour)
|
|
||||||
ects_parcour_txt = (
|
ects_parcour_txt = (
|
||||||
f" ({ue.get_ects(parcour):.3g} ects)" if ects_differents else ""
|
f" ({ue.get_ects(parcour):.3g} ects)" if ects_differents else ""
|
||||||
)
|
)
|
||||||
|
|
|
@ -9,12 +9,14 @@
|
||||||
|
|
||||||
import collections
|
import collections
|
||||||
import datetime
|
import datetime
|
||||||
|
import pandas as pd
|
||||||
import numpy as np
|
import numpy as np
|
||||||
from flask import g, has_request_context, url_for
|
from flask import g, has_request_context, url_for
|
||||||
|
|
||||||
from app import db
|
from app import db
|
||||||
|
from app.comp.moy_mod import ModuleImplResults
|
||||||
from app.comp.res_but import ResultatsSemestreBUT
|
from app.comp.res_but import ResultatsSemestreBUT
|
||||||
from app.models import Evaluation, FormSemestre, Identite
|
from app.models import Evaluation, FormSemestre, Identite, ModuleImpl
|
||||||
from app.models.groups import GroupDescr
|
from app.models.groups import GroupDescr
|
||||||
from app.models.ues import UniteEns
|
from app.models.ues import UniteEns
|
||||||
from app.scodoc import sco_bulletins, sco_utils as scu
|
from app.scodoc import sco_bulletins, sco_utils as scu
|
||||||
|
@ -229,7 +231,7 @@ class BulletinBUT:
|
||||||
if res.modimpl_inscr_df[modimpl.id][etud.id]: # si inscrit
|
if res.modimpl_inscr_df[modimpl.id][etud.id]: # si inscrit
|
||||||
d[modimpl.module.code] = {
|
d[modimpl.module.code] = {
|
||||||
"id": modimpl.id,
|
"id": modimpl.id,
|
||||||
"titre": modimpl.module.titre,
|
"titre": modimpl.module.titre_str(),
|
||||||
"code_apogee": modimpl.module.code_apogee,
|
"code_apogee": modimpl.module.code_apogee,
|
||||||
"url": (
|
"url": (
|
||||||
url_for(
|
url_for(
|
||||||
|
@ -249,59 +251,88 @@ class BulletinBUT:
|
||||||
# "moy": fmt_note(moyennes_etuds.mean()),
|
# "moy": fmt_note(moyennes_etuds.mean()),
|
||||||
},
|
},
|
||||||
"evaluations": (
|
"evaluations": (
|
||||||
[
|
self.etud_list_modimpl_evaluations(
|
||||||
self.etud_eval_results(etud, e)
|
etud, modimpl, modimpl_results, version
|
||||||
for e in modimpl.evaluations
|
)
|
||||||
if (e.visibulletin or version == "long")
|
|
||||||
and (e.id in modimpl_results.evaluations_etat)
|
|
||||||
and (
|
|
||||||
modimpl_results.evaluations_etat[e.id].is_complete
|
|
||||||
or self.prefs["bul_show_all_evals"]
|
|
||||||
)
|
|
||||||
]
|
|
||||||
if version != "short"
|
if version != "short"
|
||||||
else []
|
else []
|
||||||
),
|
),
|
||||||
}
|
}
|
||||||
return d
|
return d
|
||||||
|
|
||||||
def etud_eval_results(self, etud, e: Evaluation) -> dict:
|
def etud_list_modimpl_evaluations(
|
||||||
|
self,
|
||||||
|
etud: Identite,
|
||||||
|
modimpl: ModuleImpl,
|
||||||
|
modimpl_results: ModuleImplResults,
|
||||||
|
version: str,
|
||||||
|
) -> list[dict]:
|
||||||
|
"""Liste des résultats aux évaluations de ce modimpl à montrer pour cet étudiant"""
|
||||||
|
evaluation: Evaluation
|
||||||
|
eval_results = []
|
||||||
|
for evaluation in modimpl.evaluations:
|
||||||
|
if (
|
||||||
|
(evaluation.visibulletin or version == "long")
|
||||||
|
and (evaluation.id in modimpl_results.evaluations_etat)
|
||||||
|
and (
|
||||||
|
modimpl_results.evaluations_etat[evaluation.id].is_complete
|
||||||
|
or self.prefs["bul_show_all_evals"]
|
||||||
|
)
|
||||||
|
):
|
||||||
|
eval_notes = self.res.modimpls_results[modimpl.id].evals_notes[
|
||||||
|
evaluation.id
|
||||||
|
]
|
||||||
|
|
||||||
|
if (evaluation.evaluation_type == Evaluation.EVALUATION_NORMALE) or (
|
||||||
|
not np.isnan(eval_notes[etud.id])
|
||||||
|
):
|
||||||
|
eval_results.append(
|
||||||
|
self.etud_eval_results(etud, evaluation, eval_notes)
|
||||||
|
)
|
||||||
|
return eval_results
|
||||||
|
|
||||||
|
def etud_eval_results(
|
||||||
|
self, etud: Identite, evaluation: Evaluation, eval_notes: pd.DataFrame
|
||||||
|
) -> dict:
|
||||||
"dict resultats d'un étudiant à une évaluation"
|
"dict resultats d'un étudiant à une évaluation"
|
||||||
# eval_notes est une pd.Series avec toutes les notes des étudiants inscrits
|
# eval_notes est une pd.Series avec toutes les notes des étudiants inscrits
|
||||||
eval_notes = self.res.modimpls_results[e.moduleimpl_id].evals_notes[e.id]
|
|
||||||
notes_ok = eval_notes.where(eval_notes > scu.NOTES_ABSENCE).dropna()
|
notes_ok = eval_notes.where(eval_notes > scu.NOTES_ABSENCE).dropna()
|
||||||
modimpls_evals_poids = self.res.modimpls_evals_poids[e.moduleimpl_id]
|
modimpls_evals_poids = self.res.modimpls_evals_poids[evaluation.moduleimpl_id]
|
||||||
try:
|
try:
|
||||||
etud_ues_ids = self.res.etud_ues_ids(etud.id)
|
etud_ues_ids = self.res.etud_ues_ids(etud.id)
|
||||||
poids = {
|
poids = {
|
||||||
ue.acronyme: modimpls_evals_poids[ue.id][e.id]
|
ue.acronyme: modimpls_evals_poids[ue.id][evaluation.id]
|
||||||
for ue in self.res.ues
|
for ue in self.res.ues
|
||||||
if (ue.type != UE_SPORT) and (ue.id in etud_ues_ids)
|
if (ue.type != UE_SPORT) and (ue.id in etud_ues_ids)
|
||||||
}
|
}
|
||||||
except KeyError:
|
except KeyError:
|
||||||
poids = collections.defaultdict(lambda: 0.0)
|
poids = collections.defaultdict(lambda: 0.0)
|
||||||
d = {
|
d = {
|
||||||
"id": e.id,
|
"id": evaluation.id,
|
||||||
"coef": (
|
"coef": (
|
||||||
fmt_note(e.coefficient)
|
fmt_note(evaluation.coefficient)
|
||||||
if e.evaluation_type == Evaluation.EVALUATION_NORMALE
|
if evaluation.evaluation_type == Evaluation.EVALUATION_NORMALE
|
||||||
else None
|
else None
|
||||||
),
|
),
|
||||||
"date_debut": e.date_debut.isoformat() if e.date_debut else None,
|
"date_debut": (
|
||||||
"date_fin": e.date_fin.isoformat() if e.date_fin else None,
|
evaluation.date_debut.isoformat() if evaluation.date_debut else None
|
||||||
"description": e.description,
|
),
|
||||||
"evaluation_type": e.evaluation_type,
|
"date_fin": (
|
||||||
|
evaluation.date_fin.isoformat() if evaluation.date_fin else None
|
||||||
|
),
|
||||||
|
"description": evaluation.description,
|
||||||
|
"evaluation_type": evaluation.evaluation_type,
|
||||||
"note": (
|
"note": (
|
||||||
{
|
{
|
||||||
"value": fmt_note(
|
"value": fmt_note(
|
||||||
eval_notes[etud.id],
|
eval_notes[etud.id],
|
||||||
note_max=e.note_max,
|
note_max=evaluation.note_max,
|
||||||
),
|
),
|
||||||
"min": fmt_note(notes_ok.min(), note_max=e.note_max),
|
"min": fmt_note(notes_ok.min(), note_max=evaluation.note_max),
|
||||||
"max": fmt_note(notes_ok.max(), note_max=e.note_max),
|
"max": fmt_note(notes_ok.max(), note_max=evaluation.note_max),
|
||||||
"moy": fmt_note(notes_ok.mean(), note_max=e.note_max),
|
"moy": fmt_note(notes_ok.mean(), note_max=evaluation.note_max),
|
||||||
}
|
}
|
||||||
if not e.is_blocked()
|
if not evaluation.is_blocked()
|
||||||
else {}
|
else {}
|
||||||
),
|
),
|
||||||
"poids": poids,
|
"poids": poids,
|
||||||
|
@ -309,17 +340,25 @@ class BulletinBUT:
|
||||||
url_for(
|
url_for(
|
||||||
"notes.evaluation_listenotes",
|
"notes.evaluation_listenotes",
|
||||||
scodoc_dept=g.scodoc_dept,
|
scodoc_dept=g.scodoc_dept,
|
||||||
evaluation_id=e.id,
|
evaluation_id=evaluation.id,
|
||||||
)
|
)
|
||||||
if has_request_context()
|
if has_request_context()
|
||||||
else "na"
|
else "na"
|
||||||
),
|
),
|
||||||
# deprecated (supprimer avant #sco9.7)
|
# deprecated (supprimer avant #sco9.7)
|
||||||
"date": e.date_debut.isoformat() if e.date_debut else None,
|
"date": (
|
||||||
"heure_debut": (
|
evaluation.date_debut.isoformat() if evaluation.date_debut else None
|
||||||
e.date_debut.time().isoformat("minutes") if e.date_debut else None
|
),
|
||||||
|
"heure_debut": (
|
||||||
|
evaluation.date_debut.time().isoformat("minutes")
|
||||||
|
if evaluation.date_debut
|
||||||
|
else None
|
||||||
|
),
|
||||||
|
"heure_fin": (
|
||||||
|
evaluation.date_fin.time().isoformat("minutes")
|
||||||
|
if evaluation.date_fin
|
||||||
|
else None
|
||||||
),
|
),
|
||||||
"heure_fin": e.date_fin.time().isoformat("minutes") if e.date_fin else None,
|
|
||||||
}
|
}
|
||||||
return d
|
return d
|
||||||
|
|
||||||
|
@ -540,9 +579,9 @@ class BulletinBUT:
|
||||||
|
|
||||||
d.update(infos)
|
d.update(infos)
|
||||||
# --- Rangs
|
# --- Rangs
|
||||||
d[
|
d["rang_nt"] = (
|
||||||
"rang_nt"
|
f"{d['semestre']['rang']['value']} / {d['semestre']['rang']['total']}"
|
||||||
] = f"{d['semestre']['rang']['value']} / {d['semestre']['rang']['total']}"
|
)
|
||||||
d["rang_txt"] = "Rang " + d["rang_nt"]
|
d["rang_txt"] = "Rang " + d["rang_nt"]
|
||||||
|
|
||||||
d.update(sco_bulletins.make_context_dict(self.res.formsemestre, d["etud"]))
|
d.update(sco_bulletins.make_context_dict(self.res.formsemestre, d["etud"]))
|
||||||
|
|
|
@ -31,6 +31,7 @@ from app.scodoc.sco_bulletins_standard import BulletinGeneratorStandard
|
||||||
from app.scodoc.sco_logos import Logo
|
from app.scodoc.sco_logos import Logo
|
||||||
from app.scodoc.sco_pdf import PDFLOCK, SU
|
from app.scodoc.sco_pdf import PDFLOCK, SU
|
||||||
from app.scodoc.sco_preferences import SemPreferences
|
from app.scodoc.sco_preferences import SemPreferences
|
||||||
|
from app.scodoc import sco_utils as scu
|
||||||
|
|
||||||
|
|
||||||
def make_bulletin_but_court_pdf(
|
def make_bulletin_but_court_pdf(
|
||||||
|
@ -343,9 +344,11 @@ class BulletinGeneratorBUTCourt(BulletinGeneratorStandard):
|
||||||
for mod in self.bul[mod_type]:
|
for mod in self.bul[mod_type]:
|
||||||
row = [mod, bul[mod_type][mod]["titre"]]
|
row = [mod, bul[mod_type][mod]["titre"]]
|
||||||
row += [
|
row += [
|
||||||
bul["ues"][ue][mod_type][mod]["moyenne"]
|
(
|
||||||
if mod in bul["ues"][ue][mod_type]
|
bul["ues"][ue][mod_type][mod]["moyenne"]
|
||||||
else ""
|
if mod in bul["ues"][ue][mod_type]
|
||||||
|
else ""
|
||||||
|
)
|
||||||
for ue in self.ues_acronyms
|
for ue in self.ues_acronyms
|
||||||
]
|
]
|
||||||
rows.append(row)
|
rows.append(row)
|
||||||
|
@ -523,7 +526,7 @@ class BulletinGeneratorBUTCourt(BulletinGeneratorStandard):
|
||||||
if self.bul["semestre"].get("decision_annee", None):
|
if self.bul["semestre"].get("decision_annee", None):
|
||||||
txt += f"""
|
txt += f"""
|
||||||
Décision saisie le {
|
Décision saisie le {
|
||||||
datetime.datetime.fromisoformat(self.bul["semestre"]["decision_annee"]["date"]).strftime("%d/%m/%Y")
|
datetime.datetime.fromisoformat(self.bul["semestre"]["decision_annee"]["date"]).strftime(scu.DATE_FMT)
|
||||||
}, année BUT{self.bul["semestre"]["decision_annee"]["ordre"]}
|
}, année BUT{self.bul["semestre"]["decision_annee"]["ordre"]}
|
||||||
<b>{self.bul["semestre"]["decision_annee"]["code"]}</b>.
|
<b>{self.bul["semestre"]["decision_annee"]["code"]}</b>.
|
||||||
<br/>
|
<br/>
|
||||||
|
|
|
@ -269,7 +269,7 @@ class BulletinGeneratorStandardBUT(BulletinGeneratorStandard):
|
||||||
date_capitalisation = ue.get("date_capitalisation")
|
date_capitalisation = ue.get("date_capitalisation")
|
||||||
if date_capitalisation:
|
if date_capitalisation:
|
||||||
fields_bmr.append(
|
fields_bmr.append(
|
||||||
f"""Capitalisée le {date_capitalisation.strftime("%d/%m/%Y")}"""
|
f"""Capitalisée le {date_capitalisation.strftime(scu.DATE_FMT)}"""
|
||||||
)
|
)
|
||||||
t = {
|
t = {
|
||||||
"titre": " - ".join(fields_bmr),
|
"titre": " - ".join(fields_bmr),
|
||||||
|
@ -427,12 +427,11 @@ class BulletinGeneratorStandardBUT(BulletinGeneratorStandard):
|
||||||
if e["evaluation_type"] == Evaluation.EVALUATION_NORMALE
|
if e["evaluation_type"] == Evaluation.EVALUATION_NORMALE
|
||||||
else "*"
|
else "*"
|
||||||
)
|
)
|
||||||
|
note_value = e["note"].get("value", "")
|
||||||
t = {
|
t = {
|
||||||
"titre": f"{e['description'] or ''}",
|
"titre": f"{e['description'] or ''}",
|
||||||
"moyenne": e["note"]["value"],
|
"moyenne": note_value,
|
||||||
"_moyenne_pdf": Paragraph(
|
"_moyenne_pdf": Paragraph(f"""<para align=right>{note_value}</para>"""),
|
||||||
f"""<para align=right>{e["note"]["value"]}</para>"""
|
|
||||||
),
|
|
||||||
"coef": coef,
|
"coef": coef,
|
||||||
"_coef_pdf": Paragraph(
|
"_coef_pdf": Paragraph(
|
||||||
f"""<para align=right fontSize={self.small_fontsize}><i>{
|
f"""<para align=right fontSize={self.small_fontsize}><i>{
|
||||||
|
|
|
@ -0,0 +1,92 @@
|
||||||
|
##############################################################################
|
||||||
|
# ScoDoc
|
||||||
|
# Copyright (c) 1999 - 2024 Emmanuel Viennet. All rights reserved.
|
||||||
|
# See LICENSE
|
||||||
|
##############################################################################
|
||||||
|
|
||||||
|
"""Code expérimental: si deux référentiel sont presques identiques
|
||||||
|
(mêmes compétences, niveaux, parcours)
|
||||||
|
essaie de changer une formation de référentiel.
|
||||||
|
"""
|
||||||
|
|
||||||
|
from app import clear_scodoc_cache, db
|
||||||
|
|
||||||
|
from app.models import (
|
||||||
|
ApcParcours,
|
||||||
|
ApcReferentielCompetences,
|
||||||
|
ApcValidationRCUE,
|
||||||
|
Formation,
|
||||||
|
FormSemestreInscription,
|
||||||
|
UniteEns,
|
||||||
|
)
|
||||||
|
from app.scodoc.sco_exceptions import ScoValueError
|
||||||
|
|
||||||
|
|
||||||
|
def formation_change_referentiel(
|
||||||
|
formation: Formation, new_ref: ApcReferentielCompetences
|
||||||
|
):
|
||||||
|
"""Try to change ref."""
|
||||||
|
if not formation.referentiel_competence:
|
||||||
|
raise ScoValueError("formation non associée à un référentiel")
|
||||||
|
if not isinstance(new_ref, ApcReferentielCompetences):
|
||||||
|
raise ScoValueError("nouveau référentiel invalide")
|
||||||
|
|
||||||
|
r = formation.referentiel_competence.map_to_other_referentiel(new_ref)
|
||||||
|
if isinstance(r, str):
|
||||||
|
raise ScoValueError(f"référentiels incompatibles: {r}")
|
||||||
|
parcours_map, competences_map, niveaux_map = r
|
||||||
|
|
||||||
|
formation.referentiel_competence = new_ref
|
||||||
|
db.session.add(formation)
|
||||||
|
# UEs - Niveaux et UEs - parcours
|
||||||
|
for ue in formation.ues:
|
||||||
|
if ue.niveau_competence:
|
||||||
|
ue.niveau_competence_id = niveaux_map[ue.niveau_competence_id]
|
||||||
|
db.session.add(ue)
|
||||||
|
if ue.parcours:
|
||||||
|
new_list = [ApcParcours.query.get(parcours_map[p.id]) for p in ue.parcours]
|
||||||
|
ue.parcours.clear()
|
||||||
|
ue.parcours.extend(new_list)
|
||||||
|
db.session.add(ue)
|
||||||
|
# Modules / parcours et app_critiques
|
||||||
|
for module in formation.modules:
|
||||||
|
if module.parcours:
|
||||||
|
new_list = [
|
||||||
|
ApcParcours.query.get(parcours_map[p.id]) for p in module.parcours
|
||||||
|
]
|
||||||
|
module.parcours.clear()
|
||||||
|
module.parcours.extend(new_list)
|
||||||
|
db.session.add(module)
|
||||||
|
if module.app_critiques: # efface les apprentissages critiques
|
||||||
|
module.app_critiques.clear()
|
||||||
|
db.session.add(module)
|
||||||
|
# ApcValidationRCUE
|
||||||
|
for valid_rcue in ApcValidationRCUE.query.join(
|
||||||
|
UniteEns, UniteEns.id == ApcValidationRCUE.ue1_id
|
||||||
|
).filter_by(formation_id=formation.id):
|
||||||
|
if valid_rcue.parcour:
|
||||||
|
valid_rcue.parcour_id = parcours_map[valid_rcue.parcour.id]
|
||||||
|
db.session.add(valid_rcue)
|
||||||
|
for valid_rcue in ApcValidationRCUE.query.join(
|
||||||
|
UniteEns, UniteEns.id == ApcValidationRCUE.ue2_id
|
||||||
|
).filter_by(formation_id=formation.id):
|
||||||
|
if valid_rcue.parcour:
|
||||||
|
valid_rcue.parcour_id = parcours_map[valid_rcue.parcour.id]
|
||||||
|
db.session.add(valid_rcue)
|
||||||
|
# FormSemestre / parcours_formsemestre
|
||||||
|
for formsemestre in formation.formsemestres:
|
||||||
|
new_list = [
|
||||||
|
ApcParcours.query.get(parcours_map[p.id]) for p in formsemestre.parcours
|
||||||
|
]
|
||||||
|
formsemestre.parcours.clear()
|
||||||
|
formsemestre.parcours.extend(new_list)
|
||||||
|
db.session.add(formsemestre)
|
||||||
|
# FormSemestreInscription.parcour_id
|
||||||
|
for inscr in FormSemestreInscription.query.filter_by(
|
||||||
|
formsemestre_id=formsemestre.id
|
||||||
|
).filter(FormSemestreInscription.parcour_id != None):
|
||||||
|
if inscr.parcour_id is not None:
|
||||||
|
inscr.parcour_id = parcours_map[inscr.parcour_id]
|
||||||
|
#
|
||||||
|
db.session.commit()
|
||||||
|
clear_scodoc_cache()
|
|
@ -542,9 +542,9 @@ def formation_semestre_niveaux_warning(formation: Formation, semestre_idx: int)
|
||||||
for parcour_code, niveaux in niveaux_sans_ue_by_parcour.items():
|
for parcour_code, niveaux in niveaux_sans_ue_by_parcour.items():
|
||||||
H.append(
|
H.append(
|
||||||
f"""<li>Parcours {parcour_code} : {
|
f"""<li>Parcours {parcour_code} : {
|
||||||
len(niveaux)} niveaux sans UEs
|
len(niveaux)} niveaux sans UEs :
|
||||||
<span>
|
<span class="niveau-nom"><span>
|
||||||
{ ', '.join( f'{niveau.competence.titre} {niveau.ordre}'
|
{ '</span>, <span>'.join( f'{niveau.competence.titre} {niveau.ordre}'
|
||||||
for niveau in niveaux
|
for niveau in niveaux
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,9 +10,11 @@
|
||||||
from flask_wtf import FlaskForm
|
from flask_wtf import FlaskForm
|
||||||
from flask_wtf.file import FileField, FileAllowed
|
from flask_wtf.file import FileField, FileAllowed
|
||||||
from wtforms import SelectField, SubmitField
|
from wtforms import SelectField, SubmitField
|
||||||
|
from wtforms.validators import DataRequired
|
||||||
|
|
||||||
|
|
||||||
class FormationRefCompForm(FlaskForm):
|
class FormationRefCompForm(FlaskForm):
|
||||||
|
"Choix d'un référentiel"
|
||||||
referentiel_competence = SelectField(
|
referentiel_competence = SelectField(
|
||||||
"Choisir parmi les référentiels déjà chargés :"
|
"Choisir parmi les référentiels déjà chargés :"
|
||||||
)
|
)
|
||||||
|
@ -21,6 +23,7 @@ class FormationRefCompForm(FlaskForm):
|
||||||
|
|
||||||
|
|
||||||
class RefCompLoadForm(FlaskForm):
|
class RefCompLoadForm(FlaskForm):
|
||||||
|
"Upload d'un référentiel"
|
||||||
referentiel_standard = SelectField(
|
referentiel_standard = SelectField(
|
||||||
"Choisir un référentiel de compétences officiel BUT"
|
"Choisir un référentiel de compétences officiel BUT"
|
||||||
)
|
)
|
||||||
|
@ -47,3 +50,12 @@ class RefCompLoadForm(FlaskForm):
|
||||||
)
|
)
|
||||||
return False
|
return False
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
|
class FormationChangeRefCompForm(FlaskForm):
|
||||||
|
"choix d'un nouveau ref. comp. pour une formation"
|
||||||
|
object_select = SelectField(
|
||||||
|
"Choisir le nouveau référentiel", validators=[DataRequired()]
|
||||||
|
)
|
||||||
|
submit = SubmitField("Changer le référentiel de la formation")
|
||||||
|
cancel = SubmitField("Annuler")
|
||||||
|
|
|
@ -77,7 +77,7 @@ from app.models.but_refcomp import (
|
||||||
ApcNiveau,
|
ApcNiveau,
|
||||||
ApcParcours,
|
ApcParcours,
|
||||||
)
|
)
|
||||||
from app.models import Evaluation, Scolog, ScolarAutorisationInscription
|
from app.models import Evaluation, ModuleImpl, Scolog, ScolarAutorisationInscription
|
||||||
from app.models.but_validations import (
|
from app.models.but_validations import (
|
||||||
ApcValidationAnnee,
|
ApcValidationAnnee,
|
||||||
ApcValidationRCUE,
|
ApcValidationRCUE,
|
||||||
|
@ -413,12 +413,12 @@ class DecisionsProposeesAnnee(DecisionsProposees):
|
||||||
# Si validée par niveau supérieur:
|
# Si validée par niveau supérieur:
|
||||||
if self.code_valide == sco_codes.ADSUP:
|
if self.code_valide == sco_codes.ADSUP:
|
||||||
self.codes.insert(0, sco_codes.ADSUP)
|
self.codes.insert(0, sco_codes.ADSUP)
|
||||||
self.explanation = f"<div>{explanation}</div>"
|
self.explanation = f'<div class="deca-expl">{explanation}</div>'
|
||||||
messages = self.descr_pb_coherence()
|
messages = self.descr_pb_coherence()
|
||||||
if messages:
|
if messages:
|
||||||
self.explanation += (
|
self.explanation += (
|
||||||
'<div class="warning">'
|
'<div class="warning warning-info">'
|
||||||
+ '</div><div class="warning">'.join(messages)
|
+ '</div><div class="warning warning-info">'.join(messages)
|
||||||
+ "</div>"
|
+ "</div>"
|
||||||
)
|
)
|
||||||
self.codes = [self.codes[0]] + sorted((c or "") for c in self.codes[1:])
|
self.codes = [self.codes[0]] + sorted((c or "") for c in self.codes[1:])
|
||||||
|
@ -796,16 +796,33 @@ class DecisionsProposeesAnnee(DecisionsProposees):
|
||||||
if self.formsemestre_pair is not None:
|
if self.formsemestre_pair is not None:
|
||||||
sco_cache.invalidate_formsemestre(formsemestre_id=self.formsemestre_pair.id)
|
sco_cache.invalidate_formsemestre(formsemestre_id=self.formsemestre_pair.id)
|
||||||
|
|
||||||
def has_notes_en_attente(self) -> bool:
|
def _get_current_res(self) -> ResultatsSemestreBUT:
|
||||||
"Vrai si l'étudiant a au moins une note en attente dans le semestre origine de ce deca"
|
"Les res. du semestre d'origine du deca"
|
||||||
res = (
|
return (
|
||||||
self.res_pair
|
self.res_pair
|
||||||
if self.formsemestre_pair
|
if self.formsemestre_pair
|
||||||
and (self.formsemestre.id == self.formsemestre_pair.id)
|
and (self.formsemestre.id == self.formsemestre_pair.id)
|
||||||
else self.res_impair
|
else self.res_impair
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def has_notes_en_attente(self) -> bool:
|
||||||
|
"Vrai si l'étudiant a au moins une note en attente dans le semestre origine de ce deca"
|
||||||
|
res = self._get_current_res()
|
||||||
return res and self.etud.id in res.get_etudids_attente()
|
return res and self.etud.id in res.get_etudids_attente()
|
||||||
|
|
||||||
|
def get_modimpls_attente(self) -> list[ModuleImpl]:
|
||||||
|
"Liste des ModuleImpl dans lesquels l'étudiant à au moins une note en ATTente"
|
||||||
|
res = self._get_current_res()
|
||||||
|
modimpls_results = [
|
||||||
|
modimpl_result
|
||||||
|
for modimpl_result in res.modimpls_results.values()
|
||||||
|
if self.etud.id in modimpl_result.etudids_attente
|
||||||
|
]
|
||||||
|
modimpls = [
|
||||||
|
db.session.get(ModuleImpl, mr.moduleimpl_id) for mr in modimpls_results
|
||||||
|
]
|
||||||
|
return sorted(modimpls, key=lambda mi: (mi.module.numero, mi.module.code))
|
||||||
|
|
||||||
def record_all(self, only_validantes: bool = False) -> bool:
|
def record_all(self, only_validantes: bool = False) -> bool:
|
||||||
"""Enregistre les codes qui n'ont pas été spécifiés par le formulaire,
|
"""Enregistre les codes qui n'ont pas été spécifiés par le formulaire,
|
||||||
et sont donc en mode "automatique".
|
et sont donc en mode "automatique".
|
||||||
|
@ -997,19 +1014,23 @@ class DecisionsProposeesAnnee(DecisionsProposees):
|
||||||
if dec_ue.code_valide not in CODES_UE_VALIDES:
|
if dec_ue.code_valide not in CODES_UE_VALIDES:
|
||||||
if (
|
if (
|
||||||
dec_ue.ue_status
|
dec_ue.ue_status
|
||||||
and dec_ue.ue_status["was_capitalized"]
|
and dec_ue.ue_status["is_capitalized"]
|
||||||
):
|
):
|
||||||
messages.append(
|
messages.append(
|
||||||
f"Information: l'UE {ue.acronyme} capitalisée est utilisée pour un RCUE cette année"
|
f"Information: l'UE {ue.acronyme} capitalisée est utilisée pour un RCUE cette année"
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
messages.append(
|
messages.append(
|
||||||
f"L'UE {ue.acronyme} n'est pas validée mais son RCUE l'est !"
|
f"L'UE {ue.acronyme} n'est pas validée mais son RCUE l'est (probablement une validation antérieure)"
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
messages.append(
|
messages.append(
|
||||||
f"L'UE {ue.acronyme} n'a pas décision (???)"
|
f"L'UE {ue.acronyme} n'a pas décision (???)"
|
||||||
)
|
)
|
||||||
|
# Voyons si on est dispensé de cette ue ?
|
||||||
|
res = self.res_impair if ue.semestre_idx % 2 else self.res_pair
|
||||||
|
if res and (self.etud.id, ue.id) in res.dispense_ues:
|
||||||
|
messages.append(f"Pas (ré)inscrit à l'UE {ue.acronyme}")
|
||||||
return messages
|
return messages
|
||||||
|
|
||||||
def valide_diplome(self) -> bool:
|
def valide_diplome(self) -> bool:
|
||||||
|
@ -1514,7 +1535,7 @@ class DecisionsProposeesUE(DecisionsProposees):
|
||||||
|
|
||||||
def __repr__(self) -> str:
|
def __repr__(self) -> str:
|
||||||
return f"""<{self.__class__.__name__} ue={self.ue.acronyme} valid={self.code_valide
|
return f"""<{self.__class__.__name__} ue={self.ue.acronyme} valid={self.code_valide
|
||||||
} codes={self.codes} explanation={self.explanation}>"""
|
} codes={self.codes} explanation="{self.explanation}">"""
|
||||||
|
|
||||||
def compute_codes(self):
|
def compute_codes(self):
|
||||||
"""Calcul des .codes attribuables et de l'explanation associée"""
|
"""Calcul des .codes attribuables et de l'explanation associée"""
|
||||||
|
|
|
@ -55,11 +55,21 @@ def pvjury_page_but(formsemestre_id: int, fmt="html"):
|
||||||
else:
|
else:
|
||||||
line_sep = "\n"
|
line_sep = "\n"
|
||||||
rows, titles = pvjury_table_but(formsemestre, line_sep=line_sep)
|
rows, titles = pvjury_table_but(formsemestre, line_sep=line_sep)
|
||||||
|
if fmt.startswith("xls"):
|
||||||
|
titles.update(
|
||||||
|
{
|
||||||
|
"etudid": "etudid",
|
||||||
|
"code_nip": "nip",
|
||||||
|
"code_ine": "ine",
|
||||||
|
"ects_but": "Total ECTS BUT",
|
||||||
|
"civilite": "Civ.",
|
||||||
|
"nom": "Nom",
|
||||||
|
"prenom": "Prénom",
|
||||||
|
}
|
||||||
|
)
|
||||||
# Style excel... passages à la ligne sur \n
|
# Style excel... passages à la ligne sur \n
|
||||||
xls_style_base = sco_excel.excel_make_style()
|
xls_style_base = sco_excel.excel_make_style()
|
||||||
xls_style_base["alignment"] = Alignment(wrapText=True, vertical="top")
|
xls_style_base["alignment"] = Alignment(wrapText=True, vertical="top")
|
||||||
|
|
||||||
tab = GenTable(
|
tab = GenTable(
|
||||||
base_url=f"{request.base_url}?formsemestre_id={formsemestre_id}",
|
base_url=f"{request.base_url}?formsemestre_id={formsemestre_id}",
|
||||||
caption=title,
|
caption=title,
|
||||||
|
@ -116,7 +126,7 @@ def pvjury_table_but(
|
||||||
"pas de référentiel de compétences associé à la formation de ce semestre !"
|
"pas de référentiel de compétences associé à la formation de ce semestre !"
|
||||||
)
|
)
|
||||||
titles = {
|
titles = {
|
||||||
"nom": "Code" if anonymous else "Nom",
|
"nom_pv": "Code" if anonymous else "Nom",
|
||||||
"cursus": "Cursus",
|
"cursus": "Cursus",
|
||||||
"ects": "ECTS",
|
"ects": "ECTS",
|
||||||
"ues": "UE validées",
|
"ues": "UE validées",
|
||||||
|
@ -144,33 +154,47 @@ def pvjury_table_but(
|
||||||
except ScoValueError:
|
except ScoValueError:
|
||||||
deca = None
|
deca = None
|
||||||
|
|
||||||
|
ects_but_valides = but_ects_valides(etud, referentiel_competence_id)
|
||||||
row = {
|
row = {
|
||||||
"nom": etud.code_ine or etud.code_nip or etud.id
|
"nom_pv": (
|
||||||
if anonymous # Mode anonyme: affiche INE ou sinon NIP, ou id
|
etud.code_ine or etud.code_nip or etud.id
|
||||||
else etud.etat_civil_pv(
|
if anonymous # Mode anonyme: affiche INE ou sinon NIP, ou id
|
||||||
line_sep=line_sep, with_paragraph=with_paragraph_nom
|
else etud.etat_civil_pv(
|
||||||
|
line_sep=line_sep, with_paragraph=with_paragraph_nom
|
||||||
|
)
|
||||||
),
|
),
|
||||||
"_nom_order": etud.sort_key,
|
"_nom_pv_order": etud.sort_key,
|
||||||
"_nom_target_attrs": f'class="etudinfo" id="{etud.id}"',
|
"_nom_pv_target_attrs": f'class="etudinfo" id="{etud.id}"',
|
||||||
"_nom_td_attrs": f'id="{etud.id}" class="etudinfo"',
|
"_nom_pv_td_attrs": f'id="{etud.id}" class="etudinfo"',
|
||||||
"_nom_target": url_for(
|
"_nom_pv_target": url_for(
|
||||||
"scolar.fiche_etud",
|
"scolar.fiche_etud",
|
||||||
scodoc_dept=g.scodoc_dept,
|
scodoc_dept=g.scodoc_dept,
|
||||||
etudid=etud.id,
|
etudid=etud.id,
|
||||||
),
|
),
|
||||||
"cursus": _descr_cursus_but(etud),
|
"cursus": _descr_cursus_but(etud),
|
||||||
"ects": f"""{deca.ects_annee():g}<br><br>Tot. {but_ects_valides(etud, referentiel_competence_id ):g}""",
|
"ects": f"""{deca.ects_annee():g}<br><br>Tot. {ects_but_valides:g}""",
|
||||||
|
"_ects_xls": deca.ects_annee(),
|
||||||
|
"ects_but": ects_but_valides,
|
||||||
"ues": deca.descr_ues_validation(line_sep=line_sep) if deca else "-",
|
"ues": deca.descr_ues_validation(line_sep=line_sep) if deca else "-",
|
||||||
"niveaux": deca.descr_niveaux_validation(line_sep=line_sep)
|
"niveaux": (
|
||||||
if deca
|
deca.descr_niveaux_validation(line_sep=line_sep) if deca else "-"
|
||||||
else "-",
|
),
|
||||||
"decision_but": deca.code_valide if deca else "",
|
"decision_but": deca.code_valide if deca else "",
|
||||||
"devenir": ", ".join([f"S{i}" for i in deca.get_autorisations_passage()])
|
"devenir": (
|
||||||
if deca
|
", ".join([f"S{i}" for i in deca.get_autorisations_passage()])
|
||||||
else "",
|
if deca
|
||||||
|
else ""
|
||||||
|
),
|
||||||
|
# pour exports excel seulement:
|
||||||
|
"civilite": etud.civilite_etat_civil_str,
|
||||||
|
"nom": etud.nom,
|
||||||
|
"prenom": etud.prenom_etat_civil or etud.prenom or "",
|
||||||
|
"etudid": etud.id,
|
||||||
|
"code_nip": etud.code_nip,
|
||||||
|
"code_ine": etud.code_ine,
|
||||||
}
|
}
|
||||||
if deca.valide_diplome() or not only_diplome:
|
if deca.valide_diplome() or not only_diplome:
|
||||||
rows.append(row)
|
rows.append(row)
|
||||||
|
|
||||||
rows.sort(key=lambda x: x["_nom_order"])
|
rows.sort(key=lambda x: x["_nom_pv_order"])
|
||||||
return rows, titles
|
return rows, titles
|
||||||
|
|
|
@ -16,8 +16,8 @@ from app.scodoc.sco_exceptions import ScoValueError
|
||||||
|
|
||||||
|
|
||||||
def formsemestre_validation_auto_but(
|
def formsemestre_validation_auto_but(
|
||||||
formsemestre: FormSemestre, only_adm: bool = True
|
formsemestre: FormSemestre, only_adm: bool = True, dry_run=False
|
||||||
) -> int:
|
) -> tuple[int, list[jury_but.DecisionsProposeesAnnee]]:
|
||||||
"""Calcul automatique des décisions de jury sur une "année" BUT.
|
"""Calcul automatique des décisions de jury sur une "année" BUT.
|
||||||
|
|
||||||
- N'enregistre jamais de décisions de l'année scolaire précédente, même
|
- N'enregistre jamais de décisions de l'année scolaire précédente, même
|
||||||
|
@ -27,16 +27,22 @@ def formsemestre_validation_auto_but(
|
||||||
En revanche, si only_adm est faux, on enregistre la première décision proposée par ScoDoc
|
En revanche, si only_adm est faux, on enregistre la première décision proposée par ScoDoc
|
||||||
(mode à n'utiliser que pour les tests unitaires vérifiant la saisie des jurys)
|
(mode à n'utiliser que pour les tests unitaires vérifiant la saisie des jurys)
|
||||||
|
|
||||||
Returns: nombre d'étudiants pour lesquels on a enregistré au moins un code.
|
Returns:
|
||||||
|
- En mode normal, (nombre d'étudiants pour lesquels on a enregistré au moins un code, []])
|
||||||
|
- En mode dry_run, (0, list[DecisionsProposeesAnnee])
|
||||||
"""
|
"""
|
||||||
if not formsemestre.formation.is_apc():
|
if not formsemestre.formation.is_apc():
|
||||||
raise ScoValueError("fonction réservée aux formations BUT")
|
raise ScoValueError("fonction réservée aux formations BUT")
|
||||||
nb_etud_modif = 0
|
nb_etud_modif = 0
|
||||||
|
decas = []
|
||||||
with sco_cache.DeferredSemCacheManager():
|
with sco_cache.DeferredSemCacheManager():
|
||||||
for etudid in formsemestre.etuds_inscriptions:
|
for etudid in formsemestre.etuds_inscriptions:
|
||||||
etud = Identite.get_etud(etudid)
|
etud = Identite.get_etud(etudid)
|
||||||
deca = jury_but.DecisionsProposeesAnnee(etud, formsemestre)
|
deca = jury_but.DecisionsProposeesAnnee(etud, formsemestre)
|
||||||
nb_etud_modif += deca.record_all(only_validantes=only_adm)
|
if not dry_run:
|
||||||
|
nb_etud_modif += deca.record_all(only_validantes=only_adm)
|
||||||
|
else:
|
||||||
|
decas.append(deca)
|
||||||
|
|
||||||
db.session.commit()
|
db.session.commit()
|
||||||
ScolarNews.add(
|
ScolarNews.add(
|
||||||
|
@ -49,4 +55,4 @@ def formsemestre_validation_auto_but(
|
||||||
formsemestre_id=formsemestre.id,
|
formsemestre_id=formsemestre.id,
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
return nb_etud_modif
|
return nb_etud_modif, decas
|
||||||
|
|
|
@ -21,8 +21,6 @@ from app.but.jury_but import (
|
||||||
DecisionsProposeesRCUE,
|
DecisionsProposeesRCUE,
|
||||||
DecisionsProposeesUE,
|
DecisionsProposeesUE,
|
||||||
)
|
)
|
||||||
from app.comp import res_sem
|
|
||||||
from app.comp.res_but import ResultatsSemestreBUT
|
|
||||||
from app.models import (
|
from app.models import (
|
||||||
ApcNiveau,
|
ApcNiveau,
|
||||||
FormSemestre,
|
FormSemestre,
|
||||||
|
@ -33,11 +31,8 @@ from app.models import (
|
||||||
ScolarFormSemestreValidation,
|
ScolarFormSemestreValidation,
|
||||||
ScolarNews,
|
ScolarNews,
|
||||||
)
|
)
|
||||||
from app.models.config import ScoDocSiteConfig
|
|
||||||
from app.scodoc import html_sco_header
|
|
||||||
from app.scodoc import codes_cursus as sco_codes
|
from app.scodoc import codes_cursus as sco_codes
|
||||||
from app.scodoc.sco_exceptions import ScoValueError
|
from app.scodoc.sco_exceptions import ScoValueError
|
||||||
from app.scodoc import sco_preferences
|
|
||||||
from app.scodoc import sco_utils as scu
|
from app.scodoc import sco_utils as scu
|
||||||
|
|
||||||
|
|
||||||
|
@ -109,23 +104,32 @@ def show_etud(deca: DecisionsProposeesAnnee, read_only: bool = True) -> str:
|
||||||
</div>"""
|
</div>"""
|
||||||
)
|
)
|
||||||
ue_impair, ue_pair = rcue.ue_1, rcue.ue_2
|
ue_impair, ue_pair = rcue.ue_1, rcue.ue_2
|
||||||
# Les UEs à afficher,
|
# Les UEs à afficher : on regarde si read only et si dispense (non ré-inscription à l'UE)
|
||||||
# qui
|
# tuples (UniteEns, read_only, dispense)
|
||||||
ues_ro = [
|
ues_ro_dispense = [
|
||||||
(
|
(
|
||||||
ue_impair,
|
ue_impair,
|
||||||
rcue.ue_cur_impair is None,
|
rcue.ue_cur_impair is None,
|
||||||
|
deca.res_impair
|
||||||
|
and ue_impair
|
||||||
|
and (deca.etud.id, ue_impair.id) in deca.res_impair.dispense_ues,
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
ue_pair,
|
ue_pair,
|
||||||
rcue.ue_cur_pair is None,
|
rcue.ue_cur_pair is None,
|
||||||
|
deca.res_pair
|
||||||
|
and ue_pair
|
||||||
|
and (deca.etud.id, ue_pair.id) in deca.res_pair.dispense_ues,
|
||||||
),
|
),
|
||||||
]
|
]
|
||||||
# Ordonne selon les dates des 2 semestres considérés:
|
# Ordonne selon les dates des 2 semestres considérés:
|
||||||
if reverse_semestre:
|
if reverse_semestre:
|
||||||
ues_ro[0], ues_ro[1] = ues_ro[1], ues_ro[0]
|
ues_ro_dispense[0], ues_ro_dispense[1] = (
|
||||||
|
ues_ro_dispense[1],
|
||||||
|
ues_ro_dispense[0],
|
||||||
|
)
|
||||||
# Colonnes d'UE:
|
# Colonnes d'UE:
|
||||||
for ue, ue_read_only in ues_ro:
|
for ue, ue_read_only, ue_dispense in ues_ro_dispense:
|
||||||
if ue:
|
if ue:
|
||||||
H.append(
|
H.append(
|
||||||
_gen_but_niveau_ue(
|
_gen_but_niveau_ue(
|
||||||
|
@ -134,6 +138,7 @@ def show_etud(deca: DecisionsProposeesAnnee, read_only: bool = True) -> str:
|
||||||
disabled=read_only or ue_read_only,
|
disabled=read_only or ue_read_only,
|
||||||
annee_prec=ue_read_only,
|
annee_prec=ue_read_only,
|
||||||
niveau_id=ue.niveau_competence.id,
|
niveau_id=ue.niveau_competence.id,
|
||||||
|
ue_dispense=ue_dispense,
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
|
@ -188,21 +193,30 @@ def _gen_but_niveau_ue(
|
||||||
disabled: bool = False,
|
disabled: bool = False,
|
||||||
annee_prec: bool = False,
|
annee_prec: bool = False,
|
||||||
niveau_id: int = None,
|
niveau_id: int = None,
|
||||||
|
ue_dispense: bool = False,
|
||||||
) -> str:
|
) -> str:
|
||||||
if dec_ue.ue_status and dec_ue.ue_status["is_capitalized"]:
|
if dec_ue.ue_status and dec_ue.ue_status["is_capitalized"]:
|
||||||
moy_ue_str = f"""<span class="ue_cap">{
|
moy_ue_str = f"""<span class="ue_cap">{
|
||||||
scu.fmt_note(dec_ue.moy_ue_with_cap)}</span>"""
|
scu.fmt_note(dec_ue.moy_ue_with_cap)}</span>"""
|
||||||
scoplement = f"""<div class="scoplement">
|
|
||||||
<div>
|
if ue_dispense:
|
||||||
<b>UE {ue.acronyme} capitalisée </b>
|
etat_en_cours = """Non (ré)inscrit à cette UE"""
|
||||||
<span>le {dec_ue.ue_status["event_date"].strftime("%d/%m/%Y")}
|
else:
|
||||||
</span>
|
etat_en_cours = f"""UE en cours
|
||||||
</div>
|
|
||||||
<div>UE en cours
|
|
||||||
{ "sans notes" if np.isnan(dec_ue.moy_ue)
|
{ "sans notes" if np.isnan(dec_ue.moy_ue)
|
||||||
else
|
else
|
||||||
("avec moyenne <b>" + scu.fmt_note(dec_ue.moy_ue) + "</b>")
|
("avec moyenne <b>" + scu.fmt_note(dec_ue.moy_ue) + "</b>")
|
||||||
}
|
}
|
||||||
|
"""
|
||||||
|
|
||||||
|
scoplement = f"""<div class="scoplement">
|
||||||
|
<div>
|
||||||
|
<b>UE {ue.acronyme} capitalisée </b>
|
||||||
|
<span>le {dec_ue.ue_status["event_date"].strftime(scu.DATE_FMT)}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
{ etat_en_cours }
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
"""
|
"""
|
||||||
|
@ -214,7 +228,7 @@ def _gen_but_niveau_ue(
|
||||||
<div>
|
<div>
|
||||||
<b>UE {ue.acronyme} antérieure </b>
|
<b>UE {ue.acronyme} antérieure </b>
|
||||||
<span>validée {dec_ue.validation.code}
|
<span>validée {dec_ue.validation.code}
|
||||||
le {dec_ue.validation.event_date.strftime("%d/%m/%Y")}
|
le {dec_ue.validation.event_date.strftime(scu.DATE_FMT)}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
<div>Non reprise dans l'année en cours</div>
|
<div>Non reprise dans l'année en cours</div>
|
||||||
|
@ -232,9 +246,7 @@ def _gen_but_niveau_ue(
|
||||||
moy_ue_str = f"""<span>{scu.fmt_note(dec_ue.moy_ue)}</span>"""
|
moy_ue_str = f"""<span>{scu.fmt_note(dec_ue.moy_ue)}</span>"""
|
||||||
if dec_ue.code_valide:
|
if dec_ue.code_valide:
|
||||||
date_str = (
|
date_str = (
|
||||||
f"""enregistré le {dec_ue.validation.event_date.strftime("%d/%m/%Y")}
|
f"""enregistré le {dec_ue.validation.event_date.strftime(scu.DATEATIME_FMT)}"""
|
||||||
à {dec_ue.validation.event_date.strftime("%Hh%M")}
|
|
||||||
"""
|
|
||||||
if dec_ue.validation and dec_ue.validation.event_date
|
if dec_ue.validation and dec_ue.validation.event_date
|
||||||
else ""
|
else ""
|
||||||
)
|
)
|
||||||
|
@ -244,7 +256,13 @@ def _gen_but_niveau_ue(
|
||||||
</div>
|
</div>
|
||||||
"""
|
"""
|
||||||
else:
|
else:
|
||||||
scoplement = ""
|
if dec_ue.ue_status and dec_ue.ue_status["was_capitalized"]:
|
||||||
|
scoplement = """<div class="scoplement">
|
||||||
|
UE déjà capitalisée avec résultat moins favorable.
|
||||||
|
</div>
|
||||||
|
"""
|
||||||
|
else:
|
||||||
|
scoplement = ""
|
||||||
|
|
||||||
ue_class = "" # 'recorded' if dec_ue.code_valide is not None else ''
|
ue_class = "" # 'recorded' if dec_ue.code_valide is not None else ''
|
||||||
if dec_ue.code_valide is not None and dec_ue.codes:
|
if dec_ue.code_valide is not None and dec_ue.codes:
|
||||||
|
|
|
@ -75,7 +75,7 @@ class RegroupementCoherentUE:
|
||||||
else None
|
else None
|
||||||
)
|
)
|
||||||
|
|
||||||
# Autres validations pour l'UE paire
|
# Autres validations pour les UEs paire/impaire
|
||||||
self.validation_ue_best_pair = best_autre_ue_validation(
|
self.validation_ue_best_pair = best_autre_ue_validation(
|
||||||
etud.id,
|
etud.id,
|
||||||
niveau.id,
|
niveau.id,
|
||||||
|
@ -101,14 +101,24 @@ class RegroupementCoherentUE:
|
||||||
"résultats formsemestre de l'UE si elle est courante, None sinon"
|
"résultats formsemestre de l'UE si elle est courante, None sinon"
|
||||||
self.ue_status_impair = None
|
self.ue_status_impair = None
|
||||||
if self.ue_cur_impair:
|
if self.ue_cur_impair:
|
||||||
|
# UE courante
|
||||||
ue_status = res_impair.get_etud_ue_status(etud.id, self.ue_cur_impair.id)
|
ue_status = res_impair.get_etud_ue_status(etud.id, self.ue_cur_impair.id)
|
||||||
self.moy_ue_1 = ue_status["moy"] if ue_status else None # avec capitalisée
|
self.moy_ue_1 = ue_status["moy"] if ue_status else None # avec capitalisée
|
||||||
self.ue_1 = self.ue_cur_impair
|
self.ue_1 = self.ue_cur_impair
|
||||||
self.res_impair = res_impair
|
self.res_impair = res_impair
|
||||||
self.ue_status_impair = ue_status
|
self.ue_status_impair = ue_status
|
||||||
elif self.validation_ue_best_impair:
|
elif self.validation_ue_best_impair:
|
||||||
|
# UE capitalisée
|
||||||
self.moy_ue_1 = self.validation_ue_best_impair.moy_ue
|
self.moy_ue_1 = self.validation_ue_best_impair.moy_ue
|
||||||
self.ue_1 = self.validation_ue_best_impair.ue
|
self.ue_1 = self.validation_ue_best_impair.ue
|
||||||
|
if (
|
||||||
|
res_impair
|
||||||
|
and self.validation_ue_best_impair
|
||||||
|
and self.validation_ue_best_impair.ue
|
||||||
|
):
|
||||||
|
self.ue_status_impair = res_impair.get_etud_ue_status(
|
||||||
|
etud.id, self.validation_ue_best_impair.ue.id
|
||||||
|
)
|
||||||
else:
|
else:
|
||||||
self.moy_ue_1, self.ue_1 = None, None
|
self.moy_ue_1, self.ue_1 = None, None
|
||||||
self.moy_ue_1_val = self.moy_ue_1 if self.moy_ue_1 is not None else 0.0
|
self.moy_ue_1_val = self.moy_ue_1 if self.moy_ue_1 is not None else 0.0
|
||||||
|
|
|
@ -23,6 +23,7 @@ from app.models import (
|
||||||
)
|
)
|
||||||
from app.scodoc import sco_cache
|
from app.scodoc import sco_cache
|
||||||
from app.scodoc import codes_cursus
|
from app.scodoc import codes_cursus
|
||||||
|
from app.scodoc import sco_utils as scu
|
||||||
|
|
||||||
|
|
||||||
class ValidationsSemestre(ResultatsCache):
|
class ValidationsSemestre(ResultatsCache):
|
||||||
|
@ -84,7 +85,7 @@ class ValidationsSemestre(ResultatsCache):
|
||||||
"code": decision.code,
|
"code": decision.code,
|
||||||
"assidu": decision.assidu,
|
"assidu": decision.assidu,
|
||||||
"compense_formsemestre_id": decision.compense_formsemestre_id,
|
"compense_formsemestre_id": decision.compense_formsemestre_id,
|
||||||
"event_date": decision.event_date.strftime("%d/%m/%Y"),
|
"event_date": decision.event_date.strftime(scu.DATE_FMT),
|
||||||
}
|
}
|
||||||
self.decisions_jury = decisions_jury
|
self.decisions_jury = decisions_jury
|
||||||
|
|
||||||
|
@ -107,7 +108,7 @@ class ValidationsSemestre(ResultatsCache):
|
||||||
decisions_jury_ues[decision.etudid][decision.ue.id] = {
|
decisions_jury_ues[decision.etudid][decision.ue.id] = {
|
||||||
"code": decision.code,
|
"code": decision.code,
|
||||||
"ects": ects, # 0. si UE non validée
|
"ects": ects, # 0. si UE non validée
|
||||||
"event_date": decision.event_date.strftime("%d/%m/%Y"),
|
"event_date": decision.event_date.strftime(scu.DATE_FMT),
|
||||||
}
|
}
|
||||||
|
|
||||||
self.decisions_jury_ues = decisions_jury_ues
|
self.decisions_jury_ues = decisions_jury_ues
|
||||||
|
|
|
@ -72,7 +72,15 @@ class ModuleImplResults:
|
||||||
les caches sont gérés par ResultatsSemestre.
|
les caches sont gérés par ResultatsSemestre.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, moduleimpl: ModuleImpl):
|
def __init__(
|
||||||
|
self, moduleimpl: ModuleImpl, etudids: list[int], etudids_actifs: set[int]
|
||||||
|
):
|
||||||
|
"""
|
||||||
|
Args:
|
||||||
|
- etudids : liste des etudids, qui donne l'index du dataframe
|
||||||
|
(doit être tous les étudiants inscrits au semestre incluant les DEM et DEF)
|
||||||
|
- etudids_actifs l'ensemble des étudiants inscrits au semestre, non DEM/DEF.
|
||||||
|
"""
|
||||||
self.moduleimpl_id = moduleimpl.id
|
self.moduleimpl_id = moduleimpl.id
|
||||||
self.module_id = moduleimpl.module.id
|
self.module_id = moduleimpl.module.id
|
||||||
self.etudids = None
|
self.etudids = None
|
||||||
|
@ -105,14 +113,21 @@ class ModuleImplResults:
|
||||||
"""
|
"""
|
||||||
self.evals_etudids_sans_note = {}
|
self.evals_etudids_sans_note = {}
|
||||||
"""dict: evaluation_id : set des etudids non notés dans cette eval, sans les démissions."""
|
"""dict: evaluation_id : set des etudids non notés dans cette eval, sans les démissions."""
|
||||||
self.load_notes()
|
self.load_notes(etudids, etudids_actifs)
|
||||||
self.etuds_use_session2 = pd.Series(False, index=self.evals_notes.index)
|
self.etuds_use_session2 = pd.Series(False, index=self.evals_notes.index)
|
||||||
"""1 bool par etud, indique si sa moyenne de module vient de la session2"""
|
"""1 bool par etud, indique si sa moyenne de module vient de la session2"""
|
||||||
self.etuds_use_rattrapage = pd.Series(False, index=self.evals_notes.index)
|
self.etuds_use_rattrapage = pd.Series(False, index=self.evals_notes.index)
|
||||||
"""1 bool par etud, indique si sa moyenne de module utilise la note de rattrapage"""
|
"""1 bool par etud, indique si sa moyenne de module utilise la note de rattrapage"""
|
||||||
|
|
||||||
def load_notes(self): # ré-écriture de df_load_modimpl_notes
|
def load_notes(
|
||||||
|
self, etudids: list[int], etudids_actifs: set[int]
|
||||||
|
): # ré-écriture de df_load_modimpl_notes
|
||||||
"""Charge toutes les notes de toutes les évaluations du module.
|
"""Charge toutes les notes de toutes les évaluations du module.
|
||||||
|
Args:
|
||||||
|
- etudids : liste des etudids, qui donne l'index du dataframe
|
||||||
|
(doit être tous les étudiants inscrits au semestre incluant les DEM et DEF)
|
||||||
|
- etudids_actifs l'ensemble des étudiants inscrits au semestre, non DEM/DEF.
|
||||||
|
|
||||||
Dataframe evals_notes
|
Dataframe evals_notes
|
||||||
colonnes: le nom de la colonne est l'evaluation_id (int)
|
colonnes: le nom de la colonne est l'evaluation_id (int)
|
||||||
index (lignes): etudid (int)
|
index (lignes): etudid (int)
|
||||||
|
@ -135,12 +150,12 @@ class ModuleImplResults:
|
||||||
qui ont des notes ATT.
|
qui ont des notes ATT.
|
||||||
"""
|
"""
|
||||||
moduleimpl = db.session.get(ModuleImpl, self.moduleimpl_id)
|
moduleimpl = db.session.get(ModuleImpl, self.moduleimpl_id)
|
||||||
self.etudids = self._etudids()
|
self.etudids = etudids
|
||||||
|
|
||||||
# --- Calcul nombre d'inscrits pour déterminer les évaluations "completes":
|
# --- Calcul nombre d'inscrits pour déterminer les évaluations "completes":
|
||||||
# on prend les inscrits au module ET au semestre (donc sans démissionnaires)
|
# on prend les inscrits au module ET au semestre (donc sans démissionnaires)
|
||||||
inscrits_module = {ins.etud.id for ins in moduleimpl.inscriptions}.intersection(
|
inscrits_module = {ins.etud.id for ins in moduleimpl.inscriptions}.intersection(
|
||||||
moduleimpl.formsemestre.etudids_actifs
|
etudids_actifs
|
||||||
)
|
)
|
||||||
self.nb_inscrits_module = len(inscrits_module)
|
self.nb_inscrits_module = len(inscrits_module)
|
||||||
|
|
||||||
|
@ -235,17 +250,6 @@ class ModuleImplResults:
|
||||||
eval_df[str(evaluation.id)] = pd.to_numeric(eval_df[str(evaluation.id)])
|
eval_df[str(evaluation.id)] = pd.to_numeric(eval_df[str(evaluation.id)])
|
||||||
return eval_df
|
return eval_df
|
||||||
|
|
||||||
def _etudids(self):
|
|
||||||
"""L'index du dataframe est la liste de tous les étudiants inscrits au semestre
|
|
||||||
(incluant les DEM et DEF)
|
|
||||||
"""
|
|
||||||
return [
|
|
||||||
inscr.etudid
|
|
||||||
for inscr in db.session.get(
|
|
||||||
ModuleImpl, self.moduleimpl_id
|
|
||||||
).formsemestre.inscriptions
|
|
||||||
]
|
|
||||||
|
|
||||||
def get_evaluations_coefs(self, modimpl: ModuleImpl) -> np.array:
|
def get_evaluations_coefs(self, modimpl: ModuleImpl) -> np.array:
|
||||||
"""Coefficients des évaluations.
|
"""Coefficients des évaluations.
|
||||||
Les coefs des évals incomplètes, rattrapage, session 2, bonus sont forcés à zéro.
|
Les coefs des évals incomplètes, rattrapage, session 2, bonus sont forcés à zéro.
|
||||||
|
|
|
@ -99,9 +99,11 @@ def df_load_module_coefs(formation_id: int, semestre_idx: int = None) -> pd.Data
|
||||||
# 0 pour modules normaux, 1. pour bonus (car par défaut, on veut qu'un bonus agisse
|
# 0 pour modules normaux, 1. pour bonus (car par défaut, on veut qu'un bonus agisse
|
||||||
# sur toutes les UE)
|
# sur toutes les UE)
|
||||||
default_poids = {
|
default_poids = {
|
||||||
mod.id: 1.0
|
mod.id: (
|
||||||
if (mod.module_type == ModuleType.STANDARD) and (mod.ue.type == UE_SPORT)
|
1.0
|
||||||
else 0.0
|
if (mod.module_type == ModuleType.STANDARD) and (mod.ue.type == UE_SPORT)
|
||||||
|
else 0.0
|
||||||
|
)
|
||||||
for mod in modules
|
for mod in modules
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -148,10 +150,12 @@ def df_load_modimpl_coefs(
|
||||||
# 0 pour modules normaux, 1. pour bonus (car par défaut, on veut qu'un bonus agisse
|
# 0 pour modules normaux, 1. pour bonus (car par défaut, on veut qu'un bonus agisse
|
||||||
# sur toutes les UE)
|
# sur toutes les UE)
|
||||||
default_poids = {
|
default_poids = {
|
||||||
modimpl.id: 1.0
|
modimpl.id: (
|
||||||
if (modimpl.module.module_type == ModuleType.STANDARD)
|
1.0
|
||||||
and (modimpl.module.ue.type == UE_SPORT)
|
if (modimpl.module.module_type == ModuleType.STANDARD)
|
||||||
else 0.0
|
and (modimpl.module.ue.type == UE_SPORT)
|
||||||
|
else 0.0
|
||||||
|
)
|
||||||
for modimpl in formsemestre.modimpls_sorted
|
for modimpl in formsemestre.modimpls_sorted
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -200,8 +204,9 @@ def notes_sem_load_cube(formsemestre: FormSemestre) -> tuple:
|
||||||
modimpls_results = {}
|
modimpls_results = {}
|
||||||
modimpls_evals_poids = {}
|
modimpls_evals_poids = {}
|
||||||
modimpls_notes = []
|
modimpls_notes = []
|
||||||
|
etudids, etudids_actifs = formsemestre.etudids_actifs()
|
||||||
for modimpl in formsemestre.modimpls_sorted:
|
for modimpl in formsemestre.modimpls_sorted:
|
||||||
mod_results = moy_mod.ModuleImplResultsAPC(modimpl)
|
mod_results = moy_mod.ModuleImplResultsAPC(modimpl, etudids, etudids_actifs)
|
||||||
evals_poids, _ = moy_mod.load_evaluations_poids(modimpl.id)
|
evals_poids, _ = moy_mod.load_evaluations_poids(modimpl.id)
|
||||||
etuds_moy_module = mod_results.compute_module_moy(evals_poids)
|
etuds_moy_module = mod_results.compute_module_moy(evals_poids)
|
||||||
modimpls_results[modimpl.id] = mod_results
|
modimpls_results[modimpl.id] = mod_results
|
||||||
|
|
|
@ -256,8 +256,9 @@ def notes_sem_load_matrix(formsemestre: FormSemestre) -> tuple[np.ndarray, dict]
|
||||||
"""
|
"""
|
||||||
modimpls_results = {}
|
modimpls_results = {}
|
||||||
modimpls_notes = []
|
modimpls_notes = []
|
||||||
|
etudids, etudids_actifs = formsemestre.etudids_actifs()
|
||||||
for modimpl in formsemestre.modimpls_sorted:
|
for modimpl in formsemestre.modimpls_sorted:
|
||||||
mod_results = moy_mod.ModuleImplResultsClassic(modimpl)
|
mod_results = moy_mod.ModuleImplResultsClassic(modimpl, etudids, etudids_actifs)
|
||||||
etuds_moy_module = mod_results.compute_module_moy()
|
etuds_moy_module = mod_results.compute_module_moy()
|
||||||
modimpls_results[modimpl.id] = mod_results
|
modimpls_results[modimpl.id] = mod_results
|
||||||
modimpls_notes.append(etuds_moy_module)
|
modimpls_notes.append(etuds_moy_module)
|
||||||
|
|
|
@ -438,7 +438,7 @@ class ResultatsSemestre(ResultatsCache):
|
||||||
|
|
||||||
def get_etud_ue_status(self, etudid: int, ue_id: int) -> dict | None:
|
def get_etud_ue_status(self, etudid: int, ue_id: int) -> dict | None:
|
||||||
"""L'état de l'UE pour cet étudiant.
|
"""L'état de l'UE pour cet étudiant.
|
||||||
Result: dict, ou None si l'UE n'est pas dans ce semestre.
|
Result: dict, ou None si l'UE n'existe pas ou n'est pas dans ce semestre.
|
||||||
{
|
{
|
||||||
"is_capitalized": # vrai si la version capitalisée est celle prise en compte (meilleure)
|
"is_capitalized": # vrai si la version capitalisée est celle prise en compte (meilleure)
|
||||||
"was_capitalized":# si elle a été capitalisée (meilleure ou pas)
|
"was_capitalized":# si elle a été capitalisée (meilleure ou pas)
|
||||||
|
@ -456,6 +456,8 @@ class ResultatsSemestre(ResultatsCache):
|
||||||
}
|
}
|
||||||
"""
|
"""
|
||||||
ue: UniteEns = db.session.get(UniteEns, ue_id)
|
ue: UniteEns = db.session.get(UniteEns, ue_id)
|
||||||
|
if not ue:
|
||||||
|
return None
|
||||||
ue_dict = ue.to_dict()
|
ue_dict = ue.to_dict()
|
||||||
|
|
||||||
if ue.type == UE_SPORT:
|
if ue.type == UE_SPORT:
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
# See LICENSE
|
# See LICENSE
|
||||||
##############################################################################
|
##############################################################################
|
||||||
|
|
||||||
|
import datetime
|
||||||
from threading import Thread
|
from threading import Thread
|
||||||
|
|
||||||
from flask import current_app, g
|
from flask import current_app, g
|
||||||
|
@ -83,9 +84,12 @@ Adresses d'origine:
|
||||||
\n\n"""
|
\n\n"""
|
||||||
+ msg.body
|
+ msg.body
|
||||||
)
|
)
|
||||||
|
now = datetime.datetime.now()
|
||||||
|
formatted_time = now.strftime("%Y-%m-%d %H:%M:%S") + ".{:03d}".format(
|
||||||
|
now.microsecond // 1000
|
||||||
|
)
|
||||||
current_app.logger.info(
|
current_app.logger.info(
|
||||||
f"""email sent to{
|
f"""[{formatted_time}] email sent to{
|
||||||
' (mode test)' if email_test_mode_address else ''
|
' (mode test)' if email_test_mode_address else ''
|
||||||
}: {msg.recipients}
|
}: {msg.recipients}
|
||||||
from sender {msg.sender}
|
from sender {msg.sender}
|
||||||
|
|
|
@ -59,3 +59,4 @@ def check_taxe_now(taxes):
|
||||||
|
|
||||||
|
|
||||||
from app.entreprises import routes
|
from app.entreprises import routes
|
||||||
|
from app.entreprises.activate import activate_module
|
||||||
|
|
|
@ -0,0 +1,31 @@
|
||||||
|
##############################################################################
|
||||||
|
# ScoDoc
|
||||||
|
# Copyright (c) 1999 - 2024 Emmanuel Viennet. All rights reserved.
|
||||||
|
# See LICENSE
|
||||||
|
##############################################################################
|
||||||
|
|
||||||
|
"""Activation du module entreprises
|
||||||
|
|
||||||
|
L'affichage du module est contrôlé par la config ScoDocConfig.enable_entreprises
|
||||||
|
|
||||||
|
Au moment de l'activation, il est en général utile de proposer de configurer les
|
||||||
|
permissions de rôles standards: AdminEntreprise UtilisateurEntreprise ObservateurEntreprise
|
||||||
|
|
||||||
|
Voir associations dans sco_roles_default
|
||||||
|
|
||||||
|
"""
|
||||||
|
from app.auth.models import Role
|
||||||
|
from app.models import ScoDocSiteConfig
|
||||||
|
from app.scodoc.sco_roles_default import SCO_ROLES_ENTREPRISES_DEFAULT
|
||||||
|
|
||||||
|
|
||||||
|
def activate_module(
|
||||||
|
enable: bool = True, set_default_roles_permission: bool = False
|
||||||
|
) -> bool:
|
||||||
|
"""Active le module et en option donne les permissions aux rôles standards.
|
||||||
|
True si l'état d'activation a changé.
|
||||||
|
"""
|
||||||
|
change = ScoDocSiteConfig.enable_entreprises(enable)
|
||||||
|
if enable and set_default_roles_permission:
|
||||||
|
Role.reset_roles_permissions(SCO_ROLES_ENTREPRISES_DEFAULT)
|
||||||
|
return change
|
|
@ -0,0 +1,17 @@
|
||||||
|
"""
|
||||||
|
Formulaire activation module entreprises
|
||||||
|
"""
|
||||||
|
|
||||||
|
from flask_wtf import FlaskForm
|
||||||
|
from wtforms.fields.simple import BooleanField, SubmitField
|
||||||
|
|
||||||
|
from app.models import ScoDocSiteConfig
|
||||||
|
|
||||||
|
|
||||||
|
class ActivateEntreprisesForm(FlaskForm):
|
||||||
|
"Formulaire activation module entreprises"
|
||||||
|
set_default_roles_permission = BooleanField(
|
||||||
|
"(re)mettre les rôles 'Entreprise' à leurs valeurs par défaut"
|
||||||
|
)
|
||||||
|
submit = SubmitField("Valider")
|
||||||
|
cancel = SubmitField("Annuler", render_kw={"formnovalidate": True})
|
|
@ -48,13 +48,15 @@ class BonusConfigurationForm(FlaskForm):
|
||||||
for (name, displayed_name) in ScoDocSiteConfig.get_bonus_sport_class_list()
|
for (name, displayed_name) in ScoDocSiteConfig.get_bonus_sport_class_list()
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
submit_bonus = SubmitField("Valider")
|
submit_bonus = SubmitField("Enregistrer ce bonus")
|
||||||
cancel_bonus = SubmitField("Annuler", render_kw={"formnovalidate": True})
|
cancel_bonus = SubmitField("Annuler", render_kw={"formnovalidate": True})
|
||||||
|
|
||||||
|
|
||||||
class ScoDocConfigurationForm(FlaskForm):
|
class ScoDocConfigurationForm(FlaskForm):
|
||||||
"Panneau de configuration avancée"
|
"Panneau de configuration avancée"
|
||||||
enable_entreprises = BooleanField("activer le module <em>entreprises</em>")
|
disable_passerelle = BooleanField( # disable car par défaut activée
|
||||||
|
"""cacher les fonctions liées à une passerelle de publication des résultats vers les étudiants ("œil"). N'affecte pas l'API, juste la présentation."""
|
||||||
|
)
|
||||||
month_debut_annee_scolaire = SelectField(
|
month_debut_annee_scolaire = SelectField(
|
||||||
label="Mois de début des années scolaires",
|
label="Mois de début des années scolaires",
|
||||||
description="""Date pivot. En France métropolitaine, août.
|
description="""Date pivot. En France métropolitaine, août.
|
||||||
|
@ -83,7 +85,7 @@ class ScoDocConfigurationForm(FlaskForm):
|
||||||
disable_bul_pdf = BooleanField(
|
disable_bul_pdf = BooleanField(
|
||||||
"interdire les exports des bulletins en PDF (déconseillé)"
|
"interdire les exports des bulletins en PDF (déconseillé)"
|
||||||
)
|
)
|
||||||
submit_scodoc = SubmitField("Valider")
|
submit_scodoc = SubmitField("Enregistrer ces paramètres")
|
||||||
cancel_scodoc = SubmitField("Annuler", render_kw={"formnovalidate": True})
|
cancel_scodoc = SubmitField("Annuler", render_kw={"formnovalidate": True})
|
||||||
|
|
||||||
|
|
||||||
|
@ -98,6 +100,7 @@ def configuration():
|
||||||
form_scodoc = ScoDocConfigurationForm(
|
form_scodoc = ScoDocConfigurationForm(
|
||||||
data={
|
data={
|
||||||
"enable_entreprises": ScoDocSiteConfig.is_entreprises_enabled(),
|
"enable_entreprises": ScoDocSiteConfig.is_entreprises_enabled(),
|
||||||
|
"disable_passerelle": ScoDocSiteConfig.is_passerelle_disabled(),
|
||||||
"month_debut_annee_scolaire": ScoDocSiteConfig.get_month_debut_annee_scolaire(),
|
"month_debut_annee_scolaire": ScoDocSiteConfig.get_month_debut_annee_scolaire(),
|
||||||
"month_debut_periode2": ScoDocSiteConfig.get_month_debut_periode2(),
|
"month_debut_periode2": ScoDocSiteConfig.get_month_debut_periode2(),
|
||||||
"email_from_addr": ScoDocSiteConfig.get("email_from_addr"),
|
"email_from_addr": ScoDocSiteConfig.get("email_from_addr"),
|
||||||
|
@ -123,12 +126,12 @@ def configuration():
|
||||||
flash("Fonction bonus inchangée.")
|
flash("Fonction bonus inchangée.")
|
||||||
return redirect(url_for("scodoc.index"))
|
return redirect(url_for("scodoc.index"))
|
||||||
elif form_scodoc.submit_scodoc.data and form_scodoc.validate():
|
elif form_scodoc.submit_scodoc.data and form_scodoc.validate():
|
||||||
if ScoDocSiteConfig.enable_entreprises(
|
if ScoDocSiteConfig.disable_passerelle(
|
||||||
enabled=form_scodoc.data["enable_entreprises"]
|
disabled=form_scodoc.data["disable_passerelle"]
|
||||||
):
|
):
|
||||||
flash(
|
flash(
|
||||||
"Module entreprise "
|
"Fonction passerelle "
|
||||||
+ ("activé" if form_scodoc.data["enable_entreprises"] else "désactivé")
|
+ ("cachées" if form_scodoc.data["disable_passerelle"] else "montrées")
|
||||||
)
|
)
|
||||||
if ScoDocSiteConfig.set_month_debut_annee_scolaire(
|
if ScoDocSiteConfig.set_month_debut_annee_scolaire(
|
||||||
int(form_scodoc.data["month_debut_annee_scolaire"])
|
int(form_scodoc.data["month_debut_annee_scolaire"])
|
||||||
|
@ -171,6 +174,7 @@ def configuration():
|
||||||
|
|
||||||
return render_template(
|
return render_template(
|
||||||
"configuration.j2",
|
"configuration.j2",
|
||||||
|
is_entreprises_enabled=ScoDocSiteConfig.is_entreprises_enabled(),
|
||||||
form_bonus=form_bonus,
|
form_bonus=form_bonus,
|
||||||
form_scodoc=form_scodoc,
|
form_scodoc=form_scodoc,
|
||||||
scu=scu,
|
scu=scu,
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
# -*- coding: UTF-8 -*
|
# -*- coding: UTF-8 -*
|
||||||
"""Gestion de l'assiduité (assiduités + justificatifs)
|
"""Gestion de l'assiduité (assiduités + justificatifs)"""
|
||||||
"""
|
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
|
||||||
from flask_login import current_user
|
from flask_login import current_user
|
||||||
|
@ -21,6 +21,7 @@ from app.scodoc import sco_abs_notification
|
||||||
from app.scodoc.sco_archives_justificatifs import JustificatifArchiver
|
from app.scodoc.sco_archives_justificatifs import JustificatifArchiver
|
||||||
from app.scodoc.sco_exceptions import ScoValueError
|
from app.scodoc.sco_exceptions import ScoValueError
|
||||||
from app.scodoc.sco_permissions import Permission
|
from app.scodoc.sco_permissions import Permission
|
||||||
|
from app.scodoc import sco_utils as scu
|
||||||
from app.scodoc.sco_utils import (
|
from app.scodoc.sco_utils import (
|
||||||
EtatAssiduite,
|
EtatAssiduite,
|
||||||
EtatJustificatif,
|
EtatJustificatif,
|
||||||
|
@ -113,9 +114,9 @@ class Assiduite(ScoDocModel):
|
||||||
"entry_date": self.entry_date,
|
"entry_date": self.entry_date,
|
||||||
"user_id": None if user is None else user.id, # l'uid
|
"user_id": None if user is None else user.id, # l'uid
|
||||||
"user_name": None if user is None else user.user_name, # le login
|
"user_name": None if user is None else user.user_name, # le login
|
||||||
"user_nom_complet": None
|
"user_nom_complet": (
|
||||||
if user is None
|
None if user is None else user.get_nomcomplet()
|
||||||
else user.get_nomcomplet(), # "Marie Dupont"
|
), # "Marie Dupont"
|
||||||
"est_just": self.est_just,
|
"est_just": self.est_just,
|
||||||
"external_data": self.external_data,
|
"external_data": self.external_data,
|
||||||
}
|
}
|
||||||
|
@ -336,13 +337,19 @@ class Assiduite(ScoDocModel):
|
||||||
"""
|
"""
|
||||||
return get_formsemestre_from_data(self.to_dict())
|
return get_formsemestre_from_data(self.to_dict())
|
||||||
|
|
||||||
def get_module(self, traduire: bool = False) -> int | str:
|
def get_module(self, traduire: bool = False) -> Module | str:
|
||||||
"TODO documenter"
|
"""
|
||||||
|
Retourne le module associé à l'assiduité
|
||||||
|
Si traduire est vrai, retourne le titre du module précédé du code
|
||||||
|
Sinon rentourne l'objet Module ou None
|
||||||
|
"""
|
||||||
|
|
||||||
if self.moduleimpl_id is not None:
|
if self.moduleimpl_id is not None:
|
||||||
|
modimpl: ModuleImpl = ModuleImpl.query.get(self.moduleimpl_id)
|
||||||
|
mod: Module = Module.query.get(modimpl.module_id)
|
||||||
if traduire:
|
if traduire:
|
||||||
modimpl: ModuleImpl = ModuleImpl.query.get(self.moduleimpl_id)
|
|
||||||
mod: Module = Module.query.get(modimpl.module_id)
|
|
||||||
return f"{mod.code} {mod.titre}"
|
return f"{mod.code} {mod.titre}"
|
||||||
|
return mod
|
||||||
|
|
||||||
elif self.external_data is not None and "module" in self.external_data:
|
elif self.external_data is not None and "module" in self.external_data:
|
||||||
return (
|
return (
|
||||||
|
@ -358,7 +365,7 @@ class Assiduite(ScoDocModel):
|
||||||
retourne le texte "saisie le <date> par <User>"
|
retourne le texte "saisie le <date> par <User>"
|
||||||
"""
|
"""
|
||||||
|
|
||||||
date: str = self.entry_date.strftime("%d/%m/%Y à %H:%M")
|
date: str = self.entry_date.strftime(scu.DATEATIME_FMT)
|
||||||
utilisateur: str = ""
|
utilisateur: str = ""
|
||||||
if self.user is not None:
|
if self.user is not None:
|
||||||
self.user: User
|
self.user: User
|
||||||
|
@ -654,6 +661,24 @@ class Justificatif(ScoDocModel):
|
||||||
|
|
||||||
return assiduites_dejustifiees
|
return assiduites_dejustifiees
|
||||||
|
|
||||||
|
def get_assiduites(self) -> Query:
|
||||||
|
"""
|
||||||
|
get_assiduites Récupère les assiduités qui sont concernées par le justificatif
|
||||||
|
(Concernée ≠ Justifiée, mais qui sont sur la même période)
|
||||||
|
Ne prends pas en compte les Présences
|
||||||
|
Returns:
|
||||||
|
Query: Les assiduités concernées
|
||||||
|
"""
|
||||||
|
|
||||||
|
assiduites_query = Assiduite.query.filter(
|
||||||
|
Assiduite.etudid == self.etudid,
|
||||||
|
Assiduite.date_debut >= self.date_debut,
|
||||||
|
Assiduite.date_fin <= self.date_fin,
|
||||||
|
Assiduite.etat != EtatAssiduite.PRESENT,
|
||||||
|
)
|
||||||
|
|
||||||
|
return assiduites_query
|
||||||
|
|
||||||
|
|
||||||
def is_period_conflicting(
|
def is_period_conflicting(
|
||||||
date_debut: datetime,
|
date_debut: datetime,
|
||||||
|
|
|
@ -8,16 +8,19 @@
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
import functools
|
import functools
|
||||||
from operator import attrgetter
|
from operator import attrgetter
|
||||||
|
import yaml
|
||||||
|
|
||||||
from flask import g
|
from flask import g
|
||||||
from flask_sqlalchemy.query import Query
|
from flask_sqlalchemy.query import Query
|
||||||
from sqlalchemy.orm import class_mapper
|
from sqlalchemy.orm import class_mapper
|
||||||
import sqlalchemy
|
import sqlalchemy
|
||||||
|
|
||||||
from app import db
|
from app import db, log
|
||||||
|
|
||||||
from app.scodoc.sco_utils import ModuleType
|
from app.scodoc.sco_utils import ModuleType
|
||||||
from app.scodoc.sco_exceptions import ScoNoReferentielCompetences
|
from app.scodoc.sco_exceptions import ScoNoReferentielCompetences, ScoValueError
|
||||||
|
|
||||||
|
REFCOMP_EQUIVALENCE_FILENAME = "ressources/referentiels/equivalences.yaml"
|
||||||
|
|
||||||
|
|
||||||
# from https://stackoverflow.com/questions/2537471/method-of-iterating-over-sqlalchemy-models-defined-columns
|
# from https://stackoverflow.com/questions/2537471/method-of-iterating-over-sqlalchemy-models-defined-columns
|
||||||
|
@ -104,6 +107,11 @@ class ApcReferentielCompetences(db.Model, XMLModel):
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return f"<ApcReferentielCompetences {self.id} {self.specialite!r} {self.departement!r}>"
|
return f"<ApcReferentielCompetences {self.id} {self.specialite!r} {self.departement!r}>"
|
||||||
|
|
||||||
|
def get_title(self) -> str:
|
||||||
|
"Titre affichable"
|
||||||
|
# utilise type_titre (B.U.T.), spécialité, version
|
||||||
|
return f"{self.type_titre} {self.specialite} {self.get_version()}"
|
||||||
|
|
||||||
def get_version(self) -> str:
|
def get_version(self) -> str:
|
||||||
"La version, normalement sous forme de date iso yyy-mm-dd"
|
"La version, normalement sous forme de date iso yyy-mm-dd"
|
||||||
if not self.version_orebut:
|
if not self.version_orebut:
|
||||||
|
@ -124,9 +132,11 @@ class ApcReferentielCompetences(db.Model, XMLModel):
|
||||||
"type_departement": self.type_departement,
|
"type_departement": self.type_departement,
|
||||||
"type_titre": self.type_titre,
|
"type_titre": self.type_titre,
|
||||||
"version_orebut": self.version_orebut,
|
"version_orebut": self.version_orebut,
|
||||||
"scodoc_date_loaded": self.scodoc_date_loaded.isoformat() + "Z"
|
"scodoc_date_loaded": (
|
||||||
if self.scodoc_date_loaded
|
self.scodoc_date_loaded.isoformat() + "Z"
|
||||||
else "",
|
if self.scodoc_date_loaded
|
||||||
|
else ""
|
||||||
|
),
|
||||||
"scodoc_orig_filename": self.scodoc_orig_filename,
|
"scodoc_orig_filename": self.scodoc_orig_filename,
|
||||||
"competences": {
|
"competences": {
|
||||||
x.titre: x.to_dict(with_app_critiques=with_app_critiques)
|
x.titre: x.to_dict(with_app_critiques=with_app_critiques)
|
||||||
|
@ -234,6 +244,92 @@ class ApcReferentielCompetences(db.Model, XMLModel):
|
||||||
|
|
||||||
return parcours_info
|
return parcours_info
|
||||||
|
|
||||||
|
def equivalents(self) -> set["ApcReferentielCompetences"]:
|
||||||
|
"""Ensemble des référentiels du même département
|
||||||
|
qui peuvent être considérés comme "équivalents", au sens
|
||||||
|
une formation de ce référentiel pourrait changer vers un équivalent,
|
||||||
|
en ignorant les apprentissages critiques.
|
||||||
|
Pour cela, il faut avoir le même type, etc et les mêmes compétences,
|
||||||
|
niveaux et parcours (voir map_to_other_referentiel).
|
||||||
|
"""
|
||||||
|
candidats = ApcReferentielCompetences.query.filter_by(
|
||||||
|
dept_id=self.dept_id
|
||||||
|
).filter(ApcReferentielCompetences.id != self.id)
|
||||||
|
return {
|
||||||
|
referentiel
|
||||||
|
for referentiel in candidats
|
||||||
|
if not isinstance(self.map_to_other_referentiel(referentiel), str)
|
||||||
|
}
|
||||||
|
|
||||||
|
def map_to_other_referentiel(
|
||||||
|
self, other: "ApcReferentielCompetences"
|
||||||
|
) -> str | tuple[dict[int, int], dict[int, int], dict[int, int]]:
|
||||||
|
"""Build mapping between this referentiel and ref2.
|
||||||
|
If successful, returns 3 dicts mapping self ids to other ids.
|
||||||
|
Else return a string, error message.
|
||||||
|
"""
|
||||||
|
if self.type_structure != other.type_structure:
|
||||||
|
return "type_structure mismatch"
|
||||||
|
if self.type_departement != other.type_departement:
|
||||||
|
return "type_departement mismatch"
|
||||||
|
# Table d'équivalences entre refs:
|
||||||
|
equiv = self._load_config_equivalences()
|
||||||
|
# mêmes parcours ?
|
||||||
|
eq_parcours = equiv.get("parcours", {})
|
||||||
|
parcours_by_code_1 = {eq_parcours.get(p.code, p.code): p for p in self.parcours}
|
||||||
|
parcours_by_code_2 = {
|
||||||
|
eq_parcours.get(p.code, p.code): p for p in other.parcours
|
||||||
|
}
|
||||||
|
if parcours_by_code_1.keys() != parcours_by_code_2.keys():
|
||||||
|
return "parcours mismatch"
|
||||||
|
parcours_map = {
|
||||||
|
parcours_by_code_1[eq_parcours.get(code, code)]
|
||||||
|
.id: parcours_by_code_2[eq_parcours.get(code, code)]
|
||||||
|
.id
|
||||||
|
for code in parcours_by_code_1
|
||||||
|
}
|
||||||
|
# mêmes compétences ?
|
||||||
|
competence_by_code_1 = {c.titre: c for c in self.competences}
|
||||||
|
competence_by_code_2 = {c.titre: c for c in other.competences}
|
||||||
|
if competence_by_code_1.keys() != competence_by_code_2.keys():
|
||||||
|
return "competences mismatch"
|
||||||
|
competences_map = {
|
||||||
|
competence_by_code_1[titre].id: competence_by_code_2[titre].id
|
||||||
|
for titre in competence_by_code_1
|
||||||
|
}
|
||||||
|
# mêmes niveaux (dans chaque compétence) ?
|
||||||
|
niveaux_map = {}
|
||||||
|
for titre in competence_by_code_1:
|
||||||
|
c1 = competence_by_code_1[titre]
|
||||||
|
c2 = competence_by_code_2[titre]
|
||||||
|
niveau_by_attr_1 = {(n.annee, n.ordre, n.libelle): n for n in c1.niveaux}
|
||||||
|
niveau_by_attr_2 = {(n.annee, n.ordre, n.libelle): n for n in c2.niveaux}
|
||||||
|
if niveau_by_attr_1.keys() != niveau_by_attr_2.keys():
|
||||||
|
return f"niveaux mismatch in comp. '{titre}'"
|
||||||
|
niveaux_map.update(
|
||||||
|
{
|
||||||
|
niveau_by_attr_1[a].id: niveau_by_attr_2[a].id
|
||||||
|
for a in niveau_by_attr_1
|
||||||
|
}
|
||||||
|
)
|
||||||
|
return parcours_map, competences_map, niveaux_map
|
||||||
|
|
||||||
|
def _load_config_equivalences(self) -> dict:
|
||||||
|
"""Load config file ressources/referentiels/equivalences.yaml
|
||||||
|
used to define equivalences between distinct referentiels
|
||||||
|
"""
|
||||||
|
try:
|
||||||
|
with open(REFCOMP_EQUIVALENCE_FILENAME, encoding="utf-8") as f:
|
||||||
|
doc = yaml.safe_load(f.read())
|
||||||
|
except FileNotFoundError:
|
||||||
|
log(f"_load_config_equivalences: {REFCOMP_EQUIVALENCE_FILENAME} not found")
|
||||||
|
return {}
|
||||||
|
except yaml.parser.ParserError as exc:
|
||||||
|
raise ScoValueError(
|
||||||
|
f"erreur dans le fichier {REFCOMP_EQUIVALENCE_FILENAME}"
|
||||||
|
) from exc
|
||||||
|
return doc.get(self.specialite, {})
|
||||||
|
|
||||||
|
|
||||||
class ApcCompetence(db.Model, XMLModel):
|
class ApcCompetence(db.Model, XMLModel):
|
||||||
"Compétence"
|
"Compétence"
|
||||||
|
@ -374,9 +470,11 @@ class ApcNiveau(db.Model, XMLModel):
|
||||||
"libelle": self.libelle,
|
"libelle": self.libelle,
|
||||||
"annee": self.annee,
|
"annee": self.annee,
|
||||||
"ordre": self.ordre,
|
"ordre": self.ordre,
|
||||||
"app_critiques": {x.code: x.to_dict() for x in self.app_critiques}
|
"app_critiques": (
|
||||||
if with_app_critiques
|
{x.code: x.to_dict() for x in self.app_critiques}
|
||||||
else {},
|
if with_app_critiques
|
||||||
|
else {}
|
||||||
|
),
|
||||||
}
|
}
|
||||||
|
|
||||||
def to_dict_bul(self):
|
def to_dict_bul(self):
|
||||||
|
@ -464,9 +562,9 @@ class ApcNiveau(db.Model, XMLModel):
|
||||||
return []
|
return []
|
||||||
|
|
||||||
if competence is None:
|
if competence is None:
|
||||||
parcour_niveaux: list[
|
parcour_niveaux: list[ApcParcoursNiveauCompetence] = (
|
||||||
ApcParcoursNiveauCompetence
|
annee_parcour.niveaux_competences
|
||||||
] = annee_parcour.niveaux_competences
|
)
|
||||||
niveaux: list[ApcNiveau] = [
|
niveaux: list[ApcNiveau] = [
|
||||||
pn.competence.niveaux.filter_by(ordre=pn.niveau).first()
|
pn.competence.niveaux.filter_by(ordre=pn.niveau).first()
|
||||||
for pn in parcour_niveaux
|
for pn in parcour_niveaux
|
||||||
|
|
|
@ -10,6 +10,7 @@ from app.models.etudiants import Identite
|
||||||
from app.models.formsemestre import FormSemestre
|
from app.models.formsemestre import FormSemestre
|
||||||
from app.models.ues import UniteEns
|
from app.models.ues import UniteEns
|
||||||
from app.scodoc import sco_preferences
|
from app.scodoc import sco_preferences
|
||||||
|
from app.scodoc import sco_utils as scu
|
||||||
|
|
||||||
|
|
||||||
class ApcValidationRCUE(db.Model):
|
class ApcValidationRCUE(db.Model):
|
||||||
|
@ -63,14 +64,13 @@ class ApcValidationRCUE(db.Model):
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return f"""Décision sur RCUE {self.ue1.acronyme}/{self.ue2.acronyme}: {
|
return f"""Décision sur RCUE {self.ue1.acronyme}/{self.ue2.acronyme}: {
|
||||||
self.code} enregistrée le {self.date.strftime("%d/%m/%Y")}"""
|
self.code} enregistrée le {self.date.strftime(scu.DATE_FMT)}"""
|
||||||
|
|
||||||
def html(self) -> str:
|
def html(self) -> str:
|
||||||
"description en HTML"
|
"description en HTML"
|
||||||
return f"""Décision sur RCUE {self.ue1.acronyme}/{self.ue2.acronyme}:
|
return f"""Décision sur RCUE {self.ue1.acronyme}/{self.ue2.acronyme}:
|
||||||
<b>{self.code}</b>
|
<b>{self.code}</b>
|
||||||
<em>enregistrée le {self.date.strftime("%d/%m/%Y")}
|
<em>enregistrée le {self.date.strftime(scu.DATEATIME_FMT)}</em>"""
|
||||||
à {self.date.strftime("%Hh%M")}</em>"""
|
|
||||||
|
|
||||||
def annee(self) -> str:
|
def annee(self) -> str:
|
||||||
"""l'année BUT concernée: "BUT1", "BUT2" ou "BUT3" """
|
"""l'année BUT concernée: "BUT1", "BUT2" ou "BUT3" """
|
||||||
|
@ -164,7 +164,7 @@ class ApcValidationAnnee(db.Model):
|
||||||
def html(self) -> str:
|
def html(self) -> str:
|
||||||
"Affichage html"
|
"Affichage html"
|
||||||
date_str = (
|
date_str = (
|
||||||
f"""le {self.date.strftime("%d/%m/%Y")} à {self.date.strftime("%Hh%M")}"""
|
f"""le {self.date.strftime(scu.DATEATIME_FMT)}"""
|
||||||
if self.date
|
if self.date
|
||||||
else "(sans date)"
|
else "(sans date)"
|
||||||
)
|
)
|
||||||
|
|
|
@ -92,6 +92,7 @@ class ScoDocSiteConfig(db.Model):
|
||||||
"INSTITUTION_CITY": str,
|
"INSTITUTION_CITY": str,
|
||||||
"DEFAULT_PDF_FOOTER_TEMPLATE": str,
|
"DEFAULT_PDF_FOOTER_TEMPLATE": str,
|
||||||
"enable_entreprises": bool,
|
"enable_entreprises": bool,
|
||||||
|
"disable_passerelle": bool, # remplace pref. bul_display_publication
|
||||||
"month_debut_annee_scolaire": int,
|
"month_debut_annee_scolaire": int,
|
||||||
"month_debut_periode2": int,
|
"month_debut_periode2": int,
|
||||||
"disable_bul_pdf": bool,
|
"disable_bul_pdf": bool,
|
||||||
|
@ -244,6 +245,12 @@ class ScoDocSiteConfig(db.Model):
|
||||||
cfg = ScoDocSiteConfig.query.filter_by(name="enable_entreprises").first()
|
cfg = ScoDocSiteConfig.query.filter_by(name="enable_entreprises").first()
|
||||||
return cfg is not None and cfg.value
|
return cfg is not None and cfg.value
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def is_passerelle_disabled(cls):
|
||||||
|
"""True si on doit cacher les fonctions passerelle ("oeil")."""
|
||||||
|
cfg = ScoDocSiteConfig.query.filter_by(name="disable_passerelle").first()
|
||||||
|
return cfg is not None and cfg.value
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def is_user_require_email_institutionnel_enabled(cls) -> bool:
|
def is_user_require_email_institutionnel_enabled(cls) -> bool:
|
||||||
"""True si impose saisie email_institutionnel"""
|
"""True si impose saisie email_institutionnel"""
|
||||||
|
@ -263,6 +270,11 @@ class ScoDocSiteConfig(db.Model):
|
||||||
"""Active (ou déactive) le module entreprises. True si changement."""
|
"""Active (ou déactive) le module entreprises. True si changement."""
|
||||||
return cls.set("enable_entreprises", "on" if enabled else "")
|
return cls.set("enable_entreprises", "on" if enabled else "")
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def disable_passerelle(cls, disabled: bool = True) -> bool:
|
||||||
|
"""Désactive (ou active) les fonctions liées à la présence d'une passerelle. True si changement."""
|
||||||
|
return cls.set("disable_passerelle", "on" if disabled else "")
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def disable_bul_pdf(cls, enabled=True) -> bool:
|
def disable_bul_pdf(cls, enabled=True) -> bool:
|
||||||
"""Interdit (ou autorise) les exports PDF. True si changement."""
|
"""Interdit (ou autorise) les exports PDF. True si changement."""
|
||||||
|
|
|
@ -297,7 +297,7 @@ class Identite(models.ScoDocModel):
|
||||||
else:
|
else:
|
||||||
return self.nom
|
return self.nom
|
||||||
|
|
||||||
@cached_property
|
@property
|
||||||
def nomprenom(self, reverse=False) -> str:
|
def nomprenom(self, reverse=False) -> str:
|
||||||
"""Civilité/nom/prenom pour affichages: "M. Pierre Dupont"
|
"""Civilité/nom/prenom pour affichages: "M. Pierre Dupont"
|
||||||
Si reverse, "Dupont Pierre", sans civilité.
|
Si reverse, "Dupont Pierre", sans civilité.
|
||||||
|
@ -334,16 +334,14 @@ class Identite(models.ScoDocModel):
|
||||||
return f"{(self.nom_usuel or self.nom or '?').upper()} {(self.prenom or '')[:2].capitalize()}."
|
return f"{(self.nom_usuel or self.nom or '?').upper()} {(self.prenom or '')[:2].capitalize()}."
|
||||||
|
|
||||||
@cached_property
|
@cached_property
|
||||||
def sort_key(self) -> tuple:
|
def sort_key(self) -> str:
|
||||||
"clé pour tris par ordre alphabétique"
|
"clé pour tris par ordre alphabétique"
|
||||||
# Note: scodoc7 utilisait sco_etud.etud_sort_key, à mettre à jour
|
# Note: scodoc7 utilisait sco_etud.etud_sort_key, à mettre à jour
|
||||||
# si on modifie cette méthode.
|
# si on modifie cette méthode.
|
||||||
return (
|
return scu.sanitize_string(
|
||||||
scu.sanitize_string(
|
(self.nom_usuel or self.nom or "") + ";" + (self.prenom or ""),
|
||||||
self.nom_usuel or self.nom or "", remove_spaces=False
|
remove_spaces=False,
|
||||||
).lower(),
|
).lower()
|
||||||
scu.sanitize_string(self.prenom or "", remove_spaces=False).lower(),
|
|
||||||
)
|
|
||||||
|
|
||||||
def get_first_email(self, field="email") -> str:
|
def get_first_email(self, field="email") -> str:
|
||||||
"Le mail associé à la première adresse de l'étudiant, ou None"
|
"Le mail associé à la première adresse de l'étudiant, ou None"
|
||||||
|
@ -483,7 +481,9 @@ class Identite(models.ScoDocModel):
|
||||||
"code_ine": self.code_ine or "",
|
"code_ine": self.code_ine or "",
|
||||||
"code_nip": self.code_nip or "",
|
"code_nip": self.code_nip or "",
|
||||||
"date_naissance": (
|
"date_naissance": (
|
||||||
self.date_naissance.strftime("%d/%m/%Y") if self.date_naissance else ""
|
self.date_naissance.strftime(scu.DATE_FMT)
|
||||||
|
if self.date_naissance
|
||||||
|
else ""
|
||||||
),
|
),
|
||||||
"dept_acronym": self.departement.acronym,
|
"dept_acronym": self.departement.acronym,
|
||||||
"dept_id": self.dept_id,
|
"dept_id": self.dept_id,
|
||||||
|
@ -542,8 +542,6 @@ class Identite(models.ScoDocModel):
|
||||||
|
|
||||||
def inscriptions(self) -> list["FormSemestreInscription"]:
|
def inscriptions(self) -> list["FormSemestreInscription"]:
|
||||||
"Liste des inscriptions à des formsemestres, triée, la plus récente en tête"
|
"Liste des inscriptions à des formsemestres, triée, la plus récente en tête"
|
||||||
from app.models.formsemestre import FormSemestre, FormSemestreInscription
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
FormSemestreInscription.query.join(FormSemestreInscription.formsemestre)
|
FormSemestreInscription.query.join(FormSemestreInscription.formsemestre)
|
||||||
.filter(
|
.filter(
|
||||||
|
@ -569,8 +567,6 @@ class Identite(models.ScoDocModel):
|
||||||
(il est rare qu'il y en ai plus d'une, mais c'est possible).
|
(il est rare qu'il y en ai plus d'une, mais c'est possible).
|
||||||
Triées par date de début de semestre décroissante (le plus récent en premier).
|
Triées par date de début de semestre décroissante (le plus récent en premier).
|
||||||
"""
|
"""
|
||||||
from app.models.formsemestre import FormSemestre, FormSemestreInscription
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
FormSemestreInscription.query.join(FormSemestreInscription.formsemestre)
|
FormSemestreInscription.query.join(FormSemestreInscription.formsemestre)
|
||||||
.filter(
|
.filter(
|
||||||
|
@ -739,7 +735,7 @@ class Identite(models.ScoDocModel):
|
||||||
"""
|
"""
|
||||||
if with_paragraph:
|
if with_paragraph:
|
||||||
return f"""{self.etat_civil}{line_sep}n°{self.code_nip or ""}{line_sep}né{self.e} le {
|
return f"""{self.etat_civil}{line_sep}n°{self.code_nip or ""}{line_sep}né{self.e} le {
|
||||||
self.date_naissance.strftime("%d/%m/%Y") if self.date_naissance else ""}{
|
self.date_naissance.strftime(scu.DATE_FMT) if self.date_naissance else ""}{
|
||||||
line_sep}à {self.lieu_naissance or ""}"""
|
line_sep}à {self.lieu_naissance or ""}"""
|
||||||
return self.etat_civil
|
return self.etat_civil
|
||||||
|
|
||||||
|
@ -1099,6 +1095,5 @@ class EtudAnnotation(db.Model):
|
||||||
return e
|
return e
|
||||||
|
|
||||||
|
|
||||||
from app.models.formsemestre import FormSemestre
|
from app.models.formsemestre import FormSemestre, FormSemestreInscription
|
||||||
from app.models.modules import Module
|
|
||||||
from app.models.moduleimpls import ModuleImpl, ModuleImplInscription
|
from app.models.moduleimpls import ModuleImpl, ModuleImplInscription
|
||||||
|
|
|
@ -207,7 +207,9 @@ class Evaluation(models.ScoDocModel):
|
||||||
e_dict["poids"] = self.get_ue_poids_dict() # { ue_id : poids }
|
e_dict["poids"] = self.get_ue_poids_dict() # { ue_id : poids }
|
||||||
|
|
||||||
# Deprecated
|
# Deprecated
|
||||||
e_dict["jour"] = self.date_debut.strftime("%d/%m/%Y") if self.date_debut else ""
|
e_dict["jour"] = (
|
||||||
|
self.date_debut.strftime(scu.DATE_FMT) if self.date_debut else ""
|
||||||
|
)
|
||||||
|
|
||||||
return evaluation_enrich_dict(self, e_dict)
|
return evaluation_enrich_dict(self, e_dict)
|
||||||
|
|
||||||
|
@ -315,10 +317,10 @@ class Evaluation(models.ScoDocModel):
|
||||||
def descr_heure(self) -> str:
|
def descr_heure(self) -> str:
|
||||||
"Description de la plage horaire pour affichages ('de 13h00 à 14h00')"
|
"Description de la plage horaire pour affichages ('de 13h00 à 14h00')"
|
||||||
if self.date_debut and (not self.date_fin or self.date_fin == self.date_debut):
|
if self.date_debut and (not self.date_fin or self.date_fin == self.date_debut):
|
||||||
return f"""à {self.date_debut.strftime("%Hh%M")}"""
|
return f"""à {self.date_debut.strftime(scu.TIME_FMT)}"""
|
||||||
elif self.date_debut and self.date_fin:
|
elif self.date_debut and self.date_fin:
|
||||||
return f"""de {self.date_debut.strftime("%Hh%M")
|
return f"""de {self.date_debut.strftime(scu.TIME_FMT)
|
||||||
} à {self.date_fin.strftime("%Hh%M")}"""
|
} à {self.date_fin.strftime(scu.TIME_FMT)}"""
|
||||||
else:
|
else:
|
||||||
return ""
|
return ""
|
||||||
|
|
||||||
|
@ -345,7 +347,7 @@ class Evaluation(models.ScoDocModel):
|
||||||
|
|
||||||
def _h(dt: datetime.datetime) -> str:
|
def _h(dt: datetime.datetime) -> str:
|
||||||
if dt.minute:
|
if dt.minute:
|
||||||
return dt.strftime("%Hh%M")
|
return dt.strftime(scu.TIME_FMT)
|
||||||
return f"{dt.hour}h"
|
return f"{dt.hour}h"
|
||||||
|
|
||||||
if self.date_fin is None:
|
if self.date_fin is None:
|
||||||
|
@ -539,8 +541,8 @@ class EvaluationUEPoids(db.Model):
|
||||||
def evaluation_enrich_dict(e: Evaluation, e_dict: dict):
|
def evaluation_enrich_dict(e: Evaluation, e_dict: dict):
|
||||||
"""add or convert some fields in an evaluation dict"""
|
"""add or convert some fields in an evaluation dict"""
|
||||||
# For ScoDoc7 compat
|
# For ScoDoc7 compat
|
||||||
e_dict["heure_debut"] = e.date_debut.strftime("%Hh%M") if e.date_debut else ""
|
e_dict["heure_debut"] = e.date_debut.strftime(scu.TIME_FMT) if e.date_debut else ""
|
||||||
e_dict["heure_fin"] = e.date_fin.strftime("%Hh%M") if e.date_fin else ""
|
e_dict["heure_fin"] = e.date_fin.strftime(scu.TIME_FMT) if e.date_fin else ""
|
||||||
e_dict["jour_iso"] = e.date_debut.isoformat() if e.date_debut else ""
|
e_dict["jour_iso"] = e.date_debut.isoformat() if e.date_debut else ""
|
||||||
# Calcule durée en minutes
|
# Calcule durée en minutes
|
||||||
e_dict["descrheure"] = e.descr_heure()
|
e_dict["descrheure"] = e.descr_heure()
|
||||||
|
@ -614,7 +616,7 @@ def check_and_convert_evaluation_args(data: dict, moduleimpl: "ModuleImpl"):
|
||||||
):
|
):
|
||||||
raise ScoValueError(
|
raise ScoValueError(
|
||||||
f"""La date de début de l'évaluation ({
|
f"""La date de début de l'évaluation ({
|
||||||
data["date_debut"].strftime("%d/%m/%Y")
|
data["date_debut"].strftime(scu.DATE_FMT)
|
||||||
}) n'est pas dans le semestre !""",
|
}) n'est pas dans le semestre !""",
|
||||||
dest_url="javascript:history.back();",
|
dest_url="javascript:history.back();",
|
||||||
)
|
)
|
||||||
|
@ -629,7 +631,7 @@ def check_and_convert_evaluation_args(data: dict, moduleimpl: "ModuleImpl"):
|
||||||
):
|
):
|
||||||
raise ScoValueError(
|
raise ScoValueError(
|
||||||
f"""La date de fin de l'évaluation ({
|
f"""La date de fin de l'évaluation ({
|
||||||
data["date_fin"].strftime("%d/%m/%Y")
|
data["date_fin"].strftime(scu.DATE_FMT)
|
||||||
}) n'est pas dans le semestre !""",
|
}) n'est pas dans le semestre !""",
|
||||||
dest_url="javascript:history.back();",
|
dest_url="javascript:history.back();",
|
||||||
)
|
)
|
||||||
|
|
|
@ -232,7 +232,9 @@ class ScolarNews(db.Model):
|
||||||
)
|
)
|
||||||
|
|
||||||
# Transforme les URL en URL absolues
|
# Transforme les URL en URL absolues
|
||||||
base = scu.ScoURL()
|
base = url_for("scolar.index_html", scodoc_dept=g.scodoc_dept)[
|
||||||
|
: -len("/index_html")
|
||||||
|
]
|
||||||
txt = re.sub('href=/.*?"', 'href="' + base + "/", txt)
|
txt = re.sub('href=/.*?"', 'href="' + base + "/", txt)
|
||||||
|
|
||||||
# Transforme les liens HTML en texte brut: '<a href="url">texte</a>' devient 'texte: url'
|
# Transforme les liens HTML en texte brut: '<a href="url">texte</a>' devient 'texte: url'
|
||||||
|
@ -249,11 +251,12 @@ class ScolarNews(db.Model):
|
||||||
news_list = cls.last_news(n=n)
|
news_list = cls.last_news(n=n)
|
||||||
if not news_list:
|
if not news_list:
|
||||||
return ""
|
return ""
|
||||||
|
dept_news_url = url_for("scolar.dept_news", scodoc_dept=g.scodoc_dept)
|
||||||
H = [
|
H = [
|
||||||
f"""<div class="news"><span class="newstitle"><a href="{
|
f"""<div class="scobox news"><div class="scobox-title"><a href="{
|
||||||
url_for("scolar.dept_news", scodoc_dept=g.scodoc_dept)
|
dept_news_url
|
||||||
}">Dernières opérations</a>
|
}">Dernières opérations</a>
|
||||||
</span><ul class="newslist">"""
|
</div><ul class="newslist">"""
|
||||||
]
|
]
|
||||||
|
|
||||||
for news in news_list:
|
for news in news_list:
|
||||||
|
@ -261,16 +264,22 @@ class ScolarNews(db.Model):
|
||||||
f"""<li class="newslist"><span class="newsdate">{news.formatted_date()}</span><span
|
f"""<li class="newslist"><span class="newsdate">{news.formatted_date()}</span><span
|
||||||
class="newstext">{news}</span></li>"""
|
class="newstext">{news}</span></li>"""
|
||||||
)
|
)
|
||||||
|
H.append(
|
||||||
|
f"""<li class="newslist">
|
||||||
|
<span class="newstext"><a href="{dept_news_url}" class="stdlink">...</a>
|
||||||
|
</span>
|
||||||
|
</li>"""
|
||||||
|
)
|
||||||
|
|
||||||
H.append("</ul>")
|
H.append("</ul></div>")
|
||||||
|
|
||||||
# Informations générales
|
# Informations générales
|
||||||
H.append(
|
H.append(
|
||||||
f"""<div><a class="discretelink" href="{scu.SCO_ANNONCES_WEBSITE}">
|
f"""<div>
|
||||||
Pour en savoir plus sur ScoDoc voir le site scodoc.org</a>.
|
Pour en savoir plus sur ScoDoc voir
|
||||||
|
<a class="stdlink" href="{scu.SCO_ANNONCES_WEBSITE}">scodoc.org</a>
|
||||||
</div>
|
</div>
|
||||||
"""
|
"""
|
||||||
)
|
)
|
||||||
|
|
||||||
H.append("</div>")
|
|
||||||
return "\n".join(H)
|
return "\n".join(H)
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
"""ScoDoc 9 models : Formations
|
"""ScoDoc 9 models : Formations
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
from flask import abort, g
|
||||||
from flask_sqlalchemy.query import Query
|
from flask_sqlalchemy.query import Query
|
||||||
|
|
||||||
import app
|
import app
|
||||||
|
@ -64,6 +66,21 @@ class Formation(db.Model):
|
||||||
"titre complet pour affichage"
|
"titre complet pour affichage"
|
||||||
return f"""Formation {self.titre} ({self.acronyme}) [version {self.version}] code {self.formation_code}"""
|
return f"""Formation {self.titre} ({self.acronyme}) [version {self.version}] code {self.formation_code}"""
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def get_formation(cls, formation_id: int | str, dept_id: int = None) -> "Formation":
|
||||||
|
"""Formation ou 404, cherche uniquement dans le département spécifié
|
||||||
|
ou le courant (g.scodoc_dept)"""
|
||||||
|
if not isinstance(formation_id, int):
|
||||||
|
try:
|
||||||
|
formation_id = int(formation_id)
|
||||||
|
except (TypeError, ValueError):
|
||||||
|
abort(404, "formation_id invalide")
|
||||||
|
if g.scodoc_dept:
|
||||||
|
dept_id = dept_id if dept_id is not None else g.scodoc_dept_id
|
||||||
|
if dept_id is not None:
|
||||||
|
return cls.query.filter_by(id=formation_id, dept_id=dept_id).first_or_404()
|
||||||
|
return cls.query.filter_by(id=formation_id).first_or_404()
|
||||||
|
|
||||||
def to_dict(self, with_refcomp_attrs=False, with_departement=True):
|
def to_dict(self, with_refcomp_attrs=False, with_departement=True):
|
||||||
"""As a dict.
|
"""As a dict.
|
||||||
Si with_refcomp_attrs, ajoute attributs permettant de retrouver le ref. de comp.
|
Si with_refcomp_attrs, ajoute attributs permettant de retrouver le ref. de comp.
|
||||||
|
|
|
@ -208,7 +208,7 @@ class FormSemestre(models.ScoDocModel):
|
||||||
return cls.query.filter_by(id=formsemestre_id).first_or_404()
|
return cls.query.filter_by(id=formsemestre_id).first_or_404()
|
||||||
|
|
||||||
def sort_key(self) -> tuple:
|
def sort_key(self) -> tuple:
|
||||||
"""clé pour tris par ordre alphabétique
|
"""clé pour tris par ordre de date_debut, le plus ancien en tête
|
||||||
(pour avoir le plus récent d'abord, sort avec reverse=True)"""
|
(pour avoir le plus récent d'abord, sort avec reverse=True)"""
|
||||||
return (self.date_debut, self.semestre_id)
|
return (self.date_debut, self.semestre_id)
|
||||||
|
|
||||||
|
@ -224,12 +224,12 @@ class FormSemestre(models.ScoDocModel):
|
||||||
d["formsemestre_id"] = self.id
|
d["formsemestre_id"] = self.id
|
||||||
d["titre_num"] = self.titre_num()
|
d["titre_num"] = self.titre_num()
|
||||||
if self.date_debut:
|
if self.date_debut:
|
||||||
d["date_debut"] = self.date_debut.strftime("%d/%m/%Y")
|
d["date_debut"] = self.date_debut.strftime(scu.DATE_FMT)
|
||||||
d["date_debut_iso"] = self.date_debut.isoformat()
|
d["date_debut_iso"] = self.date_debut.isoformat()
|
||||||
else:
|
else:
|
||||||
d["date_debut"] = d["date_debut_iso"] = ""
|
d["date_debut"] = d["date_debut_iso"] = ""
|
||||||
if self.date_fin:
|
if self.date_fin:
|
||||||
d["date_fin"] = self.date_fin.strftime("%d/%m/%Y")
|
d["date_fin"] = self.date_fin.strftime(scu.DATE_FMT)
|
||||||
d["date_fin_iso"] = self.date_fin.isoformat()
|
d["date_fin_iso"] = self.date_fin.isoformat()
|
||||||
else:
|
else:
|
||||||
d["date_fin"] = d["date_fin_iso"] = ""
|
d["date_fin"] = d["date_fin_iso"] = ""
|
||||||
|
@ -247,7 +247,7 @@ class FormSemestre(models.ScoDocModel):
|
||||||
|
|
||||||
def to_dict_api(self):
|
def to_dict_api(self):
|
||||||
"""
|
"""
|
||||||
Un dict avec les informations sur le semestre destiné à l'api
|
Un dict avec les informations sur le semestre destinées à l'api
|
||||||
"""
|
"""
|
||||||
d = dict(self.__dict__)
|
d = dict(self.__dict__)
|
||||||
d.pop("_sa_instance_state", None)
|
d.pop("_sa_instance_state", None)
|
||||||
|
@ -255,12 +255,12 @@ class FormSemestre(models.ScoDocModel):
|
||||||
d["annee_scolaire"] = self.annee_scolaire()
|
d["annee_scolaire"] = self.annee_scolaire()
|
||||||
d["bul_hide_xml"] = self.bul_hide_xml
|
d["bul_hide_xml"] = self.bul_hide_xml
|
||||||
if self.date_debut:
|
if self.date_debut:
|
||||||
d["date_debut"] = self.date_debut.strftime("%d/%m/%Y")
|
d["date_debut"] = self.date_debut.strftime(scu.DATE_FMT)
|
||||||
d["date_debut_iso"] = self.date_debut.isoformat()
|
d["date_debut_iso"] = self.date_debut.isoformat()
|
||||||
else:
|
else:
|
||||||
d["date_debut"] = d["date_debut_iso"] = ""
|
d["date_debut"] = d["date_debut_iso"] = ""
|
||||||
if self.date_fin:
|
if self.date_fin:
|
||||||
d["date_fin"] = self.date_fin.strftime("%d/%m/%Y")
|
d["date_fin"] = self.date_fin.strftime(scu.DATE_FMT)
|
||||||
d["date_fin_iso"] = self.date_fin.isoformat()
|
d["date_fin_iso"] = self.date_fin.isoformat()
|
||||||
else:
|
else:
|
||||||
d["date_fin"] = d["date_fin_iso"] = ""
|
d["date_fin"] = d["date_fin_iso"] = ""
|
||||||
|
@ -936,12 +936,16 @@ class FormSemestre(models.ScoDocModel):
|
||||||
partitions += [p for p in self.partitions if p.partition_name is None]
|
partitions += [p for p in self.partitions if p.partition_name is None]
|
||||||
return partitions
|
return partitions
|
||||||
|
|
||||||
@cached_property
|
def etudids_actifs(self) -> tuple[list[int], set[int]]:
|
||||||
def etudids_actifs(self) -> set:
|
"""Liste les etudids inscrits (incluant DEM et DEF),
|
||||||
"Set des etudids inscrits non démissionnaires et non défaillants"
|
qui ser al'index des dataframes de notes
|
||||||
return {ins.etudid for ins in self.inscriptions if ins.etat == scu.INSCRIT}
|
et donne l'ensemble des inscrits non DEM ni DEF.
|
||||||
|
"""
|
||||||
|
return [inscr.etudid for inscr in self.inscriptions], {
|
||||||
|
ins.etudid for ins in self.inscriptions if ins.etat == scu.INSCRIT
|
||||||
|
}
|
||||||
|
|
||||||
@cached_property
|
@property
|
||||||
def etuds_inscriptions(self) -> dict:
|
def etuds_inscriptions(self) -> dict:
|
||||||
"""Map { etudid : inscription } (incluant DEM et DEF)"""
|
"""Map { etudid : inscription } (incluant DEM et DEF)"""
|
||||||
return {ins.etud.id: ins for ins in self.inscriptions}
|
return {ins.etud.id: ins for ins in self.inscriptions}
|
||||||
|
|
|
@ -409,6 +409,14 @@ class UniteEns(models.ScoDocModel):
|
||||||
Renvoie (True, "") si ok, sinon (False, error_message)
|
Renvoie (True, "") si ok, sinon (False, error_message)
|
||||||
"""
|
"""
|
||||||
msg = ""
|
msg = ""
|
||||||
|
# Safety check
|
||||||
|
if self.formation.referentiel_competence is None:
|
||||||
|
return False, "pas de référentiel de compétence"
|
||||||
|
# Si tous les parcours, aucun (tronc commun)
|
||||||
|
if {p.id for p in parcours} == {
|
||||||
|
p.id for p in self.formation.referentiel_competence.parcours
|
||||||
|
}:
|
||||||
|
parcours = []
|
||||||
# Le niveau est-il dans tous ces parcours ? Sinon, l'enlève
|
# Le niveau est-il dans tous ces parcours ? Sinon, l'enlève
|
||||||
prev_niveau = self.niveau_competence
|
prev_niveau = self.niveau_competence
|
||||||
if (
|
if (
|
||||||
|
@ -424,6 +432,7 @@ class UniteEns(models.ScoDocModel):
|
||||||
self.niveau_competence, parcours
|
self.niveau_competence, parcours
|
||||||
)
|
)
|
||||||
if not ok:
|
if not ok:
|
||||||
|
self.formation.invalidate_cached_sems()
|
||||||
self.niveau_competence = prev_niveau # restore
|
self.niveau_competence = prev_niveau # restore
|
||||||
return False, error_message
|
return False, error_message
|
||||||
|
|
||||||
|
|
|
@ -72,7 +72,7 @@ class ScolarFormSemestreValidation(db.Model):
|
||||||
return f"""décision sur UE {self.ue.acronyme if self.ue else self.ue_id
|
return f"""décision sur UE {self.ue.acronyme if self.ue else self.ue_id
|
||||||
} ({self.ue_id}): {self.code}"""
|
} ({self.ue_id}): {self.code}"""
|
||||||
return f"""décision sur semestre {self.formsemestre.titre_mois()} du {
|
return f"""décision sur semestre {self.formsemestre.titre_mois()} du {
|
||||||
self.event_date.strftime("%d/%m/%Y")}"""
|
self.event_date.strftime(scu.DATE_FMT)}"""
|
||||||
|
|
||||||
def delete(self):
|
def delete(self):
|
||||||
"Efface cette validation"
|
"Efface cette validation"
|
||||||
|
@ -113,14 +113,14 @@ class ScolarFormSemestreValidation(db.Model):
|
||||||
if self.ue.parcours else ""}
|
if self.ue.parcours else ""}
|
||||||
{("émise par " + link)}
|
{("émise par " + link)}
|
||||||
: <b>{self.code}</b>{moyenne}
|
: <b>{self.code}</b>{moyenne}
|
||||||
le {self.event_date.strftime("%d/%m/%Y")} à {self.event_date.strftime("%Hh%M")}
|
le {self.event_date.strftime(scu.DATEATIME_FMT)}
|
||||||
"""
|
"""
|
||||||
else:
|
else:
|
||||||
return f"""Validation du semestre S{
|
return f"""Validation du semestre S{
|
||||||
self.formsemestre.semestre_id if self.formsemestre else "?"}
|
self.formsemestre.semestre_id if self.formsemestre else "?"}
|
||||||
{self.formsemestre.html_link_status() if self.formsemestre else ""}
|
{self.formsemestre.html_link_status() if self.formsemestre else ""}
|
||||||
: <b>{self.code}</b>
|
: <b>{self.code}</b>
|
||||||
le {self.event_date.strftime("%d/%m/%Y")} à {self.event_date.strftime("%Hh%M")}
|
le {self.event_date.strftime(scu.DATEATIME_FMT)}
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def ects(self) -> float:
|
def ects(self) -> float:
|
||||||
|
@ -175,8 +175,8 @@ class ScolarAutorisationInscription(db.Model):
|
||||||
)
|
)
|
||||||
return f"""Autorisation de passage vers <b>S{self.semestre_id}</b> émise par
|
return f"""Autorisation de passage vers <b>S{self.semestre_id}</b> émise par
|
||||||
{link}
|
{link}
|
||||||
le {self.date.strftime("%d/%m/%Y")} à {self.date.strftime("%Hh%M")}
|
le {self.date.strftime(scu.DATEATIME_FMT)}
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def autorise_etud(
|
def autorise_etud(
|
||||||
|
|
|
@ -48,6 +48,7 @@ from typing import Any
|
||||||
from urllib.parse import urlparse, urlencode, parse_qs, urlunparse
|
from urllib.parse import urlparse, urlencode, parse_qs, urlunparse
|
||||||
|
|
||||||
from openpyxl.utils import get_column_letter
|
from openpyxl.utils import get_column_letter
|
||||||
|
import reportlab
|
||||||
from reportlab.platypus import Paragraph, Spacer
|
from reportlab.platypus import Paragraph, Spacer
|
||||||
from reportlab.platypus import Table, KeepInFrame
|
from reportlab.platypus import Table, KeepInFrame
|
||||||
from reportlab.lib.colors import Color
|
from reportlab.lib.colors import Color
|
||||||
|
@ -263,16 +264,16 @@ class GenTable:
|
||||||
colspan_count -= 1
|
colspan_count -= 1
|
||||||
# if colspan_count > 0:
|
# if colspan_count > 0:
|
||||||
# continue # skip cells after a span
|
# continue # skip cells after a span
|
||||||
if pdf_mode:
|
if pdf_mode and f"_{cid}_pdf" in row:
|
||||||
content = row.get(f"_{cid}_pdf", False) or row.get(cid, "")
|
content = row[f"_{cid}_pdf"]
|
||||||
elif xls_mode:
|
elif xls_mode and f"_{cid}_xls" in row:
|
||||||
content = row.get(f"_{cid}_xls", False) or row.get(cid, "")
|
content = row[f"_{cid}_xls"]
|
||||||
else:
|
else:
|
||||||
content = row.get(cid, "")
|
content = row.get(cid, "")
|
||||||
# Convert None to empty string ""
|
# Convert None to empty string ""
|
||||||
content = "" if content is None else content
|
content = "" if content is None else content
|
||||||
|
|
||||||
colspan = row.get("_%s_colspan" % cid, 0)
|
colspan = row.get(f"_{cid}_colspan", 0)
|
||||||
if colspan > 1:
|
if colspan > 1:
|
||||||
pdf_style_list.append(
|
pdf_style_list.append(
|
||||||
(
|
(
|
||||||
|
@ -676,6 +677,7 @@ class GenTable:
|
||||||
fmt="html",
|
fmt="html",
|
||||||
page_title="",
|
page_title="",
|
||||||
filename=None,
|
filename=None,
|
||||||
|
cssstyles=[],
|
||||||
javascripts=[],
|
javascripts=[],
|
||||||
with_html_headers=True,
|
with_html_headers=True,
|
||||||
publish=True,
|
publish=True,
|
||||||
|
@ -696,6 +698,7 @@ class GenTable:
|
||||||
H.append(
|
H.append(
|
||||||
self.html_header
|
self.html_header
|
||||||
or html_sco_header.sco_header(
|
or html_sco_header.sco_header(
|
||||||
|
cssstyles=cssstyles,
|
||||||
page_title=page_title,
|
page_title=page_title,
|
||||||
javascripts=javascripts,
|
javascripts=javascripts,
|
||||||
init_qtip=init_qtip,
|
init_qtip=init_qtip,
|
||||||
|
@ -721,7 +724,7 @@ class GenTable:
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
return pdf_doc
|
return pdf_doc
|
||||||
elif fmt == "xls" or fmt == "xlsx": # dans les 2 cas retourne du xlsx
|
elif fmt in ("xls", "xlsx"): # dans les 2 cas retourne du xlsx
|
||||||
xls = self.excel()
|
xls = self.excel()
|
||||||
if publish:
|
if publish:
|
||||||
return scu.send_file(
|
return scu.send_file(
|
||||||
|
@ -730,8 +733,7 @@ class GenTable:
|
||||||
suffix=scu.XLSX_SUFFIX,
|
suffix=scu.XLSX_SUFFIX,
|
||||||
mime=scu.XLSX_MIMETYPE,
|
mime=scu.XLSX_MIMETYPE,
|
||||||
)
|
)
|
||||||
else:
|
return xls
|
||||||
return xls
|
|
||||||
elif fmt == "text":
|
elif fmt == "text":
|
||||||
return self.text()
|
return self.text()
|
||||||
elif fmt == "csv":
|
elif fmt == "csv":
|
||||||
|
@ -811,7 +813,10 @@ if __name__ == "__main__":
|
||||||
document,
|
document,
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
document.build(objects)
|
try:
|
||||||
|
document.build(objects)
|
||||||
|
except (ValueError, KeyError, reportlab.platypus.doctemplate.LayoutError) as exc:
|
||||||
|
raise ScoPDFFormatError(str(exc)) from exc
|
||||||
data = doc.getvalue()
|
data = doc.getvalue()
|
||||||
with open("/tmp/gen_table.pdf", "wb") as f:
|
with open("/tmp/gen_table.pdf", "wb") as f:
|
||||||
f.write(data)
|
f.write(data)
|
||||||
|
|
|
@ -30,7 +30,7 @@
|
||||||
|
|
||||||
import html
|
import html
|
||||||
|
|
||||||
from flask import g, render_template
|
from flask import g, render_template, url_for
|
||||||
from flask import request
|
from flask import request
|
||||||
from flask_login import current_user
|
from flask_login import current_user
|
||||||
|
|
||||||
|
@ -163,7 +163,7 @@ def sco_header(
|
||||||
params = {
|
params = {
|
||||||
"page_title": page_title or sco_version.SCONAME,
|
"page_title": page_title or sco_version.SCONAME,
|
||||||
"no_side_bar": no_side_bar,
|
"no_side_bar": no_side_bar,
|
||||||
"ScoURL": scu.ScoURL(),
|
"ScoURL": url_for("scolar.index_html", scodoc_dept=g.scodoc_dept),
|
||||||
"encoding": scu.SCO_ENCODING,
|
"encoding": scu.SCO_ENCODING,
|
||||||
"titrebandeau_mkup": "<td>" + titrebandeau + "</td>",
|
"titrebandeau_mkup": "<td>" + titrebandeau + "</td>",
|
||||||
"authuser": current_user.user_name,
|
"authuser": current_user.user_name,
|
||||||
|
@ -179,6 +179,7 @@ def sco_header(
|
||||||
|
|
||||||
H = [
|
H = [
|
||||||
"""<!DOCTYPE html><html lang="fr">
|
"""<!DOCTYPE html><html lang="fr">
|
||||||
|
<!-- ScoDoc legacy -->
|
||||||
<head>
|
<head>
|
||||||
<meta charset="utf-8"/>
|
<meta charset="utf-8"/>
|
||||||
<title>%(page_title)s</title>
|
<title>%(page_title)s</title>
|
||||||
|
@ -219,7 +220,7 @@ def sco_header(
|
||||||
<script>
|
<script>
|
||||||
window.onload=function(){{enableTooltips("gtrcontent")}};
|
window.onload=function(){{enableTooltips("gtrcontent")}};
|
||||||
|
|
||||||
const SCO_URL="{scu.ScoURL()}";
|
const SCO_URL="{url_for("scolar.index_html", scodoc_dept=g.scodoc_dept)}";
|
||||||
const SCO_TIMEZONE="{scu.TIME_ZONE}";
|
const SCO_TIMEZONE="{scu.TIME_ZONE}";
|
||||||
</script>"""
|
</script>"""
|
||||||
)
|
)
|
||||||
|
@ -303,13 +304,16 @@ def sco_header(
|
||||||
# div pour affichage messages temporaires
|
# div pour affichage messages temporaires
|
||||||
H.append('<div id="sco_msg" class="head_message"></div>')
|
H.append('<div id="sco_msg" class="head_message"></div>')
|
||||||
#
|
#
|
||||||
|
H.append('<div class="sco-app-content">')
|
||||||
return "".join(H)
|
return "".join(H)
|
||||||
|
|
||||||
|
|
||||||
def sco_footer():
|
def sco_footer():
|
||||||
"""Main HTMl pages footer"""
|
"""Main HTMl pages footer"""
|
||||||
return (
|
return (
|
||||||
"""</div><!-- /gtrcontent -->""" + scu.CUSTOM_HTML_FOOTER + """</body></html>"""
|
"""</div></div><!-- /gtrcontent -->"""
|
||||||
|
+ scu.CUSTOM_HTML_FOOTER
|
||||||
|
+ """</body></html>"""
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -102,25 +102,33 @@ def sidebar_common():
|
||||||
<a href="{home_link}" class="sidebar">Accueil</a> <br>
|
<a href="{home_link}" class="sidebar">Accueil</a> <br>
|
||||||
<div id="authuser"><a id="authuserlink" href="{
|
<div id="authuser"><a id="authuserlink" href="{
|
||||||
url_for("users.user_info_page",
|
url_for("users.user_info_page",
|
||||||
scodoc_dept=g.scodoc_dept, user_name=current_user.user_name)
|
scodoc_dept=g.scodoc_dept, user_name=current_user.user_name)
|
||||||
}">{current_user.user_name}</a>
|
}">{current_user.user_name}</a>
|
||||||
<br><a id="deconnectlink" href="{url_for("auth.logout")}">déconnexion</a>
|
<br><a id="deconnectlink" href="{url_for("auth.logout")}">déconnexion</a>
|
||||||
</div>
|
</div>
|
||||||
{sidebar_dept()}
|
{sidebar_dept()}
|
||||||
<h2 class="insidebar">Scolarité</h2>
|
<h2 class="insidebar">Scolarité</h2>
|
||||||
<a href="{scu.ScoURL()}" class="sidebar">Semestres</a> <br>
|
<a href="{
|
||||||
<a href="{scu.NotesURL()}" class="sidebar">Formations</a> <br>
|
url_for("scolar.index_html", scodoc_dept=g.scodoc_dept)
|
||||||
|
}" class="sidebar">Semestres</a> <br>
|
||||||
|
<a href="{
|
||||||
|
url_for("notes.index_html", scodoc_dept=g.scodoc_dept)
|
||||||
|
}" class="sidebar">Formations</a> <br>
|
||||||
"""
|
"""
|
||||||
]
|
]
|
||||||
if current_user.has_permission(Permission.AbsChange):
|
if current_user.has_permission(Permission.AbsChange):
|
||||||
H.append(
|
H.append(
|
||||||
f""" <a href="{scu.AssiduitesURL()}" class="sidebar">Assiduité</a> <br> """
|
f""" <a href="{
|
||||||
|
url_for("assiduites.bilan_dept", scodoc_dept=g.scodoc_dept)
|
||||||
|
}" class="sidebar">Assiduité</a> <br> """
|
||||||
)
|
)
|
||||||
if current_user.has_permission(
|
if current_user.has_permission(
|
||||||
Permission.UsersAdmin
|
Permission.UsersAdmin
|
||||||
) or current_user.has_permission(Permission.UsersView):
|
) or current_user.has_permission(Permission.UsersView):
|
||||||
H.append(
|
H.append(
|
||||||
f"""<a href="{scu.UsersURL()}" class="sidebar">Utilisateurs</a> <br>"""
|
f"""<a href="{
|
||||||
|
url_for("users.index_html", scodoc_dept=g.scodoc_dept)
|
||||||
|
}" class="sidebar">Utilisateurs</a> <br>"""
|
||||||
)
|
)
|
||||||
|
|
||||||
if current_user.has_permission(Permission.EditPreferences):
|
if current_user.has_permission(Permission.EditPreferences):
|
||||||
|
@ -141,7 +149,9 @@ def sidebar(etudid: int = None):
|
||||||
params = {}
|
params = {}
|
||||||
|
|
||||||
H = [
|
H = [
|
||||||
f"""<div class="sidebar">
|
f"""
|
||||||
|
<!-- sidebar py -->
|
||||||
|
<div class="sidebar">
|
||||||
{ sidebar_common() }
|
{ sidebar_common() }
|
||||||
<div class="box-chercheetud">Chercher étudiant:<br>
|
<div class="box-chercheetud">Chercher étudiant:<br>
|
||||||
<form method="get" id="form-chercheetud"
|
<form method="get" id="form-chercheetud"
|
||||||
|
@ -180,9 +190,9 @@ def sidebar(etudid: int = None):
|
||||||
)
|
)
|
||||||
H.append(
|
H.append(
|
||||||
f"""<span title="absences du {
|
f"""<span title="absences du {
|
||||||
formsemestre.date_debut.strftime("%d/%m/%Y")
|
formsemestre.date_debut.strftime(scu.DATE_FMT)
|
||||||
} au {
|
} au {
|
||||||
formsemestre.date_fin.strftime("%d/%m/%Y")
|
formsemestre.date_fin.strftime(scu.DATE_FMT)
|
||||||
}">({
|
}">({
|
||||||
sco_preferences.get_preference("assi_metrique", None)})
|
sco_preferences.get_preference("assi_metrique", None)})
|
||||||
<br>{nbabsjust:1g} J., {nbabsnj:1g} N.J.</span>"""
|
<br>{nbabsjust:1g} J., {nbabsnj:1g} N.J.</span>"""
|
||||||
|
|
|
@ -12,6 +12,7 @@ import psycopg2.extras
|
||||||
|
|
||||||
from app import log
|
from app import log
|
||||||
from app.scodoc.sco_exceptions import ScoException, ScoValueError, NoteProcessError
|
from app.scodoc.sco_exceptions import ScoException, ScoValueError, NoteProcessError
|
||||||
|
from app.scodoc import sco_utils as scu
|
||||||
|
|
||||||
quote_html = html.escape
|
quote_html = html.escape
|
||||||
|
|
||||||
|
@ -460,7 +461,8 @@ def dictfilter(d, fields, filter_nulls=True):
|
||||||
# --- Misc Tools
|
# --- Misc Tools
|
||||||
|
|
||||||
|
|
||||||
def DateDMYtoISO(dmy: str, null_is_empty=False) -> str | None: # XXX deprecated
|
# XXX deprecated, voir convert_fr_date
|
||||||
|
def DateDMYtoISO(dmy: str, null_is_empty=False) -> str | None:
|
||||||
"""Convert date string from french format (or ISO) to ISO.
|
"""Convert date string from french format (or ISO) to ISO.
|
||||||
If null_is_empty (default false), returns "" if no input.
|
If null_is_empty (default false), returns "" if no input.
|
||||||
"""
|
"""
|
||||||
|
@ -474,7 +476,7 @@ def DateDMYtoISO(dmy: str, null_is_empty=False) -> str | None: # XXX deprecated
|
||||||
if not isinstance(dmy, str):
|
if not isinstance(dmy, str):
|
||||||
raise ScoValueError(f'Date (j/m/a) invalide: "{dmy}"')
|
raise ScoValueError(f'Date (j/m/a) invalide: "{dmy}"')
|
||||||
try:
|
try:
|
||||||
dt = datetime.datetime.strptime(dmy, "%d/%m/%Y")
|
dt = datetime.datetime.strptime(dmy, scu.DATE_FMT)
|
||||||
except ValueError:
|
except ValueError:
|
||||||
try:
|
try:
|
||||||
dt = datetime.datetime.fromisoformat(dmy)
|
dt = datetime.datetime.fromisoformat(dmy)
|
||||||
|
|
|
@ -34,6 +34,7 @@ from app.models.absences import BilletAbsence
|
||||||
from app.models.etudiants import Identite
|
from app.models.etudiants import Identite
|
||||||
from app.scodoc.gen_tables import GenTable
|
from app.scodoc.gen_tables import GenTable
|
||||||
from app.scodoc import sco_preferences
|
from app.scodoc import sco_preferences
|
||||||
|
from app.scodoc import sco_utils as scu
|
||||||
|
|
||||||
|
|
||||||
def query_billets_etud(etudid: int = None, etat: bool = None) -> Query:
|
def query_billets_etud(etudid: int = None, etat: bool = None) -> Query:
|
||||||
|
@ -89,12 +90,12 @@ def table_billets(
|
||||||
m = " matin"
|
m = " matin"
|
||||||
else:
|
else:
|
||||||
m = " après-midi"
|
m = " après-midi"
|
||||||
billet_dict["abs_begin_str"] = billet.abs_begin.strftime("%d/%m/%Y") + m
|
billet_dict["abs_begin_str"] = billet.abs_begin.strftime(scu.DATE_FMT) + m
|
||||||
if billet.abs_end.hour < 12:
|
if billet.abs_end.hour < 12:
|
||||||
m = " matin"
|
m = " matin"
|
||||||
else:
|
else:
|
||||||
m = " après-midi"
|
m = " après-midi"
|
||||||
billet_dict["abs_end_str"] = billet.abs_end.strftime("%d/%m/%Y") + m
|
billet_dict["abs_end_str"] = billet.abs_end.strftime(scu.DATE_FMT) + m
|
||||||
if billet.etat == 0:
|
if billet.etat == 0:
|
||||||
if billet.justified:
|
if billet.justified:
|
||||||
billet_dict["etat_str"] = "à traiter"
|
billet_dict["etat_str"] = "à traiter"
|
||||||
|
|
|
@ -515,11 +515,13 @@ class ApoEtud(dict):
|
||||||
# ne trouve pas de semestre impair
|
# ne trouve pas de semestre impair
|
||||||
self.validation_annee_but = None
|
self.validation_annee_but = None
|
||||||
return
|
return
|
||||||
self.validation_annee_but: ApcValidationAnnee = ApcValidationAnnee.query.filter_by(
|
self.validation_annee_but: ApcValidationAnnee = (
|
||||||
formsemestre_id=formsemestre.id,
|
ApcValidationAnnee.query.filter_by(
|
||||||
etudid=self.etud["etudid"],
|
formsemestre_id=formsemestre.id,
|
||||||
referentiel_competence_id=self.cur_res.formsemestre.formation.referentiel_competence_id,
|
etudid=self.etud["etudid"],
|
||||||
).first()
|
referentiel_competence_id=self.cur_res.formsemestre.formation.referentiel_competence_id,
|
||||||
|
).first()
|
||||||
|
)
|
||||||
self.is_nar = (
|
self.is_nar = (
|
||||||
self.validation_annee_but and self.validation_annee_but.code == NAR
|
self.validation_annee_but and self.validation_annee_but.code == NAR
|
||||||
)
|
)
|
||||||
|
@ -1003,7 +1005,7 @@ def comp_apo_sems(etape_apogee, annee_scolaire: int) -> list[dict]:
|
||||||
def nar_etuds_table(apo_data, nar_etuds):
|
def nar_etuds_table(apo_data, nar_etuds):
|
||||||
"""Liste les NAR -> excel table"""
|
"""Liste les NAR -> excel table"""
|
||||||
code_etape = apo_data.etape_apogee
|
code_etape = apo_data.etape_apogee
|
||||||
today = datetime.datetime.today().strftime("%d/%m/%y")
|
today = datetime.datetime.today().strftime(scu.DATE_FMT)
|
||||||
rows = []
|
rows = []
|
||||||
nar_etuds.sort(key=lambda k: k["nom"])
|
nar_etuds.sort(key=lambda k: k["nom"])
|
||||||
for e in nar_etuds:
|
for e in nar_etuds:
|
||||||
|
|
|
@ -49,11 +49,13 @@
|
||||||
"""
|
"""
|
||||||
import datetime
|
import datetime
|
||||||
import glob
|
import glob
|
||||||
|
import gzip
|
||||||
import mimetypes
|
import mimetypes
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
import shutil
|
import shutil
|
||||||
import time
|
import time
|
||||||
|
import zlib
|
||||||
|
|
||||||
import chardet
|
import chardet
|
||||||
|
|
||||||
|
@ -62,7 +64,7 @@ from flask import g
|
||||||
import app.scodoc.sco_utils as scu
|
import app.scodoc.sco_utils as scu
|
||||||
from config import Config
|
from config import Config
|
||||||
from app import log
|
from app import log
|
||||||
from app.scodoc.sco_exceptions import ScoValueError
|
from app.scodoc.sco_exceptions import ScoException, ScoValueError
|
||||||
|
|
||||||
|
|
||||||
class BaseArchiver:
|
class BaseArchiver:
|
||||||
|
@ -241,11 +243,13 @@ class BaseArchiver:
|
||||||
filename: str,
|
filename: str,
|
||||||
data: str | bytes,
|
data: str | bytes,
|
||||||
dept_id: int = None,
|
dept_id: int = None,
|
||||||
|
compress=False,
|
||||||
):
|
):
|
||||||
"""Store data in archive, under given filename.
|
"""Store data in archive, under given filename.
|
||||||
Filename may be modified (sanitized): return used filename
|
Filename may be modified (sanitized): return used filename
|
||||||
The file is created or replaced.
|
The file is created or replaced.
|
||||||
data may be str or bytes
|
data may be str or bytes
|
||||||
|
If compress, data is gziped and filename suffix ".gz" added.
|
||||||
"""
|
"""
|
||||||
if isinstance(data, str):
|
if isinstance(data, str):
|
||||||
data = data.encode(scu.SCO_ENCODING)
|
data = data.encode(scu.SCO_ENCODING)
|
||||||
|
@ -255,8 +259,14 @@ class BaseArchiver:
|
||||||
try:
|
try:
|
||||||
scu.GSL.acquire()
|
scu.GSL.acquire()
|
||||||
fname = os.path.join(archive_id, filename)
|
fname = os.path.join(archive_id, filename)
|
||||||
with open(fname, "wb") as f:
|
if compress:
|
||||||
f.write(data)
|
if not fname.endswith(".gz"):
|
||||||
|
fname += ".gz"
|
||||||
|
with gzip.open(fname, "wb") as f:
|
||||||
|
f.write(data)
|
||||||
|
else:
|
||||||
|
with open(fname, "wb") as f:
|
||||||
|
f.write(data)
|
||||||
except FileNotFoundError as exc:
|
except FileNotFoundError as exc:
|
||||||
raise ScoValueError(
|
raise ScoValueError(
|
||||||
f"Erreur stockage archive (dossier inexistant, chemin {fname})"
|
f"Erreur stockage archive (dossier inexistant, chemin {fname})"
|
||||||
|
@ -274,8 +284,17 @@ class BaseArchiver:
|
||||||
fname = os.path.join(archive_id, filename)
|
fname = os.path.join(archive_id, filename)
|
||||||
log(f"reading archive file {fname}")
|
log(f"reading archive file {fname}")
|
||||||
try:
|
try:
|
||||||
with open(fname, "rb") as f:
|
if fname.endswith(".gz"):
|
||||||
data = f.read()
|
try:
|
||||||
|
with gzip.open(fname) as f:
|
||||||
|
data = f.read()
|
||||||
|
except (OSError, EOFError, zlib.error) as exc:
|
||||||
|
raise ScoValueError(
|
||||||
|
f"Erreur lecture archive ({fname} invalide)"
|
||||||
|
) from exc
|
||||||
|
else:
|
||||||
|
with open(fname, "rb") as f:
|
||||||
|
data = f.read()
|
||||||
except FileNotFoundError as exc:
|
except FileNotFoundError as exc:
|
||||||
raise ScoValueError(
|
raise ScoValueError(
|
||||||
f"Erreur lecture archive (inexistant, chemin {fname})"
|
f"Erreur lecture archive (inexistant, chemin {fname})"
|
||||||
|
@ -288,6 +307,8 @@ class BaseArchiver:
|
||||||
"""
|
"""
|
||||||
archive_id = self.get_id_from_name(oid, archive_name, dept_id=dept_id)
|
archive_id = self.get_id_from_name(oid, archive_name, dept_id=dept_id)
|
||||||
data = self.get(archive_id, filename)
|
data = self.get(archive_id, filename)
|
||||||
|
if filename.endswith(".gz"):
|
||||||
|
filename = filename[:-3]
|
||||||
mime = mimetypes.guess_type(filename)[0]
|
mime = mimetypes.guess_type(filename)[0]
|
||||||
if mime is None:
|
if mime is None:
|
||||||
mime = "application/octet-stream"
|
mime = "application/octet-stream"
|
||||||
|
|
|
@ -68,7 +68,7 @@ PV_ARCHIVER = SemsArchiver()
|
||||||
|
|
||||||
|
|
||||||
def do_formsemestre_archive(
|
def do_formsemestre_archive(
|
||||||
formsemestre_id,
|
formsemestre: FormSemestre,
|
||||||
group_ids: list[int] = None, # si indiqué, ne prend que ces groupes
|
group_ids: list[int] = None, # si indiqué, ne prend que ces groupes
|
||||||
description="",
|
description="",
|
||||||
date_jury="",
|
date_jury="",
|
||||||
|
@ -92,19 +92,18 @@ def do_formsemestre_archive(
|
||||||
raise ScoValueError(
|
raise ScoValueError(
|
||||||
"do_formsemestre_archive: version de bulletin demandée invalide"
|
"do_formsemestre_archive: version de bulletin demandée invalide"
|
||||||
)
|
)
|
||||||
formsemestre = FormSemestre.get_formsemestre(formsemestre_id)
|
|
||||||
res: NotesTableCompat = res_sem.load_formsemestre_results(formsemestre)
|
res: NotesTableCompat = res_sem.load_formsemestre_results(formsemestre)
|
||||||
sem_archive_id = formsemestre_id
|
sem_archive_id = formsemestre.id
|
||||||
archive_id = PV_ARCHIVER.create_obj_archive(
|
archive_id = PV_ARCHIVER.create_obj_archive(
|
||||||
sem_archive_id, description, formsemestre.dept_id
|
sem_archive_id, description, formsemestre.dept_id
|
||||||
)
|
)
|
||||||
date = PV_ARCHIVER.get_archive_date(archive_id).strftime("%d/%m/%Y à %H:%M")
|
date = PV_ARCHIVER.get_archive_date(archive_id).strftime(scu.DATEATIME_FMT)
|
||||||
|
|
||||||
if not group_ids:
|
if not group_ids:
|
||||||
# tous les inscrits du semestre
|
# tous les inscrits du semestre
|
||||||
group_ids = [sco_groups.get_default_group(formsemestre_id)]
|
group_ids = [sco_groups.get_default_group(formsemestre.id)]
|
||||||
groups_infos = sco_groups_view.DisplayedGroupsInfos(
|
groups_infos = sco_groups_view.DisplayedGroupsInfos(
|
||||||
group_ids, formsemestre_id=formsemestre_id
|
group_ids, formsemestre_id=formsemestre.id
|
||||||
)
|
)
|
||||||
groups_filename = "-" + groups_infos.groups_filename
|
groups_filename = "-" + groups_infos.groups_filename
|
||||||
etudids = [m["etudid"] for m in groups_infos.members]
|
etudids = [m["etudid"] for m in groups_infos.members]
|
||||||
|
@ -142,19 +141,23 @@ def do_formsemestre_archive(
|
||||||
)
|
)
|
||||||
|
|
||||||
# Bulletins en JSON
|
# Bulletins en JSON
|
||||||
data = gen_formsemestre_recapcomplet_json(formsemestre_id, xml_with_decisions=True)
|
data = gen_formsemestre_recapcomplet_json(formsemestre.id, xml_with_decisions=True)
|
||||||
data_js = json.dumps(data, indent=1, cls=ScoDocJSONEncoder)
|
data_js = json.dumps(data, indent=1, cls=ScoDocJSONEncoder)
|
||||||
if data:
|
if data:
|
||||||
PV_ARCHIVER.store(
|
PV_ARCHIVER.store(
|
||||||
archive_id, "Bulletins.json", data_js, dept_id=formsemestre.dept_id
|
archive_id,
|
||||||
|
"Bulletins.json",
|
||||||
|
data_js,
|
||||||
|
dept_id=formsemestre.dept_id,
|
||||||
|
compress=True,
|
||||||
)
|
)
|
||||||
# Décisions de jury, en XLS
|
# Décisions de jury, en XLS
|
||||||
if formsemestre.formation.is_apc():
|
if formsemestre.formation.is_apc():
|
||||||
response = jury_but_pv.pvjury_page_but(formsemestre_id, fmt="xls")
|
response = jury_but_pv.pvjury_page_but(formsemestre.id, fmt="xls")
|
||||||
data = response.get_data()
|
data = response.get_data()
|
||||||
else: # formations classiques
|
else: # formations classiques
|
||||||
data = sco_pv_forms.formsemestre_pvjury(
|
data = sco_pv_forms.formsemestre_pvjury(
|
||||||
formsemestre_id, fmt="xls", publish=False
|
formsemestre.id, fmt="xls", publish=False
|
||||||
)
|
)
|
||||||
if data:
|
if data:
|
||||||
PV_ARCHIVER.store(
|
PV_ARCHIVER.store(
|
||||||
|
@ -165,7 +168,7 @@ def do_formsemestre_archive(
|
||||||
)
|
)
|
||||||
# Classeur bulletins (PDF)
|
# Classeur bulletins (PDF)
|
||||||
data, _ = sco_bulletins_pdf.get_formsemestre_bulletins_pdf(
|
data, _ = sco_bulletins_pdf.get_formsemestre_bulletins_pdf(
|
||||||
formsemestre_id, version=bul_version
|
formsemestre.id, version=bul_version
|
||||||
)
|
)
|
||||||
if data:
|
if data:
|
||||||
PV_ARCHIVER.store(
|
PV_ARCHIVER.store(
|
||||||
|
@ -173,10 +176,11 @@ def do_formsemestre_archive(
|
||||||
"Bulletins.pdf",
|
"Bulletins.pdf",
|
||||||
data,
|
data,
|
||||||
dept_id=formsemestre.dept_id,
|
dept_id=formsemestre.dept_id,
|
||||||
|
compress=True,
|
||||||
)
|
)
|
||||||
# Lettres individuelles (PDF):
|
# Lettres individuelles (PDF):
|
||||||
data = sco_pv_lettres_inviduelles.pdf_lettres_individuelles(
|
data = sco_pv_lettres_inviduelles.pdf_lettres_individuelles(
|
||||||
formsemestre_id,
|
formsemestre.id,
|
||||||
etudids=etudids,
|
etudids=etudids,
|
||||||
date_jury=date_jury,
|
date_jury=date_jury,
|
||||||
date_commission=date_commission,
|
date_commission=date_commission,
|
||||||
|
@ -217,7 +221,7 @@ def formsemestre_archive(formsemestre_id, group_ids: list[int] = None):
|
||||||
"""Make and store new archive for this formsemestre.
|
"""Make and store new archive for this formsemestre.
|
||||||
(all students or only selected groups)
|
(all students or only selected groups)
|
||||||
"""
|
"""
|
||||||
formsemestre: FormSemestre = FormSemestre.query.get_or_404(formsemestre_id)
|
formsemestre = FormSemestre.get_formsemestre(formsemestre_id)
|
||||||
if not formsemestre.can_edit_pv():
|
if not formsemestre.can_edit_pv():
|
||||||
raise ScoPermissionDenied(
|
raise ScoPermissionDenied(
|
||||||
dest_url=url_for(
|
dest_url=url_for(
|
||||||
|
@ -320,7 +324,7 @@ enregistrés et non modifiables, on peut les retrouver ultérieurement.
|
||||||
else:
|
else:
|
||||||
tf[2]["anonymous"] = False
|
tf[2]["anonymous"] = False
|
||||||
do_formsemestre_archive(
|
do_formsemestre_archive(
|
||||||
formsemestre_id,
|
formsemestre,
|
||||||
group_ids=group_ids,
|
group_ids=group_ids,
|
||||||
description=tf[2]["description"],
|
description=tf[2]["description"],
|
||||||
date_jury=tf[2]["date_jury"],
|
date_jury=tf[2]["date_jury"],
|
||||||
|
@ -352,7 +356,7 @@ def formsemestre_list_archives(formsemestre_id):
|
||||||
"""Page listing archives"""
|
"""Page listing archives"""
|
||||||
formsemestre = FormSemestre.get_formsemestre(formsemestre_id)
|
formsemestre = FormSemestre.get_formsemestre(formsemestre_id)
|
||||||
sem_archive_id = formsemestre_id
|
sem_archive_id = formsemestre_id
|
||||||
L = []
|
archives_descr = []
|
||||||
for archive_id in PV_ARCHIVER.list_obj_archives(
|
for archive_id in PV_ARCHIVER.list_obj_archives(
|
||||||
sem_archive_id, dept_id=formsemestre.dept_id
|
sem_archive_id, dept_id=formsemestre.dept_id
|
||||||
):
|
):
|
||||||
|
@ -366,28 +370,30 @@ def formsemestre_list_archives(formsemestre_id):
|
||||||
archive_id, dept_id=formsemestre.dept_id
|
archive_id, dept_id=formsemestre.dept_id
|
||||||
),
|
),
|
||||||
}
|
}
|
||||||
L.append(a)
|
archives_descr.append(a)
|
||||||
|
|
||||||
H = [html_sco_header.html_sem_header("Archive des PV et résultats ")]
|
H = [html_sco_header.html_sem_header("Archive des PV et résultats ")]
|
||||||
if not L:
|
if not archives_descr:
|
||||||
H.append("<p>aucune archive enregistrée</p>")
|
H.append("<p>aucune archive enregistrée</p>")
|
||||||
else:
|
else:
|
||||||
H.append("<ul>")
|
H.append("<ul>")
|
||||||
for a in L:
|
for a in archives_descr:
|
||||||
archive_name = PV_ARCHIVER.get_archive_name(a["archive_id"])
|
archive_name = PV_ARCHIVER.get_archive_name(a["archive_id"])
|
||||||
H.append(
|
H.append(
|
||||||
'<li>%s : <em>%s</em> (<a href="formsemestre_delete_archive?formsemestre_id=%s&archive_name=%s">supprimer</a>)<ul>'
|
f"""<li>{a["date"].strftime("%d/%m/%Y %H:%M")} : <em>{a["description"]}</em>
|
||||||
% (
|
(<a href="{ url_for( "notes.formsemestre_delete_archive", scodoc_dept=g.scodoc_dept,
|
||||||
a["date"].strftime("%d/%m/%Y %H:%M"),
|
formsemestre_id=formsemestre_id, archive_name=archive_name
|
||||||
a["description"],
|
)}">supprimer</a>)
|
||||||
formsemestre_id,
|
<ul>"""
|
||||||
archive_name,
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
for filename in a["content"]:
|
for filename in a["content"]:
|
||||||
H.append(
|
H.append(
|
||||||
'<li><a href="formsemestre_get_archived_file?formsemestre_id=%s&archive_name=%s&filename=%s">%s</a></li>'
|
f"""<li><a href="{
|
||||||
% (formsemestre_id, archive_name, filename, filename)
|
url_for( "notes.formsemestre_get_archived_file", scodoc_dept=g.scodoc_dept,
|
||||||
|
formsemestre_id=formsemestre_id,
|
||||||
|
archive_name=archive_name,
|
||||||
|
filename=filename
|
||||||
|
)}">{filename[:-3] if filename.endswith(".gz") else filename}</a></li>"""
|
||||||
)
|
)
|
||||||
if not a["content"]:
|
if not a["content"]:
|
||||||
H.append("<li><em>aucun fichier !</em></li>")
|
H.append("<li><em>aucun fichier !</em></li>")
|
||||||
|
@ -399,7 +405,7 @@ def formsemestre_list_archives(formsemestre_id):
|
||||||
|
|
||||||
def formsemestre_get_archived_file(formsemestre_id, archive_name, filename):
|
def formsemestre_get_archived_file(formsemestre_id, archive_name, filename):
|
||||||
"""Send file to client."""
|
"""Send file to client."""
|
||||||
formsemestre: FormSemestre = FormSemestre.query.get_or_404(formsemestre_id)
|
formsemestre = FormSemestre.get_formsemestre(formsemestre_id)
|
||||||
sem_archive_id = formsemestre.id
|
sem_archive_id = formsemestre.id
|
||||||
return PV_ARCHIVER.get_archived_file(
|
return PV_ARCHIVER.get_archived_file(
|
||||||
sem_archive_id, archive_name, filename, dept_id=formsemestre.dept_id
|
sem_archive_id, archive_name, filename, dept_id=formsemestre.dept_id
|
||||||
|
|
|
@ -372,12 +372,38 @@ def str_to_time(time_str: str) -> time:
|
||||||
def get_assiduites_stats(
|
def get_assiduites_stats(
|
||||||
assiduites: Query, metric: str = "all", filtered: dict[str, object] = None
|
assiduites: Query, metric: str = "all", filtered: dict[str, object] = None
|
||||||
) -> dict[str, int | float]:
|
) -> dict[str, int | float]:
|
||||||
"""Compte les assiduités en fonction des filtres"""
|
"""
|
||||||
# XXX TODO-assiduite : documenter !!!
|
Calcule les statistiques sur les assiduités
|
||||||
# Que sont les filtres ? Quelles valeurs ?
|
(nombre de jours, demi-journées et heures passées,
|
||||||
# documenter permet de faire moins de bug: qualité du code non satisfaisante.
|
non justifiées, justifiées et total)
|
||||||
#
|
|
||||||
# + on se perd entre les clés en majuscules et en minuscules. Pourquoi
|
Les filtres :
|
||||||
|
- etat : filtre les assiduités par leur état
|
||||||
|
valeur : (absent, present, retard)
|
||||||
|
- date_debut/date_fin : prend les assiduités qui se trouvent entre les dates
|
||||||
|
valeur : datetime.datetime
|
||||||
|
- moduleimpl_id : filtre les assiduités en fonction du moduleimpl_id
|
||||||
|
valeur : int | None
|
||||||
|
- formsemestre : prend les assiduités du formsemestre donné
|
||||||
|
valeur : FormSemestre
|
||||||
|
- formsemestre_modimpls : prend les assiduités avec un moduleimpl du formsemestre
|
||||||
|
valeur : FormSemestre
|
||||||
|
- est_just : filtre les assiduités en fonction de si elles sont justifiées ou non
|
||||||
|
valeur : bool
|
||||||
|
- user_id : filtre les assiduités en fonction de l'utilisateur qui les a créées
|
||||||
|
valeur : int
|
||||||
|
- split : effectue un comptage par état d'assiduité
|
||||||
|
valeur : str (du moment que la clé est présente dans filtered)
|
||||||
|
|
||||||
|
Les métriques :
|
||||||
|
- journee : comptage en nombre de journée
|
||||||
|
- demi : comptage en nombre de demi journée
|
||||||
|
- heure : comptage en heure
|
||||||
|
- compte : nombre d'objets
|
||||||
|
- all : renvoi toute les métriques
|
||||||
|
|
||||||
|
|
||||||
|
"""
|
||||||
|
|
||||||
if filtered is not None:
|
if filtered is not None:
|
||||||
deb, fin = None, None
|
deb, fin = None, None
|
||||||
|
@ -414,34 +440,71 @@ def get_assiduites_stats(
|
||||||
calculator: CountCalculator = CountCalculator()
|
calculator: CountCalculator = CountCalculator()
|
||||||
calculator.compute_assiduites(assiduites)
|
calculator.compute_assiduites(assiduites)
|
||||||
|
|
||||||
|
# S'il n'y a pas de filtre ou que le filtre split n'est pas dans les filtres
|
||||||
if filtered is None or "split" not in filtered:
|
if filtered is None or "split" not in filtered:
|
||||||
|
# On récupère le comptage total
|
||||||
|
# only_total permet de ne récupérer que le total
|
||||||
count: dict = calculator.to_dict(only_total=True)
|
count: dict = calculator.to_dict(only_total=True)
|
||||||
|
|
||||||
|
# On ne garde que les métriques demandées
|
||||||
for key, val in count.items():
|
for key, val in count.items():
|
||||||
if key in metrics:
|
if key in metrics:
|
||||||
output[key] = val
|
output[key] = val
|
||||||
|
# On renvoie le total si on a rien demandé (ou que metrics == ["all"])
|
||||||
return output if output else count
|
return output if output else count
|
||||||
|
|
||||||
# Récupération des états
|
|
||||||
etats: list[str] = (
|
|
||||||
filtered["etat"].split(",") if "etat" in filtered else scu.EtatAssiduite.all()
|
|
||||||
)
|
|
||||||
|
|
||||||
# être sur que les états sont corrects
|
|
||||||
etats = [etat for etat in etats if etat.upper() in scu.EtatAssiduite.all()]
|
|
||||||
|
|
||||||
# Préparation du dictionnaire de retour avec les valeurs du calcul
|
# Préparation du dictionnaire de retour avec les valeurs du calcul
|
||||||
count: dict = calculator.to_dict(only_total=False)
|
count: dict = calculator.to_dict(only_total=False)
|
||||||
|
|
||||||
|
# Récupération des états depuis la saisie utilisateur
|
||||||
|
etats: list[str] = (
|
||||||
|
filtered["etat"].split(",") if "etat" in filtered else scu.EtatAssiduite.all()
|
||||||
|
)
|
||||||
for etat in etats:
|
for etat in etats:
|
||||||
# TODO-assiduite: on se perd entre les lower et upper.
|
# On vérifie que l'état est bien un état d'assiduité
|
||||||
# Pourquoi EtatAssiduite est en majuscules si tout le reste est en minuscules ?
|
# sinon on passe à l'état suivant
|
||||||
etat = etat.lower()
|
if not scu.EtatAssiduite.contains(etat):
|
||||||
|
continue
|
||||||
|
|
||||||
|
# On récupère le comptage pour chaque état
|
||||||
if etat != "present":
|
if etat != "present":
|
||||||
output[etat] = count[etat]
|
output[etat] = count[etat]
|
||||||
output[etat]["justifie"] = count[etat + "_just"]
|
output[etat]["justifie"] = count[etat + "_just"]
|
||||||
output[etat]["non_justifie"] = count[etat + "_non_just"]
|
output[etat]["non_justifie"] = count[etat + "_non_just"]
|
||||||
else:
|
else:
|
||||||
output[etat] = count[etat]
|
output[etat] = count[etat]
|
||||||
|
|
||||||
output["total"] = count["total"]
|
output["total"] = count["total"]
|
||||||
|
|
||||||
|
# le dictionnaire devrait ressembler à :
|
||||||
|
# {
|
||||||
|
# "absent": {
|
||||||
|
# "journee": 1,
|
||||||
|
# "demi": 2,
|
||||||
|
# "heure": 3,
|
||||||
|
# "compte": 4,
|
||||||
|
# "justifie": {
|
||||||
|
# "journee": 1,
|
||||||
|
# "demi": 2,
|
||||||
|
# "heure": 3,
|
||||||
|
# "compte": 4
|
||||||
|
# },
|
||||||
|
# "non_justifie": {
|
||||||
|
# "journee": 1,
|
||||||
|
# "demi": 2,
|
||||||
|
# "heure": 3,
|
||||||
|
# "compte": 4
|
||||||
|
# }
|
||||||
|
# },
|
||||||
|
# ...
|
||||||
|
# "total": {
|
||||||
|
# "journee": 1,
|
||||||
|
# "demi": 2,
|
||||||
|
# "heure": 3,
|
||||||
|
# "compte": 4
|
||||||
|
# }
|
||||||
|
# }
|
||||||
|
|
||||||
return output
|
return output
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -126,7 +126,7 @@ def make_context_dict(formsemestre: FormSemestre, etud: dict) -> dict:
|
||||||
|
|
||||||
# ajoute date courante
|
# ajoute date courante
|
||||||
t = time.localtime()
|
t = time.localtime()
|
||||||
C["date_dmy"] = time.strftime("%d/%m/%Y", t)
|
C["date_dmy"] = time.strftime(scu.DATE_FMT, t)
|
||||||
C["date_iso"] = time.strftime("%Y-%m-%d", t)
|
C["date_iso"] = time.strftime("%Y-%m-%d", t)
|
||||||
|
|
||||||
return C
|
return C
|
||||||
|
@ -446,7 +446,8 @@ def _ue_mod_bulletin(
|
||||||
):
|
):
|
||||||
"""Infos sur les modules (et évaluations) dans une UE
|
"""Infos sur les modules (et évaluations) dans une UE
|
||||||
(ajoute les informations aux modimpls)
|
(ajoute les informations aux modimpls)
|
||||||
Result: liste de modules de l'UE avec les infos dans chacun (seulement ceux où l'étudiant est inscrit).
|
Result: liste de modules de l'UE avec les infos dans chacun (seulement
|
||||||
|
ceux où l'étudiant est inscrit).
|
||||||
"""
|
"""
|
||||||
bul_show_mod_rangs = sco_preferences.get_preference(
|
bul_show_mod_rangs = sco_preferences.get_preference(
|
||||||
"bul_show_mod_rangs", formsemestre_id
|
"bul_show_mod_rangs", formsemestre_id
|
||||||
|
|
|
@ -61,7 +61,7 @@ from flask_login import current_user
|
||||||
|
|
||||||
from app.models import FormSemestre, Identite, ScoDocSiteConfig
|
from app.models import FormSemestre, Identite, ScoDocSiteConfig
|
||||||
from app.scodoc import sco_utils as scu
|
from app.scodoc import sco_utils as scu
|
||||||
from app.scodoc.sco_exceptions import NoteProcessError
|
from app.scodoc.sco_exceptions import NoteProcessError, ScoPDFFormatError
|
||||||
from app import log
|
from app import log
|
||||||
from app.scodoc import sco_formsemestre
|
from app.scodoc import sco_formsemestre
|
||||||
from app.scodoc import sco_pdf
|
from app.scodoc import sco_pdf
|
||||||
|
@ -228,7 +228,15 @@ class BulletinGenerator:
|
||||||
preferences=sco_preferences.SemPreferences(formsemestre_id),
|
preferences=sco_preferences.SemPreferences(formsemestre_id),
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
document.build(story)
|
try:
|
||||||
|
document.build(story)
|
||||||
|
except (
|
||||||
|
ValueError,
|
||||||
|
KeyError,
|
||||||
|
reportlab.platypus.doctemplate.LayoutError,
|
||||||
|
) as exc:
|
||||||
|
raise ScoPDFFormatError(str(exc)) from exc
|
||||||
|
|
||||||
data = report.getvalue()
|
data = report.getvalue()
|
||||||
return data
|
return data
|
||||||
|
|
||||||
|
|
|
@ -89,7 +89,7 @@ def formsemestre_bulletinetud_published_dict(
|
||||||
version="long",
|
version="long",
|
||||||
) -> dict:
|
) -> dict:
|
||||||
"""Dictionnaire representant les informations _publiees_ du bulletin de notes
|
"""Dictionnaire representant les informations _publiees_ du bulletin de notes
|
||||||
Utilisé pour JSON, devrait l'être aussi pour XML. (todo)
|
Utilisé pour JSON des formations classiques (mais pas pour le XML, qui est deprecated).
|
||||||
|
|
||||||
version:
|
version:
|
||||||
short (sans les évaluations)
|
short (sans les évaluations)
|
||||||
|
@ -169,6 +169,21 @@ def formsemestre_bulletinetud_published_dict(
|
||||||
pid = partition["partition_id"]
|
pid = partition["partition_id"]
|
||||||
partitions_etud_groups[pid] = sco_groups.get_etud_groups_in_partition(pid)
|
partitions_etud_groups[pid] = sco_groups.get_etud_groups_in_partition(pid)
|
||||||
|
|
||||||
|
# Il serait préférable de factoriser et d'avoir la même section
|
||||||
|
# "semestre" que celle des bulletins BUT.
|
||||||
|
etud_groups = sco_groups.get_etud_formsemestre_groups(
|
||||||
|
etud, formsemestre, only_to_show=True
|
||||||
|
)
|
||||||
|
d["semestre"] = {
|
||||||
|
"etapes": [str(x.etape_apo) for x in formsemestre.etapes if x.etape_apo],
|
||||||
|
"date_debut": formsemestre.date_debut.isoformat(),
|
||||||
|
"date_fin": formsemestre.date_fin.isoformat(),
|
||||||
|
"annee_universitaire": formsemestre.annee_scolaire_str(),
|
||||||
|
"numero": formsemestre.semestre_id,
|
||||||
|
"inscription": "", # inutilisé mais nécessaire pour le js de Seb.
|
||||||
|
"groupes": [group.to_dict() for group in etud_groups],
|
||||||
|
}
|
||||||
|
|
||||||
ues_stat = nt.get_ues_stat_dict()
|
ues_stat = nt.get_ues_stat_dict()
|
||||||
modimpls = nt.get_modimpls_dict()
|
modimpls = nt.get_modimpls_dict()
|
||||||
nbetuds = len(nt.etud_moy_gen_ranks)
|
nbetuds = len(nt.etud_moy_gen_ranks)
|
||||||
|
|
|
@ -352,7 +352,7 @@ class BulletinGeneratorLegacy(sco_bulletins_generator.BulletinGenerator):
|
||||||
H.append(
|
H.append(
|
||||||
f"""<p>
|
f"""<p>
|
||||||
<span class="bull_appreciations_date">{
|
<span class="bull_appreciations_date">{
|
||||||
appreciation.date.strftime("%d/%m/%y") if appreciation.date else ""
|
appreciation.date.strftime(scu.DATE_FMT) if appreciation.date else ""
|
||||||
}</span>
|
}</span>
|
||||||
{appreciation.comment_safe()}
|
{appreciation.comment_safe()}
|
||||||
<span class="bull_appreciations_link">{mlink}</span>
|
<span class="bull_appreciations_link">{mlink}</span>
|
||||||
|
|
|
@ -182,7 +182,7 @@ class BulletinGeneratorStandard(sco_bulletins_generator.BulletinGenerator):
|
||||||
H.append(
|
H.append(
|
||||||
f"""<p>
|
f"""<p>
|
||||||
<span class="bull_appreciations_date">{
|
<span class="bull_appreciations_date">{
|
||||||
appreciation.date.strftime("%d/%m/%Y")
|
appreciation.date.strftime(scu.DATE_FMT)
|
||||||
if appreciation.date else ""}</span>
|
if appreciation.date else ""}</span>
|
||||||
{appreciation.comment_safe()}
|
{appreciation.comment_safe()}
|
||||||
<span class="bull_appreciations_link">{mlink}</span>
|
<span class="bull_appreciations_link">{mlink}</span>
|
||||||
|
|
|
@ -55,7 +55,6 @@ from flask import g
|
||||||
|
|
||||||
import app
|
import app
|
||||||
from app import db, log
|
from app import db, log
|
||||||
from app.scodoc import notesdb as ndb
|
|
||||||
from app.scodoc import sco_utils as scu
|
from app.scodoc import sco_utils as scu
|
||||||
from app.scodoc.sco_exceptions import ScoException
|
from app.scodoc.sco_exceptions import ScoException
|
||||||
|
|
||||||
|
@ -174,17 +173,15 @@ class EvaluationCache(ScoDocCache):
|
||||||
@classmethod
|
@classmethod
|
||||||
def invalidate_all_sems(cls):
|
def invalidate_all_sems(cls):
|
||||||
"delete all evaluations in current dept from cache"
|
"delete all evaluations in current dept from cache"
|
||||||
|
from app.models.evaluations import Evaluation
|
||||||
|
from app.models.formsemestre import FormSemestre
|
||||||
|
from app.models.moduleimpls import ModuleImpl
|
||||||
|
|
||||||
evaluation_ids = [
|
evaluation_ids = [
|
||||||
x[0]
|
e.id
|
||||||
for x in ndb.SimpleQuery(
|
for e in Evaluation.query.join(ModuleImpl)
|
||||||
"""SELECT e.id
|
.join(FormSemestre)
|
||||||
FROM notes_evaluation e, notes_moduleimpl mi, notes_formsemestre s
|
.filter_by(dept_id=g.scodoc_dept_id)
|
||||||
WHERE s.dept_id=%(dept_id)s
|
|
||||||
AND s.id = mi.formsemestre_id
|
|
||||||
AND mi.id = e.moduleimpl_id;
|
|
||||||
""",
|
|
||||||
{"dept_id": g.scodoc_dept_id},
|
|
||||||
)
|
|
||||||
]
|
]
|
||||||
cls.delete_many(evaluation_ids)
|
cls.delete_many(evaluation_ids)
|
||||||
|
|
||||||
|
|
|
@ -29,7 +29,6 @@
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import calendar
|
import calendar
|
||||||
import datetime
|
|
||||||
import html
|
import html
|
||||||
import time
|
import time
|
||||||
|
|
||||||
|
@ -231,41 +230,41 @@ def next_iso_day(date):
|
||||||
|
|
||||||
def YearTable(
|
def YearTable(
|
||||||
year,
|
year,
|
||||||
events=[],
|
events_by_day: dict[str, list[dict]],
|
||||||
firstmonth=9,
|
firstmonth=9,
|
||||||
lastmonth=7,
|
lastmonth=7,
|
||||||
halfday=0,
|
|
||||||
dayattributes="",
|
dayattributes="",
|
||||||
pad_width=8,
|
|
||||||
):
|
):
|
||||||
|
# Code simplifié en 2024: utilisé seulement pour calendrier évaluations
|
||||||
"""Generate a calendar table
|
"""Generate a calendar table
|
||||||
events = list of tuples (date, text, color, href [,halfday])
|
events = list of tuples (date, text, color, href [,halfday])
|
||||||
where date is a string in ISO format (yyyy-mm-dd)
|
where date is a string in ISO format (yyyy-mm-dd)
|
||||||
halfday is boolean (true: morning, false: afternoon)
|
halfday is boolean (true: morning, false: afternoon)
|
||||||
text = text to put in calendar (must be short, 1-5 cars) (optional)
|
text = text to put in calendar (must be short, 1-5 cars) (optional)
|
||||||
if halfday, generate 2 cells per day (morning, afternoon)
|
|
||||||
"""
|
"""
|
||||||
T = [
|
T = [
|
||||||
'<table id="maincalendar" class="maincalendar" border="3" cellpadding="1" cellspacing="1" frame="box">'
|
"""<table id="maincalendar" class="maincalendar"
|
||||||
|
border="3" cellpadding="1" cellspacing="1" frame="box">"""
|
||||||
]
|
]
|
||||||
T.append("<tr>")
|
T.append("<tr>")
|
||||||
month = firstmonth
|
month = firstmonth
|
||||||
while 1:
|
while True:
|
||||||
T.append('<td valign="top">')
|
T.append('<td valign="top">')
|
||||||
T.append(MonthTableHead(month))
|
T.append(_month_table_head(month))
|
||||||
T.append(
|
T.append(
|
||||||
MonthTableBody(
|
_month_table_body(
|
||||||
month,
|
month,
|
||||||
year,
|
year,
|
||||||
events,
|
events_by_day,
|
||||||
halfday,
|
|
||||||
dayattributes,
|
dayattributes,
|
||||||
is_work_saturday(),
|
is_work_saturday(),
|
||||||
pad_width=pad_width,
|
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
T.append(MonthTableTail())
|
T.append(
|
||||||
T.append("</td>")
|
"""
|
||||||
|
</table>
|
||||||
|
</td>"""
|
||||||
|
)
|
||||||
if month == lastmonth:
|
if month == lastmonth:
|
||||||
break
|
break
|
||||||
month = month + 1
|
month = month + 1
|
||||||
|
@ -323,29 +322,32 @@ WEEKDAYCOLOR = GRAY1
|
||||||
WEEKENDCOLOR = GREEN3
|
WEEKENDCOLOR = GREEN3
|
||||||
|
|
||||||
|
|
||||||
def MonthTableHead(month):
|
def _month_table_head(month):
|
||||||
color = WHITE
|
color = WHITE
|
||||||
return """<table class="monthcalendar" border="0" cellpadding="0" cellspacing="0" frame="box">
|
return f"""<table class="monthcalendar" border="0" cellpadding="0" cellspacing="0" frame="box">
|
||||||
<tr bgcolor="%s"><td class="calcol" colspan="2" align="center">%s</td></tr>\n""" % (
|
<tr bgcolor="{color}">
|
||||||
color,
|
<td class="calcol" colspan="2" align="center">{MONTHNAMES_ABREV[month - 1]}</td>
|
||||||
MONTHNAMES_ABREV[month - 1],
|
</tr>\n"""
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
def MonthTableTail():
|
def _month_table_body(
|
||||||
return "</table>\n"
|
month,
|
||||||
|
year,
|
||||||
|
events_by_day: dict[str, list[dict]],
|
||||||
def MonthTableBody(
|
trattributes="",
|
||||||
month, year, events=[], halfday=0, trattributes="", work_saturday=False, pad_width=8
|
work_saturday=False,
|
||||||
):
|
) -> str:
|
||||||
|
"""
|
||||||
|
events : [event]
|
||||||
|
event = [ yyyy-mm-dd, legend, href, color, descr ] XXX
|
||||||
|
"""
|
||||||
firstday, nbdays = calendar.monthrange(year, month)
|
firstday, nbdays = calendar.monthrange(year, month)
|
||||||
localtime = time.localtime()
|
localtime = time.localtime()
|
||||||
current_weeknum = time.strftime("%U", localtime)
|
current_weeknum = time.strftime("%U", localtime)
|
||||||
current_year = localtime[0]
|
current_year = localtime[0]
|
||||||
T = []
|
rows = []
|
||||||
# cherche date du lundi de la 1ere semaine de ce mois
|
# cherche date du lundi de la 1ere semaine de ce mois
|
||||||
monday = ddmmyyyy("1/%d/%d" % (month, year))
|
monday = ddmmyyyy(f"1/{month}/{year}")
|
||||||
while monday.weekday != 0:
|
while monday.weekday != 0:
|
||||||
monday = monday.prev()
|
monday = monday.prev()
|
||||||
|
|
||||||
|
@ -354,158 +356,51 @@ def MonthTableBody(
|
||||||
else:
|
else:
|
||||||
weekend = ("S", "D")
|
weekend = ("S", "D")
|
||||||
|
|
||||||
if not halfday:
|
for d in range(1, nbdays + 1):
|
||||||
for d in range(1, nbdays + 1):
|
weeknum = time.strftime(
|
||||||
weeknum = time.strftime(
|
"%U", time.strptime("%d/%d/%d" % (d, month, year), scu.DATE_FMT)
|
||||||
"%U", time.strptime("%d/%d/%d" % (d, month, year), "%d/%m/%Y")
|
)
|
||||||
)
|
day = DAYNAMES_ABREV[(firstday + d - 1) % 7]
|
||||||
day = DAYNAMES_ABREV[(firstday + d - 1) % 7]
|
if day in weekend:
|
||||||
if day in weekend:
|
bgcolor = WEEKENDCOLOR
|
||||||
bgcolor = WEEKENDCOLOR
|
weekclass = "wkend"
|
||||||
weekclass = "wkend"
|
attrs = ""
|
||||||
attrs = ""
|
else:
|
||||||
else:
|
bgcolor = WEEKDAYCOLOR
|
||||||
bgcolor = WEEKDAYCOLOR
|
weekclass = "wk" + str(monday).replace("/", "_")
|
||||||
weekclass = "wk" + str(monday).replace("/", "_")
|
attrs = trattributes
|
||||||
attrs = trattributes
|
# events this day ?
|
||||||
color = None
|
events = events_by_day.get(f"{year}-{month:02}-{d:02}", [])
|
||||||
legend = ""
|
color = None
|
||||||
href = ""
|
ev_txts = []
|
||||||
descr = ""
|
for ev in events:
|
||||||
# event this day ?
|
color = ev.get("color")
|
||||||
# each event is a tuple (date, text, color, href)
|
href = ev.get("href", "")
|
||||||
# where date is a string in ISO format (yyyy-mm-dd)
|
description = ev.get("description", "")
|
||||||
for ev in events:
|
|
||||||
ev_year = int(ev[0][:4])
|
|
||||||
ev_month = int(ev[0][5:7])
|
|
||||||
ev_day = int(ev[0][8:10])
|
|
||||||
if year == ev_year and month == ev_month and ev_day == d:
|
|
||||||
if ev[1]:
|
|
||||||
legend = ev[1]
|
|
||||||
if ev[2]:
|
|
||||||
color = ev[2]
|
|
||||||
if ev[3]:
|
|
||||||
href = ev[3]
|
|
||||||
if len(ev) > 4 and ev[4]:
|
|
||||||
descr = ev[4]
|
|
||||||
#
|
|
||||||
cc = []
|
|
||||||
if color is not None:
|
|
||||||
cc.append('<td bgcolor="%s" class="calcell">' % color)
|
|
||||||
else:
|
|
||||||
cc.append('<td class="calcell">')
|
|
||||||
|
|
||||||
if href:
|
if href:
|
||||||
href = 'href="%s"' % href
|
href = f'href="{href}"'
|
||||||
if descr:
|
if description:
|
||||||
descr = 'title="%s"' % html.escape(descr, quote=True)
|
description = f"""title="{html.escape(description, quote=True)}" """
|
||||||
if href or descr:
|
if href or description:
|
||||||
cc.append("<a %s %s>" % (href, descr))
|
ev_txts.append(f"""<a {href} {description}>{ev.get("title", "")}</a>""")
|
||||||
|
|
||||||
if legend or d == 1:
|
|
||||||
if pad_width is not None:
|
|
||||||
n = pad_width - len(legend) # pad to 8 cars
|
|
||||||
if n > 0:
|
|
||||||
legend = (
|
|
||||||
" " * (n // 2) + legend + " " * ((n + 1) // 2)
|
|
||||||
)
|
|
||||||
else:
|
else:
|
||||||
legend = " " # empty cell
|
ev_txts.append(ev.get("title", " "))
|
||||||
cc.append(legend)
|
#
|
||||||
if href or descr:
|
cc = []
|
||||||
cc.append("</a>")
|
if color is not None:
|
||||||
cc.append("</td>")
|
cc.append(f'<td bgcolor="{color}" class="calcell">')
|
||||||
cell = "".join(cc)
|
else:
|
||||||
if day == "D":
|
cc.append('<td class="calcell">')
|
||||||
monday = monday.next_day(7)
|
|
||||||
if (
|
|
||||||
weeknum == current_weeknum
|
|
||||||
and current_year == year
|
|
||||||
and weekclass != "wkend"
|
|
||||||
):
|
|
||||||
weekclass += " currentweek"
|
|
||||||
T.append(
|
|
||||||
'<tr bgcolor="%s" class="%s" %s><td class="calday">%d%s</td>%s</tr>'
|
|
||||||
% (bgcolor, weekclass, attrs, d, day, cell)
|
|
||||||
)
|
|
||||||
else:
|
|
||||||
# Calendar with 2 cells / day
|
|
||||||
for d in range(1, nbdays + 1):
|
|
||||||
weeknum = time.strftime(
|
|
||||||
"%U", time.strptime("%d/%d/%d" % (d, month, year), "%d/%m/%Y")
|
|
||||||
)
|
|
||||||
day = DAYNAMES_ABREV[(firstday + d - 1) % 7]
|
|
||||||
if day in weekend:
|
|
||||||
bgcolor = WEEKENDCOLOR
|
|
||||||
weekclass = "wkend"
|
|
||||||
attrs = ""
|
|
||||||
else:
|
|
||||||
bgcolor = WEEKDAYCOLOR
|
|
||||||
weekclass = "wk" + str(monday).replace("/", "_")
|
|
||||||
attrs = trattributes
|
|
||||||
if (
|
|
||||||
weeknum == current_weeknum
|
|
||||||
and current_year == year
|
|
||||||
and weekclass != "wkend"
|
|
||||||
):
|
|
||||||
weeknum += " currentweek"
|
|
||||||
|
|
||||||
if day == "D":
|
cc.append(f"{', '.join(ev_txts)}</td>")
|
||||||
monday = monday.next_day(7)
|
cells = "".join(cc)
|
||||||
T.append(
|
if day == "D":
|
||||||
'<tr bgcolor="%s" class="wk%s" %s><td class="calday">%d%s</td>'
|
monday = monday.next_day(7)
|
||||||
% (bgcolor, weekclass, attrs, d, day)
|
if weeknum == current_weeknum and current_year == year and weekclass != "wkend":
|
||||||
)
|
weekclass += " currentweek"
|
||||||
cc = []
|
rows.append(
|
||||||
for morning in (True, False):
|
f"""<tr bgcolor="{bgcolor}" class="{weekclass}" {attrs}>
|
||||||
color = None
|
<td class="calday">{d}{day}</td>{cells}</tr>"""
|
||||||
legend = ""
|
)
|
||||||
href = ""
|
|
||||||
descr = ""
|
return "\n".join(rows)
|
||||||
for ev in events:
|
|
||||||
ev_year = int(ev[0][:4])
|
|
||||||
ev_month = int(ev[0][5:7])
|
|
||||||
ev_day = int(ev[0][8:10])
|
|
||||||
if ev[4] is not None:
|
|
||||||
ev_half = int(ev[4])
|
|
||||||
else:
|
|
||||||
ev_half = 0
|
|
||||||
if (
|
|
||||||
year == ev_year
|
|
||||||
and month == ev_month
|
|
||||||
and ev_day == d
|
|
||||||
and morning == ev_half
|
|
||||||
):
|
|
||||||
if ev[1]:
|
|
||||||
legend = ev[1]
|
|
||||||
if ev[2]:
|
|
||||||
color = ev[2]
|
|
||||||
if ev[3]:
|
|
||||||
href = ev[3]
|
|
||||||
if len(ev) > 5 and ev[5]:
|
|
||||||
descr = ev[5]
|
|
||||||
#
|
|
||||||
if color is not None:
|
|
||||||
cc.append('<td bgcolor="%s" class="calcell">' % (color))
|
|
||||||
else:
|
|
||||||
cc.append('<td class="calcell">')
|
|
||||||
if href:
|
|
||||||
href = 'href="%s"' % href
|
|
||||||
if descr:
|
|
||||||
descr = 'title="%s"' % html.escape(descr, quote=True)
|
|
||||||
if href or descr:
|
|
||||||
cc.append("<a %s %s>" % (href, descr))
|
|
||||||
if legend or d == 1:
|
|
||||||
n = 3 - len(legend) # pad to 3 cars
|
|
||||||
if n > 0:
|
|
||||||
legend = (
|
|
||||||
" " * (n // 2) + legend + " " * ((n + 1) // 2)
|
|
||||||
)
|
|
||||||
else:
|
|
||||||
legend = " " # empty cell
|
|
||||||
cc.append(legend)
|
|
||||||
if href or descr:
|
|
||||||
cc.append("</a>")
|
|
||||||
cc.append("</td>\n")
|
|
||||||
T.append("".join(cc) + "</tr>")
|
|
||||||
return "\n".join(T)
|
|
||||||
|
|
|
@ -71,12 +71,10 @@ def report_debouche_date(start_year=None, fmt="html"):
|
||||||
etudids = get_etudids_with_debouche(start_year)
|
etudids = get_etudids_with_debouche(start_year)
|
||||||
tab = table_debouche_etudids(etudids, keep_numeric=keep_numeric)
|
tab = table_debouche_etudids(etudids, keep_numeric=keep_numeric)
|
||||||
|
|
||||||
tab.filename = scu.make_filename("debouche_scodoc_%s" % start_year)
|
tab.filename = scu.make_filename(f"debouche_scodoc_{start_year}")
|
||||||
tab.origin = (
|
tab.origin = f"Généré par {sco_version.SCONAME} le {scu.timedate_human_repr()}"
|
||||||
"Généré par %s le " % sco_version.SCONAME + scu.timedate_human_repr() + ""
|
tab.caption = f"Récapitulatif débouchés à partir du 1/1/{start_year}."
|
||||||
)
|
tab.base_url = f"{request.base_url}?start_year={start_year}"
|
||||||
tab.caption = "Récapitulatif débouchés à partir du 1/1/%s." % start_year
|
|
||||||
tab.base_url = "%s?start_year=%s" % (request.base_url, start_year)
|
|
||||||
return tab.make_page(
|
return tab.make_page(
|
||||||
title="""<h2 class="formsemestre">Débouchés étudiants </h2>""",
|
title="""<h2 class="formsemestre">Débouchés étudiants </h2>""",
|
||||||
init_qtip=True,
|
init_qtip=True,
|
||||||
|
@ -118,7 +116,16 @@ def get_etudids_with_debouche(start_year):
|
||||||
|
|
||||||
def table_debouche_etudids(etudids, keep_numeric=True):
|
def table_debouche_etudids(etudids, keep_numeric=True):
|
||||||
"""Rapport pour ces étudiants"""
|
"""Rapport pour ces étudiants"""
|
||||||
L = []
|
rows = []
|
||||||
|
# Recherche les débouchés:
|
||||||
|
itemsuivi_etuds = {etudid: itemsuivi_list_etud(etudid) for etudid in etudids}
|
||||||
|
all_tags = set()
|
||||||
|
for debouche in itemsuivi_etuds.values():
|
||||||
|
if debouche:
|
||||||
|
for it in debouche:
|
||||||
|
all_tags.update(tag.strip() for tag in it["tags"].split(","))
|
||||||
|
all_tags = tuple(sorted(all_tags))
|
||||||
|
|
||||||
for etudid in etudids:
|
for etudid in etudids:
|
||||||
etud = sco_etud.get_etud_info(filled=True, etudid=etudid)[0]
|
etud = sco_etud.get_etud_info(filled=True, etudid=etudid)[0]
|
||||||
# retrouve le "dernier" semestre (au sens de la date de fin)
|
# retrouve le "dernier" semestre (au sens de la date de fin)
|
||||||
|
@ -152,25 +159,33 @@ def table_debouche_etudids(etudids, keep_numeric=True):
|
||||||
"sem_ident": "%s %s"
|
"sem_ident": "%s %s"
|
||||||
% (last_sem["date_debut_iso"], last_sem["titre"]), # utile pour tris
|
% (last_sem["date_debut_iso"], last_sem["titre"]), # utile pour tris
|
||||||
}
|
}
|
||||||
|
|
||||||
# recherche des débouchés
|
# recherche des débouchés
|
||||||
debouche = itemsuivi_list_etud(etudid) # liste de plusieurs items
|
debouche = itemsuivi_etuds[etudid] # liste de plusieurs items
|
||||||
if debouche:
|
if debouche:
|
||||||
row["debouche"] = "<br>".join(
|
if keep_numeric: # pour excel:
|
||||||
[
|
row["debouche"] = "\n".join(
|
||||||
str(it["item_date"])
|
f"""{it["item_date"]}: {it["situation"]}""" for it in debouche
|
||||||
+ " : "
|
)
|
||||||
+ it["situation"]
|
else:
|
||||||
+ " <i>"
|
row["debouche"] = "<br>".join(
|
||||||
+ it["tags"]
|
[
|
||||||
+ "</i>"
|
str(it["item_date"])
|
||||||
for it in debouche
|
+ " : "
|
||||||
]
|
+ it["situation"]
|
||||||
) #
|
+ " <i>"
|
||||||
|
+ it["tags"]
|
||||||
|
+ "</i>"
|
||||||
|
for it in debouche
|
||||||
|
]
|
||||||
|
)
|
||||||
|
for it in debouche:
|
||||||
|
for tag in it["tags"].split(","):
|
||||||
|
tag = tag.strip()
|
||||||
|
row[f"tag_{tag}"] = tag
|
||||||
else:
|
else:
|
||||||
row["debouche"] = "non renseigné"
|
row["debouche"] = "non renseigné"
|
||||||
L.append(row)
|
rows.append(row)
|
||||||
L.sort(key=lambda x: x["sem_ident"])
|
rows.sort(key=lambda x: x["sem_ident"])
|
||||||
|
|
||||||
titles = {
|
titles = {
|
||||||
"civilite": "",
|
"civilite": "",
|
||||||
|
@ -184,21 +199,25 @@ def table_debouche_etudids(etudids, keep_numeric=True):
|
||||||
"effectif": "Eff.",
|
"effectif": "Eff.",
|
||||||
"debouche": "Débouché",
|
"debouche": "Débouché",
|
||||||
}
|
}
|
||||||
|
columns_ids = [
|
||||||
|
"semestre",
|
||||||
|
"semestre_id",
|
||||||
|
"periode",
|
||||||
|
"civilite",
|
||||||
|
"nom",
|
||||||
|
"prenom",
|
||||||
|
"moy",
|
||||||
|
"rang",
|
||||||
|
"effectif",
|
||||||
|
"debouche",
|
||||||
|
]
|
||||||
|
for tag in all_tags:
|
||||||
|
titles[f"tag_{tag}"] = tag
|
||||||
|
columns_ids.append(f"tag_{tag}")
|
||||||
tab = GenTable(
|
tab = GenTable(
|
||||||
columns_ids=(
|
columns_ids=columns_ids,
|
||||||
"semestre",
|
|
||||||
"semestre_id",
|
|
||||||
"periode",
|
|
||||||
"civilite",
|
|
||||||
"nom",
|
|
||||||
"prenom",
|
|
||||||
"moy",
|
|
||||||
"rang",
|
|
||||||
"effectif",
|
|
||||||
"debouche",
|
|
||||||
),
|
|
||||||
titles=titles,
|
titles=titles,
|
||||||
rows=L,
|
rows=rows,
|
||||||
# html_col_width='4em',
|
# html_col_width='4em',
|
||||||
html_sortable=True,
|
html_sortable=True,
|
||||||
html_class="table_leftalign table_listegroupe",
|
html_class="table_leftalign table_listegroupe",
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
|
|
||||||
##############################################################################
|
##############################################################################
|
||||||
#
|
#
|
||||||
# Gestion scolarite IUT
|
# ScoDoc
|
||||||
#
|
#
|
||||||
# Copyright (c) 1999 - 2024 Emmanuel Viennet. All rights reserved.
|
# Copyright (c) 1999 - 2024 Emmanuel Viennet. All rights reserved.
|
||||||
#
|
#
|
||||||
|
@ -28,254 +28,171 @@
|
||||||
"""Page accueil département (liste des semestres, etc)
|
"""Page accueil département (liste des semestres, etc)
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from flask import g
|
from sqlalchemy import desc
|
||||||
from flask import url_for
|
from flask import g, url_for, render_template
|
||||||
from flask_login import current_user
|
from flask_login import current_user
|
||||||
|
from flask_sqlalchemy.query import Query
|
||||||
|
|
||||||
import app
|
import app
|
||||||
from app import log
|
from app import log
|
||||||
from app.models import ScolarNews
|
from app.models import FormSemestre, ScolarNews, ScoDocSiteConfig
|
||||||
import app.scodoc.sco_utils as scu
|
import app.scodoc.sco_utils as scu
|
||||||
from app.scodoc.gen_tables import GenTable
|
from app.scodoc.gen_tables import GenTable
|
||||||
from app.scodoc.sco_permissions import Permission
|
from app.scodoc.sco_permissions import Permission
|
||||||
from app.scodoc import html_sco_header
|
|
||||||
import app.scodoc.notesdb as ndb
|
import app.scodoc.notesdb as ndb
|
||||||
from app.scodoc import sco_formsemestre
|
|
||||||
from app.scodoc import sco_formsemestre_inscriptions
|
|
||||||
from app.scodoc import sco_modalites
|
from app.scodoc import sco_modalites
|
||||||
from app.scodoc import sco_preferences
|
from app.scodoc import sco_preferences
|
||||||
from app.scodoc import sco_users
|
from app.scodoc import sco_users
|
||||||
|
from app.views import ScoData
|
||||||
|
|
||||||
|
|
||||||
def index_html(showcodes=0, showsemtable=0):
|
def index_html(showcodes=0, showsemtable=0, export_table_formsemestres=False):
|
||||||
"Page accueil département (liste des semestres)"
|
"Page accueil département (liste des semestres)"
|
||||||
showcodes = int(showcodes)
|
showcodes = int(showcodes)
|
||||||
showsemtable = int(showsemtable)
|
showsemtable = int(showsemtable) or export_table_formsemestres
|
||||||
H = []
|
|
||||||
|
|
||||||
# News:
|
# Liste tous les formsemestres du dept, le plus récent d'abord
|
||||||
H.append(ScolarNews.scolar_news_summary_html())
|
current_formsemestres = (
|
||||||
|
FormSemestre.query.filter_by(dept_id=g.scodoc_dept_id, etat=True)
|
||||||
# Avertissement de mise à jour:
|
.filter(FormSemestre.modalite != "EXT")
|
||||||
H.append("""<div id="update_warning"></div>""")
|
.order_by(desc(FormSemestre.date_debut))
|
||||||
|
|
||||||
# Liste de toutes les sessions:
|
|
||||||
sems = sco_formsemestre.do_formsemestre_list()
|
|
||||||
cursems = [] # semestres "courants"
|
|
||||||
othersems = [] # autres (verrouillés)
|
|
||||||
# icon image:
|
|
||||||
groupicon = scu.icontag("groupicon_img", title="Inscrits", border="0")
|
|
||||||
emptygroupicon = scu.icontag(
|
|
||||||
"emptygroupicon_img", title="Pas d'inscrits", border="0"
|
|
||||||
)
|
)
|
||||||
lockicon = scu.icontag("lock32_img", title="verrouillé", border="0")
|
locked_formsemestres = (
|
||||||
# Sélection sur l'etat du semestre
|
FormSemestre.query.filter_by(dept_id=g.scodoc_dept_id, etat=False)
|
||||||
for sem in sems:
|
.filter(FormSemestre.modalite != "EXT")
|
||||||
if sem["etat"] and sem["modalite"] != "EXT":
|
.order_by(desc(FormSemestre.date_debut))
|
||||||
sem["lockimg"] = ""
|
)
|
||||||
cursems.append(sem)
|
formsemestres = (
|
||||||
else:
|
FormSemestre.query.filter_by(dept_id=g.scodoc_dept_id)
|
||||||
sem["lockimg"] = lockicon
|
.filter(FormSemestre.modalite != "EXT")
|
||||||
othersems.append(sem)
|
.order_by(desc(FormSemestre.date_debut))
|
||||||
# Responsable de formation:
|
)
|
||||||
sco_formsemestre.sem_set_responsable_name(sem)
|
if showsemtable: # table de tous les formsemestres
|
||||||
|
table = _sem_table_gt(
|
||||||
if showcodes:
|
formsemestres,
|
||||||
sem["tmpcode"] = f"<td><tt>{sem['formsemestre_id']}</tt></td>"
|
showcodes=showcodes,
|
||||||
else:
|
fmt="xlsx" if export_table_formsemestres else "html",
|
||||||
sem["tmpcode"] = ""
|
|
||||||
# Nombre d'inscrits:
|
|
||||||
args = {"formsemestre_id": sem["formsemestre_id"]}
|
|
||||||
ins = sco_formsemestre_inscriptions.do_formsemestre_inscription_list(args=args)
|
|
||||||
nb = len(ins) # nb etudiants
|
|
||||||
sem["nb_inscrits"] = nb
|
|
||||||
if nb > 0:
|
|
||||||
sem["groupicon"] = groupicon
|
|
||||||
else:
|
|
||||||
sem["groupicon"] = emptygroupicon
|
|
||||||
|
|
||||||
# S'il n'y a pas d'utilisateurs dans la base, affiche message
|
|
||||||
if not sco_users.get_users_count(dept=g.scodoc_dept):
|
|
||||||
H.append(
|
|
||||||
"""<h2>Aucun utilisateur défini !</h2><p>Pour définir des utilisateurs
|
|
||||||
<a href="Users">passez par la page Utilisateurs</a>.
|
|
||||||
<br>
|
|
||||||
Définissez au moins un utilisateur avec le rôle AdminXXX
|
|
||||||
(le responsable du département XXX).
|
|
||||||
</p>
|
|
||||||
"""
|
|
||||||
)
|
)
|
||||||
|
if export_table_formsemestres:
|
||||||
# Liste des formsemestres "courants"
|
return table # cas spécial: on renvoie juste cette table
|
||||||
if cursems:
|
html_table_formsemestres = table.html()
|
||||||
H.append('<h2 class="listesems">Sessions en cours</h2>')
|
|
||||||
H.append(_sem_table(cursems))
|
|
||||||
else:
|
else:
|
||||||
# aucun semestre courant: affiche aide
|
html_table_formsemestres = None
|
||||||
H.append(
|
|
||||||
"""<h2 class="listesems">Aucune session en cours !</h2>
|
|
||||||
<p>Pour ajouter une session, aller dans <a href="Notes" id="link-programmes">Formations</a>,
|
|
||||||
choisissez une formation, puis suivez le lien "<em>UE, modules, semestres</em>".
|
|
||||||
</p><p>
|
|
||||||
Là, en bas de page, suivez le lien
|
|
||||||
"<em>Mettre en place un nouveau semestre de formation...</em>"
|
|
||||||
</p>"""
|
|
||||||
)
|
|
||||||
|
|
||||||
if showsemtable:
|
current_formsemestres_by_modalite, modalites = (
|
||||||
H.append(
|
sco_modalites.group_formsemestres_by_modalite(current_formsemestres)
|
||||||
f"""<hr>
|
|
||||||
<h2>Semestres de {sco_preferences.get_preference("DeptName")}</h2>
|
|
||||||
"""
|
|
||||||
)
|
|
||||||
H.append(_sem_table_gt(sems, showcodes=showcodes).html())
|
|
||||||
H.append("</table>")
|
|
||||||
if not showsemtable:
|
|
||||||
H.append(
|
|
||||||
f"""<hr>
|
|
||||||
<p><a class="stdlink" href="{url_for('scolar.index_html',
|
|
||||||
scodoc_dept=g.scodoc_dept, showsemtable=1)
|
|
||||||
}">Voir table des semestres (dont {len(othersems)}
|
|
||||||
verrouillé{'s' if len(othersems) else ''})</a>
|
|
||||||
</p>"""
|
|
||||||
)
|
|
||||||
|
|
||||||
H.append(
|
|
||||||
f"""<p>
|
|
||||||
<form action="{url_for('notes.view_formsemestre_by_etape', scodoc_dept=g.scodoc_dept)}">
|
|
||||||
Chercher étape courante:
|
|
||||||
<input name="etape_apo" type="text" size="8" spellcheck="false"></input>
|
|
||||||
</form>
|
|
||||||
</p>"""
|
|
||||||
)
|
)
|
||||||
#
|
passerelle_disabled = ScoDocSiteConfig.is_passerelle_disabled()
|
||||||
H.append(
|
return render_template(
|
||||||
"""<hr>
|
"scolar/index.j2",
|
||||||
<h3>Gestion des étudiants</h3>
|
current_user=current_user,
|
||||||
<ul>
|
current_formsemestres=current_formsemestres,
|
||||||
"""
|
current_formsemestres_by_modalite=current_formsemestres_by_modalite,
|
||||||
)
|
dept_name=sco_preferences.get_preference("DeptName"),
|
||||||
if current_user.has_permission(Permission.EtudInscrit):
|
emptygroupicon=scu.icontag(
|
||||||
H.append(
|
"emptygroupicon_img", title="Pas d'inscrits", border="0"
|
||||||
f"""
|
),
|
||||||
<li><a class="stdlink" href="{
|
formsemestres=formsemestres,
|
||||||
url_for("scolar.etudident_create_form", scodoc_dept=g.scodoc_dept)
|
groupicon=scu.icontag("groupicon_img", title="Inscrits", border="0"),
|
||||||
}">créer <em>un</em> nouvel étudiant</a>
|
html_table_formsemestres=html_table_formsemestres,
|
||||||
</li>
|
icon_hidden="" if passerelle_disabled else scu.ICON_HIDDEN,
|
||||||
<li><a class="stdlink" href="{
|
icon_published="" if passerelle_disabled else scu.ICON_PUBLISHED,
|
||||||
url_for("scolar.form_students_import_excel", scodoc_dept=g.scodoc_dept)
|
locked_formsemestres=locked_formsemestres,
|
||||||
}">importer de nouveaux étudiants</a>
|
modalites=modalites,
|
||||||
(<em>ne pas utiliser</em> sauf cas particulier : utilisez plutôt le lien dans
|
nb_locked=locked_formsemestres.count(),
|
||||||
le tableau de bord semestre si vous souhaitez inscrire les
|
nb_user_accounts=sco_users.get_users_count(dept=g.scodoc_dept),
|
||||||
étudiants importés à un semestre)
|
page_title=f"ScoDoc {g.scodoc_dept}",
|
||||||
</li>
|
Permission=Permission,
|
||||||
"""
|
scolar_news_summary=ScolarNews.scolar_news_summary_html(),
|
||||||
)
|
showcodes=showcodes,
|
||||||
H.append(
|
showsemtable=showsemtable,
|
||||||
f"""
|
sco=ScoData(),
|
||||||
<li><a class="stdlink" href="{
|
|
||||||
url_for("scolar.export_etudiants_courants", scodoc_dept=g.scodoc_dept)
|
|
||||||
}">exporter tableau des étudiants des semestres en cours</a>
|
|
||||||
</li>
|
|
||||||
"""
|
|
||||||
)
|
|
||||||
if current_user.has_permission(
|
|
||||||
Permission.EtudInscrit
|
|
||||||
) and sco_preferences.get_preference("portal_url"):
|
|
||||||
H.append(
|
|
||||||
f"""
|
|
||||||
<li><a class="stdlink" href="{
|
|
||||||
url_for("scolar.formsemestre_import_etud_admission",
|
|
||||||
scodoc_dept=g.scodoc_dept, tous_courants=1)
|
|
||||||
}">resynchroniser les données étudiants des semestres en cours depuis le portail</a>
|
|
||||||
</li>
|
|
||||||
"""
|
|
||||||
)
|
|
||||||
H.append("</ul>")
|
|
||||||
#
|
|
||||||
if current_user.has_permission(Permission.EditApogee):
|
|
||||||
H.append(
|
|
||||||
f"""<hr>
|
|
||||||
<h3>Exports Apogée</h3>
|
|
||||||
<ul>
|
|
||||||
<li><a class="stdlink" href="{url_for('notes.semset_page', scodoc_dept=g.scodoc_dept)
|
|
||||||
}">Années scolaires / exports Apogée</a></li>
|
|
||||||
</ul>
|
|
||||||
"""
|
|
||||||
)
|
|
||||||
#
|
|
||||||
H.append(
|
|
||||||
"""<hr>
|
|
||||||
<h3>Assistance</h3>
|
|
||||||
<ul>
|
|
||||||
<li><a class="stdlink" href="https://scodoc.org/Contact" target="_blank"
|
|
||||||
rel="noopener noreferrer">Contact (Discord)</a></li>
|
|
||||||
<li><a class="stdlink" href="sco_dump_and_send_db">Envoyer données</a></li>
|
|
||||||
</ul>
|
|
||||||
"""
|
|
||||||
)
|
|
||||||
#
|
|
||||||
return (
|
|
||||||
html_sco_header.sco_header(
|
|
||||||
page_title=f"ScoDoc {g.scodoc_dept}", javascripts=["js/scolar_index.js"]
|
|
||||||
)
|
|
||||||
+ "\n".join(H)
|
|
||||||
+ html_sco_header.sco_footer()
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def _sem_table(sems):
|
def _convert_formsemestres_to_dicts(
|
||||||
"""Affiche liste des semestres, utilisée pour semestres en cours"""
|
formsemestres: Query, showcodes: bool, fmt: str = "html"
|
||||||
tmpl = """<tr class="%(trclass)s">%(tmpcode)s
|
) -> list[dict]:
|
||||||
<td class="semicon">%(lockimg)s <a href="%(notes_url)s/formsemestre_status?formsemestre_id=%(formsemestre_id)s#groupes">%(groupicon)s</a></td>
|
""" """
|
||||||
<td class="datesem">%(mois_debut)s <a title="%(session_id)s">-</a> %(mois_fin)s</td>
|
if fmt == "html":
|
||||||
<td><a class="stdlink" href="%(notes_url)s/formsemestre_status?formsemestre_id=%(formsemestre_id)s">%(titre_num)s</a>
|
# icon images:
|
||||||
<span class="respsem">(%(responsable_name)s)</span>
|
groupicon = scu.icontag("groupicon_img", title="Inscrits", border="0")
|
||||||
</td>
|
emptygroupicon = scu.icontag(
|
||||||
</tr>
|
"emptygroupicon_img", title="Pas d'inscrits", border="0"
|
||||||
"""
|
)
|
||||||
|
lockicon = scu.icontag("lock32_img", title="verrouillé", border="0")
|
||||||
# Liste des semestres, groupés par modalités
|
else:
|
||||||
sems_by_mod, modalites = sco_modalites.group_sems_by_modalite(sems)
|
groupicon = "X"
|
||||||
|
emptygroupicon = ""
|
||||||
H = ['<table class="listesems">']
|
lockicon = "X"
|
||||||
for modalite in modalites:
|
# génère liste de dict
|
||||||
if len(modalites) > 1:
|
sems = []
|
||||||
H.append('<tr><th colspan="3">%s</th></tr>' % modalite["titre"])
|
formsemestre: FormSemestre
|
||||||
|
for formsemestre in formsemestres:
|
||||||
if sems_by_mod[modalite["modalite"]]:
|
nb_inscrits = len(formsemestre.inscriptions)
|
||||||
cur_idx = sems_by_mod[modalite["modalite"]][0]["semestre_id"]
|
formation = formsemestre.formation
|
||||||
for sem in sems_by_mod[modalite["modalite"]]:
|
sem = {
|
||||||
if cur_idx != sem["semestre_id"]:
|
"anneescolaire": formsemestre.annee_scolaire(),
|
||||||
sem["trclass"] = "firstsem" # separe les groupes de semestres
|
"anneescolaire_str": formsemestre.annee_scolaire_str(),
|
||||||
cur_idx = sem["semestre_id"]
|
"bul_hide_xml": formsemestre.bul_hide_xml,
|
||||||
else:
|
"dateord": formsemestre.date_debut,
|
||||||
sem["trclass"] = ""
|
"elt_annee_apo": formsemestre.elt_annee_apo,
|
||||||
sem["notes_url"] = scu.NotesURL()
|
"elt_sem_apo": formsemestre.elt_sem_apo,
|
||||||
H.append(tmpl % sem)
|
"etapes_apo_str": formsemestre.etapes_apo_str(),
|
||||||
H.append("</table>")
|
"formation": f"{formation.acronyme} v{formation.version}",
|
||||||
return "\n".join(H)
|
"_formation_target": url_for(
|
||||||
|
"notes.ue_table",
|
||||||
|
scodoc_dept=g.scodoc_dept,
|
||||||
|
formation_id=formation.id,
|
||||||
|
semestre_idx=formsemestre.semestre_id,
|
||||||
|
),
|
||||||
|
"formsemestre_id": formsemestre.id,
|
||||||
|
"groupicon": groupicon if nb_inscrits > 0 else emptygroupicon,
|
||||||
|
"lockimg": "" if formsemestre.etat else lockicon,
|
||||||
|
"modalite": formsemestre.modalite,
|
||||||
|
"mois_debut": formsemestre.mois_debut(),
|
||||||
|
"mois_fin": formsemestre.mois_fin(),
|
||||||
|
"nb_inscrits": nb_inscrits,
|
||||||
|
"responsable_name": formsemestre.responsables_str(),
|
||||||
|
"semestre_id": formsemestre.semestre_id,
|
||||||
|
"session_id": formsemestre.session_id(),
|
||||||
|
"titre_num": formsemestre.titre_num(),
|
||||||
|
"tmpcode": (f"<td><tt>{formsemestre.id}</tt></td>" if showcodes else ""),
|
||||||
|
}
|
||||||
|
sems.append(sem)
|
||||||
|
return sems
|
||||||
|
|
||||||
|
|
||||||
def _sem_table_gt(sems, showcodes=False):
|
def _sem_table_gt(formsemestres: Query, showcodes=False, fmt="html") -> GenTable:
|
||||||
"""Nouvelle version de la table des semestres
|
"""Table des semestres
|
||||||
Utilise une datatables.
|
Utilise une datatables.
|
||||||
"""
|
"""
|
||||||
_style_sems(sems)
|
sems = _style_sems(
|
||||||
columns_ids = (
|
_convert_formsemestres_to_dicts(formsemestres, showcodes, fmt=fmt), fmt=fmt
|
||||||
"lockimg",
|
)
|
||||||
|
sems.sort(
|
||||||
|
key=lambda s: (
|
||||||
|
-s["anneescolaire"],
|
||||||
|
s["semestre_id"] if s["semestre_id"] > 0 else -s["semestre_id"] * 1000,
|
||||||
|
s["modalite"],
|
||||||
|
)
|
||||||
|
)
|
||||||
|
columns_ids = ["lockimg"]
|
||||||
|
if not ScoDocSiteConfig.is_passerelle_disabled():
|
||||||
|
columns_ids.append("published")
|
||||||
|
columns_ids += [
|
||||||
|
"dash_mois_fin",
|
||||||
"semestre_id_n",
|
"semestre_id_n",
|
||||||
"modalite",
|
"modalite",
|
||||||
#'mois_debut',
|
|
||||||
"dash_mois_fin",
|
|
||||||
"titre_resp",
|
"titre_resp",
|
||||||
"nb_inscrits",
|
"nb_inscrits",
|
||||||
|
"formation",
|
||||||
"etapes_apo_str",
|
"etapes_apo_str",
|
||||||
"elt_annee_apo",
|
"elt_annee_apo",
|
||||||
"elt_sem_apo",
|
"elt_sem_apo",
|
||||||
)
|
]
|
||||||
if showcodes:
|
if showcodes:
|
||||||
columns_ids = ("formsemestre_id",) + columns_ids
|
columns_ids.insert(0, "formsemestre_id") # prepend
|
||||||
|
|
||||||
html_class = "stripe cell-border compact hover order-column table_leftalign semlist"
|
html_class = "stripe cell-border compact hover order-column table_leftalign semlist"
|
||||||
if current_user.has_permission(Permission.EditApogee):
|
if current_user.has_permission(Permission.EditApogee):
|
||||||
|
@ -284,7 +201,7 @@ def _sem_table_gt(sems, showcodes=False):
|
||||||
titles={
|
titles={
|
||||||
"formsemestre_id": "id",
|
"formsemestre_id": "id",
|
||||||
"semestre_id_n": "S#",
|
"semestre_id_n": "S#",
|
||||||
"modalite": "",
|
"modalite": "" if fmt == "html" else "Modalité",
|
||||||
"mois_debut": "Début",
|
"mois_debut": "Début",
|
||||||
"dash_mois_fin": "Année",
|
"dash_mois_fin": "Année",
|
||||||
"titre_resp": "Semestre",
|
"titre_resp": "Semestre",
|
||||||
|
@ -292,6 +209,7 @@ def _sem_table_gt(sems, showcodes=False):
|
||||||
"etapes_apo_str": "Étape Apo.",
|
"etapes_apo_str": "Étape Apo.",
|
||||||
"elt_annee_apo": "Elt. année Apo.",
|
"elt_annee_apo": "Elt. année Apo.",
|
||||||
"elt_sem_apo": "Elt. sem. Apo.",
|
"elt_sem_apo": "Elt. sem. Apo.",
|
||||||
|
"formation": "Formation",
|
||||||
},
|
},
|
||||||
columns_ids=columns_ids,
|
columns_ids=columns_ids,
|
||||||
rows=sems,
|
rows=sems,
|
||||||
|
@ -311,22 +229,39 @@ def _sem_table_gt(sems, showcodes=False):
|
||||||
return tab
|
return tab
|
||||||
|
|
||||||
|
|
||||||
def _style_sems(sems):
|
def _style_sems(sems: list[dict], fmt="html") -> list[dict]:
|
||||||
"""ajoute quelques attributs de présentation pour la table"""
|
"""ajoute quelques attributs de présentation pour la table"""
|
||||||
|
is_h = fmt == "html"
|
||||||
|
if is_h:
|
||||||
|
icon_published = scu.ICON_PUBLISHED
|
||||||
|
icon_hidden = scu.ICON_HIDDEN
|
||||||
|
else:
|
||||||
|
icon_published = "publié"
|
||||||
|
icon_hidden = "non publié"
|
||||||
for sem in sems:
|
for sem in sems:
|
||||||
sem["notes_url"] = scu.NotesURL()
|
status_url = url_for(
|
||||||
sem["_groupicon_target"] = (
|
"notes.formsemestre_status",
|
||||||
"%(notes_url)s/formsemestre_status?formsemestre_id=%(formsemestre_id)s"
|
scodoc_dept=g.scodoc_dept,
|
||||||
% sem
|
formsemestre_id=sem["formsemestre_id"],
|
||||||
)
|
)
|
||||||
|
sem["_groupicon_target"] = status_url
|
||||||
sem["_formsemestre_id_class"] = "blacktt"
|
sem["_formsemestre_id_class"] = "blacktt"
|
||||||
sem["dash_mois_fin"] = '<a title="%(session_id)s"></a> %(anneescolaire)s' % sem
|
sem["dash_mois_fin"] = (
|
||||||
|
(f"""<a title="{sem['session_id']}">{sem['anneescolaire_str']}</a>""")
|
||||||
|
if is_h
|
||||||
|
else sem["anneescolaire_str"]
|
||||||
|
)
|
||||||
sem["_dash_mois_fin_class"] = "datesem"
|
sem["_dash_mois_fin_class"] = "datesem"
|
||||||
sem["titre_resp"] = (
|
sem["titre_resp"] = (
|
||||||
"""<a class="stdlink" href="%(notes_url)s/formsemestre_status?formsemestre_id=%(formsemestre_id)s">%(titre_num)s</a>
|
(
|
||||||
<span class="respsem">(%(responsable_name)s)</span>"""
|
f"""<a class="stdlink" href="{status_url}">{sem['titre_num']}</a>
|
||||||
% sem
|
<span class="respsem">({sem['responsable_name']})</span>"""
|
||||||
|
)
|
||||||
|
if is_h
|
||||||
|
else f"""{sem['titre_num']} ({sem["responsable_name"]})"""
|
||||||
)
|
)
|
||||||
|
sem["published"] = icon_hidden if sem["bul_hide_xml"] else icon_published
|
||||||
|
|
||||||
sem["_css_row_class"] = "css_S%d css_M%s" % (
|
sem["_css_row_class"] = "css_S%d css_M%s" % (
|
||||||
sem["semestre_id"],
|
sem["semestre_id"],
|
||||||
sem["modalite"],
|
sem["modalite"],
|
||||||
|
@ -347,6 +282,7 @@ def _style_sems(sems):
|
||||||
sem["_elt_sem_apo_td_attrs"] = (
|
sem["_elt_sem_apo_td_attrs"] = (
|
||||||
f""" data-oid="{sem['formsemestre_id']}" data-value="{sem['elt_sem_apo']}" """
|
f""" data-oid="{sem['formsemestre_id']}" data-value="{sem['elt_sem_apo']}" """
|
||||||
)
|
)
|
||||||
|
return sems
|
||||||
|
|
||||||
|
|
||||||
def delete_dept(dept_id: int) -> str:
|
def delete_dept(dept_id: int) -> str:
|
||||||
|
|
|
@ -58,21 +58,20 @@ def formation_delete(formation_id=None, dialog_confirmed=False):
|
||||||
html_sco_header.sco_header(page_title="Suppression d'une formation"),
|
html_sco_header.sco_header(page_title="Suppression d'une formation"),
|
||||||
f"""<h2>Suppression de la formation {formation.titre} ({formation.acronyme})</h2>""",
|
f"""<h2>Suppression de la formation {formation.titre} ({formation.acronyme})</h2>""",
|
||||||
]
|
]
|
||||||
|
formsemestres = formation.formsemestres.all()
|
||||||
sems = sco_formsemestre.do_formsemestre_list({"formation_id": formation_id})
|
if formsemestres:
|
||||||
if sems:
|
|
||||||
H.append(
|
H.append(
|
||||||
"""<p class="warning">Impossible de supprimer cette formation,
|
"""<p class="warning">Impossible de supprimer cette formation,
|
||||||
car les sessions suivantes l'utilisent:</p>
|
car les sessions suivantes l'utilisent:</p>
|
||||||
<ul>"""
|
<ul>"""
|
||||||
)
|
)
|
||||||
for sem in sems:
|
for formsemestre in formsemestres:
|
||||||
H.append(
|
H.append(f"""<li>{formsemestre.html_link_status()}</li>""")
|
||||||
'<li><a class="stdlink" href="formsemestre_status?formsemestre_id=%(formsemestre_id)s">%(titremois)s</a></li>'
|
|
||||||
% sem
|
|
||||||
)
|
|
||||||
H.append(
|
H.append(
|
||||||
'</ul><p><a class="stdlink" href="%s">Revenir</a></p>' % scu.NotesURL()
|
f"""</ul>
|
||||||
|
<p><a class="stdlink" href="{
|
||||||
|
url_for("notes.index_html", scodoc_dept=g.scodoc_dept)
|
||||||
|
}">Revenir</a></p>"""
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
if not dialog_confirmed:
|
if not dialog_confirmed:
|
||||||
|
@ -85,14 +84,16 @@ def formation_delete(formation_id=None, dialog_confirmed=False):
|
||||||
</p>
|
</p>
|
||||||
""",
|
""",
|
||||||
OK="Supprimer cette formation",
|
OK="Supprimer cette formation",
|
||||||
cancel_url=scu.NotesURL(),
|
cancel_url=url_for("notes.index_html", scodoc_dept=g.scodoc_dept),
|
||||||
parameters={"formation_id": formation_id},
|
parameters={"formation_id": formation_id},
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
do_formation_delete(formation_id)
|
do_formation_delete(formation_id)
|
||||||
H.append(
|
H.append(
|
||||||
f"""<p>OK, formation supprimée.</p>
|
f"""<p>OK, formation supprimée.</p>
|
||||||
<p><a class="stdlink" href="{scu.NotesURL()}">continuer</a></p>"""
|
<p><a class="stdlink" href="{
|
||||||
|
url_for("notes.index_html", scodoc_dept=g.scodoc_dept)
|
||||||
|
}">continuer</a></p>"""
|
||||||
)
|
)
|
||||||
|
|
||||||
H.append(html_sco_header.sco_footer())
|
H.append(html_sco_header.sco_footer())
|
||||||
|
@ -252,7 +253,7 @@ def formation_edit(formation_id=None, create=False):
|
||||||
if tf[0] == 0:
|
if tf[0] == 0:
|
||||||
return "\n".join(H) + tf[1] + html_sco_header.sco_footer()
|
return "\n".join(H) + tf[1] + html_sco_header.sco_footer()
|
||||||
elif tf[0] == -1:
|
elif tf[0] == -1:
|
||||||
return flask.redirect(scu.NotesURL())
|
return flask.redirect(url_for("notes.index_html", scodoc_dept=g.scodoc_dept))
|
||||||
else:
|
else:
|
||||||
# check unicity : constraint UNIQUE(acronyme,titre,version)
|
# check unicity : constraint UNIQUE(acronyme,titre,version)
|
||||||
if create:
|
if create:
|
||||||
|
|
|
@ -448,7 +448,7 @@ def module_edit(
|
||||||
(
|
(
|
||||||
"titre",
|
"titre",
|
||||||
{
|
{
|
||||||
"size": 30,
|
"size": 64,
|
||||||
"explanation": """nom du module. Exemple:
|
"explanation": """nom du module. Exemple:
|
||||||
<em>Introduction à la démarche ergonomique</em>""",
|
<em>Introduction à la démarche ergonomique</em>""",
|
||||||
},
|
},
|
||||||
|
@ -456,8 +456,8 @@ def module_edit(
|
||||||
(
|
(
|
||||||
"abbrev",
|
"abbrev",
|
||||||
{
|
{
|
||||||
"size": 20,
|
"size": 32,
|
||||||
"explanation": """nom abrégé (pour bulletins).
|
"explanation": """(optionnel) nom abrégé pour bulletins.
|
||||||
Exemple: <em>Intro. à l'ergonomie</em>""",
|
Exemple: <em>Intro. à l'ergonomie</em>""",
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
|
|
@ -298,27 +298,6 @@ def ue_edit(ue_id=None, create=False, formation_id=None, default_semestre_idx=No
|
||||||
cursus = formation.get_cursus()
|
cursus = formation.get_cursus()
|
||||||
is_apc = cursus.APC_SAE
|
is_apc = cursus.APC_SAE
|
||||||
semestres_indices = list(range(1, cursus.NB_SEM + 1))
|
semestres_indices = list(range(1, cursus.NB_SEM + 1))
|
||||||
H = [
|
|
||||||
html_sco_header.sco_header(page_title=title, javascripts=["js/edit_ue.js"]),
|
|
||||||
"<h2>" + title,
|
|
||||||
f" (formation {formation.acronyme}, version {formation.version})</h2>",
|
|
||||||
"""
|
|
||||||
<p class="help">Les UE sont des groupes de modules dans une formation donnée,
|
|
||||||
utilisés pour la validation (on calcule des moyennes par UE et applique des
|
|
||||||
seuils ("barres")).
|
|
||||||
</p>
|
|
||||||
|
|
||||||
<p class="help">Note: sauf exception, l'UE n'a pas de coefficient associé.
|
|
||||||
Seuls les <em>modules</em> ont des coefficients.
|
|
||||||
</p>""",
|
|
||||||
(
|
|
||||||
f"""
|
|
||||||
<h4>UE du semestre S{ue.semestre_idx}</h4>
|
|
||||||
"""
|
|
||||||
if is_apc and ue
|
|
||||||
else ""
|
|
||||||
),
|
|
||||||
]
|
|
||||||
|
|
||||||
ue_types = cursus.ALLOWED_UE_TYPES
|
ue_types = cursus.ALLOWED_UE_TYPES
|
||||||
ue_types.sort()
|
ue_types.sort()
|
||||||
|
@ -489,7 +468,7 @@ def ue_edit(ue_id=None, create=False, formation_id=None, default_semestre_idx=No
|
||||||
if ue and is_apc:
|
if ue and is_apc:
|
||||||
ue_parcours_div = apc_edit_ue.form_ue_choix_parcours(ue)
|
ue_parcours_div = apc_edit_ue.form_ue_choix_parcours(ue)
|
||||||
if ue and ue.modules.count() and ue.semestre_idx is not None:
|
if ue and ue.modules.count() and ue.semestre_idx is not None:
|
||||||
modules_div = f"""<div id="ue_list_modules">
|
modules_div = f"""<div class="scobox" id="ue_list_modules">
|
||||||
<div><b>{ue.modules.count()} modules sont rattachés
|
<div><b>{ue.modules.count()} modules sont rattachés
|
||||||
à cette UE</b> du semestre S{ue.semestre_idx},
|
à cette UE</b> du semestre S{ue.semestre_idx},
|
||||||
elle ne peut donc pas être changée de semestre.</div>
|
elle ne peut donc pas être changée de semestre.</div>
|
||||||
|
@ -511,18 +490,34 @@ def ue_edit(ue_id=None, create=False, formation_id=None, default_semestre_idx=No
|
||||||
"""
|
"""
|
||||||
else:
|
else:
|
||||||
clone_form = ""
|
clone_form = ""
|
||||||
bonus_div = """<div id="bonus_description"></div>"""
|
|
||||||
ue_div = """<div id="ue_list_code" class="sco_box sco_green_bg"></div>"""
|
return f"""
|
||||||
return (
|
{html_sco_header.sco_header(page_title=title, javascripts=["js/edit_ue.js"])}
|
||||||
"\n".join(H)
|
<h2>{title}, (formation {formation.acronyme}, version {formation.version})</h2>
|
||||||
+ tf[1]
|
<p class="help">Les UEs sont des groupes de modules dans une formation donnée,
|
||||||
+ clone_form
|
utilisés pour la validation (on calcule des moyennes par UE et applique des
|
||||||
+ ue_parcours_div
|
seuils ("barres")).
|
||||||
+ modules_div
|
</p>
|
||||||
+ bonus_div
|
|
||||||
+ ue_div
|
<p class="help">Note: sauf exception, l'UE n'a pas de coefficient associé.
|
||||||
+ html_sco_header.sco_footer()
|
Seuls les <em>modules</em> ont des coefficients.
|
||||||
)
|
</p>
|
||||||
|
|
||||||
|
<div class="scobox">
|
||||||
|
<div class="scobox-title">
|
||||||
|
Édition de l'UE {('du semestre S'+str(ue.semestre_idx)) if is_apc and ue else ''}
|
||||||
|
</div>
|
||||||
|
{tf[1]}
|
||||||
|
</div>
|
||||||
|
{clone_form}
|
||||||
|
{ue_parcours_div}
|
||||||
|
{modules_div}
|
||||||
|
|
||||||
|
<div id="bonus_description"></div>
|
||||||
|
<div id="ue_list_code" class="sco_box sco_green_bg"></div>
|
||||||
|
|
||||||
|
{html_sco_header.sco_footer()}
|
||||||
|
"""
|
||||||
elif tf[0] == 1:
|
elif tf[0] == 1:
|
||||||
if create:
|
if create:
|
||||||
if not tf[2]["ue_code"]:
|
if not tf[2]["ue_code"]:
|
||||||
|
@ -756,7 +751,7 @@ def ue_table(formation_id=None, semestre_idx=1, msg=""): # was ue_list
|
||||||
H = [
|
H = [
|
||||||
html_sco_header.sco_header(
|
html_sco_header.sco_header(
|
||||||
cssstyles=html_sco_header.BOOTSTRAP_MULTISELECT_CSS
|
cssstyles=html_sco_header.BOOTSTRAP_MULTISELECT_CSS
|
||||||
+ ["libjs/jQuery-tagEditor/jquery.tag-editor.css"],
|
+ ["libjs/jQuery-tagEditor/jquery.tag-editor.css", "css/ue_table.css"],
|
||||||
javascripts=html_sco_header.BOOTSTRAP_MULTISELECT_JS
|
javascripts=html_sco_header.BOOTSTRAP_MULTISELECT_JS
|
||||||
+ [
|
+ [
|
||||||
"libjs/jinplace-1.2.1.min.js",
|
"libjs/jinplace-1.2.1.min.js",
|
||||||
|
@ -842,8 +837,7 @@ du programme" (menu "Semestre") si vous avez un semestre en cours);
|
||||||
<a href="{url_for('notes.refcomp_show',
|
<a href="{url_for('notes.refcomp_show',
|
||||||
scodoc_dept=g.scodoc_dept, refcomp_id=formation.referentiel_competence.id)}"
|
scodoc_dept=g.scodoc_dept, refcomp_id=formation.referentiel_competence.id)}"
|
||||||
class="stdlink">
|
class="stdlink">
|
||||||
{formation.referentiel_competence.type_titre}
|
{formation.referentiel_competence.get_title()}
|
||||||
{formation.referentiel_competence.specialite_long}
|
|
||||||
</a> """
|
</a> """
|
||||||
msg_refcomp = "changer"
|
msg_refcomp = "changer"
|
||||||
H.append(f"""<ul><li>{descr_refcomp}""")
|
H.append(f"""<ul><li>{descr_refcomp}""")
|
||||||
|
@ -1170,14 +1164,17 @@ def _ue_table_ues(
|
||||||
if has_perm_change:
|
if has_perm_change:
|
||||||
H.append(
|
H.append(
|
||||||
f"""<a class="stdlink" href="{
|
f"""<a class="stdlink" href="{
|
||||||
url_for("notes.ue_set_internal", scodoc_dept=g.scodoc_dept, ue_id=ue["ue_id"])
|
url_for("notes.ue_set_internal",
|
||||||
|
scodoc_dept=g.scodoc_dept, ue_id=ue["ue_id"])
|
||||||
}">transformer en UE ordinaire</a> """
|
}">transformer en UE ordinaire</a> """
|
||||||
)
|
)
|
||||||
H.append("</span>")
|
H.append("</span>")
|
||||||
ue_editable = editable and not ue_is_locked(ue["ue_id"])
|
ue_editable = editable and not ue_is_locked(ue["ue_id"])
|
||||||
if ue_editable:
|
if ue_editable:
|
||||||
H.append(
|
H.append(
|
||||||
'<a class="stdlink" href="ue_edit?ue_id=%(ue_id)s">modifier</a>' % ue
|
f"""<a class="stdlink" href="{
|
||||||
|
url_for("notes.ue_edit", scodoc_dept=g.scodoc_dept, ue_id=ue["ue_id"])
|
||||||
|
}">modifier</a>"""
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
H.append('<span class="locked">[verrouillé]</span>')
|
H.append('<span class="locked">[verrouillé]</span>')
|
||||||
|
|
|
@ -478,11 +478,11 @@ def convert_ics(
|
||||||
"heure_deb": event.decoded("dtstart")
|
"heure_deb": event.decoded("dtstart")
|
||||||
.replace(tzinfo=timezone.utc)
|
.replace(tzinfo=timezone.utc)
|
||||||
.astimezone(tz=None)
|
.astimezone(tz=None)
|
||||||
.strftime("%H:%M"),
|
.strftime(scu.TIME_FMT),
|
||||||
"heure_fin": event.decoded("dtend")
|
"heure_fin": event.decoded("dtend")
|
||||||
.replace(tzinfo=timezone.utc)
|
.replace(tzinfo=timezone.utc)
|
||||||
.astimezone(tz=None)
|
.astimezone(tz=None)
|
||||||
.strftime("%H:%M"),
|
.strftime(scu.TIME_FMT),
|
||||||
"jour": event.decoded("dtstart").date().isoformat(),
|
"jour": event.decoded("dtstart").date().isoformat(),
|
||||||
"start": event.decoded("dtstart").isoformat(),
|
"start": event.decoded("dtstart").isoformat(),
|
||||||
"end": event.decoded("dtend").isoformat(),
|
"end": event.decoded("dtend").isoformat(),
|
||||||
|
|
|
@ -452,7 +452,7 @@ def table_apo_csv_list(semset):
|
||||||
apo_data = sco_apogee_csv.ApoData(csv_data, periode=semset["sem_id"])
|
apo_data = sco_apogee_csv.ApoData(csv_data, periode=semset["sem_id"])
|
||||||
t["filename"] = apo_data.apo_csv.titles["apoC_Fichier_Exp"]
|
t["filename"] = apo_data.apo_csv.titles["apoC_Fichier_Exp"]
|
||||||
t["nb_etuds"] = len(apo_data.etuds)
|
t["nb_etuds"] = len(apo_data.etuds)
|
||||||
t["date_str"] = t["date"].strftime("%d/%m/%Y à %H:%M")
|
t["date_str"] = t["date"].strftime(scu.DATEATIME_FMT)
|
||||||
view_link = url_for(
|
view_link = url_for(
|
||||||
"notes.view_apo_csv",
|
"notes.view_apo_csv",
|
||||||
scodoc_dept=g.scodoc_dept,
|
scodoc_dept=g.scodoc_dept,
|
||||||
|
|
|
@ -122,16 +122,14 @@ def format_pays(s):
|
||||||
return ""
|
return ""
|
||||||
|
|
||||||
|
|
||||||
def etud_sort_key(etud: dict) -> tuple:
|
def etud_sort_key(etud: dict) -> str:
|
||||||
"""Clé de tri pour les étudiants représentés par des dict (anciens codes).
|
"""Clé de tri pour les étudiants représentés par des dict (anciens codes).
|
||||||
Equivalent moderne: identite.sort_key
|
Equivalent moderne: identite.sort_key
|
||||||
"""
|
"""
|
||||||
return (
|
return scu.sanitize_string(
|
||||||
scu.sanitize_string(
|
(etud.get("nom_usuel") or etud["nom"] or "") + ";" + (etud["prenom"] or ""),
|
||||||
etud.get("nom_usuel") or etud["nom"] or "", remove_spaces=False
|
remove_spaces=False,
|
||||||
).lower(),
|
).lower()
|
||||||
scu.sanitize_string(etud["prenom"] or "", remove_spaces=False).lower(),
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
_identiteEditor = ndb.EditableTable(
|
_identiteEditor = ndb.EditableTable(
|
||||||
|
|
|
@ -135,7 +135,7 @@ def evaluation_check_absences_html(
|
||||||
f"""<h2 class="eval_check_absences">{
|
f"""<h2 class="eval_check_absences">{
|
||||||
evaluation.description or "évaluation"
|
evaluation.description or "évaluation"
|
||||||
} du {
|
} du {
|
||||||
evaluation.date_debut.strftime("%d/%m/%Y") if evaluation.date_debut else ""
|
evaluation.date_debut.strftime(scu.DATE_FMT) if evaluation.date_debut else ""
|
||||||
} """
|
} """
|
||||||
]
|
]
|
||||||
if (
|
if (
|
||||||
|
|
|
@ -90,7 +90,7 @@ def evaluation_create_form(
|
||||||
raise ValueError("missing moduleimpl_id parameter")
|
raise ValueError("missing moduleimpl_id parameter")
|
||||||
numeros = [(e.numero or 0) for e in modimpl.evaluations]
|
numeros = [(e.numero or 0) for e in modimpl.evaluations]
|
||||||
initvalues = {
|
initvalues = {
|
||||||
"jour": time.strftime("%d/%m/%Y", time.localtime()),
|
"jour": time.strftime(scu.DATE_FMT, time.localtime()),
|
||||||
"note_max": 20,
|
"note_max": 20,
|
||||||
"numero": (max(numeros) + 1) if numeros else 0,
|
"numero": (max(numeros) + 1) if numeros else 0,
|
||||||
"publish_incomplete": is_malus,
|
"publish_incomplete": is_malus,
|
||||||
|
@ -144,7 +144,7 @@ def evaluation_create_form(
|
||||||
if edit:
|
if edit:
|
||||||
initvalues["blocked"] = evaluation.is_blocked()
|
initvalues["blocked"] = evaluation.is_blocked()
|
||||||
initvalues["blocked_until"] = (
|
initvalues["blocked_until"] = (
|
||||||
evaluation.blocked_until.strftime("%d/%m/%Y")
|
evaluation.blocked_until.strftime(scu.DATE_FMT)
|
||||||
if evaluation.blocked_until
|
if evaluation.blocked_until
|
||||||
and evaluation.blocked_until < Evaluation.BLOCKED_FOREVER
|
and evaluation.blocked_until < Evaluation.BLOCKED_FOREVER
|
||||||
else ""
|
else ""
|
||||||
|
@ -231,7 +231,13 @@ def evaluation_create_form(
|
||||||
{
|
{
|
||||||
"input_type": "boolcheckbox",
|
"input_type": "boolcheckbox",
|
||||||
"title": "Prise en compte immédiate",
|
"title": "Prise en compte immédiate",
|
||||||
"explanation": "notes utilisées même si incomplètes",
|
"explanation": """notes utilisées même si incomplètes (dangereux,
|
||||||
|
à n'utiliser que dans des cas particuliers
|
||||||
|
<a target="_blank" rel="noopener noreferrer"
|
||||||
|
href="https://scodoc.org/Evaluation/#pourquoi-eviter-dutiliser-prise-en-compte-immediate"
|
||||||
|
>voir la documentation</a>
|
||||||
|
)
|
||||||
|
""",
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
|
@ -374,13 +380,7 @@ def evaluation_create_form(
|
||||||
args = tf[2]
|
args = tf[2]
|
||||||
# modifie le codage des dates
|
# modifie le codage des dates
|
||||||
# (nb: ce formulaire ne permet de créer que des évaluation sur la même journée)
|
# (nb: ce formulaire ne permet de créer que des évaluation sur la même journée)
|
||||||
if args.get("jour"):
|
date_debut = scu.convert_fr_date(args["jour"]) if args.get("jour") else None
|
||||||
try:
|
|
||||||
date_debut = datetime.datetime.strptime(args["jour"], "%d/%m/%Y")
|
|
||||||
except ValueError as exc:
|
|
||||||
raise ScoValueError("Date (j/m/a) invalide") from exc
|
|
||||||
else:
|
|
||||||
date_debut = None
|
|
||||||
args["date_debut"] = date_debut
|
args["date_debut"] = date_debut
|
||||||
args["date_fin"] = date_debut # même jour
|
args["date_fin"] = date_debut # même jour
|
||||||
args.pop("jour", None)
|
args.pop("jour", None)
|
||||||
|
@ -405,7 +405,7 @@ def evaluation_create_form(
|
||||||
if args.get("blocked_until"):
|
if args.get("blocked_until"):
|
||||||
try:
|
try:
|
||||||
args["blocked_until"] = datetime.datetime.strptime(
|
args["blocked_until"] = datetime.datetime.strptime(
|
||||||
args["blocked_until"], "%d/%m/%Y"
|
args["blocked_until"], scu.DATE_FMT
|
||||||
)
|
)
|
||||||
except ValueError as exc:
|
except ValueError as exc:
|
||||||
raise ScoValueError("Date déblocage (j/m/a) invalide") from exc
|
raise ScoValueError("Date déblocage (j/m/a) invalide") from exc
|
||||||
|
|
|
@ -126,13 +126,15 @@ def evaluations_recap_table(formsemestre: FormSemestre) -> list[dict]:
|
||||||
evaluation_id=evaluation_id,
|
evaluation_id=evaluation_id,
|
||||||
),
|
),
|
||||||
"_titre_target_attrs": 'class="discretelink"',
|
"_titre_target_attrs": 'class="discretelink"',
|
||||||
"date": e.date_debut.strftime("%d/%m/%Y") if e.date_debut else "",
|
"date": e.date_debut.strftime(scu.DATE_FMT) if e.date_debut else "",
|
||||||
"_date_order": e.date_debut.isoformat() if e.date_debut else "",
|
"_date_order": e.date_debut.isoformat() if e.date_debut else "",
|
||||||
"complete": "oui" if eval_etat.is_complete else "non",
|
"complete": "oui" if eval_etat.is_complete else "non",
|
||||||
"_complete_target": "#",
|
"_complete_target": "#",
|
||||||
"_complete_target_attrs": 'class="bull_link" title="prise en compte dans les moyennes"'
|
"_complete_target_attrs": (
|
||||||
if eval_etat.is_complete
|
'class="bull_link" title="prise en compte dans les moyennes"'
|
||||||
else 'class="bull_link incomplete" title="il manque des notes"',
|
if eval_etat.is_complete
|
||||||
|
else 'class="bull_link incomplete" title="il manque des notes"'
|
||||||
|
),
|
||||||
"manquantes": len(modimpl_results.evals_etudids_sans_note[e.id]),
|
"manquantes": len(modimpl_results.evals_etudids_sans_note[e.id]),
|
||||||
"inscrits": modimpl_results.nb_inscrits_module,
|
"inscrits": modimpl_results.nb_inscrits_module,
|
||||||
"nb_abs": sum(modimpl_results.evals_notes[e.id] == scu.NOTES_ABSENCE),
|
"nb_abs": sum(modimpl_results.evals_notes[e.id] == scu.NOTES_ABSENCE),
|
||||||
|
|
|
@ -25,8 +25,8 @@
|
||||||
#
|
#
|
||||||
##############################################################################
|
##############################################################################
|
||||||
|
|
||||||
"""Evaluations
|
"""Evaluations"""
|
||||||
"""
|
|
||||||
import collections
|
import collections
|
||||||
import datetime
|
import datetime
|
||||||
import operator
|
import operator
|
||||||
|
@ -50,6 +50,7 @@ from app.scodoc import sco_cal
|
||||||
from app.scodoc import sco_evaluation_db
|
from app.scodoc import sco_evaluation_db
|
||||||
from app.scodoc import sco_formsemestre_inscriptions
|
from app.scodoc import sco_formsemestre_inscriptions
|
||||||
from app.scodoc import sco_groups
|
from app.scodoc import sco_groups
|
||||||
|
from app.scodoc import sco_gen_cal
|
||||||
from app.scodoc import sco_moduleimpl
|
from app.scodoc import sco_moduleimpl
|
||||||
from app.scodoc import sco_preferences
|
from app.scodoc import sco_preferences
|
||||||
from app.scodoc import sco_users
|
from app.scodoc import sco_users
|
||||||
|
@ -360,6 +361,106 @@ def do_evaluation_etat_in_mod(nt, modimpl: ModuleImpl):
|
||||||
return etat
|
return etat
|
||||||
|
|
||||||
|
|
||||||
|
class JourEval(sco_gen_cal.Jour):
|
||||||
|
"""
|
||||||
|
Représentation d'un jour dans un calendrier d'évaluations
|
||||||
|
"""
|
||||||
|
|
||||||
|
COLOR_INCOMPLETE = "#FF6060"
|
||||||
|
COLOR_COMPLETE = "#A0FFA0"
|
||||||
|
COLOR_FUTUR = "#70E0FF"
|
||||||
|
|
||||||
|
def __init__(
|
||||||
|
self,
|
||||||
|
date: datetime.date,
|
||||||
|
evaluations: list[Evaluation],
|
||||||
|
parent: "CalendrierEval",
|
||||||
|
):
|
||||||
|
super().__init__(date)
|
||||||
|
|
||||||
|
self.evaluations: list[Evaluation] = evaluations
|
||||||
|
self.evaluations.sort(key=lambda e: e.date_debut)
|
||||||
|
|
||||||
|
self.parent: "CalendrierEval" = parent
|
||||||
|
|
||||||
|
def get_html(self) -> str:
|
||||||
|
htmls = []
|
||||||
|
|
||||||
|
for e in self.evaluations:
|
||||||
|
url: str = url_for(
|
||||||
|
"notes.moduleimpl_status",
|
||||||
|
scodoc_dept=g.scodoc_dept,
|
||||||
|
moduleimpl_id=e.moduleimpl_id,
|
||||||
|
)
|
||||||
|
title: str = (
|
||||||
|
e.moduleimpl.module.code or e.moduleimpl.module.abbrev or "éval."
|
||||||
|
)
|
||||||
|
htmls.append(
|
||||||
|
f"""<a
|
||||||
|
href="{url}"
|
||||||
|
style="{self._get_eval_style(e)}"
|
||||||
|
title="{self._get_eval_title(e)}"
|
||||||
|
class="stdlink"
|
||||||
|
>{title}</a>"""
|
||||||
|
)
|
||||||
|
|
||||||
|
return ", ".join(htmls)
|
||||||
|
|
||||||
|
def _get_eval_style(self, e: Evaluation) -> str:
|
||||||
|
color: str = ""
|
||||||
|
# Etat (notes completes) de l'évaluation:
|
||||||
|
modimpl_result = self.parent.nt.modimpls_results[e.moduleimpl.id]
|
||||||
|
if modimpl_result.evaluations_etat[e.id].is_complete:
|
||||||
|
color = JourEval.COLOR_COMPLETE
|
||||||
|
else:
|
||||||
|
color = JourEval.COLOR_INCOMPLETE
|
||||||
|
if e.date_debut > datetime.datetime.now(scu.TIME_ZONE):
|
||||||
|
color = JourEval.COLOR_FUTUR
|
||||||
|
|
||||||
|
return f"background-color: {color};"
|
||||||
|
|
||||||
|
def _get_eval_title(self, e: Evaluation) -> str:
|
||||||
|
heure_debut_txt, heure_fin_txt = "", ""
|
||||||
|
if e.date_debut != e.date_fin:
|
||||||
|
heure_debut_txt = (
|
||||||
|
e.date_debut.strftime(scu.TIME_FMT) if e.date_debut else ""
|
||||||
|
)
|
||||||
|
heure_fin_txt = e.date_fin.strftime(scu.TIME_FMT) if e.date_fin else ""
|
||||||
|
|
||||||
|
title = f"{e.description or e.moduleimpl.module.titre_str()}"
|
||||||
|
if heure_debut_txt:
|
||||||
|
title += f" de {heure_debut_txt} à {heure_fin_txt}"
|
||||||
|
|
||||||
|
return title
|
||||||
|
|
||||||
|
|
||||||
|
class CalendrierEval(sco_gen_cal.Calendrier):
|
||||||
|
"""
|
||||||
|
Représentation des évaluations d'un semestre dans un calendrier
|
||||||
|
"""
|
||||||
|
|
||||||
|
def __init__(self, year: int, evals: list[Evaluation], nt: NotesTableCompat):
|
||||||
|
# On prend du 01/09 au 31/08
|
||||||
|
date_debut: datetime.datetime = datetime.datetime(year, 9, 1, 0, 0)
|
||||||
|
date_fin: datetime.datetime = datetime.datetime(year + 1, 8, 31, 23, 59)
|
||||||
|
super().__init__(date_debut, date_fin)
|
||||||
|
|
||||||
|
# évalutions du semestre
|
||||||
|
self.evals: dict[datetime.date, list[Evaluation]] = {}
|
||||||
|
for e in evals:
|
||||||
|
if e.date_debut is not None:
|
||||||
|
day = e.date_debut.date()
|
||||||
|
if day not in self.evals:
|
||||||
|
self.evals[day] = []
|
||||||
|
self.evals[day].append(e)
|
||||||
|
|
||||||
|
self.nt: NotesTableCompat = nt
|
||||||
|
|
||||||
|
def instanciate_jour(self, date: datetime.date) -> JourEval:
|
||||||
|
return JourEval(date, self.evals.get(date, []), parent=self)
|
||||||
|
|
||||||
|
|
||||||
|
# View
|
||||||
def formsemestre_evaluations_cal(formsemestre_id):
|
def formsemestre_evaluations_cal(formsemestre_id):
|
||||||
"""Page avec calendrier de toutes les evaluations de ce semestre"""
|
"""Page avec calendrier de toutes les evaluations de ce semestre"""
|
||||||
formsemestre = FormSemestre.get_formsemestre(formsemestre_id)
|
formsemestre = FormSemestre.get_formsemestre(formsemestre_id)
|
||||||
|
@ -368,56 +469,9 @@ def formsemestre_evaluations_cal(formsemestre_id):
|
||||||
evaluations = formsemestre.get_evaluations()
|
evaluations = formsemestre.get_evaluations()
|
||||||
nb_evals = len(evaluations)
|
nb_evals = len(evaluations)
|
||||||
|
|
||||||
color_incomplete = "#FF6060"
|
|
||||||
color_complete = "#A0FFA0"
|
|
||||||
color_futur = "#70E0FF"
|
|
||||||
|
|
||||||
year = formsemestre.annee_scolaire()
|
year = formsemestre.annee_scolaire()
|
||||||
events = {} # (day, halfday) : event
|
cal = CalendrierEval(year, evaluations, nt)
|
||||||
for e in evaluations:
|
cal_html = cal.get_html()
|
||||||
if e.date_debut is None:
|
|
||||||
continue # éval. sans date
|
|
||||||
txt = e.moduleimpl.module.code or e.moduleimpl.module.abbrev or "éval."
|
|
||||||
if e.date_debut == e.date_fin:
|
|
||||||
heure_debut_txt, heure_fin_txt = "?", "?"
|
|
||||||
else:
|
|
||||||
heure_debut_txt = e.date_debut.strftime("%Hh%M") if e.date_debut else "?"
|
|
||||||
heure_fin_txt = e.date_fin.strftime("%Hh%M") if e.date_fin else "?"
|
|
||||||
|
|
||||||
description = f"""{
|
|
||||||
e.moduleimpl.module.titre
|
|
||||||
}, de {heure_debut_txt} à {heure_fin_txt}"""
|
|
||||||
|
|
||||||
# Etat (notes completes) de l'évaluation:
|
|
||||||
modimpl_result = nt.modimpls_results[e.moduleimpl.id]
|
|
||||||
if modimpl_result.evaluations_etat[e.id].is_complete:
|
|
||||||
color = color_complete
|
|
||||||
else:
|
|
||||||
color = color_incomplete
|
|
||||||
if e.date_debut > datetime.datetime.now(scu.TIME_ZONE):
|
|
||||||
color = color_futur
|
|
||||||
href = url_for(
|
|
||||||
"notes.moduleimpl_status",
|
|
||||||
scodoc_dept=g.scodoc_dept,
|
|
||||||
moduleimpl_id=e.moduleimpl_id,
|
|
||||||
)
|
|
||||||
day = e.date_debut.date().isoformat() # yyyy-mm-dd
|
|
||||||
event = events.get(day)
|
|
||||||
if not event:
|
|
||||||
events[day] = [day, txt, color, href, description, e.moduleimpl]
|
|
||||||
else:
|
|
||||||
if event[-1].id != e.moduleimpl.id:
|
|
||||||
# plusieurs evals de modules differents a la meme date
|
|
||||||
event[1] += ", " + txt
|
|
||||||
event[4] += ", " + description
|
|
||||||
if color == color_incomplete:
|
|
||||||
event[2] = color_incomplete
|
|
||||||
if color == color_futur:
|
|
||||||
event[2] = color_futur
|
|
||||||
|
|
||||||
cal_html = sco_cal.YearTable(
|
|
||||||
year, events=list(events.values()), halfday=False, pad_width=None
|
|
||||||
)
|
|
||||||
|
|
||||||
return f"""
|
return f"""
|
||||||
{
|
{
|
||||||
|
@ -433,15 +487,15 @@ def formsemestre_evaluations_cal(formsemestre_id):
|
||||||
</p>
|
</p>
|
||||||
<ul>
|
<ul>
|
||||||
<li>en <span style=
|
<li>en <span style=
|
||||||
"background-color: {color_incomplete}">rouge</span>
|
"background-color: {JourEval.COLOR_INCOMPLETE}">rouge</span>
|
||||||
les évaluations passées auxquelles il manque des notes
|
les évaluations passées auxquelles il manque des notes
|
||||||
</li>
|
</li>
|
||||||
<li>en <span style=
|
<li>en <span style=
|
||||||
"background-color: {color_complete}">vert</span>
|
"background-color: {JourEval.COLOR_COMPLETE}">vert</span>
|
||||||
les évaluations déjà notées
|
les évaluations déjà notées
|
||||||
</li>
|
</li>
|
||||||
<li>en <span style=
|
<li>en <span style=
|
||||||
"background-color: {color_futur}">bleu</span>
|
"background-color: {JourEval.COLOR_FUTUR}">bleu</span>
|
||||||
les évaluations futures
|
les évaluations futures
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
@ -526,7 +580,7 @@ def formsemestre_evaluations_delai_correction(formsemestre_id, fmt="html"):
|
||||||
"date_first_complete": date_first_complete,
|
"date_first_complete": date_first_complete,
|
||||||
"delai_correction": delai_correction,
|
"delai_correction": delai_correction,
|
||||||
"jour": (
|
"jour": (
|
||||||
e.date_debut.strftime("%d/%m/%Y") if e.date_debut else "sans date"
|
e.date_debut.strftime(scu.DATE_FMT) if e.date_debut else "sans date"
|
||||||
),
|
),
|
||||||
"_jour_target": url_for(
|
"_jour_target": url_for(
|
||||||
"notes.evaluation_listenotes",
|
"notes.evaluation_listenotes",
|
||||||
|
@ -539,7 +593,9 @@ def formsemestre_evaluations_delai_correction(formsemestre_id, fmt="html"):
|
||||||
scodoc_dept=g.scodoc_dept,
|
scodoc_dept=g.scodoc_dept,
|
||||||
moduleimpl_id=e.moduleimpl.id,
|
moduleimpl_id=e.moduleimpl.id,
|
||||||
),
|
),
|
||||||
"module_titre": e.moduleimpl.module.abbrev or e.moduleimpl.module.titre,
|
"module_titre": e.moduleimpl.module.abbrev
|
||||||
|
or e.moduleimpl.module.titre
|
||||||
|
or "",
|
||||||
"responsable_id": e.moduleimpl.responsable_id,
|
"responsable_id": e.moduleimpl.responsable_id,
|
||||||
"responsable_nomplogin": sco_users.user_info(
|
"responsable_nomplogin": sco_users.user_info(
|
||||||
e.moduleimpl.responsable_id
|
e.moduleimpl.responsable_id
|
||||||
|
|
|
@ -72,7 +72,7 @@ def xldate_as_datetime(xldate, datemode=0):
|
||||||
Peut lever une ValueError
|
Peut lever une ValueError
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
return datetime.datetime.strptime(xldate, "%d/%m/%Y")
|
return datetime.datetime.strptime(xldate, scu.DATE_FMT)
|
||||||
except:
|
except:
|
||||||
return openpyxl.utils.datetime.from_ISO8601(xldate)
|
return openpyxl.utils.datetime.from_ISO8601(xldate)
|
||||||
|
|
||||||
|
|
|
@ -103,7 +103,7 @@ class ScoPDFFormatError(ScoValueError):
|
||||||
super().__init__(
|
super().__init__(
|
||||||
f"""Erreur dans un format pdf:
|
f"""Erreur dans un format pdf:
|
||||||
<p>{msg}</p>
|
<p>{msg}</p>
|
||||||
<p>Vérifiez les paramètres (polices de caractères, balisage)
|
<p>Vérifiez les paramètres (polices de caractères, balisage, réglages bulletins...)
|
||||||
dans les paramètres ou préférences.
|
dans les paramètres ou préférences.
|
||||||
</p>
|
</p>
|
||||||
""",
|
""",
|
||||||
|
|
|
@ -489,9 +489,10 @@ def formation_import_xml(doc: str, import_tags=True, use_local_refcomp=False):
|
||||||
return formation.id, modules_old2new, ues_old2new
|
return formation.id, modules_old2new, ues_old2new
|
||||||
|
|
||||||
|
|
||||||
def formation_list_table() -> GenTable:
|
def formation_list_table(detail: bool) -> GenTable:
|
||||||
"""List formation, grouped by titre and sorted by versions
|
"""List formation, grouped by titre and sorted by versions
|
||||||
and listing associated semestres
|
and listing associated semestres.
|
||||||
|
If detail, add column with more details.
|
||||||
returns a table
|
returns a table
|
||||||
"""
|
"""
|
||||||
formations: list[Formation] = Formation.query.filter_by(dept_id=g.scodoc_dept_id)
|
formations: list[Formation] = Formation.query.filter_by(dept_id=g.scodoc_dept_id)
|
||||||
|
@ -507,6 +508,7 @@ def formation_list_table() -> GenTable:
|
||||||
)
|
)
|
||||||
|
|
||||||
editable = current_user.has_permission(Permission.EditFormation)
|
editable = current_user.has_permission(Permission.EditFormation)
|
||||||
|
can_implement = current_user.has_permission(Permission.EditFormSemestre)
|
||||||
|
|
||||||
# Traduit/ajoute des champs à afficher:
|
# Traduit/ajoute des champs à afficher:
|
||||||
rows = []
|
rows = []
|
||||||
|
@ -533,6 +535,15 @@ def formation_list_table() -> GenTable:
|
||||||
if formation.referentiel_competence
|
if formation.referentiel_competence
|
||||||
else ""
|
else ""
|
||||||
),
|
),
|
||||||
|
"_referentiel_target": (
|
||||||
|
url_for(
|
||||||
|
"notes.refcomp_show",
|
||||||
|
scodoc_dept=g.scodoc_dept,
|
||||||
|
refcomp_id=formation.referentiel_competence.id,
|
||||||
|
)
|
||||||
|
if formation.referentiel_competence
|
||||||
|
else ""
|
||||||
|
),
|
||||||
}
|
}
|
||||||
# Ajoute les semestres associés à chaque formation:
|
# Ajoute les semestres associés à chaque formation:
|
||||||
row["formsemestres"] = formation.formsemestres.order_by(
|
row["formsemestres"] = formation.formsemestres.order_by(
|
||||||
|
@ -547,20 +558,28 @@ def formation_list_table() -> GenTable:
|
||||||
)}">{s.session_id()}</a>"""
|
)}">{s.session_id()}</a>"""
|
||||||
for s in row["formsemestres"]
|
for s in row["formsemestres"]
|
||||||
]
|
]
|
||||||
+ [
|
+ (
|
||||||
f"""<a class="stdlink" id="add-semestre-{
|
[
|
||||||
formation.acronyme.lower().replace(" ", "-")}"
|
f"""<a class="stdlink"
|
||||||
href="{ url_for("notes.formsemestre_createwithmodules",
|
href="{ url_for("notes.formsemestre_createwithmodules",
|
||||||
scodoc_dept=g.scodoc_dept, formation_id=formation.id, semestre_id=1
|
scodoc_dept=g.scodoc_dept, formation_id=formation.id, semestre_id=1
|
||||||
)
|
)
|
||||||
}">ajouter</a>
|
}">ajouter</a>
|
||||||
"""
|
"""
|
||||||
]
|
]
|
||||||
)
|
if can_implement
|
||||||
if row["formsemestres"]:
|
else []
|
||||||
row["date_fin_dernier_sem"] = (
|
|
||||||
row["formsemestres"][-1].date_fin.isoformat(),
|
|
||||||
)
|
)
|
||||||
|
)
|
||||||
|
# Répartition des UEs dans les semestres
|
||||||
|
# utilise pour voir si la formation couvre tous les semestres
|
||||||
|
row["semestres_ues"] = ", ".join(
|
||||||
|
"S" + str(x if (x is not None and x > 0) else "-")
|
||||||
|
for x in sorted({(ue.semestre_idx or 0) for ue in formation.ues})
|
||||||
|
)
|
||||||
|
# Date surtout utilisées pour le tri:
|
||||||
|
if row["formsemestres"]:
|
||||||
|
row["date_fin_dernier_sem"] = row["formsemestres"][-1].date_fin.isoformat()
|
||||||
row["annee_dernier_sem"] = row["formsemestres"][-1].date_fin.year
|
row["annee_dernier_sem"] = row["formsemestres"][-1].date_fin.year
|
||||||
else:
|
else:
|
||||||
row["date_fin_dernier_sem"] = ""
|
row["date_fin_dernier_sem"] = ""
|
||||||
|
@ -613,6 +632,8 @@ def formation_list_table() -> GenTable:
|
||||||
"commentaire",
|
"commentaire",
|
||||||
"sems_list_txt",
|
"sems_list_txt",
|
||||||
)
|
)
|
||||||
|
if detail:
|
||||||
|
columns_ids += ("annee_dernier_sem", "semestres_ues")
|
||||||
titles = {
|
titles = {
|
||||||
"buttons": "",
|
"buttons": "",
|
||||||
"commentaire": "Commentaire",
|
"commentaire": "Commentaire",
|
||||||
|
@ -623,6 +644,9 @@ def formation_list_table() -> GenTable:
|
||||||
"formation_code": "Code",
|
"formation_code": "Code",
|
||||||
"sems_list_txt": "Semestres",
|
"sems_list_txt": "Semestres",
|
||||||
"referentiel": "Réf.",
|
"referentiel": "Réf.",
|
||||||
|
"date_fin_dernier_sem": "Fin dernier sem.",
|
||||||
|
"annee_dernier_sem": "Année dernier sem.",
|
||||||
|
"semestres_ues": "Semestres avec UEs",
|
||||||
}
|
}
|
||||||
return GenTable(
|
return GenTable(
|
||||||
columns_ids=columns_ids,
|
columns_ids=columns_ids,
|
||||||
|
@ -635,7 +659,7 @@ def formation_list_table() -> GenTable:
|
||||||
html_class="formation_list_table table_leftalign",
|
html_class="formation_list_table table_leftalign",
|
||||||
html_with_td_classes=True,
|
html_with_td_classes=True,
|
||||||
html_sortable=True,
|
html_sortable=True,
|
||||||
base_url=f"{request.base_url}",
|
base_url=f"{request.base_url}" + ("?detail=on" if detail else ""),
|
||||||
page_title=title,
|
page_title=title,
|
||||||
pdf_title=title,
|
pdf_title=title,
|
||||||
preferences=sco_preferences.SemPreferences(),
|
preferences=sco_preferences.SemPreferences(),
|
||||||
|
|
|
@ -494,7 +494,7 @@ def table_formsemestres(
|
||||||
):
|
):
|
||||||
"""Une table presentant des semestres"""
|
"""Une table presentant des semestres"""
|
||||||
for sem in sems:
|
for sem in sems:
|
||||||
sem_set_responsable_name(sem)
|
sem_set_responsable_name(sem) # TODO utiliser formsemestre.responsables_str()
|
||||||
sem["_titre_num_target"] = url_for(
|
sem["_titre_num_target"] = url_for(
|
||||||
"notes.formsemestre_status",
|
"notes.formsemestre_status",
|
||||||
scodoc_dept=g.scodoc_dept,
|
scodoc_dept=g.scodoc_dept,
|
||||||
|
|
|
@ -812,14 +812,18 @@ def do_formsemestre_createwithmodules(edit=False, formsemestre: FormSemestre = N
|
||||||
)
|
)
|
||||||
msg = ""
|
msg = ""
|
||||||
if tf[0] == 1:
|
if tf[0] == 1:
|
||||||
# check dates
|
# convert and check dates
|
||||||
if ndb.DateDMYtoISO(tf[2]["date_debut"]) > ndb.DateDMYtoISO(tf[2]["date_fin"]):
|
tf[2]["date_debut"] = scu.convert_fr_date(tf[2]["date_debut"])
|
||||||
msg = '<ul class="tf-msg"><li class="tf-msg">Dates de début et fin incompatibles !</li></ul>'
|
tf[2]["date_fin"] = scu.convert_fr_date(tf[2]["date_fin"])
|
||||||
|
if tf[2]["date_debut"] > tf[2]["date_fin"]:
|
||||||
|
msg = """<ul class="tf-msg">
|
||||||
|
<li class="tf-msg">Dates de début et fin incompatibles !</li>
|
||||||
|
</ul>"""
|
||||||
|
|
||||||
if (
|
if (
|
||||||
sco_preferences.get_preference("always_require_apo_sem_codes")
|
sco_preferences.get_preference("always_require_apo_sem_codes")
|
||||||
and not any(
|
and not any(
|
||||||
[tf[2]["etape_apo" + str(n)] for n in range(0, scu.EDIT_NB_ETAPES + 1)]
|
tf[2]["etape_apo" + str(n)] for n in range(0, scu.EDIT_NB_ETAPES + 1)
|
||||||
)
|
)
|
||||||
# n'impose pas d'Apo pour les sem. extérieurs
|
# n'impose pas d'Apo pour les sem. extérieurs
|
||||||
and ((formsemestre is None) or formsemestre.modalite != "EXT")
|
and ((formsemestre is None) or formsemestre.modalite != "EXT")
|
||||||
|
@ -1427,18 +1431,25 @@ Ceci n'est possible que si :
|
||||||
|
|
||||||
def formsemestre_delete2(formsemestre_id, dialog_confirmed=False):
|
def formsemestre_delete2(formsemestre_id, dialog_confirmed=False):
|
||||||
"""Delete a formsemestre (confirmation)"""
|
"""Delete a formsemestre (confirmation)"""
|
||||||
|
formsemestre = FormSemestre.get_formsemestre(formsemestre_id)
|
||||||
# Confirmation dialog
|
# Confirmation dialog
|
||||||
if not dialog_confirmed:
|
if not dialog_confirmed:
|
||||||
return scu.confirm_dialog(
|
return scu.confirm_dialog(
|
||||||
"""<h2>Vous voulez vraiment supprimer ce semestre ???</h2><p>(opération irréversible)</p>""",
|
"""<h2>Vous voulez vraiment supprimer ce semestre ???</h2>
|
||||||
|
<p>(opération irréversible)</p>
|
||||||
|
""",
|
||||||
dest_url="",
|
dest_url="",
|
||||||
cancel_url="formsemestre_status?formsemestre_id=%s" % formsemestre_id,
|
cancel_url=url_for(
|
||||||
parameters={"formsemestre_id": formsemestre_id},
|
"notes.formsemestre_status",
|
||||||
|
scodoc_dept=g.scodoc_dept,
|
||||||
|
formsemestre_id=formsemestre.id,
|
||||||
|
),
|
||||||
|
parameters={"formsemestre_id": formsemestre.id},
|
||||||
)
|
)
|
||||||
# Bon, s'il le faut...
|
# Bon, s'il le faut...
|
||||||
do_formsemestre_delete(formsemestre_id)
|
do_formsemestre_delete(formsemestre.id)
|
||||||
flash("Semestre supprimé !")
|
flash("Semestre supprimé !")
|
||||||
return flask.redirect(scu.ScoURL())
|
return flask.redirect(url_for("scolar.index_html", scodoc_dept=g.scodoc_dept))
|
||||||
|
|
||||||
|
|
||||||
def formsemestre_has_decisions_or_compensations(
|
def formsemestre_has_decisions_or_compensations(
|
||||||
|
|
|
@ -521,7 +521,7 @@ def _record_ue_validations_and_coefs(
|
||||||
coef = _convert_field_to_float(coef)
|
coef = _convert_field_to_float(coef)
|
||||||
if coef == "" or coef is False:
|
if coef == "" or coef is False:
|
||||||
coef = None
|
coef = None
|
||||||
now_dmy = time.strftime("%d/%m/%Y")
|
now_dmy = time.strftime(scu.DATE_FMT)
|
||||||
log(
|
log(
|
||||||
f"_record_ue_validations_and_coefs: {formsemestre.id} etudid={etud.id} ue_id={ue.id} moy_ue={note} ue_coef={coef}"
|
f"_record_ue_validations_and_coefs: {formsemestre.id} etudid={etud.id} ue_id={ue.id} moy_ue={note} ue_coef={coef}"
|
||||||
)
|
)
|
||||||
|
|
|
@ -106,7 +106,7 @@ def do_formsemestre_inscription_create(args, method=None):
|
||||||
cnx,
|
cnx,
|
||||||
args={
|
args={
|
||||||
"etudid": args["etudid"],
|
"etudid": args["etudid"],
|
||||||
"event_date": time.strftime("%d/%m/%Y"),
|
"event_date": time.strftime(scu.DATE_FMT),
|
||||||
"formsemestre_id": args["formsemestre_id"],
|
"formsemestre_id": args["formsemestre_id"],
|
||||||
"event_type": "INSCRIPTION",
|
"event_type": "INSCRIPTION",
|
||||||
},
|
},
|
||||||
|
|
|
@ -25,8 +25,7 @@
|
||||||
#
|
#
|
||||||
##############################################################################
|
##############################################################################
|
||||||
|
|
||||||
"""Tableau de bord semestre
|
"""Tableau de bord semestre"""
|
||||||
"""
|
|
||||||
|
|
||||||
import datetime
|
import datetime
|
||||||
|
|
||||||
|
@ -65,14 +64,11 @@ from app.scodoc import sco_archives_formsemestre
|
||||||
from app.scodoc import sco_bulletins
|
from app.scodoc import sco_bulletins
|
||||||
from app.scodoc import codes_cursus
|
from app.scodoc import codes_cursus
|
||||||
from app.scodoc import sco_compute_moy
|
from app.scodoc import sco_compute_moy
|
||||||
from app.scodoc import sco_edit_ue
|
|
||||||
from app.scodoc import sco_evaluations
|
from app.scodoc import sco_evaluations
|
||||||
from app.scodoc import sco_evaluation_db
|
|
||||||
from app.scodoc import sco_formations
|
from app.scodoc import sco_formations
|
||||||
from app.scodoc import sco_formsemestre
|
from app.scodoc import sco_formsemestre
|
||||||
from app.scodoc import sco_formsemestre_inscriptions
|
from app.scodoc import sco_formsemestre_inscriptions
|
||||||
from app.scodoc import sco_groups
|
from app.scodoc import sco_groups
|
||||||
from app.scodoc import sco_moduleimpl
|
|
||||||
from app.scodoc import sco_preferences
|
from app.scodoc import sco_preferences
|
||||||
from app.scodoc import sco_users
|
from app.scodoc import sco_users
|
||||||
from app.scodoc.gen_tables import GenTable
|
from app.scodoc.gen_tables import GenTable
|
||||||
|
@ -147,8 +143,10 @@ def _build_menu_stats(formsemestre: FormSemestre):
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
def formsemestre_status_menubar(formsemestre: FormSemestre) -> str:
|
def formsemestre_status_menubar(formsemestre: FormSemestre | None) -> str:
|
||||||
"""HTML to render menubar"""
|
"""HTML to render menubar"""
|
||||||
|
if formsemestre is None:
|
||||||
|
return ""
|
||||||
formsemestre_id = formsemestre.id
|
formsemestre_id = formsemestre.id
|
||||||
if formsemestre.etat:
|
if formsemestre.etat:
|
||||||
change_lock_msg = "Verrouiller"
|
change_lock_msg = "Verrouiller"
|
||||||
|
@ -636,7 +634,7 @@ def formsemestre_description_table(
|
||||||
"UE": modimpl.module.ue.acronyme,
|
"UE": modimpl.module.ue.acronyme,
|
||||||
"_UE_td_attrs": ue_info.get("_UE_td_attrs", ""),
|
"_UE_td_attrs": ue_info.get("_UE_td_attrs", ""),
|
||||||
"Code": modimpl.module.code or "",
|
"Code": modimpl.module.code or "",
|
||||||
"Module": modimpl.module.abbrev or modimpl.module.titre,
|
"Module": modimpl.module.abbrev or modimpl.module.titre or "",
|
||||||
"_Module_class": "scotext",
|
"_Module_class": "scotext",
|
||||||
"Inscrits": mod_nb_inscrits,
|
"Inscrits": mod_nb_inscrits,
|
||||||
"Responsable": sco_users.user_info(modimpl.responsable_id)["nomprenom"],
|
"Responsable": sco_users.user_info(modimpl.responsable_id)["nomprenom"],
|
||||||
|
@ -693,7 +691,7 @@ def formsemestre_description_table(
|
||||||
)
|
)
|
||||||
e["_date_evaluation_order"] = e["jour"].isoformat()
|
e["_date_evaluation_order"] = e["jour"].isoformat()
|
||||||
e["date_evaluation"] = (
|
e["date_evaluation"] = (
|
||||||
e["jour"].strftime("%d/%m/%Y") if e["jour"] else ""
|
e["jour"].strftime(scu.DATE_FMT) if e["jour"] else ""
|
||||||
)
|
)
|
||||||
e["UE"] = row["UE"]
|
e["UE"] = row["UE"]
|
||||||
e["_UE_td_attrs"] = row["_UE_td_attrs"]
|
e["_UE_td_attrs"] = row["_UE_td_attrs"]
|
||||||
|
@ -798,7 +796,7 @@ def _make_listes_sem(formsemestre: FormSemestre) -> str:
|
||||||
'Tous les étudiants'}
|
'Tous les étudiants'}
|
||||||
</div>
|
</div>
|
||||||
<div class="sem-groups-partition-titre">{
|
<div class="sem-groups-partition-titre">{
|
||||||
"Gestion de l'assiduité" if not partition_is_empty else ""
|
"Assiduité" if not partition_is_empty else ""
|
||||||
}</div>
|
}</div>
|
||||||
"""
|
"""
|
||||||
)
|
)
|
||||||
|
@ -824,14 +822,14 @@ def _make_listes_sem(formsemestre: FormSemestre) -> str:
|
||||||
</div>
|
</div>
|
||||||
<div class="sem-groups-assi">
|
<div class="sem-groups-assi">
|
||||||
<div>
|
<div>
|
||||||
<a class="btn" href="{
|
<a class="stdlink" href="{
|
||||||
url_for("assiduites.visu_assi_group",
|
url_for("assiduites.visu_assi_group",
|
||||||
scodoc_dept=g.scodoc_dept,
|
scodoc_dept=g.scodoc_dept,
|
||||||
date_debut=formsemestre.date_debut.isoformat(),
|
date_debut=formsemestre.date_debut.isoformat(),
|
||||||
date_fin=formsemestre.date_fin.isoformat(),
|
date_fin=formsemestre.date_fin.isoformat(),
|
||||||
group_ids=group.id,
|
group_ids=group.id,
|
||||||
)}">
|
)}">
|
||||||
<button>Bilan assiduité</button></a>
|
Bilan</a>
|
||||||
</div>
|
</div>
|
||||||
"""
|
"""
|
||||||
)
|
)
|
||||||
|
@ -839,42 +837,42 @@ def _make_listes_sem(formsemestre: FormSemestre) -> str:
|
||||||
H.append(
|
H.append(
|
||||||
f"""
|
f"""
|
||||||
<div>
|
<div>
|
||||||
<a class="btn" href="{
|
<a class="stdlink" href="{
|
||||||
url_for("assiduites.visu_assiduites_group",
|
url_for("assiduites.visu_assiduites_group",
|
||||||
scodoc_dept=g.scodoc_dept,
|
scodoc_dept=g.scodoc_dept,
|
||||||
formsemestre_id=formsemestre.id,
|
formsemestre_id=formsemestre.id,
|
||||||
jour = datetime.date.today().isoformat(),
|
jour = datetime.date.today().isoformat(),
|
||||||
group_ids=group.id,
|
group_ids=group.id,
|
||||||
)}">
|
)}">
|
||||||
<button>Visualiser</button></a>
|
Visualiser</a>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<a class="btn" href="{
|
<a class="stdlink" href="{
|
||||||
url_for("assiduites.signal_assiduites_group",
|
url_for("assiduites.signal_assiduites_group",
|
||||||
scodoc_dept=g.scodoc_dept,
|
scodoc_dept=g.scodoc_dept,
|
||||||
jour=datetime.date.today().isoformat(),
|
jour=datetime.date.today().isoformat(),
|
||||||
formsemestre_id=formsemestre.id,
|
formsemestre_id=formsemestre.id,
|
||||||
group_ids=group.id,
|
group_ids=group.id,
|
||||||
)}">
|
)}">
|
||||||
<button>Saisie journalière</button></a>
|
Saisie journalière</a>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<a class="btn" href="{
|
<a class="stdlink" href="{
|
||||||
url_for("assiduites.signal_assiduites_diff",
|
url_for("assiduites.signal_assiduites_diff",
|
||||||
scodoc_dept=g.scodoc_dept,
|
scodoc_dept=g.scodoc_dept,
|
||||||
formsemestre_id=formsemestre.id,
|
formsemestre_id=formsemestre.id,
|
||||||
group_ids=group.id,
|
group_ids=group.id,
|
||||||
)}">
|
)}">
|
||||||
<button>Saisie différée</button></a>
|
Saisie différée</a>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<a class="btn" href="{
|
<a class="stdlink" href="{
|
||||||
url_for("assiduites.bilan_dept",
|
url_for("assiduites.bilan_dept",
|
||||||
scodoc_dept=g.scodoc_dept,
|
scodoc_dept=g.scodoc_dept,
|
||||||
formsemestre_id=formsemestre.id,
|
formsemestre_id=formsemestre.id,
|
||||||
group_ids=group.id,
|
group_ids=group.id,
|
||||||
)}">
|
)}">
|
||||||
<button>Justificatifs en attente</button></a>
|
Justificatifs en attente</a>
|
||||||
</div>
|
</div>
|
||||||
"""
|
"""
|
||||||
)
|
)
|
||||||
|
@ -1128,6 +1126,19 @@ def formsemestre_status(formsemestre_id=None, check_parcours=True):
|
||||||
_make_listes_sem(formsemestre),
|
_make_listes_sem(formsemestre),
|
||||||
"</div>",
|
"</div>",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
# --- Lien Traitement Justificatifs:
|
||||||
|
|
||||||
|
if current_user.has_permission(Permission.AbsJustifView):
|
||||||
|
H.append(
|
||||||
|
f"""<p>
|
||||||
|
<a class="stdlink" href="{url_for('assiduites.traitement_justificatifs',
|
||||||
|
scodoc_dept=g.scodoc_dept,
|
||||||
|
formsemestre_id=formsemestre.id)}">
|
||||||
|
Traitement des justificatifs d'absence</a>
|
||||||
|
</p>"""
|
||||||
|
)
|
||||||
|
|
||||||
# --- Lien mail enseignants:
|
# --- Lien mail enseignants:
|
||||||
adrlist = list(mails_enseignants - {None, ""})
|
adrlist = list(mails_enseignants - {None, ""})
|
||||||
if adrlist:
|
if adrlist:
|
||||||
|
@ -1483,7 +1494,12 @@ def formsemestre_note_etuds_sans_notes(
|
||||||
</div>
|
</div>
|
||||||
{message}
|
{message}
|
||||||
|
|
||||||
<form method="post">
|
<style>
|
||||||
|
.sco-std-form select, .sco-std-form input[type="submit"] {{
|
||||||
|
height: 24px;
|
||||||
|
}}
|
||||||
|
</style>
|
||||||
|
<form class="sco-std-form" method="post">
|
||||||
<input type="hidden" name="formsemestre_id" value="{formsemestre.id}">
|
<input type="hidden" name="formsemestre_id" value="{formsemestre.id}">
|
||||||
<input type="hidden" name="etudid" value="{etudid or ""}">
|
<input type="hidden" name="etudid" value="{etudid or ""}">
|
||||||
|
|
||||||
|
@ -1494,7 +1510,7 @@ def formsemestre_note_etuds_sans_notes(
|
||||||
<option value="ATT" selected>ATT (en attente)</option>
|
<option value="ATT" selected>ATT (en attente)</option>
|
||||||
<option value="EXC">EXC (neutralisée)</option>
|
<option value="EXC">EXC (neutralisée)</option>
|
||||||
</select>
|
</select>
|
||||||
<input type="submit" name="enregistrer">
|
<input type="submit" value="Enregistrer">
|
||||||
</form>
|
</form>
|
||||||
{html_sco_header.sco_footer()}
|
{html_sco_header.sco_footer()}
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -57,14 +57,12 @@ from app.scodoc import html_sco_header
|
||||||
from app.scodoc import sco_assiduites
|
from app.scodoc import sco_assiduites
|
||||||
from app.scodoc import codes_cursus
|
from app.scodoc import codes_cursus
|
||||||
from app.scodoc import sco_cache
|
from app.scodoc import sco_cache
|
||||||
from app.scodoc import sco_edit_ue
|
|
||||||
from app.scodoc import sco_etud
|
from app.scodoc import sco_etud
|
||||||
from app.scodoc import sco_formsemestre
|
from app.scodoc import sco_formsemestre
|
||||||
from app.scodoc import sco_formsemestre_inscriptions
|
from app.scodoc import sco_formsemestre_inscriptions
|
||||||
from app.scodoc import sco_cursus
|
from app.scodoc import sco_cursus
|
||||||
from app.scodoc import sco_cursus_dut
|
from app.scodoc import sco_cursus_dut
|
||||||
from app.scodoc.sco_cursus_dut import etud_est_inscrit_ue
|
from app.scodoc.sco_cursus_dut import etud_est_inscrit_ue
|
||||||
from app.scodoc import sco_photos
|
|
||||||
from app.scodoc import sco_preferences
|
from app.scodoc import sco_preferences
|
||||||
from app.scodoc import sco_pv_dict
|
from app.scodoc import sco_pv_dict
|
||||||
from app.scodoc.sco_permissions import Permission
|
from app.scodoc.sco_permissions import Permission
|
||||||
|
@ -1162,7 +1160,7 @@ def formsemestre_validate_previous_ue(formsemestre: FormSemestre, etud: Identite
|
||||||
"input_type": "date",
|
"input_type": "date",
|
||||||
"size": 9,
|
"size": 9,
|
||||||
"explanation": "j/m/a",
|
"explanation": "j/m/a",
|
||||||
"default": time.strftime("%d/%m/%Y"),
|
"default": time.strftime(scu.DATE_FMT),
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
|
@ -1210,7 +1208,9 @@ def formsemestre_validate_previous_ue(formsemestre: FormSemestre, etud: Identite
|
||||||
|
|
||||||
<p class="help">Utiliser cette page pour enregistrer des UEs validées antérieurement,
|
<p class="help">Utiliser cette page pour enregistrer des UEs validées antérieurement,
|
||||||
<em>dans un semestre hors ScoDoc</em>.</p>
|
<em>dans un semestre hors ScoDoc</em>.</p>
|
||||||
<p class="expl"><b>Les UE validées dans ScoDoc sont
|
|
||||||
|
<div class="scobox explanation">
|
||||||
|
<p><b>Les UE validées dans ScoDoc sont
|
||||||
automatiquement prises en compte</b>.
|
automatiquement prises en compte</b>.
|
||||||
</p>
|
</p>
|
||||||
<p>Cette page est surtout utile pour les étudiants ayant
|
<p>Cette page est surtout utile pour les étudiants ayant
|
||||||
|
@ -1227,11 +1227,12 @@ def formsemestre_validate_previous_ue(formsemestre: FormSemestre, etud: Identite
|
||||||
l'attribution des ECTS si le code jury est validant (ADM).
|
l'attribution des ECTS si le code jury est validant (ADM).
|
||||||
</p>
|
</p>
|
||||||
<p>On ne peut valider ici que les UEs du cursus <b>{formation.titre}</b></p>
|
<p>On ne peut valider ici que les UEs du cursus <b>{formation.titre}</b></p>
|
||||||
|
</div>
|
||||||
|
|
||||||
{_get_etud_ue_cap_html(etud, formsemestre)}
|
{_get_etud_ue_cap_html(etud, formsemestre)}
|
||||||
|
|
||||||
<div class="sco_box">
|
<div class="scobox">
|
||||||
<div class="sco_box_title">
|
<div class="scobox-title">
|
||||||
Enregistrer une UE antérieure
|
Enregistrer une UE antérieure
|
||||||
</div>
|
</div>
|
||||||
{tf[1]}
|
{tf[1]}
|
||||||
|
|
|
@ -0,0 +1,153 @@
|
||||||
|
"""
|
||||||
|
Génération d'un calendrier
|
||||||
|
(Classe abstraite à implémenter dans les classes filles)
|
||||||
|
"""
|
||||||
|
|
||||||
|
import datetime
|
||||||
|
from flask import render_template
|
||||||
|
|
||||||
|
import app.scodoc.sco_utils as scu
|
||||||
|
from app import g
|
||||||
|
|
||||||
|
|
||||||
|
class Jour:
|
||||||
|
"""
|
||||||
|
Représente un jour dans le calendrier
|
||||||
|
Permet d'obtenir les informations sur le jour
|
||||||
|
et générer une représentation html
|
||||||
|
"""
|
||||||
|
|
||||||
|
def __init__(self, date: datetime.date):
|
||||||
|
self.date = date
|
||||||
|
self.class_list: list[str] = []
|
||||||
|
|
||||||
|
if self.is_non_work():
|
||||||
|
self.class_list.append("non-travail")
|
||||||
|
if self.is_current_week():
|
||||||
|
self.class_list.append("sem-courante")
|
||||||
|
|
||||||
|
def get_nom(self, short=True):
|
||||||
|
"""
|
||||||
|
Renvoie le nom du jour
|
||||||
|
"M19" ou "Mer 19"
|
||||||
|
|
||||||
|
par défaut en version courte
|
||||||
|
"""
|
||||||
|
str_jour: str = scu.DAY_NAMES[self.date.weekday()].capitalize()
|
||||||
|
return (
|
||||||
|
f"{str_jour[0] if short or self.is_non_work() else str_jour[:3]+' '}"
|
||||||
|
+ f"{self.date.day}"
|
||||||
|
)
|
||||||
|
|
||||||
|
def is_non_work(self):
|
||||||
|
"""
|
||||||
|
Renvoie True si le jour est un jour non travaillé
|
||||||
|
(en fonction de la préférence du département)
|
||||||
|
"""
|
||||||
|
return self.date.weekday() in scu.NonWorkDays.get_all_non_work_days(
|
||||||
|
dept_id=g.scodoc_dept_id
|
||||||
|
)
|
||||||
|
|
||||||
|
def is_current_week(self):
|
||||||
|
"""
|
||||||
|
Renvoie True si le jour est dans la semaine courante
|
||||||
|
"""
|
||||||
|
return self.date.isocalendar()[0:2] == datetime.date.today().isocalendar()[0:2]
|
||||||
|
|
||||||
|
def get_date(self) -> str:
|
||||||
|
"""
|
||||||
|
Renvoie la date du jour au format "dd/mm/yyyy"
|
||||||
|
"""
|
||||||
|
return self.date.strftime(scu.DATE_FMT)
|
||||||
|
|
||||||
|
def get_html(self):
|
||||||
|
"""
|
||||||
|
Renvoie le code html du jour
|
||||||
|
à surcharger dans les classes filles
|
||||||
|
|
||||||
|
l'html final ressemblera à :
|
||||||
|
|
||||||
|
<div class="jour {{jour.get_class()}}">
|
||||||
|
<span class="nom">{{jour.get_nom()}}</span>
|
||||||
|
<div class="contenu">
|
||||||
|
{{jour.get_html() | safe}}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
"""
|
||||||
|
raise NotImplementedError("Méthode à implémenter dans les classes filles")
|
||||||
|
|
||||||
|
def get_class(self):
|
||||||
|
"""
|
||||||
|
Renvoie la classe css du jour
|
||||||
|
|
||||||
|
utilise self.class_list
|
||||||
|
-> fait un join de la liste
|
||||||
|
|
||||||
|
"""
|
||||||
|
return " ".join(self.class_list)
|
||||||
|
|
||||||
|
|
||||||
|
class Calendrier:
|
||||||
|
"""
|
||||||
|
Représente un calendrier
|
||||||
|
Permet d'obtenir les informations sur les jours
|
||||||
|
et générer une représentation html
|
||||||
|
"""
|
||||||
|
|
||||||
|
def __init__(self, date_debut: datetime.date, date_fin: datetime.date):
|
||||||
|
self.date_debut = date_debut
|
||||||
|
self.date_fin = date_fin
|
||||||
|
self.jours: dict[str, list[Jour]] = {}
|
||||||
|
|
||||||
|
def _get_dates_between(self) -> list[datetime.date]:
|
||||||
|
"""
|
||||||
|
get_dates_between Renvoie la liste des dates entre date_debut et date_fin
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
list[datetime.date]: liste des dates entre date_debut et date_fin
|
||||||
|
"""
|
||||||
|
resultat = []
|
||||||
|
date_actuelle: datetime.date = self.date_debut
|
||||||
|
while date_actuelle <= self.date_fin:
|
||||||
|
if isinstance(date_actuelle, datetime.datetime):
|
||||||
|
resultat.append(date_actuelle.date())
|
||||||
|
elif isinstance(date_actuelle, datetime.date):
|
||||||
|
resultat.append(date_actuelle)
|
||||||
|
date_actuelle += datetime.timedelta(days=1)
|
||||||
|
return resultat
|
||||||
|
|
||||||
|
def organize_by_month(self):
|
||||||
|
"""
|
||||||
|
Organise les jours par mois
|
||||||
|
Instancie un objet Jour pour chaque jour
|
||||||
|
|
||||||
|
met à jour self.jours
|
||||||
|
"""
|
||||||
|
organized = {}
|
||||||
|
for date in self._get_dates_between():
|
||||||
|
# Récupérer le mois en français
|
||||||
|
month = scu.MONTH_NAMES_ABBREV[date.month - 1]
|
||||||
|
# Ajouter le jour à la liste correspondante au mois
|
||||||
|
if month not in organized:
|
||||||
|
organized[month] = []
|
||||||
|
|
||||||
|
jour: Jour = self.instanciate_jour(date)
|
||||||
|
|
||||||
|
organized[month].append(jour)
|
||||||
|
|
||||||
|
self.jours = organized
|
||||||
|
|
||||||
|
def instanciate_jour(self, date: datetime.date) -> Jour:
|
||||||
|
"""
|
||||||
|
Instancie un objet Jour pour chaque jour
|
||||||
|
A surcharger dans les classes filles si besoin
|
||||||
|
"""
|
||||||
|
raise NotImplementedError("Méthode à implémenter dans les classes filles")
|
||||||
|
|
||||||
|
def get_html(self):
|
||||||
|
"""
|
||||||
|
get_html Renvoie le code html du calendrier
|
||||||
|
"""
|
||||||
|
self.organize_by_month()
|
||||||
|
return render_template("calendrier.j2", calendrier=self.jours)
|
|
@ -453,6 +453,10 @@ class DisplayedGroupsInfos:
|
||||||
for i in to_remove:
|
for i in to_remove:
|
||||||
del T[i]
|
del T[i]
|
||||||
|
|
||||||
|
def get_etudids(self) -> set[int]:
|
||||||
|
"Les etudids des groupes choisis"
|
||||||
|
return {member["etudid"] for member in self.members}
|
||||||
|
|
||||||
def get_form_elem(self):
|
def get_form_elem(self):
|
||||||
"""html hidden input with groups"""
|
"""html hidden input with groups"""
|
||||||
H = []
|
H = []
|
||||||
|
|
|
@ -513,7 +513,7 @@ def _build_page(
|
||||||
|
|
||||||
<div>{scu.EMO_WARNING}
|
<div>{scu.EMO_WARNING}
|
||||||
<em>Seuls les semestres dont la date de fin est proche de la date de début
|
<em>Seuls les semestres dont la date de fin est proche de la date de début
|
||||||
de ce semestre ({formsemestre.date_debut.strftime("%d/%m/%Y")}) sont pris en
|
de ce semestre ({formsemestre.date_debut.strftime(scu.DATE_FMT)}) sont pris en
|
||||||
compte.</em>
|
compte.</em>
|
||||||
</div>
|
</div>
|
||||||
{etuds_select_boxes(auth_etuds_by_sem, inscrits_ailleurs)}
|
{etuds_select_boxes(auth_etuds_by_sem, inscrits_ailleurs)}
|
||||||
|
@ -704,7 +704,7 @@ def etuds_select_boxes(
|
||||||
elink += (
|
elink += (
|
||||||
'<span class="finalisationinscription">'
|
'<span class="finalisationinscription">'
|
||||||
+ " : inscription finalisée le "
|
+ " : inscription finalisée le "
|
||||||
+ etud["datefinalisationinscription"].strftime("%d/%m/%Y")
|
+ etud["datefinalisationinscription"].strftime(scu.DATE_FMT)
|
||||||
+ "</span>"
|
+ "</span>"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -705,7 +705,8 @@ def _add_eval_columns(
|
||||||
nb_att = 0
|
nb_att = 0
|
||||||
sum_notes = 0
|
sum_notes = 0
|
||||||
notes = [] # liste des notes numeriques, pour calcul histogramme uniquement
|
notes = [] # liste des notes numeriques, pour calcul histogramme uniquement
|
||||||
inscrits = evaluation.moduleimpl.formsemestre.etudids_actifs # set d'etudids
|
# actifs == inscrit au semestre, non DEM ni DEF:
|
||||||
|
_, etudids_actifs = evaluation.moduleimpl.formsemestre.etudids_actifs()
|
||||||
notes_db = sco_evaluation_db.do_evaluation_get_all_notes(evaluation.id)
|
notes_db = sco_evaluation_db.do_evaluation_get_all_notes(evaluation.id)
|
||||||
|
|
||||||
if evaluation.date_debut:
|
if evaluation.date_debut:
|
||||||
|
@ -734,7 +735,7 @@ def _add_eval_columns(
|
||||||
nb_att += 1
|
nb_att += 1
|
||||||
# calcul moyenne SANS LES ABSENTS ni les DEMISSIONNAIRES
|
# calcul moyenne SANS LES ABSENTS ni les DEMISSIONNAIRES
|
||||||
if (
|
if (
|
||||||
(etudid in inscrits)
|
(etudid in etudids_actifs)
|
||||||
and val is not None
|
and val is not None
|
||||||
and val != scu.NOTES_NEUTRALISE
|
and val != scu.NOTES_NEUTRALISE
|
||||||
and val != scu.NOTES_ATTENTE
|
and val != scu.NOTES_ATTENTE
|
||||||
|
@ -758,7 +759,7 @@ def _add_eval_columns(
|
||||||
comment,
|
comment,
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
if (etudid in inscrits) and evaluation.publish_incomplete:
|
if (etudid in etudids_actifs) and evaluation.publish_incomplete:
|
||||||
# Note manquante mais prise en compte immédiate: affiche ATT
|
# Note manquante mais prise en compte immédiate: affiche ATT
|
||||||
val = scu.NOTES_ATTENTE
|
val = scu.NOTES_ATTENTE
|
||||||
val_fmt = "ATT"
|
val_fmt = "ATT"
|
||||||
|
@ -826,7 +827,7 @@ def _add_eval_columns(
|
||||||
nb_notes,
|
nb_notes,
|
||||||
evaluation.description,
|
evaluation.description,
|
||||||
(
|
(
|
||||||
evaluation.date_debut.strftime("%d/%m/%Y")
|
evaluation.date_debut.strftime(scu.DATE_FMT)
|
||||||
if evaluation.date_debut
|
if evaluation.date_debut
|
||||||
else ""
|
else ""
|
||||||
),
|
),
|
||||||
|
@ -875,8 +876,7 @@ def _add_moymod_column(
|
||||||
col_id = "moymod"
|
col_id = "moymod"
|
||||||
formsemestre = FormSemestre.get_formsemestre(formsemestre_id)
|
formsemestre = FormSemestre.get_formsemestre(formsemestre_id)
|
||||||
nt: NotesTableCompat = res_sem.load_formsemestre_results(formsemestre)
|
nt: NotesTableCompat = res_sem.load_formsemestre_results(formsemestre)
|
||||||
inscrits = formsemestre.etudids_actifs
|
_, etudids_actifs = formsemestre.etudids_actifs()
|
||||||
|
|
||||||
nb_notes = 0
|
nb_notes = 0
|
||||||
sum_notes = 0
|
sum_notes = 0
|
||||||
notes = [] # liste des notes numeriques, pour calcul histogramme uniquement
|
notes = [] # liste des notes numeriques, pour calcul histogramme uniquement
|
||||||
|
@ -885,7 +885,7 @@ def _add_moymod_column(
|
||||||
val = nt.get_etud_mod_moy(moduleimpl_id, etudid) # note sur 20, ou 'NA','NI'
|
val = nt.get_etud_mod_moy(moduleimpl_id, etudid) # note sur 20, ou 'NA','NI'
|
||||||
row[col_id] = scu.fmt_note(val, keep_numeric=keep_numeric)
|
row[col_id] = scu.fmt_note(val, keep_numeric=keep_numeric)
|
||||||
row["_" + col_id + "_td_attrs"] = ' class="moyenne" '
|
row["_" + col_id + "_td_attrs"] = ' class="moyenne" '
|
||||||
if etudid in inscrits and not isinstance(val, str):
|
if etudid in etudids_actifs and not isinstance(val, str):
|
||||||
notes.append(val)
|
notes.append(val)
|
||||||
if not np.isnan(val):
|
if not np.isnan(val):
|
||||||
nb_notes = nb_notes + 1
|
nb_notes = nb_notes + 1
|
||||||
|
@ -928,7 +928,7 @@ def _add_apc_columns(
|
||||||
# on va y ajouter une clé par UE du semestre
|
# on va y ajouter une clé par UE du semestre
|
||||||
nt: ResultatsSemestreBUT = res_sem.load_formsemestre_results(modimpl.formsemestre)
|
nt: ResultatsSemestreBUT = res_sem.load_formsemestre_results(modimpl.formsemestre)
|
||||||
modimpl_results: ModuleImplResults = nt.modimpls_results[modimpl.id]
|
modimpl_results: ModuleImplResults = nt.modimpls_results[modimpl.id]
|
||||||
inscrits = modimpl.formsemestre.etudids_actifs
|
_, etudids_actifs = modimpl.formsemestre.etudids_actifs()
|
||||||
# les UE dans lesquelles ce module a un coef non nul:
|
# les UE dans lesquelles ce module a un coef non nul:
|
||||||
ues_with_coef = nt.modimpl_coefs_df[modimpl.id][
|
ues_with_coef = nt.modimpl_coefs_df[modimpl.id][
|
||||||
nt.modimpl_coefs_df[modimpl.id] > 0
|
nt.modimpl_coefs_df[modimpl.id] > 0
|
||||||
|
@ -946,7 +946,7 @@ def _add_apc_columns(
|
||||||
if (
|
if (
|
||||||
isinstance(moy_ue, float)
|
isinstance(moy_ue, float)
|
||||||
and not np.isnan(moy_ue)
|
and not np.isnan(moy_ue)
|
||||||
and row["etudid"] in inscrits
|
and row["etudid"] in etudids_actifs
|
||||||
):
|
):
|
||||||
sum_by_ue[ue.id] += moy_ue
|
sum_by_ue[ue.id] += moy_ue
|
||||||
nb_notes_by_ue[ue.id] += 1
|
nb_notes_by_ue[ue.id] += 1
|
||||||
|
|
|
@ -34,22 +34,28 @@ from operator import itemgetter
|
||||||
from flask import url_for, g, request
|
from flask import url_for, g, request
|
||||||
|
|
||||||
import app
|
import app
|
||||||
import app.scodoc.sco_utils as scu
|
from app.scodoc import (
|
||||||
from app.scodoc import html_sco_header
|
html_sco_header,
|
||||||
from app.scodoc import sco_formsemestre
|
sco_formsemestre,
|
||||||
from app.scodoc import sco_preferences
|
sco_groups_view,
|
||||||
from app.scodoc import sco_report
|
sco_preferences,
|
||||||
from app.scodoc import sco_etud
|
sco_report,
|
||||||
import sco_version
|
sco_etud,
|
||||||
|
)
|
||||||
|
from app.models import FormSemestre
|
||||||
from app.scodoc.gen_tables import GenTable
|
from app.scodoc.gen_tables import GenTable
|
||||||
|
import app.scodoc.sco_utils as scu
|
||||||
|
import sco_version
|
||||||
|
|
||||||
|
|
||||||
def formsemestre_table_etuds_lycees(
|
def formsemestre_table_etuds_lycees(
|
||||||
formsemestre_id, group_lycees=True, only_primo=False
|
formsemestre: FormSemestre, groups_infos, group_lycees=True, only_primo=False
|
||||||
):
|
):
|
||||||
"""Récupère liste d'etudiants avec etat et decision."""
|
"""Récupère liste d'etudiants avec etat et decision."""
|
||||||
sem = sco_formsemestre.get_formsemestre(formsemestre_id)
|
sem = sco_formsemestre.get_formsemestre(formsemestre.id)
|
||||||
etuds = sco_report.tsp_etud_list(formsemestre_id, only_primo=only_primo)[0]
|
etuds = sco_report.tsp_etud_list(
|
||||||
|
formsemestre.id, groups_infos=groups_infos, only_primo=only_primo
|
||||||
|
)[0]
|
||||||
if only_primo:
|
if only_primo:
|
||||||
primostr = "primo-entrants du "
|
primostr = "primo-entrants du "
|
||||||
else:
|
else:
|
||||||
|
@ -59,7 +65,7 @@ def formsemestre_table_etuds_lycees(
|
||||||
etuds,
|
etuds,
|
||||||
group_lycees,
|
group_lycees,
|
||||||
title,
|
title,
|
||||||
sco_preferences.SemPreferences(formsemestre_id),
|
sco_preferences.SemPreferences(formsemestre.id),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@ -180,13 +186,20 @@ def _table_etuds_lycees(etuds, group_lycees, title, preferences, no_links=False)
|
||||||
|
|
||||||
def formsemestre_etuds_lycees(
|
def formsemestre_etuds_lycees(
|
||||||
formsemestre_id,
|
formsemestre_id,
|
||||||
|
group_ids: list[int] = None, # si indiqué, ne prend que ces groupes
|
||||||
fmt="html",
|
fmt="html",
|
||||||
only_primo=False,
|
only_primo=False,
|
||||||
no_grouping=False,
|
no_grouping=False,
|
||||||
):
|
):
|
||||||
"""Table des lycées d'origine"""
|
"""Table des lycées d'origine"""
|
||||||
|
formsemestre = FormSemestre.get_formsemestre(formsemestre_id)
|
||||||
|
groups_infos = sco_groups_view.DisplayedGroupsInfos(
|
||||||
|
group_ids,
|
||||||
|
formsemestre_id=formsemestre.id,
|
||||||
|
select_all_when_unspecified=True,
|
||||||
|
)
|
||||||
tab, etuds_by_lycee = formsemestre_table_etuds_lycees(
|
tab, etuds_by_lycee = formsemestre_table_etuds_lycees(
|
||||||
formsemestre_id, only_primo=only_primo, group_lycees=not no_grouping
|
formsemestre, groups_infos, only_primo=only_primo, group_lycees=not no_grouping
|
||||||
)
|
)
|
||||||
tab.base_url = "%s?formsemestre_id=%s" % (request.base_url, formsemestre_id)
|
tab.base_url = "%s?formsemestre_id=%s" % (request.base_url, formsemestre_id)
|
||||||
if only_primo:
|
if only_primo:
|
||||||
|
@ -196,13 +209,19 @@ def formsemestre_etuds_lycees(
|
||||||
t = tab.make_page(fmt=fmt, with_html_headers=False)
|
t = tab.make_page(fmt=fmt, with_html_headers=False)
|
||||||
if fmt != "html":
|
if fmt != "html":
|
||||||
return t
|
return t
|
||||||
F = [sco_report.tsp_form_primo_group(only_primo, no_grouping, formsemestre_id, fmt)]
|
F = [
|
||||||
|
sco_report.tsp_form_primo_group(
|
||||||
|
only_primo, no_grouping, formsemestre_id, fmt, groups_infos=groups_infos
|
||||||
|
)
|
||||||
|
]
|
||||||
H = [
|
H = [
|
||||||
html_sco_header.sco_header(
|
html_sco_header.sco_header(
|
||||||
page_title=tab.page_title,
|
page_title=tab.page_title,
|
||||||
init_google_maps=True,
|
init_google_maps=True,
|
||||||
init_qtip=True,
|
init_qtip=True,
|
||||||
javascripts=["js/etud_info.js", "js/map_lycees.js"],
|
cssstyles=sco_groups_view.CSSSTYLES,
|
||||||
|
javascripts=sco_groups_view.JAVASCRIPTS
|
||||||
|
+ ["js/etud_info.js", "js/map_lycees.js"],
|
||||||
),
|
),
|
||||||
"""<h2 class="formsemestre">Lycées d'origine des étudiants</h2>""",
|
"""<h2 class="formsemestre">Lycées d'origine des étudiants</h2>""",
|
||||||
"\n".join(F),
|
"\n".join(F),
|
||||||
|
|
|
@ -36,37 +36,45 @@ Elle n'est pas utilisée pour les parcours, ni pour rien d'autre
|
||||||
import collections
|
import collections
|
||||||
import app.scodoc.notesdb as ndb
|
import app.scodoc.notesdb as ndb
|
||||||
from app import log
|
from app import log
|
||||||
|
from app.models import FormSemestre
|
||||||
|
|
||||||
|
|
||||||
def list_formsemestres_modalites(sems):
|
def list_formsemestres_modalites(formsemestres: list[FormSemestre]) -> list[dict]:
|
||||||
"""Liste ordonnée des modalités présentes dans ces formsemestres"""
|
"""Liste ordonnée des modalités présentes dans ces formsemestres"""
|
||||||
modalites = {}
|
modalites = {}
|
||||||
for sem in sems:
|
for formsemestre in formsemestres:
|
||||||
if sem["modalite"] not in modalites:
|
if formsemestre.modalite not in modalites:
|
||||||
m = do_modalite_list(args={"modalite": sem["modalite"]})[0]
|
m = do_modalite_list(args={"modalite": formsemestre.modalite})[0]
|
||||||
modalites[m["modalite"]] = m
|
modalites[m["modalite"]] = m
|
||||||
modalites = list(modalites.values())
|
modalites = list(modalites.values())
|
||||||
modalites.sort(key=lambda x: x["numero"])
|
modalites.sort(key=lambda x: x["numero"])
|
||||||
return modalites
|
return modalites
|
||||||
|
|
||||||
|
|
||||||
def group_sems_by_modalite(sems):
|
def group_formsemestres_by_modalite(
|
||||||
"""Given the list of fromsemestre, group them by modalite,
|
formsemestres: list[FormSemestre],
|
||||||
|
) -> dict[str, list[FormSemestre]]:
|
||||||
|
"""Given the list of formsemestre, group them by modalite,
|
||||||
sorted in each one by semestre id and date
|
sorted in each one by semestre id and date
|
||||||
"""
|
"""
|
||||||
sems_by_mod = collections.defaultdict(list)
|
sems_by_mod = collections.defaultdict(list)
|
||||||
modalites = list_formsemestres_modalites(sems)
|
modalites = list_formsemestres_modalites(formsemestres)
|
||||||
for modalite in modalites:
|
sems_by_mod = {
|
||||||
for sem in sems:
|
modalite["modalite"]: [
|
||||||
if sem["semestre_id"] < 0: # formations en un semestre
|
formsemestre
|
||||||
sem["sortkey"] = (-100 * sem["semestre_id"], sem["dateord"])
|
for formsemestre in formsemestres
|
||||||
else:
|
if formsemestre.modalite == modalite["modalite"]
|
||||||
sem["sortkey"] = (sem["semestre_id"], sem["dateord"])
|
]
|
||||||
if sem["modalite"] == modalite["modalite"]:
|
for modalite in modalites
|
||||||
sems_by_mod[modalite["modalite"]].append(sem)
|
}
|
||||||
# tri dans chaque modalité par indice de semestre et date debut
|
# tri dans chaque modalité par indice de semestre et date debut
|
||||||
for modalite in modalites:
|
for modalite in modalites:
|
||||||
sems_by_mod[modalite["modalite"]].sort(key=lambda x: x["sortkey"])
|
sems_by_mod[modalite["modalite"]].sort(
|
||||||
|
key=lambda x: (
|
||||||
|
x.semestre_id if x.semestre_id > 0 else -1000 * x.semestre_id,
|
||||||
|
x.date_debut,
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
return sems_by_mod, modalites
|
return sems_by_mod, modalites
|
||||||
|
|
||||||
|
|
|
@ -50,8 +50,6 @@ from app.scodoc import html_sco_header
|
||||||
from app.scodoc import htmlutils
|
from app.scodoc import htmlutils
|
||||||
from app.scodoc import sco_cache
|
from app.scodoc import sco_cache
|
||||||
from app.scodoc import codes_cursus
|
from app.scodoc import codes_cursus
|
||||||
from app.scodoc import sco_edit_module
|
|
||||||
from app.scodoc import sco_edit_ue
|
|
||||||
from app.scodoc import sco_etud
|
from app.scodoc import sco_etud
|
||||||
from app.scodoc import sco_formsemestre_inscriptions
|
from app.scodoc import sco_formsemestre_inscriptions
|
||||||
from app.scodoc import sco_groups
|
from app.scodoc import sco_groups
|
||||||
|
@ -431,7 +429,7 @@ def moduleimpl_inscriptions_stats(formsemestre_id):
|
||||||
)
|
)
|
||||||
if info["ue_status"]["event_date"]:
|
if info["ue_status"]["event_date"]:
|
||||||
H.append(
|
H.append(
|
||||||
f"""(cap. le {info["ue_status"]["event_date"].strftime("%d/%m/%Y")})"""
|
f"""(cap. le {info["ue_status"]["event_date"].strftime(scu.DATE_FMT)})"""
|
||||||
)
|
)
|
||||||
if is_apc:
|
if is_apc:
|
||||||
is_inscrit_ue = (etud.id, ue.id) not in res.dispense_ues
|
is_inscrit_ue = (etud.id, ue.id) not in res.dispense_ues
|
||||||
|
@ -584,7 +582,7 @@ def _list_but_ue_inscriptions(res: NotesTableCompat, read_only: bool = True) ->
|
||||||
validation = validations_ue[-1] if validations_ue else None
|
validation = validations_ue[-1] if validations_ue else None
|
||||||
expl_validation = (
|
expl_validation = (
|
||||||
f"""Validée ({validation.code}) le {
|
f"""Validée ({validation.code}) le {
|
||||||
validation.event_date.strftime("%d/%m/%Y")}"""
|
validation.event_date.strftime(scu.DATE_FMT)}"""
|
||||||
if validation
|
if validation
|
||||||
else ""
|
else ""
|
||||||
)
|
)
|
||||||
|
|
|
@ -25,10 +25,9 @@
|
||||||
#
|
#
|
||||||
##############################################################################
|
##############################################################################
|
||||||
|
|
||||||
"""Tableau de bord module
|
"""Tableau de bord module"""
|
||||||
"""
|
|
||||||
import math
|
import math
|
||||||
import time
|
|
||||||
import datetime
|
import datetime
|
||||||
|
|
||||||
from flask import g, url_for
|
from flask import g, url_for
|
||||||
|
@ -48,13 +47,10 @@ from app.scodoc.sco_permissions import Permission
|
||||||
|
|
||||||
from app.scodoc import html_sco_header
|
from app.scodoc import html_sco_header
|
||||||
from app.scodoc import htmlutils
|
from app.scodoc import htmlutils
|
||||||
from app.scodoc import sco_cal
|
|
||||||
from app.scodoc import sco_compute_moy
|
from app.scodoc import sco_compute_moy
|
||||||
from app.scodoc import sco_evaluations
|
from app.scodoc import sco_evaluations
|
||||||
from app.scodoc import sco_formsemestre_status
|
|
||||||
from app.scodoc import sco_groups
|
from app.scodoc import sco_groups
|
||||||
from app.scodoc import sco_moduleimpl
|
from app.scodoc import sco_moduleimpl
|
||||||
from app.scodoc import sco_permissions_check
|
|
||||||
from app.tables import list_etuds
|
from app.tables import list_etuds
|
||||||
|
|
||||||
|
|
||||||
|
@ -262,7 +258,7 @@ def moduleimpl_status(moduleimpl_id=None, partition_id=None):
|
||||||
# 2ieme ligne: Semestre, Coef
|
# 2ieme ligne: Semestre, Coef
|
||||||
H.append("""<tr><td class="fichetitre2">""")
|
H.append("""<tr><td class="fichetitre2">""")
|
||||||
if formsemestre.semestre_id >= 0:
|
if formsemestre.semestre_id >= 0:
|
||||||
H.append("""Semestre: </td><td>%s""" % formsemestre.semestre_id)
|
H.append(f"""Semestre: </td><td>{formsemestre.semestre_id}""")
|
||||||
else:
|
else:
|
||||||
H.append("""</td><td>""")
|
H.append("""</td><td>""")
|
||||||
if sem_locked:
|
if sem_locked:
|
||||||
|
@ -290,7 +286,8 @@ def moduleimpl_status(moduleimpl_id=None, partition_id=None):
|
||||||
)
|
)
|
||||||
if current_user.has_permission(Permission.EtudInscrit):
|
if current_user.has_permission(Permission.EtudInscrit):
|
||||||
H.append(
|
H.append(
|
||||||
f"""<a class="stdlink" style="margin-left:2em;" href="moduleimpl_inscriptions_edit?moduleimpl_id={modimpl.id}">modifier</a>"""
|
f"""<a class="stdlink" style="margin-left:2em;"
|
||||||
|
href="moduleimpl_inscriptions_edit?moduleimpl_id={modimpl.id}">modifier</a>"""
|
||||||
)
|
)
|
||||||
H.append("</td></tr>")
|
H.append("</td></tr>")
|
||||||
# Ligne: règle de calcul
|
# Ligne: règle de calcul
|
||||||
|
@ -329,8 +326,6 @@ def moduleimpl_status(moduleimpl_id=None, partition_id=None):
|
||||||
>Saisie Absences journée</a></span>
|
>Saisie Absences journée</a></span>
|
||||||
"""
|
"""
|
||||||
)
|
)
|
||||||
year, week, day = datetime.date.today().isocalendar()
|
|
||||||
semaine: str = f"{year}-W{week}"
|
|
||||||
H.append(
|
H.append(
|
||||||
f"""
|
f"""
|
||||||
<span class="moduleimpl_abs_link"><a class="stdlink" href="{
|
<span class="moduleimpl_abs_link"><a class="stdlink" href="{
|
||||||
|
@ -338,11 +333,10 @@ def moduleimpl_status(moduleimpl_id=None, partition_id=None):
|
||||||
"assiduites.signal_assiduites_diff",
|
"assiduites.signal_assiduites_diff",
|
||||||
scodoc_dept=g.scodoc_dept,
|
scodoc_dept=g.scodoc_dept,
|
||||||
group_ids=group_id,
|
group_ids=group_id,
|
||||||
semaine=semaine,
|
|
||||||
formsemestre_id=formsemestre.id,
|
formsemestre_id=formsemestre.id,
|
||||||
moduleimpl_id="" if moduleimpl_id is None else moduleimpl_id
|
moduleimpl_id="" if moduleimpl_id is None else moduleimpl_id
|
||||||
)}"
|
)}"
|
||||||
>Saisie Absences hebdo</a></span>
|
>Saisie Absences Différée</a></span>
|
||||||
"""
|
"""
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -617,7 +611,7 @@ def _ligne_evaluation(
|
||||||
|
|
||||||
if evaluation.is_blocked():
|
if evaluation.is_blocked():
|
||||||
etat_txt = f"""évaluation bloquée {
|
etat_txt = f"""évaluation bloquée {
|
||||||
"jusqu'au " + evaluation.blocked_until.strftime("%d/%m/%Y")
|
"jusqu'au " + evaluation.blocked_until.strftime(scu.DATE_FMT)
|
||||||
if evaluation.blocked_until < Evaluation.BLOCKED_FOREVER
|
if evaluation.blocked_until < Evaluation.BLOCKED_FOREVER
|
||||||
else "" }
|
else "" }
|
||||||
"""
|
"""
|
||||||
|
@ -660,7 +654,8 @@ def _ligne_evaluation(
|
||||||
<th class="moduleimpl_evaluations">Notes</th>
|
<th class="moduleimpl_evaluations">Notes</th>
|
||||||
<th class="moduleimpl_evaluations">Abs</th>
|
<th class="moduleimpl_evaluations">Abs</th>
|
||||||
<th class="moduleimpl_evaluations">N</th>
|
<th class="moduleimpl_evaluations">N</th>
|
||||||
<th class="moduleimpl_evaluations moduleimpl_evaluation_moy" colspan="2"><span>{etat_txt}</span></th>
|
<th class="moduleimpl_evaluations moduleimpl_evaluation_moy"
|
||||||
|
colspan="2"><span>{etat_txt}</span></th>
|
||||||
</tr>
|
</tr>
|
||||||
<tr class="{tr_class} mievr_in">
|
<tr class="{tr_class} mievr_in">
|
||||||
<td class="mievr">"""
|
<td class="mievr">"""
|
||||||
|
|
|
@ -180,7 +180,7 @@ def fiche_etud(etudid=None):
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
info["etat_civil"] = ""
|
info["etat_civil"] = ""
|
||||||
info["ScoURL"] = scu.ScoURL()
|
info["ScoURL"] = url_for("scolar.index_html", scodoc_dept=g.scodoc_dept)
|
||||||
info["authuser"] = current_user
|
info["authuser"] = current_user
|
||||||
if restrict_etud_data:
|
if restrict_etud_data:
|
||||||
info["info_naissance"] = ""
|
info["info_naissance"] = ""
|
||||||
|
@ -730,7 +730,7 @@ def get_html_annotations_list(etud: Identite) -> list[str]:
|
||||||
author = User.query.filter_by(user_name=annot.author).first()
|
author = User.query.filter_by(user_name=annot.author).first()
|
||||||
html_annotations_list.append(
|
html_annotations_list.append(
|
||||||
f"""<tr><td><span class="annodate">Le {
|
f"""<tr><td><span class="annodate">Le {
|
||||||
annot.date.strftime("%d/%m/%Y") if annot.date else "?"}
|
annot.date.strftime(scu.DATE_FMT) if annot.date else "?"}
|
||||||
par {author.get_prenomnom() if author else "?"} :
|
par {author.get_prenomnom() if author else "?"} :
|
||||||
</span><span class="annoc">{annot.comment or ""}</span></td>{del_link}</tr>
|
</span><span class="annoc">{annot.comment or ""}</span></td>{del_link}</tr>
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -458,7 +458,12 @@ def pdf_basic_page(
|
||||||
if title:
|
if title:
|
||||||
head = Paragraph(SU(title), StyleSheet["Heading3"])
|
head = Paragraph(SU(title), StyleSheet["Heading3"])
|
||||||
objects = [head] + objects
|
objects = [head] + objects
|
||||||
document.build(objects)
|
|
||||||
|
try:
|
||||||
|
document.build(objects)
|
||||||
|
except (ValueError, KeyError, reportlab.platypus.doctemplate.LayoutError) as exc:
|
||||||
|
raise ScoPDFFormatError(str(exc)) from exc
|
||||||
|
|
||||||
data = report.getvalue()
|
data = report.getvalue()
|
||||||
return data
|
return data
|
||||||
|
|
||||||
|
|
|
@ -335,7 +335,7 @@ class PlacementRunner:
|
||||||
|
|
||||||
def _production_pdf(self):
|
def _production_pdf(self):
|
||||||
pdf_title = "<br>".join(self.desceval)
|
pdf_title = "<br>".join(self.desceval)
|
||||||
pdf_title += f"""\nDate : {self.evaluation.date_debut.strftime("%d/%m/%Y")
|
pdf_title += f"""\nDate : {self.evaluation.date_debut.strftime(scu.DATE_FMT)
|
||||||
if self.evaluation.date_debut else '-'
|
if self.evaluation.date_debut else '-'
|
||||||
} - Horaire : {self.evaluation.heure_debut()} à {self.evaluation.heure_fin()
|
} - Horaire : {self.evaluation.heure_debut()} à {self.evaluation.heure_fin()
|
||||||
}"""
|
}"""
|
||||||
|
@ -485,7 +485,7 @@ class PlacementRunner:
|
||||||
worksheet.append_blank_row()
|
worksheet.append_blank_row()
|
||||||
worksheet.append_single_cell_row(desceval, self.styles["titres"])
|
worksheet.append_single_cell_row(desceval, self.styles["titres"])
|
||||||
worksheet.append_single_cell_row(
|
worksheet.append_single_cell_row(
|
||||||
f"""Date : {self.evaluation.date_debut.strftime("%d/%m/%Y")
|
f"""Date : {self.evaluation.date_debut.strftime(scu.DATE_FMT)
|
||||||
if self.evaluation.date_debut else '-'
|
if self.evaluation.date_debut else '-'
|
||||||
} - Horaire : {self.evaluation.heure_debut()} à {self.evaluation.heure_fin()
|
} - Horaire : {self.evaluation.heure_debut()} à {self.evaluation.heure_fin()
|
||||||
}""",
|
}""",
|
||||||
|
|
|
@ -517,7 +517,7 @@ def _normalize_apo_fields(infolist):
|
||||||
)
|
)
|
||||||
infos["datefinalisationinscription_str"] = infos[
|
infos["datefinalisationinscription_str"] = infos[
|
||||||
"datefinalisationinscription"
|
"datefinalisationinscription"
|
||||||
].strftime("%d/%m/%Y")
|
].strftime(scu.DATE_FMT)
|
||||||
else:
|
else:
|
||||||
infos["datefinalisationinscription"] = None
|
infos["datefinalisationinscription"] = None
|
||||||
infos["datefinalisationinscription_str"] = ""
|
infos["datefinalisationinscription_str"] = ""
|
||||||
|
|
|
@ -600,17 +600,6 @@ class BasePreferences:
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
# Assiduité
|
# Assiduité
|
||||||
(
|
|
||||||
"assi_limit_annee",
|
|
||||||
{
|
|
||||||
"initvalue": 1,
|
|
||||||
"title": "Ne lister que l'assiduité de l'année",
|
|
||||||
"explanation": "Limite l'affichage des listes d'assiduité et de justificatifs à l'année en cours",
|
|
||||||
"input_type": "boolcheckbox",
|
|
||||||
"labels": ["non", "oui"],
|
|
||||||
"category": "assi",
|
|
||||||
},
|
|
||||||
),
|
|
||||||
(
|
(
|
||||||
"forcer_module",
|
"forcer_module",
|
||||||
{
|
{
|
||||||
|
@ -622,16 +611,17 @@ class BasePreferences:
|
||||||
"explanation": "toute saisie d'absence doit indiquer le module concerné",
|
"explanation": "toute saisie d'absence doit indiquer le module concerné",
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
# (
|
(
|
||||||
# "forcer_present",
|
"non_present",
|
||||||
# {
|
{
|
||||||
# "initvalue": 0,
|
"initvalue": 0,
|
||||||
# "title": "Forcer l'appel des présents",
|
"title": "Désactiver la saisie des présences",
|
||||||
# "input_type": "boolcheckbox",
|
"input_type": "boolcheckbox",
|
||||||
# "labels": ["non", "oui"],
|
"labels": ["non", "oui"],
|
||||||
# "category": "assi",
|
"category": "assi",
|
||||||
# },
|
"explanation": "Désactive la saisie et l'affichage des présences",
|
||||||
# ),
|
},
|
||||||
|
),
|
||||||
(
|
(
|
||||||
"periode_defaut",
|
"periode_defaut",
|
||||||
{
|
{
|
||||||
|
@ -655,18 +645,18 @@ class BasePreferences:
|
||||||
"category": "assi",
|
"category": "assi",
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
(
|
# (
|
||||||
"assi_etat_defaut",
|
# "assi_etat_defaut",
|
||||||
{
|
# {
|
||||||
"explanation": "⚠ non fonctionnel, travaux en cours !",
|
# "explanation": "⚠ non fonctionnel, travaux en cours !",
|
||||||
"initvalue": "aucun",
|
# "initvalue": "aucun",
|
||||||
"input_type": "menu",
|
# "input_type": "menu",
|
||||||
"labels": ["aucun", "present", "retard", "absent"],
|
# "labels": ["aucun", "present", "retard", "absent"],
|
||||||
"allowed_values": ["aucun", "present", "retard", "absent"],
|
# "allowed_values": ["aucun", "present", "retard", "absent"],
|
||||||
"title": "Définir l'état par défaut",
|
# "title": "Définir l'état par défaut",
|
||||||
"category": "assi",
|
# "category": "assi",
|
||||||
},
|
# },
|
||||||
),
|
# ),
|
||||||
(
|
(
|
||||||
"non_travail",
|
"non_travail",
|
||||||
{
|
{
|
||||||
|
@ -1601,18 +1591,6 @@ class BasePreferences:
|
||||||
"labels": ["non", "oui"],
|
"labels": ["non", "oui"],
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
(
|
|
||||||
"bul_display_publication",
|
|
||||||
{
|
|
||||||
"initvalue": 1,
|
|
||||||
"title": "Afficher icône indiquant si les bulletins sont publiés",
|
|
||||||
"explanation": "décocher si vous n'avez pas de passerelle ou portail étudiant publiant les bulletins",
|
|
||||||
"input_type": "boolcheckbox",
|
|
||||||
"labels": ["non", "oui"],
|
|
||||||
"category": "bul",
|
|
||||||
"only_global": False,
|
|
||||||
},
|
|
||||||
),
|
|
||||||
# champs des bulletins PDF:
|
# champs des bulletins PDF:
|
||||||
(
|
(
|
||||||
"bul_pdf_title",
|
"bul_pdf_title",
|
||||||
|
@ -2283,16 +2261,17 @@ class BasePreferences:
|
||||||
before_table="<details><summary>{title}</summary>",
|
before_table="<details><summary>{title}</summary>",
|
||||||
after_table="</details>",
|
after_table="</details>",
|
||||||
)
|
)
|
||||||
|
dest_url = url_for("scolar.index_html", scodoc_dept=g.scodoc_dept)
|
||||||
if tf[0] == 0:
|
if tf[0] == 0:
|
||||||
return "\n".join(H) + tf[1] + html_sco_header.sco_footer()
|
return "\n".join(H) + tf[1] + html_sco_header.sco_footer()
|
||||||
elif tf[0] == -1:
|
if tf[0] == -1:
|
||||||
return flask.redirect(scu.ScoURL()) # cancel
|
return flask.redirect(dest_url) # cancel
|
||||||
else:
|
#
|
||||||
for pref in self.prefs_definition:
|
for pref in self.prefs_definition:
|
||||||
self.prefs[None][pref[0]] = tf[2][pref[0]]
|
self.prefs[None][pref[0]] = tf[2][pref[0]]
|
||||||
self.save()
|
self.save()
|
||||||
flash("Préférences modifiées")
|
flash("Préférences modifiées")
|
||||||
return flask.redirect(scu.ScoURL())
|
return flask.redirect(dest_url)
|
||||||
|
|
||||||
def build_tf_form(self, categories: list[str] = None, formsemestre_id: int = None):
|
def build_tf_form(self, categories: list[str] = None, formsemestre_id: int = None):
|
||||||
"""Build list of elements for TrivialFormulator.
|
"""Build list of elements for TrivialFormulator.
|
||||||
|
@ -2456,10 +2435,12 @@ function set_global_pref(el, pref_name) {
|
||||||
before_table="<details><summary>{title}</summary>",
|
before_table="<details><summary>{title}</summary>",
|
||||||
after_table="</details>",
|
after_table="</details>",
|
||||||
)
|
)
|
||||||
dest_url = (
|
dest_url = url_for(
|
||||||
scu.NotesURL()
|
"notes.formsemestre_status",
|
||||||
+ "/formsemestre_status?formsemestre_id=%s" % self.formsemestre_id
|
scodoc_dept=g.scodoc_dept,
|
||||||
|
formsemestre_id=self.formsemestre_id,
|
||||||
)
|
)
|
||||||
|
|
||||||
if tf[0] == 0:
|
if tf[0] == 0:
|
||||||
return "\n".join(H) + tf[1] + html_sco_header.sco_footer()
|
return "\n".join(H) + tf[1] + html_sco_header.sco_footer()
|
||||||
elif tf[0] == -1:
|
elif tf[0] == -1:
|
||||||
|
@ -2505,7 +2486,9 @@ function set_global_pref(el, pref_name) {
|
||||||
request.base_url + "?formsemestre_id=" + str(self.formsemestre_id)
|
request.base_url + "?formsemestre_id=" + str(self.formsemestre_id)
|
||||||
)
|
)
|
||||||
elif destination == "global":
|
elif destination == "global":
|
||||||
return flask.redirect(scu.ScoURL() + "/edit_preferences")
|
return flask.redirect(
|
||||||
|
url_for("scolar.edit_preferences", scodoc_dept=g.scodoc_dept)
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
|
|
|
@ -327,7 +327,7 @@ def feuille_preparation_jury(formsemestre_id):
|
||||||
"Préparé par %s le %s sur %s pour %s"
|
"Préparé par %s le %s sur %s pour %s"
|
||||||
% (
|
% (
|
||||||
sco_version.SCONAME,
|
sco_version.SCONAME,
|
||||||
time.strftime("%d/%m/%Y"),
|
time.strftime(scu.DATE_FMT),
|
||||||
request.url_root,
|
request.url_root,
|
||||||
current_user,
|
current_user,
|
||||||
)
|
)
|
||||||
|
|
|
@ -50,7 +50,7 @@ from app.scodoc import sco_bulletins_pdf
|
||||||
from app.scodoc import sco_pv_dict
|
from app.scodoc import sco_pv_dict
|
||||||
from app.scodoc import sco_pdf
|
from app.scodoc import sco_pdf
|
||||||
from app.scodoc import sco_preferences
|
from app.scodoc import sco_preferences
|
||||||
from app.scodoc.sco_exceptions import ScoValueError
|
from app.scodoc.sco_exceptions import ScoPDFFormatError, ScoValueError
|
||||||
from app.scodoc.sco_cursus_dut import SituationEtudCursus
|
from app.scodoc.sco_cursus_dut import SituationEtudCursus
|
||||||
from app.scodoc.sco_pv_templates import CourrierIndividuelTemplate, jury_titres
|
from app.scodoc.sco_pv_templates import CourrierIndividuelTemplate, jury_titres
|
||||||
import sco_version
|
import sco_version
|
||||||
|
@ -132,7 +132,11 @@ def pdf_lettres_individuelles(
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
document.build(objects)
|
try:
|
||||||
|
document.build(objects)
|
||||||
|
except (ValueError, KeyError, reportlab.platypus.doctemplate.LayoutError) as exc:
|
||||||
|
raise ScoPDFFormatError(str(exc)) from exc
|
||||||
|
|
||||||
data = report.getvalue()
|
data = report.getvalue()
|
||||||
return data
|
return data
|
||||||
|
|
||||||
|
@ -241,13 +245,14 @@ def pdf_lettre_individuelle(sem, decision, etud: Identite, params, signature=Non
|
||||||
titre_jury_court = "s"
|
titre_jury_court = "s"
|
||||||
else:
|
else:
|
||||||
titre_jury_court = ""
|
titre_jury_court = ""
|
||||||
params[
|
params["autorisations_txt"] = (
|
||||||
"autorisations_txt"
|
"""Vous êtes autorisé%s à continuer dans le%s semestre%s : <b>%s</b>"""
|
||||||
] = """Vous êtes autorisé%s à continuer dans le%s semestre%s : <b>%s</b>""" % (
|
% (
|
||||||
etud.e,
|
etud.e,
|
||||||
titre_jury_court,
|
titre_jury_court,
|
||||||
titre_jury_court,
|
titre_jury_court,
|
||||||
decision["autorisations_descr"],
|
decision["autorisations_descr"],
|
||||||
|
)
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
params["autorisations_txt"] = ""
|
params["autorisations_txt"] = ""
|
||||||
|
|
|
@ -126,7 +126,11 @@ def pvjury_pdf(
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
document.build(objects)
|
try:
|
||||||
|
document.build(objects)
|
||||||
|
except (ValueError, KeyError, reportlab.platypus.doctemplate.LayoutError) as exc:
|
||||||
|
raise ScoPDFFormatError(str(exc)) from exc
|
||||||
|
|
||||||
data = report.getvalue()
|
data = report.getvalue()
|
||||||
return data
|
return data
|
||||||
|
|
||||||
|
|
|
@ -110,7 +110,7 @@ def formsemestre_recapcomplet(
|
||||||
force_publishing=force_publishing,
|
force_publishing=force_publishing,
|
||||||
)
|
)
|
||||||
|
|
||||||
table_html, table, freq_codes_annuels = _formsemestre_recapcomplet_to_html(
|
table_html, _, freq_codes_annuels = _formsemestre_recapcomplet_to_html(
|
||||||
formsemestre,
|
formsemestre,
|
||||||
filename=filename,
|
filename=filename,
|
||||||
mode_jury=mode_jury,
|
mode_jury=mode_jury,
|
||||||
|
@ -198,9 +198,9 @@ def formsemestre_recapcomplet(
|
||||||
scodoc_dept=g.scodoc_dept, formsemestre_id=formsemestre_id)
|
scodoc_dept=g.scodoc_dept, formsemestre_id=formsemestre_id)
|
||||||
}">Calcul automatique des décisions du jury</a>
|
}">Calcul automatique des décisions du jury</a>
|
||||||
</li>
|
</li>
|
||||||
<li><a class="stdlink" href="{url_for('notes.formsemestre_jury_but_erase',
|
<li><a class="stdlink" href="{url_for('notes.formsemestre_jury_erase',
|
||||||
scodoc_dept=g.scodoc_dept, formsemestre_id=formsemestre_id, only_one_sem=1)
|
scodoc_dept=g.scodoc_dept, formsemestre_id=formsemestre_id, only_one_sem=1)
|
||||||
}">Effacer <em>toutes</em> les décisions de jury BUT issues de ce semestre</a>
|
}">Effacer <em>toutes</em> les décisions de jury issues de ce semestre</a>
|
||||||
</li>
|
</li>
|
||||||
"""
|
"""
|
||||||
)
|
)
|
||||||
|
|
|
@ -40,6 +40,7 @@ from operator import itemgetter
|
||||||
from flask import url_for, g, request
|
from flask import url_for, g, request
|
||||||
import pydot
|
import pydot
|
||||||
|
|
||||||
|
from app import log
|
||||||
from app.but import jury_but
|
from app.but import jury_but
|
||||||
from app.comp import res_sem
|
from app.comp import res_sem
|
||||||
from app.comp.res_compat import NotesTableCompat
|
from app.comp.res_compat import NotesTableCompat
|
||||||
|
@ -47,18 +48,21 @@ from app.models import FormSemestre, ScolarAutorisationInscription
|
||||||
from app.models import FormationModalite
|
from app.models import FormationModalite
|
||||||
from app.models.etudiants import Identite
|
from app.models.etudiants import Identite
|
||||||
|
|
||||||
import app.scodoc.sco_utils as scu
|
from app.scodoc import (
|
||||||
from app.scodoc import notesdb as ndb
|
codes_cursus,
|
||||||
from app.scodoc import html_sco_header
|
html_sco_header,
|
||||||
from app.scodoc import codes_cursus
|
sco_etud,
|
||||||
from app.scodoc import sco_etud
|
sco_formsemestre,
|
||||||
from app.scodoc import sco_formsemestre
|
sco_formsemestre_inscriptions,
|
||||||
from app.scodoc import sco_formsemestre_inscriptions
|
sco_groups_view,
|
||||||
from app.scodoc import sco_preferences
|
sco_preferences,
|
||||||
import sco_version
|
)
|
||||||
from app.scodoc.gen_tables import GenTable
|
from app.scodoc.gen_tables import GenTable
|
||||||
from app import log
|
|
||||||
from app.scodoc.codes_cursus import code_semestre_validant
|
from app.scodoc.codes_cursus import code_semestre_validant
|
||||||
|
from app.scodoc.sco_exceptions import ScoValueError
|
||||||
|
from app.scodoc import notesdb as ndb
|
||||||
|
import app.scodoc.sco_utils as scu
|
||||||
|
import sco_version
|
||||||
|
|
||||||
MAX_ETUD_IN_DESCR = 20
|
MAX_ETUD_IN_DESCR = 20
|
||||||
|
|
||||||
|
@ -68,21 +72,25 @@ LEGENDES_CODES_BUT = {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
def formsemestre_etuds_stats(sem: dict, only_primo=False):
|
def formsemestre_etuds_stats(
|
||||||
|
formsemestre: FormSemestre,
|
||||||
|
only_primo=False,
|
||||||
|
groups_infos: sco_groups_view.DisplayedGroupsInfos | None = None,
|
||||||
|
):
|
||||||
"""Récupère liste d'etudiants avec etat et decision."""
|
"""Récupère liste d'etudiants avec etat et decision."""
|
||||||
formsemestre: FormSemestre = FormSemestre.query.get_or_404(sem["formsemestre_id"])
|
|
||||||
nt: NotesTableCompat = res_sem.load_formsemestre_results(formsemestre)
|
nt: NotesTableCompat = res_sem.load_formsemestre_results(formsemestre)
|
||||||
|
etudids = groups_infos.get_etudids() if groups_infos else set()
|
||||||
T = nt.get_table_moyennes_triees()
|
rows = nt.get_table_moyennes_triees()
|
||||||
|
|
||||||
# Décisions de jury BUT pour les semestres pairs seulement
|
# Décisions de jury BUT pour les semestres pairs seulement
|
||||||
jury_but_mode = (
|
jury_but_mode = (
|
||||||
formsemestre.formation.is_apc() and formsemestre.semestre_id % 2 == 0
|
formsemestre.formation.is_apc() and formsemestre.semestre_id % 2 == 0
|
||||||
)
|
)
|
||||||
# Construit liste d'étudiants du semestre avec leur decision
|
# Construit liste d'étudiants du semestre avec leur decision
|
||||||
etuds = []
|
etuds = []
|
||||||
for t in T:
|
for t in rows:
|
||||||
etudid = t[-1]
|
etudid = t[-1]
|
||||||
|
if etudids and etudid not in etudids:
|
||||||
|
continue
|
||||||
etudiant = Identite.get_etud(etudid)
|
etudiant = Identite.get_etud(etudid)
|
||||||
etud = sco_etud.get_etud_info(etudid=etudid, filled=True)[0]
|
etud = sco_etud.get_etud_info(etudid=etudid, filled=True)[0]
|
||||||
etud["annee_admission"] = etud["annee"] # plus explicite
|
etud["annee_admission"] = etud["annee"] # plus explicite
|
||||||
|
@ -96,7 +104,7 @@ def formsemestre_etuds_stats(sem: dict, only_primo=False):
|
||||||
etud["codedecision"] = "(nd)" # pas de decision jury
|
etud["codedecision"] = "(nd)" # pas de decision jury
|
||||||
# Ajout devenir (autorisations inscriptions), utile pour stats passage
|
# Ajout devenir (autorisations inscriptions), utile pour stats passage
|
||||||
aut_list = ScolarAutorisationInscription.query.filter_by(
|
aut_list = ScolarAutorisationInscription.query.filter_by(
|
||||||
etudid=etudid, origin_formsemestre_id=sem["formsemestre_id"]
|
etudid=etudid, origin_formsemestre_id=formsemestre.id
|
||||||
).all()
|
).all()
|
||||||
autorisations = [f"S{a.semestre_id}" for a in aut_list]
|
autorisations = [f"S{a.semestre_id}" for a in aut_list]
|
||||||
autorisations.sort()
|
autorisations.sort()
|
||||||
|
@ -115,27 +123,27 @@ def formsemestre_etuds_stats(sem: dict, only_primo=False):
|
||||||
bs.append(etud["specialite"])
|
bs.append(etud["specialite"])
|
||||||
etud["bac-specialite"] = " ".join(bs)
|
etud["bac-specialite"] = " ".join(bs)
|
||||||
#
|
#
|
||||||
if (not only_primo) or is_primo_etud(etud, sem):
|
if (not only_primo) or is_primo_etud(etud, formsemestre):
|
||||||
etuds.append(etud)
|
etuds.append(etud)
|
||||||
return etuds
|
return etuds
|
||||||
|
|
||||||
|
|
||||||
def is_primo_etud(etud: dict, sem: dict):
|
def is_primo_etud(etud: dict, formsemestre: FormSemestre):
|
||||||
"""Determine si un (filled) etud a été inscrit avant ce semestre.
|
"""Determine si un (filled) etud a été inscrit avant ce semestre.
|
||||||
Regarde la liste des semestres dans lesquels l'étudiant est inscrit.
|
Regarde la liste des semestres dans lesquels l'étudiant est inscrit.
|
||||||
Si semestre pair, considère comme primo-entrants ceux qui étaient
|
Si semestre pair, considère comme primo-entrants ceux qui étaient
|
||||||
primo dans le précédent (S_{2n-1}).
|
primo dans le précédent (S_{2n-1}).
|
||||||
"""
|
"""
|
||||||
debut_cur = sem["date_debut_iso"]
|
debut_cur_iso = formsemestre.date_debut.isoformat()
|
||||||
# si semestre impair et sem. précédent contigu, recule date debut
|
# si semestre impair et sem. précédent contigu, recule date debut
|
||||||
if (
|
if (
|
||||||
(len(etud["sems"]) > 1)
|
(len(etud["sems"]) > 1)
|
||||||
and (sem["semestre_id"] % 2 == 0)
|
and (formsemestre.semestre_id % 2 == 0)
|
||||||
and (etud["sems"][1]["semestre_id"] == (sem["semestre_id"] - 1))
|
and (etud["sems"][1]["semestre_id"] == (formsemestre.semestre_id - 1))
|
||||||
):
|
):
|
||||||
debut_cur = etud["sems"][1]["date_debut_iso"]
|
debut_cur_iso = etud["sems"][1]["date_debut_iso"]
|
||||||
for s in etud["sems"]: # le + recent d'abord
|
for s in etud["sems"]: # le + recent d'abord
|
||||||
if s["date_debut_iso"] < debut_cur:
|
if s["date_debut_iso"] < debut_cur_iso:
|
||||||
return False
|
return False
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
@ -274,22 +282,6 @@ def formsemestre_report(
|
||||||
return tab
|
return tab
|
||||||
|
|
||||||
|
|
||||||
# def formsemestre_report_bacs(formsemestre_id, fmt='html'):
|
|
||||||
# """
|
|
||||||
# Tableau sur résultats par type de bac
|
|
||||||
# """
|
|
||||||
# sem = sco_formsemestre.get_formsemestre( formsemestre_id)
|
|
||||||
# title = 'Statistiques bacs ' + sem['titreannee']
|
|
||||||
# etuds = formsemestre_etuds_stats(sem)
|
|
||||||
# tab = formsemestre_report(formsemestre_id, etuds,
|
|
||||||
# category='bac', result='codedecision',
|
|
||||||
# category_name='Bac',
|
|
||||||
# title=title)
|
|
||||||
# return tab.make_page(
|
|
||||||
# title = """<h2>Résultats de <a href="formsemestre_status?formsemestre_id=%(formsemestre_id)s">%(titreannee)s</a></h2>""" % sem,
|
|
||||||
# fmt=fmt, page_title = title)
|
|
||||||
|
|
||||||
|
|
||||||
def formsemestre_report_counts(
|
def formsemestre_report_counts(
|
||||||
formsemestre_id: int,
|
formsemestre_id: int,
|
||||||
fmt="html",
|
fmt="html",
|
||||||
|
@ -297,6 +289,7 @@ def formsemestre_report_counts(
|
||||||
result: str = None,
|
result: str = None,
|
||||||
allkeys: bool = False,
|
allkeys: bool = False,
|
||||||
only_primo: bool = False,
|
only_primo: bool = False,
|
||||||
|
group_ids: list[int] = None, # si indiqué, ne prend que ces groupes
|
||||||
):
|
):
|
||||||
"""
|
"""
|
||||||
Tableau comptage avec choix des categories
|
Tableau comptage avec choix des categories
|
||||||
|
@ -307,8 +300,12 @@ def formsemestre_report_counts(
|
||||||
si vrai, toutes les valeurs présentes dans les données
|
si vrai, toutes les valeurs présentes dans les données
|
||||||
sinon liste prédéfinie (voir ci-dessous)
|
sinon liste prédéfinie (voir ci-dessous)
|
||||||
"""
|
"""
|
||||||
formsemestre: FormSemestre = FormSemestre.query.get_or_404(formsemestre_id)
|
formsemestre = FormSemestre.get_formsemestre(formsemestre_id)
|
||||||
sem = sco_formsemestre.get_formsemestre(formsemestre_id)
|
groups_infos = sco_groups_view.DisplayedGroupsInfos(
|
||||||
|
group_ids,
|
||||||
|
formsemestre_id=formsemestre.id,
|
||||||
|
select_all_when_unspecified=True,
|
||||||
|
)
|
||||||
# Décisions de jury BUT pour les semestres pairs seulement
|
# Décisions de jury BUT pour les semestres pairs seulement
|
||||||
jury_but_mode = (
|
jury_but_mode = (
|
||||||
formsemestre.formation.is_apc() and formsemestre.semestre_id % 2 == 0
|
formsemestre.formation.is_apc() and formsemestre.semestre_id % 2 == 0
|
||||||
|
@ -319,7 +316,9 @@ def formsemestre_report_counts(
|
||||||
|
|
||||||
category_name = category.capitalize()
|
category_name = category.capitalize()
|
||||||
title = "Comptages " + category_name
|
title = "Comptages " + category_name
|
||||||
etuds = formsemestre_etuds_stats(sem, only_primo=only_primo)
|
etuds = formsemestre_etuds_stats(
|
||||||
|
formsemestre, groups_infos=groups_infos, only_primo=only_primo
|
||||||
|
)
|
||||||
tab = formsemestre_report(
|
tab = formsemestre_report(
|
||||||
formsemestre_id,
|
formsemestre_id,
|
||||||
etuds,
|
etuds,
|
||||||
|
@ -329,7 +328,7 @@ def formsemestre_report_counts(
|
||||||
title=title,
|
title=title,
|
||||||
only_primo=only_primo,
|
only_primo=only_primo,
|
||||||
)
|
)
|
||||||
if not etuds:
|
if len(formsemestre.inscriptions) == 0:
|
||||||
F = ["""<p><em>Aucun étudiant</em></p>"""]
|
F = ["""<p><em>Aucun étudiant</em></p>"""]
|
||||||
else:
|
else:
|
||||||
if allkeys:
|
if allkeys:
|
||||||
|
@ -357,9 +356,10 @@ def formsemestre_report_counts(
|
||||||
keys += ["nb_rcue_valides", "decision_annee"]
|
keys += ["nb_rcue_valides", "decision_annee"]
|
||||||
keys.sort(key=scu.heterogeneous_sorting_key)
|
keys.sort(key=scu.heterogeneous_sorting_key)
|
||||||
F = [
|
F = [
|
||||||
"""<form name="f" method="get" action="%s"><p>
|
f"""<form id="group_selector" name="f" method="get" action="{request.base_url}">
|
||||||
Colonnes: <select name="result" onchange="document.f.submit()">"""
|
Colonnes:
|
||||||
% request.base_url
|
<select name="result" onchange="document.f.submit()">
|
||||||
|
"""
|
||||||
]
|
]
|
||||||
for k in keys:
|
for k in keys:
|
||||||
if k == result:
|
if k == result:
|
||||||
|
@ -381,30 +381,38 @@ def formsemestre_report_counts(
|
||||||
'<option value="%s" %s>%s</option>'
|
'<option value="%s" %s>%s</option>'
|
||||||
% (k, selected, LEGENDES_CODES_BUT.get(k, k))
|
% (k, selected, LEGENDES_CODES_BUT.get(k, k))
|
||||||
)
|
)
|
||||||
F.append("</select>")
|
|
||||||
if only_primo:
|
|
||||||
checked = 'checked="1"'
|
|
||||||
else:
|
|
||||||
checked = ""
|
|
||||||
F.append(
|
F.append(
|
||||||
'<br><input type="checkbox" name="only_primo" onchange="document.f.submit()" %s>Restreindre aux primo-entrants</input>'
|
f"""
|
||||||
% checked
|
</select>
|
||||||
|
<div style="margin-top:12px;">
|
||||||
|
<input type="checkbox" name="only_primo" onchange="document.f.submit()"
|
||||||
|
{'checked' if only_primo else ''}>
|
||||||
|
Restreindre aux primo-entrants</input>
|
||||||
|
<span style="margin: 12px;">
|
||||||
|
Restreindre au(x) groupe(s) :
|
||||||
|
{sco_groups_view.menu_groups_choice(groups_infos, submit_on_change=True)
|
||||||
|
if groups_infos else ''}
|
||||||
|
</span>
|
||||||
|
<input type="hidden" name="formsemestre_id" value="{formsemestre_id}"/>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
"""
|
||||||
)
|
)
|
||||||
F.append(
|
|
||||||
'<input type="hidden" name="formsemestre_id" value="%s"/>' % formsemestre_id
|
|
||||||
)
|
|
||||||
F.append("</p></form>")
|
|
||||||
|
|
||||||
t = tab.make_page(
|
tableau = tab.make_page(
|
||||||
title="""<h2 class="formsemestre">Comptes croisés</h2>""",
|
|
||||||
fmt=fmt,
|
fmt=fmt,
|
||||||
|
title="""<h2 class="formsemestre">Comptes croisés</h2>""",
|
||||||
with_html_headers=False,
|
with_html_headers=False,
|
||||||
)
|
)
|
||||||
if fmt != "html":
|
if fmt != "html":
|
||||||
return t
|
return tableau
|
||||||
H = [
|
H = [
|
||||||
html_sco_header.sco_header(page_title=title),
|
html_sco_header.sco_header(
|
||||||
t,
|
cssstyles=sco_groups_view.CSSSTYLES,
|
||||||
|
javascripts=sco_groups_view.JAVASCRIPTS,
|
||||||
|
page_title=title,
|
||||||
|
),
|
||||||
|
tableau,
|
||||||
"\n".join(F),
|
"\n".join(F),
|
||||||
"""<p class="help">Le tableau affiche le nombre d'étudiants de ce semestre dans chacun
|
"""<p class="help">Le tableau affiche le nombre d'étudiants de ce semestre dans chacun
|
||||||
des cas choisis: à l'aide des deux menus, vous pouvez choisir les catégories utilisées
|
des cas choisis: à l'aide des deux menus, vous pouvez choisir les catégories utilisées
|
||||||
|
@ -418,7 +426,8 @@ def formsemestre_report_counts(
|
||||||
|
|
||||||
# --------------------------------------------------------------------------
|
# --------------------------------------------------------------------------
|
||||||
def table_suivi_cohorte(
|
def table_suivi_cohorte(
|
||||||
formsemestre_id,
|
formsemestre: FormSemestre,
|
||||||
|
groups_infos,
|
||||||
percent=False,
|
percent=False,
|
||||||
bac="", # selection sur type de bac
|
bac="", # selection sur type de bac
|
||||||
bacspecialite="",
|
bacspecialite="",
|
||||||
|
@ -441,9 +450,8 @@ def table_suivi_cohorte(
|
||||||
Determination des dates: on regroupe les semestres commençant à des dates proches
|
Determination des dates: on regroupe les semestres commençant à des dates proches
|
||||||
|
|
||||||
"""
|
"""
|
||||||
sem = sco_formsemestre.get_formsemestre(
|
sem = sco_formsemestre.get_formsemestre(formsemestre.id)
|
||||||
formsemestre_id
|
# sem est le semestre origine
|
||||||
) # sem est le semestre origine
|
|
||||||
t0 = time.time()
|
t0 = time.time()
|
||||||
|
|
||||||
def logt(op):
|
def logt(op):
|
||||||
|
@ -452,12 +460,12 @@ def table_suivi_cohorte(
|
||||||
|
|
||||||
logt("table_suivi_cohorte: start")
|
logt("table_suivi_cohorte: start")
|
||||||
# 1-- Liste des semestres posterieurs dans lesquels ont été les etudiants de sem
|
# 1-- Liste des semestres posterieurs dans lesquels ont été les etudiants de sem
|
||||||
formsemestre = FormSemestre.get_formsemestre(formsemestre_id)
|
|
||||||
nt: NotesTableCompat = res_sem.load_formsemestre_results(formsemestre)
|
nt: NotesTableCompat = res_sem.load_formsemestre_results(formsemestre)
|
||||||
etudids = nt.get_etudids()
|
etudids_inscrits = {ins.etudid for ins in formsemestre.inscriptions}
|
||||||
|
etudids_groups = groups_infos.get_etudids()
|
||||||
|
etudids = etudids_inscrits.intersection(etudids_groups)
|
||||||
logt("A: orig etuds set")
|
logt("A: orig etuds set")
|
||||||
S = {formsemestre_id: sem} # ensemble de formsemestre_id
|
S = {formsemestre.id: sem} # ensemble de formsemestre_id
|
||||||
orig_set = set() # ensemble d'etudid du semestre d'origine
|
orig_set = set() # ensemble d'etudid du semestre d'origine
|
||||||
bacs = set()
|
bacs = set()
|
||||||
bacspecialites = set()
|
bacspecialites = set()
|
||||||
|
@ -479,7 +487,7 @@ def table_suivi_cohorte(
|
||||||
)
|
)
|
||||||
and (not civilite or (civilite == etud["civilite"]))
|
and (not civilite or (civilite == etud["civilite"]))
|
||||||
and (not statut or (statut == etud["statut"]))
|
and (not statut or (statut == etud["statut"]))
|
||||||
and (not only_primo or is_primo_etud(etud, sem))
|
and (not only_primo or is_primo_etud(etud, formsemestre))
|
||||||
):
|
):
|
||||||
orig_set.add(etudid)
|
orig_set.add(etudid)
|
||||||
# semestres suivants:
|
# semestres suivants:
|
||||||
|
@ -524,17 +532,15 @@ def table_suivi_cohorte(
|
||||||
s["nb_dipl"] = nb_dipl
|
s["nb_dipl"] = nb_dipl
|
||||||
|
|
||||||
# 3-- Regroupe les semestres par date de debut
|
# 3-- Regroupe les semestres par date de debut
|
||||||
P = [] # liste de periodsem
|
|
||||||
|
|
||||||
class PeriodSem:
|
class PeriodSem:
|
||||||
pass
|
def __init__(self, datedebut: datetime.datetime, sems: list[dict]):
|
||||||
|
self.datedebut = datedebut
|
||||||
|
self.sems = sems
|
||||||
|
|
||||||
# semestre de depart:
|
# semestre de depart:
|
||||||
porigin = PeriodSem()
|
|
||||||
d, m, y = [int(x) for x in sem["date_debut"].split("/")]
|
d, m, y = [int(x) for x in sem["date_debut"].split("/")]
|
||||||
porigin.datedebut = datetime.datetime(y, m, d)
|
porigin = PeriodSem(datetime.datetime(y, m, d), [sem])
|
||||||
porigin.sems = [sem]
|
P = [] # liste de periodsem
|
||||||
|
|
||||||
#
|
#
|
||||||
tolerance = datetime.timedelta(days=45)
|
tolerance = datetime.timedelta(days=45)
|
||||||
for s in sems:
|
for s in sems:
|
||||||
|
@ -545,9 +551,7 @@ def table_suivi_cohorte(
|
||||||
merged = True
|
merged = True
|
||||||
break
|
break
|
||||||
if not merged:
|
if not merged:
|
||||||
p = PeriodSem()
|
p = PeriodSem(s["date_debut_dt"], [s])
|
||||||
p.datedebut = s["date_debut_dt"]
|
|
||||||
p.sems = [s]
|
|
||||||
P.append(p)
|
P.append(p)
|
||||||
|
|
||||||
# 4-- regroupe par indice de semestre S_i
|
# 4-- regroupe par indice de semestre S_i
|
||||||
|
@ -602,7 +606,7 @@ def table_suivi_cohorte(
|
||||||
L.append(d)
|
L.append(d)
|
||||||
# Compte nb de démissions et de ré-orientation par période
|
# Compte nb de démissions et de ré-orientation par période
|
||||||
logt("D: cout dems reos")
|
logt("D: cout dems reos")
|
||||||
sem["dems"], sem["reos"] = _count_dem_reo(formsemestre_id, sem["members"])
|
sem["dems"], sem["reos"] = _count_dem_reo(formsemestre.id, sem["members"])
|
||||||
for p in P:
|
for p in P:
|
||||||
p.dems = set()
|
p.dems = set()
|
||||||
p.reos = set()
|
p.reos = set()
|
||||||
|
@ -666,8 +670,8 @@ def table_suivi_cohorte(
|
||||||
L.append(l)
|
L.append(l)
|
||||||
|
|
||||||
columns_ids = [p.datedebut for p in P]
|
columns_ids = [p.datedebut for p in P]
|
||||||
titles = dict([(p.datedebut, p.datedebut.strftime("%d/%m/%y")) for p in P])
|
titles = dict([(p.datedebut, p.datedebut.strftime(scu.DATE_FMT)) for p in P])
|
||||||
titles[porigin.datedebut] = porigin.datedebut.strftime("%d/%m/%y")
|
titles[porigin.datedebut] = porigin.datedebut.strftime(scu.DATE_FMT)
|
||||||
if percent:
|
if percent:
|
||||||
pp = "(en % de la population initiale) "
|
pp = "(en % de la population initiale) "
|
||||||
titles["row_title"] = "%"
|
titles["row_title"] = "%"
|
||||||
|
@ -703,7 +707,7 @@ def table_suivi_cohorte(
|
||||||
caption="Suivi cohorte " + pp + sem["titreannee"] + dbac,
|
caption="Suivi cohorte " + pp + sem["titreannee"] + dbac,
|
||||||
page_title="Suivi cohorte " + sem["titreannee"],
|
page_title="Suivi cohorte " + sem["titreannee"],
|
||||||
html_class="table_cohorte",
|
html_class="table_cohorte",
|
||||||
preferences=sco_preferences.SemPreferences(formsemestre_id),
|
preferences=sco_preferences.SemPreferences(formsemestre.id),
|
||||||
)
|
)
|
||||||
# Explication: liste des semestres associés à chaque date
|
# Explication: liste des semestres associés à chaque date
|
||||||
if not P:
|
if not P:
|
||||||
|
@ -713,13 +717,10 @@ def table_suivi_cohorte(
|
||||||
else:
|
else:
|
||||||
expl = ["<h3>Semestres associés à chaque date:</h3><ul>"]
|
expl = ["<h3>Semestres associés à chaque date:</h3><ul>"]
|
||||||
for p in P:
|
for p in P:
|
||||||
expl.append("<li><b>%s</b>:" % p.datedebut.strftime("%d/%m/%y"))
|
expl.append(f"""<li><b>{p.datedebut.strftime(scu.DATE_FMT)}</b>:""")
|
||||||
ls = []
|
ls = []
|
||||||
for s in p.sems:
|
for s in p.sems:
|
||||||
ls.append(
|
ls.append(formsemestre.html_link_status())
|
||||||
'<a href="formsemestre_status?formsemestre_id=%(formsemestre_id)s">%(titreannee)s</a>'
|
|
||||||
% s
|
|
||||||
)
|
|
||||||
expl.append(", ".join(ls) + "</li>")
|
expl.append(", ".join(ls) + "</li>")
|
||||||
expl.append("</ul>")
|
expl.append("</ul>")
|
||||||
return (
|
return (
|
||||||
|
@ -737,6 +738,7 @@ def table_suivi_cohorte(
|
||||||
def formsemestre_suivi_cohorte(
|
def formsemestre_suivi_cohorte(
|
||||||
formsemestre_id,
|
formsemestre_id,
|
||||||
fmt="html",
|
fmt="html",
|
||||||
|
group_ids: list[int] = None, # si indiqué, ne prend que ces groupes
|
||||||
percent=1,
|
percent=1,
|
||||||
bac="",
|
bac="",
|
||||||
bacspecialite="",
|
bacspecialite="",
|
||||||
|
@ -747,9 +749,19 @@ def formsemestre_suivi_cohorte(
|
||||||
only_primo=False,
|
only_primo=False,
|
||||||
) -> str:
|
) -> str:
|
||||||
"""Affiche suivi cohortes par numero de semestre"""
|
"""Affiche suivi cohortes par numero de semestre"""
|
||||||
annee_bac = str(annee_bac or "")
|
try:
|
||||||
annee_admission = str(annee_admission or "")
|
annee_bac = str(annee_bac or "")
|
||||||
percent = int(percent)
|
annee_admission = str(annee_admission or "")
|
||||||
|
percent = int(percent)
|
||||||
|
except ValueError as exc:
|
||||||
|
raise ScoValueError("formsemestre_suivi_cohorte: argument invalide") from exc
|
||||||
|
|
||||||
|
formsemestre = FormSemestre.get_formsemestre(formsemestre_id)
|
||||||
|
groups_infos = sco_groups_view.DisplayedGroupsInfos(
|
||||||
|
group_ids,
|
||||||
|
formsemestre_id=formsemestre.id,
|
||||||
|
select_all_when_unspecified=True,
|
||||||
|
)
|
||||||
(
|
(
|
||||||
tab,
|
tab,
|
||||||
expl,
|
expl,
|
||||||
|
@ -760,7 +772,8 @@ def formsemestre_suivi_cohorte(
|
||||||
civilites,
|
civilites,
|
||||||
statuts,
|
statuts,
|
||||||
) = table_suivi_cohorte(
|
) = table_suivi_cohorte(
|
||||||
formsemestre_id,
|
formsemestre,
|
||||||
|
groups_infos=groups_infos,
|
||||||
percent=percent,
|
percent=percent,
|
||||||
bac=bac,
|
bac=bac,
|
||||||
bacspecialite=bacspecialite,
|
bacspecialite=bacspecialite,
|
||||||
|
@ -772,7 +785,7 @@ def formsemestre_suivi_cohorte(
|
||||||
)
|
)
|
||||||
tab.base_url = (
|
tab.base_url = (
|
||||||
"%s?formsemestre_id=%s&percent=%s&bac=%s&bacspecialite=%s&civilite=%s"
|
"%s?formsemestre_id=%s&percent=%s&bac=%s&bacspecialite=%s&civilite=%s"
|
||||||
% (request.base_url, formsemestre_id, percent, bac, bacspecialite, civilite)
|
% (request.base_url, formsemestre.id, percent, bac, bacspecialite, civilite)
|
||||||
)
|
)
|
||||||
if only_primo:
|
if only_primo:
|
||||||
tab.base_url += "&only_primo=on"
|
tab.base_url += "&only_primo=on"
|
||||||
|
@ -783,25 +796,29 @@ def formsemestre_suivi_cohorte(
|
||||||
base_url = request.base_url
|
base_url = request.base_url
|
||||||
burl = "%s?formsemestre_id=%s&bac=%s&bacspecialite=%s&civilite=%s&statut=%s" % (
|
burl = "%s?formsemestre_id=%s&bac=%s&bacspecialite=%s&civilite=%s&statut=%s" % (
|
||||||
base_url,
|
base_url,
|
||||||
formsemestre_id,
|
formsemestre.id,
|
||||||
bac,
|
bac,
|
||||||
bacspecialite,
|
bacspecialite,
|
||||||
civilite,
|
civilite,
|
||||||
statut,
|
statut,
|
||||||
)
|
)
|
||||||
if percent:
|
if percent:
|
||||||
pplink = '<p><a href="%s&percent=0">Afficher les résultats bruts</a></p>' % burl
|
pplink = f"""<p><a class="stdlink"
|
||||||
|
href="{burl}&percent=0">Afficher les résultats bruts</a></p>"""
|
||||||
else:
|
else:
|
||||||
pplink = (
|
pplink = f"""<p><a class="stdlink"
|
||||||
'<p><a href="%s&percent=1">Afficher les résultats en pourcentages</a></p>'
|
href="{burl}&percent=1">Afficher les résultats en pourcentages</a></p>"""
|
||||||
% burl
|
|
||||||
)
|
|
||||||
|
|
||||||
H = [
|
H = [
|
||||||
html_sco_header.sco_header(page_title=tab.page_title),
|
html_sco_header.sco_header(
|
||||||
|
cssstyles=sco_groups_view.CSSSTYLES,
|
||||||
|
javascripts=sco_groups_view.JAVASCRIPTS,
|
||||||
|
page_title=tab.page_title,
|
||||||
|
),
|
||||||
"""<h2 class="formsemestre">Suivi cohorte: devenir des étudiants de ce semestre</h2>""",
|
"""<h2 class="formsemestre">Suivi cohorte: devenir des étudiants de ce semestre</h2>""",
|
||||||
_gen_form_selectetuds(
|
_gen_form_selectetuds(
|
||||||
formsemestre_id,
|
formsemestre.id,
|
||||||
|
groups_infos=groups_infos,
|
||||||
only_primo=only_primo,
|
only_primo=only_primo,
|
||||||
bac=bac,
|
bac=bac,
|
||||||
bacspecialite=bacspecialite,
|
bacspecialite=bacspecialite,
|
||||||
|
@ -854,6 +871,7 @@ def _gen_form_selectetuds(
|
||||||
annee_admissions=None,
|
annee_admissions=None,
|
||||||
civilites=None,
|
civilites=None,
|
||||||
statuts=None,
|
statuts=None,
|
||||||
|
groups_infos: sco_groups_view.DisplayedGroupsInfos = None,
|
||||||
):
|
):
|
||||||
"""HTML form pour choix criteres selection etudiants"""
|
"""HTML form pour choix criteres selection etudiants"""
|
||||||
annee_bacs = annee_bacs or []
|
annee_bacs = annee_bacs or []
|
||||||
|
@ -877,9 +895,10 @@ def _gen_form_selectetuds(
|
||||||
else:
|
else:
|
||||||
selected = 'selected="selected"'
|
selected = 'selected="selected"'
|
||||||
F = [
|
F = [
|
||||||
f"""<form id="f" method="get" action="{request.base_url}">
|
f"""<form id="group_selector" name="f" method="get" action="{request.base_url}">
|
||||||
<p>Bac: <select name="bac" onchange="javascript: submit(this);">
|
<div>Bac:
|
||||||
<option value="" {selected}>tous</option>
|
<select name="bac" onchange="javascript: submit(this);">
|
||||||
|
<option value="" {selected}>tous</option>
|
||||||
"""
|
"""
|
||||||
]
|
]
|
||||||
for b in bacs:
|
for b in bacs:
|
||||||
|
@ -894,7 +913,8 @@ def _gen_form_selectetuds(
|
||||||
else:
|
else:
|
||||||
selected = 'selected="selected"'
|
selected = 'selected="selected"'
|
||||||
F.append(
|
F.append(
|
||||||
f""" Bac/Specialité: <select name="bacspecialite" onchange="javascript: submit(this);">
|
f""" Bac/Specialité:
|
||||||
|
<select name="bacspecialite" onchange="javascript: submit(this);">
|
||||||
<option value="" {selected}>tous</option>
|
<option value="" {selected}>tous</option>
|
||||||
"""
|
"""
|
||||||
)
|
)
|
||||||
|
@ -938,17 +958,24 @@ def _gen_form_selectetuds(
|
||||||
else:
|
else:
|
||||||
selected = ""
|
selected = ""
|
||||||
F.append(f'<option value="{b}" {selected}>{b}</option>')
|
F.append(f'<option value="{b}" {selected}>{b}</option>')
|
||||||
F.append("</select>")
|
|
||||||
|
|
||||||
F.append(
|
F.append(
|
||||||
f"""<br>
|
f"""
|
||||||
<input type="checkbox" name="only_primo"
|
</select>
|
||||||
onchange="javascript: submit(this);"
|
<div style="margin-top:12px;">
|
||||||
{'checked="1"' if only_primo else ""}/>Restreindre aux primo-entrants
|
<input type="checkbox" name="only_primo"
|
||||||
<input type="hidden" name="formsemestre_id" value="{formsemestre_id}"/>
|
onchange="javascript: submit(this);"
|
||||||
<input type="hidden" name="percent" value="{percent}"/>
|
{'checked="1"' if only_primo else ""}/>Restreindre aux primo-entrants
|
||||||
|
|
||||||
</p>
|
<span style="margin: 12px;">
|
||||||
|
Restreindre au(x) groupe(s) :
|
||||||
|
{sco_groups_view.menu_groups_choice(groups_infos, submit_on_change=True)
|
||||||
|
if groups_infos else ''}
|
||||||
|
</span>
|
||||||
|
<input type="hidden" name="formsemestre_id" value="{formsemestre_id}"/>
|
||||||
|
<input type="hidden" name="percent" value="{percent}"/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</form>
|
</form>
|
||||||
"""
|
"""
|
||||||
)
|
)
|
||||||
|
@ -1002,17 +1029,6 @@ def _count_dem_reo(formsemestre_id, etudids):
|
||||||
return dems, reos
|
return dems, reos
|
||||||
|
|
||||||
|
|
||||||
"""OLDGEA:
|
|
||||||
27s pour S1 F.I. classique Semestre 1 2006-2007
|
|
||||||
B 2.3s
|
|
||||||
C 5.6s
|
|
||||||
D 5.9s
|
|
||||||
Z 27s => cache des semestres pour nt
|
|
||||||
|
|
||||||
à chaud: 3s
|
|
||||||
B: etuds sets: 2.4s => lent: N x getEtudInfo (non caché)
|
|
||||||
"""
|
|
||||||
|
|
||||||
EXP_LIC = re.compile(r"licence", re.I)
|
EXP_LIC = re.compile(r"licence", re.I)
|
||||||
EXP_LPRO = re.compile(r"professionnelle", re.I)
|
EXP_LPRO = re.compile(r"professionnelle", re.I)
|
||||||
|
|
||||||
|
@ -1125,6 +1141,7 @@ def get_code_cursus_etud(
|
||||||
|
|
||||||
def tsp_etud_list(
|
def tsp_etud_list(
|
||||||
formsemestre_id,
|
formsemestre_id,
|
||||||
|
groups_infos: sco_groups_view.DisplayedGroupsInfos | None = None,
|
||||||
only_primo=False,
|
only_primo=False,
|
||||||
bac="", # selection sur type de bac
|
bac="", # selection sur type de bac
|
||||||
bacspecialite="",
|
bacspecialite="",
|
||||||
|
@ -1136,11 +1153,13 @@ def tsp_etud_list(
|
||||||
"""Liste des etuds a considerer dans table suivi cursus
|
"""Liste des etuds a considerer dans table suivi cursus
|
||||||
ramene aussi ensembles des bacs, genres, statuts de (tous) les etudiants
|
ramene aussi ensembles des bacs, genres, statuts de (tous) les etudiants
|
||||||
"""
|
"""
|
||||||
# log('tsp_etud_list(%s, bac="%s")' % (formsemestre_id,bac))
|
|
||||||
sem = sco_formsemestre.get_formsemestre(formsemestre_id)
|
|
||||||
formsemestre = FormSemestre.get_formsemestre(formsemestre_id)
|
formsemestre = FormSemestre.get_formsemestre(formsemestre_id)
|
||||||
nt: NotesTableCompat = res_sem.load_formsemestre_results(formsemestre)
|
etudids_inscrits = {ins.etudid for ins in formsemestre.inscriptions}
|
||||||
etudids = nt.get_etudids()
|
if groups_infos:
|
||||||
|
etudids_groups = groups_infos.get_etudids()
|
||||||
|
etudids = etudids_inscrits.intersection(etudids_groups)
|
||||||
|
else:
|
||||||
|
etudids = etudids_inscrits
|
||||||
etuds = []
|
etuds = []
|
||||||
bacs = set()
|
bacs = set()
|
||||||
bacspecialites = set()
|
bacspecialites = set()
|
||||||
|
@ -1162,7 +1181,7 @@ def tsp_etud_list(
|
||||||
)
|
)
|
||||||
and (not civilite or (civilite == etud["civilite"]))
|
and (not civilite or (civilite == etud["civilite"]))
|
||||||
and (not statut or (statut == etud["statut"]))
|
and (not statut or (statut == etud["statut"]))
|
||||||
and (not only_primo or is_primo_etud(etud, sem))
|
and (not only_primo or is_primo_etud(etud, formsemestre))
|
||||||
):
|
):
|
||||||
etuds.append(etud)
|
etuds.append(etud)
|
||||||
|
|
||||||
|
@ -1173,7 +1192,6 @@ def tsp_etud_list(
|
||||||
civilites.add(etud["civilite"])
|
civilites.add(etud["civilite"])
|
||||||
if etud["statut"]: # ne montre pas les statuts non renseignés
|
if etud["statut"]: # ne montre pas les statuts non renseignés
|
||||||
statuts.add(etud["statut"])
|
statuts.add(etud["statut"])
|
||||||
# log('tsp_etud_list: %s etuds' % len(etuds))
|
|
||||||
return etuds, bacs, bacspecialites, annee_bacs, annee_admissions, civilites, statuts
|
return etuds, bacs, bacspecialites, annee_bacs, annee_admissions, civilites, statuts
|
||||||
|
|
||||||
|
|
||||||
|
@ -1290,31 +1308,30 @@ def table_suivi_cursus(formsemestre_id, only_primo=False, grouped_parcours=True)
|
||||||
return tab
|
return tab
|
||||||
|
|
||||||
|
|
||||||
def tsp_form_primo_group(only_primo, no_grouping, formsemestre_id, fmt):
|
def tsp_form_primo_group(
|
||||||
"""Element de formulaire pour choisir si restriction aux primos entrants et groupement par lycees"""
|
only_primo, no_grouping, formsemestre_id, fmt, groups_infos=None
|
||||||
F = ["""<form name="f" method="get" action="%s">""" % request.base_url]
|
) -> str:
|
||||||
if only_primo:
|
"""Element de formulaire pour choisir si restriction aux primos entrants,
|
||||||
checked = 'checked="1"'
|
groupement par lycees et groupes
|
||||||
else:
|
"""
|
||||||
checked = ""
|
primo_checked = 'checked="1"' if only_primo else ""
|
||||||
F.append(
|
no_grouping_checked = 'checked="1"' if no_grouping else ""
|
||||||
'<input type="checkbox" name="only_primo" onchange="document.f.submit()" %s>Restreindre aux primo-entrants</input>'
|
return f"""
|
||||||
% checked
|
<form id="group_selector" name="f" method="get" action="{request.base_url}">
|
||||||
)
|
<input type="checkbox" name="only_primo"
|
||||||
if no_grouping:
|
onchange="document.f.submit()" {primo_checked}>Restreindre aux primo-entrants</input>
|
||||||
checked = 'checked="1"'
|
<input type="checkbox" name="no_grouping" onchange="document.f.submit()"
|
||||||
else:
|
{no_grouping_checked}>Lister chaque étudiant</input>
|
||||||
checked = ""
|
|
||||||
F.append(
|
<span style="margin: 12px;">
|
||||||
'<input type="checkbox" name="no_grouping" onchange="document.f.submit()" %s>Lister chaque étudiant</input>'
|
Restreindre au(x) groupe(s) :
|
||||||
% checked
|
{sco_groups_view.menu_groups_choice(groups_infos, submit_on_change=True)
|
||||||
)
|
if groups_infos else ''}
|
||||||
F.append(
|
</span>
|
||||||
'<input type="hidden" name="formsemestre_id" value="%s"/>' % formsemestre_id
|
<input type="hidden" name="formsemestre_id" value="{formsemestre_id}"/>
|
||||||
)
|
<input type="hidden" name="fmt" value="{fmt}"/>
|
||||||
F.append('<input type="hidden" name="fmt" value="%s"/>' % fmt)
|
</form>
|
||||||
F.append("""</form>""")
|
"""
|
||||||
return "\n".join(F)
|
|
||||||
|
|
||||||
|
|
||||||
def formsemestre_suivi_cursus(
|
def formsemestre_suivi_cursus(
|
||||||
|
@ -1337,7 +1354,11 @@ def formsemestre_suivi_cursus(
|
||||||
t = tab.make_page(fmt=fmt, with_html_headers=False)
|
t = tab.make_page(fmt=fmt, with_html_headers=False)
|
||||||
if fmt != "html":
|
if fmt != "html":
|
||||||
return t
|
return t
|
||||||
F = [tsp_form_primo_group(only_primo, no_grouping, formsemestre_id, fmt)]
|
F = [
|
||||||
|
tsp_form_primo_group(
|
||||||
|
only_primo, no_grouping, formsemestre_id, fmt, groups_infos=None
|
||||||
|
)
|
||||||
|
]
|
||||||
|
|
||||||
H = [
|
H = [
|
||||||
html_sco_header.sco_header(
|
html_sco_header.sco_header(
|
||||||
|
@ -1356,6 +1377,7 @@ def formsemestre_suivi_cursus(
|
||||||
# -------------
|
# -------------
|
||||||
def graph_cursus(
|
def graph_cursus(
|
||||||
formsemestre_id,
|
formsemestre_id,
|
||||||
|
groups_infos: sco_groups_view.DisplayedGroupsInfos | None = None,
|
||||||
fmt="svg",
|
fmt="svg",
|
||||||
only_primo=False,
|
only_primo=False,
|
||||||
bac="", # selection sur type de bac
|
bac="", # selection sur type de bac
|
||||||
|
@ -1376,6 +1398,7 @@ def graph_cursus(
|
||||||
statuts,
|
statuts,
|
||||||
) = tsp_etud_list(
|
) = tsp_etud_list(
|
||||||
formsemestre_id,
|
formsemestre_id,
|
||||||
|
groups_infos=groups_infos,
|
||||||
only_primo=only_primo,
|
only_primo=only_primo,
|
||||||
bac=bac,
|
bac=bac,
|
||||||
bacspecialite=bacspecialite,
|
bacspecialite=bacspecialite,
|
||||||
|
@ -1512,6 +1535,9 @@ def graph_cursus(
|
||||||
# semestre de depart en vert
|
# semestre de depart en vert
|
||||||
n = g.get_node("SEM" + str(formsemestre_id))[0]
|
n = g.get_node("SEM" + str(formsemestre_id))[0]
|
||||||
n.set_color("green")
|
n.set_color("green")
|
||||||
|
n.set_style("filled")
|
||||||
|
n.set_fillcolor("lightgreen")
|
||||||
|
n.set_penwidth(2.0)
|
||||||
# demissions en rouge, octagonal
|
# demissions en rouge, octagonal
|
||||||
for nid in dem_nodes.values():
|
for nid in dem_nodes.values():
|
||||||
n = g.get_node(nid)[0]
|
n = g.get_node(nid)[0]
|
||||||
|
@ -1606,6 +1632,7 @@ def graph_cursus(
|
||||||
|
|
||||||
def formsemestre_graph_cursus(
|
def formsemestre_graph_cursus(
|
||||||
formsemestre_id,
|
formsemestre_id,
|
||||||
|
group_ids: list[int] = None, # si indiqué, ne prend que ces groupes
|
||||||
fmt="html",
|
fmt="html",
|
||||||
only_primo=False,
|
only_primo=False,
|
||||||
bac="", # selection sur type de bac
|
bac="", # selection sur type de bac
|
||||||
|
@ -1619,7 +1646,12 @@ def formsemestre_graph_cursus(
|
||||||
"""Graphe suivi cohortes"""
|
"""Graphe suivi cohortes"""
|
||||||
annee_bac = str(annee_bac or "")
|
annee_bac = str(annee_bac or "")
|
||||||
annee_admission = str(annee_admission or "")
|
annee_admission = str(annee_admission or "")
|
||||||
# log("formsemestre_graph_cursus")
|
formsemestre = FormSemestre.get_formsemestre(formsemestre_id)
|
||||||
|
groups_infos = sco_groups_view.DisplayedGroupsInfos(
|
||||||
|
group_ids,
|
||||||
|
formsemestre_id=formsemestre.id,
|
||||||
|
select_all_when_unspecified=True,
|
||||||
|
)
|
||||||
sem = sco_formsemestre.get_formsemestre(formsemestre_id)
|
sem = sco_formsemestre.get_formsemestre(formsemestre_id)
|
||||||
if fmt == "pdf":
|
if fmt == "pdf":
|
||||||
(
|
(
|
||||||
|
@ -1633,6 +1665,7 @@ def formsemestre_graph_cursus(
|
||||||
statuts,
|
statuts,
|
||||||
) = graph_cursus(
|
) = graph_cursus(
|
||||||
formsemestre_id,
|
formsemestre_id,
|
||||||
|
groups_infos=groups_infos,
|
||||||
fmt="pdf",
|
fmt="pdf",
|
||||||
only_primo=only_primo,
|
only_primo=only_primo,
|
||||||
bac=bac,
|
bac=bac,
|
||||||
|
@ -1657,6 +1690,7 @@ def formsemestre_graph_cursus(
|
||||||
statuts,
|
statuts,
|
||||||
) = graph_cursus(
|
) = graph_cursus(
|
||||||
formsemestre_id,
|
formsemestre_id,
|
||||||
|
groups_infos=groups_infos,
|
||||||
fmt="png",
|
fmt="png",
|
||||||
only_primo=only_primo,
|
only_primo=only_primo,
|
||||||
bac=bac,
|
bac=bac,
|
||||||
|
@ -1695,6 +1729,7 @@ def formsemestre_graph_cursus(
|
||||||
statuts,
|
statuts,
|
||||||
) = graph_cursus(
|
) = graph_cursus(
|
||||||
formsemestre_id,
|
formsemestre_id,
|
||||||
|
groups_infos=groups_infos,
|
||||||
only_primo=only_primo,
|
only_primo=only_primo,
|
||||||
bac=bac,
|
bac=bac,
|
||||||
bacspecialite=bacspecialite,
|
bacspecialite=bacspecialite,
|
||||||
|
@ -1706,14 +1741,17 @@ def formsemestre_graph_cursus(
|
||||||
|
|
||||||
H = [
|
H = [
|
||||||
html_sco_header.sco_header(
|
html_sco_header.sco_header(
|
||||||
|
cssstyles=sco_groups_view.CSSSTYLES,
|
||||||
|
javascripts=sco_groups_view.JAVASCRIPTS,
|
||||||
page_title="Graphe cursus de %(titreannee)s" % sem,
|
page_title="Graphe cursus de %(titreannee)s" % sem,
|
||||||
no_side_bar=True,
|
no_side_bar=True,
|
||||||
),
|
),
|
||||||
"""<h2 class="formsemestre">Cursus des étudiants de ce semestre</h2>""",
|
"""<h2 class="formsemestre">Cursus des étudiants de ce semestre</h2>""",
|
||||||
doc,
|
doc,
|
||||||
"<p>%d étudiants sélectionnés</p>" % len(etuds),
|
f"<p>{len(etuds)} étudiants sélectionnés</p>",
|
||||||
_gen_form_selectetuds(
|
_gen_form_selectetuds(
|
||||||
formsemestre_id,
|
formsemestre_id,
|
||||||
|
groups_infos=groups_infos,
|
||||||
only_primo=only_primo,
|
only_primo=only_primo,
|
||||||
bac=bac,
|
bac=bac,
|
||||||
bacspecialite=bacspecialite,
|
bacspecialite=bacspecialite,
|
||||||
|
@ -1743,6 +1781,10 @@ def formsemestre_graph_cursus(
|
||||||
passant d'un semestre à l'autre (s'il y en a moins de {MAX_ETUD_IN_DESCR}, vous
|
passant d'un semestre à l'autre (s'il y en a moins de {MAX_ETUD_IN_DESCR}, vous
|
||||||
pouvez visualiser leurs noms en passant le curseur sur le chiffre).
|
pouvez visualiser leurs noms en passant le curseur sur le chiffre).
|
||||||
</p>
|
</p>
|
||||||
|
<p class="help">
|
||||||
|
Le menu <em>Restreindre au(x) groupe(s)</em> permet de restreindre l'étude aux
|
||||||
|
étudiants appartenant aux groupes indiqués <em>dans le semestre d'origine</em>.
|
||||||
|
</p>
|
||||||
""",
|
""",
|
||||||
html_sco_header.sco_footer(),
|
html_sco_header.sco_footer(),
|
||||||
]
|
]
|
||||||
|
|
|
@ -51,7 +51,24 @@ SCO_ROLES_DEFAULTS = {
|
||||||
p.UsersView,
|
p.UsersView,
|
||||||
p.ViewEtudData,
|
p.ViewEtudData,
|
||||||
),
|
),
|
||||||
# Rôles pour l'application relations entreprises
|
# LecteurAPI peut utiliser l'API en lecture
|
||||||
|
"LecteurAPI": (p.ScoView,),
|
||||||
|
"Observateur": (p.Observateur,),
|
||||||
|
# RespPE est le responsable poursuites d'études
|
||||||
|
# il peut ajouter des tags sur les formations:
|
||||||
|
# (doit avoir un rôle Ens en plus !)
|
||||||
|
"RespPe": (p.EditFormationTags,),
|
||||||
|
# Super Admin est un root: création/suppression de départements
|
||||||
|
# _tous_ les droits
|
||||||
|
# Afin d'avoir tous les droits, il ne doit pas être asscoié à un département
|
||||||
|
"SuperAdmin": p.ALL_PERMISSIONS,
|
||||||
|
}
|
||||||
|
|
||||||
|
# Rôles pour l'application relations entreprises
|
||||||
|
# séparés pour pouvoir les réinitialiser lors de l'activation du module Entreprises
|
||||||
|
# Note: Admin (chef de dept n'a par défaut aucun rôle lié à ce module)
|
||||||
|
|
||||||
|
SCO_ROLES_ENTREPRISES_DEFAULT = {
|
||||||
# ObservateurEntreprise est un observateur de l'application entreprise
|
# ObservateurEntreprise est un observateur de l'application entreprise
|
||||||
"ObservateurEntreprise": (p.RelationsEntrepView,),
|
"ObservateurEntreprise": (p.RelationsEntrepView,),
|
||||||
# UtilisateurEntreprise est un utilisateur de l'application entreprise (droit de modification)
|
# UtilisateurEntreprise est un utilisateur de l'application entreprise (droit de modification)
|
||||||
|
@ -70,19 +87,10 @@ SCO_ROLES_DEFAULTS = {
|
||||||
p.RelationsEntrepValidate,
|
p.RelationsEntrepValidate,
|
||||||
p.RelationsEntrepViewCorrs,
|
p.RelationsEntrepViewCorrs,
|
||||||
),
|
),
|
||||||
# LecteurAPI peut utiliser l'API en lecture
|
|
||||||
"LecteurAPI": (p.ScoView,),
|
|
||||||
"Observateur": (p.Observateur,),
|
|
||||||
# RespPE est le responsable poursuites d'études
|
|
||||||
# il peut ajouter des tags sur les formations:
|
|
||||||
# (doit avoir un rôle Ens en plus !)
|
|
||||||
"RespPe": (p.EditFormationTags,),
|
|
||||||
# Super Admin est un root: création/suppression de départements
|
|
||||||
# _tous_ les droits
|
|
||||||
# Afin d'avoir tous les droits, il ne doit pas être asscoié à un département
|
|
||||||
"SuperAdmin": p.ALL_PERMISSIONS,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SCO_ROLES_DEFAULTS.update(SCO_ROLES_ENTREPRISES_DEFAULT)
|
||||||
|
|
||||||
# Les rôles accessibles via la page d'admin utilisateurs
|
# Les rôles accessibles via la page d'admin utilisateurs
|
||||||
# - associés à un département:
|
# - associés à un département:
|
||||||
ROLES_ATTRIBUABLES_DEPT = ("Ens", "Secr", "Admin", "RespPe")
|
ROLES_ATTRIBUABLES_DEPT = ("Ens", "Secr", "Admin", "RespPe")
|
||||||
|
|
|
@ -68,7 +68,6 @@ from app.scodoc import sco_excel
|
||||||
from app.scodoc import sco_formsemestre_inscriptions
|
from app.scodoc import sco_formsemestre_inscriptions
|
||||||
from app.scodoc import sco_groups
|
from app.scodoc import sco_groups
|
||||||
from app.scodoc import sco_groups_view
|
from app.scodoc import sco_groups_view
|
||||||
from app.scodoc import sco_permissions_check
|
|
||||||
from app.scodoc import sco_undo_notes
|
from app.scodoc import sco_undo_notes
|
||||||
import app.scodoc.notesdb as ndb
|
import app.scodoc.notesdb as ndb
|
||||||
from app.scodoc.TrivialFormulator import TrivialFormulator, TF
|
from app.scodoc.TrivialFormulator import TrivialFormulator, TF
|
||||||
|
@ -531,7 +530,7 @@ def notes_add(
|
||||||
|
|
||||||
Return: tuple (etudids_changed, nb_suppress, etudids_with_decision)
|
Return: tuple (etudids_changed, nb_suppress, etudids_with_decision)
|
||||||
"""
|
"""
|
||||||
assert evaluation_id is not None
|
evaluation = Evaluation.get_evaluation(evaluation_id)
|
||||||
now = psycopg2.Timestamp(*time.localtime()[:6])
|
now = psycopg2.Timestamp(*time.localtime()[:6])
|
||||||
|
|
||||||
# Vérifie inscription et valeur note
|
# Vérifie inscription et valeur note
|
||||||
|
@ -541,10 +540,16 @@ def notes_add(
|
||||||
evaluation_id, getallstudents=True, include_demdef=True
|
evaluation_id, getallstudents=True, include_demdef=True
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
# Les étudiants inscrits au semestre ni DEM ni DEF
|
||||||
|
_, etudids_actifs = evaluation.moduleimpl.formsemestre.etudids_actifs()
|
||||||
for etudid, value in notes:
|
for etudid, value in notes:
|
||||||
if check_inscription and (etudid not in inscrits):
|
if check_inscription and (
|
||||||
|
(etudid not in inscrits) or (etudid not in etudids_actifs)
|
||||||
|
):
|
||||||
|
log(f"notes_add: {etudid} non inscrit ou DEM/DEF: aborting")
|
||||||
raise NoteProcessError(f"étudiant {etudid} non inscrit dans ce module")
|
raise NoteProcessError(f"étudiant {etudid} non inscrit dans ce module")
|
||||||
if (value is not None) and not isinstance(value, float):
|
if (value is not None) and not isinstance(value, float):
|
||||||
|
log(f"notes_add: {etudid} valeur de note invalide ({value}): aborting")
|
||||||
raise NoteProcessError(
|
raise NoteProcessError(
|
||||||
f"etudiant {etudid}: valeur de note invalide ({value})"
|
f"etudiant {etudid}: valeur de note invalide ({value})"
|
||||||
)
|
)
|
||||||
|
@ -555,7 +560,6 @@ def notes_add(
|
||||||
cursor = cnx.cursor(cursor_factory=ndb.ScoDocCursor)
|
cursor = cnx.cursor(cursor_factory=ndb.ScoDocCursor)
|
||||||
etudids_changed = []
|
etudids_changed = []
|
||||||
nb_suppress = 0
|
nb_suppress = 0
|
||||||
evaluation: Evaluation = Evaluation.query.get_or_404(evaluation_id)
|
|
||||||
formsemestre: FormSemestre = evaluation.moduleimpl.formsemestre
|
formsemestre: FormSemestre = evaluation.moduleimpl.formsemestre
|
||||||
res: NotesTableCompat = res_sem.load_formsemestre_results(formsemestre)
|
res: NotesTableCompat = res_sem.load_formsemestre_results(formsemestre)
|
||||||
# etudids pour lesquels il y a une decision de jury et que la note change:
|
# etudids pour lesquels il y a une decision de jury et que la note change:
|
||||||
|
@ -888,7 +892,7 @@ def feuille_saisie_notes(evaluation_id, group_ids=[]):
|
||||||
eval_name = f"{evaluation.moduleimpl.module.code}-{indication_date}"
|
eval_name = f"{evaluation.moduleimpl.module.code}-{indication_date}"
|
||||||
|
|
||||||
date_str = (
|
date_str = (
|
||||||
f"""du {evaluation.date_debut.strftime("%d/%m/%Y")}"""
|
f"""du {evaluation.date_debut.strftime(scu.DATE_FMT)}"""
|
||||||
if evaluation.date_debut
|
if evaluation.date_debut
|
||||||
else "(sans date)"
|
else "(sans date)"
|
||||||
)
|
)
|
||||||
|
|
|
@ -47,12 +47,11 @@ from app import db, log
|
||||||
from app.models import Identite
|
from app.models import Identite
|
||||||
import app.scodoc.sco_utils as scu
|
import app.scodoc.sco_utils as scu
|
||||||
from app.scodoc.TrivialFormulator import TrivialFormulator
|
from app.scodoc.TrivialFormulator import TrivialFormulator
|
||||||
from app.scodoc.sco_exceptions import ScoValueError
|
from app.scodoc.sco_exceptions import ScoPDFFormatError, ScoValueError
|
||||||
from app.scodoc.sco_pdf import SU
|
from app.scodoc.sco_pdf import SU
|
||||||
from app.scodoc import html_sco_header
|
from app.scodoc import html_sco_header
|
||||||
from app.scodoc import htmlutils
|
from app.scodoc import htmlutils
|
||||||
from app.scodoc import sco_import_etuds
|
from app.scodoc import sco_import_etuds
|
||||||
from app.scodoc import sco_etud
|
|
||||||
from app.scodoc import sco_excel
|
from app.scodoc import sco_excel
|
||||||
from app.scodoc import sco_groups_view
|
from app.scodoc import sco_groups_view
|
||||||
from app.scodoc import sco_pdf
|
from app.scodoc import sco_pdf
|
||||||
|
@ -246,8 +245,9 @@ def _trombino_zip(groups_infos):
|
||||||
|
|
||||||
|
|
||||||
# Copy photos from portal to ScoDoc
|
# Copy photos from portal to ScoDoc
|
||||||
def trombino_copy_photos(group_ids=[], dialog_confirmed=False):
|
def trombino_copy_photos(group_ids=None, dialog_confirmed=False):
|
||||||
"Copy photos from portal to ScoDoc (overwriting local copy)"
|
"Copy photos from portal to ScoDoc (overwriting local copy)"
|
||||||
|
group_ids = [] if group_ids is None else group_ids
|
||||||
groups_infos = sco_groups_view.DisplayedGroupsInfos(group_ids)
|
groups_infos = sco_groups_view.DisplayedGroupsInfos(group_ids)
|
||||||
back_url = "groups_view?%s&curtab=tab-photos" % groups_infos.groups_query_args
|
back_url = "groups_view?%s&curtab=tab-photos" % groups_infos.groups_query_args
|
||||||
|
|
||||||
|
@ -387,7 +387,10 @@ def _trombino_pdf(groups_infos):
|
||||||
preferences=sco_preferences.SemPreferences(sem["formsemestre_id"]),
|
preferences=sco_preferences.SemPreferences(sem["formsemestre_id"]),
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
document.build(objects)
|
try:
|
||||||
|
document.build(objects)
|
||||||
|
except (ValueError, KeyError, reportlab.platypus.doctemplate.LayoutError) as exc:
|
||||||
|
raise ScoPDFFormatError(str(exc)) from exc
|
||||||
report.seek(0)
|
report.seek(0)
|
||||||
return send_file(
|
return send_file(
|
||||||
report,
|
report,
|
||||||
|
@ -464,7 +467,10 @@ def _listeappel_photos_pdf(groups_infos):
|
||||||
preferences=sco_preferences.SemPreferences(sem["formsemestre_id"]),
|
preferences=sco_preferences.SemPreferences(sem["formsemestre_id"]),
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
document.build(objects)
|
try:
|
||||||
|
document.build(objects)
|
||||||
|
except (ValueError, KeyError, reportlab.platypus.doctemplate.LayoutError) as exc:
|
||||||
|
raise ScoPDFFormatError(str(exc)) from exc
|
||||||
data = report.getvalue()
|
data = report.getvalue()
|
||||||
|
|
||||||
return scu.sendPDFFile(data, filename)
|
return scu.sendPDFFile(data, filename)
|
||||||
|
|
|
@ -31,7 +31,7 @@
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import io
|
import io
|
||||||
|
import reportlab
|
||||||
from reportlab.lib import colors
|
from reportlab.lib import colors
|
||||||
from reportlab.lib.colors import black
|
from reportlab.lib.colors import black
|
||||||
from reportlab.lib.pagesizes import A4, A3
|
from reportlab.lib.pagesizes import A4, A3
|
||||||
|
@ -277,10 +277,12 @@ def pdf_trombino_tours(
|
||||||
preferences=sco_preferences.SemPreferences(),
|
preferences=sco_preferences.SemPreferences(),
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
document.build(objects)
|
document.build(objects)
|
||||||
except (ValueError, KeyError) as exc:
|
except (ValueError, KeyError, reportlab.platypus.doctemplate.LayoutError) as exc:
|
||||||
raise ScoPDFFormatError(str(exc)) from exc
|
raise ScoPDFFormatError(str(exc)) from exc
|
||||||
|
|
||||||
data = report.getvalue()
|
data = report.getvalue()
|
||||||
|
|
||||||
return scu.sendPDFFile(data, filename)
|
return scu.sendPDFFile(data, filename)
|
||||||
|
@ -470,7 +472,10 @@ def pdf_feuille_releve_absences(
|
||||||
preferences=sco_preferences.SemPreferences(),
|
preferences=sco_preferences.SemPreferences(),
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
document.build(objects)
|
try:
|
||||||
|
document.build(objects)
|
||||||
|
except (ValueError, KeyError, reportlab.platypus.doctemplate.LayoutError) as exc:
|
||||||
|
raise ScoPDFFormatError(str(exc)) from exc
|
||||||
data = report.getvalue()
|
data = report.getvalue()
|
||||||
|
|
||||||
return scu.sendPDFFile(data, filename)
|
return scu.sendPDFFile(data, filename)
|
||||||
|
|
|
@ -109,6 +109,38 @@ ETATS_INSCRIPTION = {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
def convert_fr_date(date_str: str, allow_iso=True) -> datetime.datetime:
|
||||||
|
"""Converti une date saisie par un humain français avant 2070
|
||||||
|
en un objet datetime.
|
||||||
|
12/2/1972 => 1972-02-12, 12/2/72 => 1972-02-12, mais 12/2/24 => 2024-02-12
|
||||||
|
Le pivot est 70.
|
||||||
|
ScoValueError si date invalide.
|
||||||
|
"""
|
||||||
|
try:
|
||||||
|
return datetime.datetime.strptime(date_str, DATE_FMT)
|
||||||
|
except ValueError:
|
||||||
|
# Try to add century ?
|
||||||
|
m = re.match(r"^(\d{1,2})/(\d{1,2})/(\d\d)$", date_str)
|
||||||
|
if m:
|
||||||
|
year = int(m.group(3))
|
||||||
|
if year < 70:
|
||||||
|
year += 2000
|
||||||
|
else:
|
||||||
|
year += 1900
|
||||||
|
try:
|
||||||
|
return datetime.datetime.strptime(
|
||||||
|
f"{m.group(1)}/{m.group(2)}/{year}", DATE_FMT
|
||||||
|
)
|
||||||
|
except ValueError:
|
||||||
|
pass
|
||||||
|
if allow_iso:
|
||||||
|
try:
|
||||||
|
return datetime.datetime.fromisoformat(date_str)
|
||||||
|
except ValueError as exc:
|
||||||
|
raise ScoValueError("Date (j/m/a or ISO) invalide") from exc
|
||||||
|
raise ScoValueError("Date (j/m/a) invalide")
|
||||||
|
|
||||||
|
|
||||||
def print_progress_bar(
|
def print_progress_bar(
|
||||||
iteration,
|
iteration,
|
||||||
total,
|
total,
|
||||||
|
@ -170,6 +202,7 @@ class BiDirectionalEnum(Enum):
|
||||||
"""Permet la recherche inverse d'un enum
|
"""Permet la recherche inverse d'un enum
|
||||||
Condition : les clés et les valeurs doivent être uniques
|
Condition : les clés et les valeurs doivent être uniques
|
||||||
les clés doivent être en MAJUSCULES
|
les clés doivent être en MAJUSCULES
|
||||||
|
=> (respect de la convention des constantes)
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
|
@ -181,10 +214,17 @@ class BiDirectionalEnum(Enum):
|
||||||
return attr.upper() in cls._member_names_
|
return attr.upper() in cls._member_names_
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def all(cls, keys=True):
|
def all(cls, keys=True) -> tuple[str | object]:
|
||||||
"""Retourne toutes les clés de l'enum"""
|
"""Retourne toutes les clés de l'enum (en minuscules) ou les valeurs"""
|
||||||
# pylint: disable-next=no-member
|
return (
|
||||||
return cls._member_names_ if keys else list(cls._value2member_map_.keys())
|
tuple(
|
||||||
|
k.lower()
|
||||||
|
# pylint: disable-next=no-member
|
||||||
|
for k in cls._member_names_
|
||||||
|
) # renvoie les clés en minuscules
|
||||||
|
if keys
|
||||||
|
else tuple(cls._value2member_map_.keys()) # renvoie les valeurs
|
||||||
|
)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def get(cls, attr: str, default: any = None):
|
def get(cls, attr: str, default: any = None):
|
||||||
|
@ -510,6 +550,11 @@ MONTH_NAMES = (
|
||||||
)
|
)
|
||||||
DAY_NAMES = ("lundi", "mardi", "mercredi", "jeudi", "vendredi", "samedi", "dimanche")
|
DAY_NAMES = ("lundi", "mardi", "mercredi", "jeudi", "vendredi", "samedi", "dimanche")
|
||||||
|
|
||||||
|
TIME_FMT = "%H:%M" # affichage des heures
|
||||||
|
DATE_FMT = "%d/%m/%Y" # affichage des dates
|
||||||
|
DATEATIME_FMT = DATE_FMT + " à " + TIME_FMT
|
||||||
|
DATETIME_FMT = DATE_FMT + " " + TIME_FMT
|
||||||
|
|
||||||
|
|
||||||
def fmt_note(val, note_max=None, keep_numeric=False):
|
def fmt_note(val, note_max=None, keep_numeric=False):
|
||||||
"""conversion note en str pour affichage dans tables HTML ou PDF.
|
"""conversion note en str pour affichage dans tables HTML ou PDF.
|
||||||
|
@ -740,51 +785,6 @@ BULLETINS_VERSIONS_BUT = BULLETINS_VERSIONS | {
|
||||||
"butcourt": "Version courte spéciale BUT"
|
"butcourt": "Version courte spéciale BUT"
|
||||||
}
|
}
|
||||||
|
|
||||||
# ----- Support for ScoDoc7 compatibility
|
|
||||||
|
|
||||||
|
|
||||||
def ScoURL():
|
|
||||||
"""base URL for this sco instance.
|
|
||||||
e.g. https://scodoc.xxx.fr/ScoDoc/DEPT/Scolarite
|
|
||||||
= page accueil département
|
|
||||||
"""
|
|
||||||
return url_for("scolar.index_html", scodoc_dept=g.scodoc_dept)[
|
|
||||||
: -len("/index_html")
|
|
||||||
]
|
|
||||||
|
|
||||||
|
|
||||||
def NotesURL():
|
|
||||||
"""URL of Notes
|
|
||||||
e.g. https://scodoc.xxx.fr/ScoDoc/DEPT/Scolarite/Notes
|
|
||||||
= url de base des méthodes de notes
|
|
||||||
(page accueil programmes).
|
|
||||||
"""
|
|
||||||
return url_for("notes.index_html", scodoc_dept=g.scodoc_dept)[: -len("/index_html")]
|
|
||||||
|
|
||||||
|
|
||||||
def AbsencesURL():
|
|
||||||
"""URL of Absences"""
|
|
||||||
return url_for("absences.index_html", scodoc_dept=g.scodoc_dept)[
|
|
||||||
: -len("/index_html")
|
|
||||||
]
|
|
||||||
|
|
||||||
|
|
||||||
def AssiduitesURL():
|
|
||||||
"""URL of Assiduités"""
|
|
||||||
return url_for("assiduites.bilan_dept", scodoc_dept=g.scodoc_dept)[
|
|
||||||
: -len("/BilanDept")
|
|
||||||
]
|
|
||||||
|
|
||||||
|
|
||||||
def UsersURL():
|
|
||||||
"""URL of Users
|
|
||||||
e.g. https://scodoc.xxx.fr/ScoDoc/DEPT/Scolarite/Users
|
|
||||||
= url de base des requêtes ZScoUsers
|
|
||||||
et page accueil users
|
|
||||||
"""
|
|
||||||
return url_for("users.index_html", scodoc_dept=g.scodoc_dept)[: -len("/index_html")]
|
|
||||||
|
|
||||||
|
|
||||||
# ---- Simple python utilities
|
# ---- Simple python utilities
|
||||||
|
|
||||||
|
|
||||||
|
@ -1027,9 +1027,9 @@ def bul_filename(formsemestre, etud, prefix="bul"):
|
||||||
|
|
||||||
def flash_errors(form):
|
def flash_errors(form):
|
||||||
"""Flashes form errors (version sommaire)"""
|
"""Flashes form errors (version sommaire)"""
|
||||||
for field, errors in form.errors.items():
|
for field, _ in form.errors.items():
|
||||||
flash(
|
flash(
|
||||||
"Erreur: voir le champ %s" % (getattr(form, field).label.text,),
|
f"Erreur: voir le champ {getattr(form, field).label.text}",
|
||||||
"warning",
|
"warning",
|
||||||
)
|
)
|
||||||
# see https://getbootstrap.com/docs/4.0/components/alerts/
|
# see https://getbootstrap.com/docs/4.0/components/alerts/
|
||||||
|
@ -1442,7 +1442,16 @@ def icontag(name, file_format="png", no_size=False, **attrs):
|
||||||
|
|
||||||
|
|
||||||
ICON_PDF = icontag("pdficon16x20_img", title="Version PDF")
|
ICON_PDF = icontag("pdficon16x20_img", title="Version PDF")
|
||||||
ICON_XLS = icontag("xlsicon_img", title="Version tableur")
|
ICON_XLS = icontag("xlsicon_img", title="Export tableur (xlsx)")
|
||||||
|
|
||||||
|
ICON_PUBLISHED = """<img src="/ScoDoc/static/icons/eye_visible_green.svg"
|
||||||
|
width="24" height="19" border="0"
|
||||||
|
title="Bulletins publiés sur la passerelle étudiants"
|
||||||
|
alt="Bulletins publiés sur la passerelle étudiants" />"""
|
||||||
|
ICON_HIDDEN = """<img src="/ScoDoc/static/icons/eye_hidden.svg"
|
||||||
|
width="24" height="19" border="0"
|
||||||
|
title="Bulletins NON publiés sur la passerelle étudiants"
|
||||||
|
alt="Bulletins NON publiés sur la passerelle étudiants" />"""
|
||||||
|
|
||||||
# HTML emojis
|
# HTML emojis
|
||||||
EMO_WARNING = "⚠️" # warning /!\
|
EMO_WARNING = "⚠️" # warning /!\
|
||||||
|
@ -1627,6 +1636,12 @@ def is_entreprises_enabled():
|
||||||
return ScoDocSiteConfig.is_entreprises_enabled()
|
return ScoDocSiteConfig.is_entreprises_enabled()
|
||||||
|
|
||||||
|
|
||||||
|
def is_passerelle_disabled():
|
||||||
|
from app.models import ScoDocSiteConfig
|
||||||
|
|
||||||
|
return ScoDocSiteConfig.is_passerelle_disabled()
|
||||||
|
|
||||||
|
|
||||||
def is_assiduites_module_forced(
|
def is_assiduites_module_forced(
|
||||||
formsemestre_id: int = None, dept_id: int = None
|
formsemestre_id: int = None, dept_id: int = None
|
||||||
) -> bool:
|
) -> bool:
|
||||||
|
|
|
@ -6,7 +6,9 @@
|
||||||
--color-justi: #29b990;
|
--color-justi: #29b990;
|
||||||
--color-justi-clair: #48f6ff;
|
--color-justi-clair: #48f6ff;
|
||||||
--color-justi-attente: yellow;
|
--color-justi-attente: yellow;
|
||||||
--color-justi-attente-stripe: #29b990; /* pink #fa25cb; */ /* #789dbb;*/
|
--color-justi-attente-stripe: #29b990;
|
||||||
|
/* pink #fa25cb; */
|
||||||
|
/* #789dbb;*/
|
||||||
--color-justi-modifie: rgb(255, 230, 0);
|
--color-justi-modifie: rgb(255, 230, 0);
|
||||||
--color-justi-invalide: #a84476;
|
--color-justi-invalide: #a84476;
|
||||||
--color-nonwork: #badfff;
|
--color-nonwork: #badfff;
|
||||||
|
@ -28,27 +30,23 @@
|
||||||
--color-defaut-dark: #444;
|
--color-defaut-dark: #444;
|
||||||
--color-default-text: #1f1f1f;
|
--color-default-text: #1f1f1f;
|
||||||
|
|
||||||
--motif-justi: repeating-linear-gradient(
|
--motif-justi: repeating-linear-gradient(135deg,
|
||||||
135deg,
|
transparent,
|
||||||
transparent,
|
transparent 4px,
|
||||||
transparent 4px,
|
var(--color-justi) 4px,
|
||||||
var(--color-justi) 4px,
|
var(--color-justi) 8px);
|
||||||
var(--color-justi) 8px
|
--motif-justi-invalide: repeating-linear-gradient(-135deg,
|
||||||
);
|
transparent,
|
||||||
--motif-justi-invalide: repeating-linear-gradient(
|
transparent 4px,
|
||||||
-135deg,
|
var(--color-justi-invalide) 4px,
|
||||||
transparent,
|
var(--color-justi-invalide) 8px);
|
||||||
transparent 4px,
|
|
||||||
var(--color-justi-invalide) 4px,
|
|
||||||
var(--color-justi-invalide) 8px
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
* {
|
* {
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
}
|
}
|
||||||
|
|
||||||
.selectors > * {
|
.selectors>* {
|
||||||
margin: 10px 0;
|
margin: 10px 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -339,6 +337,11 @@
|
||||||
background-image: url(../icons/retard.svg);
|
background-image: url(../icons/retard.svg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.rbtn.conflit::before {
|
||||||
|
background-color: var(--color-absent);
|
||||||
|
background-image: url(../icons/solveur_conflits.svg);
|
||||||
|
}
|
||||||
|
|
||||||
.rbtn:checked:before {
|
.rbtn:checked:before {
|
||||||
outline: 5px solid var(--color-primary);
|
outline: 5px solid var(--color-primary);
|
||||||
border-radius: 50%;
|
border-radius: 50%;
|
||||||
|
@ -405,29 +408,11 @@
|
||||||
.assiduite {
|
.assiduite {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
top: 20px;
|
top: 20px;
|
||||||
cursor: pointer;
|
|
||||||
border-radius: 4px;
|
border-radius: 4px;
|
||||||
z-index: 10;
|
z-index: 10;
|
||||||
height: 100px;
|
height: 100px;
|
||||||
padding: 4px;
|
padding: 4px;
|
||||||
}
|
border: 1px solid #444;
|
||||||
|
|
||||||
.assiduite-info {
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
height: 100%;
|
|
||||||
justify-content: space-between;
|
|
||||||
}
|
|
||||||
|
|
||||||
.assiduite-id,
|
|
||||||
.assiduite-period,
|
|
||||||
.assiduite-state,
|
|
||||||
.assiduite-user_id {
|
|
||||||
font-size: 12px;
|
|
||||||
white-space: nowrap;
|
|
||||||
overflow: hidden;
|
|
||||||
text-overflow: ellipsis;
|
|
||||||
text-align: center;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.assiduites-container {
|
.assiduites-container {
|
||||||
|
@ -438,7 +423,7 @@
|
||||||
margin-bottom: 10px;
|
margin-bottom: 10px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.action-buttons {
|
.modal-buttons {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
display: flex;
|
display: flex;
|
||||||
|
@ -449,48 +434,38 @@
|
||||||
bottom: 5%;
|
bottom: 5%;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Ajout de la classe CSS pour la bordure en pointillés */
|
|
||||||
.assiduite.selected {
|
|
||||||
border: 2px dashed black;
|
|
||||||
}
|
|
||||||
|
|
||||||
.assiduite-special {
|
.assiduite-special {
|
||||||
height: 120px;
|
height: 120px;
|
||||||
position: absolute;
|
position: absolute;
|
||||||
z-index: 5;
|
z-index: 5;
|
||||||
border: 2px solid #000;
|
border: 5px solid var(--color-primary);
|
||||||
background-color: rgba(36, 36, 36, 0.25);
|
|
||||||
background-image: repeating-linear-gradient(
|
|
||||||
135deg,
|
|
||||||
transparent,
|
|
||||||
transparent 5px,
|
|
||||||
rgba(81, 81, 81, 0.61) 5px,
|
|
||||||
rgba(81, 81, 81, 0.61) 10px
|
|
||||||
);
|
|
||||||
border-radius: 5px;
|
border-radius: 5px;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*<== Info sur l'assiduité sélectionnée ==>*/
|
.assiduite .assiduite-bubble {
|
||||||
.modal-assiduite-content {
|
top: 5px;
|
||||||
background-color: #fefefe;
|
left: 50%;
|
||||||
margin: 5% auto;
|
transform: translateX(-50%);
|
||||||
padding: 20px;
|
|
||||||
border: 1px solid #888;
|
|
||||||
width: max-content;
|
|
||||||
position: relative;
|
|
||||||
border-radius: 10px;
|
|
||||||
display: none;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.modal-assiduite-content.show {
|
.assiduite-actions {
|
||||||
display: block;
|
position: absolute;
|
||||||
|
right: 0;
|
||||||
|
margin: 5px;
|
||||||
|
top: 0;
|
||||||
|
font-size: 16px;
|
||||||
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
|
|
||||||
.modal-assiduite-content .infos {
|
.action-buttons {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
justify-content: center;
|
||||||
justify-content: space-evenly;
|
align-items: center;
|
||||||
align-items: flex-start;
|
flex-wrap: wrap;
|
||||||
|
gap: 2px;
|
||||||
|
height: 100%;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*<=== Mass Action ==>*/
|
/*<=== Mass Action ==>*/
|
||||||
|
@ -500,55 +475,18 @@
|
||||||
justify-content: flex-start;
|
justify-content: flex-start;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
margin: 2% 0;
|
gap: 4px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.mass-selection span {
|
|
||||||
margin: 0 1%;
|
|
||||||
}
|
|
||||||
|
|
||||||
.mass-selection .rbtn {
|
.mass-selection .rbtn {
|
||||||
background-color: transparent;
|
background-color: transparent;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*<== Loader ==> */
|
.mass-selection em {
|
||||||
|
margin-left: 16px;
|
||||||
.loader-container {
|
|
||||||
display: none;
|
|
||||||
/* Cacher le loader par défaut */
|
|
||||||
position: fixed;
|
|
||||||
top: 0;
|
|
||||||
left: 0;
|
|
||||||
right: 0;
|
|
||||||
bottom: 0;
|
|
||||||
background-color: rgba(0, 0, 0, 0.5);
|
|
||||||
/* Fond semi-transparent pour bloquer les clics */
|
|
||||||
z-index: 9999;
|
|
||||||
/* Placer le loader au-dessus de tout le contenu */
|
|
||||||
}
|
|
||||||
|
|
||||||
.loader {
|
|
||||||
border: 6px solid #f3f3f3;
|
|
||||||
border-radius: 50%;
|
|
||||||
border-top: 6px solid var(--color-primary);
|
|
||||||
width: 60px;
|
|
||||||
height: 60px;
|
|
||||||
position: absolute;
|
|
||||||
top: 50%;
|
|
||||||
left: 50%;
|
|
||||||
transform: translate(-50%, -50%);
|
|
||||||
animation: spin 2s linear infinite;
|
|
||||||
}
|
|
||||||
|
|
||||||
@keyframes spin {
|
|
||||||
0% {
|
|
||||||
transform: translate(-50%, -50%) rotate(0deg);
|
|
||||||
}
|
|
||||||
|
|
||||||
100% {
|
|
||||||
transform: translate(-50%, -50%) rotate(360deg);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.fieldsplit {
|
.fieldsplit {
|
||||||
|
@ -569,7 +507,7 @@
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
}
|
}
|
||||||
|
|
||||||
#page-assiduite-content > * {
|
#page-assiduite-content>* {
|
||||||
margin: 1.5% 0;
|
margin: 1.5% 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -643,12 +581,6 @@
|
||||||
border: solid 1px #333;
|
border: solid 1px #333;
|
||||||
}
|
}
|
||||||
|
|
||||||
.assi-liste {
|
|
||||||
border: 1px solid gray;
|
|
||||||
border-radius: 12px;
|
|
||||||
margin-right: 24px;
|
|
||||||
padding: 12px;
|
|
||||||
}
|
|
||||||
#options-tableau label {
|
#options-tableau label {
|
||||||
font-weight: normal;
|
font-weight: normal;
|
||||||
margin-right: 12px;
|
margin-right: 12px;
|
||||||
|
@ -657,15 +589,20 @@
|
||||||
section.assi-form {
|
section.assi-form {
|
||||||
margin-bottom: 12px;
|
margin-bottom: 12px;
|
||||||
}
|
}
|
||||||
|
|
||||||
table.liste_assi td.date {
|
table.liste_assi td.date {
|
||||||
width: 140px;
|
width: 140px;
|
||||||
}
|
}
|
||||||
|
|
||||||
table.liste_assi.dataTable tbody td.date-debut {
|
table.liste_assi.dataTable tbody td.date-debut {
|
||||||
padding-left: 12px;
|
padding-left: 12px;
|
||||||
}
|
}
|
||||||
|
|
||||||
table.liste_assi td.actions {
|
table.liste_assi td.actions {
|
||||||
white-space: nowrap; /* boutons horizontalement */
|
white-space: nowrap;
|
||||||
|
/* boutons horizontalement */
|
||||||
}
|
}
|
||||||
|
|
||||||
table.liste_assi td.actions a:last-child {
|
table.liste_assi td.actions a:last-child {
|
||||||
padding-right: 12px;
|
padding-right: 12px;
|
||||||
}
|
}
|
||||||
|
@ -673,31 +610,146 @@ table.liste_assi td.actions a:last-child {
|
||||||
tr.row-assiduite td {
|
tr.row-assiduite td {
|
||||||
border-bottom: 1px solid grey;
|
border-bottom: 1px solid grey;
|
||||||
}
|
}
|
||||||
|
|
||||||
table.liste_assi tbody tr td.assi-type {
|
table.liste_assi tbody tr td.assi-type {
|
||||||
padding-left: 8px;
|
padding-left: 8px;
|
||||||
padding-right: 4px;
|
padding-right: 4px;
|
||||||
}
|
}
|
||||||
|
|
||||||
tr.row-assiduite.absent td.assi-type {
|
tr.row-assiduite.absent td.assi-type {
|
||||||
background-color: var(--color-absent-clair);
|
background-color: var(--color-absent-clair);
|
||||||
}
|
}
|
||||||
|
|
||||||
tr.row-assiduite.absent.justifiee td.assi-type {
|
tr.row-assiduite.absent.justifiee td.assi-type {
|
||||||
background-color: var(--color-absent-justi);
|
background-color: var(--color-absent-justi);
|
||||||
}
|
}
|
||||||
|
|
||||||
tr.row-assiduite.retard td.assi-type {
|
tr.row-assiduite.retard td.assi-type {
|
||||||
background-color: var(--color-retard);
|
background-color: var(--color-retard);
|
||||||
}
|
}
|
||||||
|
|
||||||
tr.row-assiduite.present td.assi-type {
|
tr.row-assiduite.present td.assi-type {
|
||||||
background-color: var(--color-present);
|
background-color: var(--color-present);
|
||||||
}
|
}
|
||||||
|
|
||||||
tr.row-justificatif.valide td.assi-type {
|
tr.row-justificatif.valide td.assi-type {
|
||||||
background-color: var(--color-justi);
|
background-color: var(--color-justi);
|
||||||
}
|
}
|
||||||
|
|
||||||
tr.row-justificatif.attente td.assi-type {
|
tr.row-justificatif.attente td.assi-type {
|
||||||
background-color: var(--color-justi-attente);
|
background-color: var(--color-justi-attente);
|
||||||
}
|
}
|
||||||
|
|
||||||
tr.row-justificatif.modifie td.assi-type {
|
tr.row-justificatif.modifie td.assi-type {
|
||||||
background-color: var(--color-justi-modifie);
|
background-color: var(--color-justi-modifie);
|
||||||
}
|
}
|
||||||
|
|
||||||
tr.row-justificatif.non_valide td.assi-type {
|
tr.row-justificatif.non_valide td.assi-type {
|
||||||
background-color: var(--color-justi-invalide);
|
background-color: var(--color-justi-invalide);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
|
||||||
|
<== Loader ==>
|
||||||
|
|
||||||
|
*/
|
||||||
|
/* HTML: <div class="loader"></div> */
|
||||||
|
.loader {
|
||||||
|
width: 80px;
|
||||||
|
height: 70px;
|
||||||
|
border: 5px solid #000;
|
||||||
|
padding: 0 8px;
|
||||||
|
box-sizing: border-box;
|
||||||
|
background:
|
||||||
|
linear-gradient(#fff 0 0) 0 0/8px 20px,
|
||||||
|
linear-gradient(#fff 0 0) 100% 0/8px 20px,
|
||||||
|
radial-gradient(farthest-side, #fff 90%, #0000) 0 5px/8px 8px content-box,
|
||||||
|
#000;
|
||||||
|
background-repeat: no-repeat;
|
||||||
|
animation: l3 2s infinite linear;
|
||||||
|
}
|
||||||
|
|
||||||
|
@keyframes l3 {
|
||||||
|
25% {
|
||||||
|
background-position: 0 0, 100% 100%, 100% calc(100% - 5px)
|
||||||
|
}
|
||||||
|
|
||||||
|
50% {
|
||||||
|
background-position: 0 100%, 100% 100%, 0 calc(100% - 5px)
|
||||||
|
}
|
||||||
|
|
||||||
|
75% {
|
||||||
|
background-position: 0 100%, 100% 0, 100% 5px
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#loader {
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
position: fixed;
|
||||||
|
top: 50%;
|
||||||
|
left: 50%;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
transform: translate(-50%, -50%);
|
||||||
|
z-index: 1000;
|
||||||
|
background-color: rgba(255, 255, 255, 0.8);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <== Couleurs ==>
|
||||||
|
*/
|
||||||
|
|
||||||
|
.color.present {
|
||||||
|
background-color: var(--color-present) !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.color.absent {
|
||||||
|
background-color: var(--color-absent) !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.color.absent.est_just {
|
||||||
|
background-color: var(--color-absent-justi) !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.color.retard {
|
||||||
|
background-color: var(--color-retard) !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.color.retard.est_just {
|
||||||
|
background-color: var(--color-retard-justi) !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.color.nonwork {
|
||||||
|
background-color: var(--color-nonwork) !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.color {
|
||||||
|
background-color: var(--color-defaut) !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.color.invalide {
|
||||||
|
background-color: var(--color-justi-invalide) !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.color.attente {
|
||||||
|
background: repeating-linear-gradient(to bottom,
|
||||||
|
var(--color-justi-attente-stripe) 0px,
|
||||||
|
var(--color-justi-attente-stripe) 4px,
|
||||||
|
var(--color-justi-attente) 4px,
|
||||||
|
var(--color-justi-attente) 7px) !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.color.est_just {
|
||||||
|
background-color: var(--color-justi) !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
#gtrcontent .pdp {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
#gtrcontent[data-pdp="true"] .pdp {
|
||||||
|
display: block;
|
||||||
|
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue