19/05/2024 - 22h15

master
cherif 2024-05-19 22:15:33 +02:00
parent ae5e5a99e6
commit 52fcecb308
6 changed files with 5588 additions and 17 deletions

View File

@ -1,9 +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="sdf">
<list default="true" id="c6d0259a-16e1-410d-91a1-830590ee2a08" name="Changes" comment="18/05/2024 - 22h30">
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" 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$/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" />
<change beforePath="$PROJECT_DIR$/unite_enseignement_mgt.py" beforeDir="false" afterPath="$PROJECT_DIR$/unite_enseignement_mgt.py" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
@ -73,13 +77,6 @@
<option name="presentableId" value="Default" />
<updated>1680804787304</updated>
</task>
<task id="LOCAL-00256" summary="04/04/24 - 19h30">
<created>1712250957207</created>
<option name="number" value="00256" />
<option name="presentableId" value="LOCAL-00256" />
<option name="project" value="LOCAL" />
<updated>1712250957207</updated>
</task>
<task id="LOCAL-00257" summary="04/04/24 - 21h30">
<created>1712258561441</created>
<option name="number" value="00257" />
@ -416,7 +413,14 @@
<option name="project" value="LOCAL" />
<updated>1716053773666</updated>
</task>
<option name="localTasksCounter" value="305" />
<task id="LOCAL-00305" summary="18/05/2024 - 22h30">
<created>1716064737342</created>
<option name="number" value="00305" />
<option name="presentableId" value="LOCAL-00305" />
<option name="project" value="LOCAL" />
<updated>1716064737343</updated>
</task>
<option name="localTasksCounter" value="306" />
<servers />
</component>
<component name="Vcs.Log.Tabs.Properties">
@ -458,7 +462,6 @@
</option>
</component>
<component name="VcsManagerConfiguration">
<MESSAGE value="27/04/2024 - 22h" />
<MESSAGE value="28/04/2024 - 22h" />
<MESSAGE value="02/05/2024 - 22h" />
<MESSAGE value="sss" />
@ -483,6 +486,7 @@
<MESSAGE value="ddd" />
<MESSAGE value="17/05/2024 - 21h30" />
<MESSAGE value="sdf" />
<option name="LAST_COMMIT_MESSAGE" value="sdf" />
<MESSAGE value="18/05/2024 - 22h30" />
<option name="LAST_COMMIT_MESSAGE" value="18/05/2024 - 22h30" />
</component>
</project>

View File

