diff --git a/css/swad22.120.css b/css/swad22.120.4.css similarity index 99% rename from css/swad22.120.css rename to css/swad22.120.4.css index e48cd9b2..018ff581 100644 --- a/css/swad22.120.css +++ b/css/swad22.120.4.css @@ -1252,7 +1252,7 @@ a:hover /* Default ==> underlined */ .MENU_TXT_DARK {color:#d0d0d0;} /***************************** Users connected *******************************/ -#courseconnected +#globalconnected, #courseconnected { box-sizing:border-box; width:136px; diff --git a/swad_HTML.c b/swad_HTML.c index 3a4a40d6..b815b998 100644 --- a/swad_HTML.c +++ b/swad_HTML.c @@ -35,12 +35,6 @@ #include "swad_global.h" #include "swad_HTML.h" -/*****************************************************************************/ -/************** External global variables from others modules ****************/ -/*****************************************************************************/ - -extern struct Globals Gbl; - /*****************************************************************************/ /**************************** Private constants ******************************/ /*****************************************************************************/ diff --git a/swad_RSS.c b/swad_RSS.c index 44c578ef..e1394be9 100644 --- a/swad_RSS.c +++ b/swad_RSS.c @@ -39,12 +39,6 @@ #include "swad_notice_database.h" #include "swad_RSS.h" -/*****************************************************************************/ -/*************** External global variables from others modules ***************/ -/*****************************************************************************/ - -extern struct Globals Gbl; - /*****************************************************************************/ /***************************** Private prototypes ****************************/ /*****************************************************************************/ diff --git a/swad_account.c b/swad_account.c index f3987db8..1b650bfe 100644 --- a/swad_account.c +++ b/swad_account.c @@ -113,7 +113,7 @@ void Acc_PutLinkToCreateAccount (void) extern const char *Txt_Actions[ActLst_NUM_ACTIONS]; Lay_PutContextualLinkIconText (ActFrmMyAcc,NULL, - NULL,NULL, + NULL,NULL, "at.svg",Ico_BLACK, Txt_Actions[ActCreUsrAcc],NULL); } diff --git a/swad_admin.c b/swad_admin.c index 3b019ca9..a6416245 100644 --- a/swad_admin.c +++ b/swad_admin.c @@ -58,21 +58,21 @@ extern struct Globals Gbl; /***************************** Private prototypes ****************************/ /*****************************************************************************/ -static void Adm_ReqAddAdm (HieLvl_Level_t Scope,long Cod, +static void Adm_ReqAddAdm (HieLvl_Level_t Level,long Cod, const char *InsCtrDegName); -static void Enr_AddAdm (HieLvl_Level_t Scope,long Cod, +static void Adm_AddAdm (HieLvl_Level_t Level,long Cod, const char *InsCtrDegName); static void Adm_RegisterAdmin (struct Usr_Data *UsrDat, - HieLvl_Level_t Scope,long Cod, + HieLvl_Level_t Level,long Cod, const char *InsCtrDegName); static void Adm_ReqRemOrRemAdm (Enr_ReqDelOrDelUsr_t ReqDelOrDelUsr, - HieLvl_Level_t Scope,long Cod, + HieLvl_Level_t Level,long Cod, const char *InsCtrDegName); -static void Adm_AskIfRemAdm (Usr_MeOrOther_t MeOrOther,HieLvl_Level_t Scope, +static void Adm_AskIfRemAdm (Usr_MeOrOther_t MeOrOther,HieLvl_Level_t Level, const char *InsCtrDegName); static void Adm_EffectivelyRemAdm (struct Usr_Data *UsrDat, - HieLvl_Level_t Scope,long Cod, + HieLvl_Level_t Level,long Cod, const char *InsCtrDegName); /*****************************************************************************/ @@ -106,7 +106,7 @@ void Adm_ReqAddAdmOfDeg (void) /**** Ask if really wanted to add an administrator to current institution ****/ /*****************************************************************************/ -static void Adm_ReqAddAdm (HieLvl_Level_t Scope,long Cod, +static void Adm_ReqAddAdm (HieLvl_Level_t Level,long Cod, const char *InsCtrDegName) { extern const char *Txt_THE_USER_X_is_already_an_administrator_of_Y; @@ -130,12 +130,12 @@ static void Adm_ReqAddAdm (HieLvl_Level_t Scope,long Cod, if (Usr_GetParOtherUsrCodEncryptedAndGetUsrData ()) { /* Check if I am allowed to register user as administrator in institution/center/degree */ - ICanRegister = ((Scope == HieLvl_DEG && Gbl.Usrs.Me.Role.Logged >= Rol_CTR_ADM) || - (Scope == HieLvl_CTR && Gbl.Usrs.Me.Role.Logged >= Rol_INS_ADM) || - (Scope == HieLvl_INS && Gbl.Usrs.Me.Role.Logged == Rol_SYS_ADM)); + ICanRegister = ((Level == HieLvl_DEG && Gbl.Usrs.Me.Role.Logged >= Rol_CTR_ADM) || + (Level == HieLvl_CTR && Gbl.Usrs.Me.Role.Logged >= Rol_INS_ADM) || + (Level == HieLvl_INS && Gbl.Usrs.Me.Role.Logged == Rol_SYS_ADM)); if (ICanRegister) { - if (Adm_DB_CheckIfUsrIsAdm (Gbl.Usrs.Other.UsrDat.UsrCod,Scope,Cod)) // User is already an administrator of current institution/center/degree + if (Adm_DB_CheckIfUsrIsAdm (Gbl.Usrs.Other.UsrDat.UsrCod,Level,Cod)) // User is already an administrator of current institution/center/degree { Ale_ShowAlert (Ale_INFO,Txt_THE_USER_X_is_already_an_administrator_of_Y, Gbl.Usrs.Other.UsrDat.FullName,InsCtrDegName); @@ -152,7 +152,7 @@ static void Adm_ReqAddAdm (HieLvl_Level_t Scope,long Cod, Rec_ShowSharedRecordUnmodifiable (&Gbl.Usrs.Other.UsrDat); /* End alert */ - Ale_ShowAlertAndButton2 (Enr_ActNewAdm[Scope],NULL,NULL, + Ale_ShowAlertAndButton2 (Enr_ActNewAdm[Level],NULL,NULL, Usr_PutParOtherUsrCodEncrypted,Gbl.Usrs.Other.UsrDat.EnUsrCod, Btn_CREATE_BUTTON,Txt_Register_user_IN_A_COURSE_OR_DEGREE); } @@ -171,7 +171,7 @@ static void Adm_ReqAddAdm (HieLvl_Level_t Scope,long Cod, void Adm_AddAdmToIns (void) { - Enr_AddAdm (HieLvl_INS,Gbl.Hierarchy.Ins.InsCod,Gbl.Hierarchy.Ins.FullName); + Adm_AddAdm (HieLvl_INS,Gbl.Hierarchy.Ins.InsCod,Gbl.Hierarchy.Ins.FullName); } /*****************************************************************************/ @@ -180,7 +180,7 @@ void Adm_AddAdmToIns (void) void Adm_AddAdmToCtr (void) { - Enr_AddAdm (HieLvl_CTR,Gbl.Hierarchy.Ctr.CtrCod,Gbl.Hierarchy.Ctr.FullName); + Adm_AddAdm (HieLvl_CTR,Gbl.Hierarchy.Ctr.CtrCod,Gbl.Hierarchy.Ctr.FullName); } /*****************************************************************************/ @@ -189,32 +189,32 @@ void Adm_AddAdmToCtr (void) void Adm_AddAdmToDeg (void) { - Enr_AddAdm (HieLvl_DEG,Gbl.Hierarchy.Deg.DegCod,Gbl.Hierarchy.Deg.FullName); + Adm_AddAdm (HieLvl_DEG,Gbl.Hierarchy.Deg.DegCod,Gbl.Hierarchy.Deg.FullName); } /*****************************************************************************/ /******************** Get list with data of administrators *******************/ /*****************************************************************************/ -void Adm_GetAdmsLst (HieLvl_Level_t Scope) +void Adm_GetAdmsLst (HieLvl_Level_t Level) { char *Query = NULL; /***** Build query *****/ - Usr_DB_BuildQueryToGetAdmsLst (Scope,&Query); + Usr_DB_BuildQueryToGetAdmsLst (Level,&Query); /***** Get list of administrators from database *****/ - Usr_GetListUsrsFromQuery (Query,Rol_DEG_ADM,Scope); + Usr_GetListUsrsFromQuery (Query,Rol_DEG_ADM,Level); /***** Free query string *****/ free (Query); } /*****************************************************************************/ -/******************* Add an administrator to current degree ******************/ +/******************* Add an administrator in a given level *******************/ /*****************************************************************************/ -static void Enr_AddAdm (HieLvl_Level_t Scope,long Cod, +static void Adm_AddAdm (HieLvl_Level_t Level,long Cod, const char *InsCtrDegName) { bool ICanRegister; @@ -225,13 +225,13 @@ static void Enr_AddAdm (HieLvl_Level_t Scope,long Cod, if (Usr_GetParOtherUsrCodEncryptedAndGetUsrData ()) { /* Check if I am allowed to register user as administrator in institution/center/degree */ - ICanRegister = ((Scope == HieLvl_DEG && Gbl.Usrs.Me.Role.Logged >= Rol_CTR_ADM) || - (Scope == HieLvl_CTR && Gbl.Usrs.Me.Role.Logged >= Rol_INS_ADM) || - (Scope == HieLvl_INS && Gbl.Usrs.Me.Role.Logged == Rol_SYS_ADM)); + ICanRegister = ((Level == HieLvl_DEG && Gbl.Usrs.Me.Role.Logged >= Rol_CTR_ADM) || + (Level == HieLvl_CTR && Gbl.Usrs.Me.Role.Logged >= Rol_INS_ADM) || + (Level == HieLvl_INS && Gbl.Usrs.Me.Role.Logged == Rol_SYS_ADM)); if (ICanRegister) { /***** Register administrator in current institution/center/degree in database *****/ - Adm_RegisterAdmin (&Gbl.Usrs.Other.UsrDat,Scope, + Adm_RegisterAdmin (&Gbl.Usrs.Other.UsrDat,Level, Cod,InsCtrDegName); /***** Show user's record *****/ @@ -250,20 +250,20 @@ static void Enr_AddAdm (HieLvl_Level_t Scope,long Cod, /*****************************************************************************/ static void Adm_RegisterAdmin (struct Usr_Data *UsrDat, - HieLvl_Level_t Scope,long Cod, + HieLvl_Level_t Level,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; /***** Check if user was and administrator of current institution/center/degree *****/ - if (Adm_DB_CheckIfUsrIsAdm (UsrDat->UsrCod,Scope,Cod)) + if (Adm_DB_CheckIfUsrIsAdm (UsrDat->UsrCod,Level,Cod)) Ale_ShowAlert (Ale_SUCCESS,Txt_THE_USER_X_is_already_an_administrator_of_Y, UsrDat->FullName,InsCtrDegName); else // User was not administrator of current institution/center/degree { /***** Insert or replace administrator in current institution/center/degree *****/ - Adm_DB_InsertAdmin (UsrDat->UsrCod,Scope,Cod); + Adm_DB_InsertAdmin (UsrDat->UsrCod,Level,Cod); Ale_ShowAlert (Ale_SUCCESS,Txt_THE_USER_X_has_been_enroled_as_administrator_of_Y, UsrDat->FullName,InsCtrDegName); @@ -335,7 +335,7 @@ void Adm_RemAdmDeg (void) /*****************************************************************************/ static void Adm_ReqRemOrRemAdm (Enr_ReqDelOrDelUsr_t ReqDelOrDelUsr, - HieLvl_Level_t Scope,long Cod, + HieLvl_Level_t Level,long Cod, const char *InsCtrDegName) { extern const char *Txt_THE_USER_X_is_not_an_administrator_of_Y; @@ -350,21 +350,21 @@ static void Adm_ReqRemOrRemAdm (Enr_ReqDelOrDelUsr_t ReqDelOrDelUsr, /* Check if it's forbidden to remove an administrator */ MeOrOther = Usr_ItsMe (Gbl.Usrs.Other.UsrDat.UsrCod); ICanRemove = (MeOrOther == Usr_ME || - (Scope == HieLvl_DEG && Gbl.Usrs.Me.Role.Logged >= Rol_CTR_ADM) || - (Scope == HieLvl_CTR && Gbl.Usrs.Me.Role.Logged >= Rol_INS_ADM) || - (Scope == HieLvl_INS && Gbl.Usrs.Me.Role.Logged == Rol_SYS_ADM)); + (Level == HieLvl_DEG && Gbl.Usrs.Me.Role.Logged >= Rol_CTR_ADM) || + (Level == HieLvl_CTR && Gbl.Usrs.Me.Role.Logged >= Rol_INS_ADM) || + (Level == HieLvl_INS && Gbl.Usrs.Me.Role.Logged == Rol_SYS_ADM)); if (ICanRemove) { /* Check if the other user is an admin of the current institution/center/degree */ - if (Adm_DB_CheckIfUsrIsAdm (Gbl.Usrs.Other.UsrDat.UsrCod,Scope,Cod)) + if (Adm_DB_CheckIfUsrIsAdm (Gbl.Usrs.Other.UsrDat.UsrCod,Level,Cod)) { // The other user is an administrator of current institution/center/degree ==> ask for removing or remove her/him switch (ReqDelOrDelUsr) { case Enr_REQUEST_REMOVE_USR: // Ask if remove administrator from current institution - Adm_AskIfRemAdm (MeOrOther,Scope,InsCtrDegName); + Adm_AskIfRemAdm (MeOrOther,Level,InsCtrDegName); break; case Enr_REMOVE_USR: // Remove administrator from current institution - Adm_EffectivelyRemAdm (&Gbl.Usrs.Other.UsrDat,Scope, + Adm_EffectivelyRemAdm (&Gbl.Usrs.Other.UsrDat,Level, Cod,InsCtrDegName); break; } @@ -385,7 +385,7 @@ static void Adm_ReqRemOrRemAdm (Enr_ReqDelOrDelUsr_t ReqDelOrDelUsr, /** Ask if really wanted to remove an administrator from current institution */ /*****************************************************************************/ -static void Adm_AskIfRemAdm (Usr_MeOrOther_t MeOrOther,HieLvl_Level_t Scope, +static void Adm_AskIfRemAdm (Usr_MeOrOther_t MeOrOther,HieLvl_Level_t Level, const char *InsCtrDegName) { extern const char *Txt_Do_you_really_want_to_be_removed_as_an_administrator_of_X; @@ -423,7 +423,7 @@ static void Adm_AskIfRemAdm (Usr_MeOrOther_t MeOrOther,HieLvl_Level_t Scope, Rec_ShowSharedRecordUnmodifiable (&Gbl.Usrs.Other.UsrDat); /* End alert */ - Ale_ShowAlertAndButton2 (ActRemAdm[Scope],NULL,NULL, + Ale_ShowAlertAndButton2 (ActRemAdm[Level],NULL,NULL, Usr_PutParOtherUsrCodEncrypted,Gbl.Usrs.Other.UsrDat.EnUsrCod, Btn_REMOVE_BUTTON,TxtButton[MeOrOther]); } @@ -436,16 +436,16 @@ static void Adm_AskIfRemAdm (Usr_MeOrOther_t MeOrOther,HieLvl_Level_t Scope, /*****************************************************************************/ static void Adm_EffectivelyRemAdm (struct Usr_Data *UsrDat, - HieLvl_Level_t Scope,long Cod, + HieLvl_Level_t Level,long Cod, const char *InsCtrDegName) { extern const char *Txt_THE_USER_X_has_been_removed_as_administrator_of_Y; extern const char *Txt_THE_USER_X_is_not_an_administrator_of_Y; - if (Adm_DB_CheckIfUsrIsAdm (UsrDat->UsrCod,Scope,Cod)) // User is administrator of current institution/center/degree + if (Adm_DB_CheckIfUsrIsAdm (UsrDat->UsrCod,Level,Cod)) // User is administrator of current institution/center/degree { /***** Remove user as administrator of institution, center or degree *****/ - Adm_DB_RemAdmin (UsrDat->UsrCod,Scope,Cod); + Adm_DB_RemAdmin (UsrDat->UsrCod,Level,Cod); Ale_ShowAlert (Ale_SUCCESS,Txt_THE_USER_X_has_been_removed_as_administrator_of_Y, UsrDat->FullName,InsCtrDegName); diff --git a/swad_admin.h b/swad_admin.h index 2490ef6a..957feb25 100644 --- a/swad_admin.h +++ b/swad_admin.h @@ -43,7 +43,7 @@ void Adm_AddAdmToIns (void); void Adm_AddAdmToCtr (void); void Adm_AddAdmToDeg (void); -void Adm_GetAdmsLst (HieLvl_Level_t Scope); +void Adm_GetAdmsLst (HieLvl_Level_t Level); void Adm_ReqRemAdmOfIns (void); void Adm_ReqRemAdmOfCtr (void); diff --git a/swad_admin_database.c b/swad_admin_database.c index 03151add..c3115ad2 100644 --- a/swad_admin_database.c +++ b/swad_admin_database.c @@ -41,7 +41,7 @@ extern struct Globals Gbl; /** Insert/replace user as administrator of an institution, center or degree */ /*****************************************************************************/ -void Adm_DB_InsertAdmin (long UsrCod,HieLvl_Level_t Scope,long Cod) +void Adm_DB_InsertAdmin (long UsrCod,HieLvl_Level_t Level,long Cod) { DB_QueryREPLACE ("can not create administrator", "REPLACE INTO usr_admins" @@ -49,7 +49,7 @@ void Adm_DB_InsertAdmin (long UsrCod,HieLvl_Level_t Scope,long Cod) " VALUES" " (%ld,'%s',%ld)", UsrCod, - Sco_GetDBStrFromScope (Scope), + Hie_GetDBStrFromLevel (Level), Cod); } @@ -68,10 +68,10 @@ unsigned Adm_DB_GetAdmsCurrentScopeExceptMe (MYSQL_RES **mysql_res) " OR (Scope='%s' AND Cod=%ld)" " OR (Scope='%s' AND Cod=%ld))" " AND UsrCod<>%ld", - Sco_GetDBStrFromScope (HieLvl_SYS), - Sco_GetDBStrFromScope (HieLvl_INS),Gbl.Hierarchy.Ins.InsCod, - Sco_GetDBStrFromScope (HieLvl_CTR),Gbl.Hierarchy.Ctr.CtrCod, - Sco_GetDBStrFromScope (HieLvl_DEG),Gbl.Hierarchy.Deg.DegCod, + Hie_GetDBStrFromLevel (HieLvl_SYS), + Hie_GetDBStrFromLevel (HieLvl_INS),Gbl.Hierarchy.Ins.InsCod, + Hie_GetDBStrFromLevel (HieLvl_CTR),Gbl.Hierarchy.Ctr.CtrCod, + Hie_GetDBStrFromLevel (HieLvl_DEG),Gbl.Hierarchy.Deg.DegCod, Gbl.Usrs.Me.UsrDat.UsrCod); } @@ -79,7 +79,7 @@ unsigned Adm_DB_GetAdmsCurrentScopeExceptMe (MYSQL_RES **mysql_res) /***** Check if a user is an administrator of a degree/center/institution ****/ /*****************************************************************************/ -bool Adm_DB_CheckIfUsrIsAdm (long UsrCod,HieLvl_Level_t Scope,long Cod) +bool Adm_DB_CheckIfUsrIsAdm (long UsrCod,HieLvl_Level_t Level,long Cod) { return DB_QueryEXISTS ("can not check if a user is administrator", @@ -90,7 +90,7 @@ bool Adm_DB_CheckIfUsrIsAdm (long UsrCod,HieLvl_Level_t Scope,long Cod) " AND Scope='%s'" " AND Cod=%ld)", UsrCod, - Sco_GetDBStrFromScope (Scope), + Hie_GetDBStrFromLevel (Level), Cod); } @@ -108,14 +108,14 @@ bool Adm_DB_CheckIfUsrIsSuperuser (long UsrCod) " WHERE UsrCod=%ld" " AND Scope='%s')", UsrCod, - Sco_GetDBStrFromScope (HieLvl_SYS)); + Hie_GetDBStrFromLevel (HieLvl_SYS)); } /*****************************************************************************/ /***** Remove user as administrator of an institution, center or degree ******/ /*****************************************************************************/ -void Adm_DB_RemAdmin (long UsrCod,HieLvl_Level_t Scope,long Cod) +void Adm_DB_RemAdmin (long UsrCod,HieLvl_Level_t Level,long Cod) { DB_QueryDELETE ("can not remove an administrator", "DELETE FROM usr_admins" @@ -123,7 +123,7 @@ void Adm_DB_RemAdmin (long UsrCod,HieLvl_Level_t Scope,long Cod) " AND Scope='%s'" " AND Cod=%ld", UsrCod, - Sco_GetDBStrFromScope (Scope), + Hie_GetDBStrFromLevel (Level), Cod); } @@ -143,12 +143,12 @@ void Adm_DB_RemUsrAsAdmin (long UsrCod) /********* Remove administrators of an institution, center or degree *********/ /*****************************************************************************/ -void Adm_DB_RemAdmins (HieLvl_Level_t Scope,long Cod) +void Adm_DB_RemAdmins (HieLvl_Level_t Level,long Cod) { DB_QueryDELETE ("can not remove administrators", "DELETE FROM usr_admins" " WHERE Scope='%s'" " AND Cod=%ld", - Sco_GetDBStrFromScope (Scope), + Hie_GetDBStrFromLevel (Level), Cod); } diff --git a/swad_admin_database.h b/swad_admin_database.h index 237b920e..8466130c 100644 --- a/swad_admin_database.h +++ b/swad_admin_database.h @@ -33,14 +33,14 @@ /****************************** Public prototypes ****************************/ /*****************************************************************************/ -void Adm_DB_InsertAdmin (long UsrCod,HieLvl_Level_t Scope,long Cod); +void Adm_DB_InsertAdmin (long UsrCod,HieLvl_Level_t Level,long Cod); unsigned Adm_DB_GetAdmsCurrentScopeExceptMe (MYSQL_RES **mysql_res); -bool Adm_DB_CheckIfUsrIsAdm (long UsrCod,HieLvl_Level_t Scope,long Cod); +bool Adm_DB_CheckIfUsrIsAdm (long UsrCod,HieLvl_Level_t Level,long Cod); bool Adm_DB_CheckIfUsrIsSuperuser (long UsrCod); -void Adm_DB_RemAdmin (long UsrCod,HieLvl_Level_t Scope,long Cod); +void Adm_DB_RemAdmin (long UsrCod,HieLvl_Level_t Level,long Cod); void Adm_DB_RemUsrAsAdmin (long UsrCod); -void Adm_DB_RemAdmins (HieLvl_Level_t Scope,long Cod); +void Adm_DB_RemAdmins (HieLvl_Level_t Level,long Cod); #endif diff --git a/swad_agenda_database.c b/swad_agenda_database.c index 7d9337a1..b5f68879 100644 --- a/swad_agenda_database.c +++ b/swad_agenda_database.c @@ -343,12 +343,12 @@ unsigned Agd_DB_GetNumEventsFromUsr (long UsrCod) /*****************************************************************************/ /********************** Get number of users with events **********************/ /*****************************************************************************/ -// Returns the number of users with events in a given scope +// Returns the number of users with events in a given hierarchy level -unsigned Agd_DB_GetNumUsrsWithEvents (HieLvl_Level_t Scope) +unsigned Agd_DB_GetNumUsrsWithEvents (HieLvl_Level_t Level) { /***** Get number of users with events from database *****/ - switch (Scope) + switch (Level) { case HieLvl_SYS: return (unsigned) @@ -422,7 +422,7 @@ unsigned Agd_DB_GetNumUsrsWithEvents (HieLvl_Level_t Scope) " AND crs_users.UsrCod=agd_agendas.UsrCod", Gbl.Hierarchy.Crs.CrsCod); default: - Err_WrongScopeExit (); + Err_WrongHierarchyLevelExit (); return 0; // Not reached } } @@ -430,12 +430,12 @@ unsigned Agd_DB_GetNumUsrsWithEvents (HieLvl_Level_t Scope) /*****************************************************************************/ /*************************** Get number of events ****************************/ /*****************************************************************************/ -// Returns the number of events in a given scope +// Returns the number of events in a given hierarchy level -unsigned Agd_DB_GetNumEvents (HieLvl_Level_t Scope) +unsigned Agd_DB_GetNumEvents (HieLvl_Level_t Level) { /***** Get number of events from database *****/ - switch (Scope) + switch (Level) { case HieLvl_SYS: return (unsigned) @@ -517,7 +517,7 @@ unsigned Agd_DB_GetNumEvents (HieLvl_Level_t Scope) " AND crs_users.UsrCod=agd_agendas.UsrCod", Gbl.Hierarchy.Crs.CrsCod); default: - Err_WrongScopeExit (); + Err_WrongHierarchyLevelExit (); return 0; // Not reached } } diff --git a/swad_agenda_database.h b/swad_agenda_database.h index 1f25ca13..0c8878bd 100644 --- a/swad_agenda_database.h +++ b/swad_agenda_database.h @@ -56,8 +56,8 @@ void Agd_DB_RemoveUsrEvents (long UsrCod); unsigned Agd_DB_GetNumEventsFromUsr (long UsrCod); -unsigned Agd_DB_GetNumUsrsWithEvents (HieLvl_Level_t Scope); +unsigned Agd_DB_GetNumUsrsWithEvents (HieLvl_Level_t Level); -unsigned Agd_DB_GetNumEvents (HieLvl_Level_t Scope); +unsigned Agd_DB_GetNumEvents (HieLvl_Level_t Level); #endif diff --git a/swad_assignment.c b/swad_assignment.c index fff3a9a5..5d7b895b 100644 --- a/swad_assignment.c +++ b/swad_assignment.c @@ -1642,7 +1642,7 @@ static bool Asg_CheckIfIBelongToCrsOrGrpsThisAssignment (long AsgCod) // Returns the number of assignments // in this location (all the platform, the current degree or the current course) -unsigned Asg_GetNumAssignments (HieLvl_Level_t Scope,unsigned *NumNotif) +unsigned Asg_GetNumAssignments (HieLvl_Level_t Level,unsigned *NumNotif) { MYSQL_RES *mysql_res; MYSQL_ROW row; @@ -1653,7 +1653,7 @@ unsigned Asg_GetNumAssignments (HieLvl_Level_t Scope,unsigned *NumNotif) *NumNotif = 0; /***** Get number of assignments from database *****/ - if (Asg_DB_GetNumAssignments (&mysql_res,Scope)) + if (Asg_DB_GetNumAssignments (&mysql_res,Level)) { /***** Get number of assignments *****/ row = mysql_fetch_row (mysql_res); diff --git a/swad_assignment.h b/swad_assignment.h index 2de9b170..b730c654 100644 --- a/swad_assignment.h +++ b/swad_assignment.h @@ -105,7 +105,7 @@ void Asg_UnhideAssignment (void); void Asg_ReceiveFormAssignment (void); void Asg_RemoveCrsAssignments (long CrsCod); -unsigned Asg_GetNumAssignments (HieLvl_Level_t Scope,unsigned *NumNotif); +unsigned Asg_GetNumAssignments (HieLvl_Level_t Level,unsigned *NumNotif); //-------------------------------- Figures ------------------------------------ void Asg_GetAndShowAssignmentsStats (void); diff --git a/swad_assignment_database.c b/swad_assignment_database.c index a7b7db1c..e856799b 100644 --- a/swad_assignment_database.c +++ b/swad_assignment_database.c @@ -519,10 +519,10 @@ unsigned Asg_DB_GetUsrsFromAssignmentExceptMe (MYSQL_RES **mysql_res,long AsgCod // Returns the number of courses with assignments // in this location (all the platform, the current degree or the current course) -unsigned Asg_DB_GetNumCoursesWithAssignments (HieLvl_Level_t Scope) +unsigned Asg_DB_GetNumCoursesWithAssignments (HieLvl_Level_t Level) { /***** Get number of courses with assignments from database *****/ - switch (Scope) + switch (Level) { case HieLvl_SYS: return (unsigned) @@ -586,7 +586,7 @@ unsigned Asg_DB_GetNumCoursesWithAssignments (HieLvl_Level_t Scope) " WHERE CrsCod=%ld", Gbl.Hierarchy.Crs.CrsCod); default: - Err_WrongScopeExit (); + Err_WrongHierarchyLevelExit (); return 0; // Not reached } } @@ -597,10 +597,10 @@ unsigned Asg_DB_GetNumCoursesWithAssignments (HieLvl_Level_t Scope) // Returns the number of assignments // in this location (all the platform, the current degree or the current course) -unsigned Asg_DB_GetNumAssignments (MYSQL_RES **mysql_res,HieLvl_Level_t Scope) +unsigned Asg_DB_GetNumAssignments (MYSQL_RES **mysql_res,HieLvl_Level_t Level) { /***** Get number of assignments from database *****/ - switch (Scope) + switch (Level) { case HieLvl_SYS: return (unsigned) @@ -670,7 +670,7 @@ unsigned Asg_DB_GetNumAssignments (MYSQL_RES **mysql_res,HieLvl_Level_t Scope) " WHERE CrsCod=%ld", Gbl.Hierarchy.Crs.CrsCod); default: - Err_WrongScopeExit (); + Err_WrongHierarchyLevelExit (); return 0; // Not reached } } diff --git a/swad_assignment_database.h b/swad_assignment_database.h index 01edc96f..c337e5fb 100644 --- a/swad_assignment_database.h +++ b/swad_assignment_database.h @@ -73,9 +73,9 @@ void Asg_DB_UpdateNumUsrsNotifiedByEMailAboutAssignment (long AsgCod, unsigned NumUsrsToBeNotifiedByEMail); unsigned Asg_DB_GetUsrsFromAssignmentExceptMe (MYSQL_RES **mysql_res,long AsgCod); -unsigned Asg_DB_GetNumCoursesWithAssignments (HieLvl_Level_t Scope); +unsigned Asg_DB_GetNumCoursesWithAssignments (HieLvl_Level_t Level); -unsigned Asg_DB_GetNumAssignments (MYSQL_RES **mysql_res,HieLvl_Level_t Scope); +unsigned Asg_DB_GetNumAssignments (MYSQL_RES **mysql_res,HieLvl_Level_t Level); unsigned Asg_DB_GetNumAssignmentsInCrs (long CrsCod); diff --git a/swad_attendance.c b/swad_attendance.c index c1dbc689..dddfaee2 100644 --- a/swad_attendance.c +++ b/swad_attendance.c @@ -1377,7 +1377,7 @@ void Att_RemoveCrsEvents (long CrsCod) // Returns the number of attendance events // in this location (all the platform, the current degree or the current course) -unsigned Att_GetNumEvents (HieLvl_Level_t Scope,unsigned *NumNotif) +unsigned Att_GetNumEvents (HieLvl_Level_t Level,unsigned *NumNotif) { MYSQL_RES *mysql_res; MYSQL_ROW row; @@ -1388,7 +1388,7 @@ unsigned Att_GetNumEvents (HieLvl_Level_t Scope,unsigned *NumNotif) *NumNotif = 0; /***** Get number of attendance events from database *****/ - if (Att_DB_GetNumEvents (&mysql_res,Scope)) + if (Att_DB_GetNumEvents (&mysql_res,Level)) { /***** Get number of attendance events *****/ row = mysql_fetch_row (mysql_res); diff --git a/swad_attendance.h b/swad_attendance.h index 60c86efa..34f35231 100644 --- a/swad_attendance.h +++ b/swad_attendance.h @@ -103,7 +103,7 @@ void Att_UpdateEvent (struct Att_Event *Event,const char *Description); void Att_RemoveCrsEvents (long CrsCod); -unsigned Att_GetNumEvents (HieLvl_Level_t Scope,unsigned *NumNotif); +unsigned Att_GetNumEvents (HieLvl_Level_t Level,unsigned *NumNotif); void Att_SeeOneEvent (void); diff --git a/swad_attendance_database.c b/swad_attendance_database.c index b7d48e6c..87c74f5d 100644 --- a/swad_attendance_database.c +++ b/swad_attendance_database.c @@ -854,9 +854,9 @@ unsigned Att_DB_GetNumEventsInCrs (long CrsCod) // Returns the number of courses with attendance events // in this location (all the platform, the current degree or the current course) -unsigned Att_DB_GetNumCoursesWithEvents (HieLvl_Level_t Scope) +unsigned Att_DB_GetNumCoursesWithEvents (HieLvl_Level_t Level) { - switch (Scope) + switch (Level) { case HieLvl_SYS: return DB_QueryCOUNT ("can not get number of courses with attendance events", @@ -900,7 +900,7 @@ unsigned Att_DB_GetNumCoursesWithEvents (HieLvl_Level_t Scope) " WHERE CrsCod=%ld", Gbl.Hierarchy.Crs.CrsCod); default: - Err_WrongScopeExit (); + Err_WrongHierarchyLevelExit (); return 0; // Not reached } } @@ -909,9 +909,9 @@ unsigned Att_DB_GetNumCoursesWithEvents (HieLvl_Level_t Scope) /********************* Get number of attendance events ***********************/ /*****************************************************************************/ -unsigned Att_DB_GetNumEvents (MYSQL_RES **mysql_res,HieLvl_Level_t Scope) +unsigned Att_DB_GetNumEvents (MYSQL_RES **mysql_res,HieLvl_Level_t Level) { - switch (Scope) + switch (Level) { case HieLvl_SYS: return (unsigned) @@ -965,7 +965,7 @@ unsigned Att_DB_GetNumEvents (MYSQL_RES **mysql_res,HieLvl_Level_t Scope) " WHERE CrsCod=%ld", Gbl.Hierarchy.Crs.CrsCod); default: - Err_WrongScopeExit (); + Err_WrongHierarchyLevelExit (); return 0; // Not reached } } diff --git a/swad_attendance_database.h b/swad_attendance_database.h index 6a043235..f2923870 100644 --- a/swad_attendance_database.h +++ b/swad_attendance_database.h @@ -86,8 +86,8 @@ void Att_DB_RemoveGrpsAssociatedToCrsEvents (long CrsCod); void Att_DB_RemoveCrsEvents (long CrsCod); unsigned Att_DB_GetNumEventsInCrs (long CrsCod); -unsigned Att_DB_GetNumCoursesWithEvents (HieLvl_Level_t Scope); +unsigned Att_DB_GetNumCoursesWithEvents (HieLvl_Level_t Level); -unsigned Att_DB_GetNumEvents (MYSQL_RES **mysql_res,HieLvl_Level_t Scope); +unsigned Att_DB_GetNumEvents (MYSQL_RES **mysql_res,HieLvl_Level_t Level); #endif diff --git a/swad_banner_database.c b/swad_banner_database.c index 5edfbf2e..b3f7d84c 100644 --- a/swad_banner_database.c +++ b/swad_banner_database.c @@ -29,13 +29,6 @@ #include "swad_banner_database.h" #include "swad_config.h" #include "swad_database.h" -#include "swad_global.h" - -/*****************************************************************************/ -/************** External global variables from others modules ****************/ -/*****************************************************************************/ - -extern struct Globals Gbl; /*****************************************************************************/ /************************** Get list of all banners **************************/ diff --git a/swad_browser_database.c b/swad_browser_database.c index 5f0322d4..9852a055 100644 --- a/swad_browser_database.c +++ b/swad_browser_database.c @@ -1577,7 +1577,7 @@ unsigned Brw_DB_GetNumberOfPublicFiles (MYSQL_RES **mysql_res,Brw_License_t Lice (unsigned) Brw_ADMI_SHR_CRS, (unsigned) License); default: - Err_WrongScopeExit (); + Err_WrongHierarchyLevelExit (); return 0; // Not reached } } @@ -3765,7 +3765,7 @@ void Brw_DB_GetSizeOfFileBrowser (MYSQL_RES **mysql_res, } break; default: - Err_WrongScopeExit (); + Err_WrongHierarchyLevelExit (); break; } } diff --git a/swad_browser_resource.c b/swad_browser_resource.c index b0be12f0..bca5da6a 100644 --- a/swad_browser_resource.c +++ b/swad_browser_resource.c @@ -36,12 +36,6 @@ #include "swad_parameter_code.h" #include "swad_resource_database.h" -/*****************************************************************************/ -/******************** Global variables from other modules ********************/ -/*****************************************************************************/ - -extern struct Globals Gbl; - /*****************************************************************************/ /****************************** Get link to file *****************************/ /*****************************************************************************/ diff --git a/swad_center.c b/swad_center.c index 35d2dd50..f038d160 100644 --- a/swad_center.c +++ b/swad_center.c @@ -1709,7 +1709,7 @@ unsigned Ctr_GetCachedNumCtrsWithMapInIns (long InsCod) unsigned Ctr_GetCachedNumCtrsWithDegs (void) { unsigned NumCtrsWithDegs; - long Cod = Sco_GetCurrentCod (); + long Cod = Hie_GetCurrentCod (); /***** Get number of centers with degrees from cache *****/ if (!FigCch_GetFigureFromCache (FigCch_NUM_CTRS_WITH_DEGS,Gbl.Scope.Current,Cod, @@ -1731,7 +1731,7 @@ unsigned Ctr_GetCachedNumCtrsWithDegs (void) unsigned Ctr_GetCachedNumCtrsWithCrss (void) { unsigned NumCtrsWithCrss; - long Cod = Sco_GetCurrentCod (); + long Cod = Hie_GetCurrentCod (); /***** Get number of centers with courses *****/ if (!FigCch_GetFigureFromCache (FigCch_NUM_CTRS_WITH_CRSS,Gbl.Scope.Current,Cod, @@ -1759,7 +1759,7 @@ unsigned Ctr_GetCachedNumCtrsWithUsrs (Rol_Role_t Role) [Rol_TCH] = FigCch_NUM_CTRS_WITH_TCHS, // Teachers }; unsigned NumCtrsWithUsrs; - long Cod = Sco_GetCurrentCod (); + long Cod = Hie_GetCurrentCod (); /***** Get number of centers with users from cache *****/ if (!FigCch_GetFigureFromCache (FigureCtrs[Role],Gbl.Scope.Current,Cod, diff --git a/swad_center.h b/swad_center.h index 847af2b0..30503cb1 100644 --- a/swad_center.h +++ b/swad_center.h @@ -67,7 +67,7 @@ typedef enum } Ctr_Order_t; #define Ctr_ORDER_DEFAULT Ctr_ORDER_BY_CENTER -struct ListCenters +struct Ctr_ListCtrs { unsigned Num; // Number of centers struct Ctr_Center *Lst; // List of centers diff --git a/swad_center_database.c b/swad_center_database.c index 89d5a030..c53fc517 100644 --- a/swad_center_database.c +++ b/swad_center_database.c @@ -433,11 +433,11 @@ unsigned Ctr_DB_GetNumCtrsWithMapInIns (long InsCod) /********************* Get number of centers with degrees ********************/ /*****************************************************************************/ -unsigned Ctr_DB_GetNumCtrsWithDegs (HieLvl_Level_t Scope,long Cod) +unsigned Ctr_DB_GetNumCtrsWithDegs (HieLvl_Level_t Level,long Cod) { char SubQuery[128]; - Hie_DB_BuildSubquery (SubQuery,Scope,Cod); + Hie_DB_BuildSubquery (SubQuery,Level,Cod); return (unsigned) DB_QueryCOUNT ("can not get number of centers with degrees", @@ -455,11 +455,11 @@ unsigned Ctr_DB_GetNumCtrsWithDegs (HieLvl_Level_t Scope,long Cod) /********************* Get number of centers with courses ********************/ /*****************************************************************************/ -unsigned Ctr_DB_GetNumCtrsWithCrss (HieLvl_Level_t Scope,long Cod) +unsigned Ctr_DB_GetNumCtrsWithCrss (HieLvl_Level_t Level,long Cod) { char SubQuery[128]; - Hie_DB_BuildSubquery (SubQuery,Scope,Cod); + Hie_DB_BuildSubquery (SubQuery,Level,Cod); return (unsigned) DB_QueryCOUNT ("can not get number of centers with courses", @@ -480,11 +480,11 @@ unsigned Ctr_DB_GetNumCtrsWithCrss (HieLvl_Level_t Scope,long Cod) /*****************************************************************************/ unsigned Ctr_DB_GetNumCtrsWithUsrs (Rol_Role_t Role, - HieLvl_Level_t Scope,long Cod) + HieLvl_Level_t Level,long Cod) { char SubQuery[128]; - Hie_DB_BuildSubquery (SubQuery,Scope,Cod); + Hie_DB_BuildSubquery (SubQuery,Level,Cod); return (unsigned) DB_QueryCOUNT ("can not get number of centers with users", diff --git a/swad_center_database.h b/swad_center_database.h index 0f8d1ec9..633595e6 100644 --- a/swad_center_database.h +++ b/swad_center_database.h @@ -62,10 +62,10 @@ unsigned Ctr_DB_GetNumCtrsInPlc (long PlcCod); unsigned Ctr_DB_GetNumCtrsWithMap (void); unsigned Ctr_DB_GetNumCtrsWithMapInCty (long CtyCod); unsigned Ctr_DB_GetNumCtrsWithMapInIns (long InsCod); -unsigned Ctr_DB_GetNumCtrsWithDegs (HieLvl_Level_t Scope,long Cod); -unsigned Ctr_DB_GetNumCtrsWithCrss (HieLvl_Level_t Scope,long Cod); +unsigned Ctr_DB_GetNumCtrsWithDegs (HieLvl_Level_t Level,long Cod); +unsigned Ctr_DB_GetNumCtrsWithCrss (HieLvl_Level_t Level,long Cod); unsigned Ctr_DB_GetNumCtrsWithUsrs (Rol_Role_t Role, - HieLvl_Level_t Scope,long Cod); + HieLvl_Level_t Level,long Cod); void Ctr_DB_UpdateCtrIns (long CtrCod,long NewInsCod); void Ctr_DB_UpdateCtrPlc (long CtrCod,long NewPlcCod); diff --git a/swad_changelog.h b/swad_changelog.h index fbe00528..314f6dba 100644 --- a/swad_changelog.h +++ b/swad_changelog.h @@ -629,10 +629,11 @@ TODO: Emilce Barrera Mesa: Podr TODO: Emilce Barrera Mesa: Mis estudiantes presentan muchas dificultades a la hora de poner la foto porque la plataforma es muy exigente respecto al fondo de la imagen. */ -#define Log_PLATFORM_VERSION "SWAD 22.120.3 (2023-06-21)" -#define CSS_FILE "swad22.120.css" +#define Log_PLATFORM_VERSION "SWAD 22.120.4 (2023-07-11)" +#define CSS_FILE "swad22.120.4.css" #define JS_FILE "swad22.49.js" /* + Version 22.120.4: Jul 11, 2023 Fixed bug in CSS related to global connected. (337624 lines) Version 22.120.3: Jun 21, 2023 Fixed bug in forums. Reported by Raymon Moreno Colina. (337647 lines) Version 22.120.2: Jun 07, 2023 Code refactoring related to cookies and hidden-visible. (337646 lines) Version 22.120.1: Jun 06, 2023 Translation of messages about cookies. (337620 lines) diff --git a/swad_connected_database.c b/swad_connected_database.c index 965182f7..afcb8f41 100644 --- a/swad_connected_database.c +++ b/swad_connected_database.c @@ -171,7 +171,7 @@ unsigned Con_DB_GetNumConnectedFromCurrentLocation (MYSQL_RES **mysql_res,Rol_Ro " AND usr_connected.UsrCod=usr_data.UsrCod", Gbl.Hierarchy.Crs.CrsCod); default: - Err_WrongScopeExit (); + Err_WrongHierarchyLevelExit (); } return 0; // Not reached case Rol_GST: @@ -314,7 +314,7 @@ unsigned Con_DB_GetNumConnectedFromCurrentLocation (MYSQL_RES **mysql_res,Rol_Ro Gbl.Hierarchy.Crs.CrsCod, (unsigned) Role); default: - Err_WrongScopeExit (); + Err_WrongHierarchyLevelExit (); } return 0; // Not reached default: @@ -469,7 +469,7 @@ unsigned Con_DB_GetConnectedFromCurrentLocation (MYSQL_RES **mysql_res,Rol_Role_ Gbl.Hierarchy.Crs.CrsCod, (unsigned) Role); default: - Err_WrongScopeExit (); + Err_WrongHierarchyLevelExit (); } return 0; // Not reached default: diff --git a/swad_country.c b/swad_country.c index 2b2fb7ce..eb4022ac 100644 --- a/swad_country.c +++ b/swad_country.c @@ -1746,7 +1746,7 @@ unsigned Cty_GetCachedNumCtysWithUsrs (Rol_Role_t Role) [Rol_TCH] = FigCch_NUM_CTYS_WITH_TCHS, // Teachers }; unsigned NumCtysWithUsrs; - long Cod = Sco_GetCurrentCod (); + long Cod = Hie_GetCurrentCod (); /***** Get number of countries with users from cache *****/ if (!FigCch_GetFigureFromCache (FigureCtys[Role],Gbl.Scope.Current,Cod, diff --git a/swad_country.h b/swad_country.h index cb158dca..2e71902c 100644 --- a/swad_country.h +++ b/swad_country.h @@ -66,7 +66,7 @@ typedef enum } Cty_Order_t; #define Cty_ORDER_DEFAULT Cty_ORDER_BY_NUM_USRS -struct ListCountries +struct Cty_ListCtys { unsigned Num; // Number of countries struct Cty_Countr *Lst; // List of countries diff --git a/swad_country_database.c b/swad_country_database.c index d90eed14..3223cd4a 100644 --- a/swad_country_database.c +++ b/swad_country_database.c @@ -334,11 +334,11 @@ unsigned Cty_DB_GetNumCtysWithCrss (void) /*****************************************************************************/ unsigned Cty_DB_GetNumCtysWithUsrs (Rol_Role_t Role, - HieLvl_Level_t Scope,long Cod) + HieLvl_Level_t Level,long Cod) { char SubQuery[128]; - Hie_DB_BuildSubquery (SubQuery,Scope,Cod); + Hie_DB_BuildSubquery (SubQuery,Level,Cod); return (unsigned) DB_QueryCOUNT ("can not get number of countries with users", diff --git a/swad_country_database.h b/swad_country_database.h index 96933d61..0596051d 100644 --- a/swad_country_database.h +++ b/swad_country_database.h @@ -52,7 +52,7 @@ unsigned Cty_DB_GetNumCtysWithCtrs (void); unsigned Cty_DB_GetNumCtysWithDegs (void); unsigned Cty_DB_GetNumCtysWithCrss (void); unsigned Cty_DB_GetNumCtysWithUsrs (Rol_Role_t Role, - HieLvl_Level_t Scope,long Cod); + HieLvl_Level_t Level,long Cod); bool Cty_DB_CheckIfNumericCountryCodeExists (long CtyCod); bool Cty_DB_CheckIfAlpha2CountryCodeExists (const char Alpha2[2 + 1]); diff --git a/swad_course.c b/swad_course.c index 2a4fcea3..f699a43e 100644 --- a/swad_course.c +++ b/swad_course.c @@ -598,7 +598,7 @@ unsigned Crs_GetCachedNumCrssWithUsrs (Rol_Role_t Role) [Rol_TCH] = FigCch_NUM_CRSS_WITH_TCHS, // Teachers }; unsigned NumCrssWithUsrs; - long Cod = Sco_GetCurrentCod (); + long Cod = Hie_GetCurrentCod (); /***** Get number of courses with users from cache *****/ if (!FigCch_GetFigureFromCache (FigureCrss[Role],Gbl.Scope.Current,Cod, diff --git a/swad_course.h b/swad_course.h index 1b9496a5..42ed6cc8 100644 --- a/swad_course.h +++ b/swad_course.h @@ -64,7 +64,7 @@ struct Crs_Course char FullName[Cns_HIERARCHY_MAX_BYTES_FULL_NAME + 1]; // Full name of course }; -struct Crs_ListCourses +struct Crs_ListCrss { unsigned Num; // Number of courses struct Crs_Course *Lst; // List of courses diff --git a/swad_course_database.c b/swad_course_database.c index 9a539a64..404dcd66 100644 --- a/swad_course_database.c +++ b/swad_course_database.c @@ -408,11 +408,11 @@ unsigned Crs_DB_GetNumCrssInDeg (long DegCod) /*****************************************************************************/ unsigned Crs_DB_GetNumCrssWithUsrs (Rol_Role_t Role, - HieLvl_Level_t Scope,long Cod) + HieLvl_Level_t Level,long HieCod) { char SubQuery[128]; - Hie_DB_BuildSubquery (SubQuery,Scope,Cod); + Hie_DB_BuildSubquery (SubQuery,Level,HieCod); return (unsigned) DB_QueryCOUNT ("can not get number of courses with users", diff --git a/swad_course_database.h b/swad_course_database.h index 8b75fdc4..33cb309e 100644 --- a/swad_course_database.h +++ b/swad_course_database.h @@ -60,7 +60,7 @@ unsigned Crs_DB_GetNumCrssInIns (long InsCod); unsigned Crs_DB_GetNumCrssInCtr (long CtrCod); unsigned Crs_DB_GetNumCrssInDeg (long DegCod); unsigned Crs_DB_GetNumCrssWithUsrs (Rol_Role_t Role, - HieLvl_Level_t Scope,long Cod); + HieLvl_Level_t Level,long HieCod); unsigned Crs_DB_GetCrssFromUsr (MYSQL_RES **mysql_res,long UsrCod,long DegCod); diff --git a/swad_database.c b/swad_database.c index b488a2c2..8929e2ff 100644 --- a/swad_database.c +++ b/swad_database.c @@ -42,12 +42,6 @@ #include "swad_HTML.h" #include "swad_language.h" -/*****************************************************************************/ -/************** External global variables from others modules ****************/ -/*****************************************************************************/ - -extern struct Globals Gbl; - /*****************************************************************************/ /************************* Private global variables **************************/ /*****************************************************************************/ diff --git a/swad_degree.c b/swad_degree.c index 0052484f..e7c35f1b 100644 --- a/swad_degree.c +++ b/swad_degree.c @@ -955,7 +955,7 @@ void Deg_PutIconToViewDegrees (void) /************ Create a list with all degrees that have students **************/ /*****************************************************************************/ -void Deg_GetListAllDegsWithStds (struct ListDegrees *Degs) +void Deg_GetListAllDegsWithStds (struct Deg_ListDegs *Degs) { MYSQL_RES *mysql_res; unsigned NumDeg; @@ -1015,7 +1015,7 @@ void Deg_GetListDegsInCurrentCtr (void) /*************************** Free list of degrees ****************************/ /*****************************************************************************/ -void Deg_FreeListDegs (struct ListDegrees *Degs) +void Deg_FreeListDegs (struct Deg_ListDegs *Degs) { if (Degs->Lst) { @@ -1662,7 +1662,7 @@ unsigned Deg_GetCachedNumDegsInCtr (long CtrCod) unsigned Deg_GetCachedNumDegsWithCrss (void) { unsigned NumDegsWithCrss; - long Cod = Sco_GetCurrentCod (); + long Cod = Hie_GetCurrentCod (); /***** Get number of degrees with courses from cache *****/ if (!FigCch_GetFigureFromCache (FigCch_NUM_DEGS_WITH_CRSS,Gbl.Scope.Current,Cod, @@ -1690,7 +1690,7 @@ unsigned Deg_GetCachedNumDegsWithUsrs (Rol_Role_t Role) [Rol_TCH] = FigCch_NUM_DEGS_WITH_TCHS, // Teachers }; unsigned NumDegsWithUsrs; - long Cod = Sco_GetCurrentCod (); + long Cod = Hie_GetCurrentCod (); /***** Get number of degrees with users from cache *****/ if (!FigCch_GetFigureFromCache (FigureDegs[Role],Gbl.Scope.Current,Cod, diff --git a/swad_degree.h b/swad_degree.h index 8447acd3..67d50b56 100644 --- a/swad_degree.h +++ b/swad_degree.h @@ -59,7 +59,7 @@ struct Deg_Degree char WWW[Cns_MAX_BYTES_WWW + 1]; }; -struct ListDegrees +struct Deg_ListDegs { unsigned Num; // Number of degrees struct Deg_Degree *Lst; // List of degrees @@ -84,9 +84,9 @@ void Deg_EditDegrees (void); void Deg_PutIconToViewDegrees (void); -void Deg_GetListAllDegsWithStds (struct ListDegrees *Degs); +void Deg_GetListAllDegsWithStds (struct Deg_ListDegs *Degs); void Deg_GetListDegsInCurrentCtr (void); -void Deg_FreeListDegs (struct ListDegrees *Degs); +void Deg_FreeListDegs (struct Deg_ListDegs *Degs); void Deg_ReceiveFormReqDeg (void); void Deg_ReceiveFormNewDeg (void); diff --git a/swad_degree_database.c b/swad_degree_database.c index 92509b8e..82a3e1d7 100644 --- a/swad_degree_database.c +++ b/swad_degree_database.c @@ -77,10 +77,10 @@ void Deg_DB_CreateDegree (struct Deg_Degree *Deg,Hie_Status_t Status) /************************* Get number of degree types ************************/ /*****************************************************************************/ -unsigned Deg_DB_GetNumDegreeTypes (HieLvl_Level_t Scope) +unsigned Deg_DB_GetNumDegreeTypes (HieLvl_Level_t Level) { /***** Get number of types of degree from database *****/ - switch (Scope) + switch (Level) { case HieLvl_SYS: return (unsigned) @@ -140,7 +140,7 @@ unsigned Deg_DB_GetNumDegreeTypes (HieLvl_Level_t Scope) " AND deg_degrees.DegTypCod=deg_types.DegTypCod", Gbl.Hierarchy.Deg.DegCod); default: - Err_WrongScopeExit (); + Err_WrongHierarchyLevelExit (); return 0; // Not reached } } @@ -150,7 +150,7 @@ unsigned Deg_DB_GetNumDegreeTypes (HieLvl_Level_t Scope) /*****************************************************************************/ unsigned Deg_DB_GetDegreeTypes (MYSQL_RES **mysql_res, - HieLvl_Level_t Scope,DegTyp_Order_t Order) + HieLvl_Level_t Level,DegTyp_Order_t Order) { static const char *OrderBySubQuery[DegTyp_NUM_ORDERS] = { @@ -160,7 +160,7 @@ unsigned Deg_DB_GetDegreeTypes (MYSQL_RES **mysql_res, }; /***** Get types of degree from database *****/ - switch (Scope) + switch (Level) { case HieLvl_SYS: /* Get @@ -257,7 +257,7 @@ unsigned Deg_DB_GetDegreeTypes (MYSQL_RES **mysql_res, Gbl.Hierarchy.Deg.DegCod, OrderBySubQuery[Order]); default: - Err_WrongScopeExit (); + Err_WrongHierarchyLevelExit (); return 0; // Not reached } } @@ -465,7 +465,7 @@ unsigned Deg_DB_GetDegsWithPendingCrss (MYSQL_RES **mysql_res) " GROUP BY crs_courses.DegCod" " ORDER BY deg_degrees.ShortName", Gbl.Usrs.Me.UsrDat.UsrCod, - Sco_GetDBStrFromScope (HieLvl_DEG), + Hie_GetDBStrFromLevel (HieLvl_DEG), (unsigned) Hie_STATUS_BIT_PENDING); case Rol_SYS_ADM: return (unsigned) @@ -563,11 +563,11 @@ unsigned Deg_DB_SearchDegs (MYSQL_RES **mysql_res, /***************** Get current number of degrees with courses ****************/ /*****************************************************************************/ -unsigned Deg_DB_GetNumDegsWithCrss (HieLvl_Level_t Scope,long Cod) +unsigned Deg_DB_GetNumDegsWithCrss (HieLvl_Level_t Level,long Cod) { char SubQuery[128]; - Hie_DB_BuildSubquery (SubQuery,Scope,Cod); + Hie_DB_BuildSubquery (SubQuery,Level,Cod); return (unsigned) DB_QueryCOUNT ("can not get number of degrees with courses", @@ -588,11 +588,11 @@ unsigned Deg_DB_GetNumDegsWithCrss (HieLvl_Level_t Scope,long Cod) /*****************************************************************************/ unsigned Deg_DB_GetNumDegsWithUsrs (Rol_Role_t Role, - HieLvl_Level_t Scope,long Cod) + HieLvl_Level_t Level,long Cod) { char SubQuery[128]; - Hie_DB_BuildSubquery (SubQuery,Scope,Cod); + Hie_DB_BuildSubquery (SubQuery,Level,Cod); return (unsigned) DB_QueryCOUNT ("can not get number of degrees with users", diff --git a/swad_degree_database.h b/swad_degree_database.h index a07108c5..500fabc2 100644 --- a/swad_degree_database.h +++ b/swad_degree_database.h @@ -40,9 +40,9 @@ void Deg_DB_CreateDegreeType (const char DegTypName[DegTyp_MAX_BYTES_DEGREE_TYPE_NAME + 1]); void Deg_DB_CreateDegree (struct Deg_Degree *Deg,Hie_Status_t Status); -unsigned Deg_DB_GetNumDegreeTypes (HieLvl_Level_t Scope); +unsigned Deg_DB_GetNumDegreeTypes (HieLvl_Level_t Level); unsigned Deg_DB_GetDegreeTypes (MYSQL_RES **mysql_res, - HieLvl_Level_t Scope,DegTyp_Order_t Order); + HieLvl_Level_t Level,DegTyp_Order_t Order); void Deg_DB_GetDegTypeNameByCod (struct DegTyp_DegreeType *DegTyp); unsigned Deg_DB_GetDegreeDataByCod (MYSQL_RES **mysql_res,long DegCod); long Deg_DB_GetInsCodOfDegreeByCod (long DegCod); @@ -62,9 +62,9 @@ unsigned Deg_DB_SearchDegs (MYSQL_RES **mysql_res, const char SearchQuery[Sch_MAX_BYTES_SEARCH_QUERY + 1], const char *RangeQuery); -unsigned Deg_DB_GetNumDegsWithCrss (HieLvl_Level_t Scope,long Cod); +unsigned Deg_DB_GetNumDegsWithCrss (HieLvl_Level_t Level,long Cod); unsigned Deg_DB_GetNumDegsWithUsrs (Rol_Role_t Role, - HieLvl_Level_t Scope,long Cod); + HieLvl_Level_t Level,long Cod); unsigned Deg_DB_GetNumDegsInCty (long CtyCod); unsigned Deg_DB_GetNumDegsInIns (long InsCod); diff --git a/swad_degree_type.c b/swad_degree_type.c index 7010d507..fcadd86d 100644 --- a/swad_degree_type.c +++ b/swad_degree_type.c @@ -65,13 +65,13 @@ static struct DegTyp_DegreeType *DegTyp_EditingDegTyp = NULL; // Static variable /*************************** Private prototypes ******************************/ /*****************************************************************************/ -static void DegTyp_SeeDegreeTypes (Act_Action_t NextAction,HieLvl_Level_t Scope, +static void DegTyp_SeeDegreeTypes (Act_Action_t NextAction,HieLvl_Level_t Level, DegTyp_Order_t DefaultOrder); static DegTyp_Order_t DegTyp_GetParDegTypOrder (DegTyp_Order_t DefaultOrder); static void DegTyp_ListDegreeTypes (const struct DegTyp_DegTypes *DegTypes, Act_Action_t NextAction, - HieLvl_Level_t Scope, + HieLvl_Level_t Level, DegTyp_Order_t SelectedOrder); static void DegTyp_EditDegreeTypesInternal (const struct DegTyp_DegTypes *DegTypes); @@ -85,7 +85,7 @@ static void DegTyp_ListDegreeTypesForEdition (const struct DegTyp_DegTypes *DegT static void DegTyp_PutFormToCreateDegreeType (void); static void DegTyp_PutHeadDegreeTypesForSeeing (Act_Action_t NextAction, - HieLvl_Level_t Scope, + HieLvl_Level_t Level, DegTyp_Order_t SelectedOrder); static void DegTyp_PutHeadDegreeTypesForEdition (void); @@ -154,7 +154,7 @@ void DegTyp_SeeDegreeTypesInStaTab (void) DegTyp_ORDER_BY_NUM_DEGREES); // Default order if not specified } -static void DegTyp_SeeDegreeTypes (Act_Action_t NextAction,HieLvl_Level_t Scope, +static void DegTyp_SeeDegreeTypes (Act_Action_t NextAction,HieLvl_Level_t Level, DegTyp_Order_t DefaultOrder) { DegTyp_Order_t SelectedOrder; @@ -164,10 +164,10 @@ static void DegTyp_SeeDegreeTypes (Act_Action_t NextAction,HieLvl_Level_t Scope, SelectedOrder = DegTyp_GetParDegTypOrder (DefaultOrder); /***** Get list of degree types *****/ - DegTyp_GetListDegreeTypes (&DegTypes,Scope,SelectedOrder); + DegTyp_GetListDegreeTypes (&DegTypes,Level,SelectedOrder); /***** List degree types *****/ - DegTyp_ListDegreeTypes (&DegTypes,NextAction,Scope,SelectedOrder); + DegTyp_ListDegreeTypes (&DegTypes,NextAction,Level,SelectedOrder); /***** Free list of degree types *****/ DegTyp_FreeListDegreeTypes (&DegTypes); @@ -194,7 +194,7 @@ static DegTyp_Order_t DegTyp_GetParDegTypOrder (DegTyp_Order_t DefaultOrder) static void DegTyp_ListDegreeTypes (const struct DegTyp_DegTypes *DegTypes, Act_Action_t NextAction, - HieLvl_Level_t Scope, + HieLvl_Level_t Level, DegTyp_Order_t SelectedOrder) { extern const char *Hlp_CENTER_DegreeTypes; @@ -225,7 +225,7 @@ static void DegTyp_ListDegreeTypes (const struct DegTyp_DegTypes *DegTypes, HTM_TABLE_BeginWideMarginPadding (2); /***** Write heading *****/ - DegTyp_PutHeadDegreeTypesForSeeing (NextAction,Scope,SelectedOrder); + DegTyp_PutHeadDegreeTypesForSeeing (NextAction,Level,SelectedOrder); /***** List current degree types for seeing *****/ DegTyp_ListDegreeTypesForSeeing (DegTypes); @@ -502,7 +502,7 @@ static void DegTyp_PutFormToCreateDegreeType (void) /*****************************************************************************/ static void DegTyp_PutHeadDegreeTypesForSeeing (Act_Action_t NextAction, - HieLvl_Level_t Scope, + HieLvl_Level_t Level, DegTyp_Order_t SelectedOrder) { extern const char *Txt_DEGREE_TYPES_HELP_ORDER[DegTyp_NUM_ORDERS]; @@ -529,7 +529,7 @@ static void DegTyp_PutHeadDegreeTypesForSeeing (Act_Action_t NextAction, Frm_BeginForm (NextAction); if (NextAction == ActSeeUseGbl) { - Figures.Scope = Scope; + Figures.Level = Level; Figures.FigureType = Fig_DEGREE_TYPES; Fig_PutParsFigures (&Figures); } @@ -579,14 +579,14 @@ static void DegTyp_PutHeadDegreeTypesForEdition (void) /*****************************************************************************/ void DegTyp_GetListDegreeTypes (struct DegTyp_DegTypes *DegTypes, - HieLvl_Level_t Scope,DegTyp_Order_t Order) + HieLvl_Level_t Level,DegTyp_Order_t Order) { MYSQL_RES *mysql_res; MYSQL_ROW row; unsigned NumTyp; /***** Get types of degree from database *****/ - DegTypes->Num = Deg_DB_GetDegreeTypes (&mysql_res,Scope,Order); + DegTypes->Num = Deg_DB_GetDegreeTypes (&mysql_res,Level,Order); DegTypes->Lst = NULL; /***** Get degree types *****/ diff --git a/swad_degree_type.h b/swad_degree_type.h index c9e4fc52..b2993c95 100644 --- a/swad_degree_type.h +++ b/swad_degree_type.h @@ -76,7 +76,7 @@ void DegTyp_PutIconToViewDegreeTypes (void); bool DegTyp_CheckIfICanCreateDegreeTypes (void); void DegTyp_GetListDegreeTypes (struct DegTyp_DegTypes *DegTypes, - HieLvl_Level_t Scope,DegTyp_Order_t Order); + HieLvl_Level_t Level,DegTyp_Order_t Order); void DegTyp_FreeListDegreeTypes (struct DegTyp_DegTypes *DegTypes); void DegTyp_ReceiveFormNewDegreeType (void); diff --git a/swad_enrolment.c b/swad_enrolment.c index 8e873b64..50e9baa6 100644 --- a/swad_enrolment.c +++ b/swad_enrolment.c @@ -3471,7 +3471,7 @@ bool Enr_CheckIfUsrSharesAnyOfMyCrs (struct Usr_Data *UsrDat) #define Enr_DB_MAX_BYTES_SUBQUERY_ROLES (Rol_NUM_ROLES * (10 + 1) - 1) -unsigned Enr_GetNumUsrsInCrss (HieLvl_Level_t Scope,long Cod,unsigned Roles) +unsigned Enr_GetNumUsrsInCrss (HieLvl_Level_t Level,long Cod,unsigned Roles) { bool AnyUserInCourses; unsigned NumUsrs; @@ -3496,22 +3496,22 @@ unsigned Enr_GetNumUsrsInCrss (HieLvl_Level_t Scope,long Cod,unsigned Roles) (1 << Rol_TCH))); /***** Get number of users from database *****/ - NumUsrs = Enr_DB_GetNumUsrsInCrss (Scope,Cod,Roles,AnyUserInCourses); + NumUsrs = Enr_DB_GetNumUsrsInCrss (Level,Cod,Roles,AnyUserInCourses); - FigCch_UpdateFigureIntoCache (Enr_GetFigureNumUsrsInCrss (Roles),Scope,Cod, + FigCch_UpdateFigureIntoCache (Enr_GetFigureNumUsrsInCrss (Roles),Level,Cod, FigCch_UNSIGNED,&NumUsrs); return NumUsrs; } -unsigned Enr_GetCachedNumUsrsInCrss (HieLvl_Level_t Scope,long Cod,unsigned Roles) +unsigned Enr_GetCachedNumUsrsInCrss (HieLvl_Level_t Level,long Cod,unsigned Roles) { unsigned NumUsrsInCrss; /***** Get number of users in courses from cache *****/ - if (!FigCch_GetFigureFromCache (Enr_GetFigureNumUsrsInCrss (Roles),Scope,Cod, + if (!FigCch_GetFigureFromCache (Enr_GetFigureNumUsrsInCrss (Roles),Level,Cod, FigCch_UNSIGNED,&NumUsrsInCrss)) /***** Get current number of users in courses from database and update cache *****/ - NumUsrsInCrss = Enr_GetNumUsrsInCrss (Scope,Cod,Roles); + NumUsrsInCrss = Enr_GetNumUsrsInCrss (Level,Cod,Roles); return NumUsrsInCrss; } @@ -3564,7 +3564,7 @@ unsigned Enr_GetCachedNumUsrsNotBelongingToAnyCrs (void) /************ Get average number of courses with users of a type *************/ /*****************************************************************************/ -double Enr_GetCachedAverageNumUsrsPerCrs (HieLvl_Level_t Scope,long Cod,Rol_Role_t Role) +double Enr_GetCachedAverageNumUsrsPerCrs (HieLvl_Level_t Level,long Cod,Rol_Role_t Role) { static const FigCch_FigureCached_t FigureNumUsrsPerCrs[Rol_NUM_ROLES] = { @@ -3576,12 +3576,12 @@ double Enr_GetCachedAverageNumUsrsPerCrs (HieLvl_Level_t Scope,long Cod,Rol_Role double AverageNumUsrsPerCrs; /***** Get number of users per course from cache *****/ - if (!FigCch_GetFigureFromCache (FigureNumUsrsPerCrs[Role],Scope,Cod, + if (!FigCch_GetFigureFromCache (FigureNumUsrsPerCrs[Role],Level,Cod, FigCch_DOUBLE,&AverageNumUsrsPerCrs)) { /***** Get current number of users per course from database and update cache *****/ - AverageNumUsrsPerCrs = Enr_DB_GetAverageNumUsrsPerCrs (Scope,Cod,Role); - FigCch_UpdateFigureIntoCache (FigureNumUsrsPerCrs[Role],Scope,Cod, + AverageNumUsrsPerCrs = Enr_DB_GetAverageNumUsrsPerCrs (Level,Cod,Role); + FigCch_UpdateFigureIntoCache (FigureNumUsrsPerCrs[Role],Level,Cod, FigCch_DOUBLE,&AverageNumUsrsPerCrs); } @@ -3592,7 +3592,7 @@ double Enr_GetCachedAverageNumUsrsPerCrs (HieLvl_Level_t Scope,long Cod,Rol_Role /************ Get average number of courses with users of a role *************/ /*****************************************************************************/ -double Enr_GetCachedAverageNumCrssPerUsr (HieLvl_Level_t Scope,long Cod,Rol_Role_t Role) +double Enr_GetCachedAverageNumCrssPerUsr (HieLvl_Level_t Level,long Cod,Rol_Role_t Role) { static const FigCch_FigureCached_t FigureNumCrssPerUsr[Rol_NUM_ROLES] = { @@ -3604,12 +3604,12 @@ double Enr_GetCachedAverageNumCrssPerUsr (HieLvl_Level_t Scope,long Cod,Rol_Role double AverageNumCrssPerUsr; /***** Get number of courses per user from cache *****/ - if (!FigCch_GetFigureFromCache (FigureNumCrssPerUsr[Role],Scope,Cod, + if (!FigCch_GetFigureFromCache (FigureNumCrssPerUsr[Role],Level,Cod, FigCch_DOUBLE,&AverageNumCrssPerUsr)) { /***** Get current number of courses per user from database and update cache *****/ - AverageNumCrssPerUsr = Enr_DB_GetAverageNumCrssPerUsr (Scope,Cod,Role); - FigCch_UpdateFigureIntoCache (FigureNumCrssPerUsr[Role],Scope,Cod, + AverageNumCrssPerUsr = Enr_DB_GetAverageNumCrssPerUsr (Level,Cod,Role); + FigCch_UpdateFigureIntoCache (FigureNumCrssPerUsr[Role],Level,Cod, FigCch_DOUBLE,&AverageNumCrssPerUsr); } diff --git a/swad_enrolment.h b/swad_enrolment.h index 47d3260a..432b8ad2 100644 --- a/swad_enrolment.h +++ b/swad_enrolment.h @@ -142,7 +142,7 @@ void Enr_FreeMyCourses (void); bool Enr_CheckIfIBelongToCrs (long CrsCod); void Enr_FlushCacheUsrBelongsToCrs (void); bool Enr_CheckIfUsrBelongsToCrs (long UsrCod,long CrsCod, - bool CountOnlyAcceptedCourses);; + bool CountOnlyAcceptedCourses); void Enr_FlushCacheUsrBelongsToCurrentCrs (void); bool Enr_CheckIfUsrBelongsToCurrentCrs (const struct Usr_Data *UsrDat); void Enr_FlushCacheUsrHasAcceptedInCurrentCrs (void); @@ -150,10 +150,10 @@ bool Enr_CheckIfUsrHasAcceptedInCurrentCrs (const struct Usr_Data *UsrDat); void Enr_FlushCacheUsrSharesAnyOfMyCrs (void); bool Enr_CheckIfUsrSharesAnyOfMyCrs (struct Usr_Data *UsrDat); -unsigned Enr_GetNumUsrsInCrss (HieLvl_Level_t Scope,long Cod,unsigned Roles); -unsigned Enr_GetCachedNumUsrsInCrss (HieLvl_Level_t Scope,long Cod,unsigned Roles); +unsigned Enr_GetNumUsrsInCrss (HieLvl_Level_t Level,long Cod,unsigned Roles); +unsigned Enr_GetCachedNumUsrsInCrss (HieLvl_Level_t Level,long Cod,unsigned Roles); unsigned Enr_GetCachedNumUsrsNotBelongingToAnyCrs (void); -double Enr_GetCachedAverageNumUsrsPerCrs (HieLvl_Level_t Scope,long Cod,Rol_Role_t Role); -double Enr_GetCachedAverageNumCrssPerUsr (HieLvl_Level_t Scope,long Cod,Rol_Role_t Role); +double Enr_GetCachedAverageNumUsrsPerCrs (HieLvl_Level_t Level,long Cod,Rol_Role_t Role); +double Enr_GetCachedAverageNumCrssPerUsr (HieLvl_Level_t Level,long Cod,Rol_Role_t Role); #endif diff --git a/swad_enrolment_database.c b/swad_enrolment_database.c index dc86c5ed..32504433 100644 --- a/swad_enrolment_database.c +++ b/swad_enrolment_database.c @@ -442,7 +442,7 @@ unsigned Enr_DB_GetNumUsrsInCrssOfAUsr (long UsrCod,Rol_Role_t UsrRole, #define Enr_DB_MAX_BYTES_SUBQUERY_ROLES (Rol_NUM_ROLES * (10 + 1) - 1) -unsigned Enr_DB_GetNumUsrsInCrss (HieLvl_Level_t Scope,long Cod,unsigned Roles, +unsigned Enr_DB_GetNumUsrsInCrss (HieLvl_Level_t Level,long Cod,unsigned Roles, bool AnyUserInCourses) { char UnsignedStr[Cns_MAX_DECIMAL_DIGITS_UINT + 1]; @@ -497,7 +497,7 @@ unsigned Enr_DB_GetNumUsrsInCrss (HieLvl_Level_t Scope,long Cod,unsigned Roles, sprintf (SubQueryRoles,"=%u",FirstRoleRequested); /***** Get number of users from database *****/ - switch (Scope) + switch (Level) { case HieLvl_SYS: if (AnyUserInCourses) // Any user @@ -644,7 +644,7 @@ unsigned Enr_DB_GetNumUsrsInCrss (HieLvl_Level_t Scope,long Cod,unsigned Roles, Cod, SubQueryRoles); default: - Err_WrongScopeExit (); + Err_WrongHierarchyLevelExit (); return 0; // Not reached } } @@ -670,9 +670,9 @@ unsigned Enr_DB_GetNumUsrsNotBelongingToAnyCrs (void) /************ Get average number of courses with users of a type *************/ /*****************************************************************************/ -double Enr_DB_GetAverageNumUsrsPerCrs (HieLvl_Level_t Scope,long Cod,Rol_Role_t Role) +double Enr_DB_GetAverageNumUsrsPerCrs (HieLvl_Level_t Level,long Cod,Rol_Role_t Role) { - switch (Scope) + switch (Level) { case HieLvl_SYS: if (Role == Rol_UNK) // Any user @@ -813,7 +813,7 @@ double Enr_DB_GetAverageNumUsrsPerCrs (HieLvl_Level_t Scope,long Cod,Rol_Role_t 1 << Role); default: - Err_WrongScopeExit (); + Err_WrongHierarchyLevelExit (); return 0.0; // Not reached } } @@ -822,9 +822,9 @@ double Enr_DB_GetAverageNumUsrsPerCrs (HieLvl_Level_t Scope,long Cod,Rol_Role_t /************ Get average number of courses with users of a role *************/ /*****************************************************************************/ -double Enr_DB_GetAverageNumCrssPerUsr (HieLvl_Level_t Scope,long Cod,Rol_Role_t Role) +double Enr_DB_GetAverageNumCrssPerUsr (HieLvl_Level_t Level,long Cod,Rol_Role_t Role) { - switch (Scope) + switch (Level) { case HieLvl_SYS: if (Role == Rol_UNK) // Any user @@ -960,7 +960,7 @@ double Enr_DB_GetAverageNumCrssPerUsr (HieLvl_Level_t Scope,long Cod,Rol_Role_t case HieLvl_CRS: return 1.0; default: - Err_WrongScopeExit (); + Err_WrongHierarchyLevelExit (); return 0.0; // Not reached } } @@ -1087,7 +1087,7 @@ unsigned Enr_DB_GetEnrolmentRequests (MYSQL_RES **mysql_res,unsigned RolesSelect " AND crs_courses.CrsCod=crs_requests.CrsCod" " AND ((1<0" " ORDER BY crs_requests.RequestTime DESC", - Gbl.Usrs.Me.UsrDat.UsrCod,Sco_GetDBStrFromScope (HieLvl_DEG), + Gbl.Usrs.Me.UsrDat.UsrCod,Hie_GetDBStrFromLevel (HieLvl_DEG), RolesSelected); case Rol_CTR_ADM: // Requests in all centers administrated by me @@ -1109,7 +1109,7 @@ unsigned Enr_DB_GetEnrolmentRequests (MYSQL_RES **mysql_res,unsigned RolesSelect " AND crs_courses.CrsCod=crs_requests.CrsCod" " AND ((1<0" " ORDER BY crs_requests.RequestTime DESC", - Gbl.Usrs.Me.UsrDat.UsrCod,Sco_GetDBStrFromScope (HieLvl_CTR), + Gbl.Usrs.Me.UsrDat.UsrCod,Hie_GetDBStrFromLevel (HieLvl_CTR), RolesSelected); case Rol_INS_ADM: // Requests in all institutions administrated by me @@ -1133,7 +1133,7 @@ unsigned Enr_DB_GetEnrolmentRequests (MYSQL_RES **mysql_res,unsigned RolesSelect " AND crs_courses.CrsCod=crs_requests.CrsCod" " AND ((1<0" " ORDER BY crs_requests.RequestTime DESC", - Gbl.Usrs.Me.UsrDat.UsrCod,Sco_GetDBStrFromScope (HieLvl_INS), + Gbl.Usrs.Me.UsrDat.UsrCod,Hie_GetDBStrFromLevel (HieLvl_INS), RolesSelected); case Rol_SYS_ADM: // All requests @@ -1211,7 +1211,7 @@ unsigned Enr_DB_GetEnrolmentRequests (MYSQL_RES **mysql_res,unsigned RolesSelect " AND ((1<0" " ORDER BY crs_requests.RequestTime DESC", Gbl.Usrs.Me.UsrDat.UsrCod, - Sco_GetDBStrFromScope (HieLvl_DEG), + Hie_GetDBStrFromLevel (HieLvl_DEG), Gbl.Hierarchy.Cty.CtyCod, RolesSelected); case Rol_CTR_ADM: @@ -1240,7 +1240,7 @@ unsigned Enr_DB_GetEnrolmentRequests (MYSQL_RES **mysql_res,unsigned RolesSelect " AND ((1<0" " ORDER BY crs_requests.RequestTime DESC", Gbl.Usrs.Me.UsrDat.UsrCod, - Sco_GetDBStrFromScope (HieLvl_CTR), + Hie_GetDBStrFromLevel (HieLvl_CTR), Gbl.Hierarchy.Cty.CtyCod, RolesSelected); case Rol_INS_ADM: @@ -1269,7 +1269,7 @@ unsigned Enr_DB_GetEnrolmentRequests (MYSQL_RES **mysql_res,unsigned RolesSelect " AND ((1<0" " ORDER BY crs_requests.RequestTime DESC", Gbl.Usrs.Me.UsrDat.UsrCod, - Sco_GetDBStrFromScope (HieLvl_INS), + Hie_GetDBStrFromLevel (HieLvl_INS), Gbl.Hierarchy.Cty.CtyCod, RolesSelected); case Rol_SYS_ADM: @@ -1354,7 +1354,7 @@ unsigned Enr_DB_GetEnrolmentRequests (MYSQL_RES **mysql_res,unsigned RolesSelect " AND ((1<0" " ORDER BY crs_requests.RequestTime DESC", Gbl.Usrs.Me.UsrDat.UsrCod, - Sco_GetDBStrFromScope (HieLvl_DEG), + Hie_GetDBStrFromLevel (HieLvl_DEG), Gbl.Hierarchy.Ins.InsCod, RolesSelected); case Rol_CTR_ADM: @@ -1380,7 +1380,7 @@ unsigned Enr_DB_GetEnrolmentRequests (MYSQL_RES **mysql_res,unsigned RolesSelect " AND crs_courses.CrsCod=crs_requests.CrsCod" " AND ((1<0" " ORDER BY crs_requests.RequestTime DESC", - Gbl.Usrs.Me.UsrDat.UsrCod,Sco_GetDBStrFromScope (HieLvl_CTR), + Gbl.Usrs.Me.UsrDat.UsrCod,Hie_GetDBStrFromLevel (HieLvl_CTR), Gbl.Hierarchy.Ins.InsCod, RolesSelected); case Rol_INS_ADM: // If I am logged as admin of this institution, I can view all requesters from this institution @@ -1460,7 +1460,7 @@ unsigned Enr_DB_GetEnrolmentRequests (MYSQL_RES **mysql_res,unsigned RolesSelect " AND ((1<0" " ORDER BY crs_requests.RequestTime DESC", Gbl.Usrs.Me.UsrDat.UsrCod, - Sco_GetDBStrFromScope (HieLvl_DEG), + Hie_GetDBStrFromLevel (HieLvl_DEG), Gbl.Hierarchy.Ctr.CtrCod, RolesSelected); case Rol_CTR_ADM: // If I am logged as admin of this center , I can view all requesters from this center @@ -1568,7 +1568,7 @@ unsigned Enr_DB_GetEnrolmentRequests (MYSQL_RES **mysql_res,unsigned RolesSelect } return 0; // Not reached default: - Err_WrongScopeExit (); + Err_WrongHierarchyLevelExit (); return 0; // Not reached } } diff --git a/swad_enrolment_database.h b/swad_enrolment_database.h index 4aa32ba6..995dc2fd 100644 --- a/swad_enrolment_database.h +++ b/swad_enrolment_database.h @@ -58,11 +58,11 @@ unsigned Enr_DB_GetNumCrssOfUsrWithARole (long UsrCod,Rol_Role_t Role); unsigned Enr_DB_GetNumCrssOfUsrWithARoleNotAccepted (long UsrCod,Rol_Role_t Role); unsigned Enr_DB_GetNumUsrsInCrssOfAUsr (long UsrCod,Rol_Role_t UsrRole, unsigned OthersRoles); -unsigned Enr_DB_GetNumUsrsInCrss (HieLvl_Level_t Scope,long Cod,unsigned Roles, +unsigned Enr_DB_GetNumUsrsInCrss (HieLvl_Level_t Level,long Cod,unsigned Roles, bool AnyUserInCourses); unsigned Enr_DB_GetNumUsrsNotBelongingToAnyCrs (void); -double Enr_DB_GetAverageNumUsrsPerCrs (HieLvl_Level_t Scope,long Cod,Rol_Role_t Role); -double Enr_DB_GetAverageNumCrssPerUsr (HieLvl_Level_t Scope,long Cod,Rol_Role_t Role); +double Enr_DB_GetAverageNumUsrsPerCrs (HieLvl_Level_t Level,long Cod,Rol_Role_t Role); +double Enr_DB_GetAverageNumCrssPerUsr (HieLvl_Level_t Level,long Cod,Rol_Role_t Role); void Enr_DB_RemUsrFromCrs (long UsrCod,long CrsCod); void Enr_DB_RemUsrFromAllCrss (long UsrCod); diff --git a/swad_error.c b/swad_error.c index e7c3cb35..e3d39125 100644 --- a/swad_error.c +++ b/swad_error.c @@ -81,9 +81,9 @@ void Err_WrongActionExit (void) /************* Write error message and exit when wrong scope *****************/ /*****************************************************************************/ -void Err_WrongScopeExit (void) +void Err_WrongHierarchyLevelExit (void) { - Err_ShowErrorAndExit ("Wrong scope."); + Err_ShowErrorAndExit ("Wrong hierarchy level."); } /*****************************************************************************/ diff --git a/swad_error.h b/swad_error.h index bb14f4b6..5aab8207 100644 --- a/swad_error.h +++ b/swad_error.h @@ -32,7 +32,7 @@ void Err_PathTooLongExit (void); void Err_QuerySizeExceededExit (void); void Err_WrongActionExit (void); -void Err_WrongScopeExit (void); +void Err_WrongHierarchyLevelExit (void); void Err_WrongCountrExit (void); void Err_WrongInstitExit (void); void Err_WrongCenterExit (void); diff --git a/swad_exam_database.c b/swad_exam_database.c index 3b1c0a19..9ebeb33b 100644 --- a/swad_exam_database.c +++ b/swad_exam_database.c @@ -265,12 +265,12 @@ bool Exa_DB_CheckIfSimilarExamExists (long CrsCod,long ExaCod,const char *Title) /*****************************************************************************/ /********************* Get number of courses with exams **********************/ /*****************************************************************************/ -// Returns the number of courses with exams in this location +// Returns the number of courses with exams in a given location -unsigned Exa_DB_GetNumCoursesWithExams (HieLvl_Level_t Scope) +unsigned Exa_DB_GetNumCoursesWithExams (HieLvl_Level_t Level) { /***** Get number of courses with exams from database *****/ - switch (Scope) + switch (Level) { case HieLvl_SYS: return DB_QueryCOUNT ("can not get number of courses with exams", @@ -327,7 +327,7 @@ unsigned Exa_DB_GetNumCoursesWithExams (HieLvl_Level_t Scope) " WHERE CrsCod=%ld", Gbl.Hierarchy.Crs.CrsCod); default: - Err_WrongScopeExit (); + Err_WrongHierarchyLevelExit (); return 0; // Not reached } } @@ -335,12 +335,12 @@ unsigned Exa_DB_GetNumCoursesWithExams (HieLvl_Level_t Scope) /*****************************************************************************/ /**************************** Get number of exams ****************************/ /*****************************************************************************/ -// Returns the number of exams in this location +// Returns the number of exams in a given location -unsigned Exa_DB_GetNumExams (HieLvl_Level_t Scope) +unsigned Exa_DB_GetNumExams (HieLvl_Level_t Level) { /***** Get number of exams from database *****/ - switch (Scope) + switch (Level) { case HieLvl_SYS: return DB_QueryCOUNT ("can not get number of exams", @@ -397,7 +397,7 @@ unsigned Exa_DB_GetNumExams (HieLvl_Level_t Scope) " WHERE CrsCod=%ld", Gbl.Hierarchy.Crs.CrsCod); default: - Err_WrongScopeExit (); + Err_WrongHierarchyLevelExit (); return 0; // Not reached } } @@ -406,10 +406,10 @@ unsigned Exa_DB_GetNumExams (HieLvl_Level_t Scope) /************* Get average number of questions per course exam ***************/ /*****************************************************************************/ -double Exa_DB_GetNumQstsPerCrsExam (HieLvl_Level_t Scope) +double Exa_DB_GetNumQstsPerCrsExam (HieLvl_Level_t Level) { /***** Get number of questions per exam from database *****/ - switch (Scope) + switch (Level) { case HieLvl_SYS: return DB_QuerySELECTDouble ("can not get number of questions per exam", @@ -490,7 +490,7 @@ double Exa_DB_GetNumQstsPerCrsExam (HieLvl_Level_t Scope) " GROUP BY exa_set_questions.ExaCod) AS NumQstsTable", Gbl.Hierarchy.Crs.CrsCod); default: - Err_WrongScopeExit (); + Err_WrongHierarchyLevelExit (); return 0.0; // Not reached } } diff --git a/swad_exam_database.h b/swad_exam_database.h index bef5cc1b..ca4564ac 100644 --- a/swad_exam_database.h +++ b/swad_exam_database.h @@ -47,9 +47,9 @@ unsigned Exa_DB_GetExamStartEnd (MYSQL_RES **mysql_res,long ExaCod); void Exa_DB_GetExamTitle (long ExaCod,char *Title,size_t TitleSize); void Exa_DB_GetExamTxt (long ExaCod,char Txt[Cns_MAX_BYTES_TEXT + 1]); bool Exa_DB_CheckIfSimilarExamExists (long CrsCod,long ExaCod,const char *Title); -unsigned Exa_DB_GetNumCoursesWithExams (HieLvl_Level_t Scope); -unsigned Exa_DB_GetNumExams (HieLvl_Level_t Scope); -double Exa_DB_GetNumQstsPerCrsExam (HieLvl_Level_t Scope); +unsigned Exa_DB_GetNumCoursesWithExams (HieLvl_Level_t Level); +unsigned Exa_DB_GetNumExams (HieLvl_Level_t Level); +double Exa_DB_GetNumQstsPerCrsExam (HieLvl_Level_t Level); void Exa_DB_RemoveExam (long ExaCod); void Exa_DB_RemoveAllExamsFromCrs (long CrsCod); diff --git a/swad_figure.c b/swad_figure.c index 01427c2c..d1239ebd 100644 --- a/swad_figure.c +++ b/swad_figure.c @@ -66,7 +66,7 @@ extern struct Globals Gbl; static void Fig_ReqShowFigure (Fig_FigureType_t SelectedFigureType); static void Fig_PutParFigureType (Fig_FigureType_t FigureType); -static void Fig_PutParScopeFig (HieLvl_Level_t ScopeFig); +static void Fig_PutParFigScope (HieLvl_Level_t Level); /*****************************************************************************/ /************************** Show use of the platform *************************/ @@ -106,8 +106,8 @@ static void Fig_ReqShowFigure (Fig_FigureType_t SelectedFigureType) 1 << HieLvl_DEG | 1 << HieLvl_CRS; Gbl.Scope.Default = HieLvl_SYS; - Sco_GetScope ("ScopeFig"); - Sco_PutSelectorScope ("ScopeFig",HTM_DONT_SUBMIT_ON_CHANGE); + Sco_GetScope ("FigScope"); + Sco_PutSelectorScope ("FigScope",HTM_DONT_SUBMIT_ON_CHANGE); HTM_LABEL_End (); HTM_BR (); @@ -152,7 +152,7 @@ void Fig_PutIconToShowFigure (Fig_FigureType_t FigureType) Sco_AdjustScope (); /***** Put icon to show figure *****/ - Figures.Scope = Gbl.Scope.Current; + Figures.Level = Gbl.Scope.Current; Figures.FigureType = FigureType; Lay_PutContextualLinkOnlyIcon (ActSeeUseGbl,NULL, Fig_PutParsFigures,&Figures, @@ -167,7 +167,7 @@ void Fig_PutParsFigures (void *Figures) { if (Figures) { - Fig_PutParScopeFig (((struct Fig_Figures *) Figures)->Scope); + Fig_PutParFigScope (((struct Fig_Figures *) Figures)->Level); Fig_PutParFigureType (((struct Fig_Figures *) Figures)->FigureType); } } @@ -185,9 +185,9 @@ static void Fig_PutParFigureType (Fig_FigureType_t FigureType) /********* Put hidden parameter for the type of figure (statistic) ***********/ /*****************************************************************************/ -static void Fig_PutParScopeFig (HieLvl_Level_t ScopeFig) +static void Fig_PutParFigScope (HieLvl_Level_t Level) { - Sco_PutParScope ("ScopeFig",ScopeFig); + Sco_PutParScope ("FigScope",Level); } /*****************************************************************************/ diff --git a/swad_figure.h b/swad_figure.h index 445bf1fb..5001b069 100644 --- a/swad_figure.h +++ b/swad_figure.h @@ -76,7 +76,7 @@ typedef enum struct Fig_Figures { - HieLvl_Level_t Scope; + HieLvl_Level_t Level; Fig_FigureType_t FigureType; }; diff --git a/swad_figure_cache.c b/swad_figure_cache.c index 5fabaad2..5eab1a86 100644 --- a/swad_figure_cache.c +++ b/swad_figure_cache.c @@ -39,7 +39,7 @@ /*****************************************************************************/ void FigCch_UpdateFigureIntoCache (FigCch_FigureCached_t Figure, - HieLvl_Level_t Scope,long Cod, + HieLvl_Level_t Level,long Cod, FigCch_Type_t Type,const void *ValuePtr) { /***** Trivial check *****/ @@ -50,11 +50,11 @@ void FigCch_UpdateFigureIntoCache (FigCch_FigureCached_t Figure, switch (Type) { case FigCch_UNSIGNED: - Fig_DB_UpdateUnsignedFigureIntoCache (Figure,Scope,Cod, + Fig_DB_UpdateUnsignedFigureIntoCache (Figure,Level,Cod, *((unsigned *) ValuePtr)); break; case FigCch_DOUBLE: - Fig_DB_UpdateDoubleFigureIntoCache (Figure,Scope,Cod, + Fig_DB_UpdateDoubleFigureIntoCache (Figure,Level,Cod, *((double *) ValuePtr)); break; } @@ -66,7 +66,7 @@ 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, - HieLvl_Level_t Scope,long Cod, + HieLvl_Level_t Level,long Cod, FigCch_Type_t Type,void *ValuePtr) { /* The higher the level, the longer a value remains cached */ @@ -97,11 +97,11 @@ bool FigCch_GetFigureFromCache (FigCch_FigureCached_t Figure, /***** Trivial check *****/ if (Figure == FigCch_UNKNOWN || // Unknown figure - Scope == HieLvl_UNK) // Unknown scope + Level == HieLvl_UNK) // Unknown scope return false; /***** Get figure's value if cached and recent *****/ - if (Fig_DB_GetFigureFromCache (&mysql_res,Figure,Scope,Cod,Type,TimeCached[Scope])) + if (Fig_DB_GetFigureFromCache (&mysql_res,Figure,Level,Cod,Type,TimeCached[Level])) { /* Get row */ row = mysql_fetch_row (mysql_res); diff --git a/swad_figure_cache.h b/swad_figure_cache.h index 8fbf474e..9fbd38e2 100644 --- a/swad_figure_cache.h +++ b/swad_figure_cache.h @@ -111,10 +111,10 @@ typedef enum /*****************************************************************************/ void FigCch_UpdateFigureIntoCache (FigCch_FigureCached_t Figure, - HieLvl_Level_t Scope,long Cod, + HieLvl_Level_t Level,long Cod, FigCch_Type_t Type,const void *ValuePtr); bool FigCch_GetFigureFromCache (FigCch_FigureCached_t Figure, - HieLvl_Level_t Scope,long Cod, + HieLvl_Level_t Level,long Cod, FigCch_Type_t Type,void *ValuePtr); #endif diff --git a/swad_figure_database.c b/swad_figure_database.c index 3169c4bf..1640bf5a 100644 --- a/swad_figure_database.c +++ b/swad_figure_database.c @@ -34,7 +34,7 @@ /*****************************************************************************/ void Fig_DB_UpdateUnsignedFigureIntoCache (FigCch_FigureCached_t Figure, - HieLvl_Level_t Scope,long Cod, + HieLvl_Level_t Level,long Cod, unsigned Value) { DB_QueryREPLACE ("can not update cached figure value", @@ -43,7 +43,7 @@ void Fig_DB_UpdateUnsignedFigureIntoCache (FigCch_FigureCached_t Figure, " VALUES" " (%u,'%s',%ld,%u,'0.0')", (unsigned) Figure, - Sco_GetDBStrFromScope (Scope), + Hie_GetDBStrFromLevel (Level), Cod, Value); } @@ -53,7 +53,7 @@ void Fig_DB_UpdateUnsignedFigureIntoCache (FigCch_FigureCached_t Figure, /*****************************************************************************/ void Fig_DB_UpdateDoubleFigureIntoCache (FigCch_FigureCached_t Figure, - HieLvl_Level_t Scope,long Cod, + HieLvl_Level_t Level,long Cod, double Value) { Str_SetDecimalPointToUS (); // To write the decimal point as a dot @@ -63,20 +63,19 @@ void Fig_DB_UpdateDoubleFigureIntoCache (FigCch_FigureCached_t Figure, " VALUES" " (%u,'%s',%ld,0,'%.15lg')", (unsigned) Figure, - Sco_GetDBStrFromScope (Scope), + Hie_GetDBStrFromLevel (Level), Cod, Value); Str_SetDecimalPointToLocal (); // Return to local system } - /***** Get figure's value if cached and recent *****/ /*****************************************************************************/ /************************** Get figure from cache ****************************/ /*****************************************************************************/ unsigned Fig_DB_GetFigureFromCache (MYSQL_RES **mysql_res, FigCch_FigureCached_t Figure, - HieLvl_Level_t Scope,long Cod, + HieLvl_Level_t Level,long Cod, FigCch_Type_t Type,time_t TimeCached) { static const char *Field[FigCch_NUM_TYPES] = @@ -94,6 +93,6 @@ unsigned Fig_DB_GetFigureFromCache (MYSQL_RES **mysql_res, " AND Cod=%ld" " AND LastUpdate>FROM_UNIXTIME(UNIX_TIMESTAMP()-%lu)", Field[Type], - (unsigned) Figure,Sco_GetDBStrFromScope (Scope),Cod, + (unsigned) Figure,Hie_GetDBStrFromLevel (Level),Cod, TimeCached); } diff --git a/swad_figure_database.h b/swad_figure_database.h index 7b3478a3..9b1d8a27 100644 --- a/swad_figure_database.h +++ b/swad_figure_database.h @@ -37,15 +37,15 @@ /*****************************************************************************/ void Fig_DB_UpdateUnsignedFigureIntoCache (FigCch_FigureCached_t Figure, - HieLvl_Level_t Scope,long Cod, + HieLvl_Level_t Level,long Cod, unsigned Value); void Fig_DB_UpdateDoubleFigureIntoCache (FigCch_FigureCached_t Figure, - HieLvl_Level_t Scope,long Cod, + HieLvl_Level_t Level,long Cod, double Value); unsigned Fig_DB_GetFigureFromCache (MYSQL_RES **mysql_res, FigCch_FigureCached_t Figure, - HieLvl_Level_t Scope,long Cod, + HieLvl_Level_t Level,long Cod, FigCch_Type_t Type,time_t TimeCached); #endif diff --git a/swad_follow_database.c b/swad_follow_database.c index 6b221f99..336a8f21 100644 --- a/swad_follow_database.c +++ b/swad_follow_database.c @@ -401,7 +401,7 @@ unsigned Fol_DB_GetNumFollowinFollowers (unsigned Fol) Gbl.Hierarchy.Crs.CrsCod, FieldDB[Fol]); default: - Err_WrongScopeExit (); + Err_WrongHierarchyLevelExit (); return 0; // Not reached } } @@ -508,7 +508,7 @@ double Fol_DB_GetNumFollowedPerFollower (unsigned Fol) FieldDB[Fol], FieldDB[1 - Fol]); default: - Err_WrongScopeExit (); + Err_WrongHierarchyLevelExit (); return 0.0; // Not reached } } @@ -663,7 +663,7 @@ unsigned Fol_DB_GetRankingFollowers (MYSQL_RES **mysql_res) Gbl.Hierarchy.Crs.CrsCod); break; default: - Err_WrongScopeExit (); + Err_WrongHierarchyLevelExit (); return 0; // Not reached } } diff --git a/swad_forum.c b/swad_forum.c index 773fdbb3..08214437 100644 --- a/swad_forum.c +++ b/swad_forum.c @@ -3330,7 +3330,7 @@ void For_GetAndShowForumStats (void) For_ShowStatOfAForumType (For_FORUM_COURSE_TCHS,-1L,-1L,-1L,-1L,Gbl.Hierarchy.Crs.CrsCod,&FiguresForum); break; default: - Err_WrongScopeExit (); + Err_WrongHierarchyLevelExit (); break; } diff --git a/swad_forum_database.c b/swad_forum_database.c index a806196a..3993211e 100644 --- a/swad_forum_database.c +++ b/swad_forum_database.c @@ -126,7 +126,7 @@ unsigned For_DB_GetNumPstsOfUsrInForum (const struct For_Forum *Forum, /************* Remove all threads and posts in forums of a scope *************/ /*****************************************************************************/ -void For_DB_RemoveForums (HieLvl_Level_t Scope,long HieCod) +void For_DB_RemoveForums (HieLvl_Level_t Level,long HieCod) { static const struct { @@ -156,8 +156,8 @@ void For_DB_RemoveForums (HieLvl_Level_t Scope,long HieCod) " AND for_threads.HieCod=%ld" " AND for_threads.ThrCod=for_posts.ThrCod" " AND for_posts.PstCod=for_disabled.PstCod", - ForumType[Scope].Usrs, - ForumType[Scope].Tchs, + ForumType[Level].Usrs, + ForumType[Level].Tchs, HieCod); /***** Remove posts *****/ @@ -171,8 +171,8 @@ void For_DB_RemoveForums (HieLvl_Level_t Scope,long HieCod) " for_threads.ForumType=%u)" " AND for_threads.HieCod=%ld" " AND for_threads.ThrCod=for_posts.ThrCod", - ForumType[Scope].Usrs, - ForumType[Scope].Tchs, + ForumType[Level].Usrs, + ForumType[Level].Tchs, HieCod); /***** Remove threads read *****/ @@ -186,8 +186,8 @@ void For_DB_RemoveForums (HieLvl_Level_t Scope,long HieCod) " for_threads.ForumType=%u)" " AND for_threads.HieCod=%ld" " AND for_threads.ThrCod=for_read.ThrCod", - ForumType[Scope].Usrs, - ForumType[Scope].Tchs, + ForumType[Level].Usrs, + ForumType[Level].Tchs, HieCod); /***** Remove threads *****/ @@ -198,8 +198,8 @@ void For_DB_RemoveForums (HieLvl_Level_t Scope,long HieCod) " OR" " for_threads.ForumType=%u)" " AND HieCod=%ld", - ForumType[Scope].Usrs, - ForumType[Scope].Tchs, + ForumType[Level].Usrs, + ForumType[Level].Tchs, HieCod); } diff --git a/swad_forum_database.h b/swad_forum_database.h index a11d9c29..e0adfb6e 100644 --- a/swad_forum_database.h +++ b/swad_forum_database.h @@ -39,7 +39,7 @@ unsigned For_DB_GetNumThrsInForumNewerThan (const struct For_Forum *Forum, const char *Time); unsigned For_DB_GetNumPstsOfUsrInForum (const struct For_Forum *Forum, long UsrCod); -void For_DB_RemoveForums (HieLvl_Level_t Scope,long HieCod); +void For_DB_RemoveForums (HieLvl_Level_t Level,long HieCod); //------------------------------- Posts --------------------------------------- long For_DB_InsertForumPst (long ThrCod,long UsrCod, diff --git a/swad_forum_resource.c b/swad_forum_resource.c index 2f66c1c9..a05569be 100644 --- a/swad_forum_resource.c +++ b/swad_forum_resource.c @@ -33,12 +33,6 @@ #include "swad_parameter_code.h" #include "swad_resource_database.h" -/*****************************************************************************/ -/************** External global variables from others modules ****************/ -/*****************************************************************************/ - -extern struct Globals Gbl; - /*****************************************************************************/ /**************************** Get link to thread *****************************/ /*****************************************************************************/ diff --git a/swad_game_database.c b/swad_game_database.c index 04dd4be1..02abd916 100644 --- a/swad_game_database.c +++ b/swad_game_database.c @@ -274,10 +274,10 @@ bool Gam_DB_CheckIfSimilarGameExists (const struct Gam_Game *Game) /*****************************************************************************/ // Returns the number of courses with games in this location -unsigned Gam_DB_GetNumCoursesWithGames (HieLvl_Level_t Scope) +unsigned Gam_DB_GetNumCoursesWithGames (HieLvl_Level_t Level) { /***** Get number of courses with games from database *****/ - switch (Scope) + switch (Level) { case HieLvl_SYS: return (unsigned) @@ -349,10 +349,10 @@ unsigned Gam_DB_GetNumCoursesWithGames (HieLvl_Level_t Scope) /*****************************************************************************/ // Returns the number of games in this location -unsigned Gam_DB_GetNumGames (HieLvl_Level_t Scope) +unsigned Gam_DB_GetNumGames (HieLvl_Level_t Level) { /***** Get number of games from database *****/ - switch (Scope) + switch (Level) { case HieLvl_SYS: return (unsigned) @@ -652,10 +652,10 @@ unsigned Gam_DB_GetNextQuestionIndexInGame (long GamCod,unsigned QstInd) /***************** Get average number of questions per game ******************/ /*****************************************************************************/ -double Gam_DB_GetNumQstsPerGame (HieLvl_Level_t Scope) +double Gam_DB_GetNumQstsPerGame (HieLvl_Level_t Level) { /***** Get number of questions per game from database *****/ - switch (Scope) + switch (Level) { case HieLvl_SYS: return @@ -742,7 +742,7 @@ double Gam_DB_GetNumQstsPerGame (HieLvl_Level_t Scope) " GROUP BY gam_questions.GamCod) AS NumQstsTable", Gbl.Hierarchy.Crs.CrsCod); default: - Err_WrongScopeExit (); + Err_WrongHierarchyLevelExit (); return 0.0; // Not reached } } diff --git a/swad_game_database.h b/swad_game_database.h index ca82ab2c..240f8fc9 100644 --- a/swad_game_database.h +++ b/swad_game_database.h @@ -47,8 +47,8 @@ unsigned Gam_DB_GetGameDataByCod (MYSQL_RES **mysql_res,long GamCod); void Gam_DB_GetGameTitle (long GamCod,char *Title,size_t TitleSize); void Gam_DB_GetGameTxt (long GamCod,char Txt[Cns_MAX_BYTES_TEXT + 1]); bool Gam_DB_CheckIfSimilarGameExists (const struct Gam_Game *Game); -unsigned Gam_DB_GetNumCoursesWithGames (HieLvl_Level_t Scope); -unsigned Gam_DB_GetNumGames (HieLvl_Level_t Scope); +unsigned Gam_DB_GetNumCoursesWithGames (HieLvl_Level_t Level); +unsigned Gam_DB_GetNumGames (HieLvl_Level_t Level); void Gam_DB_RemoveGame (long GamCod); void Gam_DB_RemoveCrsGames (long CrsCod); @@ -67,7 +67,7 @@ unsigned Gam_DB_GetQstIndFromQstCod (long GamCod,long QstCod); unsigned Gam_DB_GetMaxQuestionIndexInGame (long GamCod); unsigned Gam_DB_GetPrevQuestionIndexInGame (long GamCod,unsigned QstInd); unsigned Gam_DB_GetNextQuestionIndexInGame (long GamCod,unsigned QstInd); -double Gam_DB_GetNumQstsPerGame (HieLvl_Level_t Scope); +double Gam_DB_GetNumQstsPerGame (HieLvl_Level_t Level); unsigned Gam_DB_GetTstTagsPresentInAGame (MYSQL_RES **mysql_res,long GamCod); unsigned Gam_DB_GetNumAnswersOfQstsInGame (MYSQL_RES **mysql_res,long GamCod); diff --git a/swad_global.h b/swad_global.h index dca3c35a..f19b2885 100644 --- a/swad_global.h +++ b/swad_global.h @@ -89,17 +89,23 @@ struct Globals { HieLvl_Level_t Level; // Current level in the hierarchy: system, country, institution, center, degree or course long Cod; // Code of the current country, institution, center, degree or course - struct ListCountries Ctys;// List of countries + struct Cty_ListCtys Ctys; // List of countries struct Cty_Countr Cty; // Current country - struct ListInstits Inss; // List of institutions in current country + struct Ins_ListInss Inss; // List of institutions in current country struct Ins_Instit Ins; // Current institution - struct ListCenters Ctrs; // List of centers in current institution + struct Ctr_ListCtrs Ctrs; // List of centers in current institution struct Ctr_Center Ctr; // Current center - struct ListDegrees Degs; // List of degrees in current center + struct Deg_ListDegs Degs; // List of degrees in current center struct Deg_Degree Deg; // Current degree - struct Crs_ListCourses Crss; // List of courses in current degree + struct Crs_ListCrss Crss; // List of courses in current degree struct Crs_Course Crs; // Current course. Aditional info about course is stored in Gbl.Crs. } Hierarchy; + struct + { + HieLvl_Level_t Current; + HieLvl_Level_t Default; + unsigned Allowed; + } Scope; struct { bool IsWebService; // Must generate HTML output (IsWebService==false) or SOAP-XML output (IsWebService==true)? @@ -227,12 +233,6 @@ struct Globals char FileNamePhoto[NAME_MAX + 1]; // File name (with no path and no .jpg) of the temporary file with the selected face Enr_RegRemOneUsrAction_t RegRemAction; // Enrolment action } Usrs; - struct - { - HieLvl_Level_t Current; - HieLvl_Level_t Default; - unsigned Allowed; - } Scope; struct { char PathPriv[PATH_MAX + 1]; // Absolute path to the private directory of the course diff --git a/swad_hierarchy.c b/swad_hierarchy.c index 73f8816c..5fc35afe 100644 --- a/swad_hierarchy.c +++ b/swad_hierarchy.c @@ -523,22 +523,22 @@ void Hie_SetHierarchyFromUsrLastHierarchy (void) Hie_ResetHierarchy (); /***** Copy last hierarchy scope and code to current hierarchy *****/ - switch (Gbl.Usrs.Me.UsrLast.LastHie.Scope) + switch (Gbl.Usrs.Me.UsrLast.LastHie.Level) { case HieLvl_CTY: // Country - Gbl.Hierarchy.Cty.CtyCod = Gbl.Usrs.Me.UsrLast.LastHie.Cod; + Gbl.Hierarchy.Cty.CtyCod = Gbl.Usrs.Me.UsrLast.LastHie.HieCod; break; case HieLvl_INS: // Institution - Gbl.Hierarchy.Ins.InsCod = Gbl.Usrs.Me.UsrLast.LastHie.Cod; + Gbl.Hierarchy.Ins.InsCod = Gbl.Usrs.Me.UsrLast.LastHie.HieCod; break; case HieLvl_CTR: // Center - Gbl.Hierarchy.Ctr.CtrCod = Gbl.Usrs.Me.UsrLast.LastHie.Cod; + Gbl.Hierarchy.Ctr.CtrCod = Gbl.Usrs.Me.UsrLast.LastHie.HieCod; break; case HieLvl_DEG: // Degree - Gbl.Hierarchy.Deg.DegCod = Gbl.Usrs.Me.UsrLast.LastHie.Cod; + Gbl.Hierarchy.Deg.DegCod = Gbl.Usrs.Me.UsrLast.LastHie.HieCod; break; case HieLvl_CRS: // Course - Gbl.Hierarchy.Crs.CrsCod = Gbl.Usrs.Me.UsrLast.LastHie.Cod; + Gbl.Hierarchy.Crs.CrsCod = Gbl.Usrs.Me.UsrLast.LastHie.HieCod; break; default: break; @@ -760,7 +760,7 @@ void Hie_GetAndWriteInsCtrDegAdminBy (long UsrCod,unsigned ColSpan) } break; default: // There are no administrators in other scopes - Err_WrongScopeExit (); + Err_WrongHierarchyLevelExit (); break; } HTM_TD_End (); @@ -1041,7 +1041,7 @@ static void Hie_GetAndShowHierarchyWithInss (void) case HieLvl_CRS: break; default: - Err_WrongScopeExit (); + Err_WrongHierarchyLevelExit (); break; } @@ -1082,7 +1082,7 @@ static void Hie_GetAndShowHierarchyWithCtrs (void) case HieLvl_CRS: break; default: - Err_WrongScopeExit (); + Err_WrongHierarchyLevelExit (); break; } @@ -1127,7 +1127,7 @@ static void Hie_GetAndShowHierarchyWithDegs (void) case HieLvl_CRS: break; default: - Err_WrongScopeExit (); + Err_WrongHierarchyLevelExit (); break; } @@ -1176,7 +1176,7 @@ static void Hie_GetAndShowHierarchyWithCrss (void) case HieLvl_CRS: break; default: - Err_WrongScopeExit (); + Err_WrongHierarchyLevelExit (); break; } @@ -1265,7 +1265,7 @@ static void Hie_GetAndShowHierarchyTotal (void) case HieLvl_CRS: break; default: - Err_WrongScopeExit (); + Err_WrongHierarchyLevelExit (); break; } diff --git a/swad_hierarchy_config.c b/swad_hierarchy_config.c index 7be9cecc..088c1a6f 100644 --- a/swad_hierarchy_config.c +++ b/swad_hierarchy_config.c @@ -334,7 +334,7 @@ void HieCfg_QR (ParCod_Param_t ParCode,long HieCod) /************************ Number of users in courses *************************/ /*****************************************************************************/ -void HieCfg_NumUsrsInCrss (HieLvl_Level_t Scope,long Cod,Rol_Role_t Role) +void HieCfg_NumUsrsInCrss (HieLvl_Level_t Level,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]; @@ -349,7 +349,7 @@ void HieCfg_NumUsrsInCrss (HieLvl_Level_t Scope,long Cod,Rol_Role_t Role) /* Data */ HTM_TD_Begin ("class=\"LB DAT_%s\"",The_GetSuffix ()); - HTM_Unsigned (Enr_GetCachedNumUsrsInCrss (Scope,Cod, + HTM_Unsigned (Enr_GetCachedNumUsrsInCrss (Level,Cod, Role == Rol_UNK ? (1 << Rol_STD) | (1 << Rol_NET) | (1 << Rol_TCH) : // Any user diff --git a/swad_hierarchy_config.h b/swad_hierarchy_config.h index 70a60fb1..94202d77 100644 --- a/swad_hierarchy_config.h +++ b/swad_hierarchy_config.h @@ -50,6 +50,6 @@ void HieCfg_Shortcut (bool PrintView,ParCod_Param_t ParCode,long HieCod); void HieCfg_NumCtrs (unsigned NumCtrs,bool PutForm); void HieCfg_NumCtrsWithMap (unsigned NumCtrs,unsigned NumCtrsWithMap); void HieCfg_QR (ParCod_Param_t ParCode,long HieCod); -void HieCfg_NumUsrsInCrss (HieLvl_Level_t Scope,long Cod,Rol_Role_t Role); +void HieCfg_NumUsrsInCrss (HieLvl_Level_t Level,long Cod,Rol_Role_t Role); #endif diff --git a/swad_hierarchy_database.c b/swad_hierarchy_database.c index 39fe5eeb..56351d03 100644 --- a/swad_hierarchy_database.c +++ b/swad_hierarchy_database.c @@ -34,7 +34,7 @@ /******************* Get number of countries with users **********************/ /*****************************************************************************/ -void Hie_DB_BuildSubquery (char SubQuery[128],HieLvl_Level_t Scope,long Cod) +void Hie_DB_BuildSubquery (char SubQuery[128],HieLvl_Level_t Level,long HieCod) { static const char *Format[HieLvl_NUM_LEVELS] = { @@ -47,8 +47,8 @@ void Hie_DB_BuildSubquery (char SubQuery[128],HieLvl_Level_t Scope,long Cod) [HieLvl_CRS] = "crs_users.CrsCod=%ld AND ", // Course }; - if (Cod > 0) - sprintf (SubQuery,Format[Scope],Cod); + if (HieCod > 0) + sprintf (SubQuery,Format[Level],HieCod); else SubQuery[0] = '\0'; } @@ -97,8 +97,8 @@ unsigned Hie_DB_GetInsCtrDegAdminBy (MYSQL_RES **mysql_res,long UsrCod) " AND usr_admins.Cod=deg_degrees.DegCod)" " ORDER BY S," "FullName", - (unsigned) HieLvl_SYS,UsrCod,Sco_GetDBStrFromScope (HieLvl_SYS), - (unsigned) HieLvl_INS,UsrCod,Sco_GetDBStrFromScope (HieLvl_INS), - (unsigned) HieLvl_CTR,UsrCod,Sco_GetDBStrFromScope (HieLvl_CTR), - (unsigned) HieLvl_DEG,UsrCod,Sco_GetDBStrFromScope (HieLvl_DEG)); + (unsigned) HieLvl_SYS,UsrCod,Hie_GetDBStrFromLevel (HieLvl_SYS), + (unsigned) HieLvl_INS,UsrCod,Hie_GetDBStrFromLevel (HieLvl_INS), + (unsigned) HieLvl_CTR,UsrCod,Hie_GetDBStrFromLevel (HieLvl_CTR), + (unsigned) HieLvl_DEG,UsrCod,Hie_GetDBStrFromLevel (HieLvl_DEG)); } diff --git a/swad_hierarchy_database.h b/swad_hierarchy_database.h index e7ea0c58..41038a7e 100644 --- a/swad_hierarchy_database.h +++ b/swad_hierarchy_database.h @@ -33,7 +33,7 @@ /***************************** Public prototypes *****************************/ /*****************************************************************************/ -void Hie_DB_BuildSubquery (char SubQuery[128],HieLvl_Level_t Scope,long Cod); +void Hie_DB_BuildSubquery (char SubQuery[128],HieLvl_Level_t Level,long HieCod); unsigned Hie_DB_GetInsCtrDegAdminBy (MYSQL_RES **mysql_res,long UsrCod); #endif diff --git a/swad_indicator_database.c b/swad_indicator_database.c index 80dd09d2..21b5c9ee 100644 --- a/swad_indicator_database.c +++ b/swad_indicator_database.c @@ -360,7 +360,7 @@ unsigned Ind_DB_GetTableOfCourses (MYSQL_RES **mysql_res, "crs_courses.FullName", Gbl.Hierarchy.Crs.CrsCod); default: - Err_WrongScopeExit (); + Err_WrongHierarchyLevelExit (); return 0; // Not reached } } diff --git a/swad_institution.c b/swad_institution.c index 3756f345..b35e5163 100644 --- a/swad_institution.c +++ b/swad_institution.c @@ -1635,7 +1635,7 @@ unsigned Ins_GetCachedNumInssInCty (long CtyCod) unsigned Ins_GetCachedNumInssWithCtrs (void) { unsigned NumInssWithCtrs; - long Cod = Sco_GetCurrentCod (); + long Cod = Hie_GetCurrentCod (); /***** Get number of institutions with centers from cache *****/ if (!FigCch_GetFigureFromCache (FigCch_NUM_INSS_WITH_CTRS,Gbl.Scope.Current,Cod, @@ -1657,7 +1657,7 @@ unsigned Ins_GetCachedNumInssWithCtrs (void) unsigned Ins_GetCachedNumInssWithDegs (void) { unsigned NumInssWithDegs; - long Cod = Sco_GetCurrentCod (); + long Cod = Hie_GetCurrentCod (); /***** Get number of institutions with degrees from cache *****/ if (!FigCch_GetFigureFromCache (FigCch_NUM_INSS_WITH_DEGS,Gbl.Scope.Current,Cod, @@ -1679,7 +1679,7 @@ unsigned Ins_GetCachedNumInssWithDegs (void) unsigned Ins_GetCachedNumInssWithCrss (void) { unsigned NumInssWithCrss; - long Cod = Sco_GetCurrentCod (); + long Cod = Hie_GetCurrentCod (); /***** Get number of institutions with courses from cache *****/ if (!FigCch_GetFigureFromCache (FigCch_NUM_INSS_WITH_CRSS,Gbl.Scope.Current,Cod, @@ -1707,7 +1707,7 @@ unsigned Ins_GetCachedNumInssWithUsrs (Rol_Role_t Role) [Rol_TCH] = FigCch_NUM_INSS_WITH_TCHS, // Teachers }; unsigned NumInssWithUsrs; - long Cod = Sco_GetCurrentCod (); + long Cod = Hie_GetCurrentCod (); /***** Get number of institutions with users from cache *****/ if (!FigCch_GetFigureFromCache (FigureInss[Role],Gbl.Scope.Current,Cod, @@ -2010,7 +2010,7 @@ void Ins_GetAndShowInstitutionsStats (void) /***** Form to select type of list used to display degree photos *****/ Set_GetAndUpdatePrefsAboutUsrList (); - Figures.Scope = Gbl.Scope.Current; + Figures.Level = Gbl.Scope.Current; Figures.FigureType = Fig_INSTITS; Usr_ShowFormsToSelectUsrListType (Fig_PutParsFigures,&Figures); diff --git a/swad_institution.h b/swad_institution.h index a15f192f..6c56fe09 100644 --- a/swad_institution.h +++ b/swad_institution.h @@ -61,7 +61,7 @@ typedef enum } Ins_Order_t; #define Ins_ORDER_DEFAULT Ins_ORDER_BY_NUM_USRS -struct ListInstits +struct Ins_ListInss { unsigned Num; // Number of institutions struct Ins_Instit *Lst; // List of institutions diff --git a/swad_institution_database.c b/swad_institution_database.c index 1dba73c1..3a4f590d 100644 --- a/swad_institution_database.c +++ b/swad_institution_database.c @@ -382,7 +382,7 @@ unsigned Ins_DB_GetInssOrderedByNumCtrs (MYSQL_RES **mysql_res) " GROUP BY InsCod", Gbl.Hierarchy.Ins.InsCod); default: - Err_WrongScopeExit (); + Err_WrongHierarchyLevelExit (); return 0; // Not reached } } @@ -435,7 +435,7 @@ unsigned Ins_DB_GetInssOrderedByNumDegs (MYSQL_RES **mysql_res) " ORDER BY N DESC", Gbl.Hierarchy.Ins.InsCod); default: - Err_WrongScopeExit (); + Err_WrongHierarchyLevelExit (); return 0; // Not reached } } @@ -494,7 +494,7 @@ unsigned Ins_DB_GetInssOrderedByNumCrss (MYSQL_RES **mysql_res) " ORDER BY N DESC", Gbl.Hierarchy.Ins.InsCod); default: - Err_WrongScopeExit (); + Err_WrongHierarchyLevelExit (); return 0; // Not reached } } @@ -560,7 +560,7 @@ unsigned Ins_DB_GetInssOrderedByNumUsrsInCrss (MYSQL_RES **mysql_res) " ORDER BY N DESC", Gbl.Hierarchy.Ins.InsCod); default: - Err_WrongScopeExit (); + Err_WrongHierarchyLevelExit (); return 0; // Not reached } } @@ -607,7 +607,7 @@ unsigned Ins_DB_GetInssOrderedByNumUsrsWhoClaimToBelongToThem (MYSQL_RES **mysql " ORDER BY N DESC", Gbl.Hierarchy.Ins.InsCod); default: - Err_WrongScopeExit (); + Err_WrongHierarchyLevelExit (); return 0; // Not reached } } @@ -656,11 +656,11 @@ unsigned Ins_DB_GetNumInssInCty (long CtyCod) /****************** Get number of institutions with centres ******************/ /*****************************************************************************/ -unsigned Ins_DB_GetNumInssWithCtrs (HieLvl_Level_t Scope,long Cod) +unsigned Ins_DB_GetNumInssWithCtrs (HieLvl_Level_t Level,long HieCod) { char SubQuery[128]; - Hie_DB_BuildSubquery (SubQuery,Scope,Cod); + Hie_DB_BuildSubquery (SubQuery,Level,HieCod); return (unsigned) DB_QueryCOUNT ("can not get number of institutions with centers", @@ -676,11 +676,11 @@ unsigned Ins_DB_GetNumInssWithCtrs (HieLvl_Level_t Scope,long Cod) /****************** Get number of institutions with degrees ******************/ /*****************************************************************************/ -unsigned Ins_DB_GetNumInssWithDegs (HieLvl_Level_t Scope,long Cod) +unsigned Ins_DB_GetNumInssWithDegs (HieLvl_Level_t Level,long HieCod) { char SubQuery[128]; - Hie_DB_BuildSubquery (SubQuery,Scope,Cod); + Hie_DB_BuildSubquery (SubQuery,Level,HieCod); return (unsigned) DB_QueryCOUNT ("can not get number of institutions with degrees", @@ -698,11 +698,11 @@ unsigned Ins_DB_GetNumInssWithDegs (HieLvl_Level_t Scope,long Cod) /****************** Get number of institutions with courses ******************/ /*****************************************************************************/ -unsigned Ins_DB_GetNumInssWithCrss (HieLvl_Level_t Scope,long Cod) +unsigned Ins_DB_GetNumInssWithCrss (HieLvl_Level_t Level,long HieCod) { char SubQuery[128]; - Hie_DB_BuildSubquery (SubQuery,Scope,Cod); + Hie_DB_BuildSubquery (SubQuery,Level,HieCod); return (unsigned) DB_QueryCOUNT ("can not get number of institutions with courses", @@ -723,11 +723,11 @@ unsigned Ins_DB_GetNumInssWithCrss (HieLvl_Level_t Scope,long Cod) /*****************************************************************************/ unsigned Ins_DB_GetNumInnsWithUsrs (Rol_Role_t Role, - HieLvl_Level_t Scope,long Cod) + HieLvl_Level_t Level,long HieCod) { char SubQuery[128]; - Hie_DB_BuildSubquery (SubQuery,Scope,Cod); + Hie_DB_BuildSubquery (SubQuery,Level,HieCod); return (unsigned) DB_QueryCOUNT ("can not get number of institutions with users", diff --git a/swad_institution_database.h b/swad_institution_database.h index 693d6ce5..f2429537 100644 --- a/swad_institution_database.h +++ b/swad_institution_database.h @@ -70,11 +70,11 @@ unsigned Ins_DB_SearchInss (MYSQL_RES **mysql_res, unsigned Ins_DB_GetNumInssInCty (long CtyCod); -unsigned Ins_DB_GetNumInssWithCtrs (HieLvl_Level_t Scope,long Cod); -unsigned Ins_DB_GetNumInssWithDegs (HieLvl_Level_t Scope,long Cod); -unsigned Ins_DB_GetNumInssWithCrss (HieLvl_Level_t Scope,long Cod); +unsigned Ins_DB_GetNumInssWithCtrs (HieLvl_Level_t Level,long HieCod); +unsigned Ins_DB_GetNumInssWithDegs (HieLvl_Level_t Level,long HieCod); +unsigned Ins_DB_GetNumInssWithCrss (HieLvl_Level_t Level,long HieCod); unsigned Ins_DB_GetNumInnsWithUsrs (Rol_Role_t Role, - HieLvl_Level_t Scope,long Cod); + HieLvl_Level_t Level,long HieCod); unsigned Ins_DB_GetInssFromUsr (MYSQL_RES **mysql_res,long UsrCod,long CtyCod); bool Ins_DB_CheckIfUsrBelongsToIns (long UsrCod,long InsCod); diff --git a/swad_logo.c b/swad_logo.c index b8dd7511..15429cd8 100644 --- a/swad_logo.c +++ b/swad_logo.c @@ -62,7 +62,7 @@ static void Lgo_PutIconToRemoveLogo (Act_Action_t ActionRem); /***************** Draw institution, center or degree logo *******************/ /*****************************************************************************/ -void Lgo_DrawLogo (HieLvl_Level_t Scope,long Cod,const char *AltText, +void Lgo_DrawLogo (HieLvl_Level_t Level,long HieCod,const char *AltText, unsigned Size,const char *Class) { static const char *HieIcon[HieLvl_NUM_LEVELS] = @@ -82,15 +82,15 @@ void Lgo_DrawLogo (HieLvl_Level_t Scope,long Cod,const char *AltText, bool ClassNotEmpty; /***** Path to logo *****/ - if (HieIcon[Scope]) // Scope is correct + if (HieIcon[Level]) // Scope is correct { - if (Cod > 0) // Institution, center or degree exists + if (HieCod > 0) // Institution, center or degree exists { /* Degree */ - if (Scope == HieLvl_DEG) + if (Level == HieLvl_DEG) { Folder = Cfg_FOLDER_DEG; - DegCod = Cod; + DegCod = HieCod; snprintf (PathLogo,sizeof (PathLogo),"%s/%02u/%u/logo/%u.png", Cfg_PATH_DEG_PUBLIC, (unsigned) (DegCod % 100), @@ -98,17 +98,17 @@ void Lgo_DrawLogo (HieLvl_Level_t Scope,long Cod,const char *AltText, (unsigned) DegCod); LogoFound = Fil_CheckIfPathExists (PathLogo); if (LogoFound) - Cod = DegCod; + HieCod = DegCod; } /* Center */ - if (!LogoFound && Scope != HieLvl_INS) + if (!LogoFound && Level != HieLvl_INS) { Folder = Cfg_FOLDER_CTR; - if (Scope == HieLvl_DEG) // && !LogoFound - CtrCod = Deg_DB_GetCtrCodOfDegreeByCod (Cod); + if (Level == HieLvl_DEG) // && !LogoFound + CtrCod = Deg_DB_GetCtrCodOfDegreeByCod (HieCod); else - CtrCod = Cod; + CtrCod = HieCod; snprintf (PathLogo,sizeof (PathLogo),"%s/%02u/%u/logo/%u.png", Cfg_PATH_CTR_PUBLIC, (unsigned) (CtrCod % 100), @@ -116,19 +116,19 @@ void Lgo_DrawLogo (HieLvl_Level_t Scope,long Cod,const char *AltText, (unsigned) CtrCod); LogoFound = Fil_CheckIfPathExists (PathLogo); if (LogoFound) - Cod = CtrCod; + HieCod = CtrCod; } /* Institution */ if (!LogoFound) { Folder = Cfg_FOLDER_INS; - if (Scope == HieLvl_DEG) // && !LogoFound - InsCod = Deg_DB_GetInsCodOfDegreeByCod (Cod); - else if (Scope == HieLvl_CTR) // && !LogoFound - InsCod = Ctr_DB_GetInsCodOfCenterByCod (Cod); + if (Level == HieLvl_DEG) // && !LogoFound + InsCod = Deg_DB_GetInsCodOfDegreeByCod (HieCod); + else if (Level == HieLvl_CTR) // && !LogoFound + InsCod = Ctr_DB_GetInsCodOfCenterByCod (HieCod); else - InsCod = Cod; + InsCod = HieCod; snprintf (PathLogo,sizeof (PathLogo),"%s/%02u/%u/logo/%u.png", Cfg_PATH_INS_PUBLIC, (unsigned) (InsCod % 100), @@ -136,7 +136,7 @@ void Lgo_DrawLogo (HieLvl_Level_t Scope,long Cod,const char *AltText, (unsigned) InsCod); LogoFound = Fil_CheckIfPathExists (PathLogo); if (LogoFound) - Cod = InsCod; + HieCod = InsCod; } /***** Draw logo *****/ @@ -149,10 +149,10 @@ void Lgo_DrawLogo (HieLvl_Level_t Scope,long Cod,const char *AltText, { if (asprintf (&URL,"%s/%s/%02u/%u/logo", Cfg_URL_SWAD_PUBLIC,Folder, - (unsigned) (Cod % 100), - (unsigned) Cod) < 0) + (unsigned) (HieCod % 100), + (unsigned) HieCod) < 0) Err_NotEnoughMemoryExit (); - if (asprintf (&Icon,"%u.png",(unsigned) Cod) < 0) + if (asprintf (&Icon,"%u.png",(unsigned) HieCod) < 0) Err_NotEnoughMemoryExit (); HTM_IMG (URL,Icon,AltText, @@ -167,7 +167,7 @@ void Lgo_DrawLogo (HieLvl_Level_t Scope,long Cod,const char *AltText, free (URL); } else - HTM_IMG (Cfg_URL_ICON_PUBLIC,HieIcon[Scope],AltText, + HTM_IMG (Cfg_URL_ICON_PUBLIC,HieIcon[Level],AltText, "class=\"ICO%ux%u ICO_%s_%s" "%s%s\"", Size,Size, @@ -185,7 +185,7 @@ void Lgo_DrawLogo (HieLvl_Level_t Scope,long Cod,const char *AltText, /************* the logo of institution, center or degree ***************/ /*****************************************************************************/ -void Lgo_PutIconToChangeLogo (HieLvl_Level_t Scope) +void Lgo_PutIconToChangeLogo (HieLvl_Level_t Level) { static Act_Action_t Action[HieLvl_NUM_LEVELS] = { @@ -198,7 +198,7 @@ void Lgo_PutIconToChangeLogo (HieLvl_Level_t Scope) [HieLvl_CRS] = ActUnk, // Course }; - Lay_PutContextualLinkOnlyIcon (Action[Scope],NULL, + Lay_PutContextualLinkOnlyIcon (Action[Level],NULL, NULL,NULL, "shield-alt.svg",Ico_BLACK); } @@ -207,7 +207,7 @@ void Lgo_PutIconToChangeLogo (HieLvl_Level_t Scope) /**** Show a form for sending a logo of the institution, center or degree ****/ /*****************************************************************************/ -void Lgo_RequestLogo (HieLvl_Level_t Scope) +void Lgo_RequestLogo (HieLvl_Level_t Level) { extern const char *Txt_Logo; extern const char *Txt_You_can_send_a_file_with_an_image_in_PNG_format_transparent_background_and_size_X_Y; @@ -219,7 +219,7 @@ void Lgo_RequestLogo (HieLvl_Level_t Scope) char PathLogo[PATH_MAX + 1]; /***** Set action depending on scope *****/ - switch (Scope) + switch (Level) { case HieLvl_INS: Cod = Gbl.Hierarchy.Ins.InsCod; @@ -309,7 +309,7 @@ static void Lgo_PutIconToRemoveLogo (Act_Action_t ActionRem) /******* Receive the logo of the current institution, center or degree *******/ /*****************************************************************************/ -void Lgo_ReceiveLogo (HieLvl_Level_t Scope) +void Lgo_ReceiveLogo (HieLvl_Level_t Level) { extern const char *Txt_The_file_is_not_X; long Cod; @@ -322,7 +322,7 @@ void Lgo_ReceiveLogo (HieLvl_Level_t Scope) bool WrongType = false; /***** Set variables depending on scope *****/ - switch (Scope) + switch (Level) { case HieLvl_INS: Cod = Gbl.Hierarchy.Ins.InsCod; @@ -386,14 +386,14 @@ void Lgo_ReceiveLogo (HieLvl_Level_t Scope) /******* Remove the logo of the current institution, center or degree ********/ /*****************************************************************************/ -void Lgo_RemoveLogo (HieLvl_Level_t Scope) +void Lgo_RemoveLogo (HieLvl_Level_t Level) { long Cod; const char *Folder; char FileNameLogo[PATH_MAX + 1]; // Full name (including path and .png) of the destination file /***** Set variables depending on scope *****/ - switch (Scope) + switch (Level) { case HieLvl_INS: Cod = Gbl.Hierarchy.Ins.InsCod; diff --git a/swad_logo.h b/swad_logo.h index 8ea469ab..3160d9a5 100644 --- a/swad_logo.h +++ b/swad_logo.h @@ -27,11 +27,11 @@ /***************************** Public prototypes *****************************/ /*****************************************************************************/ -void Lgo_DrawLogo (HieLvl_Level_t Scope,long Cod,const char *AltText, +void Lgo_DrawLogo (HieLvl_Level_t Level,long HieCod,const char *AltText, unsigned Size,const char *Class); -void Lgo_PutIconToChangeLogo (HieLvl_Level_t Scope); -void Lgo_RequestLogo (HieLvl_Level_t Scope); -void Lgo_ReceiveLogo (HieLvl_Level_t Scope); -void Lgo_RemoveLogo (HieLvl_Level_t Scope); +void Lgo_PutIconToChangeLogo (HieLvl_Level_t Level); +void Lgo_RequestLogo (HieLvl_Level_t Level); +void Lgo_ReceiveLogo (HieLvl_Level_t Level); +void Lgo_RemoveLogo (HieLvl_Level_t Level); #endif diff --git a/swad_message_database.c b/swad_message_database.c index 2ebe7f75..931be4bd 100644 --- a/swad_message_database.c +++ b/swad_message_database.c @@ -978,7 +978,7 @@ unsigned Msg_DB_GetKnownRecipients (MYSQL_RES **mysql_res,long MsgCod) /******** (all the platform, current degree or current course) **********/ /*****************************************************************************/ -unsigned Msg_DB_GetNumSntMsgs (HieLvl_Level_t Scope,Msg_Status_t MsgStatus) +unsigned Msg_DB_GetNumSntMsgs (HieLvl_Level_t Level,Msg_Status_t MsgStatus) { static const char *Table[Msg_NUM_STATUS] = { @@ -989,7 +989,7 @@ unsigned Msg_DB_GetNumSntMsgs (HieLvl_Level_t Scope,Msg_Status_t MsgStatus) /***** Get the number of messages sent from this location (all the platform, current degree or current course) from database *****/ - switch (Scope) + switch (Level) { case HieLvl_SYS: return (unsigned) DB_GetNumRowsTable (Table[MsgStatus]); @@ -1067,7 +1067,7 @@ unsigned Msg_DB_GetNumSntMsgs (HieLvl_Level_t Scope,Msg_Status_t MsgStatus) /****** (all the platform, current degree or current course) ********/ /*****************************************************************************/ -unsigned Msg_DB_GetNumRcvMsgs (HieLvl_Level_t Scope,Msg_Status_t MsgStatus) +unsigned Msg_DB_GetNumRcvMsgs (HieLvl_Level_t Level,Msg_Status_t MsgStatus) { static const char *Table[Msg_NUM_STATUS] = { @@ -1082,7 +1082,7 @@ unsigned Msg_DB_GetNumRcvMsgs (HieLvl_Level_t Scope,Msg_Status_t MsgStatus) { case Msg_STATUS_ALL: case Msg_STATUS_DELETED: - switch (Scope) + switch (Level) { case HieLvl_SYS: return (unsigned) DB_GetNumRowsTable (Table[MsgStatus]); @@ -1167,7 +1167,7 @@ unsigned Msg_DB_GetNumRcvMsgs (HieLvl_Level_t Scope,Msg_Status_t MsgStatus) } return 0; case Msg_STATUS_NOTIFIED: - switch (Scope) + switch (Level) { case HieLvl_SYS: return (unsigned) diff --git a/swad_message_database.h b/swad_message_database.h index 90f2c420..857cffbd 100644 --- a/swad_message_database.h +++ b/swad_message_database.h @@ -79,8 +79,8 @@ unsigned Msg_DB_GetRecipientsCods (MYSQL_RES **mysql_res, long ReplyUsrCod,const char *ListRecipients); unsigned Msg_DB_GetNumRecipients (long MsgCod); unsigned Msg_DB_GetKnownRecipients (MYSQL_RES **mysql_res,long MsgCod); -unsigned Msg_DB_GetNumSntMsgs (HieLvl_Level_t Scope,Msg_Status_t MsgStatus); -unsigned Msg_DB_GetNumRcvMsgs (HieLvl_Level_t Scope,Msg_Status_t MsgStatus); +unsigned Msg_DB_GetNumSntMsgs (HieLvl_Level_t Level,Msg_Status_t MsgStatus); +unsigned Msg_DB_GetNumRcvMsgs (HieLvl_Level_t Level,Msg_Status_t MsgStatus); unsigned Msg_DB_GetNumMsgsSentByTchsCrs (long CrsCod); unsigned Msg_DB_GetNumMsgsSentByUsr (long UsrCod); diff --git a/swad_network_database.c b/swad_network_database.c index 398b1d82..c2b360b5 100644 --- a/swad_network_database.c +++ b/swad_network_database.c @@ -224,7 +224,7 @@ unsigned Net_DB_GetWebAndSocialNetworksStats (MYSQL_RES **mysql_res) Gbl.Hierarchy.Crs.CrsCod); break; default: - Err_WrongScopeExit (); + Err_WrongHierarchyLevelExit (); return 0; // Not reached } } diff --git a/swad_notice.c b/swad_notice.c index aad49f28..2fd648ef 100644 --- a/swad_notice.c +++ b/swad_notice.c @@ -685,14 +685,14 @@ 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 (HieLvl_Level_t Scope,Not_Status_t Status,unsigned *NumNotif) +unsigned Not_GetNumNotices (HieLvl_Level_t Level,Not_Status_t Status,unsigned *NumNotif) { MYSQL_RES *mysql_res; MYSQL_ROW row; unsigned NumNotices; /***** Get number of notices from database *****/ - if (Not_DB_GetNumNotices (&mysql_res,Scope,Status) == 1) + if (Not_DB_GetNumNotices (&mysql_res,Level,Status) == 1) { /***** Get number of notices *****/ row = mysql_fetch_row (mysql_res); @@ -726,14 +726,14 @@ unsigned Not_GetNumNotices (HieLvl_Level_t Scope,Not_Status_t Status,unsigned *N // Returns the number of deleted notices // sent from this location (all the platform, current degree or current course) -unsigned Not_GetNumNoticesDeleted (HieLvl_Level_t Scope,unsigned *NumNotif) +unsigned Not_GetNumNoticesDeleted (HieLvl_Level_t Level,unsigned *NumNotif) { MYSQL_RES *mysql_res; MYSQL_ROW row; unsigned NumNotices; /***** Get number of notices from database *****/ - if (Not_DB_GetNumNoticesDeleted (&mysql_res,Scope) == 1) + if (Not_DB_GetNumNoticesDeleted (&mysql_res,Level) == 1) { /***** Get number of notices *****/ row = mysql_fetch_row (mysql_res); diff --git a/swad_notice.h b/swad_notice.h index 37445122..5e4f61bf 100644 --- a/swad_notice.h +++ b/swad_notice.h @@ -78,8 +78,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 (HieLvl_Level_t Scope,Not_Status_t Status,unsigned *NumNotif); -unsigned Not_GetNumNoticesDeleted (HieLvl_Level_t Scope,unsigned *NumNotif); +unsigned Not_GetNumNotices (HieLvl_Level_t Level,Not_Status_t Status,unsigned *NumNotif); +unsigned Not_GetNumNoticesDeleted (HieLvl_Level_t Level,unsigned *NumNotif); //-------------------------------- Figures ------------------------------------ void Not_GetAndShowNoticesStats (void); diff --git a/swad_notice_database.c b/swad_notice_database.c index 13b3b56a..a9634b0c 100644 --- a/swad_notice_database.c +++ b/swad_notice_database.c @@ -187,9 +187,9 @@ unsigned Not_DB_GetActiveNotices (MYSQL_RES **mysql_res,long CrsCod) /*****************************************************************************/ unsigned Not_DB_GetNumNotices (MYSQL_RES **mysql_res, - HieLvl_Level_t Scope,Not_Status_t Status) + HieLvl_Level_t Level,Not_Status_t Status) { - switch (Scope) + switch (Level) { case HieLvl_SYS: return (unsigned) @@ -270,7 +270,7 @@ unsigned Not_DB_GetNumNotices (MYSQL_RES **mysql_res, Gbl.Hierarchy.Crs.CrsCod, Status); default: - Err_WrongScopeExit (); + Err_WrongHierarchyLevelExit (); return 0; // Not reached } } @@ -280,9 +280,9 @@ unsigned Not_DB_GetNumNotices (MYSQL_RES **mysql_res, /*****************************************************************************/ unsigned Not_DB_GetNumNoticesDeleted (MYSQL_RES **mysql_res, - HieLvl_Level_t Scope) + HieLvl_Level_t Level) { - switch (Scope) + switch (Level) { case HieLvl_SYS: return (unsigned) @@ -351,7 +351,7 @@ unsigned Not_DB_GetNumNoticesDeleted (MYSQL_RES **mysql_res, " WHERE CrsCod=%ld", Gbl.Hierarchy.Crs.CrsCod); default: - Err_WrongScopeExit (); + Err_WrongHierarchyLevelExit (); return 0; // Not reached } } diff --git a/swad_notice_database.h b/swad_notice_database.h index 731a8c89..9b58a978 100644 --- a/swad_notice_database.h +++ b/swad_notice_database.h @@ -44,9 +44,9 @@ unsigned Not_DB_ContentNotice (MYSQL_RES **mysql_res,long NotCod); unsigned Not_DB_GetAllNotices (MYSQL_RES **mysql_res); unsigned Not_DB_GetActiveNotices (MYSQL_RES **mysql_res,long CrsCod); unsigned Not_DB_GetNumNotices (MYSQL_RES **mysql_res, - HieLvl_Level_t Scope,Not_Status_t Status); + HieLvl_Level_t Level,Not_Status_t Status); unsigned Not_DB_GetNumNoticesDeleted (MYSQL_RES **mysql_res, - HieLvl_Level_t Scope); + HieLvl_Level_t Level); void Not_DB_RemoveNotice (long NotCod); void Not_DB_RemoveCrsNotices (long CrsCod); diff --git a/swad_notification_database.c b/swad_notification_database.c index 41473dd4..01294367 100644 --- a/swad_notification_database.c +++ b/swad_notification_database.c @@ -590,7 +590,7 @@ unsigned Ntf_DB_GetNumNotifs (MYSQL_RES **mysql_res,Ntf_NotifyEvent_t NotifyEven Gbl.Hierarchy.Crs.CrsCod, (unsigned) NotifyEvent); default: - Err_WrongScopeExit (); + Err_WrongHierarchyLevelExit (); return 0; // Not reached } } diff --git a/swad_photo.c b/swad_photo.c index 9ec4852b..8ad7d62f 100644 --- a/swad_photo.c +++ b/swad_photo.c @@ -1996,7 +1996,7 @@ static void Pho_PutLinkToCalculateDegreeStats (const struct Pho_DegPhotos *DegPh extern const char *Txt_Calculate_average_photo_of_THE_DEGREE_X; extern const char *Txt_unknown_TIME; extern const char *Txt_time; - struct ListDegrees Degs; + struct Deg_ListDegs Degs; unsigned NumDeg; struct Deg_Degree Deg; long EstimatedTimeToComputeAvgPhotoInMicroseconds; diff --git a/swad_profile_database.c b/swad_profile_database.c index 4a26c145..5b869ef5 100644 --- a/swad_profile_database.c +++ b/swad_profile_database.c @@ -410,7 +410,7 @@ unsigned Prf_DB_GetRankingFigure (MYSQL_RES **mysql_res,const char *FldName) FldName, FldName); default: - Err_WrongScopeExit (); + Err_WrongHierarchyLevelExit (); return 0; // Not reached } } @@ -559,7 +559,7 @@ unsigned Prf_DB_GetRankingClicksPerDay (MYSQL_RES **mysql_res) " LIMIT 100", Gbl.Hierarchy.Crs.CrsCod); default: - Err_WrongScopeExit (); + Err_WrongHierarchyLevelExit (); return 0; // Not reached } } diff --git a/swad_program_database.c b/swad_program_database.c index 7e4bbff3..22a32e7b 100644 --- a/swad_program_database.c +++ b/swad_program_database.c @@ -250,10 +250,10 @@ void Prg_DB_GetItemTxt (long ItmCod,char Txt[Cns_MAX_BYTES_TEXT + 1]) // Returns the number of courses with program items // in this location (all the platform, current degree or current course) -unsigned Prg_DB_GetNumCoursesWithItems (HieLvl_Level_t Scope) +unsigned Prg_DB_GetNumCoursesWithItems (HieLvl_Level_t Level) { /***** Get number of courses with program items from database *****/ - switch (Scope) + switch (Level) { case HieLvl_SYS: return (unsigned) @@ -326,9 +326,9 @@ unsigned Prg_DB_GetNumCoursesWithItems (HieLvl_Level_t Scope) /*****************************************************************************/ // Returns the number of program items in a hierarchy scope -unsigned Prg_DB_GetNumItems (HieLvl_Level_t Scope) +unsigned Prg_DB_GetNumItems (HieLvl_Level_t Level) { - switch (Scope) + switch (Level) { case HieLvl_SYS: return (unsigned) @@ -392,7 +392,7 @@ unsigned Prg_DB_GetNumItems (HieLvl_Level_t Scope) " WHERE CrsCod=%ld", Gbl.Hierarchy.Crs.CrsCod); default: - Err_WrongScopeExit (); + Err_WrongHierarchyLevelExit (); return 0; // Not reached } } diff --git a/swad_program_database.h b/swad_program_database.h index f9b527e5..20185c9b 100644 --- a/swad_program_database.h +++ b/swad_program_database.h @@ -49,8 +49,8 @@ unsigned Prg_DB_GetListItems (MYSQL_RES **mysql_res); unsigned Prg_DB_GetItemDataByCod (MYSQL_RES **mysql_res,long ItmCod); void Prg_DB_GetItemTxt (long ItmCod,char Txt[Cns_MAX_BYTES_TEXT + 1]); -unsigned Prg_DB_GetNumCoursesWithItems (HieLvl_Level_t Scope); -unsigned Prg_DB_GetNumItems (HieLvl_Level_t Scope); +unsigned Prg_DB_GetNumCoursesWithItems (HieLvl_Level_t Level); +unsigned Prg_DB_GetNumItems (HieLvl_Level_t Level); void Prg_DB_RemoveItemRange (const struct Prg_ItemRange *ToRemove); void Prg_DB_RemoveCrsItems (long CrsCod); diff --git a/swad_project_database.c b/swad_project_database.c index 4d774a29..80d2e132 100644 --- a/swad_project_database.c +++ b/swad_project_database.c @@ -689,10 +689,10 @@ long Prj_DB_GetCrsOfPrj (long PrjCod) // Returns the number of courses with projects // in this location (all the platform, current degree or current course) -unsigned Prj_DB_GetNumCoursesWithProjects (HieLvl_Level_t Scope) +unsigned Prj_DB_GetNumCoursesWithProjects (HieLvl_Level_t Level) { /***** Get number of courses with projects from database *****/ - switch (Scope) + switch (Level) { case HieLvl_SYS: return (unsigned) @@ -756,7 +756,7 @@ unsigned Prj_DB_GetNumCoursesWithProjects (HieLvl_Level_t Scope) " WHERE CrsCod=%ld", Gbl.Hierarchy.Crs.CrsCod); default: - Err_WrongScopeExit (); + Err_WrongHierarchyLevelExit (); return 0; // Not reached } } @@ -766,10 +766,10 @@ unsigned Prj_DB_GetNumCoursesWithProjects (HieLvl_Level_t Scope) /*****************************************************************************/ // Returns the number of projects in this location -unsigned Prj_DB_GetNumProjects (HieLvl_Level_t Scope) +unsigned Prj_DB_GetNumProjects (HieLvl_Level_t Level) { /***** Get number of projects from database *****/ - switch (Scope) + switch (Level) { case HieLvl_SYS: return (unsigned) @@ -833,7 +833,7 @@ unsigned Prj_DB_GetNumProjects (HieLvl_Level_t Scope) " WHERE CrsCod=%ld", Gbl.Hierarchy.Crs.CrsCod); default: - Err_WrongScopeExit (); + Err_WrongHierarchyLevelExit (); return 0; // Not reached } } diff --git a/swad_project_database.h b/swad_project_database.h index ab9ec88e..306f0bb4 100644 --- a/swad_project_database.h +++ b/swad_project_database.h @@ -53,8 +53,8 @@ unsigned Prj_DB_GetUsrsInPrj (MYSQL_RES **mysql_res, long PrjCod,Prj_RoleInProject_t RoleInProject); unsigned Prj_DB_GetMyRolesInPrj (MYSQL_RES **mysql_res,long PrjCod); long Prj_DB_GetCrsOfPrj (long PrjCod); -unsigned Prj_DB_GetNumCoursesWithProjects (HieLvl_Level_t Scope); -unsigned Prj_DB_GetNumProjects (HieLvl_Level_t Scope); +unsigned Prj_DB_GetNumCoursesWithProjects (HieLvl_Level_t Level); +unsigned Prj_DB_GetNumProjects (HieLvl_Level_t Level); void Prj_DB_RemoveUsrFromPrj (long PrjCod,Prj_RoleInProject_t RoleInPrj,long UsrCod); void Prj_DB_RemoveUsrFromProjects (long UsrCod); diff --git a/swad_question.c b/swad_question.c index 6fb4c3f2..5508da20 100644 --- a/swad_question.c +++ b/swad_question.c @@ -3643,7 +3643,7 @@ void Qst_RemoveAllMedFilesFromAnsOfAllQstsInCrs (long CrsCod) // Returns the number of test questions // in this location (all the platform, current degree or current course) -unsigned Qst_GetNumQuestions (HieLvl_Level_t Scope,Qst_AnswerType_t AnsType, +unsigned Qst_GetNumQuestions (HieLvl_Level_t Level,Qst_AnswerType_t AnsType, struct Qst_Stats *Stats) { extern const char *Qst_DB_StrAnswerTypes[Qst_NUM_ANS_TYPES]; @@ -3656,7 +3656,7 @@ unsigned Qst_GetNumQuestions (HieLvl_Level_t Scope,Qst_AnswerType_t AnsType, Stats->TotalScore = 0.0; /***** Get number of questions from database *****/ - if (Qst_DB_GetNumQsts (&mysql_res,Scope,AnsType)) + if (Qst_DB_GetNumQsts (&mysql_res,Level,AnsType)) { /***** Get number of questions *****/ row = mysql_fetch_row (mysql_res); diff --git a/swad_question.h b/swad_question.h index 5fcf3e52..5f6abf98 100644 --- a/swad_question.h +++ b/swad_question.h @@ -274,7 +274,7 @@ void Qst_RemoveMediaFromAllAnsOfQst (long CrsCod,long QstCod); void Qst_RemoveAllMedFilesFromStemOfAllQstsInCrs (long CrsCod); void Qst_RemoveAllMedFilesFromAnsOfAllQstsInCrs (long CrsCod); -unsigned Qst_GetNumQuestions (HieLvl_Level_t Scope,Qst_AnswerType_t AnsType, +unsigned Qst_GetNumQuestions (HieLvl_Level_t Level,Qst_AnswerType_t AnsType, struct Qst_Stats *Stats); void Qst_GetTestStats (Qst_AnswerType_t AnsType,struct Qst_Stats *Stats); diff --git a/swad_question_database.c b/swad_question_database.c index f7c46c71..d820e1da 100644 --- a/swad_question_database.c +++ b/swad_question_database.c @@ -595,9 +595,9 @@ unsigned Qst_DB_GetNumQstsInCrs (long CrsCod) // in this location (all the platform, current degree or current course) unsigned Qst_DB_GetNumQsts (MYSQL_RES **mysql_res, - HieLvl_Level_t Scope,Qst_AnswerType_t AnsType) + HieLvl_Level_t Level,Qst_AnswerType_t AnsType) { - switch (Scope) + switch (Level) { case HieLvl_SYS: if (AnsType == Qst_ANS_UNKNOWN) // Any type @@ -762,7 +762,7 @@ unsigned Qst_DB_GetNumQsts (MYSQL_RES **mysql_res, Gbl.Hierarchy.Crs.CrsCod, Qst_DB_StrAnswerTypes[AnsType]); default: - Err_WrongScopeExit (); + Err_WrongHierarchyLevelExit (); return 0; // Not reached } } @@ -773,13 +773,13 @@ unsigned Qst_DB_GetNumQsts (MYSQL_RES **mysql_res, // Returns the number of courses with test questions // in this location (all the platform, current degree or current course) -unsigned Qst_DB_GetNumCrssWithQsts (HieLvl_Level_t Scope, +unsigned Qst_DB_GetNumCrssWithQsts (HieLvl_Level_t Level, Qst_AnswerType_t AnsType) { extern const char *Qst_DB_StrAnswerTypes[Qst_NUM_ANS_TYPES]; /***** Get number of courses with test questions from database *****/ - switch (Scope) + switch (Level) { case HieLvl_SYS: if (AnsType == Qst_ANS_UNKNOWN) // Any type @@ -920,7 +920,7 @@ unsigned Qst_DB_GetNumCrssWithQsts (HieLvl_Level_t Scope, Gbl.Hierarchy.Crs.CrsCod, Qst_DB_StrAnswerTypes[AnsType]); default: - Err_WrongScopeExit (); + Err_WrongHierarchyLevelExit (); return 0; // Not reached } } @@ -931,14 +931,14 @@ unsigned Qst_DB_GetNumCrssWithQsts (HieLvl_Level_t Scope, // Returns the number of courses with pluggable test questions // in this location (all the platform, current degree or current course) -unsigned Qst_DB_GetNumCrssWithPluggableQsts (HieLvl_Level_t Scope, +unsigned Qst_DB_GetNumCrssWithPluggableQsts (HieLvl_Level_t Level, Qst_AnswerType_t AnsType) { extern const char *Qst_DB_StrAnswerTypes[Qst_NUM_ANS_TYPES]; extern const char *Tst_DB_Pluggable[TstCfg_NUM_OPTIONS_PLUGGABLE]; /***** Get number of courses with test questions from database *****/ - switch (Scope) + switch (Level) { case HieLvl_SYS: if (AnsType == Qst_ANS_UNKNOWN) // Any type @@ -1127,7 +1127,7 @@ unsigned Qst_DB_GetNumCrssWithPluggableQsts (HieLvl_Level_t Scope, Qst_DB_StrAnswerTypes[AnsType], Tst_DB_Pluggable[TstCfg_PLUGGABLE_YES]); default: - Err_WrongScopeExit (); + Err_WrongHierarchyLevelExit (); return 0; // Not reached } } diff --git a/swad_question_database.h b/swad_question_database.h index c37b9ac1..530526c3 100644 --- a/swad_question_database.h +++ b/swad_question_database.h @@ -47,10 +47,10 @@ unsigned Qst_DB_GetTrivialQst (MYSQL_RES **mysql_res, float lowerScore,float upperScore); unsigned Qst_DB_GetNumQstsInCrs (long CrsCod); unsigned Qst_DB_GetNumQsts (MYSQL_RES **mysql_res, - HieLvl_Level_t Scope,Qst_AnswerType_t AnsType); -unsigned Qst_DB_GetNumCrssWithQsts (HieLvl_Level_t Scope, + HieLvl_Level_t Level,Qst_AnswerType_t AnsType); +unsigned Qst_DB_GetNumCrssWithQsts (HieLvl_Level_t Level, Qst_AnswerType_t AnsType); -unsigned Qst_DB_GetNumCrssWithPluggableQsts (HieLvl_Level_t Scope, +unsigned Qst_DB_GetNumCrssWithPluggableQsts (HieLvl_Level_t Level, Qst_AnswerType_t AnsType); unsigned Qst_DB_GetRecentQuestions (MYSQL_RES **mysql_res, diff --git a/swad_rubric_database.c b/swad_rubric_database.c index 82ac1145..507472f3 100644 --- a/swad_rubric_database.c +++ b/swad_rubric_database.c @@ -177,10 +177,10 @@ bool Rub_DB_CheckIfSimilarRubricExists (const struct Rub_Rubric *Rubric) /*****************************************************************************/ // Returns the number of courses with rubrics in this location -unsigned Rub_DB_GetNumCoursesWithRubrics (HieLvl_Level_t Scope) +unsigned Rub_DB_GetNumCoursesWithRubrics (HieLvl_Level_t Level) { /***** Get number of courses with rubrics from database *****/ - switch (Scope) + switch (Level) { case HieLvl_SYS: return (unsigned) @@ -250,12 +250,12 @@ unsigned Rub_DB_GetNumCoursesWithRubrics (HieLvl_Level_t Scope) /*****************************************************************************/ /*************************** Get number of rubrics ***************************/ /*****************************************************************************/ -// Returns the number of rubrics in this location +// Returns the number of rubrics in a given location -unsigned Rub_DB_GetNumRubrics (HieLvl_Level_t Scope) +unsigned Rub_DB_GetNumRubrics (HieLvl_Level_t Level) { /***** Get number of rubrics from database *****/ - switch (Scope) + switch (Level) { case HieLvl_SYS: return (unsigned) @@ -690,10 +690,10 @@ bool Rub_DB_CheckIfSimilarCriterionExists (const struct RubCri_Criterion *Criter /**************** Get average number of criteria per rubric ******************/ /*****************************************************************************/ -double Rub_DB_GetNumCriteriaPerRubric (HieLvl_Level_t Scope) +double Rub_DB_GetNumCriteriaPerRubric (HieLvl_Level_t Level) { /***** Get number of criteria per rubric from database *****/ - switch (Scope) + switch (Level) { case HieLvl_SYS: return @@ -780,7 +780,7 @@ double Rub_DB_GetNumCriteriaPerRubric (HieLvl_Level_t Scope) " GROUP BY rub_criteria.RubCod) AS NumCriteriaTable", Gbl.Hierarchy.Crs.CrsCod); default: - Err_WrongScopeExit (); + Err_WrongHierarchyLevelExit (); return 0.0; // Not reached } } diff --git a/swad_rubric_database.h b/swad_rubric_database.h index 0bcd7327..942c4545 100644 --- a/swad_rubric_database.h +++ b/swad_rubric_database.h @@ -47,8 +47,8 @@ unsigned Rub_DB_GetRubricDataByCod (MYSQL_RES **mysql_res,long RubCod); void Rub_DB_GetRubricTitle (long RubCod,char *Title,size_t TitleSize); void Rub_DB_GetRubricTxt (struct Rub_Rubric *Rubric); bool Rub_DB_CheckIfSimilarRubricExists (const struct Rub_Rubric *Rubric); -unsigned Rub_DB_GetNumCoursesWithRubrics (HieLvl_Level_t Scope); -unsigned Rub_DB_GetNumRubrics (HieLvl_Level_t Scope); +unsigned Rub_DB_GetNumCoursesWithRubrics (HieLvl_Level_t Level); +unsigned Rub_DB_GetNumRubrics (HieLvl_Level_t Level); void Rub_DB_RemoveRubric (long RubCod); void Rub_DB_RemoveCrsRubrics (long CrsCod); @@ -76,7 +76,7 @@ unsigned Rub_DB_GetCriterionDataByCod (MYSQL_RES **mysql_res,long CriCod); bool Rub_DB_CheckIfSimilarCriterionExists (const struct RubCri_Criterion *Criterion, const char Title[RubCri_MAX_BYTES_TITLE + 1]); -double Rub_DB_GetNumCriteriaPerRubric (HieLvl_Level_t Scope); +double Rub_DB_GetNumCriteriaPerRubric (HieLvl_Level_t Level); void Rub_DB_RemoveCriterionFromRubric (const struct RubCri_Criterion *Criterion); void Rub_DB_RemoveRubricCriteria (long RubCod); diff --git a/swad_scope.c b/swad_scope.c index c1be278b..42086d16 100644 --- a/swad_scope.c +++ b/swad_scope.c @@ -52,7 +52,7 @@ void Sco_PutSelectorScope (const char *ParName,HTM_SubmitOnChange_t SubmitOnChan extern const char *Txt_Center; extern const char *Txt_Degree; extern const char *Txt_Course; - HieLvl_Level_t Scope; + HieLvl_Level_t Level; unsigned ScopeUnsigned; bool WriteScope; static const char **TxtScope[HieLvl_NUM_LEVELS] = @@ -78,14 +78,14 @@ void Sco_PutSelectorScope (const char *ParName,HTM_SubmitOnChange_t SubmitOnChan "id=\"%s\" name=\"%s\" class=\"INPUT_%s\"", ParName,ParName,The_GetSuffix ()); - for (Scope = (HieLvl_Level_t) 1; - Scope <= (HieLvl_Level_t) (HieLvl_NUM_LEVELS - 1); - Scope++) - if ((Gbl.Scope.Allowed & (1 << Scope))) + for (Level = (HieLvl_Level_t) 1; + Level <= (HieLvl_Level_t) (HieLvl_NUM_LEVELS - 1); + Level++) + if ((Gbl.Scope.Allowed & (1 << Level))) { /* Don't put forbidden options in selectable list */ WriteScope = false; - switch (Scope) + switch (Level) { case HieLvl_SYS: WriteScope = true; @@ -117,13 +117,13 @@ void Sco_PutSelectorScope (const char *ParName,HTM_SubmitOnChange_t SubmitOnChan if (WriteScope) { /***** Write allowed option *****/ - ScopeUnsigned = (unsigned) Scope; + ScopeUnsigned = (unsigned) Level; HTM_OPTION (HTM_Type_UNSIGNED,&ScopeUnsigned, - Scope == Gbl.Scope.Current ? HTM_OPTION_SELECTED : + Level == Gbl.Scope.Current ? HTM_OPTION_SELECTED : HTM_OPTION_UNSELECTED, HTM_OPTION_ENABLED, "%s: %s", - *TxtScope[Scope],TxtName[Scope]); + *TxtScope[Level],TxtName[Level]); } } @@ -134,15 +134,15 @@ void Sco_PutSelectorScope (const char *ParName,HTM_SubmitOnChange_t SubmitOnChan /********************** Put hidden parameter scope ***************************/ /*****************************************************************************/ -void Sco_PutParCurrentScope (void *Scope) +void Sco_PutParCurrentScope (void *Level) { - if (Scope) - Sco_PutParScope ("ScopeUsr",*((HieLvl_Level_t *) Scope)); + if (Level) + Sco_PutParScope ("ScopeUsr",*((HieLvl_Level_t *) Level)); } -void Sco_PutParScope (const char *ParName,HieLvl_Level_t Scope) +void Sco_PutParScope (const char *ParName,HieLvl_Level_t Level) { - Par_PutParUnsigned (NULL,ParName,(unsigned) Scope); + Par_PutParUnsigned (NULL,ParName,(unsigned) Level); } /*****************************************************************************/ @@ -284,27 +284,27 @@ HieLvl_Level_t Sco_GetScopeFromUnsignedStr (const char *UnsignedStr) } /*****************************************************************************/ -/*********************** Get scope from database string **********************/ +/***************** Get hierarchy level from database string ******************/ /*****************************************************************************/ -HieLvl_Level_t Sco_GetScopeFromDBStr (const char *ScopeDBStr) +HieLvl_Level_t Hie_GetLevelFromDBStr (const char *LevelDBStr) { - HieLvl_Level_t Scope; + HieLvl_Level_t Level; - for (Scope = (HieLvl_Level_t) 0; - Scope <= (HieLvl_Level_t) (HieLvl_NUM_LEVELS - 1); - Scope++) - if (!strcmp (Sco_GetDBStrFromScope (Scope),ScopeDBStr)) - return Scope; + for (Level = (HieLvl_Level_t) 0; + Level <= (HieLvl_Level_t) (HieLvl_NUM_LEVELS - 1); + Level++) + if (!strcmp (Hie_GetDBStrFromLevel (Level),LevelDBStr)) + return Level; return HieLvl_UNK; } /*****************************************************************************/ -/*********************** Get database string from source *********************/ +/****************** Get database string from hierarchy level *****************/ /*****************************************************************************/ -const char *Sco_GetDBStrFromScope (HieLvl_Level_t Scope) +const char *Hie_GetDBStrFromLevel (HieLvl_Level_t Level) { static const char *Sco_ScopeDB[HieLvl_NUM_LEVELS] = { @@ -317,17 +317,17 @@ const char *Sco_GetDBStrFromScope (HieLvl_Level_t Scope) [HieLvl_CRS] = "Crs", }; - if (Scope >= HieLvl_NUM_LEVELS) - Scope = HieLvl_UNK; + if (Level >= HieLvl_NUM_LEVELS) + Level = HieLvl_UNK; - return Sco_ScopeDB[Scope]; + return Sco_ScopeDB[Level]; } /*****************************************************************************/ -/**************************** Get current scope code *************************/ +/************************** Get current hierarchy code ***********************/ /*****************************************************************************/ -long Sco_GetCurrentCod (void) +long Hie_GetCurrentCod (void) { switch (Gbl.Scope.Current) { @@ -344,7 +344,7 @@ long Sco_GetCurrentCod (void) case HieLvl_CRS: return Gbl.Hierarchy.Crs.CrsCod; default: - Err_WrongScopeExit (); + Err_WrongHierarchyLevelExit (); return -1L; // Not reached } } diff --git a/swad_scope.h b/swad_scope.h index 2cff036a..db0203c6 100644 --- a/swad_scope.h +++ b/swad_scope.h @@ -37,8 +37,8 @@ /*****************************************************************************/ void Sco_PutSelectorScope (const char *ParName,HTM_SubmitOnChange_t SubmitOnChange); -void Sco_PutParCurrentScope (void *Scope); -void Sco_PutParScope (const char *ParName,HieLvl_Level_t Scope); +void Sco_PutParCurrentScope (void *Level); +void Sco_PutParScope (const char *ParName,HieLvl_Level_t Level); void Sco_GetScope (const char *ParName); void Sco_AdjustScope (void); @@ -46,9 +46,9 @@ void Sco_SetScopesForListingGuests (void); void Sco_SetScopesForListingStudents (void); HieLvl_Level_t Sco_GetScopeFromUnsignedStr (const char *UnsignedStr); -HieLvl_Level_t Sco_GetScopeFromDBStr (const char *ScopeDBStr); -const char *Sco_GetDBStrFromScope (HieLvl_Level_t Scope); +HieLvl_Level_t Hie_GetLevelFromDBStr (const char *LevelDBStr); +const char *Hie_GetDBStrFromLevel (HieLvl_Level_t Level); -long Sco_GetCurrentCod (void); +long Hie_GetCurrentCod (void); #endif diff --git a/swad_survey.c b/swad_survey.c index 8c7b65c0..b585c6d8 100644 --- a/swad_survey.c +++ b/swad_survey.c @@ -594,10 +594,10 @@ static void Svy_ShowOneSurvey (struct Svy_Surveys *Surveys, HidVis_GroupClass[Surveys->Svy.Status.HiddenOrVisible], The_GetSuffix ()); HTM_TxtColonNBSP (Txt_Scope); - switch (Surveys->Svy.Scope) + switch (Surveys->Svy.Level) { case HieLvl_UNK: // Unknown - Err_WrongScopeExit (); + Err_WrongHierarchyLevelExit (); break; case HieLvl_SYS: // System HTM_Txt (Cfg_PLATFORM_SHORT_NAME); @@ -634,7 +634,7 @@ static void Svy_ShowOneSurvey (struct Svy_Surveys *Surveys, HTM_DIV_End (); /* Groups whose users can answer this survey */ - if (Surveys->Svy.Scope == HieLvl_CRS) + if (Surveys->Svy.Level == HieLvl_CRS) if (Gbl.Crs.Grps.NumGrps) Svy_GetAndWriteNamesOfGrpsAssociatedToSvy (&Surveys->Svy); @@ -665,8 +665,8 @@ static void Svy_ShowOneSurvey (struct Svy_Surveys *Surveys, The_ChangeRowColor (); /***** Mark possible notification as seen *****/ - if (Surveys->Svy.Scope == HieLvl_CRS) // Only course surveys are notified - Ntf_DB_MarkNotifAsSeenUsingCod (Ntf_EVENT_SURVEY,Surveys->Svy.Cod); + if (Surveys->Svy.Level == HieLvl_CRS) // Only course surveys are notified + Ntf_DB_MarkNotifAsSeenUsingCod (Ntf_EVENT_SURVEY,Surveys->Svy.HieCod); if (ShowOnlyThisSvyComplete) { @@ -1138,11 +1138,11 @@ void Svy_GetSurveyDataByCod (struct Svy_Survey *Svy) Svy->SvyCod = Str_ConvertStrCodToLongCod (row[0]); /* Get survey scope (row[1]) */ - if ((Svy->Scope = Sco_GetScopeFromDBStr (row[1])) == HieLvl_UNK) - Err_WrongScopeExit (); + if ((Svy->Level = Hie_GetLevelFromDBStr (row[1])) == HieLvl_UNK) + Err_WrongHierarchyLevelExit (); /* Get code of the country, institution, center, degree or course (row[2]) */ - Svy->Cod = Str_ConvertStrCodToLongCod (row[2]); + Svy->HieCod = Str_ConvertStrCodToLongCod (row[2]); /* Get whether the survey is hidden (row[3]) */ Svy->Status.HiddenOrVisible = (row[3][0] == 'Y') ? HidVis_HIDDEN : @@ -1174,28 +1174,28 @@ void Svy_GetSurveyDataByCod (struct Svy_Survey *Svy) Svy->Status.IAmLoggedWithAValidRoleToAnswer = (Svy->Roles & (1 << Gbl.Usrs.Me.Role.Logged)); /* Do I belong to valid groups to answer this survey? */ - switch (Svy->Scope) + switch (Svy->Level) { case HieLvl_UNK: // Unknown - Err_WrongScopeExit (); + Err_WrongHierarchyLevelExit (); break; case HieLvl_SYS: // System Svy->Status.IBelongToScope = Gbl.Usrs.Me.Logged; break; case HieLvl_CTY: // Country - Svy->Status.IBelongToScope = Cty_CheckIfIBelongToCty (Svy->Cod); + Svy->Status.IBelongToScope = Cty_CheckIfIBelongToCty (Svy->HieCod); break; case HieLvl_INS: // Institution - Svy->Status.IBelongToScope = Ins_CheckIfIBelongToIns (Svy->Cod); + Svy->Status.IBelongToScope = Ins_CheckIfIBelongToIns (Svy->HieCod); break; case HieLvl_CTR: // Center - Svy->Status.IBelongToScope = Ctr_CheckIfIBelongToCtr (Svy->Cod); + Svy->Status.IBelongToScope = Ctr_CheckIfIBelongToCtr (Svy->HieCod); break; case HieLvl_DEG: // Degree - Svy->Status.IBelongToScope = Deg_CheckIfIBelongToDeg (Svy->Cod); + Svy->Status.IBelongToScope = Deg_CheckIfIBelongToDeg (Svy->HieCod); break; case HieLvl_CRS: // Course - Svy->Status.IBelongToScope = Enr_CheckIfIBelongToCrs (Svy->Cod) && + Svy->Status.IBelongToScope = Enr_CheckIfIBelongToCrs (Svy->HieCod) && Svy_DB_CheckIfICanDoThisSurveyBasedOnGrps (Svy->SvyCod); break; } @@ -1216,12 +1216,12 @@ void Svy_GetSurveyDataByCod (struct Svy_Survey *Svy) switch (Gbl.Usrs.Me.Role.Logged) { case Rol_STD: - Svy->Status.ICanViewResults = (Svy->Scope == HieLvl_CRS || - Svy->Scope == HieLvl_DEG || - Svy->Scope == HieLvl_CTR || - Svy->Scope == HieLvl_INS || - Svy->Scope == HieLvl_CTY || - Svy->Scope == HieLvl_SYS) && + Svy->Status.ICanViewResults = (Svy->Level == HieLvl_CRS || + Svy->Level == HieLvl_DEG || + Svy->Level == HieLvl_CTR || + Svy->Level == HieLvl_INS || + Svy->Level == HieLvl_CTY || + Svy->Level == HieLvl_SYS) && (Svy->NumQsts != 0) && Svy->Status.HiddenOrVisible == HidVis_VISIBLE && Svy->Status.Open && @@ -1233,59 +1233,59 @@ void Svy_GetSurveyDataByCod (struct Svy_Survey *Svy) break; case Rol_NET: Svy->Status.ICanViewResults = - Svy->Status.ICanViewComments = (Svy->Scope == HieLvl_CRS || - Svy->Scope == HieLvl_DEG || - Svy->Scope == HieLvl_CTR || - Svy->Scope == HieLvl_INS || - Svy->Scope == HieLvl_CTY || - Svy->Scope == HieLvl_SYS) && + Svy->Status.ICanViewComments = (Svy->Level == HieLvl_CRS || + Svy->Level == HieLvl_DEG || + Svy->Level == HieLvl_CTR || + Svy->Level == HieLvl_INS || + Svy->Level == HieLvl_CTY || + Svy->Level == HieLvl_SYS) && Svy->NumQsts != 0 && !Svy->Status.ICanAnswer; Svy->Status.ICanEdit = false; break; case Rol_TCH: Svy->Status.ICanViewResults = - Svy->Status.ICanViewComments = (Svy->Scope == HieLvl_CRS || - Svy->Scope == HieLvl_DEG || - Svy->Scope == HieLvl_CTR || - Svy->Scope == HieLvl_INS || - Svy->Scope == HieLvl_CTY || - Svy->Scope == HieLvl_SYS) && + Svy->Status.ICanViewComments = (Svy->Level == HieLvl_CRS || + Svy->Level == HieLvl_DEG || + Svy->Level == HieLvl_CTR || + Svy->Level == HieLvl_INS || + Svy->Level == HieLvl_CTY || + Svy->Level == HieLvl_SYS) && Svy->NumQsts != 0 && !Svy->Status.ICanAnswer; - Svy->Status.ICanEdit = Svy->Scope == HieLvl_CRS; // && Svy->Status.IBelongToScope + Svy->Status.ICanEdit = Svy->Level == HieLvl_CRS; // && Svy->Status.IBelongToScope break; case Rol_DEG_ADM: Svy->Status.ICanViewResults = - Svy->Status.ICanViewComments = (Svy->Scope == HieLvl_DEG || - Svy->Scope == HieLvl_CTR || - Svy->Scope == HieLvl_INS || - Svy->Scope == HieLvl_CTY || - Svy->Scope == HieLvl_SYS) && + Svy->Status.ICanViewComments = (Svy->Level == HieLvl_DEG || + Svy->Level == HieLvl_CTR || + Svy->Level == HieLvl_INS || + Svy->Level == HieLvl_CTY || + Svy->Level == HieLvl_SYS) && (Svy->NumQsts != 0) && !Svy->Status.ICanAnswer; - Svy->Status.ICanEdit = Svy->Scope == HieLvl_DEG && + Svy->Status.ICanEdit = Svy->Level == HieLvl_DEG && Svy->Status.IBelongToScope; break; case Rol_CTR_ADM: Svy->Status.ICanViewResults = - Svy->Status.ICanViewComments = (Svy->Scope == HieLvl_CTR || - Svy->Scope == HieLvl_INS || - Svy->Scope == HieLvl_CTY || - Svy->Scope == HieLvl_SYS) && + Svy->Status.ICanViewComments = (Svy->Level == HieLvl_CTR || + Svy->Level == HieLvl_INS || + Svy->Level == HieLvl_CTY || + Svy->Level == HieLvl_SYS) && (Svy->NumQsts != 0) && !Svy->Status.ICanAnswer; - Svy->Status.ICanEdit = Svy->Scope == HieLvl_CTR && + Svy->Status.ICanEdit = Svy->Level == HieLvl_CTR && Svy->Status.IBelongToScope; break; case Rol_INS_ADM: Svy->Status.ICanViewResults = - Svy->Status.ICanViewComments = (Svy->Scope == HieLvl_INS || - Svy->Scope == HieLvl_CTY || - Svy->Scope == HieLvl_SYS) && + Svy->Status.ICanViewComments = (Svy->Level == HieLvl_INS || + Svy->Level == HieLvl_CTY || + Svy->Level == HieLvl_SYS) && (Svy->NumQsts != 0) && !Svy->Status.ICanAnswer; - Svy->Status.ICanEdit = Svy->Scope == HieLvl_INS && + Svy->Status.ICanEdit = Svy->Level == HieLvl_INS && Svy->Status.IBelongToScope; break; case Rol_SYS_ADM: @@ -1304,7 +1304,7 @@ void Svy_GetSurveyDataByCod (struct Svy_Survey *Svy) { /* Initialize to empty survey */ Svy->SvyCod = -1L; - Svy->Scope = HieLvl_UNK; + Svy->Level = HieLvl_UNK; Svy->Roles = 0; Svy->UsrCod = -1L; Svy->TimeUTC[Dat_STR_TIME] = @@ -1650,7 +1650,7 @@ void Svy_ReqCreatOrEditSvy (void) /* Initialize to empty survey */ Surveys.Svy.SvyCod = -1L; - Surveys.Svy.Scope = HieLvl_UNK; + Surveys.Svy.Level = HieLvl_UNK; Surveys.Svy.Roles = (1 << Rol_STD); Surveys.Svy.UsrCod = Gbl.Usrs.Me.UsrDat.UsrCod; Surveys.Svy.TimeUTC[Dat_STR_TIME] = Dat_GetStartExecutionTimeUTC (); @@ -1800,52 +1800,52 @@ static void Svy_SetDefaultAndAllowedScope (struct Svy_Survey *Svy) case Rol_TCH: // Teachers only can edit course surveys if (Gbl.Hierarchy.Level == HieLvl_CRS) // Course selected { - if (Svy->Scope == HieLvl_UNK) // Scope not defined - Svy->Scope = HieLvl_CRS; - if (Svy->Scope == HieLvl_CRS) + if (Svy->Level == HieLvl_UNK) // Scope not defined + Svy->Level = HieLvl_CRS; + if (Svy->Level == HieLvl_CRS) { - Gbl.Scope.Default = Svy->Scope; + Gbl.Scope.Default = Svy->Level; Gbl.Scope.Allowed = 1 << HieLvl_CRS; ICanEdit = true; } } break; case Rol_DEG_ADM: // Degree admins only can edit degree surveys - if (Svy->Scope == HieLvl_UNK) // Scope not defined - Svy->Scope = HieLvl_DEG; - if (Svy->Scope == HieLvl_DEG) + if (Svy->Level == HieLvl_UNK) // Scope not defined + Svy->Level = HieLvl_DEG; + if (Svy->Level == HieLvl_DEG) { - Gbl.Scope.Default = Svy->Scope; + Gbl.Scope.Default = Svy->Level; Gbl.Scope.Allowed = 1 << HieLvl_DEG; ICanEdit = true; } break; case Rol_CTR_ADM: // Center admins only can edit center surveys - if (Svy->Scope == HieLvl_UNK) // Scope not defined - Svy->Scope = HieLvl_CTR; - if (Svy->Scope == HieLvl_CTR) + if (Svy->Level == HieLvl_UNK) // Scope not defined + Svy->Level = HieLvl_CTR; + if (Svy->Level == HieLvl_CTR) { - Gbl.Scope.Default = Svy->Scope; + Gbl.Scope.Default = Svy->Level; Gbl.Scope.Allowed = 1 << HieLvl_CTR; ICanEdit = true; } break; case Rol_INS_ADM: // Institution admins only can edit institution surveys - if (Svy->Scope == HieLvl_UNK) // Scope not defined - Svy->Scope = HieLvl_INS; - if (Svy->Scope == HieLvl_INS) + if (Svy->Level == HieLvl_UNK) // Scope not defined + Svy->Level = HieLvl_INS; + if (Svy->Level == HieLvl_INS) { - Gbl.Scope.Default = Svy->Scope; + Gbl.Scope.Default = Svy->Level; Gbl.Scope.Allowed = 1 << HieLvl_INS; ICanEdit = true; } break; case Rol_SYS_ADM:// System admins can edit any survey - if (Svy->Scope == HieLvl_UNK) // Scope not defined - Svy->Scope = (Gbl.Hierarchy.Level < HieLvl_NUM_LEVELS && + if (Svy->Level == HieLvl_UNK) // Scope not defined + Svy->Level = (Gbl.Hierarchy.Level < HieLvl_NUM_LEVELS && Gbl.Hierarchy.Level != HieLvl_UNK) ? Gbl.Hierarchy.Level : HieLvl_SYS; - Gbl.Scope.Default = Svy->Scope; + Gbl.Scope.Default = Svy->Level; Gbl.Scope.Allowed = 1 << HieLvl_SYS | 1 << HieLvl_CTY | 1 << HieLvl_INS | @@ -1952,7 +1952,7 @@ void Svy_ReceiveFormSurvey (void) ItsANewSurvey = ((NewSvy.SvyCod = ParCod_GetPar (ParCod_Svy)) <= 0); if (ItsANewSurvey) - NewSvy.Scope = HieLvl_UNK; + NewSvy.Level = HieLvl_UNK; else { /* Get data of the old (current) survey from database */ @@ -1960,7 +1960,7 @@ void Svy_ReceiveFormSurvey (void) Svy_GetSurveyDataByCod (&OldSvy); if (!OldSvy.Status.ICanEdit) Err_NoPermissionExit (); - NewSvy.Scope = OldSvy.Scope; + NewSvy.Level = OldSvy.Level; } /***** Get scope *****/ @@ -1970,46 +1970,46 @@ void Svy_ReceiveFormSurvey (void) { case HieLvl_SYS: if (Gbl.Usrs.Me.Role.Logged != Rol_SYS_ADM) - Err_WrongScopeExit (); - NewSvy.Scope = HieLvl_SYS; - NewSvy.Cod = -1L; + Err_WrongHierarchyLevelExit (); + NewSvy.Level = HieLvl_SYS; + NewSvy.HieCod = -1L; break; case HieLvl_CTY: if (Gbl.Usrs.Me.Role.Logged != Rol_SYS_ADM) - Err_WrongScopeExit (); - NewSvy.Scope = HieLvl_CTY; - NewSvy.Cod = Gbl.Hierarchy.Cty.CtyCod; + Err_WrongHierarchyLevelExit (); + NewSvy.Level = HieLvl_CTY; + NewSvy.HieCod = Gbl.Hierarchy.Cty.CtyCod; break; case HieLvl_INS: if (Gbl.Usrs.Me.Role.Logged != Rol_SYS_ADM && Gbl.Usrs.Me.Role.Logged != Rol_INS_ADM) - Err_WrongScopeExit (); - NewSvy.Scope = HieLvl_INS; - NewSvy.Cod = Gbl.Hierarchy.Ins.InsCod; + Err_WrongHierarchyLevelExit (); + NewSvy.Level = HieLvl_INS; + NewSvy.HieCod = Gbl.Hierarchy.Ins.InsCod; break; case HieLvl_CTR: if (Gbl.Usrs.Me.Role.Logged != Rol_SYS_ADM && Gbl.Usrs.Me.Role.Logged != Rol_CTR_ADM) - Err_WrongScopeExit (); - NewSvy.Scope = HieLvl_CTR; - NewSvy.Cod = Gbl.Hierarchy.Ctr.CtrCod; + Err_WrongHierarchyLevelExit (); + NewSvy.Level = HieLvl_CTR; + NewSvy.HieCod = Gbl.Hierarchy.Ctr.CtrCod; break; case HieLvl_DEG: if (Gbl.Usrs.Me.Role.Logged != Rol_SYS_ADM && Gbl.Usrs.Me.Role.Logged != Rol_DEG_ADM) - Err_WrongScopeExit (); - NewSvy.Scope = HieLvl_DEG; - NewSvy.Cod = Gbl.Hierarchy.Deg.DegCod; + Err_WrongHierarchyLevelExit (); + NewSvy.Level = HieLvl_DEG; + NewSvy.HieCod = Gbl.Hierarchy.Deg.DegCod; break; case HieLvl_CRS: if (Gbl.Usrs.Me.Role.Logged != Rol_SYS_ADM && Gbl.Usrs.Me.Role.Logged != Rol_TCH) - Err_WrongScopeExit (); - NewSvy.Scope = HieLvl_CRS; - NewSvy.Cod = Gbl.Hierarchy.Crs.CrsCod; + Err_WrongHierarchyLevelExit (); + NewSvy.Level = HieLvl_CRS; + NewSvy.HieCod = Gbl.Hierarchy.Crs.CrsCod; break; default: - Err_WrongScopeExit (); + Err_WrongHierarchyLevelExit (); break; } @@ -2067,7 +2067,7 @@ void Svy_ReceiveFormSurvey (void) Svy_ReqCreatOrEditSvy (); /***** Notify by email about the new survey *****/ - if (NewSvy.Scope == HieLvl_CRS) // Notify only the surveys for a course, not for a degree or global + if (NewSvy.Level == HieLvl_CRS) // Notify only the surveys for a course, not for a degree or global if ((NumUsrsToBeNotifiedByEMail = Ntf_StoreNotifyEventsToAllUsrs (Ntf_EVENT_SURVEY,NewSvy.SvyCod))) Svy_DB_UpdateNumUsrsNotifiedByEMailAboutSurvey (NewSvy.SvyCod,NumUsrsToBeNotifiedByEMail); @@ -2200,23 +2200,23 @@ static void Svy_GetAndWriteNamesOfGrpsAssociatedToSvy (struct Svy_Survey *Svy) /************* (country, institution, center, degree or course) **************/ /*****************************************************************************/ -void Svy_RemoveSurveys (HieLvl_Level_t Scope,long Cod) +void Svy_RemoveSurveys (HieLvl_Level_t Level,long HieCod) { /***** Remove all users in surveys *****/ - Svy_DB_RemoveUsrsWhoHaveAnsweredSvysIn (Scope,Cod); + Svy_DB_RemoveUsrsWhoHaveAnsweredSvysIn (Level,HieCod); /***** Remove all answers and comments in surveys *****/ - Svy_DB_RemoveAnswersSvysIn (Scope,Cod); - Svy_DB_RemoveCommentsSvysIn (Scope,Cod); + Svy_DB_RemoveAnswersSvysIn (Level,HieCod); + Svy_DB_RemoveCommentsSvysIn (Level,HieCod); /***** Remove all questions in surveys *****/ - Svy_DB_RemoveQstsSvysIn (Scope,Cod); + Svy_DB_RemoveQstsSvysIn (Level,HieCod); /***** Remove all groups *****/ - Svy_DB_RemoveGrpsSvysIn (Scope,Cod); + Svy_DB_RemoveGrpsSvysIn (Level,HieCod); /***** Remove all surveys *****/ - Svy_DB_RemoveSvysIn (Scope,Cod); + Svy_DB_RemoveSvysIn (Level,HieCod); } /*****************************************************************************/ @@ -3327,14 +3327,14 @@ static void Svy_ReceiveAndStoreUserAnswersToASurvey (long SvyCod) // Returns the number of surveys for courses // in this location (all the platform, current degree or current course) -unsigned Svy_GetNumCrsSurveys (HieLvl_Level_t Scope,unsigned *NumNotif) +unsigned Svy_GetNumCrsSurveys (HieLvl_Level_t Level,unsigned *NumNotif) { MYSQL_RES *mysql_res; MYSQL_ROW row; unsigned NumSurveys; /***** Get number of surveys from database *****/ - if (Svy_DB_GetNumCrsSurveys (&mysql_res,Scope)) + if (Svy_DB_GetNumCrsSurveys (&mysql_res,Level)) { /***** Get number of surveys *****/ row = mysql_fetch_row (mysql_res); diff --git a/swad_survey.h b/swad_survey.h index a9fe6888..c9c2db4d 100644 --- a/swad_survey.h +++ b/swad_survey.h @@ -43,8 +43,8 @@ struct Svy_Survey { long SvyCod; - HieLvl_Level_t Scope; - long Cod; // Country, institution, center, degree or course code + HieLvl_Level_t Level; + long HieCod; // Country, institution, center, degree or course code unsigned Roles; // Example: if survey can be made by students, Roles == (1 << Rol_STD) long UsrCod; char Title[Svy_MAX_BYTES_SURVEY_TITLE + 1]; @@ -121,7 +121,7 @@ void Svy_ResetSurvey (void); void Svy_HideSurvey (void); void Svy_UnhideSurvey (void); void Svy_ReceiveFormSurvey (void); -void Svy_RemoveSurveys (HieLvl_Level_t Scope,long Cod); +void Svy_RemoveSurveys (HieLvl_Level_t Level,long Cod); void Svy_ReqEditQuestion (void); void Svy_ReceiveQst (void); @@ -131,7 +131,7 @@ void Svy_RemoveQst (void); void Svy_ReceiveSurveyAnswers (void); -unsigned Svy_GetNumCrsSurveys (HieLvl_Level_t Scope,unsigned *NumNotif); +unsigned Svy_GetNumCrsSurveys (HieLvl_Level_t Level,unsigned *NumNotif); //-------------------------------- Figures ------------------------------------ void Svy_GetAndShowSurveysStats (void); diff --git a/swad_survey_database.c b/swad_survey_database.c index ce773c5e..89dabe54 100644 --- a/swad_survey_database.c +++ b/swad_survey_database.c @@ -68,8 +68,8 @@ long Svy_DB_CreateSurvey (const struct Svy_Survey *Svy,const char *Txt) " ('%s',%ld,'N',%u,%ld," "FROM_UNIXTIME(%ld),FROM_UNIXTIME(%ld)," "'%s','%s')", - Sco_GetDBStrFromScope (Svy->Scope), - Svy->Cod, + Hie_GetDBStrFromLevel (Svy->Level), + Svy->HieCod, Svy->Roles, Gbl.Usrs.Me.UsrDat.UsrCod, Svy->TimeUTC[Dat_STR_TIME], @@ -94,8 +94,8 @@ void Svy_DB_UpdateSurvey (const struct Svy_Survey *Svy,const char *Txt) "Title='%s'," "Txt='%s'" " WHERE SvyCod=%ld", - Sco_GetDBStrFromScope (Svy->Scope), - Svy->Cod, + Hie_GetDBStrFromLevel (Svy->Level), + Svy->HieCod, Svy->Roles, Svy->TimeUTC[Dat_STR_TIME], Svy->TimeUTC[Dat_END_TIME], @@ -155,7 +155,7 @@ unsigned Svy_DB_GetListSurveys (MYSQL_RES **mysql_res, }; unsigned NumSvys; long Cods[HieLvl_NUM_LEVELS]; - HieLvl_Level_t Scope; + HieLvl_Level_t Level; bool SubQueryFilled = false; /***** Set hierarchy codes *****/ @@ -167,23 +167,23 @@ unsigned Svy_DB_GetListSurveys (MYSQL_RES **mysql_res, Cods[HieLvl_CRS] = Gbl.Hierarchy.Crs.CrsCod; // Course /***** Fill subqueries for system, country, institution, center and degree *****/ - for (Scope = HieLvl_SYS; - Scope <= HieLvl_DEG; - Scope++) - if (ScopesAllowed & 1 << Scope) + for (Level = HieLvl_SYS; + Level <= HieLvl_DEG; + Level++) + if (ScopesAllowed & 1 << Level) { - if (asprintf (&SubQuery[Scope],"%s(Scope='%s' AND Cod=%ld%s)", + if (asprintf (&SubQuery[Level],"%s(Scope='%s' AND Cod=%ld%s)", SubQueryFilled ? " OR " : "", - Sco_GetDBStrFromScope (Scope),Cods[Scope], - (HiddenAllowed & 1 << Scope) ? "" : + Hie_GetDBStrFromLevel (Level),Cods[Level], + (HiddenAllowed & 1 << Level) ? "" : " AND Hidden='N'") < 0) Err_NotEnoughMemoryExit (); SubQueryFilled = true; } else { - if (asprintf (&SubQuery[Scope],"%s","") < 0) + if (asprintf (&SubQuery[Level],"%s","") < 0) Err_NotEnoughMemoryExit (); } @@ -209,7 +209,7 @@ unsigned Svy_DB_GetListSurveys (MYSQL_RES **mysql_res, ")", SubQueryFilled ? " OR " : "", - Sco_GetDBStrFromScope (HieLvl_CRS),Cods[HieLvl_CRS], + Hie_GetDBStrFromLevel (HieLvl_CRS),Cods[HieLvl_CRS], (HiddenAllowed & 1 << HieLvl_CRS) ? "" : " AND Hidden='N'", Gbl.Usrs.Me.UsrDat.UsrCod) < 0) @@ -220,7 +220,7 @@ unsigned Svy_DB_GetListSurveys (MYSQL_RES **mysql_res, if (asprintf (&SubQuery[HieLvl_CRS],"%s(Scope='%s' AND Cod=%ld%s)", SubQueryFilled ? " OR " : "", - Sco_GetDBStrFromScope (HieLvl_CRS),Cods[HieLvl_CRS], + Hie_GetDBStrFromLevel (HieLvl_CRS),Cods[HieLvl_CRS], (HiddenAllowed & 1 << HieLvl_CRS) ? "" : " AND Hidden='N'") < 0) Err_NotEnoughMemoryExit (); @@ -255,10 +255,10 @@ unsigned Svy_DB_GetListSurveys (MYSQL_RES **mysql_res, } /***** Free allocated memory for subqueries *****/ - for (Scope = HieLvl_SYS; - Scope <= HieLvl_CRS; - Scope++) - free (SubQuery[Scope]); + for (Level = HieLvl_SYS; + Level <= HieLvl_CRS; + Level++) + free (SubQuery[Level]); return NumSvys; } @@ -342,8 +342,8 @@ bool Svy_DB_CheckIfSimilarSurveyExists (const struct Svy_Survey *Svy) " AND Cod=%ld" " AND Title='%s'" " AND SvyCod<>%ld)", - Sco_GetDBStrFromScope (Svy->Scope), - Svy->Cod, + Hie_GetDBStrFromLevel (Svy->Level), + Svy->HieCod, Svy->Title, Svy->SvyCod); } @@ -354,10 +354,10 @@ bool Svy_DB_CheckIfSimilarSurveyExists (const struct Svy_Survey *Svy) // Returns the number of courses with surveys for courses // in this location (all the platform, current degree or current course) -unsigned Svy_DB_GetNumCrssWithCrsSurveys (HieLvl_Level_t Scope) +unsigned Svy_DB_GetNumCrssWithCrsSurveys (HieLvl_Level_t Level) { /***** Get number of courses with surveys from database *****/ - switch (Scope) + switch (Level) { case HieLvl_SYS: return (unsigned) @@ -365,7 +365,7 @@ unsigned Svy_DB_GetNumCrssWithCrsSurveys (HieLvl_Level_t Scope) "SELECT COUNT(DISTINCT Cod)" " FROM svy_surveys" " WHERE Scope='%s'", - Sco_GetDBStrFromScope (HieLvl_CRS)); + Hie_GetDBStrFromLevel (HieLvl_CRS)); case HieLvl_CTY: return (unsigned) DB_QueryCOUNT ("can not get number of courses with surveys", @@ -382,7 +382,7 @@ unsigned Svy_DB_GetNumCrssWithCrsSurveys (HieLvl_Level_t Scope) " AND crs_courses.CrsCod=svy_surveys.Cod" " AND svy_surveys.Scope='%s'", Gbl.Hierarchy.Cty.CtyCod, - Sco_GetDBStrFromScope (HieLvl_CRS)); + Hie_GetDBStrFromLevel (HieLvl_CRS)); case HieLvl_INS: return (unsigned) DB_QueryCOUNT ("can not get number of courses with surveys", @@ -397,7 +397,7 @@ unsigned Svy_DB_GetNumCrssWithCrsSurveys (HieLvl_Level_t Scope) " AND crs_courses.CrsCod=svy_surveys.Cod" " AND svy_surveys.Scope='%s'", Gbl.Hierarchy.Ins.InsCod, - Sco_GetDBStrFromScope (HieLvl_CRS)); + Hie_GetDBStrFromLevel (HieLvl_CRS)); case HieLvl_CTR: return (unsigned) DB_QueryCOUNT ("can not get number of courses with surveys", @@ -410,7 +410,7 @@ unsigned Svy_DB_GetNumCrssWithCrsSurveys (HieLvl_Level_t Scope) " AND crs_courses.CrsCod=svy_surveys.Cod" " AND svy_surveys.Scope='%s'", Gbl.Hierarchy.Ctr.CtrCod, - Sco_GetDBStrFromScope (HieLvl_CRS)); + Hie_GetDBStrFromLevel (HieLvl_CRS)); case HieLvl_DEG: return (unsigned) DB_QueryCOUNT ("can not get number of courses with surveys", @@ -421,7 +421,7 @@ unsigned Svy_DB_GetNumCrssWithCrsSurveys (HieLvl_Level_t Scope) " AND crs_courses.CrsCod=svy_surveys.Cod" " AND svy_surveys.Scope='%s'", Gbl.Hierarchy.Deg.DegCod, - Sco_GetDBStrFromScope (HieLvl_CRS)); + Hie_GetDBStrFromLevel (HieLvl_CRS)); case HieLvl_CRS: return (unsigned) DB_QueryCOUNT ("can not get number of courses with surveys", @@ -429,10 +429,10 @@ unsigned Svy_DB_GetNumCrssWithCrsSurveys (HieLvl_Level_t Scope) " FROM svy_surveys" " WHERE Scope='%s'" " AND Cod=%ld", - Sco_GetDBStrFromScope (HieLvl_CRS), + Hie_GetDBStrFromLevel (HieLvl_CRS), Gbl.Hierarchy.Crs.CrsCod); default: - Err_WrongScopeExit (); + Err_WrongHierarchyLevelExit (); return 0; // Not reached } } @@ -443,10 +443,10 @@ unsigned Svy_DB_GetNumCrssWithCrsSurveys (HieLvl_Level_t Scope) // Returns the number of surveys for courses // in this location (all the platform, current degree or current course) -unsigned Svy_DB_GetNumCrsSurveys (MYSQL_RES **mysql_res,HieLvl_Level_t Scope) +unsigned Svy_DB_GetNumCrsSurveys (MYSQL_RES **mysql_res,HieLvl_Level_t Level) { /***** Get number of surveys from database *****/ - switch (Scope) + switch (Level) { case HieLvl_SYS: return (unsigned) @@ -455,7 +455,7 @@ unsigned Svy_DB_GetNumCrsSurveys (MYSQL_RES **mysql_res,HieLvl_Level_t Scope) "SUM(NumNotif)" // row[1] " FROM svy_surveys" " WHERE Scope='%s'", - Sco_GetDBStrFromScope (HieLvl_CRS)); + Hie_GetDBStrFromLevel (HieLvl_CRS)); case HieLvl_CTY: return (unsigned) DB_QuerySELECT (mysql_res,"can not get number of surveys", @@ -473,7 +473,7 @@ unsigned Svy_DB_GetNumCrsSurveys (MYSQL_RES **mysql_res,HieLvl_Level_t Scope) " AND crs_courses.CrsCod=svy_surveys.Cod" " AND svy_surveys.Scope='%s'", Gbl.Hierarchy.Cty.CtyCod, - Sco_GetDBStrFromScope (HieLvl_CRS)); + Hie_GetDBStrFromLevel (HieLvl_CRS)); case HieLvl_INS: return (unsigned) DB_QuerySELECT (mysql_res,"can not get number of surveys", @@ -489,7 +489,7 @@ unsigned Svy_DB_GetNumCrsSurveys (MYSQL_RES **mysql_res,HieLvl_Level_t Scope) " AND crs_courses.CrsCod=svy_surveys.Cod" " AND svy_surveys.Scope='%s'", Gbl.Hierarchy.Ins.InsCod, - Sco_GetDBStrFromScope (HieLvl_CRS)); + Hie_GetDBStrFromLevel (HieLvl_CRS)); case HieLvl_CTR: return (unsigned) DB_QuerySELECT (mysql_res,"can not get number of surveys", @@ -503,7 +503,7 @@ unsigned Svy_DB_GetNumCrsSurveys (MYSQL_RES **mysql_res,HieLvl_Level_t Scope) " AND crs_courses.CrsCod=svy_surveys.Cod" " AND svy_surveys.Scope='%s'", Gbl.Hierarchy.Ctr.CtrCod, - Sco_GetDBStrFromScope (HieLvl_CRS)); + Hie_GetDBStrFromLevel (HieLvl_CRS)); case HieLvl_DEG: return (unsigned) DB_QuerySELECT (mysql_res,"can not get number of surveys", @@ -515,7 +515,7 @@ unsigned Svy_DB_GetNumCrsSurveys (MYSQL_RES **mysql_res,HieLvl_Level_t Scope) " AND crs_courses.CrsCod=svy_surveys.Cod" " AND svy_surveys.Scope='%s'", Gbl.Hierarchy.Deg.DegCod, - Sco_GetDBStrFromScope (HieLvl_CRS)); + Hie_GetDBStrFromLevel (HieLvl_CRS)); case HieLvl_CRS: return (unsigned) DB_QuerySELECT (mysql_res,"can not get number of surveys", @@ -524,10 +524,10 @@ unsigned Svy_DB_GetNumCrsSurveys (MYSQL_RES **mysql_res,HieLvl_Level_t Scope) " FROM svy_surveys" " WHERE svy_surveys.Scope='%s'" " AND CrsCod=%ld", - Sco_GetDBStrFromScope (HieLvl_CRS), + Hie_GetDBStrFromLevel (HieLvl_CRS), Gbl.Hierarchy.Crs.CrsCod); default: - Err_WrongScopeExit (); + Err_WrongHierarchyLevelExit (); return 0; // Not reached } } @@ -536,10 +536,10 @@ unsigned Svy_DB_GetNumCrsSurveys (MYSQL_RES **mysql_res,HieLvl_Level_t Scope) /************ Get average number of questions per course survey **************/ /*****************************************************************************/ -double Svy_DB_GetNumQstsPerCrsSurvey (HieLvl_Level_t Scope) +double Svy_DB_GetNumQstsPerCrsSurvey (HieLvl_Level_t Level) { /***** Get number of questions per survey from database *****/ - switch (Scope) + switch (Level) { case HieLvl_SYS: return DB_QuerySELECTDouble ("can not get number of questions per survey", @@ -550,7 +550,7 @@ double Svy_DB_GetNumQstsPerCrsSurvey (HieLvl_Level_t Scope) " WHERE svy_surveys.Scope='%s'" " AND svy_surveys.SvyCod=svy_questions.SvyCod" " GROUP BY svy_questions.SvyCod) AS NumQstsTable", - Sco_GetDBStrFromScope (HieLvl_CRS)); + Hie_GetDBStrFromLevel (HieLvl_CRS)); case HieLvl_CTY: return DB_QuerySELECTDouble ("can not get number of questions per survey", "SELECT AVG(NumQsts)" @@ -570,7 +570,7 @@ double Svy_DB_GetNumQstsPerCrsSurvey (HieLvl_Level_t Scope) " AND svy_surveys.SvyCod=svy_questions.SvyCod" " GROUP BY svy_questions.SvyCod) AS NumQstsTable", Gbl.Hierarchy.Cty.CtyCod, - Sco_GetDBStrFromScope (HieLvl_CRS)); + Hie_GetDBStrFromLevel (HieLvl_CRS)); case HieLvl_INS: return DB_QuerySELECTDouble ("can not get number of questions per survey", "SELECT AVG(NumQsts)" @@ -588,7 +588,7 @@ double Svy_DB_GetNumQstsPerCrsSurvey (HieLvl_Level_t Scope) " AND svy_surveys.SvyCod=svy_questions.SvyCod" " GROUP BY svy_questions.SvyCod) AS NumQstsTable", Gbl.Hierarchy.Ins.InsCod, - Sco_GetDBStrFromScope (HieLvl_CRS)); + Hie_GetDBStrFromLevel (HieLvl_CRS)); case HieLvl_CTR: return DB_QuerySELECTDouble ("can not get number of questions per survey", "SELECT AVG(NumQsts)" @@ -604,7 +604,7 @@ double Svy_DB_GetNumQstsPerCrsSurvey (HieLvl_Level_t Scope) " AND svy_surveys.SvyCod=svy_questions.SvyCod" " GROUP BY svy_questions.SvyCod) AS NumQstsTable", Gbl.Hierarchy.Ctr.CtrCod, - Sco_GetDBStrFromScope (HieLvl_CRS)); + Hie_GetDBStrFromLevel (HieLvl_CRS)); case HieLvl_DEG: return DB_QuerySELECTDouble ("can not get number of questions per survey", "SELECT AVG(NumQsts)" @@ -618,7 +618,7 @@ double Svy_DB_GetNumQstsPerCrsSurvey (HieLvl_Level_t Scope) " AND svy_surveys.SvyCod=svy_questions.SvyCod" " GROUP BY svy_questions.SvyCod) AS NumQstsTable", Gbl.Hierarchy.Deg.DegCod, - Sco_GetDBStrFromScope (HieLvl_CRS)); + Hie_GetDBStrFromLevel (HieLvl_CRS)); case HieLvl_CRS: return DB_QuerySELECTDouble ("can not get number of questions per survey", "SELECT AVG(NumQsts)" @@ -629,9 +629,9 @@ double Svy_DB_GetNumQstsPerCrsSurvey (HieLvl_Level_t Scope) " AND svy_surveys.Cod=%ld" " AND svy_surveys.SvyCod=svy_questions.SvyCod" " GROUP BY svy_questions.SvyCod) AS NumQstsTable", - Sco_GetDBStrFromScope (HieLvl_CRS),Gbl.Hierarchy.Crs.CrsCod); + Hie_GetDBStrFromLevel (HieLvl_CRS),Gbl.Hierarchy.Crs.CrsCod); default: - Err_WrongScopeExit (); + Err_WrongHierarchyLevelExit (); return 0.0; // Not reached } } @@ -676,11 +676,11 @@ unsigned Svy_DB_GetUsrsFromSurveyExceptMe (MYSQL_RES **mysql_res,long SvyCod) " AND (svy_surveys.Roles&(1<0)", SvyCod, SvyCod, - Sco_GetDBStrFromScope (HieLvl_CRS), + Hie_GetDBStrFromLevel (HieLvl_CRS), Gbl.Usrs.Me.UsrDat.UsrCod, SvyCod, Gbl.Usrs.Me.UsrDat.UsrCod, - Sco_GetDBStrFromScope (HieLvl_CRS)); + Hie_GetDBStrFromLevel (HieLvl_CRS)); } /*****************************************************************************/ @@ -700,14 +700,14 @@ void Svy_DB_RemoveSvy (long SvyCod) /************* (country, institution, center, degree or course) **************/ /*****************************************************************************/ -void Svy_DB_RemoveSvysIn (HieLvl_Level_t Scope,long Cod) +void Svy_DB_RemoveSvysIn (HieLvl_Level_t Level,long HieCod) { DB_QueryDELETE ("can not remove all surveys in a place on the hierarchy", "DELETE FROM svy_surveys" " WHERE Scope='%s'" " AND Cod=%ld", - Sco_GetDBStrFromScope (Scope), - Cod); + Hie_GetDBStrFromLevel (Level), + HieCod); } /*****************************************************************************/ @@ -818,7 +818,7 @@ void Svy_DB_RemoveGrpsAssociatedToSurvey (long SvyCod) /********** (country, institution, center, degree or course) *********/ /*****************************************************************************/ -void Svy_DB_RemoveGrpsSvysIn (HieLvl_Level_t Scope,long Cod) +void Svy_DB_RemoveGrpsSvysIn (HieLvl_Level_t Level,long HieCod) { DB_QueryDELETE ("can not remove all groups" " associated to surveys of a course", @@ -828,8 +828,8 @@ void Svy_DB_RemoveGrpsSvysIn (HieLvl_Level_t Scope,long Cod) " WHERE svy_surveys.Scope='%s'" " AND svy_surveys.Cod=%ld" " AND svy_surveys.SvyCod=svy_groups.SvyCod", - Sco_GetDBStrFromScope (Scope), - Cod); + Hie_GetDBStrFromLevel (Level), + HieCod); } /*****************************************************************************/ @@ -1016,7 +1016,7 @@ void Svy_DB_RemoveQstsSvy (long SvyCod) /******** (country, institution, center, degree or course) ********/ /*****************************************************************************/ -void Svy_DB_RemoveQstsSvysIn (HieLvl_Level_t Scope,long Cod) +void Svy_DB_RemoveQstsSvysIn (HieLvl_Level_t Level,long HieCod) { DB_QueryDELETE ("can not remove questions of surveys" " in a place on the hierarchy", @@ -1026,8 +1026,8 @@ void Svy_DB_RemoveQstsSvysIn (HieLvl_Level_t Scope,long Cod) " WHERE svy_surveys.Scope='%s'" " AND svy_surveys.Cod=%ld" " AND svy_surveys.SvyCod=svy_questions.SvyCod", - Sco_GetDBStrFromScope (Scope), - Cod); + Hie_GetDBStrFromLevel (Level), + HieCod); } /*****************************************************************************/ @@ -1191,7 +1191,7 @@ void Svy_DB_RemoveAnswersSvy (long SvyCod) /********* (country, institution, center, degree or course) *********/ /*****************************************************************************/ -void Svy_DB_RemoveAnswersSvysIn (HieLvl_Level_t Scope,long Cod) +void Svy_DB_RemoveAnswersSvysIn (HieLvl_Level_t Level,long HieCod) { DB_QueryDELETE ("can not remove answers of surveys" " in a place on the hierarchy", @@ -1203,8 +1203,8 @@ void Svy_DB_RemoveAnswersSvysIn (HieLvl_Level_t Scope,long Cod) " AND svy_surveys.Cod=%ld" " AND svy_surveys.SvyCod=svy_questions.SvyCod" " AND svy_questions.QstCod=svy_answers.QstCod", - Sco_GetDBStrFromScope (Scope), - Cod); + Hie_GetDBStrFromLevel (Level), + HieCod); } /*****************************************************************************/ @@ -1269,7 +1269,7 @@ void Svy_DB_RemoveCommentsSvy (long SvyCod) /********* (country, institution, center, degree or course) ********/ /*****************************************************************************/ -void Svy_DB_RemoveCommentsSvysIn (HieLvl_Level_t Scope,long Cod) +void Svy_DB_RemoveCommentsSvysIn (HieLvl_Level_t Level,long HieCod) { DB_QueryDELETE ("can not remove comments of surveys" " in a place on the hierarchy", @@ -1281,8 +1281,8 @@ void Svy_DB_RemoveCommentsSvysIn (HieLvl_Level_t Scope,long Cod) " AND svy_surveys.Cod=%ld" " AND svy_surveys.SvyCod=svy_questions.SvyCod" " AND svy_questions.QstCod=svy_comments.QstCod", - Sco_GetDBStrFromScope (Scope), - Cod); + Hie_GetDBStrFromLevel (Level), + HieCod); } /*****************************************************************************/ @@ -1348,7 +1348,7 @@ void Svy_DB_RemoveUsrsWhoHaveAnsweredSvy (long SvyCod) /************* (country, institution, center, degree or course) **************/ /*****************************************************************************/ -void Svy_DB_RemoveUsrsWhoHaveAnsweredSvysIn (HieLvl_Level_t Scope,long Cod) +void Svy_DB_RemoveUsrsWhoHaveAnsweredSvysIn (HieLvl_Level_t Level,long HieCod) { DB_QueryDELETE ("can not remove users" " who had answered surveys in a place on the hierarchy", @@ -1358,6 +1358,6 @@ void Svy_DB_RemoveUsrsWhoHaveAnsweredSvysIn (HieLvl_Level_t Scope,long Cod) " WHERE svy_surveys.Scope='%s'" " AND svy_surveys.Cod=%ld" " AND svy_surveys.SvyCod=svy_users.SvyCod", - Sco_GetDBStrFromScope (Scope), - Cod); + Hie_GetDBStrFromLevel (Level), + HieCod); } diff --git a/swad_survey_database.h b/swad_survey_database.h index 534416d4..9e869396 100644 --- a/swad_survey_database.h +++ b/swad_survey_database.h @@ -53,13 +53,13 @@ void Svy_DB_GetSurveyTitle (long SvyCod,char *Title,size_t TitleSize); unsigned Svy_DB_GetSurveyTitleAndText (MYSQL_RES **mysql_res,long SvyCod); void Svy_DB_GetSurveyTxt (long SvyCod,char Txt[Cns_MAX_BYTES_TEXT + 1]); bool Svy_DB_CheckIfSimilarSurveyExists (const struct Svy_Survey *Svy); -unsigned Svy_DB_GetNumCrssWithCrsSurveys (HieLvl_Level_t Scope); -unsigned Svy_DB_GetNumCrsSurveys (MYSQL_RES **mysql_res,HieLvl_Level_t Scope); -double Svy_DB_GetNumQstsPerCrsSurvey (HieLvl_Level_t Scope); +unsigned Svy_DB_GetNumCrssWithCrsSurveys (HieLvl_Level_t Level); +unsigned Svy_DB_GetNumCrsSurveys (MYSQL_RES **mysql_res,HieLvl_Level_t Level); +double Svy_DB_GetNumQstsPerCrsSurvey (HieLvl_Level_t Level); unsigned Svy_DB_GetUsrsFromSurveyExceptMe (MYSQL_RES **mysql_res,long SvyCod); void Svy_DB_RemoveSvy (long SvyCod); -void Svy_DB_RemoveSvysIn (HieLvl_Level_t Scope,long Cod); +void Svy_DB_RemoveSvysIn (HieLvl_Level_t Level,long HieCod); //---------------------------- Surveys groups --------------------------------- void Svy_DB_CreateGrp (long SvyCod,long GrpCod); @@ -70,7 +70,7 @@ bool Svy_DB_CheckIfICanDoThisSurveyBasedOnGrps (long SvyCod); void Svy_DB_RemoveGroupsOfType (long GrpTypCod); void Svy_DB_RemoveGroup (long GrpCod); void Svy_DB_RemoveGrpsAssociatedToSurvey (long SvyCod); -void Svy_DB_RemoveGrpsSvysIn (HieLvl_Level_t Scope,long Cod); +void Svy_DB_RemoveGrpsSvysIn (HieLvl_Level_t Level,long HieCod); //--------------------------- Surveys questions ------------------------------- long Svy_DB_CreateQuestion (long SvyCod, @@ -90,7 +90,7 @@ unsigned Svy_DB_GetLastQstInd (MYSQL_RES **mysql_res,long SvyCod); void Svy_DB_RemoveQst (long QstCod); void Svy_DB_RemoveQstsSvy (long SvyCod); -void Svy_DB_RemoveQstsSvysIn (HieLvl_Level_t Scope,long Cod); +void Svy_DB_RemoveQstsSvysIn (HieLvl_Level_t Level,long HieCod); //---------------------------- Surveys answers -------------------------------- void Svy_DB_CreateAnswer (long QstCod,unsigned AnsInd,const char *Text); @@ -105,7 +105,7 @@ Svy_AnswerType_t Svy_DB_ConvertFromStrAnsTypDBToAnsTyp (const char *StrAnsTypeDB void Svy_DB_RemoveAnswerQst (long QstCod,unsigned AnsInd); void Svy_DB_RemoveAnswersQst (long QstCod); void Svy_DB_RemoveAnswersSvy (long SvyCod); -void Svy_DB_RemoveAnswersSvysIn (HieLvl_Level_t Scope,long Cod); +void Svy_DB_RemoveAnswersSvysIn (HieLvl_Level_t Level,long HieCod); //---------------------------- Surveys comments ------------------------------- void Svy_DB_CreateComments (long QstCod,const char *Comments); @@ -113,7 +113,7 @@ unsigned Svy_DB_GetCommentsQst (MYSQL_RES **mysql_res,long QstCod); void Svy_DB_RemoveCommentsQst (long QstCod); void Svy_DB_RemoveCommentsSvy (long SvyCod); -void Svy_DB_RemoveCommentsSvysIn (HieLvl_Level_t Scope,long Cod); +void Svy_DB_RemoveCommentsSvysIn (HieLvl_Level_t Level,long HieCod); //--------------------- Users who have answered surveys ----------------------- void Svy_DB_RegisterIHaveAnsweredSvy (long SvyCod); @@ -122,6 +122,6 @@ bool Svy_DB_CheckIfIHaveAnsweredSvy (long SvyCod); unsigned Svy_DB_GetNumUsrsWhoHaveAnsweredSvy (long SvyCod); void Svy_DB_RemoveUsrsWhoHaveAnsweredSvy (long SvyCod); -void Svy_DB_RemoveUsrsWhoHaveAnsweredSvysIn (HieLvl_Level_t Scope,long Cod); +void Svy_DB_RemoveUsrsWhoHaveAnsweredSvysIn (HieLvl_Level_t Level,long HieCod); #endif diff --git a/swad_timeline_database.c b/swad_timeline_database.c index 6d4ba31c..9a916e58 100644 --- a/swad_timeline_database.c +++ b/swad_timeline_database.c @@ -299,7 +299,7 @@ unsigned Tml_DB_GetNumNotesAndUsrsByType (MYSQL_RES **mysql_res, Gbl.Hierarchy.Crs.CrsCod, (unsigned) NoteType); default: - Err_WrongScopeExit (); + Err_WrongHierarchyLevelExit (); return 0; // Not reached } } @@ -389,7 +389,7 @@ unsigned Tml_DB_GetNumNotesAndUsrsTotal (MYSQL_RES **mysql_res) " AND crs_users.UsrCod=tml_notes.UsrCod", Gbl.Hierarchy.Crs.CrsCod); default: - Err_WrongScopeExit (); + Err_WrongHierarchyLevelExit (); return 0; // Not reached } } diff --git a/swad_user.c b/swad_user.c index 8a924d7b..33ac81c9 100644 --- a/swad_user.c +++ b/swad_user.c @@ -188,7 +188,7 @@ static void Usr_WriteUsrData (const char *BgColor, const char *Data,const char *Link, bool NonBreak,bool Accepted); -static void Usr_GetGstsLst (HieLvl_Level_t Scope); +static void Usr_GetGstsLst (HieLvl_Level_t Level); static void Usr_AllocateUsrsList (Rol_Role_t Role); static void Usr_PutButtonToConfirmIWantToSeeBigList (unsigned NumUsrs, @@ -360,8 +360,8 @@ void Usr_ResetUsrDataExceptUsrCodAndIDs (struct Usr_Data *UsrDat) void Usr_ResetMyLastData (void) { Gbl.Usrs.Me.UsrLast.WhatToSearch = Sch_WHAT_TO_SEARCH_DEFAULT; - Gbl.Usrs.Me.UsrLast.LastHie.Scope = HieLvl_UNK; - Gbl.Usrs.Me.UsrLast.LastHie.Cod = -1L; + Gbl.Usrs.Me.UsrLast.LastHie.Level = HieLvl_UNK; + Gbl.Usrs.Me.UsrLast.LastHie.HieCod = -1L; Gbl.Usrs.Me.UsrLast.LastAct = ActUnk; Gbl.Usrs.Me.UsrLast.LastRole = Rol_UNK; Gbl.Usrs.Me.UsrLast.LastTime = 0; @@ -614,27 +614,27 @@ static void Usr_GetMyLastData (void) Gbl.Usrs.Me.UsrLast.WhatToSearch = Sch_WHAT_TO_SEARCH_DEFAULT; /* Get last hierarchy: scope (row[1]) and code (row[2]) */ - Gbl.Usrs.Me.UsrLast.LastHie.Scope = Sco_GetScopeFromDBStr (row[1]); - switch (Gbl.Usrs.Me.UsrLast.LastHie.Scope) + Gbl.Usrs.Me.UsrLast.LastHie.Level = Hie_GetLevelFromDBStr (row[1]); + switch (Gbl.Usrs.Me.UsrLast.LastHie.Level) { case HieLvl_SYS: // System - Gbl.Usrs.Me.UsrLast.LastHie.Cod = -1L; + Gbl.Usrs.Me.UsrLast.LastHie.HieCod = -1L; break; case HieLvl_CTY: // Country case HieLvl_INS: // Institution case HieLvl_CTR: // Center case HieLvl_DEG: // Degree case HieLvl_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.HieCod = Str_ConvertStrCodToLongCod (row[2]); + if (Gbl.Usrs.Me.UsrLast.LastHie.HieCod <= 0) { - Gbl.Usrs.Me.UsrLast.LastHie.Scope = HieLvl_UNK; - Gbl.Usrs.Me.UsrLast.LastHie.Cod = -1L; + Gbl.Usrs.Me.UsrLast.LastHie.Level = HieLvl_UNK; + Gbl.Usrs.Me.UsrLast.LastHie.HieCod = -1L; } break; default: - Gbl.Usrs.Me.UsrLast.LastHie.Scope = HieLvl_UNK; - Gbl.Usrs.Me.UsrLast.LastHie.Cod = -1L; + Gbl.Usrs.Me.UsrLast.LastHie.Level = HieLvl_UNK; + Gbl.Usrs.Me.UsrLast.LastHie.HieCod = -1L; break; } @@ -2015,8 +2015,8 @@ static void Usr_SetMyPrefsAndRoles (void) // Role and action will be got from last data // only if I am in the same hierarchy location that the stored one GetRoleAndActionFromLastData = - (Gbl.Hierarchy.Level == Gbl.Usrs.Me.UsrLast.LastHie.Scope && // The same scope... - Gbl.Hierarchy.Cod == Gbl.Usrs.Me.UsrLast.LastHie.Cod); // ...and code in hierarchy + (Gbl.Hierarchy.Level == Gbl.Usrs.Me.UsrLast.LastHie.Level && // The same scope... + Gbl.Hierarchy.Cod == Gbl.Usrs.Me.UsrLast.LastHie.HieCod); // ...and code in hierarchy /***** Get role and action from last data *****/ if (GetRoleAndActionFromLastData) @@ -2693,15 +2693,15 @@ static void Usr_WriteUsrData (const char *BgColor, // - Rol_NET Non-editing teacher // - Rol_TCH Teacher -void Usr_GetListUsrs (HieLvl_Level_t Scope,Rol_Role_t Role) +void Usr_GetListUsrs (HieLvl_Level_t Level,Rol_Role_t Role) { char *Query = NULL; /***** Build query *****/ - Usr_DB_BuildQueryToGetUsrsLst (Scope,Role,&Query); + Usr_DB_BuildQueryToGetUsrsLst (Level,Role,&Query); /***** Get list of users from database given a query *****/ - Usr_GetListUsrsFromQuery (Query,Role,Scope); + Usr_GetListUsrsFromQuery (Query,Role,Level); /***** Free query string *****/ free (Query); @@ -2729,15 +2729,15 @@ void Usr_SearchListUsrs (Rol_Role_t Role) /************************ Get list with data of guests ***********************/ /*****************************************************************************/ -static void Usr_GetGstsLst (HieLvl_Level_t Scope) +static void Usr_GetGstsLst (HieLvl_Level_t Level) { char *Query = NULL; /***** Build query *****/ - Usr_DB_BuildQueryToGetGstsLst (Scope,&Query); + Usr_DB_BuildQueryToGetGstsLst (Level,&Query); /***** Get list of students from database *****/ - Usr_GetListUsrsFromQuery (Query,Rol_GST,Scope); + Usr_GetListUsrsFromQuery (Query,Rol_GST,Level); /***** Free query string *****/ free (Query); @@ -2765,7 +2765,7 @@ void Usr_GetUnorderedStdsCodesInDeg (long DegCod) /********************** Get list of users from database **********************/ /*****************************************************************************/ -void Usr_GetListUsrsFromQuery (char *Query,Rol_Role_t Role,HieLvl_Level_t Scope) +void Usr_GetListUsrsFromQuery (char *Query,Rol_Role_t Role,HieLvl_Level_t Level) { extern const char *Txt_The_list_of_X_users_is_too_large_to_be_displayed; MYSQL_RES *mysql_res; @@ -2857,10 +2857,10 @@ void Usr_GetListUsrsFromQuery (char *Query,Rol_Role_t Role,HieLvl_Level_t Scope) switch (Role) { case Rol_UNK: // Here Rol_UNK means any user - switch (Scope) + switch (Level) { case HieLvl_UNK: // Unknown - Err_WrongScopeExit (); + Err_WrongHierarchyLevelExit (); break; case HieLvl_SYS: // System // Query result has not a column with the acceptation @@ -2895,10 +2895,10 @@ void Usr_GetListUsrsFromQuery (char *Query,Rol_Role_t Role,HieLvl_Level_t Scope) case Rol_STD: case Rol_NET: case Rol_TCH: - switch (Scope) + switch (Level) { case HieLvl_UNK: // Unknown - Err_WrongScopeExit (); + Err_WrongHierarchyLevelExit (); break; case HieLvl_SYS: // System case HieLvl_CTY: // Country @@ -6332,7 +6332,7 @@ unsigned Usr_GetTotalNumberOfUsers (void) (1 << Rol_TCH); return Enr_GetCachedNumUsrsInCrss (Gbl.Scope.Current,Cod,Roles); // All users in courses default: - Err_WrongScopeExit (); + Err_WrongHierarchyLevelExit (); return 0; // Not reached } } @@ -6632,7 +6632,7 @@ static void Usr_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 = Sco_GetCurrentCod (); + long Cod = Hie_GetCurrentCod (); const char *Class; unsigned Roles; diff --git a/swad_user.h b/swad_user.h index 235d4da4..63fa3613 100644 --- a/swad_user.h +++ b/swad_user.h @@ -104,7 +104,7 @@ typedef enum } Usr_GetRoleInCurrentCrs_t; -// Related with user's sexs +// Related with user's sexes #define Usr_NUM_SEXS 4 // Unknown, female, male, all typedef enum { @@ -227,8 +227,8 @@ struct Usr_Last Sch_WhatToSearch_t WhatToSearch; // Search courses, teachers, documents...? struct { - HieLvl_Level_t Scope; // Course, degree, center, etc. - long Cod; // Course code, degree code, center code, etc. + HieLvl_Level_t Level; // Course, degree, center, etc. + long HieCod; // Course code, degree code, center code, etc. } LastHie; Act_Action_t LastAct; Rol_Role_t LastRole; @@ -241,8 +241,8 @@ struct Usr_InList long UsrCod; char EnUsrCod[Cry_BYTES_ENCRYPTED_STR_SHA256_BASE64 + 1]; char Password[Pwd_BYTES_ENCRYPTED_PASSWORD + 1]; - char Surname1 [Usr_MAX_BYTES_FIRSTNAME_OR_SURNAME + 1]; - char Surname2 [Usr_MAX_BYTES_FIRSTNAME_OR_SURNAME + 1]; + char Surname1[Usr_MAX_BYTES_FIRSTNAME_OR_SURNAME + 1]; + char Surname2[Usr_MAX_BYTES_FIRSTNAME_OR_SURNAME + 1]; char FrstName[Usr_MAX_BYTES_FIRSTNAME_OR_SURNAME + 1]; Usr_Sex_t Sex; char Photo[Cry_BYTES_ENCRYPTED_STR_SHA256_BASE64 + 1]; // Name of public link to photo @@ -352,13 +352,13 @@ void Usr_WriteRowUsrMainData (unsigned NumUsr,struct Usr_Data *UsrDat, bool PutCheckBoxToSelectUsr,Rol_Role_t Role, struct Usr_SelectedUsrs *SelectedUsrs); -void Usr_GetListUsrs (HieLvl_Level_t Scope,Rol_Role_t Role); +void Usr_GetListUsrs (HieLvl_Level_t Level,Rol_Role_t Role); void Usr_SearchListUsrs (Rol_Role_t Role); void Usr_GetUnorderedStdsCodesInDeg (long DegCod); -void Usr_GetListUsrsFromQuery (char *Query,Rol_Role_t Role,HieLvl_Level_t Scope); +void Usr_GetListUsrsFromQuery (char *Query,Rol_Role_t Role,HieLvl_Level_t Level); void Usr_CopyBasicUsrDataFromList (struct Usr_Data *UsrDat, const struct Usr_InList *UsrInList); diff --git a/swad_user_database.c b/swad_user_database.c index 06c3f175..e35f3fda 100644 --- a/swad_user_database.c +++ b/swad_user_database.c @@ -330,7 +330,8 @@ bool Usr_DB_FindStrInUsrsNames (const char *Str) // - Rol_NET Non-editing teacher // - Rol_TCH Teacher -void Usr_DB_BuildQueryToGetUsrsLst (HieLvl_Level_t Scope,Rol_Role_t Role,char **Query) +void Usr_DB_BuildQueryToGetUsrsLst (HieLvl_Level_t Level,Rol_Role_t Role, + char **Query) { const char *QueryFields = "DISTINCT " @@ -352,7 +353,7 @@ void Usr_DB_BuildQueryToGetUsrsLst (HieLvl_Level_t Scope,Rol_Role_t Role,char ** "usr_data.UsrCod"; /***** Build query *****/ - switch (Scope) + switch (Level) { case HieLvl_SYS: /* Get users in courses from the whole platform */ @@ -456,7 +457,7 @@ void Usr_DB_BuildQueryToGetUsrsLst (HieLvl_Level_t Scope,Rol_Role_t Role,char ** Usr_DB_BuildQueryToGetUsrsLstCrs (Query,Role); break; default: - Err_WrongScopeExit (); + Err_WrongHierarchyLevelExit (); break; } /* @@ -662,7 +663,7 @@ void Usr_DB_BuildQueryToGetUsrsLstCrs (char **Query,Rol_Role_t Role) /************ Build query to get list with data of administrators ************/ /*****************************************************************************/ -void Usr_DB_BuildQueryToGetAdmsLst (HieLvl_Level_t Scope,char **Query) +void Usr_DB_BuildQueryToGetAdmsLst (HieLvl_Level_t Level,char **Query) { static const char *QueryFields = "UsrCod," // row[ 0] @@ -687,7 +688,7 @@ void Usr_DB_BuildQueryToGetAdmsLst (HieLvl_Level_t Scope,char **Query) // SELECT... WHERE UsrCod IN (SELECT...) OR UsrCod IN (SELECT...) <-- fast // instead of using or with different joins: // SELECT... WHERE (...) OR (...) <-- very slow - switch (Scope) + switch (Level) { case HieLvl_SYS: // All admins DB_BuildQuery (Query, @@ -739,10 +740,10 @@ void Usr_DB_BuildQueryToGetAdmsLst (HieLvl_Level_t Scope,char **Query) " AND ins_instits.CtyCod=%ld)" " %s", QueryFields, - Sco_GetDBStrFromScope (HieLvl_SYS), - Sco_GetDBStrFromScope (HieLvl_INS),Gbl.Hierarchy.Cty.CtyCod, - Sco_GetDBStrFromScope (HieLvl_CTR),Gbl.Hierarchy.Cty.CtyCod, - Sco_GetDBStrFromScope (HieLvl_DEG),Gbl.Hierarchy.Cty.CtyCod, + Hie_GetDBStrFromLevel (HieLvl_SYS), + Hie_GetDBStrFromLevel (HieLvl_INS),Gbl.Hierarchy.Cty.CtyCod, + Hie_GetDBStrFromLevel (HieLvl_CTR),Gbl.Hierarchy.Cty.CtyCod, + Hie_GetDBStrFromLevel (HieLvl_DEG),Gbl.Hierarchy.Cty.CtyCod, OrderBySubQuery); break; case HieLvl_INS: // System admins, @@ -778,10 +779,10 @@ void Usr_DB_BuildQueryToGetAdmsLst (HieLvl_Level_t Scope,char **Query) " AND ctr_centers.InsCod=%ld)" "%s", QueryFields, - Sco_GetDBStrFromScope (HieLvl_SYS), - Sco_GetDBStrFromScope (HieLvl_INS),Gbl.Hierarchy.Ins.InsCod, - Sco_GetDBStrFromScope (HieLvl_CTR),Gbl.Hierarchy.Ins.InsCod, - Sco_GetDBStrFromScope (HieLvl_DEG),Gbl.Hierarchy.Ins.InsCod, + Hie_GetDBStrFromLevel (HieLvl_SYS), + Hie_GetDBStrFromLevel (HieLvl_INS),Gbl.Hierarchy.Ins.InsCod, + Hie_GetDBStrFromLevel (HieLvl_CTR),Gbl.Hierarchy.Ins.InsCod, + Hie_GetDBStrFromLevel (HieLvl_DEG),Gbl.Hierarchy.Ins.InsCod, OrderBySubQuery); break; case HieLvl_CTR: // System admins, @@ -814,10 +815,10 @@ void Usr_DB_BuildQueryToGetAdmsLst (HieLvl_Level_t Scope,char **Query) " AND deg_degrees.CtrCod=%ld)" "%s", QueryFields, - Sco_GetDBStrFromScope (HieLvl_SYS), - Sco_GetDBStrFromScope (HieLvl_INS),Gbl.Hierarchy.Ins.InsCod, - Sco_GetDBStrFromScope (HieLvl_CTR),Gbl.Hierarchy.Ctr.CtrCod, - Sco_GetDBStrFromScope (HieLvl_DEG),Gbl.Hierarchy.Ctr.CtrCod, + Hie_GetDBStrFromLevel (HieLvl_SYS), + Hie_GetDBStrFromLevel (HieLvl_INS),Gbl.Hierarchy.Ins.InsCod, + Hie_GetDBStrFromLevel (HieLvl_CTR),Gbl.Hierarchy.Ctr.CtrCod, + Hie_GetDBStrFromLevel (HieLvl_DEG),Gbl.Hierarchy.Ctr.CtrCod, OrderBySubQuery); break; case HieLvl_DEG: // System admins @@ -846,14 +847,14 @@ void Usr_DB_BuildQueryToGetAdmsLst (HieLvl_Level_t Scope,char **Query) " AND Cod=%ld)" "%s", QueryFields, - Sco_GetDBStrFromScope (HieLvl_SYS), - Sco_GetDBStrFromScope (HieLvl_INS),Gbl.Hierarchy.Ins.InsCod, - Sco_GetDBStrFromScope (HieLvl_CTR),Gbl.Hierarchy.Ctr.CtrCod, - Sco_GetDBStrFromScope (HieLvl_DEG),Gbl.Hierarchy.Deg.DegCod, + Hie_GetDBStrFromLevel (HieLvl_SYS), + Hie_GetDBStrFromLevel (HieLvl_INS),Gbl.Hierarchy.Ins.InsCod, + Hie_GetDBStrFromLevel (HieLvl_CTR),Gbl.Hierarchy.Ctr.CtrCod, + Hie_GetDBStrFromLevel (HieLvl_DEG),Gbl.Hierarchy.Deg.DegCod, OrderBySubQuery); break; default: // not aplicable - Err_WrongScopeExit (); + Err_WrongHierarchyLevelExit (); break; } } @@ -862,7 +863,7 @@ void Usr_DB_BuildQueryToGetAdmsLst (HieLvl_Level_t Scope,char **Query) /************************ Get list with data of guests ***********************/ /*****************************************************************************/ -void Usr_DB_BuildQueryToGetGstsLst (HieLvl_Level_t Scope,char **Query) +void Usr_DB_BuildQueryToGetGstsLst (HieLvl_Level_t Level,char **Query) { static const char *QueryFields = "UsrCod," // row[ 0] @@ -883,7 +884,7 @@ void Usr_DB_BuildQueryToGetGstsLst (HieLvl_Level_t Scope,char **Query) "UsrCod"; /***** Build query *****/ - switch (Scope) + switch (Level) { case HieLvl_SYS: DB_BuildQuery (Query, @@ -939,7 +940,7 @@ void Usr_DB_BuildQueryToGetGstsLst (HieLvl_Level_t Scope,char **Query) OrderBySubQuery); break; default: // not aplicable - Err_WrongScopeExit (); + Err_WrongHierarchyLevelExit (); break; // Not reached } } @@ -1082,7 +1083,7 @@ void Usr_DB_BuildQueryToSearchListUsrs (Rol_Role_t Role,char **Query) OrderBySubQuery); break; default: - Err_WrongScopeExit (); + Err_WrongHierarchyLevelExit (); break; } break; @@ -1242,7 +1243,7 @@ void Usr_DB_BuildQueryToSearchListUsrs (Rol_Role_t Role,char **Query) OrderBySubQuery); break; default: - Err_WrongScopeExit (); + Err_WrongHierarchyLevelExit (); break; } break; @@ -1371,7 +1372,7 @@ unsigned Usr_DB_GetNumUsrsWhoChoseAnOption (const char *SubQuery) " AND %s", Gbl.Hierarchy.Crs.CrsCod,SubQuery); default: - Err_WrongScopeExit (); + Err_WrongHierarchyLevelExit (); return 0; // Not reached } } @@ -1460,7 +1461,7 @@ void Usr_DB_InsertMyLastData (void) "'%s',%ld,%ld,%u,NOW(),FROM_UNIXTIME(%ld))", Gbl.Usrs.Me.UsrDat.UsrCod, (unsigned) Sch_SEARCH_ALL, - Sco_GetDBStrFromScope (Gbl.Hierarchy.Level), + Hie_GetDBStrFromLevel (Gbl.Hierarchy.Level), Gbl.Hierarchy.Cod, Act_GetActCod (Gbl.Action.Act), (unsigned) Gbl.Usrs.Me.Role.Logged, @@ -1482,7 +1483,7 @@ void Usr_DB_UpdateMyLastData (void) "LastRole=%u," "LastTime=NOW()" " WHERE UsrCod=%ld", - Sco_GetDBStrFromScope (Gbl.Hierarchy.Level), + Hie_GetDBStrFromLevel (Gbl.Hierarchy.Level), Gbl.Hierarchy.Cod, Act_GetActCod (Gbl.Action.Act), (unsigned) Gbl.Usrs.Me.Role.Logged, diff --git a/swad_user_database.h b/swad_user_database.h index b7fb516a..04813246 100644 --- a/swad_user_database.h +++ b/swad_user_database.h @@ -54,10 +54,11 @@ unsigned Usr_DB_GetUsrDataFromUsrCod (MYSQL_RES **mysql_res,long UsrCod, Usr_GetPrefs_t GetPrefs); unsigned Usr_DB_GetSomeUsrDataFromUsrCod (MYSQL_RES **mysql_res,long UsrCod); bool Usr_DB_FindStrInUsrsNames (const char *Str); -void Usr_DB_BuildQueryToGetUsrsLst (HieLvl_Level_t Scope,Rol_Role_t Role,char **Query); +void Usr_DB_BuildQueryToGetUsrsLst (HieLvl_Level_t Level,Rol_Role_t Role, + char **Query); void Usr_DB_BuildQueryToGetUsrsLstCrs (char **Query,Rol_Role_t Role); -void Usr_DB_BuildQueryToGetAdmsLst (HieLvl_Level_t Scope,char **Query); -void Usr_DB_BuildQueryToGetGstsLst (HieLvl_Level_t Scope,char **Query); +void Usr_DB_BuildQueryToGetAdmsLst (HieLvl_Level_t Level,char **Query); +void Usr_DB_BuildQueryToGetGstsLst (HieLvl_Level_t Level,char **Query); void Usr_DB_BuildQueryToSearchListUsrs (Rol_Role_t Role,char **Query); void Usr_DB_BuildQueryToGetUnorderedStdsCodesInDeg (long DegCod,char **Query); unsigned Usr_DB_GetNumUsrsWhoChoseAnOption (const char *SubQuery);