parent
c6dd32c31d
commit
79ca3fb207
|
@ -1,10 +1,11 @@
|
|||
<?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="13/05/2025 - 20h">
|
||||
<list default="true" id="c6d0259a-16e1-410d-91a1-830590ee2a08" name="Changes" comment="14/05/2025 - 20h">
|
||||
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/Dashbord_queries/inscription_tdb_qries.py" beforeDir="false" afterPath="$PROJECT_DIR$/Dashbord_queries/inscription_tdb_qries.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" />
|
||||
</list>
|
||||
<option name="SHOW_DIALOG" value="false" />
|
||||
|
@ -82,13 +83,6 @@
|
|||
<option name="presentableId" value="Default" />
|
||||
<updated>1680804787304</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00411" summary="qsdsqqs">
|
||||
<created>1729684312512</created>
|
||||
<option name="number" value="00411" />
|
||||
<option name="presentableId" value="LOCAL-00411" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1729684312514</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00412" summary="29/10/2024 - 18h30">
|
||||
<created>1730223616262</created>
|
||||
<option name="number" value="00412" />
|
||||
|
@ -425,7 +419,14 @@
|
|||
<option name="project" value="LOCAL" />
|
||||
<updated>1747159305323</updated>
|
||||
</task>
|
||||
<option name="localTasksCounter" value="460" />
|
||||
<task id="LOCAL-00460" summary="14/05/2025 - 20h">
|
||||
<created>1747251650255</created>
|
||||
<option name="number" value="00460" />
|
||||
<option name="presentableId" value="LOCAL-00460" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1747251650255</updated>
|
||||
</task>
|
||||
<option name="localTasksCounter" value="461" />
|
||||
<servers />
|
||||
</component>
|
||||
<component name="Vcs.Log.Tabs.Properties">
|
||||
|
@ -467,7 +468,6 @@
|
|||
</option>
|
||||
</component>
|
||||
<component name="VcsManagerConfiguration">
|
||||
<MESSAGE value="30/01/2025 - 16h" />
|
||||
<MESSAGE value="01/02/2025 - 20h" />
|
||||
<MESSAGE value="06-02-2025 - new_design_2025" />
|
||||
<MESSAGE value="08/02/205 - 22h30" />
|
||||
|
@ -492,6 +492,7 @@
|
|||
<MESSAGE value="08/05/2025 - 19" />
|
||||
<MESSAGE value="13/05/2025 - 17h" />
|
||||
<MESSAGE value="13/05/2025 - 20h" />
|
||||
<option name="LAST_COMMIT_MESSAGE" value="13/05/2025 - 20h" />
|
||||
<MESSAGE value="14/05/2025 - 20h" />
|
||||
<option name="LAST_COMMIT_MESSAGE" value="14/05/2025 - 20h" />
|
||||
</component>
|
||||
</project>
|
|
@ -1717,12 +1717,3 @@ def TBD_Inscription_Export_Dashbord_To_Csv(diction):
|
|||
return False, " Impossible d'exporter les données "
|
||||
|
||||
|
||||
|
||||
"""
|
||||
TDB : Nombre d'inscription par session
|
||||
"""
|
||||
|
||||
|
||||
"""
|
||||
TDB : Nombre d'inscription par formation
|
||||
"""
|
1607
Log/log_file.log
1607
Log/log_file.log
File diff suppressed because it is too large
Load Diff
54
main.py
54
main.py
|
@ -10690,6 +10690,60 @@ def Export_To_Excel_List_Participant_To_Evaluation(token, evaluation_id):
|
|||
return False
|
||||
|
||||
|
||||
|
||||
"""
|
||||
API pour Recuperer toutes les notes d'une list d'apprenant (APPRENANT, PAS INSCRIT)
|
||||
avec des filtres possible sur les session et les ue
|
||||
filtre :
|
||||
- session (list)
|
||||
- ue (list)
|
||||
- appreant (list)
|
||||
"""
|
||||
@app.route('/myclass/api/Get_List_Apprenant_Notes_With_Filter/', methods=['POST','GET'])
|
||||
@crossdomain(origin='*')
|
||||
def Get_List_Apprenant_Notes_With_Filter():
|
||||
# On recupere le corps (payload) de la requete
|
||||
payload = mycommon.strip_dictionary (request.form.to_dict())
|
||||
print(" ### Get_List_Apprenant_Notes_With_Filter payload = ",payload)
|
||||
status, retval = note_evaluation_mgt.Get_List_Apprenant_Notes_With_Filter(payload)
|
||||
return jsonify(status=status, message=retval)
|
||||
|
||||
|
||||
"""
|
||||
API pour exporter au format excel toutes les notes d'une list d'apprenant (APPRENANT, PAS INSCRIT)
|
||||
avec des filtres possible sur les session et les ue
|
||||
filtre :
|
||||
- session (list)
|
||||
- ue (list)
|
||||
- appreant (list)
|
||||
"""
|
||||
@app.route('/myclass/api/Export_To_Excel_List_Apprenant_Notes_With_Filter/<token>/<list_session_id>/<list_ue_id>/<list_apprenant_id>', methods=['POST','GET'])
|
||||
@crossdomain(origin='*')
|
||||
def Export_To_Excel_List_Apprenant_Notes_With_Filter(token, list_session_id, list_ue_id, list_apprenant_id ):
|
||||
# On recupere le corps (payload) de la requete
|
||||
payload = mycommon.strip_dictionary (request.form.to_dict())
|
||||
payload = {}
|
||||
payload['token'] = str(token)
|
||||
if( str(list_session_id) != "-"):
|
||||
payload['list_session_id'] = str(list_session_id)
|
||||
|
||||
if (str(list_ue_id) != "-"):
|
||||
payload['list_ue_id'] = str(list_ue_id)
|
||||
|
||||
if( str(list_apprenant_id) != "-"):
|
||||
payload['list_apprenant_id'] = str(list_apprenant_id)
|
||||
|
||||
|
||||
print(" ### Export_To_Excel_List_Apprenant_Notes_With_Filter payload = ",payload)
|
||||
|
||||
status, retval = note_evaluation_mgt.Export_To_Excel_List_Apprenant_Notes_With_Filter(payload)
|
||||
if(status ):
|
||||
return retval
|
||||
else:
|
||||
return False
|
||||
|
||||
|
||||
|
||||
"""
|
||||
API pour verifier la disponibilité d'une ressource sur un creneau donnée dans l'agenda
|
||||
"""
|
||||
|
|
|
@ -2334,10 +2334,6 @@ def Export_Excel_List_Participant_Notes(diction):
|
|||
Verification de la validité de la liste des inscription
|
||||
"""
|
||||
|
||||
|
||||
#print("tab_my_session_ids = ", tab_my_session_ids)
|
||||
|
||||
|
||||
for my_inscription_id in tab_my_inscription_ids:
|
||||
# Verifier qui la formation n'a pas deja été evaluée
|
||||
|
||||
|
@ -2813,6 +2809,7 @@ filtre :
|
|||
Algorithme :
|
||||
1 - recuperer toutes les 'inscription_id' appartenant a un 'apprenant_id' ==> tab_inscription
|
||||
2 - recuperer les 'evaluation_id' concernée par la list_ue_id
|
||||
3 - recuperer les 'evaluation_id' concernée par la list_session_id
|
||||
|
||||
"""
|
||||
|
||||
|
@ -2835,7 +2832,7 @@ def Get_List_Apprenant_Notes_With_Filter(diction):
|
|||
"""
|
||||
Verification des champs obligatoires
|
||||
"""
|
||||
field_list_obligatoire = ['token', 'list_session_id', 'list_ue_id', 'list_apprenant_id' ]
|
||||
field_list_obligatoire = ['token', 'list_apprenant_id' ]
|
||||
|
||||
for val in field_list_obligatoire:
|
||||
if val not in diction:
|
||||
|
@ -2865,6 +2862,7 @@ def Get_List_Apprenant_Notes_With_Filter(diction):
|
|||
tab_my_session_ids = str(my_session_ids).split(",")
|
||||
tab_my_session_ids_ObjectId = []
|
||||
for tmp in tab_my_session_ids:
|
||||
if( tmp ):
|
||||
tab_my_session_ids_ObjectId.append(ObjectId(str(tmp)))
|
||||
|
||||
filt_session_ids = {}
|
||||
|
@ -2881,6 +2879,7 @@ def Get_List_Apprenant_Notes_With_Filter(diction):
|
|||
tab_my_ue_ids = str(my_ue_ids).split(",")
|
||||
tab_my_ue_ids_ObjectId = []
|
||||
for tmp in tab_my_ue_ids:
|
||||
if (tmp):
|
||||
tab_my_ue_ids_ObjectId.append(ObjectId(str(tmp)))
|
||||
|
||||
filt_ue_ids = {}
|
||||
|
@ -2898,6 +2897,7 @@ def Get_List_Apprenant_Notes_With_Filter(diction):
|
|||
tab_my_apprenant_ids = str(my_apprenant_ids).split(",")
|
||||
tab_my_apprenant_ids_ObjectId = []
|
||||
for tmp in tab_my_apprenant_ids:
|
||||
if (tmp):
|
||||
tab_my_apprenant_ids_ObjectId.append(ObjectId(str(tmp)))
|
||||
|
||||
filt_apprenant_ids = {}
|
||||
|
@ -2909,6 +2909,9 @@ def Get_List_Apprenant_Notes_With_Filter(diction):
|
|||
"""
|
||||
filt_concerned_tab_inscription_id = {}
|
||||
concerned_tab_inscription_id = []
|
||||
|
||||
|
||||
|
||||
for val in MYSY_GV.dbname['inscription'].find({'apprenant_id':{'$in': tab_my_apprenant_ids } ,
|
||||
'valide':'1',
|
||||
'locked':'0',
|
||||
|
@ -2918,25 +2921,51 @@ def Get_List_Apprenant_Notes_With_Filter(diction):
|
|||
if(len(concerned_tab_inscription_id) > 0 ):
|
||||
filt_concerned_tab_inscription_id = {"inscription_id": {"$in": concerned_tab_inscription_id}}
|
||||
|
||||
|
||||
|
||||
|
||||
"""
|
||||
2 - Recuperer les evaluation_id
|
||||
2 - Recuperer les evaluation_id concernée par l'UE
|
||||
"""
|
||||
filt_concerned_tab_evaluation_id = {}
|
||||
concerned_tab_evaluation_id = []
|
||||
|
||||
|
||||
|
||||
for val in MYSY_GV.dbname['note_evaluation'].find({'class_eu_id': {'$in': tab_my_ue_ids},
|
||||
'valide': '1',
|
||||
'locked': '0',
|
||||
'partner_owner_recid': str(my_partner['recid'])}):
|
||||
|
||||
concerned_tab_evaluation_id.append((str(val['_id'])))
|
||||
|
||||
if (len(concerned_tab_evaluation_id) > 0):
|
||||
filt_concerned_tab_evaluation_id = {"evaluation_id": {"$in": concerned_tab_inscription_id}}
|
||||
filt_concerned_tab_evaluation_id = {"evaluation_id": {"$in": concerned_tab_evaluation_id}}
|
||||
|
||||
|
||||
"""
|
||||
3 - Recuperer les session_id
|
||||
"""
|
||||
filt_concerned_tab_session_id = {}
|
||||
concerned_tab_session_id = []
|
||||
|
||||
for val in MYSY_GV.dbname['note_evaluation'].find({'class_eu_id': {'$in': tab_my_session_ids},
|
||||
'valide': '1',
|
||||
'locked': '0',
|
||||
'partner_owner_recid': str(my_partner['recid'])}):
|
||||
concerned_tab_session_id.append((str(val['_id'])))
|
||||
|
||||
if (len(concerned_tab_session_id) > 0):
|
||||
filt_concerned_tab_session_id = {"evaluation_id": {"$in": concerned_tab_session_id}}
|
||||
|
||||
|
||||
qery_match = {'$and': [{"partner_owner_recid": str(my_partner['recid'])},
|
||||
{"valide": '1'},
|
||||
{"locked": '0'},
|
||||
filt_concerned_tab_inscription_id,
|
||||
filt_concerned_tab_evaluation_id
|
||||
filt_concerned_tab_evaluation_id,
|
||||
filt_concerned_tab_session_id,
|
||||
|
||||
|
||||
]}
|
||||
|
||||
|
@ -2966,84 +2995,19 @@ def Get_List_Apprenant_Notes_With_Filter(diction):
|
|||
}
|
||||
},
|
||||
{'$project': {'_id': 1, 'code': 1, 'titre': 1, 'class_id': 1, 'class_eu_id': 1,
|
||||
'type_eval_id': 1, 'session_id': 1, 'partner_owner_recid': 1}}
|
||||
'type_eval_id': 1, 'session_id': 1, 'partner_owner_recid': 1,
|
||||
'eval_date_heure_debut':1, 'eval_date_heure_fin':1}}
|
||||
|
||||
],
|
||||
'as': 'note_evaluation_collection'
|
||||
}}
|
||||
])
|
||||
|
||||
print(" ### Get_List_Apprenant_Notes_With_Filter ici pipe_qry = ", pipe_qry)
|
||||
#print(" ### Get_List_Apprenant_Notes_With_Filter ici pipe_qry = ", pipe_qry)
|
||||
cpt = 0
|
||||
tab_lines_inscription_data = []
|
||||
for retval in MYSY_GV.dbname['note_evaluation_participant'].aggregate(pipe_qry):
|
||||
cpt = cpt + 1
|
||||
print(" ### retval = ", retval)
|
||||
|
||||
"""
|
||||
Verification de la validité de la liste des inscription
|
||||
"""
|
||||
|
||||
|
||||
#print("tab_my_session_ids = ", tab_my_session_ids)
|
||||
|
||||
|
||||
for my_inscription_id in tab_my_inscription_ids:
|
||||
# Verifier qui la formation n'a pas deja été evaluée
|
||||
|
||||
|
||||
|
||||
tmp_count = MYSY_GV.dbname['inscription'].count_documents({'session_id': {'$in': tab_my_session_ids, },
|
||||
'_id': ObjectId(str(my_inscription_id)),
|
||||
'partner_owner_recid': str(my_partner['recid']),
|
||||
} )
|
||||
|
||||
if (tmp_count != 1):
|
||||
mycommon.myprint(str(inspect.stack()[0][3]) + " L'inscription "+str(my_inscription_id)+" est invalide ")
|
||||
return False, " L'inscription "+str(my_inscription_id)+" est invalide "
|
||||
|
||||
"""
|
||||
Verification de la validité de la liste des sessions
|
||||
"""
|
||||
for my_session_ids in tab_my_session_ids:
|
||||
# Verifier qui la formation n'a pas deja été evaluée
|
||||
tmp_count = MYSY_GV.dbname['session_formation'].count_documents({'_id': ObjectId(str(my_session_ids)),
|
||||
'partner_owner_recid': str(my_partner['recid']),
|
||||
'valide':'1'
|
||||
} )
|
||||
|
||||
if (tmp_count != 1):
|
||||
mycommon.myprint(str(inspect.stack()[0][3]) + " La session "+str(my_session_ids)+" est invalide ")
|
||||
return False, " L'inscription "+str(my_session_ids)+" est invalide "
|
||||
|
||||
|
||||
RetObject = []
|
||||
nb_val = 0
|
||||
|
||||
query = [{'$match': {'inscription_id': {'$in':tab_my_inscription_ids}, 'partner_owner_recid': str(my_partner['recid']),
|
||||
}},
|
||||
{'$sort': {'_id': -1}},
|
||||
{'$lookup':
|
||||
{
|
||||
'from': 'note_evaluation',
|
||||
"let": {'evaluation_id': "$evaluation_id", 'partner_owner_recid': '$partner_owner_recid'},
|
||||
'pipeline': [{'$match':
|
||||
{'$expr': {'$and': [
|
||||
{'$eq': ["$valide", "1"]},
|
||||
{'$eq': ["$_id", {'$convert': {
|
||||
'input': "$$evaluation_id",
|
||||
'to': "objectId",
|
||||
'onError': {'error': 'true'},
|
||||
'onNull': {'isnull': 'true'}
|
||||
}}]},
|
||||
|
||||
]}}},
|
||||
], 'as': 'note_evaluation_collection'}
|
||||
}
|
||||
|
||||
]
|
||||
#print("#### Get_List_Participant_Notes laa 01 : query = ", query)
|
||||
for retval in MYSY_GV.dbname['note_evaluation_participant'].aggregate(query):
|
||||
for retval in MYSY_GV.dbname['note_evaluation_participant'].aggregate(pipe_qry):
|
||||
if ("note_evaluation_collection" in retval.keys()):
|
||||
user = {}
|
||||
nom_apprenant = ""
|
||||
|
@ -3052,13 +3016,14 @@ def Get_List_Apprenant_Notes_With_Filter(diction):
|
|||
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']))},
|
||||
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']))},
|
||||
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']
|
||||
|
@ -3080,7 +3045,8 @@ def Get_List_Apprenant_Notes_With_Filter(diction):
|
|||
ue_data = MYSY_GV.dbname['unite_enseignement'].find_one({'_id': ObjectId(str(user['class_eu_id'])),
|
||||
'valide': '1',
|
||||
'locked': '0',
|
||||
'partner_owner_recid':str(my_partner['recid'])})
|
||||
'partner_owner_recid': str(
|
||||
my_partner['recid'])})
|
||||
if ("code" in ue_data.keys()):
|
||||
class_ue_code = str(ue_data['code'])
|
||||
if ("titre" in ue_data.keys()):
|
||||
|
@ -3089,38 +3055,34 @@ def Get_List_Apprenant_Notes_With_Filter(diction):
|
|||
user['class_ue_code'] = class_ue_code
|
||||
user['class_ue_titre'] = class_ue_titre
|
||||
|
||||
|
||||
user['type_eval_id'] = str(retval['note_evaluation_collection'][0]['type_eval_id'])
|
||||
type_eval_data = MYSY_GV.dbname['type_eval_id'].find_one({'_id': ObjectId(str(user['type_eval_id'])),
|
||||
'valide': '1',
|
||||
'locked': '0',
|
||||
'partner_owner_recid':str(my_partner['recid'])})
|
||||
'partner_owner_recid': str(
|
||||
my_partner['recid'])})
|
||||
if (type_eval_data and 'code' in type_eval_data.keys()):
|
||||
user['type_eval_code'] = type_eval_data['code']
|
||||
else:
|
||||
user['type_eval_code'] = ""
|
||||
|
||||
|
||||
|
||||
|
||||
user['eval_date_heure_debut'] = str(retval['note_evaluation_collection'][0]['eval_date_heure_debut'])
|
||||
user['eval_date_heure_fin'] = str(retval['note_evaluation_collection'][0]['eval_date_heure_fin'])
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
user['nom'] = nom_apprenant
|
||||
user['prenom'] = prenom_apprenant
|
||||
user['email'] = email_apprenant
|
||||
user['id'] = str(nb_val)
|
||||
user['id'] = str(cpt)
|
||||
if ("note" not in retval.keys()):
|
||||
user['note'] = "-1"
|
||||
|
||||
nb_val = nb_val + 1
|
||||
cpt = cpt + 1
|
||||
|
||||
RetObject.append(mycommon.JSONEncoder().encode(user))
|
||||
|
||||
#print(" ### user = ", user)
|
||||
|
||||
|
||||
return True, RetObject
|
||||
|
||||
except Exception as e:
|
||||
|
@ -3128,3 +3090,392 @@ def Get_List_Apprenant_Notes_With_Filter(diction):
|
|||
mycommon.myprint(str(inspect.stack()[0][3]) + " -" + str(e) + " - ERRORRRR AT Line : " + str(exc_tb.tb_lineno))
|
||||
return False, "Impossible de récupérer les notes de l'apprenant"
|
||||
|
||||
|
||||
"""
|
||||
Cette fonction permet d'exporter les notes d'une list d'apprenant (APPRENANT, PAS INSCRIT)
|
||||
avec des filtres possible sur les session et les ue
|
||||
filtre :
|
||||
- session (list)
|
||||
- ue (list)
|
||||
- appreant (list)
|
||||
"""
|
||||
def Export_To_Excel_List_Apprenant_Notes_With_Filter(diction):
|
||||
try:
|
||||
diction = mycommon.strip_dictionary(diction)
|
||||
|
||||
"""
|
||||
Verification des input acceptés
|
||||
"""
|
||||
field_list = ['token', 'list_session_id', 'list_ue_id', 'list_apprenant_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', 'list_apprenant_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 la liste des arguments ")
|
||||
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
|
||||
|
||||
### Les sessions de formation
|
||||
my_session_ids = ""
|
||||
if ("list_session_id" in diction.keys()):
|
||||
if diction['list_session_id']:
|
||||
my_session_ids = diction['list_session_id']
|
||||
|
||||
tab_my_session_ids = str(my_session_ids).split(",")
|
||||
tab_my_session_ids_ObjectId = []
|
||||
for tmp in tab_my_session_ids:
|
||||
if( tmp ):
|
||||
tab_my_session_ids_ObjectId.append(ObjectId(str(tmp)))
|
||||
|
||||
filt_session_ids = {}
|
||||
if(len(tab_my_session_ids) > 0 ):
|
||||
filt_session_ids = {'session_id':{'$in':tab_my_session_ids}}
|
||||
|
||||
|
||||
### Les ue
|
||||
my_ue_ids = ""
|
||||
if ("list_ue_id" in diction.keys()):
|
||||
if diction['list_ue_id']:
|
||||
my_ue_ids = diction['list_ue_id']
|
||||
|
||||
tab_my_ue_ids = str(my_ue_ids).split(",")
|
||||
tab_my_ue_ids_ObjectId = []
|
||||
for tmp in tab_my_ue_ids:
|
||||
if (tmp):
|
||||
tab_my_ue_ids_ObjectId.append(ObjectId(str(tmp)))
|
||||
|
||||
filt_ue_ids = {}
|
||||
if (len(tab_my_ue_ids) > 0):
|
||||
filt_ue_ids = {'ue_id': {'$in': tab_my_ue_ids}}
|
||||
|
||||
|
||||
|
||||
### Les apprenants
|
||||
my_apprenant_ids = ""
|
||||
if ("list_apprenant_id" in diction.keys()):
|
||||
if diction['list_apprenant_id']:
|
||||
my_apprenant_ids = diction['list_apprenant_id']
|
||||
|
||||
tab_my_apprenant_ids = str(my_apprenant_ids).split(",")
|
||||
tab_my_apprenant_ids_ObjectId = []
|
||||
for tmp in tab_my_apprenant_ids:
|
||||
if (tmp):
|
||||
tab_my_apprenant_ids_ObjectId.append(ObjectId(str(tmp)))
|
||||
|
||||
filt_apprenant_ids = {}
|
||||
if (len(tab_my_apprenant_ids) > 0):
|
||||
filt_apprenant_ids = {'apprenant_id': {'$in': tab_my_apprenant_ids}}
|
||||
|
||||
"""
|
||||
1 - Recuperer les inscription_id
|
||||
"""
|
||||
filt_concerned_tab_inscription_id = {}
|
||||
concerned_tab_inscription_id = []
|
||||
|
||||
|
||||
|
||||
for val in MYSY_GV.dbname['inscription'].find({'apprenant_id':{'$in': tab_my_apprenant_ids } ,
|
||||
'valide':'1',
|
||||
'locked':'0',
|
||||
'partner_owner_recid':str(my_partner['recid'])}):
|
||||
concerned_tab_inscription_id.append((str(val['_id'])))
|
||||
|
||||
if(len(concerned_tab_inscription_id) > 0 ):
|
||||
filt_concerned_tab_inscription_id = {"inscription_id": {"$in": concerned_tab_inscription_id}}
|
||||
|
||||
|
||||
|
||||
|
||||
"""
|
||||
2 - Recuperer les evaluation_id concernée par l'UE
|
||||
"""
|
||||
filt_concerned_tab_evaluation_id = {}
|
||||
concerned_tab_evaluation_id = []
|
||||
|
||||
|
||||
|
||||
for val in MYSY_GV.dbname['note_evaluation'].find({'class_eu_id': {'$in': tab_my_ue_ids},
|
||||
'valide': '1',
|
||||
'locked': '0',
|
||||
'partner_owner_recid': str(my_partner['recid'])}):
|
||||
|
||||
concerned_tab_evaluation_id.append((str(val['_id'])))
|
||||
|
||||
if (len(concerned_tab_evaluation_id) > 0):
|
||||
filt_concerned_tab_evaluation_id = {"evaluation_id": {"$in": concerned_tab_evaluation_id}}
|
||||
|
||||
|
||||
"""
|
||||
3 - Recuperer les session_id
|
||||
"""
|
||||
filt_concerned_tab_session_id = {}
|
||||
concerned_tab_session_id = []
|
||||
|
||||
for val in MYSY_GV.dbname['note_evaluation'].find({'class_eu_id': {'$in': tab_my_session_ids},
|
||||
'valide': '1',
|
||||
'locked': '0',
|
||||
'partner_owner_recid': str(my_partner['recid'])}):
|
||||
concerned_tab_session_id.append((str(val['_id'])))
|
||||
|
||||
if (len(concerned_tab_session_id) > 0):
|
||||
filt_concerned_tab_session_id = {"evaluation_id": {"$in": concerned_tab_session_id}}
|
||||
|
||||
|
||||
qery_match = {'$and': [{"partner_owner_recid": str(my_partner['recid'])},
|
||||
{"valide": '1'},
|
||||
{"locked": '0'},
|
||||
filt_concerned_tab_inscription_id,
|
||||
filt_concerned_tab_evaluation_id,
|
||||
filt_concerned_tab_session_id,
|
||||
|
||||
|
||||
]}
|
||||
|
||||
pipe_qry = ([
|
||||
{'$match': qery_match},
|
||||
{'$lookup': {
|
||||
'from': 'note_evaluation',
|
||||
"let": {'evaluation_id': "$evaluation_id", 'partner_owner_recid': '$partner_owner_recid'},
|
||||
'pipeline': [
|
||||
{'$match':
|
||||
{'$expr':
|
||||
{'$and':
|
||||
[
|
||||
|
||||
{'$eq': ["$_id", {'$convert': {
|
||||
'input': "$$evaluation_id",
|
||||
'to': "objectId",
|
||||
'onError': {'error': 'true'},
|
||||
'onNull': {'isnull': 'true'}
|
||||
}}]},
|
||||
|
||||
{'$eq': ["$valide", "1"]},
|
||||
{'$eq': ["$partner_owner_recid", '$$partner_owner_recid']},
|
||||
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
{'$project': {'_id': 1, 'code': 1, 'titre': 1, 'class_id': 1, 'class_eu_id': 1,
|
||||
'type_eval_id': 1, 'session_id': 1, 'partner_owner_recid': 1,
|
||||
'eval_date_heure_debut':1, 'eval_date_heure_fin':1}}
|
||||
|
||||
],
|
||||
'as': 'note_evaluation_collection'
|
||||
}}
|
||||
])
|
||||
|
||||
ts = datetime.now().timestamp()
|
||||
ts = str(ts).replace(".", "").replace(",", "")[-5:]
|
||||
|
||||
orig_file_name = "Export_Reponse_" + str(ts) + ".xlsx"
|
||||
outputFilename = str(MYSY_GV.TEMPORARY_DIRECTORY) + "/" + str(orig_file_name)
|
||||
|
||||
tab_exported_fields_header = ["formation", "classe", "evaluation_code", "evaluation_titre",
|
||||
"evaluation_eval_date_heure_debut", "evaluation_eval_date_heure_fin",
|
||||
"nom_apprenant",
|
||||
"prenom_apprenant", "email_apprenant", "evaluation_note", ]
|
||||
|
||||
# Create a workbook and add a worksheet.
|
||||
workbook = xlsxwriter.Workbook(outputFilename)
|
||||
worksheet = workbook.add_worksheet()
|
||||
|
||||
nb_val = 0
|
||||
row = 0
|
||||
column = 0
|
||||
|
||||
"""
|
||||
Creation de l'entete du fichier excel
|
||||
"""
|
||||
|
||||
for header_item in tab_exported_fields_header:
|
||||
worksheet.write(row, column, header_item)
|
||||
column += 1
|
||||
|
||||
"""
|
||||
Creation des data du fichier excel
|
||||
"""
|
||||
|
||||
#print(" ### Get_List_Apprenant_Notes_With_Filter ici pipe_qry = ", pipe_qry)
|
||||
cpt = 0
|
||||
tab_lines_inscription_data = []
|
||||
RetObject = []
|
||||
for retval in MYSY_GV.dbname['note_evaluation_participant'].aggregate(pipe_qry):
|
||||
if ("note_evaluation_collection" in retval.keys()):
|
||||
user = {}
|
||||
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['_id'] = str(retval['_id'])
|
||||
user['evaluation_id'] = str(retval['evaluation_id'])
|
||||
user['inscription_id'] = str(retval['inscription_id'])
|
||||
user['note'] = str(retval['note'])
|
||||
|
||||
user['note_evaluation_id'] = str(retval['note_evaluation_collection'][0]['_id'])
|
||||
user['note_evaluation_code'] = str(retval['note_evaluation_collection'][0]['code'])
|
||||
|
||||
user['note_evaluation_titre'] = str(retval['note_evaluation_collection'][0]['titre'])
|
||||
user['session_id'] = str(retval['note_evaluation_collection'][0]['session_id'])
|
||||
user['class_eu_id'] = str(retval['note_evaluation_collection'][0]['class_eu_id'])
|
||||
|
||||
class_ue_code = ""
|
||||
class_ue_titre = ""
|
||||
ue_data = MYSY_GV.dbname['unite_enseignement'].find_one({'_id': ObjectId(str(user['class_eu_id'])),
|
||||
'valide': '1',
|
||||
'locked': '0',
|
||||
'partner_owner_recid': str(
|
||||
my_partner['recid'])})
|
||||
if ("code" in ue_data.keys()):
|
||||
class_ue_code = str(ue_data['code'])
|
||||
if ("titre" in ue_data.keys()):
|
||||
class_ue_titre = str(ue_data['titre'])
|
||||
|
||||
user['class_ue_code'] = class_ue_code
|
||||
user['class_ue_titre'] = class_ue_titre
|
||||
|
||||
user['type_eval_id'] = str(retval['note_evaluation_collection'][0]['type_eval_id'])
|
||||
type_eval_data = MYSY_GV.dbname['type_eval_id'].find_one({'_id': ObjectId(str(user['type_eval_id'])),
|
||||
'valide': '1',
|
||||
'locked': '0',
|
||||
'partner_owner_recid': str(
|
||||
my_partner['recid'])})
|
||||
if (type_eval_data and 'code' in type_eval_data.keys()):
|
||||
user['type_eval_code'] = type_eval_data['code']
|
||||
else:
|
||||
user['type_eval_code'] = ""
|
||||
|
||||
user['eval_date_heure_debut'] = str(retval['note_evaluation_collection'][0]['eval_date_heure_debut'])
|
||||
user['eval_date_heure_fin'] = str(retval['note_evaluation_collection'][0]['eval_date_heure_fin'])
|
||||
|
||||
user['nom'] = nom_apprenant
|
||||
user['prenom'] = prenom_apprenant
|
||||
user['email'] = email_apprenant
|
||||
user['id'] = str(cpt)
|
||||
if ("note" not in retval.keys()):
|
||||
user['note'] = "-1"
|
||||
|
||||
evaluation_formation = ""
|
||||
evaluation_code_session = ""
|
||||
|
||||
# Recuperation des données de la session
|
||||
session_data = MYSY_GV.dbname['session_formation'].find_one(
|
||||
{'_id': ObjectId(str(user['session_id'])),
|
||||
'valide': '1',
|
||||
'partner_owner_recid': str(my_partner['recid'])})
|
||||
|
||||
if (session_data and "code_session" in session_data.keys()):
|
||||
evaluation_code_session = session_data['code_session']
|
||||
|
||||
# Recuperer les données de la formation
|
||||
if( "class_internal_url" in session_data and session_data['class_internal_url']):
|
||||
qry_class = {'internal_url': str(session_data['class_internal_url']),
|
||||
'valide': '1', 'locked': '0',
|
||||
'partner_owner_recid': str(my_partner['recid'])}
|
||||
|
||||
class_data = MYSY_GV.dbname['myclass'].find_one(qry_class)
|
||||
|
||||
if (class_data and "title" in class_data.keys()):
|
||||
evaluation_formation = class_data['title']
|
||||
|
||||
|
||||
column = 0
|
||||
row = row + 1
|
||||
|
||||
# Champ : formation
|
||||
worksheet.write(row, column, evaluation_formation)
|
||||
column += 1
|
||||
|
||||
# Champ : classe / evaluation_code_session
|
||||
worksheet.write(row, column, evaluation_code_session)
|
||||
column += 1
|
||||
|
||||
# Champ : evaluation_code
|
||||
worksheet.write(row, column, str(retval['note_evaluation_collection'][0]['code']) )
|
||||
column += 1
|
||||
|
||||
# Champ : evaluation_titre
|
||||
worksheet.write(row, column, str(retval['note_evaluation_collection'][0]['titre']) )
|
||||
column += 1
|
||||
|
||||
# Champ : evaluation_eval_date_heure_debut
|
||||
worksheet.write(row, column, str(retval['note_evaluation_collection'][0]['eval_date_heure_debut']) )
|
||||
column += 1
|
||||
|
||||
# Champ : evaluation_eval_date_heure_fin
|
||||
worksheet.write(row, column, str(retval['note_evaluation_collection'][0]['eval_date_heure_fin']) )
|
||||
column += 1
|
||||
|
||||
# Champ : nom
|
||||
worksheet.write(row, column, user['nom'])
|
||||
column += 1
|
||||
|
||||
# Champ : prenom
|
||||
worksheet.write(row, column, user['prenom'])
|
||||
column += 1
|
||||
|
||||
# Champ : email
|
||||
worksheet.write(row, column, user['email'])
|
||||
column += 1
|
||||
|
||||
# Champ : note
|
||||
worksheet.write(row, column, user['note'])
|
||||
column += 1
|
||||
|
||||
|
||||
cpt = cpt + 1
|
||||
|
||||
RetObject.append(mycommon.JSONEncoder().encode(user))
|
||||
|
||||
#print(" ### user = ", user)
|
||||
|
||||
|
||||
workbook.close()
|
||||
if os.path.exists(outputFilename):
|
||||
# print(" ### ok os.path.exists(outputFilename) "+str(outputFilename))
|
||||
return True, send_file(outputFilename, as_attachment=True)
|
||||
|
||||
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 d'exporter les notes de l'apprenant"
|
||||
|
|
Loading…
Reference in New Issue