mirror of https://github.com/acanas/swad-core.git
Version19.210.3
This commit is contained in:
parent
a0da2d16bf
commit
b197ba44df
|
@ -98,6 +98,8 @@ static void Ctr_PutHeadCentresForEdition (void);
|
|||
static void Ctr_RecFormRequestOrCreateCtr (unsigned Status);
|
||||
static void Ctr_CreateCentre (unsigned Status);
|
||||
|
||||
static unsigned Ctr_GetNumCtrsInCty (long CtyCod);
|
||||
|
||||
static void Ctr_EditingCentreConstructor (void);
|
||||
static void Ctr_EditingCentreDestructor (void);
|
||||
|
||||
|
@ -1946,7 +1948,7 @@ void Ctr_FlushCacheNumCtrsInCty (void)
|
|||
Gbl.Cache.NumCtrsInCty.NumCtrs = 0;
|
||||
}
|
||||
|
||||
unsigned Ctr_GetNumCtrsInCty (long CtyCod)
|
||||
static unsigned Ctr_GetNumCtrsInCty (long CtyCod)
|
||||
{
|
||||
/***** 1. Fast check: Trivial case *****/
|
||||
if (CtyCod <= 0)
|
||||
|
@ -1964,6 +1966,8 @@ unsigned Ctr_GetNumCtrsInCty (long CtyCod)
|
|||
" WHERE institutions.CtyCod=%ld"
|
||||
" AND institutions.InsCod=centres.InsCod",
|
||||
CtyCod);
|
||||
FigCch_UpdateFigureIntoCache (FigCch_NUM_CTRS,Hie_CTY,Gbl.Cache.NumCtrsInCty.CtyCod,
|
||||
FigCch_UNSIGNED,&Gbl.Cache.NumCtrsInCty.NumCtrs);
|
||||
return Gbl.Cache.NumCtrsInCty.NumCtrs;
|
||||
}
|
||||
|
||||
|
@ -1974,12 +1978,8 @@ unsigned Ctr_GetCachedNumCtrsInCty (long CtyCod)
|
|||
/***** Get number of centres from cache *****/
|
||||
if (!FigCch_GetFigureFromCache (FigCch_NUM_CTRS,Hie_CTY,CtyCod,
|
||||
FigCch_UNSIGNED,&NumCtrs))
|
||||
{
|
||||
/***** Get current number of centres from database and update cache *****/
|
||||
NumCtrs = Ctr_GetNumCtrsInCty (CtyCod);
|
||||
FigCch_UpdateFigureIntoCache (FigCch_NUM_CTRS,Hie_CTY,CtyCod,
|
||||
FigCch_UNSIGNED,&NumCtrs);
|
||||
}
|
||||
|
||||
return NumCtrs;
|
||||
}
|
||||
|
@ -2011,7 +2011,8 @@ unsigned Ctr_GetNumCtrsInIns (long InsCod)
|
|||
"SELECT COUNT(*) FROM centres"
|
||||
" WHERE InsCod=%ld",
|
||||
InsCod);
|
||||
|
||||
FigCch_UpdateFigureIntoCache (FigCch_NUM_CTRS,Hie_INS,Gbl.Cache.NumCtrsInIns.InsCod,
|
||||
FigCch_UNSIGNED,&Gbl.Cache.NumCtrsInIns.NumCtrs);
|
||||
return Gbl.Cache.NumCtrsInIns.NumCtrs;
|
||||
}
|
||||
|
||||
|
@ -2022,12 +2023,8 @@ unsigned Ctr_GetCachedNumCtrsInIns (long InsCod)
|
|||
/***** Get number of centres from cache *****/
|
||||
if (!FigCch_GetFigureFromCache (FigCch_NUM_CTRS,Hie_INS,InsCod,
|
||||
FigCch_UNSIGNED,&NumCtrs))
|
||||
{
|
||||
/***** Get current number of centres from database and update cache *****/
|
||||
NumCtrs = Ctr_GetNumCtrsInIns (InsCod);
|
||||
FigCch_UpdateFigureIntoCache (FigCch_NUM_CTRS,Hie_INS,InsCod,
|
||||
FigCch_UNSIGNED,&NumCtrs);
|
||||
}
|
||||
|
||||
return NumCtrs;
|
||||
}
|
||||
|
@ -2061,31 +2058,55 @@ unsigned Ctr_GetCachedNumCtrsWithMapInSys (void)
|
|||
/************** Get number of centres with map in a country ******************/
|
||||
/*****************************************************************************/
|
||||
|
||||
unsigned Ctr_GetNumCtrsWithMapInCty (long CtyCod)
|
||||
unsigned Ctr_GetCachedNumCtrsWithMapInCty (long CtyCod)
|
||||
{
|
||||
/***** Get number of centres with map from database
|
||||
(coordinates 0, 0 means not set ==> don't show map) *****/
|
||||
return (unsigned) DB_QueryCOUNT ("ccan not get number of centres with map",
|
||||
unsigned NumCtrsWithMap;
|
||||
|
||||
/***** Get number of centres with map from cache *****/
|
||||
if (!FigCch_GetFigureFromCache (FigCch_NUM_CTRS_WITH_MAP,Hie_CTY,CtyCod,
|
||||
FigCch_UNSIGNED,&NumCtrsWithMap))
|
||||
{
|
||||
/***** Get current number of centres with map from database and update cache *****/
|
||||
/* Ccoordinates 0, 0 means not set ==> don't show map */
|
||||
NumCtrsWithMap = (unsigned)
|
||||
DB_QueryCOUNT ("ccan not get number of centres with map",
|
||||
"SELECT COUNT(*) FROM institutions,centres"
|
||||
" WHERE institutions.CtyCod=%ld"
|
||||
" AND institutions.InsCod=centres.InsCod"
|
||||
" AND (centres.Latitude<>0 OR centres.Longitude<>0)",
|
||||
CtyCod);
|
||||
FigCch_UpdateFigureIntoCache (FigCch_NUM_CTRS_WITH_MAP,Hie_CTY,CtyCod,
|
||||
FigCch_UNSIGNED,&NumCtrsWithMap);
|
||||
}
|
||||
|
||||
return NumCtrsWithMap;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/************* Get number of centres with map in an institution **************/
|
||||
/*****************************************************************************/
|
||||
|
||||
unsigned Ctr_GetNumCtrsWithMapInIns (long InsCod)
|
||||
unsigned Ctr_GetCachedNumCtrsWithMapInIns (long InsCod)
|
||||
{
|
||||
/***** Get number of centres with map from database
|
||||
(coordinates 0, 0 means not set ==> don't show map) *****/
|
||||
return (unsigned) DB_QueryCOUNT ("can not get number of centres with map",
|
||||
unsigned NumCtrsWithMap;
|
||||
|
||||
/***** Get number of centres with map from cache *****/
|
||||
if (!FigCch_GetFigureFromCache (FigCch_NUM_CTRS_WITH_MAP,Hie_INS,InsCod,
|
||||
FigCch_UNSIGNED,&NumCtrsWithMap))
|
||||
{
|
||||
/***** Get current number of centres with map from database and update cache *****/
|
||||
/* Ccoordinates 0, 0 means not set ==> don't show map */
|
||||
NumCtrsWithMap = (unsigned)
|
||||
DB_QueryCOUNT ("can not get number of centres with map",
|
||||
"SELECT COUNT(*) FROM centres"
|
||||
" WHERE InsCod=%ld"
|
||||
" AND (Latitude<>0 OR Longitude<>0)",
|
||||
InsCod);
|
||||
FigCch_UpdateFigureIntoCache (FigCch_NUM_CTRS_WITH_MAP,Hie_INS,InsCod,
|
||||
FigCch_UNSIGNED,&NumCtrsWithMap);
|
||||
}
|
||||
|
||||
return NumCtrsWithMap;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
|
|
@ -135,7 +135,6 @@ void Ctr_RecFormNewCtr (void);
|
|||
unsigned Ctr_GetCachedNumCtrsInSys (void);
|
||||
|
||||
void Ctr_FlushCacheNumCtrsInCty (void);
|
||||
unsigned Ctr_GetNumCtrsInCty (long CtyCod);
|
||||
unsigned Ctr_GetCachedNumCtrsInCty (long CtyCod);
|
||||
|
||||
void Ctr_FlushCacheNumCtrsInIns (void);
|
||||
|
@ -143,8 +142,9 @@ unsigned Ctr_GetNumCtrsInIns (long InsCod);
|
|||
unsigned Ctr_GetCachedNumCtrsInIns (long InsCod);
|
||||
|
||||
unsigned Ctr_GetCachedNumCtrsWithMapInSys (void);
|
||||
unsigned Ctr_GetNumCtrsWithMapInCty (long CtyCod);
|
||||
unsigned Ctr_GetNumCtrsWithMapInIns (long InsCod);
|
||||
unsigned Ctr_GetCachedNumCtrsWithMapInCty (long CtyCod);
|
||||
unsigned Ctr_GetCachedNumCtrsWithMapInIns (long InsCod);
|
||||
|
||||
unsigned Ctr_GetNumCtrsInPlc (long PlcCod);
|
||||
|
||||
unsigned Ctr_GetCachedNumCtrsWithDegs (const char *SubQuery,
|
||||
|
|
|
@ -544,10 +544,13 @@ enscript -2 --landscape --color --file-align=2 --highlight --line-numbers -o - *
|
|||
En OpenSWAD:
|
||||
ps2pdf source.ps destination.pdf
|
||||
*/
|
||||
#define Log_PLATFORM_VERSION "SWAD 19.210 (2020-05-03)"
|
||||
#define Log_PLATFORM_VERSION "SWAD 19.210.3 (2020-05-03)"
|
||||
#define CSS_FILE "swad19.193.1.css"
|
||||
#define JS_FILE "swad19.193.1.js"
|
||||
/*
|
||||
Version 19.210.3: May 03, 2020 All figures cacheable are cached everytime they are calculated. (301089 lines)
|
||||
Version 19.210.2: May 03, 2020 More figures cached. (301125 lines)
|
||||
Version 19.210.1: May 03, 2020 More figures cached. (301129 lines)
|
||||
Version 19.210: May 03, 2020 More figures cached. (301124 lines)
|
||||
1 change necessary in database:
|
||||
DELETE FROM figures;
|
||||
|
|
|
@ -148,7 +148,7 @@ static void CtyCfg_Configuration (bool PrintView)
|
|||
/***** Shortcut to the country *****/
|
||||
CtyCfg_Shortcut (PrintView);
|
||||
|
||||
NumCtrsWithMap = Ctr_GetNumCtrsWithMapInCty (Gbl.Hierarchy.Cty.CtyCod);
|
||||
NumCtrsWithMap = Ctr_GetCachedNumCtrsWithMapInCty (Gbl.Hierarchy.Cty.CtyCod);
|
||||
if (PrintView)
|
||||
/***** QR code with link to the country *****/
|
||||
CtyCfg_QR ();
|
||||
|
|
|
@ -457,6 +457,8 @@ unsigned Crs_GetNumCrssInCty (long CtyCod)
|
|||
" AND centres.CtrCod=degrees.CtrCod"
|
||||
" AND degrees.DegCod=courses.DegCod",
|
||||
CtyCod);
|
||||
FigCch_UpdateFigureIntoCache (FigCch_NUM_CRSS,Hie_CTY,Gbl.Cache.NumCrssInCty.CtyCod,
|
||||
FigCch_UNSIGNED,&Gbl.Cache.NumCrssInCty.NumCrss);
|
||||
return Gbl.Cache.NumCrssInCty.NumCrss;
|
||||
}
|
||||
|
||||
|
@ -467,12 +469,8 @@ unsigned Crs_GetCachedNumCrssInCty (long CtyCod)
|
|||
/***** Get number of courses from cache *****/
|
||||
if (!FigCch_GetFigureFromCache (FigCch_NUM_CRSS,Hie_CTY,CtyCod,
|
||||
FigCch_UNSIGNED,&NumCrss))
|
||||
{
|
||||
/***** Get current number of courses from database and update cache *****/
|
||||
NumCrss = Crs_GetNumCrssInCty (CtyCod);
|
||||
FigCch_UpdateFigureIntoCache (FigCch_NUM_CRSS,Hie_CTY,CtyCod,
|
||||
FigCch_UNSIGNED,&NumCrss);
|
||||
}
|
||||
|
||||
return NumCrss;
|
||||
}
|
||||
|
@ -507,6 +505,8 @@ unsigned Crs_GetNumCrssInIns (long InsCod)
|
|||
" AND centres.CtrCod=degrees.CtrCod"
|
||||
" AND degrees.DegCod=courses.DegCod",
|
||||
InsCod);
|
||||
FigCch_UpdateFigureIntoCache (FigCch_NUM_CRSS,Hie_INS,Gbl.Cache.NumCrssInIns.InsCod,
|
||||
FigCch_UNSIGNED,&Gbl.Cache.NumCrssInIns.NumCrss);
|
||||
return Gbl.Cache.NumCrssInIns.NumCrss;
|
||||
}
|
||||
|
||||
|
@ -517,12 +517,8 @@ unsigned Crs_GetCachedNumCrssInIns (long InsCod)
|
|||
/***** Get number of courses from cache *****/
|
||||
if (!FigCch_GetFigureFromCache (FigCch_NUM_CRSS,Hie_INS,InsCod,
|
||||
FigCch_UNSIGNED,&NumCrss))
|
||||
{
|
||||
/***** Get current number of courses from database and update cache *****/
|
||||
NumCrss = Crs_GetNumCrssInIns (InsCod);
|
||||
FigCch_UpdateFigureIntoCache (FigCch_NUM_CRSS,Hie_INS,InsCod,
|
||||
FigCch_UNSIGNED,&NumCrss);
|
||||
}
|
||||
|
||||
return NumCrss;
|
||||
}
|
||||
|
@ -602,6 +598,8 @@ unsigned Crs_GetNumCrssInDeg (long DegCod)
|
|||
"SELECT COUNT(*) FROM courses"
|
||||
" WHERE DegCod=%ld",
|
||||
DegCod);
|
||||
FigCch_UpdateFigureIntoCache (FigCch_NUM_CRSS,Hie_DEG,Gbl.Cache.NumCrssInDeg.DegCod,
|
||||
FigCch_UNSIGNED,&Gbl.Cache.NumCrssInDeg.NumCrss);
|
||||
return Gbl.Cache.NumCrssInDeg.NumCrss;
|
||||
}
|
||||
|
||||
|
@ -612,12 +610,8 @@ unsigned Crs_GetCachedNumCrssInDeg (long DegCod)
|
|||
/***** Get number of courses from cache *****/
|
||||
if (!FigCch_GetFigureFromCache (FigCch_NUM_CRSS,Hie_DEG,DegCod,
|
||||
FigCch_UNSIGNED,&NumCrss))
|
||||
{
|
||||
/***** Get current number of courses from database and update cache *****/
|
||||
NumCrss = Crs_GetNumCrssInDeg (DegCod);
|
||||
FigCch_UpdateFigureIntoCache (FigCch_NUM_CRSS,Hie_DEG,DegCod,
|
||||
FigCch_UNSIGNED,&NumCrss);
|
||||
}
|
||||
|
||||
return NumCrss;
|
||||
}
|
||||
|
|
|
@ -1941,6 +1941,8 @@ unsigned Deg_GetNumDegsInCty (long CtyCod)
|
|||
" AND institutions.InsCod=centres.InsCod"
|
||||
" AND centres.CtrCod=degrees.CtrCod",
|
||||
CtyCod);
|
||||
FigCch_UpdateFigureIntoCache (FigCch_NUM_DEGS,Hie_CTY,Gbl.Cache.NumDegsInCty.CtyCod,
|
||||
FigCch_UNSIGNED,&Gbl.Cache.NumDegsInCty.NumDegs);
|
||||
return Gbl.Cache.NumDegsInCty.NumDegs;
|
||||
}
|
||||
|
||||
|
@ -1951,12 +1953,8 @@ unsigned Deg_GetCachedNumDegsInCty (long CtyCod)
|
|||
/***** Get number of degrees from cache *****/
|
||||
if (!FigCch_GetFigureFromCache (FigCch_NUM_DEGS,Hie_CTY,CtyCod,
|
||||
FigCch_UNSIGNED,&NumDegs))
|
||||
{
|
||||
/***** Get current number of degrees from database and update cache *****/
|
||||
NumDegs = Deg_GetNumDegsInCty (CtyCod);
|
||||
FigCch_UpdateFigureIntoCache (FigCch_NUM_DEGS,Hie_CTY,CtyCod,
|
||||
FigCch_UNSIGNED,&NumDegs);
|
||||
}
|
||||
|
||||
return NumDegs;
|
||||
}
|
||||
|
@ -1990,6 +1988,8 @@ unsigned Deg_GetNumDegsInIns (long InsCod)
|
|||
" WHERE centres.InsCod=%ld"
|
||||
" AND centres.CtrCod=degrees.CtrCod",
|
||||
InsCod);
|
||||
FigCch_UpdateFigureIntoCache (FigCch_NUM_DEGS,Hie_INS,Gbl.Cache.NumDegsInIns.InsCod,
|
||||
FigCch_UNSIGNED,&Gbl.Cache.NumDegsInIns.NumDegs);
|
||||
return Gbl.Cache.NumDegsInIns.NumDegs;
|
||||
}
|
||||
|
||||
|
@ -2000,12 +2000,8 @@ unsigned Deg_GetCachedNumDegsInIns (long InsCod)
|
|||
/***** Get number of degrees from cache *****/
|
||||
if (!FigCch_GetFigureFromCache (FigCch_NUM_DEGS,Hie_INS,InsCod,
|
||||
FigCch_UNSIGNED,&NumDegs))
|
||||
{
|
||||
/***** Get current number of degrees from database and update cache *****/
|
||||
NumDegs = Deg_GetNumDegsInIns (InsCod);
|
||||
FigCch_UpdateFigureIntoCache (FigCch_NUM_DEGS,Hie_INS,InsCod,
|
||||
FigCch_UNSIGNED,&NumDegs);
|
||||
}
|
||||
|
||||
return NumDegs;
|
||||
}
|
||||
|
@ -2037,6 +2033,8 @@ unsigned Deg_GetNumDegsInCtr (long CtrCod)
|
|||
"SELECT COUNT(*) FROM degrees"
|
||||
" WHERE CtrCod=%ld",
|
||||
CtrCod);
|
||||
FigCch_UpdateFigureIntoCache (FigCch_NUM_DEGS,Hie_CTR,Gbl.Cache.NumDegsInCtr.CtrCod,
|
||||
FigCch_UNSIGNED,&Gbl.Cache.NumDegsInCtr.NumDegs);
|
||||
return Gbl.Cache.NumDegsInCtr.NumDegs;
|
||||
}
|
||||
|
||||
|
@ -2047,12 +2045,8 @@ unsigned Deg_GetCachedNumDegsInCtr (long CtrCod)
|
|||
/***** Get number of degrees from cache *****/
|
||||
if (!FigCch_GetFigureFromCache (FigCch_NUM_DEGS,Hie_CTR,CtrCod,
|
||||
FigCch_UNSIGNED,&NumDegs))
|
||||
{
|
||||
/***** Get current number of degrees from database and update cache *****/
|
||||
NumDegs = Deg_GetNumDegsInCtr (CtrCod);
|
||||
FigCch_UpdateFigureIntoCache (FigCch_NUM_DEGS,Hie_CTR,CtrCod,
|
||||
FigCch_UNSIGNED,&NumDegs);
|
||||
}
|
||||
|
||||
return NumDegs;
|
||||
}
|
||||
|
|
|
@ -386,7 +386,6 @@ static void Ins_ListOneInstitutionForSeeing (struct Instit *Ins,unsigned NumIns)
|
|||
const char *TxtClassNormal;
|
||||
const char *TxtClassStrong;
|
||||
const char *BgColor;
|
||||
unsigned NumUsrsIns;
|
||||
Ins_StatusTxt_t StatusTxt;
|
||||
|
||||
if (Ins->Status & Ins_STATUS_BIT_PENDING)
|
||||
|
@ -417,14 +416,7 @@ static void Ins_ListOneInstitutionForSeeing (struct Instit *Ins,unsigned NumIns)
|
|||
|
||||
/***** Number of users who claim to belong to this institution *****/
|
||||
HTM_TD_Begin ("class=\"%s RM %s\"",TxtClassNormal,BgColor);
|
||||
if (!FigCch_GetFigureFromCache (FigCch_NUM_USRS_BELONG_INS,Hie_INS,Ins->InsCod,
|
||||
FigCch_UNSIGNED,&NumUsrsIns))
|
||||
{
|
||||
NumUsrsIns = Usr_GetNumUsrsWhoClaimToBelongToIns (Ins);
|
||||
FigCch_UpdateFigureIntoCache (FigCch_NUM_USRS_BELONG_INS,Hie_INS,Ins->InsCod,
|
||||
FigCch_UNSIGNED,&NumUsrsIns);
|
||||
}
|
||||
HTM_Unsigned (NumUsrsIns);
|
||||
HTM_Unsigned (Usr_GetCachedNumUsrsWhoClaimToBelongToIns (Ins));
|
||||
HTM_TD_End ();
|
||||
|
||||
/***** Other stats *****/
|
||||
|
@ -1088,7 +1080,7 @@ static void Ins_ListInstitutionsForEdition (void)
|
|||
char WWW[Cns_MAX_BYTES_WWW + 1];
|
||||
struct UsrData UsrDat;
|
||||
bool ICanEdit;
|
||||
unsigned NumCtrss;
|
||||
unsigned NumCtrs;
|
||||
unsigned NumUsrsIns;
|
||||
unsigned NumUsrsInCrssOfIns;
|
||||
Ins_StatusTxt_t StatusTxt;
|
||||
|
@ -1109,7 +1101,7 @@ static void Ins_ListInstitutionsForEdition (void)
|
|||
Ins = &Gbl.Hierarchy.Inss.Lst[NumIns];
|
||||
|
||||
ICanEdit = Ins_CheckIfICanEdit (Ins);
|
||||
NumCtrss = Ctr_GetNumCtrsInIns (Ins->InsCod);
|
||||
NumCtrs = Ctr_GetNumCtrsInIns (Ins->InsCod);
|
||||
NumUsrsIns = Usr_GetNumUsrsWhoClaimToBelongToIns (Ins);
|
||||
NumUsrsInCrssOfIns = Usr_GetNumUsrsInCrss (Hie_INS,Ins->InsCod,
|
||||
1 << Rol_STD |
|
||||
|
@ -1121,7 +1113,7 @@ static void Ins_ListInstitutionsForEdition (void)
|
|||
/* Put icon to remove institution */
|
||||
HTM_TD_Begin ("class=\"BM\"");
|
||||
if (!ICanEdit ||
|
||||
NumCtrss || // Institution has centres
|
||||
NumCtrs || // Institution has centres
|
||||
NumUsrsIns || // Institution has users
|
||||
NumUsrsInCrssOfIns) // Institution has users
|
||||
// Institution has centres or users ==> deletion forbidden
|
||||
|
@ -1205,7 +1197,7 @@ static void Ins_ListInstitutionsForEdition (void)
|
|||
|
||||
/* Number of centres */
|
||||
HTM_TD_Begin ("class=\"DAT RM\"");
|
||||
HTM_Unsigned (NumCtrss);
|
||||
HTM_Unsigned (NumCtrs);
|
||||
HTM_TD_End ();
|
||||
|
||||
/* Number of users in courses of this institution */
|
||||
|
@ -1985,6 +1977,8 @@ unsigned Ins_GetNumInssInCty (long CtyCod)
|
|||
" WHERE CtyCod=%ld",
|
||||
CtyCod);
|
||||
Gbl.Cache.NumInssInCty.Valid = true;
|
||||
FigCch_UpdateFigureIntoCache (FigCch_NUM_INSS,Hie_CTY,Gbl.Cache.NumInssInCty.CtyCod,
|
||||
FigCch_UNSIGNED,&Gbl.Cache.NumInssInCty.NumInss);
|
||||
return Gbl.Cache.NumInssInCty.NumInss;
|
||||
}
|
||||
|
||||
|
@ -1995,12 +1989,8 @@ unsigned Ins_GetCachedNumInssInCty (long CtyCod)
|
|||
/***** Get number of institutions from cache *****/
|
||||
if (!FigCch_GetFigureFromCache (FigCch_NUM_INSS,Hie_CTY,CtyCod,
|
||||
FigCch_UNSIGNED,&NumInss))
|
||||
{
|
||||
/***** Get current number of institutions from database and update cache *****/
|
||||
NumInss = Ins_GetNumInssInCty (CtyCod);
|
||||
FigCch_UpdateFigureIntoCache (FigCch_NUM_INSS,Hie_CTY,CtyCod,
|
||||
FigCch_UNSIGNED,&NumInss);
|
||||
}
|
||||
|
||||
return NumInss;
|
||||
}
|
||||
|
|
|
@ -160,7 +160,7 @@ static void InsCfg_Configuration (bool PrintView)
|
|||
/***** Shortcut to the institution *****/
|
||||
InsCfg_Shortcut (PrintView);
|
||||
|
||||
NumCtrsWithMap = Ctr_GetNumCtrsWithMapInIns (Gbl.Hierarchy.Ins.InsCod);
|
||||
NumCtrsWithMap = Ctr_GetCachedNumCtrsWithMapInIns (Gbl.Hierarchy.Ins.InsCod);
|
||||
if (PrintView)
|
||||
/***** QR code with link to the institution *****/
|
||||
InsCfg_QR ();
|
||||
|
@ -462,7 +462,6 @@ static void InsCfg_QR (void)
|
|||
static void InsCfg_NumUsrs (void)
|
||||
{
|
||||
extern const char *Txt_Users_of_the_institution;
|
||||
unsigned NumUsrsIns;
|
||||
|
||||
/***** Number of users *****/
|
||||
HTM_TR_Begin (NULL);
|
||||
|
@ -472,14 +471,7 @@ static void InsCfg_NumUsrs (void)
|
|||
|
||||
/* Data */
|
||||
HTM_TD_Begin ("class=\"DAT LB\"");
|
||||
if (!FigCch_GetFigureFromCache (FigCch_NUM_USRS_BELONG_INS,Hie_INS,Gbl.Hierarchy.Ins.InsCod,
|
||||
FigCch_UNSIGNED,&NumUsrsIns))
|
||||
{
|
||||
NumUsrsIns = Usr_GetNumUsrsWhoClaimToBelongToIns (&Gbl.Hierarchy.Ins);
|
||||
FigCch_UpdateFigureIntoCache (FigCch_NUM_USRS_BELONG_INS,Hie_INS,Gbl.Hierarchy.Ins.InsCod,
|
||||
FigCch_UNSIGNED,&NumUsrsIns);
|
||||
}
|
||||
HTM_Unsigned (NumUsrsIns);
|
||||
HTM_Unsigned (Usr_GetCachedNumUsrsWhoClaimToBelongToIns (&Gbl.Hierarchy.Ins));
|
||||
HTM_TD_End ();
|
||||
|
||||
HTM_TR_End ();
|
||||
|
|
|
@ -131,13 +131,7 @@ static void SysCfg_Configuration (bool PrintView)
|
|||
SysCfg_Shortcut (PrintView);
|
||||
|
||||
/***** Get number of centres with map *****/
|
||||
if (!FigCch_GetFigureFromCache (FigCch_NUM_CTRS_WITH_MAP,Hie_SYS,-1L,
|
||||
FigCch_UNSIGNED,&NumCtrsWithMap))
|
||||
{
|
||||
NumCtrsWithMap = Ctr_GetCachedNumCtrsWithMapInSys ();
|
||||
FigCch_UpdateFigureIntoCache (FigCch_NUM_CTRS_WITH_MAP,Hie_SYS,-1L,
|
||||
FigCch_UNSIGNED,&NumCtrsWithMap);
|
||||
}
|
||||
|
||||
if (PrintView)
|
||||
/***** QR code with link to the country *****/
|
||||
|
|
122
swad_user.c
122
swad_user.c
|
@ -270,6 +270,10 @@ static void Usr_DrawClassPhoto (Usr_ClassPhotoType_t ClassPhotoType,
|
|||
struct SelectedUsrs *SelectedUsrs,
|
||||
bool PutCheckBoxToSelectUsr);
|
||||
|
||||
static FigCch_FigureCached_t Usr_GetFigureNumUsrsInCrss (unsigned Roles);
|
||||
static double Usr_GetNumCrssPerUsr (Hie_Level_t Scope,long Cod,Rol_Role_t Role);
|
||||
static double Usr_GetNumUsrsPerCrs (Hie_Level_t Scope,long Cod,Rol_Role_t Role);
|
||||
|
||||
/*****************************************************************************/
|
||||
/**** Show alert about number of clicks remaining before sending my photo ****/
|
||||
/*****************************************************************************/
|
||||
|
@ -4179,6 +4183,8 @@ unsigned Usr_GetNumUsrsWhoDontClaimToBelongToAnyCty (void)
|
|||
"SELECT COUNT(UsrCod) FROM usr_data"
|
||||
" WHERE CtyCod<0");
|
||||
Gbl.Cache.NumUsrsWhoDontClaimToBelongToAnyCty.Valid = true;
|
||||
FigCch_UpdateFigureIntoCache (FigCch_NUM_USRS_BELONG_CTY,Hie_CTY,-1L,
|
||||
FigCch_UNSIGNED,&Gbl.Cache.NumUsrsWhoDontClaimToBelongToAnyCty.NumUsrs);
|
||||
return Gbl.Cache.NumUsrsWhoDontClaimToBelongToAnyCty.NumUsrs;
|
||||
}
|
||||
|
||||
|
@ -4189,12 +4195,8 @@ unsigned Usr_GetCachedNumUsrsWhoDontClaimToBelongToAnyCty (void)
|
|||
/***** Get number of user who don't claim to belong to any country from cache *****/
|
||||
if (!FigCch_GetFigureFromCache (FigCch_NUM_USRS_BELONG_CTY,Hie_CTY,-1L,
|
||||
FigCch_UNSIGNED,&NumUsrs))
|
||||
{
|
||||
/***** Get current number of user who don't claim to belong to any country from database and update cache *****/
|
||||
NumUsrs = Usr_GetNumUsrsWhoDontClaimToBelongToAnyCty ();
|
||||
FigCch_UpdateFigureIntoCache (FigCch_NUM_USRS_BELONG_CTY,Hie_CTY,-1L,
|
||||
FigCch_UNSIGNED,&NumUsrs);
|
||||
}
|
||||
|
||||
return NumUsrs;
|
||||
}
|
||||
|
@ -4221,6 +4223,8 @@ unsigned Usr_GetNumUsrsWhoClaimToBelongToAnotherCty (void)
|
|||
"SELECT COUNT(UsrCod) FROM usr_data"
|
||||
" WHERE CtyCod=0");
|
||||
Gbl.Cache.NumUsrsWhoClaimToBelongToAnotherCty.Valid = true;
|
||||
FigCch_UpdateFigureIntoCache (FigCch_NUM_USRS_BELONG_CTY,Hie_CTY,0,
|
||||
FigCch_UNSIGNED,&Gbl.Cache.NumUsrsWhoClaimToBelongToAnotherCty.NumUsrs);
|
||||
return Gbl.Cache.NumUsrsWhoClaimToBelongToAnotherCty.NumUsrs;
|
||||
}
|
||||
|
||||
|
@ -4231,12 +4235,8 @@ unsigned Usr_GetCachedNumUsrsWhoClaimToBelongToAnotherCty (void)
|
|||
/***** Get number of users who claim to belong to another country form cache *****/
|
||||
if (!FigCch_GetFigureFromCache (FigCch_NUM_USRS_BELONG_CTY,Hie_CTY,0,
|
||||
FigCch_UNSIGNED,&NumUsrsCty))
|
||||
{
|
||||
/***** Get current number of users who claim to belong to another country from database and update cache *****/
|
||||
NumUsrsCty = Usr_GetNumUsrsWhoClaimToBelongToAnotherCty ();
|
||||
FigCch_UpdateFigureIntoCache (FigCch_NUM_USRS_BELONG_CTY,Hie_CTY,0,
|
||||
FigCch_UNSIGNED,&NumUsrsCty);
|
||||
}
|
||||
|
||||
return NumUsrsCty;
|
||||
}
|
||||
|
@ -4279,6 +4279,8 @@ unsigned Usr_GetNumUsrsWhoClaimToBelongToCty (struct Country *Cty)
|
|||
" WHERE CtyCod=%ld",
|
||||
Cty->CtyCod);
|
||||
Cty->NumUsrsWhoClaimToBelongToCty.Valid = true;
|
||||
FigCch_UpdateFigureIntoCache (FigCch_NUM_USRS_BELONG_CTY,Hie_CTY,Gbl.Cache.NumUsrsWhoClaimToBelongToCty.CtyCod,
|
||||
FigCch_UNSIGNED,&Gbl.Cache.NumUsrsWhoClaimToBelongToCty.NumUsrs);
|
||||
return Cty->NumUsrsWhoClaimToBelongToCty.NumUsrs;
|
||||
}
|
||||
|
||||
|
@ -4289,12 +4291,8 @@ unsigned Usr_GetCachedNumUsrsWhoClaimToBelongToCty (struct Country *Cty)
|
|||
/***** Get number of users who claim to belong to country from cache ******/
|
||||
if (!FigCch_GetFigureFromCache (FigCch_NUM_USRS_BELONG_CTY,Hie_CTY,Cty->CtyCod,
|
||||
FigCch_UNSIGNED,&NumUsrsCty))
|
||||
{
|
||||
/***** Get current number of users who claim to belong to country from database and update cache ******/
|
||||
NumUsrsCty = Usr_GetNumUsrsWhoClaimToBelongToCty (Cty);
|
||||
FigCch_UpdateFigureIntoCache (FigCch_NUM_USRS_BELONG_CTY,Hie_CTY,Cty->CtyCod,
|
||||
FigCch_UNSIGNED,&NumUsrsCty);
|
||||
}
|
||||
|
||||
return NumUsrsCty;
|
||||
}
|
||||
|
@ -4337,9 +4335,24 @@ unsigned Usr_GetNumUsrsWhoClaimToBelongToIns (struct Instit *Ins)
|
|||
" WHERE InsCod=%ld",
|
||||
Ins->InsCod);
|
||||
Ins->NumUsrsWhoClaimToBelongToIns.Valid = true;
|
||||
FigCch_UpdateFigureIntoCache (FigCch_NUM_USRS_BELONG_INS,Hie_INS,Gbl.Cache.NumUsrsWhoClaimToBelongToIns.InsCod,
|
||||
FigCch_UNSIGNED,&Gbl.Cache.NumUsrsWhoClaimToBelongToIns.NumUsrs);
|
||||
return Ins->NumUsrsWhoClaimToBelongToIns.NumUsrs;
|
||||
}
|
||||
|
||||
unsigned Usr_GetCachedNumUsrsWhoClaimToBelongToIns (struct Instit *Ins)
|
||||
{
|
||||
unsigned NumUsrsIns;
|
||||
|
||||
/***** Get number of users who claim to belong to institution from cache *****/
|
||||
if (!FigCch_GetFigureFromCache (FigCch_NUM_USRS_BELONG_INS,Hie_INS,Ins->InsCod,
|
||||
FigCch_UNSIGNED,&NumUsrsIns))
|
||||
/***** Get current number of users who claim to belong to institution from database and update cache *****/
|
||||
NumUsrsIns = Usr_GetNumUsrsWhoClaimToBelongToIns (Ins);
|
||||
|
||||
return NumUsrsIns;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/*********** Get number of users who claim to belong to a centre *************/
|
||||
/*****************************************************************************/
|
||||
|
@ -4377,6 +4390,8 @@ unsigned Usr_GetNumUsrsWhoClaimToBelongToCtr (struct Centre *Ctr)
|
|||
"SELECT COUNT(UsrCod) FROM usr_data"
|
||||
" WHERE CtrCod=%ld",
|
||||
Ctr->CtrCod);
|
||||
FigCch_UpdateFigureIntoCache (FigCch_NUM_USRS_BELONG_CTR,Hie_CTR,Gbl.Cache.NumUsrsWhoClaimToBelongToCtr.CtrCod,
|
||||
FigCch_UNSIGNED,&Gbl.Cache.NumUsrsWhoClaimToBelongToCtr.NumUsrs);
|
||||
return Ctr->NumUsrsWhoClaimToBelongToCtr.NumUsrs;
|
||||
}
|
||||
|
||||
|
@ -4384,34 +4399,15 @@ unsigned Usr_GetCachedNumUsrsWhoClaimToBelongToCtr (struct Centre *Ctr)
|
|||
{
|
||||
unsigned NumUsrsCtr;
|
||||
|
||||
/***** Get number of users who claim to belong to centre from cache *****/
|
||||
if (!FigCch_GetFigureFromCache (FigCch_NUM_USRS_BELONG_CTR,Hie_CTR,Ctr->CtrCod,
|
||||
FigCch_UNSIGNED,&NumUsrsCtr))
|
||||
{
|
||||
/***** Get current number of users who claim to belong to centre from database and update cache *****/
|
||||
NumUsrsCtr = Usr_GetNumUsrsWhoClaimToBelongToCtr (Ctr);
|
||||
FigCch_UpdateFigureIntoCache (FigCch_NUM_USRS_BELONG_CTR,Hie_CTR,Ctr->CtrCod,
|
||||
FigCch_UNSIGNED,&NumUsrsCtr);
|
||||
}
|
||||
|
||||
return NumUsrsCtr;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/******************* Get number of teachers in a centre **********************/
|
||||
/*****************************************************************************/
|
||||
|
||||
unsigned Usr_GetNumberOfTeachersInCentre (long CtrCod)
|
||||
{
|
||||
/***** Get the number of teachers in a centre from database *****/
|
||||
return
|
||||
(unsigned) DB_QueryCOUNT ("can not get the number of teachers in a centre",
|
||||
"SELECT COUNT(DISTINCT usr_data.UsrCod)"
|
||||
" FROM usr_data,crs_usr"
|
||||
" WHERE usr_data.CtrCod=%ld"
|
||||
" AND usr_data.UsrCod=crs_usr.UsrCod"
|
||||
" AND crs_usr.Role=%u",
|
||||
CtrCod,(unsigned) Rol_TCH);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/******* Build query to get list with data of users in current course ********/
|
||||
/*****************************************************************************/
|
||||
|
@ -9469,62 +9465,48 @@ unsigned Usr_GetNumUsrsInCrss (Hie_Level_t Scope,long Cod,unsigned Roles)
|
|||
break;
|
||||
}
|
||||
|
||||
FigCch_UpdateFigureIntoCache (Usr_GetFigureNumUsrsInCrss (Roles),Scope,Cod,
|
||||
FigCch_UNSIGNED,&NumUsrs);
|
||||
return NumUsrs;
|
||||
}
|
||||
|
||||
unsigned Usr_GetCachedNumUsrsInCrss (Hie_Level_t Scope,long Cod,unsigned Roles)
|
||||
{
|
||||
FigCch_FigureCached_t Figure = FigCch_NUM_USRS_IN_CRSS; // Initialized to avoid warning
|
||||
unsigned NumUsrsInCrss;
|
||||
|
||||
/***** Set figure depending on roles *****/
|
||||
/***** Get number of users in courses from cache *****/
|
||||
if (!FigCch_GetFigureFromCache (Usr_GetFigureNumUsrsInCrss (Roles),Scope,Cod,
|
||||
FigCch_UNSIGNED,&NumUsrsInCrss))
|
||||
/***** Get current number of users in courses from database and update cache *****/
|
||||
NumUsrsInCrss = Usr_GetNumUsrsInCrss (Scope,Cod,Roles);
|
||||
|
||||
return NumUsrsInCrss;
|
||||
}
|
||||
|
||||
static FigCch_FigureCached_t Usr_GetFigureNumUsrsInCrss (unsigned Roles)
|
||||
{
|
||||
switch (Roles)
|
||||
{
|
||||
case 1 << Rol_STD: // Students
|
||||
Figure = FigCch_NUM_STDS_IN_CRSS;
|
||||
break;
|
||||
return FigCch_NUM_STDS_IN_CRSS;
|
||||
case 1 << Rol_NET: // Non-editing teachers
|
||||
Figure = FigCch_NUM_NETS_IN_CRSS;
|
||||
break;
|
||||
return FigCch_NUM_NETS_IN_CRSS;
|
||||
case 1 << Rol_TCH: // Teachers
|
||||
Figure = FigCch_NUM_TCHS_IN_CRSS;
|
||||
break;
|
||||
return FigCch_NUM_TCHS_IN_CRSS;
|
||||
case 1 << Rol_STD |
|
||||
1 << Rol_NET |
|
||||
1 << Rol_TCH: // Any users in courses
|
||||
Figure = FigCch_NUM_USRS_IN_CRSS;
|
||||
break;
|
||||
return FigCch_NUM_USRS_IN_CRSS;
|
||||
default:
|
||||
Rol_WrongRoleExit ();
|
||||
return FigCch_UNKNOWN; // Not reached
|
||||
}
|
||||
|
||||
/***** Get number of users in courses from cache *****/
|
||||
if (!FigCch_GetFigureFromCache (Figure,Scope,Cod,
|
||||
FigCch_UNSIGNED,&NumUsrsInCrss))
|
||||
{
|
||||
/***** Get current number of users in courses from database and update cache *****/
|
||||
NumUsrsInCrss = Usr_GetNumUsrsInCrss (Scope,Cod,Roles);
|
||||
FigCch_UpdateFigureIntoCache (Figure,Scope,Cod,
|
||||
FigCch_UNSIGNED,&NumUsrsInCrss);
|
||||
}
|
||||
|
||||
return NumUsrsInCrss;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/******** Get total number of users who do not belong to any course **********/
|
||||
/*****************************************************************************/
|
||||
|
||||
unsigned Usr_GetNumUsrsNotBelongingToAnyCrs (void)
|
||||
{
|
||||
/***** Get number of users who are in table of users but not in table courses-users *****/
|
||||
return
|
||||
(unsigned) DB_QueryCOUNT ("can not get number of users"
|
||||
" who do not belong to any course",
|
||||
"SELECT COUNT(*) FROM usr_data WHERE UsrCod NOT IN"
|
||||
" (SELECT DISTINCT(UsrCod) FROM crs_usr)");
|
||||
}
|
||||
|
||||
unsigned Usr_GetCachedNumUsrsNotBelongingToAnyCrs (void)
|
||||
{
|
||||
unsigned NumGsts;
|
||||
|
@ -9534,7 +9516,11 @@ unsigned Usr_GetCachedNumUsrsNotBelongingToAnyCrs (void)
|
|||
FigCch_UNSIGNED,&NumGsts))
|
||||
{
|
||||
/***** Get current number of guests from database and update cache *****/
|
||||
NumGsts = Usr_GetNumUsrsNotBelongingToAnyCrs ();
|
||||
NumGsts = (unsigned)
|
||||
DB_QueryCOUNT ("can not get number of users"
|
||||
" who do not belong to any course",
|
||||
"SELECT COUNT(*) FROM usr_data WHERE UsrCod NOT IN"
|
||||
" (SELECT DISTINCT(UsrCod) FROM crs_usr)");
|
||||
FigCch_UpdateFigureIntoCache (FigCch_NUM_GSTS,Hie_SYS,-1L,
|
||||
FigCch_UNSIGNED,&NumGsts);
|
||||
}
|
||||
|
@ -9546,7 +9532,7 @@ unsigned Usr_GetCachedNumUsrsNotBelongingToAnyCrs (void)
|
|||
/************ Get average number of courses with users of a role *************/
|
||||
/*****************************************************************************/
|
||||
|
||||
double Usr_GetNumCrssPerUsr (Hie_Level_t Scope,long Cod,Rol_Role_t Role)
|
||||
static double Usr_GetNumCrssPerUsr (Hie_Level_t Scope,long Cod,Rol_Role_t Role)
|
||||
{
|
||||
MYSQL_RES *mysql_res;
|
||||
MYSQL_ROW row;
|
||||
|
@ -9715,7 +9701,7 @@ double Usr_GetCachedNumCrssPerUsr (Hie_Level_t Scope,long Cod,Rol_Role_t Role)
|
|||
/************ Get average number of courses with users of a type *************/
|
||||
/*****************************************************************************/
|
||||
|
||||
double Usr_GetNumUsrsPerCrs (Hie_Level_t Scope,long Cod,Rol_Role_t Role)
|
||||
static double Usr_GetNumUsrsPerCrs (Hie_Level_t Scope,long Cod,Rol_Role_t Role)
|
||||
{
|
||||
MYSQL_RES *mysql_res;
|
||||
MYSQL_ROW row;
|
||||
|
|
|
@ -422,13 +422,12 @@ unsigned Usr_GetCachedNumUsrsWhoClaimToBelongToCty (struct Country *Cty);
|
|||
|
||||
void Usr_FlushCacheNumUsrsWhoClaimToBelongToIns (void);
|
||||
unsigned Usr_GetNumUsrsWhoClaimToBelongToIns (struct Instit *Ins);
|
||||
unsigned Usr_GetCachedNumUsrsWhoClaimToBelongToIns (struct Instit *Ins);
|
||||
|
||||
void Usr_FlushCacheNumUsrsWhoClaimToBelongToCtr (void);
|
||||
unsigned Usr_GetNumUsrsWhoClaimToBelongToCtr (struct Centre *Ctr);
|
||||
unsigned Usr_GetCachedNumUsrsWhoClaimToBelongToCtr (struct Centre *Ctr);
|
||||
|
||||
unsigned Usr_GetNumberOfTeachersInCentre (long CtrCod);
|
||||
|
||||
void Usr_GetListUsrs (Hie_Level_t Scope,Rol_Role_t Role);
|
||||
|
||||
void Usr_SearchListUsrs (Rol_Role_t Role);
|
||||
|
@ -521,13 +520,9 @@ unsigned Usr_GetTotalNumberOfUsersInPlatform (void);
|
|||
unsigned Usr_GetNumUsrsInCrss (Hie_Level_t Scope,long Cod,unsigned Roles);
|
||||
unsigned Usr_GetCachedNumUsrsInCrss (Hie_Level_t Scope,long Cod,unsigned Roles);
|
||||
|
||||
unsigned Usr_GetNumUsrsNotBelongingToAnyCrs (void);
|
||||
unsigned Usr_GetCachedNumUsrsNotBelongingToAnyCrs (void);
|
||||
|
||||
double Usr_GetNumCrssPerUsr (Hie_Level_t Scope,long Cod,Rol_Role_t Role);
|
||||
double Usr_GetCachedNumCrssPerUsr (Hie_Level_t Scope,long Cod,Rol_Role_t Role);
|
||||
|
||||
double Usr_GetNumUsrsPerCrs (Hie_Level_t Scope,long Cod,Rol_Role_t Role);
|
||||
double Usr_GetCachedNumUsrsPerCrs (Hie_Level_t Scope,long Cod,Rol_Role_t Role);
|
||||
|
||||
bool Usr_CheckIfUsrBanned (long UsrCod);
|
||||
|
|
Loading…
Reference in New Issue