Version 23.9.6: Sep 19, 2023 Code refactoring in hierarchy.

This commit is contained in:
acanas 2023-09-19 19:38:03 +02:00
parent 050d6c8234
commit 4dd1e6edfd
22 changed files with 64 additions and 100 deletions

View File

@ -1293,7 +1293,8 @@ static void Asg_ShowLstGrpsToEditAssignment (long AsgCod)
"AsgCod",
AsgCod) ? "" :
" checked=\"checked\"");
HTM_TxtF ("%s %s",Txt_The_whole_course,Gbl.Hierarchy.Node[HieLvl_CRS].ShrtName);
HTM_TxtF ("%s %s",Txt_The_whole_course,
Gbl.Hierarchy.Node[HieLvl_CRS].ShrtName);
HTM_LABEL_End ();
HTM_TD_End ();
HTM_TR_End ();
@ -1572,7 +1573,8 @@ static void Asg_GetAndWriteNamesOfGrpsAssociatedToAsg (struct Asg_Assignment *As
}
}
else
HTM_TxtF ("%s %s",Txt_The_whole_course,Gbl.Hierarchy.Node[HieLvl_CRS].ShrtName);
HTM_TxtF ("%s %s",Txt_The_whole_course,
Gbl.Hierarchy.Node[HieLvl_CRS].ShrtName);
HTM_DIV_End ();

View File

@ -1109,7 +1109,8 @@ static void Att_ShowLstGrpsToEditEvent (long AttCod)
"AttCod",
AttCod) ? "" :
" checked=\"checked\"");
HTM_TxtF ("%s %s",Txt_The_whole_course,Gbl.Hierarchy.Node[HieLvl_CRS].ShrtName);
HTM_TxtF ("%s %s",Txt_The_whole_course,
Gbl.Hierarchy.Node[HieLvl_CRS].ShrtName);
HTM_LABEL_End ();
HTM_TD_End ();
@ -1335,8 +1336,8 @@ static void Att_GetAndWriteNamesOfGrpsAssociatedToEvent (struct Att_Event *Event
}
}
else
HTM_TxtF ("%s %s",
Txt_The_whole_course,Gbl.Hierarchy.Node[HieLvl_CRS].ShrtName);
HTM_TxtF ("%s %s",Txt_The_whole_course,
Gbl.Hierarchy.Node[HieLvl_CRS].ShrtName);
/***** End container *****/
HTM_DIV_End ();

View File

@ -241,7 +241,7 @@ void Ctr_ShowCtrsOfCurrentIns (void)
Ctr_ListCenters ();
/***** Free list of centers *****/
Ctr_FreeListCenters ();
Hie_FreeList (HieLvl_INS);
}
/*****************************************************************************/
@ -450,7 +450,7 @@ static void Ctr_EditCentersInternal (void)
Box_BoxEnd ();
/***** Free list of centers *****/
Ctr_FreeListCenters ();
Hie_FreeList (HieLvl_INS);
/***** Free list of places *****/
Plc_FreeListPlaces (&Places);
@ -654,21 +654,6 @@ static void Ctr_GetCoordFromRow (MYSQL_RES *mysql_res,
Coord->Altitude = Map_GetAltitudeFromStr (row[2]);
}
/*****************************************************************************/
/**************************** Free list of centers ***************************/
/*****************************************************************************/
void Ctr_FreeListCenters (void)
{
if (Gbl.Hierarchy.List[HieLvl_INS].Lst)
{
/***** Free memory used by the list of courses in degree *****/
free (Gbl.Hierarchy.List[HieLvl_INS].Lst);
Gbl.Hierarchy.List[HieLvl_INS].Lst = NULL;
Gbl.Hierarchy.List[HieLvl_INS].Num = 0;
}
}
/*****************************************************************************/
/************************** Write selector of center *************************/
/*****************************************************************************/

View File

@ -57,7 +57,6 @@ void Ctr_GetBasicListOfCenters (long InsCod);
void Ctr_GetFullListOfCenters (long InsCod,Hie_Order_t SelectedOrder);
bool Ctr_GetCenterDataByCod (struct Hie_Node *Ctr);
void Ctr_GetCoordByCod (long CtrCod,struct Map_Coordinates *Coord);
void Ctr_FreeListCenters (void);
void Ctr_WriteSelectorOfCenter (void);
void Ctr_RemoveCenter (void);
void Ctr_ChangeCtrPlc (void);

