21/05/23 - 10h

master
cherif 2023-05-21 09:59:21 +02:00
parent c2a9ac7efc
commit 1e2545013c
10 changed files with 1477 additions and 71 deletions

View File

@ -4,7 +4,14 @@
<list default="true" id="c6d0259a-16e1-410d-91a1-830590ee2a08" name="Changes" comment="15/05/23 - 23h">
<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$/Session_Formation.py" beforeDir="false" afterPath="$PROJECT_DIR$/Session_Formation.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/class_mgt.py" beforeDir="false" afterPath="$PROJECT_DIR$/class_mgt.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/data_indexees.csv" beforeDir="false" afterPath="$PROJECT_DIR$/data_indexees.csv" afterDir="false" />
<change beforePath="$PROJECT_DIR$/ela_output_test_file_pandas_2.txt" beforeDir="false" afterPath="$PROJECT_DIR$/ela_output_test_file_pandas_2.txt" afterDir="false" />
<change beforePath="$PROJECT_DIR$/lms_chamilo/mysy_lms.py" beforeDir="false" afterPath="$PROJECT_DIR$/lms_chamilo/mysy_lms.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/main.py" beforeDir="false" afterPath="$PROJECT_DIR$/main.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/prj_common.py" beforeDir="false" afterPath="$PROJECT_DIR$/prj_common.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/wrapper.py" beforeDir="false" afterPath="$PROJECT_DIR$/wrapper.py" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
@ -208,7 +215,14 @@
<option name="project" value="LOCAL" />
<updated>1684159880527</updated>
</task>
<option name="localTasksCounter" value="22" />
<task id="LOCAL-00022" summary="15/05/23 - 23h">
<created>1684182658305</created>
<option name="number" value="00022" />
<option name="presentableId" value="LOCAL-00022" />
<option name="project" value="LOCAL" />
<updated>1684182658305</updated>
</task>
<option name="localTasksCounter" value="23" />
<servers />
</component>
<component name="Vcs.Log.Tabs.Properties">

File diff suppressed because it is too large Load Diff

View File

@ -397,8 +397,9 @@ def GetActiveSessionFormation_List(diction):
if(debut_inscr <= datetime.now() and fin_inscr >= datetime.now()):
RetObject.append(mycommon.JSONEncoder().encode(retval))
else:
if( str(local_tmp['session_ondemande']).strip() == "1"):
RetObject.append(mycommon.JSONEncoder().encode(retval))
if ("session_ondemande" in local_tmp.keys()):
if( str(local_tmp['session_ondemande']).strip() == "1"):
RetObject.append(mycommon.JSONEncoder().encode(retval))

View File