@ -11239,3 +11239,115 @@ def Get_Statgaire_List_Partner_with_filter_FOR_ONLY_INSCRIPTION_NO_TOKEN(diction
exc_type, exc_obj, exc_tb = sys.exc_info()
mycommon.myprint(str(inspect.stack()[0][3]) + " -" + str(e) + " - ERRORRRR AT Line : " + str(exc_tb.tb_lineno))
return False, "Impossible de récupérer la liste des stagiaires"
"""
Cette fonction prend l'_id d'une session et retourne les inscriptions qui sont valide
avec un nombre de champs limité
"""
def Get_Accepted_Insription_From_Session_id_Reduice_Fields(diction):
try:
field_list = ['token', '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'est pas autorisé, Creation partenaire annulée")
return False, "de récupérer la liste des stagiaires . Toutes les informations fournies ne sont pas valables"
"""
Verification de la liste des champs obligatoires
"""
field_list_obligatoire = ['token', 'session_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, "Impossible de récupérer la liste des stagiaires, Toutes les informations necessaires n'ont pas été fournies"
# Recuperation du recid du partner
mydata = {}
mytoken = ""
if ("token" in diction.keys()):
if diction['token']:
mytoken = diction['token']
# Verifier la validité du token
retval = mycommon.check_partner_token_validity("", mytoken)
if retval is False:
return "Err_Connexion", " La session de connexion n'est pas valide"
partner_recid = mycommon.get_parnter_recid_from_token(mytoken)
if (partner_recid is False):
mycommon.myprint(str(inspect.stack()[0][3]) + " - Impossible de récupérer la liste des stagiaires, ")
return False, "Impossible de récupérer la liste des stagiaires, Les informations d'identification sont incorrectes "
class_internal_url = ""
if ("class_internal_url" in diction.keys()):
if diction['class_internal_url']:
class_internal_url = diction['class_internal_url']
session_id = ""
if ("session_id" in diction.keys()):
if diction['session_id']:
session_id = diction['session_id']
## Recuperation de toutes les stagiaire rattaché à cette session
coll_session = MYSY_GV.dbname['inscription']
myquery = {}
myquery['session_id'] = session_id
myquery['status'] = "1"
myquery['valide'] = "1"
RetObject = []
val_tmp = 0
#print(" #### myquery 01111 = "+str(myquery))
for retval in coll_session.find(myquery,
{'_id':1, 'email':1,
'session_id':1,
'apprenant_id':1,
}).sort([("_id", pymongo.DESCENDING), ]):
val_tmp = val_tmp + 1
user = retval
user['id'] = str(val_tmp)
apprenant_nom = ""
apprenant_prenom = ""
apprenant_email = ""
# Si il a un apprenant_id
# print(" ### retVal = ", retVal )
if ("apprenant_id" in retval.keys()):
if (retval['apprenant_id'] and str(retval['apprenant_id']) != 'undefined'):
apprenant_retval = MYSY_GV.dbname['apprenant'].find_one(
{'_id': ObjectId(retval['apprenant_id']),
'valide': '1', 'locked': '0'})
if (apprenant_retval is not None):
apprenant_nom = apprenant_retval['nom']
apprenant_prenom = apprenant_retval['prenom']
apprenant_email = apprenant_retval['email']
user['apprenant_nom'] = apprenant_nom
user['apprenant_prenom'] = apprenant_prenom
user['apprenant_email'] = apprenant_email
user['groupe'] = ""
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) + " - ERRORRRR AT Line : " + str(exc_tb.tb_lineno))
return False, "Impossible de récupérer la liste des stagiaires de la formation"

File diff suppressed because it is too large Load Diff

73
main.py
View File

@ -4531,6 +4531,21 @@ def Get_Statgaire_List_Partner_with_filter_FOR_ONLY_INSCRIPTION_NO_TOKEN():
"""
API qui prend l'_id d'une session et retourne les inscriptions qui sont valide
avec un nombre de champs limité
"""
@app.route('/myclass/api/Get_Accepted_Insription_From_Session_id_Reduice_Fields/', methods=['POST','GET'])
@crossdomain(origin='*')
def Get_Accepted_Insription_From_Session_id_Reduice_Fields():
# On recupere le corps (payload) de la requete
payload = mycommon.strip_dictionary (request.form.to_dict())
print(" ### Get_Accepted_Insription_From_Session_id_Reduice_Fields payload = ",payload)
status, retval = inscription.Get_Accepted_Insription_From_Session_id_Reduice_Fields(payload)
return jsonify(status=status, message=retval)
"""
API qui recupere les informations d'une inscription en partant de '_id' de la ligne
@ -9453,6 +9468,60 @@ def Delete_Evaluation_Planification():
return jsonify(status=status, message=retval)
"""
API pour inscrire des participants ou groupes de paricipants
à une évaluation
"""
@app.route('/myclass/api/Record_Participant_To_Evaluation/', methods=['POST','GET'])
@crossdomain(origin='*')
def Record_Participant_To_Evaluation():
# On recupere le corps (payload) de la requete
payload = mycommon.strip_dictionary (request.form.to_dict())
print(" ### Record_Participant_To_Evaluation payload = ",payload)
status, retval = note_evaluation_mgt.Record_Participant_To_Evaluation(payload)
return jsonify(status=status, message=retval)
"""
API pour desinscrire / supprimer des participants ou groupes de paricipants
à une évaluation
"""
@app.route('/myclass/api/Delete_Participant_From_Evaluation/', methods=['POST','GET'])
@crossdomain(origin='*')
def Delete_Participant_From_Evaluation():
# On recupere le corps (payload) de la requete
payload = mycommon.strip_dictionary (request.form.to_dict())
print(" ### Delete_Participant_From_Evaluation payload = ",payload)
status, retval = note_evaluation_mgt.Delete_Participant_From_Evaluation(payload)
return jsonify(status=status, message=retval)
"""
API pour Mise à jour les note evaluation
à une évaluation
"""
@app.route('/myclass/api/Update_Participant_Evaluation_Note/', methods=['POST','GET'])
@crossdomain(origin='*')
def Update_Participant_Evaluation_Note():
# On recupere le corps (payload) de la requete
payload = mycommon.strip_dictionary (request.form.to_dict())
print(" ### Update_Participant_Evaluation_Note payload = ",payload)
status, retval = note_evaluation_mgt.Update_Participant_Evaluation_Note(payload)
return jsonify(status=status, message=retval)
"""
API pour Recuperer la liste des inscrits et groupe inscrit à une
evaluation
"""
@app.route('/myclass/api/Get_List_Participant_To_Evaluation/', methods=['POST','GET'])
@crossdomain(origin='*')
def Get_List_Participant_To_Evaluation():
# On recupere le corps (payload) de la requete
payload = mycommon.strip_dictionary (request.form.to_dict())
print(" ### Get_List_Participant_To_Evaluation payload = ",payload)
status, retval = note_evaluation_mgt.Get_List_Participant_To_Evaluation(payload)
return jsonify(status=status, message=retval)
@ -9478,7 +9547,7 @@ if __name__ == '__main__':
/!\ Dasactivé en dev pour pas consommer de ressource pr rien.
"""
"""
scheduler = BackgroundScheduler()
# Create the job
scheduler.add_job(func=Flask_Cron_Strip_Get_Customer_Abonnement_Data, trigger="interval", minutes=3)
@ -9492,7 +9561,7 @@ if __name__ == '__main__':
# /!\ IMPORTANT /!\ : Shut down the scheduler when exiting the app
atexit.register(lambda: scheduler.shutdown())
"""
app.run(host='localhost', port=MYSY_GV.MYSY_PORT_DEV, debug=True, threaded=True)
# Create the background scheduler

View File

@ -14,6 +14,8 @@ Par exemple la saisie d'une evaluation planifiée :
En suite la saisie de la note dans la collection : 'note_evaluation_apprenant'
"""
import ast
import bson
import pymongo
from pymongo import MongoClient
@ -385,6 +387,7 @@ def Update_Evaluation_Planification(diction):
new_data['update_by'] = str(my_partner['_id'])
new_data['partner_owner_recid'] = str(my_partner['recid'])
result = MYSY_GV.dbname['note_evaluation'].find_one_and_update(
{'_id': ObjectId(str(local_evaluation_id)),
'partner_owner_recid': my_partner['recid'],
@ -701,6 +704,13 @@ def Get_Given_Evaluation_Planification(diction):
user = retval
user['id'] = str(val_tmp)
val_tmp = val_tmp + 1
# Recuperer l'internal url de la formation
class_data = MYSY_GV.dbname['myclass'].find_one({'_id':ObjectId(str(retval['class_id'])),
'partner_owner_recid':str(my_partner['recid'])})
user['class_internal_url'] = str(class_data['internal_url'])
RetObject.append(mycommon.JSONEncoder().encode(user))
return True, RetObject
@ -716,7 +726,8 @@ def Get_Given_Evaluation_Planification(diction):
"""
Supprimer une evaluation planifiée
/!\ : les regles de suppression ne sont pas encore implémentés
Regle :
Un évaluation n'est supprimable que s'il n'y pas d'incrit dans la collection "note_evaluation_participant"
"""
def Delete_Evaluation_Planification(diction):
try:
@ -773,6 +784,16 @@ def Delete_Evaluation_Planification(diction):
str(inspect.stack()[0][3]) + " L'identifiant de l'évaluation est invalide ")
return False, " L'identifiant de l'évaluation est invalide "
note_evaluation_participant_count = MYSY_GV.dbname['note_evaluation_participant'].count_documents({'evaluation_id':str(diction['evaluation_id']),
'partner_owner_recid':str(my_partner['recid']),
'valide':'1'})
if( note_evaluation_participant_count > 0 ):
mycommon.myprint(
str(inspect.stack()[0][3]) + " Il y a "+str(note_evaluation_participant_count)+" inscription(s) pour cette evaluation. Suppression annulée ")
return False, " Il y a "+str(note_evaluation_participant_count)+" inscription(s) pour cette evaluation. Suppression annulée "
delete = MYSY_GV.dbname['note_evaluation'].delete_one({ '_id':ObjectId(str(diction['evaluation_id'])),
'partner_owner_recid':my_partner['recid'],
'valide': '1',
@ -789,3 +810,475 @@ def Delete_Evaluation_Planification(diction):
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 supprimer l'évaluation "
"""
Inscrire des participants ou groupe de participants a un évaluation
"""
def Record_Participant_To_Evaluation(diction):
try:
diction = mycommon.strip_dictionary(diction)
"""
Verification des input acceptés
"""
field_list = ['token', 'evaluation_id', 'tab_inscription_id', 'tab_group_inscription_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', 'tab_inscription_id', 'tab_group_inscription_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 l'evaluation est valide
"""
is_evaluation_valide = MYSY_GV.dbname['note_evaluation'].count_documents({"_id":ObjectId(str(diction['evaluation_id'])),
'valide':'1',
'locked':'0',
'partner_owner_recid':str(my_partner['recid'])})
if( is_evaluation_valide != 1):
mycommon.myprint(
str(inspect.stack()[0][3]) + " L'identifiant de l'évaluation n'est pas valide ")
return False, " L'identifiant de l'évaluation n'est pas valide "
tab_inscription_id = str(diction['tab_inscription_id']).split(",")
for inscription_id in tab_inscription_id:
# Verifier que le stagiaire est bien inscrit. Le statut de l'inscription doit etre "1"
if( inscription_id ):
is_inscription_valide = MYSY_GV.dbname['inscription'].count_documents(
{'_id': ObjectId(str(inscription_id)),
'status': '1',
'partner_owner_recid': str(my_partner['recid'])})
if (is_inscription_valide != 1):
mycommon.myprint(
str(inspect.stack()[0][
3]) + " L'identifiant de l'inscription "+str(inscription_id)+" est invalide ")
return False, " L'identifiant de l'inscription "+str(inscription_id)+" est invalide "
tab_group_inscription_id = str(diction['tab_group_inscription_id']).split(",")
for group_inscription_id in tab_group_inscription_id:
# Verifier que le stagiaire est bien inscrit. Le statut de l'inscription doit etre "1"
if( group_inscription_id ):
is_tab_inscription_valide = MYSY_GV.dbname['group_inscription'].count_documents(
{'_id': ObjectId(str(group_inscription_id)),
'status': '1',
'partner_owner_recid': str(my_partner['recid'])})
if (is_tab_inscription_valide != 1):
mycommon.myprint(
str(inspect.stack()[0][
3]) + " L'identifiant du group d'inscription " + str(group_inscription_id) + " est invalide ")
return False, " L'identifiant du group d'inscription " + str(group_inscription_id) + " est invalide "
"""
Gestion des inscription des inscrits (PAS LES GROUPE. Ils seront traités plus bas)
"""
warning_msg = ""
is_warning = ""
for inscription_id in tab_inscription_id:
if( inscription_id ):
new_data = {}
new_data['evaluation_id'] = str(diction['evaluation_id'])
new_data['inscription_id'] = str(inscription_id)
new_data['group_inscription_id'] = ""
new_data['note'] = ""
new_data['valide'] = "1"
new_data['locked'] = "0"
new_data['partner_owner_recid'] = str(my_partner['recid'])
new_data['date_update'] = str(datetime.now())
new_data['update_by'] = str(my_partner['_id'])
ret_val = MYSY_GV.dbname['note_evaluation_participant'].find_one_and_update(
{'evaluation_id': str(diction['evaluation_id']), 'inscription_id': str(inscription_id),
'partner_owner_recid':str(my_partner['recid'])},
{"$set": new_data},
return_document=ReturnDocument.AFTER,
upsert=True,
)
if (ret_val is None):
mycommon.myprint(str(inspect.stack()[0][3]) + " WARNING : Impossible d'inscrire la participant : " + str(inscription_id))
is_warning = "1"
warning_msg = warning_msg + "\n Impossible d'inscrire la participant " + str(inscription_id)
#warning_msg = ""
#is_warning = ""
for group_inscription_id in tab_group_inscription_id:
if( group_inscription_id ):
new_data = {}
new_data['evaluation_id'] = str(diction['evaluation_id'])
new_data['inscription_id'] = ""
new_data['group_inscription_id'] = str(group_inscription_id)
new_data['note'] = ""
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['partner_owner_recid'] = str(my_partner['recid'])
ret_val = MYSY_GV.dbname['note_evaluation_participant'].find_one_and_update(
{'evaluation_id': str(diction['evaluation_id']), 'group_inscription_id': str(group_inscription_id),
'partner_owner_recid':str(my_partner['recid'])},
{"$set": new_data},
return_document=ReturnDocument.AFTER,
upsert=True,
)
if (ret_val is None):
mycommon.myprint(str(
inspect.stack()[0][3]) + " WARNING : Impossible d'inscrire le groupe " + str(group_inscription_id))
is_warning = "1"
warning_msg = warning_msg + "\n Impossible d'inscrire le groupe " + str(group_inscription_id)
if (is_warning == "1"):
return True, str(warning_msg)
return True, " L'inscription a été correctement faite"
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 d'inscrire les participants à l'évaluation "
"""
Supprimer / Desinscrire des participants ou groupes de participants
a un évaluation
"""
def Delete_Participant_From_Evaluation(diction):
try:
diction = mycommon.strip_dictionary(diction)
"""
Verification des input acceptés
"""
field_list = ['token', 'evaluation_id', 'tab_inscription_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', 'tab_inscription_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 l'evaluation est valide
"""
is_evaluation_valide = MYSY_GV.dbname['note_evaluation'].count_documents(
{"_id": ObjectId(str(diction['evaluation_id'])),
'valide': '1',
'locked': '0',
'partner_owner_recid': str(my_partner['recid'])})
if (is_evaluation_valide != 1):
mycommon.myprint(
str(inspect.stack()[0][3]) + " L'identifiant de l'évaluation n'est pas valide ")
return False, " L'identifiant de l'évaluation n'est pas valide "
tab_id_to_delete = []
tab_inscription_id = str(diction['tab_inscription_id']).split(",")
for inscription_id in tab_inscription_id:
if( inscription_id ):
# Verifier que le stagiaire est bien inscrit. Le statut de l'inscription doit etre "1"
is_inscription_valide = MYSY_GV.dbname['note_evaluation_participant'].count_documents(
{'_id': ObjectId(str(inscription_id)),
'partner_owner_recid': str(my_partner['recid'])})
if (is_inscription_valide != 1):
mycommon.myprint(
str(inspect.stack()[0][
3]) + " L'identifiant de l'inscription " + str(inscription_id) + " est invalide ")
return False, " L'identifiant de l'inscription " + str(inscription_id) + " est invalide "
tab_id_to_delete.append(ObjectId(str(inscription_id)))
warning_msg = ""
is_warning = ""
# Suppression des inscription
if( len(tab_id_to_delete) > 0 and tab_id_to_delete[0]):
qry_delete_inscription = {'partner_owner_recid': str(my_partner['recid']),
"_id": {"$in": tab_id_to_delete},
}
print(" ### qry_delete_inscription = ", qry_delete_inscription )
MYSY_GV.dbname['note_evaluation_participant'].delete_many(qry_delete_inscription)
return True, " La suppression a été correctement faite"
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 supprimer les inscriptions à l'évaluation "
"""
Mise à jour note evaluation
Cette fonction met à jour la note d'un inscrit ou groupe d'inscrit.
{note_evaluation_participant_id:'kjdskjkdj',
tab_participant_note [
{note_evaluation_participant_id:'4444', note:'33'},
{note_evaluation_participant_id:'4444', note:'33'}
]
}
"""
def Update_Participant_Evaluation_Note(diction):
try:
diction = mycommon.strip_dictionary(diction)
"""
Verification des input acceptés
"""
field_list = ['token', 'evaluation_id', 'tab_participant_note']
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', 'tab_participant_note']
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 l'evaluation est valide
"""
is_evaluation_valide = MYSY_GV.dbname['note_evaluation'].count_documents(
{"_id": ObjectId(str(diction['evaluation_id'])),
'valide': '1',
'locked': '0',
'partner_owner_recid': str(my_partner['recid'])})
if (is_evaluation_valide != 1):
mycommon.myprint(
str(inspect.stack()[0][3]) + " L'identifiant de l'évaluation n'est pas valide ")
return False, " L'identifiant de l'évaluation n'est pas valide "
JSON_tab_participant_note = ast.literal_eval(diction['tab_participant_note'])
for val in JSON_tab_participant_note:
if( '_id' in val.keys() and val['_id'] ):
print(" #### VAL = ", val)
new_data = {}
if("note" in val.keys() ):
new_data['note'] = str(val['note'])
else:
new_data['note'] = "-1"
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['partner_owner_recid'] = str(my_partner['recid'])
ret_val = MYSY_GV.dbname['note_evaluation_participant'].find_one_and_update(
{'_id': ObjectId(str(val['_id'])),
'partner_owner_recid': str(my_partner['recid'])},
{"$set": new_data},
return_document=ReturnDocument.AFTER,
upsert=False,
)
return True, " La mise à jour des notes été correctement faite"
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 mettre à jour les notes "
"""
Recuperer la liste des inscrits et groupe inscrit à une
evaluation
"""
def Get_List_Participant_To_Evaluation(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 l'evaluation est valide
"""
is_evaluation_valide = MYSY_GV.dbname['note_evaluation'].count_documents({"_id":ObjectId(str(diction['evaluation_id'])),
'valide':'1',
'locked':'0',
'partner_owner_recid':str(my_partner['recid'])})
if( is_evaluation_valide != 1):
mycommon.myprint(
str(inspect.stack()[0][3]) + " L'identifiant de l'évaluation n'est pas valide ")
return False, " L'identifiant de l'évaluation n'est pas valide "
RetObject = []
nb_val = 0
for retval in MYSY_GV.dbname['note_evaluation_participant'].find({'evaluation_id':str(diction['evaluation_id']),
'valide':'1',
'locked':'0',
'partner_owner_recid':str(my_partner['recid']),
}):
user = retval
nom_apprenant = ""
prenom_apprenant = ""
email_apprenant = ""
groupe = ""
if( "inscription_id" in retval and retval['inscription_id']):
# Recuprer les données de l'inscrit
inscription_data = MYSY_GV.dbname['inscription'].find_one({'_id':ObjectId(str(retval['inscription_id']))},
{'_id':1, 'apprenant_id':1})
apprenant_data = MYSY_GV.dbname['apprenant'].find_one({'_id':ObjectId(str(inscription_data['apprenant_id']))},
{'_id':1, 'nom':1, 'prenom':1, 'email':1})
nom_apprenant = apprenant_data['nom']
prenom_apprenant = apprenant_data['prenom']
email_apprenant = apprenant_data['email']
user['nom'] = nom_apprenant
user['prenom'] = prenom_apprenant
user['email'] = email_apprenant
user['id'] = str(nb_val)
if( "note" not in retval.keys() ):
user['note'] = "-1"
nb_val = nb_val + 1
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) + " - ERRORRRR AT Line : " + str(exc_tb.tb_lineno))
return False, "Impossible de récupérer la liste des inscrits à l'évaluation"

View File

@ -533,9 +533,7 @@ def Delete_Given_Unite_Enseignement(diction):
"""
Recuperer une UE données
"""
"""
Recuperer la liste des UE, sans filtres
"""
def Get_Given_Unite_Enseignement(diction):
try:
diction = mycommon.strip_dictionary(diction)
@ -647,8 +645,25 @@ def Get_List_Unite_Enseignement_Of_Given_Class(diction):
RetObject = []
val_tmp = 0
is_qry_data = "0"
if( "class_id" in diction.keys() and diction['class_id']) :
is_qry_data = "1"
if ("class_internal_url" in diction.keys() and diction['class_internal_url']):
is_qry_data = "1"
if( is_qry_data == "0" ):
# L'utilisateur n'a fournir aucun element pour faire la requete. on retourne du vide dans ce cas.
user = []
RetObject.append(mycommon.JSONEncoder().encode(user))
# print(" #### RetObject = ", RetObject)
return True, RetObject
if( "class_id" in diction.keys() and diction['class_id']):
qry = {"partner_owner_recid":str(my_partner['recid']), 'valide':'1', 'locked':'0', '_id':ObjectId(str(diction['class_id']))}
elif ( "class_internal_url" in diction.keys() and diction['class_internal_url'] ):
qry = {"partner_owner_recid": str(my_partner['recid']), 'valide': '1', 'locked': '0',
'internal_url': str(diction['class_internal_url'])}
@ -659,9 +674,13 @@ def Get_List_Unite_Enseignement_Of_Given_Class(diction):
for local_val in New_retVal['list_unite_enseignement'] :
user = local_val
user['id'] = str(val_tmp)
val_tmp = val_tmp + 1
user['class_id'] = str(New_retVal['_id'])
user['internal_url'] = str(New_retVal['internal_url'])
"""
Recuperation des données associées à cette UE
"""