View File

@ -437,7 +437,8 @@ static void CtrCfg_Photo (bool PrintView,bool PutForm,bool PutLink,
/***** Photo image *****/
HTM_DIV_Begin ("class=\"CM\"");
if (PutLink)
HTM_A_Begin ("href=\"%s\" target=\"_blank\"",Gbl.Hierarchy.Node[HieLvl_CTR].WWW);
HTM_A_Begin ("href=\"%s\" target=\"_blank\"",
Gbl.Hierarchy.Node[HieLvl_CTR].WWW);
if (asprintf (&URL,"%s/%02u/%u",
Cfg_URL_CTR_PUBLIC,
(unsigned) (Gbl.Hierarchy.Node[HieLvl_CTR].Cod % 100),
@ -573,7 +574,7 @@ static void CtrCfg_Institution (bool PrintView,bool PutForm)
Frm_EndForm ();
/* Free list of institutions */
Ins_FreeListInstitutions ();
Hie_FreeList (HieLvl_CTY);
}
else // I can not move center to another institution
{
@ -769,7 +770,8 @@ static void CtrCfg_NumDegs (void)
HTM_TD_Begin ("class=\"LB DAT_%s\"",The_GetSuffix ());
Frm_BeginFormGoTo (ActSeeDeg);
ParCod_PutPar (ParCod_Ctr,Gbl.Hierarchy.Node[HieLvl_CTR].Cod);
if (asprintf (&Title,Txt_Degrees_of_CENTER_X,Gbl.Hierarchy.Node[HieLvl_CTR].ShrtName) < 0)
if (asprintf (&Title,Txt_Degrees_of_CENTER_X,
Gbl.Hierarchy.Node[HieLvl_CTR].ShrtName) < 0)
Err_NotEnoughMemoryExit ();
HTM_BUTTON_Submit_Begin (Title,"class=\"LB BT_LINK\"");
free (Title);
@ -1002,7 +1004,8 @@ void CtrCfg_ChangeCtrPhotoAttr (void)
Par_GetParText ("Attribution",NewPhotoAttribution,Med_MAX_BYTES_ATTRIBUTION);
/***** Update the table changing old attribution by new attribution *****/
Ctr_DB_UpdateCtrPhotoAttribution (Gbl.Hierarchy.Node[HieLvl_CTR].Cod,NewPhotoAttribution);
Ctr_DB_UpdateCtrPhotoAttribution (Gbl.Hierarchy.Node[HieLvl_CTR].Cod,
NewPhotoAttribution);
/***** Show the center information again *****/
CtrCfg_ShowConfiguration ();
@ -1113,7 +1116,8 @@ void CtrCfg_ChangeCtrLatitude (void)
NewLatitude = Map_GetLatitudeFromStr (LatitudeStr);
/***** Update database changing old latitude by new latitude *****/
Ctr_DB_UpdateCtrCoordinate (Gbl.Hierarchy.Node[HieLvl_CTR].Cod,"Latitude",NewLatitude);
Ctr_DB_UpdateCtrCoordinate (Gbl.Hierarchy.Node[HieLvl_CTR].Cod,
"Latitude",NewLatitude);
/***** Show the form again *****/
CtrCfg_ShowConfiguration ();
@ -1133,7 +1137,8 @@ void CtrCfg_ChangeCtrLongitude (void)
NewLongitude = Map_GetLongitudeFromStr (LongitudeStr);
/***** Update database changing old longitude by new longitude *****/
Ctr_DB_UpdateCtrCoordinate (Gbl.Hierarchy.Node[HieLvl_CTR].Cod,"Longitude",NewLongitude);
Ctr_DB_UpdateCtrCoordinate (Gbl.Hierarchy.Node[HieLvl_CTR].Cod,
"Longitude",NewLongitude);
/***** Show the form again *****/
CtrCfg_ShowConfiguration ();
@ -1153,7 +1158,8 @@ void CtrCfg_ChangeCtrAltitude (void)
NewAltitude = Map_GetAltitudeFromStr (AltitudeStr);
/***** Update database changing old altitude by new altitude *****/
Ctr_DB_UpdateCtrCoordinate (Gbl.Hierarchy.Node[HieLvl_CTR].Cod,"Altitude",NewAltitude);
Ctr_DB_UpdateCtrCoordinate (Gbl.Hierarchy.Node[HieLvl_CTR].Cod,
"Altitude",NewAltitude);
/***** Show the form again *****/
CtrCfg_ShowConfiguration ();

View File

@ -632,10 +632,11 @@ TODO: Francisco Javier Fern
Me sale este error, no si por no recordar yo la sintaxis apropiada para mandar a varios destinatarios. ¿No era así?
"can npt create received message (duplicated entry '243218-2160773' for key 'UsrCod_MsgCod')
*/
#define Log_PLATFORM_VERSION "SWAD 23.9.5 (2023-09-19)"
#define Log_PLATFORM_VERSION "SWAD 23.9.6 (2023-09-19)"
#define CSS_FILE "swad22.120.4.css"
#define JS_FILE "swad22.49.js"
/*
Version 23.9.6: Sep 19, 2023 Code refactoring in hierarchy. (337410 lines)
Version 23.9.5: Sep 19, 2023 Code refactoring in hierarchy. (337441 lines)
Version 23.9.4: Sep 19, 2023 Code refactoring in calls for exams. (337504 lines)
Version 23.9.3: Sep 19, 2023 Changes and code refactoring related to class photo. (337507 lines)

View File

@ -335,7 +335,7 @@ void Cty_ListCountries2 (void)
}
/***** Free list of countries *****/
Cty_FreeListCountries ();
Hie_FreeList (HieLvl_SYS);
}
/*****************************************************************************/
@ -695,7 +695,7 @@ static void Cty_EditCountriesInternal (void)
Box_BoxEnd ();
/***** Free list of countries *****/
Cty_FreeListCountries ();
Hie_FreeList (HieLvl_SYS);
}
/*****************************************************************************/
@ -1028,21 +1028,6 @@ void Cty_GetCountryNameInLanguage (long CtyCod,Lan_Language_t Language,
Str_Copy (Gbl.Cache.CountryName.CtyName,CtyName,Cty_MAX_BYTES_NAME);
}
/*****************************************************************************/
/*************************** Free list of countries **************************/
/*****************************************************************************/
void Cty_FreeListCountries (void)
{
if (Gbl.Hierarchy.List[HieLvl_SYS].Lst)
{
/***** Free memory used by the list of courses in institution *****/
free (Gbl.Hierarchy.List[HieLvl_SYS].Lst);
Gbl.Hierarchy.List[HieLvl_SYS].Lst = NULL;
Gbl.Hierarchy.List[HieLvl_SYS].Num = 0;
}
}
/*****************************************************************************/
/***************************** List all countries ****************************/
/*****************************************************************************/

View File

@ -67,7 +67,6 @@ void Cty_WriteScriptGoogleGeochart (void);
void Cty_PutParCtyOrder (void);
void Cty_EditCountries (void);
void Cty_GetBasicListOfCountries (void);
void Cty_FreeListCountries (void);
void Cty_WriteSelectorOfCountry (void);
void Cty_WriteCountryName (long CtyCod);
bool Cty_GetBasicCountryDataByCod (struct Hie_Node *Cty);

View File

@ -711,7 +711,7 @@ void Crs_ShowCrssOfCurrentDeg (void)
Crs_ListCourses ();
/***** Free list of courses in this degree *****/
Crs_FreeListCoursesInCurrentDegree ();
Hie_FreeList (HieLvl_DEG);
}
/*****************************************************************************/
@ -746,20 +746,6 @@ static void Crs_GetListCrssInCurrentDeg (void)
DB_FreeMySQLResult (&mysql_res);
}
/*****************************************************************************/
/********************* Free list of courses in this degree *******************/
/*****************************************************************************/
void Crs_FreeListCoursesInCurrentDegree (void)
{
if (Gbl.Hierarchy.List[HieLvl_DEG].Lst)
{
/***** Free memory used by the list of courses in degree *****/
free (Gbl.Hierarchy.List[HieLvl_DEG].Lst);
Gbl.Hierarchy.List[HieLvl_DEG].Lst = NULL;
}
}
/*****************************************************************************/
/********************** Write selector of my coursess ************************/
/*****************************************************************************/
@ -1070,10 +1056,10 @@ static void Crs_EditCoursesInternal (void)
Box_BoxEnd ();
/***** Free list of courses in this degree *****/
Crs_FreeListCoursesInCurrentDegree ();
Hie_FreeList (HieLvl_DEG);
/***** Free list of degrees in this center *****/
Deg_FreeListDegs (&Gbl.Hierarchy.List[HieLvl_CTR]);
Hie_FreeList (HieLvl_CTR);
}
/*****************************************************************************/

