parent
c871574e6a
commit
35db83eb12
|
@ -1,14 +1,13 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ChangeListManager">
|
||||
<list default="true" id="c6d0259a-16e1-410d-91a1-830590ee2a08" name="Changes" comment="30/04/2025 - 15h">
|
||||
<change afterPath="$PROJECT_DIR$/base_class_calcul_note.py" afterDir="false" />
|
||||
<list default="true" id="c6d0259a-16e1-410d-91a1-830590ee2a08" name="Changes" comment="02/05/2025 - 20h">
|
||||
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/Collection_Historique.py" beforeDir="false" afterPath="$PROJECT_DIR$/Collection_Historique.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/GlobalVariable.py" beforeDir="false" afterPath="$PROJECT_DIR$/GlobalVariable.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/Inscription_mgt.py" beforeDir="false" afterPath="$PROJECT_DIR$/Inscription_mgt.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/Log/log_file.log" beforeDir="false" afterPath="$PROJECT_DIR$/Log/log_file.log" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/equipe_team_mgt.py" beforeDir="false" afterPath="$PROJECT_DIR$/equipe_team_mgt.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/base_class_calcul_note.py" beforeDir="false" afterPath="$PROJECT_DIR$/base_class_calcul_note.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/main.py" beforeDir="false" afterPath="$PROJECT_DIR$/main.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/note_evaluation_mgt.py" beforeDir="false" afterPath="$PROJECT_DIR$/note_evaluation_mgt.py" afterDir="false" />
|
||||
</list>
|
||||
<option name="SHOW_DIALOG" value="false" />
|
||||
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
||||
|
@ -85,13 +84,6 @@
|
|||
<option name="presentableId" value="Default" />
|
||||
<updated>1680804787304</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00401" summary="sdfsd">
|
||||
<created>1727693258457</created>
|
||||
<option name="number" value="00401" />
|
||||
<option name="presentableId" value="LOCAL-00401" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1727693258457</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00402" summary="sdfsdsdsd">
|
||||
<created>1727982203432</created>
|
||||
<option name="number" value="00402" />
|
||||
|
@ -428,7 +420,14 @@
|
|||
<option name="project" value="LOCAL" />
|
||||
<updated>1746039183867</updated>
|
||||
</task>
|
||||
<option name="localTasksCounter" value="450" />
|
||||
<task id="LOCAL-00450" summary="02/05/2025 - 20h">
|
||||
<created>1746211624600</created>
|
||||
<option name="number" value="00450" />
|
||||
<option name="presentableId" value="LOCAL-00450" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1746211624601</updated>
|
||||
</task>
|
||||
<option name="localTasksCounter" value="451" />
|
||||
<servers />
|
||||
</component>
|
||||
<component name="Vcs.Log.Tabs.Properties">
|
||||
|
@ -470,7 +469,6 @@
|
|||
</option>
|
||||
</component>
|
||||
<component name="VcsManagerConfiguration">
|
||||
<MESSAGE value="sdfd" />
|
||||
<MESSAGE value="sdfdd" />
|
||||
<MESSAGE value="31/12/2024 - 12h30" />
|
||||
<MESSAGE value="03/01/2025 - 17h30" />
|
||||
|
@ -495,6 +493,7 @@
|
|||
<MESSAGE value="29/03/2025 - 21h" />
|
||||
<MESSAGE value="25/04/2025 - 15h" />
|
||||
<MESSAGE value="30/04/2025 - 15h" />
|
||||
<option name="LAST_COMMIT_MESSAGE" value="30/04/2025 - 15h" />
|
||||
<MESSAGE value="02/05/2025 - 20h" />
|
||||
<option name="LAST_COMMIT_MESSAGE" value="02/05/2025 - 20h" />
|
||||
</component>
|
||||
</project>
|
|
@ -7706,7 +7706,9 @@ def Get_Statgaire_List_Partner_with_filter(diction):
|
|||
list_session_id = []
|
||||
if ("code_session" in diction.keys()):
|
||||
filt_code_session = {'code_session': {'$regex': str(diction['code_session']), "$options": "i"}}
|
||||
"""qry_list_session_id = { { '$and' :[ {'code_session': {'$regex': str(diction['code_session']), "$options": "i"}},
|
||||
|
||||
"""
|
||||
qry_list_session_id = { { '$and' :[ {'code_session': {'$regex': str(diction['code_session']), "$options": "i"}},
|
||||
{'partner_owner_recid': str(partner_recid)} ]}, {'_id':1}}
|
||||
"""
|
||||
|
||||
|
@ -7726,6 +7728,9 @@ def Get_Statgaire_List_Partner_with_filter(diction):
|
|||
#print(" ### liste des Id des sessions eligible list_session_id = ", list_session_id)
|
||||
filt_session_id = {'session_id': {'$in': list_session_id, }}
|
||||
|
||||
|
||||
#print(" ### filt_session_id zzzzzzzzz = ", filt_session_id)
|
||||
|
||||
filt_class_title = {}
|
||||
if ("class_title" in diction.keys()):
|
||||
filt_class_title = {'title': {'$regex': str(diction['class_title']), "$options": "i"}}
|
||||
|
@ -7749,10 +7754,12 @@ def Get_Statgaire_List_Partner_with_filter(diction):
|
|||
if ("client_rattachement_id" in diction.keys()):
|
||||
filt_client_rattachement_id = {'client_rattachement_id': str(diction['client_rattachement_id'])}
|
||||
|
||||
"""
|
||||
filt_session_id = {}
|
||||
if ("session_id" in diction.keys()):
|
||||
filt_session_id = {'session_id': str(diction['session_id'])}
|
||||
|
||||
"""
|
||||
#print(" ### filt_session_id 0222 zzzzzzzzz = ", filt_session_id)
|
||||
# -----
|
||||
|
||||
filt_client_nom = {}
|
||||
|
@ -7807,10 +7814,9 @@ def Get_Statgaire_List_Partner_with_filter(diction):
|
|||
|
||||
]}}},
|
||||
], 'as': 'apprenant_collection'}}
|
||||
|
||||
|
||||
]
|
||||
#print("#### Get_Statgaire_List_Partner_with_filter laa 01 : query = ", query)
|
||||
|
||||
print("#### Get_Statgaire_List_Partner_with_filter laa 01 : query = ", query)
|
||||
RetObject = []
|
||||
cpt = 0
|
||||
for retVal in MYSY_GV.dbname['inscription'].aggregate(query):
|
||||
|
|
3556
Log/log_file.log
3556
Log/log_file.log
File diff suppressed because it is too large
Load Diff
|
@ -37,25 +37,10 @@ import prj_common as mycommon
|
|||
import secrets
|
||||
import inspect
|
||||
import sys, os
|
||||
import csv
|
||||
import pandas as pd
|
||||
|
||||
from pymongo import ReturnDocument
|
||||
import GlobalVariable as MYSY_GV
|
||||
from math import isnan
|
||||
import GlobalVariable as MYSY_GV
|
||||
import ela_index_bdd_classes as eibdd
|
||||
import email_mgt as email
|
||||
import jinja2
|
||||
from flask import send_file
|
||||
from xhtml2pdf import pisa
|
||||
from email.message import EmailMessage
|
||||
from email.mime.text import MIMEText
|
||||
from email import encoders
|
||||
import smtplib
|
||||
from email.mime.multipart import MIMEMultipart
|
||||
from email.mime.text import MIMEText
|
||||
from email.mime.base import MIMEBase
|
||||
from email import encoders
|
||||
|
||||
|
||||
|
||||
"""
|
||||
|
@ -68,14 +53,14 @@ Les données en entrée :
|
|||
- La session
|
||||
- Liste des inscrit
|
||||
"""
|
||||
def run_calcul_mode_1(diction):
|
||||
def run_pre_calcul_moyenne_somme(diction):
|
||||
try:
|
||||
diction = mycommon.strip_dictionary(diction)
|
||||
|
||||
"""
|
||||
Verification des input acceptés
|
||||
"""
|
||||
field_list = ['token', 'class_id', 'session_id', 'eu_id', 'tab_inscriptions_ids' ]
|
||||
field_list = ['token', 'class_id', 'session_id', 'tab_ue_ids', 'tab_inscriptions_ids' ]
|
||||
|
||||
incom_keys = diction.keys()
|
||||
for val in incom_keys:
|
||||
|
@ -87,7 +72,7 @@ def run_calcul_mode_1(diction):
|
|||
"""
|
||||
Verification des champs obligatoires
|
||||
"""
|
||||
field_list_obligatoire = ['token', 'class_id', 'session_id', 'eu_id', 'tab_inscriptions_ids' ]
|
||||
field_list_obligatoire = ['token', 'class_id', 'session_id', 'tab_ue_ids', 'tab_inscriptions_ids' ]
|
||||
|
||||
for val in field_list_obligatoire:
|
||||
if val not in diction:
|
||||
|
@ -124,24 +109,29 @@ def run_calcul_mode_1(diction):
|
|||
'valide': '1',
|
||||
'partner_owner_recid': str(my_partner['recid'])})
|
||||
|
||||
tab_ue_ids = ""
|
||||
if ("tab_ue_ids" in diction.keys()):
|
||||
if diction['tab_ue_ids']:
|
||||
tab_ue_ids = diction['tab_ue_ids']
|
||||
|
||||
tab_ue_ids_splited = str(tab_ue_ids).split(",")
|
||||
|
||||
for my_ue_id in tab_ue_ids_splited:
|
||||
my_ue_id = str(my_ue_id).strip()
|
||||
|
||||
# Verifier la validité de l'unité d'enseignement
|
||||
is_ue_valide_count = MYSY_GV.dbname['unite_enseignement'].count_documents(
|
||||
{'_id': ObjectId(str(diction['eu_id'])),
|
||||
{'_id': ObjectId(str(my_ue_id)),
|
||||
'valide': '1',
|
||||
'locked':'0',
|
||||
'partner_owner_recid': str(my_partner['recid'])})
|
||||
|
||||
if (is_ue_valide_count != 1):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3]) + " L'identifiant de l'unité d'enseignement est invalide ")
|
||||
return False, " L'identifiant de l'unité d'enseignement est invalide"
|
||||
str(inspect.stack()[0][3]) + " L'identifiant de l'unité d'enseignement est invalide "+str(my_ue_id))
|
||||
return False, " L'identifiant de l'unité d'enseignement "+str(my_ue_id)+" est invalide "
|
||||
|
||||
|
||||
is_ue_valide_data = MYSY_GV.dbname['unite_enseignement'].find_one(
|
||||
{'_id': ObjectId(str(diction['eu_id'])),
|
||||
'valide': '1',
|
||||
'locked': '0',
|
||||
'partner_owner_recid': str(my_partner['recid'])})
|
||||
|
||||
|
||||
# Verifier si la formartion est valide
|
||||
|
@ -196,54 +186,34 @@ def run_calcul_mode_1(diction):
|
|||
b) Pour chaque evaluation concerné aller cherche les note
|
||||
"""
|
||||
|
||||
"""
|
||||
TRAITEMENT DES TD
|
||||
"""
|
||||
evaluation_type_TD_id = ""
|
||||
for val in MYSY_GV.dbname['type_evaluation'].find({'partner_owner_recid':str(my_partner['recid']),
|
||||
for my_ue_id in tab_ue_ids_splited:
|
||||
my_ue_id = str(my_ue_id).strip()
|
||||
|
||||
|
||||
my_ue_id_data = MYSY_GV.dbname['unite_enseignement'].find_one(
|
||||
{'_id': ObjectId(str(my_ue_id)),
|
||||
'valide': '1',
|
||||
'locked': '0',
|
||||
'code': {'$regex': "TD", "$options": "i"}}):
|
||||
evaluation_type_TD_id = str(val['_id'])
|
||||
'partner_owner_recid': str(my_partner['recid'])})
|
||||
|
||||
|
||||
liste_note_evaluation_TD_ids = []
|
||||
|
||||
print(" ~#### QTRYYY = ", {'partner_owner_recid':str(my_partner['recid']),
|
||||
evaluation_distinc_type_eval = MYSY_GV.dbname['note_evaluation'].distinct("type_eval_id",
|
||||
{'class_eu_id': str(my_ue_id),
|
||||
'valide': '1',
|
||||
'locked': '0',
|
||||
'class_id':str(diction['class_id']),
|
||||
'class_eu_id': str(diction['eu_id']),
|
||||
'type_eval_id':str(evaluation_type_TD_id)}
|
||||
'partner_owner_recid': str(my_partner['recid'])
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
for val in MYSY_GV.dbname['note_evaluation'].find({'partner_owner_recid':str(my_partner['recid']),
|
||||
'valide':'1',
|
||||
'locked':'0',
|
||||
'class_id':str(diction['class_id']),
|
||||
'class_eu_id': str(diction['eu_id']),
|
||||
'type_eval_id':str(evaluation_type_TD_id)}):
|
||||
liste_note_evaluation_TD_ids.append(str(val['_id']))
|
||||
#print(" ### la liste evaluation_distinc_type_eval = ", evaluation_distinc_type_eval)
|
||||
|
||||
|
||||
print(" ### la liste des evaluations de type TD sont : ", liste_note_evaluation_TD_ids)
|
||||
|
||||
nb_eval_td = len(liste_note_evaluation_TD_ids)
|
||||
|
||||
|
||||
#print(" ### TRAITEMENT UE_ID = ", my_ue_id)
|
||||
|
||||
tab_note_final = []
|
||||
for my_inscription in tab_inscriptions_ids_splited:
|
||||
somme_note_td = 0
|
||||
moyenne_note_td = 0
|
||||
tab_apprenant_note_td = []
|
||||
print("###############################################")
|
||||
for note_evaluation_participant in MYSY_GV.dbname['note_evaluation_participant'].find(
|
||||
{'partner_owner_recid':str(my_partner['recid']),
|
||||
'valide':'1',
|
||||
'locked':'0',
|
||||
'inscription_id' : str(my_inscription),
|
||||
'evaluation_id':{'$in':liste_note_evaluation_TD_ids}
|
||||
}):
|
||||
|
||||
inscri_data = MYSY_GV.dbname['inscription'].find_one({'partner_owner_recid': str(my_partner['recid']),
|
||||
'valide': '1',
|
||||
'locked': '0',
|
||||
|
@ -251,83 +221,217 @@ def run_calcul_mode_1(diction):
|
|||
{'nom': 1, 'prenom': 1, 'email': 1}
|
||||
)
|
||||
|
||||
node_note_finale_inscrit = {}
|
||||
node_note_finale_inscrit['inscription_id'] = str(inscri_data['_id'])
|
||||
node_note_finale_inscrit['inscription_nom'] = str(inscri_data['nom'])
|
||||
node_note_finale_inscrit['inscription_email'] = str(inscri_data['email'])
|
||||
node_note_finale_inscrit['class_id'] = str(diction['class_id'])
|
||||
node_note_finale_inscrit['session_id'] = str(diction['session_id'])
|
||||
node_note_finale_inscrit['ue_id'] = str(my_ue_id)
|
||||
|
||||
############
|
||||
|
||||
"""
|
||||
A supprimer après, la c'est juste pour voir les data
|
||||
Traitement des Types d'evaluation
|
||||
"""
|
||||
evaluation_data = MYSY_GV.dbname['note_evaluation'].find_one({'partner_owner_recid':str(my_partner['recid']),
|
||||
for eval_type_id in evaluation_distinc_type_eval :
|
||||
|
||||
eval_type_id_data = MYSY_GV.dbname['type_evaluation'].find_one({'partner_owner_recid': str(my_partner['recid']),
|
||||
'valide': '1',
|
||||
'locked': '0',
|
||||
'_id':ObjectId(str(note_evaluation_participant['evaluation_id']))})
|
||||
'_id': ObjectId(str(eval_type_id))})
|
||||
|
||||
#print(" TRAITEMENT TYPE EVAL : ", str(eval_type_id_data["code"]))
|
||||
|
||||
local_diction = diction
|
||||
local_diction['tab_inscriptions_ids'] = str(my_inscription)
|
||||
local_diction['inscri_data_nom'] = inscri_data['nom']
|
||||
local_diction['inscri_data_prenom'] = inscri_data['prenom']
|
||||
local_diction['inscri_data_email'] = inscri_data['email']
|
||||
local_diction['ue_id'] = str(my_ue_id)
|
||||
|
||||
if ("tab_ue_ids" in local_diction.keys()):
|
||||
del local_diction["tab_ue_ids"]
|
||||
|
||||
somme_note_td = somme_note_td + mycommon.tryFloat(str(note_evaluation_participant['note']))
|
||||
local_diction['evaluation_type_code'] = str(eval_type_id_data["code"])
|
||||
local_diction['evaluation_type_id'] = str(eval_type_id_data["_id"])
|
||||
|
||||
print("$$$$$$$$$$$$$$$$$$$$ ", evaluation_data['code'], " Du ", evaluation_data['eval_date_heure_debut'], " Au ", evaluation_data['eval_date_heure_fin'])
|
||||
print(" Session : is_session_valide_data = ", is_session_valide_data['code_session'])
|
||||
print(" Unit. Ensei : is_ue_valide_data = ", is_ue_valide_data['code'])
|
||||
print(" Apprenant : my_inscription = ", my_inscription, " Nom = ",inscri_data['nom'], " Email = ", str(inscri_data['email']) )
|
||||
print(" note_evaluation_participant = ", note_evaluation_participant['note'])
|
||||
tab_apprenant_note_td.append(str(note_evaluation_participant['note']))
|
||||
local_status, local_retval_moyenne_TD, local_retval_somme_TD, local_retval_nb_eval_TD = Cacul_Note_By_Evaluation_Type(
|
||||
local_diction)
|
||||
if (local_status):
|
||||
new_node = {}
|
||||
new_node['inscription_id'] = str(inscri_data['_id'])
|
||||
new_node['inscription_nom'] = str(inscri_data['nom'])
|
||||
new_node['inscription_email'] = str(inscri_data['email'])
|
||||
new_node['class_id'] = str(diction['class_id'])
|
||||
new_node['session_id'] = str(diction['session_id'])
|
||||
new_node['ue_id'] = str(my_ue_id)
|
||||
new_node['type_eval'] = str(eval_type_id_data["code"])
|
||||
new_node['type_eval_id'] = str(eval_type_id)
|
||||
new_node['moyenne'] = str(local_retval_moyenne_TD)
|
||||
new_node['somme'] = str(local_retval_somme_TD)
|
||||
new_node['nb_evaluation'] = str(local_retval_nb_eval_TD)
|
||||
|
||||
tab_note_final.append(new_node)
|
||||
else:
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3]) + " WARNING : " + str(local_retval_moyenne_TD))
|
||||
|
||||
moyenne_note_td = somme_note_td / nb_eval_td
|
||||
print("")
|
||||
print(" ## Somme_note TD = ", str(somme_note_td), " ## Moyenne TP = ", str(moyenne_note_td))
|
||||
print("")
|
||||
print("")
|
||||
|
||||
"""
|
||||
FIN TRAITEMENT DES TD
|
||||
Mise à jour de la collection des notes d'une session de formation : 'session_formation_final_note_classement_detail'
|
||||
"""
|
||||
|
||||
print(" TPPPPPPPPPPPPPPPPPPPPPP")
|
||||
for note_finale in tab_note_final:
|
||||
qry_key = {}
|
||||
qry_key['partner_owner_recid'] = my_partner['recid']
|
||||
qry_key['valide'] = "1"
|
||||
qry_key['locked'] = "0"
|
||||
qry_key['inscription_id'] = note_finale['inscription_id']
|
||||
qry_key['session_id'] = note_finale['session_id']
|
||||
qry_key['type_eval'] = note_finale['type_eval']
|
||||
qry_key['ue_id'] = note_finale['ue_id']
|
||||
|
||||
|
||||
new_data = note_finale
|
||||
new_data['date_update'] = str(datetime.now())
|
||||
new_data['update_by'] = str(my_partner['_id'])
|
||||
new_data['valide'] = "1"
|
||||
new_data['locked'] = "0"
|
||||
|
||||
|
||||
ret_val2 = MYSY_GV.dbname['session_formation_final_note_classement_detail'].find_one_and_update(
|
||||
qry_key,
|
||||
{"$set": new_data},
|
||||
return_document=ReturnDocument.AFTER,
|
||||
upsert=True,
|
||||
)
|
||||
|
||||
|
||||
return True, tab_note_final
|
||||
|
||||
except Exception as e:
|
||||
exc_type, exc_obj, exc_tb = sys.exc_info()
|
||||
mycommon.myprint(str(inspect.stack()[0][3]) + " -" + str(e) + " - Line : " + str(exc_tb.tb_lineno))
|
||||
return False, " Impossible de calculer les notes avec le -calcul_mode_1- "
|
||||
|
||||
"""
|
||||
TRAITEMENT DES TP
|
||||
Cette fonction calcule les moyennes les sommes par ue/inscrit/type evaluation
|
||||
"""
|
||||
evaluation_type_TP_id = ""
|
||||
for val in MYSY_GV.dbname['type_evaluation'].find({'partner_owner_recid': str(my_partner['recid']),
|
||||
def Cacul_Note_By_Evaluation_Type(diction):
|
||||
try:
|
||||
diction = mycommon.strip_dictionary(diction)
|
||||
|
||||
|
||||
"""
|
||||
Verification des input acceptés
|
||||
"""
|
||||
field_list = ['token', 'class_id', 'session_id', 'ue_id', 'tab_inscriptions_ids', 'evaluation_type_id',
|
||||
'inscri_data_nom', 'inscri_data_prenom', 'inscri_data_email', 'evaluation_type_code']
|
||||
|
||||
|
||||
incom_keys = diction.keys()
|
||||
for val in incom_keys:
|
||||
if val not in field_list and val.startswith('my_') is False:
|
||||
mycommon.myprint(str(
|
||||
inspect.stack()[0][3]) + " Le champ '" + val + "' n'est pas autorisé")
|
||||
return False, " Les informations fournies sont incorrectes"
|
||||
|
||||
"""
|
||||
Verification des champs obligatoires
|
||||
"""
|
||||
field_list_obligatoire = ['token', 'class_id', 'session_id', 'ue_id', 'tab_inscriptions_ids', 'evaluation_type_id',
|
||||
'inscri_data_nom', 'inscri_data_prenom', 'inscri_data_email']
|
||||
|
||||
for val in field_list_obligatoire:
|
||||
if val not in diction:
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3]) + " - La valeur '" + val + "' n'est pas presente dans liste ")
|
||||
return False, " Les informations fournies sont incorrectes"
|
||||
|
||||
"""
|
||||
Verification de l'identité et autorisation de l'entité qui
|
||||
appelle cette API
|
||||
"""
|
||||
token = ""
|
||||
if ("token" in diction.keys()):
|
||||
if diction['token']:
|
||||
token = diction['token']
|
||||
|
||||
local_status, my_partner = mycommon.Check_Connexion_And_Return_Partner_Data(diction)
|
||||
if (local_status is not True):
|
||||
return local_status, my_partner
|
||||
|
||||
is_session_valide_data = MYSY_GV.dbname['session_formation'].find_one(
|
||||
{'_id': ObjectId(str(diction['session_id'])),
|
||||
'valide': '1',
|
||||
'partner_owner_recid': str(my_partner['recid'])})
|
||||
|
||||
|
||||
is_ue_valide_data = MYSY_GV.dbname['unite_enseignement'].find_one(
|
||||
{'_id': ObjectId(str(diction['ue_id'])),
|
||||
'valide': '1',
|
||||
'locked': '0',
|
||||
'code': {'$regex': "TP", "$options": "i"}}):
|
||||
evaluation_type_TP_id = str(val['_id'])
|
||||
|
||||
liste_note_evaluation_TP_ids = []
|
||||
'partner_owner_recid': str(my_partner['recid'])})
|
||||
|
||||
|
||||
is_myclass_valide_data = MYSY_GV.dbname['myclass'].find_one(
|
||||
{'_id': ObjectId(str(diction['class_id'])),
|
||||
'valide': '1',
|
||||
'locked': '0',
|
||||
'partner_owner_recid': str(my_partner['recid'])})
|
||||
|
||||
# Verifier la validité de la liste des inscrits fournie
|
||||
tab_inscriptions_ids = ""
|
||||
if ("tab_inscriptions_ids" in diction.keys()):
|
||||
if diction['tab_inscriptions_ids']:
|
||||
tab_inscriptions_ids = diction['tab_inscriptions_ids']
|
||||
|
||||
tab_inscriptions_ids_splited = str(tab_inscriptions_ids).split(",")
|
||||
|
||||
# Controle de validité de toutes info avant de commencer les traitements
|
||||
for my_inscription in tab_inscriptions_ids_splited:
|
||||
my_inscription = str(my_inscription).strip()
|
||||
|
||||
|
||||
evaluation_type_id = ""
|
||||
if( "evaluation_type_id" in diction and diction['evaluation_type_id']):
|
||||
evaluation_type_id = diction['evaluation_type_id']
|
||||
|
||||
|
||||
|
||||
liste_note_evaluation_ids = []
|
||||
|
||||
for val in MYSY_GV.dbname['note_evaluation'].find({'partner_owner_recid': str(my_partner['recid']),
|
||||
'valide': '1',
|
||||
'locked': '0',
|
||||
'class_id': str(diction['class_id']),
|
||||
'class_eu_id': str(diction['eu_id']),
|
||||
'type_eval_id': str(evaluation_type_TP_id)}):
|
||||
liste_note_evaluation_TP_ids.append(str(val['_id']))
|
||||
'class_eu_id': str(diction['ue_id']),
|
||||
'type_eval_id': str(evaluation_type_id)}):
|
||||
liste_note_evaluation_ids.append(str(val['_id']))
|
||||
|
||||
print(" ### la liste des evaluations de type TPP sont : ", liste_note_evaluation_TP_ids)
|
||||
somme_note = 0
|
||||
moyenne_note = 0
|
||||
|
||||
nb_eval_tp = len(liste_note_evaluation_TP_ids)
|
||||
#print(" ### la liste des evaluations de type sont : ", liste_note_evaluation_ids)
|
||||
|
||||
nb_eval = len(liste_note_evaluation_ids)
|
||||
#print(" ### la liste len(liste_note_evaluation_ids) : ", len(liste_note_evaluation_ids))
|
||||
|
||||
if( nb_eval > 0 ):
|
||||
for my_inscription in tab_inscriptions_ids_splited:
|
||||
somme_note_tp = 0
|
||||
moyenne_note_tp = 0
|
||||
tab_apprenant_note_tp = []
|
||||
print("###############################################")
|
||||
somme_note = 0
|
||||
moyenne_note = 0
|
||||
tab_apprenant_note = []
|
||||
|
||||
for note_evaluation_participant in MYSY_GV.dbname['note_evaluation_participant'].find(
|
||||
{'partner_owner_recid': str(my_partner['recid']),
|
||||
'valide': '1',
|
||||
'locked': '0',
|
||||
'inscription_id': str(my_inscription),
|
||||
'evaluation_id': {'$in': liste_note_evaluation_TP_ids}
|
||||
'evaluation_id': {'$in': liste_note_evaluation_ids}
|
||||
}):
|
||||
|
||||
print(" ### note_evaluation_participant TPPP= ", note_evaluation_participant)
|
||||
inscri_data = MYSY_GV.dbname['inscription'].find_one({'partner_owner_recid': str(my_partner['recid']),
|
||||
'valide': '1',
|
||||
'locked': '0',
|
||||
'_id': ObjectId(str(my_inscription).strip())},
|
||||
{'nom': 1, 'prenom': 1, 'email': 1}
|
||||
)
|
||||
|
||||
"""
|
||||
A supprimer après, la c'est juste pour voir les data
|
||||
|
@ -338,27 +442,559 @@ def run_calcul_mode_1(diction):
|
|||
'locked': '0',
|
||||
'_id': ObjectId(str(note_evaluation_participant['evaluation_id']))})
|
||||
|
||||
somme_note_tp = somme_note_tp + mycommon.tryFloat(str(note_evaluation_participant['note']))
|
||||
somme_note = somme_note + mycommon.tryFloat(str(note_evaluation_participant['note']))
|
||||
|
||||
print("$$$$$$$$$$$$$$$$$$$$ ", evaluation_data['code'], " Du ",
|
||||
evaluation_data['eval_date_heure_debut'], " Au ", evaluation_data['eval_date_heure_fin'])
|
||||
print(" Session : is_session_valide_data = ", is_session_valide_data['code_session'])
|
||||
print(" Unit. Ensei : is_ue_valide_data = ", is_ue_valide_data['code'])
|
||||
print(" Apprenant : my_inscription = ", my_inscription, " Nom = ", inscri_data['nom'], " Email = ",
|
||||
str(inscri_data['email']))
|
||||
print(" note_evaluation_participant = ", note_evaluation_participant['note'])
|
||||
tab_apprenant_note_tp.append(str(note_evaluation_participant['note']))
|
||||
#print("************* ", evaluation_data['code'], " Du ",evaluation_data['eval_date_heure_debut'], " Au ", evaluation_data['eval_date_heure_fin'])
|
||||
#print(" Session : is_session_valide_data = ", is_session_valide_data['code_session'])
|
||||
#print(" Unit. Ensei : is_ue_valide_data = ", is_ue_valide_data['code'])
|
||||
|
||||
moyenne_note_tp = somme_note_tp / nb_eval_tp
|
||||
#print(" note_evaluation_participant = ", note_evaluation_participant['note'])
|
||||
tab_apprenant_note.append(str(note_evaluation_participant['note']))
|
||||
|
||||
if( nb_eval == 0 ):
|
||||
moyenne_note = "-"
|
||||
somme_note = "-"
|
||||
else:
|
||||
moyenne_note = round(somme_note / nb_eval, 2)
|
||||
"""
|
||||
print("")
|
||||
print(" ## Somme_note TP = ", str(somme_note_tp), " ## Moyenne TP= ", str(moyenne_note_tp))
|
||||
print(" ## Somme_note ",str(diction['evaluation_type']), " = ", str(somme_note), " ## Moyenne TP= ", str(moyenne_note))
|
||||
print("")
|
||||
print("")
|
||||
"""
|
||||
|
||||
else :
|
||||
moyenne_note = "-"
|
||||
somme_note = "-"
|
||||
|
||||
|
||||
return True, " Les notes avec le -calcul_mode_1- ont été correctement calculées"
|
||||
return True, str(moyenne_note), str(somme_note), str(nb_eval)
|
||||
|
||||
except Exception as e:
|
||||
exc_type, exc_obj, exc_tb = sys.exc_info()
|
||||
mycommon.myprint(str(inspect.stack()[0][3]) + " -" + str(e) + " - Line : " + str(exc_tb.tb_lineno))
|
||||
return False, " Impossible de calculer les notes avec le -calcul_mode_1- "
|
||||
return False, " Impossible de lancer Cacul_Note_By_Evaluation_Type "
|
||||
|
||||
|
||||
"""
|
||||
Cette fonction calcul la moyenne generale en
|
||||
appliquant la forule 1:
|
||||
• Nom : calcul_mode_1
|
||||
Detail : ( ((Moyenne Art. (TD) + Moyenne Art(TP) * 2) ) /3 + Examen Final ) / 2
|
||||
|
||||
Alog :
|
||||
la fonction va essentiellement travailler sur la collection : session_formation_final_note_classement_detail
|
||||
|
||||
|
||||
"""
|
||||
def Cacul_Note_Finale_For_calcul_mode_1(diction):
|
||||
try:
|
||||
diction = mycommon.strip_dictionary(diction)
|
||||
|
||||
|
||||
"""
|
||||
Verification des input acceptés
|
||||
"""
|
||||
field_list = ['token', 'class_id', 'session_id', 'ue_id', 'tab_inscriptions_ids',]
|
||||
|
||||
|
||||
incom_keys = diction.keys()
|
||||
for val in incom_keys:
|
||||
if val not in field_list and val.startswith('my_') is False:
|
||||
mycommon.myprint(str(
|
||||
inspect.stack()[0][3]) + " Le champ '" + val + "' n'est pas autorisé")
|
||||
return False, " Les informations fournies sont incorrectes"
|
||||
|
||||
"""
|
||||
Verification des champs obligatoires
|
||||
"""
|
||||
field_list_obligatoire = ['token', 'class_id', 'session_id', 'ue_id', 'tab_inscriptions_ids',]
|
||||
|
||||
for val in field_list_obligatoire:
|
||||
if val not in diction:
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3]) + " - La valeur '" + val + "' n'est pas presente dans liste ")
|
||||
return False, " Les informations fournies sont incorrectes"
|
||||
|
||||
"""
|
||||
Verification de l'identité et autorisation de l'entité qui
|
||||
appelle cette API
|
||||
"""
|
||||
token = ""
|
||||
if ("token" in diction.keys()):
|
||||
if diction['token']:
|
||||
token = diction['token']
|
||||
|
||||
local_status, my_partner = mycommon.Check_Connexion_And_Return_Partner_Data(diction)
|
||||
if (local_status is not True):
|
||||
return local_status, my_partner
|
||||
|
||||
is_session_valide_data = MYSY_GV.dbname['session_formation'].find_one(
|
||||
{'_id': ObjectId(str(diction['session_id'])),
|
||||
'valide': '1',
|
||||
'partner_owner_recid': str(my_partner['recid'])})
|
||||
|
||||
|
||||
is_ue_valide_data = MYSY_GV.dbname['unite_enseignement'].find_one(
|
||||
{'_id': ObjectId(str(diction['ue_id'])),
|
||||
'valide': '1',
|
||||
'locked': '0',
|
||||
'partner_owner_recid': str(my_partner['recid'])})
|
||||
|
||||
|
||||
is_myclass_valide_data = MYSY_GV.dbname['myclass'].find_one(
|
||||
{'_id': ObjectId(str(diction['class_id'])),
|
||||
'valide': '1',
|
||||
'locked': '0',
|
||||
'partner_owner_recid': str(my_partner['recid'])})
|
||||
|
||||
# Verifier la validité de la liste des inscrits fournie
|
||||
tab_inscriptions_ids = ""
|
||||
if ("tab_inscriptions_ids" in diction.keys()):
|
||||
if diction['tab_inscriptions_ids']:
|
||||
tab_inscriptions_ids = diction['tab_inscriptions_ids']
|
||||
|
||||
tab_inscriptions_ids_splited = str(tab_inscriptions_ids).split(",")
|
||||
|
||||
# Controle de validité de toutes info avant de commencer les traitements
|
||||
for my_inscription in tab_inscriptions_ids_splited:
|
||||
my_inscription = str(my_inscription).strip()
|
||||
|
||||
|
||||
|
||||
type_eval_td_data = MYSY_GV.dbname['type_evaluation'].find_one({'code': {'$regex': "td", "$options": "i"},
|
||||
'partner_owner_recid': str(my_partner['recid']),
|
||||
'valide': '1',
|
||||
'locked': '0',
|
||||
})
|
||||
|
||||
type_eval_tp_data = MYSY_GV.dbname['type_evaluation'].find_one({'code': {'$regex': "tp", "$options": "i"},
|
||||
'partner_owner_recid': str(my_partner['recid']),
|
||||
'valide': '1',
|
||||
'locked': '0',
|
||||
})
|
||||
|
||||
type_eval_examen_data = MYSY_GV.dbname['type_evaluation'].find_one({'code': {'$regex': "Examen", "$options": "i"},
|
||||
'partner_owner_recid': str(my_partner['recid']),
|
||||
'valide': '1',
|
||||
'locked': '0',
|
||||
})
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
basic_qry = {'partner_owner_recid': str(my_partner['recid']),
|
||||
'valide': '1',
|
||||
'locked': '0',
|
||||
'session_id': str(diction['session_id']),
|
||||
'ue_id': str( diction['ue_id']),
|
||||
}
|
||||
|
||||
for my_inscription in tab_inscriptions_ids_splited:
|
||||
# 1 - recuperer toutes les notes pre_calculée de l'apprenant
|
||||
|
||||
local_node = {}
|
||||
|
||||
MA_TD_float = 0
|
||||
MA_TP_float = 0
|
||||
MA_Examen_float = 0
|
||||
|
||||
basic_qry['inscription_id'] = str(my_inscription)
|
||||
|
||||
#### Recuperation des data TD
|
||||
basic_qry['type_eval_id'] = str(type_eval_td_data['_id'])
|
||||
MA_TD_data = MYSY_GV.dbname['session_formation_final_note_classement_detail'].find_one(basic_qry)
|
||||
print(" ### MA_TD_data = ", MA_TD_data)
|
||||
MA_TD_float = float(MA_TD_data['moyenne'])
|
||||
print(" ############################ ")
|
||||
|
||||
#### Recuperation des data TP
|
||||
basic_qry['type_eval_id'] = str(type_eval_tp_data['_id'])
|
||||
MA_TP_data = MYSY_GV.dbname['session_formation_final_note_classement_detail'].find_one(basic_qry)
|
||||
print(" ### MA_TP_data = ", MA_TP_data)
|
||||
MA_TP_float = float(MA_TP_data['moyenne'])
|
||||
print(" ############################ ")
|
||||
|
||||
#### Recuperation des data Examen
|
||||
basic_qry['type_eval_id'] = str(type_eval_examen_data['_id'])
|
||||
MA_EXAMEN_data = MYSY_GV.dbname['session_formation_final_note_classement_detail'].find_one(basic_qry)
|
||||
print(" ### MA_EXAMEN_data = ", MA_EXAMEN_data)
|
||||
MA_Examen_float = float(MA_EXAMEN_data['moyenne'])
|
||||
print(" ############################ ")
|
||||
|
||||
note_finale_ue = ( (( (MA_TD_float + (MA_TP_float * 2 )) / 3 ) + MA_Examen_float) )/ 2
|
||||
tmp = (MA_TD_float + (MA_TP_float * 2 )) / 3
|
||||
|
||||
print(" ## tmp = ", tmp)
|
||||
|
||||
note_finale_ue = round(note_finale_ue, 2)
|
||||
|
||||
print(" ## MA_TD_float = ", MA_TD_float)
|
||||
print(" ## MA_TP_float = ", MA_TP_float)
|
||||
print(" ## MA_Examen_float = ", MA_Examen_float)
|
||||
|
||||
print(" ### note_finale_ue = ", note_finale_ue)
|
||||
|
||||
local_node['inscription_id'] = str(my_inscription)
|
||||
local_node['session_id'] = str(MA_EXAMEN_data['session_id'])
|
||||
local_node['type_eval'] = "note_finale"
|
||||
local_node['type_eval_id'] = "----"
|
||||
local_node['ue_id'] = str(MA_EXAMEN_data['ue_id'])
|
||||
local_node['class_id'] = str(MA_EXAMEN_data['class_id'])
|
||||
local_node['inscription_email'] = str(MA_EXAMEN_data['inscription_email'])
|
||||
local_node['inscription_nom'] = str(MA_EXAMEN_data['inscription_nom'])
|
||||
local_node['session_id'] = str(MA_EXAMEN_data['session_id'])
|
||||
|
||||
local_node['note_td'] = str(MA_TD_float)
|
||||
local_node['note_tp'] = str(MA_TP_float)
|
||||
local_node['note_examen'] = str(MA_Examen_float)
|
||||
local_node['regle_calcul'] = "( ((Moyenne Art. (TD) + Moyenne Art(TP) * 2) ) /3 + Examen Final ) / 2"
|
||||
local_node['note_finale'] = str(note_finale_ue)
|
||||
|
||||
local_node['create_date'] = str(datetime.now())
|
||||
local_node['created_by'] = str(my_partner['_id'])
|
||||
local_node['valide'] = "1"
|
||||
local_node['locked'] = "0"
|
||||
local_node['partner_owner_recid'] = str(my_partner['recid'])
|
||||
|
||||
qry_key = {}
|
||||
qry_key['partner_owner_recid'] = my_partner['recid']
|
||||
qry_key['valide'] = "1"
|
||||
qry_key['locked'] = "0"
|
||||
qry_key['inscription_id'] = local_node['inscription_id']
|
||||
qry_key['session_id'] = local_node['session_id']
|
||||
qry_key['type_eval'] = local_node['type_eval']
|
||||
qry_key['ue_id'] = local_node['ue_id']
|
||||
|
||||
|
||||
|
||||
ret_val2 = MYSY_GV.dbname['session_formation_final_note_classement'].find_one_and_update(
|
||||
qry_key,
|
||||
{"$set": local_node},
|
||||
return_document=ReturnDocument.AFTER,
|
||||
upsert=True,
|
||||
)
|
||||
|
||||
|
||||
"""
|
||||
Après le calcul de la moyenne finale, il faut faire le classement
|
||||
"""
|
||||
basic_qry = {'partner_owner_recid': str(my_partner['recid']),
|
||||
'valide': '1',
|
||||
'locked': '0',
|
||||
'session_id': str(diction['session_id']),
|
||||
'ue_id': str(diction['ue_id']),
|
||||
}
|
||||
|
||||
|
||||
classement = 0
|
||||
note_precedente = ""
|
||||
for sorted_data in MYSY_GV.dbname['session_formation_final_note_classement'].find(basic_qry).sort([("note_finale", pymongo.DESCENDING), ]):
|
||||
# Gestion des Execo
|
||||
if( str(note_precedente) != str(sorted_data['note_finale'])):
|
||||
classement = classement + 1
|
||||
note_precedente = str(sorted_data['note_finale'])
|
||||
|
||||
#MAJ du rang
|
||||
print(" MAJJ classement = ", classement)
|
||||
MYSY_GV.dbname['session_formation_final_note_classement'].find_one_and_update(
|
||||
{'_id':ObjectId(str(sorted_data['_id'])),
|
||||
'partner_owner_recid':str(sorted_data['partner_owner_recid']),
|
||||
'valide':'1',
|
||||
'locked':'0'
|
||||
|
||||
},
|
||||
{"$set": {'rang':str(classement)}},
|
||||
return_document=ReturnDocument.AFTER,
|
||||
upsert=False,
|
||||
)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
return True, "Calcul Final Moyenne et Classement ok"
|
||||
|
||||
except Exception as e:
|
||||
exc_type, exc_obj, exc_tb = sys.exc_info()
|
||||
mycommon.myprint(str(inspect.stack()[0][3]) + " -" + str(e) + " - Line : " + str(exc_tb.tb_lineno))
|
||||
return False, " Impossible de lancer Cacul_Note_By_Evaluation_Type "
|
||||
|
||||
|
||||
|
||||
"""
|
||||
Cette fonction retourne la liste des notes finales
|
||||
d'une session de formation
|
||||
avec des filter sur :
|
||||
- la formation (code),
|
||||
- list UE tab_ue_id
|
||||
- list session tab_session_id
|
||||
|
||||
"""
|
||||
def Get_List_Evaluation_Final_Note_Classement_Detail_With_Filter(diction):
|
||||
try:
|
||||
diction = mycommon.strip_dictionary(diction)
|
||||
|
||||
"""
|
||||
Verification des input acceptés
|
||||
"""
|
||||
field_list = ['token','class_external_code', 'tab_ue_id', 'tab_session_id']
|
||||
|
||||
incom_keys = diction.keys()
|
||||
for val in incom_keys:
|
||||
if val not in field_list and val.startswith('my_') is False:
|
||||
mycommon.myprint(str(
|
||||
inspect.stack()[0][3]) + " Le champ '" + val + "' n'existe pas")
|
||||
return False, " Les informations fournies sont incorrectes",
|
||||
|
||||
"""
|
||||
Verification des champs obligatoires
|
||||
"""
|
||||
field_list_obligatoire = ['token', ]
|
||||
for val in field_list_obligatoire:
|
||||
if val not in diction:
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3]) + " - La valeur '" + val + "' n'est pas presente dans liste ")
|
||||
return False, " Les informations fournies sont incorrectes",
|
||||
|
||||
"""
|
||||
Verification de l'identité et autorisation de l'entité qui
|
||||
appelle cette API
|
||||
"""
|
||||
token = ""
|
||||
if ("token" in diction.keys()):
|
||||
if diction['token']:
|
||||
token = diction['token']
|
||||
|
||||
local_status, my_partner = mycommon.Check_Connexion_And_Return_Partner_Data(diction)
|
||||
if (local_status is not True):
|
||||
return local_status, my_partner
|
||||
|
||||
filt_session_id = {}
|
||||
if( "tab_session_id" in diction.keys() ):
|
||||
tab_session_id = str(diction['tab_session_id']).split(",")
|
||||
if(len(tab_session_id) > 0 ):
|
||||
filt_session_id = {'session_id':{'$in': tab_session_id }}
|
||||
|
||||
|
||||
filt_ue_id = {}
|
||||
if ("tab_ue_id" in diction.keys()):
|
||||
tab_ue_id = str(diction['tab_ue_id']).split(",")
|
||||
if (len(tab_ue_id) > 0):
|
||||
filt_ue_id = {'ue_id': {'$in': tab_ue_id}}
|
||||
|
||||
|
||||
|
||||
"""
|
||||
Clés de mise à jour
|
||||
"""
|
||||
data_cle = {}
|
||||
data_cle['partner_owner_recid'] = str(my_partner['recid'])
|
||||
data_cle['valide'] = "1"
|
||||
data_cle['locked'] = "0"
|
||||
|
||||
query = {"$and": [filt_session_id, filt_ue_id, data_cle]}
|
||||
|
||||
RetObject = []
|
||||
val_tmp = 0
|
||||
|
||||
for retval in MYSY_GV.dbname['session_formation_final_note_classement_detail'].find(query).sort([("ue_id", pymongo.DESCENDING),("inscription_id", pymongo.DESCENDING),
|
||||
("type_eval_id", pymongo.DESCENDING), ]):
|
||||
user = retval
|
||||
user['id'] = str(val_tmp)
|
||||
val_tmp = val_tmp + 1
|
||||
|
||||
ue_id_code = ""
|
||||
if( "ue_id" in retval.keys() ):
|
||||
ue_id_data = MYSY_GV.dbname['unite_enseignement'].find_one({'_id':ObjectId(str(retval['ue_id'])),
|
||||
'partner_owner_recid':my_partner['recid'],
|
||||
'valide':'1',
|
||||
'locked':'0'},
|
||||
{'code':1})
|
||||
if( ue_id_data and "code" in ue_id_data.keys() ):
|
||||
ue_id_code = ue_id_data['code']
|
||||
|
||||
user['ue_id_code'] = ue_id_code
|
||||
|
||||
class_id_external_code = ""
|
||||
if ("class_id" in retval.keys()):
|
||||
class_id_data = MYSY_GV.dbname['myclass'].find_one({'_id': ObjectId(str(retval['ue_id'])),
|
||||
'partner_owner_recid': my_partner['recid'],
|
||||
'valide': '1',
|
||||
'locked': '0'},
|
||||
{'external_code': 1})
|
||||
if (class_id_data and "external_code" in class_id_data.keys()):
|
||||
class_id_external_code = class_id_data['external_code']
|
||||
|
||||
user['class_id_external_code'] = class_id_external_code
|
||||
|
||||
inscription_id_nom = ""
|
||||
inscription_id_prenom = ""
|
||||
inscription_id_mail = ""
|
||||
if ("inscription_id" in retval.keys()):
|
||||
inscription_id_data = MYSY_GV.dbname['inscription'].find_one({'_id': ObjectId(str(retval['inscription_id'])),
|
||||
'partner_owner_recid': my_partner['recid'],
|
||||
'valide': '1',},
|
||||
{'email': 1, 'nom':1, 'prenom':1})
|
||||
|
||||
if (inscription_id_data and "email" in inscription_id_data.keys()):
|
||||
inscription_id_mail = inscription_id_data['email']
|
||||
|
||||
if (inscription_id_data and "nom" in inscription_id_data.keys()):
|
||||
inscription_id_nom = inscription_id_data['nom']
|
||||
|
||||
if (inscription_id_data and "prenom" in inscription_id_data.keys()):
|
||||
inscription_id_prenom = inscription_id_data['prenom']
|
||||
|
||||
|
||||
user['inscription_id_mail'] = inscription_id_mail
|
||||
user['inscription_id_nom'] = inscription_id_nom
|
||||
user['inscription_id_prenom'] = inscription_id_prenom
|
||||
|
||||
|
||||
RetObject.append(mycommon.JSONEncoder().encode(user))
|
||||
|
||||
return True, RetObject
|
||||
|
||||
|
||||
except Exception as e:
|
||||
exc_type, exc_obj, exc_tb = sys.exc_info()
|
||||
mycommon.myprint(str(inspect.stack()[0][3]) + " -" + str(e) + " - Line : " + str(exc_tb.tb_lineno))
|
||||
return False, " Impossible de récupérer la liste des évaluations "
|
||||
|
||||
|
||||
"""
|
||||
Recuperation des notes finales avec le classement
|
||||
"""
|
||||
def Get_List_Evaluation_Final_Note_Classement_With_Filter(diction):
|
||||
try:
|
||||
diction = mycommon.strip_dictionary(diction)
|
||||
|
||||
"""
|
||||
Verification des input acceptés
|
||||
"""
|
||||
field_list = ['token','class_external_code', 'tab_ue_id', 'tab_session_id']
|
||||
|
||||
incom_keys = diction.keys()
|
||||
for val in incom_keys:
|
||||
if val not in field_list and val.startswith('my_') is False:
|
||||
mycommon.myprint(str(
|
||||
inspect.stack()[0][3]) + " Le champ '" + val + "' n'existe pas")
|
||||
return False, " Les informations fournies sont incorrectes",
|
||||
|
||||
"""
|
||||
Verification des champs obligatoires
|
||||
"""
|
||||
field_list_obligatoire = ['token', ]
|
||||
for val in field_list_obligatoire:
|
||||
if val not in diction:
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3]) + " - La valeur '" + val + "' n'est pas presente dans liste ")
|
||||
return False, " Les informations fournies sont incorrectes",
|
||||
|
||||
"""
|
||||
Verification de l'identité et autorisation de l'entité qui
|
||||
appelle cette API
|
||||
"""
|
||||
token = ""
|
||||
if ("token" in diction.keys()):
|
||||
if diction['token']:
|
||||
token = diction['token']
|
||||
|
||||
local_status, my_partner = mycommon.Check_Connexion_And_Return_Partner_Data(diction)
|
||||
if (local_status is not True):
|
||||
return local_status, my_partner
|
||||
|
||||
filt_session_id = {}
|
||||
if( "tab_session_id" in diction.keys() ):
|
||||
tab_session_id = str(diction['tab_session_id']).split(",")
|
||||
if(len(tab_session_id) > 0 ):
|
||||
filt_session_id = {'session_id':{'$in': tab_session_id }}
|
||||
|
||||
|
||||
filt_ue_id = {}
|
||||
if ("tab_ue_id" in diction.keys()):
|
||||
tab_ue_id = str(diction['tab_ue_id']).split(",")
|
||||
if (len(tab_ue_id) > 0):
|
||||
filt_ue_id = {'ue_id': {'$in': tab_ue_id}}
|
||||
|
||||
|
||||
|
||||
"""
|
||||
Clés de mise à jour
|
||||
"""
|
||||
data_cle = {}
|
||||
data_cle['partner_owner_recid'] = str(my_partner['recid'])
|
||||
data_cle['valide'] = "1"
|
||||
data_cle['locked'] = "0"
|
||||
|
||||
query = {"$and": [filt_session_id, filt_ue_id, data_cle]}
|
||||
|
||||
RetObject = []
|
||||
val_tmp = 0
|
||||
|
||||
for retval in MYSY_GV.dbname['session_formation_final_note_classement'].find(query).sort([("ue_id", pymongo.DESCENDING),("inscription_id", pymongo.DESCENDING),
|
||||
("type_eval_id", pymongo.DESCENDING), ]):
|
||||
user = retval
|
||||
user['id'] = str(val_tmp)
|
||||
val_tmp = val_tmp + 1
|
||||
|
||||
ue_id_code = ""
|
||||
if( "ue_id" in retval.keys() ):
|
||||
ue_id_data = MYSY_GV.dbname['unite_enseignement'].find_one({'_id':ObjectId(str(retval['ue_id'])),
|
||||
'partner_owner_recid':my_partner['recid'],
|
||||
'valide':'1',
|
||||
'locked':'0'},
|
||||
{'code':1})
|
||||
if( ue_id_data and "code" in ue_id_data.keys() ):
|
||||
ue_id_code = ue_id_data['code']
|
||||
|
||||
user['ue_id_code'] = ue_id_code
|
||||
|
||||
class_id_external_code = ""
|
||||
if ("class_id" in retval.keys()):
|
||||
class_id_data = MYSY_GV.dbname['myclass'].find_one({'_id': ObjectId(str(retval['ue_id'])),
|
||||
'partner_owner_recid': my_partner['recid'],
|
||||
'valide': '1',
|
||||
'locked': '0'},
|
||||
{'external_code': 1})
|
||||
if (class_id_data and "external_code" in class_id_data.keys()):
|
||||
class_id_external_code = class_id_data['external_code']
|
||||
|
||||
user['class_id_external_code'] = class_id_external_code
|
||||
|
||||
inscription_id_nom = ""
|
||||
inscription_id_prenom = ""
|
||||
inscription_id_mail = ""
|
||||
if ("inscription_id" in retval.keys()):
|
||||
inscription_id_data = MYSY_GV.dbname['inscription'].find_one({'_id': ObjectId(str(retval['inscription_id'])),
|
||||
'partner_owner_recid': my_partner['recid'],
|
||||
'valide': '1',},
|
||||
{'email': 1, 'nom':1, 'prenom':1})
|
||||
|
||||
if (inscription_id_data and "email" in inscription_id_data.keys()):
|
||||
inscription_id_mail = inscription_id_data['email']
|
||||
|
||||
if (inscription_id_data and "nom" in inscription_id_data.keys()):
|
||||
inscription_id_nom = inscription_id_data['nom']
|
||||
|
||||
if (inscription_id_data and "prenom" in inscription_id_data.keys()):
|
||||
inscription_id_prenom = inscription_id_data['prenom']
|
||||
|
||||
|
||||
user['inscription_id_mail'] = inscription_id_mail
|
||||
user['inscription_id_nom'] = inscription_id_nom
|
||||
user['inscription_id_prenom'] = inscription_id_prenom
|
||||
|
||||
|
||||
RetObject.append(mycommon.JSONEncoder().encode(user))
|
||||
|
||||
return True, RetObject
|
||||
|
||||
|
||||
except Exception as e:
|
||||
exc_type, exc_obj, exc_tb = sys.exc_info()
|
||||
mycommon.myprint(str(inspect.stack()[0][3]) + " -" + str(e) + " - Line : " + str(exc_tb.tb_lineno))
|
||||
return False, " Impossible de récupérer la liste des évaluations "
|
||||
|
||||
|
|
66
main.py
66
main.py
|
@ -10419,6 +10419,18 @@ def Update_Evaluation_Planification():
|
|||
return jsonify(status=status, message=retval)
|
||||
|
||||
|
||||
"""
|
||||
API pour Dupliquer une évaluation planifiée
|
||||
"""
|
||||
@app.route('/myclass/api/Duplicate_Evaluation_Planification/', methods=['POST','GET'])
|
||||
@crossdomain(origin='*')
|
||||
def Duplicate_Evaluation_Planification():
|
||||
# On recupere le corps (payload) de la requete
|
||||
payload = mycommon.strip_dictionary (request.form.to_dict())
|
||||
print(" ### Duplicate_Evaluation_Planification payload = ",payload)
|
||||
status, retval = note_evaluation_mgt.Duplicate_Evaluation_Planification(payload)
|
||||
return jsonify(status=status, message=retval)
|
||||
|
||||
|
||||
|
||||
"""
|
||||
|
@ -12157,15 +12169,59 @@ def Add_Update_Equipe_Team_Membres():
|
|||
|
||||
|
||||
"""
|
||||
API de calcul de la note finale d'une formation avec le model : calcul_mode_1
|
||||
API de PRE PRE PRE calcul de la note finale
|
||||
"""
|
||||
@app.route('/myclass/api/run_calcul_mode_1', methods=['POST','GET'])
|
||||
@app.route('/myclass/api/run_pre_calcul_moyenne_somme', methods=['POST','GET'])
|
||||
@crossdomain(origin='*')
|
||||
def run_calcul_mode_1():
|
||||
def run_pre_calcul_moyenne_somme():
|
||||
# On recupere le corps (payload) de la requete
|
||||
payload = mycommon.strip_dictionary(request.form.to_dict())
|
||||
print(" ### run_calcul_mode_1 : payload = ",payload)
|
||||
localStatus, message= base_class_calcul_note.run_calcul_mode_1(payload)
|
||||
print(" ### run_pre_calcul_moyenne_somme : payload = ",payload)
|
||||
localStatus, message= base_class_calcul_note.run_pre_calcul_moyenne_somme(payload)
|
||||
return jsonify(status=localStatus, message=message )
|
||||
|
||||
|
||||
|
||||
"""
|
||||
API qui retourne les DETAIL de la note finale par type d'evaluation
|
||||
"""
|
||||
@app.route('/myclass/api/Get_List_Evaluation_Final_Note_Classement_Detail_With_Filter', methods=['POST','GET'])
|
||||
@crossdomain(origin='*')
|
||||
def Get_List_Evaluation_Final_Note_Classement_Detail_With_Filter():
|
||||
# On recupere le corps (payload) de la requete
|
||||
payload = mycommon.strip_dictionary(request.form.to_dict())
|
||||
print(" ### Get_List_Evaluation_Final_Note_Classement_Detail_With_Filter : payload = ",payload)
|
||||
localStatus, message= base_class_calcul_note.Get_List_Evaluation_Final_Note_Classement_Detail_With_Filter(payload)
|
||||
return jsonify(status=localStatus, message=message )
|
||||
|
||||
|
||||
|
||||
|
||||
"""
|
||||
API qui retourne la note finale et le classement sur une session de formation
|
||||
"""
|
||||
@app.route('/myclass/api/Get_List_Evaluation_Final_Note_Classement_With_Filter', methods=['POST','GET'])
|
||||
@crossdomain(origin='*')
|
||||
def Get_List_Evaluation_Final_Note_Classement_With_Filter():
|
||||
# On recupere le corps (payload) de la requete
|
||||
payload = mycommon.strip_dictionary(request.form.to_dict())
|
||||
print(" ### Get_List_Evaluation_Final_Note_Classement_With_Filter : payload = ",payload)
|
||||
localStatus, message= base_class_calcul_note.Get_List_Evaluation_Final_Note_Classement_With_Filter(payload)
|
||||
return jsonify(status=localStatus, message=message )
|
||||
|
||||
|
||||
|
||||
|
||||
"""
|
||||
API de calcul de la note finale d'une formation avec le model : calcul_mode_1
|
||||
"""
|
||||
@app.route('/myclass/api/Cacul_Note_Finale_For_calcul_mode_1', methods=['POST','GET'])
|
||||
@crossdomain(origin='*')
|
||||
def Cacul_Note_Finale_For_calcul_mode_1():
|
||||
# On recupere le corps (payload) de la requete
|
||||
payload = mycommon.strip_dictionary(request.form.to_dict())
|
||||
print(" ### Cacul_Note_Finale_For_calcul_mode_1 : payload = ",payload)
|
||||
localStatus, message= base_class_calcul_note.Cacul_Note_Finale_For_calcul_mode_1(payload)
|
||||
return jsonify(status=localStatus, message=message )
|
||||
|
||||
|
||||
|
|
|
@ -203,8 +203,8 @@ def Add_Evaluation_Planification(diction):
|
|||
new_data['valide'] = "1"
|
||||
new_data['locked'] = "0"
|
||||
|
||||
new_data['date_update'] = str(datetime.now())
|
||||
new_data['update_by'] = str(my_partner['_id'])
|
||||
new_data['create_date'] = str(datetime.now())
|
||||
new_data['created_by'] = str(my_partner['_id'])
|
||||
new_data['partner_owner_recid'] = str(my_partner['recid'])
|
||||
|
||||
inserted_id = MYSY_GV.dbname['note_evaluation'].insert_one(new_data).inserted_id
|
||||
|
@ -222,6 +222,7 @@ def Add_Evaluation_Planification(diction):
|
|||
return False, " Impossible de créer l'évaluation "
|
||||
|
||||
|
||||
|
||||
"""
|
||||
Mettre à jour une évaluation planifiée
|
||||
"""
|
||||
|
@ -422,6 +423,163 @@ def Update_Evaluation_Planification(diction):
|
|||
return False, " Impossible de mettre à jour l'évaluation "
|
||||
|
||||
|
||||
"""
|
||||
Dupliquer une évaluation planifiée
|
||||
"""
|
||||
def Duplicate_Evaluation_Planification(diction):
|
||||
try:
|
||||
diction = mycommon.strip_dictionary(diction)
|
||||
|
||||
"""
|
||||
Verification des input acceptés
|
||||
"""
|
||||
field_list = ['token', 'evaluation_id', ]
|
||||
|
||||
incom_keys = diction.keys()
|
||||
for val in incom_keys:
|
||||
if val not in field_list and val.startswith('my_') is False:
|
||||
mycommon.myprint(str(
|
||||
inspect.stack()[0][3]) + " Le champ '" + val + "' n'est pas autorisé")
|
||||
return False, " Les informations fournies sont incorrectes"
|
||||
|
||||
"""
|
||||
Verification des champs obligatoires
|
||||
"""
|
||||
field_list_obligatoire = ['token', 'evaluation_id', ]
|
||||
|
||||
for val in field_list_obligatoire:
|
||||
if val not in diction:
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3]) + " - La valeur '" + val + "' n'est pas presente dans liste ")
|
||||
return False, " Les informations fournies sont incorrectes"
|
||||
|
||||
"""
|
||||
Verification de l'identité et autorisation de l'entité qui
|
||||
appelle cette API
|
||||
"""
|
||||
token = ""
|
||||
if ("token" in diction.keys()):
|
||||
if diction['token']:
|
||||
token = diction['token']
|
||||
|
||||
local_status, my_partner = mycommon.Check_Connexion_And_Return_Partner_Data(diction)
|
||||
if (local_status is not True):
|
||||
return local_status, my_partner
|
||||
|
||||
|
||||
"""
|
||||
Verifier que class_ue_id est valide
|
||||
"""
|
||||
is_evaluation_id_existe_class = MYSY_GV.dbname['note_evaluation'].count_documents({ '_id':ObjectId(str(diction['evaluation_id'])),
|
||||
'partner_owner_recid':my_partner['recid'],
|
||||
'valide': '1',
|
||||
'locked': '0'
|
||||
})
|
||||
|
||||
if (is_evaluation_id_existe_class != 1):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3]) + " L'identifiant de l'évaluation est invalide ")
|
||||
return False, " L'identifiant de l'évaluation est invalide "
|
||||
"""
|
||||
# Verifier que les element de l'evaluation existent et sont valides. par exmple, la formation, la session, le responsable etc
|
||||
class_id, class_eu_id, type_eval_id, session_id, responsable_id
|
||||
"""
|
||||
evaluation_id_data = MYSY_GV.dbname['note_evaluation'].find_one(
|
||||
{'_id': ObjectId(str(diction['evaluation_id'])),
|
||||
'partner_owner_recid': my_partner['recid'],
|
||||
'valide': '1',
|
||||
'locked': '0'
|
||||
})
|
||||
|
||||
if( evaluation_id_data and "class_id" in evaluation_id_data.keys() and evaluation_id_data['class_id']):
|
||||
is_existe_class_and_class_ue = MYSY_GV.dbname['myclass'].count_documents(
|
||||
{'_id': ObjectId(str(evaluation_id_data['class_id'])),
|
||||
'list_unite_enseignement._id': str(evaluation_id_data['class_eu_id']),
|
||||
'partner_owner_recid': my_partner['recid'],
|
||||
'valide': '1',
|
||||
'locked': '0'})
|
||||
|
||||
if (is_existe_class_and_class_ue != 1):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3]) + " La formation et l'UE ne sont pas cohérents ")
|
||||
return False, " La formation et l'UE ne sont pas cohérents "
|
||||
|
||||
|
||||
if (evaluation_id_data and "type_eval_id" in evaluation_id_data.keys() and evaluation_id_data['type_eval_id']):
|
||||
is_valide_type_eval = MYSY_GV.dbname['type_evaluation'].count_documents(
|
||||
{'_id': ObjectId(str(evaluation_id_data['type_eval_id'])),
|
||||
'partner_owner_recid': my_partner[
|
||||
'recid'],
|
||||
'valide': '1',
|
||||
'locked': '0'})
|
||||
|
||||
if (is_valide_type_eval != 1):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3]) + " L'identifiant du type d'évaluation est invalide ")
|
||||
return False, " L'identifiant du type d'évaluation est invalide "
|
||||
|
||||
if (evaluation_id_data and "responsable_id" in evaluation_id_data.keys() and evaluation_id_data['responsable_id']):
|
||||
is_valide_responsable = MYSY_GV.dbname['ressource_humaine'].count_documents(
|
||||
{'_id': ObjectId(str(evaluation_id_data['responsable_id'])),
|
||||
'partner_recid': my_partner[
|
||||
'recid'],
|
||||
'valide': '1',
|
||||
'locked': '0'})
|
||||
|
||||
if (is_valide_responsable != 1):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3]) + " L'identifiant du responsable de l'évaluation est invalide ")
|
||||
return False, " L'identifiant du responsable de l'évaluation est invalide "
|
||||
|
||||
|
||||
if (evaluation_id_data and "session_id" in evaluation_id_data.keys() and evaluation_id_data['session_id']):
|
||||
is_valide_session_id = MYSY_GV.dbname['session_formation'].count_documents(
|
||||
{'_id': ObjectId(str(evaluation_id_data['session_id'])),
|
||||
'partner_owner_recid': my_partner[
|
||||
'recid'],
|
||||
'valide': '1',
|
||||
})
|
||||
|
||||
if (is_valide_session_id != 1):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3]) + " L'identifiant de la session (class) est invalide ")
|
||||
return False, " L'identifiant de la session (class) est invalide "
|
||||
|
||||
|
||||
new_data = evaluation_id_data
|
||||
|
||||
del new_data['_id']
|
||||
new_data['code'] = "Dup_"+str(evaluation_id_data['code'])
|
||||
|
||||
new_data['valide'] = "1"
|
||||
new_data['locked'] = "0"
|
||||
|
||||
new_data['create_date'] = str(datetime.now())
|
||||
new_data['created_by'] = str(my_partner['_id'])
|
||||
new_data['partner_owner_recid'] = str(my_partner['recid'])
|
||||
|
||||
|
||||
result = MYSY_GV.dbname['note_evaluation'].insert_one(new_data).inserted_id
|
||||
|
||||
|
||||
|
||||
if (result is None ):
|
||||
mycommon.myprint(
|
||||
" Impossible de dupliquer l'évaluation (2) ")
|
||||
return False, " Impossible de mettre à jour l'évaluation (2) "
|
||||
|
||||
|
||||
|
||||
|
||||
return True, " L'évaluation a été correctement dupliquée"
|
||||
|
||||
except Exception as e:
|
||||
exc_type, exc_obj, exc_tb = sys.exc_info()
|
||||
mycommon.myprint(str(inspect.stack()[0][3]) + " -" + str(e) + " - Line : " + str(exc_tb.tb_lineno))
|
||||
return False, " Impossible de dupliquer l'évaluation "
|
||||
|
||||
|
||||
|
||||
"""
|
||||
Recuperation de la liste des evaluation planifiée
|
||||
"""
|
||||
|
@ -2029,7 +2187,7 @@ def Get_List_Participant_Notes(diction):
|
|||
}
|
||||
|
||||
]
|
||||
print("#### Get_List_Participant_Notes laa 01 : query = ", query)
|
||||
#print("#### Get_List_Participant_Notes laa 01 : query = ", query)
|
||||
for retval in MYSY_GV.dbname['note_evaluation_participant'].aggregate(query):
|
||||
if( "note_evaluation_collection" in retval.keys() ):
|
||||
user = {}
|
||||
|
|
Loading…
Reference in New Issue