@ -2024,8 +2024,8 @@ def get_class(diction):
text_size = text_size + len(str(no_html))
if (len(retVal['description']) > MYSY_GV.MAX_CARACT_DETAIL):
retVal['description'] = tmp_str[:MYSY_GV.MAX_CARACT_DETAIL] + " ..."
if (len(no_html) > MYSY_GV.MAX_CARACT_DETAIL):
retVal['description'] = no_html[:MYSY_GV.MAX_CARACT_DETAIL] + " ..."
if ("objectif" in retVal.keys()):
@ -2035,9 +2035,8 @@ def get_class(diction):
nb_pave_a_afficher = nb_pave_a_afficher + 1
if (len(retVal['objectif']) > MYSY_GV.MAX_CARACT_DETAIL):
retVal['objectif'] = tmp_str[:MYSY_GV.MAX_CARACT_DETAIL] + " ..."
if (len(no_html) > MYSY_GV.MAX_CARACT_DETAIL):
retVal['objectif'] = no_html[:MYSY_GV.MAX_CARACT_DETAIL] + " ..."
if ("pourqui" in retVal.keys() and retVal['pourqui']):
@ -2052,14 +2051,15 @@ def get_class(diction):
nb_pave_a_afficher = nb_pave_a_afficher + 1
if (len(retVal['programme']) > MYSY_GV.MAX_CARACT_DETAIL):
retVal['programme'] = tmp_str[:MYSY_GV.MAX_CARACT_DETAIL] + " ..."
if (len(no_html) > MYSY_GV.MAX_CARACT_DETAIL):
retVal['programme'] = no_html[:MYSY_GV.MAX_CARACT_DETAIL] + " ..."
if ("pedagogie" in retVal.keys()):
tmp_str = retVal['pedagogie']
if (len(retVal['pedagogie']) > MYSY_GV.MAX_CARACT_DETAIL):
retVal['pedagogie'] = tmp_str[:MYSY_GV.MAX_CARACT_DETAIL] + " ..."
no_html = mycommon.cleanhtml(retVal['pedagogie'])
if (len(no_html) > MYSY_GV.MAX_CARACT_DETAIL):
retVal['pedagogie'] = no_html[:MYSY_GV.MAX_CARACT_DETAIL] + " ..."
#retVal["text_size"] = str(text_size)
@ -2878,6 +2878,17 @@ def add_class_mass(file=None, Folder=None, diction=None):
mydata['description'] = tmp_desc
"""
Verifier que le domaine est bien dans la liste acceptée
"""
count_domaine = MYSY_GV.dbname['liste_domaine_metier'].count_documents({'domaine': str(mydata['domaine']), 'valide': '1', 'locked':'0'})
if (count_domaine <= 0):
mycommon.myprint(str(
inspect.stack()[0][
3]) + " - Le domaine '"+str(mydata['domaine'])+"' pour la formation à la ligne " + str(n + 2) +" n'est pas autorisé. Verifier la liste des domaines autorisés")
return False, " - Le domaine '"+str(mydata['domaine'])+"' pour la formation à la ligne " + str(n + 2) +" n'est pas autorisé. Verifier la liste des domaines autorisés"
formateur = ""
if ("formateur" in df.keys()):
if (str(df['formateur'].values[n])):
@ -2940,6 +2951,18 @@ def add_class_mass(file=None, Folder=None, diction=None):
if ("metier" in df.keys()):
if (str(df['metier'].values[n])):
metier = str(df['metier'].values[n]).strip()
"""
Verifier que le metier est bien dans la liste acceptée
"""
count_domaine = MYSY_GV.dbname['liste_domaine_metier'].count_documents(
{'metier': str(metier), 'valide': '1', 'locked': '0'})
if (count_domaine <= 0):
mycommon.myprint(str(
inspect.stack()[0][ 3]) + " - Le metier '" + str(metier) + "' pour la formation à la ligne " + str(n + 2) + " n'est pas autorisé. Verifier la liste des domaines autorisés")
return False, " - Le metier '" + str(metier) + "' pour la formation à la ligne " + str( n + 2) + " n'est pas autorisé. Verifier la liste des domaines autorisés"
mydata['metier'] = metier
@ -3190,23 +3213,28 @@ def get_class_by_metier(diction):
if ("description" in retVal.keys()):
tmp_str = retVal['description']
if (len(retVal['description']) > MYSY_GV.MAX_CARACT_DETAIL):
retVal['description'] = tmp_str[:MYSY_GV.MAX_CARACT_DETAIL] + " ..."
no_html = mycommon.cleanhtml(retVal['description'])
if (len(no_html) > MYSY_GV.MAX_CARACT_DETAIL):
retVal['description'] = no_html[:MYSY_GV.MAX_CARACT_DETAIL] + " ..."
if ("objectif" in retVal.keys()):
tmp_str = retVal['objectif']
if (len(retVal['objectif']) > MYSY_GV.MAX_CARACT_DETAIL):
retVal['objectif'] = tmp_str[:MYSY_GV.MAX_CARACT_DETAIL] + " ..."
no_html = mycommon.cleanhtml(retVal['objectif'])
if (len(no_html) > MYSY_GV.MAX_CARACT_DETAIL):
retVal['objectif'] = no_html[:MYSY_GV.MAX_CARACT_DETAIL] + " ..."
if ("programme" in retVal.keys()):
tmp_str = retVal['programme']
if (len(retVal['programme']) > MYSY_GV.MAX_CARACT_DETAIL):
retVal['programme'] = tmp_str[:MYSY_GV.MAX_CARACT_DETAIL] + " ..."
no_html = mycommon.cleanhtml(retVal['programme'])
if (len(no_html) > MYSY_GV.MAX_CARACT_DETAIL):
retVal['programme'] = no_html[:MYSY_GV.MAX_CARACT_DETAIL] + " ..."
if ("pedagogie" in retVal.keys()):
tmp_str = retVal['pedagogie']
if (len(retVal['pedagogie']) > MYSY_GV.MAX_CARACT_DETAIL):
retVal['pedagogie'] = tmp_str[:MYSY_GV.MAX_CARACT_DETAIL] + " ..."
no_html = mycommon.cleanhtml(retVal['pedagogie'])
if (len(no_html) > MYSY_GV.MAX_CARACT_DETAIL):
retVal['pedagogie'] = no_html[:MYSY_GV.MAX_CARACT_DETAIL] + " ..."
# mycommon.myprint(str(retVal))
user = retVal
@ -3423,27 +3451,31 @@ def get_associated_class_of_partnair(diction):
if ("description" in retVal.keys()):
tmp_str = retVal['description']
if (len(retVal['description']) > MYSY_GV.MAX_CARACT_DETAIL):
retVal['description'] = tmp_str[:MYSY_GV.MAX_CARACT_DETAIL] + " ..."
no_html = mycommon.cleanhtml(retVal['description'])
if (len(no_html) > MYSY_GV.MAX_CARACT_DETAIL):
retVal['description'] = no_html[:MYSY_GV.MAX_CARACT_DETAIL] + " ..."
if ("objectif" in retVal.keys()):
tmp_str = retVal['objectif']
if (len(retVal['objectif']) > MYSY_GV.MAX_CARACT_DETAIL):
retVal['objectif'] = tmp_str[:MYSY_GV.MAX_CARACT_DETAIL] + " ..."
no_html = mycommon.cleanhtml(retVal['objectif'])
if (len(no_html) > MYSY_GV.MAX_CARACT_DETAIL):
retVal['objectif'] = no_html[:MYSY_GV.MAX_CARACT_DETAIL] + " ..."
if ("programme" in retVal.keys()):
tmp_str = retVal['programme']
if (len(retVal['programme']) > MYSY_GV.MAX_CARACT_DETAIL):
retVal['programme'] = tmp_str[:MYSY_GV.MAX_CARACT_DETAIL] + " ..."
no_html = mycommon.cleanhtml(retVal['programme'])
if (len(no_html) > MYSY_GV.MAX_CARACT_DETAIL):
retVal['programme'] = no_html[:MYSY_GV.MAX_CARACT_DETAIL] + " ..."
if ("pedagogie" in retVal.keys()):
tmp_str = retVal['pedagogie']
if (len(retVal['pedagogie']) > MYSY_GV.MAX_CARACT_DETAIL):
retVal['pedagogie'] = tmp_str[:MYSY_GV.MAX_CARACT_DETAIL] + " ..."
no_html = mycommon.cleanhtml(retVal['pedagogie'])
if (len(no_html) > MYSY_GV.MAX_CARACT_DETAIL):
retVal['pedagogie'] = no_html[:MYSY_GV.MAX_CARACT_DETAIL] + " ..."
#mycommon.myprint(str(retVal))

View File

@ -1,5 +1,4 @@
,index,mots,occurence,moyenne,id_formation,source_field
0,0,huile,1,0.25,MYSY_Test_AP,keyword
1,1,aromatherapie,1,0.25,MYSY_Test_AP,keyword
2,2,essentielle,1,0.25,MYSY_Test_AP,keyword
3,3,aroma,1,0.25,MYSY_Test_AP,keyword
0,0,sql,1,0.33,MYSY_Demo_001,keyword
1,1,bdd,1,0.33,MYSY_Demo_001,keyword
2,2,relationnel,1,0.33,MYSY_Demo_001,keyword

1 index mots occurence moyenne id_formation source_field
2 0 0 huile sql 1 0.25 0.33 MYSY_Test_AP MYSY_Demo_001 keyword
3 1 1 aromatherapie bdd 1 0.25 0.33 MYSY_Test_AP MYSY_Demo_001 keyword
4 2 2 essentielle relationnel 1 0.25 0.33 MYSY_Test_AP MYSY_Demo_001 keyword
3 3 aroma 1 0.25 MYSY_Test_AP keyword

View File

@ -1,5 +1,4 @@
mots occurence moyenne id_formation source_field
0 huile 1 0.25 MYSY_Test_AP keyword
1 aromatherapie 1 0.25 MYSY_Test_AP keyword
2 essentielle 1 0.25 MYSY_Test_AP keyword
3 aroma 1 0.25 MYSY_Test_AP keyword
mots occurence moyenne id_formation source_field
0 sql 1 0.33 MYSY_Demo_001 keyword
1 bdd 1 0.33 MYSY_Demo_001 keyword
2 relationnel 1 0.33 MYSY_Demo_001 keyword

View File

@ -2802,7 +2802,7 @@ Etape 4 : (pas fait encore)
Apres la creation de la formation, on crée la session associée. car dans le cadre du LMS, une formation = 1 session (moteur)
"""
def Create_Update_Class_From_Lms(diction):
def Create_Class_From_Lms(diction):
try:
'''
# Verification que les champs reçus dans l'API sont bien dans la liste des champs autorisés
@ -2863,7 +2863,8 @@ def Create_Update_Class_From_Lms(diction):
)
cur = conn.cursor()
myquery = "SELECT a.title, a.content, b.code, b.title, b.full_internal_url FROM c_course_description as a left join course as b ON a.c_id = b.id WHERE c_id= '"+ str(lms_class_id)+"' "
cur2 = conn.cursor()
myquery = "SELECT a.title, a.content, b.code, b.title, b.internal_url, b.full_internal_url FROM c_course_description as a left join course as b ON a.c_id = b.id WHERE c_id= '"+ str(lms_class_id)+"' "
print(" ### myquery = ", myquery)
cur.execute(myquery)
@ -2925,6 +2926,10 @@ def Create_Update_Class_From_Lms(diction):
new_diction['distantiel'] = "1"
new_diction['presentiel'] = "0"
new_diction['published'] = "1"
new_diction['certif'] = "0"
new_diction['cpf'] = "0"
new_diction['note'] = "4"
new_diction['price'] = 0
class_internal_url = ""
@ -2974,19 +2979,24 @@ def Create_Update_Class_From_Lms(diction):
"""
Mettre à jour la table 'course' avec la valeur du 'full_internal_url
"""
if (not local_class_internal_url):
my_query_local_class_internal_url = "UPDATE course SET full_internal_url = '" + str(class_internal_url) + "' WHERE id= '"+ str(lms_class_id)+"' "
print(" ### my_query_local_class_internal_url = ", my_query_local_class_internal_url)
local_class_internal_url_full = str(MYSY_GV.CLIENT_URL_BASE)+str("Display-Detail-formation/")+str(new_diction['internal_url'])
try:
# cur.execute("INSERT INTO employees (first_name,last_name) VALUES (?, ?)", ("Maria", "DB"))
cur.execute(my_query_local_class_internal_url)
except mariadb.Error as e:
# print(f"Error: {e}")
mycommon.myprint(" Impossible de mettre à jours la table cours avec le class_internal_url " + str({e}))
return False, "Impossible de mettre à jour le class_internal_url" + str({e})
my_query_local_class_internal_url = "UPDATE course SET full_internal_url = '" + str(local_class_internal_url_full) + "' , " \
" internal_url = '" + str(new_diction['internal_url']) + "' " \
" WHERE id= '"+ str(lms_class_id)+"' "
print(" ### my_query_local_class_internal_url = ", my_query_local_class_internal_url)
try:
# cur.execute("INSERT INTO employees (first_name,last_name) VALUES (?, ?)", ("Maria", "DB"))
cur2.execute(my_query_local_class_internal_url)
conn.commit()
print(" ### cur2.execute record(s) affected = ", cur2.rowcount)
except mariadb.Error as e:
# print(f"Error: {e}")
mycommon.myprint(" Impossible de mettre à jours la table cours avec le class_internal_url " + str({e}))
return False, "Impossible de mettre à jour le class_internal_url" + str({e})
conn.close()
@ -3045,3 +3055,181 @@ def Create_Update_Class_From_Lms(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 créer ou mettre à jour la formation dans le moteur de recherche "
"""
Cette fonction met à jour une formation de MySy-LMS vers MySy-Search
Dans ce cas de figure, tous les champs ne sont 'updatable'
Ne seront pris/mis à jour que les champs reellement saisi dans le LMS (ex : description, objectif, etc)
"""
def Update_Class_From_Lms(diction):
try:
'''
# Verification que les champs reçus dans l'API sont bien dans la liste des champs autorisés
# Cela evite le cas ou une entité tierce ajouter les valeurs inconnu dans l'API
# Ici on doit mettre tous les champs possible (obligatoire ou non) de la BDD dans la liste
# field_list.
'''
field_list = ['lms_mysy_recid', 'lms_class_code', 'lms_class_id']
incom_keys = diction.keys()
for val in incom_keys:
if val not in field_list:
mycommon.myprint(str(
inspect.stack()[0][3]) + " Le champ '" + val + "' n'existe pas, mise à jour logo lms annulée")
return False, " Les informations fournies sont incorrecte",
'''
Une fois qu'on a controlé que toutes les clés mise dans l'API sont correcte. etape precedente,
On controle que les champs obligatoires sont presents dans la liste
'''
field_list_obligatoire = ['lms_mysy_recid', 'lms_class_code', 'lms_class_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 incorrecte",
lms_mysy_recid = ""
if ("lms_mysy_recid" in diction.keys()):
if diction['lms_mysy_recid']:
lms_mysy_recid = diction['lms_mysy_recid']
lms_class_code = ""
if ("lms_class_code" in diction.keys()):
if diction['lms_class_code']:
lms_class_code = diction['lms_class_code']
lms_class_id = ""
if ("lms_class_id" in diction.keys()):
if diction['lms_class_id']:
lms_class_id = diction['lms_class_id']
# Recuperation des données du partenaire
local_status, my_partner = mycommon.get_partner_data_from_recid(lms_mysy_recid)
if (local_status is False):
mycommon.myprint(str(inspect.stack()[0][3]) + " - impossible de recuperer les données du partenaire")
#return False, str(inspect.stack()[0][3]) + " - impossible de recuperer les données du partenaire",
"""
Recuperation des données de la formation dans le LMS
"""
conn = mariadb.connect(
user=MYSY_GV.MYSY_MARIADB_USER,
password=MYSY_GV.MYSY_MARIADB_USER_PASS,
host=MYSY_GV.MYSY_MARIADB_HOST,
port=MYSY_GV.MYSY_MARIADB_PORT,
database=MYSY_GV.MYSY_LMS_BDD
)
cur = conn.cursor()
cur2 = conn.cursor()
myquery = "SELECT a.title, a.content, b.code, b.title, b.internal_url, b.full_internal_url FROM c_course_description as a left join course as b ON a.c_id = b.id WHERE c_id= '"+ str(lms_class_id)+"' "
print(" ### myquery = ", myquery)
cur.execute(myquery)
"""
/!\: Important :
Dans mysy lms, l'utilisateur crée un titre, puis une description. ex : "objectif": "detail de l'objectif" ou "méthode":"detail de la
de la méthode", etc.
Pour gérer les fautes de frappe dans l'identification des titre, on va utiliser le calcul de distance de Levenshtein
"""
# La liste des champs necessaires à la creation d'une formation dans moteur de recherche
field_list = ['description', 'trainer', 'institut_formation' 'plus_produit', 'mots_cle',
'objectif', 'programme', 'prerequis', 'pourqui']
new_diction = {}
local_class_code = ""
local_class_title = ""
local_class_internal_url = ""
for courses_info in cur:
pave_title_tab = str(courses_info[0]).split(" ")
for local_val in pave_title_tab:
if( lev('description',str(local_val).lower() ) <= 2 ):
new_diction['description'] = courses_info[1]
if (lev('objectif', str(local_val).lower()) <= 2):
new_diction['objectif'] = courses_info[1]
if (lev('programme', str(local_val).lower()) <= 2):
new_diction['programme'] = courses_info[1]
if (lev('prerequis', str(local_val).lower()) <= 2):
new_diction['prerequis'] = courses_info[1]
if (lev('pourqui', str(local_val).lower()) <= 2):
new_diction['pourqui'] = courses_info[1]
if (lev('programme', str(local_val).lower()) <= 2):
new_diction['programme'] = courses_info[1]
if (lev('cles', str(local_val).lower()) <= 2):
new_diction['mots_cle'] = courses_info[1]
if (lev('comparatif', str(local_val).lower()) <= 2):
new_diction['plus_produit'] = courses_info[1]
local_class_code = courses_info[2]
local_class_title = courses_info[3]
local_class_internal_url = courses_info[4]
if(local_class_code ):
new_diction['external_code'] = local_class_code
if (local_class_title):
new_diction['title'] = local_class_title
class_internal_url = ""
if (not local_class_internal_url):
mycommon.myprint(str(inspect.stack()[0][3]) + " - impossible de faire la mise à jour. Pas de valeur pour 'local_class_internal_url' ")
return False, str(inspect.stack()[0][3]) + " - impossible de faire la mise à jour. Pas de valeur pour 'local_class_internal_url' ",
new_diction['internal_url'] = class_internal_url
if ("token" in my_partner.keys()):
if my_partner['token']:
new_diction['token'] = my_partner['token']
if ("nom" in my_partner.keys()):
if my_partner['nom']:
new_diction['trainer'] = my_partner['nom']
new_diction['source'] = "mysy_lms"
print(" ### new_diction = ", new_diction)
"""
Avant de mettre à jour la formation, on va s'assurer que les données champs obligatoire sont renseignés
"""
field_list_obligatoire_formation = ['external_code', 'title', 'description', 'trainer', 'distantiel', 'presentiel',
'token']
for local_val_ftion in field_list_obligatoire_formation:
if local_val_ftion not in new_diction.keys():
mycommon.myprint(
str(inspect.stack()[0][3]) + " - impossible de créer la formation dans le moteur de recherche :" \
" Le champs '"+local_val_ftion+"' n'existe pas.")
return False, str(
inspect.stack()[0][3]) + " - impossible de créer la formation dans le moteur de recherche :" \
" Le champs '"+local_val_ftion+"' n'existe pas.",
local_status, local_retval = class_mgt.update_class(new_diction)
if (local_status is False):
return local_status, local_retval
return True, " La formation a bien été créée/mise à jour dans le moteur de recherche"
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 ou mettre à jour la formation dans le moteur de recherche "

36
main.py
View File

@ -2345,6 +2345,18 @@ def get_List_domaine_metier():
localStatus, message= mycommon.get_List_domaine_metier()
return jsonify(status=localStatus, message=message )
"""
Cette API retour la liste distinct des metiers
"""
@app.route('/myclass/api/get_List_metier_formation/', methods=['POST','GET'])
@crossdomain(origin='*')
def get_List_metier_formation():
# On recupere le corps (payload) de la requete
payload = request.form.to_dict()
print(" ### get_List_metier_formation : payload = ",str(payload))
localStatus, message= mycommon.get_List_metier_formation()
return jsonify(status=localStatus, message=message )
"""
API de verification de la vlidation d'un email
@ -2937,18 +2949,32 @@ def test_connexion_php_myadmin():
"""
Cette API permet de créer et mettre à jour une formation du LMS vers le Search (de chamilo ver mysy)
Cette API permet de créer une formation du LMS vers le Search (de chamilo ver mysy)
"""
@app.route('/myclass/api/Create_Update_Class_From_Lms/', methods=['POST','GET'])
@app.route('/myclass/api/Create_Class_From_Lms/', methods=['POST','GET'])
@crossdomain(origin='*')
def Create_Update_Class_From_Lms():
def Create_Class_From_Lms():
# On recupere le corps (payload) de la requete
payload = request.form.to_dict()
print(" ### Create_Update_Class_From_Lms : payload = ",payload)
localStatus, message = mysy_lms.Create_Update_Class_From_Lms(payload)
print(" ### Create_Class_From_Lms : payload = ",payload)
localStatus, message = mysy_lms.Create_Class_From_Lms(payload)
return jsonify(status=localStatus, message=message)
"""
Cette API permet de mettre à jour une formation du LMS vers le Search (de chamilo ver mysy)
"""
@app.route('/myclass/api/Update_Class_From_Lms/', methods=['POST','GET'])
@crossdomain(origin='*')
def Update_Class_From_Lms():
# On recupere le corps (payload) de la requete
payload = request.form.to_dict()
print(" ### Update_Class_From_Lms : payload = ",payload)
localStatus, message = mysy_lms.Update_Class_From_Lms(payload)
return jsonify(status=localStatus, message=message)
if __name__ == '__main__':
print(" debut api")
context = SSL.Context(SSL.SSLv23_METHOD)

View File

@ -453,7 +453,11 @@ Cette fonction créer la reference interne d'une formation
def Create_internal_call_ref():
retval = None
now = datetime.now()
retval = "Mysy_"+str(now)
# getting the timestamp
ts = str(datetime.timestamp(now)).replace(".", "").replace(",", "")
retval = "Mysy_"+str(ts)
return str(retval)
def textdist():
@ -2739,7 +2743,7 @@ def get_List_domaine_formation():
for retval in coll_liste_domaine_metier.find(myquery).distinct('domaine'):
user = retval
RetObject.append(JSONEncoder().encode(user))
RetObject.append(user)
return True, RetObject
@ -2748,6 +2752,31 @@ def get_List_domaine_formation():
print(str(inspect.stack()[0][3]) + " -" + str(e) + " - ERRORRRR AT Line : " + str(exc_tb.tb_lineno))
return False, " Impossible de recuperer la liste de domaines de formation"
"""
Cette fonction retour la liste distinct des metiers
"""
def get_List_metier_formation():
try:
coll_liste_domaine_metier = MYSY_GV.dbname['liste_domaine_metier']
myquery = {}
myquery['valide'] = "1"
RetObject = []
val_tmp = 1
for retval in coll_liste_domaine_metier.find(myquery).distinct('metier'):
user = retval
RetObject.append(user)
return True, RetObject
except Exception as e:
exc_type, exc_obj, exc_tb = sys.exc_info()
print(str(inspect.stack()[0][3]) + " -" + str(e) + " - ERRORRRR AT Line : " + str(exc_tb.tb_lineno))
return False, " Impossible de recuperer la liste de domaines de formation"
"""
Fonction de recuperation de liste des domaines & metiers

View File

@ -298,11 +298,12 @@ def get_all_class(diction):
#print("AVANT ==> "+str(x['description']))
if ("description" in x.keys()):
val = x['description']
if( len(x['description']) > MYSY_GV.MAX_CARACT ):
x['description'] = val[:MYSY_GV.MAX_CARACT]+" ..."
no_html = mycommon.cleanhtml(x['description'])
if( len(no_html) > MYSY_GV.MAX_CARACT ):
x['description'] = no_html[:MYSY_GV.MAX_CARACT]+" ..."
else:
x['description'] = val[:MYSY_GV.MAX_CARACT]
x['description'] = no_html
#mycommon.myprint("APRES ==> " + str(x['description']))
@ -436,11 +437,14 @@ def get_training_in_user_zone(diction):
val = str(val).replace("&nbsp;", " ").replace('\n','')
#print("AVANT 2 ==> " + str(x['description']) + " taille = " + str(len(x['description'])))
if( len(x['description']) > MYSY_GV.MAX_CARACT ):
x['description'] = val[:MYSY_GV.MAX_CARACT]+" ..."
no_html = mycommon.cleanhtml(x['description'])
no_html = str(no_html).replace("&nbsp;", " ").replace('\n', '')
if( len(no_html) > MYSY_GV.MAX_CARACT ):
x['description'] = no_html[:MYSY_GV.MAX_CARACT]+" ..."
else:
x['description'] = val[:MYSY_GV.MAX_CARACT]
x['description'] = no_html
#print("APRES 2 ==> " + str(x['description']))
@ -700,10 +704,11 @@ def recherche_text_simple(diction):
user = x
val = x['description']
if (len(x['description']) > MYSY_GV.MAX_CARACT):
x['description'] = val[:MYSY_GV.MAX_CARACT] + " ..."
no_html = mycommon.cleanhtml(x['description'])
if (len(no_html) > MYSY_GV.MAX_CARACT):
x['description'] = no_html[:MYSY_GV.MAX_CARACT] + " ..."
else:
x['description'] = val[:MYSY_GV.MAX_CARACT]
x['description'] = no_html
insertObject.append(JSONEncoder().encode(user))
@ -839,11 +844,12 @@ def recherche_text_simple(diction):
user = x
val = mycommon.clean_emoji(str(x['description']))
no_html = mycommon.cleanhtml(val)
if (len(x['description']) > MYSY_GV.MAX_CARACT):
x['description'] = val[:MYSY_GV.MAX_CARACT] + " ..."
if (len(no_html) > MYSY_GV.MAX_CARACT):
x['description'] = no_html[:MYSY_GV.MAX_CARACT] + " ..."
else:
x['description'] = val[:MYSY_GV.MAX_CARACT]
x['description'] = no_html
insertObject.append(JSONEncoder().encode(user))
'''
@ -1358,10 +1364,11 @@ def recherche_tips(diction):
#mycommon.myprint(x)
user = x
val = x['description']
if (len(x['description']) > MYSY_GV.MAX_CARACT):
x['description'] = val[:MYSY_GV.MAX_CARACT] + " ..."
no_html = mycommon.cleanhtml(x['description'])
if (len(no_html) > MYSY_GV.MAX_CARACT):
x['description'] = no_html[:MYSY_GV.MAX_CARACT] + " ..."
else:
x['description'] = val[:MYSY_GV.MAX_CARACT]
x['description'] = no_html
insertObject.append(JSONEncoder().encode(user))
# mycommon.myprint(" insertObject = ", insertObject)