View File

@ -73,7 +73,6 @@ unsigned Crs_GetCachedNumCrssWithUsrs (Rol_Role_t Role);
void Crs_WriteSelectorOfCourse (void);
void Crs_ShowCrssOfCurrentDeg (void);
void Crs_FreeListCoursesInCurrentDegree (void);
void Crs_WriteSelectorMyCoursesInBreadcrumb (void);
void Crs_EditCourses (void);

View File

@ -236,7 +236,7 @@ static void CrsCfg_Degree (bool PrintView,bool PutForm)
Frm_EndForm ();
/* Free list of degrees of the current center */
Deg_FreeListDegs (&Gbl.Hierarchy.List[HieLvl_CTR]);
Hie_FreeList (HieLvl_CTR);
}
else // I can not move course to another degree
{

View File

@ -306,8 +306,8 @@ void Deg_ShowDegsOfCurrentCtr (void)
Deg_ListDegrees ();
/***** Free list of degrees and centers *****/
Deg_FreeListDegs (&Gbl.Hierarchy.List[HieLvl_CTR]);
Ctr_FreeListCenters ();
Hie_FreeList (HieLvl_CTR);
Hie_FreeList (HieLvl_INS);
}
/*****************************************************************************/
@ -1027,7 +1027,7 @@ void Deg_GetListDegsInCurrentCtr (void)
/*************************** Free list of degrees ****************************/
/*****************************************************************************/
void Deg_FreeListDegs (struct Hie_List *Degs)
void Deg_FreeListAllDegsWithStds (struct Hie_List *Degs)
{
if (Degs->Lst)
{

View File

@ -64,7 +64,7 @@ void Deg_PutIconToViewDegrees (void);
void Deg_GetListAllDegsWithStds (struct Hie_List *Degs);
void Deg_GetListDegsInCurrentCtr (void);
void Deg_FreeListDegs (struct Hie_List *Degs);
void Deg_FreeListAllDegsWithStds (struct Hie_List *Degs);
void Deg_ReceiveFormReqDeg (void);
void Deg_ReceiveFormNewDeg (void);

View File

@ -231,7 +231,7 @@ static void DegCfg_Center (bool PrintView,bool PutForm)
Frm_EndForm ();
/* Free list of centers */
Ctr_FreeListCenters ();
Hie_FreeList (HieLvl_INS);
}
else // I can not move degree to another center
{

View File

@ -338,7 +338,7 @@ static void Dpt_EditDepartmentsInternal (void)
Dpt_FreeListDepartments (&Departments);
/***** Free list of institutions *****/
Ins_FreeListInstitutions ();
Hie_FreeList (HieLvl_CTY);
}
/*****************************************************************************/

View File

@ -278,11 +278,11 @@ void Gbl_Cleanup (void)
Rec_FreeListFields ();
Grp_FreeListGrpTypesAndGrps ();
Grp_FreeListCodSelectedGrps ();
Crs_FreeListCoursesInCurrentDegree ();
Deg_FreeListDegs (&Gbl.Hierarchy.List[HieLvl_CTR]);
Ins_FreeListInstitutions ();
Ctr_FreeListCenters ();
Cty_FreeListCountries ();
Hie_FreeList (HieLvl_DEG);
Hie_FreeList (HieLvl_CTR);
Hie_FreeList (HieLvl_INS);
Hie_FreeList (HieLvl_CTY);
Hie_FreeList (HieLvl_SYS);
for (Role = (Rol_Role_t) 0;
Role <= (Rol_Role_t) (Rol_NUM_ROLES - 1);

View File

@ -929,6 +929,21 @@ Hie_Order_t Hie_GetParHieOrder (void)
(unsigned long) Hie_ORDER_DEFAULT);
}
/*****************************************************************************/
/**************************** Free list of centers ***************************/
/*****************************************************************************/
void Hie_FreeList (HieLvl_Level_t Level)
{
if (Gbl.Hierarchy.List[Level].Lst)
{
/***** Free memory used by the list of child nodes *****/
free (Gbl.Hierarchy.List[Level].Lst);
Gbl.Hierarchy.List[Level].Lst = NULL;
Gbl.Hierarchy.List[Level].Num = 0;
}
}
/*****************************************************************************/
/********* Get and show stats about hierarchy ***********/
/********* (countries, institutions, centers, degrees and courses) ***********/

View File

@ -62,6 +62,8 @@ void Hie_PutParOtherHieCod (void *HieCod);
Hie_Order_t Hie_GetParHieOrder (void);
void Hie_FreeList (HieLvl_Level_t Level);
//-------------------------------- Figures ------------------------------------
void Hie_GetAndShowHierarchyStats (void);

View File

@ -280,7 +280,7 @@ void Ins_ShowInssOfCurrentCty (void)
Ins_ListInstitutions ();
/***** Free list of institutions *****/
Ins_FreeListInstitutions ();
Hie_FreeList (HieLvl_CTY);
}
}
@ -542,7 +542,7 @@ static void Ins_EditInstitutionsInternal (void)
Box_BoxEnd ();
/***** Free list of institutions *****/
Ins_FreeListInstitutions ();
Hie_FreeList (HieLvl_CTY);
}
/*****************************************************************************/
@ -794,21 +794,6 @@ void Ins_GetShrtNameAndCtyOfInstitution (struct Hie_Node *Ins,
Cns_HIERARCHY_MAX_BYTES_FULL_NAME);
}
/*****************************************************************************/
/************************* Free list of institutions *************************/
/*****************************************************************************/
void Ins_FreeListInstitutions (void)
{
if (Gbl.Hierarchy.List[HieLvl_CTY].Lst)
{
/***** Free memory used by the list of institutions *****/
free (Gbl.Hierarchy.List[HieLvl_CTY].Lst);
Gbl.Hierarchy.List[HieLvl_CTY].Num = 0;
Gbl.Hierarchy.List[HieLvl_CTY].Lst = NULL;
}
}
/*****************************************************************************/
/************************ Write selector of institution **********************/
/*****************************************************************************/

