wwssdss
parent
b523fa42d5
commit
ed58489236
|
@ -3,6 +3,7 @@
|
|||
<component name="ChangeListManager">
|
||||
<list default="true" id="c6d0259a-16e1-410d-91a1-830590ee2a08" name="Changes" comment="wwssd">
|
||||
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/Inscription_mgt.py" beforeDir="false" afterPath="$PROJECT_DIR$/Inscription_mgt.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/Log/log_file.log" beforeDir="false" afterPath="$PROJECT_DIR$/Log/log_file.log" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/main.py" beforeDir="false" afterPath="$PROJECT_DIR$/main.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/survey_mgt.py" beforeDir="false" afterPath="$PROJECT_DIR$/survey_mgt.py" afterDir="false" />
|
||||
|
|
|
@ -152,7 +152,7 @@ def AddStagiairetoClass(diction):
|
|||
my_session_data = MYSY_GV.dbname['session_formation'].find_one(my_session_data_qry)
|
||||
if( my_session_data is None ):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3]) + " L'identifiant de la session est invalide session_id = ", str(session_id))
|
||||
str(inspect.stack()[0][3]) + " L'identifiant de la session est invalide session_id = "+ str(session_id))
|
||||
return False, " L'identifiant de la session est invalide"
|
||||
|
||||
mytoken = ""
|
||||
|
@ -226,7 +226,7 @@ def AddStagiairetoClass(diction):
|
|||
mydata['class_internal_url'] = str(tmp_val['class_internal_url']).strip()
|
||||
|
||||
|
||||
civilite = "Neutre"
|
||||
civilite = "neutre"
|
||||
if ("civilite" in diction.keys()):
|
||||
if diction['civilite']:
|
||||
civilite = str(diction['civilite']).strip().lower()
|
||||
|
|
2444
Log/log_file.log
2444
Log/log_file.log
File diff suppressed because it is too large
Load Diff
15
main.py
15
main.py
|
@ -10189,6 +10189,21 @@ def Get_Survey_Stat_Data_For_Given_related_collection_id():
|
|||
return jsonify(status=status, message=retval)
|
||||
|
||||
|
||||
"""
|
||||
API pour recuperer la liste des questions d'un 'related_collection' et 'related_collection_id'
|
||||
avec statistique
|
||||
"""
|
||||
@app.route('/myclass/api/Get_Entity_Question_List_With_Stat_For_Given_related_collection_id/', methods=['POST','GET'])
|
||||
@crossdomain(origin='*')
|
||||
def Get_Entity_Question_List_With_Stat_For_Given_related_collection_id():
|
||||
# On recupere le corps (payload) de la requete
|
||||
payload = mycommon.strip_dictionary (request.form.to_dict())
|
||||
print(" ### Get_Entity_Question_List_With_Stat_For_Given_related_collection_id payload = ",payload)
|
||||
status, retval = survey_mgt.Get_Entity_Question_List_With_Stat_For_Given_related_collection_id(payload)
|
||||
return jsonify(status=status, message=retval)
|
||||
|
||||
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
print(" debut api")
|
||||
|
|
124
survey_mgt.py
124
survey_mgt.py
|
@ -2212,7 +2212,7 @@ def Export_To_Excel_Survey_with_filter(diction):
|
|||
|
||||
|
||||
"""
|
||||
cette fonction permet de faire des statistiques ou de projections graphiques sur
|
||||
Cette fonction permet de faire des statistiques ou de projections graphiques sur
|
||||
sur des reponses, par exemple la moyenne de satisfaction par rapport
|
||||
a un formateur ou par rapport à une formation
|
||||
"""
|
||||
|
@ -2411,27 +2411,123 @@ def Get_Survey_Stat_Data_For_Given_related_collection_id(diction):
|
|||
if( nb_question_response > 0 ):
|
||||
moyenne_question_response = round(somme_question_response / nb_question_response, 2)
|
||||
|
||||
tmp['nb_question_response'] = str(nb_question_response)
|
||||
tmp['somme_question_response'] = str(somme_question_response)
|
||||
tmp['moyenne_question_response'] = str(moyenne_question_response)
|
||||
tmp['nb_question_response'] = mycommon.tryFloat(str(nb_question_response))
|
||||
tmp['somme_question_response'] = mycommon.tryFloat(str(somme_question_response))
|
||||
tmp['moyenne_question_response'] = mycommon.tryFloat(str(moyenne_question_response))
|
||||
|
||||
tmp['count'] = str(nb_question_response)
|
||||
tmp['count'] = mycommon.tryFloat(str(nb_question_response))
|
||||
if( str(question_analyse_type) == "moyenne"):
|
||||
tmp['value'] = str(moyenne_question_response)
|
||||
tmp['value'] = mycommon.tryFloat(str(moyenne_question_response))
|
||||
elif( str(question_analyse_type) == "somme"):
|
||||
tmp['value'] = str(somme_question_response)
|
||||
tmp['value'] = mycommon.tryFloat(str(somme_question_response))
|
||||
|
||||
else:
|
||||
tmp['nb_question_response'] = "0"
|
||||
tmp['somme_question_response'] = "0"
|
||||
tmp['moyenne_question_response'] = "0"
|
||||
tmp['count'] = "0"
|
||||
tmp['value'] = "0"
|
||||
tmp['nb_question_response'] = 0
|
||||
tmp['somme_question_response'] = 0
|
||||
tmp['moyenne_question_response'] = 0
|
||||
tmp['count'] = 0
|
||||
tmp['value'] = 0
|
||||
|
||||
print(" ### les reponses range_date_month: ", range_date_month)
|
||||
|
||||
return True, range_date_month
|
||||
RetObject = []
|
||||
RetObject.append(mycommon.JSONEncoder().encode(range_date_month))
|
||||
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 statistiques "
|
||||
|
||||
|
||||
"""
|
||||
Recuperer la liste des questions d'un 'related_collection' et 'related_collection_id'
|
||||
avec statistique
|
||||
|
||||
"""
|
||||
def Get_Entity_Question_List_With_Stat_For_Given_related_collection_id(diction):
|
||||
try:
|
||||
diction = mycommon.strip_dictionary(diction)
|
||||
|
||||
"""
|
||||
Verification des input acceptés
|
||||
"""
|
||||
field_list = ['token', 'related_collection', 'related_collection_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', 'related_collection', 'related_collection_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
|
||||
|
||||
|
||||
#print(" ### range_date_month = ", range_date_month)
|
||||
qery_match = {'$and': [{"partner_owner_recid": str(my_partner['recid'])},
|
||||
{"valide": '1', 'locked':'0', 'statut':'2',
|
||||
"date_reponse": {"$exists": True},
|
||||
'user_response.is_statistic': "1",
|
||||
'related_collection':str(diction['related_collection']),
|
||||
'related_collection_id': str(diction['related_collection_id']),
|
||||
},
|
||||
]}
|
||||
|
||||
pipe_qry = ([
|
||||
{'$match': qery_match},
|
||||
|
||||
])
|
||||
|
||||
#print(" ### Get_Survey_Stat_Data ici pipe_qry = ", pipe_qry)
|
||||
RetObject = []
|
||||
val_tmp = 0
|
||||
|
||||
RetObject = []
|
||||
raw_question_id = []
|
||||
cpt = 0
|
||||
|
||||
for retval in MYSY_GV.dbname['survey'].aggregate(pipe_qry):
|
||||
for tmp in retval['user_response']:
|
||||
if (tmp['is_statistic'] == "1" and str(tmp['question_id']) not in raw_question_id):
|
||||
raw_question_id.append(str(tmp['question_id']))
|
||||
|
||||
node = {}
|
||||
node['id'] = str(cpt)
|
||||
cpt = cpt + 1
|
||||
node['question_question'] = str(tmp['question'])
|
||||
node['related_collection'] = str(diction['related_collection'])
|
||||
node['related_collection_id'] = str(diction['related_collection_id'])
|
||||
node['question_id'] = str(tmp['question_id'])
|
||||
node['question_question'] = str(tmp['question'])
|
||||
RetObject.append(mycommon.JSONEncoder().encode(node))
|
||||
|
||||
|
||||
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 questions "
|
||||
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue