2020-12-26 00:11:55 +01:00
|
|
|
# -*- mode: python -*-
|
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
2020-12-28 21:49:53 +01:00
|
|
|
"""Test de base de ScoDoc
|
2020-12-26 00:11:55 +01:00
|
|
|
|
2020-12-28 21:49:53 +01:00
|
|
|
Création 10 étudiants, formation, semestre, inscription etudiant, creation 1 evaluation, saisie 10 notes.
|
2020-12-26 00:11:55 +01:00
|
|
|
|
|
|
|
Utiliser comme:
|
2021-06-24 10:59:03 +02:00
|
|
|
flask test-interactive scotests/test_basic.py
|
2020-12-26 00:11:55 +01:00
|
|
|
|
|
|
|
"""
|
2020-12-27 13:45:24 +01:00
|
|
|
import random
|
|
|
|
|
2021-06-24 10:59:03 +02:00
|
|
|
from flask import g
|
|
|
|
|
|
|
|
from app import decorators
|
2020-12-28 21:49:53 +01:00
|
|
|
import scotests.sco_fake_gen as sco_fake_gen # pylint: disable=import-error
|
2021-06-24 10:59:03 +02:00
|
|
|
from app.scodoc import sco_utils as scu
|
|
|
|
from app.scodoc import sco_abs
|
|
|
|
from app.scodoc import sco_abs_views
|
|
|
|
from app.scodoc import sco_bulletins
|
|
|
|
from app.scodoc import sco_evaluations
|
|
|
|
from app.scodoc import sco_codes_parcours
|
|
|
|
from app.scodoc import sco_parcours_dut
|
|
|
|
from app.scodoc import sco_formsemestre_validation
|
|
|
|
|
|
|
|
|
|
|
|
context = sco_fake_gen.Sco8Context()
|
|
|
|
g.scodoc_dept = "TEST00"
|
|
|
|
|
|
|
|
G = sco_fake_gen.ScoFake(context)
|
2020-12-27 13:45:24 +01:00
|
|
|
G.verbose = False
|
|
|
|
|
|
|
|
# --- Création d'étudiants
|
|
|
|
etuds = [G.create_etud(code_nip=None) for _ in range(10)]
|
|
|
|
|
|
|
|
# --- Création d'une formation
|
|
|
|
f = G.create_formation(acronyme="")
|
|
|
|
ue = G.create_ue(formation_id=f["formation_id"], acronyme="TST1", titre="ue test")
|
|
|
|
mat = G.create_matiere(ue_id=ue["ue_id"], titre="matière test")
|
|
|
|
mod = G.create_module(
|
|
|
|
matiere_id=mat["matiere_id"],
|
|
|
|
code="TSM1",
|
|
|
|
coefficient=1.0,
|
|
|
|
titre="module test",
|
|
|
|
ue_id=ue["ue_id"], # faiblesse de l'API
|
|
|
|
formation_id=f["formation_id"], # faiblesse de l'API
|
|
|
|
)
|
|
|
|
|
|
|
|
# --- Mise place d'un semestre
|
|
|
|
sem = G.create_formsemestre(
|
|
|
|
formation_id=f["formation_id"],
|
|
|
|
semestre_id=1,
|
|
|
|
date_debut="01/01/2020",
|
|
|
|
date_fin="30/06/2020",
|
|
|
|
)
|
|
|
|
|
|
|
|
mi = G.create_moduleimpl(
|
|
|
|
module_id=mod["module_id"],
|
|
|
|
formsemestre_id=sem["formsemestre_id"],
|
|
|
|
responsable_id="bach",
|
|
|
|
)
|
|
|
|
|
|
|
|
# --- Inscription des étudiants
|
|
|
|
for etud in etuds:
|
|
|
|
G.inscrit_etudiant(sem, etud)
|
|
|
|
|
|
|
|
# --- Creation évaluation
|
|
|
|
e = G.create_evaluation(
|
|
|
|
moduleimpl_id=mi["moduleimpl_id"],
|
|
|
|
jour="01/01/2020",
|
|
|
|
description="evaluation test",
|
|
|
|
coefficient=1.0,
|
|
|
|
)
|
2020-12-26 00:11:55 +01:00
|
|
|
|
2021-03-02 23:53:43 +01:00
|
|
|
# --- Saisie toutes les notes de l'évaluation
|
2020-12-27 13:45:24 +01:00
|
|
|
for etud in etuds:
|
|
|
|
nb_changed, nb_suppress, existing_decisions = G.create_note(
|
|
|
|
evaluation=e, etud=etud, note=float(random.randint(0, 20))
|
|
|
|
)
|
2021-02-04 23:16:18 +01:00
|
|
|
|
2021-03-02 23:53:43 +01:00
|
|
|
# --- Vérifie que les notes sont prises en compte:
|
|
|
|
b = sco_bulletins.formsemestre_bulletinetud_dict(
|
2021-06-24 10:59:03 +02:00
|
|
|
context, sem["formsemestre_id"], etud["etudid"], REQUEST=REQUEST
|
2021-03-02 23:53:43 +01:00
|
|
|
)
|
|
|
|
# Toute les notes sont saisies, donc eval complète
|
2021-06-24 10:59:03 +02:00
|
|
|
etat = sco_evaluations.do_evaluation_etat(context, e["evaluation_id"])
|
2021-03-02 23:53:43 +01:00
|
|
|
assert etat["evalcomplete"]
|
|
|
|
# Un seul module, donc moy gen == note module
|
|
|
|
assert b["ues"][0]["cur_moy_ue_txt"] == b["ues"][0]["modules"][0]["mod_moy_txt"]
|
|
|
|
# Note au module égale à celle de l'éval
|
|
|
|
assert (
|
|
|
|
b["ues"][0]["modules"][0]["mod_moy_txt"]
|
|
|
|
== b["ues"][0]["modules"][0]["evaluations"][0]["note_txt"]
|
|
|
|
)
|
|
|
|
|
|
|
|
# --- Une autre évaluation
|
|
|
|
e2 = G.create_evaluation(
|
|
|
|
moduleimpl_id=mi["moduleimpl_id"],
|
|
|
|
jour="02/01/2020",
|
|
|
|
description="evaluation test 2",
|
|
|
|
coefficient=1.0,
|
|
|
|
)
|
|
|
|
# Saisie les notes des 5 premiers étudiants:
|
|
|
|
for etud in etuds[:5]:
|
|
|
|
nb_changed, nb_suppress, existing_decisions = G.create_note(
|
|
|
|
evaluation=e2, etud=etud, note=float(random.randint(0, 20))
|
|
|
|
)
|
|
|
|
# Cette éval n'est pas complète
|
2021-06-24 10:59:03 +02:00
|
|
|
etat = sco_evaluations.do_evaluation_etat(context, e2["evaluation_id"])
|
2021-03-02 23:53:43 +01:00
|
|
|
assert etat["evalcomplete"] == False
|
|
|
|
# la première éval est toujours complète:
|
2021-06-24 10:59:03 +02:00
|
|
|
etat = sco_evaluations.do_evaluation_etat(context, e["evaluation_id"])
|
2021-03-02 23:53:43 +01:00
|
|
|
assert etat["evalcomplete"]
|
|
|
|
|
|
|
|
# Modifie l'évaluation 2 pour "prise en compte immédiate"
|
|
|
|
e2["publish_incomplete"] = "1"
|
2021-06-17 00:08:37 +02:00
|
|
|
sco_evaluations.do_evaluation_edit(context, REQUEST, e2)
|
2021-06-24 10:59:03 +02:00
|
|
|
etat = sco_evaluations.do_evaluation_etat(context, e2["evaluation_id"])
|
2021-03-02 23:53:43 +01:00
|
|
|
assert etat["evalcomplete"] == False
|
|
|
|
assert etat["nb_att"] == 0 # il n'y a pas de notes (explicitement) en attente
|
|
|
|
assert etat["evalattente"] # mais l'eval est en attente (prise en compte immédiate)
|
|
|
|
|
|
|
|
# Saisie des notes qui manquent:
|
|
|
|
for etud in etuds[5:]:
|
|
|
|
nb_changed, nb_suppress, existing_decisions = G.create_note(
|
|
|
|
evaluation=e2, etud=etud, note=float(random.randint(0, 20))
|
|
|
|
)
|
2021-06-24 10:59:03 +02:00
|
|
|
etat = sco_evaluations.do_evaluation_etat(context, e2["evaluation_id"])
|
2021-03-02 23:53:43 +01:00
|
|
|
assert etat["evalcomplete"]
|
|
|
|
assert etat["nb_att"] == 0
|
|
|
|
assert not etat["evalattente"] # toutes les notes sont présentes
|
|
|
|
|
2021-02-04 23:16:18 +01:00
|
|
|
# --- Saisie absences
|
|
|
|
etudid = etuds[0]["etudid"]
|
|
|
|
|
|
|
|
_ = sco_abs_views.doSignaleAbsence(
|
2021-06-24 10:59:03 +02:00
|
|
|
context,
|
2021-02-04 23:16:18 +01:00
|
|
|
"15/01/2020",
|
|
|
|
"18/01/2020",
|
|
|
|
demijournee=2,
|
|
|
|
etudid=etudid,
|
|
|
|
REQUEST=REQUEST,
|
|
|
|
)
|
|
|
|
|
|
|
|
_ = sco_abs_views.doJustifAbsence(
|
2021-06-24 10:59:03 +02:00
|
|
|
context,
|
2021-02-04 23:16:18 +01:00
|
|
|
"17/01/2020",
|
|
|
|
"18/01/2020",
|
|
|
|
demijournee=2,
|
|
|
|
etudid=etudid,
|
|
|
|
REQUEST=REQUEST,
|
|
|
|
)
|
|
|
|
|
2021-07-19 19:53:01 +02:00
|
|
|
nbabs, nbabsjust = sco_abs.get_abs_count(etudid, sem)
|
|
|
|
assert nbabs == 6, "incorrect nbabs (%d)" % nbabs
|
|
|
|
assert nbabsjust == 2, "incorrect nbabsjust (%s)" % nbabsjust
|
2021-04-19 11:26:22 +02:00
|
|
|
|
|
|
|
# --- Permission saisie notes et décisions de jury, avec ou sans démission ou défaillance
|
|
|
|
# on n'a pas encore saisi de décisions
|
|
|
|
assert not sco_parcours_dut.formsemestre_has_decisions(context, sem["formsemestre_id"])
|
|
|
|
# Saisie d'un décision AJ, non assidu
|
|
|
|
etudid = etuds[-1]["etudid"]
|
|
|
|
sco_parcours_dut.formsemestre_validate_ues(
|
2021-06-24 10:59:03 +02:00
|
|
|
context,
|
2021-04-19 11:26:22 +02:00
|
|
|
sem["formsemestre_id"],
|
|
|
|
etudid,
|
|
|
|
sco_codes_parcours.AJ,
|
|
|
|
False,
|
|
|
|
REQUEST=REQUEST,
|
|
|
|
)
|
|
|
|
assert sco_parcours_dut.formsemestre_has_decisions(
|
2021-06-24 10:59:03 +02:00
|
|
|
context, sem["formsemestre_id"]
|
|
|
|
), "décisions manquantes"
|
2021-04-19 11:26:22 +02:00
|
|
|
# Suppression de la décision
|
|
|
|
sco_formsemestre_validation.formsemestre_validation_suppress_etud(
|
2021-06-24 10:59:03 +02:00
|
|
|
context, sem["formsemestre_id"], etudid
|
2021-04-19 11:26:22 +02:00
|
|
|
)
|
|
|
|
assert not sco_parcours_dut.formsemestre_has_decisions(
|
2021-06-24 10:59:03 +02:00
|
|
|
context, sem["formsemestre_id"]
|
|
|
|
), "décisions non effacées"
|