Version 20.88.2: Jun 02, 2021 Queries moved to module swad_center_database. Fixed bug in visibility of exam results. Reported by Mancia Anguita López.

This commit is contained in:
acanas 2021-06-02 20:47:31 +02:00
parent 920018f1f3
commit 4f83e637c6
7 changed files with 184 additions and 99 deletions

View File

@ -97,7 +97,7 @@ static void Ctr_PutParamGoToCtr (void *CtrCod);
static void Ctr_PutFormToCreateCenter (const struct Plc_Places *Places); static void Ctr_PutFormToCreateCenter (const struct Plc_Places *Places);
static void Ctr_PutHeadCentersForSeeing (bool OrderSelectable); static void Ctr_PutHeadCentersForSeeing (bool OrderSelectable);
static void Ctr_PutHeadCentersForEdition (void); static void Ctr_PutHeadCentersForEdition (void);
static void Ctr_ReceiveFormRequestOrCreateCtr (unsigned Status); static void Ctr_ReceiveFormRequestOrCreateCtr (Ctr_Status_t Status);
static unsigned Ctr_GetNumCtrsInCty (long CtyCod); static unsigned Ctr_GetNumCtrsInCty (long CtyCod);
@ -1312,12 +1312,7 @@ void Ctr_ChangeCtrStatus (void)
Ctr_GetDataOfCenterByCod (Ctr_EditingCtr); Ctr_GetDataOfCenterByCod (Ctr_EditingCtr);
/***** Update status in table of centers *****/ /***** Update status in table of centers *****/
DB_QueryUPDATE ("can not update the status of a center", Ctr_DB_UpdateCtrStatus (Ctr_EditingCtr->CtrCod,Status);
"UPDATE ctr_centers"
" SET Status=%u"
" WHERE CtrCod=%ld",
(unsigned) Status,
Ctr_EditingCtr->CtrCod);
Ctr_EditingCtr->Status = Status; Ctr_EditingCtr->Status = Status;
/***** Write message to show the change made /***** Write message to show the change made
@ -1590,7 +1585,7 @@ void Ctr_ReceiveFormReqCtr (void)
Ctr_EditingCenterConstructor (); Ctr_EditingCenterConstructor ();
/***** Receive form to request a new center *****/ /***** Receive form to request a new center *****/
Ctr_ReceiveFormRequestOrCreateCtr ((unsigned) Ctr_STATUS_BIT_PENDING); Ctr_ReceiveFormRequestOrCreateCtr ((Ctr_Status_t) Ctr_STATUS_BIT_PENDING);
} }
/*****************************************************************************/ /*****************************************************************************/
@ -1603,14 +1598,14 @@ void Ctr_ReceiveFormNewCtr (void)
Ctr_EditingCenterConstructor (); Ctr_EditingCenterConstructor ();
/***** Receive form to create a new center *****/ /***** Receive form to create a new center *****/
Ctr_ReceiveFormRequestOrCreateCtr (0); Ctr_ReceiveFormRequestOrCreateCtr ((Ctr_Status_t) 0);
} }
/*****************************************************************************/ /*****************************************************************************/
/************* Receive form to request or create a new center ****************/ /************* Receive form to request or create a new center ****************/
/*****************************************************************************/ /*****************************************************************************/
static void Ctr_ReceiveFormRequestOrCreateCtr (unsigned Status) static void Ctr_ReceiveFormRequestOrCreateCtr (Ctr_Status_t Status)
{ {
extern const char *Txt_The_center_X_already_exists; extern const char *Txt_The_center_X_already_exists;
extern const char *Txt_Created_new_center_X; extern const char *Txt_Created_new_center_X;
@ -1625,11 +1620,9 @@ static void Ctr_ReceiveFormRequestOrCreateCtr (unsigned Status)
if ((Ctr_EditingCtr->PlcCod = Plc_GetParamPlcCod ()) < 0) // 0 is reserved for "other place" if ((Ctr_EditingCtr->PlcCod = Plc_GetParamPlcCod ()) < 0) // 0 is reserved for "other place"
Ale_ShowAlert (Ale_ERROR,"Wrong place."); Ale_ShowAlert (Ale_ERROR,"Wrong place.");
/* Get center short name */ /* Get center short name and full name */
Par_GetParToText ("ShortName",Ctr_EditingCtr->ShrtName,Cns_HIERARCHY_MAX_BYTES_SHRT_NAME); Par_GetParToText ("ShortName",Ctr_EditingCtr->ShrtName,Cns_HIERARCHY_MAX_BYTES_SHRT_NAME);
Par_GetParToText ("FullName" ,Ctr_EditingCtr->FullName,Cns_HIERARCHY_MAX_BYTES_FULL_NAME);
/* Get center full name */
Par_GetParToText ("FullName",Ctr_EditingCtr->FullName,Cns_HIERARCHY_MAX_BYTES_FULL_NAME);
/* Get center WWW */ /* Get center WWW */
Par_GetParToText ("WWW",Ctr_EditingCtr->WWW,Cns_MAX_BYTES_WWW); Par_GetParToText ("WWW",Ctr_EditingCtr->WWW,Cns_MAX_BYTES_WWW);
@ -1708,14 +1701,7 @@ static unsigned Ctr_GetNumCtrsInCty (long CtyCod)
/***** 3. Slow: number of centers in a country from database *****/ /***** 3. Slow: number of centers in a country from database *****/
Gbl.Cache.NumCtrsInCty.CtyCod = CtyCod; Gbl.Cache.NumCtrsInCty.CtyCod = CtyCod;
Gbl.Cache.NumCtrsInCty.NumCtrs = (unsigned) Gbl.Cache.NumCtrsInCty.NumCtrs = Ctr_DB_GetNumCtrsInCty (CtyCod);
DB_QueryCOUNT ("can not get number of centers in a country",
"SELECT COUNT(*)"
" FROM ins_instits,"
"ctr_centers"
" WHERE ins_instits.CtyCod=%ld"
" AND ins_instits.InsCod=ctr_centers.InsCod",
CtyCod);
FigCch_UpdateFigureIntoCache (FigCch_NUM_CTRS,HieLvl_CTY,Gbl.Cache.NumCtrsInCty.CtyCod, FigCch_UpdateFigureIntoCache (FigCch_NUM_CTRS,HieLvl_CTY,Gbl.Cache.NumCtrsInCty.CtyCod,
FigCch_UNSIGNED,&Gbl.Cache.NumCtrsInCty.NumCtrs); FigCch_UNSIGNED,&Gbl.Cache.NumCtrsInCty.NumCtrs);
return Gbl.Cache.NumCtrsInCty.NumCtrs; return Gbl.Cache.NumCtrsInCty.NumCtrs;
@ -1756,12 +1742,7 @@ unsigned Ctr_GetNumCtrsInIns (long InsCod)
/***** 3. Slow: number of centers in an institution from database *****/ /***** 3. Slow: number of centers in an institution from database *****/
Gbl.Cache.NumCtrsInIns.InsCod = InsCod; Gbl.Cache.NumCtrsInIns.InsCod = InsCod;
Gbl.Cache.NumCtrsInIns.NumCtrs = (unsigned) Gbl.Cache.NumCtrsInIns.NumCtrs = Ctr_DB_GetNumCtrsInIns (InsCod);
DB_QueryCOUNT ("can not get number of centers in an institution",
"SELECT COUNT(*)"
" FROM ctr_centers"
" WHERE InsCod=%ld",
InsCod);
FigCch_UpdateFigureIntoCache (FigCch_NUM_CTRS,HieLvl_INS,Gbl.Cache.NumCtrsInIns.InsCod, FigCch_UpdateFigureIntoCache (FigCch_NUM_CTRS,HieLvl_INS,Gbl.Cache.NumCtrsInIns.InsCod,
FigCch_UNSIGNED,&Gbl.Cache.NumCtrsInIns.NumCtrs); FigCch_UNSIGNED,&Gbl.Cache.NumCtrsInIns.NumCtrs);
return Gbl.Cache.NumCtrsInIns.NumCtrs; return Gbl.Cache.NumCtrsInIns.NumCtrs;
@ -1794,12 +1775,7 @@ unsigned Ctr_GetCachedNumCtrsWithMapInSys (void)
{ {
/***** Get current number of centers with map from database and update cache *****/ /***** Get current number of centers with map from database and update cache *****/
/* Ccoordinates 0, 0 means not set ==> don't show map */ /* Ccoordinates 0, 0 means not set ==> don't show map */
NumCtrsWithMap = (unsigned) NumCtrsWithMap = (unsigned) Ctr_DB_GetNumCtrsWithMap ();
DB_QueryCOUNT ("can not get number of centers with map",
"SELECT COUNT(*)"
" FROM ctr_centers"
" WHERE Latitude<>0"
" OR Longitude<>0");
FigCch_UpdateFigureIntoCache (FigCch_NUM_CTRS_WITH_MAP,HieLvl_SYS,-1L, FigCch_UpdateFigureIntoCache (FigCch_NUM_CTRS_WITH_MAP,HieLvl_SYS,-1L,
FigCch_UNSIGNED,&NumCtrsWithMap); FigCch_UNSIGNED,&NumCtrsWithMap);
} }
@ -1821,16 +1797,7 @@ unsigned Ctr_GetCachedNumCtrsWithMapInCty (long CtyCod)
{ {
/***** Get current number of centers with map from database and update cache *****/ /***** Get current number of centers with map from database and update cache *****/
/* Ccoordinates 0, 0 means not set ==> don't show map */ /* Ccoordinates 0, 0 means not set ==> don't show map */
NumCtrsWithMap = (unsigned) NumCtrsWithMap = Ctr_DB_GetNumCtrsWithMapInCty (CtyCod);
DB_QueryCOUNT ("can not get number of centers with map",
"SELECT COUNT(*)"
" FROM ins_instits,"
"ctr_centers"
" WHERE ins_instits.CtyCod=%ld"
" AND ins_instits.InsCod=ctr_centers.InsCod"
" AND (ctr_centers.Latitude<>0"
" OR ctr_centers.Longitude<>0)",
CtyCod);
FigCch_UpdateFigureIntoCache (FigCch_NUM_CTRS_WITH_MAP,HieLvl_CTY,CtyCod, FigCch_UpdateFigureIntoCache (FigCch_NUM_CTRS_WITH_MAP,HieLvl_CTY,CtyCod,
FigCch_UNSIGNED,&NumCtrsWithMap); FigCch_UNSIGNED,&NumCtrsWithMap);
} }
@ -1852,14 +1819,7 @@ unsigned Ctr_GetCachedNumCtrsWithMapInIns (long InsCod)
{ {
/***** Get current number of centers with map from database and update cache *****/ /***** Get current number of centers with map from database and update cache *****/
/* Ccoordinates 0, 0 means not set ==> don't show map */ /* Ccoordinates 0, 0 means not set ==> don't show map */
NumCtrsWithMap = (unsigned) NumCtrsWithMap = Ctr_DB_GetNumCtrsWithMapInIns (InsCod);
DB_QueryCOUNT ("can not get number of centers with map",
"SELECT COUNT(*)"
" FROM ctr_centers"
" WHERE InsCod=%ld"
" AND (Latitude<>0"
" OR Longitude<>0)",
InsCod);
FigCch_UpdateFigureIntoCache (FigCch_NUM_CTRS_WITH_MAP,HieLvl_INS,InsCod, FigCch_UpdateFigureIntoCache (FigCch_NUM_CTRS_WITH_MAP,HieLvl_INS,InsCod,
FigCch_UNSIGNED,&NumCtrsWithMap); FigCch_UNSIGNED,&NumCtrsWithMap);
} }
@ -1881,15 +1841,7 @@ unsigned Ctr_GetCachedNumCtrsWithDegs (const char *SubQuery,
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 = (unsigned) NumCtrsWithDegs = Ctr_DB_GetNumCtrsWithDegs (SubQuery);
DB_QueryCOUNT ("can not get number of centers with degrees",
"SELECT COUNT(DISTINCT ctr_centers.CtrCod)"
" 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_CTRS_WITH_DEGS,Scope,Cod, FigCch_UpdateFigureIntoCache (FigCch_NUM_CTRS_WITH_DEGS,Scope,Cod,
FigCch_UNSIGNED,&NumCtrsWithDegs); FigCch_UNSIGNED,&NumCtrsWithDegs);
} }
@ -1911,17 +1863,7 @@ unsigned Ctr_GetCachedNumCtrsWithCrss (const char *SubQuery,
FigCch_UNSIGNED,&NumCtrsWithCrss)) FigCch_UNSIGNED,&NumCtrsWithCrss))
{ {
/***** Get number of centers with courses *****/ /***** Get number of centers with courses *****/
NumCtrsWithCrss = (unsigned) NumCtrsWithCrss = Ctr_DB_GetNumCtrsWithCrss (SubQuery);
DB_QueryCOUNT ("can not get number of centers with courses",
"SELECT COUNT(DISTINCT ctr_centers.CtrCod)"
" 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_CTRS_WITH_CRSS,Scope,Cod, FigCch_UpdateFigureIntoCache (FigCch_NUM_CTRS_WITH_CRSS,Scope,Cod,
FigCch_UNSIGNED,&NumCtrsWithCrss); FigCch_UNSIGNED,&NumCtrsWithCrss);
} }
@ -1949,21 +1891,7 @@ unsigned Ctr_GetCachedNumCtrsWithUsrs (Rol_Role_t Role,const char *SubQuery,
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 = (unsigned) NumCtrsWithUsrs = Ctr_DB_GetNumCtrsWithUsrs (Role,SubQuery);
DB_QueryCOUNT ("can not get number of centers with users",
"SELECT COUNT(DISTINCT ctr_centers.CtrCod)"
" FROM ins_instits,"
"ctr_centers,"
"deg_degrees,"
"crs_courses,"
"crs_users"
" WHERE %s"
"institutions.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 (FigureCtrs[Role],Scope,Cod, FigCch_UpdateFigureIntoCache (FigureCtrs[Role],Scope,Cod,
FigCch_UNSIGNED,&NumCtrsWithUsrs); FigCch_UNSIGNED,&NumCtrsWithUsrs);
} }

