mirror of https://github.com/acanas/swad-core.git
Version 20.97: Sep 10, 2021 Code refactoring related to scope.
This commit is contained in:
parent
1f178d96cb
commit
f7d2334077
|
@ -1833,18 +1833,18 @@ unsigned Ctr_GetCachedNumCtrsWithMapInIns (long InsCod)
|
||||||
/********************* Get number of centers with degrees ********************/
|
/********************* Get number of centers with degrees ********************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
unsigned Ctr_GetCachedNumCtrsWithDegs (const char *SubQuery,
|
unsigned Ctr_GetCachedNumCtrsWithDegs (void)
|
||||||
HieLvl_Level_t Scope,long Cod)
|
|
||||||
{
|
{
|
||||||
unsigned NumCtrsWithDegs;
|
unsigned NumCtrsWithDegs;
|
||||||
|
long Cod = Sco_GetCurrentCod ();
|
||||||
|
|
||||||
/***** Get number of centers with degrees from cache *****/
|
/***** Get number of centers with degrees from cache *****/
|
||||||
if (!FigCch_GetFigureFromCache (FigCch_NUM_CTRS_WITH_DEGS,Scope,Cod,
|
if (!FigCch_GetFigureFromCache (FigCch_NUM_CTRS_WITH_DEGS,Gbl.Scope.Current,Cod,
|
||||||
FigCch_UNSIGNED,&NumCtrsWithDegs))
|
FigCch_UNSIGNED,&NumCtrsWithDegs))
|
||||||
{
|
{
|
||||||
/***** Get current number of centers with degrees from database and update cache *****/
|
/***** Get current number of centers with degrees from database and update cache *****/
|
||||||
NumCtrsWithDegs = Ctr_DB_GetNumCtrsWithDegs (SubQuery);
|
NumCtrsWithDegs = Ctr_DB_GetNumCtrsWithDegs (Gbl.Scope.Current,Cod);
|
||||||
FigCch_UpdateFigureIntoCache (FigCch_NUM_CTRS_WITH_DEGS,Scope,Cod,
|
FigCch_UpdateFigureIntoCache (FigCch_NUM_CTRS_WITH_DEGS,Gbl.Scope.Current,Cod,
|
||||||
FigCch_UNSIGNED,&NumCtrsWithDegs);
|
FigCch_UNSIGNED,&NumCtrsWithDegs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1855,18 +1855,18 @@ unsigned Ctr_GetCachedNumCtrsWithDegs (const char *SubQuery,
|
||||||
/********************* Get number of centers with courses ********************/
|
/********************* Get number of centers with courses ********************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
unsigned Ctr_GetCachedNumCtrsWithCrss (const char *SubQuery,
|
unsigned Ctr_GetCachedNumCtrsWithCrss (void)
|
||||||
HieLvl_Level_t Scope,long Cod)
|
|
||||||
{
|
{
|
||||||
unsigned NumCtrsWithCrss;
|
unsigned NumCtrsWithCrss;
|
||||||
|
long Cod = Sco_GetCurrentCod ();
|
||||||
|
|
||||||
/***** Get number of centers with courses *****/
|
/***** Get number of centers with courses *****/
|
||||||
if (!FigCch_GetFigureFromCache (FigCch_NUM_CTRS_WITH_CRSS,Scope,Cod,
|
if (!FigCch_GetFigureFromCache (FigCch_NUM_CTRS_WITH_CRSS,Gbl.Scope.Current,Cod,
|
||||||
FigCch_UNSIGNED,&NumCtrsWithCrss))
|
FigCch_UNSIGNED,&NumCtrsWithCrss))
|
||||||
{
|
{
|
||||||
/***** Get number of centers with courses *****/
|
/***** Get number of centers with courses *****/
|
||||||
NumCtrsWithCrss = Ctr_DB_GetNumCtrsWithCrss (SubQuery);
|
NumCtrsWithCrss = Ctr_DB_GetNumCtrsWithCrss (Gbl.Scope.Current,Cod);
|
||||||
FigCch_UpdateFigureIntoCache (FigCch_NUM_CTRS_WITH_CRSS,Scope,Cod,
|
FigCch_UpdateFigureIntoCache (FigCch_NUM_CTRS_WITH_CRSS,Gbl.Scope.Current,Cod,
|
||||||
FigCch_UNSIGNED,&NumCtrsWithCrss);
|
FigCch_UNSIGNED,&NumCtrsWithCrss);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1877,8 +1877,7 @@ unsigned Ctr_GetCachedNumCtrsWithCrss (const char *SubQuery,
|
||||||
/********************* Get number of centers with users **********************/
|
/********************* Get number of centers with users **********************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
unsigned Ctr_GetCachedNumCtrsWithUsrs (Rol_Role_t Role,const char *SubQuery,
|
unsigned Ctr_GetCachedNumCtrsWithUsrs (Rol_Role_t Role)
|
||||||
HieLvl_Level_t Scope,long Cod)
|
|
||||||
{
|
{
|
||||||
static const FigCch_FigureCached_t FigureCtrs[Rol_NUM_ROLES] =
|
static const FigCch_FigureCached_t FigureCtrs[Rol_NUM_ROLES] =
|
||||||
{
|
{
|
||||||
|
@ -1887,14 +1886,15 @@ unsigned Ctr_GetCachedNumCtrsWithUsrs (Rol_Role_t Role,const char *SubQuery,
|
||||||
[Rol_TCH] = FigCch_NUM_CTRS_WITH_TCHS, // Teachers
|
[Rol_TCH] = FigCch_NUM_CTRS_WITH_TCHS, // Teachers
|
||||||
};
|
};
|
||||||
unsigned NumCtrsWithUsrs;
|
unsigned NumCtrsWithUsrs;
|
||||||
|
long Cod = Sco_GetCurrentCod ();
|
||||||
|
|
||||||
/***** Get number of centers with users from cache *****/
|
/***** Get number of centers with users from cache *****/
|
||||||
if (!FigCch_GetFigureFromCache (FigureCtrs[Role],Scope,Cod,
|
if (!FigCch_GetFigureFromCache (FigureCtrs[Role],Gbl.Scope.Current,Cod,
|
||||||
FigCch_UNSIGNED,&NumCtrsWithUsrs))
|
FigCch_UNSIGNED,&NumCtrsWithUsrs))
|
||||||
{
|
{
|
||||||
/***** Get current number of centers with users from database and update cache *****/
|
/***** Get current number of centers with users from database and update cache *****/
|
||||||
NumCtrsWithUsrs = Ctr_DB_GetNumCtrsWithUsrs (Role,SubQuery);
|
NumCtrsWithUsrs = Ctr_DB_GetNumCtrsWithUsrs (Role,Gbl.Scope.Current,Cod);
|
||||||
FigCch_UpdateFigureIntoCache (FigureCtrs[Role],Scope,Cod,
|
FigCch_UpdateFigureIntoCache (FigureCtrs[Role],Gbl.Scope.Current,Cod,
|
||||||
FigCch_UNSIGNED,&NumCtrsWithUsrs);
|
FigCch_UNSIGNED,&NumCtrsWithUsrs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -139,12 +139,9 @@ unsigned Ctr_GetCachedNumCtrsWithMapInSys (void);
|
||||||
unsigned Ctr_GetCachedNumCtrsWithMapInCty (long CtyCod);
|
unsigned Ctr_GetCachedNumCtrsWithMapInCty (long CtyCod);
|
||||||
unsigned Ctr_GetCachedNumCtrsWithMapInIns (long InsCod);
|
unsigned Ctr_GetCachedNumCtrsWithMapInIns (long InsCod);
|
||||||
|
|
||||||
unsigned Ctr_GetCachedNumCtrsWithDegs (const char *SubQuery,
|
unsigned Ctr_GetCachedNumCtrsWithDegs (void);
|
||||||
HieLvl_Level_t Scope,long Cod);
|
unsigned Ctr_GetCachedNumCtrsWithCrss (void);
|
||||||
unsigned Ctr_GetCachedNumCtrsWithCrss (const char *SubQuery,
|
unsigned Ctr_GetCachedNumCtrsWithUsrs (Rol_Role_t Role);
|
||||||
HieLvl_Level_t Scope,long Cod);
|
|
||||||
unsigned Ctr_GetCachedNumCtrsWithUsrs (Rol_Role_t Role,const char *SubQuery,
|
|
||||||
HieLvl_Level_t Scope,long Cod);
|
|
||||||
|
|
||||||
void Ctr_ListCtrsFound (MYSQL_RES **mysql_res,unsigned NumCtrs);
|
void Ctr_ListCtrsFound (MYSQL_RES **mysql_res,unsigned NumCtrs);
|
||||||
|
|
||||||
|
|
|
@ -30,6 +30,7 @@
|
||||||
#include "swad_database.h"
|
#include "swad_database.h"
|
||||||
#include "swad_error.h"
|
#include "swad_error.h"
|
||||||
#include "swad_global.h"
|
#include "swad_global.h"
|
||||||
|
#include "swad_hierarchy.h"
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/************** External global variables from others modules ****************/
|
/************** External global variables from others modules ****************/
|
||||||
|
@ -413,8 +414,12 @@ unsigned Ctr_DB_GetNumCtrsWithMapInIns (long InsCod)
|
||||||
/********************* Get number of centers with degrees ********************/
|
/********************* Get number of centers with degrees ********************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
unsigned Ctr_DB_GetNumCtrsWithDegs (const char *SubQuery)
|
unsigned Ctr_DB_GetNumCtrsWithDegs (HieLvl_Level_t Scope,long Cod)
|
||||||
{
|
{
|
||||||
|
char SubQuery[128];
|
||||||
|
|
||||||
|
Hie_DB_BuildSubquery (SubQuery,Scope,Cod);
|
||||||
|
|
||||||
return (unsigned)
|
return (unsigned)
|
||||||
DB_QueryCOUNT ("can not get number of centers with degrees",
|
DB_QueryCOUNT ("can not get number of centers with degrees",
|
||||||
"SELECT COUNT(DISTINCT ctr_centers.CtrCod)"
|
"SELECT COUNT(DISTINCT ctr_centers.CtrCod)"
|
||||||
|
@ -430,8 +435,12 @@ unsigned Ctr_DB_GetNumCtrsWithDegs (const char *SubQuery)
|
||||||
/********************* Get number of centers with courses ********************/
|
/********************* Get number of centers with courses ********************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
unsigned Ctr_DB_GetNumCtrsWithCrss (const char *SubQuery)
|
unsigned Ctr_DB_GetNumCtrsWithCrss (HieLvl_Level_t Scope,long Cod)
|
||||||
{
|
{
|
||||||
|
char SubQuery[128];
|
||||||
|
|
||||||
|
Hie_DB_BuildSubquery (SubQuery,Scope,Cod);
|
||||||
|
|
||||||
return (unsigned)
|
return (unsigned)
|
||||||
DB_QueryCOUNT ("can not get number of centers with courses",
|
DB_QueryCOUNT ("can not get number of centers with courses",
|
||||||
"SELECT COUNT(DISTINCT ctr_centers.CtrCod)"
|
"SELECT COUNT(DISTINCT ctr_centers.CtrCod)"
|
||||||
|
@ -449,8 +458,13 @@ unsigned Ctr_DB_GetNumCtrsWithCrss (const char *SubQuery)
|
||||||
/********************* Get number of centers with users **********************/
|
/********************* Get number of centers with users **********************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
unsigned Ctr_DB_GetNumCtrsWithUsrs (Rol_Role_t Role,const char *SubQuery)
|
unsigned Ctr_DB_GetNumCtrsWithUsrs (Rol_Role_t Role,
|
||||||
|
HieLvl_Level_t Scope,long Cod)
|
||||||
{
|
{
|
||||||
|
char SubQuery[128];
|
||||||
|
|
||||||
|
Hie_DB_BuildSubquery (SubQuery,Scope,Cod);
|
||||||
|
|
||||||
return (unsigned)
|
return (unsigned)
|
||||||
DB_QueryCOUNT ("can not get number of centers with users",
|
DB_QueryCOUNT ("can not get number of centers with users",
|
||||||
"SELECT COUNT(DISTINCT ctr_centers.CtrCod)"
|
"SELECT COUNT(DISTINCT ctr_centers.CtrCod)"
|
||||||
|
|
|
@ -60,9 +60,10 @@ unsigned Ctr_DB_GetNumCtrsInPlc (long PlcCod);
|
||||||
unsigned Ctr_DB_GetNumCtrsWithMap (void);
|
unsigned Ctr_DB_GetNumCtrsWithMap (void);
|
||||||
unsigned Ctr_DB_GetNumCtrsWithMapInCty (long CtyCod);
|
unsigned Ctr_DB_GetNumCtrsWithMapInCty (long CtyCod);
|
||||||
unsigned Ctr_DB_GetNumCtrsWithMapInIns (long InsCod);
|
unsigned Ctr_DB_GetNumCtrsWithMapInIns (long InsCod);
|
||||||
unsigned Ctr_DB_GetNumCtrsWithDegs (const char *SubQuery);
|
unsigned Ctr_DB_GetNumCtrsWithDegs (HieLvl_Level_t Scope,long Cod);
|
||||||
unsigned Ctr_DB_GetNumCtrsWithCrss (const char *SubQuery);
|
unsigned Ctr_DB_GetNumCtrsWithCrss (HieLvl_Level_t Scope,long Cod);
|
||||||
unsigned Ctr_DB_GetNumCtrsWithUsrs (Rol_Role_t Role,const char *SubQuery);
|
unsigned Ctr_DB_GetNumCtrsWithUsrs (Rol_Role_t Role,
|
||||||
|
HieLvl_Level_t Scope,long Cod);
|
||||||
|
|
||||||
void Ctr_DB_UpdateCtrIns (long CtrCod,long NewInsCod);
|
void Ctr_DB_UpdateCtrIns (long CtrCod,long NewInsCod);
|
||||||
void Ctr_DB_UpdateCtrPlc (long CtrCod,long NewPlcCod);
|
void Ctr_DB_UpdateCtrPlc (long CtrCod,long NewPlcCod);
|
||||||
|
|
|
@ -602,13 +602,14 @@ TODO: FIX BUG, URGENT! En las fechas como par
|
||||||
|
|
||||||
TODO: En las encuestas, que los estudiantes no puedan ver los resultados hasta que no finalice el plazo.
|
TODO: En las encuestas, que los estudiantes no puedan ver los resultados hasta que no finalice el plazo.
|
||||||
*/
|
*/
|
||||||
#define Log_PLATFORM_VERSION "SWAD 20.96.7 (2021-09-09)"
|
#define Log_PLATFORM_VERSION "SWAD 20.97 (2021-09-10)"
|
||||||
#define CSS_FILE "swad20.45.css"
|
#define CSS_FILE "swad20.45.css"
|
||||||
#define JS_FILE "swad20.69.1.js"
|
#define JS_FILE "swad20.69.1.js"
|
||||||
/*
|
/*
|
||||||
TODO: Rename CENTRE to CENTER in help wiki.
|
TODO: Rename CENTRE to CENTER in help wiki.
|
||||||
TODO: Rename ASSESSMENT.Announcements to ASSESSMENT.Calls_for_exams
|
TODO: Rename ASSESSMENT.Announcements to ASSESSMENT.Calls_for_exams
|
||||||
|
|
||||||
|
Version 20.97: Sep 10, 2021 Code refactoring related to scope. (314566 lines)
|
||||||
Version 20.96.7: Sep 09, 2021 Queries moved to module swad_exam_database. (314527 lines)
|
Version 20.96.7: Sep 09, 2021 Queries moved to module swad_exam_database. (314527 lines)
|
||||||
Version 20.96.6: Sep 09, 2021 Queries moved to module swad_exam_database. (314471 lines)
|
Version 20.96.6: Sep 09, 2021 Queries moved to module swad_exam_database. (314471 lines)
|
||||||
Version 20.96.5: Sep 09, 2021 Queries moved to module swad_exam_database. (314448 lines)
|
Version 20.96.5: Sep 09, 2021 Queries moved to module swad_exam_database. (314448 lines)
|
||||||
|
|
|
@ -1759,8 +1759,7 @@ unsigned Cty_GetCachedNumCtysWithCrss (void)
|
||||||
/******************* Get number of countries with users **********************/
|
/******************* Get number of countries with users **********************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
unsigned Cty_GetCachedNumCtysWithUsrs (Rol_Role_t Role,const char *SubQuery,
|
unsigned Cty_GetCachedNumCtysWithUsrs (Rol_Role_t Role)
|
||||||
HieLvl_Level_t Scope,long Cod)
|
|
||||||
{
|
{
|
||||||
static const FigCch_FigureCached_t FigureCtys[Rol_NUM_ROLES] =
|
static const FigCch_FigureCached_t FigureCtys[Rol_NUM_ROLES] =
|
||||||
{
|
{
|
||||||
|
@ -1769,14 +1768,15 @@ unsigned Cty_GetCachedNumCtysWithUsrs (Rol_Role_t Role,const char *SubQuery,
|
||||||
[Rol_TCH] = FigCch_NUM_CTYS_WITH_TCHS, // Teachers
|
[Rol_TCH] = FigCch_NUM_CTYS_WITH_TCHS, // Teachers
|
||||||
};
|
};
|
||||||
unsigned NumCtysWithUsrs;
|
unsigned NumCtysWithUsrs;
|
||||||
|
long Cod = Sco_GetCurrentCod ();
|
||||||
|
|
||||||
/***** Get number of countries with users from cache *****/
|
/***** Get number of countries with users from cache *****/
|
||||||
if (!FigCch_GetFigureFromCache (FigureCtys[Role],Scope,Cod,
|
if (!FigCch_GetFigureFromCache (FigureCtys[Role],Gbl.Scope.Current,Cod,
|
||||||
FigCch_UNSIGNED,&NumCtysWithUsrs))
|
FigCch_UNSIGNED,&NumCtysWithUsrs))
|
||||||
{
|
{
|
||||||
/***** Get current number of countries with users from database and update cache *****/
|
/***** Get current number of countries with users from database and update cache *****/
|
||||||
NumCtysWithUsrs = Cty_DB_GetNumCtysWithUsrs (Role,SubQuery);
|
NumCtysWithUsrs = Cty_DB_GetNumCtysWithUsrs (Role,Gbl.Scope.Current,Cod);
|
||||||
FigCch_UpdateFigureIntoCache (FigureCtys[Role],Scope,Cod,
|
FigCch_UpdateFigureIntoCache (FigureCtys[Role],Gbl.Scope.Current,Cod,
|
||||||
FigCch_UNSIGNED,&NumCtysWithUsrs);
|
FigCch_UNSIGNED,&NumCtysWithUsrs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -119,8 +119,7 @@ unsigned Cty_GetCachedNumCtysWithCtrs (void);
|
||||||
unsigned Cty_GetCachedNumCtysWithDegs (void);
|
unsigned Cty_GetCachedNumCtysWithDegs (void);
|
||||||
unsigned Cty_GetCachedNumCtysWithCrss (void);
|
unsigned Cty_GetCachedNumCtysWithCrss (void);
|
||||||
|
|
||||||
unsigned Cty_GetCachedNumCtysWithUsrs (Rol_Role_t Role,const char *SubQuery,
|
unsigned Cty_GetCachedNumCtysWithUsrs (Rol_Role_t Role);
|
||||||
HieLvl_Level_t Scope,long Cod);
|
|
||||||
|
|
||||||
void Cty_ListCtysFound (MYSQL_RES **mysql_res,unsigned NumCtys);
|
void Cty_ListCtysFound (MYSQL_RES **mysql_res,unsigned NumCtys);
|
||||||
|
|
||||||
|
|
|
@ -33,6 +33,7 @@
|
||||||
#include "swad_database.h"
|
#include "swad_database.h"
|
||||||
#include "swad_error.h"
|
#include "swad_error.h"
|
||||||
#include "swad_global.h"
|
#include "swad_global.h"
|
||||||
|
#include "swad_hierarchy.h"
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/************** External global variables from others modules ****************/
|
/************** External global variables from others modules ****************/
|
||||||
|
@ -340,8 +341,13 @@ unsigned Cty_DB_GetNumCtysWithCrss (void)
|
||||||
/******************* Get number of countries with users **********************/
|
/******************* Get number of countries with users **********************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
unsigned Cty_DB_GetNumCtysWithUsrs (Rol_Role_t Role,const char *SubQuery)
|
unsigned Cty_DB_GetNumCtysWithUsrs (Rol_Role_t Role,
|
||||||
|
HieLvl_Level_t Scope,long Cod)
|
||||||
{
|
{
|
||||||
|
char SubQuery[128];
|
||||||
|
|
||||||
|
Hie_DB_BuildSubquery (SubQuery,Scope,Cod);
|
||||||
|
|
||||||
return (unsigned)
|
return (unsigned)
|
||||||
DB_QueryCOUNT ("can not get number of countries with users",
|
DB_QueryCOUNT ("can not get number of countries with users",
|
||||||
"SELECT COUNT(DISTINCT cty_countrs.CtyCod)"
|
"SELECT COUNT(DISTINCT cty_countrs.CtyCod)"
|
||||||
|
|
|
@ -54,7 +54,8 @@ unsigned Cty_DB_GetNumCtysWithInss (void);
|
||||||
unsigned Cty_DB_GetNumCtysWithCtrs (void);
|
unsigned Cty_DB_GetNumCtysWithCtrs (void);
|
||||||
unsigned Cty_DB_GetNumCtysWithDegs (void);
|
unsigned Cty_DB_GetNumCtysWithDegs (void);
|
||||||
unsigned Cty_DB_GetNumCtysWithCrss (void);
|
unsigned Cty_DB_GetNumCtysWithCrss (void);
|
||||||
unsigned Cty_DB_GetNumCtysWithUsrs (Rol_Role_t Role,const char *SubQuery);
|
unsigned Cty_DB_GetNumCtysWithUsrs (Rol_Role_t Role,
|
||||||
|
HieLvl_Level_t Scope,long Cod);
|
||||||
|
|
||||||
bool Cty_DB_CheckIfNumericCountryCodeExists (long CtyCod);
|
bool Cty_DB_CheckIfNumericCountryCodeExists (long CtyCod);
|
||||||
bool Cty_DB_CheckIfAlpha2CountryCodeExists (const char Alpha2[2 + 1]);
|
bool Cty_DB_CheckIfAlpha2CountryCodeExists (const char Alpha2[2 + 1]);
|
||||||
|
|
|
@ -598,8 +598,7 @@ unsigned Crs_GetCachedNumCrssInDeg (long DegCod)
|
||||||
/********************* Get number of courses with users **********************/
|
/********************* Get number of courses with users **********************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
unsigned Crs_GetCachedNumCrssWithUsrs (Rol_Role_t Role,const char *SubQuery,
|
unsigned Crs_GetCachedNumCrssWithUsrs (Rol_Role_t Role)
|
||||||
HieLvl_Level_t Scope,long Cod)
|
|
||||||
{
|
{
|
||||||
static const FigCch_FigureCached_t FigureCrss[Rol_NUM_ROLES] =
|
static const FigCch_FigureCached_t FigureCrss[Rol_NUM_ROLES] =
|
||||||
{
|
{
|
||||||
|
@ -608,14 +607,15 @@ unsigned Crs_GetCachedNumCrssWithUsrs (Rol_Role_t Role,const char *SubQuery,
|
||||||
[Rol_TCH] = FigCch_NUM_CRSS_WITH_TCHS, // Teachers
|
[Rol_TCH] = FigCch_NUM_CRSS_WITH_TCHS, // Teachers
|
||||||
};
|
};
|
||||||
unsigned NumCrssWithUsrs;
|
unsigned NumCrssWithUsrs;
|
||||||
|
long Cod = Sco_GetCurrentCod ();
|
||||||
|
|
||||||
/***** Get number of courses with users from cache *****/
|
/***** Get number of courses with users from cache *****/
|
||||||
if (!FigCch_GetFigureFromCache (FigureCrss[Role],Scope,Cod,
|
if (!FigCch_GetFigureFromCache (FigureCrss[Role],Gbl.Scope.Current,Cod,
|
||||||
FigCch_UNSIGNED,&NumCrssWithUsrs))
|
FigCch_UNSIGNED,&NumCrssWithUsrs))
|
||||||
{
|
{
|
||||||
/***** Get current number of courses with users from database and update cache *****/
|
/***** Get current number of courses with users from database and update cache *****/
|
||||||
NumCrssWithUsrs = Crs_DB_GetNumCrssWithUsrs (Role,SubQuery);
|
NumCrssWithUsrs = Crs_DB_GetNumCrssWithUsrs (Role,Gbl.Scope.Current,Cod);
|
||||||
FigCch_UpdateFigureIntoCache (FigureCrss[Role],Scope,Cod,
|
FigCch_UpdateFigureIntoCache (FigureCrss[Role],Gbl.Scope.Current,Cod,
|
||||||
FigCch_UNSIGNED,&NumCrssWithUsrs);
|
FigCch_UNSIGNED,&NumCrssWithUsrs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -113,8 +113,7 @@ void Crs_FlushCacheNumCrssInDeg (void);
|
||||||
unsigned Crs_GetNumCrssInDeg (long DegCod);
|
unsigned Crs_GetNumCrssInDeg (long DegCod);
|
||||||
unsigned Crs_GetCachedNumCrssInDeg (long DegCod);
|
unsigned Crs_GetCachedNumCrssInDeg (long DegCod);
|
||||||
|
|
||||||
unsigned Crs_GetCachedNumCrssWithUsrs (Rol_Role_t Role,const char *SubQuery,
|
unsigned Crs_GetCachedNumCrssWithUsrs (Rol_Role_t Role);
|
||||||
HieLvl_Level_t Scope,long Cod);
|
|
||||||
|
|
||||||
void Crs_WriteSelectorOfCourse (void);
|
void Crs_WriteSelectorOfCourse (void);
|
||||||
void Crs_ShowCrssOfCurrentDeg (void);
|
void Crs_ShowCrssOfCurrentDeg (void);
|
||||||
|
|
|
@ -34,6 +34,7 @@
|
||||||
#include "swad_database.h"
|
#include "swad_database.h"
|
||||||
#include "swad_error.h"
|
#include "swad_error.h"
|
||||||
#include "swad_global.h"
|
#include "swad_global.h"
|
||||||
|
#include "swad_hierarchy.h"
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/************** External global variables from others modules ****************/
|
/************** External global variables from others modules ****************/
|
||||||
|
@ -355,8 +356,13 @@ unsigned Crs_DB_GetNumCrssInDeg (long DegCod)
|
||||||
/******************** Get number of courses with users ***********************/
|
/******************** Get number of courses with users ***********************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
unsigned Crs_DB_GetNumCrssWithUsrs (Rol_Role_t Role,const char *SubQuery)
|
unsigned Crs_DB_GetNumCrssWithUsrs (Rol_Role_t Role,
|
||||||
|
HieLvl_Level_t Scope,long Cod)
|
||||||
{
|
{
|
||||||
|
char SubQuery[128];
|
||||||
|
|
||||||
|
Hie_DB_BuildSubquery (SubQuery,Scope,Cod);
|
||||||
|
|
||||||
return (unsigned)
|
return (unsigned)
|
||||||
DB_QueryCOUNT ("can not get number of courses with users",
|
DB_QueryCOUNT ("can not get number of courses with users",
|
||||||
"SELECT COUNT(DISTINCT crs_courses.CrsCod)"
|
"SELECT COUNT(DISTINCT crs_courses.CrsCod)"
|
||||||
|
|
|
@ -61,7 +61,8 @@ unsigned Crs_DB_GetNumCrssInCty (long CtyCod);
|
||||||
unsigned Crs_DB_GetNumCrssInIns (long InsCod);
|
unsigned Crs_DB_GetNumCrssInIns (long InsCod);
|
||||||
unsigned Crs_DB_GetNumCrssInCtr (long CtrCod);
|
unsigned Crs_DB_GetNumCrssInCtr (long CtrCod);
|
||||||
unsigned Crs_DB_GetNumCrssInDeg (long DegCod);
|
unsigned Crs_DB_GetNumCrssInDeg (long DegCod);
|
||||||
unsigned Crs_DB_GetNumCrssWithUsrs (Rol_Role_t Role,const char *SubQuery);
|
unsigned Crs_DB_GetNumCrssWithUsrs (Rol_Role_t Role,
|
||||||
|
HieLvl_Level_t Scope,long Cod);
|
||||||
|
|
||||||
void Crs_DB_UpdateInstitutionalCrsCod (long CrsCod,const char *NewInstitutionalCrsCod);
|
void Crs_DB_UpdateInstitutionalCrsCod (long CrsCod,const char *NewInstitutionalCrsCod);
|
||||||
void Crs_DB_UpdateCrsStatus (long CrsCod,Crs_Status_t Status);
|
void Crs_DB_UpdateCrsStatus (long CrsCod,Crs_Status_t Status);
|
||||||
|
|
|
@ -1808,18 +1808,18 @@ unsigned Deg_GetCachedNumDegsInCtr (long CtrCod)
|
||||||
/********************* Get number of centers with courses ********************/
|
/********************* Get number of centers with courses ********************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
unsigned Deg_GetCachedNumDegsWithCrss (const char *SubQuery,
|
unsigned Deg_GetCachedNumDegsWithCrss (void)
|
||||||
HieLvl_Level_t Scope,long Cod)
|
|
||||||
{
|
{
|
||||||
unsigned NumDegsWithCrss;
|
unsigned NumDegsWithCrss;
|
||||||
|
long Cod = Sco_GetCurrentCod ();
|
||||||
|
|
||||||
/***** Get number of degrees with courses from cache *****/
|
/***** Get number of degrees with courses from cache *****/
|
||||||
if (!FigCch_GetFigureFromCache (FigCch_NUM_DEGS_WITH_CRSS,Scope,Cod,
|
if (!FigCch_GetFigureFromCache (FigCch_NUM_DEGS_WITH_CRSS,Gbl.Scope.Current,Cod,
|
||||||
FigCch_UNSIGNED,&NumDegsWithCrss))
|
FigCch_UNSIGNED,&NumDegsWithCrss))
|
||||||
{
|
{
|
||||||
/***** Get current number of degrees with courses from database and update cache *****/
|
/***** Get current number of degrees with courses from database and update cache *****/
|
||||||
NumDegsWithCrss = Deg_DB_GetNumDegsWithCrss (SubQuery);
|
NumDegsWithCrss = Deg_DB_GetNumDegsWithCrss (Gbl.Scope.Current,Cod);
|
||||||
FigCch_UpdateFigureIntoCache (FigCch_NUM_DEGS_WITH_CRSS,Scope,Cod,
|
FigCch_UpdateFigureIntoCache (FigCch_NUM_DEGS_WITH_CRSS,Gbl.Scope.Current,Cod,
|
||||||
FigCch_UNSIGNED,&NumDegsWithCrss);
|
FigCch_UNSIGNED,&NumDegsWithCrss);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1830,8 +1830,7 @@ unsigned Deg_GetCachedNumDegsWithCrss (const char *SubQuery,
|
||||||
/********************* Get number of degrees with users **********************/
|
/********************* Get number of degrees with users **********************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
unsigned Deg_GetCachedNumDegsWithUsrs (Rol_Role_t Role,const char *SubQuery,
|
unsigned Deg_GetCachedNumDegsWithUsrs (Rol_Role_t Role)
|
||||||
HieLvl_Level_t Scope,long Cod)
|
|
||||||
{
|
{
|
||||||
static const FigCch_FigureCached_t FigureDegs[Rol_NUM_ROLES] =
|
static const FigCch_FigureCached_t FigureDegs[Rol_NUM_ROLES] =
|
||||||
{
|
{
|
||||||
|
@ -1840,14 +1839,15 @@ unsigned Deg_GetCachedNumDegsWithUsrs (Rol_Role_t Role,const char *SubQuery,
|
||||||
[Rol_TCH] = FigCch_NUM_DEGS_WITH_TCHS, // Teachers
|
[Rol_TCH] = FigCch_NUM_DEGS_WITH_TCHS, // Teachers
|
||||||
};
|
};
|
||||||
unsigned NumDegsWithUsrs;
|
unsigned NumDegsWithUsrs;
|
||||||
|
long Cod = Sco_GetCurrentCod ();
|
||||||
|
|
||||||
/***** Get number of degrees with users from cache *****/
|
/***** Get number of degrees with users from cache *****/
|
||||||
if (!FigCch_GetFigureFromCache (FigureDegs[Role],Scope,Cod,
|
if (!FigCch_GetFigureFromCache (FigureDegs[Role],Gbl.Scope.Current,Cod,
|
||||||
FigCch_UNSIGNED,&NumDegsWithUsrs))
|
FigCch_UNSIGNED,&NumDegsWithUsrs))
|
||||||
{
|
{
|
||||||
/***** Get current number of degrees with users from database and update cache *****/
|
/***** Get current number of degrees with users from database and update cache *****/
|
||||||
NumDegsWithUsrs = Deg_DB_GetNumDegsWithUsrs (Role,SubQuery);
|
NumDegsWithUsrs = Deg_DB_GetNumDegsWithUsrs (Role,Gbl.Scope.Current,Cod);
|
||||||
FigCch_UpdateFigureIntoCache (FigureDegs[Role],Scope,Cod,
|
FigCch_UpdateFigureIntoCache (FigureDegs[Role],Gbl.Scope.Current,Cod,
|
||||||
FigCch_UNSIGNED,&NumDegsWithUsrs);
|
FigCch_UNSIGNED,&NumDegsWithUsrs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -142,10 +142,8 @@ void Deg_FlushCacheNumDegsInCtr (void);
|
||||||
unsigned Deg_GetNumDegsInCtr (long CtrCod);
|
unsigned Deg_GetNumDegsInCtr (long CtrCod);
|
||||||
unsigned Deg_GetCachedNumDegsInCtr (long CtrCod);
|
unsigned Deg_GetCachedNumDegsInCtr (long CtrCod);
|
||||||
|
|
||||||
unsigned Deg_GetCachedNumDegsWithCrss (const char *SubQuery,
|
unsigned Deg_GetCachedNumDegsWithCrss (void);
|
||||||
HieLvl_Level_t Scope,long Cod);
|
unsigned Deg_GetCachedNumDegsWithUsrs (Rol_Role_t Role);
|
||||||
unsigned Deg_GetCachedNumDegsWithUsrs (Rol_Role_t Role,const char *SubQuery,
|
|
||||||
HieLvl_Level_t Scope,long Cod);
|
|
||||||
|
|
||||||
void Deg_ListDegsFound (MYSQL_RES **mysql_res,unsigned NumCrss);
|
void Deg_ListDegsFound (MYSQL_RES **mysql_res,unsigned NumCrss);
|
||||||
|
|
||||||
|
|
|
@ -29,6 +29,7 @@
|
||||||
#include "swad_degree_database.h"
|
#include "swad_degree_database.h"
|
||||||
#include "swad_error.h"
|
#include "swad_error.h"
|
||||||
#include "swad_global.h"
|
#include "swad_global.h"
|
||||||
|
#include "swad_hierarchy.h"
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/************** External global variables from others modules ****************/
|
/************** External global variables from others modules ****************/
|
||||||
|
@ -476,8 +477,12 @@ bool Deg_DB_CheckIfDegNameExistsInCtr (const char *FieldName,const char *Name,
|
||||||
/***************** Get current number of degrees with courses ****************/
|
/***************** Get current number of degrees with courses ****************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
unsigned Deg_DB_GetNumDegsWithCrss (const char *SubQuery)
|
unsigned Deg_DB_GetNumDegsWithCrss (HieLvl_Level_t Scope,long Cod)
|
||||||
{
|
{
|
||||||
|
char SubQuery[128];
|
||||||
|
|
||||||
|
Hie_DB_BuildSubquery (SubQuery,Scope,Cod);
|
||||||
|
|
||||||
return (unsigned)
|
return (unsigned)
|
||||||
DB_QueryCOUNT ("can not get number of degrees with courses",
|
DB_QueryCOUNT ("can not get number of degrees with courses",
|
||||||
"SELECT COUNT(DISTINCT deg_degrees.DegCod)"
|
"SELECT COUNT(DISTINCT deg_degrees.DegCod)"
|
||||||
|
@ -495,8 +500,13 @@ unsigned Deg_DB_GetNumDegsWithCrss (const char *SubQuery)
|
||||||
/**************** Get current number of degrees with users *******************/
|
/**************** Get current number of degrees with users *******************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
unsigned Deg_DB_GetNumDegsWithUsrs (Rol_Role_t Role,const char *SubQuery)
|
unsigned Deg_DB_GetNumDegsWithUsrs (Rol_Role_t Role,
|
||||||
|
HieLvl_Level_t Scope,long Cod)
|
||||||
{
|
{
|
||||||
|
char SubQuery[128];
|
||||||
|
|
||||||
|
Hie_DB_BuildSubquery (SubQuery,Scope,Cod);
|
||||||
|
|
||||||
return (unsigned)
|
return (unsigned)
|
||||||
DB_QueryCOUNT ("can not get number of degrees with users",
|
DB_QueryCOUNT ("can not get number of degrees with users",
|
||||||
"SELECT COUNT(DISTINCT deg_degrees.DegCod)"
|
"SELECT COUNT(DISTINCT deg_degrees.DegCod)"
|
||||||
|
|
|
@ -64,8 +64,9 @@ unsigned Deg_DB_GetDegsWithStds (MYSQL_RES **mysql_res);
|
||||||
bool Deg_DB_CheckIfDegNameExistsInCtr (const char *FieldName,const char *Name,
|
bool Deg_DB_CheckIfDegNameExistsInCtr (const char *FieldName,const char *Name,
|
||||||
long DegCod,long CtrCod);
|
long DegCod,long CtrCod);
|
||||||
|
|
||||||
unsigned Deg_DB_GetNumDegsWithCrss (const char *SubQuery);
|
unsigned Deg_DB_GetNumDegsWithCrss (HieLvl_Level_t Scope,long Cod);
|
||||||
unsigned Deg_DB_GetNumDegsWithUsrs (Rol_Role_t Role,const char *SubQuery);
|
unsigned Deg_DB_GetNumDegsWithUsrs (Rol_Role_t Role,
|
||||||
|
HieLvl_Level_t Scope,long Cod);
|
||||||
unsigned Deg_DB_GetNumDegsInCty (long CtyCod);
|
unsigned Deg_DB_GetNumDegsInCty (long CtyCod);
|
||||||
unsigned Deg_DB_GetNumDegsInIns (long InsCod);
|
unsigned Deg_DB_GetNumDegsInIns (long InsCod);
|
||||||
unsigned Deg_DB_GetNumDegsInCtr (long CtrCod);
|
unsigned Deg_DB_GetNumDegsInCtr (long CtrCod);
|
||||||
|
|
128
swad_figure.c
128
swad_figure.c
|
@ -36,6 +36,7 @@
|
||||||
#include "swad_box.h"
|
#include "swad_box.h"
|
||||||
#include "swad_database.h"
|
#include "swad_database.h"
|
||||||
#include "swad_error.h"
|
#include "swad_error.h"
|
||||||
|
#include "swad_exam_database.h"
|
||||||
#include "swad_figure.h"
|
#include "swad_figure.h"
|
||||||
#include "swad_figure_cache.h"
|
#include "swad_figure_cache.h"
|
||||||
#include "swad_file_browser.h"
|
#include "swad_file_browser.h"
|
||||||
|
@ -43,6 +44,7 @@
|
||||||
#include "swad_form.h"
|
#include "swad_form.h"
|
||||||
#include "swad_forum.h"
|
#include "swad_forum.h"
|
||||||
#include "swad_global.h"
|
#include "swad_global.h"
|
||||||
|
#include "swad_hierarchy.h"
|
||||||
#include "swad_hierarchy_level.h"
|
#include "swad_hierarchy_level.h"
|
||||||
#include "swad_HTML.h"
|
#include "swad_HTML.h"
|
||||||
#include "swad_institution.h"
|
#include "swad_institution.h"
|
||||||
|
@ -434,12 +436,7 @@ static void Fig_GetAndShowNumUsrsInCrss (Rol_Role_t Role)
|
||||||
{
|
{
|
||||||
extern const char *Txt_Total;
|
extern const char *Txt_Total;
|
||||||
extern const char *Txt_ROLES_PLURAL_Abc[Rol_NUM_ROLES][Usr_NUM_SEXS];
|
extern const char *Txt_ROLES_PLURAL_Abc[Rol_NUM_ROLES][Usr_NUM_SEXS];
|
||||||
long Cod = (Gbl.Scope.Current == HieLvl_CTY ? Gbl.Hierarchy.Cty.CtyCod :
|
long Cod = Sco_GetCurrentCod ();
|
||||||
(Gbl.Scope.Current == HieLvl_INS ? Gbl.Hierarchy.Ins.InsCod :
|
|
||||||
(Gbl.Scope.Current == HieLvl_CTR ? Gbl.Hierarchy.Ctr.CtrCod :
|
|
||||||
(Gbl.Scope.Current == HieLvl_DEG ? Gbl.Hierarchy.Deg.DegCod :
|
|
||||||
(Gbl.Scope.Current == HieLvl_CRS ? Gbl.Hierarchy.Crs.CrsCod :
|
|
||||||
-1L)))));
|
|
||||||
char *Class = (Role == Rol_UNK) ? "DAT_N LINE_TOP RB" :
|
char *Class = (Role == Rol_UNK) ? "DAT_N LINE_TOP RB" :
|
||||||
"DAT RB";
|
"DAT RB";
|
||||||
unsigned Roles = (Role == Rol_UNK) ? ((1 << Rol_STD) |
|
unsigned Roles = (Role == Rol_UNK) ? ((1 << Rol_STD) |
|
||||||
|
@ -696,7 +693,6 @@ static void Fig_GetAndShowHierarchyWithCtrs (void)
|
||||||
{
|
{
|
||||||
extern const char *Txt_With_;
|
extern const char *Txt_With_;
|
||||||
extern const char *Txt_centers;
|
extern const char *Txt_centers;
|
||||||
char SubQuery[128];
|
|
||||||
unsigned NumCtysWithCtrs = 1;
|
unsigned NumCtysWithCtrs = 1;
|
||||||
unsigned NumInssWithCtrs = 1;
|
unsigned NumInssWithCtrs = 1;
|
||||||
|
|
||||||
|
@ -705,11 +701,10 @@ static void Fig_GetAndShowHierarchyWithCtrs (void)
|
||||||
{
|
{
|
||||||
case HieLvl_SYS:
|
case HieLvl_SYS:
|
||||||
NumCtysWithCtrs = Cty_GetCachedNumCtysWithCtrs ();
|
NumCtysWithCtrs = Cty_GetCachedNumCtysWithCtrs ();
|
||||||
NumInssWithCtrs = Ins_GetCachedNumInssWithCtrs ("",HieLvl_SYS,-1L);
|
/* falls through */
|
||||||
break;
|
/* no break */
|
||||||
case HieLvl_CTY:
|
case HieLvl_CTY:
|
||||||
sprintf (SubQuery,"ins_instits.CtyCod=%ld AND ",Gbl.Hierarchy.Cty.CtyCod);
|
NumInssWithCtrs = Ins_GetCachedNumInssWithCtrs ();
|
||||||
NumInssWithCtrs = Ins_GetCachedNumInssWithCtrs (SubQuery,HieLvl_CTY,Gbl.Hierarchy.Cty.CtyCod);
|
|
||||||
break;
|
break;
|
||||||
case HieLvl_INS:
|
case HieLvl_INS:
|
||||||
case HieLvl_CTR:
|
case HieLvl_CTR:
|
||||||
|
@ -739,7 +734,6 @@ static void Fig_GetAndShowHierarchyWithDegs (void)
|
||||||
{
|
{
|
||||||
extern const char *Txt_With_;
|
extern const char *Txt_With_;
|
||||||
extern const char *Txt_degrees;
|
extern const char *Txt_degrees;
|
||||||
char SubQuery[128];
|
|
||||||
unsigned NumCtysWithDegs = 1;
|
unsigned NumCtysWithDegs = 1;
|
||||||
unsigned NumInssWithDegs = 1;
|
unsigned NumInssWithDegs = 1;
|
||||||
unsigned NumCtrsWithDegs = 1;
|
unsigned NumCtrsWithDegs = 1;
|
||||||
|
@ -749,17 +743,15 @@ static void Fig_GetAndShowHierarchyWithDegs (void)
|
||||||
{
|
{
|
||||||
case HieLvl_SYS:
|
case HieLvl_SYS:
|
||||||
NumCtysWithDegs = Cty_GetCachedNumCtysWithDegs ();
|
NumCtysWithDegs = Cty_GetCachedNumCtysWithDegs ();
|
||||||
NumInssWithDegs = Ins_GetCachedNumInssWithDegs ("",HieLvl_SYS,-1L);
|
/* falls through */
|
||||||
NumCtrsWithDegs = Ctr_GetCachedNumCtrsWithDegs ("",HieLvl_SYS,-1L);
|
/* no break */
|
||||||
break;
|
break;
|
||||||
case HieLvl_CTY:
|
case HieLvl_CTY:
|
||||||
sprintf (SubQuery,"ins_instits.CtyCod=%ld AND ",Gbl.Hierarchy.Cty.CtyCod);
|
NumInssWithDegs = Ins_GetCachedNumInssWithDegs ();
|
||||||
NumInssWithDegs = Ins_GetCachedNumInssWithDegs (SubQuery,HieLvl_CTY,Gbl.Hierarchy.Cty.CtyCod);
|
/* falls through */
|
||||||
NumCtrsWithDegs = Ctr_GetCachedNumCtrsWithDegs (SubQuery,HieLvl_CTY,Gbl.Hierarchy.Cty.CtyCod);
|
/* no break */
|
||||||
break;
|
|
||||||
case HieLvl_INS:
|
case HieLvl_INS:
|
||||||
sprintf (SubQuery,"ctr_centers.InsCod=%ld AND ",Gbl.Hierarchy.Ins.InsCod);
|
NumCtrsWithDegs = Ctr_GetCachedNumCtrsWithDegs ();
|
||||||
NumCtrsWithDegs = Ctr_GetCachedNumCtrsWithDegs (SubQuery,HieLvl_INS,Gbl.Hierarchy.Ins.InsCod);
|
|
||||||
break;
|
break;
|
||||||
case HieLvl_CTR:
|
case HieLvl_CTR:
|
||||||
case HieLvl_DEG:
|
case HieLvl_DEG:
|
||||||
|
@ -788,7 +780,6 @@ static void Fig_GetAndShowHierarchyWithCrss (void)
|
||||||
{
|
{
|
||||||
extern const char *Txt_With_;
|
extern const char *Txt_With_;
|
||||||
extern const char *Txt_courses;
|
extern const char *Txt_courses;
|
||||||
char SubQuery[128];
|
|
||||||
unsigned NumCtysWithCrss = 1;
|
unsigned NumCtysWithCrss = 1;
|
||||||
unsigned NumInssWithCrss = 1;
|
unsigned NumInssWithCrss = 1;
|
||||||
unsigned NumCtrsWithCrss = 1;
|
unsigned NumCtrsWithCrss = 1;
|
||||||
|
@ -799,25 +790,18 @@ static void Fig_GetAndShowHierarchyWithCrss (void)
|
||||||
{
|
{
|
||||||
case HieLvl_SYS:
|
case HieLvl_SYS:
|
||||||
NumCtysWithCrss = Cty_GetCachedNumCtysWithCrss ();
|
NumCtysWithCrss = Cty_GetCachedNumCtysWithCrss ();
|
||||||
NumInssWithCrss = Ins_GetCachedNumInssWithCrss ("",HieLvl_SYS,-1L);
|
/* falls through */
|
||||||
NumCtrsWithCrss = Ctr_GetCachedNumCtrsWithCrss ("",HieLvl_SYS,-1L);
|
/* no break */
|
||||||
NumDegsWithCrss = Deg_GetCachedNumDegsWithCrss ("",HieLvl_SYS,-1L);
|
|
||||||
break;
|
|
||||||
case HieLvl_CTY:
|
case HieLvl_CTY:
|
||||||
sprintf (SubQuery,"ins_instits.CtyCod=%ld AND ",Gbl.Hierarchy.Cty.CtyCod);
|
NumInssWithCrss = Ins_GetCachedNumInssWithCrss ();
|
||||||
NumInssWithCrss = Ins_GetCachedNumInssWithCrss (SubQuery,HieLvl_CTY,Gbl.Hierarchy.Cty.CtyCod);
|
/* falls through */
|
||||||
NumCtrsWithCrss = Ctr_GetCachedNumCtrsWithCrss (SubQuery,HieLvl_CTY,Gbl.Hierarchy.Cty.CtyCod);
|
/* no break */
|
||||||
NumDegsWithCrss = Deg_GetCachedNumDegsWithCrss (SubQuery,HieLvl_CTY,Gbl.Hierarchy.Cty.CtyCod);
|
|
||||||
break;
|
|
||||||
case HieLvl_INS:
|
case HieLvl_INS:
|
||||||
sprintf (SubQuery,"ctr_centers.InsCod=%ld AND ",Gbl.Hierarchy.Ins.InsCod);
|
NumCtrsWithCrss = Ctr_GetCachedNumCtrsWithCrss ();
|
||||||
NumCtrsWithCrss = Ctr_GetCachedNumCtrsWithCrss (SubQuery,HieLvl_INS,Gbl.Hierarchy.Ins.InsCod);
|
/* falls through */
|
||||||
NumDegsWithCrss = Deg_GetCachedNumDegsWithCrss (SubQuery,HieLvl_INS,Gbl.Hierarchy.Ins.InsCod);
|
/* no break */
|
||||||
break;
|
|
||||||
case HieLvl_CTR:
|
case HieLvl_CTR:
|
||||||
sprintf (SubQuery,"deg_degrees.CtrCod=%ld AND ",
|
NumDegsWithCrss = Deg_GetCachedNumDegsWithCrss ();
|
||||||
Gbl.Hierarchy.Ctr.CtrCod);
|
|
||||||
NumDegsWithCrss = Deg_GetCachedNumDegsWithCrss (SubQuery,HieLvl_CTR,Gbl.Hierarchy.Ctr.CtrCod);
|
|
||||||
break;
|
break;
|
||||||
case HieLvl_DEG:
|
case HieLvl_DEG:
|
||||||
case HieLvl_CRS:
|
case HieLvl_CRS:
|
||||||
|
@ -845,68 +829,18 @@ static void Fig_GetAndShowHierarchyWithUsrs (Rol_Role_t Role)
|
||||||
{
|
{
|
||||||
extern const char *Txt_With_;
|
extern const char *Txt_With_;
|
||||||
extern const char *Txt_ROLES_PLURAL_abc[Rol_NUM_ROLES][Usr_NUM_SEXS];
|
extern const char *Txt_ROLES_PLURAL_abc[Rol_NUM_ROLES][Usr_NUM_SEXS];
|
||||||
char SubQuery[128];
|
unsigned NumCtysWithUsrs;
|
||||||
unsigned NumCtysWithUsrs = 0;
|
unsigned NumInssWithUsrs;
|
||||||
unsigned NumInssWithUsrs = 0;
|
unsigned NumCtrsWithUsrs;
|
||||||
unsigned NumCtrsWithUsrs = 0;
|
unsigned NumDegsWithUsrs;
|
||||||
unsigned NumDegsWithUsrs = 0;
|
unsigned NumCrssWithUsrs;
|
||||||
unsigned NumCrssWithUsrs = 0;
|
|
||||||
|
|
||||||
/***** Get number of elements with students *****/
|
/***** Get number of elements with students *****/
|
||||||
switch (Gbl.Scope.Current)
|
NumCtysWithUsrs = Cty_GetCachedNumCtysWithUsrs (Role);
|
||||||
{
|
NumInssWithUsrs = Ins_GetCachedNumInssWithUsrs (Role);
|
||||||
case HieLvl_SYS:
|
NumCtrsWithUsrs = Ctr_GetCachedNumCtrsWithUsrs (Role);
|
||||||
NumCtysWithUsrs = Cty_GetCachedNumCtysWithUsrs (Role,"",HieLvl_SYS,-1L);
|
NumDegsWithUsrs = Deg_GetCachedNumDegsWithUsrs (Role);
|
||||||
NumInssWithUsrs = Ins_GetCachedNumInssWithUsrs (Role,"",HieLvl_SYS,-1L);
|
NumCrssWithUsrs = Crs_GetCachedNumCrssWithUsrs (Role);
|
||||||
NumCtrsWithUsrs = Ctr_GetCachedNumCtrsWithUsrs (Role,"",HieLvl_SYS,-1L);
|
|
||||||
NumDegsWithUsrs = Deg_GetCachedNumDegsWithUsrs (Role,"",HieLvl_SYS,-1L);
|
|
||||||
NumCrssWithUsrs = Crs_GetCachedNumCrssWithUsrs (Role,"",HieLvl_SYS,-1L);
|
|
||||||
break;
|
|
||||||
case HieLvl_CTY:
|
|
||||||
sprintf (SubQuery,"ins_instits.CtyCod=%ld AND ",Gbl.Hierarchy.Cty.CtyCod);
|
|
||||||
NumCtysWithUsrs = Cty_GetCachedNumCtysWithUsrs (Role,SubQuery,HieLvl_CTY,Gbl.Hierarchy.Cty.CtyCod);
|
|
||||||
NumInssWithUsrs = Ins_GetCachedNumInssWithUsrs (Role,SubQuery,HieLvl_CTY,Gbl.Hierarchy.Cty.CtyCod);
|
|
||||||
NumCtrsWithUsrs = Ctr_GetCachedNumCtrsWithUsrs (Role,SubQuery,HieLvl_CTY,Gbl.Hierarchy.Cty.CtyCod);
|
|
||||||
NumDegsWithUsrs = Deg_GetCachedNumDegsWithUsrs (Role,SubQuery,HieLvl_CTY,Gbl.Hierarchy.Cty.CtyCod);
|
|
||||||
NumCrssWithUsrs = Crs_GetCachedNumCrssWithUsrs (Role,SubQuery,HieLvl_CTY,Gbl.Hierarchy.Cty.CtyCod);
|
|
||||||
break;
|
|
||||||
case HieLvl_INS:
|
|
||||||
sprintf (SubQuery,"ctr_centers.InsCod=%ld AND ",Gbl.Hierarchy.Ins.InsCod);
|
|
||||||
NumCtysWithUsrs = Cty_GetCachedNumCtysWithUsrs (Role,SubQuery,HieLvl_INS,Gbl.Hierarchy.Ins.InsCod);
|
|
||||||
NumInssWithUsrs = Ins_GetCachedNumInssWithUsrs (Role,SubQuery,HieLvl_INS,Gbl.Hierarchy.Ins.InsCod);
|
|
||||||
NumCtrsWithUsrs = Ctr_GetCachedNumCtrsWithUsrs (Role,SubQuery,HieLvl_INS,Gbl.Hierarchy.Ins.InsCod);
|
|
||||||
NumDegsWithUsrs = Deg_GetCachedNumDegsWithUsrs (Role,SubQuery,HieLvl_INS,Gbl.Hierarchy.Ins.InsCod);
|
|
||||||
NumCrssWithUsrs = Crs_GetCachedNumCrssWithUsrs (Role,SubQuery,HieLvl_INS,Gbl.Hierarchy.Ins.InsCod);
|
|
||||||
break;
|
|
||||||
case HieLvl_CTR:
|
|
||||||
sprintf (SubQuery,"deg_degrees.CtrCod=%ld AND ",
|
|
||||||
Gbl.Hierarchy.Ctr.CtrCod);
|
|
||||||
NumCtysWithUsrs = Cty_GetCachedNumCtysWithUsrs (Role,SubQuery,HieLvl_CTR,Gbl.Hierarchy.Ctr.CtrCod);
|
|
||||||
NumInssWithUsrs = Ins_GetCachedNumInssWithUsrs (Role,SubQuery,HieLvl_CTR,Gbl.Hierarchy.Ctr.CtrCod);
|
|
||||||
NumCtrsWithUsrs = Ctr_GetCachedNumCtrsWithUsrs (Role,SubQuery,HieLvl_CTR,Gbl.Hierarchy.Ctr.CtrCod);
|
|
||||||
NumDegsWithUsrs = Deg_GetCachedNumDegsWithUsrs (Role,SubQuery,HieLvl_CTR,Gbl.Hierarchy.Ctr.CtrCod);
|
|
||||||
NumCrssWithUsrs = Crs_GetCachedNumCrssWithUsrs (Role,SubQuery,HieLvl_CTR,Gbl.Hierarchy.Ctr.CtrCod);
|
|
||||||
break;
|
|
||||||
case HieLvl_DEG:
|
|
||||||
sprintf (SubQuery,"crs_courses.DegCod=%ld AND ",Gbl.Hierarchy.Deg.DegCod);
|
|
||||||
NumCtysWithUsrs = Cty_GetCachedNumCtysWithUsrs (Role,SubQuery,HieLvl_DEG,Gbl.Hierarchy.Deg.DegCod);
|
|
||||||
NumInssWithUsrs = Ins_GetCachedNumInssWithUsrs (Role,SubQuery,HieLvl_DEG,Gbl.Hierarchy.Deg.DegCod);
|
|
||||||
NumCtrsWithUsrs = Ctr_GetCachedNumCtrsWithUsrs (Role,SubQuery,HieLvl_DEG,Gbl.Hierarchy.Deg.DegCod);
|
|
||||||
NumDegsWithUsrs = Deg_GetCachedNumDegsWithUsrs (Role,SubQuery,HieLvl_DEG,Gbl.Hierarchy.Deg.DegCod);
|
|
||||||
NumCrssWithUsrs = Crs_GetCachedNumCrssWithUsrs (Role,SubQuery,HieLvl_DEG,Gbl.Hierarchy.Deg.DegCod);
|
|
||||||
break;
|
|
||||||
case HieLvl_CRS:
|
|
||||||
sprintf (SubQuery,"crs_users.CrsCod=%ld AND ",Gbl.Hierarchy.Crs.CrsCod);
|
|
||||||
NumCtysWithUsrs = Cty_GetCachedNumCtysWithUsrs (Role,SubQuery,HieLvl_CRS,Gbl.Hierarchy.Crs.CrsCod);
|
|
||||||
NumInssWithUsrs = Ins_GetCachedNumInssWithUsrs (Role,SubQuery,HieLvl_CRS,Gbl.Hierarchy.Crs.CrsCod);
|
|
||||||
NumCtrsWithUsrs = Ctr_GetCachedNumCtrsWithUsrs (Role,SubQuery,HieLvl_CRS,Gbl.Hierarchy.Crs.CrsCod);
|
|
||||||
NumDegsWithUsrs = Deg_GetCachedNumDegsWithUsrs (Role,SubQuery,HieLvl_CRS,Gbl.Hierarchy.Crs.CrsCod);
|
|
||||||
NumCrssWithUsrs = Crs_GetCachedNumCrssWithUsrs (Role,SubQuery,HieLvl_CRS,Gbl.Hierarchy.Crs.CrsCod);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
Err_WrongScopeExit ();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
/***** Write number of elements with students *****/
|
/***** Write number of elements with students *****/
|
||||||
Fig_ShowHierarchyRow (Txt_With_,Txt_ROLES_PLURAL_abc[Role][Usr_SEX_UNKNOWN],
|
Fig_ShowHierarchyRow (Txt_With_,Txt_ROLES_PLURAL_abc[Role][Usr_SEX_UNKNOWN],
|
||||||
|
|
|
@ -802,3 +802,26 @@ void Hie_FreeGoToMsg (void)
|
||||||
{
|
{
|
||||||
Str_FreeString ();
|
Str_FreeString ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
/******************* Get number of countries with users **********************/
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
void Hie_DB_BuildSubquery (char SubQuery[128],HieLvl_Level_t Scope,long Cod)
|
||||||
|
{
|
||||||
|
static const char *Format[HieLvl_NUM_LEVELS] =
|
||||||
|
{
|
||||||
|
[HieLvl_UNK] = "", // Unknown
|
||||||
|
[HieLvl_SYS] = "", // System
|
||||||
|
[HieLvl_CTY] = "ins_instits.CtyCod=%ld AND ", // Country
|
||||||
|
[HieLvl_INS] = "ctr_centers.InsCod=%ld AND ", // Institution
|
||||||
|
[HieLvl_CTR] = "deg_degrees.CtrCod=%ld AND ", // Center
|
||||||
|
[HieLvl_DEG] = "crs_courses.DegCod=%ld AND ", // Degree
|
||||||
|
[HieLvl_CRS] = "crs_users.CrsCod=%ld AND ", // Course
|
||||||
|
};
|
||||||
|
|
||||||
|
if (Cod > 0)
|
||||||
|
sprintf (SubQuery,Format[Scope],Cod);
|
||||||
|
else
|
||||||
|
SubQuery[0] = '\0';
|
||||||
|
}
|
||||||
|
|
|
@ -69,4 +69,6 @@ void Hie_GetAndWriteInsCtrDegAdminBy (long UsrCod,unsigned ColSpan);
|
||||||
char *Hie_BuildGoToMsg (const char *Where);
|
char *Hie_BuildGoToMsg (const char *Where);
|
||||||
void Hie_FreeGoToMsg (void);
|
void Hie_FreeGoToMsg (void);
|
||||||
|
|
||||||
|
void Hie_DB_BuildSubquery (char SubQuery[128],HieLvl_Level_t Scope,long Cod);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -1983,98 +1983,136 @@ unsigned Ins_GetCachedNumInssInCty (long CtyCod)
|
||||||
/***************** Get number of institutions with centers *******************/
|
/***************** Get number of institutions with centers *******************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
unsigned Ins_GetCachedNumInssWithCtrs (const char *SubQuery,
|
unsigned Ins_GetCachedNumInssWithCtrs (void)
|
||||||
HieLvl_Level_t Scope,long Cod)
|
|
||||||
{
|
{
|
||||||
unsigned NumInssWithCtrs;
|
unsigned NumInssWithCtrs;
|
||||||
|
long Cod = Sco_GetCurrentCod ();
|
||||||
|
|
||||||
/***** Get number of institutions with centers from cache *****/
|
/***** Get number of institutions with centers from cache *****/
|
||||||
if (!FigCch_GetFigureFromCache (FigCch_NUM_INSS_WITH_CTRS,Scope,Cod,
|
if (!FigCch_GetFigureFromCache (FigCch_NUM_INSS_WITH_CTRS,Gbl.Scope.Current,Cod,
|
||||||
FigCch_UNSIGNED,&NumInssWithCtrs))
|
FigCch_UNSIGNED,&NumInssWithCtrs))
|
||||||
{
|
{
|
||||||
/***** Get current number of institutions with centers from database and update cache *****/
|
/***** Get current number of institutions with centers from database and update cache *****/
|
||||||
NumInssWithCtrs = (unsigned)
|
NumInssWithCtrs = Ins_DB_GetNumInssWithCtrs (Gbl.Scope.Current,Cod);
|
||||||
DB_QueryCOUNT ("can not get number of institutions with centers",
|
FigCch_UpdateFigureIntoCache (FigCch_NUM_INSS_WITH_CTRS,Gbl.Scope.Current,Cod,
|
||||||
"SELECT COUNT(DISTINCT ins_instits.InsCod)"
|
|
||||||
" FROM ins_instits,"
|
|
||||||
"ctr_centers"
|
|
||||||
" WHERE %sinstitutions.InsCod=ctr_centers.InsCod",
|
|
||||||
SubQuery);
|
|
||||||
FigCch_UpdateFigureIntoCache (FigCch_NUM_INSS_WITH_CTRS,Scope,Cod,
|
|
||||||
FigCch_UNSIGNED,&NumInssWithCtrs);
|
FigCch_UNSIGNED,&NumInssWithCtrs);
|
||||||
}
|
}
|
||||||
|
|
||||||
return NumInssWithCtrs;
|
return NumInssWithCtrs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
/****************** Get number of institutions with centres ******************/
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
unsigned Ins_DB_GetNumInssWithCtrs (HieLvl_Level_t Scope,long Cod)
|
||||||
|
{
|
||||||
|
char SubQuery[128];
|
||||||
|
|
||||||
|
Hie_DB_BuildSubquery (SubQuery,Scope,Cod);
|
||||||
|
|
||||||
|
return (unsigned)
|
||||||
|
DB_QueryCOUNT ("can not get number of institutions with centers",
|
||||||
|
"SELECT COUNT(DISTINCT ins_instits.InsCod)"
|
||||||
|
" FROM ins_instits,"
|
||||||
|
"ctr_centers"
|
||||||
|
" WHERE %sinstitutions.InsCod=ctr_centers.InsCod",
|
||||||
|
SubQuery);
|
||||||
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/****************** Get number of institutions with degrees ******************/
|
/****************** Get number of institutions with degrees ******************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
unsigned Ins_GetCachedNumInssWithDegs (const char *SubQuery,
|
unsigned Ins_GetCachedNumInssWithDegs (void)
|
||||||
HieLvl_Level_t Scope,long Cod)
|
|
||||||
{
|
{
|
||||||
unsigned NumInssWithDegs;
|
unsigned NumInssWithDegs;
|
||||||
|
long Cod = Sco_GetCurrentCod ();
|
||||||
|
|
||||||
/***** Get number of institutions with degrees from cache *****/
|
/***** Get number of institutions with degrees from cache *****/
|
||||||
if (!FigCch_GetFigureFromCache (FigCch_NUM_INSS_WITH_DEGS,Scope,Cod,
|
if (!FigCch_GetFigureFromCache (FigCch_NUM_INSS_WITH_DEGS,Gbl.Scope.Current,Cod,
|
||||||
FigCch_UNSIGNED,&NumInssWithDegs))
|
FigCch_UNSIGNED,&NumInssWithDegs))
|
||||||
{
|
{
|
||||||
/***** Get current number of institutions with degrees from database and update cache *****/
|
/***** Get current number of institutions with degrees from database and update cache *****/
|
||||||
NumInssWithDegs = (unsigned)
|
NumInssWithDegs = Ins_DB_GetNumInssWithDegs (Gbl.Scope.Current,Cod);
|
||||||
DB_QueryCOUNT ("can not get number of institutions with degrees",
|
FigCch_UpdateFigureIntoCache (FigCch_NUM_INSS_WITH_DEGS,Gbl.Scope.Current,Cod,
|
||||||
"SELECT COUNT(DISTINCT ins_instits.InsCod)"
|
|
||||||
" FROM ins_instits,"
|
|
||||||
"ctr_centers,"
|
|
||||||
"deg_degrees"
|
|
||||||
" WHERE %sinstitutions.InsCod=ctr_centers.InsCod"
|
|
||||||
" AND ctr_centers.CtrCod=deg_degrees.CtrCod",
|
|
||||||
SubQuery);
|
|
||||||
FigCch_UpdateFigureIntoCache (FigCch_NUM_INSS_WITH_DEGS,Scope,Cod,
|
|
||||||
FigCch_UNSIGNED,&NumInssWithDegs);
|
FigCch_UNSIGNED,&NumInssWithDegs);
|
||||||
}
|
}
|
||||||
|
|
||||||
return NumInssWithDegs;
|
return NumInssWithDegs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
/****************** Get number of institutions with degrees ******************/
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
unsigned Ins_DB_GetNumInssWithDegs (HieLvl_Level_t Scope,long Cod)
|
||||||
|
{
|
||||||
|
char SubQuery[128];
|
||||||
|
|
||||||
|
Hie_DB_BuildSubquery (SubQuery,Scope,Cod);
|
||||||
|
|
||||||
|
return (unsigned)
|
||||||
|
DB_QueryCOUNT ("can not get number of institutions with degrees",
|
||||||
|
"SELECT COUNT(DISTINCT ins_instits.InsCod)"
|
||||||
|
" FROM ins_instits,"
|
||||||
|
"ctr_centers,"
|
||||||
|
"deg_degrees"
|
||||||
|
" WHERE %sinstitutions.InsCod=ctr_centers.InsCod"
|
||||||
|
" AND ctr_centers.CtrCod=deg_degrees.CtrCod",
|
||||||
|
SubQuery);
|
||||||
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/****************** Get number of institutions with courses ******************/
|
/****************** Get number of institutions with courses ******************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
unsigned Ins_GetCachedNumInssWithCrss (const char *SubQuery,
|
unsigned Ins_GetCachedNumInssWithCrss (void)
|
||||||
HieLvl_Level_t Scope,long Cod)
|
|
||||||
{
|
{
|
||||||
unsigned NumInssWithCrss;
|
unsigned NumInssWithCrss;
|
||||||
|
long Cod = Sco_GetCurrentCod ();
|
||||||
|
|
||||||
/***** Get number of institutions with courses from cache *****/
|
/***** Get number of institutions with courses from cache *****/
|
||||||
if (!FigCch_GetFigureFromCache (FigCch_NUM_INSS_WITH_CRSS,Scope,Cod,
|
if (!FigCch_GetFigureFromCache (FigCch_NUM_INSS_WITH_CRSS,Gbl.Scope.Current,Cod,
|
||||||
FigCch_UNSIGNED,&NumInssWithCrss))
|
FigCch_UNSIGNED,&NumInssWithCrss))
|
||||||
{
|
{
|
||||||
/***** Get current number of institutions with courses from database and update cache *****/
|
/***** Get current number of institutions with courses from database and update cache *****/
|
||||||
NumInssWithCrss = (unsigned)
|
NumInssWithCrss = Ins_DB_GetNumInssWithCrss (Gbl.Scope.Current,Cod);
|
||||||
DB_QueryCOUNT ("can not get number of institutions with courses",
|
FigCch_UpdateFigureIntoCache (FigCch_NUM_INSS_WITH_CRSS,Gbl.Scope.Current,Cod,
|
||||||
"SELECT COUNT(DISTINCT ins_instits.InsCod)"
|
|
||||||
" FROM ins_instits,"
|
|
||||||
"ctr_centers,"
|
|
||||||
"deg_degrees,"
|
|
||||||
"crs_courses"
|
|
||||||
" WHERE %sinstitutions.InsCod=ctr_centers.InsCod"
|
|
||||||
" AND ctr_centers.CtrCod=deg_degrees.CtrCod"
|
|
||||||
" AND deg_degrees.DegCod=crs_courses.DegCod",
|
|
||||||
SubQuery);
|
|
||||||
FigCch_UpdateFigureIntoCache (FigCch_NUM_INSS_WITH_CRSS,Scope,Cod,
|
|
||||||
FigCch_UNSIGNED,&NumInssWithCrss);
|
FigCch_UNSIGNED,&NumInssWithCrss);
|
||||||
}
|
}
|
||||||
|
|
||||||
return NumInssWithCrss;
|
return NumInssWithCrss;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
/****************** Get number of institutions with courses ******************/
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
unsigned Ins_DB_GetNumInssWithCrss (HieLvl_Level_t Scope,long Cod)
|
||||||
|
{
|
||||||
|
char SubQuery[128];
|
||||||
|
|
||||||
|
Hie_DB_BuildSubquery (SubQuery,Scope,Cod);
|
||||||
|
|
||||||
|
return (unsigned)
|
||||||
|
DB_QueryCOUNT ("can not get number of institutions with courses",
|
||||||
|
"SELECT COUNT(DISTINCT ins_instits.InsCod)"
|
||||||
|
" FROM ins_instits,"
|
||||||
|
"ctr_centers,"
|
||||||
|
"deg_degrees,"
|
||||||
|
"crs_courses"
|
||||||
|
" WHERE %sinstitutions.InsCod=ctr_centers.InsCod"
|
||||||
|
" AND ctr_centers.CtrCod=deg_degrees.CtrCod"
|
||||||
|
" AND deg_degrees.DegCod=crs_courses.DegCod",
|
||||||
|
SubQuery);
|
||||||
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/****************** Get number of institutions with users ********************/
|
/****************** Get number of institutions with users ********************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
unsigned Ins_GetCachedNumInssWithUsrs (Rol_Role_t Role,const char *SubQuery,
|
unsigned Ins_GetCachedNumInssWithUsrs (Rol_Role_t Role)
|
||||||
HieLvl_Level_t Scope,long Cod)
|
|
||||||
{
|
{
|
||||||
static const FigCch_FigureCached_t FigureInss[Rol_NUM_ROLES] =
|
static const FigCch_FigureCached_t FigureInss[Rol_NUM_ROLES] =
|
||||||
{
|
{
|
||||||
|
@ -2083,33 +2121,49 @@ unsigned Ins_GetCachedNumInssWithUsrs (Rol_Role_t Role,const char *SubQuery,
|
||||||
[Rol_TCH] = FigCch_NUM_INSS_WITH_TCHS, // Teachers
|
[Rol_TCH] = FigCch_NUM_INSS_WITH_TCHS, // Teachers
|
||||||
};
|
};
|
||||||
unsigned NumInssWithUsrs;
|
unsigned NumInssWithUsrs;
|
||||||
|
long Cod = Sco_GetCurrentCod ();
|
||||||
|
|
||||||
/***** Get number of institutions with users from cache *****/
|
/***** Get number of institutions with users from cache *****/
|
||||||
if (!FigCch_GetFigureFromCache (FigureInss[Role],Scope,Cod,
|
if (!FigCch_GetFigureFromCache (FigureInss[Role],Gbl.Scope.Current,Cod,
|
||||||
FigCch_UNSIGNED,&NumInssWithUsrs))
|
FigCch_UNSIGNED,&NumInssWithUsrs))
|
||||||
{
|
{
|
||||||
/***** Get current number of institutions with users from database and update cache *****/
|
/***** Get current number of institutions with users from database and update cache *****/
|
||||||
NumInssWithUsrs = (unsigned)
|
NumInssWithUsrs = Ins_DB_GetNumInnsWithUsrs (Role,Gbl.Scope.Current,Cod);
|
||||||
DB_QueryCOUNT ("can not get number of institutions with users",
|
FigCch_UpdateFigureIntoCache (FigureInss[Role],Gbl.Scope.Current,Cod,
|
||||||
"SELECT COUNT(DISTINCT ins_instits.InsCod)"
|
|
||||||
" FROM ins_instits,"
|
|
||||||
"ctr_centers,"
|
|
||||||
"deg_degrees,"
|
|
||||||
"crs_courses,"
|
|
||||||
"crs_users"
|
|
||||||
" WHERE %sinstitutions.InsCod=ctr_centers.InsCod"
|
|
||||||
" AND ctr_centers.CtrCod=deg_degrees.CtrCod"
|
|
||||||
" AND deg_degrees.DegCod=crs_courses.DegCod"
|
|
||||||
" AND crs_courses.CrsCod=crs_users.CrsCod"
|
|
||||||
" AND crs_users.Role=%u",
|
|
||||||
SubQuery,(unsigned) Role);
|
|
||||||
FigCch_UpdateFigureIntoCache (FigureInss[Role],Scope,Cod,
|
|
||||||
FigCch_UNSIGNED,&NumInssWithUsrs);
|
FigCch_UNSIGNED,&NumInssWithUsrs);
|
||||||
}
|
}
|
||||||
|
|
||||||
return NumInssWithUsrs;
|
return NumInssWithUsrs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
/************* Get current number of institutions with users *****************/
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
unsigned Ins_DB_GetNumInnsWithUsrs (Rol_Role_t Role,
|
||||||
|
HieLvl_Level_t Scope,long Cod)
|
||||||
|
{
|
||||||
|
char SubQuery[128];
|
||||||
|
|
||||||
|
Hie_DB_BuildSubquery (SubQuery,Scope,Cod);
|
||||||
|
|
||||||
|
return (unsigned)
|
||||||
|
DB_QueryCOUNT ("can not get number of institutions with users",
|
||||||
|
"SELECT COUNT(DISTINCT ins_instits.InsCod)"
|
||||||
|
" FROM ins_instits,"
|
||||||
|
"ctr_centers,"
|
||||||
|
"deg_degrees,"
|
||||||
|
"crs_courses,"
|
||||||
|
"crs_users"
|
||||||
|
" WHERE %s"
|
||||||
|
"ins_instits.InsCod=ctr_centers.InsCod"
|
||||||
|
" AND ctr_centers.CtrCod=deg_degrees.CtrCod"
|
||||||
|
" AND deg_degrees.DegCod=crs_courses.DegCod"
|
||||||
|
" AND crs_courses.CrsCod=crs_users.CrsCod"
|
||||||
|
" AND crs_users.Role=%u",
|
||||||
|
SubQuery,(unsigned) Role);
|
||||||
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/*************************** List institutions found *************************/
|
/*************************** List institutions found *************************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
|
@ -134,14 +134,15 @@ void Ins_FlushCacheNumInssInCty (void);
|
||||||
unsigned Ins_GetNumInssInCty (long CtyCod);
|
unsigned Ins_GetNumInssInCty (long CtyCod);
|
||||||
unsigned Ins_GetCachedNumInssInCty (long CtyCod);
|
unsigned Ins_GetCachedNumInssInCty (long CtyCod);
|
||||||
|
|
||||||
unsigned Ins_GetCachedNumInssWithCtrs (const char *SubQuery,
|
unsigned Ins_GetCachedNumInssWithCtrs (void);
|
||||||
HieLvl_Level_t Scope,long Cod);
|
unsigned Ins_DB_GetNumInssWithCtrs (HieLvl_Level_t Scope,long Cod);
|
||||||
unsigned Ins_GetCachedNumInssWithDegs (const char *SubQuery,
|
unsigned Ins_GetCachedNumInssWithDegs (void);
|
||||||
HieLvl_Level_t Scope,long Cod);
|
unsigned Ins_DB_GetNumInssWithDegs (HieLvl_Level_t Scope,long Cod);
|
||||||
unsigned Ins_GetCachedNumInssWithCrss (const char *SubQuery,
|
unsigned Ins_GetCachedNumInssWithCrss (void);
|
||||||
HieLvl_Level_t Scope,long Cod);
|
unsigned Ins_DB_GetNumInssWithCrss (HieLvl_Level_t Scope,long Cod);
|
||||||
unsigned Ins_GetCachedNumInssWithUsrs (Rol_Role_t Role,const char *SubQuery,
|
unsigned Ins_GetCachedNumInssWithUsrs (Rol_Role_t Role);
|
||||||
HieLvl_Level_t Scope,long Cod);
|
unsigned Ins_DB_GetNumInnsWithUsrs (Rol_Role_t Role,
|
||||||
|
HieLvl_Level_t Scope,long Cod);
|
||||||
|
|
||||||
void Ins_ListInssFound (MYSQL_RES **mysql_res,unsigned NumInss);
|
void Ins_ListInssFound (MYSQL_RES **mysql_res,unsigned NumInss);
|
||||||
|
|
||||||
|
|
26
swad_scope.c
26
swad_scope.c
|
@ -366,3 +366,29 @@ const char *Sco_GetDBStrFromScope (HieLvl_Level_t Scope)
|
||||||
|
|
||||||
return Sco_ScopeDB[Scope];
|
return Sco_ScopeDB[Scope];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
/**************************** Get current scope code *************************/
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
long Sco_GetCurrentCod (void)
|
||||||
|
{
|
||||||
|
switch (Gbl.Scope.Current)
|
||||||
|
{
|
||||||
|
case HieLvl_SYS:
|
||||||
|
return -1L;
|
||||||
|
case HieLvl_CTY:
|
||||||
|
return Gbl.Hierarchy.Cty.CtyCod;
|
||||||
|
case HieLvl_INS:
|
||||||
|
return Gbl.Hierarchy.Ins.InsCod;
|
||||||
|
case HieLvl_CTR:
|
||||||
|
return Gbl.Hierarchy.Ctr.CtrCod;
|
||||||
|
case HieLvl_DEG:
|
||||||
|
return Gbl.Hierarchy.Deg.DegCod;
|
||||||
|
case HieLvl_CRS:
|
||||||
|
return Gbl.Hierarchy.Crs.CrsCod;
|
||||||
|
default:
|
||||||
|
Err_WrongScopeExit ();
|
||||||
|
return -1L; // Not reached
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -57,4 +57,6 @@ HieLvl_Level_t Sco_GetScopeFromUnsignedStr (const char *UnsignedStr);
|
||||||
HieLvl_Level_t Sco_GetScopeFromDBStr (const char *ScopeDBStr);
|
HieLvl_Level_t Sco_GetScopeFromDBStr (const char *ScopeDBStr);
|
||||||
const char *Sco_GetDBStrFromScope (HieLvl_Level_t Scope);
|
const char *Sco_GetDBStrFromScope (HieLvl_Level_t Scope);
|
||||||
|
|
||||||
|
long Sco_GetCurrentCod (void);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue