13/05/23 - 23h

master
cherif 2023-05-14 00:00:46 +02:00
parent 0b79324237
commit c4ecc8d3ab
3 changed files with 131 additions and 11 deletions

View File

@ -1,12 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project version="4"> <project version="4">
<component name="ChangeListManager"> <component name="ChangeListManager">
<list default="true" id="c6d0259a-16e1-410d-91a1-830590ee2a08" name="Changes" comment="12/05/23 - 19h"> <list default="true" id="c6d0259a-16e1-410d-91a1-830590ee2a08" name="Changes" comment="13/05/23 - 17h">
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" 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$/class_mgt.py" beforeDir="false" afterPath="$PROJECT_DIR$/class_mgt.py" 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$/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" />
</list> </list>
<option name="SHOW_DIALOG" value="false" /> <option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" /> <option name="HIGHLIGHT_CONFLICTS" value="true" />
@ -189,7 +187,14 @@
<option name="project" value="LOCAL" /> <option name="project" value="LOCAL" />
<updated>1683911749819</updated> <updated>1683911749819</updated>
</task> </task>
<option name="localTasksCounter" value="19" /> <task id="LOCAL-00019" summary="13/05/23 - 17h">
<created>1683991333030</created>
<option name="number" value="00019" />
<option name="presentableId" value="LOCAL-00019" />
<option name="project" value="LOCAL" />
<updated>1683991333030</updated>
</task>
<option name="localTasksCounter" value="20" />
<servers /> <servers />
</component> </component>
<component name="Vcs.Log.Tabs.Properties"> <component name="Vcs.Log.Tabs.Properties">
@ -220,6 +225,7 @@
<MESSAGE value="29/04/23 - 21h" /> <MESSAGE value="29/04/23 - 21h" />
<MESSAGE value="05/05/23 - 21h" /> <MESSAGE value="05/05/23 - 21h" />
<MESSAGE value="12/05/23 - 19h" /> <MESSAGE value="12/05/23 - 19h" />
<option name="LAST_COMMIT_MESSAGE" value="12/05/23 - 19h" /> <MESSAGE value="13/05/23 - 17h" />
<option name="LAST_COMMIT_MESSAGE" value="13/05/23 - 17h" />
</component> </component>
</project> </project>

View File

@ -22,6 +22,7 @@ import ela_index_bdd_classes as eibdd
import email_mgt as email import email_mgt as email
class JSONEncoder(json.JSONEncoder): class JSONEncoder(json.JSONEncoder):
def default(self, o): def default(self, o):
if isinstance(o, ObjectId): if isinstance(o, ObjectId):

View File

@ -27,7 +27,8 @@ import hashlib
import bcrypt import bcrypt
from pymongo import ReturnDocument from pymongo import ReturnDocument
import paramiko import paramiko
from Levenshtein import distance as lev
import class_mgt as class_mgt
""" """
Test connexion SQL sur localhost Phpmyadmin Test connexion SQL sur localhost Phpmyadmin
@ -2793,6 +2794,13 @@ Depuis le lms, un bouton qui appelle le webservice en passant en argument
Etape 2 : Etape 2 :
Dans mysy search (moteur), on se connecte dans le lms, pour collecter les infos et les dupliquer et publier dans mysy search Dans mysy search (moteur), on se connecte dans le lms, pour collecter les infos et les dupliquer et publier dans mysy search
Etape 3 :
Une fois la formation créer et/ou publier, mettre l'url (mysy search) dans la table 'course' de mysy lms.
Ceci permettra de mettre un bouton de visualisation dans mysy lms.
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_Update_Class_From_Lms(diction):
try: try:
@ -2855,13 +2863,118 @@ def Create_Update_Class_From_Lms(diction):
) )
cur = conn.cursor() cur = conn.cursor()
myquery = "SELECT * FROM c_course_description WHERE c_id='" + str(lms_class_id)+"' " 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)+"' "
print(" ### myquery = ", myquery) print(" ### myquery = ", myquery)
cur.execute(myquery) cur.execute(myquery)
for courses_info in cur: """
print(" ### les information de la formation : ", str(courses_info)) /!\: Important :
conn.close() 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 = ""
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]
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
new_diction['distantiel'] = "1"
new_diction['presentiel'] = "0"
class_internal_url = ""
if (local_class_internal_url):
new_diction['internal_url'] = local_class_internal_url
else:
local_status, class_internal_url = mycommon.CreateInternalUrl(local_class_title)
if( local_status is False ):
mycommon.myprint(str(inspect.stack()[0][3]) + " - impossible de generer le class_internal_url")
return False, str(inspect.stack()[0][3]) + " - impossible de generer le 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']
print(" ### new_diction = ", new_diction)
"""
Avant d'importer 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.add_class(new_diction)
if (local_status is False):
return local_status, local_retval
"""
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)
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})
conn.commit()
conn.close()
return True, " La formation a bien été créée/mise à jour dans le moteur de recherche" return True, " La formation a bien été créée/mise à jour dans le moteur de recherche"