View File

@ -34,6 +34,7 @@
#include <unistd.h> // For unlink #include <unistd.h> // For unlink
#include "swad_center.h" #include "swad_center.h"
#include "swad_center_database.h"
#include "swad_database.h" #include "swad_database.h"
#include "swad_error.h" #include "swad_error.h"
#include "swad_figure_cache.h" #include "swad_figure_cache.h"

View File

@ -73,7 +73,7 @@ extern struct Globals Gbl;
/***************************** Create a new center ***************************/ /***************************** Create a new center ***************************/
/*****************************************************************************/ /*****************************************************************************/
long Ctr_DB_CreateCenter (const struct Ctr_Center *Ctr,unsigned Status) long Ctr_DB_CreateCenter (const struct Ctr_Center *Ctr,Ctr_Status_t Status)
{ {
return return
DB_QueryINSERTandReturnCode ("can not create a new center", DB_QueryINSERTandReturnCode ("can not create a new center",
@ -85,7 +85,7 @@ long Ctr_DB_CreateCenter (const struct Ctr_Center *Ctr,unsigned Status)
"'%s','%s','%s','')", "'%s','%s','%s','')",
Ctr->InsCod, Ctr->InsCod,
Ctr->PlcCod, Ctr->PlcCod,
Status, (unsigned) Status,
Gbl.Usrs.Me.UsrDat.UsrCod, Gbl.Usrs.Me.UsrDat.UsrCod,
Ctr->ShrtName, Ctr->ShrtName,
Ctr->FullName, Ctr->FullName,
@ -317,13 +317,42 @@ bool Ctr_DB_CheckIfCtrNameExistsInIns (const char *FieldName,const char *Name,
CtrCod) != 0); CtrCod) != 0);
} }
/*****************************************************************************/
/******************** Get number of centers in a country *********************/
/*****************************************************************************/
unsigned Ctr_DB_GetNumCtrsInCty (long CtyCod)
{
return (unsigned)
DB_QueryCOUNT ("can not get number of centers in a country",
"SELECT COUNT(*)"
" FROM ins_instits,"
"ctr_centers"
" WHERE ins_instits.CtyCod=%ld"
" AND ins_instits.InsCod=ctr_centers.InsCod",
CtyCod);
}
/*****************************************************************************/
/****************** Get number of centers in an institution ******************/
/*****************************************************************************/
unsigned Ctr_DB_GetNumCtrsInIns (long InsCod)
{
return (unsigned)
DB_QueryCOUNT ("can not get number of centers in an institution",
"SELECT COUNT(*)"
" FROM ctr_centers"
" WHERE InsCod=%ld",
InsCod);
}
/*****************************************************************************/ /*****************************************************************************/
/******* Get number of centers (of the current institution) in a place *******/ /******* Get number of centers (of the current institution) in a place *******/
/*****************************************************************************/ /*****************************************************************************/
unsigned Ctr_DB_GetNumCtrsInPlc (long PlcCod) unsigned Ctr_DB_GetNumCtrsInPlc (long PlcCod)
{ {
/***** Get number of centers (of the current institution) in a place *****/
return (unsigned) return (unsigned)
DB_QueryCOUNT ("can not get the number of centers in a place", DB_QueryCOUNT ("can not get the number of centers in a place",
"SELECT COUNT(*)" "SELECT COUNT(*)"
@ -334,6 +363,111 @@ unsigned Ctr_DB_GetNumCtrsInPlc (long PlcCod)
PlcCod); PlcCod);
} }
/*****************************************************************************/
/*********************** Get number of centers with map **********************/
/*****************************************************************************/
unsigned Ctr_DB_GetNumCtrsWithMap (void)
{
return (unsigned)
DB_QueryCOUNT ("can not get number of centers with map",
"SELECT COUNT(*)"
" FROM ctr_centers"
" WHERE Latitude<>0"
" OR Longitude<>0");
}
/*****************************************************************************/
/**************** Get number of centers with map in a country ****************/
/*****************************************************************************/
unsigned Ctr_DB_GetNumCtrsWithMapInCty (long CtyCod)
{
return (unsigned)
DB_QueryCOUNT ("can not get number of centers with map",
"SELECT COUNT(*)"
" FROM ins_instits,"
"ctr_centers"
" WHERE ins_instits.CtyCod=%ld"
" AND ins_instits.InsCod=ctr_centers.InsCod"
" AND (ctr_centers.Latitude<>0"
" OR ctr_centers.Longitude<>0)",
CtyCod);
}
/*****************************************************************************/
/************* Get number of centers with map in an institution **************/
/*****************************************************************************/
unsigned Ctr_DB_GetNumCtrsWithMapInIns (long InsCod)
{
return (unsigned)
DB_QueryCOUNT ("can not get number of centers with map",
"SELECT COUNT(*)"
" FROM ctr_centers"
" WHERE InsCod=%ld"
" AND (Latitude<>0"
" OR Longitude<>0)",
InsCod);
}
/*****************************************************************************/
/********************* Get number of centers with degrees ********************/
/*****************************************************************************/
unsigned Ctr_DB_GetNumCtrsWithDegs (const char *SubQuery)
{
return (unsigned)
DB_QueryCOUNT ("can not get number of centers with degrees",
"SELECT COUNT(DISTINCT ctr_centers.CtrCod)"
" FROM ins_instits,"
"ctr_centers,"
"deg_degrees"
" WHERE %sinstitutions.InsCod=ctr_centers.InsCod"
" AND ctr_centers.CtrCod=deg_degrees.CtrCod",
SubQuery);
}
/*****************************************************************************/
/********************* Get number of centers with courses ********************/
/*****************************************************************************/
unsigned Ctr_DB_GetNumCtrsWithCrss (const char *SubQuery)
{
return (unsigned)
DB_QueryCOUNT ("can not get number of centers with courses",
"SELECT COUNT(DISTINCT ctr_centers.CtrCod)"
" 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 centers with users **********************/
/*****************************************************************************/
unsigned Ctr_DB_GetNumCtrsWithUsrs (Rol_Role_t Role,const char *SubQuery)
{
return (unsigned)
DB_QueryCOUNT ("can not get number of centers with users",
"SELECT COUNT(DISTINCT ctr_centers.CtrCod)"
" FROM ins_instits,"
"ctr_centers,"
"deg_degrees,"
"crs_courses,"
"crs_users"
" WHERE %s"
"institutions.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);
}
/*****************************************************************************/ /*****************************************************************************/
/************** Update database changing old place by new place **************/ /************** Update database changing old place by new place **************/
/*****************************************************************************/ /*****************************************************************************/
@ -379,6 +513,20 @@ void Ctr_DB_UpdateCtrWWW (long CtrCod,const char NewWWW[Cns_MAX_BYTES_WWW + 1])
CtrCod); CtrCod);
} }
/*****************************************************************************/
/******************** Update status in table of centers **********************/
/*****************************************************************************/
void Ctr_DB_UpdateCtrStatus (long CtrCod,Ctr_Status_t Status)
{
DB_QueryUPDATE ("can not update the status of a center",
"UPDATE ctr_centers"
" SET Status=%u"
" WHERE CtrCod=%ld",
(unsigned) Status,
CtrCod);
}
/*****************************************************************************/ /*****************************************************************************/
/****************************** Remove a center ******************************/ /****************************** Remove a center ******************************/
/*****************************************************************************/ /*****************************************************************************/

View File

@ -44,7 +44,7 @@
/****************************** Public prototypes ****************************/ /****************************** Public prototypes ****************************/
/*****************************************************************************/ /*****************************************************************************/
long Ctr_DB_CreateCenter (const struct Ctr_Center *Ctr,unsigned Status); long Ctr_DB_CreateCenter (const struct Ctr_Center *Ctr,Ctr_Status_t Status);
unsigned Ctr_DB_GetListOfCtrsInCurrentIns (MYSQL_RES **mysql_res); unsigned Ctr_DB_GetListOfCtrsInCurrentIns (MYSQL_RES **mysql_res);
unsigned Ctr_DB_GetListOfCtrsFull (MYSQL_RES **mysql_res,long InsCod); unsigned Ctr_DB_GetListOfCtrsFull (MYSQL_RES **mysql_res,long InsCod);
@ -56,11 +56,20 @@ long Ctr_DB_GetInsCodOfCenterByCod (long CtrCod);
void Ctr_DB_GetShortNameOfCenterByCod (long CtrCod,char ShrtName[Cns_HIERARCHY_MAX_BYTES_SHRT_NAME + 1]); void Ctr_DB_GetShortNameOfCenterByCod (long CtrCod,char ShrtName[Cns_HIERARCHY_MAX_BYTES_SHRT_NAME + 1]);
bool Ctr_DB_CheckIfCtrNameExistsInIns (const char *FieldName,const char *Name, bool Ctr_DB_CheckIfCtrNameExistsInIns (const char *FieldName,const char *Name,
long CtrCod,long InsCod); long CtrCod,long InsCod);
unsigned Ctr_DB_GetNumCtrsInCty (long CtyCod);
unsigned Ctr_DB_GetNumCtrsInIns (long InsCod);
unsigned Ctr_DB_GetNumCtrsInPlc (long PlcCod); unsigned Ctr_DB_GetNumCtrsInPlc (long PlcCod);
unsigned Ctr_DB_GetNumCtrsWithMap (void);
unsigned Ctr_DB_GetNumCtrsWithMapInCty (long CtyCod);
unsigned Ctr_DB_GetNumCtrsWithMapInIns (long InsCod);
unsigned Ctr_DB_GetNumCtrsWithDegs (const char *SubQuery);
unsigned Ctr_DB_GetNumCtrsWithCrss (const char *SubQuery);
unsigned Ctr_DB_GetNumCtrsWithUsrs (Rol_Role_t Role,const char *SubQuery);
void Ctr_DB_UpdateCtrPlc (long CtrCod,long NewPlcCod); void Ctr_DB_UpdateCtrPlc (long CtrCod,long NewPlcCod);
void Ctr_DB_UpdateCtrName (long CtrCod,const char *FieldName,const char *NewCtrName); void Ctr_DB_UpdateCtrName (long CtrCod,const char *FieldName,const char *NewCtrName);
void Ctr_DB_UpdateCtrWWW (long CtrCod,const char NewWWW[Cns_MAX_BYTES_WWW + 1]); void Ctr_DB_UpdateCtrWWW (long CtrCod,const char NewWWW[Cns_MAX_BYTES_WWW + 1]);
void Ctr_DB_UpdateCtrStatus (long CtrCod,Ctr_Status_t Status);
void Ctr_DB_RemoveCenter (long CtrCod); void Ctr_DB_RemoveCenter (long CtrCod);

View File

@ -609,6 +609,8 @@ TODO: En las encuestas, que los estudiantes no puedan ver los resultados hasta q
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.88.2: Jun 02, 2021 Queries moved to module swad_center_database.
Fixed bug in visibility of exam results. Reported by Mancia Anguita López. (312738 lines)
Version 20.88.1: Jun 02, 2021 Queries moved to module swad_center_database. (312668 lines) Version 20.88.1: Jun 02, 2021 Queries moved to module swad_center_database. (312668 lines)
Version 20.88: Jun 02, 2021 New module swad_center_database for database queries related to centers. (312638 lines) Version 20.88: Jun 02, 2021 New module swad_center_database for database queries related to centers. (312638 lines)
Version 20.87.1: Jun 01, 2021 Database function moved from swad_calendar to swad_setting. (312549 lines) Version 20.87.1: Jun 01, 2021 Database function moved from swad_calendar to swad_setting. (312549 lines)

View File

@ -30,6 +30,7 @@
#include <string.h> // For string functions #include <string.h> // For string functions
#include "swad_box.h" #include "swad_box.h"
#include "swad_center_database.h"
#include "swad_constant.h" #include "swad_constant.h"
#include "swad_database.h" #include "swad_database.h"
#include "swad_error.h" #include "swad_error.h"

View File

@ -1430,8 +1430,7 @@ static void TstPrn_WriteIntAnsPrint (struct UsrData *UsrDat,
/***** Write the correct answer *****/ /***** Write the correct answer *****/
HTM_TD_Begin ("class=\"ANS_0 CM\""); HTM_TD_Begin ("class=\"ANS_0 CM\"");
if (ICanView[TstVis_VISIBLE_QST_ANS_TXT] && if (ICanView[TstVis_VISIBLE_CORRECT_ANSWER])
ICanView[TstVis_VISIBLE_CORRECT_ANSWER])
HTM_Long (Question->Answer.Integer); HTM_Long (Question->Answer.Integer);
else else
Ico_PutIconNotVisible (); Ico_PutIconNotVisible ();
@ -1486,8 +1485,7 @@ static void TstPrn_WriteFltAnsPrint (struct UsrData *UsrDat,
/***** Write the correct answer *****/ /***** Write the correct answer *****/
HTM_TD_Begin ("class=\"ANS_0 CM\""); HTM_TD_Begin ("class=\"ANS_0 CM\"");
if (ICanView[TstVis_VISIBLE_QST_ANS_TXT] && if (ICanView[TstVis_VISIBLE_CORRECT_ANSWER])
ICanView[TstVis_VISIBLE_CORRECT_ANSWER])
{ {
HTM_Txt ("["); HTM_Txt ("[");
HTM_Double (Question->Answer.FloatingPoint[0]); HTM_Double (Question->Answer.FloatingPoint[0]);
@ -1542,8 +1540,7 @@ static void TstPrn_WriteTF_AnsPrint (struct UsrData *UsrDat,
/***** Write the correct answer *****/ /***** Write the correct answer *****/
HTM_TD_Begin ("class=\"ANS_0 CM\""); HTM_TD_Begin ("class=\"ANS_0 CM\"");
if (ICanView[TstVis_VISIBLE_QST_ANS_TXT] && if (ICanView[TstVis_VISIBLE_CORRECT_ANSWER])
ICanView[TstVis_VISIBLE_CORRECT_ANSWER])
Tst_WriteAnsTF (Question->Answer.TF); Tst_WriteAnsTF (Question->Answer.TF);
else else
Ico_PutIconNotVisible (); Ico_PutIconNotVisible ();
@ -1760,8 +1757,7 @@ static void TstPrn_WriteTxtAnsPrint (struct UsrData *UsrDat,
HTM_TD_End (); HTM_TD_End ();
/***** Write the correct answers *****/ /***** Write the correct answers *****/
if (ICanView[TstVis_VISIBLE_QST_ANS_TXT] && if (ICanView[TstVis_VISIBLE_CORRECT_ANSWER])
ICanView[TstVis_VISIBLE_CORRECT_ANSWER])
{ {
HTM_TD_Begin ("class=\"CT\""); HTM_TD_Begin ("class=\"CT\"");
HTM_TABLE_BeginPadding (2); HTM_TABLE_BeginPadding (2);