View File

@ -58,7 +58,6 @@ void Ins_FlushCacheFullNameAndCtyOfInstitution (void);
void Ins_GetShrtNameAndCtyOfInstitution (struct Hie_Node *Ins,
char CtyName[Cns_HIERARCHY_MAX_BYTES_FULL_NAME + 1]);
void Ins_FreeListInstitutions (void);
void Ins_WriteSelectorOfInstitution (void);
void Ins_RemoveInstitution (void);

View File

@ -2070,7 +2070,7 @@ static void Pho_PutLinkToCalculateDegreeStats (const struct Pho_DegPhotos *DegPh
HTM_DIV_End ();
/***** Free list of all degrees with students *****/
Deg_FreeListDegs (&Degs);
Deg_FreeListAllDegsWithStds (&Degs);
}
}

View File

@ -3859,7 +3859,7 @@ static void Rec_ShowFormMyInsCtrDpt (bool IAmATeacher)
HTM_TD_Begin ("class=\"REC_C2_BOT LM\"");
/* Get list of institutions in this country */
Ins_FreeListInstitutions ();
Hie_FreeList (HieLvl_CTY);
if (Gbl.Usrs.Me.UsrDat.InsCtyCod > 0)
Ins_GetBasicListOfInstitutions (Gbl.Usrs.Me.UsrDat.InsCtyCod);
@ -3911,7 +3911,7 @@ static void Rec_ShowFormMyInsCtrDpt (bool IAmATeacher)
HTM_TD_Begin ("class=\"REC_C2_BOT LM\"");
/* Get list of centers in this institution */
Ctr_FreeListCenters ();
Hie_FreeList (HieLvl_INS);
if (Gbl.Usrs.Me.UsrDat.InsCod > 0)
Ctr_GetBasicListOfCenters (Gbl.Usrs.Me.UsrDat.InsCod);