mirror of https://github.com/acanas/swad-core.git
Version19.209
This commit is contained in:
parent
378cc4de2f
commit
2bfc915e08
|
@ -604,7 +604,8 @@ CREATE TABLE IF NOT EXISTS figures (
|
|||
Figure INT NOT NULL,
|
||||
Scope ENUM('Sys','Cty','Ins','Ctr','Deg','Crs') NOT NULL DEFAULT 'Sys',
|
||||
Cod INT NOT NULL DEFAULT -1,
|
||||
Value INT NOT NULL,
|
||||
ValueInt INT NOT NULL DEFAULT 0,
|
||||
ValueDouble DOUBLE PRECISION NOT NULL DEFAULT 0.0,
|
||||
LastUpdate TIMESTAMP,
|
||||
UNIQUE INDEX(Figure,Scope,Cod));
|
||||
--
|
||||
|
|
|
@ -544,10 +544,16 @@ enscript -2 --landscape --color --file-align=2 --highlight --line-numbers -o - *
|
|||
En OpenSWAD:
|
||||
ps2pdf source.ps destination.pdf
|
||||
*/
|
||||
#define Log_PLATFORM_VERSION "SWAD 19.208.1 (2020-05-01)"
|
||||
#define Log_PLATFORM_VERSION "SWAD 19.209 (2020-05-01)"
|
||||
#define CSS_FILE "swad19.193.1.css"
|
||||
#define JS_FILE "swad19.193.1.js"
|
||||
/*
|
||||
Version 19.209: May 01, 2020 More figures cached. (300734 lines)
|
||||
3 changes necessary in database:
|
||||
ALTER TABLE figures CHANGE COLUMN Value ValueInt INT NOT NULL DEFAULT 0;
|
||||
ALTER TABLE figures ADD COLUMN ValueDouble DOUBLE PRECISION NOT NULL DEFAULT 0.0 AFTER ValueInt;
|
||||
DELETE FROM figures;
|
||||
|
||||
Version 19.208.1: May 01, 2020 Fixed bug in cache of figures. (300599 lines)
|
||||
Version 19.208: May 01, 2020 New module for cache of figures. (300598 lines)
|
||||
1 change necessary in database:
|
||||
|
|
|
@ -1317,22 +1317,24 @@ mysql> DESCRIBE expanded_folders;
|
|||
/***** Table figures *****/
|
||||
/*
|
||||
mysql> DESCRIBE figures;
|
||||
+------------+-------------------------------------------+------+-----+-------------------+-----------------------------+
|
||||
| Field | Type | Null | Key | Default | Extra |
|
||||
+------------+-------------------------------------------+------+-----+-------------------+-----------------------------+
|
||||
| Figure | int(11) | NO | PRI | NULL | |
|
||||
| Scope | enum('Sys','Cty','Ins','Ctr','Deg','Crs') | NO | PRI | Sys | |
|
||||
| Cod | int(11) | NO | PRI | -1 | |
|
||||
| Value | int(11) | NO | | NULL | |
|
||||
| LastUpdate | timestamp | NO | | CURRENT_TIMESTAMP | on update CURRENT_TIMESTAMP |
|
||||
+------------+-------------------------------------------+------+-----+-------------------+-----------------------------+
|
||||
5 rows in set (0.01 sec)
|
||||
+-------------+-------------------------------------------+------+-----+-------------------+-----------------------------+
|
||||
| Field | Type | Null | Key | Default | Extra |
|
||||
+-------------+-------------------------------------------+------+-----+-------------------+-----------------------------+
|
||||
| Figure | int(11) | NO | PRI | NULL | |
|
||||
| Scope | enum('Sys','Cty','Ins','Ctr','Deg','Crs') | NO | PRI | Sys | |
|
||||
| Cod | int(11) | NO | PRI | -1 | |
|
||||
| ValueInt | int(11) | NO | | 0 | |
|
||||
| ValueDouble | double | NO | | 0 | |
|
||||
| LastUpdate | timestamp | NO | | CURRENT_TIMESTAMP | on update CURRENT_TIMESTAMP |
|
||||
+-------------+-------------------------------------------+------+-----+-------------------+-----------------------------+
|
||||
6 rows in set (0.00 sec)
|
||||
*/
|
||||
DB_CreateTable ("CREATE TABLE IF NOT EXISTS figures ("
|
||||
"Figure INT NOT NULL,"
|
||||
"Scope ENUM('Sys','Cty','Ins','Ctr','Deg','Crs') NOT NULL DEFAULT 'Sys',"
|
||||
"Cod INT NOT NULL DEFAULT -1,"
|
||||
"Value INT NOT NULL,"
|
||||
"ValueInt INT NOT NULL,"
|
||||
"ValueDouble DOUBLE PRECISION NOT NULL,"
|
||||
"LastUpdate TIMESTAMP,"
|
||||
"UNIQUE INDEX(Figure,Scope,Cod))");
|
||||
|
||||
|
|
|
@ -34,6 +34,7 @@
|
|||
#include "swad_box.h"
|
||||
#include "swad_database.h"
|
||||
#include "swad_figure.h"
|
||||
#include "swad_figure_cache.h"
|
||||
#include "swad_file_browser.h"
|
||||
#include "swad_follow.h"
|
||||
#include "swad_form.h"
|
||||
|
@ -424,9 +425,54 @@ static void Fig_GetAndShowNumUsrsInCrss (Rol_Role_t Role)
|
|||
{
|
||||
extern const char *Txt_Total;
|
||||
extern const char *Txt_ROLES_PLURAL_Abc[Rol_NUM_ROLES][Usr_NUM_SEXS];
|
||||
static FigCch_FigureCached_t FigureNumUsrs[Rol_NUM_ROLES] =
|
||||
{
|
||||
[Rol_UNK ] = FigCch_NUM_USRS_IN_CRSS, // Any users in courses
|
||||
[Rol_GST ] = FigCch_UNKNOWN, // Not applicable
|
||||
[Rol_USR ] = FigCch_UNKNOWN, // Not applicable
|
||||
[Rol_STD ] = FigCch_NUM_STDS_IN_CRSS, // Students
|
||||
[Rol_NET ] = FigCch_NUM_NETS_IN_CRSS, // Non-editing teachers
|
||||
[Rol_TCH ] = FigCch_NUM_TCHS_IN_CRSS, // Teachers
|
||||
[Rol_DEG_ADM] = FigCch_UNKNOWN, // Not applicable
|
||||
[Rol_CTR_ADM] = FigCch_UNKNOWN, // Not applicable
|
||||
[Rol_INS_ADM] = FigCch_UNKNOWN, // Not applicable
|
||||
[Rol_SYS_ADM] = FigCch_UNKNOWN, // Not applicable
|
||||
};
|
||||
static FigCch_FigureCached_t FigureNumCrssPerUsr[Rol_NUM_ROLES] =
|
||||
{
|
||||
[Rol_UNK ] = FigCch_NUM_CRSS_PER_USR, // Number of courses per user
|
||||
[Rol_GST ] = FigCch_UNKNOWN, // Not applicable
|
||||
[Rol_USR ] = FigCch_UNKNOWN, // Not applicable
|
||||
[Rol_STD ] = FigCch_NUM_CRSS_PER_STD, // Number of courses per student
|
||||
[Rol_NET ] = FigCch_NUM_CRSS_PER_NET, // Number of courses per non-editing teacher
|
||||
[Rol_TCH ] = FigCch_NUM_CRSS_PER_TCH, // Number of courses per teacher
|
||||
[Rol_DEG_ADM] = FigCch_UNKNOWN, // Not applicable
|
||||
[Rol_CTR_ADM] = FigCch_UNKNOWN, // Not applicable
|
||||
[Rol_INS_ADM] = FigCch_UNKNOWN, // Not applicable
|
||||
[Rol_SYS_ADM] = FigCch_UNKNOWN, // Not applicable
|
||||
};
|
||||
static FigCch_FigureCached_t FigureNumUsrsPerCrs[Rol_NUM_ROLES] =
|
||||
{
|
||||
[Rol_UNK ] = FigCch_NUM_USRS_PER_CRS, // Number of users per course
|
||||
[Rol_GST ] = FigCch_UNKNOWN, // Not applicable
|
||||
[Rol_USR ] = FigCch_UNKNOWN, // Not applicable
|
||||
[Rol_STD ] = FigCch_NUM_STDS_PER_CRS, // Number of students per course
|
||||
[Rol_NET ] = FigCch_NUM_NETS_PER_CRS, // Number of non-editing teachers per course
|
||||
[Rol_TCH ] = FigCch_NUM_TCHS_PER_CRS, // Number of teachers per course
|
||||
[Rol_DEG_ADM] = FigCch_UNKNOWN, // Not applicable
|
||||
[Rol_CTR_ADM] = FigCch_UNKNOWN, // Not applicable
|
||||
[Rol_INS_ADM] = FigCch_UNKNOWN, // Not applicable
|
||||
[Rol_SYS_ADM] = FigCch_UNKNOWN, // Not applicable
|
||||
};
|
||||
unsigned NumUsrs;
|
||||
double NumCrssPerUsr;
|
||||
double NumUsrsPerCrs;
|
||||
long Cod = (Gbl.Scope.Current == Hie_CTY ? Gbl.Hierarchy.Cty.CtyCod :
|
||||
(Gbl.Scope.Current == Hie_INS ? Gbl.Hierarchy.Ins.InsCod :
|
||||
(Gbl.Scope.Current == Hie_CTR ? Gbl.Hierarchy.Ctr.CtrCod :
|
||||
(Gbl.Scope.Current == Hie_DEG ? Gbl.Hierarchy.Deg.DegCod :
|
||||
(Gbl.Scope.Current == Hie_CRS ? Gbl.Hierarchy.Crs.CrsCod :
|
||||
-1L)))));
|
||||
char *Class = (Role == Rol_UNK) ? "DAT_N_LINE_TOP RB" :
|
||||
"DAT RB";
|
||||
unsigned Roles = (Role == Rol_UNK) ? ((1 << Rol_STD) |
|
||||
|
@ -435,20 +481,34 @@ static void Fig_GetAndShowNumUsrsInCrss (Rol_Role_t Role)
|
|||
(1 << Role);
|
||||
|
||||
/***** Get the number of users belonging to any course *****/
|
||||
NumUsrs = Usr_GetNumUsrsInCrss (Gbl.Scope.Current,
|
||||
(Gbl.Scope.Current == Hie_CTY ? Gbl.Hierarchy.Cty.CtyCod :
|
||||
(Gbl.Scope.Current == Hie_INS ? Gbl.Hierarchy.Ins.InsCod :
|
||||
(Gbl.Scope.Current == Hie_CTR ? Gbl.Hierarchy.Ctr.CtrCod :
|
||||
(Gbl.Scope.Current == Hie_DEG ? Gbl.Hierarchy.Deg.DegCod :
|
||||
(Gbl.Scope.Current == Hie_CRS ? Gbl.Hierarchy.Crs.CrsCod :
|
||||
-1L))))),
|
||||
Roles);
|
||||
if (!FigCch_GetFigureFromCache (FigureNumUsrs[Role],Gbl.Scope.Current,Cod,
|
||||
FigCch_Type_UNSIGNED,&NumUsrs))
|
||||
{
|
||||
// Not updated recently in cache ==> compute and update it in cache
|
||||
NumUsrs = Usr_GetNumUsrsInCrss (Gbl.Scope.Current,Cod,Roles);
|
||||
FigCch_UpdateFigureIntoCache (FigureNumUsrs[Role],Gbl.Scope.Current,Cod,
|
||||
FigCch_Type_UNSIGNED,&NumUsrs);
|
||||
}
|
||||
|
||||
/***** Get average number of courses per user *****/
|
||||
NumCrssPerUsr = Usr_GetNumCrssPerUsr (Role);
|
||||
if (!FigCch_GetFigureFromCache (FigureNumCrssPerUsr[Role],Gbl.Scope.Current,Cod,
|
||||
FigCch_Type_DOUBLE,&NumCrssPerUsr))
|
||||
{
|
||||
// Not updated recently in cache ==> compute and update it in cache
|
||||
NumCrssPerUsr = Usr_GetNumCrssPerUsr (Gbl.Scope.Current,Cod,Role);
|
||||
FigCch_UpdateFigureIntoCache (FigureNumCrssPerUsr[Role],Gbl.Scope.Current,Cod,
|
||||
FigCch_Type_DOUBLE,&NumCrssPerUsr);
|
||||
}
|
||||
|
||||
/***** Query the number of users per course *****/
|
||||
NumUsrsPerCrs = Usr_GetNumUsrsPerCrs (Role);
|
||||
if (!FigCch_GetFigureFromCache (FigureNumUsrsPerCrs[Role],Gbl.Scope.Current,Cod,
|
||||
FigCch_Type_DOUBLE,&NumUsrsPerCrs))
|
||||
{
|
||||
// Not updated recently in cache ==> compute and update it in cache
|
||||
NumUsrsPerCrs = Usr_GetNumUsrsPerCrs (Gbl.Scope.Current,Cod,Role);
|
||||
FigCch_UpdateFigureIntoCache (FigureNumUsrsPerCrs[Role],Gbl.Scope.Current,Cod,
|
||||
FigCch_Type_DOUBLE,&NumUsrsPerCrs);
|
||||
}
|
||||
|
||||
/***** Write the total number of users *****/
|
||||
HTM_TR_Begin (NULL);
|
||||
|
|
|
@ -64,19 +64,34 @@
|
|||
|
||||
void FigCch_UpdateFigureIntoCache (FigCch_FigureCached_t Figure,
|
||||
Hie_Level_t Scope,long Cod,
|
||||
unsigned Value)
|
||||
FigCch_Type_t Type,const void *ValuePtr)
|
||||
{
|
||||
/***** Trivial check *****/
|
||||
if (Figure == FigCch_UNKNOWN)
|
||||
return;
|
||||
|
||||
/***** Update figure's value in database *****/
|
||||
DB_QueryREPLACE ("can not update cached figure value",
|
||||
"REPLACE INTO figures"
|
||||
" (Figure,Scope,Cod,Value)"
|
||||
" VALUES"
|
||||
" (%u,'%s',%ld,%u)",
|
||||
(unsigned) Figure,Sco_GetDBStrFromScope (Scope),Cod,Value);
|
||||
switch (Type)
|
||||
{
|
||||
case FigCch_Type_UNSIGNED:
|
||||
DB_QueryREPLACE ("can not update cached figure value",
|
||||
"REPLACE INTO figures"
|
||||
" (Figure,Scope,Cod,ValueInt)"
|
||||
" VALUES"
|
||||
" (%u,'%s',%ld,%u)",
|
||||
(unsigned) Figure,Sco_GetDBStrFromScope (Scope),Cod,
|
||||
*((unsigned *) ValuePtr));
|
||||
break;
|
||||
case FigCch_Type_DOUBLE:
|
||||
DB_QueryREPLACE ("can not update cached figure value",
|
||||
"REPLACE INTO figures"
|
||||
" (Figure,Scope,Cod,ValueDouble)"
|
||||
" VALUES"
|
||||
" (%u,'%s',%ld,%.15lg)",
|
||||
(unsigned) Figure,Sco_GetDBStrFromScope (Scope),Cod,
|
||||
*((double *) ValuePtr));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
@ -86,13 +101,27 @@ void FigCch_UpdateFigureIntoCache (FigCch_FigureCached_t Figure,
|
|||
|
||||
bool FigCch_GetFigureFromCache (FigCch_FigureCached_t Figure,
|
||||
Hie_Level_t Scope,long Cod,
|
||||
unsigned *Value)
|
||||
FigCch_Type_t Type,void *ValuePtr)
|
||||
{
|
||||
static const char *Field[FigCch_NUM_TYPES] =
|
||||
{
|
||||
[FigCch_Type_UNSIGNED] = "ValueInt",
|
||||
[FigCch_Type_DOUBLE ] = "ValueDouble",
|
||||
};
|
||||
MYSQL_RES *mysql_res;
|
||||
MYSQL_ROW row;
|
||||
bool Found = false;
|
||||
|
||||
*Value = 0; // Default value when not found
|
||||
/***** Set default value when not found *****/
|
||||
switch (Type)
|
||||
{
|
||||
case FigCch_Type_UNSIGNED:
|
||||
*((unsigned *) ValuePtr) = 0;
|
||||
break;
|
||||
case FigCch_Type_DOUBLE:
|
||||
*((double *) ValuePtr) = 0.0;
|
||||
break;
|
||||
}
|
||||
|
||||
/***** Trivial check *****/
|
||||
if (Figure == FigCch_UNKNOWN)
|
||||
|
@ -100,10 +129,11 @@ bool FigCch_GetFigureFromCache (FigCch_FigureCached_t Figure,
|
|||
|
||||
/***** Get figure's value if cached and recent *****/
|
||||
if (DB_QuerySELECT (&mysql_res,"can not get cached figure value",
|
||||
"SELECT Value"
|
||||
"SELECT %s"
|
||||
" FROM figures"
|
||||
" WHERE Figure=%u AND Scope='%s' AND Cod=%ld"
|
||||
" AND LastUpdate>FROM_UNIXTIME(UNIX_TIMESTAMP()-%lu)",
|
||||
Field[Type],
|
||||
(unsigned) Figure,Sco_GetDBStrFromScope (Scope),Cod,
|
||||
FigCch_TIME_CACHE))
|
||||
{
|
||||
|
@ -112,8 +142,19 @@ bool FigCch_GetFigureFromCache (FigCch_FigureCached_t Figure,
|
|||
|
||||
/* Get value (row[0]) */
|
||||
if (row[0])
|
||||
if (sscanf (row[0],"%u",Value) == 1)
|
||||
Found = true;
|
||||
{
|
||||
switch (Type)
|
||||
{
|
||||
case FigCch_Type_UNSIGNED:
|
||||
if (sscanf (row[0],"%u",(unsigned *) ValuePtr) == 1)
|
||||
Found = true;
|
||||
break;
|
||||
case FigCch_Type_DOUBLE:
|
||||
if (sscanf (row[0],"%lf",(double *) ValuePtr) == 1)
|
||||
Found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/***** Free structure that stores the query result *****/
|
||||
|
|
|
@ -40,28 +40,45 @@ typedef enum
|
|||
{
|
||||
FigCch_UNKNOWN = 0, // Unknown figure
|
||||
//--------------------------------------------------------------------------
|
||||
FigCch_NUM_STDS_IN_CRSS = 1, // Number of students in courses
|
||||
FigCch_NUM_NETS_IN_CRSS = 2, // Number of non-editing teachers in courses
|
||||
FigCch_NUM_TCHS_IN_CRSS = 3, // Number of teachers in courses
|
||||
FigCch_NUM_USRS_IN_CRSS = 4, // Number of users in courses
|
||||
FigCch_NUM_CTYS = 1, // Number of countries
|
||||
FigCch_NUM_INSS = 2, // Number of institutions
|
||||
FigCch_NUM_CTRS = 3, // Number of centres
|
||||
FigCch_NUM_CTRS_WITH_MAP = 4, // Number of centres with map
|
||||
FigCch_NUM_DEGS = 5, // Number of degrees
|
||||
FigCch_NUM_CRSS = 6, // Number of courses
|
||||
//--------------------------------------------------------------------------
|
||||
FigCch_NUM_CTYS = 5, // Number of countries
|
||||
FigCch_NUM_INSS = 6, // Number of institutions
|
||||
FigCch_NUM_CTRS = 7, // Number of centres
|
||||
FigCch_NUM_CTRS_WITH_MAP = 8, // Number of centres with map
|
||||
FigCch_NUM_DEGS = 9, // Number of degrees
|
||||
FigCch_NUM_CRSS = 10, // Number of courses
|
||||
FigCch_NUM_STDS_IN_CRSS = 7, // Number of students in courses
|
||||
FigCch_NUM_NETS_IN_CRSS = 8, // Number of non-editing teachers in courses
|
||||
FigCch_NUM_TCHS_IN_CRSS = 9, // Number of teachers in courses
|
||||
FigCch_NUM_USRS_IN_CRSS = 10, // Number of users in courses
|
||||
//--------------------------------------------------------------------------
|
||||
FigCch_NUM_CRSS_PER_USR = 11, // Number of courses per user
|
||||
FigCch_NUM_CRSS_PER_STD = 12, // Number of courses per student
|
||||
FigCch_NUM_CRSS_PER_NET = 13, // Number of courses per non-editing teacher
|
||||
FigCch_NUM_CRSS_PER_TCH = 14, // Number of courses per teacher
|
||||
//--------------------------------------------------------------------------
|
||||
FigCch_NUM_USRS_PER_CRS = 15, // Number of users per course
|
||||
FigCch_NUM_STDS_PER_CRS = 16, // Number of students per course
|
||||
FigCch_NUM_NETS_PER_CRS = 17, // Number of non-editing teachers per course
|
||||
FigCch_NUM_TCHS_PER_CRS = 18, // Number of teachers per course
|
||||
} FigCch_FigureCached_t;
|
||||
|
||||
#define FigCch_NUM_TYPES 2
|
||||
typedef enum
|
||||
{
|
||||
FigCch_Type_UNSIGNED,
|
||||
FigCch_Type_DOUBLE,
|
||||
} FigCch_Type_t;
|
||||
|
||||
/*****************************************************************************/
|
||||
/***************************** Public prototypes *****************************/
|
||||
/*****************************************************************************/
|
||||
|
||||
void FigCch_UpdateFigureIntoCache (FigCch_FigureCached_t Figure,
|
||||
Hie_Level_t Scope,long Cod,
|
||||
unsigned Value);
|
||||
FigCch_Type_t Type,const void *ValuePtr);
|
||||
bool FigCch_GetFigureFromCache (FigCch_FigureCached_t Figure,
|
||||
Hie_Level_t Scope,long Cod,
|
||||
unsigned *Value);
|
||||
FigCch_Type_t Type,void *ValuePtr);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -133,12 +133,12 @@ static void SysCfg_Configuration (bool PrintView)
|
|||
|
||||
/***** Get number of centres with map *****/
|
||||
if (!FigCch_GetFigureFromCache (FigCch_NUM_CTRS_WITH_MAP,Hie_SYS,-1L,
|
||||
&NumCtrsWithMap))
|
||||
FigCch_Type_UNSIGNED,&NumCtrsWithMap))
|
||||
{
|
||||
// Not updated recently in cache ==> compute and update it in cache
|
||||
NumCtrsWithMap = Ctr_GetNumCtrsWithMapInSys ();
|
||||
FigCch_UpdateFigureIntoCache (FigCch_NUM_CTRS_WITH_MAP,Hie_SYS,-1L,
|
||||
NumCtrsWithMap);
|
||||
FigCch_Type_UNSIGNED,&NumCtrsWithMap);
|
||||
}
|
||||
|
||||
if (PrintView)
|
||||
|
@ -147,11 +147,13 @@ static void SysCfg_Configuration (bool PrintView)
|
|||
else
|
||||
{
|
||||
/***** Get number of centres *****/
|
||||
if (!FigCch_GetFigureFromCache (FigCch_NUM_CTRS,Hie_SYS,-1L,&NumCtrs))
|
||||
if (!FigCch_GetFigureFromCache (FigCch_NUM_CTRS,Hie_SYS,-1L,
|
||||
FigCch_Type_UNSIGNED,&NumCtrs))
|
||||
{
|
||||
// Not updated recently in cache ==> compute and update it in cache
|
||||
NumCtrs = Ctr_GetNumCtrsInSys ();
|
||||
FigCch_UpdateFigureIntoCache (FigCch_NUM_CTRS,Hie_SYS,-1L,NumCtrs);
|
||||
FigCch_UpdateFigureIntoCache (FigCch_NUM_CTRS,Hie_SYS,-1L,
|
||||
FigCch_Type_UNSIGNED,&NumCtrs);
|
||||
}
|
||||
|
||||
/***** Number of countries,
|
||||
|
@ -364,11 +366,13 @@ static void SysCfg_NumCtys (void)
|
|||
HTM_TD_Begin ("class=\"LB\"");
|
||||
Frm_StartFormGoTo (ActSeeCty);
|
||||
HTM_BUTTON_SUBMIT_Begin (Txt_Countries,"BT_LINK DAT",NULL);
|
||||
if (!FigCch_GetFigureFromCache (FigCch_NUM_CTYS,Hie_SYS,-1L,&NumCtys))
|
||||
if (!FigCch_GetFigureFromCache (FigCch_NUM_CTYS,Hie_SYS,-1L,
|
||||
FigCch_Type_UNSIGNED,&NumCtys))
|
||||
{
|
||||
// Not updated recently in cache ==> compute and update it in cache
|
||||
NumCtys = Cty_GetNumCtysTotal ();
|
||||
FigCch_UpdateFigureIntoCache (FigCch_NUM_CTYS,Hie_SYS,-1L,NumCtys);
|
||||
FigCch_UpdateFigureIntoCache (FigCch_NUM_CTYS,Hie_SYS,-1L,
|
||||
FigCch_Type_UNSIGNED,&NumCtys);
|
||||
}
|
||||
HTM_Unsigned (NumCtys);
|
||||
HTM_BUTTON_End ();
|
||||
|
@ -395,11 +399,13 @@ static void SysCfg_NumInss (void)
|
|||
|
||||
/* Data */
|
||||
HTM_TD_Begin ("class=\"DAT LB\"");
|
||||
if (!FigCch_GetFigureFromCache (FigCch_NUM_INSS,Hie_SYS,-1L,&NumInss))
|
||||
if (!FigCch_GetFigureFromCache (FigCch_NUM_INSS,Hie_SYS,-1L,
|
||||
FigCch_Type_UNSIGNED,&NumInss))
|
||||
{
|
||||
// Not updated recently in cache ==> compute and update it in cache
|
||||
NumInss = Ins_GetNumInssTotal ();
|
||||
FigCch_UpdateFigureIntoCache (FigCch_NUM_INSS,Hie_SYS,-1L,NumInss);
|
||||
FigCch_UpdateFigureIntoCache (FigCch_NUM_INSS,Hie_SYS,-1L,
|
||||
FigCch_Type_UNSIGNED,&NumInss);
|
||||
}
|
||||
HTM_Unsigned (NumInss);
|
||||
HTM_TD_End ();
|
||||
|
@ -424,11 +430,13 @@ static void SysCfg_NumDegs (void)
|
|||
|
||||
/* Data */
|
||||
HTM_TD_Begin ("class=\"DAT LB\"");
|
||||
if (!FigCch_GetFigureFromCache (FigCch_NUM_DEGS,Hie_SYS,-1L,&NumDegs))
|
||||
if (!FigCch_GetFigureFromCache (FigCch_NUM_DEGS,Hie_SYS,-1L,
|
||||
FigCch_Type_UNSIGNED,&NumDegs))
|
||||
{
|
||||
// Not updated recently in cache ==> compute and update it in cache
|
||||
NumDegs = Deg_GetNumDegsTotal ();
|
||||
FigCch_UpdateFigureIntoCache (FigCch_NUM_DEGS,Hie_SYS,-1L,NumDegs);
|
||||
FigCch_UpdateFigureIntoCache (FigCch_NUM_DEGS,Hie_SYS,-1L,
|
||||
FigCch_Type_UNSIGNED,&NumDegs);
|
||||
}
|
||||
HTM_Unsigned (NumDegs);
|
||||
HTM_TD_End ();
|
||||
|
@ -453,11 +461,13 @@ static void SysCfg_NumCrss (void)
|
|||
|
||||
/* Data */
|
||||
HTM_TD_Begin ("class=\"DAT LB\"");
|
||||
if (!FigCch_GetFigureFromCache (FigCch_NUM_CRSS,Hie_SYS,-1L,&NumCrss))
|
||||
if (!FigCch_GetFigureFromCache (FigCch_NUM_CRSS,Hie_SYS,-1L,
|
||||
FigCch_Type_UNSIGNED,&NumCrss))
|
||||
{
|
||||
// Not updated recently in cache ==> compute and update it in cache
|
||||
NumCrss = Crs_GetNumCrssTotal ();
|
||||
FigCch_UpdateFigureIntoCache (FigCch_NUM_CRSS,Hie_SYS,-1L,NumCrss);
|
||||
FigCch_UpdateFigureIntoCache (FigCch_NUM_CRSS,Hie_SYS,-1L,
|
||||
FigCch_Type_UNSIGNED,&NumCrss);
|
||||
}
|
||||
HTM_Unsigned (NumCrss);
|
||||
HTM_TD_End ();
|
||||
|
@ -499,7 +509,7 @@ static void SysCfg_NumUsrsInCrss (Rol_Role_t Role)
|
|||
/* Data */
|
||||
HTM_TD_Begin ("class=\"DAT LB\"");
|
||||
if (!FigCch_GetFigureFromCache (Figure[Role],Hie_SYS,-1L,
|
||||
&NumUsrsInCrss))
|
||||
FigCch_Type_UNSIGNED,&NumUsrsInCrss))
|
||||
{
|
||||
// Not updated recently in cache ==> compute and update it in cache
|
||||
NumUsrsInCrss = Usr_GetNumUsrsInCrss (Hie_SYS,-1L,
|
||||
|
@ -508,7 +518,7 @@ static void SysCfg_NumUsrsInCrss (Rol_Role_t Role)
|
|||
(1 << Rol_TCH) : // Any user
|
||||
(1 << Role));
|
||||
FigCch_UpdateFigureIntoCache (Figure[Role],Hie_SYS,-1L,
|
||||
NumUsrsInCrss);
|
||||
FigCch_Type_UNSIGNED,&NumUsrsInCrss);
|
||||
}
|
||||
HTM_Unsigned (NumUsrsInCrss);
|
||||
HTM_TD_End ();
|
||||
|
|
42
swad_user.c
42
swad_user.c
|
@ -9434,14 +9434,14 @@ unsigned Usr_GetNumUsrsNotBelongingToAnyCrs (void)
|
|||
/************ Get average number of courses with users of a role *************/
|
||||
/*****************************************************************************/
|
||||
|
||||
double Usr_GetNumCrssPerUsr (Rol_Role_t Role)
|
||||
double Usr_GetNumCrssPerUsr (Hie_Level_t Scope,long Cod,Rol_Role_t Role)
|
||||
{
|
||||
MYSQL_RES *mysql_res;
|
||||
MYSQL_ROW row;
|
||||
double NumCrssPerUsr;
|
||||
|
||||
/***** Get number of courses per user from database *****/
|
||||
switch (Gbl.Scope.Current)
|
||||
switch (Scope)
|
||||
{
|
||||
case Hie_SYS:
|
||||
if (Role == Rol_UNK) // Any user
|
||||
|
@ -9470,7 +9470,7 @@ double Usr_GetNumCrssPerUsr (Rol_Role_t Role)
|
|||
" AND degrees.DegCod=courses.DegCod"
|
||||
" AND courses.CrsCod=crs_usr.CrsCod"
|
||||
" GROUP BY crs_usr.UsrCod) AS NumCrssTable",
|
||||
Gbl.Hierarchy.Cty.CtyCod);
|
||||
Cod);
|
||||
else
|
||||
DB_QuerySELECT (&mysql_res,"can not get number of courses per user",
|
||||
"SELECT AVG(NumCrss) FROM "
|
||||
|
@ -9483,7 +9483,7 @@ double Usr_GetNumCrssPerUsr (Rol_Role_t Role)
|
|||
" AND courses.CrsCod=crs_usr.CrsCod"
|
||||
" AND crs_usr.Role=%u"
|
||||
" GROUP BY crs_usr.UsrCod) AS NumCrssTable",
|
||||
Gbl.Hierarchy.Cty.CtyCod,
|
||||
Cod,
|
||||
(unsigned) Role);
|
||||
break;
|
||||
case Hie_INS:
|
||||
|
@ -9497,7 +9497,7 @@ double Usr_GetNumCrssPerUsr (Rol_Role_t Role)
|
|||
" AND degrees.DegCod=courses.DegCod"
|
||||
" AND courses.CrsCod=crs_usr.CrsCod"
|
||||
" GROUP BY crs_usr.UsrCod) AS NumCrssTable",
|
||||
Gbl.Hierarchy.Ins.InsCod);
|
||||
Cod);
|
||||
else
|
||||
DB_QuerySELECT (&mysql_res,"can not get number of courses per user",
|
||||
"SELECT AVG(NumCrss) FROM "
|
||||
|
@ -9509,7 +9509,7 @@ double Usr_GetNumCrssPerUsr (Rol_Role_t Role)
|
|||
" AND courses.CrsCod=crs_usr.CrsCod"
|
||||
" AND crs_usr.Role=%u"
|
||||
" GROUP BY crs_usr.UsrCod) AS NumCrssTable",
|
||||
Gbl.Hierarchy.Ins.InsCod,
|
||||
Cod,
|
||||
(unsigned) Role);
|
||||
break;
|
||||
case Hie_CTR:
|
||||
|
@ -9522,7 +9522,7 @@ double Usr_GetNumCrssPerUsr (Rol_Role_t Role)
|
|||
" AND degrees.DegCod=courses.DegCod"
|
||||
" AND courses.CrsCod=crs_usr.CrsCod"
|
||||
" GROUP BY crs_usr.UsrCod) AS NumCrssTable",
|
||||
Gbl.Hierarchy.Ctr.CtrCod);
|
||||
Cod);
|
||||
else
|
||||
DB_QuerySELECT (&mysql_res,"can not get number of courses per user",
|
||||
"SELECT AVG(NumCrss) FROM "
|
||||
|
@ -9533,7 +9533,7 @@ double Usr_GetNumCrssPerUsr (Rol_Role_t Role)
|
|||
" AND courses.CrsCod=crs_usr.CrsCod"
|
||||
" AND crs_usr.Role=%u"
|
||||
" GROUP BY crs_usr.UsrCod) AS NumCrssTable",
|
||||
Gbl.Hierarchy.Ctr.CtrCod,
|
||||
Cod,
|
||||
(unsigned) Role);
|
||||
break;
|
||||
case Hie_DEG:
|
||||
|
@ -9545,7 +9545,7 @@ double Usr_GetNumCrssPerUsr (Rol_Role_t Role)
|
|||
" WHERE courses.DegCod=%ld"
|
||||
" AND courses.CrsCod=crs_usr.CrsCod"
|
||||
" GROUP BY crs_usr.UsrCod) AS NumCrssTable",
|
||||
Gbl.Hierarchy.Deg.DegCod);
|
||||
Cod);
|
||||
else
|
||||
DB_QuerySELECT (&mysql_res,"can not get number of courses per user",
|
||||
"SELECT AVG(NumCrss) FROM "
|
||||
|
@ -9555,7 +9555,7 @@ double Usr_GetNumCrssPerUsr (Rol_Role_t Role)
|
|||
" AND courses.CrsCod=crs_usr.CrsCod"
|
||||
" AND crs_usr.Role=%u"
|
||||
" GROUP BY crs_usr.UsrCod) AS NumCrssTable",
|
||||
Gbl.Hierarchy.Deg.DegCod,
|
||||
Cod,
|
||||
(unsigned) Role);
|
||||
break;
|
||||
case Hie_CRS:
|
||||
|
@ -9579,14 +9579,14 @@ double Usr_GetNumCrssPerUsr (Rol_Role_t Role)
|
|||
/************ Get average number of courses with users of a type *************/
|
||||
/*****************************************************************************/
|
||||
|
||||
double Usr_GetNumUsrsPerCrs (Rol_Role_t Role)
|
||||
double Usr_GetNumUsrsPerCrs (Hie_Level_t Scope,long Cod,Rol_Role_t Role)
|
||||
{
|
||||
MYSQL_RES *mysql_res;
|
||||
MYSQL_ROW row;
|
||||
double NumUsrsPerCrs;
|
||||
|
||||
/***** Get number of users per course from database *****/
|
||||
switch (Gbl.Scope.Current)
|
||||
switch (Scope)
|
||||
{
|
||||
case Hie_SYS:
|
||||
if (Role == Rol_UNK) // Any user
|
||||
|
@ -9615,7 +9615,7 @@ double Usr_GetNumUsrsPerCrs (Rol_Role_t Role)
|
|||
" AND degrees.DegCod=courses.DegCod"
|
||||
" AND courses.CrsCod=crs_usr.CrsCod"
|
||||
" GROUP BY crs_usr.CrsCod) AS NumUsrsTable",
|
||||
Gbl.Hierarchy.Cty.CtyCod);
|
||||
Cod);
|
||||
else
|
||||
DB_QuerySELECT (&mysql_res,"can not get number of users per course",
|
||||
"SELECT AVG(NumUsrs) FROM "
|
||||
|
@ -9628,7 +9628,7 @@ double Usr_GetNumUsrsPerCrs (Rol_Role_t Role)
|
|||
" AND courses.CrsCod=crs_usr.CrsCod"
|
||||
" AND crs_usr.Role=%u"
|
||||
" GROUP BY crs_usr.CrsCod) AS NumUsrsTable",
|
||||
Gbl.Hierarchy.Cty.CtyCod,
|
||||
Cod,
|
||||
(unsigned) Role);
|
||||
break;
|
||||
case Hie_INS:
|
||||
|
@ -9642,7 +9642,7 @@ double Usr_GetNumUsrsPerCrs (Rol_Role_t Role)
|
|||
" AND degrees.DegCod=courses.DegCod"
|
||||
" AND courses.CrsCod=crs_usr.CrsCod"
|
||||
" GROUP BY crs_usr.CrsCod) AS NumUsrsTable",
|
||||
Gbl.Hierarchy.Ins.InsCod);
|
||||
Cod);
|
||||
else
|
||||
DB_QuerySELECT (&mysql_res,"can not get number of users per course",
|
||||
"SELECT AVG(NumUsrs) FROM "
|
||||
|
@ -9654,7 +9654,7 @@ double Usr_GetNumUsrsPerCrs (Rol_Role_t Role)
|
|||
" AND courses.CrsCod=crs_usr.CrsCod"
|
||||
" AND crs_usr.Role=%u"
|
||||
" GROUP BY crs_usr.CrsCod) AS NumUsrsTable",
|
||||
Gbl.Hierarchy.Ins.InsCod,
|
||||
Cod,
|
||||
(unsigned) Role);
|
||||
break;
|
||||
case Hie_CTR:
|
||||
|
@ -9667,7 +9667,7 @@ double Usr_GetNumUsrsPerCrs (Rol_Role_t Role)
|
|||
" AND degrees.DegCod=courses.DegCod"
|
||||
" AND courses.CrsCod=crs_usr.CrsCod"
|
||||
" GROUP BY crs_usr.CrsCod) AS NumUsrsTable",
|
||||
Gbl.Hierarchy.Ctr.CtrCod);
|
||||
Cod);
|
||||
else
|
||||
DB_QuerySELECT (&mysql_res,"can not get number of users per course",
|
||||
"SELECT AVG(NumUsrs) FROM "
|
||||
|
@ -9678,7 +9678,7 @@ double Usr_GetNumUsrsPerCrs (Rol_Role_t Role)
|
|||
" AND courses.CrsCod=crs_usr.CrsCod"
|
||||
" AND crs_usr.Role=%u"
|
||||
" GROUP BY crs_usr.CrsCod) AS NumUsrsTable",
|
||||
Gbl.Hierarchy.Ctr.CtrCod,
|
||||
Cod,
|
||||
(unsigned) Role);
|
||||
break;
|
||||
case Hie_DEG:
|
||||
|
@ -9690,7 +9690,7 @@ double Usr_GetNumUsrsPerCrs (Rol_Role_t Role)
|
|||
" WHERE courses.DegCod=%ld"
|
||||
" AND courses.CrsCod=crs_usr.CrsCod"
|
||||
" GROUP BY crs_usr.CrsCod) AS NumUsrsTable",
|
||||
Gbl.Hierarchy.Deg.DegCod);
|
||||
Cod);
|
||||
else
|
||||
DB_QuerySELECT (&mysql_res,"can not get number of users per course",
|
||||
"SELECT AVG(NumUsrs) FROM "
|
||||
|
@ -9700,11 +9700,11 @@ double Usr_GetNumUsrsPerCrs (Rol_Role_t Role)
|
|||
" AND courses.CrsCod=crs_usr.CrsCod"
|
||||
" AND crs_usr.Role=%u"
|
||||
" GROUP BY crs_usr.CrsCod) AS NumUsrsTable",
|
||||
Gbl.Hierarchy.Deg.DegCod,
|
||||
Cod,
|
||||
(unsigned) Role);
|
||||
break;
|
||||
case Hie_CRS:
|
||||
return (double) Usr_GetNumUsrsInCrss (Hie_CRS,Gbl.Hierarchy.Crs.CrsCod,
|
||||
return (double) Usr_GetNumUsrsInCrss (Hie_CRS,Cod,
|
||||
Role == Rol_UNK ? 1 << Rol_STD |
|
||||
1 << Rol_NET |
|
||||
1 << Rol_TCH : // Any user
|
||||
|
|
|
@ -510,8 +510,8 @@ void Usr_ShowWarningNoUsersFound (Rol_Role_t Role);
|
|||
unsigned Usr_GetTotalNumberOfUsersInPlatform (void);
|
||||
unsigned Usr_GetNumUsrsInCrss (Hie_Level_t Scope,long Cod,unsigned Roles);
|
||||
unsigned Usr_GetNumUsrsNotBelongingToAnyCrs (void);
|
||||
double Usr_GetNumCrssPerUsr (Rol_Role_t Role);
|
||||
double Usr_GetNumUsrsPerCrs (Rol_Role_t Role);
|
||||
double Usr_GetNumCrssPerUsr (Hie_Level_t Scope,long Cod,Rol_Role_t Role);
|
||||
double Usr_GetNumUsrsPerCrs (Hie_Level_t Scope,long Cod,Rol_Role_t Role);
|
||||
|
||||
bool Usr_CheckIfUsrBanned (long UsrCod);
|
||||
void Usr_RemoveUsrFromUsrBanned (long UsrCod);
|
||||
|
|
Loading…
Reference in New Issue