forked from ScoDoc/ScoDoc
ajout de l'aléatoire dans la saisies des notes (prob avec les dates)
This commit is contained in:
parent
f04265c78e
commit
c0474f109d
@ -195,21 +195,70 @@ def saisie_note_evaluations(formsemestre: FormSemestre, user: User):
|
||||
"""
|
||||
# Récupération des id des étudiants du semestre
|
||||
list_etudids = [etud.id for etud in formsemestre.etuds]
|
||||
list_ues = formsemestre.query_ues()
|
||||
|
||||
def create_list_etudid_random_notes():
|
||||
def add_random_notes(evaluation_id, new_list_notes_eval=None, not_all=False):
|
||||
"""
|
||||
Retourne une liste de tuple (etudid, note_random)
|
||||
Permet d'ajouter des notes aléatoires à une évaluation
|
||||
"""
|
||||
return [(etudid, random.uniform(0.0, 20.0)) for etudid in list_etudids]
|
||||
if not_all:
|
||||
percent = 80 / 100
|
||||
len_list_etudids = len(list_etudids)
|
||||
new_list_etudids = random.sample(
|
||||
list_etudids, k=int(percent * len_list_etudids)
|
||||
)
|
||||
# new_list_etudids = [note.etudid for note in new_list_notes_eval]
|
||||
list_tuple_notes = [
|
||||
(etudid, random.uniform(0.0, 20.0)) for etudid in new_list_etudids
|
||||
]
|
||||
notes_add(user, evaluation_id, list_tuple_notes)
|
||||
else:
|
||||
list_tuple_notes = [
|
||||
(etudid, random.uniform(0.0, 20.0)) for etudid in list_etudids
|
||||
]
|
||||
notes_add(user, evaluation_id, list_tuple_notes)
|
||||
|
||||
def saisir_notes(evaluation_id: int, condition: int, list_notes_eval):
|
||||
"""
|
||||
Permet de saisir les notes de manière aléatoire suivant une condition
|
||||
Définition des valeurs de condition :
|
||||
0 : all_notes_saisies
|
||||
1 : all_notes_manquantes
|
||||
2 : some_notes_manquantes
|
||||
"""
|
||||
if condition == 0 or condition == 2:
|
||||
date_debut = formsemestre.date_debut
|
||||
date_fin = formsemestre.date_fin
|
||||
if condition == 0:
|
||||
add_random_notes(evaluation_id)
|
||||
for note in list_notes_eval:
|
||||
note.date = date_debut + random.random() * (date_fin - date_debut)
|
||||
db.session.add(note)
|
||||
db.session.commit()
|
||||
else:
|
||||
percent = 80 / 100
|
||||
len_list_notes_eval = len(list_notes_eval)
|
||||
new_list_notes_eval = random.sample(
|
||||
list_notes_eval, k=int(percent * len_list_notes_eval)
|
||||
)
|
||||
add_random_notes(evaluation_id, new_list_notes_eval, True)
|
||||
for note in new_list_notes_eval:
|
||||
note.date = date_debut + random.random() * (date_fin - date_debut)
|
||||
db.session.add(note)
|
||||
db.session.commit()
|
||||
|
||||
list_ues = formsemestre.query_ues()
|
||||
|
||||
for ue in list_ues:
|
||||
mods = ue.modules
|
||||
for mod in mods:
|
||||
moduleimpl = ModuleImpl.query.get_or_404(mod.id)
|
||||
for evaluation in moduleimpl.evaluations:
|
||||
notes = create_list_etudid_random_notes()
|
||||
notes_add(user, evaluation.id, notes)
|
||||
# Récupération de toutes les notes de l'évaluation
|
||||
notes_eval = models.NotesNotes.query.filter_by(
|
||||
evaluation_id=evaluation.id
|
||||
).all()
|
||||
condition_saisie_notes = random.randint(0, 2)
|
||||
saisir_notes(evaluation.id, condition_saisie_notes, notes_eval)
|
||||
|
||||
|
||||
def init_test_database():
|
||||
|
Loading…
Reference in New Issue
Block a user