Version 18.11.25

This commit is contained in:
Antonio Cañas Vargas 2018-11-03 13:13:11 +01:00
parent 358eb7e95e
commit 8c11d2551e
12 changed files with 305 additions and 236 deletions

View File

@ -630,10 +630,11 @@ static bool Acc_GetParamsNewAccount (char NewNicknameWithoutArroba[Nck_MAX_BYTES
{
/* Check if the new nickname
matches any of the nicknames of other users */
DB_BuildQuery ("SELECT COUNT(*) FROM usr_nicknames"
" WHERE Nickname='%s' AND UsrCod<>%ld",
NewNicknameWithoutArroba,Gbl.Usrs.Me.UsrDat.UsrCod);
if (DB_QueryCOUNT_new ("can not check if nickname already existed")) // A nickname of another user is the same that this nickname
if (DB_QueryCOUNT ("can not check if nickname already existed",
"SELECT COUNT(*) FROM usr_nicknames"
" WHERE Nickname='%s' AND UsrCod<>%ld",
NewNicknameWithoutArroba,
Gbl.Usrs.Me.UsrDat.UsrCod)) // A nickname of another user is the same that this nickname
{
Error = true;
snprintf (Gbl.Alert.Txt,sizeof (Gbl.Alert.Txt),
@ -660,10 +661,10 @@ static bool Acc_GetParamsNewAccount (char NewNicknameWithoutArroba[Nck_MAX_BYTES
{
/* Check if the new email matches
any of the confirmed emails of other users */
DB_BuildQuery ("SELECT COUNT(*) FROM usr_emails"
" WHERE E_mail='%s' AND Confirmed='Y'",
NewEmail);
if (DB_QueryCOUNT_new ("can not check if email already existed")) // An email of another user is the same that my email
if (DB_QueryCOUNT ("can not check if email already existed",
"SELECT COUNT(*) FROM usr_emails"
" WHERE E_mail='%s' AND Confirmed='Y'",
NewEmail)) // An email of another user is the same that my email
{
Error = true;
snprintf (Gbl.Alert.Txt,sizeof (Gbl.Alert.Txt),

View File

@ -1763,8 +1763,10 @@ void Agd_RemoveUsrEvents (long UsrCod)
unsigned Agd_GetNumEventsFromUsr (long UsrCod)
{
/***** Get number of events in a course from database *****/
DB_BuildQuery ("SELECT COUNT(*) FROM agendas WHERE UsrCod=%ld",UsrCod);
return (unsigned) DB_QueryCOUNT_new ("can not get number of events from user");
return (unsigned) DB_QueryCOUNT ("can not get number of events from user",
"SELECT COUNT(*) FROM agendas"
" WHERE UsrCod=%ld",
UsrCod);
}
/*****************************************************************************/

View File

@ -1114,10 +1114,12 @@ void Asg_ShowAssignment (void)
static bool Asg_CheckIfSimilarAssignmentExists (const char *Field,const char *Value,long AsgCod)
{
/***** Get number of assignments with a field value from database *****/
DB_BuildQuery ("SELECT COUNT(*) FROM assignments"
" WHERE CrsCod=%ld AND %s='%s' AND AsgCod<>%ld",
Gbl.CurrentCrs.Crs.CrsCod,Field,Value,AsgCod);
return (DB_QueryCOUNT_new ("can not get similar assignments") != 0);
return (DB_QueryCOUNT ("can not get similar assignments",
"SELECT COUNT(*) FROM assignments"
" WHERE CrsCod=%ld"
" AND %s='%s' AND AsgCod<>%ld",
Gbl.CurrentCrs.Crs.CrsCod,
Field,Value,AsgCod) != 0);
}
/*****************************************************************************/
@ -1552,8 +1554,10 @@ static void Asg_UpdateAssignment (struct Assignment *Asg,const char *Txt)
static bool Asg_CheckIfAsgIsAssociatedToGrps (long AsgCod)
{
/***** Get if an assignment is associated to a group from database *****/
DB_BuildQuery ("SELECT COUNT(*) FROM asg_grp WHERE AsgCod=%ld",AsgCod);
return (DB_QueryCOUNT_new ("can not check if an assignment is associated to groups") != 0);
return (DB_QueryCOUNT ("can not check if an assignment"
" is associated to groups",
"SELECT COUNT(*) FROM asg_grp WHERE AsgCod=%ld",
AsgCod) != 0);
}
/*****************************************************************************/
@ -1563,10 +1567,11 @@ static bool Asg_CheckIfAsgIsAssociatedToGrps (long AsgCod)
bool Asg_CheckIfAsgIsAssociatedToGrp (long AsgCod,long GrpCod)
{
/***** Get if an assignment is associated to a group from database *****/
DB_BuildQuery ("SELECT COUNT(*) FROM asg_grp"
" WHERE AsgCod=%ld AND GrpCod=%ld",
AsgCod,GrpCod);
return (DB_QueryCOUNT_new ("can not check if an assignment is associated to a group") != 0);
return (DB_QueryCOUNT ("can not check if an assignment"
" is associated to a group",
"SELECT COUNT(*) FROM asg_grp"
" WHERE AsgCod=%ld AND GrpCod=%ld",
AsgCod,GrpCod) != 0);
}
/*****************************************************************************/
@ -1730,19 +1735,21 @@ static bool Asg_CheckIfIBelongToCrsOrGrpsThisAssignment (long AsgCod)
case Rol_TCH:
// Students and teachers can do assignments depending on groups
/***** Get if I can do an assignment from database *****/
DB_BuildQuery ("SELECT COUNT(*) FROM assignments"
" WHERE AsgCod=%ld"
" AND "
"("
"AsgCod NOT IN (SELECT AsgCod FROM asg_grp)" // Assignment is for the whole course
" OR "
"AsgCod IN" // Assignment is for specific groups
" (SELECT asg_grp.AsgCod FROM asg_grp,crs_grp_usr"
" WHERE crs_grp_usr.UsrCod=%ld"
" AND asg_grp.GrpCod=crs_grp_usr.GrpCod)"
")",
AsgCod,Gbl.Usrs.Me.UsrDat.UsrCod);
return (DB_QueryCOUNT_new ("can not check if I can do an assignment") != 0);
return (DB_QueryCOUNT ("can not check if I can do an assignment",
"SELECT COUNT(*) FROM assignments"
" WHERE AsgCod=%ld"
" AND "
"("
// Assignment is for the whole course
"AsgCod NOT IN (SELECT AsgCod FROM asg_grp)"
" OR "
// Assignment is for specific groups
"AsgCod IN"
" (SELECT asg_grp.AsgCod FROM asg_grp,crs_grp_usr"
" WHERE crs_grp_usr.UsrCod=%ld"
" AND asg_grp.GrpCod=crs_grp_usr.GrpCod)"
")",
AsgCod,Gbl.Usrs.Me.UsrDat.UsrCod) != 0);
case Rol_DEG_ADM:
case Rol_CTR_ADM:
case Rol_INS_ADM:
@ -1761,8 +1768,11 @@ static bool Asg_CheckIfIBelongToCrsOrGrpsThisAssignment (long AsgCod)
unsigned Asg_GetNumAssignmentsInCrs (long CrsCod)
{
/***** Get number of assignments in a course from database *****/
DB_BuildQuery ("SELECT COUNT(*) FROM assignments WHERE CrsCod=%ld",CrsCod);
return (unsigned) DB_QueryCOUNT_new ("can not get number of assignments in course");
return
(unsigned) DB_QueryCOUNT ("can not get number of assignments in course",
"SELECT COUNT(*) FROM assignments"
" WHERE CrsCod=%ld",
CrsCod);
}
/*****************************************************************************/

View File

@ -1032,11 +1032,14 @@ void Att_ShowAttEvent (void)
static bool Att_CheckIfSimilarAttEventExists (const char *Field,const char *Value,long AttCod)
{
/***** Get number of attendance events with a field value from database *****/
DB_BuildQuery ("SELECT COUNT(*) FROM att_events"
" WHERE CrsCod=%ld AND %s='%s' AND AttCod<>%ld",
Gbl.CurrentCrs.Crs.CrsCod,Field,Value,AttCod);
return (DB_QueryCOUNT_new ("can not get similar attendance events") != 0);
/***** Get number of attendance events
with a field value from database *****/
return (DB_QueryCOUNT ("can not get similar attendance events",
"SELECT COUNT(*) FROM att_events"
" WHERE CrsCod=%ld"
" AND %s='%s' AND AttCod<>%ld",
Gbl.CurrentCrs.Crs.CrsCod,
Field,Value,AttCod) != 0);
}
/*****************************************************************************/
@ -1419,8 +1422,10 @@ void Att_UpdateAttEvent (struct AttendanceEvent *Att,const char *Txt)
bool Att_CheckIfAttEventIsAssociatedToGrps (long AttCod)
{
/***** Get if an attendance event is associated to a group from database *****/
DB_BuildQuery ("SELECT COUNT(*) FROM att_grp WHERE AttCod=%ld",AttCod);
return (DB_QueryCOUNT_new ("can not check if an attendance event is associated to groups") != 0);
return (DB_QueryCOUNT ("can not check if an attendance event"
" is associated to groups",
"SELECT COUNT(*) FROM att_grp WHERE AttCod=%ld",
AttCod) != 0);
}
/*****************************************************************************/
@ -1430,10 +1435,11 @@ bool Att_CheckIfAttEventIsAssociatedToGrps (long AttCod)
bool Att_CheckIfAttEventIsAssociatedToGrp (long AttCod,long GrpCod)
{
/***** Get if an attendance event is associated to a group from database *****/
DB_BuildQuery ("SELECT COUNT(*) FROM att_grp"
" WHERE AttCod=%ld AND GrpCod=%ld",
AttCod,GrpCod);
return (DB_QueryCOUNT_new ("can not check if an attendance event is associated to a group") != 0);
return (DB_QueryCOUNT ("can not check if an attendance event"
" is associated to a group",
"SELECT COUNT(*) FROM att_grp"
" WHERE AttCod=%ld AND GrpCod=%ld",
AttCod,GrpCod) != 0);
}
/*****************************************************************************/
@ -1650,8 +1656,12 @@ void Att_RemoveCrsAttEvents (long CrsCod)
unsigned Att_GetNumAttEventsInCrs (long CrsCod)
{
/***** Get number of attendance events in a course from database *****/
DB_BuildQuery ("SELECT COUNT(*) FROM att_events WHERE CrsCod=%ld",CrsCod);
return (unsigned) DB_QueryCOUNT_new ("can not get number of attendance events in course");
return
(unsigned) DB_QueryCOUNT ("can not get number of attendance events"
" in course",
"SELECT COUNT(*) FROM att_events"
" WHERE CrsCod=%ld",
CrsCod);
}
/*****************************************************************************/
@ -2425,10 +2435,12 @@ void Att_RegisterStudentsInAttEvent (void)
static void Att_GetNumStdsTotalWhoAreInAttEvent (struct AttendanceEvent *Att)
{
/***** Count number of students registered in an event in database *****/
DB_BuildQuery ("SELECT COUNT(*) FROM att_usr"
" WHERE AttCod=%ld AND Present='Y'",
Att->AttCod);
Att->NumStdsTotal = (unsigned) DB_QueryCOUNT_new ("can not get number of students who are registered in an event");
Att->NumStdsTotal =
(unsigned) DB_QueryCOUNT ("can not get number of students"
" who are registered in an event",
"SELECT COUNT(*) FROM att_usr"
" WHERE AttCod=%ld AND Present='Y'",
Att->AttCod);
}
/*****************************************************************************/

View File

@ -709,10 +709,11 @@ static void Ban_RenameBanner (Cns_ShrtOrFullName_t ShrtOrFullName)
static bool Ban_CheckIfBannerNameExists (const char *FieldName,const char *Name,long BanCod)
{
/***** Get number of banners with a name from database *****/
DB_BuildQuery ("SELECT COUNT(*) FROM banners"
" WHERE %s='%s' AND BanCod<>%ld",
FieldName,Name,BanCod);
return (DB_QueryCOUNT_new ("can not check if the name of a banner already existed") != 0);
return (DB_QueryCOUNT ("can not check if the name of a banner"
" already existed",
"SELECT COUNT(*) FROM banners"
" WHERE %s='%s' AND BanCod<>%ld",
FieldName,Name,BanCod) != 0);
}
/*****************************************************************************/

View File

@ -2066,10 +2066,11 @@ static void Ctr_RenameCentre (struct Centre *Ctr,Cns_ShrtOrFullName_t ShrtOrFull
static bool Ctr_CheckIfCtrNameExistsInIns (const char *FieldName,const char *Name,long CtrCod,long InsCod)
{
/***** Get number of centres with a name from database *****/
DB_BuildQuery ("SELECT COUNT(*) FROM centres"
" WHERE InsCod=%ld AND %s='%s' AND CtrCod<>%ld",
InsCod,FieldName,Name,CtrCod);
return (DB_QueryCOUNT_new ("can not check if the name of a centre already existed") != 0);
return (DB_QueryCOUNT ("can not check if the name of a centre"
" already existed",
"SELECT COUNT(*) FROM centres"
" WHERE InsCod=%ld AND %s='%s' AND CtrCod<>%ld",
InsCod,FieldName,Name,CtrCod) != 0);
}
/*****************************************************************************/
@ -2849,8 +2850,8 @@ static void Ctr_CreateCentre (unsigned Status)
unsigned Ctr_GetNumCtrsTotal (void)
{
/***** Get total number of centres from database *****/
DB_BuildQuery ("SELECT COUNT(*) FROM centres");
return (unsigned) DB_QueryCOUNT_new ("can not get total number of centres");
return (unsigned) DB_QueryCOUNT ("can not get total number of centres",
"SELECT COUNT(*) FROM centres");
}
/*****************************************************************************/
@ -2860,11 +2861,12 @@ unsigned Ctr_GetNumCtrsTotal (void)
unsigned Ctr_GetNumCtrsInCty (long CtyCod)
{
/***** Get number of centres of a country from database *****/
DB_BuildQuery ("SELECT COUNT(*) FROM institutions,centres"
" WHERE institutions.CtyCod=%ld"
" AND institutions.InsCod=centres.InsCod",
CtyCod);
return (unsigned) DB_QueryCOUNT_new ("can not get number of centres in a country");
return
(unsigned) DB_QueryCOUNT ("can not get number of centres in a country",
"SELECT COUNT(*) FROM institutions,centres"
" WHERE institutions.CtyCod=%ld"
" AND institutions.InsCod=centres.InsCod",
CtyCod);
}
/*****************************************************************************/
@ -2874,8 +2876,11 @@ unsigned Ctr_GetNumCtrsInCty (long CtyCod)
unsigned Ctr_GetNumCtrsInIns (long InsCod)
{
/***** Get number of centres of an institution from database *****/
DB_BuildQuery ("SELECT COUNT(*) FROM centres WHERE InsCod=%ld",InsCod);
return (unsigned) DB_QueryCOUNT_new ("can not get number of centres in an institution");
return
(unsigned) DB_QueryCOUNT ("can not get number of centres in an institution",
"SELECT COUNT(*) FROM centres"
" WHERE InsCod=%ld",
InsCod);
}
/*****************************************************************************/
@ -2885,10 +2890,11 @@ unsigned Ctr_GetNumCtrsInIns (long InsCod)
unsigned Ctr_GetNumCtrsInPlc (long PlcCod)
{
/***** Get number of centres (of the current institution) in a place *****/
DB_BuildQuery ("SELECT COUNT(*) FROM centres"
" WHERE InsCod=%ld AND PlcCod=%ld",
Gbl.CurrentIns.Ins.InsCod,PlcCod);
return (unsigned) DB_QueryCOUNT_new ("can not get the number of centres in a place");
return
(unsigned) DB_QueryCOUNT ("can not get the number of centres in a place",
"SELECT COUNT(*) FROM centres"
" WHERE InsCod=%ld AND PlcCod=%ld",
Gbl.CurrentIns.Ins.InsCod,PlcCod);
}
/*****************************************************************************/
@ -2898,12 +2904,13 @@ unsigned Ctr_GetNumCtrsInPlc (long PlcCod)
unsigned Ctr_GetNumCtrsWithDegs (const char *SubQuery)
{
/***** Get number of centres with degrees from database *****/
DB_BuildQuery ("SELECT COUNT(DISTINCT centres.CtrCod)"
" FROM institutions,centres,degrees"
" WHERE %sinstitutions.InsCod=centres.InsCod"
" AND centres.CtrCod=degrees.CtrCod",
SubQuery);
return (unsigned) DB_QueryCOUNT_new ("can not get number of centres with degrees");
return
(unsigned) DB_QueryCOUNT ("can not get number of centres with degrees",
"SELECT COUNT(DISTINCT centres.CtrCod)"
" FROM institutions,centres,degrees"
" WHERE %sinstitutions.InsCod=centres.InsCod"
" AND centres.CtrCod=degrees.CtrCod",
SubQuery);
}
/*****************************************************************************/
@ -2913,13 +2920,14 @@ unsigned Ctr_GetNumCtrsWithDegs (const char *SubQuery)
unsigned Ctr_GetNumCtrsWithCrss (const char *SubQuery)
{
/***** Get number of centres with courses from database *****/
DB_BuildQuery ("SELECT COUNT(DISTINCT centres.CtrCod)"
" FROM institutions,centres,degrees,courses"
" WHERE %sinstitutions.InsCod=centres.InsCod"
" AND centres.CtrCod=degrees.CtrCod"
" AND degrees.DegCod=courses.DegCod",
SubQuery);
return (unsigned) DB_QueryCOUNT_new ("can not get number of centres with courses");
return
(unsigned) DB_QueryCOUNT ("can not get number of centres with courses",
"SELECT COUNT(DISTINCT centres.CtrCod)"
" FROM institutions,centres,degrees,courses"
" WHERE %sinstitutions.InsCod=centres.InsCod"
" AND centres.CtrCod=degrees.CtrCod"
" AND degrees.DegCod=courses.DegCod",
SubQuery);
}
/*****************************************************************************/
@ -2929,15 +2937,16 @@ unsigned Ctr_GetNumCtrsWithCrss (const char *SubQuery)
unsigned Ctr_GetNumCtrsWithUsrs (Rol_Role_t Role,const char *SubQuery)
{
/***** Get number of centres with users from database *****/
DB_BuildQuery ("SELECT COUNT(DISTINCT centres.CtrCod)"
" FROM institutions,centres,degrees,courses,crs_usr"
" WHERE %sinstitutions.InsCod=centres.InsCod"
" AND centres.CtrCod=degrees.CtrCod"
" AND degrees.DegCod=courses.DegCod"
" AND courses.CrsCod=crs_usr.CrsCod"
" AND crs_usr.Role=%u",
SubQuery,(unsigned) Role);
return (unsigned) DB_QueryCOUNT_new ("can not get number of centres with users");
return
(unsigned) DB_QueryCOUNT ("can not get number of centres with users",
"SELECT COUNT(DISTINCT centres.CtrCod)"
" FROM institutions,centres,degrees,courses,crs_usr"
" WHERE %sinstitutions.InsCod=centres.InsCod"
" AND centres.CtrCod=degrees.CtrCod"
" AND degrees.DegCod=courses.DegCod"
" AND courses.CrsCod=crs_usr.CrsCod"
" AND crs_usr.Role=%u",
SubQuery,(unsigned) Role);
}
/*****************************************************************************/

View File

@ -355,10 +355,11 @@ En OpenSWAD:
ps2pdf source.ps destination.pdf
*/
#define Log_PLATFORM_VERSION "SWAD 18.11.24 (2018-11-03)"
#define Log_PLATFORM_VERSION "SWAD 18.11.25 (2018-11-03)"
#define CSS_FILE "swad18.4.css"
#define JS_FILE "swad17.17.1.js"
/*
Version 18.11.25: Nov 03, 2018 Joining building and performing query into one function. (236705 lines)
Version 18.11.24: Nov 03, 2018 Joining building and performing query into one function. (236636 lines)
Version 18.11.23: Nov 03, 2018 Joining building and performing query into one function. (236630 lines)
Version 18.11.22: Nov 02, 2018 Joining building and performing query into one function. (236589 lines)

View File

@ -674,9 +674,11 @@ static unsigned Con_GetConnectedUsrsTotal (Rol_Role_t Role)
return 0;
/***** Get number of connected users with a role from database *****/
DB_BuildQuery ("SELECT COUNT(*) FROM connected WHERE RoleInLastCrs=%u",
(unsigned) Role);
return (unsigned) DB_QueryCOUNT_new ("can not get number of connected users");
return
(unsigned) DB_QueryCOUNT ("can not get number of connected users",
"SELECT COUNT(*) FROM connected"
" WHERE RoleInLastCrs=%u",
(unsigned) Role);
}
/*****************************************************************************/

View File

@ -781,10 +781,12 @@ static void Cty_PutIconToEditCountries (void)
static unsigned Cty_GetNumUsrsWhoClaimToBelongToCty (long CtyCod)
{
/***** Get number of users from database *****/
DB_BuildQuery ("SELECT COUNT(*) FROM usr_data WHERE CtyCod=%ld",CtyCod);
return (unsigned) DB_QueryCOUNT_new ("can not get number of users"
" who claim to belong"
" to other countries");
return
(unsigned) DB_QueryCOUNT ("can not get number of users"
" who claim to belong to other countries",
"SELECT COUNT(*) FROM usr_data"
" WHERE CtyCod=%ld",
CtyCod);
}
/*****************************************************************************/
@ -1828,9 +1830,11 @@ void Cty_RenameCountry (void)
static bool Cty_CheckIfNumericCountryCodeExists (long CtyCod)
{
/***** Get number of countries with a name from database *****/
DB_BuildQuery ("SELECT COUNT(*) FROM countries WHERE CtyCod='%03ld'",CtyCod);
return (DB_QueryCOUNT_new ("can not check if the numeric code"
" of a country already existed") != 0);
return (DB_QueryCOUNT ("can not check if the numeric code"
" of a country already existed",
"SELECT COUNT(*) FROM countries"
" WHERE CtyCod='%03ld'",
CtyCod) != 0);
}
/*****************************************************************************/
@ -1840,9 +1844,11 @@ static bool Cty_CheckIfNumericCountryCodeExists (long CtyCod)
static bool Cty_CheckIfAlpha2CountryCodeExists (const char Alpha2[2 + 1])
{
/***** Get number of countries with a name from database *****/
DB_BuildQuery ("SELECT COUNT(*) FROM countries WHERE Alpha2='%s'",Alpha2);
return (DB_QueryCOUNT_new ("can not check if the alphabetic code"
" of a country already existed") != 0);
return (DB_QueryCOUNT ("can not check if the alphabetic code"
" of a country already existed",
"SELECT COUNT(*) FROM countries"
" WHERE Alpha2='%s'",
Alpha2) != 0);
}
/*****************************************************************************/
@ -1854,11 +1860,11 @@ static bool Cty_CheckIfCountryNameExists (Txt_Language_t Language,const char *Na
extern const char *Txt_STR_LANG_ID[1 + Txt_NUM_LANGUAGES];
/***** Get number of countries with a name from database *****/
DB_BuildQuery ("SELECT COUNT(*) FROM countries"
" WHERE Name_%s='%s' AND CtyCod<>'%03ld'",
Txt_STR_LANG_ID[Language],Name,CtyCod);
return (DB_QueryCOUNT_new ("can not check if the name"
" of a country already existed") != 0);
return (DB_QueryCOUNT ("can not check if the name"
" of a country already existed",
"SELECT COUNT(*) FROM countries"
" WHERE Name_%s='%s' AND CtyCod<>'%03ld'",
Txt_STR_LANG_ID[Language],Name,CtyCod) != 0);
}
/*****************************************************************************/
@ -2277,9 +2283,10 @@ static void Cty_CreateCountry (struct Country *Cty)
unsigned Cty_GetNumCtysTotal (void)
{
/***** Get total number of degrees from database *****/
DB_BuildQuery ("SELECT COUNT(*) FROM countries");
return (unsigned) DB_QueryCOUNT_new ("can not get the total number of countries");
/***** Get total number of countries from database *****/
return
(unsigned) DB_QueryCOUNT ("can not get the total number of countries",
"SELECT COUNT(*) FROM countries");
}
/*****************************************************************************/
@ -2289,11 +2296,13 @@ unsigned Cty_GetNumCtysTotal (void)
unsigned Cty_GetNumCtysWithInss (const char *SubQuery)
{
/***** Get number of countries with institutions from database *****/
DB_BuildQuery ("SELECT COUNT(DISTINCT countries.CtyCod)"
" FROM countries,institutions"
" WHERE %scountries.CtyCod=institutions.CtyCod",
SubQuery);
return (unsigned) DB_QueryCOUNT_new ("can not get number of countries with institutions");
return
(unsigned) DB_QueryCOUNT ("can not get number of countries"
" with institutions",
"SELECT COUNT(DISTINCT countries.CtyCod)"
" FROM countries,institutions"
" WHERE %scountries.CtyCod=institutions.CtyCod",
SubQuery);
}
/*****************************************************************************/
@ -2303,12 +2312,13 @@ unsigned Cty_GetNumCtysWithInss (const char *SubQuery)
unsigned Cty_GetNumCtysWithCtrs (const char *SubQuery)
{
/***** Get number of countries with centres from database *****/
DB_BuildQuery ("SELECT COUNT(DISTINCT countries.CtyCod)"
" FROM countries,institutions,centres"
" WHERE %scountries.CtyCod=institutions.CtyCod"
" AND institutions.InsCod=centres.InsCod",
SubQuery);
return (unsigned) DB_QueryCOUNT_new ("can not get number of countries with centres");
return
(unsigned) DB_QueryCOUNT ("can not get number of countries with centres",
"SELECT COUNT(DISTINCT countries.CtyCod)"
" FROM countries,institutions,centres"
" WHERE %scountries.CtyCod=institutions.CtyCod"
" AND institutions.InsCod=centres.InsCod",
SubQuery);
}
/*****************************************************************************/
@ -2318,13 +2328,14 @@ unsigned Cty_GetNumCtysWithCtrs (const char *SubQuery)
unsigned Cty_GetNumCtysWithDegs (const char *SubQuery)
{
/***** Get number of countries with degrees from database *****/
DB_BuildQuery ("SELECT COUNT(DISTINCT countries.CtyCod)"
" FROM countries,institutions,centres,degrees"
" WHERE %scountries.CtyCod=institutions.CtyCod"
" AND institutions.InsCod=centres.InsCod"
" AND centres.CtrCod=degrees.CtrCod",
SubQuery);
return (unsigned) DB_QueryCOUNT_new ("can not get number of countries with degrees");
return
(unsigned) DB_QueryCOUNT ("can not get number of countries with degrees",
"SELECT COUNT(DISTINCT countries.CtyCod)"
" FROM countries,institutions,centres,degrees"
" WHERE %scountries.CtyCod=institutions.CtyCod"
" AND institutions.InsCod=centres.InsCod"
" AND centres.CtrCod=degrees.CtrCod",
SubQuery);
}
/*****************************************************************************/
@ -2334,14 +2345,15 @@ unsigned Cty_GetNumCtysWithDegs (const char *SubQuery)
unsigned Cty_GetNumCtysWithCrss (const char *SubQuery)
{
/***** Get number of countries with courses from database *****/
DB_BuildQuery ("SELECT COUNT(DISTINCT countries.CtyCod)"
" FROM countries,institutions,centres,degrees,courses"
" WHERE %scountries.CtyCod=institutions.CtyCod"
" AND institutions.InsCod=centres.InsCod"
" AND centres.CtrCod=degrees.CtrCod"
" AND degrees.DegCod=courses.DegCod",
SubQuery);
return (unsigned) DB_QueryCOUNT_new ("can not get number of countries with courses");
return
(unsigned) DB_QueryCOUNT ("can not get number of countries with courses",
"SELECT COUNT(DISTINCT countries.CtyCod)"
" FROM countries,institutions,centres,degrees,courses"
" WHERE %scountries.CtyCod=institutions.CtyCod"
" AND institutions.InsCod=centres.InsCod"
" AND centres.CtrCod=degrees.CtrCod"
" AND degrees.DegCod=courses.DegCod",
SubQuery);
}
/*****************************************************************************/
@ -2351,16 +2363,17 @@ unsigned Cty_GetNumCtysWithCrss (const char *SubQuery)
unsigned Cty_GetNumCtysWithUsrs (Rol_Role_t Role,const char *SubQuery)
{
/***** Get number of countries with users from database *****/
DB_BuildQuery ("SELECT COUNT(DISTINCT countries.CtyCod)"
" FROM countries,institutions,centres,degrees,courses,crs_usr"
" WHERE %scountries.CtyCod=institutions.CtyCod"
" AND institutions.InsCod=centres.InsCod"
" AND centres.CtrCod=degrees.CtrCod"
" AND degrees.DegCod=courses.DegCod"
" AND courses.CrsCod=crs_usr.CrsCod"
" AND crs_usr.Role=%u",
SubQuery,(unsigned) Role);
return (unsigned) DB_QueryCOUNT_new ("can not get number of countries with users");
return
(unsigned) DB_QueryCOUNT ("can not get number of countries with users",
"SELECT COUNT(DISTINCT countries.CtyCod)"
" FROM countries,institutions,centres,degrees,courses,crs_usr"
" WHERE %scountries.CtyCod=institutions.CtyCod"
" AND institutions.InsCod=centres.InsCod"
" AND centres.CtrCod=degrees.CtrCod"
" AND degrees.DegCod=courses.DegCod"
" AND courses.CrsCod=crs_usr.CrsCod"
" AND crs_usr.Role=%u",
SubQuery,(unsigned) Role);
}
/*****************************************************************************/

View File

@ -794,8 +794,8 @@ static void Crs_WriteListMyCoursesToSelectOne (void)
unsigned Crs_GetNumCrssTotal (void)
{
/***** Get total number of courses from database *****/
DB_BuildQuery ("SELECT COUNT(*) FROM courses");
return (unsigned) DB_QueryCOUNT_new ("can not get the total number of courses");
return (unsigned) DB_QueryCOUNT ("can not get the total number of courses",
"SELECT COUNT(*) FROM courses");
}
/*****************************************************************************/
@ -805,13 +805,15 @@ unsigned Crs_GetNumCrssTotal (void)
unsigned Crs_GetNumCrssInCty (long CtyCod)
{
/***** Get number of courses in a country from database *****/
DB_BuildQuery ("SELECT COUNT(*) FROM institutions,centres,degrees,courses"
" WHERE institutions.CtyCod=%ld"
" AND institutions.InsCod=centres.InsCod"
" AND centres.CtrCod=degrees.CtrCod"
" AND degrees.DegCod=courses.DegCod",
CtyCod);
return (unsigned) DB_QueryCOUNT_new ("can not get the number of courses in a country");
return
(unsigned) DB_QueryCOUNT ("can not get the number of courses in a country",
"SELECT COUNT(*)"
" FROM institutions,centres,degrees,courses"
" WHERE institutions.CtyCod=%ld"
" AND institutions.InsCod=centres.InsCod"
" AND centres.CtrCod=degrees.CtrCod"
" AND degrees.DegCod=courses.DegCod",
CtyCod);
}
/*****************************************************************************/
@ -821,12 +823,14 @@ unsigned Crs_GetNumCrssInCty (long CtyCod)
unsigned Crs_GetNumCrssInIns (long InsCod)
{
/***** Get number of courses in a degree from database *****/
DB_BuildQuery ("SELECT COUNT(*) FROM centres,degrees,courses"
" WHERE centres.InsCod=%ld"
" AND centres.CtrCod=degrees.CtrCod"
" AND degrees.DegCod=courses.DegCod",
InsCod);
return (unsigned) DB_QueryCOUNT_new ("can not get the number of courses in an institution");
return
(unsigned) DB_QueryCOUNT ("can not get the number of courses"
" in an institution",
"SELECT COUNT(*) FROM centres,degrees,courses"
" WHERE centres.InsCod=%ld"
" AND centres.CtrCod=degrees.CtrCod"
" AND degrees.DegCod=courses.DegCod",
InsCod);
}
/*****************************************************************************/
@ -836,11 +840,12 @@ unsigned Crs_GetNumCrssInIns (long InsCod)
unsigned Crs_GetNumCrssInCtr (long CtrCod)
{
/***** Get number of courses in a degree from database *****/
DB_BuildQuery ("SELECT COUNT(*) FROM degrees,courses"
" WHERE degrees.CtrCod=%ld"
" AND degrees.DegCod=courses.DegCod",
CtrCod);
return (unsigned) DB_QueryCOUNT_new ("can not get the number of courses in a centre");
return
(unsigned) DB_QueryCOUNT ("can not get the number of courses in a centre",
"SELECT COUNT(*) FROM degrees,courses"
" WHERE degrees.CtrCod=%ld"
" AND degrees.DegCod=courses.DegCod",
CtrCod);
}
/*****************************************************************************/
@ -850,8 +855,11 @@ unsigned Crs_GetNumCrssInCtr (long CtrCod)
unsigned Crs_GetNumCrssInDeg (long DegCod)
{
/***** Get number of courses in a degree from database *****/
DB_BuildQuery ("SELECT COUNT(*) FROM courses WHERE DegCod=%ld",DegCod);
return (unsigned) DB_QueryCOUNT_new ("can not get the number of courses in a degree");
return
(unsigned) DB_QueryCOUNT ("can not get the number of courses in a degree",
"SELECT COUNT(*) FROM courses"
" WHERE DegCod=%ld",
DegCod);
}
/*****************************************************************************/
@ -861,15 +869,16 @@ unsigned Crs_GetNumCrssInDeg (long DegCod)
unsigned Crs_GetNumCrssWithUsrs (Rol_Role_t Role,const char *SubQuery)
{
/***** Get number of degrees with users from database *****/
DB_BuildQuery ("SELECT COUNT(DISTINCT courses.CrsCod)"
" FROM institutions,centres,degrees,courses,crs_usr"
" WHERE %sinstitutions.InsCod=centres.InsCod"
" AND centres.CtrCod=degrees.CtrCod"
" AND degrees.DegCod=courses.DegCod"
" AND courses.CrsCod=crs_usr.CrsCod"
" AND crs_usr.Role=%u",
SubQuery,(unsigned) Role);
return (unsigned) DB_QueryCOUNT_new ("can not get number of courses with users");
return
(unsigned) DB_QueryCOUNT ("can not get number of courses with users",
"SELECT COUNT(DISTINCT courses.CrsCod)"
" FROM institutions,centres,degrees,courses,crs_usr"
" WHERE %sinstitutions.InsCod=centres.InsCod"
" AND centres.CtrCod=degrees.CtrCod"
" AND degrees.DegCod=courses.DegCod"
" AND courses.CrsCod=crs_usr.CrsCod"
" AND crs_usr.Role=%u",
SubQuery,(unsigned) Role);
}
/*****************************************************************************/
@ -2751,12 +2760,12 @@ static bool Crs_CheckIfCrsNameExistsInYearOfDeg (const char *FieldName,const cha
long DegCod,unsigned Year)
{
/***** Get number of courses in a year of a degree and with a name from database *****/
DB_BuildQuery ("SELECT COUNT(*) FROM courses"
" WHERE DegCod=%ld AND Year=%u"
" AND %s='%s' AND CrsCod<>%ld",
DegCod,Year,FieldName,Name,CrsCod);
return (DB_QueryCOUNT_new ("can not check if the name"
" of a course already existed") != 0);
return (DB_QueryCOUNT ("can not check if the name"
" of a course already existed",
"SELECT COUNT(*) FROM courses"
" WHERE DegCod=%ld AND Year=%u"
" AND %s='%s' AND CrsCod<>%ld",
DegCod,Year,FieldName,Name,CrsCod) != 0);
}
/*****************************************************************************/

View File

@ -2027,10 +2027,11 @@ static bool Deg_CheckIfDegNameExistsInCtr (const char *FieldName,const char *Nam
long DegCod,long CtrCod)
{
/***** Get number of degrees with a type and a name from database *****/
DB_BuildQuery ("SELECT COUNT(*) FROM degrees"
" WHERE CtrCod=%ld AND %s='%s' AND DegCod<>%ld",
CtrCod,FieldName,Name,DegCod);
return (DB_QueryCOUNT_new ("can not check if the name of a degree already existed") != 0);
return (DB_QueryCOUNT ("can not check if the name of a degree"
" already existed",
"SELECT COUNT(*) FROM degrees"
" WHERE CtrCod=%ld AND %s='%s' AND DegCod<>%ld",
CtrCod,FieldName,Name,DegCod) != 0);
}
/*****************************************************************************/
@ -2337,8 +2338,9 @@ void Deg_RemoveLogo (void)
unsigned Deg_GetNumDegsTotal (void)
{
/***** Get total number of degrees from database *****/
DB_BuildQuery ("SELECT COUNT(*) FROM degrees");
return (unsigned) DB_QueryCOUNT_new ("can not get the total number of degrees");
return
(unsigned) DB_QueryCOUNT ("can not get the total number of degrees",
"SELECT COUNT(*) FROM degrees");
}
/*****************************************************************************/
@ -2348,13 +2350,13 @@ unsigned Deg_GetNumDegsTotal (void)
unsigned Deg_GetNumDegsInCty (long InsCod)
{
/***** Get number of degrees in a country from database *****/
DB_BuildQuery ("SELECT COUNT(*) FROM institutions,centres,degrees"
" WHERE institutions.CtyCod=%ld"
" AND institutions.InsCod=centres.InsCod"
" AND centres.CtrCod=degrees.CtrCod",
InsCod);
return (unsigned) DB_QueryCOUNT_new ("can not get the number of degrees"
" in a country");
return
(unsigned) DB_QueryCOUNT ("can not get the number of degrees in a country",
"SELECT COUNT(*) FROM institutions,centres,degrees"
" WHERE institutions.CtyCod=%ld"
" AND institutions.InsCod=centres.InsCod"
" AND centres.CtrCod=degrees.CtrCod",
InsCod);
}
/*****************************************************************************/
@ -2364,12 +2366,13 @@ unsigned Deg_GetNumDegsInCty (long InsCod)
unsigned Deg_GetNumDegsInIns (long InsCod)
{
/***** Get number of degrees in an institution from database *****/
DB_BuildQuery ("SELECT COUNT(*) FROM centres,degrees"
" WHERE centres.InsCod=%ld"
" AND centres.CtrCod=degrees.CtrCod",
InsCod);
return (unsigned) DB_QueryCOUNT_new ("can not get the number of degrees"
" in an institution");
return
(unsigned) DB_QueryCOUNT ("can not get the number of degrees"
" in an institution",
"SELECT COUNT(*) FROM centres,degrees"
" WHERE centres.InsCod=%ld"
" AND centres.CtrCod=degrees.CtrCod",
InsCod);
}
/*****************************************************************************/
@ -2379,9 +2382,11 @@ unsigned Deg_GetNumDegsInIns (long InsCod)
unsigned Deg_GetNumDegsInCtr (long CtrCod)
{
/***** Get number of degrees in a centre from database *****/
DB_BuildQuery ("SELECT COUNT(*) FROM degrees WHERE CtrCod=%ld",CtrCod);
return (unsigned) DB_QueryCOUNT_new ("can not get the number of degrees"
" in a centre");
return
(unsigned) DB_QueryCOUNT ("can not get the number of degrees in a centre",
"SELECT COUNT(*) FROM degrees"
" WHERE CtrCod=%ld",
CtrCod);
}
/*****************************************************************************/
@ -2391,14 +2396,14 @@ unsigned Deg_GetNumDegsInCtr (long CtrCod)
unsigned Deg_GetNumDegsWithCrss (const char *SubQuery)
{
/***** Get number of degrees with courses from database *****/
DB_BuildQuery ("SELECT COUNT(DISTINCT degrees.DegCod)"
" FROM institutions,centres,degrees,courses"
" WHERE %sinstitutions.InsCod=centres.InsCod"
" AND centres.CtrCod=degrees.CtrCod"
" AND degrees.DegCod=courses.DegCod",
SubQuery);
return (unsigned) DB_QueryCOUNT_new ("can not get number of degrees"
" with courses");
return
(unsigned) DB_QueryCOUNT ("can not get number of degrees with courses",
"SELECT COUNT(DISTINCT degrees.DegCod)"
" FROM institutions,centres,degrees,courses"
" WHERE %sinstitutions.InsCod=centres.InsCod"
" AND centres.CtrCod=degrees.CtrCod"
" AND degrees.DegCod=courses.DegCod",
SubQuery);
}
/*****************************************************************************/
@ -2408,16 +2413,16 @@ unsigned Deg_GetNumDegsWithCrss (const char *SubQuery)
unsigned Deg_GetNumDegsWithUsrs (Rol_Role_t Role,const char *SubQuery)
{
/***** Get number of degrees with users from database *****/
DB_BuildQuery ("SELECT COUNT(DISTINCT degrees.DegCod)"
" FROM institutions,centres,degrees,courses,crs_usr"
" WHERE %sinstitutions.InsCod=centres.InsCod"
" AND centres.CtrCod=degrees.CtrCod"
" AND degrees.DegCod=courses.DegCod"
" AND courses.CrsCod=crs_usr.CrsCod"
" AND crs_usr.Role=%u",
SubQuery,(unsigned) Role);
return (unsigned) DB_QueryCOUNT_new ("can not get number of degrees"
" with users");
return
(unsigned) DB_QueryCOUNT ("can not get number of degrees with users",
"SELECT COUNT(DISTINCT degrees.DegCod)"
" FROM institutions,centres,degrees,courses,crs_usr"
" WHERE %sinstitutions.InsCod=centres.InsCod"
" AND centres.CtrCod=degrees.CtrCod"
" AND degrees.DegCod=courses.DegCod"
" AND courses.CrsCod=crs_usr.CrsCod"
" AND crs_usr.Role=%u",
SubQuery,(unsigned) Role);
}
/*****************************************************************************/

View File

@ -808,8 +808,11 @@ long DT_GetAndCheckParamOtherDegTypCod (long MinCodAllowed)
static unsigned DT_CountNumDegsOfType (long DegTypCod)
{
/***** Get number of degrees of a type from database *****/
DB_BuildQuery ("SELECT COUNT(*) FROM degrees WHERE DegTypCod=%ld",DegTypCod);
return (unsigned) DB_QueryCOUNT_new ("can not get number of degrees of a type");
return
(unsigned) DB_QueryCOUNT ("can not get number of degrees of a type",
"SELECT COUNT(*) FROM degrees"
" WHERE DegTypCod=%ld",
DegTypCod);
}
/*****************************************************************************/
@ -991,10 +994,11 @@ void DT_RenameDegreeType (void)
static bool DT_CheckIfDegreeTypeNameExists (const char *DegTypName,long DegTypCod)
{
/***** Get number of degree types with a name from database *****/
DB_BuildQuery ("SELECT COUNT(*) FROM deg_types"
" WHERE DegTypName='%s' AND DegTypCod<>%ld",
DegTypName,DegTypCod);
return (DB_QueryCOUNT_new ("can not check if the name of a type of degree already existed") != 0);
return (DB_QueryCOUNT ("can not check if the name of a type of degree"
" already existed",
"SELECT COUNT(*) FROM deg_types"
" WHERE DegTypName='%s' AND DegTypCod<>%ld",
DegTypName,DegTypCod) != 0);
}
/*****************************************************************************/