From 97a99ecbeefb91af7487416c0d3eefb1559e634c Mon Sep 17 00:00:00 2001 From: acanas Date: Thu, 11 Feb 2021 22:57:09 +0100 Subject: [PATCH] Version20.30 --- swad_API.c | 28 +-- swad_ID.c | 2 +- swad_action.c | 31 +-- swad_agenda.c | 28 +-- swad_agenda.h | 4 +- swad_assignment.c | 28 +-- swad_assignment.h | 4 +- swad_attendance.c | 28 +-- swad_attendance.h | 4 +- swad_calendar.c | 2 +- swad_centre.c | 71 +++--- swad_centre.h | 10 +- swad_centre_config.c | 21 +- swad_changelog.h | 3 +- swad_chat.c | 2 +- swad_connected.c | 54 ++--- swad_constant.h | 7 + swad_country.c | 71 +++--- swad_country.h | 16 +- swad_country_config.c | 11 +- swad_course.c | 107 ++++----- swad_course.h | 8 +- swad_course_config.c | 13 +- swad_database.c | 22 +- swad_degree.c | 71 +++--- swad_degree.h | 10 +- swad_degree_config.c | 15 +- swad_degree_type.c | 34 +-- swad_degree_type.h | 2 +- swad_department.c | 30 +-- swad_department.h | 6 +- swad_enrolment.c | 187 +++++++-------- swad_exam.c | 42 ++-- swad_exam.h | 6 +- swad_exam_announcement.c | 16 +- swad_exam_announcement.h | 2 +- swad_exam_type.h | 2 +- swad_figure.c | 410 ++++++++++++++++----------------- swad_figure.h | 4 +- swad_figure_cache.c | 25 +-- swad_figure_cache.h | 6 +- swad_file_browser.c | 9 +- swad_follow.c | 12 +- swad_form.c | 10 +- swad_forum.c | 24 +- swad_forum.h | 2 +- swad_game.c | 42 ++-- swad_game.h | 6 +- swad_global.c | 3 +- swad_global.h | 14 +- swad_help.c | 8 +- swad_hierarchy.c | 79 +++---- swad_hierarchy.h | 30 +-- swad_hierarchy_config.c | 18 +- swad_hierarchy_config.h | 14 +- swad_hierarchy_level.h | 55 +++++ swad_indicator.c | 32 +-- swad_institution.c | 81 +++---- swad_institution.h | 12 +- swad_institution_config.c | 21 +- swad_layout.c | 17 +- swad_log.c | 2 +- swad_logo.c | 60 ++--- swad_logo.h | 10 +- swad_main.c | 1 + swad_mark.c | 2 +- swad_message.c | 55 ++--- swad_message.h | 8 +- swad_network.c | 24 +- swad_notice.c | 30 +-- swad_notice.h | 4 +- swad_notification.c | 14 +- swad_photo.c | 7 +- swad_profile.c | 28 +-- swad_program.c | 28 +-- swad_program.h | 6 +- swad_project.c | 28 +-- swad_project.h | 4 +- swad_record.c | 12 +- swad_report.c | 6 +- swad_role.c | 10 +- swad_scope.c | 164 +++++++------- swad_scope.h | 10 +- swad_search.c | 58 ++--- swad_statistic.c | 75 ++++--- swad_survey.c | 418 +++++++++++++++++----------------- swad_survey.h | 10 +- swad_system_config.c | 10 +- swad_tab.c | 4 +- swad_test.c | 48 ++-- swad_timeline_note.c | 65 +++--- swad_user.c | 462 +++++++++++++++++++------------------- swad_user.h | 20 +- 93 files changed, 1839 insertions(+), 1776 deletions(-) create mode 100644 swad_hierarchy_level.h diff --git a/swad_API.c b/swad_API.c index 43801a3f..28bd99bc 100644 --- a/swad_API.c +++ b/swad_API.c @@ -1060,8 +1060,8 @@ int swad__loginBySessionKey (struct soap *soap, loginBySessionKeyOut->userSurname2 = (char *) soap_malloc (soap,Usr_MAX_BYTES_FIRSTNAME_OR_SURNAME + 1); loginBySessionKeyOut->userPhoto = (char *) soap_malloc (soap,Cns_MAX_BYTES_WWW + 1); loginBySessionKeyOut->userBirthday = (char *) soap_malloc (soap,Dat_LENGTH_YYYYMMDD + 1); - loginBySessionKeyOut->degreeName = (char *) soap_malloc (soap,Hie_MAX_BYTES_FULL_NAME + 1); - loginBySessionKeyOut->courseName = (char *) soap_malloc (soap,Hie_MAX_BYTES_FULL_NAME + 1); + loginBySessionKeyOut->degreeName = (char *) soap_malloc (soap,Cns_HIERARCHY_MAX_BYTES_FULL_NAME + 1); + loginBySessionKeyOut->courseName = (char *) soap_malloc (soap,Cns_HIERARCHY_MAX_BYTES_FULL_NAME + 1); /***** Default values returned on error *****/ loginBySessionKeyOut->userCode = -1; @@ -1110,7 +1110,7 @@ int swad__loginBySessionKey (struct soap *soap, Crs_GetDataOfCourseByCod (&Gbl.Hierarchy.Crs); loginBySessionKeyOut->courseCode = (int) Gbl.Hierarchy.Crs.CrsCod; Str_Copy (loginBySessionKeyOut->courseName,Gbl.Hierarchy.Crs.FullName, - Hie_MAX_BYTES_FULL_NAME); + Cns_HIERARCHY_MAX_BYTES_FULL_NAME); /***** Get user code (row[0]) *****/ Gbl.Usrs.Me.UsrDat.UsrCod = Str_ConvertStrCodToLongCod (row[0]); @@ -1121,7 +1121,7 @@ int swad__loginBySessionKey (struct soap *soap, Deg_GetDataOfDegreeByCod (&Gbl.Hierarchy.Deg); loginBySessionKeyOut->degreeCode = (int) Gbl.Hierarchy.Deg.DegCod; Str_Copy (loginBySessionKeyOut->degreeName,Gbl.Hierarchy.Deg.FullName, - Hie_MAX_BYTES_FULL_NAME); + Cns_HIERARCHY_MAX_BYTES_FULL_NAME); } else UsrFound = false; @@ -1413,15 +1413,15 @@ int swad__getCourses (struct soap *soap, /* Get course short name (row[1]) */ getCoursesOut->coursesArray.__ptr[NumRow].courseShortName = - (char *) soap_malloc (soap,Hie_MAX_BYTES_SHRT_NAME + 1); + (char *) soap_malloc (soap,Cns_HIERARCHY_MAX_BYTES_SHRT_NAME + 1); Str_Copy (getCoursesOut->coursesArray.__ptr[NumRow].courseShortName,row[1], - Hie_MAX_BYTES_SHRT_NAME); + Cns_HIERARCHY_MAX_BYTES_SHRT_NAME); /* Get course full name (row[2]) */ getCoursesOut->coursesArray.__ptr[NumRow].courseFullName = - (char *) soap_malloc (soap,Hie_MAX_BYTES_FULL_NAME + 1); + (char *) soap_malloc (soap,Cns_HIERARCHY_MAX_BYTES_FULL_NAME + 1); Str_Copy (getCoursesOut->coursesArray.__ptr[NumRow].courseFullName,row[2], - Hie_MAX_BYTES_FULL_NAME); + Cns_HIERARCHY_MAX_BYTES_FULL_NAME); /* Get role (row[3]) */ if (sscanf (row[3],"%u",&Role) != 1) // Role in this course @@ -1877,7 +1877,7 @@ int swad__getUsers (struct soap *soap, Grp_GetListGrpTypesInThisCrs (Grp_ONLY_GROUP_TYPES_WITH_GROUPS); /***** Get list of users *****/ - Usr_GetListUsrs (Hie_CRS,Role); + Usr_GetListUsrs (Hie_Lvl_CRS,Role); API_CopyListUsers (soap, Role,getUsersOut); Usr_FreeUsrsList (Role); @@ -1917,7 +1917,7 @@ int swad__findUsers (struct soap *soap, "Bad web service key", "Web service key does not exist in database"); - if (Gbl.Hierarchy.Level == Hie_CRS) // Course selected + if (Gbl.Hierarchy.Level == Hie_Lvl_CRS) // Course selected /***** Check course *****/ if ((ReturnCode = API_CheckCourseAndGroupCodes (soap, Gbl.Hierarchy.Crs.CrsCod, @@ -1932,7 +1932,7 @@ int swad__findUsers (struct soap *soap, Gbl.Usrs.Me.Logged = true; Gbl.Usrs.Me.Role.Logged = Gbl.Usrs.Me.UsrDat.Roles.InCurrentCrs.Role; - if (Gbl.Hierarchy.Level == Hie_CRS) // Course selected + if (Gbl.Hierarchy.Level == Hie_Lvl_CRS) // Course selected /***** Check if I am a student, non-editing teacher or teacher in the course *****/ if (Gbl.Usrs.Me.UsrDat.Roles.InCurrentCrs.Role != Rol_STD && Gbl.Usrs.Me.UsrDat.Roles.InCurrentCrs.Role != Rol_NET && @@ -1941,7 +1941,7 @@ int swad__findUsers (struct soap *soap, "Request forbidden", "Requester must belong to course"); - if (Gbl.Hierarchy.Level == Hie_CRS) + if (Gbl.Hierarchy.Level == Hie_Lvl_CRS) { /***** Get degree of current course *****/ if ((ReturnCode = API_GetCurrentDegCodFromCurrentCrsCod ()) != SOAP_OK) // TODO: Is this necessary? @@ -1962,8 +1962,8 @@ int swad__findUsers (struct soap *soap, if (Gbl.Search.Str[0]) // Search some users { - Gbl.Scope.Current = (Gbl.Hierarchy.Level == Hie_CRS) ? Hie_CRS : - Hie_SYS; + Gbl.Scope.Current = (Gbl.Hierarchy.Level == Hie_Lvl_CRS) ? Hie_Lvl_CRS : + Hie_Lvl_SYS; if (Sch_BuildSearchQuery (SearchQuery, "CONCAT_WS(' ',FirstName,Surname1,Surname2)", NULL,NULL)) diff --git a/swad_ID.c b/swad_ID.c index 444777d3..530de2ab 100644 --- a/swad_ID.c +++ b/swad_ID.c @@ -1026,7 +1026,7 @@ void ID_ConfirmOtherUsrID (void) { /* If user is a student in current course, check if he/she has accepted */ - if (Gbl.Hierarchy.Level == Hie_CRS) + if (Gbl.Hierarchy.Level == Hie_Lvl_CRS) if (Gbl.Usrs.Other.UsrDat.Roles.InCurrentCrs.Role == Rol_STD) Gbl.Usrs.Other.UsrDat.Accepted = Usr_CheckIfUsrHasAcceptedInCurrentCrs (&Gbl.Usrs.Other.UsrDat); diff --git a/swad_action.c b/swad_action.c index 69248469..50233873 100644 --- a/swad_action.c +++ b/swad_action.c @@ -58,6 +58,7 @@ #include "swad_forum.h" #include "swad_game.h" #include "swad_global.h" +#include "swad_hierarchy.h" #include "swad_holiday.h" #include "swad_ID.h" #include "swad_indicator.h" @@ -3811,22 +3812,22 @@ bool Act_CheckIfIHavePermissionToExecuteAction (Act_Action_t Action) switch (Gbl.Hierarchy.Level) { - case Hie_SYS: // System + case Hie_Lvl_SYS: // System Permission = Act_Actions[Action].PermissionSys; break; - case Hie_CTY: // Country selected + case Hie_Lvl_CTY: // Country selected Permission = Act_Actions[Action].PermissionCty; break; - case Hie_INS: // Institution selected + case Hie_Lvl_INS: // Institution selected Permission = Act_Actions[Action].PermissionIns; break; - case Hie_CTR: // Centre selected + case Hie_Lvl_CTR: // Centre selected Permission = Act_Actions[Action].PermissionCtr; break; - case Hie_DEG: // Degree selected + case Hie_Lvl_DEG: // Degree selected Permission = Act_Actions[Action].PermissionDeg; break; - case Hie_CRS: // Course selected + case Hie_Lvl_CRS: // Course selected Permission = Gbl.Usrs.Me.IBelongToCurrentCrs ? Act_Actions[Action].PermissionCrsIfIBelong : Act_Actions[Action].PermissionCrsIfIDontBelong; break; @@ -3982,18 +3983,18 @@ static const char *Act_GetActionTextFromDB (long ActCod) // TODO: Remove when da void Act_AdjustActionWhenNoUsrLogged (void) { - static const Act_Action_t Actions[Hie_NUM_LEVELS] = + static const Act_Action_t Actions[Hie_Lvl_NUM_LEVELS] = { - [Hie_UNK] = ActUnk, // Unknown - [Hie_SYS] = ActFrmLogIn, // System - [Hie_CTY] = ActSeeCtyInf, // Country - [Hie_INS] = ActSeeInsInf, // Institution - [Hie_CTR] = ActSeeCtrInf, // Centre - [Hie_DEG] = ActSeeDegInf, // Degree - [Hie_CRS] = ActSeeCrsInf, // Course + [Hie_Lvl_UNK] = ActUnk, // Unknown + [Hie_Lvl_SYS] = ActFrmLogIn, // System + [Hie_Lvl_CTY] = ActSeeCtyInf, // Country + [Hie_Lvl_INS] = ActSeeInsInf, // Institution + [Hie_Lvl_CTR] = ActSeeCtrInf, // Centre + [Hie_Lvl_DEG] = ActSeeDegInf, // Degree + [Hie_Lvl_CRS] = ActSeeCrsInf, // Course }; - if (Gbl.Hierarchy.Level >= Hie_NUM_LEVELS) + if (Gbl.Hierarchy.Level >= Hie_Lvl_NUM_LEVELS) Gbl.Hierarchy.Level = ActUnk; Gbl.Action.Act = Actions[Gbl.Hierarchy.Level]; diff --git a/swad_agenda.c b/swad_agenda.c index d463d989..ad13409a 100644 --- a/swad_agenda.c +++ b/swad_agenda.c @@ -1858,7 +1858,7 @@ unsigned Agd_GetNumEventsFromUsr (long UsrCod) /*****************************************************************************/ // Returns the number of users with events in a given scope -unsigned Agd_GetNumUsrsWithEvents (Hie_Level_t Scope) +unsigned Agd_GetNumUsrsWithEvents (Hie_Lvl_Level_t Scope) { MYSQL_RES *mysql_res; MYSQL_ROW row; @@ -1867,13 +1867,13 @@ unsigned Agd_GetNumUsrsWithEvents (Hie_Level_t Scope) /***** Get number of courses with events from database *****/ switch (Scope) { - case Hie_SYS: + case Hie_Lvl_SYS: DB_QuerySELECT (&mysql_res,"can not get number of users with events", "SELECT COUNT(DISTINCT UsrCod)" " FROM agendas" " WHERE UsrCod>0"); break; - case Hie_CTY: + case Hie_Lvl_CTY: DB_QuerySELECT (&mysql_res,"can not get number of users with events", "SELECT COUNT(DISTINCT agendas.UsrCod)" " FROM institutions,centres,degrees,courses,crs_usr,agendas" @@ -1886,7 +1886,7 @@ unsigned Agd_GetNumUsrsWithEvents (Hie_Level_t Scope) " AND crs_usr.UsrCod=agendas.UsrCod", Gbl.Hierarchy.Cty.CtyCod); break; - case Hie_INS: + case Hie_Lvl_INS: DB_QuerySELECT (&mysql_res,"can not get number of users with events", "SELECT COUNT(DISTINCT agendas.UsrCod)" " FROM centres,degrees,courses,crs_usr,agendas" @@ -1898,7 +1898,7 @@ unsigned Agd_GetNumUsrsWithEvents (Hie_Level_t Scope) " AND crs_usr.UsrCod=agendas.UsrCod", Gbl.Hierarchy.Ins.InsCod); break; - case Hie_CTR: + case Hie_Lvl_CTR: DB_QuerySELECT (&mysql_res,"can not get number of users with events", "SELECT COUNT(DISTINCT agendas.UsrCod)" " FROM degrees,courses,crs_usr,agendas" @@ -1909,7 +1909,7 @@ unsigned Agd_GetNumUsrsWithEvents (Hie_Level_t Scope) " AND crs_usr.UsrCod=agendas.UsrCod", Gbl.Hierarchy.Ctr.CtrCod); break; - case Hie_DEG: + case Hie_Lvl_DEG: DB_QuerySELECT (&mysql_res,"can not get number of users with events", "SELECT COUNT(DISTINCT agendas.UsrCod)" " FROM courses,crs_usr,agendas" @@ -1919,7 +1919,7 @@ unsigned Agd_GetNumUsrsWithEvents (Hie_Level_t Scope) " AND crs_usr.UsrCod=agendas.UsrCod", Gbl.Hierarchy.Deg.DegCod); break; - case Hie_CRS: + case Hie_Lvl_CRS: DB_QuerySELECT (&mysql_res,"can not get number of users with events", "SELECT COUNT(DISTINCT agendas.UsrCod)" " FROM crs_usr,agendas" @@ -1948,7 +1948,7 @@ unsigned Agd_GetNumUsrsWithEvents (Hie_Level_t Scope) /*****************************************************************************/ // Returns the number of events in a given scope -unsigned Agd_GetNumEvents (Hie_Level_t Scope) +unsigned Agd_GetNumEvents (Hie_Lvl_Level_t Scope) { MYSQL_RES *mysql_res; MYSQL_ROW row; @@ -1957,13 +1957,13 @@ unsigned Agd_GetNumEvents (Hie_Level_t Scope) /***** Get number of events from database *****/ switch (Scope) { - case Hie_SYS: + case Hie_Lvl_SYS: DB_QuerySELECT (&mysql_res,"can not get number of events", "SELECT COUNT(*)" " FROM agendas" " WHERE UsrCod>0"); break; - case Hie_CTY: + case Hie_Lvl_CTY: DB_QuerySELECT (&mysql_res,"can not get number of events", "SELECT COUNT(*)" " FROM institutions,centres,degrees,courses,crs_usr,agendas" @@ -1975,7 +1975,7 @@ unsigned Agd_GetNumEvents (Hie_Level_t Scope) " AND crs_usr.UsrCod=agendas.UsrCod", Gbl.Hierarchy.Cty.CtyCod); break; - case Hie_INS: + case Hie_Lvl_INS: DB_QuerySELECT (&mysql_res,"can not get number of events", "SELECT COUNT(*)" " FROM centres,degrees,courses,crs_usr,agendas" @@ -1986,7 +1986,7 @@ unsigned Agd_GetNumEvents (Hie_Level_t Scope) " AND crs_usr.UsrCod=agendas.UsrCod", Gbl.Hierarchy.Ins.InsCod); break; - case Hie_CTR: + case Hie_Lvl_CTR: DB_QuerySELECT (&mysql_res,"can not get number of events", "SELECT COUNT(*)" " FROM degrees,courses,crs_usr,agendas" @@ -1996,7 +1996,7 @@ unsigned Agd_GetNumEvents (Hie_Level_t Scope) " AND crs_usr.UsrCod=agendas.UsrCod", Gbl.Hierarchy.Ctr.CtrCod); break; - case Hie_DEG: + case Hie_Lvl_DEG: DB_QuerySELECT (&mysql_res,"can not get number of events", "SELECT COUNT(*)" " FROM courses,crs_usr,agendas" @@ -2005,7 +2005,7 @@ unsigned Agd_GetNumEvents (Hie_Level_t Scope) " AND crs_usr.UsrCod=agendas.UsrCod", Gbl.Hierarchy.Deg.DegCod); break; - case Hie_CRS: + case Hie_Lvl_CRS: DB_QuerySELECT (&mysql_res,"can not get number of events", "SELECT COUNT(*)" " FROM crs_usr,agendas" diff --git a/swad_agenda.h b/swad_agenda.h index 84c6bf6d..830b8499 100644 --- a/swad_agenda.h +++ b/swad_agenda.h @@ -128,8 +128,8 @@ void Agd_ReceiveFormEvent (void); void Agd_RemoveUsrEvents (long UsrCod); unsigned Agd_GetNumEventsFromUsr (long UsrCod); -unsigned Agd_GetNumUsrsWithEvents (Hie_Level_t Scope); -unsigned Agd_GetNumEvents (Hie_Level_t Scope); +unsigned Agd_GetNumUsrsWithEvents (Hie_Lvl_Level_t Scope); +unsigned Agd_GetNumEvents (Hie_Lvl_Level_t Scope); void Agd_PrintAgdQRCode (void); diff --git a/swad_assignment.c b/swad_assignment.c index c3aba71e..5cc574d0 100644 --- a/swad_assignment.c +++ b/swad_assignment.c @@ -1828,7 +1828,7 @@ static bool Asg_CheckIfIBelongToCrsOrGrpsThisAssignment (long AsgCod) // Returns the number of courses with assignments // in this location (all the platform, current degree or current course) -unsigned Asg_GetNumCoursesWithAssignments (Hie_Level_t Scope) +unsigned Asg_GetNumCoursesWithAssignments (Hie_Lvl_Level_t Scope) { MYSQL_RES *mysql_res; MYSQL_ROW row; @@ -1837,13 +1837,13 @@ unsigned Asg_GetNumCoursesWithAssignments (Hie_Level_t Scope) /***** Get number of courses with assignments from database *****/ switch (Scope) { - case Hie_SYS: + case Hie_Lvl_SYS: DB_QuerySELECT (&mysql_res,"can not get number of courses with assignments", "SELECT COUNT(DISTINCT CrsCod)" " FROM assignments" " WHERE CrsCod>0"); break; - case Hie_CTY: + case Hie_Lvl_CTY: DB_QuerySELECT (&mysql_res,"can not get number of courses with assignments", "SELECT COUNT(DISTINCT assignments.CrsCod)" " FROM institutions,centres,degrees,courses,assignments" @@ -1855,7 +1855,7 @@ unsigned Asg_GetNumCoursesWithAssignments (Hie_Level_t Scope) " AND courses.CrsCod=assignments.CrsCod", Gbl.Hierarchy.Cty.CtyCod); break; - case Hie_INS: + case Hie_Lvl_INS: DB_QuerySELECT (&mysql_res,"can not get number of courses with assignments", "SELECT COUNT(DISTINCT assignments.CrsCod)" " FROM centres,degrees,courses,assignments" @@ -1866,7 +1866,7 @@ unsigned Asg_GetNumCoursesWithAssignments (Hie_Level_t Scope) " AND courses.CrsCod=assignments.CrsCod", Gbl.Hierarchy.Ins.InsCod); break; - case Hie_CTR: + case Hie_Lvl_CTR: DB_QuerySELECT (&mysql_res,"can not get number of courses with assignments", "SELECT COUNT(DISTINCT assignments.CrsCod)" " FROM degrees,courses,assignments" @@ -1876,7 +1876,7 @@ unsigned Asg_GetNumCoursesWithAssignments (Hie_Level_t Scope) " AND courses.CrsCod=assignments.CrsCod", Gbl.Hierarchy.Ctr.CtrCod); break; - case Hie_DEG: + case Hie_Lvl_DEG: DB_QuerySELECT (&mysql_res,"can not get number of courses with assignments", "SELECT COUNT(DISTINCT assignments.CrsCod)" " FROM courses,assignments" @@ -1885,7 +1885,7 @@ unsigned Asg_GetNumCoursesWithAssignments (Hie_Level_t Scope) " AND courses.CrsCod=assignments.CrsCod", Gbl.Hierarchy.Deg.DegCod); break; - case Hie_CRS: + case Hie_Lvl_CRS: DB_QuerySELECT (&mysql_res,"can not get number of courses with assignments", "SELECT COUNT(DISTINCT CrsCod)" " FROM assignments" @@ -1914,7 +1914,7 @@ unsigned Asg_GetNumCoursesWithAssignments (Hie_Level_t Scope) // Returns the number of assignments // in this location (all the platform, current degree or current course) -unsigned Asg_GetNumAssignments (Hie_Level_t Scope,unsigned *NumNotif) +unsigned Asg_GetNumAssignments (Hie_Lvl_Level_t Scope,unsigned *NumNotif) { MYSQL_RES *mysql_res; MYSQL_ROW row; @@ -1923,13 +1923,13 @@ unsigned Asg_GetNumAssignments (Hie_Level_t Scope,unsigned *NumNotif) /***** Get number of assignments from database *****/ switch (Scope) { - case Hie_SYS: + case Hie_Lvl_SYS: DB_QuerySELECT (&mysql_res,"can not get number of assignments", "SELECT COUNT(*),SUM(NumNotif)" " FROM assignments" " WHERE CrsCod>0"); break; - case Hie_CTY: + case Hie_Lvl_CTY: DB_QuerySELECT (&mysql_res,"can not get number of assignments", "SELECT COUNT(*),SUM(assignments.NumNotif)" " FROM institutions,centres,degrees,courses,assignments" @@ -1940,7 +1940,7 @@ unsigned Asg_GetNumAssignments (Hie_Level_t Scope,unsigned *NumNotif) " AND courses.CrsCod=assignments.CrsCod", Gbl.Hierarchy.Cty.CtyCod); break; - case Hie_INS: + case Hie_Lvl_INS: DB_QuerySELECT (&mysql_res,"can not get number of assignments", "SELECT COUNT(*),SUM(assignments.NumNotif)" " FROM centres,degrees,courses,assignments" @@ -1950,7 +1950,7 @@ unsigned Asg_GetNumAssignments (Hie_Level_t Scope,unsigned *NumNotif) " AND courses.CrsCod=assignments.CrsCod", Gbl.Hierarchy.Ins.InsCod); break; - case Hie_CTR: + case Hie_Lvl_CTR: DB_QuerySELECT (&mysql_res,"can not get number of assignments", "SELECT COUNT(*),SUM(assignments.NumNotif)" " FROM degrees,courses,assignments" @@ -1959,7 +1959,7 @@ unsigned Asg_GetNumAssignments (Hie_Level_t Scope,unsigned *NumNotif) " AND courses.CrsCod=assignments.CrsCod", Gbl.Hierarchy.Ctr.CtrCod); break; - case Hie_DEG: + case Hie_Lvl_DEG: DB_QuerySELECT (&mysql_res,"can not get number of assignments", "SELECT COUNT(*),SUM(assignments.NumNotif)" " FROM courses,assignments" @@ -1967,7 +1967,7 @@ unsigned Asg_GetNumAssignments (Hie_Level_t Scope,unsigned *NumNotif) " AND courses.CrsCod=assignments.CrsCod", Gbl.Hierarchy.Deg.DegCod); break; - case Hie_CRS: + case Hie_Lvl_CRS: DB_QuerySELECT (&mysql_res,"can not get number of assignments", "SELECT COUNT(*),SUM(NumNotif)" " FROM assignments" diff --git a/swad_assignment.h b/swad_assignment.h index 474dd085..3a347abf 100644 --- a/swad_assignment.h +++ b/swad_assignment.h @@ -100,8 +100,8 @@ void Asg_RemoveGroup (long GrpCod); void Asg_RemoveGroupsOfType (long GrpTypCod); void Asg_RemoveCrsAssignments (long CrsCod); -unsigned Asg_GetNumCoursesWithAssignments (Hie_Level_t Scope); -unsigned Asg_GetNumAssignments (Hie_Level_t Scope,unsigned *NumNotif); +unsigned Asg_GetNumCoursesWithAssignments (Hie_Lvl_Level_t Scope); +unsigned Asg_GetNumAssignments (Hie_Lvl_Level_t Scope,unsigned *NumNotif); unsigned Asg_GetNumAssignmentsInCrs (long CrsCod); #endif diff --git a/swad_attendance.c b/swad_attendance.c index 3c4717e9..0a5980ef 100644 --- a/swad_attendance.c +++ b/swad_attendance.c @@ -1692,7 +1692,7 @@ unsigned Att_GetNumAttEventsInCrs (long CrsCod) // Returns the number of courses with attendance events // in this location (all the platform, current degree or current course) -unsigned Att_GetNumCoursesWithAttEvents (Hie_Level_t Scope) +unsigned Att_GetNumCoursesWithAttEvents (Hie_Lvl_Level_t Scope) { MYSQL_RES *mysql_res; MYSQL_ROW row; @@ -1701,13 +1701,13 @@ unsigned Att_GetNumCoursesWithAttEvents (Hie_Level_t Scope) /***** Get number of courses with attendance events from database *****/ switch (Scope) { - case Hie_SYS: + case Hie_Lvl_SYS: DB_QuerySELECT (&mysql_res,"can not get number of courses with attendance events", "SELECT COUNT(DISTINCT CrsCod)" " FROM att_events" " WHERE CrsCod>0"); break; - case Hie_INS: + case Hie_Lvl_INS: DB_QuerySELECT (&mysql_res,"can not get number of courses with attendance events", "SELECT COUNT(DISTINCT att_events.CrsCod)" " FROM centres,degrees,courses,att_events" @@ -1718,7 +1718,7 @@ unsigned Att_GetNumCoursesWithAttEvents (Hie_Level_t Scope) " AND courses.CrsCod=att_events.CrsCod", Gbl.Hierarchy.Ins.InsCod); break; - case Hie_CTR: + case Hie_Lvl_CTR: DB_QuerySELECT (&mysql_res,"can not get number of courses with attendance events", "SELECT COUNT(DISTINCT att_events.CrsCod)" " FROM degrees,courses,att_events" @@ -1728,7 +1728,7 @@ unsigned Att_GetNumCoursesWithAttEvents (Hie_Level_t Scope) " AND courses.CrsCod=att_events.CrsCod", Gbl.Hierarchy.Ctr.CtrCod); break; - case Hie_DEG: + case Hie_Lvl_DEG: DB_QuerySELECT (&mysql_res,"can not get number of courses with attendance events", "SELECT COUNT(DISTINCT att_events.CrsCod)" " FROM courses,att_events" @@ -1737,7 +1737,7 @@ unsigned Att_GetNumCoursesWithAttEvents (Hie_Level_t Scope) " AND courses.CrsCod=att_events.CrsCod", Gbl.Hierarchy.Deg.DegCod); break; - case Hie_CRS: + case Hie_Lvl_CRS: DB_QuerySELECT (&mysql_res,"can not get number of courses with attendance events", "SELECT COUNT(DISTINCT CrsCod)" " FROM att_events" @@ -1766,7 +1766,7 @@ unsigned Att_GetNumCoursesWithAttEvents (Hie_Level_t Scope) // Returns the number of attendance events // in this location (all the platform, current degree or current course) -unsigned Att_GetNumAttEvents (Hie_Level_t Scope,unsigned *NumNotif) +unsigned Att_GetNumAttEvents (Hie_Lvl_Level_t Scope,unsigned *NumNotif) { MYSQL_RES *mysql_res; MYSQL_ROW row; @@ -1775,13 +1775,13 @@ unsigned Att_GetNumAttEvents (Hie_Level_t Scope,unsigned *NumNotif) /***** Get number of attendance events from database *****/ switch (Scope) { - case Hie_SYS: + case Hie_Lvl_SYS: DB_QuerySELECT (&mysql_res,"can not get number of attendance events", "SELECT COUNT(*),SUM(NumNotif)" " FROM att_events" " WHERE CrsCod>0"); break; - case Hie_INS: + case Hie_Lvl_INS: DB_QuerySELECT (&mysql_res,"can not get number of attendance events", "SELECT COUNT(*),SUM(att_events.NumNotif)" " FROM centres,degrees,courses,att_events" @@ -1791,7 +1791,7 @@ unsigned Att_GetNumAttEvents (Hie_Level_t Scope,unsigned *NumNotif) " AND courses.CrsCod=att_events.CrsCod", Gbl.Hierarchy.Ins.InsCod); break; - case Hie_CTR: + case Hie_Lvl_CTR: DB_QuerySELECT (&mysql_res,"can not get number of attendance events", "SELECT COUNT(*),SUM(att_events.NumNotif)" " FROM degrees,courses,att_events" @@ -1800,7 +1800,7 @@ unsigned Att_GetNumAttEvents (Hie_Level_t Scope,unsigned *NumNotif) " AND courses.CrsCod=att_events.CrsCod", Gbl.Hierarchy.Ctr.CtrCod); break; - case Hie_DEG: + case Hie_Lvl_DEG: DB_QuerySELECT (&mysql_res,"can not get number of attendance events", "SELECT COUNT(*),SUM(att_events.NumNotif)" " FROM courses,att_events" @@ -1808,7 +1808,7 @@ unsigned Att_GetNumAttEvents (Hie_Level_t Scope,unsigned *NumNotif) " AND courses.CrsCod=att_events.CrsCod", Gbl.Hierarchy.Deg.DegCod); break; - case Hie_CRS: + case Hie_Lvl_CRS: DB_QuerySELECT (&mysql_res,"can not get number of attendance events", "SELECT COUNT(*),SUM(NumNotif)" " FROM att_events" @@ -1980,7 +1980,7 @@ static void Att_ListAttStudents (struct Att_Events *Events, Grp_GetParCodsSeveralGrpsToShowUsrs (); /***** Get and order list of students in this course *****/ - Usr_GetListUsrs (Hie_CRS,Rol_STD); + Usr_GetListUsrs (Hie_Lvl_CRS,Rol_STD); /***** Begin box *****/ Box_BoxBegin (NULL,Txt_Attendance, @@ -2374,7 +2374,7 @@ void Att_RegisterStudentsInAttEvent (void) /***** 1. Get list of students in the groups selected: Gbl.Usrs.LstUsrs[Rol_STD] *****/ /* Get list of students in the groups selected */ - Usr_GetListUsrs (Hie_CRS,Rol_STD); + Usr_GetListUsrs (Hie_Lvl_CRS,Rol_STD); if (Gbl.Usrs.LstUsrs[Rol_STD].NumUsrs) // If there are students in the groups selected... { diff --git a/swad_attendance.h b/swad_attendance.h index c419d41d..d0e0c677 100644 --- a/swad_attendance.h +++ b/swad_attendance.h @@ -110,8 +110,8 @@ void Att_RemoveCrsAttEvents (long CrsCod); unsigned Att_GetNumAttEventsInCrs(long CrsCod); -unsigned Att_GetNumCoursesWithAttEvents (Hie_Level_t Scope); -unsigned Att_GetNumAttEvents (Hie_Level_t Scope,unsigned *NumNotif); +unsigned Att_GetNumCoursesWithAttEvents (Hie_Lvl_Level_t Scope); +unsigned Att_GetNumAttEvents (Hie_Lvl_Level_t Scope,unsigned *NumNotif); void Att_SeeOneAttEvent (void); diff --git a/swad_calendar.c b/swad_calendar.c index 027afc6c..2c4a9b42 100644 --- a/swad_calendar.c +++ b/swad_calendar.c @@ -309,7 +309,7 @@ static void Cal_PutIconsCalendar (__attribute__((unused)) void *Args) NULL,NULL); /***** View holidays *****/ - if (Gbl.Hierarchy.Level == Hie_INS) // Institution selected + if (Gbl.Hierarchy.Level == Hie_Lvl_INS) // Institution selected Hld_PutIconToSeeHlds (); } diff --git a/swad_centre.c b/swad_centre.c index 8c8be3c3..00400529 100644 --- a/swad_centre.c +++ b/swad_centre.c @@ -38,6 +38,7 @@ #include "swad_form.h" #include "swad_forum.h" #include "swad_global.h" +#include "swad_hierarchy.h" #include "swad_HTML.h" #include "swad_logo.h" #include "swad_message.h" @@ -226,7 +227,7 @@ void Ctr_DrawCentreLogoAndNameWithLink (struct Ctr_Centre *Ctr,Act_Action_t Acti Hie_FreeGoToMsg (); /***** Centre logo and name *****/ - Lgo_DrawLogo (Hie_CTR,Ctr->CtrCod,Ctr->ShrtName,16,ClassLogo,true); + Lgo_DrawLogo (Hie_Lvl_CTR,Ctr->CtrCod,Ctr->ShrtName,16,ClassLogo,true); HTM_TxtF (" %s",Ctr->FullName); /***** End link *****/ @@ -417,7 +418,7 @@ static void Ctr_ListOneCentreForSeeing (struct Ctr_Centre *Ctr,unsigned NumCtr) /***** Number of users in courses of this centre *****/ HTM_TD_Begin ("class=\"%s RM %s\"",TxtClassNormal,BgColor); - HTM_Unsigned (Usr_GetCachedNumUsrsInCrss (Hie_CTR,Ctr->CtrCod, + HTM_Unsigned (Usr_GetCachedNumUsrsInCrss (Hie_Lvl_CTR,Ctr->CtrCod, 1 << Rol_STD | 1 << Rol_NET | 1 << Rol_TCH)); // Any user @@ -778,11 +779,11 @@ static void Ctr_GetDataOfCentreFromRow (struct Ctr_Centre *Ctr,MYSQL_ROW row) /***** Get the short name of the centre (row[8]) *****/ Str_Copy (Ctr->ShrtName,row[8], - Hie_MAX_BYTES_SHRT_NAME); + Cns_HIERARCHY_MAX_BYTES_SHRT_NAME); /***** Get the full name of the centre (row[9]) *****/ Str_Copy (Ctr->FullName,row[9], - Hie_MAX_BYTES_FULL_NAME); + Cns_HIERARCHY_MAX_BYTES_FULL_NAME); /***** Get the URL of the centre (row[10]) *****/ Str_Copy (Ctr->WWW,row[10], @@ -840,7 +841,7 @@ void Ctr_GetShortNameOfCentreByCod (struct Ctr_Centre *Ctr) row = mysql_fetch_row (mysql_res); Str_Copy (Ctr->ShrtName,row[0], - Hie_MAX_BYTES_SHRT_NAME); + Cns_HIERARCHY_MAX_BYTES_SHRT_NAME); } /***** Free structure that stores the query result *****/ @@ -965,7 +966,7 @@ static void Ctr_ListCentresForEdition (const struct Plc_Places *Places) ICanEdit = Ctr_CheckIfICanEditACentre (Ctr); NumDegs = Deg_GetNumDegsInCtr (Ctr->CtrCod); NumUsrsCtr = Usr_GetNumUsrsWhoClaimToBelongToCtr (Ctr); - NumUsrsInCrssOfCtr = Usr_GetNumUsrsInCrss (Hie_CTR,Ctr->CtrCod, + NumUsrsInCrssOfCtr = Usr_GetNumUsrsInCrss (Hie_Lvl_CTR,Ctr->CtrCod, 1 << Rol_STD | 1 << Rol_NET | 1 << Rol_TCH); // Any user @@ -990,7 +991,7 @@ static void Ctr_ListCentresForEdition (const struct Plc_Places *Places) /* Centre logo */ HTM_TD_Begin ("title=\"%s\" class=\"HIE_LOGO\"",Ctr->FullName); - Lgo_DrawLogo (Hie_CTR,Ctr->CtrCod,Ctr->ShrtName,20,NULL,true); + Lgo_DrawLogo (Hie_Lvl_CTR,Ctr->CtrCod,Ctr->ShrtName,20,NULL,true); HTM_TD_End (); /* Place */ @@ -1027,7 +1028,7 @@ static void Ctr_ListCentresForEdition (const struct Plc_Places *Places) { Frm_StartForm (ActRenCtrSho); Ctr_PutParamOtherCtrCod (&Ctr->CtrCod); - HTM_INPUT_TEXT ("ShortName",Hie_MAX_CHARS_SHRT_NAME,Ctr->ShrtName, + HTM_INPUT_TEXT ("ShortName",Cns_HIERARCHY_MAX_CHARS_SHRT_NAME,Ctr->ShrtName, HTM_SUBMIT_ON_CHANGE, "class=\"INPUT_SHORT_NAME\""); Frm_EndForm (); @@ -1042,7 +1043,7 @@ static void Ctr_ListCentresForEdition (const struct Plc_Places *Places) { Frm_StartForm (ActRenCtrFul); Ctr_PutParamOtherCtrCod (&Ctr->CtrCod); - HTM_INPUT_TEXT ("FullName",Hie_MAX_CHARS_FULL_NAME,Ctr->FullName, + HTM_INPUT_TEXT ("FullName",Cns_HIERARCHY_MAX_CHARS_FULL_NAME,Ctr->FullName, HTM_SUBMIT_ON_CHANGE, "class=\"INPUT_FULL_NAME\""); Frm_EndForm (); @@ -1244,7 +1245,7 @@ void Ctr_RemoveCentre (void) else if (Usr_GetNumUsrsWhoClaimToBelongToCtr (Ctr_EditingCtr)) // Centre has users who claim to belong to it Ale_ShowAlert (Ale_WARNING, Txt_To_remove_a_centre_you_must_first_remove_all_degrees_and_teachers_in_the_centre); - else if (Usr_GetNumUsrsInCrss (Hie_CTR,Ctr_EditingCtr->CtrCod, + else if (Usr_GetNumUsrsInCrss (Hie_Lvl_CTR,Ctr_EditingCtr->CtrCod, 1 << Rol_STD | 1 << Rol_NET | 1 << Rol_TCH)) // Centre has users @@ -1253,10 +1254,10 @@ void Ctr_RemoveCentre (void) else // Centre has no degrees or users ==> remove it { /***** Remove all the threads and posts in forums of the centre *****/ - For_RemoveForums (Hie_CTR,Ctr_EditingCtr->CtrCod); + For_RemoveForums (Hie_Lvl_CTR,Ctr_EditingCtr->CtrCod); /***** Remove surveys of the centre *****/ - Svy_RemoveSurveys (Hie_CTR,Ctr_EditingCtr->CtrCod); + Svy_RemoveSurveys (Hie_Lvl_CTR,Ctr_EditingCtr->CtrCod); /***** Remove information related to files in centre *****/ Brw_RemoveCtrFilesFromDB (Ctr_EditingCtr->CtrCod); @@ -1370,20 +1371,20 @@ void Ctr_RenameCentre (struct Ctr_Centre *Ctr,Cns_ShrtOrFullName_t ShrtOrFullNam const char *FieldName = NULL; // Initialized to avoid warning unsigned MaxBytes = 0; // Initialized to avoid warning char *CurrentCtrName = NULL; // Initialized to avoid warning - char NewCtrName[Hie_MAX_BYTES_FULL_NAME + 1]; + char NewCtrName[Cns_HIERARCHY_MAX_BYTES_FULL_NAME + 1]; switch (ShrtOrFullName) { case Cns_SHRT_NAME: ParamName = "ShortName"; FieldName = "ShortName"; - MaxBytes = Hie_MAX_BYTES_SHRT_NAME; + MaxBytes = Cns_HIERARCHY_MAX_BYTES_SHRT_NAME; CurrentCtrName = Ctr->ShrtName; break; case Cns_FULL_NAME: ParamName = "FullName"; FieldName = "FullName"; - MaxBytes = Hie_MAX_BYTES_FULL_NAME; + MaxBytes = Cns_HIERARCHY_MAX_BYTES_FULL_NAME; CurrentCtrName = Ctr->FullName; break; } @@ -1636,7 +1637,7 @@ static void Ctr_PutFormToCreateCentre (const struct Plc_Places *Places) /***** Centre logo *****/ HTM_TD_Begin ("title=\"%s\" class=\"HIE_LOGO\"",Ctr_EditingCtr->FullName); - Lgo_DrawLogo (Hie_CTR,-1L,"",20,NULL,true); + Lgo_DrawLogo (Hie_Lvl_CTR,-1L,"",20,NULL,true); HTM_TD_End (); /***** Place *****/ @@ -1657,14 +1658,14 @@ static void Ctr_PutFormToCreateCentre (const struct Plc_Places *Places) /***** Centre short name *****/ HTM_TD_Begin ("class=\"LM\""); - HTM_INPUT_TEXT ("ShortName",Hie_MAX_CHARS_SHRT_NAME,Ctr_EditingCtr->ShrtName, + HTM_INPUT_TEXT ("ShortName",Cns_HIERARCHY_MAX_CHARS_SHRT_NAME,Ctr_EditingCtr->ShrtName, HTM_DONT_SUBMIT_ON_CHANGE, "class=\"INPUT_SHORT_NAME\" required=\"required\""); HTM_TD_End (); /***** Centre full name *****/ HTM_TD_Begin ("class=\"LM\""); - HTM_INPUT_TEXT ("FullName",Hie_MAX_CHARS_FULL_NAME,Ctr_EditingCtr->FullName, + HTM_INPUT_TEXT ("FullName",Cns_HIERARCHY_MAX_CHARS_FULL_NAME,Ctr_EditingCtr->FullName, HTM_DONT_SUBMIT_ON_CHANGE, "class=\"INPUT_FULL_NAME\" required=\"required\""); HTM_TD_End (); @@ -1851,10 +1852,10 @@ static void Ctr_ReceiveFormRequestOrCreateCtr (unsigned Status) Ale_ShowAlert (Ale_ERROR,"Wrong place."); /* Get centre short name */ - Par_GetParToText ("ShortName",Ctr_EditingCtr->ShrtName,Hie_MAX_BYTES_SHRT_NAME); + Par_GetParToText ("ShortName",Ctr_EditingCtr->ShrtName,Cns_HIERARCHY_MAX_BYTES_SHRT_NAME); /* Get centre full name */ - Par_GetParToText ("FullName",Ctr_EditingCtr->FullName,Hie_MAX_BYTES_FULL_NAME); + Par_GetParToText ("FullName",Ctr_EditingCtr->FullName,Cns_HIERARCHY_MAX_BYTES_FULL_NAME); /* Get centre WWW */ Par_GetParToText ("WWW",Ctr_EditingCtr->WWW,Cns_MAX_BYTES_WWW); @@ -1923,12 +1924,12 @@ unsigned Ctr_GetCachedNumCtrsInSys (void) unsigned NumCtrs; /***** Get number of centres from cache *****/ - if (!FigCch_GetFigureFromCache (FigCch_NUM_CTRS,Hie_SYS,-1L, + if (!FigCch_GetFigureFromCache (FigCch_NUM_CTRS,Hie_Lvl_SYS,-1L, FigCch_UNSIGNED,&NumCtrs)) { /***** Get current number of centres from database and update cache *****/ NumCtrs = (unsigned) DB_GetNumRowsTable ("centres"); - FigCch_UpdateFigureIntoCache (FigCch_NUM_CTRS,Hie_SYS,-1L, + FigCch_UpdateFigureIntoCache (FigCch_NUM_CTRS,Hie_Lvl_SYS,-1L, FigCch_UNSIGNED,&NumCtrs); } @@ -1963,7 +1964,7 @@ static unsigned Ctr_GetNumCtrsInCty (long CtyCod) " WHERE institutions.CtyCod=%ld" " AND institutions.InsCod=centres.InsCod", CtyCod); - FigCch_UpdateFigureIntoCache (FigCch_NUM_CTRS,Hie_CTY,Gbl.Cache.NumCtrsInCty.CtyCod, + FigCch_UpdateFigureIntoCache (FigCch_NUM_CTRS,Hie_Lvl_CTY,Gbl.Cache.NumCtrsInCty.CtyCod, FigCch_UNSIGNED,&Gbl.Cache.NumCtrsInCty.NumCtrs); return Gbl.Cache.NumCtrsInCty.NumCtrs; } @@ -1973,7 +1974,7 @@ unsigned Ctr_GetCachedNumCtrsInCty (long CtyCod) unsigned NumCtrs; /***** Get number of centres from cache *****/ - if (!FigCch_GetFigureFromCache (FigCch_NUM_CTRS,Hie_CTY,CtyCod, + if (!FigCch_GetFigureFromCache (FigCch_NUM_CTRS,Hie_Lvl_CTY,CtyCod, FigCch_UNSIGNED,&NumCtrs)) /***** Get current number of centres from database and update cache *****/ NumCtrs = Ctr_GetNumCtrsInCty (CtyCod); @@ -2008,7 +2009,7 @@ unsigned Ctr_GetNumCtrsInIns (long InsCod) "SELECT COUNT(*) FROM centres" " WHERE InsCod=%ld", InsCod); - FigCch_UpdateFigureIntoCache (FigCch_NUM_CTRS,Hie_INS,Gbl.Cache.NumCtrsInIns.InsCod, + FigCch_UpdateFigureIntoCache (FigCch_NUM_CTRS,Hie_Lvl_INS,Gbl.Cache.NumCtrsInIns.InsCod, FigCch_UNSIGNED,&Gbl.Cache.NumCtrsInIns.NumCtrs); return Gbl.Cache.NumCtrsInIns.NumCtrs; } @@ -2018,7 +2019,7 @@ unsigned Ctr_GetCachedNumCtrsInIns (long InsCod) unsigned NumCtrs; /***** Get number of centres from cache *****/ - if (!FigCch_GetFigureFromCache (FigCch_NUM_CTRS,Hie_INS,InsCod, + if (!FigCch_GetFigureFromCache (FigCch_NUM_CTRS,Hie_Lvl_INS,InsCod, FigCch_UNSIGNED,&NumCtrs)) /***** Get current number of centres from database and update cache *****/ NumCtrs = Ctr_GetNumCtrsInIns (InsCod); @@ -2035,7 +2036,7 @@ unsigned Ctr_GetCachedNumCtrsWithMapInSys (void) unsigned NumCtrsWithMap; /***** Get number of centres with map from cache *****/ - if (!FigCch_GetFigureFromCache (FigCch_NUM_CTRS_WITH_MAP,Hie_SYS,-1L, + if (!FigCch_GetFigureFromCache (FigCch_NUM_CTRS_WITH_MAP,Hie_Lvl_SYS,-1L, FigCch_UNSIGNED,&NumCtrsWithMap)) { /***** Get current number of centres with map from database and update cache *****/ @@ -2044,7 +2045,7 @@ unsigned Ctr_GetCachedNumCtrsWithMapInSys (void) DB_QueryCOUNT ("can not get number of centres with map", "SELECT COUNT(*) FROM centres" " WHERE Latitude<>0 OR Longitude<>0"); - FigCch_UpdateFigureIntoCache (FigCch_NUM_CTRS_WITH_MAP,Hie_SYS,-1L, + FigCch_UpdateFigureIntoCache (FigCch_NUM_CTRS_WITH_MAP,Hie_Lvl_SYS,-1L, FigCch_UNSIGNED,&NumCtrsWithMap); } @@ -2060,7 +2061,7 @@ unsigned Ctr_GetCachedNumCtrsWithMapInCty (long CtyCod) unsigned NumCtrsWithMap; /***** Get number of centres with map from cache *****/ - if (!FigCch_GetFigureFromCache (FigCch_NUM_CTRS_WITH_MAP,Hie_CTY,CtyCod, + if (!FigCch_GetFigureFromCache (FigCch_NUM_CTRS_WITH_MAP,Hie_Lvl_CTY,CtyCod, FigCch_UNSIGNED,&NumCtrsWithMap)) { /***** Get current number of centres with map from database and update cache *****/ @@ -2072,7 +2073,7 @@ unsigned Ctr_GetCachedNumCtrsWithMapInCty (long CtyCod) " AND institutions.InsCod=centres.InsCod" " AND (centres.Latitude<>0 OR centres.Longitude<>0)", CtyCod); - FigCch_UpdateFigureIntoCache (FigCch_NUM_CTRS_WITH_MAP,Hie_CTY,CtyCod, + FigCch_UpdateFigureIntoCache (FigCch_NUM_CTRS_WITH_MAP,Hie_Lvl_CTY,CtyCod, FigCch_UNSIGNED,&NumCtrsWithMap); } @@ -2088,7 +2089,7 @@ unsigned Ctr_GetCachedNumCtrsWithMapInIns (long InsCod) unsigned NumCtrsWithMap; /***** Get number of centres with map from cache *****/ - if (!FigCch_GetFigureFromCache (FigCch_NUM_CTRS_WITH_MAP,Hie_INS,InsCod, + if (!FigCch_GetFigureFromCache (FigCch_NUM_CTRS_WITH_MAP,Hie_Lvl_INS,InsCod, FigCch_UNSIGNED,&NumCtrsWithMap)) { /***** Get current number of centres with map from database and update cache *****/ @@ -2099,7 +2100,7 @@ unsigned Ctr_GetCachedNumCtrsWithMapInIns (long InsCod) " WHERE InsCod=%ld" " AND (Latitude<>0 OR Longitude<>0)", InsCod); - FigCch_UpdateFigureIntoCache (FigCch_NUM_CTRS_WITH_MAP,Hie_INS,InsCod, + FigCch_UpdateFigureIntoCache (FigCch_NUM_CTRS_WITH_MAP,Hie_Lvl_INS,InsCod, FigCch_UNSIGNED,&NumCtrsWithMap); } @@ -2125,7 +2126,7 @@ unsigned Ctr_GetNumCtrsInPlc (long PlcCod) /*****************************************************************************/ unsigned Ctr_GetCachedNumCtrsWithDegs (const char *SubQuery, - Hie_Level_t Scope,long Cod) + Hie_Lvl_Level_t Scope,long Cod) { unsigned NumCtrsWithDegs; @@ -2153,7 +2154,7 @@ unsigned Ctr_GetCachedNumCtrsWithDegs (const char *SubQuery, /*****************************************************************************/ unsigned Ctr_GetCachedNumCtrsWithCrss (const char *SubQuery, - Hie_Level_t Scope,long Cod) + Hie_Lvl_Level_t Scope,long Cod) { unsigned NumCtrsWithCrss; @@ -2182,7 +2183,7 @@ unsigned Ctr_GetCachedNumCtrsWithCrss (const char *SubQuery, /*****************************************************************************/ unsigned Ctr_GetCachedNumCtrsWithUsrs (Rol_Role_t Role,const char *SubQuery, - Hie_Level_t Scope,long Cod) + Hie_Lvl_Level_t Scope,long Cod) { static const FigCch_FigureCached_t FigureCtrs[Rol_NUM_ROLES] = { diff --git a/swad_centre.h b/swad_centre.h index 415862b3..270bf9c8 100644 --- a/swad_centre.h +++ b/swad_centre.h @@ -68,8 +68,8 @@ struct Ctr_Centre Ctr_Status_t Status; // Centre status long RequesterUsrCod; // User code of the person who requested the creation of this centre struct Coordinates Coord; // Geographical coordinates - char ShrtName[Hie_MAX_BYTES_SHRT_NAME + 1]; - char FullName[Hie_MAX_BYTES_FULL_NAME + 1]; + char ShrtName[Cns_HIERARCHY_MAX_BYTES_SHRT_NAME + 1]; + char FullName[Cns_HIERARCHY_MAX_BYTES_FULL_NAME + 1]; char WWW[Cns_MAX_BYTES_WWW + 1]; struct { @@ -148,11 +148,11 @@ unsigned Ctr_GetCachedNumCtrsWithMapInIns (long InsCod); unsigned Ctr_GetNumCtrsInPlc (long PlcCod); unsigned Ctr_GetCachedNumCtrsWithDegs (const char *SubQuery, - Hie_Level_t Scope,long Cod); + Hie_Lvl_Level_t Scope,long Cod); unsigned Ctr_GetCachedNumCtrsWithCrss (const char *SubQuery, - Hie_Level_t Scope,long Cod); + Hie_Lvl_Level_t Scope,long Cod); unsigned Ctr_GetCachedNumCtrsWithUsrs (Rol_Role_t Role,const char *SubQuery, - Hie_Level_t Scope,long Cod); + Hie_Lvl_Level_t Scope,long Cod); void Ctr_ListCtrsFound (MYSQL_RES **mysql_res,unsigned NumCtrs); diff --git a/swad_centre_config.c b/swad_centre_config.c index fbf84f60..37c1727c 100644 --- a/swad_centre_config.c +++ b/swad_centre_config.c @@ -39,6 +39,7 @@ #include "swad_form.h" #include "swad_global.h" #include "swad_help.h" +#include "swad_hierarchy.h" #include "swad_hierarchy_config.h" #include "swad_HTML.h" #include "swad_logo.h" @@ -210,10 +211,10 @@ static void CtrCfg_Configuration (bool PrintView) CtrCfg_NumCrss (); /***** Number of users in courses of this centre *****/ - HieCfg_NumUsrsInCrss (Hie_CTR,Gbl.Hierarchy.Ctr.CtrCod,Rol_TCH); - HieCfg_NumUsrsInCrss (Hie_CTR,Gbl.Hierarchy.Ctr.CtrCod,Rol_NET); - HieCfg_NumUsrsInCrss (Hie_CTR,Gbl.Hierarchy.Ctr.CtrCod,Rol_STD); - HieCfg_NumUsrsInCrss (Hie_CTR,Gbl.Hierarchy.Ctr.CtrCod,Rol_UNK); + HieCfg_NumUsrsInCrss (Hie_Lvl_CTR,Gbl.Hierarchy.Ctr.CtrCod,Rol_TCH); + HieCfg_NumUsrsInCrss (Hie_Lvl_CTR,Gbl.Hierarchy.Ctr.CtrCod,Rol_NET); + HieCfg_NumUsrsInCrss (Hie_Lvl_CTR,Gbl.Hierarchy.Ctr.CtrCod,Rol_STD); + HieCfg_NumUsrsInCrss (Hie_Lvl_CTR,Gbl.Hierarchy.Ctr.CtrCod,Rol_UNK); } /***** End table *****/ @@ -272,7 +273,7 @@ static void CtrCfg_PutIconsCtrConfig (__attribute__((unused)) void *Args) // have permission to upload logo and photo of the centre { /***** Put icon to upload logo of centre *****/ - Lgo_PutIconToChangeLogo (Hie_CTR); + Lgo_PutIconToChangeLogo (Hie_Lvl_CTR); /***** Put icon to upload photo of centre *****/ CtrCfg_PutIconToChangePhoto (); @@ -312,7 +313,7 @@ static void CtrCfg_PutIconToChangePhoto (void) static void CtrCfg_Title (bool PutLink) { HieCfg_Title (PutLink, - Hie_CTR, // Logo scope + Hie_Lvl_CTR, // Logo scope Gbl.Hierarchy.Ctr.CtrCod, // Logo code Gbl.Hierarchy.Ctr.ShrtName, // Logo short name Gbl.Hierarchy.Ctr.FullName, // Logo full name @@ -605,7 +606,7 @@ static void CtrCfg_Institution (bool PrintView,bool PutForm) "BT_LINK LT DAT",NULL); Hie_FreeGoToMsg (); } - Lgo_DrawLogo (Hie_INS,Gbl.Hierarchy.Ins.InsCod,Gbl.Hierarchy.Ins.ShrtName, + Lgo_DrawLogo (Hie_Lvl_INS,Gbl.Hierarchy.Ins.InsCod,Gbl.Hierarchy.Ins.ShrtName, 20,"LM",true); HTM_NBSP (); HTM_Txt (Gbl.Hierarchy.Ins.FullName); @@ -810,7 +811,7 @@ static void CtrCfg_NumCrss (void) void CtrCfg_RequestLogo (void) { - Lgo_RequestLogo (Hie_CTR); + Lgo_RequestLogo (Hie_Lvl_CTR); } /*****************************************************************************/ @@ -819,7 +820,7 @@ void CtrCfg_RequestLogo (void) void CtrCfg_ReceiveLogo (void) { - Lgo_ReceiveLogo (Hie_CTR); + Lgo_ReceiveLogo (Hie_Lvl_CTR); } /*****************************************************************************/ @@ -828,7 +829,7 @@ void CtrCfg_ReceiveLogo (void) void CtrCfg_RemoveLogo (void) { - Lgo_RemoveLogo (Hie_CTR); + Lgo_RemoveLogo (Hie_Lvl_CTR); } /*****************************************************************************/ diff --git a/swad_changelog.h b/swad_changelog.h index d3760509..219666c9 100644 --- a/swad_changelog.h +++ b/swad_changelog.h @@ -553,7 +553,7 @@ enscript -2 --landscape --color --file-align=2 --highlight --line-numbers -o - * En OpenSWAD: ps2pdf source.ps destination.pdf */ -#define Log_PLATFORM_VERSION "SWAD 20.29.3 (2021-02-11)" +#define Log_PLATFORM_VERSION "SWAD 20.30 (2021-02-11)" #define CSS_FILE "swad20.8.css" #define JS_FILE "swad20.6.2.js" /* @@ -601,6 +601,7 @@ TODO: DNI de un estudiante sale err TODO: BUG: Cuando un tipo de grupo sólo tiene un grupo, inscribirse es voluntario, el estudiante sólo puede pertenecer a un grupo, y se inscribe en él, debería poder desapuntarse. Ahora no puede. TODO: Salvador Romero Cortés: @acanas opción para editar posts + Version 20.30: Feb 11, 2021 Code refactoring in hierarchy. (? lines) Version 20.29.3: Feb 11, 2021 Code refactoring in timeline. (305826 lines) Version 20.29.2: Feb 11, 2021 Code refactoring in timeline. (305806 lines) Version 20.29.1: Feb 11, 2021 Code refactoring in timeline. (305780 lines) diff --git a/swad_chat.c b/swad_chat.c index de482b13..1be41f9b 100644 --- a/swad_chat.c +++ b/swad_chat.c @@ -191,7 +191,7 @@ void Cht_ShowListOfAvailableChatRooms (void) "%s %s", Txt_Degree,Deg.ShrtName); Cht_WriteLinkToChat1 (ThisRoomCode,ThisRoomShrtName,ThisRoomFullName,1,IsLastItemInLevel); - Lgo_DrawLogo (Hie_DEG,Deg.DegCod,Deg.ShrtName,16,NULL,true); + Lgo_DrawLogo (Hie_Lvl_DEG,Deg.DegCod,Deg.ShrtName,16,NULL,true); Cht_WriteLinkToChat2 (ThisRoomCode,ThisRoomFullName); /* Get my courses in this degree from database */ diff --git a/swad_connected.c b/swad_connected.c index 75135440..5b50ecdb 100644 --- a/swad_connected.c +++ b/swad_connected.c @@ -37,7 +37,7 @@ #include "swad_database.h" #include "swad_form.h" #include "swad_global.h" -#include "swad_hierarchy.h" +#include "swad_hierarchy_level.h" #include "swad_HTML.h" #include "swad_log.h" #include "swad_parameter.h" @@ -117,7 +117,7 @@ void Con_ShowConnectedUsrs (void) Con_ShowGlobalConnectedUsrs (); /***** Show connected users in the current location *****/ - if (Gbl.Scope.Current != Hie_UNK) + if (Gbl.Scope.Current != Hie_Lvl_UNK) Con_ShowConnectedUsrsBelongingToLocation (); /***** End box *****/ @@ -225,13 +225,13 @@ static void Con_ShowGlobalConnectedUsrsRole (Rol_Role_t Role,unsigned UsrsTotal) void Con_ComputeConnectedUsrsBelongingToCurrentCrs (void) { if ((Gbl.Prefs.SideCols & Lay_SHOW_RIGHT_COLUMN) && // Right column visible - Gbl.Hierarchy.Level == Hie_CRS && // Course selected + Gbl.Hierarchy.Level == Hie_Lvl_CRS && // Course selected (Gbl.Usrs.Me.IBelongToCurrentCrs || // I can view users Gbl.Usrs.Me.Role.Logged == Rol_SYS_ADM)) { Gbl.Usrs.Connected.NumUsrs = 0; Gbl.Usrs.Connected.NumUsrsToList = 0; - Gbl.Scope.Current = Hie_CRS; + Gbl.Scope.Current = Hie_Lvl_CRS; /***** Number of teachers *****/ Con_ComputeConnectedUsrsWithARoleBelongingToCurrentCrs (Rol_TCH); @@ -305,7 +305,7 @@ void Con_ShowConnectedUsrsBelongingToCurrentCrs (void) { extern const char *Txt_Connected_users; extern const char *Txt_from; - char CourseName[Hie_MAX_BYTES_SHRT_NAME + 1]; + char CourseName[Cns_HIERARCHY_MAX_BYTES_SHRT_NAME + 1]; struct ConnectedUsrs Usrs; /***** Trivial check *****/ @@ -322,7 +322,7 @@ void Con_ShowConnectedUsrsBelongingToCurrentCrs (void) // is dynamically updated via AJAX HTM_BUTTON_SUBMIT_Begin (Txt_Connected_users,"BT_LINK CONNECTED_TXT",NULL); Str_Copy (CourseName,Gbl.Hierarchy.Crs.ShrtName, - Hie_MAX_BYTES_SHRT_NAME); + Cns_HIERARCHY_MAX_BYTES_SHRT_NAME); Con_GetNumConnectedUsrsWithARoleBelongingCurrentLocation (Rol_UNK,&Usrs); HTM_TxtF ("%u %s %s",Usrs.NumUsrs,Txt_from,CourseName); HTM_BUTTON_End (); @@ -411,7 +411,7 @@ static void Con_ShowConnectedUsrsWithARoleBelongingToCurrentCrsOnRightColumn (Ro Frm_StartFormUnique (ActLstCon); // Must be unique because // the list of connected users // is dynamically updated via AJAX - Sco_PutParamScope ("ScopeCon",Hie_CRS); + Sco_PutParamScope ("ScopeCon",Hie_Lvl_CRS); HTM_INPUT_IMAGE (Cfg_URL_ICON_PUBLIC,"ellipsis-h.svg", Txt_Connected_users,"ICO16x16"); Frm_EndForm (); @@ -488,7 +488,7 @@ static void Con_GetNumConnectedUsrsWithARoleBelongingCurrentLocation (Rol_Role_t case Rol_UNK: // Here Rol_UNK means "any role" switch (Gbl.Scope.Current) { - case Hie_SYS: // Show connected users in the whole platform + case Hie_Lvl_SYS: // Show connected users in the whole platform DB_QuerySELECT (&mysql_res,"can not get number" " of connected users" " who belong to this location", @@ -497,7 +497,7 @@ static void Con_GetNumConnectedUsrsWithARoleBelongingCurrentLocation (Rol_Role_t " FROM connected,usr_data" " WHERE connected.UsrCod=usr_data.UsrCod"); break; - case Hie_CTY: // Show connected users in the current country + case Hie_Lvl_CTY: // Show connected users in the current country DB_QuerySELECT (&mysql_res,"can not get number" " of connected users" " who belong to this location", @@ -513,7 +513,7 @@ static void Con_GetNumConnectedUsrsWithARoleBelongingCurrentLocation (Rol_Role_t " AND connected.UsrCod=usr_data.UsrCod", Gbl.Hierarchy.Cty.CtyCod); break; - case Hie_INS: // Show connected users in the current institution + case Hie_Lvl_INS: // Show connected users in the current institution DB_QuerySELECT (&mysql_res,"can not get number" " of connected users" " who belong to this location", @@ -528,7 +528,7 @@ static void Con_GetNumConnectedUsrsWithARoleBelongingCurrentLocation (Rol_Role_t " AND connected.UsrCod=usr_data.UsrCod", Gbl.Hierarchy.Ins.InsCod); break; - case Hie_CTR: // Show connected users in the current centre + case Hie_Lvl_CTR: // Show connected users in the current centre DB_QuerySELECT (&mysql_res,"can not get number" " of connected users" " who belong to this location", @@ -542,7 +542,7 @@ static void Con_GetNumConnectedUsrsWithARoleBelongingCurrentLocation (Rol_Role_t " AND connected.UsrCod=usr_data.UsrCod", Gbl.Hierarchy.Ctr.CtrCod); break; - case Hie_DEG: // Show connected users in the current degree + case Hie_Lvl_DEG: // Show connected users in the current degree DB_QuerySELECT (&mysql_res,"can not get number" " of connected users" " who belong to this location", @@ -555,7 +555,7 @@ static void Con_GetNumConnectedUsrsWithARoleBelongingCurrentLocation (Rol_Role_t " AND connected.UsrCod=usr_data.UsrCod", Gbl.Hierarchy.Deg.DegCod); break; - case Hie_CRS: // Show connected users in the current course + case Hie_Lvl_CRS: // Show connected users in the current course DB_QuerySELECT (&mysql_res,"can not get number" " of connected users" " who belong to this location", @@ -587,7 +587,7 @@ static void Con_GetNumConnectedUsrsWithARoleBelongingCurrentLocation (Rol_Role_t case Rol_TCH: switch (Gbl.Scope.Current) { - case Hie_SYS: // Show connected users in the whole platform + case Hie_Lvl_SYS: // Show connected users in the whole platform DB_QuerySELECT (&mysql_res,"can not get number" " of connected users" " who belong to this location", @@ -599,7 +599,7 @@ static void Con_GetNumConnectedUsrsWithARoleBelongingCurrentLocation (Rol_Role_t " AND connected.UsrCod=usr_data.UsrCod", (unsigned) Role); break; - case Hie_CTY: // Show connected users in the current country + case Hie_Lvl_CTY: // Show connected users in the current country DB_QuerySELECT (&mysql_res,"can not get number" " of connected users" " who belong to this location", @@ -617,7 +617,7 @@ static void Con_GetNumConnectedUsrsWithARoleBelongingCurrentLocation (Rol_Role_t Gbl.Hierarchy.Cty.CtyCod, (unsigned) Role); break; - case Hie_INS: // Show connected users in the current institution + case Hie_Lvl_INS: // Show connected users in the current institution DB_QuerySELECT (&mysql_res,"can not get number" " of connected users" " who belong to this location", @@ -634,7 +634,7 @@ static void Con_GetNumConnectedUsrsWithARoleBelongingCurrentLocation (Rol_Role_t Gbl.Hierarchy.Ins.InsCod, (unsigned) Role); break; - case Hie_CTR: // Show connected users in the current centre + case Hie_Lvl_CTR: // Show connected users in the current centre DB_QuerySELECT (&mysql_res,"can not get number" " of connected users" " who belong to this location", @@ -650,7 +650,7 @@ static void Con_GetNumConnectedUsrsWithARoleBelongingCurrentLocation (Rol_Role_t Gbl.Hierarchy.Ctr.CtrCod, (unsigned) Role); break; - case Hie_DEG: // Show connected users in the current degree + case Hie_Lvl_DEG: // Show connected users in the current degree DB_QuerySELECT (&mysql_res,"can not get number" " of connected users" " who belong to this location", @@ -665,7 +665,7 @@ static void Con_GetNumConnectedUsrsWithARoleBelongingCurrentLocation (Rol_Role_t Gbl.Hierarchy.Deg.DegCod, (unsigned) Role); break; - case Hie_CRS: // Show connected users in the current course + case Hie_Lvl_CRS: // Show connected users in the current course DB_QuerySELECT (&mysql_res,"can not get number" " of connected users" " who belong to this location", @@ -897,8 +897,8 @@ static void Con_ShowConnectedUsrsCurrentLocationOneByOneOnMainZone (Rol_Role_t R const char *ClassTxt; const char *ClassLink; struct UsrData UsrDat; - bool PutLinkToRecord = (Gbl.Hierarchy.Level == Hie_CRS && // Course selected - Gbl.Scope.Current == Hie_CRS && // Scope is current course + bool PutLinkToRecord = (Gbl.Hierarchy.Level == Hie_Lvl_CRS && // Course selected + Gbl.Scope.Current == Hie_Lvl_CRS && // Scope is current course (Role == Rol_STD || // Role is student,... Role == Rol_NET || // ...non-editing teacher... Role == Rol_TCH)); // ...or teacher @@ -920,7 +920,7 @@ static void Con_ShowConnectedUsrsCurrentLocationOneByOneOnMainZone (Rol_Role_t R case Rol_TCH: switch (Gbl.Scope.Current) { - case Hie_SYS: // Show connected users in the whole platform + case Hie_Lvl_SYS: // Show connected users in the whole platform NumUsrs = (unsigned) DB_QuerySELECT (&mysql_res,"can not get list of connected users" " who belong to this location", "SELECT DISTINCTROW connected.UsrCod,connected.LastCrsCod," @@ -931,7 +931,7 @@ static void Con_ShowConnectedUsrsCurrentLocationOneByOneOnMainZone (Rol_Role_t R " ORDER BY Dif", (unsigned) Role); break; - case Hie_CTY: // Show connected users in the current country + case Hie_Lvl_CTY: // Show connected users in the current country NumUsrs = (unsigned) DB_QuerySELECT (&mysql_res,"can not get list of connected users" " who belong to this location", "SELECT DISTINCTROW connected.UsrCod,connected.LastCrsCod," @@ -948,7 +948,7 @@ static void Con_ShowConnectedUsrsCurrentLocationOneByOneOnMainZone (Rol_Role_t R Gbl.Hierarchy.Cty.CtyCod, (unsigned) Role); break; - case Hie_INS: // Show connected users in the current institution + case Hie_Lvl_INS: // Show connected users in the current institution NumUsrs = (unsigned) DB_QuerySELECT (&mysql_res,"can not get list of connected users" " who belong to this location", "SELECT DISTINCTROW connected.UsrCod,connected.LastCrsCod," @@ -964,7 +964,7 @@ static void Con_ShowConnectedUsrsCurrentLocationOneByOneOnMainZone (Rol_Role_t R Gbl.Hierarchy.Ins.InsCod, (unsigned) Role); break; - case Hie_CTR: // Show connected users in the current centre + case Hie_Lvl_CTR: // Show connected users in the current centre NumUsrs = (unsigned) DB_QuerySELECT (&mysql_res,"can not get list of connected users" " who belong to this location", "SELECT DISTINCTROW connected.UsrCod,connected.LastCrsCod," @@ -979,7 +979,7 @@ static void Con_ShowConnectedUsrsCurrentLocationOneByOneOnMainZone (Rol_Role_t R Gbl.Hierarchy.Ctr.CtrCod, (unsigned) Role); break; - case Hie_DEG: // Show connected users in the current degree + case Hie_Lvl_DEG: // Show connected users in the current degree NumUsrs = (unsigned) DB_QuerySELECT (&mysql_res,"can not get list of connected users" " who belong to this location", "SELECT DISTINCTROW connected.UsrCod,connected.LastCrsCod," @@ -993,7 +993,7 @@ static void Con_ShowConnectedUsrsCurrentLocationOneByOneOnMainZone (Rol_Role_t R Gbl.Hierarchy.Deg.DegCod, (unsigned) Role); break; - case Hie_CRS: // Show connected users in the current course + case Hie_Lvl_CRS: // Show connected users in the current course NumUsrs = (unsigned) DB_QuerySELECT (&mysql_res,"can not get list of connected users" " who belong to this location", "SELECT connected.UsrCod,connected.LastCrsCod," diff --git a/swad_constant.h b/swad_constant.h index 21e845e2..7bc851e2 100644 --- a/swad_constant.h +++ b/swad_constant.h @@ -93,6 +93,13 @@ so that all calculations should be performed by the preprocessor with integers. #define Cns_MAX_DECIMAL_DIGITS_LONGLONG (1 + Cns_MAX_DECIMAL_DIGITS_ULONGLONG) #define Cns_MAX_DECIMAL_DIGITS_INT128 (1 + Cns_MAX_DECIMAL_DIGITS_UINT128 ) +/* Hierarchy names */ +#define Cns_HIERARCHY_MAX_CHARS_SHRT_NAME (32 - 1) // 31 +#define Cns_HIERARCHY_MAX_BYTES_SHRT_NAME ((Cns_HIERARCHY_MAX_CHARS_SHRT_NAME + 1) * Str_MAX_BYTES_PER_CHAR - 1) // 511 + +#define Cns_HIERARCHY_MAX_CHARS_FULL_NAME (128 - 1) // 127 +#define Cns_HIERARCHY_MAX_BYTES_FULL_NAME ((Cns_HIERARCHY_MAX_CHARS_FULL_NAME + 1) * Str_MAX_BYTES_PER_CHAR - 1) // 2047 + /*****************************************************************************/ /******************************* Public types ********************************/ /*****************************************************************************/ diff --git a/swad_country.c b/swad_country.c index c32ec426..b76965e7 100644 --- a/swad_country.c +++ b/swad_country.c @@ -38,6 +38,7 @@ #include "swad_figure_cache.h" #include "swad_form.h" #include "swad_global.h" +#include "swad_hierarchy.h" #include "swad_HTML.h" #include "swad_survey.h" @@ -59,7 +60,7 @@ extern struct Globals Gbl; /***************************** Private variables *****************************/ /*****************************************************************************/ -static struct Country *Cty_EditingCty = NULL; // Static variable to keep the country being edited +static struct Cty_Countr *Cty_EditingCty = NULL; // Static variable to keep the country being edited long Cty_CurrentCtyCod = -1L; // Used as parameter in contextual links /*****************************************************************************/ @@ -67,7 +68,7 @@ long Cty_CurrentCtyCod = -1L; // Used as parameter in contextual links /*****************************************************************************/ static void Cty_PutHeadCountriesForSeeing (bool OrderSelectable); -static void Cty_ListOneCountryForSeeing (struct Country *Cty,unsigned NumCty); +static void Cty_ListOneCountryForSeeing (struct Cty_Countr *Cty,unsigned NumCty); static void Cty_PutIconsListingCountries (__attribute__((unused)) void *Args); static void Cty_PutIconToEditCountries (void); @@ -97,7 +98,7 @@ static void Cty_CreateCountry (void); static void Cty_EditingCountryConstructor (void); static void Cty_EditingCountryDestructor (void); -static void Cty_FormToGoToMap (struct Country *Cty); +static void Cty_FormToGoToMap (struct Cty_Countr *Cty); /*****************************************************************************/ /***************** List countries with pending institutions ******************/ @@ -115,7 +116,7 @@ void Cty_SeeCtyWithPendingInss (void) MYSQL_ROW row; unsigned NumCtys; unsigned NumCty; - struct Country Cty; + struct Cty_Countr Cty; const char *BgColor; /***** Get countries with pending institutions *****/ @@ -290,7 +291,7 @@ void Cty_ListCountries2 (void) /* Number of users in courses of other countries */ HTM_TD_Begin ("class=\"DAT RM\""); - HTM_Unsigned (Usr_GetCachedNumUsrsInCrss (Hie_CTY,0, + HTM_Unsigned (Usr_GetCachedNumUsrsInCrss (Hie_Lvl_CTY,0, 1 << Rol_STD | 1 << Rol_NET | 1 << Rol_TCH)); // Any user @@ -413,7 +414,7 @@ static void Cty_PutHeadCountriesForSeeing (bool OrderSelectable) /************************ List one country for seeing ************************/ /*****************************************************************************/ -static void Cty_ListOneCountryForSeeing (struct Country *Cty,unsigned NumCty) +static void Cty_ListOneCountryForSeeing (struct Cty_Countr *Cty,unsigned NumCty) { const char *BgColor; @@ -462,7 +463,7 @@ static void Cty_ListOneCountryForSeeing (struct Country *Cty,unsigned NumCty) /***** Number of users in courses *****/ HTM_TD_Begin ("class=\"DAT RM %s\"",BgColor); - HTM_Unsigned (Usr_GetCachedNumUsrsInCrss (Hie_CTY,Cty->CtyCod, + HTM_Unsigned (Usr_GetCachedNumUsrsInCrss (Hie_Lvl_CTY,Cty->CtyCod, 1 << Rol_STD | 1 << Rol_NET | 1 << Rol_TCH)); // Any user @@ -510,7 +511,7 @@ static void Cty_PutIconToEditCountries (void) /********************* Draw country map and name with link *******************/ /*****************************************************************************/ -void Cty_DrawCountryMapAndNameWithLink (struct Country *Cty,Act_Action_t Action, +void Cty_DrawCountryMapAndNameWithLink (struct Cty_Countr *Cty,Act_Action_t Action, const char *ClassContainer, const char *ClassMap, const char *ClassLink) @@ -551,7 +552,7 @@ void Cty_DrawCountryMapAndNameWithLink (struct Country *Cty,Act_Action_t Action, /***************************** Draw country map ******************************/ /*****************************************************************************/ -void Cty_DrawCountryMap (struct Country *Cty,const char *Class) +void Cty_DrawCountryMap (struct Cty_Countr *Cty,const char *Class) { char *URL; @@ -576,7 +577,7 @@ void Cty_DrawCountryMap (struct Country *Cty,const char *Class) /*********************** Check if country map exists *************************/ /*****************************************************************************/ -bool Cty_CheckIfCountryPhotoExists (struct Country *Cty) +bool Cty_CheckIfCountryPhotoExists (struct Cty_Countr *Cty) { char PathMap[PATH_MAX + 1]; @@ -753,7 +754,7 @@ void Cty_GetBasicListOfCountries (void) MYSQL_ROW row; unsigned long NumRows = 0; unsigned NumCty; - struct Country *Cty; + struct Cty_Countr *Cty; Lan_Language_t Lan; /***** Get countries from database *****/ @@ -767,8 +768,8 @@ void Cty_GetBasicListOfCountries (void) Gbl.Hierarchy.Ctys.Num = (unsigned) NumRows; /***** Create list with countries *****/ - if ((Gbl.Hierarchy.Ctys.Lst = (struct Country *) - calloc (NumRows,sizeof (struct Country))) == NULL) + if ((Gbl.Hierarchy.Ctys.Lst = (struct Cty_Countr *) + calloc (NumRows,sizeof (struct Cty_Countr))) == NULL) Lay_NotEnoughMemoryExit (); /***** Get the countries *****/ @@ -837,7 +838,7 @@ void Cty_GetFullListOfCountries (void) MYSQL_ROW row; unsigned long NumRows = 0; unsigned NumCty; - struct Country *Cty; + struct Cty_Countr *Cty; Lan_Language_t Lan; /***** Get countries from database *****/ @@ -901,8 +902,8 @@ void Cty_GetFullListOfCountries (void) Gbl.Hierarchy.Ctys.Num = (unsigned) NumRows; /***** Create list with countries *****/ - if ((Gbl.Hierarchy.Ctys.Lst = (struct Country *) - calloc (NumRows,sizeof (struct Country))) == NULL) + if ((Gbl.Hierarchy.Ctys.Lst = (struct Cty_Countr *) + calloc (NumRows,sizeof (struct Cty_Countr))) == NULL) Lay_NotEnoughMemoryExit (); /***** Get the countries *****/ @@ -1037,7 +1038,7 @@ void Cty_WriteCountryName (long CtyCod,const char *ClassLink) /***************** Get basic data of country given its code ******************/ /*****************************************************************************/ -bool Cty_GetDataOfCountryByCod (struct Country *Cty) +bool Cty_GetDataOfCountryByCod (struct Cty_Countr *Cty) { extern const char *Txt_Another_country; extern const char *Lan_STR_LANG_ID[1 + Lan_NUM_LANGUAGES]; @@ -1194,7 +1195,7 @@ static void Cty_ListCountriesForEdition (void) { extern const char *Txt_STR_LANG_NAME[1 + Lan_NUM_LANGUAGES]; unsigned NumCty; - struct Country *Cty; + struct Cty_Countr *Cty; unsigned NumInss; unsigned NumUsrsCty; Lan_Language_t Lan; @@ -1220,7 +1221,7 @@ static void Cty_ListCountriesForEdition (void) NumUsrsCty) // Country has users // Deletion forbidden Ico_PutIconRemovalNotAllowed (); - else if (Usr_GetNumUsrsInCrss (Hie_CTY,Cty->CtyCod, + else if (Usr_GetNumUsrsInCrss (Hie_Lvl_CTY,Cty->CtyCod, 1 << Rol_STD | 1 << Rol_NET | 1 << Rol_TCH)) // Country has users @@ -1361,7 +1362,7 @@ void Cty_RemoveCountry (void) else if (Usr_GetNumUsrsWhoClaimToBelongToCty (Cty_EditingCty)) // Country has users ==> don't remove Ale_CreateAlert (Ale_WARNING,NULL, Txt_You_can_not_remove_a_country_with_institutions_or_users); - else if (Usr_GetNumUsrsInCrss (Hie_CTY,Cty_EditingCty->CtyCod, + else if (Usr_GetNumUsrsInCrss (Hie_Lvl_CTY,Cty_EditingCty->CtyCod, 1 << Rol_STD | 1 << Rol_NET | 1 << Rol_TCH)) // Country has users @@ -1370,7 +1371,7 @@ void Cty_RemoveCountry (void) else // Country has no users ==> remove it { /***** Remove surveys of the country *****/ - Svy_RemoveSurveys (Hie_CTY,Cty_EditingCty->CtyCod); + Svy_RemoveSurveys (Hie_Lvl_CTY,Cty_EditingCty->CtyCod); /***** Remove country *****/ DB_QueryDELETE ("can not remove a country", @@ -1922,12 +1923,12 @@ unsigned Cty_GetCachedNumCtysInSys (void) unsigned NumCtys; /***** Get number of countries from cache *****/ - if (!FigCch_GetFigureFromCache (FigCch_NUM_CTYS,Hie_SYS,-1L, + if (!FigCch_GetFigureFromCache (FigCch_NUM_CTYS,Hie_Lvl_SYS,-1L, FigCch_UNSIGNED,&NumCtys)) { /***** Get current number of countries from database and update cache *****/ NumCtys = (unsigned) DB_GetNumRowsTable ("countries"); - FigCch_UpdateFigureIntoCache (FigCch_NUM_CTYS,Hie_SYS,-1L, + FigCch_UpdateFigureIntoCache (FigCch_NUM_CTYS,Hie_Lvl_SYS,-1L, FigCch_UNSIGNED,&NumCtys); } @@ -1943,7 +1944,7 @@ unsigned Cty_GetCachedNumCtysWithInss (void) unsigned NumCtysWithInss; /***** Get number of countries with institutions from cache *****/ - if (!FigCch_GetFigureFromCache (FigCch_NUM_CTYS_WITH_INSS,Hie_SYS,-1L, + if (!FigCch_GetFigureFromCache (FigCch_NUM_CTYS_WITH_INSS,Hie_Lvl_SYS,-1L, FigCch_UNSIGNED,&NumCtysWithInss)) { /***** Get current number of countries with institutions from cache *****/ @@ -1953,7 +1954,7 @@ unsigned Cty_GetCachedNumCtysWithInss (void) "SELECT COUNT(DISTINCT countries.CtyCod)" " FROM countries,institutions" " WHERE countries.CtyCod=institutions.CtyCod"); - FigCch_UpdateFigureIntoCache (FigCch_NUM_CTYS_WITH_INSS,Hie_SYS,-1L, + FigCch_UpdateFigureIntoCache (FigCch_NUM_CTYS_WITH_INSS,Hie_Lvl_SYS,-1L, FigCch_UNSIGNED,&NumCtysWithInss); } @@ -1969,7 +1970,7 @@ unsigned Cty_GetCachedNumCtysWithCtrs (void) unsigned NumCtysWithCtrs; /***** Get number of countries with centres from cache *****/ - if (!FigCch_GetFigureFromCache (FigCch_NUM_CTYS_WITH_CTRS,Hie_SYS,-1L, + if (!FigCch_GetFigureFromCache (FigCch_NUM_CTYS_WITH_CTRS,Hie_Lvl_SYS,-1L, FigCch_UNSIGNED,&NumCtysWithCtrs)) { /***** Get current number of countries with centres from database and update cache *****/ @@ -1979,7 +1980,7 @@ unsigned Cty_GetCachedNumCtysWithCtrs (void) " FROM countries,institutions,centres" " WHERE countries.CtyCod=institutions.CtyCod" " AND institutions.InsCod=centres.InsCod"); - FigCch_UpdateFigureIntoCache (FigCch_NUM_CTYS_WITH_CTRS,Hie_SYS,-1L, + FigCch_UpdateFigureIntoCache (FigCch_NUM_CTYS_WITH_CTRS,Hie_Lvl_SYS,-1L, FigCch_UNSIGNED,&NumCtysWithCtrs); } @@ -1994,7 +1995,7 @@ unsigned Cty_GetCachedNumCtysWithDegs (void) { unsigned NumCtysWithDegs; - if (!FigCch_GetFigureFromCache (FigCch_NUM_CTYS_WITH_DEGS,Hie_SYS,-1L, + if (!FigCch_GetFigureFromCache (FigCch_NUM_CTYS_WITH_DEGS,Hie_Lvl_SYS,-1L, FigCch_UNSIGNED,&NumCtysWithDegs)) { NumCtysWithDegs = (unsigned) @@ -2004,7 +2005,7 @@ unsigned Cty_GetCachedNumCtysWithDegs (void) " WHERE countries.CtyCod=institutions.CtyCod" " AND institutions.InsCod=centres.InsCod" " AND centres.CtrCod=degrees.CtrCod"); - FigCch_UpdateFigureIntoCache (FigCch_NUM_CTYS_WITH_DEGS,Hie_SYS,-1L, + FigCch_UpdateFigureIntoCache (FigCch_NUM_CTYS_WITH_DEGS,Hie_Lvl_SYS,-1L, FigCch_UNSIGNED,&NumCtysWithDegs); } @@ -2020,7 +2021,7 @@ unsigned Cty_GetCachedNumCtysWithCrss (void) unsigned NumCtysWithCrss; /***** Get number of countries with courses from cache *****/ - if (!FigCch_GetFigureFromCache (FigCch_NUM_CTYS_WITH_CRSS,Hie_SYS,-1L, + if (!FigCch_GetFigureFromCache (FigCch_NUM_CTYS_WITH_CRSS,Hie_Lvl_SYS,-1L, FigCch_UNSIGNED,&NumCtysWithCrss)) { /***** Get current number of countries with courses from database and update cache *****/ @@ -2032,7 +2033,7 @@ unsigned Cty_GetCachedNumCtysWithCrss (void) " AND institutions.InsCod=centres.InsCod" " AND centres.CtrCod=degrees.CtrCod" " AND degrees.DegCod=courses.DegCod"); - FigCch_UpdateFigureIntoCache (FigCch_NUM_CTYS_WITH_CRSS,Hie_SYS,-1L, + FigCch_UpdateFigureIntoCache (FigCch_NUM_CTYS_WITH_CRSS,Hie_Lvl_SYS,-1L, FigCch_UNSIGNED,&NumCtysWithCrss); } @@ -2044,7 +2045,7 @@ unsigned Cty_GetCachedNumCtysWithCrss (void) /*****************************************************************************/ unsigned Cty_GetCachedNumCtysWithUsrs (Rol_Role_t Role,const char *SubQuery, - Hie_Level_t Scope,long Cod) + Hie_Lvl_Level_t Scope,long Cod) { static const FigCch_FigureCached_t FigureCtys[Rol_NUM_ROLES] = { @@ -2087,7 +2088,7 @@ void Cty_ListCtysFound (MYSQL_RES **mysql_res,unsigned NumCtys) extern const char *Txt_countries; MYSQL_ROW row; unsigned NumCty; - struct Country Cty; + struct Cty_Countr Cty; /***** Query database *****/ if (NumCtys) @@ -2143,7 +2144,7 @@ static void Cty_EditingCountryConstructor (void) Lay_ShowErrorAndExit ("Error initializing country."); /***** Allocate memory for country *****/ - if ((Cty_EditingCty = (struct Country *) malloc (sizeof (struct Country))) == NULL) + if ((Cty_EditingCty = (struct Cty_Countr *) malloc (sizeof (struct Cty_Countr))) == NULL) Lay_ShowErrorAndExit ("Error allocating memory for country."); /***** Reset country *****/ @@ -2173,7 +2174,7 @@ static void Cty_EditingCountryDestructor (void) /************************ Form to go to country map **************************/ /*****************************************************************************/ -static void Cty_FormToGoToMap (struct Country *Cty) +static void Cty_FormToGoToMap (struct Cty_Countr *Cty) { extern const char *Txt_Map; diff --git a/swad_country.h b/swad_country.h index 231854b8..677e1941 100644 --- a/swad_country.h +++ b/swad_country.h @@ -31,7 +31,7 @@ #include // For boolean type #include "swad_action.h" -#include "swad_hierarchy.h" +#include "swad_hierarchy_level.h" #include "swad_institution.h" #include "swad_language.h" #include "swad_role_type.h" @@ -45,7 +45,7 @@ #define Cty_MAX_CHARS_NAME (48 - 1) // 47 #define Cty_MAX_BYTES_NAME ((Cty_MAX_CHARS_NAME + 1) * Str_MAX_BYTES_PER_CHAR - 1) // 767 -struct Country +struct Cty_Countr { long CtyCod; char Alpha2[2 + 1]; @@ -69,7 +69,7 @@ typedef enum struct ListCountries { unsigned Num; // Number of countries - struct Country *Lst; // List of countries + struct Cty_Countr *Lst; // List of countries Cty_Order_t SelectedOrder; // Order of countries }; @@ -85,12 +85,12 @@ void Cty_ListCountries2 (void); bool Cty_CheckIfICanEditCountries (void); -void Cty_DrawCountryMapAndNameWithLink (struct Country *Cty,Act_Action_t Action, +void Cty_DrawCountryMapAndNameWithLink (struct Cty_Countr *Cty,Act_Action_t Action, const char *ClassContainer, const char *ClassMap, const char *ClassLink); -void Cty_DrawCountryMap (struct Country *Cty,const char *Class); -bool Cty_CheckIfCountryPhotoExists (struct Country *Cty); +void Cty_DrawCountryMap (struct Cty_Countr *Cty,const char *Class); +bool Cty_CheckIfCountryPhotoExists (struct Cty_Countr *Cty); void Cty_WriteScriptGoogleGeochart (void); void Cty_PutHiddenParamCtyOrder (void); @@ -100,7 +100,7 @@ void Cty_GetFullListOfCountries (void); void Cty_FreeListCountries (void); void Cty_WriteSelectorOfCountry (void); void Cty_WriteCountryName (long CtyCod,const char *ClassLink); -bool Cty_GetDataOfCountryByCod (struct Country *Cty); +bool Cty_GetDataOfCountryByCod (struct Cty_Countr *Cty); void Cty_FlushCacheCountryName (void); void Cty_GetCountryName (long CtyCod,Lan_Language_t Language, char CtyName[Cty_MAX_BYTES_NAME + 1]); @@ -120,7 +120,7 @@ unsigned Cty_GetCachedNumCtysWithDegs (void); unsigned Cty_GetCachedNumCtysWithCrss (void); unsigned Cty_GetCachedNumCtysWithUsrs (Rol_Role_t Role,const char *SubQuery, - Hie_Level_t Scope,long Cod); + Hie_Lvl_Level_t Scope,long Cod); void Cty_ListCtysFound (MYSQL_RES **mysql_res,unsigned NumCtys); diff --git a/swad_country_config.c b/swad_country_config.c index 2d35223a..bf3a8f17 100644 --- a/swad_country_config.c +++ b/swad_country_config.c @@ -37,6 +37,7 @@ #include "swad_form.h" #include "swad_global.h" #include "swad_help.h" +#include "swad_hierarchy.h" #include "swad_hierarchy_config.h" #include "swad_HTML.h" @@ -170,10 +171,10 @@ static void CtyCfg_Configuration (bool PrintView) CtyCfg_NumCrss (); /***** Number of users in courses of this country *****/ - HieCfg_NumUsrsInCrss (Hie_CTY,Gbl.Hierarchy.Cty.CtyCod,Rol_TCH); - HieCfg_NumUsrsInCrss (Hie_CTY,Gbl.Hierarchy.Cty.CtyCod,Rol_NET); - HieCfg_NumUsrsInCrss (Hie_CTY,Gbl.Hierarchy.Cty.CtyCod,Rol_STD); - HieCfg_NumUsrsInCrss (Hie_CTY,Gbl.Hierarchy.Cty.CtyCod,Rol_UNK); + HieCfg_NumUsrsInCrss (Hie_Lvl_CTY,Gbl.Hierarchy.Cty.CtyCod,Rol_TCH); + HieCfg_NumUsrsInCrss (Hie_Lvl_CTY,Gbl.Hierarchy.Cty.CtyCod,Rol_NET); + HieCfg_NumUsrsInCrss (Hie_Lvl_CTY,Gbl.Hierarchy.Cty.CtyCod,Rol_STD); + HieCfg_NumUsrsInCrss (Hie_Lvl_CTY,Gbl.Hierarchy.Cty.CtyCod,Rol_UNK); } /***** End table *****/ @@ -274,8 +275,8 @@ static void CtyCfg_Map (void) unsigned Zoom; unsigned NumCtrs; unsigned NumCtr; - struct Ctr_Centre Ctr; struct Ins_Instit Ins; + struct Ctr_Centre Ctr; /***** Leaflet CSS *****/ Map_LeafletCSS (); diff --git a/swad_course.c b/swad_course.c index 32421df3..55353efa 100644 --- a/swad_course.c +++ b/swad_course.c @@ -43,6 +43,7 @@ #include "swad_game.h" #include "swad_global.h" #include "swad_help.h" +#include "swad_hierarchy.h" #include "swad_HTML.h" #include "swad_info.h" #include "swad_logo.h" @@ -103,8 +104,8 @@ static void Crs_CreateCourse (unsigned Status); static void Crs_GetDataOfCourseFromRow (struct Crs_Course *Crs,MYSQL_ROW row); static void Crs_GetShortNamesByCod (long CrsCod, - char CrsShortName[Hie_MAX_BYTES_SHRT_NAME + 1], - char DegShortName[Hie_MAX_BYTES_SHRT_NAME + 1]); + char CrsShortName[Cns_HIERARCHY_MAX_BYTES_SHRT_NAME + 1], + char DegShortName[Cns_HIERARCHY_MAX_BYTES_SHRT_NAME + 1]); static void Crs_EmptyCourseCompletely (long CrsCod); @@ -154,7 +155,7 @@ static void Crs_WriteListMyCoursesToSelectOne (void) extern const char *The_ClassFormLinkInBoxBold[The_NUM_THEMES]; extern const char *Txt_My_courses; extern const char *Txt_System; - struct Country Cty; + struct Cty_Countr Cty; struct Ins_Instit Ins; struct Ctr_Centre Ctr; struct Deg_Degree Deg; @@ -268,7 +269,7 @@ static void Crs_WriteListMyCoursesToSelectOne (void) Highlight ? ClassHighlight : ClassNormal, NULL); - Lgo_DrawLogo (Hie_INS,Ins.InsCod,Ins.ShrtName,16,NULL,true); + Lgo_DrawLogo (Hie_Lvl_INS,Ins.InsCod,Ins.ShrtName,16,NULL,true); HTM_TxtF (" %s",Ins.ShrtName); HTM_BUTTON_End (); Frm_EndForm (); @@ -290,7 +291,7 @@ static void Crs_WriteListMyCoursesToSelectOne (void) Lay_ShowErrorAndExit ("Centre not found."); /***** Write link to centre *****/ - Highlight = (Gbl.Hierarchy.Level == Hie_CTR && + Highlight = (Gbl.Hierarchy.Level == Hie_Lvl_CTR && Gbl.Hierarchy.Ctr.CtrCod == Ctr.CtrCod); HTM_LI_Begin ("class=\"%s\"",Highlight ? ClassHighlight : ClassNormal); @@ -302,7 +303,7 @@ static void Crs_WriteListMyCoursesToSelectOne (void) Highlight ? ClassHighlight : ClassNormal, NULL); - Lgo_DrawLogo (Hie_CTR,Ctr.CtrCod,Ctr.ShrtName,16,NULL,true); + Lgo_DrawLogo (Hie_Lvl_CTR,Ctr.CtrCod,Ctr.ShrtName,16,NULL,true); HTM_TxtF (" %s",Ctr.ShrtName); HTM_BUTTON_End (); Frm_EndForm (); @@ -324,7 +325,7 @@ static void Crs_WriteListMyCoursesToSelectOne (void) Lay_ShowErrorAndExit ("Degree not found."); /***** Write link to degree *****/ - Highlight = (Gbl.Hierarchy.Level == Hie_DEG && + Highlight = (Gbl.Hierarchy.Level == Hie_Lvl_DEG && Gbl.Hierarchy.Deg.DegCod == Deg.DegCod); HTM_LI_Begin ("class=\"%s\"",Highlight ? ClassHighlight : ClassNormal); @@ -336,7 +337,7 @@ static void Crs_WriteListMyCoursesToSelectOne (void) Highlight ? ClassHighlight : ClassNormal, NULL); - Lgo_DrawLogo (Hie_DEG,Deg.DegCod,Deg.ShrtName,16,NULL,true); + Lgo_DrawLogo (Hie_Lvl_DEG,Deg.DegCod,Deg.ShrtName,16,NULL,true); HTM_TxtF (" %s",Deg.ShrtName); HTM_BUTTON_End (); Frm_EndForm (); @@ -358,7 +359,7 @@ static void Crs_WriteListMyCoursesToSelectOne (void) Lay_ShowErrorAndExit ("Course not found."); /***** Write link to course *****/ - Highlight = (Gbl.Hierarchy.Level == Hie_CRS && + Highlight = (Gbl.Hierarchy.Level == Hie_Lvl_CRS && Gbl.Hierarchy.Crs.CrsCod == Crs.CrsCod); HTM_LI_Begin ("class=\"%s\"",Highlight ? ClassHighlight : ClassNormal); @@ -415,12 +416,12 @@ unsigned Crs_GetCachedNumCrssInSys (void) unsigned NumCrss; /***** Get number of courses from cache *****/ - if (!FigCch_GetFigureFromCache (FigCch_NUM_CRSS,Hie_SYS,-1L, + if (!FigCch_GetFigureFromCache (FigCch_NUM_CRSS,Hie_Lvl_SYS,-1L, FigCch_UNSIGNED,&NumCrss)) { /***** Get current number of courses from database and update cache *****/ NumCrss = (unsigned) DB_GetNumRowsTable ("courses"); - FigCch_UpdateFigureIntoCache (FigCch_NUM_CRSS,Hie_SYS,-1L, + FigCch_UpdateFigureIntoCache (FigCch_NUM_CRSS,Hie_Lvl_SYS,-1L, FigCch_UNSIGNED,&NumCrss); } @@ -458,7 +459,7 @@ unsigned Crs_GetNumCrssInCty (long CtyCod) " AND centres.CtrCod=degrees.CtrCod" " AND degrees.DegCod=courses.DegCod", CtyCod); - FigCch_UpdateFigureIntoCache (FigCch_NUM_CRSS,Hie_CTY,Gbl.Cache.NumCrssInCty.CtyCod, + FigCch_UpdateFigureIntoCache (FigCch_NUM_CRSS,Hie_Lvl_CTY,Gbl.Cache.NumCrssInCty.CtyCod, FigCch_UNSIGNED,&Gbl.Cache.NumCrssInCty.NumCrss); return Gbl.Cache.NumCrssInCty.NumCrss; } @@ -468,7 +469,7 @@ unsigned Crs_GetCachedNumCrssInCty (long CtyCod) unsigned NumCrss; /***** Get number of courses from cache *****/ - if (!FigCch_GetFigureFromCache (FigCch_NUM_CRSS,Hie_CTY,CtyCod, + if (!FigCch_GetFigureFromCache (FigCch_NUM_CRSS,Hie_Lvl_CTY,CtyCod, FigCch_UNSIGNED,&NumCrss)) /***** Get current number of courses from database and update cache *****/ NumCrss = Crs_GetNumCrssInCty (CtyCod); @@ -506,7 +507,7 @@ unsigned Crs_GetNumCrssInIns (long InsCod) " AND centres.CtrCod=degrees.CtrCod" " AND degrees.DegCod=courses.DegCod", InsCod); - FigCch_UpdateFigureIntoCache (FigCch_NUM_CRSS,Hie_INS,Gbl.Cache.NumCrssInIns.InsCod, + FigCch_UpdateFigureIntoCache (FigCch_NUM_CRSS,Hie_Lvl_INS,Gbl.Cache.NumCrssInIns.InsCod, FigCch_UNSIGNED,&Gbl.Cache.NumCrssInIns.NumCrss); return Gbl.Cache.NumCrssInIns.NumCrss; } @@ -516,7 +517,7 @@ unsigned Crs_GetCachedNumCrssInIns (long InsCod) unsigned NumCrss; /***** Get number of courses from cache *****/ - if (!FigCch_GetFigureFromCache (FigCch_NUM_CRSS,Hie_INS,InsCod, + if (!FigCch_GetFigureFromCache (FigCch_NUM_CRSS,Hie_Lvl_INS,InsCod, FigCch_UNSIGNED,&NumCrss)) /***** Get current number of courses from database and update cache *****/ NumCrss = Crs_GetNumCrssInIns (InsCod); @@ -560,12 +561,12 @@ unsigned Crs_GetCachedNumCrssInCtr (long CtrCod) unsigned NumCrss; /***** Get number of courses from cache *****/ - if (!FigCch_GetFigureFromCache (FigCch_NUM_CRSS,Hie_CTR,CtrCod, + if (!FigCch_GetFigureFromCache (FigCch_NUM_CRSS,Hie_Lvl_CTR,CtrCod, FigCch_UNSIGNED,&NumCrss)) { /***** Get current number of courses from database and update cache *****/ NumCrss = Crs_GetNumCrssInCtr (CtrCod); - FigCch_UpdateFigureIntoCache (FigCch_NUM_CRSS,Hie_CTR,CtrCod, + FigCch_UpdateFigureIntoCache (FigCch_NUM_CRSS,Hie_Lvl_CTR,CtrCod, FigCch_UNSIGNED,&NumCrss); } @@ -599,7 +600,7 @@ unsigned Crs_GetNumCrssInDeg (long DegCod) "SELECT COUNT(*) FROM courses" " WHERE DegCod=%ld", DegCod); - FigCch_UpdateFigureIntoCache (FigCch_NUM_CRSS,Hie_DEG,Gbl.Cache.NumCrssInDeg.DegCod, + FigCch_UpdateFigureIntoCache (FigCch_NUM_CRSS,Hie_Lvl_DEG,Gbl.Cache.NumCrssInDeg.DegCod, FigCch_UNSIGNED,&Gbl.Cache.NumCrssInDeg.NumCrss); return Gbl.Cache.NumCrssInDeg.NumCrss; } @@ -609,7 +610,7 @@ unsigned Crs_GetCachedNumCrssInDeg (long DegCod) unsigned NumCrss; /***** Get number of courses from cache *****/ - if (!FigCch_GetFigureFromCache (FigCch_NUM_CRSS,Hie_DEG,DegCod, + if (!FigCch_GetFigureFromCache (FigCch_NUM_CRSS,Hie_Lvl_DEG,DegCod, FigCch_UNSIGNED,&NumCrss)) /***** Get current number of courses from database and update cache *****/ NumCrss = Crs_GetNumCrssInDeg (DegCod); @@ -622,7 +623,7 @@ unsigned Crs_GetCachedNumCrssInDeg (long DegCod) /*****************************************************************************/ unsigned Crs_GetCachedNumCrssWithUsrs (Rol_Role_t Role,const char *SubQuery, - Hie_Level_t Scope,long Cod) + Hie_Lvl_Level_t Scope,long Cod) { static const FigCch_FigureCached_t FigureCrss[Rol_NUM_ROLES] = { @@ -703,7 +704,7 @@ void Crs_WriteSelectorOfCourse (void) /* Write option */ HTM_OPTION (HTM_Type_LONG,&CrsCod, - Gbl.Hierarchy.Level == Hie_CRS && // Course selected + Gbl.Hierarchy.Level == Hie_Lvl_CRS && // Course selected CrsCod == Gbl.Hierarchy.Crs.CrsCod,false, "%s",row[1]); } @@ -826,8 +827,8 @@ void Crs_WriteSelectorMyCoursesInBreadcrumb (void) long CrsCod; long DegCod; long LastDegCod; - char CrsShortName[Hie_MAX_BYTES_SHRT_NAME + 1]; - char DegShortName[Hie_MAX_BYTES_SHRT_NAME + 1]; + char CrsShortName[Cns_HIERARCHY_MAX_BYTES_SHRT_NAME + 1]; + char DegShortName[Cns_HIERARCHY_MAX_BYTES_SHRT_NAME + 1]; /***** Fill the list with the courses I belong to, if not filled *****/ if (Gbl.Usrs.Me.Logged) @@ -877,7 +878,7 @@ void Crs_WriteSelectorMyCoursesInBreadcrumb (void) /***** Write an option with the current course when I don't belong to it *****/ - if (Gbl.Hierarchy.Level == Hie_CRS && // Course selected + if (Gbl.Hierarchy.Level == Hie_Lvl_CRS && // Course selected !Gbl.Usrs.Me.IBelongToCurrentCrs) // I do not belong to it HTM_OPTION (HTM_Type_LONG,&Gbl.Hierarchy.Crs.CrsCod,true,true, "%s",Gbl.Hierarchy.Crs.ShrtName); @@ -1020,9 +1021,9 @@ static bool Crs_ListCoursesOfAYearForSeeing (unsigned Year) HTM_TR_Begin (NULL); /* Get number of users */ - NumUsrs[Rol_STD] = Usr_GetCachedNumUsrsInCrss (Hie_CRS,Crs->CrsCod,1 << Rol_STD); - NumUsrs[Rol_NET] = Usr_GetCachedNumUsrsInCrss (Hie_CRS,Crs->CrsCod,1 << Rol_NET); - NumUsrs[Rol_TCH] = Usr_GetCachedNumUsrsInCrss (Hie_CRS,Crs->CrsCod,1 << Rol_TCH); + NumUsrs[Rol_STD] = Usr_GetCachedNumUsrsInCrss (Hie_Lvl_CRS,Crs->CrsCod,1 << Rol_STD); + NumUsrs[Rol_NET] = Usr_GetCachedNumUsrsInCrss (Hie_Lvl_CRS,Crs->CrsCod,1 << Rol_NET); + NumUsrs[Rol_TCH] = Usr_GetCachedNumUsrsInCrss (Hie_Lvl_CRS,Crs->CrsCod,1 << Rol_TCH); NumUsrs[Rol_UNK] = NumUsrs[Rol_STD] + NumUsrs[Rol_NET] + NumUsrs[Rol_TCH]; @@ -1218,9 +1219,9 @@ static void Crs_ListCoursesOfAYearForEdition (unsigned Year) ICanEdit = Crs_CheckIfICanEdit (Crs); /* Get number of users */ - NumUsrs[Rol_STD] = Usr_GetNumUsrsInCrss (Hie_CRS,Crs->CrsCod,1 << Rol_STD); - NumUsrs[Rol_NET] = Usr_GetNumUsrsInCrss (Hie_CRS,Crs->CrsCod,1 << Rol_NET); - NumUsrs[Rol_TCH] = Usr_GetNumUsrsInCrss (Hie_CRS,Crs->CrsCod,1 << Rol_TCH); + NumUsrs[Rol_STD] = Usr_GetNumUsrsInCrss (Hie_Lvl_CRS,Crs->CrsCod,1 << Rol_STD); + NumUsrs[Rol_NET] = Usr_GetNumUsrsInCrss (Hie_Lvl_CRS,Crs->CrsCod,1 << Rol_NET); + NumUsrs[Rol_TCH] = Usr_GetNumUsrsInCrss (Hie_Lvl_CRS,Crs->CrsCod,1 << Rol_TCH); NumUsrs[Rol_UNK] = NumUsrs[Rol_STD] + NumUsrs[Rol_NET] + NumUsrs[Rol_TCH]; @@ -1284,7 +1285,7 @@ static void Crs_ListCoursesOfAYearForEdition (unsigned Year) { Frm_StartForm (ActRenCrsSho); Crs_PutParamOtherCrsCod (&Crs->CrsCod); - HTM_INPUT_TEXT ("ShortName",Hie_MAX_CHARS_SHRT_NAME,Crs->ShrtName, + HTM_INPUT_TEXT ("ShortName",Cns_HIERARCHY_MAX_CHARS_SHRT_NAME,Crs->ShrtName, HTM_SUBMIT_ON_CHANGE, "class=\"INPUT_SHORT_NAME\""); Frm_EndForm (); @@ -1299,7 +1300,7 @@ static void Crs_ListCoursesOfAYearForEdition (unsigned Year) { Frm_StartForm (ActRenCrsFul); Crs_PutParamOtherCrsCod (&Crs->CrsCod); - HTM_INPUT_TEXT ("FullName",Hie_MAX_CHARS_FULL_NAME,Crs->FullName, + HTM_INPUT_TEXT ("FullName",Cns_HIERARCHY_MAX_CHARS_FULL_NAME,Crs->FullName, HTM_SUBMIT_ON_CHANGE, "class=\"INPUT_FULL_NAME\""); Frm_EndForm (); @@ -1473,14 +1474,14 @@ static void Crs_PutFormToCreateCourse (void) /***** Course short name *****/ HTM_TD_Begin ("class=\"LM\""); - HTM_INPUT_TEXT ("ShortName",Hie_MAX_CHARS_SHRT_NAME,Crs_EditingCrs->ShrtName, + HTM_INPUT_TEXT ("ShortName",Cns_HIERARCHY_MAX_CHARS_SHRT_NAME,Crs_EditingCrs->ShrtName, HTM_DONT_SUBMIT_ON_CHANGE, "class=\"INPUT_SHORT_NAME\" required=\"required\""); HTM_TD_End (); /***** Course full name *****/ HTM_TD_Begin ("class=\"LM\""); - HTM_INPUT_TEXT ("FullName",Hie_MAX_CHARS_FULL_NAME,Crs_EditingCrs->FullName, + HTM_INPUT_TEXT ("FullName",Cns_HIERARCHY_MAX_CHARS_FULL_NAME,Crs_EditingCrs->FullName, HTM_DONT_SUBMIT_ON_CHANGE, "class=\"INPUT_FULL_NAME\" required=\"required\""); HTM_TD_End (); @@ -1668,10 +1669,10 @@ static void Crs_GetParamsNewCourse (struct Crs_Course *Crs) Crs->Year = Deg_ConvStrToYear (YearStr); /* Get course short name */ - Par_GetParToText ("ShortName",Crs->ShrtName,Hie_MAX_BYTES_SHRT_NAME); + Par_GetParToText ("ShortName",Crs->ShrtName,Cns_HIERARCHY_MAX_BYTES_SHRT_NAME); /* Get course full name */ - Par_GetParToText ("FullName",Crs->FullName,Hie_MAX_BYTES_FULL_NAME); + Par_GetParToText ("FullName",Crs->FullName,Cns_HIERARCHY_MAX_BYTES_FULL_NAME); } /*****************************************************************************/ @@ -1718,7 +1719,7 @@ void Crs_RemoveCourse (void) if (Crs_CheckIfICanEdit (Crs_EditingCrs)) { /***** Check if this course has users *****/ - if (Usr_GetNumUsrsInCrss (Hie_CRS,Crs_EditingCrs->CrsCod, + if (Usr_GetNumUsrsInCrss (Hie_Lvl_CRS,Crs_EditingCrs->CrsCod, 1 << Rol_STD | 1 << Rol_NET | 1 << Rol_TCH)) // Course has users ==> don't remove @@ -1818,11 +1819,11 @@ static void Crs_GetDataOfCourseFromRow (struct Crs_Course *Crs,MYSQL_ROW row) /***** Get the short name of the course (row[6]) *****/ Str_Copy (Crs->ShrtName,row[6], - Hie_MAX_BYTES_SHRT_NAME); + Cns_HIERARCHY_MAX_BYTES_SHRT_NAME); /***** Get the full name of the course (row[7]) *****/ Str_Copy (Crs->FullName,row[7], - Hie_MAX_BYTES_FULL_NAME); + Cns_HIERARCHY_MAX_BYTES_FULL_NAME); } /*****************************************************************************/ @@ -1830,8 +1831,8 @@ static void Crs_GetDataOfCourseFromRow (struct Crs_Course *Crs,MYSQL_ROW row) /*****************************************************************************/ static void Crs_GetShortNamesByCod (long CrsCod, - char CrsShortName[Hie_MAX_BYTES_SHRT_NAME + 1], - char DegShortName[Hie_MAX_BYTES_SHRT_NAME + 1]) + char CrsShortName[Cns_HIERARCHY_MAX_BYTES_SHRT_NAME + 1], + char DegShortName[Cns_HIERARCHY_MAX_BYTES_SHRT_NAME + 1]) { MYSQL_RES *mysql_res; MYSQL_ROW row; @@ -1852,9 +1853,9 @@ static void Crs_GetShortNamesByCod (long CrsCod, row = mysql_fetch_row (mysql_res); Str_Copy (CrsShortName,row[0], - Hie_MAX_BYTES_SHRT_NAME); + Cns_HIERARCHY_MAX_BYTES_SHRT_NAME); Str_Copy (DegShortName,row[1], - Hie_MAX_BYTES_SHRT_NAME); + Cns_HIERARCHY_MAX_BYTES_SHRT_NAME); } /***** Free structure that stores the query result *****/ @@ -1976,10 +1977,10 @@ static void Crs_EmptyCourseCompletely (long CrsCod) CrsCod); /***** Remove all the threads and posts in forums of the course *****/ - For_RemoveForums (Hie_CRS,CrsCod); + For_RemoveForums (Hie_Lvl_CRS,CrsCod); /***** Remove all surveys in the course *****/ - Svy_RemoveSurveys (Hie_CRS,CrsCod); + Svy_RemoveSurveys (Hie_Lvl_CRS,CrsCod); /***** Remove all games in the course *****/ Gam_RemoveCrsGames (CrsCod); @@ -2213,20 +2214,20 @@ void Crs_RenameCourse (struct Crs_Course *Crs,Cns_ShrtOrFullName_t ShrtOrFullNam const char *FieldName = NULL; // Initialized to avoid warning unsigned MaxBytes = 0; // Initialized to avoid warning char *CurrentCrsName = NULL; // Initialized to avoid warning - char NewCrsName[Hie_MAX_BYTES_FULL_NAME + 1]; + char NewCrsName[Cns_HIERARCHY_MAX_BYTES_FULL_NAME + 1]; switch (ShrtOrFullName) { case Cns_SHRT_NAME: ParamName = "ShortName"; FieldName = "ShortName"; - MaxBytes = Hie_MAX_BYTES_SHRT_NAME; + MaxBytes = Cns_HIERARCHY_MAX_BYTES_SHRT_NAME; CurrentCrsName = Crs->ShrtName; break; case Cns_FULL_NAME: ParamName = "FullName"; FieldName = "FullName"; - MaxBytes = Hie_MAX_BYTES_FULL_NAME; + MaxBytes = Cns_HIERARCHY_MAX_BYTES_FULL_NAME; CurrentCrsName = Crs->FullName; break; } @@ -2755,9 +2756,9 @@ static void Crs_WriteRowCrsData (unsigned NumCrs,MYSQL_ROW row,bool WriteColumnA Lay_ShowErrorAndExit ("Wrong code of course."); /***** Get number of teachers and students in this course *****/ - NumStds = Usr_GetNumUsrsInCrss (Hie_CRS,CrsCod,1 << Rol_STD); - NumNETs = Usr_GetNumUsrsInCrss (Hie_CRS,CrsCod,1 << Rol_NET); - NumTchs = Usr_GetNumUsrsInCrss (Hie_CRS,CrsCod,1 << Rol_TCH); + NumStds = Usr_GetNumUsrsInCrss (Hie_Lvl_CRS,CrsCod,1 << Rol_STD); + NumNETs = Usr_GetNumUsrsInCrss (Hie_Lvl_CRS,CrsCod,1 << Rol_NET); + NumTchs = Usr_GetNumUsrsInCrss (Hie_Lvl_CRS,CrsCod,1 << Rol_TCH); NumUsrs = NumStds + NumNETs + NumTchs; if (NumUsrs) { @@ -2800,7 +2801,7 @@ static void Crs_WriteRowCrsData (unsigned NumCrs,MYSQL_ROW row,bool WriteColumnA Deg_PutParamDegCod (Deg.DegCod); HTM_BUTTON_SUBMIT_Begin (Hie_BuildGoToMsg (row[2]),ClassLink,NULL); Hie_FreeGoToMsg (); - Lgo_DrawLogo (Hie_DEG,Deg.DegCod,Deg.ShrtName,20,"CT",true); + Lgo_DrawLogo (Hie_Lvl_DEG,Deg.DegCod,Deg.ShrtName,20,"CT",true); HTM_TxtF (" %s (%s)",row[2],row[6]); HTM_BUTTON_End (); Frm_EndForm (); @@ -2848,7 +2849,7 @@ static void Crs_WriteRowCrsData (unsigned NumCrs,MYSQL_ROW row,bool WriteColumnA void Crs_UpdateCrsLast (void) { - if (Gbl.Hierarchy.Level == Hie_CRS && // Course selected + if (Gbl.Hierarchy.Level == Hie_Lvl_CRS && // Course selected Gbl.Usrs.Me.Role.Logged >= Rol_STD) /***** Update my last access to current course *****/ DB_QueryUPDATE ("can not update last access to current course", diff --git a/swad_course.h b/swad_course.h index 3f5fffde..d2038df1 100644 --- a/swad_course.h +++ b/swad_course.h @@ -30,7 +30,9 @@ #include // To access MySQL databases #include // For boolean type +#include "swad_constant.h" #include "swad_degree.h" +#include "swad_hierarchy_level.h" #include "swad_user.h" /*****************************************************************************/ @@ -83,8 +85,8 @@ struct Crs_Course unsigned Year; // Year: 0 (optatives), 1, 2, 3... unsigned Status; // Course status long RequesterUsrCod; // User code of the person who requested the creation of this course - char ShrtName[Hie_MAX_BYTES_SHRT_NAME + 1]; // Short name of course - char FullName[Hie_MAX_BYTES_FULL_NAME + 1]; // Full name of course + char ShrtName[Cns_HIERARCHY_MAX_BYTES_SHRT_NAME + 1]; // Short name of course + char FullName[Cns_HIERARCHY_MAX_BYTES_FULL_NAME + 1]; // Full name of course }; struct ListCourses @@ -118,7 +120,7 @@ unsigned Crs_GetNumCrssInDeg (long DegCod); unsigned Crs_GetCachedNumCrssInDeg (long DegCod); unsigned Crs_GetCachedNumCrssWithUsrs (Rol_Role_t Role,const char *SubQuery, - Hie_Level_t Scope,long Cod); + Hie_Lvl_Level_t Scope,long Cod); void Crs_WriteSelectorOfCourse (void); void Crs_ShowCrssOfCurrentDeg (void); diff --git a/swad_course_config.c b/swad_course_config.c index 4f64eb9b..d365175c 100644 --- a/swad_course_config.c +++ b/swad_course_config.c @@ -35,6 +35,7 @@ #include "swad_database.h" #include "swad_form.h" #include "swad_global.h" +#include "swad_hierarchy.h" #include "swad_hierarchy_config.h" #include "swad_HTML.h" #include "swad_indicator.h" @@ -158,10 +159,10 @@ void CrsCfg_Configuration (bool PrintView) else { /***** Number of users *****/ - HieCfg_NumUsrsInCrss (Hie_CRS,Gbl.Hierarchy.Crs.CrsCod,Rol_TCH); - HieCfg_NumUsrsInCrss (Hie_CRS,Gbl.Hierarchy.Crs.CrsCod,Rol_NET); - HieCfg_NumUsrsInCrss (Hie_CRS,Gbl.Hierarchy.Crs.CrsCod,Rol_STD); - HieCfg_NumUsrsInCrss (Hie_CRS,Gbl.Hierarchy.Crs.CrsCod,Rol_UNK); + HieCfg_NumUsrsInCrss (Hie_Lvl_CRS,Gbl.Hierarchy.Crs.CrsCod,Rol_TCH); + HieCfg_NumUsrsInCrss (Hie_Lvl_CRS,Gbl.Hierarchy.Crs.CrsCod,Rol_NET); + HieCfg_NumUsrsInCrss (Hie_Lvl_CRS,Gbl.Hierarchy.Crs.CrsCod,Rol_STD); + HieCfg_NumUsrsInCrss (Hie_Lvl_CRS,Gbl.Hierarchy.Crs.CrsCod,Rol_UNK); /***** Indicators *****/ CrsCfg_Indicators (); @@ -203,7 +204,7 @@ void CrsCfg_PrintConfiguration (void) static void CrsCfg_Title (bool PutLink) { HieCfg_Title (PutLink, - Hie_DEG, // Logo scope + Hie_Lvl_DEG, // Logo scope Gbl.Hierarchy.Deg.DegCod, // Logo code Gbl.Hierarchy.Deg.ShrtName, // Logo short name Gbl.Hierarchy.Deg.FullName, // Logo full name @@ -262,7 +263,7 @@ static void CrsCfg_Degree (bool PrintView,bool PutForm) "BT_LINK LT DAT",NULL); Hie_FreeGoToMsg (); } - Lgo_DrawLogo (Hie_DEG,Gbl.Hierarchy.Deg.DegCod,Gbl.Hierarchy.Deg.ShrtName, + Lgo_DrawLogo (Hie_Lvl_DEG,Gbl.Hierarchy.Deg.DegCod,Gbl.Hierarchy.Deg.ShrtName, 20,"LM",true); HTM_NBSP (); HTM_Txt (Gbl.Hierarchy.Deg.FullName); diff --git a/swad_database.c b/swad_database.c index b159383c..b7b89919 100644 --- a/swad_database.c +++ b/swad_database.c @@ -469,8 +469,8 @@ mysql> DESCRIBE centres; "Latitude DOUBLE PRECISION NOT NULL DEFAULT 0," "Longitude DOUBLE PRECISION NOT NULL DEFAULT 0," "Altitude DOUBLE PRECISION NOT NULL DEFAULT 0," - "ShortName VARCHAR(511) COLLATE latin1_spanish_ci NOT NULL," // Hie_MAX_BYTES_SHRT_NAME - "FullName VARCHAR(2047) COLLATE latin1_spanish_ci NOT NULL," // Hie_MAX_BYTES_FULL_NAME + "ShortName VARCHAR(511) COLLATE latin1_spanish_ci NOT NULL," // Cns_HIERARCHY_MAX_BYTES_SHRT_NAME + "FullName VARCHAR(2047) COLLATE latin1_spanish_ci NOT NULL," // Cns_HIERARCHY_MAX_BYTES_FULL_NAME "WWW VARCHAR(255) NOT NULL," // Cns_MAX_BYTES_WWW "PhotoAttribution TEXT NOT NULL," // Med_MAX_BYTES_ATTRIBUTION "UNIQUE INDEX(CtrCod)," @@ -648,8 +648,8 @@ mysql> DESCRIBE courses; "InsCrsCod CHAR(7) NOT NULL," "Status TINYINT NOT NULL DEFAULT 0," "RequesterUsrCod INT NOT NULL DEFAULT -1," - "ShortName VARCHAR(511) COLLATE latin1_spanish_ci NOT NULL," // Hie_MAX_BYTES_SHRT_NAME - "FullName VARCHAR(2047) COLLATE latin1_spanish_ci NOT NULL," // Hie_MAX_BYTES_FULL_NAME + "ShortName VARCHAR(511) COLLATE latin1_spanish_ci NOT NULL," // Cns_HIERARCHY_MAX_BYTES_SHRT_NAME + "FullName VARCHAR(2047) COLLATE latin1_spanish_ci NOT NULL," // Cns_HIERARCHY_MAX_BYTES_FULL_NAME "NumIndicators INT NOT NULL DEFAULT -1," "UNIQUE INDEX(CrsCod)," "INDEX(DegCod,Year)," @@ -968,8 +968,8 @@ mysql> DESCRIBE degrees; "DegTypCod INT NOT NULL," "Status TINYINT NOT NULL DEFAULT 0," "RequesterUsrCod INT NOT NULL DEFAULT -1," - "ShortName VARCHAR(511) COLLATE latin1_spanish_ci NOT NULL," // Hie_MAX_BYTES_SHRT_NAME - "FullName VARCHAR(2047) COLLATE latin1_spanish_ci NOT NULL," // Hie_MAX_BYTES_FULL_NAME + "ShortName VARCHAR(511) COLLATE latin1_spanish_ci NOT NULL," // Cns_HIERARCHY_MAX_BYTES_SHRT_NAME + "FullName VARCHAR(2047) COLLATE latin1_spanish_ci NOT NULL," // Cns_HIERARCHY_MAX_BYTES_FULL_NAME "WWW VARCHAR(255) NOT NULL," // Cns_MAX_BYTES_WWW "UNIQUE INDEX(DegCod)," "INDEX(CtrCod)," @@ -993,8 +993,8 @@ mysql> DESCRIBE departments; DB_CreateTable ("CREATE TABLE IF NOT EXISTS departments (" "DptCod INT NOT NULL AUTO_INCREMENT," "InsCod INT NOT NULL," - "ShortName VARCHAR(511) NOT NULL," // Hie_MAX_BYTES_SHRT_NAME - "FullName VARCHAR(2047) NOT NULL," // Hie_MAX_BYTES_FULL_NAME + "ShortName VARCHAR(511) NOT NULL," // Cns_HIERARCHY_MAX_BYTES_SHRT_NAME + "FullName VARCHAR(2047) NOT NULL," // Cns_HIERARCHY_MAX_BYTES_FULL_NAME "WWW VARCHAR(255) NOT NULL," // Cns_MAX_BYTES_WWW "UNIQUE INDEX(DptCod)," "INDEX(InsCod))"); @@ -1308,7 +1308,7 @@ mysql> DESCRIBE exam_announcements; "CrsCod INT NOT NULL DEFAULT -1," "Status TINYINT NOT NULL DEFAULT 0," "NumNotif INT NOT NULL DEFAULT 0," - "CrsFullName VARCHAR(2047) NOT NULL," // Hie_MAX_BYTES_FULL_NAME + "CrsFullName VARCHAR(2047) NOT NULL," // Cns_HIERARCHY_MAX_BYTES_FULL_NAME "Year TINYINT NOT NULL," "ExamSession VARCHAR(2047) NOT NULL," // ExaAnn_MAX_BYTES_SESSION "CallDate DATETIME NOT NULL," @@ -1935,8 +1935,8 @@ mysql> DESCRIBE institutions; "CtyCod INT NOT NULL," "Status TINYINT NOT NULL DEFAULT 0," "RequesterUsrCod INT NOT NULL DEFAULT -1," - "ShortName VARCHAR(511) COLLATE latin1_spanish_ci NOT NULL," // Hie_MAX_BYTES_SHRT_NAME - "FullName VARCHAR(2047) COLLATE latin1_spanish_ci NOT NULL," // Hie_MAX_BYTES_FULL_NAME + "ShortName VARCHAR(511) COLLATE latin1_spanish_ci NOT NULL," // Cns_HIERARCHY_MAX_BYTES_SHRT_NAME + "FullName VARCHAR(2047) COLLATE latin1_spanish_ci NOT NULL," // Cns_HIERARCHY_MAX_BYTES_FULL_NAME "WWW VARCHAR(255) NOT NULL," // Cns_MAX_BYTES_WWW "UNIQUE INDEX(InsCod)," "INDEX(CtyCod)," diff --git a/swad_degree.c b/swad_degree.c index 7ee63a4e..191fa077 100644 --- a/swad_degree.c +++ b/swad_degree.c @@ -38,6 +38,7 @@ #include "swad_form.h" #include "swad_forum.h" #include "swad_global.h" +#include "swad_hierarchy.h" #include "swad_HTML.h" #include "swad_logo.h" #include "swad_message.h" @@ -136,7 +137,7 @@ void Deg_SeeDegWithPendingCrss (void) " AND courses.DegCod=degrees.DegCod" " GROUP BY courses.DegCod ORDER BY degrees.ShortName", Gbl.Usrs.Me.UsrDat.UsrCod, - Sco_GetDBStrFromScope (Hie_DEG), + Sco_GetDBStrFromScope (Hie_Lvl_DEG), (unsigned) Crs_STATUS_BIT_PENDING); break; case Rol_SYS_ADM: @@ -229,7 +230,7 @@ void Deg_DrawDegreeLogoAndNameWithLink (struct Deg_Degree *Deg,Act_Action_t Acti Hie_FreeGoToMsg (); /***** Degree logo and name *****/ - Lgo_DrawLogo (Hie_DEG,Deg->DegCod,Deg->ShrtName,16,ClassLogo,true); + Lgo_DrawLogo (Hie_Lvl_DEG,Deg->DegCod,Deg->ShrtName,16,ClassLogo,true); HTM_TxtF (" %s",Deg->FullName); /***** End link *****/ @@ -364,7 +365,7 @@ static void Deg_ListDegreesForEdition (void) ICanEdit = Deg_CheckIfICanEditADegree (Deg); NumCrss = Crs_GetNumCrssInDeg (Deg->DegCod); - NumUsrsInCrssOfDeg = Usr_GetNumUsrsInCrss (Hie_DEG,Deg->DegCod, + NumUsrsInCrssOfDeg = Usr_GetNumUsrsInCrss (Hie_Lvl_DEG,Deg->DegCod, 1 << Rol_STD | 1 << Rol_NET | 1 << Rol_TCH); // Any user @@ -389,7 +390,7 @@ static void Deg_ListDegreesForEdition (void) /* Degree logo */ HTM_TD_Begin ("title=\"%s\" class=\"HIE_LOGO\"",Deg->FullName); - Lgo_DrawLogo (Hie_DEG,Deg->DegCod,Deg->ShrtName,20,NULL,true); + Lgo_DrawLogo (Hie_Lvl_DEG,Deg->DegCod,Deg->ShrtName,20,NULL,true); HTM_TD_End (); /* Degree short name */ @@ -398,7 +399,7 @@ static void Deg_ListDegreesForEdition (void) { Frm_StartForm (ActRenDegSho); Deg_PutParamOtherDegCod (&Deg->DegCod); - HTM_INPUT_TEXT ("ShortName",Hie_MAX_CHARS_SHRT_NAME,Deg->ShrtName, + HTM_INPUT_TEXT ("ShortName",Cns_HIERARCHY_MAX_CHARS_SHRT_NAME,Deg->ShrtName, HTM_SUBMIT_ON_CHANGE, "class=\"INPUT_SHORT_NAME\""); Frm_EndForm (); @@ -413,7 +414,7 @@ static void Deg_ListDegreesForEdition (void) { Frm_StartForm (ActRenDegFul); Deg_PutParamOtherDegCod (&Deg->DegCod); - HTM_INPUT_TEXT ("FullName",Hie_MAX_CHARS_FULL_NAME,Deg->FullName, + HTM_INPUT_TEXT ("FullName",Cns_HIERARCHY_MAX_CHARS_FULL_NAME,Deg->FullName, HTM_SUBMIT_ON_CHANGE, "class=\"INPUT_FULL_NAME\""); Frm_EndForm (); @@ -615,19 +616,19 @@ static void Deg_PutFormToCreateDegree (void) /***** Degree logo *****/ HTM_TD_Begin ("title=\"%s\" class=\"HIE_LOGO\"",Deg_EditingDeg->FullName); - Lgo_DrawLogo (Hie_DEG,-1L,"",20,NULL,true); + Lgo_DrawLogo (Hie_Lvl_DEG,-1L,"",20,NULL,true); HTM_TD_End (); /***** Degree short name *****/ HTM_TD_Begin ("class=\"LM\""); - HTM_INPUT_TEXT ("ShortName",Hie_MAX_CHARS_SHRT_NAME,Deg_EditingDeg->ShrtName, + HTM_INPUT_TEXT ("ShortName",Cns_HIERARCHY_MAX_CHARS_SHRT_NAME,Deg_EditingDeg->ShrtName, HTM_DONT_SUBMIT_ON_CHANGE, "class=\"INPUT_SHORT_NAME\" required=\"required\""); HTM_TD_End (); /***** Degree full name *****/ HTM_TD_Begin ("class=\"LM\""); - HTM_INPUT_TEXT ("FullName",Hie_MAX_CHARS_FULL_NAME,Deg_EditingDeg->FullName, + HTM_INPUT_TEXT ("FullName",Cns_HIERARCHY_MAX_CHARS_FULL_NAME,Deg_EditingDeg->FullName, HTM_DONT_SUBMIT_ON_CHANGE, "class=\"INPUT_FULL_NAME\" required=\"required\""); HTM_TD_End (); @@ -939,7 +940,7 @@ static void Deg_ListOneDegreeForSeeing (struct Deg_Degree *Deg,unsigned NumDeg) /***** Number of users in courses of this degree *****/ HTM_TD_Begin ("class=\"%s RM %s\"",TxtClassNormal,BgColor); - HTM_Unsigned (Usr_GetCachedNumUsrsInCrss (Hie_DEG,Deg->DegCod, + HTM_Unsigned (Usr_GetCachedNumUsrsInCrss (Hie_Lvl_DEG,Deg->DegCod, 1 << Rol_STD | 1 << Rol_NET | 1 << Rol_TCH)); // Any user @@ -983,7 +984,7 @@ static void Deg_EditDegreesInternal (void) Deg_GetListDegsInCurrentCtr (); /***** Get list of degree types *****/ - DT_GetListDegreeTypes (Hie_SYS,DT_ORDER_BY_DEGREE_TYPE); + DT_GetListDegreeTypes (Hie_Lvl_SYS,DT_ORDER_BY_DEGREE_TYPE); /***** Write menu to select country, institution and centre *****/ Hie_WriteMenuHierarchy (); @@ -1204,10 +1205,10 @@ static void Deg_ReceiveFormRequestOrCreateDeg (unsigned Status) Deg_EditingDeg->CtrCod = Gbl.Hierarchy.Ctr.CtrCod; /* Get degree short name */ - Par_GetParToText ("ShortName",Deg_EditingDeg->ShrtName,Hie_MAX_BYTES_SHRT_NAME); + Par_GetParToText ("ShortName",Deg_EditingDeg->ShrtName,Cns_HIERARCHY_MAX_BYTES_SHRT_NAME); /* Get degree full name */ - Par_GetParToText ("FullName",Deg_EditingDeg->FullName,Hie_MAX_BYTES_FULL_NAME); + Par_GetParToText ("FullName",Deg_EditingDeg->FullName,Cns_HIERARCHY_MAX_BYTES_FULL_NAME); /* Get degree type */ Deg_EditingDeg->DegTypCod = DT_GetAndCheckParamOtherDegTypCod (1); @@ -1388,11 +1389,11 @@ static void Deg_GetDataOfDegreeFromRow (struct Deg_Degree *Deg,MYSQL_ROW row) /***** Get degree short name (row[5]) *****/ Str_Copy (Deg->ShrtName,row[5], - Hie_MAX_BYTES_SHRT_NAME); + Cns_HIERARCHY_MAX_BYTES_SHRT_NAME); /***** Get degree full name (row[6]) *****/ Str_Copy (Deg->FullName,row[6], - Hie_MAX_BYTES_FULL_NAME); + Cns_HIERARCHY_MAX_BYTES_FULL_NAME); /***** Get WWW (row[7]) *****/ Str_Copy (Deg->WWW,row[7], @@ -1420,7 +1421,7 @@ void Deg_GetShortNameOfDegreeByCod (struct Deg_Degree *Deg) row = mysql_fetch_row (mysql_res); Str_Copy (Deg->ShrtName,row[0], - Hie_MAX_BYTES_SHRT_NAME); + Cns_HIERARCHY_MAX_BYTES_SHRT_NAME); } /***** Free structure that stores the query result *****/ @@ -1527,10 +1528,10 @@ void Deg_RemoveDegreeCompletely (long DegCod) DB_FreeMySQLResult (&mysql_res); /***** Remove all the threads and posts in forums of the degree *****/ - For_RemoveForums (Hie_DEG,DegCod); + For_RemoveForums (Hie_Lvl_DEG,DegCod); /***** Remove surveys of the degree *****/ - Svy_RemoveSurveys (Hie_DEG,DegCod); + Svy_RemoveSurveys (Hie_Lvl_DEG,DegCod); /***** Remove information related to files in degree *****/ Brw_RemoveDegFilesFromDB (DegCod); @@ -1546,7 +1547,7 @@ void Deg_RemoveDegreeCompletely (long DegCod) /***** Remove administrators of this degree *****/ DB_QueryDELETE ("can not remove administrators of a degree", "DELETE FROM admin WHERE Scope='%s' AND Cod=%ld", - Sco_GetDBStrFromScope (Hie_DEG),DegCod); + Sco_GetDBStrFromScope (Hie_Lvl_DEG),DegCod); /***** Remove the degree *****/ DB_QueryDELETE ("can not remove a degree", @@ -1597,20 +1598,20 @@ void Deg_RenameDegree (struct Deg_Degree *Deg,Cns_ShrtOrFullName_t ShrtOrFullNam const char *FieldName = NULL; // Initialized to avoid warning unsigned MaxBytes = 0; // Initialized to avoid warning char *CurrentDegName = NULL; // Initialized to avoid warning - char NewDegName[Hie_MAX_BYTES_FULL_NAME + 1]; + char NewDegName[Cns_HIERARCHY_MAX_BYTES_FULL_NAME + 1]; switch (ShrtOrFullName) { case Cns_SHRT_NAME: ParamName = "ShortName"; FieldName = "ShortName"; - MaxBytes = Hie_MAX_BYTES_SHRT_NAME; + MaxBytes = Cns_HIERARCHY_MAX_BYTES_SHRT_NAME; CurrentDegName = Deg->ShrtName; break; case Cns_FULL_NAME: ParamName = "FullName"; FieldName = "FullName"; - MaxBytes = Hie_MAX_BYTES_FULL_NAME; + MaxBytes = Cns_HIERARCHY_MAX_BYTES_FULL_NAME; CurrentDegName = Deg->FullName; break; } @@ -1867,7 +1868,7 @@ static void Deg_PutParamGoToDeg (void *DegCod) void Deg_RequestLogo (void) { - Lgo_RequestLogo (Hie_DEG); + Lgo_RequestLogo (Hie_Lvl_DEG); } /*****************************************************************************/ @@ -1876,7 +1877,7 @@ void Deg_RequestLogo (void) void Deg_ReceiveLogo (void) { - Lgo_ReceiveLogo (Hie_DEG); + Lgo_ReceiveLogo (Hie_Lvl_DEG); } /*****************************************************************************/ @@ -1885,7 +1886,7 @@ void Deg_ReceiveLogo (void) void Deg_RemoveLogo (void) { - Lgo_RemoveLogo (Hie_DEG); + Lgo_RemoveLogo (Hie_Lvl_DEG); } /*****************************************************************************/ @@ -1897,12 +1898,12 @@ unsigned Deg_GetCachedNumDegsInSys (void) unsigned NumDegs; /***** Get number of degrees from cache *****/ - if (!FigCch_GetFigureFromCache (FigCch_NUM_DEGS,Hie_SYS,-1L, + if (!FigCch_GetFigureFromCache (FigCch_NUM_DEGS,Hie_Lvl_SYS,-1L, FigCch_UNSIGNED,&NumDegs)) { /***** Get current number of degrees from database and update cache *****/ NumDegs = (unsigned) DB_GetNumRowsTable ("degrees"); - FigCch_UpdateFigureIntoCache (FigCch_NUM_DEGS,Hie_SYS,-1L, + FigCch_UpdateFigureIntoCache (FigCch_NUM_DEGS,Hie_Lvl_SYS,-1L, FigCch_UNSIGNED,&NumDegs); } @@ -1938,7 +1939,7 @@ unsigned Deg_GetNumDegsInCty (long CtyCod) " AND institutions.InsCod=centres.InsCod" " AND centres.CtrCod=degrees.CtrCod", CtyCod); - FigCch_UpdateFigureIntoCache (FigCch_NUM_DEGS,Hie_CTY,Gbl.Cache.NumDegsInCty.CtyCod, + FigCch_UpdateFigureIntoCache (FigCch_NUM_DEGS,Hie_Lvl_CTY,Gbl.Cache.NumDegsInCty.CtyCod, FigCch_UNSIGNED,&Gbl.Cache.NumDegsInCty.NumDegs); return Gbl.Cache.NumDegsInCty.NumDegs; } @@ -1948,7 +1949,7 @@ unsigned Deg_GetCachedNumDegsInCty (long CtyCod) unsigned NumDegs; /***** Get number of degrees from cache *****/ - if (!FigCch_GetFigureFromCache (FigCch_NUM_DEGS,Hie_CTY,CtyCod, + if (!FigCch_GetFigureFromCache (FigCch_NUM_DEGS,Hie_Lvl_CTY,CtyCod, FigCch_UNSIGNED,&NumDegs)) /***** Get current number of degrees from database and update cache *****/ NumDegs = Deg_GetNumDegsInCty (CtyCod); @@ -1985,7 +1986,7 @@ unsigned Deg_GetNumDegsInIns (long InsCod) " WHERE centres.InsCod=%ld" " AND centres.CtrCod=degrees.CtrCod", InsCod); - FigCch_UpdateFigureIntoCache (FigCch_NUM_DEGS,Hie_INS,Gbl.Cache.NumDegsInIns.InsCod, + FigCch_UpdateFigureIntoCache (FigCch_NUM_DEGS,Hie_Lvl_INS,Gbl.Cache.NumDegsInIns.InsCod, FigCch_UNSIGNED,&Gbl.Cache.NumDegsInIns.NumDegs); return Gbl.Cache.NumDegsInIns.NumDegs; } @@ -1995,7 +1996,7 @@ unsigned Deg_GetCachedNumDegsInIns (long InsCod) unsigned NumDegs; /***** Get number of degrees from cache *****/ - if (!FigCch_GetFigureFromCache (FigCch_NUM_DEGS,Hie_INS,InsCod, + if (!FigCch_GetFigureFromCache (FigCch_NUM_DEGS,Hie_Lvl_INS,InsCod, FigCch_UNSIGNED,&NumDegs)) /***** Get current number of degrees from database and update cache *****/ NumDegs = Deg_GetNumDegsInIns (InsCod); @@ -2030,7 +2031,7 @@ unsigned Deg_GetNumDegsInCtr (long CtrCod) "SELECT COUNT(*) FROM degrees" " WHERE CtrCod=%ld", CtrCod); - FigCch_UpdateFigureIntoCache (FigCch_NUM_DEGS,Hie_CTR,Gbl.Cache.NumDegsInCtr.CtrCod, + FigCch_UpdateFigureIntoCache (FigCch_NUM_DEGS,Hie_Lvl_CTR,Gbl.Cache.NumDegsInCtr.CtrCod, FigCch_UNSIGNED,&Gbl.Cache.NumDegsInCtr.NumDegs); return Gbl.Cache.NumDegsInCtr.NumDegs; } @@ -2040,7 +2041,7 @@ unsigned Deg_GetCachedNumDegsInCtr (long CtrCod) unsigned NumDegs; /***** Get number of degrees from cache *****/ - if (!FigCch_GetFigureFromCache (FigCch_NUM_DEGS,Hie_CTR,CtrCod, + if (!FigCch_GetFigureFromCache (FigCch_NUM_DEGS,Hie_Lvl_CTR,CtrCod, FigCch_UNSIGNED,&NumDegs)) /***** Get current number of degrees from database and update cache *****/ NumDegs = Deg_GetNumDegsInCtr (CtrCod); @@ -2053,7 +2054,7 @@ unsigned Deg_GetCachedNumDegsInCtr (long CtrCod) /*****************************************************************************/ unsigned Deg_GetCachedNumDegsWithCrss (const char *SubQuery, - Hie_Level_t Scope,long Cod) + Hie_Lvl_Level_t Scope,long Cod) { unsigned NumDegsWithCrss; @@ -2082,7 +2083,7 @@ unsigned Deg_GetCachedNumDegsWithCrss (const char *SubQuery, /*****************************************************************************/ unsigned Deg_GetCachedNumDegsWithUsrs (Rol_Role_t Role,const char *SubQuery, - Hie_Level_t Scope,long Cod) + Hie_Lvl_Level_t Scope,long Cod) { static const FigCch_FigureCached_t FigureDegs[Rol_NUM_ROLES] = { diff --git a/swad_degree.h b/swad_degree.h index 56d663d5..dc12e821 100644 --- a/swad_degree.h +++ b/swad_degree.h @@ -31,7 +31,7 @@ #include "swad_action.h" #include "swad_constant.h" -#include "swad_hierarchy.h" +#include "swad_hierarchy_level.h" #include "swad_role_type.h" #include "swad_string.h" @@ -73,8 +73,8 @@ struct Deg_Degree long CtrCod; // Centre code Deg_Status_t Status; // Degree status long RequesterUsrCod; // User code of the person who requested the creation of this degree - char ShrtName[Hie_MAX_BYTES_SHRT_NAME + 1]; // Short name of degree - char FullName[Hie_MAX_BYTES_FULL_NAME + 1]; // Full name of degree + char ShrtName[Cns_HIERARCHY_MAX_BYTES_SHRT_NAME + 1]; // Short name of degree + char FullName[Cns_HIERARCHY_MAX_BYTES_FULL_NAME + 1]; // Full name of degree char WWW[Cns_MAX_BYTES_WWW + 1]; }; @@ -149,9 +149,9 @@ unsigned Deg_GetNumDegsInCtr (long CtrCod); unsigned Deg_GetCachedNumDegsInCtr (long CtrCod); unsigned Deg_GetCachedNumDegsWithCrss (const char *SubQuery, - Hie_Level_t Scope,long Cod); + Hie_Lvl_Level_t Scope,long Cod); unsigned Deg_GetCachedNumDegsWithUsrs (Rol_Role_t Role,const char *SubQuery, - Hie_Level_t Scope,long Cod); + Hie_Lvl_Level_t Scope,long Cod); void Deg_ListDegsFound (MYSQL_RES **mysql_res,unsigned NumCrss); diff --git a/swad_degree_config.c b/swad_degree_config.c index 3dbd5e89..ec1fce69 100644 --- a/swad_degree_config.c +++ b/swad_degree_config.c @@ -32,6 +32,7 @@ #include "swad_form.h" #include "swad_global.h" #include "swad_help.h" +#include "swad_hierarchy.h" #include "swad_hierarchy_config.h" #include "swad_HTML.h" #include "swad_logo.h" @@ -155,10 +156,10 @@ static void DegCfg_Configuration (bool PrintView) DegCfg_NumCrss (); /***** Number of users *****/ - HieCfg_NumUsrsInCrss (Hie_DEG,Gbl.Hierarchy.Deg.DegCod,Rol_TCH); - HieCfg_NumUsrsInCrss (Hie_DEG,Gbl.Hierarchy.Deg.DegCod,Rol_NET); - HieCfg_NumUsrsInCrss (Hie_DEG,Gbl.Hierarchy.Deg.DegCod,Rol_STD); - HieCfg_NumUsrsInCrss (Hie_DEG,Gbl.Hierarchy.Deg.DegCod,Rol_UNK); + HieCfg_NumUsrsInCrss (Hie_Lvl_DEG,Gbl.Hierarchy.Deg.DegCod,Rol_TCH); + HieCfg_NumUsrsInCrss (Hie_Lvl_DEG,Gbl.Hierarchy.Deg.DegCod,Rol_NET); + HieCfg_NumUsrsInCrss (Hie_Lvl_DEG,Gbl.Hierarchy.Deg.DegCod,Rol_STD); + HieCfg_NumUsrsInCrss (Hie_Lvl_DEG,Gbl.Hierarchy.Deg.DegCod,Rol_UNK); } /***** End table *****/ @@ -185,7 +186,7 @@ static void DegCfg_PutIconsToPrintAndUpload (__attribute__((unused)) void *Args) // Only degree admins, centre admins, institution admins and system admins // have permission to upload logo of the degree /***** Link to upload logo of degree *****/ - Lgo_PutIconToChangeLogo (Hie_DEG); + Lgo_PutIconToChangeLogo (Hie_Lvl_DEG); } /*****************************************************************************/ @@ -195,7 +196,7 @@ static void DegCfg_PutIconsToPrintAndUpload (__attribute__((unused)) void *Args) static void DegCfg_Title (bool PutLink) { HieCfg_Title (PutLink, - Hie_DEG, // Logo scope + Hie_Lvl_DEG, // Logo scope Gbl.Hierarchy.Deg.DegCod, // Logo code Gbl.Hierarchy.Deg.ShrtName, // Logo short name Gbl.Hierarchy.Deg.FullName, // Logo full name @@ -254,7 +255,7 @@ static void DegCfg_Centre (bool PrintView,bool PutForm) "BT_LINK LT DAT",NULL); Hie_FreeGoToMsg (); } - Lgo_DrawLogo (Hie_CTR,Gbl.Hierarchy.Ctr.CtrCod,Gbl.Hierarchy.Ctr.ShrtName, + Lgo_DrawLogo (Hie_Lvl_CTR,Gbl.Hierarchy.Ctr.CtrCod,Gbl.Hierarchy.Ctr.ShrtName, 20,"LM",true); HTM_NBSP (); HTM_Txt (Gbl.Hierarchy.Ctr.FullName); diff --git a/swad_degree_type.c b/swad_degree_type.c index 9facdca0..94614d46 100644 --- a/swad_degree_type.c +++ b/swad_degree_type.c @@ -67,12 +67,12 @@ static struct DegreeType *DT_EditingDegTyp = NULL; // Static variable to keep th /*************************** Private prototypes ******************************/ /*****************************************************************************/ -static void DT_SeeDegreeTypes (Act_Action_t NextAction,Hie_Level_t Scope, +static void DT_SeeDegreeTypes (Act_Action_t NextAction,Hie_Lvl_Level_t Scope, DT_Order_t DefaultOrder); static DT_Order_t DT_GetParamDegTypOrder (DT_Order_t DefaultOrder); static void DT_ListDegreeTypes (Act_Action_t NextAction, - Hie_Level_t Scope, + Hie_Lvl_Level_t Scope, DT_Order_t SelectedOrder); static void DT_EditDegreeTypesInternal (void); @@ -86,7 +86,7 @@ static void DT_ListDegreeTypesForEdition (void); static void DT_PutFormToCreateDegreeType (void); static void DT_PutHeadDegreeTypesForSeeing (Act_Action_t NextAction, - Hie_Level_t Scope, + Hie_Lvl_Level_t Scope, DT_Order_t SelectedOrder); static void DT_PutHeadDegreeTypesForEdition (void); static void DT_CreateDegreeType (struct DegreeType *DegTyp); @@ -111,7 +111,7 @@ void DT_WriteSelectorDegreeTypes (long SelectedDegTypCod) /***** Form to select degree types *****/ /* Get list of degree types */ - DT_GetListDegreeTypes (Hie_SYS,DT_ORDER_BY_DEGREE_TYPE); + DT_GetListDegreeTypes (Hie_Lvl_SYS,DT_ORDER_BY_DEGREE_TYPE); /* List degree types */ HTM_SELECT_Begin (HTM_SUBMIT_ON_CHANGE, @@ -137,7 +137,7 @@ void DT_WriteSelectorDegreeTypes (long SelectedDegTypCod) void DT_SeeDegreeTypesInDegTab (void) { - DT_SeeDegreeTypes (ActSeeDegTyp,Hie_SYS, + DT_SeeDegreeTypes (ActSeeDegTyp,Hie_Lvl_SYS, DT_ORDER_BY_DEGREE_TYPE); // Default order if not specified } @@ -147,7 +147,7 @@ void DT_SeeDegreeTypesInStaTab (void) DT_ORDER_BY_NUM_DEGREES); // Default order if not specified } -static void DT_SeeDegreeTypes (Act_Action_t NextAction,Hie_Level_t Scope, +static void DT_SeeDegreeTypes (Act_Action_t NextAction,Hie_Lvl_Level_t Scope, DT_Order_t DefaultOrder) { DT_Order_t SelectedOrder; @@ -185,7 +185,7 @@ static DT_Order_t DT_GetParamDegTypOrder (DT_Order_t DefaultOrder) // - statistic tab => NextAction = ActSeeUseGbl static void DT_ListDegreeTypes (Act_Action_t NextAction, - Hie_Level_t Scope, + Hie_Lvl_Level_t Scope, DT_Order_t SelectedOrder) { extern const char *Hlp_CENTRE_DegreeTypes; @@ -262,7 +262,7 @@ static void DT_EditDegreeTypesInternal (void) extern const char *Txt_Types_of_degree; /***** Get list of degree types *****/ - DT_GetListDegreeTypes (Hie_SYS,DT_ORDER_BY_DEGREE_TYPE); + DT_GetListDegreeTypes (Hie_Lvl_SYS,DT_ORDER_BY_DEGREE_TYPE); /***** Begin box *****/ Box_BoxBegin (NULL,Txt_Types_of_degree, @@ -376,7 +376,7 @@ static void DT_PutIconsListingDegTypes (__attribute__((unused)) void *Args) static void DT_PutIconToEditDegTypes (__attribute__((unused)) void *Args) { - if (Gbl.Hierarchy.Level == Hie_CTR && // Only editable if centre tab is visible + if (Gbl.Hierarchy.Level == Hie_Lvl_CTR && // Only editable if centre tab is visible DT_CheckIfICanCreateDegreeTypes ()) Ico_PutContextualIconToEdit (ActEdiDegTyp,NULL, NULL,NULL); @@ -503,7 +503,7 @@ static void DT_PutFormToCreateDegreeType (void) /*****************************************************************************/ static void DT_PutHeadDegreeTypesForSeeing (Act_Action_t NextAction, - Hie_Level_t Scope, + Hie_Lvl_Level_t Scope, DT_Order_t SelectedOrder) { extern const char *Txt_DEGREE_TYPES_HELP_ORDER[DT_NUM_ORDERS]; @@ -582,7 +582,7 @@ static void DT_CreateDegreeType (struct DegreeType *DegTyp) /**************** Create a list with all the degree types ********************/ /*****************************************************************************/ -void DT_GetListDegreeTypes (Hie_Level_t Scope,DT_Order_t Order) +void DT_GetListDegreeTypes (Hie_Lvl_Level_t Scope,DT_Order_t Order) { static const char *OrderBySubQuery[DT_NUM_ORDERS] = { @@ -596,7 +596,7 @@ void DT_GetListDegreeTypes (Hie_Level_t Scope,DT_Order_t Order) /***** Get types of degree from database *****/ switch (Scope) { - case Hie_SYS: + case Hie_Lvl_SYS: /* Get all degree types with degrees union with @@ -622,7 +622,7 @@ void DT_GetListDegreeTypes (Hie_Level_t Scope,DT_Order_t Order) " ORDER BY %s", OrderBySubQuery[Order]); break; - case Hie_CTY: + case Hie_Lvl_CTY: /* Get only degree types with degrees in the current country */ Gbl.DegTypes.Num = (unsigned) DB_QuerySELECT (&mysql_res,"can not get types of degree", @@ -639,7 +639,7 @@ void DT_GetListDegreeTypes (Hie_Level_t Scope,DT_Order_t Order) Gbl.Hierarchy.Cty.CtyCod, OrderBySubQuery[Order]); break; - case Hie_INS: + case Hie_Lvl_INS: /* Get only degree types with degrees in the current institution */ Gbl.DegTypes.Num = (unsigned) DB_QuerySELECT (&mysql_res,"can not get types of degree", @@ -655,7 +655,7 @@ void DT_GetListDegreeTypes (Hie_Level_t Scope,DT_Order_t Order) Gbl.Hierarchy.Ins.InsCod, OrderBySubQuery[Order]); break; - case Hie_CTR: + case Hie_Lvl_CTR: /* Get only degree types with degrees in the current centre */ Gbl.DegTypes.Num = (unsigned) DB_QuerySELECT (&mysql_res,"can not get types of degree", @@ -670,8 +670,8 @@ void DT_GetListDegreeTypes (Hie_Level_t Scope,DT_Order_t Order) Gbl.Hierarchy.Ctr.CtrCod, OrderBySubQuery[Order]); break; - case Hie_DEG: - case Hie_CRS: + case Hie_Lvl_DEG: + case Hie_Lvl_CRS: /* Get only degree types with degrees in the current degree */ Gbl.DegTypes.Num = (unsigned) DB_QuerySELECT (&mysql_res,"can not get types of degree", diff --git a/swad_degree_type.h b/swad_degree_type.h index acf8e476..0a5c4bcd 100644 --- a/swad_degree_type.h +++ b/swad_degree_type.h @@ -68,7 +68,7 @@ void DT_PutIconToViewDegreeTypes (void); bool DT_CheckIfICanCreateDegreeTypes (void); -void DT_GetListDegreeTypes (Hie_Level_t Scope,DT_Order_t Order); +void DT_GetListDegreeTypes (Hie_Lvl_Level_t Scope,DT_Order_t Order); void DT_FreeListDegreeTypes (void); void DT_ReceiveFormNewDegreeType (void); diff --git a/swad_department.c b/swad_department.c index b8916c7c..c93f388d 100644 --- a/swad_department.c +++ b/swad_department.c @@ -397,11 +397,11 @@ static void Dpt_GetListDepartments (struct Dpt_Departments *Departments,long Ins /* Get the short name of the department (row[2]) */ Str_Copy (Dpt->ShrtName,row[2], - Hie_MAX_BYTES_SHRT_NAME); + Cns_HIERARCHY_MAX_BYTES_SHRT_NAME); /* Get the full name of the department (row[3]) */ Str_Copy (Dpt->FullName,row[3], - Hie_MAX_BYTES_FULL_NAME); + Cns_HIERARCHY_MAX_BYTES_FULL_NAME); /* Get the URL of the department (row[4]) */ Str_Copy (Dpt->WWW,row[4], @@ -438,9 +438,9 @@ void Dpt_GetDataOfDepartmentByCod (struct Dpt_Department *Dpt) if (Dpt->DptCod == 0) { Str_Copy (Dpt->ShrtName,Txt_Another_department, - Hie_MAX_BYTES_SHRT_NAME); + Cns_HIERARCHY_MAX_BYTES_SHRT_NAME); Str_Copy (Dpt->FullName,Txt_Another_department, - Hie_MAX_BYTES_FULL_NAME); + Cns_HIERARCHY_MAX_BYTES_FULL_NAME); } else if (Dpt->DptCod > 0) { @@ -472,11 +472,11 @@ void Dpt_GetDataOfDepartmentByCod (struct Dpt_Department *Dpt) /* Get the short name of the department (row[1]) */ Str_Copy (Dpt->ShrtName,row[1], - Hie_MAX_BYTES_SHRT_NAME); + Cns_HIERARCHY_MAX_BYTES_SHRT_NAME); /* Get the full name of the department (row[2]) */ Str_Copy (Dpt->FullName,row[2], - Hie_MAX_BYTES_FULL_NAME); + Cns_HIERARCHY_MAX_BYTES_FULL_NAME); /* Get the URL of the department (row[3]) */ Str_Copy (Dpt->WWW,row[3], @@ -588,7 +588,7 @@ static void Dpt_ListDepartmentsForEdition (const struct Dpt_Departments *Departm HTM_TD_Begin ("class=\"CM\""); Frm_StartForm (ActRenDptSho); Dpt_PutParamDptCod (&Dpt->DptCod); - HTM_INPUT_TEXT ("ShortName",Hie_MAX_CHARS_SHRT_NAME,Dpt->ShrtName, + HTM_INPUT_TEXT ("ShortName",Cns_HIERARCHY_MAX_CHARS_SHRT_NAME,Dpt->ShrtName, HTM_SUBMIT_ON_CHANGE, "class=\"INPUT_SHORT_NAME\""); Frm_EndForm (); @@ -598,7 +598,7 @@ static void Dpt_ListDepartmentsForEdition (const struct Dpt_Departments *Departm HTM_TD_Begin ("class=\"CM\""); Frm_StartForm (ActRenDptFul); Dpt_PutParamDptCod (&Dpt->DptCod); - HTM_INPUT_TEXT ("FullName",Hie_MAX_CHARS_FULL_NAME,Dpt->FullName, + HTM_INPUT_TEXT ("FullName",Cns_HIERARCHY_MAX_CHARS_FULL_NAME,Dpt->FullName, HTM_SUBMIT_ON_CHANGE, "class=\"INPUT_FULL_NAME\""); Frm_EndForm (); @@ -757,20 +757,20 @@ static void Dpt_RenameDepartment (Cns_ShrtOrFullName_t ShrtOrFullName) const char *FieldName = NULL; // Initialized to avoid warning size_t MaxBytes = 0; // Initialized to avoid warning char *CurrentDptName = NULL; // Initialized to avoid warning - char NewDptName[Hie_MAX_BYTES_FULL_NAME + 1]; + char NewDptName[Cns_HIERARCHY_MAX_BYTES_FULL_NAME + 1]; switch (ShrtOrFullName) { case Cns_SHRT_NAME: ParamName = "ShortName"; FieldName = "ShortName"; - MaxBytes = Hie_MAX_BYTES_SHRT_NAME; + MaxBytes = Cns_HIERARCHY_MAX_BYTES_SHRT_NAME; CurrentDptName = Dpt_EditingDpt->ShrtName; break; case Cns_FULL_NAME: ParamName = "FullName"; FieldName = "FullName"; - MaxBytes = Hie_MAX_BYTES_FULL_NAME; + MaxBytes = Cns_HIERARCHY_MAX_BYTES_FULL_NAME; CurrentDptName = Dpt_EditingDpt->FullName; break; } @@ -958,14 +958,14 @@ static void Dpt_PutFormToCreateDepartment (void) /***** Department short name *****/ HTM_TD_Begin ("class=\"CM\""); - HTM_INPUT_TEXT ("ShortName",Hie_MAX_CHARS_SHRT_NAME,Dpt_EditingDpt->ShrtName, + HTM_INPUT_TEXT ("ShortName",Cns_HIERARCHY_MAX_CHARS_SHRT_NAME,Dpt_EditingDpt->ShrtName, HTM_DONT_SUBMIT_ON_CHANGE, "class=\"INPUT_SHORT_NAME\" required=\"required\""); HTM_TD_End (); /***** Department full name *****/ HTM_TD_Begin ("class=\"CM\""); - HTM_INPUT_TEXT ("FullName",Hie_MAX_CHARS_FULL_NAME,Dpt_EditingDpt->FullName, + HTM_INPUT_TEXT ("FullName",Cns_HIERARCHY_MAX_CHARS_FULL_NAME,Dpt_EditingDpt->FullName, HTM_DONT_SUBMIT_ON_CHANGE, "class=\"INPUT_FULL_NAME\" required=\"required\""); HTM_TD_End (); @@ -1030,10 +1030,10 @@ void Dpt_ReceiveFormNewDpt (void) Dpt_EditingDpt->InsCod = Ins_GetAndCheckParamOtherInsCod (1); /* Get department short name */ - Par_GetParToText ("ShortName",Dpt_EditingDpt->ShrtName,Hie_MAX_BYTES_SHRT_NAME); + Par_GetParToText ("ShortName",Dpt_EditingDpt->ShrtName,Cns_HIERARCHY_MAX_BYTES_SHRT_NAME); /* Get department full name */ - Par_GetParToText ("FullName",Dpt_EditingDpt->FullName,Hie_MAX_BYTES_FULL_NAME); + Par_GetParToText ("FullName",Dpt_EditingDpt->FullName,Cns_HIERARCHY_MAX_BYTES_FULL_NAME); /* Get department WWW */ Par_GetParToText ("WWW",Dpt_EditingDpt->WWW,Cns_MAX_BYTES_WWW); diff --git a/swad_department.h b/swad_department.h index 7e9db7c6..c7679745 100644 --- a/swad_department.h +++ b/swad_department.h @@ -27,7 +27,7 @@ /********************************* Headers ***********************************/ /*****************************************************************************/ -#include "swad_hierarchy.h" +#include "swad_constant.h" /*****************************************************************************/ /************************** Public types and constants ***********************/ @@ -37,8 +37,8 @@ struct Dpt_Department { long DptCod; long InsCod; - char ShrtName[Hie_MAX_BYTES_SHRT_NAME + 1]; - char FullName[Hie_MAX_BYTES_FULL_NAME + 1]; + char ShrtName[Cns_HIERARCHY_MAX_BYTES_SHRT_NAME + 1]; + char FullName[Cns_HIERARCHY_MAX_BYTES_FULL_NAME + 1]; char WWW[Cns_MAX_BYTES_WWW + 1]; unsigned NumTchs; // Non-editing teachers and teachers }; diff --git a/swad_enrolment.c b/swad_enrolment.c index 9f348ede..2d9fcd72 100644 --- a/swad_enrolment.c +++ b/swad_enrolment.c @@ -40,6 +40,7 @@ #include "swad_exam_print.h" #include "swad_form.h" #include "swad_global.h" +#include "swad_hierarchy.h" #include "swad_HTML.h" #include "swad_ID.h" #include "swad_match.h" @@ -159,26 +160,26 @@ static void Enr_AskIfRegRemUsr (struct ListUsrCods *ListUsrCods,Rol_Role_t Role) static void Enr_ShowFormToEditOtherUsr (void); -static void Enr_AddAdm (Hie_Level_t Scope,long Cod,const char *InsCtrDegName); -static void Enr_RegisterAdmin (struct UsrData *UsrDat,Hie_Level_t Scope, +static void Enr_AddAdm (Hie_Lvl_Level_t Scope,long Cod,const char *InsCtrDegName); +static void Enr_RegisterAdmin (struct UsrData *UsrDat,Hie_Lvl_Level_t Scope, long Cod,const char *InsCtrDegName); static bool Enr_CheckIfICanRemUsrFromCrs (void); static void Enr_ReqRemAdmOfDeg (void); -static void Enr_ReqRemOrRemAdm (Enr_ReqDelOrDelUsr_t ReqDelOrDelUsr,Hie_Level_t Scope, +static void Enr_ReqRemOrRemAdm (Enr_ReqDelOrDelUsr_t ReqDelOrDelUsr,Hie_Lvl_Level_t Scope, long Cod,const char *InsCtrDegName); -static void Enr_ReqAddAdm (Hie_Level_t Scope,long Cod,const char *InsCtrDegName); +static void Enr_ReqAddAdm (Hie_Lvl_Level_t Scope,long Cod,const char *InsCtrDegName); static void Enr_AskIfRemoveUsrFromCrs (struct UsrData *UsrDat); static void Enr_EffectivelyRemUsrFromCrs (struct UsrData *UsrDat, struct Crs_Course *Crs, Enr_RemoveUsrProduction_t RemoveUsrWorks, Cns_QuietOrVerbose_t QuietOrVerbose); -static void Enr_AskIfRemAdm (bool ItsMe,Hie_Level_t Scope, +static void Enr_AskIfRemAdm (bool ItsMe,Hie_Lvl_Level_t Scope, const char *InsCtrDegName); -static void Enr_EffectivelyRemAdm (struct UsrData *UsrDat,Hie_Level_t Scope, +static void Enr_EffectivelyRemAdm (struct UsrData *UsrDat,Hie_Lvl_Level_t Scope, long Cod,const char *InsCtrDegName); /*****************************************************************************/ @@ -189,7 +190,7 @@ void Enr_CheckStdsAndPutButtonToRegisterStdsInCurrentCrs (void) { /***** Put link to register students *****/ if (Gbl.Usrs.Me.Role.Logged == Rol_TCH) // Course selected and I am logged as teacher - if (!Usr_GetNumUsrsInCrss (Hie_CRS,Gbl.Hierarchy.Crs.CrsCod, + if (!Usr_GetNumUsrsInCrss (Hie_Lvl_CRS,Gbl.Hierarchy.Crs.CrsCod, 1 << Rol_STD)) // No students in course Usr_ShowWarningNoUsersFound (Rol_STD); } @@ -203,7 +204,7 @@ void Enr_PutButtonInlineToRegisterStds (long CrsCod) extern const char *Txt_Register_students; if (Gbl.Usrs.Me.Role.Logged == Rol_TCH) // Course selected and I am logged as teacher - if (!Usr_GetNumUsrsInCrss (Hie_CRS,CrsCod, + if (!Usr_GetNumUsrsInCrss (Hie_Lvl_CRS,CrsCod, 1 << Rol_STD)) // No students in course { Frm_StartForm (ActReqEnrSevStd); @@ -641,7 +642,7 @@ static void Enr_ReqAdminUsrs (Rol_Role_t Role) Enr_AskIfRegRemMe (Role); break; case Rol_TCH: - if (Gbl.Hierarchy.Level == Hie_CRS && Role == Rol_STD) + if (Gbl.Hierarchy.Level == Hie_Lvl_CRS && Role == Rol_STD) Enr_ShowFormRegRemSeveralUsrs (Rol_STD); else Enr_AskIfRegRemMe (Rol_TCH); @@ -650,7 +651,7 @@ static void Enr_ReqAdminUsrs (Rol_Role_t Role) case Rol_CTR_ADM: case Rol_INS_ADM: case Rol_SYS_ADM: - if (Gbl.Hierarchy.Level == Hie_CRS) + if (Gbl.Hierarchy.Level == Hie_Lvl_CRS) Enr_ShowFormRegRemSeveralUsrs (Role); else Enr_ReqAnotherUsrIDToRegisterRemove (Role); @@ -684,7 +685,7 @@ static void Enr_ShowFormRegRemSeveralUsrs (Rol_Role_t Role) const char *Title; /***** Contextual menu *****/ - if (Gbl.Hierarchy.Level == Hie_CRS) // Course selected + if (Gbl.Hierarchy.Level == Hie_Lvl_CRS) // Course selected { Mnu_ContextMenuBegin (); @@ -695,7 +696,7 @@ static void Enr_ShowFormRegRemSeveralUsrs (Rol_Role_t Role) Enr_PutLinkToAdminOneUsr (ActReqMdfOneStd); /* Put link to remove all the students in the current course */ - if (Usr_GetNumUsrsInCrss (Hie_CRS,Gbl.Hierarchy.Crs.CrsCod, + if (Usr_GetNumUsrsInCrss (Hie_Lvl_CRS,Gbl.Hierarchy.Crs.CrsCod, 1 << Rol_STD)) // This course has students Enr_PutLinkToRemAllStdsThisCrs (); break; @@ -763,7 +764,7 @@ static void Enr_ShowFormRegRemSeveralUsrs (Rol_Role_t Role) HTM_DIV_Begin ("class=\"%s LM\"",The_ClassTitle[Gbl.Prefs.Theme]); HTM_Txt (Txt_Step_3_Optionally_select_groups); HTM_DIV_End (); - if (Gbl.Hierarchy.Level == Hie_CRS) // Course selected + if (Gbl.Hierarchy.Level == Hie_Lvl_CRS) // Course selected { if (Gbl.Crs.Grps.NumGrps) // This course has groups? { @@ -970,7 +971,7 @@ static void Enr_PutActionsRegRemSeveralUsrs (void) HTM_UL_Begin ("class=\"LIST_LEFT %s\"",The_ClassFormInBox[Gbl.Prefs.Theme]); /***** Register / remove users listed or not listed *****/ - if (Gbl.Hierarchy.Level == Hie_CRS) // Course selected + if (Gbl.Hierarchy.Level == Hie_Lvl_CRS) // Course selected { HTM_LI_Begin (NULL); HTM_LABEL_Begin (NULL); @@ -1193,7 +1194,7 @@ static void Enr_ReceiveFormUsrsCrs (Rol_Role_t Role) if (WhatToDo.RemoveUsrs) { /***** Get list of users in current course *****/ - Usr_GetListUsrs (Hie_CRS,Role); + Usr_GetListUsrs (Hie_Lvl_CRS,Role); if (Gbl.Usrs.LstUsrs[Role].NumUsrs) { @@ -1477,27 +1478,27 @@ bool Enr_PutActionsRegRemOneUsr (bool ItsMe) bool OptionChecked = false; /***** Check if the other user belongs to the current course *****/ - if (Gbl.Hierarchy.Level == Hie_CRS) + if (Gbl.Hierarchy.Level == Hie_Lvl_CRS) UsrBelongsToCrs = Usr_CheckIfUsrBelongsToCurrentCrs (&Gbl.Usrs.Other.UsrDat); if (Gbl.Hierarchy.Ins.InsCod > 0) { /***** Check if the other user is administrator of the current institution *****/ UsrIsInsAdmin = Usr_CheckIfUsrIsAdm (Gbl.Usrs.Other.UsrDat.UsrCod, - Hie_INS, + Hie_Lvl_INS, Gbl.Hierarchy.Ins.InsCod); if (Gbl.Hierarchy.Ctr.CtrCod > 0) { /***** Check if the other user is administrator of the current centre *****/ UsrIsCtrAdmin = Usr_CheckIfUsrIsAdm (Gbl.Usrs.Other.UsrDat.UsrCod, - Hie_CTR, + Hie_Lvl_CTR, Gbl.Hierarchy.Ctr.CtrCod); if (Gbl.Hierarchy.Deg.DegCod > 0) /***** Check if the other user is administrator of the current degree *****/ UsrIsDegAdmin = Usr_CheckIfUsrIsAdm (Gbl.Usrs.Other.UsrDat.UsrCod, - Hie_DEG, + Hie_Lvl_DEG, Gbl.Hierarchy.Deg.DegCod); } } @@ -1506,7 +1507,7 @@ bool Enr_PutActionsRegRemOneUsr (bool ItsMe) HTM_UL_Begin ("class=\"LIST_LEFT %s\"",The_ClassFormInBox[Gbl.Prefs.Theme]); /***** Register user in course / Modify user's data *****/ - if (Gbl.Hierarchy.Level == Hie_CRS && Gbl.Usrs.Me.Role.Logged >= Rol_STD) + if (Gbl.Hierarchy.Level == Hie_Lvl_CRS && Gbl.Usrs.Me.Role.Logged >= Rol_STD) { Enr_PutActionModifyOneUsr (&OptionChecked,UsrBelongsToCrs,ItsMe); OptionsShown = true; @@ -1801,7 +1802,7 @@ static void Enr_RegisterUsr (struct UsrData *UsrDat,Rol_Role_t RegRemRole, } /***** Register user in current course in database *****/ - if (Gbl.Hierarchy.Level == Hie_CRS) // Course selected + if (Gbl.Hierarchy.Level == Hie_Lvl_CRS) // Course selected { if (Usr_CheckIfUsrBelongsToCurrentCrs (UsrDat)) { @@ -1846,7 +1847,7 @@ void Enr_AskRemAllStdsThisCrs (void) extern const char *Hlp_USERS_Administration_remove_all_students; extern const char *Txt_Remove_all_students; extern const char *Txt_Do_you_really_want_to_remove_the_X_students_from_the_course_Y_; - unsigned NumStds = Usr_GetNumUsrsInCrss (Hie_CRS,Gbl.Hierarchy.Crs.CrsCod, + unsigned NumStds = Usr_GetNumUsrsInCrss (Hie_Lvl_CRS,Gbl.Hierarchy.Crs.CrsCod, 1 << Rol_STD); // This course has students /***** Begin box *****/ @@ -1914,7 +1915,7 @@ unsigned Enr_RemAllStdsInCrs (struct Crs_Course *Crs) /***** Get list of students in current course *****/ Gbl.Usrs.ClassPhoto.AllGroups = true; // Get all the students of the current course - Usr_GetListUsrs (Hie_CRS,Rol_STD); + Usr_GetListUsrs (Hie_Lvl_CRS,Rol_STD); NumStdsInCrs = Gbl.Usrs.LstUsrs[Rol_STD].NumUsrs; /***** Remove all the students *****/ @@ -2036,7 +2037,7 @@ void Enr_SignUpInCrs (void) if (RoleFromForm == Rol_TCH) Notify = true; else - Notify = (Usr_GetNumUsrsInCrss (Hie_CRS,Gbl.Hierarchy.Crs.CrsCod, + Notify = (Usr_GetNumUsrsInCrss (Hie_Lvl_CRS,Gbl.Hierarchy.Crs.CrsCod, 1 << Rol_TCH) != 0); // This course has teachers if (Notify) Ntf_StoreNotifyEventsToAllUsrs (Ntf_EVENT_ENROLMENT_REQUEST,ReqCod); @@ -2271,13 +2272,13 @@ static void Enr_ShowEnrolmentRequestsGivenRoles (unsigned RolesSelected) Enr_RemoveExpiredEnrolmentRequests (); /***** Get scope *****/ - Gbl.Scope.Allowed = 1 << Hie_SYS | - 1 << Hie_CTY | - 1 << Hie_INS | - 1 << Hie_CTR | - 1 << Hie_DEG | - 1 << Hie_CRS; - Gbl.Scope.Default = Hie_CRS; + Gbl.Scope.Allowed = 1 << Hie_Lvl_SYS | + 1 << Hie_Lvl_CTY | + 1 << Hie_Lvl_INS | + 1 << Hie_Lvl_CTR | + 1 << Hie_Lvl_DEG | + 1 << Hie_Lvl_CRS; + Gbl.Scope.Default = Hie_Lvl_CRS; Sco_GetScope ("ScopeEnr"); /***** Begin box *****/ @@ -2325,7 +2326,7 @@ static void Enr_ShowEnrolmentRequestsGivenRoles (unsigned RolesSelected) /***** Build query *****/ switch (Gbl.Scope.Current) { - case Hie_SYS: // Show requesters for the whole platform + case Hie_Lvl_SYS: // Show requesters for the whole platform switch (Gbl.Usrs.Me.Role.Logged) { case Rol_TCH: @@ -2362,7 +2363,7 @@ static void Enr_ShowEnrolmentRequestsGivenRoles (unsigned RolesSelected) " AND courses.CrsCod=crs_usr_requests.CrsCod" " AND ((1<0" " ORDER BY crs_usr_requests.RequestTime DESC", - Gbl.Usrs.Me.UsrDat.UsrCod,Sco_GetDBStrFromScope (Hie_DEG), + Gbl.Usrs.Me.UsrDat.UsrCod,Sco_GetDBStrFromScope (Hie_Lvl_DEG), RolesSelected); break; case Rol_CTR_ADM: @@ -2381,7 +2382,7 @@ static void Enr_ShowEnrolmentRequestsGivenRoles (unsigned RolesSelected) " AND courses.CrsCod=crs_usr_requests.CrsCod" " AND ((1<0" " ORDER BY crs_usr_requests.RequestTime DESC", - Gbl.Usrs.Me.UsrDat.UsrCod,Sco_GetDBStrFromScope (Hie_CTR), + Gbl.Usrs.Me.UsrDat.UsrCod,Sco_GetDBStrFromScope (Hie_Lvl_CTR), RolesSelected); break; case Rol_INS_ADM: @@ -2401,7 +2402,7 @@ static void Enr_ShowEnrolmentRequestsGivenRoles (unsigned RolesSelected) " AND courses.CrsCod=crs_usr_requests.CrsCod" " AND ((1<0" " ORDER BY crs_usr_requests.RequestTime DESC", - Gbl.Usrs.Me.UsrDat.UsrCod,Sco_GetDBStrFromScope (Hie_INS), + Gbl.Usrs.Me.UsrDat.UsrCod,Sco_GetDBStrFromScope (Hie_Lvl_INS), RolesSelected); break; case Rol_SYS_ADM: @@ -2423,7 +2424,7 @@ static void Enr_ShowEnrolmentRequestsGivenRoles (unsigned RolesSelected) break; } break; - case Hie_CTY: // Show requesters for the current country + case Hie_Lvl_CTY: // Show requesters for the current country switch (Gbl.Usrs.Me.Role.Logged) { case Rol_TCH: @@ -2470,7 +2471,7 @@ static void Enr_ShowEnrolmentRequestsGivenRoles (unsigned RolesSelected) " AND courses.CrsCod=crs_usr_requests.CrsCod" " AND ((1<0" " ORDER BY crs_usr_requests.RequestTime DESC", - Gbl.Usrs.Me.UsrDat.UsrCod,Sco_GetDBStrFromScope (Hie_DEG), + Gbl.Usrs.Me.UsrDat.UsrCod,Sco_GetDBStrFromScope (Hie_Lvl_DEG), Gbl.Hierarchy.Cty.CtyCod, RolesSelected); break; @@ -2493,7 +2494,7 @@ static void Enr_ShowEnrolmentRequestsGivenRoles (unsigned RolesSelected) " AND courses.CrsCod=crs_usr_requests.CrsCod" " AND ((1<0" " ORDER BY crs_usr_requests.RequestTime DESC", - Gbl.Usrs.Me.UsrDat.UsrCod,Sco_GetDBStrFromScope (Hie_CTR), + Gbl.Usrs.Me.UsrDat.UsrCod,Sco_GetDBStrFromScope (Hie_Lvl_CTR), Gbl.Hierarchy.Cty.CtyCod, RolesSelected); break; @@ -2516,7 +2517,7 @@ static void Enr_ShowEnrolmentRequestsGivenRoles (unsigned RolesSelected) " AND courses.CrsCod=crs_usr_requests.CrsCod" " AND ((1<0" " ORDER BY crs_usr_requests.RequestTime DESC", - Gbl.Usrs.Me.UsrDat.UsrCod,Sco_GetDBStrFromScope (Hie_INS), + Gbl.Usrs.Me.UsrDat.UsrCod,Sco_GetDBStrFromScope (Hie_Lvl_INS), Gbl.Hierarchy.Cty.CtyCod, RolesSelected); break; @@ -2545,7 +2546,7 @@ static void Enr_ShowEnrolmentRequestsGivenRoles (unsigned RolesSelected) break; } break; - case Hie_INS: // Show requesters for the current institution + case Hie_Lvl_INS: // Show requesters for the current institution switch (Gbl.Usrs.Me.Role.Logged) { case Rol_TCH: @@ -2590,7 +2591,7 @@ static void Enr_ShowEnrolmentRequestsGivenRoles (unsigned RolesSelected) " AND courses.CrsCod=crs_usr_requests.CrsCod" " AND ((1<0" " ORDER BY crs_usr_requests.RequestTime DESC", - Gbl.Usrs.Me.UsrDat.UsrCod,Sco_GetDBStrFromScope (Hie_DEG), + Gbl.Usrs.Me.UsrDat.UsrCod,Sco_GetDBStrFromScope (Hie_Lvl_DEG), Gbl.Hierarchy.Ins.InsCod, RolesSelected); break; @@ -2612,7 +2613,7 @@ static void Enr_ShowEnrolmentRequestsGivenRoles (unsigned RolesSelected) " AND courses.CrsCod=crs_usr_requests.CrsCod" " AND ((1<0" " ORDER BY crs_usr_requests.RequestTime DESC", - Gbl.Usrs.Me.UsrDat.UsrCod,Sco_GetDBStrFromScope (Hie_CTR), + Gbl.Usrs.Me.UsrDat.UsrCod,Sco_GetDBStrFromScope (Hie_Lvl_CTR), Gbl.Hierarchy.Ins.InsCod, RolesSelected); break; @@ -2641,7 +2642,7 @@ static void Enr_ShowEnrolmentRequestsGivenRoles (unsigned RolesSelected) break; } break; - case Hie_CTR: // Show requesters for the current centre + case Hie_Lvl_CTR: // Show requesters for the current centre switch (Gbl.Usrs.Me.Role.Logged) { case Rol_TCH: @@ -2684,7 +2685,7 @@ static void Enr_ShowEnrolmentRequestsGivenRoles (unsigned RolesSelected) " AND courses.CrsCod=crs_usr_requests.CrsCod" " AND ((1<0" " ORDER BY crs_usr_requests.RequestTime DESC", - Gbl.Usrs.Me.UsrDat.UsrCod,Sco_GetDBStrFromScope (Hie_DEG), + Gbl.Usrs.Me.UsrDat.UsrCod,Sco_GetDBStrFromScope (Hie_Lvl_DEG), Gbl.Hierarchy.Ctr.CtrCod, RolesSelected); break; @@ -2713,7 +2714,7 @@ static void Enr_ShowEnrolmentRequestsGivenRoles (unsigned RolesSelected) break; } break; - case Hie_DEG: // Show requesters for the current degree + case Hie_Lvl_DEG: // Show requesters for the current degree switch (Gbl.Usrs.Me.Role.Logged) { case Rol_TCH: @@ -2763,7 +2764,7 @@ static void Enr_ShowEnrolmentRequestsGivenRoles (unsigned RolesSelected) break; } break; - case Hie_CRS: // Show requesters for the current course + case Hie_Lvl_CRS: // Show requesters for the current course switch (Gbl.Usrs.Me.Role.Logged) { case Rol_TCH: // If I am logged as teacher of this course , I can view all the requesters from this course @@ -2871,7 +2872,7 @@ static void Enr_ShowEnrolmentRequestsGivenRoles (unsigned RolesSelected) /***** Number of teachers in the course *****/ HTM_TD_Begin ("class=\"DAT RT\""); - HTM_Unsigned (Usr_GetNumUsrsInCrss (Hie_CRS,Crs.CrsCod, + HTM_Unsigned (Usr_GetNumUsrsInCrss (Hie_Lvl_CRS,Crs.CrsCod, 1 << Rol_TCH)); HTM_TD_End (); @@ -3285,7 +3286,7 @@ static void Enr_ShowFormToEditOtherUsr (void) if (Usr_ChkIfUsrCodExists (Gbl.Usrs.Other.UsrDat.UsrCod)) { /***** Show form to edit user *****/ - if (Gbl.Hierarchy.Level == Hie_CRS) // Course selected + if (Gbl.Hierarchy.Level == Hie_Lvl_CRS) // Course selected { /* Check if this user belongs to the current course */ if (Usr_CheckIfUsrBelongsToCurrentCrs (&Gbl.Usrs.Other.UsrDat)) @@ -3327,7 +3328,7 @@ static void Enr_ShowFormToEditOtherUsr (void) void Enr_AddAdmToIns (void) { - Enr_AddAdm (Hie_INS,Gbl.Hierarchy.Ins.InsCod,Gbl.Hierarchy.Ins.FullName); + Enr_AddAdm (Hie_Lvl_INS,Gbl.Hierarchy.Ins.InsCod,Gbl.Hierarchy.Ins.FullName); } /*****************************************************************************/ @@ -3336,7 +3337,7 @@ void Enr_AddAdmToIns (void) void Enr_AddAdmToCtr (void) { - Enr_AddAdm (Hie_CTR,Gbl.Hierarchy.Ctr.CtrCod,Gbl.Hierarchy.Ctr.FullName); + Enr_AddAdm (Hie_Lvl_CTR,Gbl.Hierarchy.Ctr.CtrCod,Gbl.Hierarchy.Ctr.FullName); } /*****************************************************************************/ @@ -3345,14 +3346,14 @@ void Enr_AddAdmToCtr (void) void Enr_AddAdmToDeg (void) { - Enr_AddAdm (Hie_DEG,Gbl.Hierarchy.Deg.DegCod,Gbl.Hierarchy.Deg.FullName); + Enr_AddAdm (Hie_Lvl_DEG,Gbl.Hierarchy.Deg.DegCod,Gbl.Hierarchy.Deg.FullName); } /*****************************************************************************/ /******************* Add an administrator to current degree ******************/ /*****************************************************************************/ -static void Enr_AddAdm (Hie_Level_t Scope,long Cod,const char *InsCtrDegName) +static void Enr_AddAdm (Hie_Lvl_Level_t Scope,long Cod,const char *InsCtrDegName) { bool ICanRegister; @@ -3362,9 +3363,9 @@ static void Enr_AddAdm (Hie_Level_t Scope,long Cod,const char *InsCtrDegName) if (Usr_GetParamOtherUsrCodEncryptedAndGetUsrData ()) { /* Check if I am allowed to register user as administrator in institution/centre/degree */ - ICanRegister = ((Scope == Hie_DEG && Gbl.Usrs.Me.Role.Logged >= Rol_CTR_ADM) || - (Scope == Hie_CTR && Gbl.Usrs.Me.Role.Logged >= Rol_INS_ADM) || - (Scope == Hie_INS && Gbl.Usrs.Me.Role.Logged == Rol_SYS_ADM)); + ICanRegister = ((Scope == Hie_Lvl_DEG && Gbl.Usrs.Me.Role.Logged >= Rol_CTR_ADM) || + (Scope == Hie_Lvl_CTR && Gbl.Usrs.Me.Role.Logged >= Rol_INS_ADM) || + (Scope == Hie_Lvl_INS && Gbl.Usrs.Me.Role.Logged == Rol_SYS_ADM)); if (ICanRegister) { /***** Register administrator in current institution/centre/degree in database *****/ @@ -3386,7 +3387,7 @@ static void Enr_AddAdm (Hie_Level_t Scope,long Cod,const char *InsCtrDegName) /**************** Register administrator in current institution **************/ /*****************************************************************************/ -static void Enr_RegisterAdmin (struct UsrData *UsrDat,Hie_Level_t Scope,long Cod,const char *InsCtrDegName) +static void Enr_RegisterAdmin (struct UsrData *UsrDat,Hie_Lvl_Level_t Scope,long Cod,const char *InsCtrDegName) { extern const char *Txt_THE_USER_X_is_already_an_administrator_of_Y; extern const char *Txt_THE_USER_X_has_been_enroled_as_administrator_of_Y; @@ -3502,7 +3503,7 @@ static bool Enr_CheckIfICanRemUsrFromCrs (void) static void Enr_ReqRemAdmOfIns (void) { - Enr_ReqRemOrRemAdm (Enr_REQUEST_REMOVE_USR,Hie_INS, + Enr_ReqRemOrRemAdm (Enr_REQUEST_REMOVE_USR,Hie_Lvl_INS, Gbl.Hierarchy.Ins.InsCod,Gbl.Hierarchy.Ins.FullName); } @@ -3512,7 +3513,7 @@ static void Enr_ReqRemAdmOfIns (void) static void Enr_ReqRemAdmOfCtr (void) { - Enr_ReqRemOrRemAdm (Enr_REQUEST_REMOVE_USR,Hie_CTR, + Enr_ReqRemOrRemAdm (Enr_REQUEST_REMOVE_USR,Hie_Lvl_CTR, Gbl.Hierarchy.Ctr.CtrCod,Gbl.Hierarchy.Ctr.FullName); } @@ -3522,7 +3523,7 @@ static void Enr_ReqRemAdmOfCtr (void) static void Enr_ReqRemAdmOfDeg (void) { - Enr_ReqRemOrRemAdm (Enr_REQUEST_REMOVE_USR,Hie_DEG, + Enr_ReqRemOrRemAdm (Enr_REQUEST_REMOVE_USR,Hie_Lvl_DEG, Gbl.Hierarchy.Deg.DegCod,Gbl.Hierarchy.Deg.FullName); } @@ -3532,7 +3533,7 @@ static void Enr_ReqRemAdmOfDeg (void) void Enr_RemAdmIns (void) { - Enr_ReqRemOrRemAdm (Enr_REMOVE_USR,Hie_INS, + Enr_ReqRemOrRemAdm (Enr_REMOVE_USR,Hie_Lvl_INS, Gbl.Hierarchy.Ins.InsCod,Gbl.Hierarchy.Ins.FullName); } @@ -3542,7 +3543,7 @@ void Enr_RemAdmIns (void) void Enr_RemAdmCtr (void) { - Enr_ReqRemOrRemAdm (Enr_REMOVE_USR,Hie_CTR, + Enr_ReqRemOrRemAdm (Enr_REMOVE_USR,Hie_Lvl_CTR, Gbl.Hierarchy.Ctr.CtrCod,Gbl.Hierarchy.Ctr.FullName); } @@ -3552,7 +3553,7 @@ void Enr_RemAdmCtr (void) void Enr_RemAdmDeg (void) { - Enr_ReqRemOrRemAdm (Enr_REMOVE_USR,Hie_DEG, + Enr_ReqRemOrRemAdm (Enr_REMOVE_USR,Hie_Lvl_DEG, Gbl.Hierarchy.Deg.DegCod,Gbl.Hierarchy.Deg.FullName); } @@ -3560,7 +3561,7 @@ void Enr_RemAdmDeg (void) /***************** Remove an admin from current institution ******************/ /*****************************************************************************/ -static void Enr_ReqRemOrRemAdm (Enr_ReqDelOrDelUsr_t ReqDelOrDelUsr,Hie_Level_t Scope, +static void Enr_ReqRemOrRemAdm (Enr_ReqDelOrDelUsr_t ReqDelOrDelUsr,Hie_Lvl_Level_t Scope, long Cod,const char *InsCtrDegName) { extern const char *Txt_THE_USER_X_is_not_an_administrator_of_Y; @@ -3575,9 +3576,9 @@ static void Enr_ReqRemOrRemAdm (Enr_ReqDelOrDelUsr_t ReqDelOrDelUsr,Hie_Level_t /* Check if it's forbidden to remove an administrator */ ItsMe = Usr_ItsMe (Gbl.Usrs.Other.UsrDat.UsrCod); ICanRemove = (ItsMe || - (Scope == Hie_DEG && Gbl.Usrs.Me.Role.Logged >= Rol_CTR_ADM) || - (Scope == Hie_CTR && Gbl.Usrs.Me.Role.Logged >= Rol_INS_ADM) || - (Scope == Hie_INS && Gbl.Usrs.Me.Role.Logged == Rol_SYS_ADM)); + (Scope == Hie_Lvl_DEG && Gbl.Usrs.Me.Role.Logged >= Rol_CTR_ADM) || + (Scope == Hie_Lvl_CTR && Gbl.Usrs.Me.Role.Logged >= Rol_INS_ADM) || + (Scope == Hie_Lvl_INS && Gbl.Usrs.Me.Role.Logged == Rol_SYS_ADM)); if (ICanRemove) { /* Check if the other user is an admin of the current institution/centre/degree */ @@ -3610,20 +3611,20 @@ static void Enr_ReqRemOrRemAdm (Enr_ReqDelOrDelUsr_t ReqDelOrDelUsr,Hie_Level_t /**** Ask if really wanted to add an administrator to current institution ****/ /*****************************************************************************/ -static void Enr_ReqAddAdm (Hie_Level_t Scope,long Cod,const char *InsCtrDegName) +static void Enr_ReqAddAdm (Hie_Lvl_Level_t Scope,long Cod,const char *InsCtrDegName) { extern const char *Txt_THE_USER_X_is_already_an_administrator_of_Y; extern const char *Txt_Do_you_really_want_to_register_the_following_user_as_an_administrator_of_X; extern const char *Txt_Register_user_IN_A_COURSE_OR_DEGREE; - static const Act_Action_t Enr_ActNewAdm[Hie_NUM_LEVELS] = + static const Act_Action_t Enr_ActNewAdm[Hie_Lvl_NUM_LEVELS] = { - [Hie_UNK] = ActUnk, - [Hie_SYS] = ActUnk, - [Hie_CTY] = ActUnk, - [Hie_INS] = ActNewAdmIns, - [Hie_CTR] = ActNewAdmCtr, - [Hie_DEG] = ActNewAdmDeg, - [Hie_CRS] = ActUnk, + [Hie_Lvl_UNK] = ActUnk, + [Hie_Lvl_SYS] = ActUnk, + [Hie_Lvl_CTY] = ActUnk, + [Hie_Lvl_INS] = ActNewAdmIns, + [Hie_Lvl_CTR] = ActNewAdmCtr, + [Hie_Lvl_DEG] = ActNewAdmDeg, + [Hie_Lvl_CRS] = ActUnk, }; bool ICanRegister; @@ -3633,9 +3634,9 @@ static void Enr_ReqAddAdm (Hie_Level_t Scope,long Cod,const char *InsCtrDegName) if (Usr_GetParamOtherUsrCodEncryptedAndGetUsrData ()) { /* Check if I am allowed to register user as administrator in institution/centre/degree */ - ICanRegister = ((Scope == Hie_DEG && Gbl.Usrs.Me.Role.Logged >= Rol_CTR_ADM) || - (Scope == Hie_CTR && Gbl.Usrs.Me.Role.Logged >= Rol_INS_ADM) || - (Scope == Hie_INS && Gbl.Usrs.Me.Role.Logged == Rol_SYS_ADM)); + ICanRegister = ((Scope == Hie_Lvl_DEG && Gbl.Usrs.Me.Role.Logged >= Rol_CTR_ADM) || + (Scope == Hie_Lvl_CTR && Gbl.Usrs.Me.Role.Logged >= Rol_INS_ADM) || + (Scope == Hie_Lvl_INS && Gbl.Usrs.Me.Role.Logged == Rol_SYS_ADM)); if (ICanRegister) { if (Usr_CheckIfUsrIsAdm (Gbl.Usrs.Other.UsrDat.UsrCod,Scope,Cod)) // User is already an administrator of current institution/centre/degree @@ -3723,7 +3724,7 @@ void Enr_CreateNewUsr1 (void) false); // I am NOT creating my own account /***** Register user in current course in database *****/ - if (Gbl.Hierarchy.Level == Hie_CRS) // Course selected + if (Gbl.Hierarchy.Level == Hie_Lvl_CRS) // Course selected { if (Usr_CheckIfUsrBelongsToCurrentCrs (&Gbl.Usrs.Other.UsrDat)) { @@ -3838,7 +3839,7 @@ void Enr_ModifyUsr1 (void) /***** Update user's data in database *****/ Enr_UpdateUsrData (&Gbl.Usrs.Other.UsrDat); - if (Gbl.Hierarchy.Level == Hie_CRS) // Course selected + if (Gbl.Hierarchy.Level == Hie_Lvl_CRS) // Course selected { /***** Get new role from record form *****/ NewRole = Rec_GetRoleFromRecordForm (); @@ -3983,15 +3984,15 @@ void Enr_ModifyUsr2 (void) Enr_ShowFormToEditOtherUsr (); break; case Enr_REGISTER_ONE_DEGREE_ADMIN: - Enr_ReqAddAdm (Hie_DEG,Gbl.Hierarchy.Deg.DegCod, + Enr_ReqAddAdm (Hie_Lvl_DEG,Gbl.Hierarchy.Deg.DegCod, Gbl.Hierarchy.Deg.FullName); break; case Enr_REGISTER_ONE_CENTRE_ADMIN: - Enr_ReqAddAdm (Hie_CTR,Gbl.Hierarchy.Ctr.CtrCod, + Enr_ReqAddAdm (Hie_Lvl_CTR,Gbl.Hierarchy.Ctr.CtrCod, Gbl.Hierarchy.Ctr.FullName); break; case Enr_REGISTER_ONE_INSTITUTION_ADMIN: - Enr_ReqAddAdm (Hie_INS,Gbl.Hierarchy.Ins.InsCod, + Enr_ReqAddAdm (Hie_Lvl_INS,Gbl.Hierarchy.Ins.InsCod, Gbl.Hierarchy.Ins.FullName); break; case Enr_REPORT_USR_AS_POSSIBLE_DUPLICATE: @@ -4195,22 +4196,22 @@ static void Enr_EffectivelyRemUsrFromCrs (struct UsrData *UsrDat, /** Ask if really wanted to remove an administrator from current institution */ /*****************************************************************************/ -static void Enr_AskIfRemAdm (bool ItsMe,Hie_Level_t Scope, +static void Enr_AskIfRemAdm (bool ItsMe,Hie_Lvl_Level_t Scope, const char *InsCtrDegName) { extern const char *Txt_Do_you_really_want_to_be_removed_as_an_administrator_of_X; extern const char *Txt_Do_you_really_want_to_remove_the_following_user_as_an_administrator_of_X; extern const char *Txt_Remove_me_as_an_administrator; extern const char *Txt_Remove_USER_as_an_administrator; - static const Act_Action_t Enr_ActRemAdm[Hie_NUM_LEVELS] = + static const Act_Action_t Enr_ActRemAdm[Hie_Lvl_NUM_LEVELS] = { - [Hie_UNK] = ActUnk, - [Hie_SYS] = ActUnk, - [Hie_CTY] = ActUnk, - [Hie_INS] = ActRemAdmIns, - [Hie_CTR] = ActRemAdmCtr, - [Hie_DEG] = ActRemAdmDeg, - [Hie_CRS] = ActUnk, + [Hie_Lvl_UNK] = ActUnk, + [Hie_Lvl_SYS] = ActUnk, + [Hie_Lvl_CTY] = ActUnk, + [Hie_Lvl_INS] = ActRemAdmIns, + [Hie_Lvl_CTR] = ActRemAdmCtr, + [Hie_Lvl_DEG] = ActRemAdmDeg, + [Hie_Lvl_CRS] = ActUnk, }; if (Usr_ChkIfUsrCodExists (Gbl.Usrs.Other.UsrDat.UsrCod)) @@ -4239,7 +4240,7 @@ static void Enr_AskIfRemAdm (bool ItsMe,Hie_Level_t Scope, /**** Remove an administrator from current institution, centre or degree *****/ /*****************************************************************************/ -static void Enr_EffectivelyRemAdm (struct UsrData *UsrDat,Hie_Level_t Scope, +static void Enr_EffectivelyRemAdm (struct UsrData *UsrDat,Hie_Lvl_Level_t Scope, long Cod,const char *InsCtrDegName) { extern const char *Txt_THE_USER_X_has_been_removed_as_administrator_of_Y; diff --git a/swad_exam.c b/swad_exam.c index ad7b743d..4b16b1ba 100644 --- a/swad_exam.c +++ b/swad_exam.c @@ -1883,7 +1883,7 @@ bool Exa_CheckIfEditable (const struct Exa_Exam *Exam) /*****************************************************************************/ // Returns the number of courses with exams in this location -unsigned Exa_GetNumCoursesWithExams (Hie_Level_t Scope) +unsigned Exa_GetNumCoursesWithExams (Hie_Lvl_Level_t Scope) { MYSQL_RES *mysql_res; MYSQL_ROW row; @@ -1892,12 +1892,12 @@ unsigned Exa_GetNumCoursesWithExams (Hie_Level_t Scope) /***** Get number of courses with exams from database *****/ switch (Scope) { - case Hie_SYS: + case Hie_Lvl_SYS: DB_QuerySELECT (&mysql_res,"can not get number of courses with exams", "SELECT COUNT(DISTINCT CrsCod)" " FROM exa_exams"); break; - case Hie_CTY: + case Hie_Lvl_CTY: DB_QuerySELECT (&mysql_res,"can not get number of courses with exams", "SELECT COUNT(DISTINCT exa_exams.CrsCod)" " FROM institutions,centres,degrees,courses,exa_exams" @@ -1908,7 +1908,7 @@ unsigned Exa_GetNumCoursesWithExams (Hie_Level_t Scope) " AND courses.CrsCod=exa_exams.CrsCod", Gbl.Hierarchy.Ins.InsCod); break; - case Hie_INS: + case Hie_Lvl_INS: DB_QuerySELECT (&mysql_res,"can not get number of courses with exams", "SELECT COUNT(DISTINCT exa_exams.CrsCod)" " FROM centres,degrees,courses,exa_exams" @@ -1918,7 +1918,7 @@ unsigned Exa_GetNumCoursesWithExams (Hie_Level_t Scope) " AND courses.CrsCod=exa_exams.CrsCod", Gbl.Hierarchy.Ins.InsCod); break; - case Hie_CTR: + case Hie_Lvl_CTR: DB_QuerySELECT (&mysql_res,"can not get number of courses with exams", "SELECT COUNT(DISTINCT exa_exams.CrsCod)" " FROM degrees,courses,exa_exams" @@ -1927,7 +1927,7 @@ unsigned Exa_GetNumCoursesWithExams (Hie_Level_t Scope) " AND courses.CrsCod=exa_exams.CrsCod", Gbl.Hierarchy.Ctr.CtrCod); break; - case Hie_DEG: + case Hie_Lvl_DEG: DB_QuerySELECT (&mysql_res,"can not get number of courses with exams", "SELECT COUNT(DISTINCT exa_exams.CrsCod)" " FROM courses,exa_exams" @@ -1935,7 +1935,7 @@ unsigned Exa_GetNumCoursesWithExams (Hie_Level_t Scope) " AND courses.CrsCod=exa_exams.CrsCod", Gbl.Hierarchy.Deg.DegCod); break; - case Hie_CRS: + case Hie_Lvl_CRS: DB_QuerySELECT (&mysql_res,"can not get number of courses with exams", "SELECT COUNT(DISTINCT CrsCod)" " FROM exa_exams" @@ -1963,7 +1963,7 @@ unsigned Exa_GetNumCoursesWithExams (Hie_Level_t Scope) /*****************************************************************************/ // Returns the number of exams in this location -unsigned Exa_GetNumExams (Hie_Level_t Scope) +unsigned Exa_GetNumExams (Hie_Lvl_Level_t Scope) { MYSQL_RES *mysql_res; MYSQL_ROW row; @@ -1972,12 +1972,12 @@ unsigned Exa_GetNumExams (Hie_Level_t Scope) /***** Get number of exams from database *****/ switch (Scope) { - case Hie_SYS: + case Hie_Lvl_SYS: DB_QuerySELECT (&mysql_res,"can not get number of exams", "SELECT COUNT(*)" " FROM exa_exams"); break; - case Hie_CTY: + case Hie_Lvl_CTY: DB_QuerySELECT (&mysql_res,"can not get number of exams", "SELECT COUNT(*)" " FROM institutions,centres,degrees,courses,exa_exams" @@ -1988,7 +1988,7 @@ unsigned Exa_GetNumExams (Hie_Level_t Scope) " AND courses.CrsCod=exa_exams.CrsCod", Gbl.Hierarchy.Cty.CtyCod); break; - case Hie_INS: + case Hie_Lvl_INS: DB_QuerySELECT (&mysql_res,"can not get number of exams", "SELECT COUNT(*)" " FROM centres,degrees,courses,exa_exams" @@ -1998,7 +1998,7 @@ unsigned Exa_GetNumExams (Hie_Level_t Scope) " AND courses.CrsCod=exa_exams.CrsCod", Gbl.Hierarchy.Ins.InsCod); break; - case Hie_CTR: + case Hie_Lvl_CTR: DB_QuerySELECT (&mysql_res,"can not get number of exams", "SELECT COUNT(*)" " FROM degrees,courses,exa_exams" @@ -2007,7 +2007,7 @@ unsigned Exa_GetNumExams (Hie_Level_t Scope) " AND courses.CrsCod=exa_exams.CrsCod", Gbl.Hierarchy.Ctr.CtrCod); break; - case Hie_DEG: + case Hie_Lvl_DEG: DB_QuerySELECT (&mysql_res,"can not get number of exams", "SELECT COUNT(*)" " FROM courses,exa_exams" @@ -2015,7 +2015,7 @@ unsigned Exa_GetNumExams (Hie_Level_t Scope) " AND courses.CrsCod=exa_exams.CrsCod", Gbl.Hierarchy.Deg.DegCod); break; - case Hie_CRS: + case Hie_Lvl_CRS: DB_QuerySELECT (&mysql_res,"can not get number of exams", "SELECT COUNT(*)" " FROM exa_exams" @@ -2042,7 +2042,7 @@ unsigned Exa_GetNumExams (Hie_Level_t Scope) /************* Get average number of questions per course exam ***************/ /*****************************************************************************/ -double Exa_GetNumQstsPerCrsExam (Hie_Level_t Scope) +double Exa_GetNumQstsPerCrsExam (Hie_Lvl_Level_t Scope) { MYSQL_RES *mysql_res; MYSQL_ROW row; @@ -2051,7 +2051,7 @@ double Exa_GetNumQstsPerCrsExam (Hie_Level_t Scope) /***** Get number of questions per exam from database *****/ switch (Scope) { - case Hie_SYS: + case Hie_Lvl_SYS: DB_QuerySELECT (&mysql_res,"can not get number of questions per exam", "SELECT AVG(NumQsts) FROM" " (SELECT COUNT(exa_set_questions.QstCod) AS NumQsts" @@ -2059,7 +2059,7 @@ double Exa_GetNumQstsPerCrsExam (Hie_Level_t Scope) " WHERE exa_exams.ExaCod=exa_set_questions.ExaCod" " GROUP BY exa_set_questions.ExaCod) AS NumQstsTable"); break; - case Hie_CTY: + case Hie_Lvl_CTY: DB_QuerySELECT (&mysql_res,"can not get number of questions per exam", "SELECT AVG(NumQsts) FROM" " (SELECT COUNT(exa_set_questions.QstCod) AS NumQsts" @@ -2073,7 +2073,7 @@ double Exa_GetNumQstsPerCrsExam (Hie_Level_t Scope) " GROUP BY exa_set_questions.ExaCod) AS NumQstsTable", Gbl.Hierarchy.Cty.CtyCod); break; - case Hie_INS: + case Hie_Lvl_INS: DB_QuerySELECT (&mysql_res,"can not get number of questions per exam", "SELECT AVG(NumQsts) FROM" " (SELECT COUNT(exa_set_questions.QstCod) AS NumQsts" @@ -2086,7 +2086,7 @@ double Exa_GetNumQstsPerCrsExam (Hie_Level_t Scope) " GROUP BY exa_set_questions.ExaCod) AS NumQstsTable", Gbl.Hierarchy.Ins.InsCod); break; - case Hie_CTR: + case Hie_Lvl_CTR: DB_QuerySELECT (&mysql_res,"can not get number of questions per exam", "SELECT AVG(NumQsts) FROM" " (SELECT COUNT(exa_set_questions.QstCod) AS NumQsts" @@ -2098,7 +2098,7 @@ double Exa_GetNumQstsPerCrsExam (Hie_Level_t Scope) " GROUP BY exa_set_questions.ExaCod) AS NumQstsTable", Gbl.Hierarchy.Ctr.CtrCod); break; - case Hie_DEG: + case Hie_Lvl_DEG: DB_QuerySELECT (&mysql_res,"can not get number of questions per exam", "SELECT AVG(NumQsts) FROM" " (SELECT COUNT(exa_set_questions.QstCod) AS NumQsts" @@ -2109,7 +2109,7 @@ double Exa_GetNumQstsPerCrsExam (Hie_Level_t Scope) " GROUP BY exa_set_questions.ExaCod) AS NumQstsTable", Gbl.Hierarchy.Deg.DegCod); break; - case Hie_CRS: + case Hie_Lvl_CRS: DB_QuerySELECT (&mysql_res,"can not get number of questions per exam", "SELECT AVG(NumQsts) FROM" " (SELECT COUNT(exa_set_questions.QstCod) AS NumQsts" diff --git a/swad_exam.h b/swad_exam.h index 0d2dc872..bc70285f 100644 --- a/swad_exam.h +++ b/swad_exam.h @@ -98,9 +98,9 @@ unsigned Exa_GetNextQuestionIndexInExam (long ExaCod,unsigned QstInd); bool Exa_CheckIfEditable (const struct Exa_Exam *Exam); -unsigned Exa_GetNumCoursesWithExams (Hie_Level_t Scope); -unsigned Exa_GetNumExams (Hie_Level_t Scope); -double Exa_GetNumQstsPerCrsExam (Hie_Level_t Scope); +unsigned Exa_GetNumCoursesWithExams (Hie_Lvl_Level_t Scope); +unsigned Exa_GetNumExams (Hie_Lvl_Level_t Scope); +double Exa_GetNumQstsPerCrsExam (Hie_Lvl_Level_t Scope); void Exa_GetScoreRange (long ExaCod,double *MinScore,double *MaxScore); diff --git a/swad_exam_announcement.c b/swad_exam_announcement.c index f25fc9df..872aa27e 100644 --- a/swad_exam_announcement.c +++ b/swad_exam_announcement.c @@ -187,11 +187,11 @@ static long ExaAnn_GetParamsExamAnn (struct ExaAnn_ExamAnnouncements *ExamAnns) ExaCod = ExaAnn_GetParamExaCod (); /***** Get the name of the course (it is allowed to be different from the official name of the course) *****/ - Par_GetParToText ("CrsName",ExamAnns->ExamAnn.CrsFullName,Hie_MAX_BYTES_FULL_NAME); + Par_GetParToText ("CrsName",ExamAnns->ExamAnn.CrsFullName,Cns_HIERARCHY_MAX_BYTES_FULL_NAME); // If the parameter is not present or is empty, initialize the string to the full name of the current course if (!ExamAnns->ExamAnn.CrsFullName[0]) Str_Copy (ExamAnns->ExamAnn.CrsFullName,Gbl.Hierarchy.Crs.FullName, - Hie_MAX_BYTES_FULL_NAME); + Cns_HIERARCHY_MAX_BYTES_FULL_NAME); /***** Get the year *****/ ExamAnns->ExamAnn.Year = (unsigned) @@ -983,7 +983,7 @@ static void ExaAnn_GetDataExamAnnFromDB (struct ExaAnn_ExamAnnouncements *ExamAn /* Name of the course (row[2]) */ Str_Copy (ExamAnns->ExamAnn.CrsFullName,row[2], - Hie_MAX_BYTES_FULL_NAME); + Cns_HIERARCHY_MAX_BYTES_FULL_NAME); /* Year (row[3]) */ if (sscanf (row[3],"%u",&ExamAnns->ExamAnn.Year) != 1) @@ -1166,7 +1166,7 @@ static void ExaAnn_ShowExamAnn (struct ExaAnn_ExamAnnouncements *ExamAnns, else HTM_A_Begin ("href=\"%s\" target=\"_blank\" class=\"EXAM_TIT\"", Ins.WWW); - Lgo_DrawLogo (Hie_INS,Ins.InsCod,Ins.FullName,64,NULL,true); + Lgo_DrawLogo (Hie_Lvl_INS,Ins.InsCod,Ins.FullName,64,NULL,true); HTM_BR (); HTM_Txt (Ins.FullName); if (TypeViewExamAnnouncement == ExaAnn_PRINT_VIEW) @@ -1217,7 +1217,7 @@ static void ExaAnn_ShowExamAnn (struct ExaAnn_ExamAnnouncements *ExamAnns, /* Data */ HTM_TD_Begin ("class=\"EXAM LB\""); if (TypeViewExamAnnouncement == ExaAnn_FORM_VIEW) - HTM_INPUT_TEXT ("CrsName",Hie_MAX_CHARS_FULL_NAME,ExamAnns->ExamAnn.CrsFullName, + HTM_INPUT_TEXT ("CrsName",Cns_HIERARCHY_MAX_CHARS_FULL_NAME,ExamAnns->ExamAnn.CrsFullName, HTM_DONT_SUBMIT_ON_CHANGE, "id=\"CrsName\" size=\"30\""); else @@ -1703,7 +1703,7 @@ void ExaAnn_GetSummaryAndContentExamAnn (char SummaryStr[Ntf_MAX_BYTES_SUMMARY + { extern const char *Txt_hours_ABBREVIATION; struct ExaAnn_ExamAnnouncements ExamAnns; - char CrsNameAndDate[Hie_MAX_BYTES_FULL_NAME + (2 + Cns_MAX_BYTES_DATE + 7) + 1]; + char CrsNameAndDate[Cns_HIERARCHY_MAX_BYTES_FULL_NAME + (2 + Cns_MAX_BYTES_DATE + 7) + 1]; char StrExamDate[Cns_MAX_BYTES_DATE + 1]; /***** Reset exam announcements context *****/ @@ -1762,9 +1762,9 @@ static void ExaAnn_GetNotifContentExamAnn (const struct ExaAnn_ExamAnnouncements extern const char *Txt_EXAM_ANNOUNCEMENT_Material_allowed; extern const char *Txt_EXAM_ANNOUNCEMENT_Other_information; extern const char *Txt_hours_ABBREVIATION; - struct Crs_Course Crs; - struct Deg_Degree Deg; struct Ins_Instit Ins; + struct Deg_Degree Deg; + struct Crs_Course Crs; char StrExamDate[Cns_MAX_BYTES_DATE + 1]; /***** Get data of course *****/ diff --git a/swad_exam_announcement.h b/swad_exam_announcement.h index 59b2f329..bc25a801 100644 --- a/swad_exam_announcement.h +++ b/swad_exam_announcement.h @@ -62,7 +62,7 @@ struct ExaAnn_ExamAnnouncement { long CrsCod; ExaAnn_Status_t Status; - char CrsFullName[Hie_MAX_BYTES_FULL_NAME + 1]; + char CrsFullName[Cns_HIERARCHY_MAX_BYTES_FULL_NAME + 1]; unsigned Year; // Number of year (0 (N.A.), 1, 2, 3, 4, 5, 6) in the degree char Session[ExaAnn_MAX_BYTES_SESSION + 1]; // Exam session is june, september, etc. struct Date CallDate; diff --git a/swad_exam_type.h b/swad_exam_type.h index 655969e0..55a8accc 100644 --- a/swad_exam_type.h +++ b/swad_exam_type.h @@ -31,7 +31,7 @@ #include // For boolean type #include "swad_date.h" -#include "swad_hierarchy.h" +#include "swad_hierarchy_level.h" #include "swad_string.h" /*****************************************************************************/ diff --git a/swad_figure.c b/swad_figure.c index 1acad273..5e0787e3 100644 --- a/swad_figure.c +++ b/swad_figure.c @@ -40,7 +40,7 @@ #include "swad_form.h" #include "swad_forum.h" #include "swad_global.h" -#include "swad_hierarchy.h" +#include "swad_hierarchy_level.h" #include "swad_HTML.h" #include "swad_institution.h" #include "swad_logo.h" @@ -101,7 +101,7 @@ struct Fig_FiguresForum static void Fig_ReqShowFigure (Fig_FigureType_t SelectedFigureType); static void Fig_PutHiddenParamFigureType (Fig_FigureType_t FigureType); -static void Fig_PutHiddenParamScopeFig (Hie_Level_t ScopeFig); +static void Fig_PutHiddenParamScopeFig (Hie_Lvl_Level_t ScopeFig); static void Fig_GetAndShowHierarchyStats (void); static void Fig_WriteHeadHierarchy (void); @@ -139,7 +139,7 @@ static void Fig_GetAndShowNumUsrsNotBelongingToAnyCrs (void); static void Fig_GetAndShowUsersRanking (void); static void Fig_GetAndShowFileBrowsersStats (void); -static void Fig_GetSizeOfFileZoneFromDB (Hie_Level_t Scope, +static void Fig_GetSizeOfFileZoneFromDB (Hie_Lvl_Level_t Scope, Brw_FileBrowser_t FileBrowser, struct Fig_SizeOfFileZones *SizeOfFileZones); static void Fig_WriteStatsExpTreesTableHead1 (void); @@ -156,7 +156,7 @@ static void Fig_WriteRowStatsFileBrowsers3 (const char *NameOfFileZones, struct Fig_SizeOfFileZones *SizeOfFileZones); static void Fig_GetAndShowOERsStats (void); -static void Fig_GetNumberOfOERsFromDB (Hie_Level_t Scope,Brw_License_t License,unsigned long NumFiles[2]); +static void Fig_GetNumberOfOERsFromDB (Hie_Lvl_Level_t Scope,Brw_License_t License,unsigned long NumFiles[2]); static void Fig_GetAndShowCourseProgramStats (void); // TODO: Change function from assignments to schedule @@ -230,13 +230,13 @@ static void Fig_ReqShowFigure (Fig_FigureType_t SelectedFigureType) /***** Compute stats for anywhere, degree or course? *****/ HTM_LABEL_Begin ("class=\"%s\"",The_ClassFormInBox[Gbl.Prefs.Theme]); HTM_TxtColonNBSP (Txt_Scope); - Gbl.Scope.Allowed = 1 << Hie_SYS | - 1 << Hie_CTY | - 1 << Hie_INS | - 1 << Hie_CTR | - 1 << Hie_DEG | - 1 << Hie_CRS; - Gbl.Scope.Default = Hie_SYS; + Gbl.Scope.Allowed = 1 << Hie_Lvl_SYS | + 1 << Hie_Lvl_CTY | + 1 << Hie_Lvl_INS | + 1 << Hie_Lvl_CTR | + 1 << Hie_Lvl_DEG | + 1 << Hie_Lvl_CRS; + Gbl.Scope.Default = Hie_Lvl_SYS; Sco_GetScope ("ScopeFig"); Sco_PutSelectorScope ("ScopeFig",HTM_DONT_SUBMIT_ON_CHANGE); HTM_LABEL_End (); @@ -276,7 +276,7 @@ void Fig_PutIconToShowFigure (Fig_FigureType_t FigureType) struct Fig_Figures Figures; /***** Set default scope (used only if Gbl.Scope.Current is unknown) *****/ - Gbl.Scope.Default = Hie_CRS; + Gbl.Scope.Default = Hie_Lvl_CRS; Sco_AdjustScope (); /***** Put icon to show figure *****/ @@ -314,7 +314,7 @@ static void Fig_PutHiddenParamFigureType (Fig_FigureType_t FigureType) /********* Put hidden parameter for the type of figure (statistic) ***********/ /*****************************************************************************/ -static void Fig_PutHiddenParamScopeFig (Hie_Level_t ScopeFig) +static void Fig_PutHiddenParamScopeFig (Hie_Lvl_Level_t ScopeFig) { Sco_PutParamScope ("ScopeFig",ScopeFig); } @@ -426,11 +426,11 @@ static void Fig_GetAndShowNumUsrsInCrss (Rol_Role_t Role) { extern const char *Txt_Total; extern const char *Txt_ROLES_PLURAL_Abc[Rol_NUM_ROLES][Usr_NUM_SEXS]; - long Cod = (Gbl.Scope.Current == Hie_CTY ? Gbl.Hierarchy.Cty.CtyCod : - (Gbl.Scope.Current == Hie_INS ? Gbl.Hierarchy.Ins.InsCod : - (Gbl.Scope.Current == Hie_CTR ? Gbl.Hierarchy.Ctr.CtrCod : - (Gbl.Scope.Current == Hie_DEG ? Gbl.Hierarchy.Deg.DegCod : - (Gbl.Scope.Current == Hie_CRS ? Gbl.Hierarchy.Crs.CrsCod : + long Cod = (Gbl.Scope.Current == Hie_Lvl_CTY ? Gbl.Hierarchy.Cty.CtyCod : + (Gbl.Scope.Current == Hie_Lvl_INS ? Gbl.Hierarchy.Ins.InsCod : + (Gbl.Scope.Current == Hie_Lvl_CTR ? Gbl.Hierarchy.Ctr.CtrCod : + (Gbl.Scope.Current == Hie_Lvl_DEG ? Gbl.Hierarchy.Deg.DegCod : + (Gbl.Scope.Current == Hie_Lvl_CRS ? Gbl.Hierarchy.Crs.CrsCod : -1L))))); char *Class = (Role == Rol_UNK) ? "DAT_N LINE_TOP RB" : "DAT RB"; @@ -658,14 +658,14 @@ static void Fig_GetAndShowHierarchyWithInss (void) /***** Get number of elements with institutions *****/ switch (Gbl.Scope.Current) { - case Hie_SYS: + case Hie_Lvl_SYS: NumCtysWithInss = Cty_GetCachedNumCtysWithInss (); break; - case Hie_CTY: - case Hie_INS: - case Hie_CTR: - case Hie_DEG: - case Hie_CRS: + case Hie_Lvl_CTY: + case Hie_Lvl_INS: + case Hie_Lvl_CTR: + case Hie_Lvl_DEG: + case Hie_Lvl_CRS: break; default: Lay_WrongScopeExit (); @@ -697,18 +697,18 @@ static void Fig_GetAndShowHierarchyWithCtrs (void) /***** Get number of elements with centres *****/ switch (Gbl.Scope.Current) { - case Hie_SYS: + case Hie_Lvl_SYS: NumCtysWithCtrs = Cty_GetCachedNumCtysWithCtrs (); - NumInssWithCtrs = Ins_GetCachedNumInssWithCtrs ("",Hie_SYS,-1L); + NumInssWithCtrs = Ins_GetCachedNumInssWithCtrs ("",Hie_Lvl_SYS,-1L); break; - case Hie_CTY: + case Hie_Lvl_CTY: sprintf (SubQuery,"institutions.CtyCod=%ld AND ",Gbl.Hierarchy.Cty.CtyCod); - NumInssWithCtrs = Ins_GetCachedNumInssWithCtrs (SubQuery,Hie_CTY,Gbl.Hierarchy.Cty.CtyCod); + NumInssWithCtrs = Ins_GetCachedNumInssWithCtrs (SubQuery,Hie_Lvl_CTY,Gbl.Hierarchy.Cty.CtyCod); break; - case Hie_INS: - case Hie_CTR: - case Hie_DEG: - case Hie_CRS: + case Hie_Lvl_INS: + case Hie_Lvl_CTR: + case Hie_Lvl_DEG: + case Hie_Lvl_CRS: break; default: Lay_WrongScopeExit (); @@ -741,23 +741,23 @@ static void Fig_GetAndShowHierarchyWithDegs (void) /***** Get number of elements with degrees *****/ switch (Gbl.Scope.Current) { - case Hie_SYS: + case Hie_Lvl_SYS: NumCtysWithDegs = Cty_GetCachedNumCtysWithDegs (); - NumInssWithDegs = Ins_GetCachedNumInssWithDegs ("",Hie_SYS,-1L); - NumCtrsWithDegs = Ctr_GetCachedNumCtrsWithDegs ("",Hie_SYS,-1L); + NumInssWithDegs = Ins_GetCachedNumInssWithDegs ("",Hie_Lvl_SYS,-1L); + NumCtrsWithDegs = Ctr_GetCachedNumCtrsWithDegs ("",Hie_Lvl_SYS,-1L); break; - case Hie_CTY: + case Hie_Lvl_CTY: sprintf (SubQuery,"institutions.CtyCod=%ld AND ",Gbl.Hierarchy.Cty.CtyCod); - NumInssWithDegs = Ins_GetCachedNumInssWithDegs (SubQuery,Hie_CTY,Gbl.Hierarchy.Cty.CtyCod); - NumCtrsWithDegs = Ctr_GetCachedNumCtrsWithDegs (SubQuery,Hie_CTY,Gbl.Hierarchy.Cty.CtyCod); + NumInssWithDegs = Ins_GetCachedNumInssWithDegs (SubQuery,Hie_Lvl_CTY,Gbl.Hierarchy.Cty.CtyCod); + NumCtrsWithDegs = Ctr_GetCachedNumCtrsWithDegs (SubQuery,Hie_Lvl_CTY,Gbl.Hierarchy.Cty.CtyCod); break; - case Hie_INS: + case Hie_Lvl_INS: sprintf (SubQuery,"centres.InsCod=%ld AND ",Gbl.Hierarchy.Ins.InsCod); - NumCtrsWithDegs = Ctr_GetCachedNumCtrsWithDegs (SubQuery,Hie_INS,Gbl.Hierarchy.Ins.InsCod); + NumCtrsWithDegs = Ctr_GetCachedNumCtrsWithDegs (SubQuery,Hie_Lvl_INS,Gbl.Hierarchy.Ins.InsCod); break; - case Hie_CTR: - case Hie_DEG: - case Hie_CRS: + case Hie_Lvl_CTR: + case Hie_Lvl_DEG: + case Hie_Lvl_CRS: break; default: Lay_WrongScopeExit (); @@ -791,29 +791,29 @@ static void Fig_GetAndShowHierarchyWithCrss (void) /***** Get number of elements with courses *****/ switch (Gbl.Scope.Current) { - case Hie_SYS: + case Hie_Lvl_SYS: NumCtysWithCrss = Cty_GetCachedNumCtysWithCrss (); - NumInssWithCrss = Ins_GetCachedNumInssWithCrss ("",Hie_SYS,-1L); - NumCtrsWithCrss = Ctr_GetCachedNumCtrsWithCrss ("",Hie_SYS,-1L); - NumDegsWithCrss = Deg_GetCachedNumDegsWithCrss ("",Hie_SYS,-1L); + NumInssWithCrss = Ins_GetCachedNumInssWithCrss ("",Hie_Lvl_SYS,-1L); + NumCtrsWithCrss = Ctr_GetCachedNumCtrsWithCrss ("",Hie_Lvl_SYS,-1L); + NumDegsWithCrss = Deg_GetCachedNumDegsWithCrss ("",Hie_Lvl_SYS,-1L); break; - case Hie_CTY: + case Hie_Lvl_CTY: sprintf (SubQuery,"institutions.CtyCod=%ld AND ",Gbl.Hierarchy.Cty.CtyCod); - NumInssWithCrss = Ins_GetCachedNumInssWithCrss (SubQuery,Hie_CTY,Gbl.Hierarchy.Cty.CtyCod); - NumCtrsWithCrss = Ctr_GetCachedNumCtrsWithCrss (SubQuery,Hie_CTY,Gbl.Hierarchy.Cty.CtyCod); - NumDegsWithCrss = Deg_GetCachedNumDegsWithCrss (SubQuery,Hie_CTY,Gbl.Hierarchy.Cty.CtyCod); + NumInssWithCrss = Ins_GetCachedNumInssWithCrss (SubQuery,Hie_Lvl_CTY,Gbl.Hierarchy.Cty.CtyCod); + NumCtrsWithCrss = Ctr_GetCachedNumCtrsWithCrss (SubQuery,Hie_Lvl_CTY,Gbl.Hierarchy.Cty.CtyCod); + NumDegsWithCrss = Deg_GetCachedNumDegsWithCrss (SubQuery,Hie_Lvl_CTY,Gbl.Hierarchy.Cty.CtyCod); break; - case Hie_INS: + case Hie_Lvl_INS: sprintf (SubQuery,"centres.InsCod=%ld AND ",Gbl.Hierarchy.Ins.InsCod); - NumCtrsWithCrss = Ctr_GetCachedNumCtrsWithCrss (SubQuery,Hie_INS,Gbl.Hierarchy.Ins.InsCod); - NumDegsWithCrss = Deg_GetCachedNumDegsWithCrss (SubQuery,Hie_INS,Gbl.Hierarchy.Ins.InsCod); + NumCtrsWithCrss = Ctr_GetCachedNumCtrsWithCrss (SubQuery,Hie_Lvl_INS,Gbl.Hierarchy.Ins.InsCod); + NumDegsWithCrss = Deg_GetCachedNumDegsWithCrss (SubQuery,Hie_Lvl_INS,Gbl.Hierarchy.Ins.InsCod); break; - case Hie_CTR: + case Hie_Lvl_CTR: sprintf (SubQuery,"degrees.CtrCod=%ld AND ",Gbl.Hierarchy.Ctr.CtrCod); - NumDegsWithCrss = Deg_GetCachedNumDegsWithCrss (SubQuery,Hie_CTR,Gbl.Hierarchy.Ctr.CtrCod); + NumDegsWithCrss = Deg_GetCachedNumDegsWithCrss (SubQuery,Hie_Lvl_CTR,Gbl.Hierarchy.Ctr.CtrCod); break; - case Hie_DEG: - case Hie_CRS: + case Hie_Lvl_DEG: + case Hie_Lvl_CRS: break; default: Lay_WrongScopeExit (); @@ -848,52 +848,52 @@ static void Fig_GetAndShowHierarchyWithUsrs (Rol_Role_t Role) /***** Get number of elements with students *****/ switch (Gbl.Scope.Current) { - case Hie_SYS: - NumCtysWithUsrs = Cty_GetCachedNumCtysWithUsrs (Role,"",Hie_SYS,-1L); - NumInssWithUsrs = Ins_GetCachedNumInssWithUsrs (Role,"",Hie_SYS,-1L); - NumCtrsWithUsrs = Ctr_GetCachedNumCtrsWithUsrs (Role,"",Hie_SYS,-1L); - NumDegsWithUsrs = Deg_GetCachedNumDegsWithUsrs (Role,"",Hie_SYS,-1L); - NumCrssWithUsrs = Crs_GetCachedNumCrssWithUsrs (Role,"",Hie_SYS,-1L); + case Hie_Lvl_SYS: + NumCtysWithUsrs = Cty_GetCachedNumCtysWithUsrs (Role,"",Hie_Lvl_SYS,-1L); + NumInssWithUsrs = Ins_GetCachedNumInssWithUsrs (Role,"",Hie_Lvl_SYS,-1L); + NumCtrsWithUsrs = Ctr_GetCachedNumCtrsWithUsrs (Role,"",Hie_Lvl_SYS,-1L); + NumDegsWithUsrs = Deg_GetCachedNumDegsWithUsrs (Role,"",Hie_Lvl_SYS,-1L); + NumCrssWithUsrs = Crs_GetCachedNumCrssWithUsrs (Role,"",Hie_Lvl_SYS,-1L); break; - case Hie_CTY: + case Hie_Lvl_CTY: sprintf (SubQuery,"institutions.CtyCod=%ld AND ",Gbl.Hierarchy.Cty.CtyCod); - NumCtysWithUsrs = Cty_GetCachedNumCtysWithUsrs (Role,SubQuery,Hie_CTY,Gbl.Hierarchy.Cty.CtyCod); - NumInssWithUsrs = Ins_GetCachedNumInssWithUsrs (Role,SubQuery,Hie_CTY,Gbl.Hierarchy.Cty.CtyCod); - NumCtrsWithUsrs = Ctr_GetCachedNumCtrsWithUsrs (Role,SubQuery,Hie_CTY,Gbl.Hierarchy.Cty.CtyCod); - NumDegsWithUsrs = Deg_GetCachedNumDegsWithUsrs (Role,SubQuery,Hie_CTY,Gbl.Hierarchy.Cty.CtyCod); - NumCrssWithUsrs = Crs_GetCachedNumCrssWithUsrs (Role,SubQuery,Hie_CTY,Gbl.Hierarchy.Cty.CtyCod); + NumCtysWithUsrs = Cty_GetCachedNumCtysWithUsrs (Role,SubQuery,Hie_Lvl_CTY,Gbl.Hierarchy.Cty.CtyCod); + NumInssWithUsrs = Ins_GetCachedNumInssWithUsrs (Role,SubQuery,Hie_Lvl_CTY,Gbl.Hierarchy.Cty.CtyCod); + NumCtrsWithUsrs = Ctr_GetCachedNumCtrsWithUsrs (Role,SubQuery,Hie_Lvl_CTY,Gbl.Hierarchy.Cty.CtyCod); + NumDegsWithUsrs = Deg_GetCachedNumDegsWithUsrs (Role,SubQuery,Hie_Lvl_CTY,Gbl.Hierarchy.Cty.CtyCod); + NumCrssWithUsrs = Crs_GetCachedNumCrssWithUsrs (Role,SubQuery,Hie_Lvl_CTY,Gbl.Hierarchy.Cty.CtyCod); break; - case Hie_INS: + case Hie_Lvl_INS: sprintf (SubQuery,"centres.InsCod=%ld AND ",Gbl.Hierarchy.Ins.InsCod); - NumCtysWithUsrs = Cty_GetCachedNumCtysWithUsrs (Role,SubQuery,Hie_INS,Gbl.Hierarchy.Ins.InsCod); - NumInssWithUsrs = Ins_GetCachedNumInssWithUsrs (Role,SubQuery,Hie_INS,Gbl.Hierarchy.Ins.InsCod); - NumCtrsWithUsrs = Ctr_GetCachedNumCtrsWithUsrs (Role,SubQuery,Hie_INS,Gbl.Hierarchy.Ins.InsCod); - NumDegsWithUsrs = Deg_GetCachedNumDegsWithUsrs (Role,SubQuery,Hie_INS,Gbl.Hierarchy.Ins.InsCod); - NumCrssWithUsrs = Crs_GetCachedNumCrssWithUsrs (Role,SubQuery,Hie_INS,Gbl.Hierarchy.Ins.InsCod); + NumCtysWithUsrs = Cty_GetCachedNumCtysWithUsrs (Role,SubQuery,Hie_Lvl_INS,Gbl.Hierarchy.Ins.InsCod); + NumInssWithUsrs = Ins_GetCachedNumInssWithUsrs (Role,SubQuery,Hie_Lvl_INS,Gbl.Hierarchy.Ins.InsCod); + NumCtrsWithUsrs = Ctr_GetCachedNumCtrsWithUsrs (Role,SubQuery,Hie_Lvl_INS,Gbl.Hierarchy.Ins.InsCod); + NumDegsWithUsrs = Deg_GetCachedNumDegsWithUsrs (Role,SubQuery,Hie_Lvl_INS,Gbl.Hierarchy.Ins.InsCod); + NumCrssWithUsrs = Crs_GetCachedNumCrssWithUsrs (Role,SubQuery,Hie_Lvl_INS,Gbl.Hierarchy.Ins.InsCod); break; - case Hie_CTR: + case Hie_Lvl_CTR: sprintf (SubQuery,"degrees.CtrCod=%ld AND ",Gbl.Hierarchy.Ctr.CtrCod); - NumCtysWithUsrs = Cty_GetCachedNumCtysWithUsrs (Role,SubQuery,Hie_CTR,Gbl.Hierarchy.Ctr.CtrCod); - NumInssWithUsrs = Ins_GetCachedNumInssWithUsrs (Role,SubQuery,Hie_CTR,Gbl.Hierarchy.Ctr.CtrCod); - NumCtrsWithUsrs = Ctr_GetCachedNumCtrsWithUsrs (Role,SubQuery,Hie_CTR,Gbl.Hierarchy.Ctr.CtrCod); - NumDegsWithUsrs = Deg_GetCachedNumDegsWithUsrs (Role,SubQuery,Hie_CTR,Gbl.Hierarchy.Ctr.CtrCod); - NumCrssWithUsrs = Crs_GetCachedNumCrssWithUsrs (Role,SubQuery,Hie_CTR,Gbl.Hierarchy.Ctr.CtrCod); + NumCtysWithUsrs = Cty_GetCachedNumCtysWithUsrs (Role,SubQuery,Hie_Lvl_CTR,Gbl.Hierarchy.Ctr.CtrCod); + NumInssWithUsrs = Ins_GetCachedNumInssWithUsrs (Role,SubQuery,Hie_Lvl_CTR,Gbl.Hierarchy.Ctr.CtrCod); + NumCtrsWithUsrs = Ctr_GetCachedNumCtrsWithUsrs (Role,SubQuery,Hie_Lvl_CTR,Gbl.Hierarchy.Ctr.CtrCod); + NumDegsWithUsrs = Deg_GetCachedNumDegsWithUsrs (Role,SubQuery,Hie_Lvl_CTR,Gbl.Hierarchy.Ctr.CtrCod); + NumCrssWithUsrs = Crs_GetCachedNumCrssWithUsrs (Role,SubQuery,Hie_Lvl_CTR,Gbl.Hierarchy.Ctr.CtrCod); break; - case Hie_DEG: + case Hie_Lvl_DEG: sprintf (SubQuery,"courses.DegCod=%ld AND ",Gbl.Hierarchy.Deg.DegCod); - NumCtysWithUsrs = Cty_GetCachedNumCtysWithUsrs (Role,SubQuery,Hie_DEG,Gbl.Hierarchy.Deg.DegCod); - NumInssWithUsrs = Ins_GetCachedNumInssWithUsrs (Role,SubQuery,Hie_DEG,Gbl.Hierarchy.Deg.DegCod); - NumCtrsWithUsrs = Ctr_GetCachedNumCtrsWithUsrs (Role,SubQuery,Hie_DEG,Gbl.Hierarchy.Deg.DegCod); - NumDegsWithUsrs = Deg_GetCachedNumDegsWithUsrs (Role,SubQuery,Hie_DEG,Gbl.Hierarchy.Deg.DegCod); - NumCrssWithUsrs = Crs_GetCachedNumCrssWithUsrs (Role,SubQuery,Hie_DEG,Gbl.Hierarchy.Deg.DegCod); + NumCtysWithUsrs = Cty_GetCachedNumCtysWithUsrs (Role,SubQuery,Hie_Lvl_DEG,Gbl.Hierarchy.Deg.DegCod); + NumInssWithUsrs = Ins_GetCachedNumInssWithUsrs (Role,SubQuery,Hie_Lvl_DEG,Gbl.Hierarchy.Deg.DegCod); + NumCtrsWithUsrs = Ctr_GetCachedNumCtrsWithUsrs (Role,SubQuery,Hie_Lvl_DEG,Gbl.Hierarchy.Deg.DegCod); + NumDegsWithUsrs = Deg_GetCachedNumDegsWithUsrs (Role,SubQuery,Hie_Lvl_DEG,Gbl.Hierarchy.Deg.DegCod); + NumCrssWithUsrs = Crs_GetCachedNumCrssWithUsrs (Role,SubQuery,Hie_Lvl_DEG,Gbl.Hierarchy.Deg.DegCod); break; - case Hie_CRS: + case Hie_Lvl_CRS: sprintf (SubQuery,"crs_usr.CrsCod=%ld AND ",Gbl.Hierarchy.Crs.CrsCod); - NumCtysWithUsrs = Cty_GetCachedNumCtysWithUsrs (Role,SubQuery,Hie_CRS,Gbl.Hierarchy.Crs.CrsCod); - NumInssWithUsrs = Ins_GetCachedNumInssWithUsrs (Role,SubQuery,Hie_CRS,Gbl.Hierarchy.Crs.CrsCod); - NumCtrsWithUsrs = Ctr_GetCachedNumCtrsWithUsrs (Role,SubQuery,Hie_CRS,Gbl.Hierarchy.Crs.CrsCod); - NumDegsWithUsrs = Deg_GetCachedNumDegsWithUsrs (Role,SubQuery,Hie_CRS,Gbl.Hierarchy.Crs.CrsCod); - NumCrssWithUsrs = Crs_GetCachedNumCrssWithUsrs (Role,SubQuery,Hie_CRS,Gbl.Hierarchy.Crs.CrsCod); + NumCtysWithUsrs = Cty_GetCachedNumCtysWithUsrs (Role,SubQuery,Hie_Lvl_CRS,Gbl.Hierarchy.Crs.CrsCod); + NumInssWithUsrs = Ins_GetCachedNumInssWithUsrs (Role,SubQuery,Hie_Lvl_CRS,Gbl.Hierarchy.Crs.CrsCod); + NumCtrsWithUsrs = Ctr_GetCachedNumCtrsWithUsrs (Role,SubQuery,Hie_Lvl_CRS,Gbl.Hierarchy.Crs.CrsCod); + NumDegsWithUsrs = Deg_GetCachedNumDegsWithUsrs (Role,SubQuery,Hie_Lvl_CRS,Gbl.Hierarchy.Crs.CrsCod); + NumCrssWithUsrs = Crs_GetCachedNumCrssWithUsrs (Role,SubQuery,Hie_Lvl_CRS,Gbl.Hierarchy.Crs.CrsCod); break; default: Lay_WrongScopeExit (); @@ -926,32 +926,32 @@ static void Fig_GetAndShowHierarchyTotal (void) /***** Get total number of elements *****/ switch (Gbl.Scope.Current) { - case Hie_SYS: + case Hie_Lvl_SYS: NumCtysTotal = Cty_GetCachedNumCtysInSys (); NumInssTotal = Ins_GetCachedNumInssInSys (); NumCtrsTotal = Ctr_GetCachedNumCtrsInSys (); NumDegsTotal = Deg_GetCachedNumDegsInSys (); NumCrssTotal = Crs_GetCachedNumCrssInSys (); break; - case Hie_CTY: + case Hie_Lvl_CTY: NumInssTotal = Ins_GetCachedNumInssInCty (Gbl.Hierarchy.Cty.CtyCod); NumCtrsTotal = Ctr_GetCachedNumCtrsInCty (Gbl.Hierarchy.Cty.CtyCod); NumDegsTotal = Deg_GetCachedNumDegsInCty (Gbl.Hierarchy.Cty.CtyCod); NumCrssTotal = Crs_GetCachedNumCrssInCty (Gbl.Hierarchy.Cty.CtyCod); break; - case Hie_INS: + case Hie_Lvl_INS: NumCtrsTotal = Ctr_GetCachedNumCtrsInIns (Gbl.Hierarchy.Ins.InsCod); NumDegsTotal = Deg_GetCachedNumDegsInIns (Gbl.Hierarchy.Ins.InsCod); NumCrssTotal = Crs_GetCachedNumCrssInIns (Gbl.Hierarchy.Ins.InsCod); break; - case Hie_CTR: + case Hie_Lvl_CTR: NumDegsTotal = Deg_GetCachedNumDegsInCtr (Gbl.Hierarchy.Ctr.CtrCod); NumCrssTotal = Crs_GetCachedNumCrssInCtr (Gbl.Hierarchy.Ctr.CtrCod); break; - case Hie_DEG: + case Hie_Lvl_DEG: NumCrssTotal = Crs_GetCachedNumCrssInDeg (Gbl.Hierarchy.Deg.DegCod); break; - case Hie_CRS: + case Hie_Lvl_CRS: break; default: Lay_WrongScopeExit (); @@ -1070,7 +1070,7 @@ static void Fig_GetAndShowInssOrderedByNumCtrs (void) /***** Get institutions ordered by number of centres *****/ switch (Gbl.Scope.Current) { - case Hie_SYS: + case Hie_Lvl_SYS: NumInss = (unsigned) DB_QuerySELECT (&mysql_res,"can not get institutions", "SELECT InsCod,COUNT(*) AS N" @@ -1078,7 +1078,7 @@ static void Fig_GetAndShowInssOrderedByNumCtrs (void) " GROUP BY InsCod" " ORDER BY N DESC"); break; - case Hie_CTY: + case Hie_Lvl_CTY: NumInss = (unsigned) DB_QuerySELECT (&mysql_res,"can not get institutions", "SELECT centres.InsCod,COUNT(*) AS N" @@ -1089,10 +1089,10 @@ static void Fig_GetAndShowInssOrderedByNumCtrs (void) " ORDER BY N DESC", Gbl.Hierarchy.Cty.CtyCod); break; - case Hie_INS: - case Hie_CTR: - case Hie_DEG: - case Hie_CRS: + case Hie_Lvl_INS: + case Hie_Lvl_CTR: + case Hie_Lvl_DEG: + case Hie_Lvl_CRS: NumInss = (unsigned) DB_QuerySELECT (&mysql_res,"can not get institutions", "SELECT InsCod,COUNT(*) AS N" @@ -1136,7 +1136,7 @@ static void Fig_GetAndShowInssOrderedByNumDegs (void) /***** Get institutions ordered by number of degrees *****/ switch (Gbl.Scope.Current) { - case Hie_SYS: + case Hie_Lvl_SYS: NumInss = (unsigned) DB_QuerySELECT (&mysql_res,"can not get institutions", "SELECT centres.InsCod,COUNT(*) AS N" @@ -1145,7 +1145,7 @@ static void Fig_GetAndShowInssOrderedByNumDegs (void) " GROUP BY InsCod" " ORDER BY N DESC"); break; - case Hie_CTY: + case Hie_Lvl_CTY: NumInss = (unsigned) DB_QuerySELECT (&mysql_res,"can not get institutions", "SELECT centres.InsCod,COUNT(*) AS N" @@ -1157,10 +1157,10 @@ static void Fig_GetAndShowInssOrderedByNumDegs (void) " ORDER BY N DESC", Gbl.Hierarchy.Cty.CtyCod); break; - case Hie_INS: - case Hie_CTR: - case Hie_DEG: - case Hie_CRS: + case Hie_Lvl_INS: + case Hie_Lvl_CTR: + case Hie_Lvl_DEG: + case Hie_Lvl_CRS: NumInss = (unsigned) DB_QuerySELECT (&mysql_res,"can not get institutions", "SELECT centres.InsCod,COUNT(*) AS N" @@ -1205,7 +1205,7 @@ static void Fig_GetAndShowInssOrderedByNumCrss (void) /***** Get institutions ordered by number of courses *****/ switch (Gbl.Scope.Current) { - case Hie_SYS: + case Hie_Lvl_SYS: NumInss = (unsigned) DB_QuerySELECT (&mysql_res,"can not get institutions", "SELECT centres.InsCod,COUNT(*) AS N" @@ -1215,7 +1215,7 @@ static void Fig_GetAndShowInssOrderedByNumCrss (void) " GROUP BY InsCod" " ORDER BY N DESC"); break; - case Hie_CTY: + case Hie_Lvl_CTY: NumInss = (unsigned) DB_QuerySELECT (&mysql_res,"can not get institutions", "SELECT centres.InsCod,COUNT(*) AS N" @@ -1228,10 +1228,10 @@ static void Fig_GetAndShowInssOrderedByNumCrss (void) " ORDER BY N DESC", Gbl.Hierarchy.Cty.CtyCod); break; - case Hie_INS: - case Hie_CTR: - case Hie_DEG: - case Hie_CRS: + case Hie_Lvl_INS: + case Hie_Lvl_CTR: + case Hie_Lvl_DEG: + case Hie_Lvl_CRS: NumInss = (unsigned) DB_QuerySELECT (&mysql_res,"can not get institutions", "SELECT centres.InsCod,COUNT(*) AS N" @@ -1277,7 +1277,7 @@ static void Fig_GetAndShowInssOrderedByNumUsrsInCrss (void) /***** Get institutions ordered by number of users in courses *****/ switch (Gbl.Scope.Current) { - case Hie_SYS: + case Hie_Lvl_SYS: NumInss = (unsigned) DB_QuerySELECT (&mysql_res,"can not get institutions", "SELECT centres.InsCod,COUNT(DISTINCT crs_usr.UsrCod) AS N" @@ -1288,7 +1288,7 @@ static void Fig_GetAndShowInssOrderedByNumUsrsInCrss (void) " GROUP BY InsCod" " ORDER BY N DESC"); break; - case Hie_CTY: + case Hie_Lvl_CTY: NumInss = (unsigned) DB_QuerySELECT (&mysql_res,"can not get institutions", "SELECT centres.InsCod,COUNT(DISTINCT crs_usr.UsrCod) AS N" @@ -1302,10 +1302,10 @@ static void Fig_GetAndShowInssOrderedByNumUsrsInCrss (void) " ORDER BY N DESC", Gbl.Hierarchy.Cty.CtyCod); break; - case Hie_INS: - case Hie_CTR: - case Hie_DEG: - case Hie_CRS: + case Hie_Lvl_INS: + case Hie_Lvl_CTR: + case Hie_Lvl_DEG: + case Hie_Lvl_CRS: NumInss = (unsigned) DB_QuerySELECT (&mysql_res,"can not get institutions", "SELECT centres.InsCod,COUNT(DISTINCT crs_usr.UsrCod) AS N" @@ -1353,7 +1353,7 @@ static void Fig_GetAndShowInssOrderedByNumUsrsWhoClaimToBelongToThem (void) /***** Get institutions ordered by number of users who claim to belong to them *****/ switch (Gbl.Scope.Current) { - case Hie_SYS: + case Hie_Lvl_SYS: NumInss = (unsigned) DB_QuerySELECT (&mysql_res,"can not get institutions", "SELECT InsCod,COUNT(*) AS N" @@ -1362,7 +1362,7 @@ static void Fig_GetAndShowInssOrderedByNumUsrsWhoClaimToBelongToThem (void) " GROUP BY InsCod" " ORDER BY N DESC"); break; - case Hie_CTY: + case Hie_Lvl_CTY: NumInss = (unsigned) DB_QuerySELECT (&mysql_res,"can not get institutions", "SELECT usr_data.InsCod,COUNT(*) AS N" @@ -1373,10 +1373,10 @@ static void Fig_GetAndShowInssOrderedByNumUsrsWhoClaimToBelongToThem (void) " ORDER BY N DESC", Gbl.Hierarchy.Cty.CtyCod); break; - case Hie_INS: - case Hie_CTR: - case Hie_DEG: - case Hie_CRS: + case Hie_Lvl_INS: + case Hie_Lvl_CTR: + case Hie_Lvl_DEG: + case Hie_Lvl_CRS: NumInss = (unsigned) DB_QuerySELECT (&mysql_res,"can not get institutions", "SELECT InsCod,COUNT(*) AS N" @@ -1492,7 +1492,7 @@ static void Fig_ShowInss (MYSQL_RES **mysql_res,unsigned NumInss, HTM_BUTTON_SUBMIT_Begin (Ins.ShrtName,The_ClassFormLinkInBox[Gbl.Prefs.Theme],NULL); if (Gbl.Usrs.Listing.WithPhotos) { - Lgo_DrawLogo (Hie_INS,Ins.InsCod,Ins.ShrtName, + Lgo_DrawLogo (Hie_Lvl_INS,Ins.InsCod,Ins.ShrtName, 40,NULL,true); HTM_NBSP (); } @@ -1633,7 +1633,7 @@ static void Fig_GetAndShowFileBrowsersStats (void) /**************** Get the size of a file zone from database ******************/ /*****************************************************************************/ -static void Fig_GetSizeOfFileZoneFromDB (Hie_Level_t Scope, +static void Fig_GetSizeOfFileZoneFromDB (Hie_Lvl_Level_t Scope, Brw_FileBrowser_t FileBrowser, struct Fig_SizeOfFileZones *SizeOfFileZones) { @@ -1644,7 +1644,7 @@ static void Fig_GetSizeOfFileZoneFromDB (Hie_Level_t Scope, switch (Scope) { /* Scope = the whole platform */ - case Hie_SYS: + case Hie_Lvl_SYS: switch (FileBrowser) { case Brw_UNKNOWN: @@ -1756,7 +1756,7 @@ static void Fig_GetSizeOfFileZoneFromDB (Hie_Level_t Scope, } break; /* Scope = the current country */ - case Hie_CTY: + case Hie_Lvl_CTY: switch (FileBrowser) { case Brw_UNKNOWN: @@ -1901,7 +1901,7 @@ static void Fig_GetSizeOfFileZoneFromDB (Hie_Level_t Scope, } break; /* Scope = the current institution */ - case Hie_INS: + case Hie_Lvl_INS: switch (FileBrowser) { case Brw_UNKNOWN: @@ -2040,7 +2040,7 @@ static void Fig_GetSizeOfFileZoneFromDB (Hie_Level_t Scope, } break; /* Scope = the current centre */ - case Hie_CTR: + case Hie_Lvl_CTR: switch (FileBrowser) { case Brw_UNKNOWN: @@ -2173,7 +2173,7 @@ static void Fig_GetSizeOfFileZoneFromDB (Hie_Level_t Scope, } break; /* Scope = the current degree */ - case Hie_DEG: + case Hie_Lvl_DEG: switch (FileBrowser) { case Brw_UNKNOWN: @@ -2300,7 +2300,7 @@ static void Fig_GetSizeOfFileZoneFromDB (Hie_Level_t Scope, } break; /* Scope = the current course */ - case Hie_CRS: + case Hie_Lvl_CRS: switch (FileBrowser) { case Brw_UNKNOWN: @@ -2820,7 +2820,7 @@ static void Fig_GetAndShowOERsStats (void) /**************** Get the size of a file zone from database ******************/ /*****************************************************************************/ -static void Fig_GetNumberOfOERsFromDB (Hie_Level_t Scope,Brw_License_t License,unsigned long NumFiles[2]) +static void Fig_GetNumberOfOERsFromDB (Hie_Lvl_Level_t Scope,Brw_License_t License,unsigned long NumFiles[2]) { MYSQL_RES *mysql_res; MYSQL_ROW row; @@ -2831,7 +2831,7 @@ static void Fig_GetNumberOfOERsFromDB (Hie_Level_t Scope,Brw_License_t License,u /***** Get the size of a file browser *****/ switch (Scope) { - case Hie_SYS: + case Hie_Lvl_SYS: NumRows = (unsigned) DB_QuerySELECT (&mysql_res,"can not get number of OERs", "SELECT Public,COUNT(*)" @@ -2840,7 +2840,7 @@ static void Fig_GetNumberOfOERsFromDB (Hie_Level_t Scope,Brw_License_t License,u " GROUP BY Public", (unsigned) License); break; - case Hie_CTY: + case Hie_Lvl_CTY: NumRows = (unsigned) DB_QuerySELECT (&mysql_res,"can not get number of OERs", "SELECT files.Public,COUNT(*)" @@ -2858,7 +2858,7 @@ static void Fig_GetNumberOfOERsFromDB (Hie_Level_t Scope,Brw_License_t License,u (unsigned) Brw_ADMI_SHR_CRS, (unsigned) License); break; - case Hie_INS: + case Hie_Lvl_INS: NumRows = (unsigned) DB_QuerySELECT (&mysql_res,"can not get number of OERs", "SELECT files.Public,COUNT(*)" @@ -2875,7 +2875,7 @@ static void Fig_GetNumberOfOERsFromDB (Hie_Level_t Scope,Brw_License_t License,u (unsigned) Brw_ADMI_SHR_CRS, (unsigned) License); break; - case Hie_CTR: + case Hie_Lvl_CTR: NumRows = (unsigned) DB_QuerySELECT (&mysql_res,"can not get number of OERs", "SELECT files.Public,COUNT(*)" @@ -2891,7 +2891,7 @@ static void Fig_GetNumberOfOERsFromDB (Hie_Level_t Scope,Brw_License_t License,u (unsigned) Brw_ADMI_SHR_CRS, (unsigned) License); break; - case Hie_DEG: + case Hie_Lvl_DEG: NumRows = (unsigned) DB_QuerySELECT (&mysql_res,"can not get number of OERs", "SELECT files.Public,COUNT(*)" @@ -2906,7 +2906,7 @@ static void Fig_GetNumberOfOERsFromDB (Hie_Level_t Scope,Brw_License_t License,u (unsigned) Brw_ADMI_SHR_CRS, (unsigned) License); break; - case Hie_CRS: + case Hie_Lvl_CRS: NumRows = (unsigned) DB_QuerySELECT (&mysql_res,"can not get number of OERs", "SELECT Public,COUNT(*)" @@ -3421,13 +3421,13 @@ static void Fig_GetAndShowTimelineActivityStats (void) /***** Get total number of users *****/ NumUsrsTotal = - (Gbl.Scope.Current == Hie_SYS) ? Usr_GetTotalNumberOfUsersInPlatform () : + (Gbl.Scope.Current == Hie_Lvl_SYS) ? Usr_GetTotalNumberOfUsersInPlatform () : Usr_GetCachedNumUsrsInCrss (Gbl.Scope.Current, - (Gbl.Scope.Current == Hie_CTY ? Gbl.Hierarchy.Cty.CtyCod : - (Gbl.Scope.Current == Hie_INS ? Gbl.Hierarchy.Ins.InsCod : - (Gbl.Scope.Current == Hie_CTR ? Gbl.Hierarchy.Ctr.CtrCod : - (Gbl.Scope.Current == Hie_DEG ? Gbl.Hierarchy.Deg.DegCod : - (Gbl.Scope.Current == Hie_CRS ? Gbl.Hierarchy.Crs.CrsCod : + (Gbl.Scope.Current == Hie_Lvl_CTY ? Gbl.Hierarchy.Cty.CtyCod : + (Gbl.Scope.Current == Hie_Lvl_INS ? Gbl.Hierarchy.Ins.InsCod : + (Gbl.Scope.Current == Hie_Lvl_CTR ? Gbl.Hierarchy.Ctr.CtrCod : + (Gbl.Scope.Current == Hie_Lvl_DEG ? Gbl.Hierarchy.Deg.DegCod : + (Gbl.Scope.Current == Hie_Lvl_CRS ? Gbl.Hierarchy.Crs.CrsCod : -1L))))), 1 << Rol_STD | 1 << Rol_NET | @@ -3440,14 +3440,14 @@ static void Fig_GetAndShowTimelineActivityStats (void) { switch (Gbl.Scope.Current) { - case Hie_SYS: + case Hie_Lvl_SYS: NumRows = DB_QuerySELECT (&mysql_res,"can not get number of social notes", "SELECT COUNT(*)," "COUNT(DISTINCT UsrCod)" " FROM tl_notes WHERE NoteType=%u", NoteType); break; - case Hie_CTY: + case Hie_Lvl_CTY: NumRows = DB_QuerySELECT (&mysql_res,"can not get number of social notes", "SELECT COUNT(DISTINCT tl_notes.NotCod)," "COUNT(DISTINCT tl_notes.UsrCod)" @@ -3462,7 +3462,7 @@ static void Fig_GetAndShowTimelineActivityStats (void) Gbl.Hierarchy.Cty.CtyCod, (unsigned) NoteType); break; - case Hie_INS: + case Hie_Lvl_INS: NumRows = DB_QuerySELECT (&mysql_res,"can not get number of social notes", "SELECT COUNT(DISTINCT tl_notes.NotCod)," "COUNT(DISTINCT tl_notes.UsrCod)" @@ -3476,7 +3476,7 @@ static void Fig_GetAndShowTimelineActivityStats (void) Gbl.Hierarchy.Ins.InsCod, (unsigned) NoteType); break; - case Hie_CTR: + case Hie_Lvl_CTR: NumRows = DB_QuerySELECT (&mysql_res,"can not get number of social notes", "SELECT COUNT(DISTINCT tl_notes.NotCod)," "COUNT(DISTINCT tl_notes.UsrCod)" @@ -3489,7 +3489,7 @@ static void Fig_GetAndShowTimelineActivityStats (void) Gbl.Hierarchy.Ctr.CtrCod, (unsigned) NoteType); break; - case Hie_DEG: + case Hie_Lvl_DEG: NumRows = DB_QuerySELECT (&mysql_res,"can not get number of social notes", "SELECT COUNT(DISTINCT tl_notes.NotCod)," "COUNT(DISTINCT tl_notes.UsrCod)" @@ -3501,7 +3501,7 @@ static void Fig_GetAndShowTimelineActivityStats (void) Gbl.Hierarchy.Deg.DegCod, (unsigned) NoteType); break; - case Hie_CRS: + case Hie_Lvl_CRS: NumRows = DB_QuerySELECT (&mysql_res,"can not get number of social notes", "SELECT COUNT(DISTINCT tl_notes.NotCod)," "COUNT(DISTINCT tl_notes.UsrCod)" @@ -3571,13 +3571,13 @@ static void Fig_GetAndShowTimelineActivityStats (void) /***** Get and write totals *****/ switch (Gbl.Scope.Current) { - case Hie_SYS: + case Hie_Lvl_SYS: NumRows = DB_QuerySELECT (&mysql_res,"can not get number of social notes", "SELECT COUNT(*)," "COUNT(DISTINCT UsrCod)" " FROM tl_notes"); break; - case Hie_CTY: + case Hie_Lvl_CTY: NumRows = DB_QuerySELECT (&mysql_res,"can not get number of social notes", "SELECT COUNT(DISTINCT tl_notes.NotCod)," "COUNT(DISTINCT tl_notes.UsrCod)" @@ -3590,7 +3590,7 @@ static void Fig_GetAndShowTimelineActivityStats (void) " AND crs_usr.UsrCod=tl_notes.UsrCod", Gbl.Hierarchy.Cty.CtyCod); break; - case Hie_INS: + case Hie_Lvl_INS: NumRows = DB_QuerySELECT (&mysql_res,"can not get number of social notes", "SELECT COUNT(DISTINCT tl_notes.NotCod)," "COUNT(DISTINCT tl_notes.UsrCod)" @@ -3602,7 +3602,7 @@ static void Fig_GetAndShowTimelineActivityStats (void) " AND crs_usr.UsrCod=tl_notes.UsrCod", Gbl.Hierarchy.Ins.InsCod); break; - case Hie_CTR: + case Hie_Lvl_CTR: NumRows = DB_QuerySELECT (&mysql_res,"can not get number of social notes", "SELECT COUNT(DISTINCT tl_notes.NotCod)," "COUNT(DISTINCT tl_notes.UsrCod)" @@ -3613,7 +3613,7 @@ static void Fig_GetAndShowTimelineActivityStats (void) " AND crs_usr.UsrCod=tl_notes.UsrCod", Gbl.Hierarchy.Ctr.CtrCod); break; - case Hie_DEG: + case Hie_Lvl_DEG: NumRows = DB_QuerySELECT (&mysql_res,"can not get number of social notes", "SELECT COUNT(DISTINCT tl_notes.NotCod)," "COUNT(DISTINCT tl_notes.UsrCod)" @@ -3623,7 +3623,7 @@ static void Fig_GetAndShowTimelineActivityStats (void) " AND crs_usr.UsrCod=tl_notes.UsrCod", Gbl.Hierarchy.Deg.DegCod); break; - case Hie_CRS: + case Hie_Lvl_CRS: NumRows = DB_QuerySELECT (&mysql_res,"can not get number of social notes", "SELECT COUNT(DISTINCT tl_notes.NotCod)," "COUNT(DISTINCT tl_notes.UsrCod)" @@ -3733,13 +3733,13 @@ static void Fig_GetAndShowFollowStats (void) /***** Get total number of users *****/ NumUsrsTotal = - (Gbl.Scope.Current == Hie_SYS) ? Usr_GetTotalNumberOfUsersInPlatform () : + (Gbl.Scope.Current == Hie_Lvl_SYS) ? Usr_GetTotalNumberOfUsersInPlatform () : Usr_GetCachedNumUsrsInCrss (Gbl.Scope.Current, - (Gbl.Scope.Current == Hie_CTY ? Gbl.Hierarchy.Cty.CtyCod : - (Gbl.Scope.Current == Hie_INS ? Gbl.Hierarchy.Ins.InsCod : - (Gbl.Scope.Current == Hie_CTR ? Gbl.Hierarchy.Ctr.CtrCod : - (Gbl.Scope.Current == Hie_DEG ? Gbl.Hierarchy.Deg.DegCod : - (Gbl.Scope.Current == Hie_CRS ? Gbl.Hierarchy.Crs.CrsCod : + (Gbl.Scope.Current == Hie_Lvl_CTY ? Gbl.Hierarchy.Cty.CtyCod : + (Gbl.Scope.Current == Hie_Lvl_INS ? Gbl.Hierarchy.Ins.InsCod : + (Gbl.Scope.Current == Hie_Lvl_CTR ? Gbl.Hierarchy.Ctr.CtrCod : + (Gbl.Scope.Current == Hie_Lvl_DEG ? Gbl.Hierarchy.Deg.DegCod : + (Gbl.Scope.Current == Hie_Lvl_CRS ? Gbl.Hierarchy.Crs.CrsCod : -1L))))), 1 << Rol_STD | 1 << Rol_NET | @@ -3752,14 +3752,14 @@ static void Fig_GetAndShowFollowStats (void) { switch (Gbl.Scope.Current) { - case Hie_SYS: + case Hie_Lvl_SYS: NumUsrs = (unsigned) DB_QueryCOUNT ("can not get the total number" " of following/followers", "SELECT COUNT(DISTINCT %s) FROM usr_follow", FieldDB[Fol]); break; - case Hie_CTY: + case Hie_Lvl_CTY: NumUsrs = (unsigned) DB_QueryCOUNT ("can not get the total number" " of following/followers", @@ -3775,7 +3775,7 @@ static void Fig_GetAndShowFollowStats (void) Gbl.Hierarchy.Cty.CtyCod, FieldDB[Fol]); break; - case Hie_INS: + case Hie_Lvl_INS: NumUsrs = (unsigned) DB_QueryCOUNT ("can not get the total number" " of following/followers", @@ -3790,7 +3790,7 @@ static void Fig_GetAndShowFollowStats (void) Gbl.Hierarchy.Ins.InsCod, FieldDB[Fol]); break; - case Hie_CTR: + case Hie_Lvl_CTR: NumUsrs = (unsigned) DB_QueryCOUNT ("can not get the total number" " of following/followers", @@ -3804,7 +3804,7 @@ static void Fig_GetAndShowFollowStats (void) Gbl.Hierarchy.Ctr.CtrCod, FieldDB[Fol]); break; - case Hie_DEG: + case Hie_Lvl_DEG: NumUsrs = (unsigned) DB_QueryCOUNT ("can not get the total number" " of following/followers", @@ -3817,7 +3817,7 @@ static void Fig_GetAndShowFollowStats (void) Gbl.Hierarchy.Deg.DegCod, FieldDB[Fol]); break; - case Hie_CRS: + case Hie_Lvl_CRS: NumUsrs = (unsigned) DB_QueryCOUNT ("can not get the total number" " of following/followers", @@ -3863,7 +3863,7 @@ static void Fig_GetAndShowFollowStats (void) { switch (Gbl.Scope.Current) { - case Hie_SYS: + case Hie_Lvl_SYS: DB_QuerySELECT (&mysql_res,"can not get number of questions" " per survey", "SELECT AVG(N) FROM " @@ -3873,7 +3873,7 @@ static void Fig_GetAndShowFollowStats (void) FieldDB[Fol], FieldDB[1 - Fol]); break; - case Hie_CTY: + case Hie_Lvl_CTY: DB_QuerySELECT (&mysql_res,"can not get number of questions" " per survey", "SELECT AVG(N) FROM " @@ -3891,7 +3891,7 @@ static void Fig_GetAndShowFollowStats (void) FieldDB[Fol], FieldDB[1 - Fol]); break; - case Hie_INS: + case Hie_Lvl_INS: DB_QuerySELECT (&mysql_res,"can not get number of questions" " per survey", "SELECT AVG(N) FROM " @@ -3908,7 +3908,7 @@ static void Fig_GetAndShowFollowStats (void) FieldDB[Fol], FieldDB[1 - Fol]); break; - case Hie_CTR: + case Hie_Lvl_CTR: DB_QuerySELECT (&mysql_res,"can not get number of questions" " per survey", "SELECT AVG(N) FROM " @@ -3924,7 +3924,7 @@ static void Fig_GetAndShowFollowStats (void) FieldDB[Fol], FieldDB[1 - Fol]); break; - case Hie_DEG: + case Hie_Lvl_DEG: DB_QuerySELECT (&mysql_res,"can not get number of questions" " per survey", "SELECT AVG(N) FROM " @@ -3939,7 +3939,7 @@ static void Fig_GetAndShowFollowStats (void) FieldDB[Fol], FieldDB[1 - Fol]); break; - case Hie_CRS: + case Hie_Lvl_CRS: DB_QuerySELECT (&mysql_res,"can not get number of questions" " per survey", "SELECT AVG(N) FROM " @@ -4035,7 +4035,7 @@ static void Fig_GetAndShowForumStats (void) /***** Write a row for each type of forum *****/ switch (Gbl.Scope.Current) { - case Hie_SYS: + case Hie_Lvl_SYS: Fig_ShowStatOfAForumType (For_FORUM_GLOBAL_USRS,-1L,-1L,-1L,-1L,-1L,&FiguresForum); Fig_ShowStatOfAForumType (For_FORUM_GLOBAL_TCHS,-1L,-1L,-1L,-1L,-1L,&FiguresForum); Fig_ShowStatOfAForumType (For_FORUM__SWAD__USRS,-1L,-1L,-1L,-1L,-1L,&FiguresForum); @@ -4049,7 +4049,7 @@ static void Fig_GetAndShowForumStats (void) Fig_ShowStatOfAForumType (For_FORUM_COURSE_USRS,-1L,-1L,-1L,-1L,-1L,&FiguresForum); Fig_ShowStatOfAForumType (For_FORUM_COURSE_TCHS,-1L,-1L,-1L,-1L,-1L,&FiguresForum); break; - case Hie_CTY: + case Hie_Lvl_CTY: Fig_ShowStatOfAForumType (For_FORUM_INSTIT_USRS,Gbl.Hierarchy.Cty.CtyCod,-1L,-1L,-1L,-1L,&FiguresForum); Fig_ShowStatOfAForumType (For_FORUM_INSTIT_TCHS,Gbl.Hierarchy.Cty.CtyCod,-1L,-1L,-1L,-1L,&FiguresForum); Fig_ShowStatOfAForumType (For_FORUM_CENTRE_USRS,Gbl.Hierarchy.Cty.CtyCod,-1L,-1L,-1L,-1L,&FiguresForum); @@ -4059,7 +4059,7 @@ static void Fig_GetAndShowForumStats (void) Fig_ShowStatOfAForumType (For_FORUM_COURSE_USRS,Gbl.Hierarchy.Cty.CtyCod,-1L,-1L,-1L,-1L,&FiguresForum); Fig_ShowStatOfAForumType (For_FORUM_COURSE_TCHS,Gbl.Hierarchy.Cty.CtyCod,-1L,-1L,-1L,-1L,&FiguresForum); break; - case Hie_INS: + case Hie_Lvl_INS: Fig_ShowStatOfAForumType (For_FORUM_INSTIT_USRS,-1L,Gbl.Hierarchy.Ins.InsCod,-1L,-1L,-1L,&FiguresForum); Fig_ShowStatOfAForumType (For_FORUM_INSTIT_TCHS,-1L,Gbl.Hierarchy.Ins.InsCod,-1L,-1L,-1L,&FiguresForum); Fig_ShowStatOfAForumType (For_FORUM_CENTRE_USRS,-1L,Gbl.Hierarchy.Ins.InsCod,-1L,-1L,-1L,&FiguresForum); @@ -4069,7 +4069,7 @@ static void Fig_GetAndShowForumStats (void) Fig_ShowStatOfAForumType (For_FORUM_COURSE_USRS,-1L,Gbl.Hierarchy.Ins.InsCod,-1L,-1L,-1L,&FiguresForum); Fig_ShowStatOfAForumType (For_FORUM_COURSE_TCHS,-1L,Gbl.Hierarchy.Ins.InsCod,-1L,-1L,-1L,&FiguresForum); break; - case Hie_CTR: + case Hie_Lvl_CTR: Fig_ShowStatOfAForumType (For_FORUM_CENTRE_USRS,-1L,-1L,Gbl.Hierarchy.Ctr.CtrCod,-1L,-1L,&FiguresForum); Fig_ShowStatOfAForumType (For_FORUM_CENTRE_TCHS,-1L,-1L,Gbl.Hierarchy.Ctr.CtrCod,-1L,-1L,&FiguresForum); Fig_ShowStatOfAForumType (For_FORUM_DEGREE_USRS,-1L,-1L,Gbl.Hierarchy.Ctr.CtrCod,-1L,-1L,&FiguresForum); @@ -4077,13 +4077,13 @@ static void Fig_GetAndShowForumStats (void) Fig_ShowStatOfAForumType (For_FORUM_COURSE_USRS,-1L,-1L,Gbl.Hierarchy.Ctr.CtrCod,-1L,-1L,&FiguresForum); Fig_ShowStatOfAForumType (For_FORUM_COURSE_TCHS,-1L,-1L,Gbl.Hierarchy.Ctr.CtrCod,-1L,-1L,&FiguresForum); break; - case Hie_DEG: + case Hie_Lvl_DEG: Fig_ShowStatOfAForumType (For_FORUM_DEGREE_USRS,-1L,-1L,-1L,Gbl.Hierarchy.Deg.DegCod,-1L,&FiguresForum); Fig_ShowStatOfAForumType (For_FORUM_DEGREE_TCHS,-1L,-1L,-1L,Gbl.Hierarchy.Deg.DegCod,-1L,&FiguresForum); Fig_ShowStatOfAForumType (For_FORUM_COURSE_USRS,-1L,-1L,-1L,Gbl.Hierarchy.Deg.DegCod,-1L,&FiguresForum); Fig_ShowStatOfAForumType (For_FORUM_COURSE_TCHS,-1L,-1L,-1L,Gbl.Hierarchy.Deg.DegCod,-1L,&FiguresForum); break; - case Hie_CRS: + case Hie_Lvl_CRS: Fig_ShowStatOfAForumType (For_FORUM_COURSE_USRS,-1L,-1L,-1L,-1L,Gbl.Hierarchy.Crs.CrsCod,&FiguresForum); Fig_ShowStatOfAForumType (For_FORUM_COURSE_TCHS,-1L,-1L,-1L,-1L,Gbl.Hierarchy.Crs.CrsCod,&FiguresForum); break; @@ -4372,13 +4372,13 @@ static void Fig_GetAndShowNumUsrsPerNotifyEvent (void) /***** Get total number of users *****/ NumUsrsTotal = - (Gbl.Scope.Current == Hie_SYS) ? Usr_GetTotalNumberOfUsersInPlatform () : + (Gbl.Scope.Current == Hie_Lvl_SYS) ? Usr_GetTotalNumberOfUsersInPlatform () : Usr_GetCachedNumUsrsInCrss (Gbl.Scope.Current, - (Gbl.Scope.Current == Hie_CTY ? Gbl.Hierarchy.Cty.CtyCod : - (Gbl.Scope.Current == Hie_INS ? Gbl.Hierarchy.Ins.InsCod : - (Gbl.Scope.Current == Hie_CTR ? Gbl.Hierarchy.Ctr.CtrCod : - (Gbl.Scope.Current == Hie_DEG ? Gbl.Hierarchy.Deg.DegCod : - (Gbl.Scope.Current == Hie_CRS ? Gbl.Hierarchy.Crs.CrsCod : + (Gbl.Scope.Current == Hie_Lvl_CTY ? Gbl.Hierarchy.Cty.CtyCod : + (Gbl.Scope.Current == Hie_Lvl_INS ? Gbl.Hierarchy.Ins.InsCod : + (Gbl.Scope.Current == Hie_Lvl_CTR ? Gbl.Hierarchy.Ctr.CtrCod : + (Gbl.Scope.Current == Hie_Lvl_DEG ? Gbl.Hierarchy.Deg.DegCod : + (Gbl.Scope.Current == Hie_Lvl_CRS ? Gbl.Hierarchy.Crs.CrsCod : -1L))))), 1 << Rol_STD | 1 << Rol_NET | @@ -4404,7 +4404,7 @@ static void Fig_GetAndShowNumUsrsPerNotifyEvent (void) /* Get number of notifications by email from database */ switch (Gbl.Scope.Current) { - case Hie_SYS: + case Hie_Lvl_SYS: DB_QuerySELECT (&mysql_res,"can not get the number" " of notifications by email", "SELECT SUM(NumEvents),SUM(NumMails)" @@ -4412,7 +4412,7 @@ static void Fig_GetAndShowNumUsrsPerNotifyEvent (void) " WHERE NotifyEvent=%u", (unsigned) NotifyEvent); break; - case Hie_CTY: + case Hie_Lvl_CTY: DB_QuerySELECT (&mysql_res,"can not get the number" " of notifications by email", "SELECT SUM(sta_notif.NumEvents),SUM(sta_notif.NumMails)" @@ -4424,7 +4424,7 @@ static void Fig_GetAndShowNumUsrsPerNotifyEvent (void) " AND sta_notif.NotifyEvent=%u", Gbl.Hierarchy.Cty.CtyCod,(unsigned) NotifyEvent); break; - case Hie_INS: + case Hie_Lvl_INS: DB_QuerySELECT (&mysql_res,"can not get the number" " of notifications by email", "SELECT SUM(sta_notif.NumEvents),SUM(sta_notif.NumMails)" @@ -4435,7 +4435,7 @@ static void Fig_GetAndShowNumUsrsPerNotifyEvent (void) " AND sta_notif.NotifyEvent=%u", Gbl.Hierarchy.Ins.InsCod,(unsigned) NotifyEvent); break; - case Hie_CTR: + case Hie_Lvl_CTR: DB_QuerySELECT (&mysql_res,"can not get the number" " of notifications by email", "SELECT SUM(sta_notif.NumEvents),SUM(sta_notif.NumMails)" @@ -4445,7 +4445,7 @@ static void Fig_GetAndShowNumUsrsPerNotifyEvent (void) " AND sta_notif.NotifyEvent=%u", Gbl.Hierarchy.Ctr.CtrCod,(unsigned) NotifyEvent); break; - case Hie_DEG: + case Hie_Lvl_DEG: DB_QuerySELECT (&mysql_res,"can not get the number" " of notifications by email", "SELECT SUM(NumEvents),SUM(NumMails)" @@ -4454,7 +4454,7 @@ static void Fig_GetAndShowNumUsrsPerNotifyEvent (void) " AND NotifyEvent=%u", Gbl.Hierarchy.Deg.DegCod,(unsigned) NotifyEvent); break; - case Hie_CRS: + case Hie_Lvl_CRS: DB_QuerySELECT (&mysql_res,"can not get the number" " of notifications by email", "SELECT SUM(NumEvents),SUM(NumMails)" @@ -5570,7 +5570,7 @@ unsigned Fig_GetNumUsrsWhoChoseAnOption (const char *SubQuery) /***** Get the number of users who have chosen this privacy option from database *****/ switch (Gbl.Scope.Current) { - case Hie_SYS: + case Hie_Lvl_SYS: NumUsrs = (unsigned) DB_QueryCOUNT ("can not get the number of users" " who have chosen an option", @@ -5578,7 +5578,7 @@ unsigned Fig_GetNumUsrsWhoChoseAnOption (const char *SubQuery) " FROM usr_data WHERE %s", SubQuery); break; - case Hie_CTY: + case Hie_Lvl_CTY: NumUsrs = (unsigned) DB_QueryCOUNT ("can not get the number of users" " who have chosen an option", @@ -5593,7 +5593,7 @@ unsigned Fig_GetNumUsrsWhoChoseAnOption (const char *SubQuery) " AND %s", Gbl.Hierarchy.Cty.CtyCod,SubQuery); break; - case Hie_INS: + case Hie_Lvl_INS: NumUsrs = (unsigned) DB_QueryCOUNT ("can not get the number of users" " who have chosen an option", @@ -5607,7 +5607,7 @@ unsigned Fig_GetNumUsrsWhoChoseAnOption (const char *SubQuery) " AND %s", Gbl.Hierarchy.Ins.InsCod,SubQuery); break; - case Hie_CTR: + case Hie_Lvl_CTR: NumUsrs = (unsigned) DB_QueryCOUNT ("can not get the number of users" " who have chosen an option", @@ -5620,7 +5620,7 @@ unsigned Fig_GetNumUsrsWhoChoseAnOption (const char *SubQuery) " AND %s", Gbl.Hierarchy.Ctr.CtrCod,SubQuery); break; - case Hie_DEG: + case Hie_Lvl_DEG: NumUsrs = (unsigned) DB_QueryCOUNT ("can not get the number of users" " who have chosen an option", @@ -5632,7 +5632,7 @@ unsigned Fig_GetNumUsrsWhoChoseAnOption (const char *SubQuery) " AND %s", Gbl.Hierarchy.Deg.DegCod,SubQuery); break; - case Hie_CRS: + case Hie_Lvl_CRS: NumUsrs = (unsigned) DB_QueryCOUNT ("can not get the number of users" " who have chosen an option", diff --git a/swad_figure.h b/swad_figure.h index 043d91b5..70b1890d 100644 --- a/swad_figure.h +++ b/swad_figure.h @@ -27,7 +27,7 @@ /********************************* Headers ***********************************/ /*****************************************************************************/ -#include "swad_hierarchy.h" +#include "swad_hierarchy_level.h" /*****************************************************************************/ /************************** Public types and constants ***********************/ @@ -73,7 +73,7 @@ typedef enum struct Fig_Figures { - Hie_Level_t Scope; + Hie_Lvl_Level_t Scope; Fig_FigureType_t FigureType; }; diff --git a/swad_figure_cache.c b/swad_figure_cache.c index f5891627..cb868e4d 100644 --- a/swad_figure_cache.c +++ b/swad_figure_cache.c @@ -30,13 +30,12 @@ #include "swad_database.h" #include "swad_figure_cache.h" #include "swad_scope.h" +#include "swad_string.h" /*****************************************************************************/ /************** External global variables from others modules ****************/ /*****************************************************************************/ -// extern struct Globals Gbl; - /*****************************************************************************/ /***************************** Private constants *****************************/ /*****************************************************************************/ @@ -58,7 +57,7 @@ /*****************************************************************************/ void FigCch_UpdateFigureIntoCache (FigCch_FigureCached_t Figure, - Hie_Level_t Scope,long Cod, + Hie_Lvl_Level_t Scope,long Cod, FigCch_Type_t Type,const void *ValuePtr) { /***** Trivial check *****/ @@ -97,19 +96,19 @@ void FigCch_UpdateFigureIntoCache (FigCch_FigureCached_t Figure, // Return true is figure is found (if figure is cached and recently updated) bool FigCch_GetFigureFromCache (FigCch_FigureCached_t Figure, - Hie_Level_t Scope,long Cod, + Hie_Lvl_Level_t Scope,long Cod, FigCch_Type_t Type,void *ValuePtr) { /* The higher the level, the longer a value remains cached */ - time_t TimeCached[Hie_NUM_LEVELS] = // Time in seconds + time_t TimeCached[Hie_Lvl_NUM_LEVELS] = // Time in seconds { - [Hie_UNK] = (time_t) ( 0), // Unknown - [Hie_SYS] = (time_t) (24UL * 60UL * 60UL), // System - [Hie_CTY] = (time_t) (12UL * 60UL * 60UL), // Country - [Hie_INS] = (time_t) ( 6UL * 60UL * 60UL), // Institution - [Hie_CTR] = (time_t) ( 3UL * 60UL * 60UL), // Centre - [Hie_DEG] = (time_t) ( 1UL * 60UL * 60UL), // Degree - [Hie_CRS] = (time_t) ( 60UL), // Course + [Hie_Lvl_UNK] = (time_t) ( 0), // Unknown + [Hie_Lvl_SYS] = (time_t) (24UL * 60UL * 60UL), // System + [Hie_Lvl_CTY] = (time_t) (12UL * 60UL * 60UL), // Country + [Hie_Lvl_INS] = (time_t) ( 6UL * 60UL * 60UL), // Institution + [Hie_Lvl_CTR] = (time_t) ( 3UL * 60UL * 60UL), // Centre + [Hie_Lvl_DEG] = (time_t) ( 1UL * 60UL * 60UL), // Degree + [Hie_Lvl_CRS] = (time_t) ( 60UL), // Course }; static const char *Field[FigCch_NUM_TYPES] = { @@ -133,7 +132,7 @@ bool FigCch_GetFigureFromCache (FigCch_FigureCached_t Figure, /***** Trivial check *****/ if (Figure == FigCch_UNKNOWN || // Unknown figure - Scope == Hie_UNK) // Unknown scope + Scope == Hie_Lvl_UNK) // Unknown scope return false; /***** Get figure's value if cached and recent *****/ diff --git a/swad_figure_cache.h b/swad_figure_cache.h index 2b850de7..ba005e4c 100644 --- a/swad_figure_cache.h +++ b/swad_figure_cache.h @@ -29,7 +29,7 @@ #include // For boolean type -#include "swad_hierarchy.h" +#include "swad_hierarchy_level.h" /*****************************************************************************/ /************************** Public types and constants ***********************/ @@ -111,10 +111,10 @@ typedef enum /*****************************************************************************/ void FigCch_UpdateFigureIntoCache (FigCch_FigureCached_t Figure, - Hie_Level_t Scope,long Cod, + Hie_Lvl_Level_t Scope,long Cod, FigCch_Type_t Type,const void *ValuePtr); bool FigCch_GetFigureFromCache (FigCch_FigureCached_t Figure, - Hie_Level_t Scope,long Cod, + Hie_Lvl_Level_t Scope,long Cod, FigCch_Type_t Type,void *ValuePtr); #endif diff --git a/swad_file_browser.c b/swad_file_browser.c index 85517bfb..4773b79f 100644 --- a/swad_file_browser.c +++ b/swad_file_browser.c @@ -47,6 +47,7 @@ #include "swad_file_MIME.h" #include "swad_form.h" #include "swad_global.h" +#include "swad_hierarchy.h" #include "swad_HTML.h" #include "swad_ID.h" #include "swad_logo.h" @@ -6855,7 +6856,7 @@ static void Brw_WriteCurrentClipboard (void) struct Prj_Project Prj; struct UsrData UsrDat; char TxtClipboardZone[1024 + - Hie_MAX_BYTES_SHRT_NAME + + Cns_HIERARCHY_MAX_BYTES_SHRT_NAME + Grp_MAX_BYTES_GROUP_TYPE_NAME + Grp_MAX_BYTES_GROUP_NAME + Usr_MAX_BYTES_FULL_NAME + @@ -12025,7 +12026,7 @@ static void Brw_WriteRowDocData (unsigned long *NumDocsNotHidden,MYSQL_ROW row) HTM_BUTTON_SUBMIT_Begin (Hie_BuildGoToMsg (InsShortName), "BT_LINK LT DAT",NULL); Hie_FreeGoToMsg (); - Lgo_DrawLogo (Hie_INS,InsCod,InsShortName,20,"BT_LINK LT",true); + Lgo_DrawLogo (Hie_Lvl_INS,InsCod,InsShortName,20,"BT_LINK LT",true); HTM_TxtF (" %s",InsShortName); HTM_BUTTON_End (); Frm_EndForm (); @@ -12041,7 +12042,7 @@ static void Brw_WriteRowDocData (unsigned long *NumDocsNotHidden,MYSQL_ROW row) HTM_BUTTON_SUBMIT_Begin (Hie_BuildGoToMsg (CtrShortName), "BT_LINK LT DAT",NULL); Hie_FreeGoToMsg (); - Lgo_DrawLogo (Hie_CTR,CtrCod,CtrShortName,20,"LT",true); + Lgo_DrawLogo (Hie_Lvl_CTR,CtrCod,CtrShortName,20,"LT",true); HTM_TxtF (" %s",CtrShortName); HTM_BUTTON_End (); Frm_EndForm (); @@ -12057,7 +12058,7 @@ static void Brw_WriteRowDocData (unsigned long *NumDocsNotHidden,MYSQL_ROW row) HTM_BUTTON_SUBMIT_Begin (Hie_BuildGoToMsg (DegShortName), "BT_LINK LT DAT",NULL); Hie_FreeGoToMsg (); - Lgo_DrawLogo (Hie_DEG,DegCod,DegShortName,20,"LT",true); + Lgo_DrawLogo (Hie_Lvl_DEG,DegCod,DegShortName,20,"LT",true); HTM_TxtF (" %s",DegShortName); HTM_BUTTON_End (); Frm_EndForm (); diff --git a/swad_follow.c b/swad_follow.c index 6e3883ff..28967e9d 100644 --- a/swad_follow.c +++ b/swad_follow.c @@ -1373,7 +1373,7 @@ void Fol_GetAndShowRankingFollowers (void) /***** Get ranking from database *****/ switch (Gbl.Scope.Current) { - case Hie_SYS: + case Hie_Lvl_SYS: NumUsrs = (unsigned) DB_QuerySELECT (&mysql_res,"can not get ranking", "SELECT FollowedCod,COUNT(FollowerCod) AS N" @@ -1381,7 +1381,7 @@ void Fol_GetAndShowRankingFollowers (void) " GROUP BY FollowedCod" " ORDER BY N DESC,FollowedCod LIMIT 100"); break; - case Hie_CTY: + case Hie_Lvl_CTY: NumUsrs = (unsigned) DB_QuerySELECT (&mysql_res,"can not get ranking", "SELECT usr_follow.FollowedCod,COUNT(DISTINCT usr_follow.FollowerCod) AS N" @@ -1396,7 +1396,7 @@ void Fol_GetAndShowRankingFollowers (void) " ORDER BY N DESC,usr_follow.FollowedCod LIMIT 100", Gbl.Hierarchy.Cty.CtyCod); break; - case Hie_INS: + case Hie_Lvl_INS: NumUsrs = (unsigned) DB_QuerySELECT (&mysql_res,"can not get ranking", "SELECT usr_follow.FollowedCod,COUNT(DISTINCT usr_follow.FollowerCod) AS N" @@ -1410,7 +1410,7 @@ void Fol_GetAndShowRankingFollowers (void) " ORDER BY N DESC,usr_follow.FollowedCod LIMIT 100", Gbl.Hierarchy.Ins.InsCod); break; - case Hie_CTR: + case Hie_Lvl_CTR: NumUsrs = (unsigned) DB_QuerySELECT (&mysql_res,"can not get ranking", "SELECT usr_follow.FollowedCod,COUNT(DISTINCT usr_follow.FollowerCod) AS N" @@ -1423,7 +1423,7 @@ void Fol_GetAndShowRankingFollowers (void) " ORDER BY N DESC,usr_follow.FollowedCod LIMIT 100", Gbl.Hierarchy.Ctr.CtrCod); break; - case Hie_DEG: + case Hie_Lvl_DEG: NumUsrs = (unsigned) DB_QuerySELECT (&mysql_res,"can not get ranking", "SELECT usr_follow.FollowedCod,COUNT(DISTINCT usr_follow.FollowerCod) AS N" @@ -1435,7 +1435,7 @@ void Fol_GetAndShowRankingFollowers (void) " ORDER BY N DESC,usr_follow.FollowedCod LIMIT 100", Gbl.Hierarchy.Deg.DegCod); break; - case Hie_CRS: + case Hie_Lvl_CRS: NumUsrs = (unsigned) DB_QuerySELECT (&mysql_res,"can not get ranking", "SELECT usr_follow.FollowedCod,COUNT(DISTINCT usr_follow.FollowerCod) AS N" diff --git a/swad_form.c b/swad_form.c index c63479e5..10ac2a6f 100644 --- a/swad_form.c +++ b/swad_form.c @@ -205,27 +205,27 @@ void Frm_SetParamsForm (char ParamsStr[Frm_MAX_BYTES_PARAMS_STR + 1],Act_Action_ it is necessary to send a parameter with course code */ switch (Gbl.Hierarchy.Level) { - case Hie_CTY: // Country + case Hie_Lvl_CTY: // Country snprintf (ParamLocation,sizeof (ParamLocation), "", Gbl.Hierarchy.Cty.CtyCod); break; - case Hie_INS: // Institution + case Hie_Lvl_INS: // Institution snprintf (ParamLocation,sizeof (ParamLocation), "", Gbl.Hierarchy.Ins.InsCod); break; - case Hie_CTR: // Centre + case Hie_Lvl_CTR: // Centre snprintf (ParamLocation,sizeof (ParamLocation), "", Gbl.Hierarchy.Ctr.CtrCod); break; - case Hie_DEG: // Degree + case Hie_Lvl_DEG: // Degree snprintf (ParamLocation,sizeof (ParamLocation), "", Gbl.Hierarchy.Deg.DegCod); break; - case Hie_CRS: // Course + case Hie_Lvl_CRS: // Course snprintf (ParamLocation,sizeof (ParamLocation), "", Gbl.Hierarchy.Crs.CrsCod); diff --git a/swad_forum.c b/swad_forum.c index 9097ef96..d6e362b9 100644 --- a/swad_forum.c +++ b/swad_forum.c @@ -2121,15 +2121,15 @@ static void For_WriteLinkToForum (const struct For_Forums *Forums, break; case For_FORUM_INSTIT_USRS: case For_FORUM_INSTIT_TCHS: - Lgo_DrawLogo (Hie_INS,Forum->Location,ForumName,16,NULL,true); + Lgo_DrawLogo (Hie_Lvl_INS,Forum->Location,ForumName,16,NULL,true); break; case For_FORUM_CENTRE_USRS: case For_FORUM_CENTRE_TCHS: - Lgo_DrawLogo (Hie_CTR,Forum->Location,ForumName,16,NULL,true); + Lgo_DrawLogo (Hie_Lvl_CTR,Forum->Location,ForumName,16,NULL,true); break; case For_FORUM_DEGREE_USRS: case For_FORUM_DEGREE_TCHS: - Lgo_DrawLogo (Hie_DEG,Forum->Location,ForumName,16,NULL,true); + Lgo_DrawLogo (Hie_Lvl_DEG,Forum->Location,ForumName,16,NULL,true); break; case For_FORUM_COURSE_USRS: case For_FORUM_COURSE_TCHS: @@ -4516,21 +4516,21 @@ void For_RemoveUsrFromThrClipboard (long UsrCod) /********** Remove all the threads and posts in forums of a degree ***********/ /*****************************************************************************/ -void For_RemoveForums (Hie_Level_t Scope,long ForumLocation) +void For_RemoveForums (Hie_Lvl_Level_t Scope,long ForumLocation) { static const struct { For_ForumType_t Usrs; For_ForumType_t Tchs; - } ForumType[Hie_NUM_LEVELS] = + } ForumType[Hie_Lvl_NUM_LEVELS] = { - [Hie_UNK] = {For_FORUM_GLOBAL_USRS,For_FORUM_GLOBAL_TCHS}, // No forums for this scope - [Hie_SYS] = {For_FORUM_GLOBAL_USRS,For_FORUM_GLOBAL_TCHS}, // Not removable - [Hie_CTY] = {For_FORUM_GLOBAL_USRS,For_FORUM_GLOBAL_TCHS}, // No forums for this scope - [Hie_INS] = {For_FORUM_INSTIT_USRS,For_FORUM_INSTIT_TCHS}, - [Hie_CTR] = {For_FORUM_CENTRE_USRS,For_FORUM_CENTRE_TCHS}, - [Hie_DEG] = {For_FORUM_DEGREE_USRS,For_FORUM_DEGREE_TCHS}, - [Hie_CRS] = {For_FORUM_COURSE_USRS,For_FORUM_COURSE_TCHS}, + [Hie_Lvl_UNK] = {For_FORUM_GLOBAL_USRS,For_FORUM_GLOBAL_TCHS}, // No forums for this scope + [Hie_Lvl_SYS] = {For_FORUM_GLOBAL_USRS,For_FORUM_GLOBAL_TCHS}, // Not removable + [Hie_Lvl_CTY] = {For_FORUM_GLOBAL_USRS,For_FORUM_GLOBAL_TCHS}, // No forums for this scope + [Hie_Lvl_INS] = {For_FORUM_INSTIT_USRS,For_FORUM_INSTIT_TCHS}, + [Hie_Lvl_CTR] = {For_FORUM_CENTRE_USRS,For_FORUM_CENTRE_TCHS}, + [Hie_Lvl_DEG] = {For_FORUM_DEGREE_USRS,For_FORUM_DEGREE_TCHS}, + [Hie_Lvl_CRS] = {For_FORUM_COURSE_USRS,For_FORUM_COURSE_TCHS}, }; /***** Remove disabled posts *****/ diff --git a/swad_forum.h b/swad_forum.h index 9387cfa4..7fdb8038 100644 --- a/swad_forum.h +++ b/swad_forum.h @@ -159,6 +159,6 @@ void For_CutThread (void); void For_PasteThread (void); void For_RemoveUsrFromThrClipboard (long UsrCod); -void For_RemoveForums (Hie_Level_t Scope,long ForumLocation); +void For_RemoveForums (Hie_Lvl_Level_t Scope,long ForumLocation); #endif diff --git a/swad_game.c b/swad_game.c index 975dee01..63eb3c80 100644 --- a/swad_game.c +++ b/swad_game.c @@ -2662,7 +2662,7 @@ void Gam_RequestNewMatch (void) /*****************************************************************************/ // Returns the number of courses with games in this location -unsigned Gam_GetNumCoursesWithGames (Hie_Level_t Scope) +unsigned Gam_GetNumCoursesWithGames (Hie_Lvl_Level_t Scope) { MYSQL_RES *mysql_res; MYSQL_ROW row; @@ -2671,12 +2671,12 @@ unsigned Gam_GetNumCoursesWithGames (Hie_Level_t Scope) /***** Get number of courses with games from database *****/ switch (Scope) { - case Hie_SYS: + case Hie_Lvl_SYS: DB_QuerySELECT (&mysql_res,"can not get number of courses with games", "SELECT COUNT(DISTINCT CrsCod)" " FROM gam_games"); break; - case Hie_CTY: + case Hie_Lvl_CTY: DB_QuerySELECT (&mysql_res,"can not get number of courses with games", "SELECT COUNT(DISTINCT gam_games.CrsCod)" " FROM institutions,centres,degrees,courses,gam_games" @@ -2687,7 +2687,7 @@ unsigned Gam_GetNumCoursesWithGames (Hie_Level_t Scope) " AND courses.CrsCod=gam_games.CrsCod", Gbl.Hierarchy.Ins.InsCod); break; - case Hie_INS: + case Hie_Lvl_INS: DB_QuerySELECT (&mysql_res,"can not get number of courses with games", "SELECT COUNT(DISTINCT gam_games.CrsCod)" " FROM centres,degrees,courses,gam_games" @@ -2697,7 +2697,7 @@ unsigned Gam_GetNumCoursesWithGames (Hie_Level_t Scope) " AND courses.CrsCod=gam_games.CrsCod", Gbl.Hierarchy.Ins.InsCod); break; - case Hie_CTR: + case Hie_Lvl_CTR: DB_QuerySELECT (&mysql_res,"can not get number of courses with games", "SELECT COUNT(DISTINCT gam_games.CrsCod)" " FROM degrees,courses,gam_games" @@ -2706,7 +2706,7 @@ unsigned Gam_GetNumCoursesWithGames (Hie_Level_t Scope) " AND courses.CrsCod=gam_games.CrsCod", Gbl.Hierarchy.Ctr.CtrCod); break; - case Hie_DEG: + case Hie_Lvl_DEG: DB_QuerySELECT (&mysql_res,"can not get number of courses with games", "SELECT COUNT(DISTINCT gam_games.CrsCod)" " FROM courses,gam_games" @@ -2714,7 +2714,7 @@ unsigned Gam_GetNumCoursesWithGames (Hie_Level_t Scope) " AND courses.CrsCod=gam_games.CrsCod", Gbl.Hierarchy.Deg.DegCod); break; - case Hie_CRS: + case Hie_Lvl_CRS: DB_QuerySELECT (&mysql_res,"can not get number of courses with games", "SELECT COUNT(DISTINCT CrsCod)" " FROM gam_games" @@ -2742,7 +2742,7 @@ unsigned Gam_GetNumCoursesWithGames (Hie_Level_t Scope) /*****************************************************************************/ // Returns the number of games in this location -unsigned Gam_GetNumGames (Hie_Level_t Scope) +unsigned Gam_GetNumGames (Hie_Lvl_Level_t Scope) { MYSQL_RES *mysql_res; MYSQL_ROW row; @@ -2751,12 +2751,12 @@ unsigned Gam_GetNumGames (Hie_Level_t Scope) /***** Get number of games from database *****/ switch (Scope) { - case Hie_SYS: + case Hie_Lvl_SYS: DB_QuerySELECT (&mysql_res,"can not get number of games", "SELECT COUNT(*)" " FROM gam_games"); break; - case Hie_CTY: + case Hie_Lvl_CTY: DB_QuerySELECT (&mysql_res,"can not get number of games", "SELECT COUNT(*)" " FROM institutions,centres,degrees,courses,gam_games" @@ -2767,7 +2767,7 @@ unsigned Gam_GetNumGames (Hie_Level_t Scope) " AND courses.CrsCod=gam_games.CrsCod", Gbl.Hierarchy.Cty.CtyCod); break; - case Hie_INS: + case Hie_Lvl_INS: DB_QuerySELECT (&mysql_res,"can not get number of games", "SELECT COUNT(*)" " FROM centres,degrees,courses,gam_games" @@ -2777,7 +2777,7 @@ unsigned Gam_GetNumGames (Hie_Level_t Scope) " AND courses.CrsCod=gam_games.CrsCod", Gbl.Hierarchy.Ins.InsCod); break; - case Hie_CTR: + case Hie_Lvl_CTR: DB_QuerySELECT (&mysql_res,"can not get number of games", "SELECT COUNT(*)" " FROM degrees,courses,gam_games" @@ -2786,7 +2786,7 @@ unsigned Gam_GetNumGames (Hie_Level_t Scope) " AND courses.CrsCod=gam_games.CrsCod", Gbl.Hierarchy.Ctr.CtrCod); break; - case Hie_DEG: + case Hie_Lvl_DEG: DB_QuerySELECT (&mysql_res,"can not get number of games", "SELECT COUNT(*)" " FROM courses,gam_games" @@ -2794,7 +2794,7 @@ unsigned Gam_GetNumGames (Hie_Level_t Scope) " AND courses.CrsCod=gam_games.CrsCod", Gbl.Hierarchy.Deg.DegCod); break; - case Hie_CRS: + case Hie_Lvl_CRS: DB_QuerySELECT (&mysql_res,"can not get number of games", "SELECT COUNT(*)" " FROM gam_games" @@ -2821,7 +2821,7 @@ unsigned Gam_GetNumGames (Hie_Level_t Scope) /************* Get average number of questions per course game ***************/ /*****************************************************************************/ -double Gam_GetNumQstsPerCrsGame (Hie_Level_t Scope) +double Gam_GetNumQstsPerCrsGame (Hie_Lvl_Level_t Scope) { MYSQL_RES *mysql_res; MYSQL_ROW row; @@ -2830,7 +2830,7 @@ double Gam_GetNumQstsPerCrsGame (Hie_Level_t Scope) /***** Get number of questions per game from database *****/ switch (Scope) { - case Hie_SYS: + case Hie_Lvl_SYS: DB_QuerySELECT (&mysql_res,"can not get number of questions per game", "SELECT AVG(NumQsts) FROM" " (SELECT COUNT(gam_questions.QstCod) AS NumQsts" @@ -2838,7 +2838,7 @@ double Gam_GetNumQstsPerCrsGame (Hie_Level_t Scope) " WHERE gam_games.GamCod=gam_questions.GamCod" " GROUP BY gam_questions.GamCod) AS NumQstsTable"); break; - case Hie_CTY: + case Hie_Lvl_CTY: DB_QuerySELECT (&mysql_res,"can not get number of questions per game", "SELECT AVG(NumQsts) FROM" " (SELECT COUNT(gam_questions.QstCod) AS NumQsts" @@ -2852,7 +2852,7 @@ double Gam_GetNumQstsPerCrsGame (Hie_Level_t Scope) " GROUP BY gam_questions.GamCod) AS NumQstsTable", Gbl.Hierarchy.Cty.CtyCod); break; - case Hie_INS: + case Hie_Lvl_INS: DB_QuerySELECT (&mysql_res,"can not get number of questions per game", "SELECT AVG(NumQsts) FROM" " (SELECT COUNT(gam_questions.QstCod) AS NumQsts" @@ -2865,7 +2865,7 @@ double Gam_GetNumQstsPerCrsGame (Hie_Level_t Scope) " GROUP BY gam_questions.GamCod) AS NumQstsTable", Gbl.Hierarchy.Ins.InsCod); break; - case Hie_CTR: + case Hie_Lvl_CTR: DB_QuerySELECT (&mysql_res,"can not get number of questions per game", "SELECT AVG(NumQsts) FROM" " (SELECT COUNT(gam_questions.QstCod) AS NumQsts" @@ -2877,7 +2877,7 @@ double Gam_GetNumQstsPerCrsGame (Hie_Level_t Scope) " GROUP BY gam_questions.GamCod) AS NumQstsTable", Gbl.Hierarchy.Ctr.CtrCod); break; - case Hie_DEG: + case Hie_Lvl_DEG: DB_QuerySELECT (&mysql_res,"can not get number of questions per game", "SELECT AVG(NumQsts) FROM" " (SELECT COUNT(gam_questions.QstCod) AS NumQsts" @@ -2888,7 +2888,7 @@ double Gam_GetNumQstsPerCrsGame (Hie_Level_t Scope) " GROUP BY gam_questions.GamCod) AS NumQstsTable", Gbl.Hierarchy.Deg.DegCod); break; - case Hie_CRS: + case Hie_Lvl_CRS: DB_QuerySELECT (&mysql_res,"can not get number of questions per game", "SELECT AVG(NumQsts) FROM" " (SELECT COUNT(gam_questions.QstCod) AS NumQsts" diff --git a/swad_game.h b/swad_game.h index ddac28da..91b7c20f 100644 --- a/swad_game.h +++ b/swad_game.h @@ -163,9 +163,9 @@ void Gam_MoveDownQst (void); void Gam_PutButtonNewMatch (struct Gam_Games *Games,long GamCod); void Gam_RequestNewMatch (void); -unsigned Gam_GetNumCoursesWithGames (Hie_Level_t Scope); -unsigned Gam_GetNumGames (Hie_Level_t Scope); -double Gam_GetNumQstsPerCrsGame (Hie_Level_t Scope); +unsigned Gam_GetNumCoursesWithGames (Hie_Lvl_Level_t Scope); +unsigned Gam_GetNumGames (Hie_Lvl_Level_t Scope); +double Gam_GetNumQstsPerCrsGame (Hie_Lvl_Level_t Scope); void Gam_ShowTstTagsPresentInAGame (long GamCod); diff --git a/swad_global.c b/swad_global.c index d09c472d..a804c7c4 100644 --- a/swad_global.c +++ b/swad_global.c @@ -43,6 +43,7 @@ #include "swad_exam_announcement.h" #include "swad_follow.h" #include "swad_global.h" +#include "swad_hierarchy.h" #include "swad_icon.h" #include "swad_link.h" #include "swad_parameter.h" @@ -290,7 +291,7 @@ void Gbl_InitializeGlobals (void) Gbl.Usrs.ClassPhoto.AllGroups = true; Gbl.Usrs.ClassPhoto.Cols = Usr_CLASS_PHOTO_COLS_DEF; - Gbl.Scope.Current = Hie_CRS; + Gbl.Scope.Current = Hie_Lvl_CRS; Gbl.Usrs.Connected.TimeToRefreshInMs = Con_MAX_TIME_TO_REFRESH_CONNECTED_IN_MS; diff --git a/swad_global.h b/swad_global.h index fff083e1..bb7a074d 100644 --- a/swad_global.h +++ b/swad_global.h @@ -187,10 +187,10 @@ struct Globals } HTMLOutput; struct { - Hie_Level_t Level; // Current level in the hierarchy: system, country, institution, centre, degree or course + Hie_Lvl_Level_t Level; // Current level in the hierarchy: system, country, institution, centre, degree or course long Cod; // Code of the current country, institution, centre, degree or course struct ListCountries Ctys;// List of countries - struct Country Cty; // Current country + struct Cty_Countr Cty; // Current country struct ListInstits Inss; // List of institutions in current country struct Ins_Instit Ins; // Current institution struct ListCentres Ctrs; // List of centres in current institution @@ -361,8 +361,8 @@ struct Globals } Record; struct { - Hie_Level_t Current; - Hie_Level_t Default; + Hie_Lvl_Level_t Current; + Hie_Lvl_Level_t Default; unsigned Allowed; } Scope; struct @@ -453,13 +453,13 @@ struct Globals struct { long InsCod; - char ShrtName[Hie_MAX_BYTES_SHRT_NAME + 1]; + char ShrtName[Cns_HIERARCHY_MAX_BYTES_SHRT_NAME + 1]; } InstitutionShrtName; struct { long InsCod; - char ShrtName[Hie_MAX_BYTES_SHRT_NAME + 1]; - char CtyName[Hie_MAX_BYTES_FULL_NAME + 1]; + char ShrtName[Cns_HIERARCHY_MAX_BYTES_SHRT_NAME + 1]; + char CtyName[Cns_HIERARCHY_MAX_BYTES_FULL_NAME + 1]; } InstitutionShrtNameAndCty; struct { diff --git a/swad_help.c b/swad_help.c index 753a9d3a..6c99c568 100644 --- a/swad_help.c +++ b/swad_help.c @@ -132,7 +132,7 @@ void Hlp_ShowHelpWhatWouldYouLikeToDo (void) if (Gbl.Usrs.Me.Logged) // I am logged { - if (Gbl.Hierarchy.Level == Hie_CRS) // Course selected + if (Gbl.Hierarchy.Level == Hie_Lvl_CRS) // Course selected { if (Gbl.Usrs.Me.IBelongToCurrentCrs) // I belong to this course { @@ -162,9 +162,9 @@ void Hlp_ShowHelpWhatWouldYouLikeToDo (void) if (Gbl.Usrs.Me.MyCrss.Num) // I am enroled in some courses { - if (Gbl.Hierarchy.Level == Hie_CRS && // Course selected + if (Gbl.Hierarchy.Level == Hie_Lvl_CRS && // Course selected Gbl.Usrs.Me.UsrDat.Roles.InCurrentCrs.Role == Rol_TCH) // I am a teacher in current course - if (!Usr_GetCachedNumUsrsInCrss (Hie_CRS,Gbl.Hierarchy.Crs.CrsCod, + if (!Usr_GetCachedNumUsrsInCrss (Hie_Lvl_CRS,Gbl.Hierarchy.Crs.CrsCod, 1 << Rol_STD)) // Current course probably has no students { /* Request students enrolment */ @@ -185,7 +185,7 @@ void Hlp_ShowHelpWhatWouldYouLikeToDo (void) if (Gbl.Hierarchy.Deg.DegCod > 0) // Degree selected { /* Select a course */ - Hlp_ShowRowHelpWhatWouldYouLikeToDo (Str_BuildStringStr (Gbl.Hierarchy.Level == Hie_CRS ? Txt_Select_create_course_in_X : + Hlp_ShowRowHelpWhatWouldYouLikeToDo (Str_BuildStringStr (Gbl.Hierarchy.Level == Hie_Lvl_CRS ? Txt_Select_create_course_in_X : Txt_Select_or_create_one_course_in_X, Gbl.Hierarchy.Deg.ShrtName), ActSeeCrs, diff --git a/swad_hierarchy.c b/swad_hierarchy.c index 412af743..1339bb63 100644 --- a/swad_hierarchy.c +++ b/swad_hierarchy.c @@ -32,6 +32,7 @@ #include "swad_database.h" #include "swad_form.h" #include "swad_global.h" +#include "swad_hierarchy.h" #include "swad_HTML.h" #include "swad_logo.h" @@ -382,7 +383,7 @@ void Hie_WriteHierarchyInBreadcrumb (void) } HTM_DIV_Begin ("class=\"BC%s %s\"", - (Gbl.Hierarchy.Level == Hie_CRS) ? "" : + (Gbl.Hierarchy.Level == Hie_Lvl_CRS) ? "" : ((Gbl.Hierarchy.Deg.DegCod > 0) ? " BC_SEMIOFF" : " BC_OFF"), ClassTxt); @@ -411,23 +412,23 @@ void Hie_WriteBigNameCtyInsCtrDegCrs (void) /***** Logo *****/ switch (Gbl.Hierarchy.Level) { - case Hie_SYS: // System + case Hie_Lvl_SYS: // System Ico_PutIcon ("swad64x64.png",Cfg_PLATFORM_FULL_NAME,"ICO40x40 TOP_LOGO"); break; - case Hie_CTY: // Country + case Hie_Lvl_CTY: // Country Cty_DrawCountryMap (&Gbl.Hierarchy.Cty,"COUNTRY_MAP_TITLE"); break; - case Hie_INS: // Institution - Lgo_DrawLogo (Hie_INS,Gbl.Hierarchy.Ins.InsCod, + case Hie_Lvl_INS: // Institution + Lgo_DrawLogo (Hie_Lvl_INS,Gbl.Hierarchy.Ins.InsCod, Gbl.Hierarchy.Ins.ShrtName,40,"TOP_LOGO",false); break; - case Hie_CTR: // Centre - Lgo_DrawLogo (Hie_CTR,Gbl.Hierarchy.Ctr.CtrCod, + case Hie_Lvl_CTR: // Centre + Lgo_DrawLogo (Hie_Lvl_CTR,Gbl.Hierarchy.Ctr.CtrCod, Gbl.Hierarchy.Ctr.ShrtName,40,"TOP_LOGO",false); break; - case Hie_DEG: // Degree - case Hie_CRS: // Course - Lgo_DrawLogo (Hie_DEG,Gbl.Hierarchy.Deg.DegCod, + case Hie_Lvl_DEG: // Degree + case Hie_Lvl_CRS: // Course + Lgo_DrawLogo (Hie_Lvl_DEG,Gbl.Hierarchy.Deg.DegCod, Gbl.Hierarchy.Deg.ShrtName,40,"TOP_LOGO",false); break; default: @@ -439,10 +440,10 @@ void Hie_WriteBigNameCtyInsCtrDegCrs (void) if (Gbl.Hierarchy.Cty.CtyCod > 0) { HTM_DIV_Begin ("id=\"big_full_name\""); - HTM_Txt ( (Gbl.Hierarchy.Level == Hie_CRS) ? Gbl.Hierarchy.Crs.FullName :// Full name - ((Gbl.Hierarchy.Level == Hie_DEG) ? Gbl.Hierarchy.Deg.FullName : - ((Gbl.Hierarchy.Level == Hie_CTR) ? Gbl.Hierarchy.Ctr.FullName : - ((Gbl.Hierarchy.Level == Hie_INS) ? Gbl.Hierarchy.Ins.FullName : + HTM_Txt ( (Gbl.Hierarchy.Level == Hie_Lvl_CRS) ? Gbl.Hierarchy.Crs.FullName :// Full name + ((Gbl.Hierarchy.Level == Hie_Lvl_DEG) ? Gbl.Hierarchy.Deg.FullName : + ((Gbl.Hierarchy.Level == Hie_Lvl_CTR) ? Gbl.Hierarchy.Ctr.FullName : + ((Gbl.Hierarchy.Level == Hie_Lvl_INS) ? Gbl.Hierarchy.Ins.FullName : Gbl.Hierarchy.Cty.Name[Gbl.Prefs.Language])))); HTM_DIV_End (); @@ -451,10 +452,10 @@ void Hie_WriteBigNameCtyInsCtrDegCrs (void) HTM_DIV_End (); HTM_DIV_Begin ("id=\"big_short_name\""); - HTM_Txt ( (Gbl.Hierarchy.Level == Hie_CRS) ? Gbl.Hierarchy.Crs.ShrtName :// Short name - ((Gbl.Hierarchy.Level == Hie_DEG) ? Gbl.Hierarchy.Deg.ShrtName : - ((Gbl.Hierarchy.Level == Hie_CTR) ? Gbl.Hierarchy.Ctr.ShrtName : - ((Gbl.Hierarchy.Level == Hie_INS) ? Gbl.Hierarchy.Ins.ShrtName : + HTM_Txt ( (Gbl.Hierarchy.Level == Hie_Lvl_CRS) ? Gbl.Hierarchy.Crs.ShrtName :// Short name + ((Gbl.Hierarchy.Level == Hie_Lvl_DEG) ? Gbl.Hierarchy.Deg.ShrtName : + ((Gbl.Hierarchy.Level == Hie_Lvl_CTR) ? Gbl.Hierarchy.Ctr.ShrtName : + ((Gbl.Hierarchy.Level == Hie_Lvl_INS) ? Gbl.Hierarchy.Ins.ShrtName : Gbl.Hierarchy.Cty.Name[Gbl.Prefs.Language])))); HTM_DIV_End (); } @@ -488,19 +489,19 @@ void Hie_SetHierarchyFromUsrLastHierarchy (void) /***** Copy last hierarchy scope and code to current hierarchy *****/ switch (Gbl.Usrs.Me.UsrLast.LastHie.Scope) { - case Hie_CTY: // Country + case Hie_Lvl_CTY: // Country Gbl.Hierarchy.Cty.CtyCod = Gbl.Usrs.Me.UsrLast.LastHie.Cod; break; - case Hie_INS: // Institution + case Hie_Lvl_INS: // Institution Gbl.Hierarchy.Ins.InsCod = Gbl.Usrs.Me.UsrLast.LastHie.Cod; break; - case Hie_CTR: // Centre + case Hie_Lvl_CTR: // Centre Gbl.Hierarchy.Ctr.CtrCod = Gbl.Usrs.Me.UsrLast.LastHie.Cod; break; - case Hie_DEG: // Degree + case Hie_Lvl_DEG: // Degree Gbl.Hierarchy.Deg.DegCod = Gbl.Usrs.Me.UsrLast.LastHie.Cod; break; - case Hie_CRS: // Course + case Hie_Lvl_CRS: // Course Gbl.Hierarchy.Crs.CrsCod = Gbl.Usrs.Me.UsrLast.LastHie.Cod; break; default: @@ -565,37 +566,37 @@ void Hie_InitHierarchy (void) depending on course code, degree code, etc. *****/ if (Gbl.Hierarchy.Crs.CrsCod > 0) // Course selected { - Gbl.Hierarchy.Level = Hie_CRS; + Gbl.Hierarchy.Level = Hie_Lvl_CRS; Gbl.Hierarchy.Cod = Gbl.Hierarchy.Crs.CrsCod; } else if (Gbl.Hierarchy.Deg.DegCod > 0) // Degree selected { - Gbl.Hierarchy.Level = Hie_DEG; + Gbl.Hierarchy.Level = Hie_Lvl_DEG; Gbl.Hierarchy.Cod = Gbl.Hierarchy.Deg.DegCod; } else if (Gbl.Hierarchy.Ctr.CtrCod > 0) // Centre selected { - Gbl.Hierarchy.Level = Hie_CTR; + Gbl.Hierarchy.Level = Hie_Lvl_CTR; Gbl.Hierarchy.Cod = Gbl.Hierarchy.Ctr.CtrCod; } else if (Gbl.Hierarchy.Ins.InsCod > 0) // Institution selected { - Gbl.Hierarchy.Level = Hie_INS; + Gbl.Hierarchy.Level = Hie_Lvl_INS; Gbl.Hierarchy.Cod = Gbl.Hierarchy.Ins.InsCod; } else if (Gbl.Hierarchy.Cty.CtyCod > 0) // Country selected { - Gbl.Hierarchy.Level = Hie_CTY; + Gbl.Hierarchy.Level = Hie_Lvl_CTY; Gbl.Hierarchy.Cod = Gbl.Hierarchy.Cty.CtyCod; } else { - Gbl.Hierarchy.Level = Hie_SYS; + Gbl.Hierarchy.Level = Hie_Lvl_SYS; Gbl.Hierarchy.Cod = -1L; } /***** Initialize paths *****/ - if (Gbl.Hierarchy.Level == Hie_CRS) // Course selected + if (Gbl.Hierarchy.Level == Hie_Lvl_CRS) // Course selected { /***** Paths of course directories *****/ snprintf (Gbl.Crs.PathPriv,sizeof (Gbl.Crs.PathPriv), @@ -644,7 +645,7 @@ void Hie_ResetHierarchy (void) Gbl.Hierarchy.Crs.CrsCod = -1L; /***** Hierarchy level and code *****/ - Gbl.Hierarchy.Level = Hie_UNK; + Gbl.Hierarchy.Level = Hie_Lvl_UNK; Gbl.Hierarchy.Cod = -1L; } @@ -690,10 +691,10 @@ void Hie_GetAndWriteInsCtrDegAdminBy (long UsrCod,unsigned ColSpan) " AND admin.Scope='%s'" " AND admin.Cod=degrees.DegCod)" " ORDER BY S,FullName", - (unsigned) Hie_SYS,UsrCod,Sco_GetDBStrFromScope (Hie_SYS), - (unsigned) Hie_INS,UsrCod,Sco_GetDBStrFromScope (Hie_INS), - (unsigned) Hie_CTR,UsrCod,Sco_GetDBStrFromScope (Hie_CTR), - (unsigned) Hie_DEG,UsrCod,Sco_GetDBStrFromScope (Hie_DEG)); + (unsigned) Hie_Lvl_SYS,UsrCod,Sco_GetDBStrFromScope (Hie_Lvl_SYS), + (unsigned) Hie_Lvl_INS,UsrCod,Sco_GetDBStrFromScope (Hie_Lvl_INS), + (unsigned) Hie_Lvl_CTR,UsrCod,Sco_GetDBStrFromScope (Hie_Lvl_CTR), + (unsigned) Hie_Lvl_DEG,UsrCod,Sco_GetDBStrFromScope (Hie_Lvl_DEG)); if (NumRows) /***** Get the list of degrees *****/ for (NumRow = 1; @@ -719,11 +720,11 @@ void Hie_GetAndWriteInsCtrDegAdminBy (long UsrCod,unsigned ColSpan) /* Get scope */ switch (Sco_GetScopeFromUnsignedStr (row[0])) { - case Hie_SYS: // System + case Hie_Lvl_SYS: // System Ico_PutIcon ("swad64x64.png",Txt_all_degrees,"ICO16x16"); HTM_TxtF (" %s",Txt_all_degrees); break; - case Hie_INS: // Institution + case Hie_Lvl_INS: // Institution Ins.InsCod = Str_ConvertStrCodToLongCod (row[1]); if (Ins.InsCod > 0) { @@ -735,7 +736,7 @@ void Hie_GetAndWriteInsCtrDegAdminBy (long UsrCod,unsigned ColSpan) "BT_LINK DAT_SMALL_NOBR","LT"); } break; - case Hie_CTR: // Centre + case Hie_Lvl_CTR: // Centre Ctr.CtrCod = Str_ConvertStrCodToLongCod (row[1]); if (Ctr.CtrCod > 0) { @@ -747,7 +748,7 @@ void Hie_GetAndWriteInsCtrDegAdminBy (long UsrCod,unsigned ColSpan) "BT_LINK DAT_SMALL_NOBR","LT"); } break; - case Hie_DEG: // Degree + case Hie_Lvl_DEG: // Degree Deg.DegCod = Str_ConvertStrCodToLongCod (row[1]); if (Deg.DegCod > 0) { diff --git a/swad_hierarchy.h b/swad_hierarchy.h index e97e1b7c..0875ffd4 100644 --- a/swad_hierarchy.h +++ b/swad_hierarchy.h @@ -27,34 +27,28 @@ /********************************* Headers ***********************************/ /*****************************************************************************/ -#include "swad_action.h" +#include "swad_centre.h" +#include "swad_country.h" +#include "swad_course.h" +#include "swad_degree.h" +#include "swad_institution.h" /*****************************************************************************/ /***************************** Public constants ******************************/ /*****************************************************************************/ -#define Hie_MAX_CHARS_SHRT_NAME (32 - 1) // 31 -#define Hie_MAX_BYTES_SHRT_NAME ((Hie_MAX_CHARS_SHRT_NAME + 1) * Str_MAX_BYTES_PER_CHAR - 1) // 511 - -#define Hie_MAX_CHARS_FULL_NAME (128 - 1) // 127 -#define Hie_MAX_BYTES_FULL_NAME ((Hie_MAX_CHARS_FULL_NAME + 1) * Str_MAX_BYTES_PER_CHAR - 1) // 2047 - /*****************************************************************************/ /******************************* Public types ********************************/ /*****************************************************************************/ -// Levels in the hierarchy -#define Hie_NUM_LEVELS 7 -typedef enum +struct Hie_Hierarchy { - Hie_UNK = 0, // Unknown - Hie_SYS = 1, // System - Hie_CTY = 2, // Country - Hie_INS = 3, // Institution - Hie_CTR = 4, // Centre - Hie_DEG = 5, // Degree - Hie_CRS = 6, // Course - } Hie_Level_t; + struct Cty_Countr Cty; + struct Ins_Instit Ins; + struct Ctr_Centre Ctr; + struct Deg_Degree Deg; + struct Crs_Course Crs; + }; /*****************************************************************************/ /***************************** Public prototypes *****************************/ diff --git a/swad_hierarchy_config.c b/swad_hierarchy_config.c index 560dcd95..883e567d 100644 --- a/swad_hierarchy_config.c +++ b/swad_hierarchy_config.c @@ -59,12 +59,12 @@ extern struct Globals Gbl; /*****************************************************************************/ void HieCfg_Title (bool PutLink, - Hie_Level_t LogoScope, + Hie_Lvl_Level_t LogoScope, long LogoCod, - char LogoShrtName[Hie_MAX_BYTES_SHRT_NAME + 1], - char LogoFullName[Hie_MAX_BYTES_FULL_NAME + 1], + char LogoShrtName[Cns_HIERARCHY_MAX_BYTES_SHRT_NAME + 1], + char LogoFullName[Cns_HIERARCHY_MAX_BYTES_FULL_NAME + 1], char LogoWWW[Cns_MAX_BYTES_WWW + 1], - char TextFullName[Hie_MAX_BYTES_FULL_NAME + 1]) + char TextFullName[Cns_HIERARCHY_MAX_BYTES_FULL_NAME + 1]) { HTM_DIV_Begin ("class=\"FRAME_TITLE FRAME_TITLE_BIG\""); if (PutLink) @@ -84,7 +84,7 @@ void HieCfg_Title (bool PutLink, /*****************************************************************************/ void HieCfg_FullName (bool PutForm,const char *Label,Act_Action_t NextAction, - const char FullName[Hie_MAX_BYTES_FULL_NAME + 1]) + const char FullName[Cns_HIERARCHY_MAX_BYTES_FULL_NAME + 1]) { /***** Full name *****/ HTM_TR_Begin (NULL); @@ -100,7 +100,7 @@ void HieCfg_FullName (bool PutForm,const char *Label,Act_Action_t NextAction, { /* Form to change full name */ Frm_StartForm (NextAction); - HTM_INPUT_TEXT ("FullName",Hie_MAX_CHARS_FULL_NAME,FullName, + HTM_INPUT_TEXT ("FullName",Cns_HIERARCHY_MAX_CHARS_FULL_NAME,FullName, HTM_SUBMIT_ON_CHANGE, "id=\"FullName\" class=\"INPUT_FULL_NAME\"" " required=\"required\""); @@ -118,7 +118,7 @@ void HieCfg_FullName (bool PutForm,const char *Label,Act_Action_t NextAction, /*****************************************************************************/ void HieCfg_ShrtName (bool PutForm,Act_Action_t NextAction, - const char ShrtName[Hie_MAX_BYTES_SHRT_NAME + 1]) + const char ShrtName[Cns_HIERARCHY_MAX_BYTES_SHRT_NAME + 1]) { extern const char *Txt_Short_name; @@ -136,7 +136,7 @@ void HieCfg_ShrtName (bool PutForm,Act_Action_t NextAction, { /* Form to change short name */ Frm_StartForm (NextAction); - HTM_INPUT_TEXT ("ShortName",Hie_MAX_CHARS_SHRT_NAME,ShrtName, + HTM_INPUT_TEXT ("ShortName",Cns_HIERARCHY_MAX_CHARS_SHRT_NAME,ShrtName, HTM_SUBMIT_ON_CHANGE, "id=\"ShortName\" class=\"INPUT_SHORT_NAME\"" " required=\"required\""); @@ -320,7 +320,7 @@ void HieCfg_QR (const char *ParamName,long HieCod) /************************ Number of users in courses *************************/ /*****************************************************************************/ -void HieCfg_NumUsrsInCrss (Hie_Level_t Scope,long Cod,Rol_Role_t Role) +void HieCfg_NumUsrsInCrss (Hie_Lvl_Level_t Scope,long Cod,Rol_Role_t Role) { extern const char *Txt_Users_in_courses; extern const char *Txt_ROLES_PLURAL_Abc[Rol_NUM_ROLES][Usr_NUM_SEXS]; diff --git a/swad_hierarchy_config.h b/swad_hierarchy_config.h index fc208934..96af40d2 100644 --- a/swad_hierarchy_config.h +++ b/swad_hierarchy_config.h @@ -40,22 +40,22 @@ /*****************************************************************************/ void HieCfg_Title (bool PutLink, - Hie_Level_t LogoScope, + Hie_Lvl_Level_t LogoScope, long LogoCod, - char LogoShrtName[Hie_MAX_BYTES_SHRT_NAME + 1], - char LogoFullName[Hie_MAX_BYTES_FULL_NAME + 1], + char LogoShrtName[Cns_HIERARCHY_MAX_BYTES_SHRT_NAME + 1], + char LogoFullName[Cns_HIERARCHY_MAX_BYTES_FULL_NAME + 1], char LogoWWW[Cns_MAX_BYTES_WWW + 1], - char TextFullName[Hie_MAX_BYTES_FULL_NAME + 1]); + char TextFullName[Cns_HIERARCHY_MAX_BYTES_FULL_NAME + 1]); void HieCfg_FullName (bool PutForm,const char *Label,Act_Action_t NextAction, - const char FullName[Hie_MAX_BYTES_FULL_NAME + 1]); + const char FullName[Cns_HIERARCHY_MAX_BYTES_FULL_NAME + 1]); void HieCfg_ShrtName (bool PutForm,Act_Action_t NextAction, - const char ShrtName[Hie_MAX_BYTES_SHRT_NAME + 1]); + const char ShrtName[Cns_HIERARCHY_MAX_BYTES_SHRT_NAME + 1]); void HieCfg_WWW (bool PrintView,bool PutForm,Act_Action_t NextAction, const char WWW[Cns_MAX_BYTES_WWW + 1]); void HieCfg_Shortcut (bool PrintView,const char *ParamName,long HieCod); void HieCfg_NumCtrs (unsigned NumCtrs,bool PutForm); void HieCfg_NumCtrsWithMap (unsigned NumCtrs,unsigned NumCtrsWithMap); void HieCfg_QR (const char *ParamName,long HieCod); -void HieCfg_NumUsrsInCrss (Hie_Level_t Scope,long Cod,Rol_Role_t Role); +void HieCfg_NumUsrsInCrss (Hie_Lvl_Level_t Scope,long Cod,Rol_Role_t Role); #endif diff --git a/swad_hierarchy_level.h b/swad_hierarchy_level.h new file mode 100644 index 00000000..67ddd6d9 --- /dev/null +++ b/swad_hierarchy_level.h @@ -0,0 +1,55 @@ +// swad_hierarchy_level.h: hierarchy levels: system, institution, centre, degree, course + +#ifndef _SWAD_HIE_LVL +#define _SWAD_HIE_LVL +/* + SWAD (Shared Workspace At a Distance in Spanish), + is a web platform developed at the University of Granada (Spain), + and used to support university teaching. + + This file is part of SWAD core. + Copyright (C) 1999-2021 Antonio Cañas Vargas + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as + published by the Free Software Foundation, either version 3 of the + License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . +*/ +/*****************************************************************************/ +/********************************* Headers ***********************************/ +/*****************************************************************************/ + +/*****************************************************************************/ +/***************************** Public constants ******************************/ +/*****************************************************************************/ + +/*****************************************************************************/ +/******************************* Public types ********************************/ +/*****************************************************************************/ + +// Levels in the hierarchy +#define Hie_Lvl_NUM_LEVELS 7 +typedef enum + { + Hie_Lvl_UNK = 0, // Unknown + Hie_Lvl_SYS = 1, // System + Hie_Lvl_CTY = 2, // Country + Hie_Lvl_INS = 3, // Institution + Hie_Lvl_CTR = 4, // Centre + Hie_Lvl_DEG = 5, // Degree + Hie_Lvl_CRS = 6, // Course + } Hie_Lvl_Level_t; + +/*****************************************************************************/ +/***************************** Public prototypes *****************************/ +/*****************************************************************************/ + +#endif diff --git a/swad_indicator.c b/swad_indicator.c index d6ff3e46..e89bc533 100644 --- a/swad_indicator.c +++ b/swad_indicator.c @@ -237,17 +237,17 @@ void Ind_ReqIndicatorsCourses (void) static void Ind_GetParamsIndicators (struct Ind_Indicators *Indicators) { /***** Get scope *****/ - Gbl.Scope.Allowed = 1 << Hie_SYS | - 1 << Hie_CTY | - 1 << Hie_INS | - 1 << Hie_CTR | - 1 << Hie_DEG | - 1 << Hie_CRS; - Gbl.Scope.Default = Hie_CRS; + Gbl.Scope.Allowed = 1 << Hie_Lvl_SYS | + 1 << Hie_Lvl_CTY | + 1 << Hie_Lvl_INS | + 1 << Hie_Lvl_CTR | + 1 << Hie_Lvl_DEG | + 1 << Hie_Lvl_CRS; + Gbl.Scope.Default = Hie_Lvl_CRS; Sco_GetScope ("ScopeInd"); /***** Get degree type code *****/ - Indicators->DegTypCod = (Gbl.Scope.Current == Hie_SYS) ? + Indicators->DegTypCod = (Gbl.Scope.Current == Hie_Lvl_SYS) ? DT_GetAndCheckParamOtherDegTypCod (-1L) : // -1L (any degree type) is allowed here -1L; @@ -348,7 +348,7 @@ static unsigned Ind_GetTableOfCourses (const struct Ind_Indicators *Indicators, switch (Gbl.Scope.Current) { - case Hie_SYS: + case Hie_Lvl_SYS: if (Indicators->DptCod >= 0) // 0 means another department { if (Indicators->DegTypCod > 0) @@ -400,7 +400,7 @@ static unsigned Ind_GetTableOfCourses (const struct Ind_Indicators *Indicators, " ORDER BY degrees.FullName,courses.FullName"); } break; - case Hie_CTY: + case Hie_Lvl_CTY: if (Indicators->DptCod >= 0) // 0 means another department NumCrss = (unsigned) DB_QuerySELECT (mysql_res,"can not get courses", @@ -430,7 +430,7 @@ static unsigned Ind_GetTableOfCourses (const struct Ind_Indicators *Indicators, " ORDER BY degrees.FullName,courses.FullName", Gbl.Hierarchy.Cty.CtyCod); break; - case Hie_INS: + case Hie_Lvl_INS: if (Indicators->DptCod >= 0) // 0 means another department NumCrss = (unsigned) DB_QuerySELECT (mysql_res,"can not get courses", @@ -458,7 +458,7 @@ static unsigned Ind_GetTableOfCourses (const struct Ind_Indicators *Indicators, " ORDER BY degrees.FullName,courses.FullName", Gbl.Hierarchy.Ins.InsCod); break; - case Hie_CTR: + case Hie_Lvl_CTR: if (Indicators->DptCod >= 0) // 0 means another department NumCrss = (unsigned) DB_QuerySELECT (mysql_res,"can not get courses", @@ -484,7 +484,7 @@ static unsigned Ind_GetTableOfCourses (const struct Ind_Indicators *Indicators, " ORDER BY degrees.FullName,courses.FullName", Gbl.Hierarchy.Ctr.CtrCod); break; - case Hie_DEG: + case Hie_Lvl_DEG: if (Indicators->DptCod >= 0) // 0 means another department NumCrss = (unsigned) DB_QuerySELECT (mysql_res,"can not get courses", @@ -510,7 +510,7 @@ static unsigned Ind_GetTableOfCourses (const struct Ind_Indicators *Indicators, " ORDER BY degrees.FullName,courses.FullName", Gbl.Hierarchy.Deg.DegCod); break; - case Hie_CRS: + case Hie_Lvl_CRS: if (Indicators->DptCod >= 0) // 0 means another department NumCrss = (unsigned) DB_QuerySELECT (mysql_res,"can not get courses", @@ -1018,10 +1018,10 @@ static void Ind_ShowTableOfCoursesWithIndicators (const struct Ind_Indicators *I break; case Ind_INDICATORS_FULL: /* Get number of users */ - NumTchs = Usr_GetNumUsrsInCrss (Hie_CRS,CrsCod, + NumTchs = Usr_GetNumUsrsInCrss (Hie_Lvl_CRS,CrsCod, 1 << Rol_NET | // Non-editing teachers 1 << Rol_TCH); // Teachers - NumStds = Usr_GetNumUsrsInCrss (Hie_CRS,CrsCod, + NumStds = Usr_GetNumUsrsInCrss (Hie_Lvl_CRS,CrsCod, 1 << Rol_STD); // Students HTM_TR_Begin (NULL); diff --git a/swad_institution.c b/swad_institution.c index 076cbecb..5a268a07 100644 --- a/swad_institution.c +++ b/swad_institution.c @@ -37,6 +37,7 @@ #include "swad_form.h" #include "swad_forum.h" #include "swad_global.h" +#include "swad_hierarchy.h" #include "swad_HTML.h" #include "swad_institution.h" #include "swad_logo.h" @@ -83,7 +84,7 @@ static void Ins_PutIconToViewInstitutions (void); static void Ins_GetDataOfInstitFromRow (struct Ins_Instit *Ins,MYSQL_ROW row); static void Ins_GetShrtNameAndCtyOfInstitution (struct Ins_Instit *Ins, - char CtyName[Hie_MAX_BYTES_FULL_NAME + 1]); + char CtyName[Cns_HIERARCHY_MAX_BYTES_FULL_NAME + 1]); static void Ins_ListInstitutionsForEdition (void); static bool Ins_CheckIfICanEdit (struct Ins_Instit *Ins); @@ -230,7 +231,7 @@ void Ins_DrawInstitutionLogoWithLink (struct Ins_Instit *Ins,unsigned Size) Ins_PutParamInsCod (Ins->InsCod); HTM_BUTTON_SUBMIT_Begin (Ins->FullName,"BT_LINK",NULL); } - Lgo_DrawLogo (Hie_INS,Ins->InsCod,Ins->FullName, + Lgo_DrawLogo (Hie_Lvl_INS,Ins->InsCod,Ins->FullName, Size,NULL,true); if (PutLink) { @@ -255,7 +256,7 @@ void Ins_DrawInstitutionLogoAndNameWithLink (struct Ins_Instit *Ins,Act_Action_t Hie_FreeGoToMsg (); /***** Institution logo and name *****/ - Lgo_DrawLogo (Hie_INS,Ins->InsCod,Ins->ShrtName,16,ClassLogo,true); + Lgo_DrawLogo (Hie_Lvl_INS,Ins->InsCod,Ins->ShrtName,16,ClassLogo,true); HTM_TxtF (" %s",Ins->FullName); /***** End link *****/ @@ -442,7 +443,7 @@ static void Ins_ListOneInstitutionForSeeing (struct Ins_Instit *Ins,unsigned Num /* Number of users in courses of this institution */ HTM_TD_Begin ("class=\"%s RM %s\"",TxtClassNormal,BgColor); - HTM_Unsigned (Usr_GetCachedNumUsrsInCrss (Hie_INS,Ins->InsCod, + HTM_Unsigned (Usr_GetCachedNumUsrsInCrss (Hie_Lvl_INS,Ins->InsCod, 1 << Rol_STD | 1 << Rol_NET | 1 << Rol_TCH)); // Any user); @@ -768,7 +769,7 @@ void Ins_GetFullListOfInstitutions (long CtyCod) void Ins_WriteInstitutionNameAndCty (long InsCod) { struct Ins_Instit Ins; - char CtyName[Hie_MAX_BYTES_FULL_NAME + 1]; + char CtyName[Cns_HIERARCHY_MAX_BYTES_FULL_NAME + 1]; /***** Get institution short name and country name *****/ Ins.InsCod = InsCod; @@ -849,11 +850,11 @@ static void Ins_GetDataOfInstitFromRow (struct Ins_Instit *Ins,MYSQL_ROW row) /***** Get the short name of the institution (row[4]) *****/ Str_Copy (Ins->ShrtName,row[4], - Hie_MAX_BYTES_SHRT_NAME); + Cns_HIERARCHY_MAX_BYTES_SHRT_NAME); /***** Get the full name of the institution (row[5]) *****/ Str_Copy (Ins->FullName,row[5], - Hie_MAX_BYTES_FULL_NAME); + Cns_HIERARCHY_MAX_BYTES_FULL_NAME); /***** Get the URL of the institution (row[6]) *****/ Str_Copy (Ins->WWW,row[6], @@ -886,7 +887,7 @@ void Ins_GetShortNameOfInstitution (struct Ins_Instit *Ins) if (Ins->InsCod == Gbl.Cache.InstitutionShrtName.InsCod) { Str_Copy (Ins->ShrtName,Gbl.Cache.InstitutionShrtName.ShrtName, - Hie_MAX_BYTES_SHRT_NAME); + Cns_HIERARCHY_MAX_BYTES_SHRT_NAME); return; } @@ -903,7 +904,7 @@ void Ins_GetShortNameOfInstitution (struct Ins_Instit *Ins) row = mysql_fetch_row (mysql_res); Str_Copy (Gbl.Cache.InstitutionShrtName.ShrtName,row[0], - Hie_MAX_BYTES_SHRT_NAME); + Cns_HIERARCHY_MAX_BYTES_SHRT_NAME); } else Gbl.Cache.InstitutionShrtName.ShrtName[0] = '\0'; @@ -912,7 +913,7 @@ void Ins_GetShortNameOfInstitution (struct Ins_Instit *Ins) DB_FreeMySQLResult (&mysql_res); Str_Copy (Ins->ShrtName,Gbl.Cache.InstitutionShrtName.ShrtName, - Hie_MAX_BYTES_SHRT_NAME); + Cns_HIERARCHY_MAX_BYTES_SHRT_NAME); } /*****************************************************************************/ @@ -927,7 +928,7 @@ void Ins_FlushCacheFullNameAndCtyOfInstitution (void) } static void Ins_GetShrtNameAndCtyOfInstitution (struct Ins_Instit *Ins, - char CtyName[Hie_MAX_BYTES_FULL_NAME + 1]) + char CtyName[Cns_HIERARCHY_MAX_BYTES_FULL_NAME + 1]) { extern const char *Lan_STR_LANG_ID[1 + Lan_NUM_LANGUAGES]; MYSQL_RES *mysql_res; @@ -945,9 +946,9 @@ static void Ins_GetShrtNameAndCtyOfInstitution (struct Ins_Instit *Ins, if (Ins->InsCod == Gbl.Cache.InstitutionShrtNameAndCty.InsCod) { Str_Copy (Ins->ShrtName,Gbl.Cache.InstitutionShrtNameAndCty.ShrtName, - Hie_MAX_BYTES_SHRT_NAME); + Cns_HIERARCHY_MAX_BYTES_SHRT_NAME); Str_Copy (CtyName,Gbl.Cache.InstitutionShrtNameAndCty.CtyName, - Hie_MAX_BYTES_FULL_NAME); + Cns_HIERARCHY_MAX_BYTES_FULL_NAME); return; } @@ -967,11 +968,11 @@ static void Ins_GetShrtNameAndCtyOfInstitution (struct Ins_Instit *Ins, /* Get the short name of this institution (row[0]) */ Str_Copy (Gbl.Cache.InstitutionShrtNameAndCty.ShrtName,row[0], - Hie_MAX_BYTES_SHRT_NAME); + Cns_HIERARCHY_MAX_BYTES_SHRT_NAME); /* Get the name of the country (row[1]) */ Str_Copy (Gbl.Cache.InstitutionShrtNameAndCty.CtyName,row[1], - Hie_MAX_BYTES_FULL_NAME); + Cns_HIERARCHY_MAX_BYTES_FULL_NAME); } else { @@ -983,9 +984,9 @@ static void Ins_GetShrtNameAndCtyOfInstitution (struct Ins_Instit *Ins, DB_FreeMySQLResult (&mysql_res); Str_Copy (Ins->ShrtName,Gbl.Cache.InstitutionShrtNameAndCty.ShrtName, - Hie_MAX_BYTES_SHRT_NAME); + Cns_HIERARCHY_MAX_BYTES_SHRT_NAME); Str_Copy (CtyName,Gbl.Cache.InstitutionShrtNameAndCty.CtyName, - Hie_MAX_BYTES_FULL_NAME); + Cns_HIERARCHY_MAX_BYTES_FULL_NAME); } /*****************************************************************************/ @@ -1103,7 +1104,7 @@ static void Ins_ListInstitutionsForEdition (void) ICanEdit = Ins_CheckIfICanEdit (Ins); NumCtrs = Ctr_GetNumCtrsInIns (Ins->InsCod); NumUsrsIns = Usr_GetNumUsrsWhoClaimToBelongToIns (Ins); - NumUsrsInCrssOfIns = Usr_GetNumUsrsInCrss (Hie_INS,Ins->InsCod, + NumUsrsInCrssOfIns = Usr_GetNumUsrsInCrss (Hie_Lvl_INS,Ins->InsCod, 1 << Rol_STD | 1 << Rol_NET | 1 << Rol_TCH); // Any user @@ -1130,7 +1131,7 @@ static void Ins_ListInstitutionsForEdition (void) /* Institution logo */ HTM_TD_Begin ("title=\"%s\" class=\"HIE_LOGO\"",Ins->FullName); - Lgo_DrawLogo (Hie_INS,Ins->InsCod,Ins->ShrtName,20,NULL,true); + Lgo_DrawLogo (Hie_Lvl_INS,Ins->InsCod,Ins->ShrtName,20,NULL,true); HTM_TD_End (); /* Institution short name */ @@ -1139,7 +1140,7 @@ static void Ins_ListInstitutionsForEdition (void) { Frm_StartForm (ActRenInsSho); Ins_PutParamOtherInsCod (&Ins->InsCod); - HTM_INPUT_TEXT ("ShortName",Hie_MAX_CHARS_SHRT_NAME,Ins->ShrtName, + HTM_INPUT_TEXT ("ShortName",Cns_HIERARCHY_MAX_CHARS_SHRT_NAME,Ins->ShrtName, HTM_SUBMIT_ON_CHANGE, "class=\"INPUT_SHORT_NAME\""); Frm_EndForm (); @@ -1154,7 +1155,7 @@ static void Ins_ListInstitutionsForEdition (void) { Frm_StartForm (ActRenInsFul); Ins_PutParamOtherInsCod (&Ins->InsCod); - HTM_INPUT_TEXT ("FullName",Hie_MAX_CHARS_FULL_NAME,Ins->FullName, + HTM_INPUT_TEXT ("FullName",Cns_HIERARCHY_MAX_CHARS_FULL_NAME,Ins->FullName, HTM_SUBMIT_ON_CHANGE, "class=\"INPUT_FULL_NAME\""); Frm_EndForm (); @@ -1373,7 +1374,7 @@ void Ins_RemoveInstitution (void) // Institution has users ==> don't remove Ale_CreateAlert (Ale_WARNING,NULL, Txt_To_remove_an_institution_you_must_first_remove_all_centres_and_users_in_the_institution); - else if (Usr_GetNumUsrsInCrss (Hie_INS,Ins_EditingIns->InsCod, + else if (Usr_GetNumUsrsInCrss (Hie_Lvl_INS,Ins_EditingIns->InsCod, 1 << Rol_STD | 1 << Rol_NET | 1 << Rol_TCH)) // Any user @@ -1383,10 +1384,10 @@ void Ins_RemoveInstitution (void) else // Institution has no users ==> remove it { /***** Remove all the threads and posts in forums of the institution *****/ - For_RemoveForums (Hie_INS,Ins_EditingIns->InsCod); + For_RemoveForums (Hie_Lvl_INS,Ins_EditingIns->InsCod); /***** Remove surveys of the institution *****/ - Svy_RemoveSurveys (Hie_INS,Ins_EditingIns->InsCod); + Svy_RemoveSurveys (Hie_Lvl_INS,Ins_EditingIns->InsCod); /***** Remove information related to files in institution *****/ Brw_RemoveInsFilesFromDB (Ins_EditingIns->InsCod); @@ -1459,20 +1460,20 @@ void Ins_RenameInstitution (struct Ins_Instit *Ins,Cns_ShrtOrFullName_t ShrtOrFu const char *FieldName = NULL; // Initialized to avoid warning unsigned MaxBytes = 0; // Initialized to avoid warning char *CurrentInsName = NULL; // Initialized to avoid warning - char NewInsName[Hie_MAX_BYTES_FULL_NAME + 1]; + char NewInsName[Cns_HIERARCHY_MAX_BYTES_FULL_NAME + 1]; switch (ShrtOrFullName) { case Cns_SHRT_NAME: ParamName = "ShortName"; FieldName = "ShortName"; - MaxBytes = Hie_MAX_BYTES_SHRT_NAME; + MaxBytes = Cns_HIERARCHY_MAX_BYTES_SHRT_NAME; CurrentInsName = Ins->ShrtName; break; case Cns_FULL_NAME: ParamName = "FullName"; FieldName = "FullName"; - MaxBytes = Hie_MAX_BYTES_FULL_NAME; + MaxBytes = Cns_HIERARCHY_MAX_BYTES_FULL_NAME; CurrentInsName = Ins->FullName; break; } @@ -1732,19 +1733,19 @@ static void Ins_PutFormToCreateInstitution (void) /***** Institution logo *****/ HTM_TD_Begin ("title=\"%s\" class=\"HIE_LOGO\"",Ins_EditingIns->FullName); - Lgo_DrawLogo (Hie_INS,-1L,"",20,NULL,true); + Lgo_DrawLogo (Hie_Lvl_INS,-1L,"",20,NULL,true); HTM_TD_End (); /***** Institution short name *****/ HTM_TD_Begin ("class=\"LM\""); - HTM_INPUT_TEXT ("ShortName",Hie_MAX_CHARS_SHRT_NAME,Ins_EditingIns->ShrtName, + HTM_INPUT_TEXT ("ShortName",Cns_HIERARCHY_MAX_CHARS_SHRT_NAME,Ins_EditingIns->ShrtName, HTM_DONT_SUBMIT_ON_CHANGE, "class=\"INPUT_SHORT_NAME\" required=\"required\""); HTM_TD_End (); /***** Institution full name *****/ HTM_TD_Begin ("class=\"LM\""); - HTM_INPUT_TEXT ("FullName",Hie_MAX_CHARS_FULL_NAME,Ins_EditingIns->FullName, + HTM_INPUT_TEXT ("FullName",Cns_HIERARCHY_MAX_CHARS_FULL_NAME,Ins_EditingIns->FullName, HTM_DONT_SUBMIT_ON_CHANGE, "class=\"INPUT_FULL_NAME\" required=\"required\""); HTM_TD_End (); @@ -1866,10 +1867,10 @@ static void Ins_ReceiveFormRequestOrCreateIns (unsigned Status) Ins_EditingIns->CtyCod = Gbl.Hierarchy.Cty.CtyCod; /* Get institution short name */ - Par_GetParToText ("ShortName",Ins_EditingIns->ShrtName,Hie_MAX_BYTES_SHRT_NAME); + Par_GetParToText ("ShortName",Ins_EditingIns->ShrtName,Cns_HIERARCHY_MAX_BYTES_SHRT_NAME); /* Get institution full name */ - Par_GetParToText ("FullName",Ins_EditingIns->FullName,Hie_MAX_BYTES_FULL_NAME); + Par_GetParToText ("FullName",Ins_EditingIns->FullName,Cns_HIERARCHY_MAX_BYTES_FULL_NAME); /* Get institution WWW */ Par_GetParToText ("WWW",Ins_EditingIns->WWW,Cns_MAX_BYTES_WWW); @@ -1937,12 +1938,12 @@ unsigned Ins_GetCachedNumInssInSys (void) unsigned NumInss; /***** Get number of institutions from cache *****/ - if (!FigCch_GetFigureFromCache (FigCch_NUM_INSS,Hie_SYS,-1L, + if (!FigCch_GetFigureFromCache (FigCch_NUM_INSS,Hie_Lvl_SYS,-1L, FigCch_UNSIGNED,&NumInss)) { /***** Get current number of institutions from database and update cache *****/ NumInss = (unsigned) DB_GetNumRowsTable ("institutions"); - FigCch_UpdateFigureIntoCache (FigCch_NUM_INSS,Hie_SYS,-1L, + FigCch_UpdateFigureIntoCache (FigCch_NUM_INSS,Hie_Lvl_SYS,-1L, FigCch_UNSIGNED,&NumInss); } @@ -1974,7 +1975,7 @@ unsigned Ins_GetNumInssInCty (long CtyCod) " WHERE CtyCod=%ld", CtyCod); Gbl.Cache.NumInssInCty.Valid = true; - FigCch_UpdateFigureIntoCache (FigCch_NUM_INSS,Hie_CTY,Gbl.Cache.NumInssInCty.CtyCod, + FigCch_UpdateFigureIntoCache (FigCch_NUM_INSS,Hie_Lvl_CTY,Gbl.Cache.NumInssInCty.CtyCod, FigCch_UNSIGNED,&Gbl.Cache.NumInssInCty.NumInss); return Gbl.Cache.NumInssInCty.NumInss; } @@ -1984,7 +1985,7 @@ unsigned Ins_GetCachedNumInssInCty (long CtyCod) unsigned NumInss; /***** Get number of institutions from cache *****/ - if (!FigCch_GetFigureFromCache (FigCch_NUM_INSS,Hie_CTY,CtyCod, + if (!FigCch_GetFigureFromCache (FigCch_NUM_INSS,Hie_Lvl_CTY,CtyCod, FigCch_UNSIGNED,&NumInss)) /***** Get current number of institutions from database and update cache *****/ NumInss = Ins_GetNumInssInCty (CtyCod); @@ -1997,7 +1998,7 @@ unsigned Ins_GetCachedNumInssInCty (long CtyCod) /*****************************************************************************/ unsigned Ins_GetCachedNumInssWithCtrs (const char *SubQuery, - Hie_Level_t Scope,long Cod) + Hie_Lvl_Level_t Scope,long Cod) { unsigned NumInssWithCtrs; @@ -2024,7 +2025,7 @@ unsigned Ins_GetCachedNumInssWithCtrs (const char *SubQuery, /*****************************************************************************/ unsigned Ins_GetCachedNumInssWithDegs (const char *SubQuery, - Hie_Level_t Scope,long Cod) + Hie_Lvl_Level_t Scope,long Cod) { unsigned NumInssWithDegs; @@ -2052,7 +2053,7 @@ unsigned Ins_GetCachedNumInssWithDegs (const char *SubQuery, /*****************************************************************************/ unsigned Ins_GetCachedNumInssWithCrss (const char *SubQuery, - Hie_Level_t Scope,long Cod) + Hie_Lvl_Level_t Scope,long Cod) { unsigned NumInssWithCrss; @@ -2081,7 +2082,7 @@ unsigned Ins_GetCachedNumInssWithCrss (const char *SubQuery, /*****************************************************************************/ unsigned Ins_GetCachedNumInssWithUsrs (Rol_Role_t Role,const char *SubQuery, - Hie_Level_t Scope,long Cod) + Hie_Lvl_Level_t Scope,long Cod) { static const FigCch_FigureCached_t FigureInss[Rol_NUM_ROLES] = { diff --git a/swad_institution.h b/swad_institution.h index a4ef6a2a..3ac98820 100644 --- a/swad_institution.h +++ b/swad_institution.h @@ -62,8 +62,8 @@ struct Ins_Instit long CtyCod; Ins_Status_t Status; // Institution status long RequesterUsrCod; // User code of the person who requested the creation of this institution - char ShrtName[Hie_MAX_BYTES_SHRT_NAME + 1]; - char FullName[Hie_MAX_BYTES_FULL_NAME + 1]; + char ShrtName[Cns_HIERARCHY_MAX_BYTES_SHRT_NAME + 1]; + char FullName[Cns_HIERARCHY_MAX_BYTES_FULL_NAME + 1]; char WWW[Cns_MAX_BYTES_WWW + 1]; struct { @@ -136,13 +136,13 @@ unsigned Ins_GetNumInssInCty (long CtyCod); unsigned Ins_GetCachedNumInssInCty (long CtyCod); unsigned Ins_GetCachedNumInssWithCtrs (const char *SubQuery, - Hie_Level_t Scope,long Cod); + Hie_Lvl_Level_t Scope,long Cod); unsigned Ins_GetCachedNumInssWithDegs (const char *SubQuery, - Hie_Level_t Scope,long Cod); + Hie_Lvl_Level_t Scope,long Cod); unsigned Ins_GetCachedNumInssWithCrss (const char *SubQuery, - Hie_Level_t Scope,long Cod); + Hie_Lvl_Level_t Scope,long Cod); unsigned Ins_GetCachedNumInssWithUsrs (Rol_Role_t Role,const char *SubQuery, - Hie_Level_t Scope,long Cod); + Hie_Lvl_Level_t Scope,long Cod); void Ins_ListInssFound (MYSQL_RES **mysql_res,unsigned NumInss); diff --git a/swad_institution_config.c b/swad_institution_config.c index 67809e46..046b20a7 100644 --- a/swad_institution_config.c +++ b/swad_institution_config.c @@ -37,6 +37,7 @@ #include "swad_form.h" #include "swad_global.h" #include "swad_help.h" +#include "swad_hierarchy.h" #include "swad_hierarchy_config.h" #include "swad_HTML.h" #include "swad_institution.h" @@ -182,10 +183,10 @@ static void InsCfg_Configuration (bool PrintView) InsCfg_NumDpts (); /***** Number of users in courses of this institution *****/ - HieCfg_NumUsrsInCrss (Hie_INS,Gbl.Hierarchy.Ins.InsCod,Rol_TCH); - HieCfg_NumUsrsInCrss (Hie_INS,Gbl.Hierarchy.Ins.InsCod,Rol_NET); - HieCfg_NumUsrsInCrss (Hie_INS,Gbl.Hierarchy.Ins.InsCod,Rol_STD); - HieCfg_NumUsrsInCrss (Hie_INS,Gbl.Hierarchy.Ins.InsCod,Rol_UNK); + HieCfg_NumUsrsInCrss (Hie_Lvl_INS,Gbl.Hierarchy.Ins.InsCod,Rol_TCH); + HieCfg_NumUsrsInCrss (Hie_Lvl_INS,Gbl.Hierarchy.Ins.InsCod,Rol_NET); + HieCfg_NumUsrsInCrss (Hie_Lvl_INS,Gbl.Hierarchy.Ins.InsCod,Rol_STD); + HieCfg_NumUsrsInCrss (Hie_Lvl_INS,Gbl.Hierarchy.Ins.InsCod,Rol_UNK); } /***** End table *****/ @@ -221,7 +222,7 @@ static void InsCfg_PutIconsToPrintAndUpload (__attribute__((unused)) void *Args) if (Gbl.Usrs.Me.Role.Logged >= Rol_INS_ADM) /***** Icon to upload logo of institution *****/ - Lgo_PutIconToChangeLogo (Hie_INS); + Lgo_PutIconToChangeLogo (Hie_Lvl_INS); /***** Put icon to view places *****/ Plc_PutIconToViewPlaces (); @@ -234,7 +235,7 @@ static void InsCfg_PutIconsToPrintAndUpload (__attribute__((unused)) void *Args) static void InsCfg_Title (bool PutLink) { HieCfg_Title (PutLink, - Hie_INS, // Logo scope + Hie_Lvl_INS, // Logo scope Gbl.Hierarchy.Ins.InsCod, // Logo code Gbl.Hierarchy.Ins.ShrtName, // Logo short name Gbl.Hierarchy.Ins.FullName, // Logo full name @@ -549,7 +550,7 @@ static void InsCfg_NumDpts (void) void InsCfg_RequestLogo (void) { - Lgo_RequestLogo (Hie_INS); + Lgo_RequestLogo (Hie_Lvl_INS); } /*****************************************************************************/ @@ -558,7 +559,7 @@ void InsCfg_RequestLogo (void) void InsCfg_ReceiveLogo (void) { - Lgo_ReceiveLogo (Hie_INS); + Lgo_ReceiveLogo (Hie_Lvl_INS); } /*****************************************************************************/ @@ -567,7 +568,7 @@ void InsCfg_ReceiveLogo (void) void InsCfg_RemoveLogo (void) { - Lgo_RemoveLogo (Hie_INS); + Lgo_RemoveLogo (Hie_Lvl_INS); } /*****************************************************************************/ @@ -578,7 +579,7 @@ void InsCfg_ChangeInsCty (void) { extern const char *Txt_The_institution_X_already_exists; extern const char *Txt_The_country_of_the_institution_X_has_changed_to_Y; - struct Country NewCty; + struct Cty_Countr NewCty; /***** Get the new country code for the institution *****/ NewCty.CtyCod = Cty_GetAndCheckParamOtherCtyCod (0); diff --git a/swad_layout.c b/swad_layout.c index 66395008..7d63daf7 100644 --- a/swad_layout.c +++ b/swad_layout.c @@ -46,6 +46,7 @@ #include "swad_global.h" #include "swad_help.h" #include "swad_hierarchy.h" +#include "swad_hierarchy_level.h" #include "swad_holiday.h" #include "swad_HTML.h" #include "swad_language.h" @@ -446,7 +447,7 @@ static void Lay_WritePageTitle (void) if (Gbl.Params.GetMethod && Gbl.Hierarchy.Deg.DegCod > 0) { HTM_TxtF ("%s > %s",Cfg_PLATFORM_SHORT_NAME,Gbl.Hierarchy.Deg.ShrtName); - if (Gbl.Hierarchy.Level == Hie_CRS) + if (Gbl.Hierarchy.Level == Hie_Lvl_CRS) HTM_TxtF (" > %s",Gbl.Hierarchy.Crs.ShrtName); } else @@ -1162,7 +1163,7 @@ static void Lay_ShowLeftColumn (void) HTM_DIV_End (); /***** Notices (yellow notes) *****/ - if (Gbl.Hierarchy.Level == Hie_CRS) + if (Gbl.Hierarchy.Level == Hie_Lvl_CRS) { HTM_DIV_Begin ("class=\"LEFT_RIGHT_CELL\""); Not_ShowNotices (Not_LIST_BRIEF_NOTICES, @@ -1195,10 +1196,10 @@ static void Lay_ShowRightColumn (void) } /***** Number of connected users in the current course *****/ - if (Gbl.Hierarchy.Level == Hie_CRS) // There is a course selected + if (Gbl.Hierarchy.Level == Hie_Lvl_CRS) // There is a course selected { HTM_DIV_Begin ("id=\"courseconnected\" class=\"LEFT_RIGHT_CELL\""); // Used for AJAX based refresh - Gbl.Scope.Current = Hie_CRS; + Gbl.Scope.Current = Hie_Lvl_CRS; Con_ShowConnectedUsrsBelongingToCurrentCrs (); HTM_DIV_End (); // Used for AJAX based refresh } @@ -1613,7 +1614,7 @@ void Lay_RefreshNotifsAndConnected (void) { unsigned NumUsr; bool ShowConnected = (Gbl.Prefs.SideCols & Lay_SHOW_RIGHT_COLUMN) && - Gbl.Hierarchy.Level == Hie_CRS; // Right column visible && There is a course selected + Gbl.Hierarchy.Level == Hie_Lvl_CRS; // Right column visible && There is a course selected /***** Sometimes, someone must do this work, so who best than processes that refresh via AJAX? *****/ @@ -1654,7 +1655,7 @@ void Lay_RefreshNotifsAndConnected (void) HTM_Txt ("|"); if (ShowConnected) { - Gbl.Scope.Current = Hie_CRS; + Gbl.Scope.Current = Hie_Lvl_CRS; Con_ShowConnectedUsrsBelongingToCurrentCrs (); } HTM_Txt ("|"); @@ -1738,7 +1739,7 @@ void Lay_WriteHeaderClassPhoto (bool PrintView,bool DrawingClassPhoto, { if (!PrintView) HTM_A_Begin ("href=\"%s\" target=\"_blank\"",Ins.WWW); - Lgo_DrawLogo (Hie_INS,Ins.InsCod,Ins.ShrtName,40,NULL,true); + Lgo_DrawLogo (Hie_Lvl_INS,Ins.InsCod,Ins.ShrtName,40,NULL,true); if (!PrintView) HTM_A_End (); } @@ -1785,7 +1786,7 @@ void Lay_WriteHeaderClassPhoto (bool PrintView,bool DrawingClassPhoto, if (!PrintView) HTM_A_Begin ("href=\"%s\" target=\"_blank\" class=\"CLASSPHOTO_TITLE\"", Deg.WWW); - Lgo_DrawLogo (Hie_DEG,Deg.DegCod,Deg.ShrtName,40,NULL,true); + Lgo_DrawLogo (Hie_Lvl_DEG,Deg.DegCod,Deg.ShrtName,40,NULL,true); if (!PrintView) HTM_A_End (); } diff --git a/swad_log.c b/swad_log.c index 3158fe2d..1c2414d5 100644 --- a/swad_log.c +++ b/swad_log.c @@ -262,7 +262,7 @@ void Log_GetAndShowLastClicks (void) Act_Action_t Action; const char *ClassRow; time_t TimeDiff; - struct Country Cty; + struct Cty_Countr Cty; struct Ins_Instit Ins; struct Ctr_Centre Ctr; struct Deg_Degree Deg; diff --git a/swad_logo.c b/swad_logo.c index c7f3bdba..a058e68c 100644 --- a/swad_logo.c +++ b/swad_logo.c @@ -73,18 +73,18 @@ static void Lgo_PutIconToRemoveLogo (Act_Action_t ActionRem); /****************************** Draw degree logo *****************************/ /*****************************************************************************/ -void Lgo_DrawLogo (Hie_Level_t Scope,long Cod,const char *AltText, +void Lgo_DrawLogo (Hie_Lvl_Level_t Scope,long Cod,const char *AltText, unsigned Size,const char *Class,bool PutIconIfNotExists) { - static const char *HieIcon[Hie_NUM_LEVELS] = + static const char *HieIcon[Hie_Lvl_NUM_LEVELS] = { - [Hie_UNK] = "sitemap.svg", // not applicable here - [Hie_SYS] = "sitemap.svg", // not applicable here - [Hie_CTY] = "sitemap.svg", // not applicable here - [Hie_INS] = "university.svg", - [Hie_CTR] = "building.svg", - [Hie_DEG] = "graduation-cap.svg", - [Hie_CRS] = "sitemap.svg", // not applicable here + [Hie_Lvl_UNK] = "sitemap.svg", // not applicable here + [Hie_Lvl_SYS] = "sitemap.svg", // not applicable here + [Hie_Lvl_CTY] = "sitemap.svg", // not applicable here + [Hie_Lvl_INS] = "university.svg", + [Hie_Lvl_CTR] = "building.svg", + [Hie_Lvl_DEG] = "graduation-cap.svg", + [Hie_Lvl_CRS] = "sitemap.svg", // not applicable here }; const char *Folder = NULL; // To avoid warning char PathLogo[PATH_MAX + 1]; @@ -102,7 +102,7 @@ void Lgo_DrawLogo (Hie_Level_t Scope,long Cod,const char *AltText, if (Cod > 0) // Institution, centre or degree exists { /* Degree */ - if (Scope == Hie_DEG) + if (Scope == Hie_Lvl_DEG) { Folder = Cfg_FOLDER_DEG; DegCod = Cod; @@ -118,10 +118,10 @@ void Lgo_DrawLogo (Hie_Level_t Scope,long Cod,const char *AltText, } /* Centre */ - if (!LogoFound && Scope != Hie_INS) + if (!LogoFound && Scope != Hie_Lvl_INS) { Folder = Cfg_FOLDER_CTR; - if (Scope == Hie_DEG) // && !LogoFound + if (Scope == Hie_Lvl_DEG) // && !LogoFound CtrCod = Deg_GetCtrCodOfDegreeByCod (Cod); else CtrCod = Cod; @@ -140,9 +140,9 @@ void Lgo_DrawLogo (Hie_Level_t Scope,long Cod,const char *AltText, if (!LogoFound) { Folder = Cfg_FOLDER_INS; - if (Scope == Hie_DEG) // && !LogoFound + if (Scope == Hie_Lvl_DEG) // && !LogoFound InsCod = Deg_GetInsCodOfDegreeByCod (Cod); - else if (Scope == Hie_CTR) // && !LogoFound + else if (Scope == Hie_Lvl_CTR) // && !LogoFound InsCod = Ctr_GetInsCodOfCentreByCod (Cod); else InsCod = Cod; @@ -200,7 +200,7 @@ void Lgo_DrawLogo (Hie_Level_t Scope,long Cod,const char *AltText, /************* the logo of institution, centre or degree ***************/ /*****************************************************************************/ -void Lgo_PutIconToChangeLogo (Hie_Level_t Scope) +void Lgo_PutIconToChangeLogo (Hie_Lvl_Level_t Scope) { extern const char *Txt_Change_logo; extern const char *Txt_Upload_logo; @@ -213,17 +213,17 @@ void Lgo_PutIconToChangeLogo (Hie_Level_t Scope) /***** Set variables depending on scope *****/ switch (Scope) { - case Hie_INS: + case Hie_Lvl_INS: Action = ActReqInsLog; Cod = Gbl.Hierarchy.Ins.InsCod; Folder = Cfg_FOLDER_INS; break; - case Hie_CTR: + case Hie_Lvl_CTR: Action = ActReqCtrLog; Cod = Gbl.Hierarchy.Ctr.CtrCod; Folder = Cfg_FOLDER_CTR; break; - case Hie_DEG: + case Hie_Lvl_DEG: Action = ActReqDegLog; Cod = Gbl.Hierarchy.Deg.DegCod; Folder = Cfg_FOLDER_DEG; @@ -253,7 +253,7 @@ void Lgo_PutIconToChangeLogo (Hie_Level_t Scope) /**** Show a form for sending a logo of the institution, centre or degree ****/ /*****************************************************************************/ -void Lgo_RequestLogo (Hie_Level_t Scope) +void Lgo_RequestLogo (Hie_Lvl_Level_t Scope) { extern const char *The_ClassFormInBox[The_NUM_THEMES]; extern const char *Txt_Logo; @@ -268,19 +268,19 @@ void Lgo_RequestLogo (Hie_Level_t Scope) /***** Set action depending on scope *****/ switch (Scope) { - case Hie_INS: + case Hie_Lvl_INS: Cod = Gbl.Hierarchy.Ins.InsCod; Folder = Cfg_FOLDER_INS; ActionRec = ActRecInsLog; FunctionToDrawContextualIcons = Lgo_PutIconToRemoveLogoIns; break; - case Hie_CTR: + case Hie_Lvl_CTR: Cod = Gbl.Hierarchy.Ctr.CtrCod; Folder = Cfg_FOLDER_CTR; ActionRec = ActRecCtrLog; FunctionToDrawContextualIcons = Lgo_PutIconToRemoveLogoCtr; break; - case Hie_DEG: + case Hie_Lvl_DEG: Cod = Gbl.Hierarchy.Deg.DegCod; Folder = Cfg_FOLDER_DEG; ActionRec = ActRecDegLog; @@ -361,7 +361,7 @@ static void Lgo_PutIconToRemoveLogo (Act_Action_t ActionRem) /******* Receive the logo of the current institution, centre or degree *******/ /*****************************************************************************/ -void Lgo_ReceiveLogo (Hie_Level_t Scope) +void Lgo_ReceiveLogo (Hie_Lvl_Level_t Scope) { extern const char *Txt_The_file_is_not_X; long Cod; @@ -376,15 +376,15 @@ void Lgo_ReceiveLogo (Hie_Level_t Scope) /***** Set variables depending on scope *****/ switch (Scope) { - case Hie_INS: + case Hie_Lvl_INS: Cod = Gbl.Hierarchy.Ins.InsCod; Folder = Cfg_FOLDER_INS; break; - case Hie_CTR: + case Hie_Lvl_CTR: Cod = Gbl.Hierarchy.Ctr.CtrCod; Folder = Cfg_FOLDER_CTR; break; - case Hie_DEG: + case Hie_Lvl_DEG: Cod = Gbl.Hierarchy.Deg.DegCod; Folder = Cfg_FOLDER_DEG; break; @@ -447,7 +447,7 @@ void Lgo_ReceiveLogo (Hie_Level_t Scope) /******* Remove the logo of the current institution, centre or degree ********/ /*****************************************************************************/ -void Lgo_RemoveLogo (Hie_Level_t Scope) +void Lgo_RemoveLogo (Hie_Lvl_Level_t Scope) { long Cod; const char *Folder; @@ -456,15 +456,15 @@ void Lgo_RemoveLogo (Hie_Level_t Scope) /***** Set variables depending on scope *****/ switch (Scope) { - case Hie_INS: + case Hie_Lvl_INS: Cod = Gbl.Hierarchy.Ins.InsCod; Folder = Cfg_FOLDER_INS; break; - case Hie_CTR: + case Hie_Lvl_CTR: Cod = Gbl.Hierarchy.Ctr.CtrCod; Folder = Cfg_FOLDER_CTR; break; - case Hie_DEG: + case Hie_Lvl_DEG: Cod = Gbl.Hierarchy.Deg.DegCod; Folder = Cfg_FOLDER_DEG; break; diff --git a/swad_logo.h b/swad_logo.h index 774188de..d19e4919 100644 --- a/swad_logo.h +++ b/swad_logo.h @@ -39,11 +39,11 @@ /***************************** Public prototypes *****************************/ /*****************************************************************************/ -void Lgo_DrawLogo (Hie_Level_t Scope,long Cod,const char *AltText, +void Lgo_DrawLogo (Hie_Lvl_Level_t Scope,long Cod,const char *AltText, unsigned Size,const char *Class,bool PutIconIfNotExists); -void Lgo_PutIconToChangeLogo (Hie_Level_t Scope); -void Lgo_RequestLogo (Hie_Level_t Scope); -void Lgo_ReceiveLogo (Hie_Level_t Scope); -void Lgo_RemoveLogo (Hie_Level_t Scope); +void Lgo_PutIconToChangeLogo (Hie_Lvl_Level_t Scope); +void Lgo_RequestLogo (Hie_Lvl_Level_t Scope); +void Lgo_ReceiveLogo (Hie_Lvl_Level_t Scope); +void Lgo_RemoveLogo (Hie_Lvl_Level_t Scope); #endif diff --git a/swad_main.c b/swad_main.c index 4870024e..71ca3cdd 100644 --- a/swad_main.c +++ b/swad_main.c @@ -38,6 +38,7 @@ #include "swad_firewall.h" #include "swad_global.h" #include "swad_hierarchy.h" +#include "swad_hierarchy_level.h" #include "swad_MFU.h" #include "swad_notification.h" #include "swad_parameter.h" diff --git a/swad_mark.c b/swad_mark.c index 9f11489f..889f3430 100644 --- a/swad_mark.c +++ b/swad_mark.c @@ -625,7 +625,7 @@ void Mrk_ShowMyMarks (void) } else // Course zone { - if (Usr_GetNumUsrsInCrss (Hie_CRS,Gbl.Hierarchy.Crs.CrsCod, + if (Usr_GetNumUsrsInCrss (Hie_Lvl_CRS,Gbl.Hierarchy.Crs.CrsCod, 1 << Rol_STD)) // If there are students in this course { Gbl.Usrs.Other.UsrDat.UsrCod = Usr_GetRamdomStdFromCrs (Gbl.Hierarchy.Crs.CrsCod); diff --git a/swad_message.c b/swad_message.c index 886e865d..5a3fd982 100644 --- a/swad_message.c +++ b/swad_message.c @@ -43,6 +43,7 @@ #include "swad_forum.h" #include "swad_global.h" #include "swad_group.h" +#include "swad_hierarchy.h" #include "swad_HTML.h" #include "swad_ID.h" #include "swad_message.h" @@ -280,9 +281,9 @@ static void Msg_PutFormMsgUsrs (struct Msg_Messages *Messages, Grp_GetParCodsSeveralGrpsToShowUsrs (); /***** Get and order lists of users from this course *****/ - Usr_GetListUsrs (Hie_CRS,Rol_STD); - Usr_GetListUsrs (Hie_CRS,Rol_NET); - Usr_GetListUsrs (Hie_CRS,Rol_TCH); + Usr_GetListUsrs (Hie_Lvl_CRS,Rol_STD); + Usr_GetListUsrs (Hie_Lvl_CRS,Rol_NET); + Usr_GetListUsrs (Hie_Lvl_CRS,Rol_TCH); NumUsrsInCrs = Gbl.Usrs.LstUsrs[Rol_STD].NumUsrs + // Students Gbl.Usrs.LstUsrs[Rol_NET].NumUsrs + // Non-editing teachers Gbl.Usrs.LstUsrs[Rol_TCH].NumUsrs; // Teachers @@ -537,7 +538,7 @@ static void Msg_WriteFormUsrsIDsOrNicksOtherRecipients (void) extern const char *Txt_nicks_emails_or_IDs_separated_by_commas; char Nickname[Nck_MAX_BYTES_NICKNAME_WITHOUT_ARROBA + 1]; unsigned ColSpan; - bool StdsAndTchsWritten = Gbl.Hierarchy.Level == Hie_CRS && // Course selected + bool StdsAndTchsWritten = Gbl.Hierarchy.Level == Hie_Lvl_CRS && // Course selected (Gbl.Usrs.Me.IBelongToCurrentCrs || // I belong to it Gbl.Usrs.Me.Role.Logged == Rol_SYS_ADM); @@ -1131,11 +1132,11 @@ static void Msg_GetParamMsgsCrsCod (struct Msg_Messages *Messages) Crs_GetDataOfCourseByCod (&Crs); Str_Copy (Messages->FilterCrsShrtName,Crs.ShrtName, - Hie_MAX_BYTES_SHRT_NAME); + Cns_HIERARCHY_MAX_BYTES_SHRT_NAME); } else Str_Copy (Messages->FilterCrsShrtName,Txt_any_course, - Hie_MAX_BYTES_SHRT_NAME); + Cns_HIERARCHY_MAX_BYTES_SHRT_NAME); } /*****************************************************************************/ @@ -2229,7 +2230,7 @@ unsigned long Msg_GetNumMsgsSentByUsr (long UsrCod) /******** (all the platform, current degree or current course) **********/ /*****************************************************************************/ -unsigned Msg_GetNumMsgsSent (Hie_Level_t Scope,Msg_Status_t MsgStatus) +unsigned Msg_GetNumMsgsSent (Hie_Lvl_Level_t Scope,Msg_Status_t MsgStatus) { const char *Table = "msg_snt"; unsigned NumMsgs = 0; // Initialized to avoid warning @@ -2248,10 +2249,10 @@ unsigned Msg_GetNumMsgsSent (Hie_Level_t Scope,Msg_Status_t MsgStatus) } switch (Scope) { - case Hie_SYS: + case Hie_Lvl_SYS: NumMsgs = (unsigned) DB_GetNumRowsTable (Table); break; - case Hie_CTY: + case Hie_Lvl_CTY: NumMsgs = (unsigned) DB_QueryCOUNT ("can not get number of sent messages", "SELECT COUNT(*)" @@ -2265,7 +2266,7 @@ unsigned Msg_GetNumMsgsSent (Hie_Level_t Scope,Msg_Status_t MsgStatus) Gbl.Hierarchy.Cty.CtyCod, Table); break; - case Hie_INS: + case Hie_Lvl_INS: NumMsgs = (unsigned) DB_QueryCOUNT ("can not get number of sent messages", "SELECT COUNT(*)" @@ -2278,7 +2279,7 @@ unsigned Msg_GetNumMsgsSent (Hie_Level_t Scope,Msg_Status_t MsgStatus) Gbl.Hierarchy.Ins.InsCod, Table); break; - case Hie_CTR: + case Hie_Lvl_CTR: NumMsgs = (unsigned) DB_QueryCOUNT ("can not get number of sent messages", "SELECT COUNT(*)" @@ -2290,7 +2291,7 @@ unsigned Msg_GetNumMsgsSent (Hie_Level_t Scope,Msg_Status_t MsgStatus) Gbl.Hierarchy.Ctr.CtrCod, Table); break; - case Hie_DEG: + case Hie_Lvl_DEG: NumMsgs = (unsigned) DB_QueryCOUNT ("can not get number of sent messages", "SELECT COUNT(*)" @@ -2301,7 +2302,7 @@ unsigned Msg_GetNumMsgsSent (Hie_Level_t Scope,Msg_Status_t MsgStatus) Gbl.Hierarchy.Deg.DegCod, Table); break; - case Hie_CRS: + case Hie_Lvl_CRS: NumMsgs = (unsigned) DB_QueryCOUNT ("can not get number of sent messages", "SELECT COUNT(*)" @@ -2323,7 +2324,7 @@ unsigned Msg_GetNumMsgsSent (Hie_Level_t Scope,Msg_Status_t MsgStatus) /****** (all the platform, current degree or current course) ********/ /*****************************************************************************/ -unsigned Msg_GetNumMsgsReceived (Hie_Level_t Scope,Msg_Status_t MsgStatus) +unsigned Msg_GetNumMsgsReceived (Hie_Lvl_Level_t Scope,Msg_Status_t MsgStatus) { char *Table; unsigned NumMsgs = 0; // Initialized to avoid warning @@ -2338,10 +2339,10 @@ unsigned Msg_GetNumMsgsReceived (Hie_Level_t Scope,Msg_Status_t MsgStatus) "msg_rcv_deleted"; switch (Scope) { - case Hie_SYS: + case Hie_Lvl_SYS: NumMsgs = (unsigned) DB_GetNumRowsTable (Table); break; - case Hie_CTY: + case Hie_Lvl_CTY: NumMsgs = (unsigned) DB_QueryCOUNT ("can not get number" " of received messages", @@ -2357,7 +2358,7 @@ unsigned Msg_GetNumMsgsReceived (Hie_Level_t Scope,Msg_Status_t MsgStatus) Gbl.Hierarchy.Cty.CtyCod, Table); break; - case Hie_INS: + case Hie_Lvl_INS: NumMsgs = (unsigned) DB_QueryCOUNT ("can not get number" " of received messages", @@ -2372,7 +2373,7 @@ unsigned Msg_GetNumMsgsReceived (Hie_Level_t Scope,Msg_Status_t MsgStatus) Gbl.Hierarchy.Ins.InsCod, Table); break; - case Hie_CTR: + case Hie_Lvl_CTR: NumMsgs = (unsigned) DB_QueryCOUNT ("can not get number" " of received messages", @@ -2386,7 +2387,7 @@ unsigned Msg_GetNumMsgsReceived (Hie_Level_t Scope,Msg_Status_t MsgStatus) Gbl.Hierarchy.Ctr.CtrCod, Table); break; - case Hie_DEG: + case Hie_Lvl_DEG: NumMsgs = (unsigned) DB_QueryCOUNT ("can not get number" " of received messages", @@ -2399,7 +2400,7 @@ unsigned Msg_GetNumMsgsReceived (Hie_Level_t Scope,Msg_Status_t MsgStatus) Gbl.Hierarchy.Deg.DegCod, Table); break; - case Hie_CRS: + case Hie_Lvl_CRS: NumMsgs = (unsigned) DB_QueryCOUNT ("can not get number" " of received messages", @@ -2419,7 +2420,7 @@ unsigned Msg_GetNumMsgsReceived (Hie_Level_t Scope,Msg_Status_t MsgStatus) case Msg_STATUS_NOTIFIED: switch (Scope) { - case Hie_SYS: + case Hie_Lvl_SYS: NumMsgs = (unsigned) DB_QueryCOUNT ("can not get number" " of received messages", @@ -2432,7 +2433,7 @@ unsigned Msg_GetNumMsgsReceived (Hie_Level_t Scope,Msg_Status_t MsgStatus) " FROM msg_rcv_deleted" " WHERE Notified='Y')"); break; - case Hie_CTY: + case Hie_Lvl_CTY: NumMsgs = (unsigned) DB_QueryCOUNT ("can not get number" " of received messages", @@ -2459,7 +2460,7 @@ unsigned Msg_GetNumMsgsReceived (Hie_Level_t Scope,Msg_Status_t MsgStatus) Gbl.Hierarchy.Cty.CtyCod, Gbl.Hierarchy.Cty.CtyCod); break; - case Hie_INS: + case Hie_Lvl_INS: NumMsgs = (unsigned) DB_QueryCOUNT ("can not get number" " of received messages", @@ -2484,7 +2485,7 @@ unsigned Msg_GetNumMsgsReceived (Hie_Level_t Scope,Msg_Status_t MsgStatus) Gbl.Hierarchy.Ins.InsCod, Gbl.Hierarchy.Ins.InsCod); break; - case Hie_CTR: + case Hie_Lvl_CTR: NumMsgs = (unsigned) DB_QueryCOUNT ("can not get number" " of received messages", @@ -2507,7 +2508,7 @@ unsigned Msg_GetNumMsgsReceived (Hie_Level_t Scope,Msg_Status_t MsgStatus) Gbl.Hierarchy.Ctr.CtrCod, Gbl.Hierarchy.Ctr.CtrCod); break; - case Hie_DEG: + case Hie_Lvl_DEG: NumMsgs = (unsigned) DB_QueryCOUNT ("can not get number" " of received messages", @@ -2528,7 +2529,7 @@ unsigned Msg_GetNumMsgsReceived (Hie_Level_t Scope,Msg_Status_t MsgStatus) Gbl.Hierarchy.Deg.DegCod, Gbl.Hierarchy.Deg.DegCod); break; - case Hie_CRS: + case Hie_Lvl_CRS: NumMsgs = (unsigned) DB_QueryCOUNT ("can not get number" " of received messages", @@ -2796,7 +2797,7 @@ static void Msg_GetDistinctCoursesInMyMessages (struct Msg_Messages *Messages) { Messages->Courses[Messages->NumCourses].CrsCod = Crs.CrsCod; Str_Copy (Messages->Courses[Messages->NumCourses].ShrtName,Crs.ShrtName, - Hie_MAX_BYTES_SHRT_NAME); + Cns_HIERARCHY_MAX_BYTES_SHRT_NAME); Messages->NumCourses++; } } diff --git a/swad_message.h b/swad_message.h index 4ac2f7f4..0ffa22e7 100644 --- a/swad_message.h +++ b/swad_message.h @@ -66,10 +66,10 @@ struct Msg_Messages struct { long CrsCod; - char ShrtName[Hie_MAX_BYTES_SHRT_NAME + 1]; + char ShrtName[Cns_HIERARCHY_MAX_BYTES_SHRT_NAME + 1]; } Courses[Crs_MAX_COURSES_PER_USR]; // Distinct courses in my messages sent or received long FilterCrsCod; // Show only messages sent from this course code - char FilterCrsShrtName[Hie_MAX_BYTES_SHRT_NAME + 1]; + char FilterCrsShrtName[Cns_HIERARCHY_MAX_BYTES_SHRT_NAME + 1]; char FilterFromTo[Usr_MAX_BYTES_FULL_NAME + 1]; // Show only messages from/to these users char FilterContent[Msg_MAX_BYTES_FILTER_CONTENT + 1]; // Show only messages that match this content bool ShowOnlyUnreadMsgs; // Show only unread messages (this option is applicable only for received messages) @@ -111,8 +111,8 @@ void Msg_ShowRecMsgs (void); unsigned Msg_GetNumMsgsSentByTchsCrs (long CrsCod); unsigned long Msg_GetNumMsgsSentByUsr (long UsrCod); -unsigned Msg_GetNumMsgsSent (Hie_Level_t Scope,Msg_Status_t MsgStatus); -unsigned Msg_GetNumMsgsReceived (Hie_Level_t Scope,Msg_Status_t MsgStatus); +unsigned Msg_GetNumMsgsSent (Hie_Lvl_Level_t Scope,Msg_Status_t MsgStatus); +unsigned Msg_GetNumMsgsReceived (Hie_Lvl_Level_t Scope,Msg_Status_t MsgStatus); void Msg_PutHiddenParamsMsgsFilters (void *Messages); void Msg_GetNotifMessage (char SummaryStr[Ntf_MAX_BYTES_SUMMARY + 1], diff --git a/swad_network.c b/swad_network.c index 2eef2593..8640a365 100644 --- a/swad_network.c +++ b/swad_network.c @@ -446,13 +446,13 @@ void Net_ShowWebAndSocialNetworksStats (void) /***** Get total number of users in current scope *****/ NumUsrsTotal = - (Gbl.Scope.Current == Hie_SYS) ? Usr_GetTotalNumberOfUsersInPlatform () : + (Gbl.Scope.Current == Hie_Lvl_SYS) ? Usr_GetTotalNumberOfUsersInPlatform () : Usr_GetCachedNumUsrsInCrss (Gbl.Scope.Current, - (Gbl.Scope.Current == Hie_CTY ? Gbl.Hierarchy.Cty.CtyCod : - (Gbl.Scope.Current == Hie_INS ? Gbl.Hierarchy.Ins.InsCod : - (Gbl.Scope.Current == Hie_CTR ? Gbl.Hierarchy.Ctr.CtrCod : - (Gbl.Scope.Current == Hie_DEG ? Gbl.Hierarchy.Deg.DegCod : - (Gbl.Scope.Current == Hie_CRS ? Gbl.Hierarchy.Crs.CrsCod : + (Gbl.Scope.Current == Hie_Lvl_CTY ? Gbl.Hierarchy.Cty.CtyCod : + (Gbl.Scope.Current == Hie_Lvl_INS ? Gbl.Hierarchy.Ins.InsCod : + (Gbl.Scope.Current == Hie_Lvl_CTR ? Gbl.Hierarchy.Ctr.CtrCod : + (Gbl.Scope.Current == Hie_Lvl_DEG ? Gbl.Hierarchy.Deg.DegCod : + (Gbl.Scope.Current == Hie_Lvl_CRS ? Gbl.Hierarchy.Crs.CrsCod : -1L))))), 1 << Rol_STD | 1 << Rol_NET | @@ -461,7 +461,7 @@ void Net_ShowWebAndSocialNetworksStats (void) /***** Get number of users with a web / social network *****/ switch (Gbl.Scope.Current) { - case Hie_SYS: + case Hie_Lvl_SYS: NumRows = (unsigned) DB_QuerySELECT (&mysql_res,"can not get number of users" " with webs / social networks", @@ -470,7 +470,7 @@ void Net_ShowWebAndSocialNetworksStats (void) " GROUP BY Web" " ORDER BY N DESC,Web"); break; - case Hie_CTY: + case Hie_Lvl_CTY: NumRows = (unsigned) DB_QuerySELECT (&mysql_res,"can not get number of users" " with webs / social networks", @@ -487,7 +487,7 @@ void Net_ShowWebAndSocialNetworksStats (void) " ORDER BY N DESC,usr_webs.Web", Gbl.Hierarchy.Cty.CtyCod); break; - case Hie_INS: + case Hie_Lvl_INS: NumRows = (unsigned) DB_QuerySELECT (&mysql_res,"can not get number of users" " with webs / social networks", @@ -503,7 +503,7 @@ void Net_ShowWebAndSocialNetworksStats (void) " ORDER BY N DESC,usr_webs.Web", Gbl.Hierarchy.Ins.InsCod); break; - case Hie_CTR: + case Hie_Lvl_CTR: NumRows = (unsigned) DB_QuerySELECT (&mysql_res,"can not get number of users" " with webs / social networks", @@ -518,7 +518,7 @@ void Net_ShowWebAndSocialNetworksStats (void) " ORDER BY N DESC,usr_webs.Web", Gbl.Hierarchy.Ctr.CtrCod); break; - case Hie_DEG: + case Hie_Lvl_DEG: NumRows = (unsigned) DB_QuerySELECT (&mysql_res,"can not get number of users" " with webs / social networks", @@ -532,7 +532,7 @@ void Net_ShowWebAndSocialNetworksStats (void) " ORDER BY N DESC,usr_webs.Web", Gbl.Hierarchy.Deg.DegCod); break; - case Hie_CRS: + case Hie_Lvl_CRS: NumRows = (unsigned) DB_QuerySELECT (&mysql_res,"can not get number of users" " with webs / social networks", diff --git a/swad_notice.c b/swad_notice.c index 83cb1f7a..59e87b16 100644 --- a/swad_notice.c +++ b/swad_notice.c @@ -371,7 +371,7 @@ void Not_ShowNotices (Not_Listing_t TypeNoticesListing,long HighlightNotCod) char RSSLink[Cns_MAX_BYTES_WWW + 1]; /***** Trivial check *****/ - if (Gbl.Hierarchy.Level != Hie_CRS) // No course selected + if (Gbl.Hierarchy.Level != Hie_Lvl_CRS) // No course selected return; /***** Get notices from database *****/ @@ -818,7 +818,7 @@ void Not_GetSummaryAndContentNotice (char SummaryStr[Ntf_MAX_BYTES_SUMMARY + 1], // Returns the number of (active or obsolete) notices // sent from this location (all the platform, current degree or current course) -unsigned Not_GetNumNotices (Hie_Level_t Scope,Not_Status_t Status,unsigned *NumNotif) +unsigned Not_GetNumNotices (Hie_Lvl_Level_t Scope,Not_Status_t Status,unsigned *NumNotif) { MYSQL_RES *mysql_res; MYSQL_ROW row; @@ -827,14 +827,14 @@ unsigned Not_GetNumNotices (Hie_Level_t Scope,Not_Status_t Status,unsigned *NumN /***** Get number of notices from database *****/ switch (Scope) { - case Hie_SYS: + case Hie_Lvl_SYS: DB_QuerySELECT (&mysql_res,"can not get number of notices", "SELECT COUNT(*),SUM(NumNotif)" " FROM notices" " WHERE Status=%u", Status); break; - case Hie_CTY: + case Hie_Lvl_CTY: DB_QuerySELECT (&mysql_res,"can not get number of notices", "SELECT COUNT(*),SUM(notices.NumNotif)" " FROM institutions,centres,degrees,courses,notices" @@ -847,7 +847,7 @@ unsigned Not_GetNumNotices (Hie_Level_t Scope,Not_Status_t Status,unsigned *NumN Gbl.Hierarchy.Cty.CtyCod, Status); break; - case Hie_INS: + case Hie_Lvl_INS: DB_QuerySELECT (&mysql_res,"can not get number of notices", "SELECT COUNT(*),SUM(notices.NumNotif)" " FROM centres,degrees,courses,notices" @@ -859,7 +859,7 @@ unsigned Not_GetNumNotices (Hie_Level_t Scope,Not_Status_t Status,unsigned *NumN Gbl.Hierarchy.Ins.InsCod, Status); break; - case Hie_CTR: + case Hie_Lvl_CTR: DB_QuerySELECT (&mysql_res,"can not get number of notices", "SELECT COUNT(*),SUM(notices.NumNotif)" " FROM degrees,courses,notices" @@ -870,7 +870,7 @@ unsigned Not_GetNumNotices (Hie_Level_t Scope,Not_Status_t Status,unsigned *NumN Gbl.Hierarchy.Ctr.CtrCod, Status); break; - case Hie_DEG: + case Hie_Lvl_DEG: DB_QuerySELECT (&mysql_res,"can not get number of notices", "SELECT COUNT(*),SUM(notices.NumNotif)" " FROM courses,notices" @@ -880,7 +880,7 @@ unsigned Not_GetNumNotices (Hie_Level_t Scope,Not_Status_t Status,unsigned *NumN Gbl.Hierarchy.Deg.DegCod, Status); break; - case Hie_CRS: + case Hie_Lvl_CRS: DB_QuerySELECT (&mysql_res,"can not get number of notices", "SELECT COUNT(*),SUM(NumNotif)" " FROM notices" @@ -920,7 +920,7 @@ unsigned Not_GetNumNotices (Hie_Level_t Scope,Not_Status_t Status,unsigned *NumN // Returns the number of deleted notices // sent from this location (all the platform, current degree or current course) -unsigned Not_GetNumNoticesDeleted (Hie_Level_t Scope,unsigned *NumNotif) +unsigned Not_GetNumNoticesDeleted (Hie_Lvl_Level_t Scope,unsigned *NumNotif) { MYSQL_RES *mysql_res; MYSQL_ROW row; @@ -929,12 +929,12 @@ unsigned Not_GetNumNoticesDeleted (Hie_Level_t Scope,unsigned *NumNotif) /***** Get number of notices from database *****/ switch (Scope) { - case Hie_SYS: + case Hie_Lvl_SYS: DB_QuerySELECT (&mysql_res,"can not get number of deleted notices", "SELECT COUNT(*),SUM(NumNotif)" " FROM notices_deleted"); break; - case Hie_CTY: + case Hie_Lvl_CTY: DB_QuerySELECT (&mysql_res,"can not get number of deleted notices", "SELECT COUNT(*),SUM(notices_deleted.NumNotif)" " FROM institutions,centres,degrees,courses,notices_deleted" @@ -945,7 +945,7 @@ unsigned Not_GetNumNoticesDeleted (Hie_Level_t Scope,unsigned *NumNotif) " AND courses.CrsCod=notices_deleted.CrsCod", Gbl.Hierarchy.Cty.CtyCod); break; - case Hie_INS: + case Hie_Lvl_INS: DB_QuerySELECT (&mysql_res,"can not get number of deleted notices", "SELECT COUNT(*),SUM(notices_deleted.NumNotif)" " FROM centres,degrees,courses,notices_deleted" @@ -955,7 +955,7 @@ unsigned Not_GetNumNoticesDeleted (Hie_Level_t Scope,unsigned *NumNotif) " AND courses.CrsCod=notices_deleted.CrsCod", Gbl.Hierarchy.Ins.InsCod); break; - case Hie_CTR: + case Hie_Lvl_CTR: DB_QuerySELECT (&mysql_res,"can not get number of deleted notices", "SELECT COUNT(*),SUM(notices_deleted.NumNotif)" " FROM degrees,courses,notices_deleted" @@ -964,7 +964,7 @@ unsigned Not_GetNumNoticesDeleted (Hie_Level_t Scope,unsigned *NumNotif) " AND courses.CrsCod=notices_deleted.CrsCod", Gbl.Hierarchy.Ctr.CtrCod); break; - case Hie_DEG: + case Hie_Lvl_DEG: DB_QuerySELECT (&mysql_res,"can not get number of deleted notices", "SELECT COUNT(*),SUM(notices_deleted.NumNotif)" " FROM courses,notices_deleted" @@ -972,7 +972,7 @@ unsigned Not_GetNumNoticesDeleted (Hie_Level_t Scope,unsigned *NumNotif) " AND courses.CrsCod=notices_deleted.CrsCod", Gbl.Hierarchy.Deg.DegCod); break; - case Hie_CRS: + case Hie_Lvl_CRS: DB_QuerySELECT (&mysql_res,"can not get number of deleted notices", "SELECT COUNT(*),SUM(NumNotif)" " FROM notices_deleted" diff --git a/swad_notice.h b/swad_notice.h index c6d67a50..bcb279e1 100644 --- a/swad_notice.h +++ b/swad_notice.h @@ -72,8 +72,8 @@ void Not_ShowNotices (Not_Listing_t TypeNoticesListing,long HighlightNotCod); void Not_GetSummaryAndContentNotice (char SummaryStr[Ntf_MAX_BYTES_SUMMARY + 1], char **ContentStr, long NotCod,bool GetContent); -unsigned Not_GetNumNotices (Hie_Level_t Scope,Not_Status_t Status,unsigned *NumNotif); -unsigned Not_GetNumNoticesDeleted (Hie_Level_t Scope,unsigned *NumNotif); +unsigned Not_GetNumNotices (Hie_Lvl_Level_t Scope,Not_Status_t Status,unsigned *NumNotif); +unsigned Not_GetNumNoticesDeleted (Hie_Lvl_Level_t Scope,unsigned *NumNotif); void Not_PutHiddenParamNotCod (long NotCod); diff --git a/swad_notification.c b/swad_notification.c index ed001f28..f02be0da 100644 --- a/swad_notification.c +++ b/swad_notification.c @@ -1262,7 +1262,7 @@ unsigned Ntf_StoreNotifyEventsToAllUsrs (Ntf_NotifyEvent_t NotifyEvent,long Cod) case Ntf_EVENT_ENROLMENT_TCH: // This function should not be called in this case return 0; case Ntf_EVENT_ENROLMENT_REQUEST: - if (Usr_GetNumUsrsInCrss (Hie_CRS,Gbl.Hierarchy.Crs.CrsCod, + if (Usr_GetNumUsrsInCrss (Hie_Lvl_CRS,Gbl.Hierarchy.Crs.CrsCod, 1 << Rol_TCH)) // If this course has teachers ==> send notification to teachers NumRows = DB_QuerySELECT (&mysql_res,"can not get users" @@ -1287,10 +1287,10 @@ unsigned Ntf_StoreNotifyEventsToAllUsrs (Ntf_NotifyEvent_t NotifyEvent,long Cod) " OR (Scope='%s' AND Cod=%ld)" " OR (Scope='%s' AND Cod=%ld))" " AND UsrCod<>%ld", - Sco_GetDBStrFromScope (Hie_SYS), - Sco_GetDBStrFromScope (Hie_INS),Gbl.Hierarchy.Ins.InsCod, - Sco_GetDBStrFromScope (Hie_CTR),Gbl.Hierarchy.Ctr.CtrCod, - Sco_GetDBStrFromScope (Hie_DEG),Gbl.Hierarchy.Deg.DegCod, + Sco_GetDBStrFromScope (Hie_Lvl_SYS), + Sco_GetDBStrFromScope (Hie_Lvl_INS),Gbl.Hierarchy.Ins.InsCod, + Sco_GetDBStrFromScope (Hie_Lvl_CTR),Gbl.Hierarchy.Ctr.CtrCod, + Sco_GetDBStrFromScope (Hie_Lvl_DEG),Gbl.Hierarchy.Deg.DegCod, Gbl.Usrs.Me.UsrDat.UsrCod); break; case Ntf_EVENT_TIMELINE_COMMENT: // New comment to one of my social notes or comments @@ -1374,11 +1374,11 @@ unsigned Ntf_StoreNotifyEventsToAllUsrs (Ntf_NotifyEvent_t NotifyEvent,long Cod) " AND (surveys.Roles&(1<0)", Cod, Cod, - Sco_GetDBStrFromScope (Hie_CRS), + Sco_GetDBStrFromScope (Hie_Lvl_CRS), Gbl.Usrs.Me.UsrDat.UsrCod, Cod, Gbl.Usrs.Me.UsrDat.UsrCod, - Sco_GetDBStrFromScope (Hie_CRS)); + Sco_GetDBStrFromScope (Hie_Lvl_CRS)); break; } diff --git a/swad_photo.c b/swad_photo.c index 8194a2fa..170c3ba5 100644 --- a/swad_photo.c +++ b/swad_photo.c @@ -45,6 +45,7 @@ #include "swad_follow.h" #include "swad_form.h" #include "swad_global.h" +#include "swad_hierarchy.h" #include "swad_HTML.h" #include "swad_logo.h" #include "swad_parameter.h" @@ -1198,7 +1199,7 @@ void Pho_ShowUsrPhoto (const struct UsrData *UsrDat,const char *PhotoURL, bool PutZoomCode = (Zoom == Pho_ZOOM) && // Make zoom BrowserTabIs1stTab; // Only in main browser tab (or AJAX) char IdCaption[Frm_MAX_BYTES_ID + 1]; - char MainDegreeShrtName[Hie_MAX_BYTES_SHRT_NAME + 1]; + char MainDegreeShrtName[Cns_HIERARCHY_MAX_BYTES_SHRT_NAME + 1]; Rol_Role_t MaxRole; // Maximum user's role in his/her main degree /***** Begin form to go to public profile *****/ @@ -2286,7 +2287,7 @@ static void Pho_ShowOrPrintListDegrees (struct Pho_DegPhotos *DegPhotos, "BT_LINK DAT","CT"); else // Pho_DEGREES_PRINT { - Lgo_DrawLogo (Hie_DEG,Deg.DegCod,Deg.ShrtName,20,"CT",true); + Lgo_DrawLogo (Hie_Lvl_DEG,Deg.DegCod,Deg.ShrtName,20,"CT",true); HTM_TxtF (" %s",Deg.FullName); } HTM_TD_End (); @@ -2469,7 +2470,7 @@ static void Pho_ShowDegreeAvgPhotoAndStat (const struct Deg_Degree *Deg, unsigned PhotoHeight; char PathRelAvgPhoto[PATH_MAX + 1]; char PhotoURL[PATH_MAX + 1]; - char PhotoCaption[1024 + Hie_MAX_BYTES_SHRT_NAME]; + char PhotoCaption[1024 + Cns_HIERARCHY_MAX_BYTES_SHRT_NAME]; bool ShowDegPhoto; char IdCaption[Frm_MAX_BYTES_ID + 1]; diff --git a/swad_profile.c b/swad_profile.c index c727ff59..c0a3fdb4 100644 --- a/swad_profile.c +++ b/swad_profile.c @@ -314,7 +314,7 @@ bool Prf_ShowUserProfile (struct UsrData *UsrDat) /***** Shared record card *****/ if (!ItsMe && // If not me... - Gbl.Hierarchy.Level == Hie_CRS) // ...and a course is selected + Gbl.Hierarchy.Level == Hie_Lvl_CRS) // ...and a course is selected { /* Get user's role in current course */ UsrDat->Roles.InCurrentCrs.Role = Rol_GetRoleUsrInCrs (UsrDat->UsrCod, @@ -961,7 +961,7 @@ static void Prf_ShowRanking (unsigned long Rank,unsigned long NumUsrs) /***** Rank in form to go to ranking *****/ Frm_StartForm (ActSeeUseGbl); - Sco_PutParamScope ("ScopeSta",Hie_SYS); + Sco_PutParamScope ("ScopeSta",Hie_Lvl_SYS); Par_PutHiddenParamUnsigned (NULL,"FigureType",(unsigned) Fig_USERS_RANKING); if (asprintf (&Title,"#%lu %s %lu",Rank,Txt_of_PART_OF_A_TOTAL,NumUsrs) < 0) Lay_NotEnoughMemoryExit (); @@ -1424,7 +1424,7 @@ static void Prf_GetAndShowRankingFigure (const char *FieldName) /***** Get ranking from database *****/ switch (Gbl.Scope.Current) { - case Hie_SYS: + case Hie_Lvl_SYS: NumUsrs = (unsigned) DB_QuerySELECT (&mysql_res,"can not get ranking", "SELECT UsrCod,%s" @@ -1435,7 +1435,7 @@ static void Prf_GetAndShowRankingFigure (const char *FieldName) FieldName, FieldName,FieldName); break; - case Hie_CTY: + case Hie_Lvl_CTY: NumUsrs = (unsigned) DB_QuerySELECT (&mysql_res,"can not get ranking", "SELECT DISTINCTROW usr_figures.UsrCod,usr_figures.%s" @@ -1453,7 +1453,7 @@ static void Prf_GetAndShowRankingFigure (const char *FieldName) Gbl.Hierarchy.Cty.CtyCod, FieldName,FieldName); break; - case Hie_INS: + case Hie_Lvl_INS: NumUsrs = (unsigned) DB_QuerySELECT (&mysql_res,"can not get ranking", "SELECT DISTINCTROW usr_figures.UsrCod,usr_figures.%s" @@ -1470,7 +1470,7 @@ static void Prf_GetAndShowRankingFigure (const char *FieldName) Gbl.Hierarchy.Ins.InsCod, FieldName,FieldName); break; - case Hie_CTR: + case Hie_Lvl_CTR: NumUsrs = (unsigned) DB_QuerySELECT (&mysql_res,"can not get ranking", "SELECT DISTINCTROW usr_figures.UsrCod,usr_figures.%s" @@ -1486,7 +1486,7 @@ static void Prf_GetAndShowRankingFigure (const char *FieldName) Gbl.Hierarchy.Ctr.CtrCod, FieldName,FieldName); break; - case Hie_DEG: + case Hie_Lvl_DEG: NumUsrs = (unsigned) DB_QuerySELECT (&mysql_res,"can not get ranking", "SELECT DISTINCTROW usr_figures.UsrCod,usr_figures.%s" @@ -1501,7 +1501,7 @@ static void Prf_GetAndShowRankingFigure (const char *FieldName) Gbl.Hierarchy.Deg.DegCod, FieldName,FieldName); break; - case Hie_CRS: + case Hie_Lvl_CRS: NumUsrs = (unsigned) DB_QuerySELECT (&mysql_res,"can not get ranking", "SELECT DISTINCTROW usr_figures.UsrCod,usr_figures.%s" @@ -1603,7 +1603,7 @@ void Prf_GetAndShowRankingClicksPerDay (void) /***** Get ranking from database *****/ switch (Gbl.Scope.Current) { - case Hie_SYS: + case Hie_Lvl_SYS: NumUsrs = (unsigned) DB_QuerySELECT (&mysql_res,"can not get ranking", "SELECT UsrCod," @@ -1614,7 +1614,7 @@ void Prf_GetAndShowRankingClicksPerDay (void) " AND UsrCod NOT IN (SELECT UsrCod FROM usr_banned)" " ORDER BY NumClicksPerDay DESC,UsrCod LIMIT 100"); break; - case Hie_CTY: + case Hie_Lvl_CTY: NumUsrs = (unsigned) DB_QuerySELECT (&mysql_res,"can not get ranking", "SELECT DISTINCTROW usr_figures.UsrCod," @@ -1633,7 +1633,7 @@ void Prf_GetAndShowRankingClicksPerDay (void) " ORDER BY NumClicksPerDay DESC,usr_figures.UsrCod LIMIT 100", Gbl.Hierarchy.Cty.CtyCod); break; - case Hie_INS: + case Hie_Lvl_INS: NumUsrs = (unsigned) DB_QuerySELECT (&mysql_res,"can not get ranking", "SELECT DISTINCTROW usr_figures.UsrCod," @@ -1651,7 +1651,7 @@ void Prf_GetAndShowRankingClicksPerDay (void) " ORDER BY NumClicksPerDay DESC,usr_figures.UsrCod LIMIT 100", Gbl.Hierarchy.Ins.InsCod); break; - case Hie_CTR: + case Hie_Lvl_CTR: NumUsrs = (unsigned) DB_QuerySELECT (&mysql_res,"can not get ranking", "SELECT DISTINCTROW usr_figures.UsrCod," @@ -1668,7 +1668,7 @@ void Prf_GetAndShowRankingClicksPerDay (void) " ORDER BY NumClicksPerDay DESC,usr_figures.UsrCod LIMIT 100", Gbl.Hierarchy.Ctr.CtrCod); break; - case Hie_DEG: + case Hie_Lvl_DEG: NumUsrs = (unsigned) DB_QuerySELECT (&mysql_res,"can not get ranking", "SELECT DISTINCTROW usr_figures.UsrCod," @@ -1684,7 +1684,7 @@ void Prf_GetAndShowRankingClicksPerDay (void) " ORDER BY NumClicksPerDay DESC,usr_figures.UsrCod LIMIT 100", Gbl.Hierarchy.Deg.DegCod); break; - case Hie_CRS: + case Hie_Lvl_CRS: NumUsrs = (unsigned) DB_QuerySELECT (&mysql_res,"can not get ranking", "SELECT DISTINCTROW usr_figures.UsrCod," diff --git a/swad_program.c b/swad_program.c index 45260280..d4ac9610 100644 --- a/swad_program.c +++ b/swad_program.c @@ -2185,7 +2185,7 @@ void Prg_RemoveCrsItems (long CrsCod) // Returns the number of courses with program items // in this location (all the platform, current degree or current course) -unsigned Prg_GetNumCoursesWithItems (Hie_Level_t Scope) +unsigned Prg_GetNumCoursesWithItems (Hie_Lvl_Level_t Scope) { MYSQL_RES *mysql_res; MYSQL_ROW row; @@ -2194,13 +2194,13 @@ unsigned Prg_GetNumCoursesWithItems (Hie_Level_t Scope) /***** Get number of courses with program items from database *****/ switch (Scope) { - case Hie_SYS: + case Hie_Lvl_SYS: DB_QuerySELECT (&mysql_res,"can not get number of courses with program items", "SELECT COUNT(DISTINCT CrsCod)" " FROM prg_items" " WHERE CrsCod>0"); break; - case Hie_CTY: + case Hie_Lvl_CTY: DB_QuerySELECT (&mysql_res,"can not get number of courses with program items", "SELECT COUNT(DISTINCT prg_items.CrsCod)" " FROM institutions,centres,degrees,courses,prg_items" @@ -2212,7 +2212,7 @@ unsigned Prg_GetNumCoursesWithItems (Hie_Level_t Scope) " AND courses.CrsCod=prg_items.CrsCod", Gbl.Hierarchy.Cty.CtyCod); break; - case Hie_INS: + case Hie_Lvl_INS: DB_QuerySELECT (&mysql_res,"can not get number of courses with program items", "SELECT COUNT(DISTINCT prg_items.CrsCod)" " FROM centres,degrees,courses,prg_items" @@ -2223,7 +2223,7 @@ unsigned Prg_GetNumCoursesWithItems (Hie_Level_t Scope) " AND courses.CrsCod=prg_items.CrsCod", Gbl.Hierarchy.Ins.InsCod); break; - case Hie_CTR: + case Hie_Lvl_CTR: DB_QuerySELECT (&mysql_res,"can not get number of courses with program items", "SELECT COUNT(DISTINCT prg_items.CrsCod)" " FROM degrees,courses,prg_items" @@ -2233,7 +2233,7 @@ unsigned Prg_GetNumCoursesWithItems (Hie_Level_t Scope) " AND courses.CrsCod=prg_items.CrsCod", Gbl.Hierarchy.Ctr.CtrCod); break; - case Hie_DEG: + case Hie_Lvl_DEG: DB_QuerySELECT (&mysql_res,"can not get number of courses with program items", "SELECT COUNT(DISTINCT prg_items.CrsCod)" " FROM courses,prg_items" @@ -2242,7 +2242,7 @@ unsigned Prg_GetNumCoursesWithItems (Hie_Level_t Scope) " AND courses.CrsCod=prg_items.CrsCod", Gbl.Hierarchy.Deg.DegCod); break; - case Hie_CRS: + case Hie_Lvl_CRS: DB_QuerySELECT (&mysql_res,"can not get number of courses with program items", "SELECT COUNT(DISTINCT CrsCod)" " FROM prg_items" @@ -2270,7 +2270,7 @@ unsigned Prg_GetNumCoursesWithItems (Hie_Level_t Scope) /*****************************************************************************/ // Returns the number of program items in a hierarchy scope -unsigned Prg_GetNumItems (Hie_Level_t Scope) +unsigned Prg_GetNumItems (Hie_Lvl_Level_t Scope) { MYSQL_RES *mysql_res; MYSQL_ROW row; @@ -2279,13 +2279,13 @@ unsigned Prg_GetNumItems (Hie_Level_t Scope) /***** Get number of program items from database *****/ switch (Scope) { - case Hie_SYS: + case Hie_Lvl_SYS: DB_QuerySELECT (&mysql_res,"can not get number of program items", "SELECT COUNT(*)" " FROM prg_items" " WHERE CrsCod>0"); break; - case Hie_CTY: + case Hie_Lvl_CTY: DB_QuerySELECT (&mysql_res,"can not get number of program items", "SELECT COUNT(*)" " FROM institutions,centres,degrees,courses,prg_items" @@ -2296,7 +2296,7 @@ unsigned Prg_GetNumItems (Hie_Level_t Scope) " AND courses.CrsCod=prg_items.CrsCod", Gbl.Hierarchy.Cty.CtyCod); break; - case Hie_INS: + case Hie_Lvl_INS: DB_QuerySELECT (&mysql_res,"can not get number of program items", "SELECT COUNT(*)" " FROM centres,degrees,courses,prg_items" @@ -2306,7 +2306,7 @@ unsigned Prg_GetNumItems (Hie_Level_t Scope) " AND courses.CrsCod=prg_items.CrsCod", Gbl.Hierarchy.Ins.InsCod); break; - case Hie_CTR: + case Hie_Lvl_CTR: DB_QuerySELECT (&mysql_res,"can not get number of program items", "SELECT COUNT(*)" " FROM degrees,courses,prg_items" @@ -2315,7 +2315,7 @@ unsigned Prg_GetNumItems (Hie_Level_t Scope) " AND courses.CrsCod=prg_items.CrsCod", Gbl.Hierarchy.Ctr.CtrCod); break; - case Hie_DEG: + case Hie_Lvl_DEG: DB_QuerySELECT (&mysql_res,"can not get number of program items", "SELECT COUNT(*)" " FROM courses,prg_items" @@ -2323,7 +2323,7 @@ unsigned Prg_GetNumItems (Hie_Level_t Scope) " AND courses.CrsCod=prg_items.CrsCod", Gbl.Hierarchy.Deg.DegCod); break; - case Hie_CRS: + case Hie_Lvl_CRS: DB_QuerySELECT (&mysql_res,"can not get number of program items", "SELECT COUNT(*)" " FROM prg_items" diff --git a/swad_program.h b/swad_program.h index eacf0176..a3868074 100644 --- a/swad_program.h +++ b/swad_program.h @@ -27,7 +27,7 @@ /********************************* Headers ***********************************/ /*****************************************************************************/ -#include "swad_hierarchy.h" +#include "swad_hierarchy_level.h" /*****************************************************************************/ /************************** Public types and constants ***********************/ @@ -56,7 +56,7 @@ void Prg_MoveRightItem (void); void Prg_RemoveCrsItems (long CrsCod); -unsigned Prg_GetNumCoursesWithItems (Hie_Level_t Scope); -unsigned Prg_GetNumItems (Hie_Level_t Scope); +unsigned Prg_GetNumCoursesWithItems (Hie_Lvl_Level_t Scope); +unsigned Prg_GetNumItems (Hie_Lvl_Level_t Scope); #endif diff --git a/swad_project.c b/swad_project.c index 9e78ce38..712a5488 100644 --- a/swad_project.c +++ b/swad_project.c @@ -4585,7 +4585,7 @@ void Prj_RemoveUsrFromProjects (long UsrCod) // Returns the number of courses with projects // in this location (all the platform, current degree or current course) -unsigned Prj_GetNumCoursesWithProjects (Hie_Level_t Scope) +unsigned Prj_GetNumCoursesWithProjects (Hie_Lvl_Level_t Scope) { MYSQL_RES *mysql_res; MYSQL_ROW row; @@ -4594,13 +4594,13 @@ unsigned Prj_GetNumCoursesWithProjects (Hie_Level_t Scope) /***** Get number of courses with projects from database *****/ switch (Scope) { - case Hie_SYS: + case Hie_Lvl_SYS: DB_QuerySELECT (&mysql_res,"can not get number of courses with projects", "SELECT COUNT(DISTINCT CrsCod)" " FROM projects" " WHERE CrsCod>0"); break; - case Hie_CTY: + case Hie_Lvl_CTY: DB_QuerySELECT (&mysql_res,"can not get number of courses with projects", "SELECT COUNT(DISTINCT projects.CrsCod)" " FROM institutions,centres,degrees,courses,projects" @@ -4612,7 +4612,7 @@ unsigned Prj_GetNumCoursesWithProjects (Hie_Level_t Scope) " AND courses.CrsCod=projects.CrsCod", Gbl.Hierarchy.Cty.CtyCod); break; - case Hie_INS: + case Hie_Lvl_INS: DB_QuerySELECT (&mysql_res,"can not get number of courses with projects", "SELECT COUNT(DISTINCT projects.CrsCod)" " FROM centres,degrees,courses,projects" @@ -4623,7 +4623,7 @@ unsigned Prj_GetNumCoursesWithProjects (Hie_Level_t Scope) " AND courses.CrsCod=projects.CrsCod", Gbl.Hierarchy.Ins.InsCod); break; - case Hie_CTR: + case Hie_Lvl_CTR: DB_QuerySELECT (&mysql_res,"can not get number of courses with projects", "SELECT COUNT(DISTINCT projects.CrsCod)" " FROM degrees,courses,projects" @@ -4633,7 +4633,7 @@ unsigned Prj_GetNumCoursesWithProjects (Hie_Level_t Scope) " AND courses.CrsCod=projects.CrsCod", Gbl.Hierarchy.Ctr.CtrCod); break; - case Hie_DEG: + case Hie_Lvl_DEG: DB_QuerySELECT (&mysql_res,"can not get number of courses with projects", "SELECT COUNT(DISTINCT projects.CrsCod)" " FROM courses,projects" @@ -4642,7 +4642,7 @@ unsigned Prj_GetNumCoursesWithProjects (Hie_Level_t Scope) " AND courses.CrsCod=projects.CrsCod", Gbl.Hierarchy.Deg.DegCod); break; - case Hie_CRS: + case Hie_Lvl_CRS: DB_QuerySELECT (&mysql_res,"can not get number of courses with projects", "SELECT COUNT(DISTINCT CrsCod)" " FROM projects" @@ -4670,7 +4670,7 @@ unsigned Prj_GetNumCoursesWithProjects (Hie_Level_t Scope) /*****************************************************************************/ // Returns the number of projects in this location -unsigned Prj_GetNumProjects (Hie_Level_t Scope) +unsigned Prj_GetNumProjects (Hie_Lvl_Level_t Scope) { MYSQL_RES *mysql_res; MYSQL_ROW row; @@ -4679,13 +4679,13 @@ unsigned Prj_GetNumProjects (Hie_Level_t Scope) /***** Get number of projects from database *****/ switch (Scope) { - case Hie_SYS: + case Hie_Lvl_SYS: DB_QuerySELECT (&mysql_res,"can not get number of projects", "SELECT COUNT(*)" " FROM projects" " WHERE CrsCod>0"); break; - case Hie_CTY: + case Hie_Lvl_CTY: DB_QuerySELECT (&mysql_res,"can not get number of projects", "SELECT COUNT(*)" " FROM institutions,centres,degrees,courses,projects" @@ -4696,7 +4696,7 @@ unsigned Prj_GetNumProjects (Hie_Level_t Scope) " AND courses.CrsCod=projects.CrsCod", Gbl.Hierarchy.Cty.CtyCod); break; - case Hie_INS: + case Hie_Lvl_INS: DB_QuerySELECT (&mysql_res,"can not get number of projects", "SELECT COUNT(*)" " FROM centres,degrees,courses,projects" @@ -4706,7 +4706,7 @@ unsigned Prj_GetNumProjects (Hie_Level_t Scope) " AND courses.CrsCod=projects.CrsCod", Gbl.Hierarchy.Ins.InsCod); break; - case Hie_CTR: + case Hie_Lvl_CTR: DB_QuerySELECT (&mysql_res,"can not get number of projects", "SELECT COUNT(*)" " FROM degrees,courses,projects" @@ -4715,7 +4715,7 @@ unsigned Prj_GetNumProjects (Hie_Level_t Scope) " AND courses.CrsCod=projects.CrsCod", Gbl.Hierarchy.Ctr.CtrCod); break; - case Hie_DEG: + case Hie_Lvl_DEG: DB_QuerySELECT (&mysql_res,"can not get number of projects", "SELECT COUNT(*)" " FROM courses,projects" @@ -4723,7 +4723,7 @@ unsigned Prj_GetNumProjects (Hie_Level_t Scope) " AND courses.CrsCod=projects.CrsCod", Gbl.Hierarchy.Deg.DegCod); break; - case Hie_CRS: + case Hie_Lvl_CRS: DB_QuerySELECT (&mysql_res,"can not get number of projects", "SELECT COUNT(*)" " FROM projects" diff --git a/swad_project.h b/swad_project.h index 0be08ca7..89cc723e 100644 --- a/swad_project.h +++ b/swad_project.h @@ -238,7 +238,7 @@ void Prj_UnloProjectEdition (void); void Prj_RemoveCrsProjects (long CrsCod); void Prj_RemoveUsrFromProjects (long UsrCod); -unsigned Prj_GetNumCoursesWithProjects (Hie_Level_t Scope); -unsigned Prj_GetNumProjects (Hie_Level_t Scope); +unsigned Prj_GetNumCoursesWithProjects (Hie_Lvl_Level_t Scope); +unsigned Prj_GetNumProjects (Hie_Lvl_Level_t Scope); #endif diff --git a/swad_record.c b/swad_record.c index dc9cd70b..644c3026 100644 --- a/swad_record.c +++ b/swad_record.c @@ -1732,7 +1732,7 @@ static void Rec_ShowCrsRecord (Rec_CourseRecordViewType_t TypeOfView, HTM_TR_Begin (NULL); HTM_TD_Begin ("class=\"LM\" style=\"width:%upx;\"",Rec_DEGREE_LOGO_SIZE); - Lgo_DrawLogo (Hie_DEG,Gbl.Hierarchy.Deg.DegCod, + Lgo_DrawLogo (Hie_Lvl_DEG,Gbl.Hierarchy.Deg.DegCod, Gbl.Hierarchy.Deg.ShrtName,Rec_DEGREE_LOGO_SIZE,NULL,true); HTM_TD_End (); @@ -2051,7 +2051,7 @@ void Rec_ShowFormOtherNewSharedRecord (struct UsrData *UsrDat,Rol_Role_t Default /* In this case UsrDat->Roles.InCurrentCrsDB is not the current role in current course. Instead it is initialized with the preferred role. */ - UsrDat->Roles.InCurrentCrs.Role = (Gbl.Hierarchy.Level == Hie_CRS) ? DefaultRole : // Course selected + UsrDat->Roles.InCurrentCrs.Role = (Gbl.Hierarchy.Level == Hie_Lvl_CRS) ? DefaultRole : // Course selected Rol_UNK; // No course selected UsrDat->Roles.InCurrentCrs.Valid = true; Rec_ShowSharedUsrRecord (Rec_SHA_OTHER_NEW_USR_FORM,UsrDat,NULL); @@ -2515,7 +2515,7 @@ static void Rec_PutIconsCommands (__attribute__((unused)) void *Args) Txt_Administer_user); } - if (Gbl.Hierarchy.Level == Hie_CRS) // Course selected + if (Gbl.Hierarchy.Level == Hie_Lvl_CRS) // Course selected { if (Gbl.Record.UsrDat->Roles.InCurrentCrs.Role == Rol_STD) // He/she is a student in current course { @@ -2689,7 +2689,7 @@ static void Rec_ShowInstitutionInHead (struct Ins_Instit *Ins,bool PutFormLinks) Ins_PutParamInsCod (Ins->InsCod); HTM_BUTTON_SUBMIT_Begin (Ins->FullName,"BT_LINK",NULL); } - Lgo_DrawLogo (Hie_INS,Ins->InsCod,Ins->ShrtName, + Lgo_DrawLogo (Hie_Lvl_INS,Ins->InsCod,Ins->ShrtName, Rec_INSTITUTION_LOGO_SIZE,NULL,true); if (PutFormLinks) { @@ -2941,7 +2941,7 @@ static void Rec_ShowRole (struct UsrData *UsrDat, HTM_SELECT_End (); break; case Rec_SHA_OTHER_EXISTING_USR_FORM: // The other user already exists in the platform - if (Gbl.Hierarchy.Level == Hie_CRS) // Course selected + if (Gbl.Hierarchy.Level == Hie_Lvl_CRS) // Course selected { /***** Set default role *****/ switch (UsrDat->Roles.InCurrentCrs.Role) @@ -3038,7 +3038,7 @@ static void Rec_ShowRole (struct UsrData *UsrDat, } break; case Rec_SHA_OTHER_NEW_USR_FORM: // The user does not exist in platform - if (Gbl.Hierarchy.Level == Hie_CRS) // Course selected + if (Gbl.Hierarchy.Level == Hie_Lvl_CRS) // Course selected switch (Gbl.Usrs.Me.Role.Logged) { case Rol_TCH: diff --git a/swad_report.c b/swad_report.c index f8f4963a..66537733 100644 --- a/swad_report.c +++ b/swad_report.c @@ -538,7 +538,7 @@ static void Rep_WriteSectionUsrInfo (void) extern const char *Txt_Email; extern const char *Txt_Country; extern const char *Txt_Institution; - char CtyName[Hie_MAX_BYTES_FULL_NAME + 1]; + char CtyName[Cns_HIERARCHY_MAX_BYTES_FULL_NAME + 1]; struct Ins_Instit Ins; /***** Start section *****/ @@ -1191,11 +1191,11 @@ static void Rep_WriteRowCrsData (long CrsCod,Rol_Role_t Role, /***** Write number of teachers / students in course *****/ if (WriteNumUsrs) fprintf (Gbl.F.Rep," (%u %s / %u %s)", - Usr_GetCachedNumUsrsInCrss (Hie_CRS,Crs.CrsCod, + Usr_GetCachedNumUsrsInCrss (Hie_Lvl_CRS,Crs.CrsCod, 1 << Rol_NET | 1 << Rol_TCH), Txt_teachers_ABBREVIATION, - Usr_GetCachedNumUsrsInCrss (Hie_CRS,Crs.CrsCod, + Usr_GetCachedNumUsrsInCrss (Hie_Lvl_CRS,Crs.CrsCod, 1 << Rol_STD), Txt_students_ABBREVIATION); } diff --git a/swad_role.c b/swad_role.c index a7cd02d6..cfe71278 100644 --- a/swad_role.c +++ b/swad_role.c @@ -119,24 +119,24 @@ void Rol_SetMyRoles (void) { /* Check if I am and administrator of current institution */ ICanBeInsAdm = Usr_CheckIfUsrIsAdm (Gbl.Usrs.Me.UsrDat.UsrCod, - Hie_INS, + Hie_Lvl_INS, Gbl.Hierarchy.Ins.InsCod); if (Gbl.Hierarchy.Ctr.CtrCod > 0) { /* Check if I am and administrator of current centre */ ICanBeCtrAdm = Usr_CheckIfUsrIsAdm (Gbl.Usrs.Me.UsrDat.UsrCod, - Hie_CTR, + Hie_Lvl_CTR, Gbl.Hierarchy.Ctr.CtrCod); if (Gbl.Hierarchy.Deg.DegCod > 0) /* Check if I am and administrator of current degree */ ICanBeDegAdm = Usr_CheckIfUsrIsAdm (Gbl.Usrs.Me.UsrDat.UsrCod, - Hie_DEG, + Hie_Lvl_DEG, Gbl.Hierarchy.Deg.DegCod); } } /***** Check if I belong to current course *****/ - if (Gbl.Hierarchy.Level == Hie_CRS) // Course selected + if (Gbl.Hierarchy.Level == Hie_Lvl_CRS) // Course selected { Gbl.Usrs.Me.IBelongToCurrentCrs = Usr_CheckIfUsrBelongsToCurrentCrs (&Gbl.Usrs.Me.UsrDat); if (Gbl.Usrs.Me.IBelongToCurrentCrs) @@ -184,7 +184,7 @@ void Rol_SetMyRoles (void) Gbl.Usrs.Me.IBelongToCurrentIns = false; /***** Build my list of available roles for current course *****/ - if (Gbl.Hierarchy.Level == Hie_CRS) + if (Gbl.Hierarchy.Level == Hie_Lvl_CRS) { if (Gbl.Usrs.Me.IBelongToCurrentCrs) Gbl.Usrs.Me.Role.Available = (1 << Gbl.Usrs.Me.UsrDat.Roles.InCurrentCrs.Role); diff --git a/swad_scope.c b/swad_scope.c index 3fe96a54..ed4f4aa1 100644 --- a/swad_scope.c +++ b/swad_scope.c @@ -71,15 +71,15 @@ void Sco_PutSelectorScope (const char *ParamName,HTM_SubmitOnChange_t SubmitOnCh extern const char *Txt_Centre; extern const char *Txt_Degree; extern const char *Txt_Course; - Hie_Level_t Scope; + Hie_Lvl_Level_t Scope; unsigned ScopeUnsigned; bool WriteScope; HTM_SELECT_Begin (SubmitOnChange, "id=\"%s\" name=\"%s\"",ParamName,ParamName); - for (Scope = (Hie_Level_t) 0; - Scope <= (Hie_Level_t) (Hie_NUM_LEVELS - 1); + for (Scope = (Hie_Lvl_Level_t) 0; + Scope <= (Hie_Lvl_Level_t) (Hie_Lvl_NUM_LEVELS - 1); Scope++) if ((Gbl.Scope.Allowed & (1 << Scope))) { @@ -87,27 +87,27 @@ void Sco_PutSelectorScope (const char *ParamName,HTM_SubmitOnChange_t SubmitOnCh WriteScope = false; switch (Scope) { - case Hie_SYS: + case Hie_Lvl_SYS: WriteScope = true; break; - case Hie_CTY: + case Hie_Lvl_CTY: if (Gbl.Hierarchy.Cty.CtyCod > 0) WriteScope = true; break; - case Hie_INS: + case Hie_Lvl_INS: if (Gbl.Hierarchy.Ins.InsCod > 0) WriteScope = true; break; - case Hie_CTR: + case Hie_Lvl_CTR: if (Gbl.Hierarchy.Ctr.CtrCod > 0) WriteScope = true; break; - case Hie_DEG: + case Hie_Lvl_DEG: if (Gbl.Hierarchy.Deg.DegCod > 0) WriteScope = true; break; - case Hie_CRS: - if (Gbl.Hierarchy.Level == Hie_CRS) + case Hie_Lvl_CRS: + if (Gbl.Hierarchy.Level == Hie_Lvl_CRS) WriteScope = true; break; default: @@ -121,42 +121,42 @@ void Sco_PutSelectorScope (const char *ParamName,HTM_SubmitOnChange_t SubmitOnCh ScopeUnsigned = (unsigned) Scope; switch (Scope) { - case Hie_SYS: + case Hie_Lvl_SYS: HTM_OPTION (HTM_Type_UNSIGNED,&ScopeUnsigned, Gbl.Scope.Current == Scope,false, "%s: %s", Txt_System, Cfg_PLATFORM_SHORT_NAME); break; - case Hie_CTY: + case Hie_Lvl_CTY: HTM_OPTION (HTM_Type_UNSIGNED,&ScopeUnsigned, Gbl.Scope.Current == Scope,false, "%s: %s", Txt_Country, Gbl.Hierarchy.Cty.Name[Gbl.Prefs.Language]); break; - case Hie_INS: + case Hie_Lvl_INS: HTM_OPTION (HTM_Type_UNSIGNED,&ScopeUnsigned, Gbl.Scope.Current == Scope,false, "%s: %s", Txt_Institution, Gbl.Hierarchy.Ins.ShrtName); break; - case Hie_CTR: + case Hie_Lvl_CTR: HTM_OPTION (HTM_Type_UNSIGNED,&ScopeUnsigned, Gbl.Scope.Current == Scope,false, "%s: %s", Txt_Centre, Gbl.Hierarchy.Ctr.ShrtName); break; - case Hie_DEG: + case Hie_Lvl_DEG: HTM_OPTION (HTM_Type_UNSIGNED,&ScopeUnsigned, Gbl.Scope.Current == Scope,false, "%s: %s", Txt_Degree, Gbl.Hierarchy.Deg.ShrtName); break; - case Hie_CRS: + case Hie_Lvl_CRS: HTM_OPTION (HTM_Type_UNSIGNED,&ScopeUnsigned, Gbl.Scope.Current == Scope,false, "%s: %s", @@ -180,10 +180,10 @@ void Sco_PutSelectorScope (const char *ParamName,HTM_SubmitOnChange_t SubmitOnCh void Sco_PutParamCurrentScope (void *Scope) { if (Scope) - Sco_PutParamScope ("ScopeUsr",*((Hie_Level_t *) Scope)); + Sco_PutParamScope ("ScopeUsr",*((Hie_Lvl_Level_t *) Scope)); } -void Sco_PutParamScope (const char *ParamName,Hie_Level_t Scope) +void Sco_PutParamScope (const char *ParamName,Hie_Lvl_Level_t Scope) { Par_PutHiddenParamUnsigned (NULL,ParamName,(unsigned) Scope); } @@ -195,11 +195,11 @@ void Sco_PutParamScope (const char *ParamName,Hie_Level_t Scope) void Sco_GetScope (const char *ParamName) { /***** Get parameter with scope *****/ - Gbl.Scope.Current = (Hie_Level_t) + Gbl.Scope.Current = (Hie_Lvl_Level_t) Par_GetParToUnsignedLong (ParamName, 0, - Hie_NUM_LEVELS - 1, - (unsigned long) Hie_UNK); + Hie_Lvl_NUM_LEVELS - 1, + (unsigned long) Hie_Lvl_UNK); /***** Adjust scope avoiding impossible or forbidden scopes *****/ Sco_AdjustScope (); @@ -212,28 +212,28 @@ void Sco_GetScope (const char *ParamName) void Sco_AdjustScope (void) { /***** Is scope is unknow, use default scope *****/ - if (Gbl.Scope.Current == Hie_UNK) + if (Gbl.Scope.Current == Hie_Lvl_UNK) Gbl.Scope.Current = Gbl.Scope.Default; /***** Avoid impossible scopes *****/ - if (Gbl.Scope.Current == Hie_CRS && Gbl.Hierarchy.Crs.CrsCod <= 0) - Gbl.Scope.Current = Hie_DEG; + if (Gbl.Scope.Current == Hie_Lvl_CRS && Gbl.Hierarchy.Crs.CrsCod <= 0) + Gbl.Scope.Current = Hie_Lvl_DEG; - if (Gbl.Scope.Current == Hie_DEG && Gbl.Hierarchy.Deg.DegCod <= 0) - Gbl.Scope.Current = Hie_CTR; + if (Gbl.Scope.Current == Hie_Lvl_DEG && Gbl.Hierarchy.Deg.DegCod <= 0) + Gbl.Scope.Current = Hie_Lvl_CTR; - if (Gbl.Scope.Current == Hie_CTR && Gbl.Hierarchy.Ctr.CtrCod <= 0) - Gbl.Scope.Current = Hie_INS; + if (Gbl.Scope.Current == Hie_Lvl_CTR && Gbl.Hierarchy.Ctr.CtrCod <= 0) + Gbl.Scope.Current = Hie_Lvl_INS; - if (Gbl.Scope.Current == Hie_INS && Gbl.Hierarchy.Ins.InsCod <= 0) - Gbl.Scope.Current = Hie_CTY; + if (Gbl.Scope.Current == Hie_Lvl_INS && Gbl.Hierarchy.Ins.InsCod <= 0) + Gbl.Scope.Current = Hie_Lvl_CTY; - if (Gbl.Scope.Current == Hie_CTY && Gbl.Hierarchy.Cty.CtyCod <= 0) - Gbl.Scope.Current = Hie_SYS; + if (Gbl.Scope.Current == Hie_Lvl_CTY && Gbl.Hierarchy.Cty.CtyCod <= 0) + Gbl.Scope.Current = Hie_Lvl_SYS; /***** Avoid forbidden scopes *****/ if ((Gbl.Scope.Allowed & (1 << Gbl.Scope.Current)) == 0) - Gbl.Scope.Current = Hie_UNK; + Gbl.Scope.Current = Hie_Lvl_UNK; } /*****************************************************************************/ @@ -245,24 +245,24 @@ void Sco_SetScopesForListingGuests (void) switch (Gbl.Usrs.Me.Role.Logged) { case Rol_CTR_ADM: - Gbl.Scope.Allowed = 1 << Hie_CTR; - Gbl.Scope.Default = Hie_CTR; + Gbl.Scope.Allowed = 1 << Hie_Lvl_CTR; + Gbl.Scope.Default = Hie_Lvl_CTR; break; case Rol_INS_ADM: - Gbl.Scope.Allowed = 1 << Hie_INS | - 1 << Hie_CTR; - Gbl.Scope.Default = Hie_INS; + Gbl.Scope.Allowed = 1 << Hie_Lvl_INS | + 1 << Hie_Lvl_CTR; + Gbl.Scope.Default = Hie_Lvl_INS; break; case Rol_SYS_ADM: - Gbl.Scope.Allowed = 1 << Hie_SYS | - 1 << Hie_CTY | - 1 << Hie_INS | - 1 << Hie_CTR; - Gbl.Scope.Default = Hie_SYS; + Gbl.Scope.Allowed = 1 << Hie_Lvl_SYS | + 1 << Hie_Lvl_CTY | + 1 << Hie_Lvl_INS | + 1 << Hie_Lvl_CTR; + Gbl.Scope.Default = Hie_Lvl_SYS; break; default: Gbl.Scope.Allowed = 0; - Gbl.Scope.Default = Hie_UNK; + Gbl.Scope.Default = Hie_Lvl_UNK; break; } } @@ -273,40 +273,40 @@ void Sco_SetScopesForListingGuests (void) void Sco_SetScopesForListingStudents (void) { - Gbl.Scope.Default = Hie_CRS; + Gbl.Scope.Default = Hie_Lvl_CRS; switch (Gbl.Usrs.Me.Role.Logged) { case Rol_STD: case Rol_NET: case Rol_TCH: - Gbl.Scope.Allowed = 1 << Hie_CRS; + Gbl.Scope.Allowed = 1 << Hie_Lvl_CRS; break; case Rol_DEG_ADM: - Gbl.Scope.Allowed = 1 << Hie_DEG | - 1 << Hie_CRS; + Gbl.Scope.Allowed = 1 << Hie_Lvl_DEG | + 1 << Hie_Lvl_CRS; break; case Rol_CTR_ADM: - Gbl.Scope.Allowed = 1 << Hie_CTR | - 1 << Hie_DEG | - 1 << Hie_CRS; + Gbl.Scope.Allowed = 1 << Hie_Lvl_CTR | + 1 << Hie_Lvl_DEG | + 1 << Hie_Lvl_CRS; break; case Rol_INS_ADM: - Gbl.Scope.Allowed = 1 << Hie_INS | - 1 << Hie_CTR | - 1 << Hie_DEG | - 1 << Hie_CRS; + Gbl.Scope.Allowed = 1 << Hie_Lvl_INS | + 1 << Hie_Lvl_CTR | + 1 << Hie_Lvl_DEG | + 1 << Hie_Lvl_CRS; break; case Rol_SYS_ADM: - Gbl.Scope.Allowed = 1 << Hie_SYS | - 1 << Hie_CTY | - 1 << Hie_INS | - 1 << Hie_CTR | - 1 << Hie_DEG | - 1 << Hie_CRS; + Gbl.Scope.Allowed = 1 << Hie_Lvl_SYS | + 1 << Hie_Lvl_CTY | + 1 << Hie_Lvl_INS | + 1 << Hie_Lvl_CTR | + 1 << Hie_Lvl_DEG | + 1 << Hie_Lvl_CRS; break; default: Gbl.Scope.Allowed = 0; - Gbl.Scope.Default = Hie_UNK; + Gbl.Scope.Default = Hie_Lvl_UNK; break; } } @@ -315,53 +315,53 @@ void Sco_SetScopesForListingStudents (void) /*********************** Get scope from unsigned string **********************/ /*****************************************************************************/ -Hie_Level_t Sco_GetScopeFromUnsignedStr (const char *UnsignedStr) +Hie_Lvl_Level_t Sco_GetScopeFromUnsignedStr (const char *UnsignedStr) { unsigned UnsignedNum; if (sscanf (UnsignedStr,"%u",&UnsignedNum) == 1) - if (UnsignedNum < Hie_NUM_LEVELS) - return (Hie_Level_t) UnsignedNum; + if (UnsignedNum < Hie_Lvl_NUM_LEVELS) + return (Hie_Lvl_Level_t) UnsignedNum; - return Hie_UNK; + return Hie_Lvl_UNK; } /*****************************************************************************/ /*********************** Get scope from database string **********************/ /*****************************************************************************/ -Hie_Level_t Sco_GetScopeFromDBStr (const char *ScopeDBStr) +Hie_Lvl_Level_t Sco_GetScopeFromDBStr (const char *ScopeDBStr) { - Hie_Level_t Scope; + Hie_Lvl_Level_t Scope; - for (Scope = (Hie_Level_t) 0; - Scope <= (Hie_Level_t) (Hie_NUM_LEVELS - 1); + for (Scope = (Hie_Lvl_Level_t) 0; + Scope <= (Hie_Lvl_Level_t) (Hie_Lvl_NUM_LEVELS - 1); Scope++) if (!strcmp (Sco_GetDBStrFromScope (Scope),ScopeDBStr)) return Scope; - return Hie_UNK; + return Hie_Lvl_UNK; } /*****************************************************************************/ /*********************** Get scope from database string **********************/ /*****************************************************************************/ -const char *Sco_GetDBStrFromScope (Hie_Level_t Scope) +const char *Sco_GetDBStrFromScope (Hie_Lvl_Level_t Scope) { - static const char *Sco_ScopeDB[Hie_NUM_LEVELS] = + static const char *Sco_ScopeDB[Hie_Lvl_NUM_LEVELS] = { - [Hie_UNK] = "Unk", - [Hie_SYS] = "Sys", - [Hie_CTY] = "Cty", - [Hie_INS] = "Ins", - [Hie_CTR] = "Ctr", - [Hie_DEG] = "Deg", - [Hie_CRS] = "Crs", + [Hie_Lvl_UNK] = "Unk", + [Hie_Lvl_SYS] = "Sys", + [Hie_Lvl_CTY] = "Cty", + [Hie_Lvl_INS] = "Ins", + [Hie_Lvl_CTR] = "Ctr", + [Hie_Lvl_DEG] = "Deg", + [Hie_Lvl_CRS] = "Crs", }; - if (Scope >= Hie_NUM_LEVELS) - Scope = Hie_UNK; + if (Scope >= Hie_Lvl_NUM_LEVELS) + Scope = Hie_Lvl_UNK; return Sco_ScopeDB[Scope]; } diff --git a/swad_scope.h b/swad_scope.h index 6b6f0775..6c85d9a4 100644 --- a/swad_scope.h +++ b/swad_scope.h @@ -29,7 +29,7 @@ #include // For boolean type -#include "swad_hierarchy.h" +#include "swad_hierarchy_level.h" #include "swad_HTML.h" /*****************************************************************************/ @@ -46,15 +46,15 @@ void Sco_PutSelectorScope (const char *ParamName,HTM_SubmitOnChange_t SubmitOnChange); void Sco_PutParamCurrentScope (void *Scope); -void Sco_PutParamScope (const char *ParamName,Hie_Level_t Scope); +void Sco_PutParamScope (const char *ParamName,Hie_Lvl_Level_t Scope); void Sco_GetScope (const char *ParamName); void Sco_AdjustScope (void); void Sco_SetScopesForListingGuests (void); void Sco_SetScopesForListingStudents (void); -Hie_Level_t Sco_GetScopeFromUnsignedStr (const char *UnsignedStr); -Hie_Level_t Sco_GetScopeFromDBStr (const char *ScopeDBStr); -const char *Sco_GetDBStrFromScope (Hie_Level_t Scope); +Hie_Lvl_Level_t Sco_GetScopeFromUnsignedStr (const char *UnsignedStr); +Hie_Lvl_Level_t Sco_GetScopeFromDBStr (const char *ScopeDBStr); +const char *Sco_GetDBStrFromScope (Hie_Lvl_Level_t Scope); #endif diff --git a/swad_search.c b/swad_search.c index 0f3718d6..15af5be6 100644 --- a/swad_search.c +++ b/swad_search.c @@ -64,7 +64,7 @@ extern struct Globals Gbl; /***************************** Private prototypes ****************************/ /*****************************************************************************/ -static void Sch_PutFormToSearchWithWhatToSearchAndScope (Act_Action_t Action,Hie_Level_t DefaultScope); +static void Sch_PutFormToSearchWithWhatToSearchAndScope (Act_Action_t Action,Hie_Lvl_Level_t DefaultScope); static bool Sch_CheckIfIHavePermissionToSearch (Sch_WhatToSearch_t WhatToSearch); static void Sch_GetParamSearch (void); static void Sch_SearchInDB (void); @@ -88,14 +88,14 @@ void Sch_ReqSysSearch (void) { /***** Search courses, teachers, documents... *****/ Sch_GetParamWhatToSearch (); - Sch_PutFormToSearchWithWhatToSearchAndScope (ActSch,Hie_SYS); + Sch_PutFormToSearchWithWhatToSearchAndScope (ActSch,Hie_Lvl_SYS); } /*****************************************************************************/ /****************** Put a form to search, including scope ********************/ /*****************************************************************************/ -static void Sch_PutFormToSearchWithWhatToSearchAndScope (Act_Action_t Action,Hie_Level_t DefaultScope) +static void Sch_PutFormToSearchWithWhatToSearchAndScope (Act_Action_t Action,Hie_Lvl_Level_t DefaultScope) { extern const char *Hlp_START_Search; extern const char *The_ClassFormInBox[The_NUM_THEMES]; @@ -147,12 +147,12 @@ static void Sch_PutFormToSearchWithWhatToSearchAndScope (Act_Action_t Action,Hie HTM_DIV_Begin ("class=\"CM\""); HTM_LABEL_Begin ("class=\"%s\"",The_ClassFormInBox[Gbl.Prefs.Theme]); HTM_TxtColonNBSP (Txt_Scope); - Gbl.Scope.Allowed = 1 << Hie_SYS | - 1 << Hie_CTY | - 1 << Hie_INS | - 1 << Hie_CTR | - 1 << Hie_DEG | - 1 << Hie_CRS; + Gbl.Scope.Allowed = 1 << Hie_Lvl_SYS | + 1 << Hie_Lvl_CTY | + 1 << Hie_Lvl_INS | + 1 << Hie_Lvl_CTR | + 1 << Hie_Lvl_DEG | + 1 << Hie_Lvl_CRS; Gbl.Scope.Default = DefaultScope; Sco_GetScope ("ScopeSch"); Sco_PutSelectorScope ("ScopeSch",HTM_DONT_SUBMIT_ON_CHANGE); @@ -231,7 +231,7 @@ void Sch_PutFormToSearchInPageTopHeading (void) /***** Put form *****/ Frm_StartForm (ActSch); - Sco_PutParamScope ("ScopeSch",Hie_SYS); + Sco_PutParamScope ("ScopeSch",Hie_Lvl_SYS); Sch_PutInputStringToSearch ("head_search_text"); Sch_PutMagnifyingGlassButton ("search-white.svg"); Frm_EndForm (); @@ -323,7 +323,7 @@ void Sch_SysSearch (void) if (Gbl.Search.Str[0]) { /***** Show search form again *****/ - Sch_PutFormToSearchWithWhatToSearchAndScope (ActSch,Hie_SYS); + Sch_PutFormToSearchWithWhatToSearchAndScope (ActSch,Hie_Lvl_SYS); /***** Show results of search *****/ Sch_SearchInDB (); @@ -348,28 +348,28 @@ static void Sch_SearchInDB (void) /***** Select courses in all the degrees or in current degree *****/ switch (Gbl.Scope.Current) { - case Hie_UNK: + case Hie_Lvl_UNK: // Not aplicable - case Hie_SYS: + case Hie_Lvl_SYS: RangeQuery[0] = '\0'; break; - case Hie_CTY: + case Hie_Lvl_CTY: sprintf (RangeQuery," AND countries.CtyCod=%ld", Gbl.Hierarchy.Cty.CtyCod); break; - case Hie_INS: + case Hie_Lvl_INS: sprintf (RangeQuery," AND institutions.InsCod=%ld", Gbl.Hierarchy.Ins.InsCod); break; - case Hie_CTR: + case Hie_Lvl_CTR: sprintf (RangeQuery," AND centres.CtrCod=%ld", Gbl.Hierarchy.Ctr.CtrCod); break; - case Hie_DEG: + case Hie_Lvl_DEG: sprintf (RangeQuery," AND degrees.DegCod=%ld", Gbl.Hierarchy.Deg.DegCod); break; - case Hie_CRS: + case Hie_Lvl_CRS: sprintf (RangeQuery," AND courses.CrsCod=%ld", Gbl.Hierarchy.Crs.CrsCod); break; @@ -451,10 +451,10 @@ static unsigned Sch_SearchCountriesInDB (const char *RangeQuery) unsigned NumCtys; /***** Check scope *****/ - if (Gbl.Scope.Current != Hie_INS && - Gbl.Scope.Current != Hie_CTR && - Gbl.Scope.Current != Hie_DEG && - Gbl.Scope.Current != Hie_CRS) + if (Gbl.Scope.Current != Hie_Lvl_INS && + Gbl.Scope.Current != Hie_Lvl_CTR && + Gbl.Scope.Current != Hie_Lvl_DEG && + Gbl.Scope.Current != Hie_Lvl_CRS) /***** Check user's permission *****/ if (Sch_CheckIfIHavePermissionToSearch (Sch_SEARCH_COUNTRIES)) { @@ -493,9 +493,9 @@ static unsigned Sch_SearchInstitutionsInDB (const char *RangeQuery) unsigned NumInss; /***** Check scope *****/ - if (Gbl.Scope.Current != Hie_CTR && - Gbl.Scope.Current != Hie_DEG && - Gbl.Scope.Current != Hie_CRS) + if (Gbl.Scope.Current != Hie_Lvl_CTR && + Gbl.Scope.Current != Hie_Lvl_DEG && + Gbl.Scope.Current != Hie_Lvl_CRS) /***** Check user's permission *****/ if (Sch_CheckIfIHavePermissionToSearch (Sch_SEARCH_INSTITS)) /***** Split institutions string into words *****/ @@ -530,8 +530,8 @@ static unsigned Sch_SearchCentresInDB (const char *RangeQuery) unsigned NumCtrs; /***** Check scope *****/ - if (Gbl.Scope.Current != Hie_DEG && - Gbl.Scope.Current != Hie_CRS) + if (Gbl.Scope.Current != Hie_Lvl_DEG && + Gbl.Scope.Current != Hie_Lvl_CRS) /***** Check user's permission *****/ if (Sch_CheckIfIHavePermissionToSearch (Sch_SEARCH_CENTRES)) /***** Split centre string into words *****/ @@ -566,7 +566,7 @@ static unsigned Sch_SearchDegreesInDB (const char *RangeQuery) unsigned NumDegs; /***** Check scope *****/ - if (Gbl.Scope.Current != Hie_CRS) + if (Gbl.Scope.Current != Hie_Lvl_CRS) /***** Check user's permission *****/ if (Sch_CheckIfIHavePermissionToSearch (Sch_SEARCH_DEGREES)) /***** Split degree string into words *****/ @@ -1181,7 +1181,7 @@ static void Sch_SaveLastSearchIntoSession (void) void Sch_PutLinkToSearchCoursesParams (__attribute__((unused)) void *Args) { - Sco_PutParamScope ("ScopeSch",Hie_SYS); + Sco_PutParamScope ("ScopeSch",Hie_Lvl_SYS); Par_PutHiddenParamUnsigned (NULL,"WhatToSearch",(unsigned) Sch_SEARCH_COURSES); } diff --git a/swad_statistic.c b/swad_statistic.c index 9432f906..b2c988fb 100644 --- a/swad_statistic.c +++ b/swad_statistic.c @@ -36,6 +36,7 @@ #include "swad_database.h" #include "swad_form.h" #include "swad_global.h" +#include "swad_hierarchy.h" #include "swad_HTML.h" #include "swad_ID.h" #include "swad_log.h" @@ -270,9 +271,9 @@ static void Sta_PutFormCrsHits (struct Sta_Stats *Stats) Grp_GetParCodsSeveralGrpsToShowUsrs (); /***** Get and order the lists of users of this course *****/ - Usr_GetListUsrs (Hie_CRS,Rol_STD); - Usr_GetListUsrs (Hie_CRS,Rol_NET); - Usr_GetListUsrs (Hie_CRS,Rol_TCH); + Usr_GetListUsrs (Hie_Lvl_CRS,Rol_STD); + Usr_GetListUsrs (Hie_Lvl_CRS,Rol_NET); + Usr_GetListUsrs (Hie_Lvl_CRS,Rol_TCH); NumTotalUsrs = Gbl.Usrs.LstUsrs[Rol_STD].NumUsrs + Gbl.Usrs.LstUsrs[Rol_NET].NumUsrs + Gbl.Usrs.LstUsrs[Rol_TCH].NumUsrs; @@ -539,13 +540,13 @@ static void Sta_PutFormGblHits (struct Sta_Stats *Stats) /* Data */ HTM_TD_Begin ("class=\"LT\""); - Gbl.Scope.Allowed = 1 << Hie_SYS | - 1 << Hie_CTY | - 1 << Hie_INS | - 1 << Hie_CTR | - 1 << Hie_DEG | - 1 << Hie_CRS; - Gbl.Scope.Default = Hie_SYS; + Gbl.Scope.Allowed = 1 << Hie_Lvl_SYS | + 1 << Hie_Lvl_CTY | + 1 << Hie_Lvl_INS | + 1 << Hie_Lvl_CTR | + 1 << Hie_Lvl_DEG | + 1 << Hie_Lvl_CRS; + Gbl.Scope.Default = Hie_Lvl_SYS; Sco_GetScope ("ScopeSta"); Sco_PutSelectorScope ("ScopeSta",HTM_DONT_SUBMIT_ON_CHANGE); HTM_TD_End (); @@ -608,7 +609,7 @@ void Sta_PutLinkToCourseHits (void) { extern const char *Txt_Visits_to_course; - if (Gbl.Hierarchy.Level == Hie_CRS) // Course selected + if (Gbl.Hierarchy.Level == Hie_Lvl_CRS) // Course selected switch (Gbl.Usrs.Me.Role.Logged) { case Rol_NET: @@ -824,13 +825,13 @@ static void Sta_ShowHits (Sta_GlobalOrCourseAccesses_t GlobalOrCourse) (unsigned long) Sta_ROLE_DEFAULT); /***** Get users range for access statistics *****/ - Gbl.Scope.Allowed = 1 << Hie_SYS | - 1 << Hie_CTY | - 1 << Hie_INS | - 1 << Hie_CTR | - 1 << Hie_DEG | - 1 << Hie_CRS; - Gbl.Scope.Default = Hie_SYS; + Gbl.Scope.Allowed = 1 << Hie_Lvl_SYS | + 1 << Hie_Lvl_CTY | + 1 << Hie_Lvl_INS | + 1 << Hie_Lvl_CTR | + 1 << Hie_Lvl_DEG | + 1 << Hie_Lvl_CRS; + Gbl.Scope.Default = Hie_Lvl_SYS; Sco_GetScope ("ScopeSta"); /***** Show form again *****/ @@ -896,16 +897,16 @@ static void Sta_ShowHits (Sta_GlobalOrCourseAccesses_t GlobalOrCourse) /***** Check if range of dates is forbidden for me *****/ NumDays = Dat_GetNumDaysBetweenDates (&Gbl.DateRange.DateIni.Date,&Gbl.DateRange.DateEnd.Date); ICanQueryWholeRange = (Gbl.Usrs.Me.Role.Logged >= Rol_TCH && GlobalOrCourse == Sta_SHOW_COURSE_ACCESSES) || - (Gbl.Usrs.Me.Role.Logged == Rol_TCH && Gbl.Scope.Current == Hie_CRS) || - (Gbl.Usrs.Me.Role.Logged == Rol_DEG_ADM && (Gbl.Scope.Current == Hie_DEG || - Gbl.Scope.Current == Hie_CRS)) || - (Gbl.Usrs.Me.Role.Logged == Rol_CTR_ADM && (Gbl.Scope.Current == Hie_CTR || - Gbl.Scope.Current == Hie_DEG || - Gbl.Scope.Current == Hie_CRS)) || - (Gbl.Usrs.Me.Role.Logged == Rol_INS_ADM && (Gbl.Scope.Current == Hie_INS || - Gbl.Scope.Current == Hie_CTR || - Gbl.Scope.Current == Hie_DEG || - Gbl.Scope.Current == Hie_CRS)) || + (Gbl.Usrs.Me.Role.Logged == Rol_TCH && Gbl.Scope.Current == Hie_Lvl_CRS) || + (Gbl.Usrs.Me.Role.Logged == Rol_DEG_ADM && (Gbl.Scope.Current == Hie_Lvl_DEG || + Gbl.Scope.Current == Hie_Lvl_CRS)) || + (Gbl.Usrs.Me.Role.Logged == Rol_CTR_ADM && (Gbl.Scope.Current == Hie_Lvl_CTR || + Gbl.Scope.Current == Hie_Lvl_DEG || + Gbl.Scope.Current == Hie_Lvl_CRS)) || + (Gbl.Usrs.Me.Role.Logged == Rol_INS_ADM && (Gbl.Scope.Current == Hie_Lvl_INS || + Gbl.Scope.Current == Hie_Lvl_CTR || + Gbl.Scope.Current == Hie_Lvl_DEG || + Gbl.Scope.Current == Hie_Lvl_CRS)) || Gbl.Usrs.Me.Role.Logged == Rol_SYS_ADM; if (!ICanQueryWholeRange && NumDays > Cfg_DAYS_IN_RECENT_LOG) { @@ -1087,10 +1088,10 @@ static void Sta_ShowHits (Sta_GlobalOrCourseAccesses_t GlobalOrCourse) /* Scope */ switch (Gbl.Scope.Current) { - case Hie_UNK: - case Hie_SYS: + case Hie_Lvl_UNK: + case Hie_Lvl_SYS: break; - case Hie_CTY: + case Hie_Lvl_CTY: if (Gbl.Hierarchy.Cty.CtyCod > 0) { sprintf (QueryAux," AND %s.CtyCod=%ld", @@ -1099,7 +1100,7 @@ static void Sta_ShowHits (Sta_GlobalOrCourseAccesses_t GlobalOrCourse) Sta_MAX_BYTES_QUERY_ACCESS); } break; - case Hie_INS: + case Hie_Lvl_INS: if (Gbl.Hierarchy.Ins.InsCod > 0) { sprintf (QueryAux," AND %s.InsCod=%ld", @@ -1108,7 +1109,7 @@ static void Sta_ShowHits (Sta_GlobalOrCourseAccesses_t GlobalOrCourse) Sta_MAX_BYTES_QUERY_ACCESS); } break; - case Hie_CTR: + case Hie_Lvl_CTR: if (Gbl.Hierarchy.Ctr.CtrCod > 0) { sprintf (QueryAux," AND %s.CtrCod=%ld", @@ -1117,7 +1118,7 @@ static void Sta_ShowHits (Sta_GlobalOrCourseAccesses_t GlobalOrCourse) Sta_MAX_BYTES_QUERY_ACCESS); } break; - case Hie_DEG: + case Hie_Lvl_DEG: if (Gbl.Hierarchy.Deg.DegCod > 0) { sprintf (QueryAux," AND %s.DegCod=%ld", @@ -1126,8 +1127,8 @@ static void Sta_ShowHits (Sta_GlobalOrCourseAccesses_t GlobalOrCourse) Sta_MAX_BYTES_QUERY_ACCESS); } break; - case Hie_CRS: - if (Gbl.Hierarchy.Level == Hie_CRS) + case Hie_Lvl_CRS: + if (Gbl.Hierarchy.Level == Hie_Lvl_CRS) { sprintf (QueryAux," AND %s.CrsCod=%ld", LogTable,Gbl.Hierarchy.Crs.CrsCod); @@ -3376,7 +3377,7 @@ static void Sta_ShowNumHitsPerCountry (Sta_CountType_t CountType, static void Sta_WriteCountry (long CtyCod) { - struct Country Cty; + struct Cty_Countr Cty; /***** Start cell *****/ HTM_TD_Begin ("class=\"LOG LM\""); diff --git a/swad_survey.c b/swad_survey.c index a0fa7a41..e02c077e 100644 --- a/swad_survey.c +++ b/swad_survey.c @@ -649,25 +649,25 @@ static void Svy_ShowOneSurvey (struct Svy_Surveys *Surveys, HTM_TxtColonNBSP (Txt_Scope); switch (Svy.Scope) { - case Hie_UNK: // Unknown + case Hie_Lvl_UNK: // Unknown Lay_ShowErrorAndExit ("Wrong survey scope."); break; - case Hie_SYS: // System + case Hie_Lvl_SYS: // System HTM_Txt (Cfg_PLATFORM_SHORT_NAME); break; - case Hie_CTY: // Country + case Hie_Lvl_CTY: // Country HTM_TxtF ("%s %s",Txt_Country,Gbl.Hierarchy.Cty.Name[Gbl.Prefs.Language]); break; - case Hie_INS: // Institution + case Hie_Lvl_INS: // Institution HTM_TxtF ("%s %s",Txt_Institution,Gbl.Hierarchy.Ins.ShrtName); break; - case Hie_CTR: // Centre + case Hie_Lvl_CTR: // Centre HTM_TxtF ("%s %s",Txt_Centre,Gbl.Hierarchy.Ctr.ShrtName); break; - case Hie_DEG: // Degree + case Hie_Lvl_DEG: // Degree HTM_TxtF ("%s %s",Txt_Degree,Gbl.Hierarchy.Deg.ShrtName); break; - case Hie_CRS: // Course + case Hie_Lvl_CRS: // Course HTM_TxtF ("%s %s",Txt_Course,Gbl.Hierarchy.Crs.ShrtName); break; } @@ -686,7 +686,7 @@ static void Svy_ShowOneSurvey (struct Svy_Surveys *Surveys, HTM_DIV_End (); /* Groups whose users can answer this survey */ - if (Svy.Scope == Hie_CRS) + if (Svy.Scope == Hie_Lvl_CRS) if (Gbl.Crs.Grps.NumGrps) Svy_GetAndWriteNamesOfGrpsAssociatedToSvy (&Svy); @@ -716,7 +716,7 @@ static void Svy_ShowOneSurvey (struct Svy_Surveys *Surveys, Gbl.RowEvenOdd = 1 - Gbl.RowEvenOdd; /***** Mark possible notification as seen *****/ - if (Svy.Scope == Hie_CRS) // Only course surveys are notified + if (Svy.Scope == Hie_Lvl_CRS) // Only course surveys are notified Ntf_MarkNotifAsSeen (Ntf_EVENT_SURVEY, SvyCod,Svy.Cod, Gbl.Usrs.Me.UsrDat.UsrCod); @@ -930,7 +930,7 @@ static void Svy_PutParams (void *Surveys) static void Svy_GetListSurveys (struct Svy_Surveys *Surveys) { - char *SubQuery[Hie_NUM_LEVELS]; + char *SubQuery[Hie_Lvl_NUM_LEVELS]; static const char *OrderBySubQuery[Dat_NUM_START_END_TIME] = { [Dat_START_TIME] = "StartTime DESC,EndTime DESC,Title DESC", @@ -942,8 +942,8 @@ static void Svy_GetListSurveys (struct Svy_Surveys *Surveys) unsigned NumSvy; unsigned ScopesAllowed = 0; unsigned HiddenAllowed = 0; - long Cods[Hie_NUM_LEVELS]; - Hie_Level_t Scope; + long Cods[Hie_Lvl_NUM_LEVELS]; + Hie_Lvl_Level_t Scope; bool SubQueryFilled = false; /***** Free list of surveys *****/ @@ -954,16 +954,16 @@ static void Svy_GetListSurveys (struct Svy_Surveys *Surveys) Svy_SetAllowedAndHiddenScopes (&ScopesAllowed,&HiddenAllowed); /***** Get list of surveys from database *****/ - Cods[Hie_SYS] = -1L; // System - Cods[Hie_CTY] = Gbl.Hierarchy.Cty.CtyCod; // Country - Cods[Hie_INS] = Gbl.Hierarchy.Ins.InsCod; // Institution - Cods[Hie_CTR] = Gbl.Hierarchy.Ctr.CtrCod; // Centre - Cods[Hie_DEG] = Gbl.Hierarchy.Deg.DegCod; // Degree - Cods[Hie_CRS] = Gbl.Hierarchy.Crs.CrsCod; // Course + Cods[Hie_Lvl_SYS] = -1L; // System + Cods[Hie_Lvl_CTY] = Gbl.Hierarchy.Cty.CtyCod; // Country + Cods[Hie_Lvl_INS] = Gbl.Hierarchy.Ins.InsCod; // Institution + Cods[Hie_Lvl_CTR] = Gbl.Hierarchy.Ctr.CtrCod; // Centre + Cods[Hie_Lvl_DEG] = Gbl.Hierarchy.Deg.DegCod; // Degree + Cods[Hie_Lvl_CRS] = Gbl.Hierarchy.Crs.CrsCod; // Course /* Fill subqueries for system, country, institution, centre and degree */ - for (Scope = Hie_SYS; - Scope <= Hie_DEG; + for (Scope = Hie_Lvl_SYS; + Scope <= Hie_Lvl_DEG; Scope++) if (ScopesAllowed & 1 << Scope) { @@ -983,11 +983,11 @@ static void Svy_GetListSurveys (struct Svy_Surveys *Surveys) } /* Fill subquery for course */ - if (ScopesAllowed & 1 << Hie_CRS) + if (ScopesAllowed & 1 << Hie_Lvl_CRS) { if (Gbl.Crs.Grps.WhichGrps == Grp_MY_GROUPS) { - if (asprintf (&SubQuery[Hie_CRS],"%s(" + if (asprintf (&SubQuery[Hie_Lvl_CRS],"%s(" "Scope='%s' AND Cod=%ld%s" " AND " "(SvyCod NOT IN" @@ -1001,19 +1001,19 @@ static void Svy_GetListSurveys (struct Svy_Surveys *Surveys) ")", SubQueryFilled ? " OR " : "", - Sco_GetDBStrFromScope (Hie_CRS),Cods[Hie_CRS], - (HiddenAllowed & 1 << Hie_CRS) ? "" : + Sco_GetDBStrFromScope (Hie_Lvl_CRS),Cods[Hie_Lvl_CRS], + (HiddenAllowed & 1 << Hie_Lvl_CRS) ? "" : " AND Hidden='N'", Gbl.Usrs.Me.UsrDat.UsrCod) < 0) Lay_NotEnoughMemoryExit (); } else // Gbl.Crs.Grps.WhichGrps == Grp_ALL_GROUPS { - if (asprintf (&SubQuery[Hie_CRS],"%s(Scope='%s' AND Cod=%ld%s)", + if (asprintf (&SubQuery[Hie_Lvl_CRS],"%s(Scope='%s' AND Cod=%ld%s)", SubQueryFilled ? " OR " : "", - Sco_GetDBStrFromScope (Hie_CRS),Cods[Hie_CRS], - (HiddenAllowed & 1 << Hie_CRS) ? "" : + Sco_GetDBStrFromScope (Hie_Lvl_CRS),Cods[Hie_Lvl_CRS], + (HiddenAllowed & 1 << Hie_Lvl_CRS) ? "" : " AND Hidden='N'") < 0) Lay_NotEnoughMemoryExit (); } @@ -1021,7 +1021,7 @@ static void Svy_GetListSurveys (struct Svy_Surveys *Surveys) } else { - if (asprintf (&SubQuery[Hie_CRS],"%s","") < 0) + if (asprintf (&SubQuery[Hie_Lvl_CRS],"%s","") < 0) Lay_NotEnoughMemoryExit (); } @@ -1031,12 +1031,12 @@ static void Svy_GetListSurveys (struct Svy_Surveys *Surveys) "SELECT SvyCod FROM surveys" " WHERE %s%s%s%s%s%s" " ORDER BY %s", - SubQuery[Hie_SYS], - SubQuery[Hie_CTY], - SubQuery[Hie_INS], - SubQuery[Hie_CTR], - SubQuery[Hie_DEG], - SubQuery[Hie_CRS], + SubQuery[Hie_Lvl_SYS], + SubQuery[Hie_Lvl_CTY], + SubQuery[Hie_Lvl_INS], + SubQuery[Hie_Lvl_CTR], + SubQuery[Hie_Lvl_DEG], + SubQuery[Hie_Lvl_CRS], OrderBySubQuery[Surveys->SelectedOrder]); else { @@ -1045,8 +1045,8 @@ static void Svy_GetListSurveys (struct Svy_Surveys *Surveys) } /* Free allocated memory for subqueries */ - for (Scope = Hie_SYS; - Scope <= Hie_CRS; + for (Scope = Hie_Lvl_SYS; + Scope <= Hie_Lvl_CRS; Scope++) free (SubQuery[Scope]); @@ -1092,45 +1092,45 @@ static void Svy_SetAllowedAndHiddenScopes (unsigned *ScopesAllowed, *HiddenAllowed = 0; break; case Rol_GST: // User not belonging to any course ******************* - *ScopesAllowed = 1 << Hie_SYS; + *ScopesAllowed = 1 << Hie_Lvl_SYS; *HiddenAllowed = 0; break; case Rol_USR: // Student or teacher in other courses... // ...but not belonging to the current course ********* - *ScopesAllowed = 1 << Hie_SYS; + *ScopesAllowed = 1 << Hie_Lvl_SYS; *HiddenAllowed = 0; if (Usr_CheckIfIBelongToCty (Gbl.Hierarchy.Cty.CtyCod)) { - *ScopesAllowed |= 1 << Hie_CTY; + *ScopesAllowed |= 1 << Hie_Lvl_CTY; if (Usr_CheckIfIBelongToIns (Gbl.Hierarchy.Ins.InsCod)) { - *ScopesAllowed |= 1 << Hie_INS; + *ScopesAllowed |= 1 << Hie_Lvl_INS; if (Usr_CheckIfIBelongToCtr (Gbl.Hierarchy.Ctr.CtrCod)) { - *ScopesAllowed |= 1 << Hie_CTR; + *ScopesAllowed |= 1 << Hie_Lvl_CTR; if (Usr_CheckIfIBelongToDeg (Gbl.Hierarchy.Deg.DegCod)) - *ScopesAllowed |= 1 << Hie_DEG; + *ScopesAllowed |= 1 << Hie_Lvl_DEG; } } } break; case Rol_STD: // Student in current course ************************** - *ScopesAllowed = 1 << Hie_SYS; + *ScopesAllowed = 1 << Hie_Lvl_SYS; *HiddenAllowed = 0; if (Usr_CheckIfIBelongToCty (Gbl.Hierarchy.Cty.CtyCod)) { - *ScopesAllowed |= 1 << Hie_CTY; + *ScopesAllowed |= 1 << Hie_Lvl_CTY; if (Usr_CheckIfIBelongToIns (Gbl.Hierarchy.Ins.InsCod)) { - *ScopesAllowed |= 1 << Hie_INS; + *ScopesAllowed |= 1 << Hie_Lvl_INS; if (Usr_CheckIfIBelongToCtr (Gbl.Hierarchy.Ctr.CtrCod)) { - *ScopesAllowed |= 1 << Hie_CTR; + *ScopesAllowed |= 1 << Hie_Lvl_CTR; if (Usr_CheckIfIBelongToDeg (Gbl.Hierarchy.Deg.DegCod)) { - *ScopesAllowed |= 1 << Hie_DEG; + *ScopesAllowed |= 1 << Hie_Lvl_DEG; if (Gbl.Usrs.Me.IBelongToCurrentCrs) - *ScopesAllowed |= 1 << Hie_CRS; + *ScopesAllowed |= 1 << Hie_Lvl_CRS; } } } @@ -1138,24 +1138,24 @@ static void Svy_SetAllowedAndHiddenScopes (unsigned *ScopesAllowed, break; case Rol_NET: // Non-editing teacher in current course ************** case Rol_TCH: // Teacher in current course ************************** - *ScopesAllowed = 1 << Hie_SYS; + *ScopesAllowed = 1 << Hie_Lvl_SYS; *HiddenAllowed = 0; if (Usr_CheckIfIBelongToCty (Gbl.Hierarchy.Cty.CtyCod)) { - *ScopesAllowed |= 1 << Hie_CTY; + *ScopesAllowed |= 1 << Hie_Lvl_CTY; if (Usr_CheckIfIBelongToIns (Gbl.Hierarchy.Ins.InsCod)) { - *ScopesAllowed |= 1 << Hie_INS; + *ScopesAllowed |= 1 << Hie_Lvl_INS; if (Usr_CheckIfIBelongToCtr (Gbl.Hierarchy.Ctr.CtrCod)) { - *ScopesAllowed |= 1 << Hie_CTR; + *ScopesAllowed |= 1 << Hie_Lvl_CTR; if (Usr_CheckIfIBelongToDeg (Gbl.Hierarchy.Deg.DegCod)) { - *ScopesAllowed |= 1 << Hie_DEG; + *ScopesAllowed |= 1 << Hie_Lvl_DEG; if (Gbl.Usrs.Me.IBelongToCurrentCrs) { - *ScopesAllowed |= 1 << Hie_CRS; - *HiddenAllowed |= 1 << Hie_CRS; // A non-editing teacher or teacher can view hidden course surveys + *ScopesAllowed |= 1 << Hie_Lvl_CRS; + *HiddenAllowed |= 1 << Hie_Lvl_CRS; // A non-editing teacher or teacher can view hidden course surveys } } } @@ -1163,79 +1163,79 @@ static void Svy_SetAllowedAndHiddenScopes (unsigned *ScopesAllowed, } break; case Rol_DEG_ADM: // Degree administrator ******************************* - *ScopesAllowed = 1 << Hie_SYS; + *ScopesAllowed = 1 << Hie_Lvl_SYS; *HiddenAllowed = 0; if (Gbl.Hierarchy.Cty.CtyCod > 0) // Country selected { - *ScopesAllowed |= 1 << Hie_CTY; + *ScopesAllowed |= 1 << Hie_Lvl_CTY; if (Gbl.Hierarchy.Ins.InsCod > 0) // Institution selected { - *ScopesAllowed |= 1 << Hie_INS; + *ScopesAllowed |= 1 << Hie_Lvl_INS; if (Gbl.Hierarchy.Ctr.CtrCod > 0) // Centre selected { - *ScopesAllowed |= 1 << Hie_CTR; + *ScopesAllowed |= 1 << Hie_Lvl_CTR; if (Gbl.Hierarchy.Deg.DegCod > 0) // Degree selected { - *ScopesAllowed |= 1 << Hie_DEG; - *HiddenAllowed |= 1 << Hie_DEG; // A degree admin can view hidden degree surveys + *ScopesAllowed |= 1 << Hie_Lvl_DEG; + *HiddenAllowed |= 1 << Hie_Lvl_DEG; // A degree admin can view hidden degree surveys } } } } break; case Rol_CTR_ADM: // Centre administrator ******************************* - *ScopesAllowed = 1 << Hie_SYS; + *ScopesAllowed = 1 << Hie_Lvl_SYS; *HiddenAllowed = 0; if (Gbl.Hierarchy.Cty.CtyCod > 0) // Country selected { - *ScopesAllowed |= 1 << Hie_CTY; + *ScopesAllowed |= 1 << Hie_Lvl_CTY; if (Gbl.Hierarchy.Ins.InsCod > 0) // Institution selected { - *ScopesAllowed |= 1 << Hie_INS; + *ScopesAllowed |= 1 << Hie_Lvl_INS; if (Gbl.Hierarchy.Ctr.CtrCod > 0) // Centre selected { - *ScopesAllowed |= 1 << Hie_CTR; - *HiddenAllowed |= 1 << Hie_CTR; // A centre admin can view hidden centre surveys + *ScopesAllowed |= 1 << Hie_Lvl_CTR; + *HiddenAllowed |= 1 << Hie_Lvl_CTR; // A centre admin can view hidden centre surveys } } } break; case Rol_INS_ADM: // Institution administrator ************************** - *ScopesAllowed = 1 << Hie_SYS; + *ScopesAllowed = 1 << Hie_Lvl_SYS; *HiddenAllowed = 0; if (Gbl.Hierarchy.Cty.CtyCod > 0) // Country selected { - *ScopesAllowed |= 1 << Hie_CTY; + *ScopesAllowed |= 1 << Hie_Lvl_CTY; if (Gbl.Hierarchy.Ins.InsCod > 0) // Institution selected { - *ScopesAllowed |= 1 << Hie_INS; - *HiddenAllowed |= 1 << Hie_INS; // An institution admin can view hidden institution surveys + *ScopesAllowed |= 1 << Hie_Lvl_INS; + *HiddenAllowed |= 1 << Hie_Lvl_INS; // An institution admin can view hidden institution surveys } } break; case Rol_SYS_ADM: // System administrator (superuser) ******************* - *ScopesAllowed = 1 << Hie_SYS; - *HiddenAllowed = 1 << Hie_SYS; // A system admin can view hidden system surveys + *ScopesAllowed = 1 << Hie_Lvl_SYS; + *HiddenAllowed = 1 << Hie_Lvl_SYS; // A system admin can view hidden system surveys if (Gbl.Hierarchy.Cty.CtyCod > 0) // Country selected { - *ScopesAllowed |= 1 << Hie_CTY; - *HiddenAllowed |= 1 << Hie_CTY; // A system admin can view hidden country surveys + *ScopesAllowed |= 1 << Hie_Lvl_CTY; + *HiddenAllowed |= 1 << Hie_Lvl_CTY; // A system admin can view hidden country surveys if (Gbl.Hierarchy.Ins.InsCod > 0) // Institution selected { - *ScopesAllowed |= 1 << Hie_INS; - *HiddenAllowed |= 1 << Hie_INS; // A system admin can view hidden institution surveys + *ScopesAllowed |= 1 << Hie_Lvl_INS; + *HiddenAllowed |= 1 << Hie_Lvl_INS; // A system admin can view hidden institution surveys if (Gbl.Hierarchy.Ctr.CtrCod > 0) // Centre selected { - *ScopesAllowed |= 1 << Hie_CTR; - *HiddenAllowed |= 1 << Hie_CTR; // A system admin can view hidden centre surveys + *ScopesAllowed |= 1 << Hie_Lvl_CTR; + *HiddenAllowed |= 1 << Hie_Lvl_CTR; // A system admin can view hidden centre surveys if (Gbl.Hierarchy.Deg.DegCod > 0) // Degree selected { - *ScopesAllowed |= 1 << Hie_DEG; - *HiddenAllowed |= 1 << Hie_DEG; // A system admin can view hidden degree surveys - if (Gbl.Hierarchy.Level == Hie_CRS) // Course selected + *ScopesAllowed |= 1 << Hie_Lvl_DEG; + *HiddenAllowed |= 1 << Hie_Lvl_DEG; // A system admin can view hidden degree surveys + if (Gbl.Hierarchy.Level == Hie_Lvl_CRS) // Course selected { - *ScopesAllowed |= 1 << Hie_CRS; - *HiddenAllowed |= 1 << Hie_CRS; // A system admin can view hidden course surveys + *ScopesAllowed |= 1 << Hie_Lvl_CRS; + *HiddenAllowed |= 1 << Hie_Lvl_CRS; // A system admin can view hidden course surveys } } } @@ -1275,7 +1275,7 @@ void Svy_GetDataOfSurveyByCod (struct Svy_Survey *Svy) Svy->SvyCod = Str_ConvertStrCodToLongCod (row[0]); /* Get survey scope (row[1]) */ - if ((Svy->Scope = Sco_GetScopeFromDBStr (row[1])) == Hie_UNK) + if ((Svy->Scope = Sco_GetScopeFromDBStr (row[1])) == Hie_Lvl_UNK) Lay_ShowErrorAndExit ("Wrong survey scope."); /* Get code of the country, institution, centre, degree or course (row[2]) */ @@ -1314,25 +1314,25 @@ void Svy_GetDataOfSurveyByCod (struct Svy_Survey *Svy) /* Do I belong to valid groups to answer this survey? */ switch (Svy->Scope) { - case Hie_UNK: // Unknown + case Hie_Lvl_UNK: // Unknown Lay_ShowErrorAndExit ("Wrong survey scope."); break; - case Hie_SYS: // System + case Hie_Lvl_SYS: // System Svy->Status.IBelongToScope = Gbl.Usrs.Me.Logged; break; - case Hie_CTY: // Country + case Hie_Lvl_CTY: // Country Svy->Status.IBelongToScope = Usr_CheckIfIBelongToCty (Svy->Cod); break; - case Hie_INS: // Institution + case Hie_Lvl_INS: // Institution Svy->Status.IBelongToScope = Usr_CheckIfIBelongToIns (Svy->Cod); break; - case Hie_CTR: // Centre + case Hie_Lvl_CTR: // Centre Svy->Status.IBelongToScope = Usr_CheckIfIBelongToCtr (Svy->Cod); break; - case Hie_DEG: // Degree + case Hie_Lvl_DEG: // Degree Svy->Status.IBelongToScope = Usr_CheckIfIBelongToDeg (Svy->Cod); break; - case Hie_CRS: // Course + case Hie_Lvl_CRS: // Course Svy->Status.IBelongToScope = Usr_CheckIfIBelongToCrs (Svy->Cod) && Svy_CheckIfICanDoThisSurveyBasedOnGrps (Svy->SvyCod); break; @@ -1354,12 +1354,12 @@ void Svy_GetDataOfSurveyByCod (struct Svy_Survey *Svy) switch (Gbl.Usrs.Me.Role.Logged) { case Rol_STD: - Svy->Status.ICanViewResults = (Svy->Scope == Hie_CRS || - Svy->Scope == Hie_DEG || - Svy->Scope == Hie_CTR || - Svy->Scope == Hie_INS || - Svy->Scope == Hie_CTY || - Svy->Scope == Hie_SYS) && + Svy->Status.ICanViewResults = (Svy->Scope == Hie_Lvl_CRS || + Svy->Scope == Hie_Lvl_DEG || + Svy->Scope == Hie_Lvl_CTR || + Svy->Scope == Hie_Lvl_INS || + Svy->Scope == Hie_Lvl_CTY || + Svy->Scope == Hie_Lvl_SYS) && (Svy->NumQsts != 0) && Svy->Status.Visible && Svy->Status.Open && @@ -1369,56 +1369,56 @@ void Svy_GetDataOfSurveyByCod (struct Svy_Survey *Svy) Svy->Status.ICanEdit = false; break; case Rol_NET: - Svy->Status.ICanViewResults = (Svy->Scope == Hie_CRS || - Svy->Scope == Hie_DEG || - Svy->Scope == Hie_CTR || - Svy->Scope == Hie_INS || - Svy->Scope == Hie_CTY || - Svy->Scope == Hie_SYS) && + Svy->Status.ICanViewResults = (Svy->Scope == Hie_Lvl_CRS || + Svy->Scope == Hie_Lvl_DEG || + Svy->Scope == Hie_Lvl_CTR || + Svy->Scope == Hie_Lvl_INS || + Svy->Scope == Hie_Lvl_CTY || + Svy->Scope == Hie_Lvl_SYS) && Svy->NumQsts != 0 && !Svy->Status.ICanAnswer; Svy->Status.ICanEdit = false; break; case Rol_TCH: - Svy->Status.ICanViewResults = (Svy->Scope == Hie_CRS || - Svy->Scope == Hie_DEG || - Svy->Scope == Hie_CTR || - Svy->Scope == Hie_INS || - Svy->Scope == Hie_CTY || - Svy->Scope == Hie_SYS) && + Svy->Status.ICanViewResults = (Svy->Scope == Hie_Lvl_CRS || + Svy->Scope == Hie_Lvl_DEG || + Svy->Scope == Hie_Lvl_CTR || + Svy->Scope == Hie_Lvl_INS || + Svy->Scope == Hie_Lvl_CTY || + Svy->Scope == Hie_Lvl_SYS) && Svy->NumQsts != 0 && !Svy->Status.ICanAnswer; - Svy->Status.ICanEdit = Svy->Scope == Hie_CRS && + Svy->Status.ICanEdit = Svy->Scope == Hie_Lvl_CRS && Svy->Status.IBelongToScope; break; case Rol_DEG_ADM: - Svy->Status.ICanViewResults = (Svy->Scope == Hie_DEG || - Svy->Scope == Hie_CTR || - Svy->Scope == Hie_INS || - Svy->Scope == Hie_CTY || - Svy->Scope == Hie_SYS) && + Svy->Status.ICanViewResults = (Svy->Scope == Hie_Lvl_DEG || + Svy->Scope == Hie_Lvl_CTR || + Svy->Scope == Hie_Lvl_INS || + Svy->Scope == Hie_Lvl_CTY || + Svy->Scope == Hie_Lvl_SYS) && (Svy->NumQsts != 0) && !Svy->Status.ICanAnswer; - Svy->Status.ICanEdit = Svy->Scope == Hie_DEG && + Svy->Status.ICanEdit = Svy->Scope == Hie_Lvl_DEG && Svy->Status.IBelongToScope; break; case Rol_CTR_ADM: - Svy->Status.ICanViewResults = (Svy->Scope == Hie_CTR || - Svy->Scope == Hie_INS || - Svy->Scope == Hie_CTY || - Svy->Scope == Hie_SYS) && + Svy->Status.ICanViewResults = (Svy->Scope == Hie_Lvl_CTR || + Svy->Scope == Hie_Lvl_INS || + Svy->Scope == Hie_Lvl_CTY || + Svy->Scope == Hie_Lvl_SYS) && (Svy->NumQsts != 0) && !Svy->Status.ICanAnswer; - Svy->Status.ICanEdit = Svy->Scope == Hie_CTR && + Svy->Status.ICanEdit = Svy->Scope == Hie_Lvl_CTR && Svy->Status.IBelongToScope; break; case Rol_INS_ADM: - Svy->Status.ICanViewResults = (Svy->Scope == Hie_INS || - Svy->Scope == Hie_CTY || - Svy->Scope == Hie_SYS) && + Svy->Status.ICanViewResults = (Svy->Scope == Hie_Lvl_INS || + Svy->Scope == Hie_Lvl_CTY || + Svy->Scope == Hie_Lvl_SYS) && (Svy->NumQsts != 0) && !Svy->Status.ICanAnswer; - Svy->Status.ICanEdit = Svy->Scope == Hie_INS && + Svy->Status.ICanEdit = Svy->Scope == Hie_Lvl_INS && Svy->Status.IBelongToScope; break; case Rol_SYS_ADM: @@ -1435,7 +1435,7 @@ void Svy_GetDataOfSurveyByCod (struct Svy_Survey *Svy) { /* Initialize to empty survey */ Svy->SvyCod = -1L; - Svy->Scope = Hie_UNK; + Svy->Scope = Hie_Lvl_UNK; Svy->Roles = 0; Svy->UsrCod = -1L; Svy->TimeUTC[Svy_START_TIME] = @@ -1905,7 +1905,7 @@ void Svy_RequestCreatOrEditSvy (void) /* Initialize to empty survey */ Svy.SvyCod = -1L; - Svy.Scope = Hie_UNK; + Svy.Scope = Hie_Lvl_UNK; Svy.Roles = (1 << Rol_STD); Svy.UsrCod = Gbl.Usrs.Me.UsrDat.UsrCod; Svy.TimeUTC[Svy_START_TIME] = Gbl.StartExecutionTimeUTC; @@ -2049,66 +2049,66 @@ static void Svy_SetDefaultAndAllowedScope (struct Svy_Survey *Svy) bool ICanEdit = false; /***** Set default scope *****/ - Gbl.Scope.Default = Hie_UNK; + Gbl.Scope.Default = Hie_Lvl_UNK; Gbl.Scope.Allowed = 0; switch (Gbl.Usrs.Me.Role.Logged) { case Rol_TCH: // Teachers only can edit course surveys - if (Gbl.Hierarchy.Level == Hie_CRS) // Course selected + if (Gbl.Hierarchy.Level == Hie_Lvl_CRS) // Course selected { - if (Svy->Scope == Hie_UNK) // Scope not defined - Svy->Scope = Hie_CRS; - if (Svy->Scope == Hie_CRS) + if (Svy->Scope == Hie_Lvl_UNK) // Scope not defined + Svy->Scope = Hie_Lvl_CRS; + if (Svy->Scope == Hie_Lvl_CRS) { Gbl.Scope.Default = Svy->Scope; - Gbl.Scope.Allowed = 1 << Hie_CRS; + Gbl.Scope.Allowed = 1 << Hie_Lvl_CRS; ICanEdit = true; } } break; case Rol_DEG_ADM: // Degree admins only can edit degree surveys - if (Svy->Scope == Hie_UNK) // Scope not defined - Svy->Scope = Hie_DEG; - if (Svy->Scope == Hie_DEG) + if (Svy->Scope == Hie_Lvl_UNK) // Scope not defined + Svy->Scope = Hie_Lvl_DEG; + if (Svy->Scope == Hie_Lvl_DEG) { Gbl.Scope.Default = Svy->Scope; - Gbl.Scope.Allowed = 1 << Hie_DEG; + Gbl.Scope.Allowed = 1 << Hie_Lvl_DEG; ICanEdit = true; } break; case Rol_CTR_ADM: // Centre admins only can edit centre surveys - if (Svy->Scope == Hie_UNK) // Scope not defined - Svy->Scope = Hie_CTR; - if (Svy->Scope == Hie_CTR) + if (Svy->Scope == Hie_Lvl_UNK) // Scope not defined + Svy->Scope = Hie_Lvl_CTR; + if (Svy->Scope == Hie_Lvl_CTR) { Gbl.Scope.Default = Svy->Scope; - Gbl.Scope.Allowed = 1 << Hie_CTR; + Gbl.Scope.Allowed = 1 << Hie_Lvl_CTR; ICanEdit = true; } break; case Rol_INS_ADM: // Institution admins only can edit institution surveys - if (Svy->Scope == Hie_UNK) // Scope not defined - Svy->Scope = Hie_INS; - if (Svy->Scope == Hie_INS) + if (Svy->Scope == Hie_Lvl_UNK) // Scope not defined + Svy->Scope = Hie_Lvl_INS; + if (Svy->Scope == Hie_Lvl_INS) { Gbl.Scope.Default = Svy->Scope; - Gbl.Scope.Allowed = 1 << Hie_INS; + Gbl.Scope.Allowed = 1 << Hie_Lvl_INS; ICanEdit = true; } break; case Rol_SYS_ADM:// System admins can edit any survey - if (Svy->Scope == Hie_UNK) // Scope not defined - Svy->Scope = (Gbl.Hierarchy.Level < Hie_NUM_LEVELS && - Gbl.Hierarchy.Level != Hie_UNK) ? Gbl.Hierarchy.Level : - Hie_SYS; + if (Svy->Scope == Hie_Lvl_UNK) // Scope not defined + Svy->Scope = (Gbl.Hierarchy.Level < Hie_Lvl_NUM_LEVELS && + Gbl.Hierarchy.Level != Hie_Lvl_UNK) ? Gbl.Hierarchy.Level : + Hie_Lvl_SYS; Gbl.Scope.Default = Svy->Scope; - Gbl.Scope.Allowed = 1 << Hie_SYS | - 1 << Hie_CTY | - 1 << Hie_INS | - 1 << Hie_CTR | - 1 << Hie_DEG | - 1 << Hie_CRS; + Gbl.Scope.Allowed = 1 << Hie_Lvl_SYS | + 1 << Hie_Lvl_CTY | + 1 << Hie_Lvl_INS | + 1 << Hie_Lvl_CTR | + 1 << Hie_Lvl_DEG | + 1 << Hie_Lvl_CRS; ICanEdit = true; break; default: @@ -2208,7 +2208,7 @@ void Svy_ReceiveFormSurvey (void) ItsANewSurvey = ((NewSvy.SvyCod = Svy_GetParamSvyCod ()) == -1L); if (ItsANewSurvey) - NewSvy.Scope = Hie_UNK; + NewSvy.Scope = Hie_Lvl_UNK; else { /* Get data of the old (current) survey from database */ @@ -2224,44 +2224,44 @@ void Svy_ReceiveFormSurvey (void) Sco_GetScope ("ScopeSvy"); switch (Gbl.Scope.Current) { - case Hie_SYS: + case Hie_Lvl_SYS: if (Gbl.Usrs.Me.Role.Logged != Rol_SYS_ADM) Lay_ShowErrorAndExit ("Wrong survey scope."); - NewSvy.Scope = Hie_SYS; + NewSvy.Scope = Hie_Lvl_SYS; NewSvy.Cod = -1L; break; - case Hie_CTY: + case Hie_Lvl_CTY: if (Gbl.Usrs.Me.Role.Logged != Rol_SYS_ADM) Lay_ShowErrorAndExit ("Wrong survey scope."); - NewSvy.Scope = Hie_CTY; + NewSvy.Scope = Hie_Lvl_CTY; NewSvy.Cod = Gbl.Hierarchy.Cty.CtyCod; break; - case Hie_INS: + case Hie_Lvl_INS: if (Gbl.Usrs.Me.Role.Logged != Rol_SYS_ADM && Gbl.Usrs.Me.Role.Logged != Rol_INS_ADM) Lay_ShowErrorAndExit ("Wrong survey scope."); - NewSvy.Scope = Hie_INS; + NewSvy.Scope = Hie_Lvl_INS; NewSvy.Cod = Gbl.Hierarchy.Ins.InsCod; break; - case Hie_CTR: + case Hie_Lvl_CTR: if (Gbl.Usrs.Me.Role.Logged != Rol_SYS_ADM && Gbl.Usrs.Me.Role.Logged != Rol_CTR_ADM) Lay_ShowErrorAndExit ("Wrong survey scope."); - NewSvy.Scope = Hie_CTR; + NewSvy.Scope = Hie_Lvl_CTR; NewSvy.Cod = Gbl.Hierarchy.Ctr.CtrCod; break; - case Hie_DEG: + case Hie_Lvl_DEG: if (Gbl.Usrs.Me.Role.Logged != Rol_SYS_ADM && Gbl.Usrs.Me.Role.Logged != Rol_DEG_ADM) Lay_ShowErrorAndExit ("Wrong survey scope."); - NewSvy.Scope = Hie_DEG; + NewSvy.Scope = Hie_Lvl_DEG; NewSvy.Cod = Gbl.Hierarchy.Deg.DegCod; break; - case Hie_CRS: + case Hie_Lvl_CRS: if (Gbl.Usrs.Me.Role.Logged != Rol_SYS_ADM && Gbl.Usrs.Me.Role.Logged != Rol_TCH) Lay_ShowErrorAndExit ("Wrong survey scope."); - NewSvy.Scope = Hie_CRS; + NewSvy.Scope = Hie_Lvl_CRS; NewSvy.Cod = Gbl.Hierarchy.Crs.CrsCod; break; default: @@ -2323,7 +2323,7 @@ void Svy_ReceiveFormSurvey (void) Svy_RequestCreatOrEditSvy (); /***** Notify by email about the new survey *****/ - if (NewSvy.Scope == Hie_CRS) // Notify only the surveys for a course, not for a degree or global + if (NewSvy.Scope == Hie_Lvl_CRS) // Notify only the surveys for a course, not for a degree or global if ((NumUsrsToBeNotifiedByEMail = Ntf_StoreNotifyEventsToAllUsrs (Ntf_EVENT_SURVEY,NewSvy.SvyCod))) Svy_UpdateNumUsrsNotifiedByEMailAboutSurvey (NewSvy.SvyCod,NumUsrsToBeNotifiedByEMail); @@ -2546,7 +2546,7 @@ static void Svy_GetAndWriteNamesOfGrpsAssociatedToSvy (struct Svy_Survey *Svy) /************ (country, institution, centre, degree or course) *************/ /*****************************************************************************/ -void Svy_RemoveSurveys (Hie_Level_t Scope,long Cod) +void Svy_RemoveSurveys (Hie_Lvl_Level_t Scope,long Cod) { /***** Remove all the users in course surveys *****/ DB_QueryDELETE ("can not remove users" @@ -3887,7 +3887,7 @@ static unsigned Svy_GetNumUsrsWhoHaveAnsweredSvy (long SvyCod) // Returns the number of courses with surveys for courses // in this location (all the platform, current degree or current course) -unsigned Svy_GetNumCoursesWithCrsSurveys (Hie_Level_t Scope) +unsigned Svy_GetNumCoursesWithCrsSurveys (Hie_Lvl_Level_t Scope) { MYSQL_RES *mysql_res; MYSQL_ROW row; @@ -3896,15 +3896,15 @@ unsigned Svy_GetNumCoursesWithCrsSurveys (Hie_Level_t Scope) /***** Get number of courses with surveys from database *****/ switch (Scope) { - case Hie_SYS: + case Hie_Lvl_SYS: DB_QuerySELECT (&mysql_res,"can not get number of courses" " with surveys", "SELECT COUNT(DISTINCT Cod)" " FROM surveys" " WHERE Scope='%s'", - Sco_GetDBStrFromScope (Hie_CRS)); + Sco_GetDBStrFromScope (Hie_Lvl_CRS)); break; - case Hie_CTY: + case Hie_Lvl_CTY: DB_QuerySELECT (&mysql_res,"can not get number of courses" " with surveys", "SELECT COUNT(DISTINCT surveys.Cod)" @@ -3916,9 +3916,9 @@ unsigned Svy_GetNumCoursesWithCrsSurveys (Hie_Level_t Scope) " AND courses.CrsCod=surveys.Cod" " AND surveys.Scope='%s'", Gbl.Hierarchy.Ins.InsCod, - Sco_GetDBStrFromScope (Hie_CRS)); + Sco_GetDBStrFromScope (Hie_Lvl_CRS)); break; - case Hie_INS: + case Hie_Lvl_INS: DB_QuerySELECT (&mysql_res,"can not get number of courses" " with surveys", "SELECT COUNT(DISTINCT surveys.Cod)" @@ -3929,9 +3929,9 @@ unsigned Svy_GetNumCoursesWithCrsSurveys (Hie_Level_t Scope) " AND courses.CrsCod=surveys.Cod" " AND surveys.Scope='%s'", Gbl.Hierarchy.Ins.InsCod, - Sco_GetDBStrFromScope (Hie_CRS)); + Sco_GetDBStrFromScope (Hie_Lvl_CRS)); break; - case Hie_CTR: + case Hie_Lvl_CTR: DB_QuerySELECT (&mysql_res,"can not get number of courses" " with surveys", "SELECT COUNT(DISTINCT surveys.Cod)" @@ -3941,9 +3941,9 @@ unsigned Svy_GetNumCoursesWithCrsSurveys (Hie_Level_t Scope) " AND courses.CrsCod=surveys.Cod" " AND surveys.Scope='%s'", Gbl.Hierarchy.Ctr.CtrCod, - Sco_GetDBStrFromScope (Hie_CRS)); + Sco_GetDBStrFromScope (Hie_Lvl_CRS)); break; - case Hie_DEG: + case Hie_Lvl_DEG: DB_QuerySELECT (&mysql_res,"can not get number of courses" " with surveys", "SELECT COUNT(DISTINCT surveys.Cod)" @@ -3952,15 +3952,15 @@ unsigned Svy_GetNumCoursesWithCrsSurveys (Hie_Level_t Scope) " AND courses.CrsCod=surveys.Cod" " AND surveys.Scope='%s'", Gbl.Hierarchy.Deg.DegCod, - Sco_GetDBStrFromScope (Hie_CRS)); + Sco_GetDBStrFromScope (Hie_Lvl_CRS)); break; - case Hie_CRS: + case Hie_Lvl_CRS: DB_QuerySELECT (&mysql_res,"can not get number of courses" " with surveys", "SELECT COUNT(DISTINCT Cod)" " FROM surveys" " WHERE Scope='%s' AND Cod=%ld", - Sco_GetDBStrFromScope (Hie_CRS), + Sco_GetDBStrFromScope (Hie_Lvl_CRS), Gbl.Hierarchy.Crs.CrsCod); break; default: @@ -3985,7 +3985,7 @@ unsigned Svy_GetNumCoursesWithCrsSurveys (Hie_Level_t Scope) // Returns the number of surveys for courses // in this location (all the platform, current degree or current course) -unsigned Svy_GetNumCrsSurveys (Hie_Level_t Scope,unsigned *NumNotif) +unsigned Svy_GetNumCrsSurveys (Hie_Lvl_Level_t Scope,unsigned *NumNotif) { MYSQL_RES *mysql_res; MYSQL_ROW row; @@ -3994,14 +3994,14 @@ unsigned Svy_GetNumCrsSurveys (Hie_Level_t Scope,unsigned *NumNotif) /***** Get number of surveys from database *****/ switch (Scope) { - case Hie_SYS: + case Hie_Lvl_SYS: DB_QuerySELECT (&mysql_res,"can not get number of surveys", "SELECT COUNT(*),SUM(NumNotif)" " FROM surveys" " WHERE Scope='%s'", - Sco_GetDBStrFromScope (Hie_CRS)); + Sco_GetDBStrFromScope (Hie_Lvl_CRS)); break; - case Hie_CTY: + case Hie_Lvl_CTY: DB_QuerySELECT (&mysql_res,"can not get number of surveys", "SELECT COUNT(*),SUM(surveys.NumNotif)" " FROM institutions,centres,degrees,courses,surveys" @@ -4012,9 +4012,9 @@ unsigned Svy_GetNumCrsSurveys (Hie_Level_t Scope,unsigned *NumNotif) " AND courses.CrsCod=surveys.Cod" " AND surveys.Scope='%s'", Gbl.Hierarchy.Cty.CtyCod, - Sco_GetDBStrFromScope (Hie_CRS)); + Sco_GetDBStrFromScope (Hie_Lvl_CRS)); break; - case Hie_INS: + case Hie_Lvl_INS: DB_QuerySELECT (&mysql_res,"can not get number of surveys", "SELECT COUNT(*),SUM(surveys.NumNotif)" " FROM centres,degrees,courses,surveys" @@ -4024,9 +4024,9 @@ unsigned Svy_GetNumCrsSurveys (Hie_Level_t Scope,unsigned *NumNotif) " AND courses.CrsCod=surveys.Cod" " AND surveys.Scope='%s'", Gbl.Hierarchy.Ins.InsCod, - Sco_GetDBStrFromScope (Hie_CRS)); + Sco_GetDBStrFromScope (Hie_Lvl_CRS)); break; - case Hie_CTR: + case Hie_Lvl_CTR: DB_QuerySELECT (&mysql_res,"can not get number of surveys", "SELECT COUNT(*),SUM(surveys.NumNotif)" " FROM degrees,courses,surveys" @@ -4035,9 +4035,9 @@ unsigned Svy_GetNumCrsSurveys (Hie_Level_t Scope,unsigned *NumNotif) " AND courses.CrsCod=surveys.Cod" " AND surveys.Scope='%s'", Gbl.Hierarchy.Ctr.CtrCod, - Sco_GetDBStrFromScope (Hie_CRS)); + Sco_GetDBStrFromScope (Hie_Lvl_CRS)); break; - case Hie_DEG: + case Hie_Lvl_DEG: DB_QuerySELECT (&mysql_res,"can not get number of surveys", "SELECT COUNT(*),SUM(surveys.NumNotif)" " FROM courses,surveys" @@ -4045,15 +4045,15 @@ unsigned Svy_GetNumCrsSurveys (Hie_Level_t Scope,unsigned *NumNotif) " AND courses.CrsCod=surveys.Cod" " AND surveys.Scope='%s'", Gbl.Hierarchy.Deg.DegCod, - Sco_GetDBStrFromScope (Hie_CRS)); + Sco_GetDBStrFromScope (Hie_Lvl_CRS)); break; - case Hie_CRS: + case Hie_Lvl_CRS: DB_QuerySELECT (&mysql_res,"can not get number of surveys", "SELECT COUNT(*),SUM(NumNotif)" " FROM surveys" " WHERE surveys.Scope='%s'" " AND CrsCod=%ld", - Sco_GetDBStrFromScope (Hie_CRS), + Sco_GetDBStrFromScope (Hie_Lvl_CRS), Gbl.Hierarchy.Crs.CrsCod); break; default: @@ -4085,7 +4085,7 @@ unsigned Svy_GetNumCrsSurveys (Hie_Level_t Scope,unsigned *NumNotif) /************ Get average number of questions per course survey **************/ /*****************************************************************************/ -double Svy_GetNumQstsPerCrsSurvey (Hie_Level_t Scope) +double Svy_GetNumQstsPerCrsSurvey (Hie_Lvl_Level_t Scope) { MYSQL_RES *mysql_res; MYSQL_ROW row; @@ -4094,7 +4094,7 @@ double Svy_GetNumQstsPerCrsSurvey (Hie_Level_t Scope) /***** Get number of questions per survey from database *****/ switch (Scope) { - case Hie_SYS: + case Hie_Lvl_SYS: DB_QuerySELECT (&mysql_res,"can not get number of questions" " per survey", "SELECT AVG(NumQsts) FROM" @@ -4103,9 +4103,9 @@ double Svy_GetNumQstsPerCrsSurvey (Hie_Level_t Scope) " WHERE surveys.Scope='%s'" " AND surveys.SvyCod=svy_questions.SvyCod" " GROUP BY svy_questions.SvyCod) AS NumQstsTable", - Sco_GetDBStrFromScope (Hie_CRS)); + Sco_GetDBStrFromScope (Hie_Lvl_CRS)); break; - case Hie_CTY: + case Hie_Lvl_CTY: DB_QuerySELECT (&mysql_res,"can not get number of questions" " per survey", "SELECT AVG(NumQsts) FROM" @@ -4120,9 +4120,9 @@ double Svy_GetNumQstsPerCrsSurvey (Hie_Level_t Scope) " AND surveys.SvyCod=svy_questions.SvyCod" " GROUP BY svy_questions.SvyCod) AS NumQstsTable", Gbl.Hierarchy.Cty.CtyCod, - Sco_GetDBStrFromScope (Hie_CRS)); + Sco_GetDBStrFromScope (Hie_Lvl_CRS)); break; - case Hie_INS: + case Hie_Lvl_INS: DB_QuerySELECT (&mysql_res,"can not get number of questions" " per survey", "SELECT AVG(NumQsts) FROM" @@ -4136,9 +4136,9 @@ double Svy_GetNumQstsPerCrsSurvey (Hie_Level_t Scope) " AND surveys.SvyCod=svy_questions.SvyCod" " GROUP BY svy_questions.SvyCod) AS NumQstsTable", Gbl.Hierarchy.Ins.InsCod, - Sco_GetDBStrFromScope (Hie_CRS)); + Sco_GetDBStrFromScope (Hie_Lvl_CRS)); break; - case Hie_CTR: + case Hie_Lvl_CTR: DB_QuerySELECT (&mysql_res,"can not get number of questions" " per survey", "SELECT AVG(NumQsts) FROM" @@ -4151,9 +4151,9 @@ double Svy_GetNumQstsPerCrsSurvey (Hie_Level_t Scope) " AND surveys.SvyCod=svy_questions.SvyCod" " GROUP BY svy_questions.SvyCod) AS NumQstsTable", Gbl.Hierarchy.Ctr.CtrCod, - Sco_GetDBStrFromScope (Hie_CRS)); + Sco_GetDBStrFromScope (Hie_Lvl_CRS)); break; - case Hie_DEG: + case Hie_Lvl_DEG: DB_QuerySELECT (&mysql_res,"can not get number of questions" " per survey", "SELECT AVG(NumQsts) FROM" @@ -4165,9 +4165,9 @@ double Svy_GetNumQstsPerCrsSurvey (Hie_Level_t Scope) " AND surveys.SvyCod=svy_questions.SvyCod" " GROUP BY svy_questions.SvyCod) AS NumQstsTable", Gbl.Hierarchy.Deg.DegCod, - Sco_GetDBStrFromScope (Hie_CRS)); + Sco_GetDBStrFromScope (Hie_Lvl_CRS)); break; - case Hie_CRS: + case Hie_Lvl_CRS: DB_QuerySELECT (&mysql_res,"can not get number of questions" " per survey", "SELECT AVG(NumQsts) FROM" @@ -4176,7 +4176,7 @@ double Svy_GetNumQstsPerCrsSurvey (Hie_Level_t Scope) " WHERE surveys.Scope='%s' AND surveys.Cod=%ld" " AND surveys.SvyCod=svy_questions.SvyCod" " GROUP BY svy_questions.SvyCod) AS NumQstsTable", - Sco_GetDBStrFromScope (Hie_CRS),Gbl.Hierarchy.Crs.CrsCod); + Sco_GetDBStrFromScope (Hie_Lvl_CRS),Gbl.Hierarchy.Crs.CrsCod); break; default: Lay_WrongScopeExit (); diff --git a/swad_survey.h b/swad_survey.h index 711cf460..3cfc47f0 100644 --- a/swad_survey.h +++ b/swad_survey.h @@ -58,7 +58,7 @@ struct Svy_Surveys struct Svy_Survey { long SvyCod; - Hie_Level_t Scope; + Hie_Lvl_Level_t Scope; long Cod; // Country, institution, centre, degree or course code unsigned Roles; // Example: if survey can be made by students, Roles == (1 << Rol_STD) long UsrCod; @@ -110,7 +110,7 @@ void Svy_UnhideSurvey (void); void Svy_ReceiveFormSurvey (void); void Svy_RemoveGroup (long GrpCod); void Svy_RemoveGroupsOfType (long GrpTypCod); -void Svy_RemoveSurveys (Hie_Level_t Scope,long Cod); +void Svy_RemoveSurveys (Hie_Lvl_Level_t Scope,long Cod); void Svy_RequestEditQuestion (void); void Svy_ReceiveQst (void); @@ -120,8 +120,8 @@ void Svy_RemoveQst (void); void Svy_ReceiveSurveyAnswers (void); -unsigned Svy_GetNumCoursesWithCrsSurveys (Hie_Level_t Scope); -unsigned Svy_GetNumCrsSurveys (Hie_Level_t Scope,unsigned *NumNotif); -double Svy_GetNumQstsPerCrsSurvey (Hie_Level_t Scope); +unsigned Svy_GetNumCoursesWithCrsSurveys (Hie_Lvl_Level_t Scope); +unsigned Svy_GetNumCrsSurveys (Hie_Lvl_Level_t Scope,unsigned *NumNotif); +double Svy_GetNumQstsPerCrsSurvey (Hie_Lvl_Level_t Scope); #endif diff --git a/swad_system_config.c b/swad_system_config.c index e97284f1..603419ab 100644 --- a/swad_system_config.c +++ b/swad_system_config.c @@ -39,7 +39,7 @@ #include "swad_figure_cache.h" #include "swad_form.h" #include "swad_help.h" -#include "swad_hierarchy.h" +#include "swad_hierarchy_level.h" #include "swad_hierarchy_config.h" #include "swad_HTML.h" #include "swad_role.h" @@ -155,10 +155,10 @@ static void SysCfg_Configuration (bool PrintView) SysCfg_NumCrss (); /***** Number of users in courses of this country *****/ - HieCfg_NumUsrsInCrss (Hie_SYS,-1L,Rol_TCH); - HieCfg_NumUsrsInCrss (Hie_SYS,-1L,Rol_NET); - HieCfg_NumUsrsInCrss (Hie_SYS,-1L,Rol_STD); - HieCfg_NumUsrsInCrss (Hie_SYS,-1L,Rol_UNK); + HieCfg_NumUsrsInCrss (Hie_Lvl_SYS,-1L,Rol_TCH); + HieCfg_NumUsrsInCrss (Hie_Lvl_SYS,-1L,Rol_NET); + HieCfg_NumUsrsInCrss (Hie_Lvl_SYS,-1L,Rol_STD); + HieCfg_NumUsrsInCrss (Hie_Lvl_SYS,-1L,Rol_UNK); } /***** End table *****/ diff --git a/swad_tab.c b/swad_tab.c index d23fd9ce..0ee5ba86 100644 --- a/swad_tab.c +++ b/swad_tab.c @@ -165,9 +165,9 @@ static bool Tab_CheckIfICanViewTab (Tab_Tab_t Tab) return (Gbl.Hierarchy.Deg.DegCod > 0 && // Degree selected Gbl.Hierarchy.Crs.CrsCod <= 0); // No course selected case TabCrs: - return (Gbl.Hierarchy.Level == Hie_CRS); // Course selected + return (Gbl.Hierarchy.Level == Hie_Lvl_CRS); // Course selected case TabAss: - return (Gbl.Hierarchy.Level == Hie_CRS || // Course selected + return (Gbl.Hierarchy.Level == Hie_Lvl_CRS || // Course selected Gbl.Usrs.Me.Role.Logged >= Rol_STD); // I belong to course or I am an admin case TabFil: return (Gbl.Hierarchy.Ins.InsCod > 0 || // Institution selected diff --git a/swad_test.c b/swad_test.c index fbc95a76..0e46702e 100644 --- a/swad_test.c +++ b/swad_test.c @@ -225,9 +225,9 @@ static void Tst_RemoveMediaFromAllAnsOfQst (long CrsCod,long QstCod); static void Tst_RemoveAllMedFilesFromStemOfAllQstsInCrs (long CrsCod); static void Tst_RemoveAllMedFilesFromAnsOfAllQstsInCrs (long CrsCod); -static unsigned Tst_GetNumTstQuestions (Hie_Level_t Scope,Tst_AnswerType_t AnsType,struct Tst_Stats *Stats); -static unsigned Tst_GetNumCoursesWithTstQuestions (Hie_Level_t Scope,Tst_AnswerType_t AnsType); -static unsigned Tst_GetNumCoursesWithPluggableTstQuestions (Hie_Level_t Scope,Tst_AnswerType_t AnsType); +static unsigned Tst_GetNumTstQuestions (Hie_Lvl_Level_t Scope,Tst_AnswerType_t AnsType,struct Tst_Stats *Stats); +static unsigned Tst_GetNumCoursesWithTstQuestions (Hie_Lvl_Level_t Scope,Tst_AnswerType_t AnsType); +static unsigned Tst_GetNumCoursesWithPluggableTstQuestions (Hie_Lvl_Level_t Scope,Tst_AnswerType_t AnsType); /*****************************************************************************/ /********************* Request a self-assessment test ************************/ @@ -5389,7 +5389,7 @@ void Tst_GetTestStats (Tst_AnswerType_t AnsType,struct Tst_Stats *Stats) // Returns the number of test questions // in this location (all the platform, current degree or current course) -static unsigned Tst_GetNumTstQuestions (Hie_Level_t Scope,Tst_AnswerType_t AnsType,struct Tst_Stats *Stats) +static unsigned Tst_GetNumTstQuestions (Hie_Lvl_Level_t Scope,Tst_AnswerType_t AnsType,struct Tst_Stats *Stats) { MYSQL_RES *mysql_res; MYSQL_ROW row; @@ -5397,7 +5397,7 @@ static unsigned Tst_GetNumTstQuestions (Hie_Level_t Scope,Tst_AnswerType_t AnsTy /***** Get number of test questions from database *****/ switch (Scope) { - case Hie_SYS: + case Hie_Lvl_SYS: if (AnsType == Tst_ANS_UNKNOWN) // Any type DB_QuerySELECT (&mysql_res,"can not get number of test questions", "SELECT COUNT(*),SUM(NumHits),SUM(Score)" @@ -5409,7 +5409,7 @@ static unsigned Tst_GetNumTstQuestions (Hie_Level_t Scope,Tst_AnswerType_t AnsTy " WHERE AnsType='%s'", Tst_StrAnswerTypesDB[AnsType]); break; - case Hie_CTY: + case Hie_Lvl_CTY: if (AnsType == Tst_ANS_UNKNOWN) // Any type DB_QuerySELECT (&mysql_res,"can not get number of test questions", "SELECT COUNT(*),SUM(NumHits),SUM(Score)" @@ -5433,7 +5433,7 @@ static unsigned Tst_GetNumTstQuestions (Hie_Level_t Scope,Tst_AnswerType_t AnsTy Gbl.Hierarchy.Cty.CtyCod, Tst_StrAnswerTypesDB[AnsType]); break; - case Hie_INS: + case Hie_Lvl_INS: if (AnsType == Tst_ANS_UNKNOWN) // Any type DB_QuerySELECT (&mysql_res,"can not get number of test questions", "SELECT COUNT(*),SUM(NumHits),SUM(Score)" @@ -5455,7 +5455,7 @@ static unsigned Tst_GetNumTstQuestions (Hie_Level_t Scope,Tst_AnswerType_t AnsTy Gbl.Hierarchy.Ins.InsCod, Tst_StrAnswerTypesDB[AnsType]); break; - case Hie_CTR: + case Hie_Lvl_CTR: if (AnsType == Tst_ANS_UNKNOWN) // Any type DB_QuerySELECT (&mysql_res,"can not get number of test questions", "SELECT COUNT(*),SUM(NumHits),SUM(Score)" @@ -5475,7 +5475,7 @@ static unsigned Tst_GetNumTstQuestions (Hie_Level_t Scope,Tst_AnswerType_t AnsTy Gbl.Hierarchy.Ctr.CtrCod, Tst_StrAnswerTypesDB[AnsType]); break; - case Hie_DEG: + case Hie_Lvl_DEG: if (AnsType == Tst_ANS_UNKNOWN) // Any type DB_QuerySELECT (&mysql_res,"can not get number of test questions", "SELECT COUNT(*),SUM(NumHits),SUM(Score)" @@ -5493,7 +5493,7 @@ static unsigned Tst_GetNumTstQuestions (Hie_Level_t Scope,Tst_AnswerType_t AnsTy Gbl.Hierarchy.Deg.DegCod, Tst_StrAnswerTypesDB[AnsType]); break; - case Hie_CRS: + case Hie_Lvl_CRS: if (AnsType == Tst_ANS_UNKNOWN) // Any type DB_QuerySELECT (&mysql_res,"can not get number of test questions", "SELECT COUNT(*),SUM(NumHits),SUM(Score)" @@ -5546,7 +5546,7 @@ static unsigned Tst_GetNumTstQuestions (Hie_Level_t Scope,Tst_AnswerType_t AnsTy // Returns the number of courses with test questions // in this location (all the platform, current degree or current course) -static unsigned Tst_GetNumCoursesWithTstQuestions (Hie_Level_t Scope,Tst_AnswerType_t AnsType) +static unsigned Tst_GetNumCoursesWithTstQuestions (Hie_Lvl_Level_t Scope,Tst_AnswerType_t AnsType) { MYSQL_RES *mysql_res; MYSQL_ROW row; @@ -5555,7 +5555,7 @@ static unsigned Tst_GetNumCoursesWithTstQuestions (Hie_Level_t Scope,Tst_AnswerT /***** Get number of courses with test questions from database *****/ switch (Scope) { - case Hie_SYS: + case Hie_Lvl_SYS: if (AnsType == Tst_ANS_UNKNOWN) // Any type DB_QuerySELECT (&mysql_res,"can not get number of courses" " with test questions", @@ -5569,7 +5569,7 @@ static unsigned Tst_GetNumCoursesWithTstQuestions (Hie_Level_t Scope,Tst_AnswerT " WHERE AnsType='%s'", Tst_StrAnswerTypesDB[AnsType]); break; - case Hie_CTY: + case Hie_Lvl_CTY: if (AnsType == Tst_ANS_UNKNOWN) // Any type DB_QuerySELECT (&mysql_res,"can not get number of courses" " with test questions", @@ -5595,7 +5595,7 @@ static unsigned Tst_GetNumCoursesWithTstQuestions (Hie_Level_t Scope,Tst_AnswerT Gbl.Hierarchy.Cty.CtyCod, Tst_StrAnswerTypesDB[AnsType]); break; - case Hie_INS: + case Hie_Lvl_INS: if (AnsType == Tst_ANS_UNKNOWN) // Any type DB_QuerySELECT (&mysql_res,"can not get number of courses" " with test questions", @@ -5619,7 +5619,7 @@ static unsigned Tst_GetNumCoursesWithTstQuestions (Hie_Level_t Scope,Tst_AnswerT Gbl.Hierarchy.Ins.InsCod, Tst_StrAnswerTypesDB[AnsType]); break; - case Hie_CTR: + case Hie_Lvl_CTR: if (AnsType == Tst_ANS_UNKNOWN) // Any type DB_QuerySELECT (&mysql_res,"can not get number of courses" " with test questions", @@ -5641,7 +5641,7 @@ static unsigned Tst_GetNumCoursesWithTstQuestions (Hie_Level_t Scope,Tst_AnswerT Gbl.Hierarchy.Ctr.CtrCod, Tst_StrAnswerTypesDB[AnsType]); break; - case Hie_DEG: + case Hie_Lvl_DEG: if (AnsType == Tst_ANS_UNKNOWN) // Any type DB_QuerySELECT (&mysql_res,"can not get number of courses" " with test questions", @@ -5661,7 +5661,7 @@ static unsigned Tst_GetNumCoursesWithTstQuestions (Hie_Level_t Scope,Tst_AnswerT Gbl.Hierarchy.Deg.DegCod, Tst_StrAnswerTypesDB[AnsType]); break; - case Hie_CRS: + case Hie_Lvl_CRS: if (AnsType == Tst_ANS_UNKNOWN) // Any type DB_QuerySELECT (&mysql_res,"can not get number of courses" " with test questions", @@ -5701,7 +5701,7 @@ static unsigned Tst_GetNumCoursesWithTstQuestions (Hie_Level_t Scope,Tst_AnswerT // Returns the number of courses with pluggable test questions // in this location (all the platform, current degree or current course) -static unsigned Tst_GetNumCoursesWithPluggableTstQuestions (Hie_Level_t Scope,Tst_AnswerType_t AnsType) +static unsigned Tst_GetNumCoursesWithPluggableTstQuestions (Hie_Lvl_Level_t Scope,Tst_AnswerType_t AnsType) { extern const char *TstCfg_PluggableDB[TstCfg_NUM_OPTIONS_PLUGGABLE]; MYSQL_RES *mysql_res; @@ -5711,7 +5711,7 @@ static unsigned Tst_GetNumCoursesWithPluggableTstQuestions (Hie_Level_t Scope,Ts /***** Get number of courses with test questions from database *****/ switch (Scope) { - case Hie_SYS: + case Hie_Lvl_SYS: if (AnsType == Tst_ANS_UNKNOWN) // Any type DB_QuerySELECT (&mysql_res,"can not get number of courses" " with pluggable test questions", @@ -5731,7 +5731,7 @@ static unsigned Tst_GetNumCoursesWithPluggableTstQuestions (Hie_Level_t Scope,Ts Tst_StrAnswerTypesDB[AnsType], TstCfg_PluggableDB[TstCfg_PLUGGABLE_YES]); break; - case Hie_CTY: + case Hie_Lvl_CTY: if (AnsType == Tst_ANS_UNKNOWN) // Any type DB_QuerySELECT (&mysql_res,"can not get number of courses" " with pluggable test questions", @@ -5763,7 +5763,7 @@ static unsigned Tst_GetNumCoursesWithPluggableTstQuestions (Hie_Level_t Scope,Ts Tst_StrAnswerTypesDB[AnsType], TstCfg_PluggableDB[TstCfg_PLUGGABLE_YES]); break; - case Hie_INS: + case Hie_Lvl_INS: if (AnsType == Tst_ANS_UNKNOWN) // Any type DB_QuerySELECT (&mysql_res,"can not get number of courses" " with pluggable test questions", @@ -5793,7 +5793,7 @@ static unsigned Tst_GetNumCoursesWithPluggableTstQuestions (Hie_Level_t Scope,Ts Tst_StrAnswerTypesDB[AnsType], TstCfg_PluggableDB[TstCfg_PLUGGABLE_YES]); break; - case Hie_CTR: + case Hie_Lvl_CTR: if (AnsType == Tst_ANS_UNKNOWN) // Any type DB_QuerySELECT (&mysql_res,"can not get number of courses" " with pluggable test questions", @@ -5821,7 +5821,7 @@ static unsigned Tst_GetNumCoursesWithPluggableTstQuestions (Hie_Level_t Scope,Ts Tst_StrAnswerTypesDB[AnsType], TstCfg_PluggableDB[TstCfg_PLUGGABLE_YES]); break; - case Hie_DEG: + case Hie_Lvl_DEG: if (AnsType == Tst_ANS_UNKNOWN) // Any type DB_QuerySELECT (&mysql_res,"can not get number of courses" " with pluggable test questions", @@ -5847,7 +5847,7 @@ static unsigned Tst_GetNumCoursesWithPluggableTstQuestions (Hie_Level_t Scope,Ts Tst_StrAnswerTypesDB[AnsType], TstCfg_PluggableDB[TstCfg_PLUGGABLE_YES]); break; - case Hie_CRS: + case Hie_Lvl_CRS: if (AnsType == Tst_ANS_UNKNOWN) // Any type DB_QuerySELECT (&mysql_res,"can not get number of courses" " with pluggable test questions", diff --git a/swad_timeline_note.c b/swad_timeline_note.c index 489e1011..6c61a644 100644 --- a/swad_timeline_note.c +++ b/swad_timeline_note.c @@ -36,6 +36,7 @@ #include "swad_exam_announcement.h" #include "swad_forum.h" #include "swad_global.h" +#include "swad_hierarchy.h" #include "swad_notice.h" #include "swad_photo.h" #include "swad_profile.h" @@ -69,17 +70,11 @@ extern struct Globals Gbl; static void TL_Not_WriteTopMessage (TL_TopMessage_t TopMessage,long PublisherCod); static void TL_Not_GetLocationInHierarchy (const struct TL_Not_Note *Not, - struct Ins_Instit *Ins, - struct Ctr_Centre *Ctr, - struct Deg_Degree *Deg, - struct Crs_Course *Crs, + struct Hie_Hierarchy *Hie, struct For_Forum *Forum, char ForumName[For_MAX_BYTES_FORUM_NAME + 1]); static void TL_Not_WriteLocationInHierarchy (const struct TL_Not_Note *Not, - const struct Ins_Instit *Ins, - const struct Ctr_Centre *Ctr, - const struct Deg_Degree *Deg, - const struct Crs_Course *Crs, + const struct Hie_Hierarchy *Hie, const char ForumName[For_MAX_BYTES_FORUM_NAME + 1]); static void TL_Not_PutFormGoToAction (const struct TL_Not_Note *Not, @@ -199,10 +194,7 @@ void TL_Not_WriteNote (struct TL_Timeline *Timeline, { struct UsrData AuthorDat; bool IAmTheAuthor; - struct Ins_Instit Ins; - struct Ctr_Centre Ctr; - struct Deg_Degree Deg; - struct Crs_Course Crs; + struct Hie_Hierarchy Hie; bool ShowPhoto = false; char PhotoURL[PATH_MAX + 1]; struct For_Forums Forums; @@ -239,10 +231,11 @@ void TL_Not_WriteNote (struct TL_Timeline *Timeline, else { /***** Initialize location in hierarchy *****/ - Ins.InsCod = -1L; - Ctr.CtrCod = -1L; - Deg.DegCod = -1L; - Crs.CrsCod = -1L; + Hie.Cty.CtyCod = -1L; + Hie.Ins.InsCod = -1L; + Hie.Ctr.CtrCod = -1L; + Hie.Deg.DegCod = -1L; + Hie.Crs.CrsCod = -1L; /***** Write sharer/commenter if distinct to author *****/ if (TopMessage != TL_TOP_MESSAGE_NONE) @@ -285,16 +278,14 @@ void TL_Not_WriteNote (struct TL_Timeline *Timeline, /* Get location in hierarchy */ if (!Not->Unavailable) - TL_Not_GetLocationInHierarchy (Not,&Ins,&Ctr,&Deg,&Crs, - &Forums.Forum,ForumName); + TL_Not_GetLocationInHierarchy (Not,&Hie,&Forums.Forum,ForumName); /* Write note type */ TL_Not_PutFormGoToAction (Not,&Forums); /* Write location in hierarchy */ if (!Not->Unavailable) - TL_Not_WriteLocationInHierarchy (Not,&Ins,&Ctr,&Deg,&Crs, - ForumName); + TL_Not_WriteLocationInHierarchy (Not,&Hie,ForumName); /* Write note summary */ TL_Not_GetNoteSummary (Not,SummaryStr); @@ -443,10 +434,7 @@ void TL_Not_WriteAuthorNote (const struct UsrData *UsrDat) /*****************************************************************************/ static void TL_Not_GetLocationInHierarchy (const struct TL_Not_Note *Not, - struct Ins_Instit *Ins, - struct Ctr_Centre *Ctr, - struct Deg_Degree *Deg, - struct Crs_Course *Crs, + struct Hie_Hierarchy *Hie, struct For_Forum *Forum, char ForumName[For_MAX_BYTES_FORUM_NAME + 1]) { @@ -455,28 +443,28 @@ static void TL_Not_GetLocationInHierarchy (const struct TL_Not_Note *Not, case TL_NOTE_INS_DOC_PUB_FILE: case TL_NOTE_INS_SHA_PUB_FILE: /* Get institution data */ - Ins->InsCod = Not->HieCod; - Ins_GetDataOfInstitutionByCod (Ins); + Hie->Ins.InsCod = Not->HieCod; + Ins_GetDataOfInstitutionByCod (&Hie->Ins); break; case TL_NOTE_CTR_DOC_PUB_FILE: case TL_NOTE_CTR_SHA_PUB_FILE: /* Get centre data */ - Ctr->CtrCod = Not->HieCod; - Ctr_GetDataOfCentreByCod (Ctr); + Hie->Ctr.CtrCod = Not->HieCod; + Ctr_GetDataOfCentreByCod (&Hie->Ctr); break; case TL_NOTE_DEG_DOC_PUB_FILE: case TL_NOTE_DEG_SHA_PUB_FILE: /* Get degree data */ - Deg->DegCod = Not->HieCod; - Deg_GetDataOfDegreeByCod (Deg); + Hie->Deg.DegCod = Not->HieCod; + Deg_GetDataOfDegreeByCod (&Hie->Deg); break; case TL_NOTE_CRS_DOC_PUB_FILE: case TL_NOTE_CRS_SHA_PUB_FILE: case TL_NOTE_EXAM_ANNOUNCEMENT: case TL_NOTE_NOTICE: /* Get course data */ - Crs->CrsCod = Not->HieCod; - Crs_GetDataOfCourseByCod (Crs); + Hie->Crs.CrsCod = Not->HieCod; + Crs_GetDataOfCourseByCod (&Hie->Crs); break; case TL_NOTE_FORUM_POST: /* Get forum type of the post */ @@ -493,10 +481,7 @@ static void TL_Not_GetLocationInHierarchy (const struct TL_Not_Note *Not, /*****************************************************************************/ static void TL_Not_WriteLocationInHierarchy (const struct TL_Not_Note *Not, - const struct Ins_Instit *Ins, - const struct Ctr_Centre *Ctr, - const struct Deg_Degree *Deg, - const struct Crs_Course *Crs, + const struct Hie_Hierarchy *Hie, const char ForumName[For_MAX_BYTES_FORUM_NAME + 1]) { extern const char *Txt_Forum; @@ -511,21 +496,21 @@ static void TL_Not_WriteLocationInHierarchy (const struct TL_Not_Note *Not, case TL_NOTE_INS_SHA_PUB_FILE: /* Write location (institution) in hierarchy */ HTM_DIV_Begin ("class=\"TL_LOC\""); - HTM_TxtF ("%s: %s",Txt_Institution,Ins->ShrtName); + HTM_TxtF ("%s: %s",Txt_Institution,Hie->Ins.ShrtName); HTM_DIV_End (); break; case TL_NOTE_CTR_DOC_PUB_FILE: case TL_NOTE_CTR_SHA_PUB_FILE: /* Write location (centre) in hierarchy */ HTM_DIV_Begin ("class=\"TL_LOC\""); - HTM_TxtF ("%s: %s",Txt_Centre,Ctr->ShrtName); + HTM_TxtF ("%s: %s",Txt_Centre,Hie->Ctr.ShrtName); HTM_DIV_End (); break; case TL_NOTE_DEG_DOC_PUB_FILE: case TL_NOTE_DEG_SHA_PUB_FILE: /* Write location (degree) in hierarchy */ HTM_DIV_Begin ("class=\"TL_LOC\""); - HTM_TxtF ("%s: %s",Txt_Degree,Deg->ShrtName); + HTM_TxtF ("%s: %s",Txt_Degree,Hie->Deg.ShrtName); HTM_DIV_End (); break; case TL_NOTE_CRS_DOC_PUB_FILE: @@ -534,7 +519,7 @@ static void TL_Not_WriteLocationInHierarchy (const struct TL_Not_Note *Not, case TL_NOTE_NOTICE: /* Write location (course) in hierarchy */ HTM_DIV_Begin ("class=\"TL_LOC\""); - HTM_TxtF ("%s: %s",Txt_Course,Crs->ShrtName); + HTM_TxtF ("%s: %s",Txt_Course,Hie->Crs.ShrtName); HTM_DIV_End (); break; case TL_NOTE_FORUM_POST: diff --git a/swad_user.c b/swad_user.c index 28180cae..266d0deb 100644 --- a/swad_user.c +++ b/swad_user.c @@ -190,9 +190,9 @@ static void Usr_WriteUsrData (const char *BgColor, static void Usr_BuildQueryToGetUsrsLstCrs (char **Query,Rol_Role_t Role); -static void Usr_GetAdmsLst (Hie_Level_t Scope); -static void Usr_GetGstsLst (Hie_Level_t Scope); -static void Usr_GetListUsrsFromQuery (char *Query,Rol_Role_t Role,Hie_Level_t Scope); +static void Usr_GetAdmsLst (Hie_Lvl_Level_t Scope); +static void Usr_GetGstsLst (Hie_Lvl_Level_t Scope); +static void Usr_GetListUsrsFromQuery (char *Query,Rol_Role_t Role,Hie_Lvl_Level_t Scope); static void Usr_AllocateUsrsList (Rol_Role_t Role); static void Usr_PutButtonToConfirmIWantToSeeBigList (unsigned NumUsrs, @@ -271,8 +271,8 @@ static void Usr_DrawClassPhoto (Usr_ClassPhotoType_t ClassPhotoType, bool PutCheckBoxToSelectUsr); static FigCch_FigureCached_t Usr_GetFigureNumUsrsInCrss (unsigned Roles); -static double Usr_GetNumCrssPerUsr (Hie_Level_t Scope,long Cod,Rol_Role_t Role); -static double Usr_GetNumUsrsPerCrs (Hie_Level_t Scope,long Cod,Rol_Role_t Role); +static double Usr_GetNumCrssPerUsr (Hie_Lvl_Level_t Scope,long Cod,Rol_Role_t Role); +static double Usr_GetNumUsrsPerCrs (Hie_Lvl_Level_t Scope,long Cod,Rol_Role_t Role); /*****************************************************************************/ /**** Show alert about number of clicks remaining before sending my photo ****/ @@ -377,7 +377,7 @@ void Usr_ResetUsrDataExceptUsrCodAndIDs (struct UsrData *UsrDat) void Usr_ResetMyLastData (void) { Gbl.Usrs.Me.UsrLast.WhatToSearch = Sch_WHAT_TO_SEARCH_DEFAULT; - Gbl.Usrs.Me.UsrLast.LastHie.Scope = Hie_UNK; + Gbl.Usrs.Me.UsrLast.LastHie.Scope = Hie_Lvl_UNK; Gbl.Usrs.Me.UsrLast.LastHie.Cod = -1L; Gbl.Usrs.Me.UsrLast.LastAct = ActUnk; Gbl.Usrs.Me.UsrLast.LastRole = Rol_UNK; @@ -792,23 +792,23 @@ static void Usr_GetMyLastData (void) Gbl.Usrs.Me.UsrLast.LastHie.Scope = Sco_GetScopeFromDBStr (row[1]); switch (Gbl.Usrs.Me.UsrLast.LastHie.Scope) { - case Hie_SYS: // System + case Hie_Lvl_SYS: // System Gbl.Usrs.Me.UsrLast.LastHie.Cod = -1L; break; - case Hie_CTY: // Country - case Hie_INS: // Institution - case Hie_CTR: // Centre - case Hie_DEG: // Degree - case Hie_CRS: // Course + case Hie_Lvl_CTY: // Country + case Hie_Lvl_INS: // Institution + case Hie_Lvl_CTR: // Centre + case Hie_Lvl_DEG: // Degree + case Hie_Lvl_CRS: // Course Gbl.Usrs.Me.UsrLast.LastHie.Cod = Str_ConvertStrCodToLongCod (row[2]); if (Gbl.Usrs.Me.UsrLast.LastHie.Cod <= 0) { - Gbl.Usrs.Me.UsrLast.LastHie.Scope = Hie_UNK; + Gbl.Usrs.Me.UsrLast.LastHie.Scope = Hie_Lvl_UNK; Gbl.Usrs.Me.UsrLast.LastHie.Cod = -1L; } break; default: - Gbl.Usrs.Me.UsrLast.LastHie.Scope = Hie_UNK; + Gbl.Usrs.Me.UsrLast.LastHie.Scope = Hie_Lvl_UNK; Gbl.Usrs.Me.UsrLast.LastHie.Cod = -1L; break; } @@ -917,7 +917,7 @@ void Usr_FlushCachesUsr (void) /***** Check if a user is an administrator of a degree/centre/institution ****/ /*****************************************************************************/ -bool Usr_CheckIfUsrIsAdm (long UsrCod,Hie_Level_t Scope,long Cod) +bool Usr_CheckIfUsrIsAdm (long UsrCod,Hie_Lvl_Level_t Scope,long Cod) { /***** Get if a user is administrator of a degree from database *****/ return (DB_QueryCOUNT ("can not check if a user is administrator", @@ -952,7 +952,7 @@ bool Usr_CheckIfUsrIsSuperuser (long UsrCod) (DB_QueryCOUNT ("can not check if a user is superuser", "SELECT COUNT(*) FROM admin" " WHERE UsrCod=%ld AND Scope='%s'", - UsrCod,Sco_GetDBStrFromScope (Hie_SYS)) != 0); + UsrCod,Sco_GetDBStrFromScope (Hie_Lvl_SYS)) != 0); return Gbl.Cache.UsrIsSuperuser.IsSuperuser; } @@ -2401,7 +2401,7 @@ unsigned long Usr_GetCrssFromUsr (long UsrCod,long DegCod,MYSQL_RES **mysql_res) /*****************************************************************************/ void Usr_GetMainDeg (long UsrCod, - char ShrtName[Hie_MAX_BYTES_SHRT_NAME + 1], + char ShrtName[Cns_HIERARCHY_MAX_BYTES_SHRT_NAME + 1], Rol_Role_t *MaxRole) { MYSQL_RES *mysql_res; @@ -2432,7 +2432,7 @@ void Usr_GetMainDeg (long UsrCod, /* Get degree name (row[0]) */ Str_Copy (ShrtName,row[0], - Hie_MAX_BYTES_SHRT_NAME); + Cns_HIERARCHY_MAX_BYTES_SHRT_NAME); /* Get maximum role (row[1]) */ *MaxRole = Rol_ConvertUnsignedStrToRole (row[1]); @@ -3385,13 +3385,13 @@ static void Usr_SetMyPrefsAndRoles (void) /***** Location in hierarchy and role are stored in session, but in login the are got from user's last data *****/ - if (Gbl.Hierarchy.Level == Hie_SYS) // No country selected + if (Gbl.Hierarchy.Level == Hie_Lvl_SYS) // No country selected { /***** Copy last hierarchy to current hierarchy *****/ Hie_SetHierarchyFromUsrLastHierarchy (); /* Course may have changed ==> get my role in current course again */ - if (Gbl.Hierarchy.Level == Hie_CRS) // Course selected + if (Gbl.Hierarchy.Level == Hie_Lvl_CRS) // Course selected { Gbl.Usrs.Me.UsrDat.Roles.InCurrentCrs.Role = Rol_GetRoleUsrInCrs (Gbl.Usrs.Me.UsrDat.UsrCod, Gbl.Hierarchy.Crs.CrsCod); @@ -3815,7 +3815,7 @@ static void Usr_WriteRowStdAllData (struct UsrData *UsrDat,char *GroupNames) " ", NULL,true,UsrDat->Accepted); - if (Gbl.Scope.Current == Hie_CRS) + if (Gbl.Scope.Current == Hie_Lvl_CRS) { /***** Write the groups a the que pertenece the student *****/ for (NumGrpTyp = 0; @@ -4183,7 +4183,7 @@ unsigned Usr_GetNumUsrsWhoDontClaimToBelongToAnyCty (void) "SELECT COUNT(UsrCod) FROM usr_data" " WHERE CtyCod<0"); Gbl.Cache.NumUsrsWhoDontClaimToBelongToAnyCty.Valid = true; - FigCch_UpdateFigureIntoCache (FigCch_NUM_USRS_BELONG_CTY,Hie_CTY,-1L, + FigCch_UpdateFigureIntoCache (FigCch_NUM_USRS_BELONG_CTY,Hie_Lvl_CTY,-1L, FigCch_UNSIGNED,&Gbl.Cache.NumUsrsWhoDontClaimToBelongToAnyCty.NumUsrs); return Gbl.Cache.NumUsrsWhoDontClaimToBelongToAnyCty.NumUsrs; } @@ -4193,7 +4193,7 @@ unsigned Usr_GetCachedNumUsrsWhoDontClaimToBelongToAnyCty (void) unsigned NumUsrs; /***** Get number of user who don't claim to belong to any country from cache *****/ - if (!FigCch_GetFigureFromCache (FigCch_NUM_USRS_BELONG_CTY,Hie_CTY,-1L, + if (!FigCch_GetFigureFromCache (FigCch_NUM_USRS_BELONG_CTY,Hie_Lvl_CTY,-1L, FigCch_UNSIGNED,&NumUsrs)) /***** Get current number of user who don't claim to belong to any country from database and update cache *****/ NumUsrs = Usr_GetNumUsrsWhoDontClaimToBelongToAnyCty (); @@ -4223,7 +4223,7 @@ unsigned Usr_GetNumUsrsWhoClaimToBelongToAnotherCty (void) "SELECT COUNT(UsrCod) FROM usr_data" " WHERE CtyCod=0"); Gbl.Cache.NumUsrsWhoClaimToBelongToAnotherCty.Valid = true; - FigCch_UpdateFigureIntoCache (FigCch_NUM_USRS_BELONG_CTY,Hie_CTY,0, + FigCch_UpdateFigureIntoCache (FigCch_NUM_USRS_BELONG_CTY,Hie_Lvl_CTY,0, FigCch_UNSIGNED,&Gbl.Cache.NumUsrsWhoClaimToBelongToAnotherCty.NumUsrs); return Gbl.Cache.NumUsrsWhoClaimToBelongToAnotherCty.NumUsrs; } @@ -4233,7 +4233,7 @@ unsigned Usr_GetCachedNumUsrsWhoClaimToBelongToAnotherCty (void) unsigned NumUsrsCty; /***** Get number of users who claim to belong to another country form cache *****/ - if (!FigCch_GetFigureFromCache (FigCch_NUM_USRS_BELONG_CTY,Hie_CTY,0, + if (!FigCch_GetFigureFromCache (FigCch_NUM_USRS_BELONG_CTY,Hie_Lvl_CTY,0, FigCch_UNSIGNED,&NumUsrsCty)) /***** Get current number of users who claim to belong to another country from database and update cache *****/ NumUsrsCty = Usr_GetNumUsrsWhoClaimToBelongToAnotherCty (); @@ -4251,7 +4251,7 @@ void Usr_FlushCacheNumUsrsWhoClaimToBelongToCty (void) Gbl.Cache.NumUsrsWhoClaimToBelongToCty.NumUsrs = 0; } -unsigned Usr_GetNumUsrsWhoClaimToBelongToCty (struct Country *Cty) +unsigned Usr_GetNumUsrsWhoClaimToBelongToCty (struct Cty_Countr *Cty) { /***** 1. Fast check: Trivial case *****/ if (Cty->CtyCod <= 0) @@ -4279,17 +4279,17 @@ unsigned Usr_GetNumUsrsWhoClaimToBelongToCty (struct Country *Cty) " WHERE CtyCod=%ld", Cty->CtyCod); Cty->NumUsrsWhoClaimToBelongToCty.Valid = true; - FigCch_UpdateFigureIntoCache (FigCch_NUM_USRS_BELONG_CTY,Hie_CTY,Gbl.Cache.NumUsrsWhoClaimToBelongToCty.CtyCod, + FigCch_UpdateFigureIntoCache (FigCch_NUM_USRS_BELONG_CTY,Hie_Lvl_CTY,Gbl.Cache.NumUsrsWhoClaimToBelongToCty.CtyCod, FigCch_UNSIGNED,&Gbl.Cache.NumUsrsWhoClaimToBelongToCty.NumUsrs); return Cty->NumUsrsWhoClaimToBelongToCty.NumUsrs; } -unsigned Usr_GetCachedNumUsrsWhoClaimToBelongToCty (struct Country *Cty) +unsigned Usr_GetCachedNumUsrsWhoClaimToBelongToCty (struct Cty_Countr *Cty) { unsigned NumUsrsCty; /***** Get number of users who claim to belong to country from cache ******/ - if (!FigCch_GetFigureFromCache (FigCch_NUM_USRS_BELONG_CTY,Hie_CTY,Cty->CtyCod, + if (!FigCch_GetFigureFromCache (FigCch_NUM_USRS_BELONG_CTY,Hie_Lvl_CTY,Cty->CtyCod, FigCch_UNSIGNED,&NumUsrsCty)) /***** Get current number of users who claim to belong to country from database and update cache ******/ NumUsrsCty = Usr_GetNumUsrsWhoClaimToBelongToCty (Cty); @@ -4335,7 +4335,7 @@ unsigned Usr_GetNumUsrsWhoClaimToBelongToIns (struct Ins_Instit *Ins) " WHERE InsCod=%ld", Ins->InsCod); Ins->NumUsrsWhoClaimToBelongToIns.Valid = true; - FigCch_UpdateFigureIntoCache (FigCch_NUM_USRS_BELONG_INS,Hie_INS,Gbl.Cache.NumUsrsWhoClaimToBelongToIns.InsCod, + FigCch_UpdateFigureIntoCache (FigCch_NUM_USRS_BELONG_INS,Hie_Lvl_INS,Gbl.Cache.NumUsrsWhoClaimToBelongToIns.InsCod, FigCch_UNSIGNED,&Gbl.Cache.NumUsrsWhoClaimToBelongToIns.NumUsrs); return Ins->NumUsrsWhoClaimToBelongToIns.NumUsrs; } @@ -4345,7 +4345,7 @@ unsigned Usr_GetCachedNumUsrsWhoClaimToBelongToIns (struct Ins_Instit *Ins) unsigned NumUsrsIns; /***** Get number of users who claim to belong to institution from cache *****/ - if (!FigCch_GetFigureFromCache (FigCch_NUM_USRS_BELONG_INS,Hie_INS,Ins->InsCod, + if (!FigCch_GetFigureFromCache (FigCch_NUM_USRS_BELONG_INS,Hie_Lvl_INS,Ins->InsCod, FigCch_UNSIGNED,&NumUsrsIns)) /***** Get current number of users who claim to belong to institution from database and update cache *****/ NumUsrsIns = Usr_GetNumUsrsWhoClaimToBelongToIns (Ins); @@ -4390,7 +4390,7 @@ unsigned Usr_GetNumUsrsWhoClaimToBelongToCtr (struct Ctr_Centre *Ctr) "SELECT COUNT(UsrCod) FROM usr_data" " WHERE CtrCod=%ld", Ctr->CtrCod); - FigCch_UpdateFigureIntoCache (FigCch_NUM_USRS_BELONG_CTR,Hie_CTR,Gbl.Cache.NumUsrsWhoClaimToBelongToCtr.CtrCod, + FigCch_UpdateFigureIntoCache (FigCch_NUM_USRS_BELONG_CTR,Hie_Lvl_CTR,Gbl.Cache.NumUsrsWhoClaimToBelongToCtr.CtrCod, FigCch_UNSIGNED,&Gbl.Cache.NumUsrsWhoClaimToBelongToCtr.NumUsrs); return Ctr->NumUsrsWhoClaimToBelongToCtr.NumUsrs; } @@ -4400,7 +4400,7 @@ unsigned Usr_GetCachedNumUsrsWhoClaimToBelongToCtr (struct Ctr_Centre *Ctr) unsigned NumUsrsCtr; /***** Get number of users who claim to belong to centre from cache *****/ - if (!FigCch_GetFigureFromCache (FigCch_NUM_USRS_BELONG_CTR,Hie_CTR,Ctr->CtrCod, + if (!FigCch_GetFigureFromCache (FigCch_NUM_USRS_BELONG_CTR,Hie_Lvl_CTR,Ctr->CtrCod, FigCch_UNSIGNED,&NumUsrsCtr)) /***** Get current number of users who claim to belong to centre from database and update cache *****/ NumUsrsCtr = Usr_GetNumUsrsWhoClaimToBelongToCtr (Ctr); @@ -4447,8 +4447,8 @@ static void Usr_BuildQueryToGetUsrsLstCrs (char **Query,Rol_Role_t Role) row[ 8]: usr_data.PhotoVisibility row[ 9]: usr_data.CtyCod row[10]: usr_data.InsCod - row[11]: crs_usr.Role (only if Scope == Hie_CRS) - row[12]: crs_usr.Accepted (only if Scope == Hie_CRS) + row[11]: crs_usr.Role (only if Scope == Hie_Lvl_CRS) + row[12]: crs_usr.Accepted (only if Scope == Hie_Lvl_CRS) */ /***** If there are no groups selected, don't do anything *****/ @@ -4604,7 +4604,7 @@ static void Usr_BuildQueryToGetUsrsLstCrs (char **Query,Rol_Role_t Role) // - Rol_NET Non-editing teacher // - Rol_TCH Teacher -void Usr_GetListUsrs (Hie_Level_t Scope,Rol_Role_t Role) +void Usr_GetListUsrs (Hie_Lvl_Level_t Scope,Rol_Role_t Role) { char *Query = NULL; const char *QueryFields = @@ -4631,14 +4631,14 @@ void Usr_GetListUsrs (Hie_Level_t Scope,Rol_Role_t Role) row[ 8]: usr_data.PhotoVisibility row[ 9]: usr_data.CtyCod row[10]: usr_data.InsCod - row[11]: crs_usr.Role (only if Scope == Hie_CRS) - row[12]: crs_usr.Accepted (only if Scope == Hie_CRS) + row[11]: crs_usr.Role (only if Scope == Hie_Lvl_CRS) + row[12]: crs_usr.Accepted (only if Scope == Hie_Lvl_CRS) */ /***** Build query *****/ switch (Scope) { - case Hie_SYS: + case Hie_Lvl_SYS: /* Get users in courses from the whole platform */ DB_BuildQuery (&Query, "SELECT %s" @@ -4653,7 +4653,7 @@ void Usr_GetListUsrs (Hie_Level_t Scope,Rol_Role_t Role) QueryFields, (unsigned) Role); break; - case Hie_CTY: + case Hie_Lvl_CTY: /* Get users in courses from the current country */ DB_BuildQuery (&Query, "SELECT %s" @@ -4674,7 +4674,7 @@ void Usr_GetListUsrs (Hie_Level_t Scope,Rol_Role_t Role) (unsigned) Role, Gbl.Hierarchy.Cty.CtyCod); break; - case Hie_INS: + case Hie_Lvl_INS: /* Get users in courses from the current institution */ DB_BuildQuery (&Query, "SELECT %s" @@ -4694,7 +4694,7 @@ void Usr_GetListUsrs (Hie_Level_t Scope,Rol_Role_t Role) (unsigned) Role, Gbl.Hierarchy.Ins.InsCod); break; - case Hie_CTR: + case Hie_Lvl_CTR: /* Get users in courses from the current centre */ DB_BuildQuery (&Query, "SELECT %s" @@ -4713,7 +4713,7 @@ void Usr_GetListUsrs (Hie_Level_t Scope,Rol_Role_t Role) (unsigned) Role, Gbl.Hierarchy.Ctr.CtrCod); break; - case Hie_DEG: + case Hie_Lvl_DEG: /* Get users in courses from the current degree */ DB_BuildQuery (&Query, "SELECT %s" @@ -4731,7 +4731,7 @@ void Usr_GetListUsrs (Hie_Level_t Scope,Rol_Role_t Role) (unsigned) Role, Gbl.Hierarchy.Deg.DegCod); break; - case Hie_CRS: + case Hie_Lvl_CRS: /* Get users from the current course */ Usr_BuildQueryToGetUsrsLstCrs (&Query,Role); break; @@ -4779,8 +4779,8 @@ void Usr_SearchListUsrs (Rol_Role_t Role) row[ 8]: usr_data.PhotoVisibility row[ 9]: usr_data.CtyCod row[10]: usr_data.InsCod - row[11]: crs_usr.Role (only if Scope == Hie_CRS) - row[12]: crs_usr.Accepted (only if Scope == Hie_CRS) + row[11]: crs_usr.Role (only if Scope == Hie_Lvl_CRS) + row[12]: crs_usr.Accepted (only if Scope == Hie_Lvl_CRS) */ const char *OrderQuery = "candidate_users.UsrCod=usr_data.UsrCod" " ORDER BY " @@ -4798,7 +4798,7 @@ void Usr_SearchListUsrs (Rol_Role_t Role) case Rol_UNK: // Here Rol_UNK means any rol (role does not matter) switch (Gbl.Scope.Current) { - case Hie_SYS: + case Hie_Lvl_SYS: /* Search users from the whole platform */ DB_BuildQuery (&Query, "SELECT %s" @@ -4806,7 +4806,7 @@ void Usr_SearchListUsrs (Rol_Role_t Role) " WHERE %s", QueryFields,OrderQuery); break; - case Hie_CTY: + case Hie_Lvl_CTY: /* Search users in courses from the current country */ DB_BuildQuery (&Query, "SELECT %s" @@ -4822,7 +4822,7 @@ void Usr_SearchListUsrs (Rol_Role_t Role) Gbl.Hierarchy.Cty.CtyCod, OrderQuery); break; - case Hie_INS: + case Hie_Lvl_INS: /* Search users in courses from the current institution */ DB_BuildQuery (&Query, "SELECT %s" @@ -4837,7 +4837,7 @@ void Usr_SearchListUsrs (Rol_Role_t Role) Gbl.Hierarchy.Ins.InsCod, OrderQuery); break; - case Hie_CTR: + case Hie_Lvl_CTR: /* Search users in courses from the current centre */ DB_BuildQuery (&Query, "SELECT %s" @@ -4851,7 +4851,7 @@ void Usr_SearchListUsrs (Rol_Role_t Role) Gbl.Hierarchy.Ctr.CtrCod, OrderQuery); break; - case Hie_DEG: + case Hie_Lvl_DEG: /* Search users in courses from the current degree */ DB_BuildQuery (&Query, "SELECT %s" @@ -4864,7 +4864,7 @@ void Usr_SearchListUsrs (Rol_Role_t Role) Gbl.Hierarchy.Deg.DegCod, OrderQuery); break; - case Hie_CRS: + case Hie_Lvl_CRS: /* Search users in courses from the current course */ DB_BuildQuery (&Query, "SELECT %s,crs_usr.Role,crs_usr.Accepted" @@ -4916,7 +4916,7 @@ void Usr_SearchListUsrs (Rol_Role_t Role) } switch (Gbl.Scope.Current) { - case Hie_SYS: + case Hie_Lvl_SYS: /* Search users in courses from the whole platform */ DB_BuildQuery (&Query, "SELECT %s" @@ -4928,7 +4928,7 @@ void Usr_SearchListUsrs (Rol_Role_t Role) SubQueryRole, OrderQuery); break; - case Hie_CTY: + case Hie_Lvl_CTY: /* Search users in courses from the current country */ DB_BuildQuery (&Query, "SELECT %s" @@ -4946,7 +4946,7 @@ void Usr_SearchListUsrs (Rol_Role_t Role) Gbl.Hierarchy.Cty.CtyCod, OrderQuery); break; - case Hie_INS: + case Hie_Lvl_INS: /* Search users in courses from the current institution */ DB_BuildQuery (&Query, "SELECT %s" @@ -4963,7 +4963,7 @@ void Usr_SearchListUsrs (Rol_Role_t Role) Gbl.Hierarchy.Ins.InsCod, OrderQuery); break; - case Hie_CTR: + case Hie_Lvl_CTR: /* Search users in courses from the current centre */ DB_BuildQuery (&Query, "SELECT %s" @@ -4979,7 +4979,7 @@ void Usr_SearchListUsrs (Rol_Role_t Role) Gbl.Hierarchy.Ctr.CtrCod, OrderQuery); break; - case Hie_DEG: + case Hie_Lvl_DEG: /* Search users in courses from the current degree */ DB_BuildQuery (&Query, "SELECT %s" @@ -4994,7 +4994,7 @@ void Usr_SearchListUsrs (Rol_Role_t Role) Gbl.Hierarchy.Deg.DegCod, OrderQuery); break; - case Hie_CRS: + case Hie_Lvl_CRS: /* Search users in courses from the current course */ DB_BuildQuery (&Query, "SELECT %s,crs_usr.Role,crs_usr.Accepted" @@ -5064,7 +5064,7 @@ void Usr_DropTmpTableWithCandidateUsrs (void) /******************** Get list with data of administrators *******************/ /*****************************************************************************/ -static void Usr_GetAdmsLst (Hie_Level_t Scope) +static void Usr_GetAdmsLst (Hie_Lvl_Level_t Scope) { const char *QueryFields = "UsrCod," @@ -5100,7 +5100,7 @@ static void Usr_GetAdmsLst (Hie_Level_t Scope) // SELECT... WHERE (...) OR (...) <-- very slow switch (Scope) { - case Hie_SYS: // All admins + case Hie_Lvl_SYS: // All admins DB_BuildQuery (&Query, "SELECT %s FROM usr_data" " WHERE UsrCod IN " @@ -5108,7 +5108,7 @@ static void Usr_GetAdmsLst (Hie_Level_t Scope) " ORDER BY Surname1,Surname2,FirstName,UsrCod", QueryFields); break; - case Hie_CTY: // System admins + case Hie_Lvl_CTY: // System admins // and admins of the institutions, centres and degrees in the current country DB_BuildQuery (&Query, "SELECT %s FROM usr_data" @@ -5135,12 +5135,12 @@ static void Usr_GetAdmsLst (Hie_Level_t Scope) " AND institutions.CtyCod=%ld)" " ORDER BY Surname1,Surname2,FirstName,UsrCod", QueryFields, - Sco_GetDBStrFromScope (Hie_SYS), - Sco_GetDBStrFromScope (Hie_INS),Gbl.Hierarchy.Cty.CtyCod, - Sco_GetDBStrFromScope (Hie_CTR),Gbl.Hierarchy.Cty.CtyCod, - Sco_GetDBStrFromScope (Hie_DEG),Gbl.Hierarchy.Cty.CtyCod); + Sco_GetDBStrFromScope (Hie_Lvl_SYS), + Sco_GetDBStrFromScope (Hie_Lvl_INS),Gbl.Hierarchy.Cty.CtyCod, + Sco_GetDBStrFromScope (Hie_Lvl_CTR),Gbl.Hierarchy.Cty.CtyCod, + Sco_GetDBStrFromScope (Hie_Lvl_DEG),Gbl.Hierarchy.Cty.CtyCod); break; - case Hie_INS: // System admins, + case Hie_Lvl_INS: // System admins, // admins of the current institution, // and admins of the centres and degrees in the current institution DB_BuildQuery (&Query, @@ -5164,12 +5164,12 @@ static void Usr_GetAdmsLst (Hie_Level_t Scope) " AND centres.InsCod=%ld)" " ORDER BY Surname1,Surname2,FirstName,UsrCod", QueryFields, - Sco_GetDBStrFromScope (Hie_SYS), - Sco_GetDBStrFromScope (Hie_INS),Gbl.Hierarchy.Ins.InsCod, - Sco_GetDBStrFromScope (Hie_CTR),Gbl.Hierarchy.Ins.InsCod, - Sco_GetDBStrFromScope (Hie_DEG),Gbl.Hierarchy.Ins.InsCod); + Sco_GetDBStrFromScope (Hie_Lvl_SYS), + Sco_GetDBStrFromScope (Hie_Lvl_INS),Gbl.Hierarchy.Ins.InsCod, + Sco_GetDBStrFromScope (Hie_Lvl_CTR),Gbl.Hierarchy.Ins.InsCod, + Sco_GetDBStrFromScope (Hie_Lvl_DEG),Gbl.Hierarchy.Ins.InsCod); break; - case Hie_CTR: // System admins, + case Hie_Lvl_CTR: // System admins, // admins of the current institution, // admins and the current centre, // and admins of the degrees in the current centre @@ -5191,12 +5191,12 @@ static void Usr_GetAdmsLst (Hie_Level_t Scope) " AND degrees.CtrCod=%ld)" " ORDER BY Surname1,Surname2,FirstName,UsrCod", QueryFields, - Sco_GetDBStrFromScope (Hie_SYS), - Sco_GetDBStrFromScope (Hie_INS),Gbl.Hierarchy.Ins.InsCod, - Sco_GetDBStrFromScope (Hie_CTR),Gbl.Hierarchy.Ctr.CtrCod, - Sco_GetDBStrFromScope (Hie_DEG),Gbl.Hierarchy.Ctr.CtrCod); + Sco_GetDBStrFromScope (Hie_Lvl_SYS), + Sco_GetDBStrFromScope (Hie_Lvl_INS),Gbl.Hierarchy.Ins.InsCod, + Sco_GetDBStrFromScope (Hie_Lvl_CTR),Gbl.Hierarchy.Ctr.CtrCod, + Sco_GetDBStrFromScope (Hie_Lvl_DEG),Gbl.Hierarchy.Ctr.CtrCod); break; - case Hie_DEG: // System admins + case Hie_Lvl_DEG: // System admins // and admins of the current institution, centre or degree DB_BuildQuery (&Query, "SELECT %s FROM usr_data" @@ -5214,10 +5214,10 @@ static void Usr_GetAdmsLst (Hie_Level_t Scope) " WHERE Scope='%s' AND Cod=%ld)" " ORDER BY Surname1,Surname2,FirstName,UsrCod", QueryFields, - Sco_GetDBStrFromScope (Hie_SYS), - Sco_GetDBStrFromScope (Hie_INS),Gbl.Hierarchy.Ins.InsCod, - Sco_GetDBStrFromScope (Hie_CTR),Gbl.Hierarchy.Ctr.CtrCod, - Sco_GetDBStrFromScope (Hie_DEG),Gbl.Hierarchy.Deg.DegCod); + Sco_GetDBStrFromScope (Hie_Lvl_SYS), + Sco_GetDBStrFromScope (Hie_Lvl_INS),Gbl.Hierarchy.Ins.InsCod, + Sco_GetDBStrFromScope (Hie_Lvl_CTR),Gbl.Hierarchy.Ctr.CtrCod, + Sco_GetDBStrFromScope (Hie_Lvl_DEG),Gbl.Hierarchy.Deg.DegCod); break; default: // not aplicable Lay_WrongScopeExit (); @@ -5232,7 +5232,7 @@ static void Usr_GetAdmsLst (Hie_Level_t Scope) /************************ Get list with data of guests ***********************/ /*****************************************************************************/ -static void Usr_GetGstsLst (Hie_Level_t Scope) +static void Usr_GetGstsLst (Hie_Lvl_Level_t Scope) { const char *QueryFields = "UsrCod," @@ -5264,14 +5264,14 @@ static void Usr_GetGstsLst (Hie_Level_t Scope) /***** Build query *****/ switch (Scope) { - case Hie_SYS: + case Hie_Lvl_SYS: DB_BuildQuery (&Query, "SELECT %s FROM usr_data" " WHERE UsrCod NOT IN (SELECT UsrCod FROM crs_usr)" " ORDER BY Surname1,Surname2,FirstName,UsrCod", QueryFields); break; - case Hie_CTY: + case Hie_Lvl_CTY: DB_BuildQuery (&Query, "SELECT %s FROM usr_data" " WHERE (CtyCod=%ld OR InsCtyCod=%ld)" @@ -5281,7 +5281,7 @@ static void Usr_GetGstsLst (Hie_Level_t Scope) Gbl.Hierarchy.Cty.CtyCod, Gbl.Hierarchy.Cty.CtyCod); break; - case Hie_INS: + case Hie_Lvl_INS: DB_BuildQuery (&Query, "SELECT %s FROM usr_data" " WHERE InsCod=%ld" @@ -5290,7 +5290,7 @@ static void Usr_GetGstsLst (Hie_Level_t Scope) QueryFields, Gbl.Hierarchy.Ins.InsCod); break; - case Hie_CTR: + case Hie_Lvl_CTR: DB_BuildQuery (&Query, "SELECT %s FROM usr_data" " WHERE CtrCod=%ld" @@ -5336,7 +5336,7 @@ void Usr_GetUnorderedStdsCodesInDeg (long DegCod) DegCod,(unsigned) Rol_STD); /***** Get list of students from database *****/ - Usr_GetListUsrsFromQuery (Query,Rol_STD,Hie_DEG); + Usr_GetListUsrsFromQuery (Query,Rol_STD,Hie_Lvl_DEG); /***** Free query string *****/ free (Query); @@ -5346,7 +5346,7 @@ void Usr_GetUnorderedStdsCodesInDeg (long DegCod) /********************** Get list of users from database **********************/ /*****************************************************************************/ -static void Usr_GetListUsrsFromQuery (char *Query,Rol_Role_t Role,Hie_Level_t Scope) +static void Usr_GetListUsrsFromQuery (char *Query,Rol_Role_t Role,Hie_Lvl_Level_t Scope) { extern const char *Txt_The_list_of_X_users_is_too_large_to_be_displayed; MYSQL_RES *mysql_res; @@ -5403,8 +5403,8 @@ static void Usr_GetListUsrsFromQuery (char *Query,Rol_Role_t Role,Hie_Level_t Sc row[ 8]: usr_data.PhotoVisibility row[ 9]: usr_data.CtyCod row[10]: usr_data.InsCod - row[11]: crs_usr.Role (only if Scope == Hie_CRS) - row[12]: crs_usr.Accepted (only if Scope == Hie_CRS) + row[11]: crs_usr.Role (only if Scope == Hie_Lvl_CRS) + row[12]: crs_usr.Accepted (only if Scope == Hie_Lvl_CRS) */ UsrInList = &Gbl.Usrs.LstUsrs[Role].Lst[NumUsr]; @@ -5448,16 +5448,16 @@ static void Usr_GetListUsrsFromQuery (char *Query,Rol_Role_t Role,Hie_Level_t Sc UsrInList->InsCod = Str_ConvertStrCodToLongCod (row[10]); /* Get user's role and acceptance of enrolment in course(s) - (row[11], row[12] if Scope == Hie_CRS) */ + (row[11], row[12] if Scope == Hie_Lvl_CRS) */ switch (Role) { case Rol_UNK: // Here Rol_UNK means any user switch (Scope) { - case Hie_UNK: // Unknown + case Hie_Lvl_UNK: // Unknown Lay_WrongScopeExit (); break; - case Hie_SYS: // System + case Hie_Lvl_SYS: // System // Query result has not a column with the acceptation UsrInList->RoleInCurrentCrsDB = Rol_UNK; if (Usr_GetNumCrssOfUsr (UsrInList->UsrCod)) @@ -5465,15 +5465,15 @@ static void Usr_GetListUsrsFromQuery (char *Query,Rol_Role_t Role,Hie_Level_t Sc else UsrInList->Accepted = false; break; - case Hie_CTY: // Country - case Hie_INS: // Institution - case Hie_CTR: // Centre - case Hie_DEG: // Degree + case Hie_Lvl_CTY: // Country + case Hie_Lvl_INS: // Institution + case Hie_Lvl_CTR: // Centre + case Hie_Lvl_DEG: // Degree // Query result has not a column with the acceptation UsrInList->RoleInCurrentCrsDB = Rol_UNK; UsrInList->Accepted = (Usr_GetNumCrssOfUsrNotAccepted (UsrInList->UsrCod) == 0); break; - case Hie_CRS: // Course + case Hie_Lvl_CRS: // Course // Query result has a column with the acceptation UsrInList->RoleInCurrentCrsDB = Rol_ConvertUnsignedStrToRole (row[11]); UsrInList->Accepted = (row[12][0] == 'Y'); @@ -5492,19 +5492,19 @@ static void Usr_GetListUsrsFromQuery (char *Query,Rol_Role_t Role,Hie_Level_t Sc case Rol_TCH: switch (Scope) { - case Hie_UNK: // Unknown + case Hie_Lvl_UNK: // Unknown Lay_WrongScopeExit (); break; - case Hie_SYS: // System - case Hie_CTY: // Country - case Hie_INS: // Institution - case Hie_CTR: // Centre - case Hie_DEG: // Degree + case Hie_Lvl_SYS: // System + case Hie_Lvl_CTY: // Country + case Hie_Lvl_INS: // Institution + case Hie_Lvl_CTR: // Centre + case Hie_Lvl_DEG: // Degree // Query result has not a column with the acceptation UsrInList->RoleInCurrentCrsDB = Rol_UNK; UsrInList->Accepted = (Usr_GetNumCrssOfUsrWithARoleNotAccepted (UsrInList->UsrCod,Role) == 0); break; - case Hie_CRS: // Course + case Hie_Lvl_CRS: // Course // Query result has a column with the acceptation UsrInList->RoleInCurrentCrsDB = Rol_ConvertUnsignedStrToRole (row[11]); UsrInList->Accepted = (row[12][0] == 'Y'); @@ -6306,9 +6306,9 @@ void Usr_PutFormToSelectUsrsToGoToAct (struct SelectedUsrs *SelectedUsrs, Grp_GetParCodsSeveralGrpsToShowUsrs (); /***** Get and order lists of users from this course *****/ - Usr_GetListUsrs (Hie_CRS,Rol_STD); - Usr_GetListUsrs (Hie_CRS,Rol_NET); - Usr_GetListUsrs (Hie_CRS,Rol_TCH); + Usr_GetListUsrs (Hie_Lvl_CRS,Rol_STD); + Usr_GetListUsrs (Hie_Lvl_CRS,Rol_NET); + Usr_GetListUsrs (Hie_Lvl_CRS,Rol_TCH); NumTotalUsrs = Gbl.Usrs.LstUsrs[Rol_STD].NumUsrs + Gbl.Usrs.LstUsrs[Rol_NET].NumUsrs + Gbl.Usrs.LstUsrs[Rol_TCH].NumUsrs; @@ -6980,7 +6980,7 @@ void Usr_ListAllDataStds (void) Sco_GetScope ("ScopeUsr"); /***** If the scope is the current course... *****/ - if (Gbl.Scope.Current == Hie_CRS) + if (Gbl.Scope.Current == Hie_Lvl_CRS) { /* Get list of groups types and groups in current course This is necessary to show columns with group selection */ @@ -6995,13 +6995,13 @@ void Usr_ListAllDataStds (void) if (Gbl.Usrs.LstUsrs[Rol_STD].NumUsrs) { - if (Gbl.Scope.Current == Hie_CRS) + if (Gbl.Scope.Current == Hie_Lvl_CRS) /***** Get list of record fields in current course *****/ Rec_GetListRecordFieldsInCurrentCrs (); /***** Set number of columns *****/ NumColumnsCommonCard = Usr_NUM_ALL_FIELDS_DATA_STD; - if (Gbl.Scope.Current == Hie_CRS) + if (Gbl.Scope.Current == Hie_Lvl_CRS) { NumColumnsCardAndGroups = NumColumnsCommonCard + Gbl.Crs.Grps.GrpTypes.Num; NumColumnsTotal = NumColumnsCardAndGroups + Gbl.Crs.Records.LstFields.Num; @@ -7010,7 +7010,7 @@ void Usr_ListAllDataStds (void) NumColumnsTotal = NumColumnsCardAndGroups = NumColumnsCommonCard; /***** Allocate memory for the string with the list of group names where student belongs to *****/ - if (Gbl.Scope.Current == Hie_CRS) + if (Gbl.Scope.Current == Hie_Lvl_CRS) { Length = (Grp_MAX_BYTES_GROUP_NAME + 2) * Gbl.Crs.Grps.GrpTypes.NumGrpsTotal; if ((GroupNames = (char *) malloc (Length + 1)) == NULL) @@ -7040,7 +7040,7 @@ void Usr_ListAllDataStds (void) HTM_TH (1,1,"LM LIGHT_BLUE",FieldNames[NumCol]); /* 2. Columns for the groups */ - if (Gbl.Scope.Current == Hie_CRS) + if (Gbl.Scope.Current == Hie_Lvl_CRS) { if (Gbl.Crs.Grps.GrpTypes.Num) for (NumGrpTyp = 0; @@ -7113,7 +7113,7 @@ void Usr_ListAllDataStds (void) HTM_TABLE_End (); /***** Free memory used by the string with the list of group names where student belongs to *****/ - if (Gbl.Scope.Current == Hie_CRS) + if (Gbl.Scope.Current == Hie_Lvl_CRS) free (GroupNames); } else // Gbl.Usrs.LstUsrs[Rol_STD].NumUsrs == 0 @@ -7213,28 +7213,28 @@ void Usr_ListAllDataTchs (void) Usr_GetAndUpdatePrefsAboutUsrList (); /***** Get scope *****/ - Gbl.Scope.Allowed = 1 << Hie_SYS | - 1 << Hie_CTY | - 1 << Hie_INS | - 1 << Hie_CTR | - 1 << Hie_DEG | - 1 << Hie_CRS; - Gbl.Scope.Default = Hie_CRS; + Gbl.Scope.Allowed = 1 << Hie_Lvl_SYS | + 1 << Hie_Lvl_CTY | + 1 << Hie_Lvl_INS | + 1 << Hie_Lvl_CTR | + 1 << Hie_Lvl_DEG | + 1 << Hie_Lvl_CRS; + Gbl.Scope.Default = Hie_Lvl_CRS; Sco_GetScope ("ScopeUsr"); /***** Get list of teachers *****/ Usr_GetListUsrs (Gbl.Scope.Current,Rol_NET); // Non-editing teachers Usr_GetListUsrs (Gbl.Scope.Current,Rol_TCH); // Teachers - if (Gbl.Scope.Current == Hie_CRS) + if (Gbl.Scope.Current == Hie_Lvl_CRS) NumUsrs = Gbl.Usrs.LstUsrs[Rol_NET].NumUsrs + Gbl.Usrs.LstUsrs[Rol_TCH].NumUsrs; else NumUsrs = Usr_GetNumUsrsInCrss (Gbl.Scope.Current, - (Gbl.Scope.Current == Hie_CTY ? Gbl.Hierarchy.Cty.CtyCod : - (Gbl.Scope.Current == Hie_INS ? Gbl.Hierarchy.Ins.InsCod : - (Gbl.Scope.Current == Hie_CTR ? Gbl.Hierarchy.Ctr.CtrCod : - (Gbl.Scope.Current == Hie_DEG ? Gbl.Hierarchy.Deg.DegCod : - (Gbl.Scope.Current == Hie_CRS ? Gbl.Hierarchy.Crs.CrsCod : + (Gbl.Scope.Current == Hie_Lvl_CTY ? Gbl.Hierarchy.Cty.CtyCod : + (Gbl.Scope.Current == Hie_Lvl_INS ? Gbl.Hierarchy.Ins.InsCod : + (Gbl.Scope.Current == Hie_Lvl_CTR ? Gbl.Hierarchy.Ctr.CtrCod : + (Gbl.Scope.Current == Hie_Lvl_DEG ? Gbl.Hierarchy.Deg.DegCod : + (Gbl.Scope.Current == Hie_Lvl_CRS ? Gbl.Hierarchy.Crs.CrsCod : -1L))))), 1 << Rol_NET | 1 << Rol_TCH); @@ -7481,12 +7481,12 @@ void Usr_ListDataAdms (void) Usr_GetAndUpdatePrefsAboutUsrList (); /***** Get scope *****/ - Gbl.Scope.Allowed = 1 << Hie_SYS | - 1 << Hie_CTY | - 1 << Hie_INS | - 1 << Hie_CTR | - 1 << Hie_DEG; - Gbl.Scope.Default = Hie_DEG; + Gbl.Scope.Allowed = 1 << Hie_Lvl_SYS | + 1 << Hie_Lvl_CTY | + 1 << Hie_Lvl_INS | + 1 << Hie_Lvl_CTR | + 1 << Hie_Lvl_DEG; + Gbl.Scope.Default = Hie_Lvl_DEG; Sco_GetScope ("ScopeUsr"); /***** Get list of administrators *****/ @@ -7750,7 +7750,7 @@ static void Usr_GetMyColsClassPhotoFromDB (void) /***** If user logged and course selected... *****/ if (Gbl.Usrs.Me.Logged && - Gbl.Hierarchy.Level == Hie_CRS) // Course selected + Gbl.Hierarchy.Level == Hie_Lvl_CRS) // Course selected { /***** Get number of columns in class photo from database *****/ NumRows = DB_QuerySELECT (&mysql_res,"can not get number of columns" @@ -7786,7 +7786,7 @@ static void Usr_GetMyColsClassPhotoFromDB (void) static void Usr_UpdateMyColsClassPhotoInDB (void) { if (Gbl.Usrs.Me.Logged && - Gbl.Hierarchy.Level == Hie_CRS) // Course selected + Gbl.Hierarchy.Level == Hie_Lvl_CRS) // Course selected /***** Update number of colums in class photo for current course *****/ DB_QueryUPDATE ("can not update number of columns in class photo", "UPDATE crs_usr_last SET ColsClassPhoto=%u" @@ -7888,7 +7888,7 @@ void Usr_GetMyPrefAboutListWithPhotosFromDB (void) static void Usr_UpdateMyPrefAboutListWithPhotosPhotoInDB (void) { if (Gbl.Usrs.Me.Logged && - Gbl.Hierarchy.Level == Hie_CRS) // Course selected + Gbl.Hierarchy.Level == Hie_Lvl_CRS) // Course selected /***** Update number of colums in class photo for current course *****/ DB_QueryUPDATE ("can not update your preference about photos in listing", "UPDATE crs_usr_last SET ListWithPhotos='%c'" @@ -7997,8 +7997,8 @@ void Usr_SeeGuests (void) /***** Draw a class photo with guests *****/ if (Gbl.Usrs.Me.ListType == Usr_LIST_AS_CLASS_PHOTO) Lay_WriteHeaderClassPhoto (false,true, - (Gbl.Scope.Current == Hie_CTR || - Gbl.Scope.Current == Hie_INS) ? Gbl.Hierarchy.Ins.InsCod : + (Gbl.Scope.Current == Hie_Lvl_CTR || + Gbl.Scope.Current == Hie_Lvl_INS) ? Gbl.Hierarchy.Ins.InsCod : -1L, -1L, -1L); @@ -8078,7 +8078,7 @@ void Usr_SeeStudents (void) /***** Contextual menu *****/ Mnu_ContextMenuBegin (); Enr_PutLinkToAdminOneUsr (ActReqMdfOneStd); // Admin one student - if (Gbl.Hierarchy.Level == Hie_CRS && // Course selected + if (Gbl.Hierarchy.Level == Hie_Lvl_CRS && // Course selected Gbl.Usrs.Me.Role.Logged != Rol_STD) // Teacher or admin { Enr_PutLinkToAdminSeveralUsrs (Rol_STD); // Admin several students @@ -8100,7 +8100,7 @@ void Usr_SeeStudents (void) Sco_GetScope ("ScopeUsr"); /***** Get groups to show ******/ - if (Gbl.Scope.Current == Hie_CRS) + if (Gbl.Scope.Current == Hie_Lvl_CRS) Grp_GetParCodsSeveralGrpsToShowUsrs (); /***** Get list of students *****/ @@ -8133,7 +8133,7 @@ void Usr_SeeStudents (void) } /***** Form to select groups *****/ - if (Gbl.Scope.Current == Hie_CRS) + if (Gbl.Scope.Current == Hie_Lvl_CRS) Grp_ShowFormToSelectSeveralGroups (Sco_PutParamCurrentScope,&Gbl.Scope.Current, Grp_MY_GROUPS); @@ -8152,15 +8152,15 @@ void Usr_SeeStudents (void) /***** Draw a class photo with students of the course *****/ if (Gbl.Usrs.Me.ListType == Usr_LIST_AS_CLASS_PHOTO) Lay_WriteHeaderClassPhoto (false,true, - (Gbl.Scope.Current == Hie_CRS || - Gbl.Scope.Current == Hie_DEG || - Gbl.Scope.Current == Hie_CTR || - Gbl.Scope.Current == Hie_INS) ? Gbl.Hierarchy.Ins.InsCod : + (Gbl.Scope.Current == Hie_Lvl_CRS || + Gbl.Scope.Current == Hie_Lvl_DEG || + Gbl.Scope.Current == Hie_Lvl_CTR || + Gbl.Scope.Current == Hie_Lvl_INS) ? Gbl.Hierarchy.Ins.InsCod : -1L, - (Gbl.Scope.Current == Hie_CRS || - Gbl.Scope.Current == Hie_DEG) ? Gbl.Hierarchy.Deg.DegCod : + (Gbl.Scope.Current == Hie_Lvl_CRS || + Gbl.Scope.Current == Hie_Lvl_DEG) ? Gbl.Hierarchy.Deg.DegCod : -1L, - Gbl.Scope.Current == Hie_CRS ? Gbl.Hierarchy.Crs.CrsCod : + Gbl.Scope.Current == Hie_Lvl_CRS ? Gbl.Hierarchy.Crs.CrsCod : -1L); /* Set options allowed */ @@ -8245,7 +8245,7 @@ void Usr_SeeTeachers (void) /***** Contextual menu *****/ Mnu_ContextMenuBegin (); Enr_PutLinkToAdminOneUsr (ActReqMdfOneTch); // Admin one teacher - if (Gbl.Hierarchy.Level == Hie_CRS && // Course selected + if (Gbl.Hierarchy.Level == Hie_Lvl_CRS && // Course selected Gbl.Usrs.Me.Role.Logged >= Rol_DEG_ADM) // I am logged as admin { Enr_PutLinkToAdminSeveralUsrs (Rol_NET); // Admin several non-editing teachers @@ -8263,32 +8263,32 @@ void Usr_SeeTeachers (void) Usr_GetAndUpdatePrefsAboutUsrList (); /***** Get scope *****/ - Gbl.Scope.Allowed = 1 << Hie_SYS | - 1 << Hie_CTY | - 1 << Hie_INS | - 1 << Hie_CTR | - 1 << Hie_DEG | - 1 << Hie_CRS; - Gbl.Scope.Default = Hie_CRS; + Gbl.Scope.Allowed = 1 << Hie_Lvl_SYS | + 1 << Hie_Lvl_CTY | + 1 << Hie_Lvl_INS | + 1 << Hie_Lvl_CTR | + 1 << Hie_Lvl_DEG | + 1 << Hie_Lvl_CRS; + Gbl.Scope.Default = Hie_Lvl_CRS; Sco_GetScope ("ScopeUsr"); /***** Get groups to show ******/ - if (Gbl.Scope.Current == Hie_CRS) + if (Gbl.Scope.Current == Hie_Lvl_CRS) Grp_GetParCodsSeveralGrpsToShowUsrs (); /***** Get lists of teachers *****/ Usr_GetListUsrs (Gbl.Scope.Current,Rol_NET); // Non-editing teachers Usr_GetListUsrs (Gbl.Scope.Current,Rol_TCH); // Teachers - if (Gbl.Scope.Current == Hie_CRS) + if (Gbl.Scope.Current == Hie_Lvl_CRS) NumUsrs = Gbl.Usrs.LstUsrs[Rol_NET].NumUsrs + Gbl.Usrs.LstUsrs[Rol_TCH].NumUsrs; else NumUsrs = Usr_GetNumUsrsInCrss (Gbl.Scope.Current, - (Gbl.Scope.Current == Hie_CTY ? Gbl.Hierarchy.Cty.CtyCod : - (Gbl.Scope.Current == Hie_INS ? Gbl.Hierarchy.Ins.InsCod : - (Gbl.Scope.Current == Hie_CTR ? Gbl.Hierarchy.Ctr.CtrCod : - (Gbl.Scope.Current == Hie_DEG ? Gbl.Hierarchy.Deg.DegCod : - (Gbl.Scope.Current == Hie_CRS ? Gbl.Hierarchy.Crs.CrsCod : + (Gbl.Scope.Current == Hie_Lvl_CTY ? Gbl.Hierarchy.Cty.CtyCod : + (Gbl.Scope.Current == Hie_Lvl_INS ? Gbl.Hierarchy.Ins.InsCod : + (Gbl.Scope.Current == Hie_Lvl_CTR ? Gbl.Hierarchy.Ctr.CtrCod : + (Gbl.Scope.Current == Hie_Lvl_DEG ? Gbl.Hierarchy.Deg.DegCod : + (Gbl.Scope.Current == Hie_Lvl_CRS ? Gbl.Hierarchy.Crs.CrsCod : -1L))))), 1 << Rol_NET | 1 << Rol_TCH); @@ -8310,7 +8310,7 @@ void Usr_SeeTeachers (void) HTM_DIV_End (); /***** Form to select groups *****/ - if (Gbl.Scope.Current == Hie_CRS) + if (Gbl.Scope.Current == Hie_Lvl_CRS) Grp_ShowFormToSelectSeveralGroups (Sco_PutParamCurrentScope,&Gbl.Scope.Current, Grp_MY_GROUPS); @@ -8329,15 +8329,15 @@ void Usr_SeeTeachers (void) /***** Draw a class photo with teachers of the course *****/ if (Gbl.Usrs.Me.ListType == Usr_LIST_AS_CLASS_PHOTO) Lay_WriteHeaderClassPhoto (false,true, - (Gbl.Scope.Current == Hie_CRS || - Gbl.Scope.Current == Hie_DEG || - Gbl.Scope.Current == Hie_CTR || - Gbl.Scope.Current == Hie_INS) ? Gbl.Hierarchy.Ins.InsCod : + (Gbl.Scope.Current == Hie_Lvl_CRS || + Gbl.Scope.Current == Hie_Lvl_DEG || + Gbl.Scope.Current == Hie_Lvl_CTR || + Gbl.Scope.Current == Hie_Lvl_INS) ? Gbl.Hierarchy.Ins.InsCod : -1L, - (Gbl.Scope.Current == Hie_CRS || - Gbl.Scope.Current == Hie_DEG) ? Gbl.Hierarchy.Deg.DegCod : + (Gbl.Scope.Current == Hie_Lvl_CRS || + Gbl.Scope.Current == Hie_Lvl_DEG) ? Gbl.Hierarchy.Deg.DegCod : -1L, - Gbl.Scope.Current == Hie_CRS ? Gbl.Hierarchy.Crs.CrsCod : + Gbl.Scope.Current == Hie_Lvl_CRS ? Gbl.Hierarchy.Crs.CrsCod : -1L); /* Set options allowed */ @@ -8436,7 +8436,7 @@ static bool Usr_SetOptionsListUsrsAllowed (Rol_Role_t UsrsRole, ICanChooseOption[Usr_OPTION_RECORDS] = ICanChooseOption[Usr_OPTION_MESSAGE] = ICanChooseOption[Usr_OPTION_FOLLOW] = - ICanChooseOption[Usr_OPTION_UNFOLLOW] = (Gbl.Scope.Current == Hie_CRS && + ICanChooseOption[Usr_OPTION_UNFOLLOW] = (Gbl.Scope.Current == Hie_Lvl_CRS && (Gbl.Usrs.Me.Role.Logged == Rol_STD || Gbl.Usrs.Me.Role.Logged == Rol_NET || Gbl.Usrs.Me.Role.Logged == Rol_TCH || @@ -8444,7 +8444,7 @@ static bool Usr_SetOptionsListUsrsAllowed (Rol_Role_t UsrsRole, ICanChooseOption[Usr_OPTION_HOMEWORK] = ICanChooseOption[Usr_OPTION_ATTENDANCE] = - ICanChooseOption[Usr_OPTION_EMAIL] = (Gbl.Scope.Current == Hie_CRS && + ICanChooseOption[Usr_OPTION_EMAIL] = (Gbl.Scope.Current == Hie_Lvl_CRS && (Gbl.Usrs.Me.Role.Logged == Rol_NET || Gbl.Usrs.Me.Role.Logged == Rol_TCH || Gbl.Usrs.Me.Role.Logged == Rol_SYS_ADM)); @@ -8454,12 +8454,12 @@ static bool Usr_SetOptionsListUsrsAllowed (Rol_Role_t UsrsRole, ICanChooseOption[Usr_OPTION_MESSAGE] = ICanChooseOption[Usr_OPTION_EMAIL] = ICanChooseOption[Usr_OPTION_FOLLOW] = - ICanChooseOption[Usr_OPTION_UNFOLLOW] = (Gbl.Scope.Current == Hie_CRS && + ICanChooseOption[Usr_OPTION_UNFOLLOW] = (Gbl.Scope.Current == Hie_Lvl_CRS && (Gbl.Usrs.Me.Role.Logged == Rol_STD || Gbl.Usrs.Me.Role.Logged == Rol_NET || Gbl.Usrs.Me.Role.Logged == Rol_TCH || Gbl.Usrs.Me.Role.Logged == Rol_SYS_ADM)); - ICanChooseOption[Usr_OPTION_HOMEWORK] = (Gbl.Scope.Current == Hie_CRS && + ICanChooseOption[Usr_OPTION_HOMEWORK] = (Gbl.Scope.Current == Hie_Lvl_CRS && (Gbl.Usrs.Me.Role.Logged == Rol_NET || Gbl.Usrs.Me.Role.Logged == Rol_TCH || Gbl.Usrs.Me.Role.Logged == Rol_SYS_ADM)); @@ -8878,8 +8878,8 @@ void Usr_SeeGstClassPhotoPrn (void) { /***** Draw the guests' class photo *****/ Lay_WriteHeaderClassPhoto (true,true, - (Gbl.Scope.Current == Hie_CTR || - Gbl.Scope.Current == Hie_INS) ? Gbl.Hierarchy.Ins.InsCod : + (Gbl.Scope.Current == Hie_Lvl_CTR || + Gbl.Scope.Current == Hie_Lvl_INS) ? Gbl.Hierarchy.Ins.InsCod : -1L, -1L,-1L); HTM_TABLE_BeginWide (); @@ -8920,15 +8920,15 @@ void Usr_SeeStdClassPhotoPrn (void) { /***** Draw the students' class photo *****/ Lay_WriteHeaderClassPhoto (true,true, - (Gbl.Scope.Current == Hie_CRS || - Gbl.Scope.Current == Hie_DEG || - Gbl.Scope.Current == Hie_CTR || - Gbl.Scope.Current == Hie_INS) ? Gbl.Hierarchy.Ins.InsCod : + (Gbl.Scope.Current == Hie_Lvl_CRS || + Gbl.Scope.Current == Hie_Lvl_DEG || + Gbl.Scope.Current == Hie_Lvl_CTR || + Gbl.Scope.Current == Hie_Lvl_INS) ? Gbl.Hierarchy.Ins.InsCod : -1L, - (Gbl.Scope.Current == Hie_CRS || - Gbl.Scope.Current == Hie_DEG) ? Gbl.Hierarchy.Deg.DegCod : + (Gbl.Scope.Current == Hie_Lvl_CRS || + Gbl.Scope.Current == Hie_Lvl_DEG) ? Gbl.Hierarchy.Deg.DegCod : -1L, - Gbl.Scope.Current == Hie_CRS ? Gbl.Hierarchy.Crs.CrsCod : + Gbl.Scope.Current == Hie_Lvl_CRS ? Gbl.Hierarchy.Crs.CrsCod : -1L); HTM_TABLE_BeginWide (); Usr_DrawClassPhoto (Usr_CLASS_PHOTO_PRN, @@ -8960,13 +8960,13 @@ void Usr_SeeTchClassPhotoPrn (void) Usr_GetAndUpdatePrefsAboutUsrList (); /***** Get scope *****/ - Gbl.Scope.Allowed = 1 << Hie_SYS | - 1 << Hie_CTY | - 1 << Hie_INS | - 1 << Hie_CTR | - 1 << Hie_DEG | - 1 << Hie_CRS; - Gbl.Scope.Default = Hie_CRS; + Gbl.Scope.Allowed = 1 << Hie_Lvl_SYS | + 1 << Hie_Lvl_CTY | + 1 << Hie_Lvl_INS | + 1 << Hie_Lvl_CTR | + 1 << Hie_Lvl_DEG | + 1 << Hie_Lvl_CRS; + Gbl.Scope.Default = Hie_Lvl_CRS; Sco_GetScope ("ScopeUsr"); /****** Get groups to show ******/ @@ -8975,16 +8975,16 @@ void Usr_SeeTchClassPhotoPrn (void) /***** Get list of teachers *****/ Usr_GetListUsrs (Gbl.Scope.Current,Rol_NET); // Non-editing teachers Usr_GetListUsrs (Gbl.Scope.Current,Rol_TCH); // Teachers - if (Gbl.Scope.Current == Hie_CRS) + if (Gbl.Scope.Current == Hie_Lvl_CRS) NumUsrs = Gbl.Usrs.LstUsrs[Rol_NET].NumUsrs + Gbl.Usrs.LstUsrs[Rol_TCH].NumUsrs; else NumUsrs = Usr_GetNumUsrsInCrss (Gbl.Scope.Current, - (Gbl.Scope.Current == Hie_CTY ? Gbl.Hierarchy.Cty.CtyCod : - (Gbl.Scope.Current == Hie_INS ? Gbl.Hierarchy.Ins.InsCod : - (Gbl.Scope.Current == Hie_CTR ? Gbl.Hierarchy.Ctr.CtrCod : - (Gbl.Scope.Current == Hie_DEG ? Gbl.Hierarchy.Deg.DegCod : - (Gbl.Scope.Current == Hie_CRS ? Gbl.Hierarchy.Crs.CrsCod : + (Gbl.Scope.Current == Hie_Lvl_CTY ? Gbl.Hierarchy.Cty.CtyCod : + (Gbl.Scope.Current == Hie_Lvl_INS ? Gbl.Hierarchy.Ins.InsCod : + (Gbl.Scope.Current == Hie_Lvl_CTR ? Gbl.Hierarchy.Ctr.CtrCod : + (Gbl.Scope.Current == Hie_Lvl_DEG ? Gbl.Hierarchy.Deg.DegCod : + (Gbl.Scope.Current == Hie_Lvl_CRS ? Gbl.Hierarchy.Crs.CrsCod : -1L))))), 1 << Rol_NET | 1 << Rol_TCH); @@ -8993,15 +8993,15 @@ void Usr_SeeTchClassPhotoPrn (void) { /***** Draw the teachers' class photo *****/ Lay_WriteHeaderClassPhoto (true,true, - (Gbl.Scope.Current == Hie_CRS || - Gbl.Scope.Current == Hie_DEG || - Gbl.Scope.Current == Hie_CTR || - Gbl.Scope.Current == Hie_INS) ? Gbl.Hierarchy.Ins.InsCod : + (Gbl.Scope.Current == Hie_Lvl_CRS || + Gbl.Scope.Current == Hie_Lvl_DEG || + Gbl.Scope.Current == Hie_Lvl_CTR || + Gbl.Scope.Current == Hie_Lvl_INS) ? Gbl.Hierarchy.Ins.InsCod : -1L, - (Gbl.Scope.Current == Hie_CRS || - Gbl.Scope.Current == Hie_DEG) ? Gbl.Hierarchy.Deg.DegCod : + (Gbl.Scope.Current == Hie_Lvl_CRS || + Gbl.Scope.Current == Hie_Lvl_DEG) ? Gbl.Hierarchy.Deg.DegCod : -1L, - Gbl.Scope.Current == Hie_CRS ? Gbl.Hierarchy.Crs.CrsCod : + Gbl.Scope.Current == Hie_Lvl_CRS ? Gbl.Hierarchy.Crs.CrsCod : -1L); HTM_TABLE_BeginWide (); @@ -9233,7 +9233,7 @@ void Usr_ShowWarningNoUsersFound (Rol_Role_t Role) else if (Gbl.Usrs.ClassPhoto.AllGroups && // All groups selected Role == Rol_TCH && // No teachers found - Gbl.Hierarchy.Level == Hie_CRS && // Course selected + Gbl.Hierarchy.Level == Hie_Lvl_CRS && // Course selected Gbl.Usrs.Me.Role.Logged >= Rol_DEG_ADM) // I am an administrator /***** Show alert and button to enrol students *****/ Ale_ShowAlertAndButton (ActReqMdfOneTch,NULL,NULL, @@ -9263,7 +9263,7 @@ unsigned Usr_GetTotalNumberOfUsersInPlatform (void) #define Usr_MAX_BYTES_SUBQUERY_ROLES (Rol_NUM_ROLES * (10 + 1) - 1) -unsigned Usr_GetNumUsrsInCrss (Hie_Level_t Scope,long Cod,unsigned Roles) +unsigned Usr_GetNumUsrsInCrss (Hie_Lvl_Level_t Scope,long Cod,unsigned Roles) { char UnsignedStr[Cns_MAX_DECIMAL_DIGITS_UINT + 1]; char SubQueryRoles[Usr_MAX_BYTES_SUBQUERY_ROLES + 1]; @@ -9342,7 +9342,7 @@ unsigned Usr_GetNumUsrsInCrss (Hie_Level_t Scope,long Cod,unsigned Roles) /***** Get number of users from database *****/ switch (Scope) { - case Hie_SYS: + case Hie_Lvl_SYS: if (AnyUserInCourses) // Any user NumUsrs = (unsigned) DB_QueryCOUNT ("can not get number of users", @@ -9355,7 +9355,7 @@ unsigned Usr_GetNumUsrsInCrss (Hie_Level_t Scope,long Cod,unsigned Roles) " FROM crs_usr WHERE Role%s", SubQueryRoles); break; - case Hie_CTY: + case Hie_Lvl_CTY: if (AnyUserInCourses) // Any user NumUsrs = (unsigned) DB_QueryCOUNT ("can not get number of users", @@ -9380,7 +9380,7 @@ unsigned Usr_GetNumUsrsInCrss (Hie_Level_t Scope,long Cod,unsigned Roles) " AND crs_usr.Role%s", Cod,SubQueryRoles); break; - case Hie_INS: + case Hie_Lvl_INS: if (AnyUserInCourses) // Any user NumUsrs = (unsigned) DB_QueryCOUNT ("can not get number of users", @@ -9403,7 +9403,7 @@ unsigned Usr_GetNumUsrsInCrss (Hie_Level_t Scope,long Cod,unsigned Roles) " AND crs_usr.Role%s", Cod,SubQueryRoles); break; - case Hie_CTR: + case Hie_Lvl_CTR: if (AnyUserInCourses) // Any user NumUsrs = (unsigned) DB_QueryCOUNT ("can not get number of users", @@ -9424,7 +9424,7 @@ unsigned Usr_GetNumUsrsInCrss (Hie_Level_t Scope,long Cod,unsigned Roles) " AND crs_usr.Role%s", Cod,SubQueryRoles); break; - case Hie_DEG: + case Hie_Lvl_DEG: if (AnyUserInCourses) // Any user NumUsrs = (unsigned) DB_QueryCOUNT ("can not get number of users", @@ -9443,7 +9443,7 @@ unsigned Usr_GetNumUsrsInCrss (Hie_Level_t Scope,long Cod,unsigned Roles) " AND crs_usr.Role%s", Cod,SubQueryRoles); break; - case Hie_CRS: + case Hie_Lvl_CRS: if (AnyUserInCourses) // Any user NumUsrs = (unsigned) DB_QueryCOUNT ("can not get number of users", @@ -9470,7 +9470,7 @@ unsigned Usr_GetNumUsrsInCrss (Hie_Level_t Scope,long Cod,unsigned Roles) return NumUsrs; } -unsigned Usr_GetCachedNumUsrsInCrss (Hie_Level_t Scope,long Cod,unsigned Roles) +unsigned Usr_GetCachedNumUsrsInCrss (Hie_Lvl_Level_t Scope,long Cod,unsigned Roles) { unsigned NumUsrsInCrss; @@ -9515,7 +9515,7 @@ unsigned Usr_GetCachedNumUsrsNotBelongingToAnyCrs (void) unsigned NumGsts; /***** Get number of guests from cache *****/ - if (!FigCch_GetFigureFromCache (FigCch_NUM_GSTS,Hie_SYS,-1L, + if (!FigCch_GetFigureFromCache (FigCch_NUM_GSTS,Hie_Lvl_SYS,-1L, FigCch_UNSIGNED,&NumGsts)) { /***** Get current number of guests from database and update cache *****/ @@ -9524,7 +9524,7 @@ unsigned Usr_GetCachedNumUsrsNotBelongingToAnyCrs (void) " who do not belong to any course", "SELECT COUNT(*) FROM usr_data WHERE UsrCod NOT IN" " (SELECT DISTINCT(UsrCod) FROM crs_usr)"); - FigCch_UpdateFigureIntoCache (FigCch_NUM_GSTS,Hie_SYS,-1L, + FigCch_UpdateFigureIntoCache (FigCch_NUM_GSTS,Hie_Lvl_SYS,-1L, FigCch_UNSIGNED,&NumGsts); } @@ -9535,7 +9535,7 @@ unsigned Usr_GetCachedNumUsrsNotBelongingToAnyCrs (void) /************ Get average number of courses with users of a role *************/ /*****************************************************************************/ -static double Usr_GetNumCrssPerUsr (Hie_Level_t Scope,long Cod,Rol_Role_t Role) +static double Usr_GetNumCrssPerUsr (Hie_Lvl_Level_t Scope,long Cod,Rol_Role_t Role) { MYSQL_RES *mysql_res; MYSQL_ROW row; @@ -9544,7 +9544,7 @@ static double Usr_GetNumCrssPerUsr (Hie_Level_t Scope,long Cod,Rol_Role_t Role) /***** Get number of courses per user from database *****/ switch (Scope) { - case Hie_SYS: + case Hie_Lvl_SYS: if (Role == Rol_UNK) // Any user DB_QuerySELECT (&mysql_res,"can not get number of courses per user", "SELECT AVG(NumCrss) FROM " @@ -9559,7 +9559,7 @@ static double Usr_GetNumCrssPerUsr (Hie_Level_t Scope,long Cod,Rol_Role_t Role) " WHERE Role=%u GROUP BY UsrCod) AS NumCrssTable", (unsigned) Role); break; - case Hie_CTY: + case Hie_Lvl_CTY: if (Role == Rol_UNK) // Any user DB_QuerySELECT (&mysql_res,"can not get number of courses per user", "SELECT AVG(NumCrss) FROM " @@ -9587,7 +9587,7 @@ static double Usr_GetNumCrssPerUsr (Hie_Level_t Scope,long Cod,Rol_Role_t Role) Cod, (unsigned) Role); break; - case Hie_INS: + case Hie_Lvl_INS: if (Role == Rol_UNK) // Any user DB_QuerySELECT (&mysql_res,"can not get number of courses per user", "SELECT AVG(NumCrss) FROM " @@ -9613,7 +9613,7 @@ static double Usr_GetNumCrssPerUsr (Hie_Level_t Scope,long Cod,Rol_Role_t Role) Cod, (unsigned) Role); break; - case Hie_CTR: + case Hie_Lvl_CTR: if (Role == Rol_UNK) // Any user DB_QuerySELECT (&mysql_res,"can not get number of courses per user", "SELECT AVG(NumCrss) FROM " @@ -9637,7 +9637,7 @@ static double Usr_GetNumCrssPerUsr (Hie_Level_t Scope,long Cod,Rol_Role_t Role) Cod, (unsigned) Role); break; - case Hie_DEG: + case Hie_Lvl_DEG: if (Role == Rol_UNK) // Any user DB_QuerySELECT (&mysql_res,"can not get number of courses per user", "SELECT AVG(NumCrss) FROM " @@ -9659,7 +9659,7 @@ static double Usr_GetNumCrssPerUsr (Hie_Level_t Scope,long Cod,Rol_Role_t Role) Cod, (unsigned) Role); break; - case Hie_CRS: + case Hie_Lvl_CRS: return 1.0; default: Lay_WrongScopeExit (); @@ -9676,7 +9676,7 @@ static double Usr_GetNumCrssPerUsr (Hie_Level_t Scope,long Cod,Rol_Role_t Role) return NumCrssPerUsr; } -double Usr_GetCachedNumCrssPerUsr (Hie_Level_t Scope,long Cod,Rol_Role_t Role) +double Usr_GetCachedNumCrssPerUsr (Hie_Lvl_Level_t Scope,long Cod,Rol_Role_t Role) { static const FigCch_FigureCached_t FigureNumCrssPerUsr[Rol_NUM_ROLES] = { @@ -9704,7 +9704,7 @@ double Usr_GetCachedNumCrssPerUsr (Hie_Level_t Scope,long Cod,Rol_Role_t Role) /************ Get average number of courses with users of a type *************/ /*****************************************************************************/ -static double Usr_GetNumUsrsPerCrs (Hie_Level_t Scope,long Cod,Rol_Role_t Role) +static double Usr_GetNumUsrsPerCrs (Hie_Lvl_Level_t Scope,long Cod,Rol_Role_t Role) { MYSQL_RES *mysql_res; MYSQL_ROW row; @@ -9713,7 +9713,7 @@ static double Usr_GetNumUsrsPerCrs (Hie_Level_t Scope,long Cod,Rol_Role_t Role) /***** Get number of users per course from database *****/ switch (Scope) { - case Hie_SYS: + case Hie_Lvl_SYS: if (Role == Rol_UNK) // Any user DB_QuerySELECT (&mysql_res,"can not get number of users per course", "SELECT AVG(NumUsrs) FROM " @@ -9728,7 +9728,7 @@ static double Usr_GetNumUsrsPerCrs (Hie_Level_t Scope,long Cod,Rol_Role_t Role) " WHERE Role=%u GROUP BY CrsCod) AS NumUsrsTable", (unsigned) Role); break; - case Hie_CTY: + case Hie_Lvl_CTY: if (Role == Rol_UNK) // Any user DB_QuerySELECT (&mysql_res,"can not get number of users per course", "SELECT AVG(NumUsrs) FROM " @@ -9756,7 +9756,7 @@ static double Usr_GetNumUsrsPerCrs (Hie_Level_t Scope,long Cod,Rol_Role_t Role) Cod, (unsigned) Role); break; - case Hie_INS: + case Hie_Lvl_INS: if (Role == Rol_UNK) // Any user DB_QuerySELECT (&mysql_res,"can not get number of users per course", "SELECT AVG(NumUsrs) FROM " @@ -9782,7 +9782,7 @@ static double Usr_GetNumUsrsPerCrs (Hie_Level_t Scope,long Cod,Rol_Role_t Role) Cod, (unsigned) Role); break; - case Hie_CTR: + case Hie_Lvl_CTR: if (Role == Rol_UNK) // Any user DB_QuerySELECT (&mysql_res,"can not get number of users per course", "SELECT AVG(NumUsrs) FROM " @@ -9806,7 +9806,7 @@ static double Usr_GetNumUsrsPerCrs (Hie_Level_t Scope,long Cod,Rol_Role_t Role) Cod, (unsigned) Role); break; - case Hie_DEG: + case Hie_Lvl_DEG: if (Role == Rol_UNK) // Any user DB_QuerySELECT (&mysql_res,"can not get number of users per course", "SELECT AVG(NumUsrs) FROM " @@ -9828,8 +9828,8 @@ static double Usr_GetNumUsrsPerCrs (Hie_Level_t Scope,long Cod,Rol_Role_t Role) Cod, (unsigned) Role); break; - case Hie_CRS: - return (double) Usr_GetNumUsrsInCrss (Hie_CRS,Cod, + case Hie_Lvl_CRS: + return (double) Usr_GetNumUsrsInCrss (Hie_Lvl_CRS,Cod, Role == Rol_UNK ? 1 << Rol_STD | 1 << Rol_NET | 1 << Rol_TCH : // Any user @@ -9850,7 +9850,7 @@ static double Usr_GetNumUsrsPerCrs (Hie_Level_t Scope,long Cod,Rol_Role_t Role) return NumUsrsPerCrs; } -double Usr_GetCachedNumUsrsPerCrs (Hie_Level_t Scope,long Cod,Rol_Role_t Role) +double Usr_GetCachedNumUsrsPerCrs (Hie_Lvl_Level_t Scope,long Cod,Rol_Role_t Role) { static const FigCch_FigureCached_t FigureNumUsrsPerCrs[Rol_NUM_ROLES] = { diff --git a/swad_user.h b/swad_user.h index d49f2cff..5d7b4564 100644 --- a/swad_user.h +++ b/swad_user.h @@ -228,7 +228,7 @@ struct UsrLast Sch_WhatToSearch_t WhatToSearch; // Search courses, teachers, documents...? struct { - Hie_Level_t Scope; // Course, degree, centre, etc. + Hie_Lvl_Level_t Scope; // Course, degree, centre, etc. long Cod; // Course code, degree code, centre code, etc. } LastHie; Act_Action_t LastAct; @@ -298,7 +298,7 @@ void Usr_WriteFirstNameBRSurnames (const struct UsrData *UsrDat); void Usr_FlushCachesUsr (void); -bool Usr_CheckIfUsrIsAdm (long UsrCod,Hie_Level_t Scope,long Cod); +bool Usr_CheckIfUsrIsAdm (long UsrCod,Hie_Lvl_Level_t Scope,long Cod); void Usr_FlushCacheUsrIsSuperuser (void); bool Usr_CheckIfUsrIsSuperuser (long UsrCod); @@ -363,7 +363,7 @@ unsigned long Usr_GetCtrsFromUsr (long UsrCod,long InsCod,MYSQL_RES **mysql_res) unsigned long Usr_GetDegsFromUsr (long UsrCod,long CtrCod,MYSQL_RES **mysql_res); unsigned long Usr_GetCrssFromUsr (long UsrCod,long DegCod,MYSQL_RES **mysql_res); void Usr_GetMainDeg (long UsrCod, - char ShrtName[Hie_MAX_BYTES_SHRT_NAME + 1], + char ShrtName[Cns_HIERARCHY_MAX_BYTES_SHRT_NAME + 1], Rol_Role_t *MaxRole); bool Usr_ChkIfEncryptedUsrCodExists (const char EncryptedUsrCod[Cry_BYTES_ENCRYPTED_STR_SHA256_BASE64]); @@ -417,8 +417,8 @@ unsigned Usr_GetNumUsrsWhoClaimToBelongToAnotherCty (void); unsigned Usr_GetCachedNumUsrsWhoClaimToBelongToAnotherCty (void); void Usr_FlushCacheNumUsrsWhoClaimToBelongToCty (void); -unsigned Usr_GetNumUsrsWhoClaimToBelongToCty (struct Country *Cty); -unsigned Usr_GetCachedNumUsrsWhoClaimToBelongToCty (struct Country *Cty); +unsigned Usr_GetNumUsrsWhoClaimToBelongToCty (struct Cty_Countr *Cty); +unsigned Usr_GetCachedNumUsrsWhoClaimToBelongToCty (struct Cty_Countr *Cty); void Usr_FlushCacheNumUsrsWhoClaimToBelongToIns (void); unsigned Usr_GetNumUsrsWhoClaimToBelongToIns (struct Ins_Instit *Ins); @@ -428,7 +428,7 @@ void Usr_FlushCacheNumUsrsWhoClaimToBelongToCtr (void); unsigned Usr_GetNumUsrsWhoClaimToBelongToCtr (struct Ctr_Centre *Ctr); unsigned Usr_GetCachedNumUsrsWhoClaimToBelongToCtr (struct Ctr_Centre *Ctr); -void Usr_GetListUsrs (Hie_Level_t Scope,Rol_Role_t Role); +void Usr_GetListUsrs (Hie_Lvl_Level_t Scope,Rol_Role_t Role); void Usr_SearchListUsrs (Rol_Role_t Role); void Usr_CreateTmpTableAndSearchCandidateUsrs (const char SearchQuery[Sch_MAX_BYTES_SEARCH_QUERY + 1]); @@ -517,13 +517,13 @@ bool Usr_ChkIfUsrCodExists (long UsrCod); void Usr_ShowWarningNoUsersFound (Rol_Role_t Role); unsigned Usr_GetTotalNumberOfUsersInPlatform (void); -unsigned Usr_GetNumUsrsInCrss (Hie_Level_t Scope,long Cod,unsigned Roles); -unsigned Usr_GetCachedNumUsrsInCrss (Hie_Level_t Scope,long Cod,unsigned Roles); +unsigned Usr_GetNumUsrsInCrss (Hie_Lvl_Level_t Scope,long Cod,unsigned Roles); +unsigned Usr_GetCachedNumUsrsInCrss (Hie_Lvl_Level_t Scope,long Cod,unsigned Roles); unsigned Usr_GetCachedNumUsrsNotBelongingToAnyCrs (void); -double Usr_GetCachedNumCrssPerUsr (Hie_Level_t Scope,long Cod,Rol_Role_t Role); -double Usr_GetCachedNumUsrsPerCrs (Hie_Level_t Scope,long Cod,Rol_Role_t Role); +double Usr_GetCachedNumCrssPerUsr (Hie_Lvl_Level_t Scope,long Cod,Rol_Role_t Role); +double Usr_GetCachedNumUsrsPerCrs (Hie_Lvl_Level_t Scope,long Cod,Rol_Role_t Role); bool Usr_CheckIfUsrBanned (long UsrCod); void Usr_RemoveUsrFromUsrBanned (long UsrCod);