ssq
parent
58745ba95c
commit
0469d3db9d
|
@ -1,7 +1,9 @@
|
|||
<?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="06/06/2024 - 20h">
|
||||
<list default="true" id="c6d0259a-16e1-410d-91a1-830590ee2a08" name="Changes" comment="07/06/2024 - 22h30">
|
||||
<change afterPath="$PROJECT_DIR$/mysy_packages.py" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/suivi_pedagogique_mgt.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" 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" />
|
||||
|
@ -75,13 +77,6 @@
|
|||
<option name="presentableId" value="Default" />
|
||||
<updated>1680804787304</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00278" summary="25/04/2024 - 19h">
|
||||
<created>1714065354319</created>
|
||||
<option name="number" value="00278" />
|
||||
<option name="presentableId" value="LOCAL-00278" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1714065354319</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00279" summary="27/04/2024 - 22h">
|
||||
<created>1714248179438</created>
|
||||
<option name="number" value="00279" />
|
||||
|
@ -418,7 +413,14 @@
|
|||
<option name="project" value="LOCAL" />
|
||||
<updated>1717697890412</updated>
|
||||
</task>
|
||||
<option name="localTasksCounter" value="327" />
|
||||
<task id="LOCAL-00327" summary="07/06/2024 - 22h30">
|
||||
<created>1717791275942</created>
|
||||
<option name="number" value="00327" />
|
||||
<option name="presentableId" value="LOCAL-00327" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1717791275945</updated>
|
||||
</task>
|
||||
<option name="localTasksCounter" value="328" />
|
||||
<servers />
|
||||
</component>
|
||||
<component name="Vcs.Log.Tabs.Properties">
|
||||
|
@ -460,7 +462,6 @@
|
|||
</option>
|
||||
</component>
|
||||
<component name="VcsManagerConfiguration">
|
||||
<MESSAGE value="13/05/2024 - 18h30" />
|
||||
<MESSAGE value="14/05/2024 - 21h30" />
|
||||
<MESSAGE value="sds" />
|
||||
<MESSAGE value="sdsdd" />
|
||||
|
@ -485,6 +486,7 @@
|
|||
<MESSAGE value="05/06/2024 - 23h" />
|
||||
<MESSAGE value="06/06/2024 - 12h" />
|
||||
<MESSAGE value="06/06/2024 - 20h" />
|
||||
<option name="LAST_COMMIT_MESSAGE" value="06/06/2024 - 20h" />
|
||||
<MESSAGE value="07/06/2024 - 22h30" />
|
||||
<option name="LAST_COMMIT_MESSAGE" value="07/06/2024 - 22h30" />
|
||||
</component>
|
||||
</project>
|
2155
Log/log_file.log
2155
Log/log_file.log
File diff suppressed because it is too large
Load Diff
88
main.py
88
main.py
|
@ -90,6 +90,7 @@ import Job_Cron as Job_Cron
|
|||
import notes_apprenant_mgt as notes_apprenant_mgt
|
||||
import note_evaluation_mgt as note_evaluation_mgt
|
||||
import groupe_inscrit_mgt as groupe_inscrit_mgt
|
||||
import suivi_pedagogique_mgt as suivi_pedagogique_mgt
|
||||
|
||||
|
||||
app = Flask(__name__)
|
||||
|
@ -9682,6 +9683,25 @@ def Get_List_Participant_Notes():
|
|||
|
||||
|
||||
|
||||
"""
|
||||
API pour Exporter au format excel la liste des note de l'inscrit"""
|
||||
@app.route('/myclass/api/Export_Excel_List_Participant_Notes/<token>/<tab_session_id>/<tab_inscription_id>/', methods=['POST','GET'])
|
||||
@crossdomain(origin='*')
|
||||
def Export_Excel_List_Participant_Notes(token, tab_session_id, tab_inscription_id):
|
||||
# On recupere le corps (payload) de la requete
|
||||
payload = mycommon.strip_dictionary (request.form.to_dict())
|
||||
payload = {}
|
||||
payload['token'] = str(token)
|
||||
payload['tab_session_id'] = str(tab_session_id)
|
||||
payload['tab_inscription_id'] = str(tab_inscription_id)
|
||||
|
||||
print(" ### Export_Excel_List_Participant_Notes payload = ",payload)
|
||||
|
||||
status, retval = note_evaluation_mgt.Export_Excel_List_Participant_Notes(payload)
|
||||
if(status ):
|
||||
return retval
|
||||
else:
|
||||
return False
|
||||
|
||||
|
||||
"""
|
||||
|
@ -9893,6 +9913,74 @@ def Check_Partner_Session_Alert():
|
|||
return jsonify(status=status, message=retval, is_warning=is_warning)
|
||||
|
||||
|
||||
"""
|
||||
API pour ajouter un suivi pédagogique
|
||||
"""
|
||||
@app.route('/myclass/api/Add_Suivi_Pedagogique/', methods=['POST','GET'])
|
||||
@crossdomain(origin='*')
|
||||
def Add_Suivi_Pedagogique():
|
||||
# On recupere le corps (payload) de la requete
|
||||
payload = mycommon.strip_dictionary (request.form.to_dict())
|
||||
print(" ### Add_Suivi_Pedagogique payload = ",payload)
|
||||
status, retval = suivi_pedagogique_mgt.Add_Suivi_Pedagogique(payload)
|
||||
return jsonify(status=status, message=retval)
|
||||
|
||||
|
||||
|
||||
|
||||
"""
|
||||
API pour mettre à jour un suivi pédagogique
|
||||
"""
|
||||
@app.route('/myclass/api/Update_Suivi_Pedagogique/', methods=['POST','GET'])
|
||||
@crossdomain(origin='*')
|
||||
def Update_Suivi_Pedagogique():
|
||||
# On recupere le corps (payload) de la requete
|
||||
payload = mycommon.strip_dictionary (request.form.to_dict())
|
||||
print(" ### Update_Suivi_Pedagogique payload = ",payload)
|
||||
status, retval = suivi_pedagogique_mgt.Update_Suivi_Pedagogique(payload)
|
||||
return jsonify(status=status, message=retval)
|
||||
|
||||
|
||||
|
||||
"""
|
||||
API pour Recuperation de la liste des suivis pédagoqiques d'un apprenant
|
||||
"""
|
||||
@app.route('/myclass/api/Get_List_Suivi_Pedagogique_No_Filter/', methods=['POST','GET'])
|
||||
@crossdomain(origin='*')
|
||||
def Get_List_Suivi_Pedagogique_No_Filter():
|
||||
# On recupere le corps (payload) de la requete
|
||||
payload = mycommon.strip_dictionary (request.form.to_dict())
|
||||
print(" ### Get_List_Suivi_Pedagogique_No_Filter payload = ",payload)
|
||||
status, retval = suivi_pedagogique_mgt.Get_List_Suivi_Pedagogique_No_Filter(payload)
|
||||
return jsonify(status=status, message=retval)
|
||||
|
||||
|
||||
|
||||
"""
|
||||
API pour Recuperer les données d'un Suivi Pedagogique
|
||||
"""
|
||||
@app.route('/myclass/api/Get_Given_Suivi_Pedagogique/', methods=['POST','GET'])
|
||||
@crossdomain(origin='*')
|
||||
def Get_Given_Suivi_Pedagogique():
|
||||
# On recupere le corps (payload) de la requete
|
||||
payload = mycommon.strip_dictionary (request.form.to_dict())
|
||||
print(" ### Get_Given_Suivi_Pedagogique payload = ",payload)
|
||||
status, retval = suivi_pedagogique_mgt.Get_Given_Suivi_Pedagogique(payload)
|
||||
return jsonify(status=status, message=retval)
|
||||
|
||||
|
||||
|
||||
"""
|
||||
API pour Supprimer un suivi pédagogique
|
||||
"""
|
||||
@app.route('/myclass/api/Delete_Suivi_Pedagogique/', methods=['POST','GET'])
|
||||
@crossdomain(origin='*')
|
||||
def Delete_Suivi_Pedagogique():
|
||||
# On recupere le corps (payload) de la requete
|
||||
payload = mycommon.strip_dictionary (request.form.to_dict())
|
||||
print(" ### Delete_Suivi_Pedagogique payload = ",payload)
|
||||
status, retval = suivi_pedagogique_mgt.Delete_Suivi_Pedagogique(payload)
|
||||
return jsonify(status=status, message=retval)
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -0,0 +1,92 @@
|
|||
import atexit
|
||||
|
||||
from flask import make_response, request, current_app, Flask, jsonify
|
||||
from functools import update_wrapper
|
||||
import json
|
||||
|
||||
import strype_payement
|
||||
import wrapper as wp
|
||||
import ela_user_account as eua
|
||||
import prj_common as pc
|
||||
from six import string_types
|
||||
from datetime import timedelta
|
||||
import Ela_Spacy as ls
|
||||
import user_message_mgt as um
|
||||
import user_session as us
|
||||
import partners as pa
|
||||
import prj_common as mycommon
|
||||
import ela_index_bdd_classes as ela_index_class
|
||||
import class_mgt as cm
|
||||
import Dev_api_functions as dev_function
|
||||
from flask_cors import CORS, cross_origin
|
||||
import time
|
||||
from OpenSSL import SSL
|
||||
from flask import redirect
|
||||
from flask import Flask, render_template, request, redirect, url_for
|
||||
import articles_avis as aa
|
||||
import GlobalVariable as MYSY_GV
|
||||
import youtubes_analyse as YTA
|
||||
import test_perso as TP
|
||||
import ela_factures_mgt as invoice
|
||||
import product_service as PS
|
||||
import ela_factures_mgt as factures
|
||||
import statistics as Stat
|
||||
import strype_payement as Stripe
|
||||
import Inscription_mgt as inscription
|
||||
import emargement as emargement
|
||||
import Session_Formation as SF
|
||||
import email_mgt as emails
|
||||
import email_inscription_mgt as emails_support
|
||||
import opco as opco
|
||||
import Attestation_Certificat as Att_Cert
|
||||
import tools_cherif.tools_cherif as tools_cherif
|
||||
import business_prices as business_prices
|
||||
import lms_chamilo.mysy_lms as mysy_lms
|
||||
import code_promo_mgt as code_promo_mgt
|
||||
from apscheduler.schedulers.background import BackgroundScheduler
|
||||
import appel_offre as appel_offre
|
||||
import partner_client as partner_client
|
||||
import Contact as Contact
|
||||
import Activite as Activite
|
||||
import ressources_humaines as ressources_humaines
|
||||
import ressources_materiels as ressources_materiels
|
||||
import partner_order as partner_order
|
||||
import partner_document_mgt as partner_document_mgt
|
||||
import user_access_right as user_access_right
|
||||
import partner_invoice as partner_invoice
|
||||
import partner_base_setup as partner_base_setup
|
||||
import attached_file_mgt as attached_file_mgt
|
||||
import base_specific_fields as base_specific_fields
|
||||
import agenda as agenda
|
||||
import base_partner_session_step as base_partner_session_step
|
||||
import Session_Formation_Sequence as Session_Formation_Sequence
|
||||
|
||||
import base_config_modele_journee as base_config_modele_journee
|
||||
import Dashbord_queries.session_tbd_qries as session_tbd_qries
|
||||
import Dashbord_queries.common_tdb_qries as common_tdb_qries
|
||||
import Dashbord_queries.formation_tbd_qries as formation_tbd_qries
|
||||
import Dashbord_queries.ressources_humaines_tbd_qries as ressources_humaines_tbd_qries
|
||||
import Dashbord_queries.inscription_tdb_qries as inscription_tdb_qries
|
||||
import Dashbord_queries.factures_tbd_qries as factures_tbd_qries
|
||||
|
||||
import Collection_Historique as Collection_Historique
|
||||
import purchase_prices as purchase_prices
|
||||
import apprenant_mgt as apprenant_mgt
|
||||
import module_editique as module_editique
|
||||
import attestation_formation as attestation_formation
|
||||
import crm_opportunite as crm_opportunite
|
||||
import site_formation as site_formation
|
||||
import paiement_condition as paiement_condition
|
||||
import E_Sign_Document as E_Sign_Document
|
||||
import competence as competence
|
||||
import formulaire_mgt as formulaire_mgt
|
||||
import survey_mgt as survey_mgt
|
||||
import unite_enseignement_mgt as unite_enseignement_mgt
|
||||
import metier_formation_mgt as metier_formation_mgt
|
||||
import categorie_formation_mgt as categorie_formation_mgt
|
||||
import domaine_formation_mgt as domaine_formation_mgt
|
||||
import invoice_paiement_mgt as invoice_paiement_mgt
|
||||
import Job_Cron as Job_Cron
|
||||
import notes_apprenant_mgt as notes_apprenant_mgt
|
||||
import note_evaluation_mgt as note_evaluation_mgt
|
||||
import groupe_inscrit_mgt as groupe_inscrit_mgt
|
|
@ -219,7 +219,7 @@ def Add_Evaluation_Planification(diction):
|
|||
|
||||
|
||||
"""
|
||||
Mettre à jour une évalution planifiée
|
||||
Mettre à jour une évaluation planifiée
|
||||
"""
|
||||
def Update_Evaluation_Planification(diction):
|
||||
try:
|
||||
|
@ -1340,7 +1340,7 @@ def Get_List_Participant_Notes(diction):
|
|||
"""
|
||||
|
||||
|
||||
print("tab_my_session_ids = ", tab_my_session_ids)
|
||||
#print("tab_my_session_ids = ", tab_my_session_ids)
|
||||
|
||||
|
||||
for my_inscription_id in tab_my_inscription_ids:
|
||||
|
@ -1427,7 +1427,7 @@ def Get_List_Participant_Notes(diction):
|
|||
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]['class_id'])
|
||||
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 = ""
|
||||
|
@ -1484,6 +1484,306 @@ def Get_List_Participant_Notes(diction):
|
|||
return False, "Impossible de récupérer les notes de l'apprenant"
|
||||
|
||||
|
||||
"""
|
||||
Exporter les notes de l'apprenant dans un doc excel
|
||||
"""
|
||||
def Export_Excel_List_Participant_Notes(diction):
|
||||
try:
|
||||
diction = mycommon.strip_dictionary(diction)
|
||||
|
||||
"""
|
||||
Verification des input acceptés
|
||||
"""
|
||||
field_list = ['token', 'tab_session_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', 'tab_session_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
|
||||
|
||||
tab_session_id = ""
|
||||
if ("tab_session_id" in diction.keys()):
|
||||
if diction['tab_session_id']:
|
||||
tab_session_id = diction['tab_session_id']
|
||||
|
||||
tab_inscription_id = ""
|
||||
if ("tab_inscription_id" in diction.keys()):
|
||||
if diction['tab_inscription_id']:
|
||||
tab_inscription_id = diction['tab_inscription_id']
|
||||
|
||||
tab_my_session_ids = str(tab_session_id).split(",")
|
||||
tab_my_inscription_ids = str(tab_inscription_id).split(",")
|
||||
|
||||
"""
|
||||
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("#### Export_Excel_List_Participant_Notes : query = ", query)
|
||||
|
||||
ts = datetime.now().timestamp()
|
||||
ts = str(ts).replace(".", "").replace(",", "")[-5:]
|
||||
|
||||
orig_file_name = "Export_Notes_" + str(ts) + ".xlsx"
|
||||
outputFilename = str(MYSY_GV.TEMPORARY_DIRECTORY) + "/" + str(orig_file_name)
|
||||
|
||||
tab_exported_fields_header = ["Formation", "Classe", "Nom", "Prenom", "Email", "UE Code", "UE Titre",
|
||||
"Evaluation", "Début Evaluation", "Fin Evaluation", "Note"
|
||||
]
|
||||
|
||||
# Create a workbook and add a worksheet.
|
||||
workbook = xlsxwriter.Workbook(outputFilename)
|
||||
worksheet = workbook.add_worksheet()
|
||||
|
||||
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
|
||||
|
||||
|
||||
for retval in MYSY_GV.dbname['note_evaluation_participant'].aggregate(query):
|
||||
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(nb_val)
|
||||
if( "note" not in retval.keys() ):
|
||||
user['note'] = "-1"
|
||||
|
||||
user['class_id'] = str(retval['note_evaluation_collection'][0]['class_id'])
|
||||
myclass_data = MYSY_GV.dbname['myclass'].find_one({'_id':ObjectId(str(user['class_id'])),
|
||||
'valide':'1',
|
||||
'locked':'0',
|
||||
'partner_owner_recid':str(my_partner['recid'])},
|
||||
{'_id':1, 'external_code':1, "title":1 })
|
||||
|
||||
"""
|
||||
Insertion des data dans le fichier excel
|
||||
"""
|
||||
column = 0
|
||||
row = row + 1
|
||||
|
||||
# Champ : Titre de la formation
|
||||
Formation = ""
|
||||
if (myclass_data and "title" in myclass_data.keys()):
|
||||
Formation = myclass_data['title']
|
||||
|
||||
worksheet.write(row, column, Formation)
|
||||
column += 1
|
||||
|
||||
# Champ : session_code (classe dans la formation initiale)
|
||||
mysession_data = MYSY_GV.dbname['session_formation'].find_one({'_id': ObjectId(str(user['session_id'])),
|
||||
'valide': '1',
|
||||
'partner_owner_recid': str(my_partner['recid'])},
|
||||
{'_id': 1, 'code_session': 1, })
|
||||
code_session = ""
|
||||
if (mysession_data and "code_session" in mysession_data.keys()):
|
||||
code_session = mysession_data['code_session']
|
||||
|
||||
worksheet.write(row, column, code_session)
|
||||
column += 1
|
||||
|
||||
# Champ : Nom
|
||||
worksheet.write(row, column, nom_apprenant)
|
||||
column += 1
|
||||
|
||||
# Champ : prenom_apprenant
|
||||
worksheet.write(row, column, prenom_apprenant)
|
||||
column += 1
|
||||
|
||||
# Champ : email_apprenant
|
||||
worksheet.write(row, column, email_apprenant)
|
||||
column += 1
|
||||
|
||||
# Champ : UE Code
|
||||
worksheet.write(row, column, class_ue_code)
|
||||
column += 1
|
||||
|
||||
# Champ : class_ue_titre
|
||||
worksheet.write(row, column, class_ue_titre)
|
||||
column += 1
|
||||
|
||||
# Champ : note_evaluation_code
|
||||
worksheet.write(row, column, user['note_evaluation_code'] )
|
||||
column += 1
|
||||
|
||||
# Champ : user['eval_date_heure_debut']
|
||||
worksheet.write(row, column, user['eval_date_heure_debut'])
|
||||
column += 1
|
||||
|
||||
# Champ : user['eval_date_heure_fin']
|
||||
worksheet.write(row, column, user['eval_date_heure_fin'])
|
||||
column += 1
|
||||
|
||||
# Champ : user['note']
|
||||
worksheet.write(row, column, user['note'])
|
||||
column += 1
|
||||
|
||||
|
||||
nb_val = nb_val + 1
|
||||
|
||||
|
||||
|
||||
workbook.close()
|
||||
if os.path.exists(outputFilename):
|
||||
# print(" ### ok os.path.exists(outputFilename) "+str(outputFilename))
|
||||
return True, send_file(outputFilename, as_attachment=True)
|
||||
|
||||
return False, " Impossible de générer l'export (2) "
|
||||
|
||||
|
||||
|
||||
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 générer l'export for "
|
||||
|
||||
|
||||
"""
|
||||
|
|
|
@ -0,0 +1,764 @@
|
|||
"""
|
||||
Ce fichier permet de gerer le suivi pédagogique d'un apprenant
|
||||
Un suivi pédagique est defini par par :
|
||||
- apprenant_id,
|
||||
- class_id (pas obligatoire)
|
||||
- session_id (pas obligatoire)
|
||||
- class_eu_id (pas obligatoire)
|
||||
- ressources_humaine_id (l'enseignant qui responsable de ce suivi)
|
||||
- date_heure_debut
|
||||
- date_heure_fin
|
||||
- observation
|
||||
- commentaire
|
||||
"""
|
||||
import ast
|
||||
|
||||
import bson
|
||||
import pymongo
|
||||
import xlsxwriter
|
||||
from pymongo import MongoClient
|
||||
import json
|
||||
from bson import ObjectId
|
||||
import re
|
||||
from datetime import datetime
|
||||
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
|
||||
|
||||
"""
|
||||
Ajout d'un suivi pédagogique
|
||||
"""
|
||||
def Add_Suivi_Pedagogique(diction):
|
||||
try:
|
||||
diction = mycommon.strip_dictionary(diction)
|
||||
|
||||
"""
|
||||
Verification des input acceptés
|
||||
"""
|
||||
field_list = ['token', 'apprenant_id', 'class_id', 'session_id', 'class_eu_id', 'responsable_id',
|
||||
'date_heure_debut', 'date_heure_fin', 'observation',
|
||||
'commentaire', ]
|
||||
|
||||
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', 'apprenant_id', 'responsable_id', 'date_heure_debut', 'date_heure_fin', 'observation' ]
|
||||
|
||||
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 la formation et l'ue de la formation existe et sont valides
|
||||
|
||||
if( "class_id" in diction.keys() and "class_eu_id" in diction.keys() ):
|
||||
is_existe_class_and_class_ue = MYSY_GV.dbname['myclass'].count_documents({ '_id':ObjectId(str(diction['class_id'])),
|
||||
'list_unite_enseignement._id': str(diction['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 "
|
||||
|
||||
elif ("class_id" in diction.keys() ):
|
||||
is_existe_class_and_class_ue = MYSY_GV.dbname['myclass'].count_documents(
|
||||
{'_id': ObjectId(str(diction['class_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 est invalide ")
|
||||
return False, " La formation est invalide "
|
||||
|
||||
"""
|
||||
Verifier que le l'apprenant est valide
|
||||
"""
|
||||
is_valide_apprenant = MYSY_GV.dbname['apprenant'].count_documents(
|
||||
{'_id': ObjectId(str(diction['apprenant_id'])),
|
||||
'partner_owner_recid': my_partner['recid'],
|
||||
'valide': '1',
|
||||
'locked': '0'})
|
||||
|
||||
if (is_valide_apprenant != 1):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3]) + " L'identifiant de l'apprenant est invalide ")
|
||||
return False, " L'identifiant de l'apprenant est invalide "
|
||||
|
||||
|
||||
"""
|
||||
Verifier que le responsable est valide
|
||||
"""
|
||||
is_valide_responsable = MYSY_GV.dbname['ressource_humaine'].count_documents(
|
||||
{'_id': ObjectId(str(diction['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 "
|
||||
|
||||
|
||||
"""
|
||||
Si session_id, verifier la validité de la session
|
||||
"""
|
||||
if ('session_id' in diction.keys() and diction['session_id']):
|
||||
is_valide_session_id = MYSY_GV.dbname['session_formation'].count_documents(
|
||||
{'_id': ObjectId(str(diction['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 "
|
||||
|
||||
"""
|
||||
Verifier que les date_heure_debut et date_heure_fin sont ok
|
||||
"""
|
||||
date_heure_debut = str(diction['date_heure_debut']).strip()[0:16]
|
||||
local_status = mycommon.CheckisDate_Hours(date_heure_debut)
|
||||
if (local_status is False):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][
|
||||
3]) + " La date de début n'est pas au format jj/mm/aaaa hh:mm")
|
||||
|
||||
return False, " La date de début n'est pas au format jj/mm/aaaa hh:mm"
|
||||
|
||||
date_heure_fin = str(diction['date_heure_fin']).strip()[0:16]
|
||||
local_status = mycommon.CheckisDate_Hours(date_heure_fin)
|
||||
if (local_status is False):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][
|
||||
3]) + " La date de fin n'est pas au format jj/mm/aaaa hh:mm")
|
||||
|
||||
return False, " La date de fin n'est pas au format jj/mm/aaaa hh:mm"
|
||||
|
||||
## Verification de la cohérence des dates. Date_du doit <= Date_au
|
||||
if (datetime.strptime(str(date_heure_debut).strip(), '%d/%m/%Y %H:%M') > datetime.strptime(
|
||||
str(date_heure_fin).strip(), '%d/%m/%Y %H:%M')):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3]) + " La date debut " + str(date_heure_debut) + " est postérieure à la date de fin " + str(date_heure_fin) + " ")
|
||||
|
||||
return False, " La date debut " + str(date_heure_debut) + " est postérieure à la date de fin " + str(date_heure_fin) + " "
|
||||
|
||||
|
||||
new_data = diction
|
||||
del diction['token']
|
||||
|
||||
# Initialisation des champs non envoyés à vide
|
||||
for val in field_list:
|
||||
if val not in diction.keys():
|
||||
new_data[str(val)] = ""
|
||||
|
||||
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'])
|
||||
|
||||
inserted_id = MYSY_GV.dbname['suivi_pedagogique'].insert_one(new_data).inserted_id
|
||||
if (not inserted_id):
|
||||
mycommon.myprint(
|
||||
" Impossible de créer le suivi pédagogique (2) ")
|
||||
return False, " Impossible de créer le suivi pédagogique (2) "
|
||||
|
||||
|
||||
return True, " Le suivi pédagoqique a été correctement ajouté"
|
||||
|
||||
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 créer le suivi pédagogique "
|
||||
|
||||
|
||||
|
||||
"""
|
||||
Mettre à jour d'un suivi pédagoqique
|
||||
"""
|
||||
def Update_Suivi_Pedagogique(diction):
|
||||
try:
|
||||
diction = mycommon.strip_dictionary(diction)
|
||||
|
||||
"""
|
||||
Verification des input acceptés
|
||||
"""
|
||||
field_list = ['token', 'apprenant_id', 'class_id', 'session_id', 'class_eu_id', 'responsable_id',
|
||||
'date_heure_debut', 'date_heure_fin', 'observation',
|
||||
'commentaire', '_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', 'apprenant_id', 'responsable_id', 'date_heure_debut', 'date_heure_fin', 'observation', '_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 le suivi pédagogique exite
|
||||
"""
|
||||
is_valide_suivi_peda_count = MYSY_GV.dbname['suivi_pedagogique'].count_documents({'_id':ObjectId(str(diction['_id'])),
|
||||
'valide':'1',
|
||||
'lockad':'0',
|
||||
'partner_owner_recid':str(my_partner['recid'])})
|
||||
|
||||
if( is_valide_suivi_peda_count != 1 ):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3]) + " L'identifiant du suivi pédagogique est invalide ")
|
||||
return False, " L'identifiant du suivi pédagogique est invalide "
|
||||
|
||||
|
||||
|
||||
# Verifier que la formation et l'ue de la formation existe et sont valides
|
||||
if( "class_id" in diction.keys() and "class_eu_id" in diction.keys() ):
|
||||
is_existe_class_and_class_ue = MYSY_GV.dbname['myclass'].count_documents({ '_id':ObjectId(str(diction['class_id'])),
|
||||
'list_unite_enseignement._id': str(diction['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 "
|
||||
|
||||
elif ("class_id" in diction.keys() ):
|
||||
is_existe_class_and_class_ue = MYSY_GV.dbname['myclass'].count_documents(
|
||||
{'_id': ObjectId(str(diction['class_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 est invalide ")
|
||||
return False, " La formation est invalide "
|
||||
|
||||
"""
|
||||
Verifier que le l'apprenant est valide
|
||||
"""
|
||||
is_valide_apprenant = MYSY_GV.dbname['apprenant'].count_documents(
|
||||
{'_id': ObjectId(str(diction['apprenant_id'])),
|
||||
'partner_owner_recid': my_partner['recid'],
|
||||
'valide': '1',
|
||||
'locked': '0'})
|
||||
|
||||
if (is_valide_apprenant != 1):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3]) + " L'identifiant de l'apprenant est invalide ")
|
||||
return False, " L'identifiant de l'apprenant est invalide "
|
||||
|
||||
|
||||
"""
|
||||
Verifier que le responsable est valide
|
||||
"""
|
||||
is_valide_responsable = MYSY_GV.dbname['ressource_humaine'].count_documents(
|
||||
{'_id': ObjectId(str(diction['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 "
|
||||
|
||||
|
||||
"""
|
||||
Si session_id, verifier la validité de la session
|
||||
"""
|
||||
if ('session_id' in diction.keys() and diction['session_id']):
|
||||
is_valide_session_id = MYSY_GV.dbname['session_formation'].count_documents(
|
||||
{'_id': ObjectId(str(diction['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 "
|
||||
|
||||
"""
|
||||
Verifier que les date_heure_debut et date_heure_fin sont ok
|
||||
"""
|
||||
date_heure_debut = str(diction['date_heure_debut']).strip()[0:16]
|
||||
local_status = mycommon.CheckisDate_Hours(date_heure_debut)
|
||||
if (local_status is False):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][
|
||||
3]) + " La date de début n'est pas au format jj/mm/aaaa hh:mm")
|
||||
|
||||
return False, " La date de début n'est pas au format jj/mm/aaaa hh:mm"
|
||||
|
||||
date_heure_fin = str(diction['date_heure_fin']).strip()[0:16]
|
||||
local_status = mycommon.CheckisDate_Hours(date_heure_fin)
|
||||
if (local_status is False):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][
|
||||
3]) + " La date de fin n'est pas au format jj/mm/aaaa hh:mm")
|
||||
|
||||
return False, " La date de fin n'est pas au format jj/mm/aaaa hh:mm"
|
||||
|
||||
## Verification de la cohérence des dates. Date_du doit <= Date_au
|
||||
if (datetime.strptime(str(date_heure_debut).strip(), '%d/%m/%Y %H:%M') > datetime.strptime(
|
||||
str(date_heure_fin).strip(), '%d/%m/%Y %H:%M')):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3]) + " La date debut " + str(date_heure_debut) + " est postérieure à la date de fin " + str(date_heure_fin) + " ")
|
||||
|
||||
return False, " La date debut " + str(date_heure_debut) + " est postérieure à la date de fin " + str(date_heure_fin) + " "
|
||||
|
||||
|
||||
local_suivi_peda_id = diction['_id']
|
||||
new_data = diction
|
||||
del diction['token']
|
||||
del diction['_id']
|
||||
|
||||
|
||||
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'])
|
||||
|
||||
|
||||
result = MYSY_GV.dbname['suivi_pedagogique'].find_one_and_update(
|
||||
{'_id': ObjectId(str(local_suivi_peda_id)),
|
||||
'partner_owner_recid': my_partner['recid'],
|
||||
'valide': '1',
|
||||
'locked': '0'
|
||||
},
|
||||
{"$set": new_data},
|
||||
upsert=False,
|
||||
return_document=ReturnDocument.AFTER
|
||||
)
|
||||
|
||||
|
||||
|
||||
if (result is None or "_id" not in result.keys()):
|
||||
mycommon.myprint(
|
||||
" Impossible de mettre à jour le suivi pédagogique (2) ")
|
||||
return False, " Impossible de mettre à jour le suivi pédagogique (2) "
|
||||
|
||||
|
||||
|
||||
|
||||
return True, " Le suivi pédagogique a été correctement mis à jour"
|
||||
|
||||
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 le suivi pédagogique "
|
||||
|
||||
|
||||
|
||||
"""
|
||||
Recuperation de la liste des suivis pédagoqiques d'un apprenant
|
||||
"""
|
||||
|
||||
def Get_List_Suivi_Pedagogique_No_Filter(diction):
|
||||
try:
|
||||
diction = mycommon.strip_dictionary(diction)
|
||||
|
||||
"""
|
||||
Verification des input acceptés
|
||||
"""
|
||||
field_list = ['token', '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'existe pas")
|
||||
return False, " Les informations fournies sont incorrectes",
|
||||
|
||||
"""
|
||||
Verification des champs obligatoires
|
||||
"""
|
||||
field_list_obligatoire = ['token', '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 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 le l'apprenant est valide
|
||||
"""
|
||||
|
||||
|
||||
is_valide_apprenant = MYSY_GV.dbname['apprenant'].count_documents(
|
||||
{'_id': ObjectId(str(diction['apprenant_id'])),
|
||||
'partner_owner_recid': my_partner['recid'],
|
||||
'valide': '1',
|
||||
'locked': '0'})
|
||||
|
||||
|
||||
|
||||
if (is_valide_apprenant != 1):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3]) + " L'identifiant de l'apprenant est invalide ")
|
||||
return False, " L'identifiant de l'apprenant est invalide "
|
||||
|
||||
|
||||
"""
|
||||
Clés de mise à jour
|
||||
"""
|
||||
data_cle = {}
|
||||
data_cle['partner_owner_recid'] = str(my_partner['recid'])
|
||||
data_cle['valide'] = "1"
|
||||
data_cle['locked'] = "0"
|
||||
data_cle['apprenant_id'] = str(diction['apprenant_id'])
|
||||
|
||||
|
||||
RetObject = []
|
||||
val_tmp = 0
|
||||
|
||||
for retval in MYSY_GV.dbname['suivi_pedagogique'].find(data_cle).sort([("_id", pymongo.DESCENDING), ]):
|
||||
user = retval
|
||||
user['id'] = str(val_tmp)
|
||||
val_tmp = val_tmp + 1
|
||||
|
||||
# Recuperer l'internal url de la formation
|
||||
class_title = ""
|
||||
if ("class_id" in retval.keys() and retval['class_id']):
|
||||
class_data = MYSY_GV.dbname['myclass'].find_one({'_id': ObjectId(str(retval['class_id'])),
|
||||
'partner_owner_recid': str(my_partner['recid'])},
|
||||
{'title': 1})
|
||||
|
||||
if (class_data and 'title' in class_data.keys()):
|
||||
class_title = class_data['title']
|
||||
|
||||
user['class_title'] = str(class_title)
|
||||
|
||||
# Recuperer session_code
|
||||
session_code = ""
|
||||
if ("session_id" in retval.keys() and retval['session_id']):
|
||||
session_data = MYSY_GV.dbname['session_formation'].find_one({'_id': ObjectId(str(retval['session_id'])),
|
||||
'partner_owner_recid': str(
|
||||
my_partner['recid'])},
|
||||
{'code_session': 1})
|
||||
|
||||
if (session_data and 'code_session' in session_data.keys()):
|
||||
session_code = session_data['code_session']
|
||||
user['session_code'] = str(session_code)
|
||||
|
||||
# Recuperer ue_code
|
||||
ue_code = ""
|
||||
ue_titre = ""
|
||||
if ("class_eu_id" in retval.keys() and retval['class_eu_id']):
|
||||
unite_enseignement_data = MYSY_GV.dbname['unite_enseignement'].find_one(
|
||||
{'_id': ObjectId(str(retval['class_eu_id'])),
|
||||
'partner_owner_recid': str(
|
||||
my_partner['recid'])},
|
||||
{'code': 1, 'titre': 1})
|
||||
|
||||
|
||||
|
||||
if (unite_enseignement_data and 'code' in unite_enseignement_data.keys()):
|
||||
ue_code = unite_enseignement_data['code']
|
||||
|
||||
if (unite_enseignement_data and 'titre' in unite_enseignement_data.keys()):
|
||||
ue_titre = unite_enseignement_data['titre']
|
||||
|
||||
user['ue_code'] = str(ue_code)
|
||||
user['ue_titre'] = str(ue_titre)
|
||||
|
||||
|
||||
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 suivis pédagogique "
|
||||
|
||||
|
||||
|
||||
"""
|
||||
Recuperer les données d'un Suivi Pedagogique
|
||||
"""
|
||||
def Get_Given_Suivi_Pedagogique(diction):
|
||||
try:
|
||||
diction = mycommon.strip_dictionary(diction)
|
||||
|
||||
"""
|
||||
Verification des input acceptés
|
||||
"""
|
||||
field_list = ['token', '_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', '_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
|
||||
|
||||
"""
|
||||
Clés de mise à jour
|
||||
"""
|
||||
data_cle = {}
|
||||
data_cle['partner_owner_recid'] = str(my_partner['recid'])
|
||||
data_cle['valide'] = "1"
|
||||
data_cle['locked'] = "0"
|
||||
data_cle['_id'] = ObjectId(str(diction['_id']))
|
||||
|
||||
|
||||
RetObject = []
|
||||
val_tmp = 0
|
||||
|
||||
for retval in MYSY_GV.dbname['suivi_pedagogique'].find(data_cle):
|
||||
user = retval
|
||||
user['id'] = str(val_tmp)
|
||||
val_tmp = val_tmp + 1
|
||||
|
||||
# Recuperer l'internal url de la formation
|
||||
class_title = ""
|
||||
if("class_id" in retval.keys() and retval['retval']):
|
||||
class_data = MYSY_GV.dbname['myclass'].find_one({'_id':ObjectId(str(retval['class_id'])),
|
||||
'partner_owner_recid':str(my_partner['recid'])}, {'title':1})
|
||||
|
||||
if( class_data and 'title' in class_data.keys() ):
|
||||
class_title = class_data['title']
|
||||
|
||||
user['class_title'] = str(class_title)
|
||||
|
||||
# Recuperer session_code
|
||||
session_code = ""
|
||||
if("session_id" in retval.keys() and retval['session_id']):
|
||||
session_data = MYSY_GV.dbname['session_formation'].find_one({'_id': ObjectId(str(retval['session_id'])),
|
||||
'partner_owner_recid': str(my_partner['recid'])},
|
||||
{'code_session': 1})
|
||||
|
||||
if (session_data and 'code_session' in class_data.keys()):
|
||||
session_code = session_data['code_session']
|
||||
user['session_code'] = str(session_code)
|
||||
|
||||
# Recuperer ue_code
|
||||
ue_code = ""
|
||||
ue_titre = ""
|
||||
if ("class_eu_id" in retval.keys() and retval['class_eu_id']):
|
||||
unite_enseignement_data = MYSY_GV.dbname['unite_enseignement'].find_one({'_id': ObjectId(str(retval['class_eu_id'])),
|
||||
'partner_owner_recid': str(
|
||||
my_partner['recid'])},
|
||||
{'code': 1, 'titre':1})
|
||||
|
||||
if (unite_enseignement_data and 'code' in class_data.keys()):
|
||||
ue_code = unite_enseignement_data['code']
|
||||
|
||||
if (unite_enseignement_data and 'ue_titre' in class_data.keys()):
|
||||
ue_titre = unite_enseignement_data['titre']
|
||||
|
||||
user['ue_code'] = str(ue_code)
|
||||
user['ue_titre'] = str(ue_titre)
|
||||
|
||||
|
||||
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 les données du suivi pédagogique "
|
||||
|
||||
|
||||
"""
|
||||
Supprimer un suivi pédagogique
|
||||
|
||||
"""
|
||||
def Delete_Suivi_Pedagogique(diction):
|
||||
try:
|
||||
diction = mycommon.strip_dictionary(diction)
|
||||
|
||||
"""
|
||||
Verification des input acceptés
|
||||
"""
|
||||
field_list = ['token', '_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', '_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_suivi_peda_exist_count = MYSY_GV.dbname['suivi_pedagogique'].count_documents({ '_id':ObjectId(str(diction['_id'])),
|
||||
'partner_owner_recid':my_partner['recid'],
|
||||
'valide': '1',
|
||||
'locked': '0'
|
||||
})
|
||||
|
||||
if (is_suivi_peda_exist_count != 1):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3]) + " L'identifiant du suivi pédagoqique est invalide ")
|
||||
return False, " L'identifiant du suivi pédagoqique est invalide "
|
||||
|
||||
|
||||
|
||||
delete = MYSY_GV.dbname['suivi_pedagogique'].delete_one({ '_id':ObjectId(str(diction['_id'])),
|
||||
'partner_owner_recid':my_partner['recid'],
|
||||
'valide': '1',
|
||||
'locked': '0'
|
||||
} )
|
||||
|
||||
|
||||
|
||||
return True, " Le suivi pédagogique a été correctement supprimé"
|
||||
|
||||
|
||||
|
||||
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 le suivi pédagogique "
|
||||
|
Loading…
Reference in New Issue